Examples of OdfOfficeMasterStyles


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

  /*
   * Return the matched text might exist in header/footer.
   */
  private TextSelection findInHeaderFooter(TextSelection selected) {
    OdfFileDom styledom = null;
    OdfOfficeMasterStyles masterpage = null;
    OdfElement element = null;

    if (selected != null) {
      OdfElement containerElement = selected.getContainerElement();
      int index = selected.getIndex();
View Full Code Here

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

    try {
      String stylePageLayoutName = null;
      int pageLayoutNameCount = 0;
      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());
                }
              }
View Full Code Here

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

  }

  //the matched text might exist in header/footer
  private TextSelection findInHeaderFooter(TextSelection selected) {
    OdfFileDom styledom = null;
    OdfOfficeMasterStyles masterpage = null;
    OdfElement element = null;

    if (selected != null) {
      OdfElement containerElement = selected.getContainerElement();
      int index = selected.getIndex();
View Full Code Here

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

  }

  //the matched text might exist in header/footer
  private TextSelection findInHeaderFooter(TextSelection selected) {
    OdfFileDom styledom = null;
    OdfOfficeMasterStyles masterpage = null;
    OdfElement element = null;

    if (selected != null) {
      OdfElement containerElement = selected.getContainerElement();
      int index = selected.getIndex();
View Full Code Here

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

  }

  @Test
  public void testMasterStyles() {
    try {
      OdfOfficeMasterStyles officeMasterStyles = odfdoc.getOfficeMasterStyles();
      Assert.assertNotNull(officeMasterStyles);

      // check if iterator has all two master pages
      testIterator(StyleMasterPageElement.class, officeMasterStyles.getMasterPages(), 2);

      // test "master-name-1"
      StyleMasterPageElement master = officeMasterStyles.getMasterPage("master-name-1");
      Assert.assertNotNull(master);
      Assert.assertEquals(master.getStyleNameAttribute(), "master-name-1");

      // test "master-name-2"
      master = officeMasterStyles.getMasterPage("master-name-2");
      Assert.assertNotNull(master);
      Assert.assertEquals(master.getStyleNameAttribute(), "master-name-2");

      // test handout master
      Assert.assertNotNull(officeMasterStyles.getHandoutMaster());

      // test layerset
      Assert.assertNotNull(officeMasterStyles.getLayerSet());
    } catch (Exception e) {
      Logger.getLogger(PresentationTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here

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

   * @throws Exception
   *             if the style DOM cannot be initialized
   */
  public static MasterPage getOrCreateMasterPage(Document doc, String name)
      throws Exception {
    OdfOfficeMasterStyles officeMasterStyles = doc.getOfficeMasterStyles();
    StyleMasterPageElement master = officeMasterStyles.getMasterPage(name);
    if (master == null) {
      master = doc.getStylesDom().newOdfElement(
          StyleMasterPageElement.class);
      master.setStyleNameAttribute(name);
      officeMasterStyles.appendChild(master);
    }
    return new MasterPage(master);
  }
View Full Code Here

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

  /*
   * Return the matched text might exist in header/footer.
   */
  private TextSelection findInHeaderFooter(TextSelection selected) {
    OdfFileDom styledom = null;
    OdfOfficeMasterStyles masterpage = null;
    OdfElement element = null;

    if (selected != null) {
      OdfElement containerElement = selected.getContainerElement();
      int index = selected.getIndex();
View Full Code Here

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

  }

  @Test
  public void testMasterStyles() {
    try {
      OdfOfficeMasterStyles officeMasterStyles = odfdoc.getOfficeMasterStyles();
      Assert.assertNotNull(officeMasterStyles);

      // check if iterator has all two master pages
      testIterator(StyleMasterPageElement.class, officeMasterStyles.getMasterPages(), 2);

      // test "master-name-1"
      StyleMasterPageElement master = officeMasterStyles.getMasterPage("master-name-1");
      Assert.assertNotNull(master);
      Assert.assertEquals(master.getStyleNameAttribute(), "master-name-1");

      // test "master-name-2"
      master = officeMasterStyles.getMasterPage("master-name-2");
      Assert.assertNotNull(master);
      Assert.assertEquals(master.getStyleNameAttribute(), "master-name-2");

      // test handout master
      Assert.assertNotNull(officeMasterStyles.getHandoutMaster());

      // test layerset
      Assert.assertNotNull(officeMasterStyles.getLayerSet());
    } catch (Exception e) {
      Logger.getLogger(PresentationTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here

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

    try {
      String stylePageLayoutName = null;
      int pageLayoutNameCount = 0;
      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());
                }
              }
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.