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)); } } }
private void processString(JaxbXmlPart sourcePart, List<Object> contents, String text, SdtPr sdtPr, RPr rPr) throws JAXBException { int pos = BindingHandler.getHyperlinkResolver().getIndexOfURL(text); if (pos==-1 || BindingHandler.getHyperlinkStyleId() == null) { addRunToDocFrag(sourcePart, contents, text, rPr); return;
/** * Workaround for the fact that Xalan doesn't let us pass an AtomicInteger into an extension * function. Instead, it converts it into an int, which means the object in our * bookmarkIdCounter parameter isn't updated. * * So here we wrap the AtomicInteger in a class, * * @author jharrop * */ public static class BookmarkCounter { protected AtomicInteger bookmarkId; BookmarkCounter(AtomicInteger bookmarkId) { this.bookmarkId = bookmarkId; } }
startEvent.publish(); bh = new BindingHandler(wmlPackage); bh.setStartingIdForNewBookmarks(openDoPEHandler.getNextBookmarkId()); bh.setDomToXPathMap(domToXPathMap); // since 3.3.6 bh.applyBindings(); XsltFinisher.setXsltProvider(xsltProvider ); finisher.apply(wmlPackage.getMainDocumentPart(), bh.getXpathsMap(), xsltFinisherfilename, finisherParams);
/** * @deprecated */ public static String getHyperlinkStyleId() { return getHyperlinkResolver().getHyperlinkStyleId(); }
public static String xpathGetString( WordprocessingMLPackage pkg, Map<String, CustomXmlPart> customXmlDataStorageParts, CTDataBinding db) { return xpathGetString( pkg, customXmlDataStorageParts, db.getStoreItemID(), db.getXpath(), db.getPrefixMappings() ); }
getHyperlinkResolver().activateHyperlinkStyle(wordMLPackage); traverser.setStartingIdForNewBookmarks(initBookmarkIdStart());
r = BindingHandler.xpathGetString(pkg, customXmlDataStorageParts, storeItemId, xpathExp, prefixMappings); } else if (log.isDebugEnabled() && r.trim().length()==0) { r = BindingHandler.xpathGetString(pkg, customXmlDataStorageParts, storeItemId, xpathExp, prefixMappings); xHTMLImporter.setHyperlinkStyle(BindingHandler.getHyperlinkResolver().getHyperlinkStyleId());
"<w:r>" + "<w:rPr>" + "<w:rStyle w:val=\"" + BindingHandler.getHyperlinkStyleId() + "\" />" + // TODO: enable this style in the document! "</w:rPr>" + "<w:t>" + url + "</w:t>" +
startEvent.publish(); bh = new BindingHandler(wmlPackage); bh.setStartingIdForNewBookmarks(openDoPEHandler.getNextBookmarkId()); bh.setDomToXPathMap(domToXPathMap); // since 3.3.6 bh.applyBindings(); XsltFinisher.setXsltProvider(xsltProvider ); finisher.apply(wmlPackage.getMainDocumentPart(), bh.getXpathsMap(), xsltFinisherfilename, finisherParams);
/** * Configure, how the handler handles links found in Custom XML. * * If hyperlinkStyleId is set to <code>null</code>, strings * containing 'http://' or 'https://' are not converted to * w:hyperlink. This is the default behavior. * * If hyperlinkStyleId is set to <code>"someWordHyperlinkStyleName"</code>, * strings containing 'http://' or 'https://' or or 'mailto:' are converted to w:hyperlink. * The default Word hyperlink style name is "Hyperlink". * * Due to the architecture of this class, this is a static flag changing the * behavior of all following calls to {@link #applyBindings}. * * @param hyperlinkStyleID * The style to use for hyperlinks (eg Hyperlink) * @deprecated */ public static void setHyperlinkStyle ( String hyperlinkStyleID) { getHyperlinkResolver().setHyperlinkStyle(hyperlinkStyleID); } /**
r = BindingHandler.xpathGetString(pkg, customXmlDataStorageParts, storeItemId, xpath, prefixMappings); r = BindingHandler.xpathGetString(pkg, customXmlDataStorageParts, storeItemId, xpath, prefixMappings);
getHyperlinkResolver().activateHyperlinkStyle(wordMLPackage); traverser.setStartingIdForNewBookmarks(initBookmarkIdStart());
r = BindingHandler.xpathGetString(pkg, customXmlDataStorageParts, storeItemId, xpathExp, prefixMappings); } else if (log.isDebugEnabled() && r.trim().length()==0) { r = BindingHandler.xpathGetString(pkg, customXmlDataStorageParts, storeItemId, xpathExp, prefixMappings); xHTMLImporter.setHyperlinkStyle(BindingHandler.getHyperlinkResolver().getHyperlinkStyleId());
"<w:r>" + "<w:rPr>" + "<w:rStyle w:val=\"" + BindingHandler.getHyperlinkStyleId() + "\" />" + // TODO: enable this style in the document! "</w:rPr>" + "<w:t>" + url + "</w:t>" +
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)); } } }
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); } } }
String r = BindingHandler.xpathGetString(pkg, customXmlDataStorageParts, dataBinding); if (r==null) return null;
/** * Workaround for the fact that Xalan doesn't let us pass an AtomicInteger into an extension * function. Instead, it converts it into an int, which means the object in our * bookmarkIdCounter parameter isn't updated. * * So here we wrap the AtomicInteger in a class, * * @author jharrop * */ public static class BookmarkCounter { protected AtomicInteger bookmarkId; BookmarkCounter(AtomicInteger bookmarkId) { this.bookmarkId = bookmarkId; } }
private void processString(JaxbXmlPart sourcePart, List<Object> contents, String text, SdtPr sdtPr, RPr rPr) throws JAXBException { int pos = BindingHandler.getHyperlinkResolver().getIndexOfURL(text); if (pos==-1 || BindingHandler.getHyperlinkStyleId() == null) { addRunToDocFrag(sourcePart, contents, text, rPr); return;