@Override protected void commit() throws IOException { if (ctStyles == null) { throw new IllegalStateException("Unable to write out styles that were never read in!"); } XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTStyles.type.getName().getNamespaceURI(), "styles")); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); ctStyles.save(out, xmlOptions); out.close(); }
/** * Read document */ @Override protected void onDocumentRead() throws IOException { StylesDocument stylesDoc; InputStream is = getPackagePart().getInputStream(); try { stylesDoc = StylesDocument.Factory.parse(is, DEFAULT_XML_OPTIONS); setStyles(stylesDoc.getStyles()); latentStyles = new XWPFLatentStyles(ctStyles.getLatentStyles(), this); } catch (XmlException e) { throw new POIXMLException("Unable to read styles", e); } finally { is.close(); } }
@Override protected void commit() throws IOException { if (ctStyles == null) { throw new IllegalStateException("Unable to write out styles that were never read in!"); } XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTStyles.type.getName().getNamespaceURI(), "styles")); Map<String,String> map = new HashMap<String,String>(); map.put("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "r"); map.put("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w"); xmlOptions.setSaveSuggestedPrefixes(map); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); ctStyles.save(out, xmlOptions); out.close(); }
@Override protected void commit() throws IOException { if (ctStyles == null) { throw new IllegalStateException("Unable to write out styles that were never read in!"); } XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTStyles.type.getName().getNamespaceURI(), "styles")); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); ctStyles.save(out, xmlOptions); out.close(); }
/** * Read document */ @Override protected void onDocumentRead() throws IOException { StylesDocument stylesDoc; InputStream is = getPackagePart().getInputStream(); try { stylesDoc = StylesDocument.Factory.parse(is, DEFAULT_XML_OPTIONS); setStyles(stylesDoc.getStyles()); latentStyles = new XWPFLatentStyles(ctStyles.getLatentStyles(), this); } catch (XmlException e) { throw new POIXMLException("Unable to read styles", e); } finally { is.close(); } }
/** * Read document */ @Override protected void onDocumentRead() throws IOException{ StylesDocument stylesDoc; try { InputStream is = getPackagePart().getInputStream(); stylesDoc = StylesDocument.Factory.parse(is); ctStyles = stylesDoc.getStyles(); latentStyles = new XWPFLatentStyles(ctStyles.getLatentStyles(), this); } catch (XmlException e) { throw new POIXMLException("Unable to read styles", e); } // Build up all the style objects for(CTStyle style : ctStyles.getStyleList()) { listStyle.add(new XWPFStyle(style, this)); } }