/** Marshal to a W3C document */ public static org.w3c.dom.Document marshaltoW3CDomDocument(Object o) { return marshaltoW3CDomDocument(o, Context.jc); }
public void diff(org.docx4j.wml.Body newer, org.docx4j.wml.Body older, javax.xml.transform.Result result, String author, java.util.Calendar date, RelationshipsPart docPartRelsNewer, RelationshipsPart docPartRelsOlder) { this.diffWorker( org.docx4j.XmlUtils.marshaltoW3CDomDocument(newer).getDocumentElement(), org.docx4j.XmlUtils.marshaltoW3CDomDocument(older).getDocumentElement(), result, author, date, docPartRelsNewer, docPartRelsOlder); }
/** * XPaths are evaluated against a DOM document representation * of the JAXBElement. These aren't kept in sync, so you can * use this method to update the DOM document from the JAXBElement. */ public void readyXPath() { doc = XmlUtils.marshaltoW3CDomDocument(getJaxbElement(), getJAXBContext()); }
@Override protected Document getSourceDocument( CS conversionSettings, CC conversionContext) throws Docx4JException { ConversionSectionWrappers conversionSectionWrappers = conversionContext.getSections(); Document ret = XmlUtils.marshaltoW3CDomDocument(conversionSectionWrappers.createSections(), Context.jcSectionModel); return ret; }
@Deprecated // see instead org.docx4j.convert.out.Converter public static Node getFootnote(WordprocessingMLPackage wmlPackage, String id) { CTFootnotes footnotes = wmlPackage.getMainDocumentPart().getFootnotesPart().getJaxbElement(); int pos = Integer.parseInt(id); // No @XmlRootElement on CTFtnEdn, so .. CTFtnEdn ftn = (CTFtnEdn)footnotes.getFootnote().get(pos); Document d = XmlUtils.marshaltoW3CDomDocument( ftn, Context.jc, Namespaces.NS_WORD12, "footnote", CTFtnEdn.class ); log.debug("Footnote " + id + ": " + XmlUtils.w3CDomNodeToString(d)); return d; }
private void addBookmarkEnd(int id, DocumentFragment docfrag) { CTMarkupRange markuprange = Context.getWmlObjectFactory().createCTMarkupRange(); markuprange.setId( BigInteger.valueOf(id ) ); Document tmpDoc = XmlUtils.marshaltoW3CDomDocument(markuprange); XmlUtils.treeCopy(tmpDoc.getDocumentElement(), docfrag); }
public static Node getFootnote(AbstractWmlConversionContext context, String id) { WordprocessingMLPackage wmlPackage = context.getWmlPackage(); CTFootnotes footnotes = wmlPackage.getMainDocumentPart().getFootnotesPart().getJaxbElement(); int pos = Integer.parseInt(id); // No @XmlRootElement on CTFtnEdn, so .. CTFtnEdn ftn = (CTFtnEdn)footnotes.getFootnote().get(pos); Document d = XmlUtils.marshaltoW3CDomDocument( ftn, Context.jc, Namespaces.NS_WORD12, "footnote", CTFtnEdn.class ); if (log.isDebugEnabled()) { log.debug("Footnote " + id + ": " + XmlUtils.w3CDomNodeToString(d)); } return d; }
private void addRun(String val, DocumentFragment docfrag) { R r = new R(); Text t = new Text(); t.setValue(val); r.getContent().add(t); Document tmpDoc = XmlUtils.marshaltoW3CDomDocument(r); XmlUtils.treeCopy(tmpDoc.getDocumentElement(), docfrag); }
@Override protected Document getSourceDocument(HTMLSettings conversionSettings, HTMLConversionContext conversionContext) throws Docx4JException { WordprocessingMLPackage wmlPackage = conversionContext.getWmlPackage(); //TODO: the docx2xhtml-core.xslt only knows about the MainDocumentPart, therefore it's //unable to process any sections.... return XmlUtils.marshaltoW3CDomDocument(wmlPackage.getMainDocumentPart().getJaxbElement()); }
protected void addHyperlinkToDocFrag(JaxbXmlPart sourcePart, DocumentFragment docfrag, String url) throws Docx4JException { if (url.startsWith("http") || url.startsWith("mailto")) { super.addHyperlinkToDocFrag(sourcePart, docfrag, url); } else { // Handle eg #/components/schemas/Pets String bookmarkName = refToBookmarkName(url); try { Document tmpDoc = XmlUtils.marshaltoW3CDomDocument( BindingHandler.getHyperlinkResolver().generateHyperlink(bookmarkName, url)); XmlUtils.treeCopy(tmpDoc.getDocumentElement(), docfrag); } catch (JAXBException e) { throw new Docx4JException(e.getMessage(), e); } } }
private void addBookmarkStart(String bookmarkName, int id, DocumentFragment docfrag) { CTBookmark bookmark = Context.getWmlObjectFactory().createCTBookmark(); JAXBElement<org.docx4j.wml.CTBookmark> bookmarkWrapped = Context.getWmlObjectFactory().createPBookmarkStart(bookmark); bookmark.setName( bookmarkName ); bookmark.setId( BigInteger.valueOf( id) ); Document tmpDoc = XmlUtils.marshaltoW3CDomDocument(bookmark); XmlUtils.treeCopy(tmpDoc.getDocumentElement(), docfrag); }
protected void addBrRunToDocFrag(DocumentFragment docfrag, RPr rPr) throws Docx4JException { // Not sure whether there is ever anything of interest in the rPr, // but add it anyway org.docx4j.wml.R run = Context.getWmlObjectFactory().createR(); if (rPr!=null) { run.setRPr(rPr); } run.getRunContent().add(Context.getWmlObjectFactory().createBr()); Document tmpDoc = XmlUtils.marshaltoW3CDomDocument(run); XmlUtils.treeCopy(tmpDoc.getDocumentElement(), docfrag); }
public static Node getEndnotes(AbstractWmlConversionContext context) { return XmlUtils.marshaltoW3CDomDocument( context.getWmlPackage().getMainDocumentPart().getEndNotesPart().getJaxbElement()); }
public static Node getFootnotes(AbstractWmlConversionContext context) { return XmlUtils.marshaltoW3CDomDocument( context.getWmlPackage().getMainDocumentPart().getFootnotesPart().getJaxbElement()); }
public static Node getEvenFooter(AbstractWmlConversionContext context) { ConversionSectionWrapper currentSection = context.getSections().getCurrentSection(); Ftr ftr = (Ftr)currentSection.getHeaderFooterPolicy().getEvenFooter().getJaxbElement(); return XmlUtils.marshaltoW3CDomDocument(ftr); }
public static Node getFirstFooter(AbstractWmlConversionContext context) { ConversionSectionWrapper currentSection = context.getSections().getCurrentSection(); Ftr ftr = (Ftr)currentSection.getHeaderFooterPolicy().getFirstFooter().getJaxbElement(); return XmlUtils.marshaltoW3CDomDocument(ftr); }
public static Node getDefaultHeader(AbstractWmlConversionContext context) { ConversionSectionWrapper currentSection = context.getSections().getCurrentSection(); Hdr hdr = currentSection.getHeaderFooterPolicy().getDefaultHeader().getJaxbElement(); return XmlUtils.marshaltoW3CDomDocument(hdr); }
public static Node getDefaultFooter(AbstractWmlConversionContext context) { ConversionSectionWrapper currentSection = context.getSections().getCurrentSection(); Ftr ftr = (Ftr)currentSection.getHeaderFooterPolicy().getDefaultFooter().getJaxbElement(); return XmlUtils.marshaltoW3CDomDocument(ftr); }
public static Node getEvenHeader(AbstractWmlConversionContext context) { ConversionSectionWrapper currentSection = context.getSections().getCurrentSection(); Hdr hdr = (Hdr)currentSection.getHeaderFooterPolicy().getEvenHeader().getJaxbElement(); return XmlUtils.marshaltoW3CDomDocument(hdr); }
public static Node getFirstHeader(AbstractWmlConversionContext context) { ConversionSectionWrapper currentSection = context.getSections().getCurrentSection(); Hdr hdr = (Hdr)currentSection.getHeaderFooterPolicy().getFirstHeader().getJaxbElement(); return XmlUtils.marshaltoW3CDomDocument(hdr); }