Package org.docx4j.model.fields
Class FieldsPreprocessor
java.lang.Object
org.docx4j.model.fields.FieldsPreprocessor
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 Summary
FieldsModifier and TypeFieldDescriptionprivate static final QNameprivate static final QNameprivate static final QNameprivate FieldRefA list of FieldRef objects representing outermost fields only.private static org.slf4j.Loggerprivate Rprivate LinkedList<FieldRef>(package private) static Templates -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Pcanonicalise(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.private Pstatic voidcomplexifyFields(JaxbXmlPart part) Convert any w:fldSimple in this part to complex field.private booleanprivate voidhandleContent(List<Object> objects, ContentAccessor attachmentPoint) private voidhandleRun(R existingRun, ContentAccessor newAttachPoint) private booleanstatic booleanisCharType(Object o2, STFldCharType charType) private booleanprivate booleanpreserveResult(FieldRef fieldRef) Its preserved, if it is locked.
-
Field Details
-
log
private static org.slf4j.Logger log -
_RInstrText_QNAME
-
_PHyperlink_QNAME
-
xslt
-
fieldRefs
A list of FieldRef objects representing outermost fields only. -
stack
-
currentField
-
newR
-
_RT_QNAME
-
-
Constructor Details
-
FieldsPreprocessor
-
-
Method Details
-
complexifyFields
Convert any w:fldSimple in this part to complex field.- Parameters:
part-- Throws:
Docx4JException
-
canonicalise
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
-
handleContent
-
fieldIsTopLevel
private boolean fieldIsTopLevel() -
inParentResult
private boolean inParentResult() -
preserveResult
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
-
isCharType
-