/** * @deprecated */ public static String getHyperlinkStyleId() { return getHyperlinkResolver().getHyperlinkStyleId(); }
/** * 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); } /**
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); } } }
protected void processString(JaxbXmlPart sourcePart, DocumentFragment docfrag, String text, RPr rPr) throws Docx4JException { int pos = BindingHandler.getHyperlinkResolver().getIndexOfURL(text); if (pos==-1 ) { addRunToDocFrag(sourcePart, docfrag, text, rPr); return; } else if (BindingHandler.getHyperlinkResolver().getHyperlinkStyleId() == null){ log.warn("No Hyperlink style set, not linking"); addRunToDocFrag(sourcePart, docfrag, text, rPr);
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);
getHyperlinkResolver().activateHyperlinkStyle(wordMLPackage);
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)); } } }
xHTMLImporter.setHyperlinkStyle(BindingHandler.getHyperlinkResolver().getHyperlinkStyleId());
protected void addHyperlinkToDocFrag(JaxbXmlPart sourcePart, DocumentFragment docfrag, String url) throws Docx4JException { // We need to add a relationship to word/_rels/document.xml.rels // but since its external, we don't use the // usual wordMLPackage.getMainDocumentPart().addTargetPart // mechanism org.docx4j.relationships.ObjectFactory factory = new org.docx4j.relationships.ObjectFactory(); org.docx4j.relationships.Relationship rel = factory.createRelationship(); rel.setType( Namespaces.HYPERLINK ); rel.setTarget(url); rel.setTargetMode("External"); sourcePart.getRelationshipsPart().addRelationship(rel); // addRelationship sets the rel's @Id try { Document tmpDoc = XmlUtils.marshaltoW3CDomDocument( BindingHandler.getHyperlinkResolver().generateHyperlink(rel.getId(), url)); XmlUtils.treeCopy(tmpDoc.getDocumentElement(), docfrag); } catch (JAXBException e) { throw new Docx4JException(e.getMessage(), e); } }
/** * @deprecated */ public static String getHyperlinkStyleId() { return getHyperlinkResolver().getHyperlinkStyleId(); }
/** * 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); } /**
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); } } }
protected void processString(JaxbXmlPart sourcePart, DocumentFragment docfrag, String text, RPr rPr) throws Docx4JException { int pos = BindingHandler.getHyperlinkResolver().getIndexOfURL(text); if (pos==-1 ) { addRunToDocFrag(sourcePart, docfrag, text, rPr); return; } else if (BindingHandler.getHyperlinkResolver().getHyperlinkStyleId() == null){ log.warn("No Hyperlink style set, not linking"); addRunToDocFrag(sourcePart, docfrag, text, rPr);
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);
protected void addHyperlinkToDocFrag(JaxbXmlPart sourcePart, DocumentFragment docfrag, String url) throws Docx4JException { // We need to add a relationship to word/_rels/document.xml.rels // but since its external, we don't use the // usual wordMLPackage.getMainDocumentPart().addTargetPart // mechanism org.docx4j.relationships.ObjectFactory factory = new org.docx4j.relationships.ObjectFactory(); org.docx4j.relationships.Relationship rel = factory.createRelationship(); rel.setType( Namespaces.HYPERLINK ); rel.setTarget(url); rel.setTargetMode("External"); sourcePart.getRelationshipsPart().addRelationship(rel); // addRelationship sets the rel's @Id try { Document tmpDoc = XmlUtils.marshaltoW3CDomDocument( BindingHandler.getHyperlinkResolver().generateHyperlink(rel.getId(), url)); XmlUtils.treeCopy(tmpDoc.getDocumentElement(), docfrag); } catch (JAXBException e) { throw new Docx4JException(e.getMessage(), e); } }
getHyperlinkResolver().activateHyperlinkStyle(wordMLPackage);
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)); } } }
xHTMLImporter.setHyperlinkStyle(BindingHandler.getHyperlinkResolver().getHyperlinkStyleId());