private String newUniqueStyleName(OdfStyleFamily styleFamily) { String unique_name; if (styleFamily.equals(OdfStyleFamily.List)) { do { unique_name = String.format("l%06x", (int) (Math.random() * 0xffffff)); } while (getListStyle(unique_name) != null); } else { do { unique_name = String.format("a%06x", (int) (Math.random() * 0xffffff)); } while (getStyle(unique_name, styleFamily) != null); } return unique_name; } }
/** * Create an <code>OdfTextListStyle</code> element * * @return an <code>OdfTextListStyle</code> element */ public OdfTextListStyle newListStyle() { OdfFileDom dom = (OdfFileDom) this.ownerDocument; OdfTextListStyle newStyle = dom.newOdfElement(OdfTextListStyle.class); newStyle.setStyleNameAttribute(newUniqueStyleName(OdfStyleFamily.List)); this.appendChild(newStyle); return newStyle; }
private String getUniqueCurrencyStyleName() { String unique_name; OdfOfficeAutomaticStyles styles = mCellElement.getAutomaticStyles(); do { unique_name = String.format("c%06x", (int) (Math.random() * 0xffffff)); } while (styles.getCurrencyStyle(unique_name) != null); return unique_name; }
/** * This method makes the style unique * * @param referenceStyle The reference <code>OdfStyle</code> element * @return an <code>OdfStyle</code> element */ public OdfStyle makeStyleUnique(OdfStyle referenceStyle) { OdfStyle newStyle = null; if (referenceStyle.getOwnerDocument() != this.getOwnerDocument()) { // import style from a different dom newStyle = (OdfStyle) this.getOwnerDocument().importNode(referenceStyle, true); } else { // just clone newStyle = (OdfStyle) referenceStyle.cloneNode(true); } newStyle.setStyleNameAttribute(newUniqueStyleName(newStyle.getFamily())); appendChild(newStyle); return newStyle; }
OdfNumberStyle style = mCellElement.getAutomaticStyles().getNumberStyle(name); if (style == null) { style = mDocument.getDocumentStyles().getNumberStyle(name); OdfNumberDateStyle style = mCellElement.getAutomaticStyles().getDateStyle(name); if (style == null) { style = mDocument.getDocumentStyles().getDateStyle(name); OdfNumberCurrencyStyle dataStyle = mCellElement.getAutomaticStyles().getCurrencyStyle(name); if (dataStyle == null) { dataStyle = mDocument.getDocumentStyles().getCurrencyStyle(name); OdfNumberPercentageStyle style = mCellElement.getAutomaticStyles().getPercentageStyle(name); if (style == null) { style = mDocument.getDocumentStyles().getPercentageStyle(name);
private OdfStyle getStyleByName(String name) { OdfStyle styleElement = null; OdfOfficeAutomaticStyles styles = mParaElement.getAutomaticStyles(); styleElement = styles.getStyle(name, OdfStyleFamily.Paragraph); if (styleElement == null) { styleElement = mDocument.getDocumentStyles().getStyle(name, OdfStyleFamily.Paragraph); } return styleElement; }
OdfOfficeAutomaticStyles autoStyles = getContentDom().getAutomaticStyles(); NodeList stylesList = autoStyles.getChildNodes(); OdfContentDom contentDom = getContentDom(); XPath xpath = contentDom.getXPath(); autoStyles.removeChild(removeStyles.get(i));
styles = contentDocument.getAutomaticStyles(); OdfOfficeStyles documentStyles = doc.getDocumentStyles(); listStyle = styles.getListStyle(DEFAULT_NAME); listStyle = styles.newListStyle(); paragraphStyle = styles.newStyle(OdfStyleFamily.Paragraph);
private OdfStyle getOrCreateStyleByName(OdfOfficeStyles documentStyles, OdfOfficeAutomaticStyles styles, String styleName, OdfStyleFamily styleFamily) { OdfStyle odfStyle = documentStyles.getStyle(styleName, styleFamily); if (odfStyle == null) { styles.getStyle(styleName, styleFamily); } if (odfStyle == null) { odfStyle = styles.newStyle(styleFamily); odfStyle.setStyleNameAttribute(styleName); odfStyle.setStyleDisplayNameAttribute(styleName); } return odfStyle; }
OdfOfficeAutomaticStyles styles = contentDocument.getAutomaticStyles(); OdfOfficeStyles documentStyles = doc.getDocumentStyles(); OdfTextListStyle listStyle = styles.getListStyle(textStyleName); if (listStyle == null) { listStyle = documentStyles.getListStyle(textStyleName);
private String getUniqueDateStyleName() { String unique_name; OdfOfficeAutomaticStyles styles = mCellElement.getAutomaticStyles(); do { unique_name = String.format("d%06x", (int) (Math.random() * 0xffffff)); } while (styles.getDateStyle(unique_name) != null); return unique_name; }
private OdfNumberDateStyle newDateStyle() { OdfFileDom dom = (OdfFileDom) dateElement.getOwnerDocument(); OdfOfficeAutomaticStyles styles = dom.getAutomaticStyles(); OdfNumberDateStyle newStyle = dom.newOdfElement(OdfNumberDateStyle.class); newStyle.setStyleNameAttribute(newUniqueStyleName(styles)); styles.appendChild(newStyle); return newStyle; }
private String getUniquePercentageStyleName() { String unique_name; OdfOfficeAutomaticStyles styles = mCellElement.getAutomaticStyles(); do { unique_name = String.format("p%06x", (int) (Math.random() * 0xffffff)); } while (styles.getPercentageStyle(unique_name) != null); return unique_name; }
private String getUniqueNumberStyleName() { String unique_name; OdfOfficeAutomaticStyles styles = mCellElement.getAutomaticStyles(); do { unique_name = String.format("n%06x", (int) (Math.random() * 0xffffff)); } while (styles.getNumberStyle(unique_name) != null); return unique_name; }
Iterator<OdfStyle> cStyles = mTextDocument.getContentDom().getAutomaticStyles().getAllStyles().iterator(); while (cStyles.hasNext()) { OdfStyle cStyle = cStyles.next();
private StyleEngineForIText processStyles( OdfDocument odfDocument, PdfOptions options ) throws Exception { StyleEngineForIText styleEngine = new StyleEngineForIText( odfDocument, options ); OdfStylesDom stylesDom = odfDocument.getStylesDom(); OdfContentDom contentDom = odfDocument.getContentDom(); // 1.1) Parse // styles.xml//office:document-styles/office:styles stylesDom.getOfficeStyles().accept( styleEngine ); // 1.2) Parse // styles.xml//office:document-styles/office:automatic-styles stylesDom.getAutomaticStyles().accept( styleEngine ); // 1.3) Parse // content.xml//office:document-content/office:automatic-styles contentDom.getAutomaticStyles().accept( styleEngine ); return styleEngine; }
OdfNumberStyle style = mCellElement.getAutomaticStyles().getNumberStyle(name); if (style == null) { style = mDocument.getDocumentStyles().getNumberStyle(name); OdfNumberDateStyle style = mCellElement.getAutomaticStyles().getDateStyle(name); if (style == null) { style = mDocument.getDocumentStyles().getDateStyle(name); OdfNumberCurrencyStyle dataStyle = mCellElement.getAutomaticStyles().getCurrencyStyle(name); if (dataStyle == null) { dataStyle = mDocument.getDocumentStyles().getCurrencyStyle(name); OdfNumberPercentageStyle style = mCellElement.getAutomaticStyles().getPercentageStyle(name); if (style == null) { style = mDocument.getDocumentStyles().getPercentageStyle(name);
private OdfStyle getStyleByName(String name) { OdfStyle styleElement = null; OdfOfficeAutomaticStyles styles = mCellElement.getAutomaticStyles(); styleElement = styles.getStyle(name, OdfStyleFamily.TableCell); if (styleElement == null) { styleElement = mDocument.getDocumentStyles().getStyle(name, OdfStyleFamily.TableCell); } return styleElement; }
OdfOfficeAutomaticStyles autoStyles = getContentDom().getAutomaticStyles(); NodeList stylesList = autoStyles.getChildNodes(); OdfContentDom contentDom = getContentDom(); XPath xpath = contentDom.getXPath(); autoStyles.removeChild(removeStyles.get(i));
styles = contentDocument.getAutomaticStyles(); OdfOfficeStyles documentStyles = doc.getDocumentStyles(); listStyle = styles.getListStyle(DEFAULT_NAME); listStyle = styles.newListStyle(); paragraphStyle = styles.newStyle(OdfStyleFamily.Paragraph);