private static void createPlaceholderBytes() throws Exception { // Only want to do this once InputStream is; try { is = ResourceUtils.getResourceViaProperty("docx4j.model.datastorage.placeholder" , placeholderResource); } catch (IOException e) { log.info("No resource on classpath at docx4j.model.datastorage.placeholder; falling back to using org/docx4j/model/datastorage/placeholder.xml"); is = ResourceUtils.getResource(placeholderResourceFallback); } placeholderBytes = IOUtils.toByteArray(is); }
public static Templates getMcPreprocessor() throws IOException, TransformerConfigurationException { if (mcPreprocessorXslt==null) { Source xsltSource = new StreamSource( ResourceUtils.getResourceViaProperty("docx4j.jaxb.JaxbValidationEventHandler", "org/docx4j/jaxb/mc-preprocessor.xslt") ); mcPreprocessorXslt = XmlUtils.getTransformerTemplate(xsltSource); } return mcPreprocessorXslt; }
public Numbering unmarshalDefaultNumbering() throws JAXBException { java.io.InputStream is = null; try { is = ResourceUtils.getResourceViaProperty( "docx4j.openpackaging.parts.WordprocessingML.NumberingDefinitionsPart.DefaultNumbering", "org/docx4j/openpackaging/parts/WordprocessingML/numbering.xml"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return unmarshal( is ); // side-effect is to set jaxbElement }
/** * Initializes the removal handler. * * This tool is thread safe and should be reused, as initialization is * relatively expensive. */ public RemovalHandler() { try { final Source xsltSource = new StreamSource( ResourceUtils.getResourceViaProperty( "docx4j.model.datastorage.RemovalHandler.xslt", "org/docx4j/model/datastorage/RemovalHandler.xslt")); removalTemplate = XmlUtils.getTransformerTemplate(xsltSource); } catch (Exception e) { throw new IllegalStateException( "Error instantiating SDT removal stylesheet", e); } }
/** * Unmarshal a default font table, useful when creating this * part from scratch. * * @return the newly created root object of the java content tree * * @throws JAXBException * If any unexpected errors occur while unmarshalling */ public Object unmarshalDefaultFonts() throws JAXBException { java.io.InputStream is = null; try { // Works in Eclipse - not absence of leading '/' is = ResourceUtils.getResourceViaProperty( "docx4j.openpackaging.parts.WordprocessingML.FontTablePart.DefaultFonts", "org/docx4j/openpackaging/parts/WordprocessingML/fontTable.xml"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return unmarshal( is ); }
@Override public Templates getFinisherXslt(String filename) throws TransformerConfigurationException { Source xsltSource; try { xsltSource = new StreamSource( ResourceUtils.getResourceViaProperty( "docx4j.model.datastorage.XsltFinisher.xslt", "XsltFinisherCustom.xslt")); } catch (IOException e) { throw new TransformerConfigurationException(e.getMessage(), e); } return XmlUtils.getTransformerTemplate(xsltSource); }
is = ResourceUtils.getResourceViaProperty("docx4j.openpackaging.parts.WordprocessingML.StyleDefinitionsPart.DefaultStyles", "org/docx4j/openpackaging/parts/WordprocessingML/styles.xml");
private static void createPlaceholderFragment() throws Exception { // create it - one time operation InputStream is; try { is = ResourceUtils.getResourceViaProperty("docx4j.model.datastorage.placeholder" , placeholderResource); } catch (IOException e) { log.info("No resource on classpath for property docx4j.model.datastorage.placeholder; falling back to using org/docx4j/model/datastorage/placeholder.xml"); is = ResourceUtils.getResource(placeholderResourceFallback); } Document tmpDoc = XmlUtils.getNewDocumentBuilder().parse(is); placeholderFragment = tmpDoc.createDocumentFragment(); XmlUtils.treeCopy(tmpDoc.getDocumentElement(), placeholderFragment); }
private static void initKnownStyles() { // Throwable t = new Throwable(); // t.printStackTrace(); java.io.InputStream is = null; try { is = ResourceUtils.getResourceViaProperty("docx4j.openpackaging.parts.WordprocessingML.StyleDefinitionsPart.KnownStyles", "org/docx4j/openpackaging/parts/WordprocessingML/KnownStyles.xml"); JAXBContext jc = Context.jc; Unmarshaller u = jc.createUnmarshaller(); u.setEventHandler(new org.docx4j.jaxb.JaxbValidationEventHandler()); org.docx4j.wml.Styles styles = (org.docx4j.wml.Styles)u.unmarshal( is ); knownStyles = new java.util.HashMap<String, org.docx4j.wml.Style>(); for ( org.docx4j.wml.Style s : styles.getStyle() ) { knownStyles.put(s.getStyleId(), s); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
u.setEventHandler(new org.docx4j.jaxb.JaxbValidationEventHandler()); InputStream is = ResourceUtils.getResourceViaProperty("docx4j.fonts.microsoft.MicrosoftFonts" , "org/docx4j/fonts/microsoft/MicrosoftFonts.xml");
java.io.InputStream is = ResourceUtils.getResourceViaProperty( "pptx4j.openpackaging.packages.PresentationMLPackage.DefaultTheme", "org/docx4j/openpackaging/parts/PresentationML/theme.xml");
public static Templates getMcPreprocessor() throws IOException, TransformerConfigurationException { if (mcPreprocessorXslt==null) { Source xsltSource = new StreamSource( ResourceUtils.getResourceViaProperty("docx4j.jaxb.JaxbValidationEventHandler", "org/docx4j/jaxb/mc-preprocessor.xslt") ); mcPreprocessorXslt = XmlUtils.getTransformerTemplate(xsltSource); } return mcPreprocessorXslt; }
public Numbering unmarshalDefaultNumbering() throws JAXBException { java.io.InputStream is = null; try { is = ResourceUtils.getResourceViaProperty( "docx4j.openpackaging.parts.WordprocessingML.NumberingDefinitionsPart.DefaultNumbering", "org/docx4j/openpackaging/parts/WordprocessingML/numbering.xml"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return unmarshal( is ); // side-effect is to set jaxbElement }
private static void createPlaceholderBytes() throws Exception { // Only want to do this once InputStream is; try { is = ResourceUtils.getResourceViaProperty("docx4j.model.datastorage.placeholder" , placeholderResource); } catch (IOException e) { log.info("No resource on classpath at docx4j.model.datastorage.placeholder; falling back to using org/docx4j/model/datastorage/placeholder.xml"); is = ResourceUtils.getResource(placeholderResourceFallback); } placeholderBytes = IOUtils.toByteArray(is); }
/** * Initializes the removal handler. * * This tool is thread safe and should be reused, as initialization is * relatively expensive. */ public RemovalHandler() { try { final Source xsltSource = new StreamSource( ResourceUtils.getResourceViaProperty( "docx4j.model.datastorage.RemovalHandler.xslt", "org/docx4j/model/datastorage/RemovalHandler.xslt")); removalTemplate = XmlUtils.getTransformerTemplate(xsltSource); } catch (Exception e) { throw new IllegalStateException( "Error instantiating SDT removal stylesheet", e); } }
/** * Unmarshal a default font table, useful when creating this * part from scratch. * * @return the newly created root object of the java content tree * * @throws JAXBException * If any unexpected errors occur while unmarshalling */ public Object unmarshalDefaultFonts() throws JAXBException { java.io.InputStream is = null; try { // Works in Eclipse - not absence of leading '/' is = ResourceUtils.getResourceViaProperty( "docx4j.openpackaging.parts.WordprocessingML.FontTablePart.DefaultFonts", "org/docx4j/openpackaging/parts/WordprocessingML/fontTable.xml"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return unmarshal( is ); }
@Override public Templates getFinisherXslt(String filename) throws TransformerConfigurationException { Source xsltSource; try { xsltSource = new StreamSource( ResourceUtils.getResourceViaProperty( "docx4j.model.datastorage.XsltFinisher.xslt", "XsltFinisherCustom.xslt")); } catch (IOException e) { throw new TransformerConfigurationException(e.getMessage(), e); } return XmlUtils.getTransformerTemplate(xsltSource); }
is = ResourceUtils.getResourceViaProperty("docx4j.openpackaging.parts.WordprocessingML.StyleDefinitionsPart.DefaultStyles", "org/docx4j/openpackaging/parts/WordprocessingML/styles.xml");
private static void createPlaceholderFragment() throws Exception { // create it - one time operation InputStream is; try { is = ResourceUtils.getResourceViaProperty("docx4j.model.datastorage.placeholder" , placeholderResource); } catch (IOException e) { log.info("No resource on classpath for property docx4j.model.datastorage.placeholder; falling back to using org/docx4j/model/datastorage/placeholder.xml"); is = ResourceUtils.getResource(placeholderResourceFallback); } Document tmpDoc = XmlUtils.getNewDocumentBuilder().parse(is); placeholderFragment = tmpDoc.createDocumentFragment(); XmlUtils.treeCopy(tmpDoc.getDocumentElement(), placeholderFragment); }
private static void initKnownStyles() { // Throwable t = new Throwable(); // t.printStackTrace(); java.io.InputStream is = null; try { is = ResourceUtils.getResourceViaProperty("docx4j.openpackaging.parts.WordprocessingML.StyleDefinitionsPart.KnownStyles", "org/docx4j/openpackaging/parts/WordprocessingML/KnownStyles.xml"); JAXBContext jc = Context.jc; Unmarshaller u = jc.createUnmarshaller(); u.setEventHandler(new org.docx4j.jaxb.JaxbValidationEventHandler()); org.docx4j.wml.Styles styles = (org.docx4j.wml.Styles)u.unmarshal( is ); knownStyles = new java.util.HashMap<String, org.docx4j.wml.Style>(); for ( org.docx4j.wml.Style s : styles.getStyle() ) { knownStyles.put(s.getStyleId(), s); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }