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

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


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


   */
  private void setWesternLanguage(Locale locale) throws Exception {
    if (getScriptType(locale) != ScriptType.WESTERN)
      return;

    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(OdfTextProperties.Language)) {
View Full Code Here

  private Locale getDefaultLanguageByProperty(OdfStyleProperty countryProp, OdfStyleProperty languageProp)
      throws Exception {
    String lang = null, ctry = null;

    OdfOfficeStyles styles = getStylesDom().getOfficeStyles();

    // get language and country setting from default style setting for
    // paragraph
    OdfDefaultStyle defaultStyle = styles.getDefaultStyle(OdfStyleFamily.Paragraph);
    if (defaultStyle != null) {
      if (defaultStyle.hasProperty(countryProp) && defaultStyle.hasProperty(languageProp)) {
        ctry = defaultStyle.getProperty(countryProp);
        lang = defaultStyle.getProperty(languageProp);
        return new Locale(lang, ctry);
      }
    }
    // if no default style setting for paragraph
    // get language and country setting from other default style settings
    Iterable<OdfDefaultStyle> defaultStyles = styles.getDefaultStyles();
    Iterator<OdfDefaultStyle> itera = defaultStyles.iterator();
    while (itera.hasNext()) {
      OdfDefaultStyle style = itera.next();
      if (style.hasProperty(countryProp) && style.hasProperty(languageProp)) {
        ctry = style.getProperty(countryProp);
View Full Code Here

        && !user_language.equals(Locale.TRADITIONAL_CHINESE.getLanguage())
        && !user_language.equals(Locale.JAPANESE.getLanguage())
        && !user_language.equals(Locale.KOREAN.getLanguage()))
      return;

    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(OdfTextProperties.LanguageAsian)) {
View Full Code Here

   * @throws Exception
   */
  private void setDefaultComplexLanguage(Locale locale) throws Exception {
    if (getScriptType(locale) != ScriptType.CTL)
      return;
    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(OdfTextProperties.LanguageComplex)) {
View Full Code Here

      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);
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

      if (autoStyles != null) {
        style = autoStyles.getListStyle(listName);
      }

      if (style == null) {
        OdfOfficeStyles styles = ((OdfSchemaDocument) fileDom.getDocument()).getDocumentStyles();
        if (styles != null) {
          style = styles.getListStyle(listName);
        }
      }
    } else {
      // if no style is specified at this particular list element, we
      // ask the parent list (if any)
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

  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

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.