Examples of OdfStylePageLayout


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

     */
    public PageLayoutProperties getPageLayoutPropertiesForWrite()
        throws Exception {
      if (mWritablePageLayoutProperties != null)
        return mWritablePageLayoutProperties;
      OdfStylePageLayout style = getPageLayoutElementForWrite();
      mWritablePageLayoutProperties = PageLayoutProperties
          .getOrCreatePageLayoutProperties(style);
      return mWritablePageLayoutProperties;
    }
View Full Code Here

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

      // TODO: get from default page layout style element
      if (styleName == null || (styleName.equals("")))
        ;

      OdfStylePageLayout styleElement = mOdfElement.getAutomaticStyles()
          .getPageLayout(styleName);

      return styleElement;
    }
View Full Code Here

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

     *             write.
     */
    protected OdfStylePageLayout getWritableStyleElementByName(
        String styleName, boolean isShared) throws Exception {
      boolean createNew = isShared;
      OdfStylePageLayout pageLayout = null;
      OdfOfficeAutomaticStyles styles = mOdfElement.getAutomaticStyles();
      if (styleName == null || (styleName.equals(""))) {
        createNew = true;
        // TODO: get default page layout style
      } else {
        styles = mOdfElement.getAutomaticStyles();
        pageLayout = styles.getPageLayout(styleName);
        if (pageLayout == null || pageLayout.getStyleUserCount() > 1) {
          createNew = true;
        }
      }
      // if style name is null or this style are used by many users,
      // should create a new one.
      if (createNew) {
        OdfStylePageLayout newPageLayout = null;
        if (pageLayout != null) {
          newPageLayout = (OdfStylePageLayout) pageLayout
              .cloneNode(true);
        }
        newPageLayout = (OdfStylePageLayout) mDocument.getStylesDom()
            .newOdfElement(StylePageLayoutElement.class);
        String newname = newUniquePageLayoutName();
        newPageLayout.setStyleNameAttribute(newname);
        styles.appendChild(newPageLayout);
        mOdfElement.setAttributeNS(OdfDocumentNamespace.STYLE.getUri(),
            "style:page-layout-name", newname);
        newPageLayout.addStyleUser(mOdfElement);
        return newPageLayout;
      }
      return pageLayout;
    }
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

      // 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
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.