getPropertyResolver(); // this inits our virtual DocDefaults style org.docx4j.wml.Document wmlDocumentEl = (org.docx4j.wml.Document)this.getJaxbElement(); Body body = wmlDocumentEl.getBody(); finder.defaultCharacterStyle = this.getStyleDefinitionsPart().getDefaultCharacterStyle(); finder.defaultParagraphStyle = this.getStyleDefinitionsPart().getDefaultParagraphStyle(); finder.styleDefinitionsPart = this.getStyleDefinitionsPart(); RelationshipsPart rp = this.getRelationshipsPart(); if (rp!=null) { for ( Relationship r : rp.getRelationships().getRelationship() ) { if (this.getEndNotesPart()!=null) { log.debug("Looking at endnotes"); CTEndnotes endnotes= this.getEndNotesPart().getJaxbElement(); finder.walkJAXBElements(endnotes); if (this.getFootnotesPart()!=null) { log.debug("Looking at footnotes"); CTFootnotes footnotes= this.getFootnotesPart().getJaxbElement(); finder.walkJAXBElements(footnotes); if (this.getCommentsPart()!=null) { log.debug("Looking at comments"); Comments comments = this.getCommentsPart().getJaxbElement(); finder.walkJAXBElements(comments); if (getNumberingDefinitionsPart()!=null) {
DocumentSettingsPart dsp = wmlPackage.getMainDocumentPart().getDocumentSettingsPart(); if (dsp==null) { dsp = new DocumentSettingsPart(); wmlPackage.getMainDocumentPart().addTargetPart(dsp); .getStyleDefinitionsPart().getDefaultParagraphStyle().getStyleId()); } catch (NullPointerException npe) { log.warn("No default paragraph style!!"); .getStyleDefinitionsPart().getDefaultTableStyle(); if (defaultTableStyle != null) { styleRenamer.setDefaultTableStyle(defaultTableStyle); Styles styles = wmlPackage.getMainDocumentPart().getStyleDefinitionsPart().getJaxbElement(); styleRenamer.propertyResolver = wmlPackage.getMainDocumentPart().getPropertyResolver(); new TraversalUtil(wmlPackage.getMainDocumentPart().getContents(), styleRenamer); } catch (Docx4JException e) {
private WordprocessingMLPackage getAsDocx(SdtElement sdtBlock) throws InvalidFormatException { clone.getMainDocumentPart().getContent().clear(); clone.getMainDocumentPart().getContent().addAll(tc.getContent()); clone.getMainDocumentPart().getContent().addAll(sdtBlock.getSdtContent().getContent()); clone.getMainDocumentPart().getJaxbElement().getBody().setSectPr(null); for (Relationship rel : clone.getMainDocumentPart().getRelationshipsPart().getJaxbElement().getRelationship() ) { clone.getMainDocumentPart().getRelationshipsPart().removeRelationship(rel);
/** * Create a paragraph containing the string simpleText, * and add it to the document. If passed null, the result * is an empty P. * * @param simpleText * @return */ public org.docx4j.wml.P addParagraphOfText(String simpleText) { org.docx4j.wml.P para = createParagraphOfText(simpleText); addObject(para); return para; }
/** * Create a paragraph containing the string simpleText, styled * using the specified style * (up to user to ensure it is a paragraph style) * and add it to the document. * * @param styleId * @param text * @return */ public org.docx4j.wml.P addStyledParagraphOfText(String styleId, String text) { org.docx4j.wml.P p = createStyledParagraphOfText(styleId, text); addObject(p); return p; }
public ListsToContentControls(WordprocessingMLPackage wmlPackage) { this.wmlPackage = wmlPackage; mainDocument = wmlPackage.getMainDocumentPart(); this.ndp=mainDocument.getNumberingDefinitionsPart(); stylesPart = wmlPackage.getMainDocumentPart().getStyleDefinitionsPart(); propertyResolver = wmlPackage.getMainDocumentPart().getPropertyResolver(); }
/** * Remove customXml, glossaryDocument, and stylesWithEffects */ private void filterMDPRels() { if (pkg.getMainDocumentPart().getRelationshipsPart()==null) return; if (log.isDebugEnabled()) { for (Relationship r : pkg.getMainDocumentPart().getRelationshipsPart().getRelationships().getRelationship()) { System.out.println(r.getType()); } } pkg.getMainDocumentPart().getRelationshipsPart().removeRelationshipsByType( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml"); pkg.getMainDocumentPart().getRelationshipsPart().removeRelationshipsByType( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument"); pkg.getMainDocumentPart().getRelationshipsPart().removeRelationshipsByType( "http://schemas.microsoft.com/office/2007/relationships/stylesWithEffects"); }
org.docx4j.wml.Document wmlDocumentEl = (org.docx4j.wml.Document)this.getJaxbElement(); Body body = wmlDocumentEl.getBody(); finder.defaultCharacterStyle = this.getStyleDefinitionsPart().getDefaultCharacterStyle(); finder.defaultParagraphStyle = this.getStyleDefinitionsPart().getDefaultParagraphStyle(); finder.styleDefinitionsPart = this.getStyleDefinitionsPart(); RelationshipsPart rp = this.getRelationshipsPart(); if (rp!=null) { for ( Relationship r : rp.getRelationships().getRelationship() ) { if (this.getEndNotesPart()!=null) { log.debug("Looking at endnotes"); CTEndnotes endnotes= this.getEndNotesPart().getJaxbElement(); finder.walkJAXBElements(endnotes); if (this.getFootnotesPart()!=null) { log.debug("Looking at footnotes"); CTFootnotes footnotes= this.getFootnotesPart().getJaxbElement(); finder.walkJAXBElements(footnotes); if (this.getCommentsPart()!=null) { log.debug("Looking at comments"); Comments comments = this.getCommentsPart().getJaxbElement(); finder.walkJAXBElements(comments);
log.debug("complexified: " + XmlUtils.marshaltoString(input.getMainDocumentPart().getJaxbElement(), true)); List<List<Object>> mdpResults = performOverList(input, input.getMainDocumentPart().getContent(), data, formTextFieldNames ); log.debug("for h|f relId: " + relId); JaxbXmlPart part = (JaxbXmlPart)input.getMainDocumentPart().getRelationshipsPart().getPart(relId); FieldsPreprocessor.complexifyFields(part ); target.getMainDocumentPart().getContent().clear(); target.getMainDocumentPart().getContent().addAll(content); log.debug(XmlUtils.marshaltoString(target.getMainDocumentPart().getJaxbElement(), true, true)); } else { lastP = Context.getWmlObjectFactory().createP(); target.getMainDocumentPart().getContent().add(lastP); Relationship rel = target.getMainDocumentPart().addTargetPart(clonedPart, AddPartBehaviour.RENAME_IF_NAME_EXISTS);
RelationshipsPart rels = wordMLPackage.getMainDocumentPart().getRelationshipsPart(); Document doc = (Document)wordMLPackage.getMainDocumentPart().getJaxbElement(); if ((wordMLPackage.getMainDocumentPart().getDocumentSettingsPart() != null) && (wordMLPackage.getMainDocumentPart().getDocumentSettingsPart().getJaxbElement() != null)) { evenAndOddHeaders = wordMLPackage.getMainDocumentPart().getDocumentSettingsPart().getJaxbElement().getEvenAndOddHeaders(); new TraversalUtil(wordMLPackage.getMainDocumentPart().getContents(), sf); } catch (Docx4JException e) { log.error(e.getMessage(), e);
rp = wordMLPackage.getMainDocumentPart().getRelationshipsPart(); ndp = wordMLPackage.getMainDocumentPart().getNumberingDefinitionsPart(); if (ndp==null) { log.debug("No NumberingDefinitions part - so adding"); try { ndp = new NumberingDefinitionsPart(); wordMLPackage.getMainDocumentPart().addTargetPart(ndp); ndp.setJaxbElement( Context.getWmlObjectFactory().createNumbering() ); } catch (InvalidFormatException e1) { ((WordprocessingMLPackage)wordMLPackage).getMainDocumentPart().getPropertyResolver().activateStyle(hyperlinkStyleId); initStyleMap(wordMLPackage.getMainDocumentPart().getStyleDefinitionsPart()); headingHandler = new HeadingHandler(wordMLPackage.getMainDocumentPart().getStyleDefinitionsPart().getJaxbElement());
public static ConversionSectionWrappers process(WordprocessingMLPackage wmlPackage, boolean dummySections, boolean dummyPageNumbering) throws Docx4JException { List<ConversionSectionWrapper> conversionSections = null; Document document = wmlPackage.getMainDocumentPart().getContents(); RelationshipsPart rels = wmlPackage.getMainDocumentPart().getRelationshipsPart(); BooleanDefaultTrue evenAndOddHeaders = null; if ((wmlPackage.getMainDocumentPart().getDocumentSettingsPart() != null) && (wmlPackage.getMainDocumentPart().getDocumentSettingsPart().getContents() != null)) { evenAndOddHeaders = wmlPackage.getMainDocumentPart().getDocumentSettingsPart().getContents().getEvenAndOddHeaders(); } if (dummySections) { conversionSections = processDummy(wmlPackage, document, rels, evenAndOddHeaders, dummyPageNumbering); } else { conversionSections = processComplete(wmlPackage, document, rels, evenAndOddHeaders, dummyPageNumbering); } return new ConversionSectionWrappers(conversionSections); }
MainDocumentPart wordDocumentPart = new MainDocumentPart(); wordDocumentPart.setJaxbElement(wmlDocumentEl); wordDocumentPart.addTargetPart(stylesPart); // NB - add it to main doc part, not package! wmlPack.getMainDocumentPart().addTargetPart(dsp); dsp.setJaxbElement(new CTSettings()); dsp.setOverrideTableStyleFontSizeAndJustification(true);
/** * @param documentPart * @param remediate * @return * @throws Exception */ public BookmarksStatus check(MainDocumentPart documentPart, boolean remediate) throws Exception { return check(documentPart.getContent(), remediate); }
protected XPathsPart createXPathsPart(WordprocessingMLPackage pkgOut, Xpaths xpaths) throws InvalidFormatException { xPathsPart = new XPathsPart(new PartName("/customXml/item1.xml")); pkgOut.getMainDocumentPart().addTargetPart(xPathsPart, AddPartBehaviour.RENAME_IF_NAME_EXISTS); addPropertiesPart(pkgOut, xPathsPart, "http://opendope.org/xpaths"); xPathsPart.setJaxbElement(xpaths); return xPathsPart; }
if (documentPart == null) { try { documentPart = new MainDocumentPart(); out.addTargetPart(documentPart); } catch (InvalidFormatException e) { if (documentPart.getStyleDefinitionsPart() == null) { Part stylesPart = new org.docx4j.openpackaging.parts.WordprocessingML.StyleDefinitionsPart(); final Styles styles = (Styles) XmlUtils.unmarshalString(STYLES_XML.getFrom(options)); ((org.docx4j.openpackaging.parts.WordprocessingML.StyleDefinitionsPart) stylesPart).setJaxbElement(styles); documentPart.addTargetPart(stylesPart); // NB - add it to main doc part, not package! assert documentPart.getStyleDefinitionsPart() != null : "Styles failed to set"; if (documentPart.getNumberingDefinitionsPart() == null) { documentPart.addTargetPart(numberingPart); // NB - add it to main doc part, not package! assert documentPart.getNumberingDefinitionsPart() != null : "Numbering failed to set";
List<Object> mdpResults = performOnInstance(input, input.getMainDocumentPart().getContent(), data, formTextFieldNames ); input.getMainDocumentPart().getContent().clear(); input.getMainDocumentPart().getContent().addAll(mdpResults); RelationshipsPart rp = input.getMainDocumentPart().getRelationshipsPart(); for ( Relationship r : rp.getJaxbElement().getRelationship() ) {
this.getContent().add( o ); finder.defaultCharacterStyle = this.getStyleDefinitionsPart().getDefaultCharacterStyle(); finder.defaultParagraphStyle = this.getStyleDefinitionsPart().getDefaultParagraphStyle(); finder.styleDefinitionsPart = this.getStyleDefinitionsPart(); log.debug("Inspecting style: " + styleName ); if (getPropertyResolver().activateStyle(styleName)) {
.getMainDocumentPart().getRelationshipsPart())); afiPart.setBinaryData(getDocxFetcher().getDocxFromIRI(iri)); .addTargetPart(afiPart); CTAltChunk ac = Context.getWmlObjectFactory() .createCTAltChunk();
public PropertyResolver(WordprocessingMLPackage wordMLPackage) throws Docx4JException { this.wordMLPackage = wordMLPackage; MainDocumentPart mdp = wordMLPackage.getMainDocumentPart(); styleDefinitionsPart = mdp.getStyleDefinitionsPart(true); themePart = mdp.getThemePart(); numberingDefinitionsPart = mdp.getNumberingDefinitionsPart(); if (wordMLPackage.getMainDocumentPart().getDocumentSettingsPart()!=null && wordMLPackage.getMainDocumentPart().getDocumentSettingsPart().getContents()!=null) { themeFontLang = wordMLPackage.getMainDocumentPart().getDocumentSettingsPart().getContents().getThemeFontLang(); } init(); }