Package org.odftoolkit.odfdom.incubator.doc.style

Examples of org.odftoolkit.odfdom.incubator.doc.style.OdfStyle


  }

  // For documentation see OdfAutomaticStyles or OdfStyles.
  void onOdfNodeInserted(OdfElement node, Node refNode) {
    if (node instanceof OdfStyle) {
      OdfStyle style = (OdfStyle) node;
      if (mStyles == null) {
        mStyles = new HashMap<OdfStyleFamily, HashMap<String, OdfStyle>>();
      }

      HashMap<String, OdfStyle> familyMap = mStyles.get(style.getFamily());
      if (familyMap == null) {
        familyMap = new HashMap<String, OdfStyle>();
        mStyles.put(style.getFamily(), familyMap);
      }

      familyMap.put(style.getStyleNameAttribute(), style);
    } else if (node instanceof OdfTextListStyle) {
      OdfTextListStyle listStyle = (OdfTextListStyle) node;
      if (mListStyles == null) {
        mListStyles = new HashMap<String, OdfTextListStyle>();
      }
View Full Code Here


  // For documentation see OdfAutomaticStyles or OdfStyles.
  void onOdfNodeRemoved(OdfElement node) {
    if (node instanceof OdfStyle) {
      if (mStyles != null) {
        OdfStyle style = (OdfStyle) node;
        HashMap<String, OdfStyle> familyMap = mStyles.get(style.getFamily());
        if (familyMap != null) {
          familyMap.remove(style.getStyleNameAttribute());
          if (familyMap.isEmpty()) {
            mStyles.remove(style.getFamily());
          }
        }
      }
    } else if (node instanceof OdfTextListStyle) {
      if (mListStyles != null) {
View Full Code Here

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

      // test content.xml:automatic-styles
      OdfOfficeAutomaticStyles autoStyles = contentDom.getAutomaticStyles();
      Assert.assertNotNull(autoStyles);

      OdfStyle style = autoStyles.getStyle("P1", OdfStyleFamily.Paragraph);
      Assert.assertNotNull(style);
      Assert.assertEquals(style.getStyleNameAttribute(), "P1");
      Assert.assertEquals(style.getStyleParentStyleNameAttribute(), "Text_20_body");
      Assert.assertEquals(style.getStyleListStyleNameAttribute(), "L1");

      style = autoStyles.getStyle("T1", OdfStyleFamily.Text);
      Assert.assertNotNull(style);
      Assert.assertEquals(style.getStyleNameAttribute(), "T1");

      for (OdfStyle testStyle : autoStyles.getStylesForFamily(OdfStyleFamily.Paragraph)) {
        testStyle(testStyle);
      }
View Full Code Here

      if (fileDom instanceof OdfContentDom) {
        autoStyles = ((OdfContentDom) fileDom).getAutomaticStyles();
      } else if (fileDom instanceof OdfStylesDom) {
        autoStyles = ((OdfStylesDom) fileDom).getAutomaticStyles();
      }
      OdfStyle parentStyle = autoStyles.getStyle(testStyle.getStyleParentStyleNameAttribute(), testStyle.getFamily());
      if (parentStyle == null) {
        parentStyle = ((Document) fileDom.getDocument()).getDocumentStyles().getStyle(testStyle.getStyleParentStyleNameAttribute(), testStyle.getFamily());
      }

      Assert.assertNotNull(parentStyle);
View Full Code Here

//      StyleTextPropertiesElement props = OdfElement.findFirstChildNode(StyleTextPropertiesElement.class, styleNode);
//      Assert.assertFalse(props.hasAttribute("style:text-underline-style"));
//      odt.save(ResourceUtilities.newTestOutputFile("saving-is-possible2.odt"));

      // Test3: New ODF 1.2 attribute node should exist
      OdfStyle styleNode2 = odt.getStylesDom().getOfficeStyles().getStyle("bug77", OdfStyleFamily.Graphic);
      StyleGraphicPropertiesElement propsGrapicElement = OdfElement.findFirstChildNode(StyleGraphicPropertiesElement.class, styleNode2);
      Assert.assertTrue("Could not find the attribute svg:opac-capicity. Workaround bug77 did not succeeded!", propsGrapicElement.hasAttribute("svg:stroke-opacity"));
      odt.save(ResourceUtilities.newTestOutputFile("saving-is-possible.odt"));
    } catch (Exception e) {
      LOG.log(Level.SEVERE, e.getMessage(), e);
View Full Code Here

  @Test
  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();
View Full Code Here

    Assert.assertTrue(paragraphNode instanceof TextPElement);

    // check paragraph style
    OdfOfficeAutomaticStyles styles = newDoc.getContentDom()
        .getAutomaticStyles();
    OdfStyle style = styles.getStyle(((TextPElement) paragraphNode)
        .getStyleName(), OdfStyleFamily.Paragraph);
    Assert.assertNotNull(style);

    // check master page style
    String masterName = style.getStyleMasterPageNameAttribute();
    StyleMasterPageElement master = newDoc.getOfficeMasterStyles()
        .getMasterPage(masterName);
    Assert.assertEquals(masterPage.getName(), masterName);
    Assert.assertNotNull(master);
View Full Code Here

  private void validPageBreakExist(TextDocument newDoc, Paragraph paragraph) throws Exception {
    Node paragraphNode = paragraph.getOdfElement().getNextSibling();
    Assert.assertTrue(paragraphNode instanceof TextPElement);
    OdfContentDom contentDocument = newDoc.getContentDom();
    OdfOfficeAutomaticStyles styles = contentDocument.getAutomaticStyles();
    OdfStyle style = styles.getStyle(((TextPElement) paragraphNode).getStyleName(), OdfStyleFamily.Paragraph);
    Assert.assertNotNull(style);
    Node paragraphPropertiesNode = style.getFirstChild();
    Assert.assertNotNull(paragraphPropertiesNode instanceof StyleParagraphPropertiesElement);
    Assert.assertEquals(((StyleParagraphPropertiesElement) paragraphPropertiesNode).getFoBreakBeforeAttribute(),
        "page");
  }
View Full Code Here

    Iterable<OdfStyle> pstyles1 = target1.getStylesDom().getOfficeStyles().getStylesForFamily(OdfStyleFamily.Paragraph);
    Iterator<OdfStyle> ite = pstyles1.iterator();
    int i=0;
    System.out.println("Custom Styles in TestInsertDocumentWithStyleBefore.odt");
    while(ite.hasNext()){
      OdfStyle odfStyle = ite.next();
      String sname = odfStyle.getAttribute("style:name");
      if(sname.startsWith("style"))
      {
        i++;
        System.out.println(sname);
      }
    } 
    Assert.assertEquals(6, i);
    target1.save(ResourceUtilities.newTestOutputFile("TestInsertDocumentWithStyleBefore.odt"));
   
    target2 = TextDocument.loadDocument(ResourceUtilities.getAbsolutePath("TestInsertDocument.odt"));
    Paragraph p2 = target2.getParagraphByIndex(2, true);
    target2.insertContentFromDocumentBefore(src2, p2, false);
   
    Iterable<OdfStyle> pstyles2 = target2.getStylesDom().getOfficeStyles().getStylesForFamily(OdfStyleFamily.Paragraph);
    Iterator<OdfStyle> ite2 = pstyles2.iterator();
    i=0;
    System.out.println("Custom Styles in TestInsertDocumentWithoutStyleBefore.odt");
    while(ite2.hasNext()){
      OdfStyle odfStyle = ite2.next();
      String sname = odfStyle.getAttribute("style:name");
      if(sname.startsWith("style"))
      {
        i++;
        System.out.println(sname);
      }
View Full Code Here

TOP

Related Classes of org.odftoolkit.odfdom.incubator.doc.style.OdfStyle

Copyright © 2018 www.massapicom. 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.