Examples of OdfStylesDom


Examples of org.odftoolkit.odfdom.dom.OdfStylesDom

  @Test
  public void testStylesDom() {
    try {
      Document odfdoc = Document.loadDocument(ResourceUtilities.getAbsolutePath(TEST_FILE));

      OdfStylesDom stylesDom = odfdoc.getStylesDom();
      Assert.assertNotNull(stylesDom);

      // test styles.xml:styles
      OdfOfficeStyles styles = odfdoc.getDocumentStyles();
      Assert.assertNotNull(styles);

      Assert.assertNotNull(styles.getDefaultStyle(OdfStyleFamily.Graphic));
      Assert.assertNotNull(styles.getDefaultStyle(OdfStyleFamily.Paragraph));
      Assert.assertNotNull(styles.getDefaultStyle(OdfStyleFamily.Table));
      Assert.assertNotNull(styles.getDefaultStyle(OdfStyleFamily.TableRow));

      OdfStyle style = styles.getStyle("Standard", OdfStyleFamily.Paragraph);
      Assert.assertNotNull(style);
      Assert.assertEquals(style.getStyleClassAttribute(), "text");

      style = styles.getStyle("List", OdfStyleFamily.Paragraph);
      Assert.assertNotNull(style);
      Assert.assertEquals(style.getProperty(StyleTextPropertiesElement.FontNameComplex), "Tahoma1");
      Assert.assertTrue(style.hasProperty(StyleTextPropertiesElement.FontNameComplex));
      Assert.assertFalse(style.hasProperty(StyleTextPropertiesElement.FontNameAsian));

      Assert.assertNull(styles.getStyle("foobar", OdfStyleFamily.Chart));

      // test styles.xml:automatic-styles
      OdfOfficeAutomaticStyles autostyles = stylesDom.getAutomaticStyles();
      Assert.assertNotNull(autostyles);

      OdfStylePageLayout pageLayout = autostyles.getPageLayout("pm1");
      Assert.assertNotNull(pageLayout);
      Assert.assertEquals(pageLayout.getProperty(StylePageLayoutPropertiesElement.PageWidth), "8.5in");
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfStylesDom

    if (existingDom == null) {
      // ToDo: bug 264 - register OdfFileDom to this class
      if (packagePath.equals("content.xml") || packagePath.endsWith("/content.xml")) {
        newFileDom = new OdfContentDom((OdfSchemaDocument) packageDocument, packagePath);
      } else if (packagePath.equals("styles.xml") || packagePath.endsWith("/styles.xml")) {
        newFileDom = new OdfStylesDom((OdfSchemaDocument) packageDocument, packagePath);
      } else if (packagePath.equals("meta.xml") || packagePath.endsWith("/meta.xml")) {
        newFileDom = new OdfMetaDom((OdfSchemaDocument) packageDocument, packagePath);
      } else if (packagePath.equals("settings.xml") || packagePath.endsWith("/settings.xml")) {
        newFileDom = new OdfSettingsDom((OdfSchemaDocument) packageDocument, packagePath);
      } else {
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfStylesDom

  @Test
  public void testStylesDom() {
    try {
      OdfDocument odfdoc = OdfDocument.loadDocument(ResourceUtilities.getAbsolutePath(TEST_FILE));

      OdfStylesDom stylesDom = odfdoc.getStylesDom();
      Assert.assertNotNull(stylesDom);

      // test styles.xml:styles
      OdfOfficeStyles styles = odfdoc.getDocumentStyles();
      Assert.assertNotNull(styles);

      Assert.assertNotNull(styles.getDefaultStyle(OdfStyleFamily.Graphic));
      Assert.assertNotNull(styles.getDefaultStyle(OdfStyleFamily.Paragraph));
      Assert.assertNotNull(styles.getDefaultStyle(OdfStyleFamily.Table));
      Assert.assertNotNull(styles.getDefaultStyle(OdfStyleFamily.TableRow));

      OdfStyle style = styles.getStyle("Standard", OdfStyleFamily.Paragraph);
      Assert.assertNotNull(style);
      Assert.assertEquals(style.getStyleClassAttribute(), "text");

      style = styles.getStyle("List", OdfStyleFamily.Paragraph);
      Assert.assertNotNull(style);
      Assert.assertEquals(style.getProperty(StyleTextPropertiesElement.FontNameComplex), "Tahoma1");
      Assert.assertTrue(style.hasProperty(StyleTextPropertiesElement.FontNameComplex));
      Assert.assertFalse(style.hasProperty(StyleTextPropertiesElement.FontNameAsian));

      Assert.assertNull(styles.getStyle("foobar", OdfStyleFamily.Chart));

      // test styles.xml:automatic-styles
      OdfOfficeAutomaticStyles autostyles = stylesDom.getAutomaticStyles();
      Assert.assertNotNull(autostyles);

      OdfStylePageLayout pageLayout = autostyles.getPageLayout("pm1");
      Assert.assertNotNull(pageLayout);
      Assert.assertEquals(pageLayout.getProperty(StylePageLayoutPropertiesElement.PageWidth), "8.5in");
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfStylesDom

  @Test
  public void testSetDefaultCellStyle() {
    OdfSpreadsheetDocument outputDocument;
    OdfContentDom contentDom; // the document object model for content.xml
    OdfStylesDom stylesDom; // the document object model for styles.xml
    // the office:automatic-styles element in content.xml
    OdfOfficeAutomaticStyles contentAutoStyles;
    // the office:styles element in styles.xml
    OdfOfficeStyles stylesOfficeStyles;
    OdfStyle style;
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfStylesDom

    if (existingDom == null) {
      // ToDo: bug 264 - register OdfFileDom to this class
      if (packagePath.equals("content.xml") || packagePath.endsWith("/content.xml")) {
        newFileDom = new OdfContentDom((OdfSchemaDocument) packageDocument, packagePath);
      } else if (packagePath.equals("styles.xml") || packagePath.endsWith("/styles.xml")) {
        newFileDom = new OdfStylesDom((OdfSchemaDocument) packageDocument, packagePath);
      } else if (packagePath.equals("meta.xml") || packagePath.endsWith("/meta.xml")) {
        newFileDom = new OdfMetaDom((OdfSchemaDocument) packageDocument, packagePath);
      } else if (packagePath.equals("settings.xml") || packagePath.endsWith("/settings.xml")) {
        newFileDom = new OdfSettingsDom((OdfSchemaDocument) packageDocument, packagePath);
      } else {
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfStylesDom

      search = new TextNavigation("ReplaceDateTarget", doc);
      // count the initial date field count. should be 1.
      OdfContentDom contentDom = doc.getContentDom();
      NodeList nodeList = contentDom.getElementsByTagName(TextDateElement.ELEMENT_NAME.getQName());
      int i = nodeList.getLength();
      OdfStylesDom styleDom = doc.getStylesDom();
      nodeList = styleDom.getElementsByTagName(TextDateElement.ELEMENT_NAME.getQName());
      i += nodeList.getLength();
      // replace all the 3 "ReplaceDateTarget" to FixedDateField.
      while (search.hasNext()) {
        TextSelection item = (TextSelection) search.nextSelection();
        FieldSelection fieldSelection = new FieldSelection(item);
        fieldSelection.replaceWithSimpleField(Field.FieldType.FIXED_DATE_FIELD);
        i++;
      }
      nodeList = contentDom.getElementsByTagName(TextDateElement.ELEMENT_NAME.getQName());
      int j = nodeList.getLength();
      nodeList = styleDom.getElementsByTagName(TextDateElement.ELEMENT_NAME.getQName());
      j += nodeList.getLength();
      Assert.assertEquals(j, i);
      doc.save(ResourceUtilities.newTestOutputFile(SAVE_FILE_REPLACE));
    } catch (Exception e) {
      Logger.getLogger(FieldSelectionTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfStylesDom

      simpleVariableField.updateField("true", varParagraph);
      // count the initial date field count.
      OdfContentDom contentDom = doc.getContentDom();
      NodeList nodeList = contentDom.getElementsByTagName(TextConditionalTextElement.ELEMENT_NAME.getQName());
      int i = nodeList.getLength();
      OdfStylesDom styleDom = doc.getStylesDom();
      nodeList = styleDom.getElementsByTagName(TextConditionalTextElement.ELEMENT_NAME.getQName());
      i += nodeList.getLength();
      // replace all the 2 "ReplaceConditionTarget" to ConditionField.
      while (search.hasNext()) {
        TextSelection item = (TextSelection) search.nextSelection();
        FieldSelection fieldSelection = new FieldSelection(item);
        fieldSelection.replaceWithConditionField("test_con_variable == \"true\"", "trueText", "falseText");
        i++;
      }
      nodeList = contentDom.getElementsByTagName(TextConditionalTextElement.ELEMENT_NAME.getQName());
      int j = nodeList.getLength();
      nodeList = styleDom.getElementsByTagName(TextConditionalTextElement.ELEMENT_NAME.getQName());
      j += nodeList.getLength();
      Assert.assertEquals(j, i);
      doc.save(ResourceUtilities.newTestOutputFile(SAVE_FILE_REPLACE));
    } catch (Exception e) {
      Logger.getLogger(FieldSelectionTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfStylesDom

      // count the initial date field count. should be 1.
      OdfContentDom contentDom = doc.getContentDom();
      NodeList nodeList = contentDom.getElementsByTagName(TextConditionalTextElement.ELEMENT_NAME.getQName());
      int i = nodeList.getLength();
      OdfStylesDom styleDom = doc.getStylesDom();
      nodeList = styleDom.getElementsByTagName(TextConditionalTextElement.ELEMENT_NAME.getQName());
      i += nodeList.getLength();
      // replace all the 2 "ReplaceHiddenTextTarget" to HiddenTextField.
      while (search.hasNext()) {
        TextSelection item = (TextSelection) search.nextSelection();
        FieldSelection fieldSelection = new FieldSelection(item);
        fieldSelection.replaceWithHiddenTextField("test_con_variable == \"true\"", "hiddenText");
        i++;
      }
      nodeList = contentDom.getElementsByTagName(TextConditionalTextElement.ELEMENT_NAME.getQName());
      int j = nodeList.getLength();
      nodeList = styleDom.getElementsByTagName(TextConditionalTextElement.ELEMENT_NAME.getQName());
      j += nodeList.getLength();
      Assert.assertEquals(j, i);
    } catch (Exception e) {
      Logger.getLogger(FieldSelectionTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
      Assert.fail("Failed with " + e.getClass().getName() + ": '" + e.getMessage() + "'");
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfStylesDom

      ReferenceField referenceField = Fields.createReferenceField(newTextSpanElement, "selection-test-ref");
      // count the initial reference field count.
      OdfContentDom contentDom = doc.getContentDom();
      NodeList nodeList = contentDom.getElementsByTagName(TextReferenceRefElement.ELEMENT_NAME.getQName());
      int i = nodeList.getLength();
      OdfStylesDom styleDom = doc.getStylesDom();
      nodeList = styleDom.getElementsByTagName(TextReferenceRefElement.ELEMENT_NAME.getQName());
      i += nodeList.getLength();
      // replace all the 2 "ReplaceReferenceTarget" to ReferenceField.
      while (search.hasNext()) {
        TextSelection item = (TextSelection) search.nextSelection();
        FieldSelection fieldSelection = new FieldSelection(item);
        fieldSelection.replaceWithReferenceField(referenceField, DisplayType.TEXT);
        i++;
      }
      nodeList = contentDom.getElementsByTagName(TextReferenceRefElement.ELEMENT_NAME.getQName());
      int j = nodeList.getLength();
      nodeList = styleDom.getElementsByTagName(TextReferenceRefElement.ELEMENT_NAME.getQName());
      j += nodeList.getLength();
      Assert.assertEquals(j, i);
      doc.save(ResourceUtilities.newTestOutputFile(SAVE_FILE_REPLACE));
    } catch (Exception e) {
      Logger.getLogger(FieldSelectionTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfStylesDom

      VariableField userVariableField = Fields.createUserVariableField(doc, "selection_user_variable", "test");
      // count the initial variable field count.
      OdfContentDom contentDom = doc.getContentDom();
      NodeList nodeList = contentDom.getElementsByTagName(TextUserFieldGetElement.ELEMENT_NAME.getQName());
      int i = nodeList.getLength();
      OdfStylesDom styleDom = doc.getStylesDom();
      nodeList = styleDom.getElementsByTagName(TextUserFieldGetElement.ELEMENT_NAME.getQName());
      i += nodeList.getLength();
      // replace all the 3 "SelectionUserVariableTarget" to VariableField.
      while (search.hasNext()) {
        TextSelection item = (TextSelection) search.nextSelection();
        FieldSelection fieldSelection = new FieldSelection(item);
        fieldSelection.replaceWithVariableField(userVariableField);
        i++;
      }
      nodeList = contentDom.getElementsByTagName(TextUserFieldGetElement.ELEMENT_NAME.getQName());
      int j = nodeList.getLength();
      nodeList = styleDom.getElementsByTagName(TextUserFieldGetElement.ELEMENT_NAME.getQName());
      j += nodeList.getLength();
      Assert.assertEquals(j, i);
      doc.save(ResourceUtilities.newTestOutputFile(SAVE_FILE_REPLACE));
    } catch (Exception e) {
      Logger.getLogger(FieldSelectionTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
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.