Package org.odftoolkit.odfdom.dom.element.style

Examples of org.odftoolkit.odfdom.dom.element.style.StyleMasterPageElement


   */
  public Header getHeader(boolean isFirstPage) {
    Header tmpHeader = isFirstPage ? firstPageHeader : standardHeader;
    if (tmpHeader == null) {
      try {
        StyleMasterPageElement masterPageElement = getMasterPage(isFirstPage);
        StyleHeaderElement headerElement = OdfElement.findFirstChildNode(StyleHeaderElement.class,
            masterPageElement);
        if (headerElement == null) {
          headerElement = masterPageElement.newStyleHeaderElement();
        }
        tmpHeader = new Header(headerElement);
      } catch (Exception e) {
        Logger.getLogger(TextDocument.class.getName()).log(Level.SEVERE, null, e);
      }
View Full Code Here


   */
  public Footer getFooter(boolean isFirstPage) {
    Footer tmpFooter = isFirstPage ? firstPageFooter : standardFooter;
    if (tmpFooter == null) {
      try {
        StyleMasterPageElement masterPageElement = getMasterPage(isFirstPage);
        StyleFooterElement footerElement = OdfElement.findFirstChildNode(StyleFooterElement.class,
            masterPageElement);
        if (footerElement == null) {
          footerElement = masterPageElement.newStyleFooterElement();
        }
        tmpFooter = new Footer(footerElement);
      } catch (Exception e) {
        Logger.getLogger(TextDocument.class.getName()).log(Level.SEVERE, null, e);
      }
View Full Code Here

      NodeList list = getStylesDom().getElementsByTagName("office:master-styles");
      if (list.getLength() > 0) {
        OdfOfficeMasterStyles officeMasterStyles = (OdfOfficeMasterStyles) list.item(0);
        // Get back the StylePageLayoutName
        for (int i = 0; i < officeMasterStyles.getLength(); i++) {
          StyleMasterPageElement syleMasterPage = (StyleMasterPageElement) officeMasterStyles.item(i);
          if(syleMasterPage.getStyleNameAttribute().equals("Standard")){         
            stylePageLayoutName = syleMasterPage.getStylePageLayoutNameAttribute();
            break;
          }
        }
        // Allows to know if StylePageLayoutName is unique
        for (int i = 0; i < officeMasterStyles.getLength(); i++) {
          StyleMasterPageElement syleMasterPage = (StyleMasterPageElement) officeMasterStyles.item(i);
          if(syleMasterPage.getStylePageLayoutNameAttribute().equals(stylePageLayoutName)){         
            pageLayoutNameCount++;
          }
        }
      }
     
      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);
View Full Code Here

    OfficeMasterStylesElement masterStyles = OdfElement.findFirstChildNode(OfficeMasterStylesElement.class,
        rootElement);
    if (masterStyles == null) {
      masterStyles = rootElement.newOfficeMasterStylesElement();
    }
    StyleMasterPageElement masterPageEle = null;
    NodeList lastMasterPages = masterStyles.getElementsByTagNameNS(OdfDocumentNamespace.STYLE.getUri(),
        "master-page");
    if (lastMasterPages != null && lastMasterPages.getLength() > 0) {
      for (int i = 0; i < lastMasterPages.getLength(); i++) {
        StyleMasterPageElement masterPage = (StyleMasterPageElement) lastMasterPages.item(i);
        String styleName = masterPage.getStyleNameAttribute();
        if (pageStyleName.equals(styleName)) {
          masterPageEle = masterPage;
          break;
        }
      }
View Full Code Here

      OdfElement contentRoot = OdfElement.findFirstChildNode(OdfElement.class, officeBody);
      tableList = fillTableList(contentRoot, tableList);
     
      // find tables from styles.xml (header & footer)
      Map<String, StyleMasterPageElement> masterPages = getMasterPages();
      StyleMasterPageElement defaultMasterPage = masterPages.get("Standard");
      if (defaultMasterPage != null) {
        tableList = fillTableList(defaultMasterPage, tableList);
      }
    } catch (Exception ex) {
      Logger.getLogger(OdfSchemaDocument.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here

    if (masterStyles != null) {
      NodeList lstMasterPages = stylesDoc.getElementsByTagNameNS(OdfDocumentNamespace.STYLE.getUri(), "master-page");
      if (lstMasterPages != null && lstMasterPages.getLength() > 0) {
        masterPages = new HashMap();
        for (int i = 0; i < lstMasterPages.getLength(); i++) {
          StyleMasterPageElement masterPage = (StyleMasterPageElement) lstMasterPages.item(i); //Take the node from the list
          //ToDo: Drop Attribute Suffix for methods returning String values and NOT Attributes
          String styleName = masterPage.getStyleNameAttribute();
          masterPages.put(styleName, masterPage);
        }
      }
    }
    return masterPages;
View Full Code Here

   * @param styleNameValue  the <code>String</code> value of <code>StyleNameAttribute</code>, see {@odf.attribute  style:name} at specification
   * @param stylePageLayoutNameValue  the <code>String</code> value of <code>StylePageLayoutNameAttribute</code>, see {@odf.attribute  style:page-layout-name} at specification
   * @return the element {@odf.element style:master-page}
   */
   public StyleMasterPageElement newStyleMasterPageElement(String styleNameValue, String stylePageLayoutNameValue) {
    StyleMasterPageElement styleMasterPage = ((OdfFileDom) this.ownerDocument).newOdfElement(StyleMasterPageElement.class);
    styleMasterPage.setStyleNameAttribute(styleNameValue);
    styleMasterPage.setStylePageLayoutNameAttribute(stylePageLayoutNameValue);
    this.appendChild(styleMasterPage);
    return styleMasterPage;
  }
View Full Code Here

      builder.append(contentDomExtractor.getText());

      //Extract text from style.xml
      OdfStylesDom styleDom = mDocument.getStylesDom();
      if (styleDom != null) {
        StyleMasterPageElement masterpage = null;
        NodeList list = styleDom.getElementsByTagName("style:master-page");
        if (list.getLength() > 0) {
          masterpage = (StyleMasterPageElement) list.item(0);
        }
        if (masterpage != null) {
View Full Code Here

        {
            mHandoutMaster = (StyleHandoutMasterElement)node;
        }
        else if( node instanceof StyleMasterPageElement )
        {
            StyleMasterPageElement masterPage = (StyleMasterPageElement)node;
           
            if( mMasterPages == null )
                mMasterPages = new HashMap< String, StyleMasterPageElement >();
           
            mMasterPages.put( masterPage.getStyleNameAttribute(), masterPage );
        }
    }
View Full Code Here

        }
        else if( node instanceof StyleMasterPageElement )
        {
            if( mMasterPages != null )
            {
                StyleMasterPageElement masterPage = (StyleMasterPageElement)node;
                mMasterPages.remove( masterPage.getStyleNameAttribute() );           
            }
        }
    }   
View Full Code Here

TOP

Related Classes of org.odftoolkit.odfdom.dom.element.style.StyleMasterPageElement

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.