Examples of OdfOfficeAutomaticStyles


Examples of org.odftoolkit.odfdom.incubator.doc.office.OdfOfficeAutomaticStyles

  private void updateTableToNone(Table table) {
    OdfFileDom dom = (OdfFileDom) getTableContainerElement().getOwnerDocument();
    TableTableElement tableEle = table.getOdfElement();
    String stylename = tableEle.getStyleName();
    OdfOfficeAutomaticStyles styles = null;
    if (dom instanceof OdfContentDom) {
      styles = ((OdfContentDom) dom).getAutomaticStyles();
    } else if (dom instanceof OdfStylesDom) {
      styles = ((OdfStylesDom) dom).getAutomaticStyles();
    }
    OdfStyle tableStyle = styles.getStyle(stylename, OdfStyleFamily.Table);
    tableStyle.setProperty(StyleTablePropertiesElement.Shadow, "none");
    NodeList cells = tableEle.getElementsByTagNameNS(OdfDocumentNamespace.TABLE.getUri(), "table-cell");
    if (cells != null && cells.getLength() > 0) {
      OdfStyle cellStyleWithoutBorder = styles.newStyle(OdfStyleFamily.TableCell);
      cellStyleWithoutBorder.setProperty(StyleTableCellPropertiesElement.Border, "none");
      cellStyleWithoutBorder.removeProperty(StyleTableCellPropertiesElement.Padding);
      String cellStyleName = cellStyleWithoutBorder.getStyleNameAttribute();
      for (int i = 0; i < cells.getLength(); i++) {
        TableTableCellElement cell = (TableTableCellElement) cells.item(i);
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.office.OdfOfficeAutomaticStyles

    NodeList nodeList = footerEle.getElementsByTagName(TextPElement.ELEMENT_NAME.getQName());
    for (int i = 0; i < nodeList.getLength(); i++) {
      TextPElement textEle = (TextPElement) nodeList.item(i);
      String stylename = textEle.getStyleName();
      OdfFileDom dom = (OdfFileDom) footerEle.getOwnerDocument();
      OdfOfficeAutomaticStyles styles = null;
      if (dom instanceof OdfContentDom) {
        styles = ((OdfContentDom) dom).getAutomaticStyles();
      } else if (dom instanceof OdfStylesDom) {
        styles = ((OdfStylesDom) dom).getAutomaticStyles();
      }
     
      OdfStyle newStyle = styles.newStyle(OdfStyleFamily.Paragraph);
      OdfStyle style = styles.getStyle(stylename, OdfStyleFamily.Paragraph);
      if (style != null) {
        String styleName = newStyle.getStyleNameAttribute();
        styles.removeChild(newStyle);
        newStyle = (OdfStyle) style.cloneNode(true);
        newStyle.setStyleNameAttribute(styleName);
        styles.appendChild(newStyle);
      }
      if (isVisible) {
        if (newStyle.hasProperty(StyleTextPropertiesElement.Display)) {
          newStyle.removeProperty(StyleTextPropertiesElement.Display);
        }
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.office.OdfOfficeAutomaticStyles

  private void updateTableToNone(Table table) {
    OdfFileDom dom = (OdfFileDom) getTableContainerElement().getOwnerDocument();
    TableTableElement tableEle = table.getOdfElement();
    String stylename = tableEle.getStyleName();
    OdfOfficeAutomaticStyles styles = null;
    if (dom instanceof OdfContentDom) {
      styles = ((OdfContentDom) dom).getAutomaticStyles();
    } else if (dom instanceof OdfStylesDom) {
      styles = ((OdfStylesDom) dom).getAutomaticStyles();
    }
    OdfStyle tableStyle = styles.getStyle(stylename, OdfStyleFamily.Table);
    tableStyle.setProperty(StyleTablePropertiesElement.Shadow, "none");
    NodeList cells = tableEle.getElementsByTagNameNS(OdfDocumentNamespace.TABLE.getUri(), "table-cell");
    if (cells != null && cells.getLength() > 0) {
      OdfStyle cellStyleWithoutBorder = styles.newStyle(OdfStyleFamily.TableCell);
      cellStyleWithoutBorder.setProperty(StyleTableCellPropertiesElement.Border, "none");
      cellStyleWithoutBorder.removeProperty(StyleTableCellPropertiesElement.Padding);
      String cellStyleName = cellStyleWithoutBorder.getStyleNameAttribute();
      for (int i = 0; i < cells.getLength(); i++) {
        TableTableCellElement cell = (TableTableCellElement) cells.item(i);
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.office.OdfOfficeAutomaticStyles

    DcDateElement dcDateElement = annotationElement.newDcDateElement();
    dcDateElement.setTextContent(dcDate);
    TextPElement notePElement = annotationElement.newTextPElement();
    TextSpanElement noteSpanElement = notePElement.newTextSpanElement();
    // set comment style
    OdfOfficeAutomaticStyles styles = null;
    if (dom instanceof OdfContentDom) {
      styles = ((OdfContentDom) dom).getAutomaticStyles();
    } else if (dom instanceof OdfStylesDom) {
      styles = ((OdfStylesDom) dom).getAutomaticStyles();
    }
    OdfStyle textStyle = styles.newStyle(OdfStyleFamily.Text);
    StyleTextPropertiesElement styleTextPropertiesElement = textStyle.newStyleTextPropertiesElement(null);
    styleTextPropertiesElement.setStyleFontNameAttribute("Tahoma");
    styleTextPropertiesElement.setFoFontSizeAttribute("10pt");
    styleTextPropertiesElement.setStyleFontNameAsianAttribute("Lucida Sans Unicode");
    styleTextPropertiesElement.setStyleFontSizeAsianAttribute("12pt");
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.office.OdfOfficeAutomaticStyles

      // Add frame and image element
      TextPElement paraLast = (TextPElement) xpath.evaluate("//text:p[last()]", contentDom, XPathConstants.NODE);
      addImageToDocument(contentDom, paraLast);

      // Access/Update automatic styles
      OdfOfficeAutomaticStyles autoStyles = embDoc.getContentDom().getAutomaticStyles();
      OdfStyle autoStyle = autoStyles.getStyle("P1", OdfStyleFamily.Paragraph);
      Assert.assertEquals(autoStyle.getStyleNameAttribute(), "P1");
      Assert.assertEquals(autoStyle.getFamilyName(), "paragraph");

      // Access/Update styles.xml
      OdfStyle documentStyle = embDoc.getDocumentStyles().getStyle("myStyle", OdfStyleFamily.Paragraph);
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.office.OdfOfficeAutomaticStyles

    DcDateElement dcDateElement = annotationElement.newDcDateElement();
    dcDateElement.setTextContent(dcDate);
    TextPElement notePElement = annotationElement.newTextPElement();
    TextSpanElement noteSpanElement = notePElement.newTextSpanElement();
    // set comment style
    OdfOfficeAutomaticStyles styles = null;
    if (dom instanceof OdfContentDom) {
      styles = ((OdfContentDom) dom).getAutomaticStyles();
    } else if (dom instanceof OdfStylesDom) {
      styles = ((OdfStylesDom) dom).getAutomaticStyles();
    }
    OdfStyle textStyle = styles.newStyle(OdfStyleFamily.Text);
    StyleTextPropertiesElement styleTextPropertiesElement = textStyle.newStyleTextPropertiesElement(null);
    styleTextPropertiesElement.setStyleFontNameAttribute("Tahoma");
    styleTextPropertiesElement.setFoFontSizeAttribute("10pt");
    styleTextPropertiesElement.setStyleFontNameAsianAttribute("Lucida Sans Unicode");
    styleTextPropertiesElement.setStyleFontSizeAsianAttribute("12pt");
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.office.OdfOfficeAutomaticStyles

   *         yet exists, a new one is inserted into the dom and returned.
   *
   */
  public OdfOfficeAutomaticStyles getOrCreateAutomaticStyles() {

    OdfOfficeAutomaticStyles automaticStyles = getAutomaticStyles();
    if (automaticStyles == null) {
      automaticStyles = newOdfElement(OdfOfficeAutomaticStyles.class);

      Node parent = getFirstChild();

View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.office.OdfOfficeAutomaticStyles

  @Test
  public void testSetDefaultCellStyle() {
    SpreadsheetDocument outputDocument;
    OdfContentDom contentDom; // the document object model for content.xml
    // the office:automatic-styles element in content.xml
    OdfOfficeAutomaticStyles contentAutoStyles;
    OdfStyle style;
    String noaaDateStyleName;
    String noaaTempStyleName;

    try {
      outputDocument = SpreadsheetDocument.newSpreadsheetDocument();
      contentDom = outputDocument.getContentDom();
      contentAutoStyles = contentDom.getOrCreateAutomaticStyles();

      OdfNumberDateStyle dateStyle = new OdfNumberDateStyle(contentDom, "yyyy-MM-dd", "numberDateStyle", null);
      OdfNumberStyle numberStyle = new OdfNumberStyle(contentDom, "#0.00", "numberTemperatureStyle");

      contentAutoStyles.appendChild(dateStyle);
      contentAutoStyles.appendChild(numberStyle);

      style = contentAutoStyles.newStyle(OdfStyleFamily.TableCell);
      noaaDateStyleName = style.getStyleNameAttribute();
      style.setStyleDataStyleNameAttribute("numberDateStyle");

      // and for time cells
      style = contentAutoStyles.newStyle(OdfStyleFamily.TableCell);
      noaaTempStyleName = style.getStyleNameAttribute();
      style.setStyleDataStyleNameAttribute("numberTemperatureStyle");
      style.setProperty(StyleParagraphPropertiesElement.TextAlign, "end");

      Table table = Table.newTable(outputDocument);
      List<Column> columns = table.insertColumnsBefore(0, 3);
      Column column = columns.get(0);
      column.setDefaultCellStyle(contentAutoStyles.getStyle(noaaDateStyleName, OdfStyleFamily.TableCell));
      Cell aCell = column.getCellByIndex(0);
      aCell.setValueType("date");
      String format = aCell.getFormatString();
      Assert.assertEquals("yyyy-MM-dd", format);

      List<Row> rows = table.insertRowsBefore(0, 1);
      Row row = rows.get(0);
      row.setDefaultCellStyle(contentAutoStyles.getStyle(noaaTempStyleName, OdfStyleFamily.TableCell));
      Cell bCell = row.getCellByIndex(0);
      bCell.setValueType("float");
      String bformat = bCell.getFormatString();
      Assert.assertEquals("#0.00", bformat);
      Assert.assertEquals("end", bCell.getHorizontalAlignment());
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.office.OdfOfficeAutomaticStyles

    return datadisplayStylename;
  }

  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;
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.office.OdfOfficeAutomaticStyles

    return unique_name;
  }

  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;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.