Class OpenDoPEHandler

java.lang.Object
org.docx4j.model.datastorage.OpenDoPEHandler

public class OpenDoPEHandler extends Object
  • Field Details

  • Constructor Details

  • Method Details

    • getDomToXPathMap

      public DomToXPathMap getDomToXPathMap()
    • getNextBookmarkId

      public AtomicInteger 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

      public WordprocessingMLPackage preprocess() throws Docx4JException
      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:
      Exception
      Docx4JException
    • getParts

      protected static Set<ContentAccessor> getParts(WordprocessingMLPackage srcPackage)
    • getW15RepeatingSection

      private CTSdtRepeatedSection getW15RepeatingSection(SdtPr sdtPr)
    • processBindingRoleIfAny

      private List<Object> processBindingRoleIfAny(WordprocessingMLPackage wordMLPackage, Object sdt)
      This applies to any sdt which might be a conditional|repeat
      Parameters:
      wordMLPackage -
      sdtParent -
      sdt -
      tag -
      sdtContent -
      Returns:
      Throws:
      Exception
    • conditionFalse

      private List<Object> 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.
      Parameters:
      sdt -
      Returns:
    • processOpenDopeRepeat

      private List<Object> processOpenDopeRepeat(Object sdt, Map<String,CustomXmlPart> customXmlDataStorageParts)
    • processW15Repeat

      private List<Object> processW15Repeat(Object repeatingSectionSdt, Map<String,CustomXmlPart> customXmlDataStorageParts)
      Parameters:
      repeatingSectionSdt -
      customXmlDataStorageParts -
      Returns:
      Since:
      3.2.2.
    • getRepeatXpathBase

      protected static String getRepeatXpathBase(String xpath)
      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 W15RepeatZeroException
      Process a repeat, whether its an OpenDoPE repeat, or a w15:RepeatingSection
      Parameters:
      sdt -
      customXmlDataStorageParts -
      storeItemId -
      xpath -
      prefixMappings -
      Returns:
      Throws:
      W15RepeatZeroException
    • repeatZero

      private List<Object> 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.
      Parameters:
      sdt -
      Returns:
    • cloneRepeatSdt

      private List<Object> cloneRepeatSdt(Object sdt, String xpathBase, int numRepeats)
    • emptyRepeatTagValue

      private void emptyRepeatTagValue(Tag tag)
    • processDescendantBindings

      private void processDescendantBindings(Object sdt, String xpathBase, int index)
    • processDescendantCondition

      private void processDescendantCondition(Object sdt, String xpathBase, int index, Tag tag)
    • createNewXPathObject

      private Xpaths.Xpath createNewXPathObject(String newPath, Xpaths.Xpath xpathObj, int index)
    • getSdtPr

      public static SdtPr getSdtPr(Object o)
    • xpathGetNodes

      private List<Node> xpathGetNodes(Map<String,CustomXmlPart> customXmlDataStorageParts, String storeItemId, String xpath, String prefixMappings)