Package org.docx4j.model.datastorage
Class OpenDoPEReverter
java.lang.Object
org.docx4j.model.datastorage.OpenDoPEReverter
Reverse the action of OpenDoPEHandler.
Useful where a user has edited an instance docx,
but you want to regenerate with fresh XML data.
This won't work if RemovalHandler has been used to
removed the content controls.
Note that any edits made by hand within a condition
or repeat will be lost, so it is recommended
that after regenerating from this reverted template,
you do a document compare (eg in Word) against your
previous instance to pick up any edits in a condition
or repeat which this process will have dropped).
This class modifies the instance, so you'll need
to clone or copy it first if that's a problem.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate WordprocessingMLPackageprivate static org.slf4j.Loggerprivate WordprocessingMLPackage(package private) Map<BigInteger,Object> (package private) Map<BigInteger,Object> -
Constructor Summary
ConstructorsConstructorDescriptionOpenDoPEReverter(WordprocessingMLPackage openDopePkg, WordprocessingMLPackage instancePkg) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidfindSdtsInTemplate(WordprocessingMLPackage pkg, OpenDoPEReverter.TopLevelSdtTemplateFinder sdtPrFinder, boolean instanceCountOnly) private voidfindSdtsInTemplatePart(ContentAccessor content, OpenDoPEReverter.TopLevelSdtTemplateFinder sdtPrFinder, boolean instanceCountOnly) private voidprivate voidprivate voidhandleSdtsInInstancePart(ContentAccessor content) private voidIf an SDT contained a hyperlink, we will have removed its w:dataBinding and w:text.private voidbooleanrevert()private booleanWhat about the case where the one repeat is used twice? That's ok, as long as there is some other object between the two lots of repeats.
-
Field Details
-
log
private static org.slf4j.Logger log -
openDopePkg
-
instancePkg
-
templateConditionSdtsByID
Map<BigInteger,Object> templateConditionSdtsByID -
templateRepeatSdtsByID
Map<BigInteger,Object> templateRepeatSdtsByID -
instanceSdtPrFinder
-
-
Constructor Details
-
OpenDoPEReverter
-
-
Method Details
-
revert
- Throws:
Docx4JException
-
sanityCheck
What about the case where the one repeat is used twice? That's ok, as long as there is some other object between the two lots of repeats. Limitation: The user could screw this up, by manually inserting a paragraph between 2 instances of a repeat. Result would be that an instance is kept, and converted back into an extra repeat! So have a sanity check that count of repeats and conditions in result matches what we have in the original template.- Throws:
Docx4JException
-
findSdtsInTemplate
private void findSdtsInTemplate(WordprocessingMLPackage pkg, OpenDoPEReverter.TopLevelSdtTemplateFinder sdtPrFinder, boolean instanceCountOnly) throws Docx4JException - Throws:
Docx4JException
-
findSdtsInTemplatePart
private void findSdtsInTemplatePart(ContentAccessor content, OpenDoPEReverter.TopLevelSdtTemplateFinder sdtPrFinder, boolean instanceCountOnly) throws Docx4JException - Throws:
Docx4JException
-
handleSdtsInInstance
- Throws:
Docx4JException
-
handleSdtsInInstancePart
- Throws:
Docx4JException
-
replaceConditions
private void replaceConditions() -
handleRepeats
private void handleRepeats() -
repairBoundSdts
If an SDT contained a hyperlink, we will have removed its w:dataBinding and w:text. So check SDT's and add back in if necessary.- Throws:
Docx4JException
-