Package org.odftoolkit.odfdom.incubator.doc.office

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


   *            - an instance of Locale that the default complex language and
   *            country will be set to.
   * @throws Exception
   */
  private void setDefaultComplexLanguage(Locale locale) throws Exception {
    OdfOfficeStyles styles = getStylesDom().getOfficeStyles();
    Iterable<OdfDefaultStyle> defaultStyles = styles.getDefaultStyles();
    if (defaultStyles != null) {
      Iterator<OdfDefaultStyle> itera = defaultStyles.iterator();
      while (itera.hasNext()) {
        OdfDefaultStyle style = itera.next();
        if (style.getFamily().getProperties().contains(
View Full Code Here


  private void setSlideLayout(DrawPageElement page,
      OdfSlide.SlideLayout slideLayout) {
    if (slideLayout == null) {
      slideLayout = OdfSlide.SlideLayout.BLANK;
    }
    OdfOfficeStyles styles = getOrCreateDocumentStyles();
    String layoutName;

    if (slideLayout.toString().equals(OdfSlide.SlideLayout.TITLE_ONLY.toString())) {
      layoutName = "AL1T" + makeUniqueName();
      try {
        StylePresentationPageLayoutElement layout = styles.newStylePresentationPageLayoutElement(layoutName);
        layout.newPresentationPlaceholderElement("title", "2.058cm", "1.743cm", "23.91cm", "3.507cm");
      } catch (Exception e1) {
        Logger.getLogger(OdfPresentationDocument.class.getName()).log(Level.SEVERE, null, e1);
      }
      page.setPresentationPresentationPageLayoutNameAttribute(layoutName);

      DrawFrameElement frame1 = page.newDrawFrameElement();
      frame1.setProperty(StyleGraphicPropertiesElement.StyleShadow, "true");
      frame1.setProperty(StyleGraphicPropertiesElement.AutoGrowHeight, "true");
      frame1.setProperty(StyleGraphicPropertiesElement.MinHeight, "3.507");
      frame1.setPresentationStyleNameAttribute(frame1.getStyleName());

      frame1.setDrawLayerAttribute("layout");
      frame1.setSvgHeightAttribute("3.006cm");
      frame1.setSvgWidthAttribute("24.299cm");
      frame1.setSvgXAttribute("1.35cm");
      frame1.setSvgYAttribute("0.717cm");
      frame1.setPresentationClassAttribute(PresentationClassAttribute.Value.TITLE.toString());
      frame1.setPresentationPlaceholderAttribute(true);
      frame1.newDrawTextBoxElement();
    } else if (slideLayout.toString().equals(OdfSlide.SlideLayout.TITLE_OUTLINE.toString())) {
      layoutName = makeUniqueName();
      try {
        styles = super.getStylesDom().getOfficeStyles();
        if (styles == null) {
          styles = super.getStylesDom().newOdfElement(OdfOfficeStyles.class);
        }
        StylePresentationPageLayoutElement layout = styles.newStylePresentationPageLayoutElement(layoutName);
        layout.newPresentationPlaceholderElement("title", "2.058cm", "1.743cm", "23.91cm", "3.507cm");
        layout.newPresentationPlaceholderElement("outline", "2.058cm", "1.743cm", "23.91cm", "3.507cm");

      } catch (Exception e1) {
        Logger.getLogger(OdfPresentationDocument.class.getName()).log(Level.SEVERE, null, e1);
      }
      page.setPresentationPresentationPageLayoutNameAttribute(layoutName);


      DrawFrameElement frame1 = page.newDrawFrameElement();
      frame1.setProperty(StyleGraphicPropertiesElement.StyleShadow, "true");
      frame1.setProperty(StyleGraphicPropertiesElement.AutoGrowHeight, "true");
      frame1.setProperty(StyleGraphicPropertiesElement.MinHeight, "3.507");
      frame1.setPresentationStyleNameAttribute(frame1.getStyleName());

      frame1.setDrawLayerAttribute("layout");
      frame1.setSvgHeightAttribute("3.006cm");
      frame1.setSvgWidthAttribute("24.299cm");
      frame1.setSvgXAttribute("1.35cm");
      frame1.setSvgYAttribute("0.717cm");
      frame1.setPresentationClassAttribute(PresentationClassAttribute.Value.TITLE.toString());
      frame1.setPresentationPlaceholderAttribute(true);
      frame1.newDrawTextBoxElement();
      DrawFrameElement frame2 = page.newDrawFrameElement();

      frame2.setProperty(StyleGraphicPropertiesElement.FillColor, "#ffffff");
      frame2.setProperty(StyleGraphicPropertiesElement.MinHeight, "13.114");
      frame2.setPresentationStyleNameAttribute(frame2.getStyleName());

      frame2.setDrawLayerAttribute("layout");
      frame2.setSvgHeightAttribute("11.629cm");
      frame2.setSvgWidthAttribute("24.199cm");
      frame2.setSvgXAttribute("1.35cm");
      frame2.setSvgYAttribute("4.337cm");
      frame2.setPresentationClassAttribute(PresentationClassAttribute.Value.OUTLINE.toString());
      frame2.setPresentationPlaceholderAttribute(true);
      frame2.newDrawTextBoxElement();
    } else if (slideLayout.toString().equals(OdfSlide.SlideLayout.TITLE_PLUS_TEXT.toString())) {
      layoutName = makeUniqueName();
      try {
        styles = super.getStylesDom().getOfficeStyles();
        if (styles == null) {
          styles = super.getStylesDom().newOdfElement(OdfOfficeStyles.class);
        }
        StylePresentationPageLayoutElement layout = styles.newStylePresentationPageLayoutElement(layoutName);
        layout.newPresentationPlaceholderElement("title", "2.058cm", "1.743cm", "23.91cm", "1.743cm");
        layout.newPresentationPlaceholderElement("subtitle", "2.058cm", "5.838cm", "23.91cm", "13.23cm");

      } catch (Exception e1) {
        Logger.getLogger(OdfPresentationDocument.class.getName()).log(Level.SEVERE, null, e1);
      }
      page.setPresentationPresentationPageLayoutNameAttribute(layoutName);

      DrawFrameElement frame1 = page.newDrawFrameElement();
      frame1.setProperty(StyleGraphicPropertiesElement.AutoGrowHeight, "true");
      frame1.setProperty(StyleGraphicPropertiesElement.MinHeight, "3.507");
      frame1.setPresentationStyleNameAttribute(frame1.getStyleName());

      frame1.setDrawLayerAttribute("layout");
      frame1.setSvgHeightAttribute("3.006cm");
      frame1.setSvgWidthAttribute("24.299cm");
      frame1.setSvgXAttribute("1.35cm");
      frame1.setSvgYAttribute("0.717cm");
      frame1.setPresentationClassAttribute(PresentationClassAttribute.Value.TITLE.toString());
      frame1.setPresentationPlaceholderAttribute(true);
      frame1.newDrawTextBoxElement();
      DrawFrameElement frame2 = page.newDrawFrameElement();
      frame2.setProperty(StyleGraphicPropertiesElement.AutoGrowHeight, "true");
      frame2.setProperty(StyleGraphicPropertiesElement.MinHeight, "3.507");
      frame2.setPresentationStyleNameAttribute(frame2.getStyleName());

      frame2.setDrawLayerAttribute("layout");
      frame2.setSvgHeightAttribute("11.88cm");
      frame2.setSvgWidthAttribute("24.299cm");
      frame2.setSvgXAttribute("1.35cm");
      frame2.setSvgYAttribute("4.712cm");
      frame2.setPresentationClassAttribute(PresentationClassAttribute.Value.SUBTITLE.toString());
      frame2.setPresentationPlaceholderAttribute(true);
      frame2.newDrawTextBoxElement();

    } else if (slideLayout.toString().equals(OdfSlide.SlideLayout.TITLE_PLUS_2_TEXT_BLOCK.toString())) {

      layoutName = makeUniqueName();
      try {
        styles = super.getStylesDom().getOfficeStyles();
        if (styles == null) {
          styles = super.getStylesDom().newOdfElement(OdfOfficeStyles.class);
        }
        StylePresentationPageLayoutElement layout = styles.newStylePresentationPageLayoutElement(layoutName);
        layout.newPresentationPlaceholderElement("outline", "2.058cm", "1.743cm", "23.91cm", "1.743cm");
        layout.newPresentationPlaceholderElement("outline", "1.35cm", "4.212cm", "11.857cm", "11.629cm");
        layout.newPresentationPlaceholderElement("outline", "4.212cm", "13.8cm", "11.857cm", "11.629cm");

      } catch (Exception e1) {
View Full Code Here

    @Test
    public void testLoadSave() {
        try {
            OdfDocument odfDocument = OdfDocument.loadDocument(ResourceUtilities.getAbsolutePath(SOURCE));
            OdfOfficeStyles styles = odfDocument.getDocumentStyles();
            Assert.assertNotNull(styles);
            OdfStyle standardStyle = styles.getStyle("Standard", OdfStyleFamily.Paragraph);
            standardStyle.setProperty(StyleParagraphPropertiesElement.MarginLeft, "4711");
            odfDocument.save(ResourceUtilities.newTestOutputFile(TARGET));
            odfDocument = OdfDocument.loadDocument(ResourceUtilities.getAbsolutePath(TARGET));
            styles = odfDocument.getDocumentStyles();
            standardStyle = styles.getStyle("Standard", OdfStyleFamily.Paragraph);
            String marginLeft = standardStyle.getProperty(StyleParagraphPropertiesElement.MarginLeft);
           
            Assert.assertTrue(marginLeft != null && marginLeft.equals("4711"));
        } catch (Exception e) {
            Logger.getLogger(StyleManipulationTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
View Full Code Here

  @Test
  public void testCreatChildrenForStyles() {
    try {
      OdfDocument textDoc = OdfTextDocument.newTextDocument();

      OdfOfficeStyles styles = textDoc.getOrCreateDocumentStyles();
      StyleDefaultStyleElement def = styles.newStyleDefaultStyleElement("text");
      def.setStyleFamilyAttribute(OdfStyleFamily.Paragraph.toString());
      def.setProperty(StyleTextPropertiesElement.TextUnderlineColor, "#00FF00");

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

    }
  }

  // todo: rename after newName rid of deprecated getDocumentStyle()
  private OdfStyle getOfficeStyle() {
    OdfOfficeStyles styles = this.mOdfSchemaDocument.getDocumentStyles();
    if (styles != null) {
      return styles.getStyle(getStyleName(), getStyleFamily());
    } else {
      return null;
    }
  }
View Full Code Here

  }

  @Test
  public void testStyles() {
    try {
      OdfOfficeStyles officeStyles = odfdoc.getDocumentStyles();
      Assert.assertNotNull(officeStyles);

      Assert.assertNotNull(officeStyles.getGradient("Linear_20_blue_2f_white"));
      testIterator(DrawGradientElement.class, officeStyles.getGradients().iterator(), 1);

      Assert.assertNotNull(officeStyles.getMarker("Arrow"));
      testIterator(DrawMarkerElement.class, officeStyles.getMarker().iterator(), 1);

      Assert.assertNotNull(officeStyles.getHatch("Black_20_0_20_Degrees"));
      testIterator(DrawHatchElement.class, officeStyles.getHatches().iterator(), 1);

      Assert.assertNotNull(officeStyles.getFillImage("Aqua"));
      testIterator(DrawFillImageElement.class, officeStyles.getFillImages().iterator(), 1);

      // check for some styles
      Assert.assertNotNull(officeStyles.getDefaultStyle(OdfStyleFamily.Graphic));
      Assert.assertNotNull(officeStyles.getStyle("standard", OdfStyleFamily.Graphic));
      Assert.assertNotNull(officeStyles.getStyle("master-name-1-outline1", OdfStyleFamily.Presentation));

      Iterator<OdfStyle> style_iter = officeStyles.getStylesForFamily(OdfStyleFamily.Presentation).iterator();
      Assert.assertNotNull(style_iter);
      Assert.assertTrue(style_iter.hasNext());
    } catch (Exception e) {
      Logger.getLogger(PresentationTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
      Assert.fail(e.getMessage());
View Full Code Here

    @Test
    public void testCloneNode() {
        try {
            OdfDocument doc = OdfTextDocument.newTextDocument();
            OdfOfficeStyles styles = doc.getOrCreateDocumentStyles();

            OdfStyle p1 = styles.newStyle("P1", OdfStyleFamily.Paragraph);
            p1.setProperty(StyleTextPropertiesElement.FontSize, "42pt");

            OdfStyle clone = (OdfStyle) p1.cloneNode(true);
            clone.setStyleNameAttribute("p1-clone");
            styles.appendChild(clone);

            OdfStyle p1clone = styles.getStyle("p1-clone", OdfStyleFamily.Paragraph);
            Assert.assertNotNull(p1clone);
            Assert.assertEquals(p1clone.getProperty(StyleTextPropertiesElement.FontSize), p1.getProperty(StyleTextPropertiesElement.FontSize));
        } catch (Exception e) {
            Logger.getLogger(ElementTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
            Assert.fail("Failed with " + e.getClass().getName() + ": '" + e.getMessage() + "'");
View Full Code Here

    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;
    String noaaDateStyleName;
    String noaaTempStyleName;

    try {
View Full Code Here

    @Test
    public void testEquals() {
        try {
            OdfDocument doc = OdfTextDocument.newTextDocument();
            OdfOfficeStyles styles = doc.getOrCreateDocumentStyles();

            OdfStyle p1 = styles.newStyle("P1", OdfStyleFamily.Paragraph);
            p1.setProperty(StyleTextPropertiesElement.FontSize, "42pt");
            OdfStyle p2 = styles.newStyle("P2", OdfStyleFamily.Paragraph);
            p2.setProperty(StyleTextPropertiesElement.FontSize, "42pt");
            OdfStyle p3 = styles.newStyle("P3", OdfStyleFamily.Paragraph);
            p3.setProperty(StyleTextPropertiesElement.FontSize, "13pt");

            OdfTextListStyle l1 = styles.newListStyle("L1");
            Assert.assertTrue(p1.equals(p1));
            Assert.assertTrue(p1.equals(p2));
            Assert.assertTrue(p2.equals(p1));
            Assert.assertFalse(p1.equals(p3));
            Assert.assertFalse(p3.equals(p1));
View Full Code Here

    @Test
    public void testPropertyInheritance() {
        try {
            OdfDocument doc = OdfTextDocument.newTextDocument();

            OdfOfficeStyles styles = doc.getOrCreateDocumentStyles();

            OdfDefaultStyle def = styles.getOrCreateDefaultStyle(OdfStyleFamily.Paragraph);
            def.setProperty(StyleTextPropertiesElement.TextUnderlineColor, "#00FF00");

            OdfStyle parent = styles.newStyle("TheParent", OdfStyleFamily.Paragraph);
            parent.setProperty(StyleTextPropertiesElement.FontSize, "17pt");
            parent.setProperty(StyleTextPropertiesElement.Color, "#FF0000");

            OdfStyle child = styles.newStyle("TheChild", OdfStyleFamily.Paragraph);
            child.setStyleParentStyleNameAttribute(parent.getStyleNameAttribute());

            Assert.assertEquals("17pt", child.getProperty(StyleTextPropertiesElement.FontSize));
            Assert.assertEquals("#FF0000", child.getProperty(StyleTextPropertiesElement.Color));
            Assert.assertEquals("#00FF00", child.getProperty(StyleTextPropertiesElement.TextUnderlineColor));
View Full Code Here

TOP

Related Classes of org.odftoolkit.odfdom.incubator.doc.office.OdfOfficeStyles

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.