Examples of OdfStylePageLayout


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

    try {
      automaticStyles = getOwnerDocument(container).getStylesDom().getAutomaticStyles();
    } catch (Exception e) {
      Logger.getLogger(Table.class.getName()).log(Level.SEVERE,  e.getMessage(), e);
    }
    OdfStylePageLayout pageLayout = automaticStyles.getPageLayout("pm1");
    if (pageLayout == null) {
      pageLayout = automaticStyles.getPageLayout("Mpm1");
    }
    if (pageLayout != null) {
      pageWidthStr = pageLayout.getProperty(StylePageLayoutPropertiesElement.PageWidth);
      if (pageWidthStr != null) {
        pageWidth = Length.parseDouble(pageWidthStr, Unit.CENTIMETER);
      }
      // margins
      double dLeftPageMargin = 0;
      double dRightPageMargin = 0;
      String leftPageMargin = pageLayout.getProperty(StylePageLayoutPropertiesElement.MarginLeft);
      String rightPageMargin = pageLayout.getProperty(StylePageLayoutPropertiesElement.MarginRight);
      if (leftPageMargin != null && rightPageMargin != null) {
        dLeftPageMargin = Length.parseDouble(leftPageMargin, Unit.CENTIMETER);
        dRightPageMargin = Length.parseDouble(rightPageMargin, Unit.CENTIMETER);
      }
      tableWidth = (pageWidth - (dLeftPageMargin + dRightPageMargin + marginLeft + marginRight)) / 2.5399;
View Full Code Here

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

      // 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");
      Assert.assertEquals(pageLayout.getProperty(StylePageLayoutPropertiesElement.PageHeight), "11in");

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

    } catch (Exception e) {
      LOG.log(Level.SEVERE, e.getMessage(), e);
View Full Code Here

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

        }
      }
     
      OdfOfficeAutomaticStyles autoStyles = getStylesDom().getAutomaticStyles();
      int autoStylesCount = autoStyles.getLength();     
      OdfStylePageLayout pageLayout = autoStyles.getPageLayout(stylePageLayoutName);
      if(pageLayout != null) {
        // Clone the OdfStylePageLayout if another master style possesses the same name before modifying its properties
        if(pageLayoutNameCount > 1){
          Node pageLayoutNew = pageLayout.cloneNode(true);         
          // Rename the style of the clone before modifying its properties
          String oldPageLayoutName = pageLayout.getStyleNameAttribute();
          pageLayout.setStyleNameAttribute("Mpm" + (autoStylesCount+1));
          // Allocate the new name of the style to the master style (the cloned style)
          if (list.getLength() > 0) {
            OdfOfficeMasterStyles masterpage = (OdfOfficeMasterStyles) list.item(0);
            for (int i = 0; i < masterpage.getLength(); i++) {
              StyleMasterPageElement vSyleMasterPage = (StyleMasterPageElement) masterpage.item(i);
              if(vSyleMasterPage.getStyleNameAttribute().equals("Standard")){
                if(vSyleMasterPage.getStylePageLayoutNameAttribute().equals(oldPageLayoutName)){         
                  vSyleMasterPage.setStylePageLayoutNameAttribute(pageLayout.getStyleNameAttribute());
                }
              }
            }
          }
          autoStyles.appendChild(pageLayoutNew);
        }
        NodeList vListStlePageLprop = pageLayout.getElementsByTagName("style:page-layout-properties");
        StylePageLayoutPropertiesElement vStlePageLprop = (StylePageLayoutPropertiesElement) vListStlePageLprop.item(0);
        StyleColumnsElement vStyleColumnsElement = vStlePageLprop.newStyleColumnsElement(columnsNumber);
        vStyleColumnsElement.setFoColumnGapAttribute(vSpacingColumn);
      }
    } catch (Exception e) {
View Full Code Here

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

          break;
        }
      }
    }
    if (masterPageEle == null) {
      OdfStylePageLayout layout = OdfElement.findFirstChildNode(OdfStylePageLayout.class, getStylesDom()
          .getAutomaticStyles());
      masterPageEle = masterStyles.newStyleMasterPageElement(pageStyleName, layout.getStyleNameAttribute());
    }
    return masterPageEle;
  }
