"the document contains fields that may refer to other files . Do you want to update"
This is the warning pop-up i`m getting while generating TABLE OF CONTENTS with below code ..
ObjectFactory factory = Context.getWmlObjectFactory();
P p = factory.createP();
R r = factory.createR();
FldChar fldchar = factory.createFldChar();
fldchar.setFldCharType(STFldCharType.BEGIN);
fldchar.setDirty(true);
r.getRunContent().add(getWrappedFldChar(fldchar));
p.getParagraphContent().add(r);
R r1 = factory.createR();
Text txt = new Text();
txt.setSpace("preserve");
txt.setValue("TOC \\o \"1-3\" \\h \\z \\u \\h");
r.getRunContent().add(factory.createRInstrText(txt) );
p.getParagraphContent().add(r1);
FldChar fldcharend = factory.createFldChar();
fldcharend.setFldCharType(STFldCharType.END);
R r2 = factory.createR();
r2.getRunContent().add(getWrappedFldChar(fldcharend));
p.getParagraphContent().add(r2);
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();
org.docx4j.wml.Document wmlDocumentEl = (org.docx4j.wml.Document)documentPart.getJaxbElement();
Body body = wmlDocumentEl.getBody();
body.getEGBlockLevelElts().add(p);
documentPart.addStyledParagraphOfText("Heading1", "Hello 1");
documentPart.addStyledParagraphOfText("Heading2", "Hello 2");
documentPart.addStyledParagraphOfText("Heading3", "Hello 3");
documentPart.addStyledParagraphOfText("Heading1", "Hello 1");
wordMLPackage.save(new File("c:\\AddTOC.docx"));
Thanx In Advance ,
Siva Kumar