Class FieldsPreprocessor

java.lang.Object
org.docx4j.model.fields.FieldsPreprocessor

public class FieldsPreprocessor extends Object
This class puts fields into a "canonical" representation (see FieldRef for description). It does this in 2 steps: - step 1: use XSLT to convert simple fields into complex ones - step 2: put all the instructions into a single run Currently the canonicalisation is done at the paragraph level, so it is not suitable for fields (such as TOC) which extend across paragraphs. TOC will need to be regenerated if touched by canonicalisation.
  • Field Details

    • log

      private static org.slf4j.Logger log
    • _RInstrText_QNAME

      private static final QName _RInstrText_QNAME
    • xslt

      static Templates xslt
    • fieldRefs

      private List<FieldRef> fieldRefs
      A list of FieldRef objects representing outermost fields only.
    • stack

      private LinkedList<FieldRef> stack
    • currentField

      private FieldRef currentField
    • newR

      private R newR
    • _RT_QNAME

      private static final QName _RT_QNAME
  • Constructor Details

    • FieldsPreprocessor

      private FieldsPreprocessor(List<FieldRef> fieldRefs)
  • Method Details

    • complexifyFields

      public static void complexifyFields(JaxbXmlPart part) throws Docx4JException
      Convert any w:fldSimple in this part to complex field.
      Parameters:
      part -
      Throws:
      Docx4JException
    • canonicalise

      public static P canonicalise(P p, List<FieldRef> fieldRefs)
      Convert the field(s) in the input P into a predictable format, and add a FieldRef object to the list for each top level field encountered. WARNING: this method should not be used where a field in the P extends into a subsequent P.
      Parameters:
      p -
      fieldRefs -
      Returns:
      the modified P
    • canonicaliseInstance

      private P canonicaliseInstance(P p)
    • handleContent

      private void handleContent(List<Object> objects, ContentAccessor attachmentPoint)
    • fieldIsTopLevel

      private boolean fieldIsTopLevel()
    • inParentResult

      private boolean inParentResult()
    • preserveResult

      private boolean preserveResult(FieldRef fieldRef)
      Its preserved, if it is locked. If it isn't locked, it is preserved unless its a MERGEFIELD or a DOCPROPERTY field.
      Parameters:
      fieldRef -
      Returns:
    • preserveParentResult

      private boolean preserveParentResult()
    • handleRun

      private void handleRun(R existingRun, ContentAccessor newAttachPoint)
    • isCharType

      public static boolean isCharType(Object o2, STFldCharType charType)