View Full Code Here

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

      // 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");
      Assert.assertEquals(pageLayout.getProperty(StylePageLayoutPropertiesElement.PageHeight), "11in");

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

    } catch (Exception e) {
      LOG.log(Level.SEVERE, e.getMessage(), e);
View Full Code Here

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

    try {
      automaticStyles = getOwnerDocument(container).getStylesDom().getAutomaticStyles();
    } catch (Exception e) {
      Logger.getLogger(Table.class.getName()).log(Level.SEVERE,  e.getMessage(), e);
    }
    OdfStylePageLayout pageLayout = automaticStyles.getPageLayout("pm1");
    if (pageLayout == null) {
      pageLayout = automaticStyles.getPageLayout("Mpm1");
    }
    if (pageLayout != null) {
      pageWidthStr = pageLayout.getProperty(StylePageLayoutPropertiesElement.PageWidth);
      if (pageWidthStr != null) {
        pageWidth = Length.parseDouble(pageWidthStr, Unit.CENTIMETER);
      }
      // margins
      double dLeftPageMargin = 0;
      double dRightPageMargin = 0;
      String leftPageMargin = pageLayout.getProperty(StylePageLayoutPropertiesElement.MarginLeft);
      String rightPageMargin = pageLayout.getProperty(StylePageLayoutPropertiesElement.MarginRight);
      if (leftPageMargin != null && rightPageMargin != null) {
        dLeftPageMargin = Length.parseDouble(leftPageMargin, Unit.CENTIMETER);
        dRightPageMargin = Length.parseDouble(rightPageMargin, Unit.CENTIMETER);
      }
      tableWidth = (pageWidth - (dLeftPageMargin + dRightPageMargin + marginLeft + marginRight)) / 2.5399;
View Full Code Here

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

  }

  @Override
  protected void onOdfNodeInserted(OdfElement node, Node refNode) {
    if (node instanceof OdfStylePageLayout) {
      OdfStylePageLayout pageLayout = (OdfStylePageLayout) node;
      if (mPageLayouts == null) {
        mPageLayouts = new HashMap<String, OdfStylePageLayout>();
      }

      mPageLayouts.put(pageLayout.getStyleNameAttribute(), pageLayout);
    } else {
      mStylesBaseImpl.onOdfNodeInserted(node, refNode);
    }
  }
View Full Code Here

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

  @Override
  protected void onOdfNodeRemoved(OdfElement node) {
    if (node instanceof OdfStylePageLayout) {
      if (mPageLayouts != null) {
        OdfStylePageLayout pageLayout = (OdfStylePageLayout) node;
        mPageLayouts.remove(pageLayout.getStyleNameAttribute());
      }
    } else {
      mStylesBaseImpl.onOdfNodeRemoved(node);
    }
  }
View Full Code Here

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

      // 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");
      Assert.assertEquals(pageLayout.getProperty(StylePageLayoutPropertiesElement.PageHeight), "11in");

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

    } catch (Exception e) {
      LOG.log(Level.SEVERE, e.getMessage(), e);
View Full Code Here

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

    Assert.assertEquals(masterPage.getName(), masterName);
    Assert.assertNotNull(master);

    // check page layout style
    String pageLayoutName = master.getStylePageLayoutNameAttribute();
    OdfStylePageLayout pageLayout = master.getAutomaticStyles()
        .getPageLayout(pageLayoutName);
    Assert.assertNotNull(pageLayout);

    // check page layout properties
    StylePageLayoutPropertiesElement properties = (StylePageLayoutPropertiesElement) pageLayout
        .getPropertiesElement(OdfStylePropertiesSet.PageLayoutProperties);
    Assert.assertNotNull(properties);
    // page width
    checkDoubleValue(masterPage.getPageWidth(), properties
        .getFoPageWidthAttribute());
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.