Package org.docx4j.model.datastorage
Class OpenDoPEHandler
java.lang.Object
org.docx4j.model.datastorage.OpenDoPEHandler
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) classprivate classThis traversor duplicates the repeats, and removes false conditonalsprivate classprivate static classDetermine the first tr, tc, tbl we encounter nested in here -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprivate BookmarkRenumberlongprivate Componentsprivate StringBufferprivate longprivate intprivate DomToXPathMapstatic booleanlongprivate static org.slf4j.Logger(package private) booleanprivate OpenDoPEHandler.ShallowTraversorprivate intprivate WordprocessingMLPackageprivate Map<String,Xpaths.Xpath> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncloneRepeatSdt(Object sdt, String xpathBase, int numRepeats) conditionFalse(Object sdt) Insert an empty placeholder SDT, to facilitate round-tripping (ie ability to convert instance docx back to original template), which you may wish to do if you want to insert updated data, but preserve certain manual edits.private Xpaths.XpathcreateNewXPathObject(String newPath, Xpaths.Xpath xpathObj, int index) private voidemptyRepeatTagValue(Tag tag) Provide a way to for user to fetch the starting bookmark ID number for use in the next stage (ie Binding Traverse).protected static Set<ContentAccessor>getParts(WordprocessingMLPackage srcPackage) protected static StringgetRepeatXpathBase(String xpath) Massage the xpath into an expected format, by dropping any trailing '/' or [1]static SdtPrprivate CTSdtRepeatedSectiongetW15RepeatingSection(SdtPr sdtPr) Preprocess content controls which have tag "od:condition|od:repeat|od:component".processBindingRoleIfAny(WordprocessingMLPackage wordMLPackage, Object sdt) This applies to any sdt which might be a conditional|repeatprivate voidprocessDescendantBindings(Object sdt, String xpathBase, int index) private voidprocessDescendantCondition(Object sdt, String xpathBase, int index, Tag tag) processOpenDopeRepeat(Object sdt, Map<String, CustomXmlPart> customXmlDataStorageParts) processRepeat(Object sdt, Map<String, CustomXmlPart> customXmlDataStorageParts, String storeItemId, String xpath, String prefixMappings, boolean isW15RepeatingSection) Process a repeat, whether its an OpenDoPE repeat, or a w15:RepeatingSectionprocessW15Repeat(Object repeatingSectionSdt, Map<String, CustomXmlPart> customXmlDataStorageParts) repeatZero(Object sdt) Insert an empty placeholder SDT, to facilitate round-tripping (ie ability to convert instance docx back to original template), which you may wish to do if you want to insert updated data, but preserve certain manual edits.xpathGetNodes(Map<String, CustomXmlPart> customXmlDataStorageParts, String storeItemId, String xpath, String prefixMappings)
-
Field Details
-
log
private static org.slf4j.Logger log -
ENABLE_XPATH_CACHE
public static boolean ENABLE_XPATH_CACHE -
xpathsMap
-
conditionsMap
-
domToXPathMap
-
wordMLPackage
-
shallowTraversor
-
bookmarkRenumber
-
BINDING_ROLE_XPATH
- See Also:
-
BINDING_ROLE_CONDITIONAL
- See Also:
-
BINDING_RESULT_CONDITION_FALSE
- See Also:
-
BINDING_ROLE_REPEAT
- See Also:
-
BINDING_RESULT_RPTD_ZERO
- See Also:
-
BINDING_RESULT_RPTD_ZERO_W15
- See Also:
-
BINDING_RESULT_RPTD
- See Also:
-
BINDING_ROLE_RPT_POS_CON
- See Also:
-
BINDING_ROLE_NARRATIVE
- See Also:
-
BINDING_ROLE_COMPONENT
- See Also:
-
BINDING_ROLE_COMPONENT_BEFORE
- See Also:
-
BINDING_ROLE_COMPONENT_AFTER
- See Also:
-
BINDING_ROLE_COMPONENT_CONTEXT
- See Also:
-
BINDING_ROLE_FINISHER
- See Also:
-
BINDING_CONTENTTYPE
- See Also:
-
BINDING_HANDLER
- See Also:
-
BINDING_PROGID
- See Also:
-
components
-
conditionTiming
-
conditionTimingTotal
private long conditionTimingTotal -
reverterSupported
boolean reverterSupported -
cloneTime
public long cloneTime -
fixBTime
public long fixBTime -
DEBUG_REPEAT_CAP
private int DEBUG_REPEAT_CAP -
totalRepeated
private int totalRepeated
-
-
Constructor Details
-
OpenDoPEHandler
- Throws:
Docx4JException
-
-
Method Details
-
getDomToXPathMap
-
getNextBookmarkId
Provide a way to for user to fetch the starting bookmark ID number for use in the next stage (ie Binding Traverse). If it isn't fetched/set, the value will have to be recalculated (less efficient).- Since:
- 3.2.1
-
preprocess
Preprocess content controls which have tag "od:condition|od:repeat|od:component". It is "preprocess" in the sense that it is "pre" opening in Word The algorithm is as follows: Inject components first. Look at each top level SDT (ShallowTraversor). If it does not have a real data binding, it might have a bindingrole tag we need to process (processBindingRoleIfAny). Conditionals are easy. processRepeat method: - clones the sdt n times - invokes DeepTraversor which changes xpath binding on descendant sdts (both sdts with real bindings and sdts with bindingrole tags). It is not the job of DeepTraversor to expand out any other repeats it might encounter, or to resolve conditionals. Those things are done by ShallowTraversor, to which control returns, as it continues its traverse. The implementation of 13 Sept 2010 replaced the previous XPath based implementation, which did not support nested repeats. I've chosen to build this around TraversalUtil, instead of using XSLT, and this seems to have worked out nicely. The implementation of 10 October 2010 replaced the v1 conventions implementation with a v2 implementation. The main method in this class can convert v1 documents to v2. The v2 implementation is not yet complete. All v1 features are implemented, but not the new v2 stuff (eg complex conditions).- Parameters:
documentPart-- Throws:
ExceptionDocx4JException
-
getParts
-
getW15RepeatingSection
-
processBindingRoleIfAny
This applies to any sdt which might be a conditional|repeat- Parameters:
wordMLPackage-sdtParent-sdt-tag-sdtContent-- Returns:
- Throws:
Exception
-
conditionFalse
Insert an empty placeholder SDT, to facilitate round-tripping (ie ability to convert instance docx back to original template), which you may wish to do if you want to insert updated data, but preserve certain manual edits.- Parameters:
sdt-- Returns:
-
processOpenDopeRepeat
-
processW15Repeat
private List<Object> processW15Repeat(Object repeatingSectionSdt, Map<String, CustomXmlPart> customXmlDataStorageParts) - Parameters:
repeatingSectionSdt-customXmlDataStorageParts-- Returns:
- Since:
- 3.2.2.
-
getRepeatXpathBase
Massage the xpath into an expected format, by dropping any trailing '/' or [1]- Parameters:
xpath-- Returns:
-
processRepeat
private List<Object> processRepeat(Object sdt, Map<String, CustomXmlPart> customXmlDataStorageParts, String storeItemId, String xpath, String prefixMappings, boolean isW15RepeatingSection) throws W15RepeatZeroExceptionProcess a repeat, whether its an OpenDoPE repeat, or a w15:RepeatingSection- Parameters:
sdt-customXmlDataStorageParts-storeItemId-xpath-prefixMappings-- Returns:
- Throws:
W15RepeatZeroException
-
repeatZero
Insert an empty placeholder SDT, to facilitate round-tripping (ie ability to convert instance docx back to original template), which you may wish to do if you want to insert updated data, but preserve certain manual edits.- Parameters:
sdt-- Returns:
-
cloneRepeatSdt
-
emptyRepeatTagValue
-
processDescendantBindings
-
processDescendantCondition
-
createNewXPathObject
-
getSdtPr
-
xpathGetNodes
-