Examples of OdfStylesDom


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

    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 if (packagePath.equals("META-INF/manifest.xml") || packagePath.endsWith("/META-INF/manifest.xml")) {
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfStylesDom

      StyleStyleElement parent = styles.newStyleStyleElement("text","TheParent");
      parent.setStyleFamilyAttribute(OdfStyleFamily.Paragraph.toString());

      parent.setProperty(StyleTextPropertiesElement.FontSize, "17pt");
      parent.setProperty(StyleTextPropertiesElement.Color, "#FF0000");
      OdfStylesDom stylesDom = textDoc.getStylesDom();
      XPath xpath = stylesDom.getXPath();
      StyleStyleElement styleTest = (StyleStyleElement) xpath.evaluate("//style:style[last()]", stylesDom, XPathConstants.NODE);
      Assert.assertEquals(styleTest, parent);
      textDoc.save(ResourceUtilities.newTestOutputFile("CreatChildrenForStyles.odt"));

    } catch (Exception e) {
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfStylesDom

  }

  private Map<String, StyleMasterPageElement> getMasterPages(OdfDocument doc) throws Exception {
 
    OdfStylesDom stylesDoc = doc.getStylesDom();
    OfficeMasterStylesElement masterStyles = OdfElement.findFirstChildNode(OfficeMasterStylesElement.class, stylesDoc.getRootElement());
    Map<String, StyleMasterPageElement> masterPages = null;
    if (masterStyles != null) {
      NodeList lstMasterPages = stylesDoc.getElementsByTagNameNS(OdfDocumentNamespace.STYLE.getUri(), "master-page");
      if (lstMasterPages != null && lstMasterPages.getLength() > 0) {
        masterPages = new HashMap<String, StyleMasterPageElement>();
        for (int i = 0; i < lstMasterPages.getLength(); i++) {
          StyleMasterPageElement masterPage = (StyleMasterPageElement) lstMasterPages.item(i); //Take the node from the list
          // ODFDOM ToDo?: Drop Attribute Suffix for methods returning String values and NOT Attributes
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.OdfStylesDom

  public void testStyleUsageCount() {
    try {
      OdfOfficeAutomaticStyles s = odfdoc.getStylesDom().getAutomaticStyles();
      OdfStyle pr1 = s.getStyle("pr1", OdfStyleFamily.Presentation);
      int styleUserCount = pr1.getStyleUserCount();
      OdfStylesDom stylesDom = odfdoc.getStylesDom();
      XPath xpath = stylesDom.getXPath();
      NodeList elementsWithStyle = (NodeList) xpath.evaluate("//draw:frame[@presentation:style-name='pr1']",
          stylesDom, XPathConstants.NODESET);
      int elementsWithStyleCount = elementsWithStyle.getLength();
      Assert.assertTrue(styleUserCount == elementsWithStyleCount);
//      //#bug51,the bug will be induced by using set attribute method
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
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.