Package org.docx4j.model.datastorage
Class UpdateXmlFromDocumentSurface
java.lang.Object
org.docx4j.model.datastorage.UpdateXmlFromDocumentSurface
Copy content control content back to the custom XML part.
Microsoft Word does this automatically for a content control
which has a w:databinding element.
It doesn't do it for a rich text control. Here we also
do that, ie for a content control with a tag such as:
'od:progid=Word.Document'
The content is converted back to escaped WordML, and
injected following the relevant XPath.
This class provides a way
to update the XML part for cases
where editing is done in something other
than Word.
Of course, this class won't work if RemovalHandler
has been used to remove all SDTs or the XML part!
Limitations:
- only the Main Document Part (for escaped WordML)
Replaces Enterprise's BindInverse.
- Since:
- 6.0.0
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Map<String,CustomXmlPart> private static org.slf4j.Loggerprivate WordprocessingMLPackageprivate booleanprivate List<CustomXmlPart>private XPathsPart -
Constructor Summary
ConstructorsConstructorDescriptionUpdateXmlFromDocumentSurface(WordprocessingMLPackage wordMLPackage, boolean supportStylesInWordAltChunkProcessing) Copy contents of OpenDoPE content controls, including rich text content controls with tag 'od:progid=Word.Document' (ie as escaped Flat OPC XML), back into their associated custom XML part element. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidfindSdts(UpdateXmlFromDocumentSurface.SdtFinder sdtPrFinder) private voidfindSdtsInPart(ContentAccessor content, UpdateXmlFromDocumentSurface.SdtFinder sdtFinder) private WordprocessingMLPackagegetAsDocx(SdtElement sdtBlock) private CustomXmlPartgetCustomXmlPart(Xpaths.Xpath xpath) getPkg()private voidhandleSdt(SdtElement sdt) private booleanisMultiline(SdtPr sdtPr) static voidprivate voidtrimParts(WordprocessingMLPackage output, RelationshipsPart rp, boolean modeDelete) Update the contents of the relevant custom XML parts, with any edits made by the user in a rich text content control with a tag containing od:progid=Word.Document (and an OpenDoPE XPath, of course).private voidupdateXmlFromSdts(List<SdtElement> contentControls)
-
Field Details
-
log
private static org.slf4j.Logger log -
pkg
-
xPathsPart
-
customXmlDataStorageParts
-
updatedParts
-
supportStylesInWordAltChunkProcessing
private boolean supportStylesInWordAltChunkProcessing
-
-
Constructor Details
-
UpdateXmlFromDocumentSurface
public UpdateXmlFromDocumentSurface(WordprocessingMLPackage wordMLPackage, boolean supportStylesInWordAltChunkProcessing) throws Docx4JException Copy contents of OpenDoPE content controls, including rich text content controls with tag 'od:progid=Word.Document' (ie as escaped Flat OPC XML), back into their associated custom XML part element. Styles and NDP are not required in Flat OPC emitted by docx4j for that Flat OPC to be imported into another docx based on those same styles/ndp; but those styles & NDP are necessary for Word 2010 altChunk processing (if the fragment is to use those styles). Setting this option to false gives smaller file sizes.- Parameters:
wordMLPackage-supportStylesInWordAltChunkProcessing-- Throws:
Docx4JException
-
-
Method Details
-
getPkg
-
updateCustomXmlParts
Update the contents of the relevant custom XML parts, with any edits made by the user in a rich text content control with a tag containing od:progid=Word.Document (and an OpenDoPE XPath, of course). The WordML package itself is updated, and the parts are returned for convenience.- Returns:
- Throws:
Docx4JException
-
getCustomXmlPart
-
updateXmlFromSdts
-
handleSdt
-
findSdts
- Throws:
Docx4JException
-
findSdtsInPart
private void findSdtsInPart(ContentAccessor content, UpdateXmlFromDocumentSurface.SdtFinder sdtFinder) throws Docx4JException - Throws:
Docx4JException
-
isMultiline
-
getAsDocx
- Throws:
InvalidFormatException
-
trimParts
private void trimParts(WordprocessingMLPackage output, RelationshipsPart rp, boolean modeDelete) throws Docx4JException - Throws:
Docx4JException
-
main
- Throws:
Docx4JException
-