use of org.docx4j.wml.FldChar in project TranskribusCore by Transkribus.
the class DocxBuilder method addComplexField.
private static void addComplexField(P p, String instrText, String instrText2) {
org.docx4j.wml.ObjectFactory wmlObjectFactory = Context.getWmlObjectFactory();
// Create object for r
R r = wmlObjectFactory.createR();
p.getContent().add(r);
// Create object for fldChar (wrapped in JAXBElement)
FldChar fldchar = wmlObjectFactory.createFldChar();
JAXBElement<org.docx4j.wml.FldChar> fldcharWrapped = wmlObjectFactory.createRFldChar(fldchar);
r.getContent().add(fldcharWrapped);
fldchar.setFldCharType(org.docx4j.wml.STFldCharType.BEGIN);
// Create object for instrText (wrapped in JAXBElement)
Text text = wmlObjectFactory.createText();
JAXBElement<org.docx4j.wml.Text> textWrapped = wmlObjectFactory.createRInstrText(text);
r.getContent().add(textWrapped);
text.setValue(instrText);
text.setSpace("preserve");
R r2 = wmlObjectFactory.createR();
p.getContent().add(r2);
if (!instrText2.equals("")) {
r2.getContent().add(wmlObjectFactory.createRTab());
text = wmlObjectFactory.createText();
JAXBElement<org.docx4j.wml.Text> textWrapped2 = wmlObjectFactory.createRInstrText(text);
r2.getContent().add(textWrapped2);
text.setValue(instrText2);
text.setSpace("preserve");
}
// R r = factory.createR();
// r.setRsidRPr("TOC entry text");
// R.Tab tab = new R.Tab();
// r.getRunContent().add(tab);
// p.getParagraphContent().add(r);
// org.docx4j.wml.Text idx = wmlObjectFactory.createText();
// JAXBElement<org.docx4j.wml.Text> textWrapped2 = wmlObjectFactory.createRInstrText(idx);
// r.getContent().add( textWrapped2);
// idx.setValue( idxText);
// idx.setSpace( "preserve");
// Create object for fldChar (wrapped in JAXBElement)
fldchar = wmlObjectFactory.createFldChar();
fldcharWrapped = wmlObjectFactory.createRFldChar(fldchar);
r2.getContent().add(fldcharWrapped);
fldchar.setFldCharType(org.docx4j.wml.STFldCharType.END);
}
use of org.docx4j.wml.FldChar in project docx4j-template by vindell.
the class Docx4J_例子2 method addFieldEnd.
public void addFieldEnd(ObjectFactory factory, P paragraph) {
FldChar fldcharend = factory.createFldChar();
fldcharend.setFldCharType(STFldCharType.END);
R run3 = factory.createR();
run3.getContent().add(fldcharend);
paragraph.getContent().add(run3);
}
use of org.docx4j.wml.FldChar in project docx4j-template by vindell.
the class Docx4J_简单例子 method addFieldBegin.
public void addFieldBegin(ObjectFactory factory, P paragraph) {
R run = factory.createR();
FldChar fldchar = factory.createFldChar();
fldchar.setFldCharType(STFldCharType.BEGIN);
run.getContent().add(fldchar);
paragraph.getContent().add(run);
}
use of org.docx4j.wml.FldChar in project docx4j-template by vindell.
the class Docx4J_简单例子2 method addFieldBegin.
public void addFieldBegin(ObjectFactory factory, P paragraph) {
R run = factory.createR();
FldChar fldchar = factory.createFldChar();
fldchar.setFldCharType(STFldCharType.BEGIN);
run.getContent().add(fldchar);
paragraph.getContent().add(run);
}
use of org.docx4j.wml.FldChar in project docx4j-template by vindell.
the class AddingPageNrToFooter method addFieldBegin.
/**
* Every fields needs to be delimited by complex field characters. This method
* adds the delimiter that precedes the actual field to the given paragraph.
* @param paragraph
*/
private static void addFieldBegin(P paragraph) {
R run = factory.createR();
FldChar fldchar = factory.createFldChar();
fldchar.setFldCharType(STFldCharType.BEGIN);
run.getContent().add(fldchar);
paragraph.getContent().add(run);
}