/** * 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"); }
protected static Set<ContentAccessor> getParts(WordprocessingMLPackage srcPackage) { Set<ContentAccessor> partList = new HashSet<ContentAccessor>(); partList.add(srcPackage.getMainDocumentPart()); // Add headers/footers RelationshipsPart rp = srcPackage.getMainDocumentPart() .getRelationshipsPart(); for (Relationship r : rp.getRelationships().getRelationship()) { if (r.getType().equals(Namespaces.HEADER)) { partList.add((HeaderPart) rp.getPart(r)); } else if (r.getType().equals(Namespaces.FOOTER)) { partList.add((FooterPart) rp.getPart(r)); } } return partList; }
protected static void removeDefinedCustomXmlParts(WordprocessingMLPackage wmlPackage, String itemId) { List<PartName> partsToRemove = new ArrayList<PartName>(); RelationshipsPart relationshipsPart = wmlPackage.getMainDocumentPart().getRelationshipsPart(); List<Relationship> relationshipsList = ((relationshipsPart != null) && (relationshipsPart.getRelationships() != null) ? relationshipsPart.getRelationships().getRelationship() : null); Part part = null; if (relationshipsList != null) { for (Relationship relationship : relationshipsList) { if (Namespaces.CUSTOM_XML_DATA_STORAGE.equals(relationship.getType())) { part = relationshipsPart.getPart(relationship); if ( itemId!=null && itemId.equals(((CustomXmlPart)part).getItemId() )) { partsToRemove.add(part.getPartName()); } else if (part instanceof XPathsPart) { partsToRemove.add(part.getPartName()); } else if (part instanceof ConditionsPart) { partsToRemove.add(part.getPartName()); } else { log.warn("Keeping " + part.getPartName() + " of type " + part.getClass().getName()); } } } } if (!partsToRemove.isEmpty()) { for (int i=0; i<partsToRemove.size(); i++) { relationshipsPart.removePart(partsToRemove.get(i)); } } }
public void update(boolean processHeadersAndFooters) throws Docx4JException { report = new StringBuilder(); updatePart(wordMLPackage.getMainDocumentPart() ); if (processHeadersAndFooters) { RelationshipsPart rp = wordMLPackage.getMainDocumentPart().getRelationshipsPart(); for ( Relationship r : rp.getJaxbElement().getRelationship() ) { if (r.getType().equals(Namespaces.HEADER) || r.getType().equals(Namespaces.FOOTER)) { JaxbXmlPart part = (JaxbXmlPart)rp.getPart(r); report.append("\n" + part.getPartName() + "\n"); log.debug("\n" + part.getPartName() + "\n"); updatePart(part ); // performOnInstance( // ((ContentAccessor)part).getContent() ); } } } log.info(report.toString()); }
public void process(WordprocessingMLPackage wordMLPackage) throws Docx4JException { commentRangeStart = new HashMap<String, String>(); commentRangeEnd = new HashMap<String, String>(); commentReference = new HashMap<String, String>(); footnoteReference = new HashMap<String, String>(); endnoteReference = new HashMap<String, String>(); // A component can apply in both the main document part, // and in headers/footers. See further // http://forums.opendope.org/Support-components-in-headers-footers-tp2964174p2964174.html process(wordMLPackage.getMainDocumentPart()); // Add headers/footers RelationshipsPart rp = wordMLPackage.getMainDocumentPart() .getRelationshipsPart(); for (Relationship r : rp.getRelationships().getRelationship()) { if (r.getType().equals(Namespaces.HEADER)) { process((HeaderPart) rp.getPart(r)); } else if (r.getType().equals(Namespaces.FOOTER)) { process((FooterPart) rp.getPart(r)); } } }
+ "/SmartArt/OUT-xx.docx")); Relationship r = wordMLPackage.getMainDocumentPart().getRelationshipsPart().getRelationshipByType(Namespaces.DRAWINGML_DIAGRAM_DATA); DiagramDataPart thisPart = (DiagramDataPart)wordMLPackage.getMainDocumentPart().getRelationshipsPart().getPart(r); Relationship r2 = wordMLPackage.getMainDocumentPart().getRelationshipsPart().getRelationshipByType(Namespaces.DRAWINGML_DIAGRAM_DRAWING); if (r2==null) { System.out.println("No DDrawingP!"); } else { DiagramDrawingPart drawingPart = (DiagramDrawingPart)wordMLPackage.getMainDocumentPart().getRelationshipsPart().getPart(r2); drawingPart.setFriendlyIds(thisPart.map); System.out.println( XmlUtils.marshaltoString(drawingPart.getJaxbElement(), true, true));
|| wmlPkg.getMainDocumentPart().getRelationshipsPart() == null) { return null; wmlPkg.getMainDocumentPart().getRelationshipsPart().getRelationshipByID(rId); if (rel != null) { org.docx4j.openpackaging.parts.Part part = wmlPkg.getMainDocumentPart().getRelationshipsPart().getPart(rel); if (part == null) { log.error("Couldn't get Part!");
for (Relationship rel : clone.getMainDocumentPart().getRelationshipsPart().getJaxbElement().getRelationship() ) { clone.getMainDocumentPart().getRelationshipsPart().removeRelationship(rel);
private void findSdtsInTemplate(WordprocessingMLPackage pkg, TopLevelSdtTemplateFinder sdtPrFinder) throws Docx4JException { findSdtsInTemplatePart(pkg.getMainDocumentPart(), sdtPrFinder); // Add headers/footers RelationshipsPart rp = pkg.getMainDocumentPart() .getRelationshipsPart(); for (Relationship r : rp.getRelationships().getRelationship()) { if (r.getType().equals(Namespaces.HEADER)) { findSdtsInTemplatePart((HeaderPart) rp.getPart(r), sdtPrFinder); } else if (r.getType().equals(Namespaces.FOOTER)) { findSdtsInTemplatePart((FooterPart) rp.getPart(r), sdtPrFinder); } } }
private void findSdts(SdtFinder sdtPrFinder) throws Docx4JException { findSdtsInPart(pkg.getMainDocumentPart(), sdtPrFinder); // Add headers/footers RelationshipsPart rp = pkg.getMainDocumentPart() .getRelationshipsPart(); for (Relationship r : rp.getRelationships().getRelationship()) { if (r.getType().equals(Namespaces.HEADER)) { findSdtsInPart((HeaderPart) rp.getPart(r), sdtPrFinder); } else if (r.getType().equals(Namespaces.FOOTER)) { findSdtsInPart((FooterPart) rp.getPart(r), sdtPrFinder); } } }
private void handleSdtsInInstance() throws Docx4JException { handleSdtsInInstancePart(instancePkg.getMainDocumentPart()); // Add headers/footers RelationshipsPart rp = instancePkg.getMainDocumentPart() .getRelationshipsPart(); for (Relationship r : rp.getRelationships().getRelationship()) { if (r.getType().equals(Namespaces.HEADER)) { handleSdtsInInstancePart((HeaderPart) rp.getPart(r)); } else if (r.getType().equals(Namespaces.FOOTER)) { handleSdtsInInstancePart((FooterPart) rp.getPart(r)); } } }
public void process(WordprocessingMLPackage wordMLPackage) throws Docx4JException { // A component can apply in both the main document part, // and in headers/footers. See further // http://forums.opendope.org/Support-components-in-headers-footers-tp2964174p2964174.html process(wordMLPackage.getMainDocumentPart()); // Add headers/footers RelationshipsPart rp = wordMLPackage.getMainDocumentPart() .getRelationshipsPart(); for (Relationship r : rp.getRelationships().getRelationship()) { if (r.getType().equals(Namespaces.HEADER)) { process((HeaderPart) rp.getPart(r)); } else if (r.getType().equals(Namespaces.FOOTER)) { process((FooterPart) rp.getPart(r)); } } }
public void applyBindings() throws Docx4JException { // A component can apply in both the main document part, // and in headers/footers. See further // http://forums.opendope.org/Support-components-in-headers-footers-tp2964174p2964174.html getHyperlinkResolver().activateHyperlinkStyle(wordMLPackage); applyBindings(wordMLPackage.getMainDocumentPart()); // Add headers/footers RelationshipsPart rp = wordMLPackage.getMainDocumentPart() .getRelationshipsPart(); for (Relationship r : rp.getRelationships().getRelationship()) { if (r.getType().equals(Namespaces.HEADER)) { applyBindings((HeaderPart) rp.getPart(r)); } else if (r.getType().equals(Namespaces.FOOTER)) { applyBindings((FooterPart) rp.getPart(r)); } } }
groupAdjacentBorders(mainDocument.getJaxbElement().getBody().getContent()); relPart = mainDocument.getRelationshipsPart(); relList = relPart.getRelationships().getRelationship(); for (Relationship rs : relList) {
callback.walkJAXBElements(mainDocument.getJaxbElement().getBody()); if (!bodyOnly) { relPart = mainDocument.getRelationshipsPart(); relList = relPart.getRelationships().getRelationship(); for (Relationship rs : relList) {
.getRelationshipsPart(); for (Relationship r : rp.getRelationships().getRelationship()) {
RelationshipsPart rels = wordMLPackage.getMainDocumentPart().getRelationshipsPart();
private void readHyperlink() { if (getDocPr()!=null && getDocPr().getHlinkClick()!=null) { String linkRelId = getDocPr().getHlinkClick().getId(); if ( linkRelId!=null && !linkRelId.equals("") ) { Relationship rel = wmlPackage.getMainDocumentPart().getRelationshipsPart().getRelationshipByID(linkRelId); if (rel.getTargetMode() == null || rel.getTargetMode().equals("Internal") ) { setHlinkReference("TODO - save this object"); } else { setHlinkReference( rel.getTarget() ); } } targetFrame = getDocPr().getHlinkClick().getTgtFrame(); tooltip = getDocPr().getHlinkClick().getTooltip(); } }
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); }
RelationshipsPart rp = this.getRelationshipsPart(); if (rp!=null) { for ( Relationship r : rp.getRelationships().getRelationship() ) {