/** * Traverse the object using your callback. Invoking this constructor starts the * traverse, by invoking the callback's walkJAXBElements method. * * @param parent * @param cb */ public TraversalUtil(Object parent, Callback cb) { this.cb = cb; cb.walkJAXBElements(parent); }
/** * @since 3.0.0 */ public static int pxToTwip(float px) { float inch = px/DPI; return inchToTwip(inch); }
private static int getIndex(List list, Object deletion) { int i = 0; for (Object o : list) { if (o==deletion || XmlUtils.unwrap(o)==deletion) { return i; } i++; } return -1; }
/** Unmarshal a String as an object in the package org.docx4j.jaxb.document. * Note: you should ensure you include a namespace declaration for w: and * any other namespace in the xml string. * Also, the object you are attempting to unmarshall to might need to * have an @XmlRootElement annotation for things to work. */ public static Object unmarshalString(String str) throws JAXBException { return unmarshalString(str, Context.jc); }
/** * Extract contents of descendant <w:t> elements. * * @param o * @param jcSVG JAXBContext * @return */ public static void extractText(Object o, Writer w) throws Exception { extractText(o, w, Context.jc); }
public static Boolean publishAsynch() { if (publishAsynch==null) { publishAsynch = Docx4jProperties.getProperty("docx4j.events.Docx4jEvent.PublishAsync", false); } return publishAsynch; }
/** Marshal to a String */ public static String marshaltoString(Object o, boolean suppressDeclaration, boolean prettyprint ) { JAXBContext jc = Context.jc; return marshaltoString(o, suppressDeclaration, prettyprint, jc ); }
protected static Exporter<FOSettings> getFOExporter(int flags) throws Docx4JException { switch (flags) { case FLAG_EXPORT_PREFER_NONXSL: return FOExporterVisitorGetInstance(); case FLAG_EXPORT_PREFER_XSL: default: return FOExporterXsltGetInstance(); } }
/** * Bind the content controls of the passed document to the xml. */ public static void bind(WordprocessingMLPackage wmlPackage, Document xmlDocument, int flags, DocxFetcher docxFetcher) throws Docx4JException { bind( wmlPackage, xmlDocument, flags, docxFetcher, null, null, null); // no final formatting step }
@Override public List<Object> getChildren(Object o) { // log.debug("getChildren for " + o.getClass().getName()); return TraversalUtil.getChildrenImpl(o); }
/** Unmarshal an InputStream as an object in the package org.docx4j.jaxb.document. * Note: you should ensure you include a namespace declaration for w: and * any other namespace in the xml string. * Also, the object you are attempting to unmarshall to might need to * have an @XmlRootElement annotation for things to work. */ public static Object unmarshal(InputStream is) throws JAXBException { return unmarshal(is, Context.jc); }
protected Node attachContents(DocumentFragment docfrag, Node xhtmlDiv, Node resultSoFar) { XmlUtils.treeCopy(resultSoFar, xhtmlDiv); return docfrag; }
/** * Convert a pixel value to twips and return as a double. This may be useful * where the returned value will then be converted to another unit, and we * don't want to lose precision due to rounding. */ public static double pxToTwipDouble(double px) { double inch = px / DPI; return inchToTwipDouble(inch); }
@Override public String parseFieldArgument(String fieldArgument) { this.fieldArgument = fieldArgument; tSwitchSeparator = Docx4jProperties.getProperty(DOCX4J_FIELDS_TOC_SWITCH_T_SEPARATOR, COMMA); return EMPTY; }
/** * Marshal this object to a String, pretty printed, and without an XML declaration. * Useful for debugging. * * @param o * @return * @since 3.0.1 */ public static String marshaltoString(Object o ) { JAXBContext jc = Context.jc; return marshaltoString(o, true, true, jc ); }
public static void visit(Object parent, Callback callback) { if ((parent != null) && (callback != null)) { callback.walkJAXBElements(parent); } }
/** * Bind the content controls of the passed document to the xml. */ public static void bind(WordprocessingMLPackage wmlPackage, Document xmlDocument, int flags) throws Docx4JException { bind( wmlPackage, xmlDocument, flags, null); }
@Override public List<Object> getChildren(Object o) { return TraversalUtil.getChildrenImpl(o); }
private static boolean shouldUseHighlightInRPr() { if (useHIghlightInRPr==null) { useHIghlightInRPr = Docx4jProperties.getProperty("docx4j.model.properties.PropertyFactory.createPropertyFromCssName.background-color.useHighlightInRPr", false); } return useHIghlightInRPr; }
/** * Use the specified JAXBContext to marshal this object to a String, pretty printed, and without an XML declaration. * Useful for debugging. * * @param o * @return * @since 3.0.1 */ public static String marshaltoString(Object o, JAXBContext jc ) { return marshaltoString(o, true, true, jc ); }