Examples of TextTableOfContentElement


Examples of org.odftoolkit.odfdom.dom.element.text.TextTableOfContentElement

   *
   * @param textNameValue  the <code>String</code> value of <code>TextNameAttribute</code>, see {@odf.attribute  text:name} at specification
   * @return the element {@odf.element text:table-of-content}
   */
   public TextTableOfContentElement newTextTableOfContentElement(String textNameValue) {
    TextTableOfContentElement textTableOfContent = ((OdfFileDom) this.ownerDocument).newOdfElement(TextTableOfContentElement.class);
    textTableOfContent.setTextNameAttribute(textNameValue);
    this.appendChild(textTableOfContent);
    return textTableOfContent;
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.text.TextTableOfContentElement

   *
   * @param textNameValue  the <code>String</code> value of <code>TextNameAttribute</code>, see {@odf.attribute  text:name} at specification
   * @return the element {@odf.element text:table-of-content}
   */
   public TextTableOfContentElement newTextTableOfContentElement(String textNameValue) {
    TextTableOfContentElement textTableOfContent = ((OdfFileDom) this.ownerDocument).newOdfElement(TextTableOfContentElement.class);
    textTableOfContent.setTextNameAttribute(textNameValue);
    this.appendChild(textTableOfContent);
    return textTableOfContent;
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.text.TextTableOfContentElement

   *
   * @param textNameValue  the <code>String</code> value of <code>TextNameAttribute</code>, see {@odf.attribute  text:name} at specification
   * @return the element {@odf.element text:table-of-content}
   */
   public TextTableOfContentElement newTextTableOfContentElement(String textNameValue) {
    TextTableOfContentElement textTableOfContent = ((OdfFileDom) this.ownerDocument).newOdfElement(TextTableOfContentElement.class);
    textTableOfContent.setTextNameAttribute(textNameValue);
    this.appendChild(textTableOfContent);
    return textTableOfContent;
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.text.TextTableOfContentElement

   *            TOC after the reference paragraph.
   * @since 0.8.6
   */
  public TextTableOfContentElement createDefaultTOC(Paragraph refParagraph, boolean before) {
   
    TextTableOfContentElement textTableOfContent =null;
    if(refParagraph==null){
      Logger.getLogger(TextDocument.class.getName()).log(Level.SEVERE,
          "Failed to create Default TOC, The refParagraph where the TOC be inserted is null");
      throw new RuntimeException("Failed to create Default TOC, The refParagraph where the TOC be inserted is null");
    }
    Node refparagraphNode = refParagraph.getOdfElement();
    Node rootNode = refparagraphNode.getParentNode();   
    try {
      OdfContentDom content = getContentDom();
      textTableOfContent = content
          .newOdfElement(TextTableOfContentElement.class);
      textTableOfContent.setTextNameAttribute("Table of Contents");
      textTableOfContent.setTextProtectedAttribute(true);
      TextTableOfContentSourceElement textTableOfContentSource = textTableOfContent
          .newTextTableOfContentSourceElement();
      textTableOfContentSource.setTextOutlineLevelAttribute(10);
      textTableOfContentSource.setTextUseIndexMarksAttribute(true);
      TextIndexTitleTemplateElement textIndexTitleTemplate = textTableOfContentSource
          .newTextIndexTitleTemplateElement();
      textIndexTitleTemplate
          .setTextStyleNameAttribute("Contents_20_Heading");
      textIndexTitleTemplate.setTextContent("Table of Contents");
      for (int i = 1; i <= 10; i++) {
        TextTableOfContentEntryTemplateElement textTableOfContentEntryTemplate = textTableOfContentSource
            .newTextTableOfContentEntryTemplateElement(i,
                "Contents_20_" + i);
        TextIndexEntryLinkStartElement TextIndexEntryLinkStart = textTableOfContentEntryTemplate
            .newTextIndexEntryLinkStartElement();
        TextIndexEntryLinkStart
            .setTextStyleNameAttribute("Index_20_Link");
        textTableOfContentEntryTemplate
            .newTextIndexEntryChapterElement();
        textTableOfContentEntryTemplate.newTextIndexEntryTextElement();
        TextIndexEntryTabStopElement TextIndexEntryTabStop = textTableOfContentEntryTemplate
            .newTextIndexEntryTabStopElement("right");
        TextIndexEntryTabStop.setStyleLeaderCharAttribute(".");
        textTableOfContentEntryTemplate
            .newTextIndexEntryPageNumberElement();
        textTableOfContentEntryTemplate
            .newTextIndexEntryLinkEndElement();
      }
      TextIndexBodyElement textIndexBody = textTableOfContent
          .newTextIndexBodyElement();
      TextIndexTitleElement TextIndexTitle = textIndexBody
          .newTextIndexTitleElement("Table of Contents_Head");
      TextPElement texp = TextIndexTitle.newTextPElement();
      texp.setTextStyleNameAttribute("Contents_20_Heading");
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.text.TextTableOfContentElement

      Logger.getLogger(TextDocument.class.getName()).log(Level.SEVERE,
          "Failed to create Default TOC, The refParagraph where the TOC be inserted is null");
      throw new RuntimeException("Failed to create Default TOC, The refParagraph where the TOC be inserted is null");
    }
    if (additionalStyle == null) {
      TextTableOfContentElement textTableOfContentElement = createDefaultTOC(refParagraph, before);
      return textTableOfContentElement;
    }
    HashMap<Integer, String> tocstyleList = additionalStyle.getStyle();
    if (tocstyleList.isEmpty()) {
      TextTableOfContentElement textTableOfContentElement =createDefaultTOC(refParagraph, before);
      return textTableOfContentElement;
    }

    Collection<String> tocvalues = tocstyleList.values();
    OdfOfficeStyles docstyles = getOrCreateDocumentStyles();
    Iterable<OdfStyle> paragraphStyles = docstyles
        .getStylesForFamily(OdfStyleFamily.Paragraph);
    ArrayList<String> pstyle = new ArrayList<String>();
    Iterator<OdfStyle> iterator = paragraphStyles.iterator();
    while (iterator.hasNext()) {
      OdfStyle style = iterator.next();
      String name = style.getStyleNameAttribute();
      pstyle.add(name);
    }
    if (!pstyle.containsAll(tocvalues)) {
      Logger.getLogger(TextDocument.class.getName())
          .log(Level.SEVERE,
              "Failed to create TOC with Styles. Some of addtional Styles that you want to include in the TOC can't be found in the document.\n"
                  + tocvalues.toString());
      throw new RuntimeException(
          "Failed to create TOC Styles.Some of addtional Styles that you want to include in the TOC can't be found in the document.");
    }
    TextTableOfContentElement textTableOfContent =null;
    // Additional Styles support
    HashMap<String, Integer> tmptocstyleList = new HashMap<String, Integer>();
    if (!tocstyleList.isEmpty()) {
      Set<Integer> key = tocstyleList.keySet();
      Iterator<Integer> it = key.iterator();
      while (it.hasNext()) {
        Integer textOutlineLevelValue = it.next();
        String textStyleNameValue = tocstyleList
            .get(textOutlineLevelValue);
        tmptocstyleList.put(textStyleNameValue, textOutlineLevelValue);
      }
    }
    // end of Additional Styles support

    Node refparagraphNode = refParagraph.getOdfElement();
    Node rootNode = refparagraphNode.getParentNode();
    try {
      OdfContentDom content = getContentDom();
      textTableOfContent = content
          .newOdfElement(TextTableOfContentElement.class);
      textTableOfContent.setTextNameAttribute("Table of Contents");
      textTableOfContent.setTextProtectedAttribute(true);

      TextTableOfContentSourceElement textTableOfContentSource = textTableOfContent
          .newTextTableOfContentSourceElement();
      textTableOfContentSource.setTextOutlineLevelAttribute(10);
      textTableOfContentSource.setTextUseIndexMarksAttribute(true);
      textTableOfContentSource.setTextUseIndexSourceStylesAttribute(true);
      TextIndexTitleTemplateElement textIndexTitleTemplate = textTableOfContentSource
          .newTextIndexTitleTemplateElement();
      textIndexTitleTemplate
          .setTextStyleNameAttribute("Contents_20_Heading");
      textIndexTitleTemplate.setTextContent("Table of Contents");
      for (int i = 1; i <= 10; i++) {
        TextTableOfContentEntryTemplateElement textTableOfContentEntryTemplate = textTableOfContentSource
            .newTextTableOfContentEntryTemplateElement(i,
                "Contents_20_" + i);
        TextIndexEntryLinkStartElement TextIndexEntryLinkStart = textTableOfContentEntryTemplate
            .newTextIndexEntryLinkStartElement();
        TextIndexEntryLinkStart
            .setTextStyleNameAttribute("Index_20_Link");
        textTableOfContentEntryTemplate
            .newTextIndexEntryChapterElement();
        textTableOfContentEntryTemplate.newTextIndexEntryTextElement();
        TextIndexEntryTabStopElement TextIndexEntryTabStop = textTableOfContentEntryTemplate
            .newTextIndexEntryTabStopElement("right");
        TextIndexEntryTabStop.setStyleLeaderCharAttribute(".");
        textTableOfContentEntryTemplate
            .newTextIndexEntryPageNumberElement();
        textTableOfContentEntryTemplate
            .newTextIndexEntryLinkEndElement();
      }

      if (!tocstyleList.isEmpty()) {
        Set<Integer> key = tocstyleList.keySet();
        Iterator<Integer> it = key.iterator();
        while (it.hasNext()) {
          Integer textOutlineLevelValue = it.next();
          String textStyleNameValue = tocstyleList
              .get(textOutlineLevelValue);
          TextIndexSourceStylesElement textIndexSourceStyles = textTableOfContentSource
              .newTextIndexSourceStylesElement(textOutlineLevelValue);
          textIndexSourceStyles
              .newTextIndexSourceStyleElement(textStyleNameValue);
        }
      }

      TextIndexBodyElement textIndexBody = textTableOfContent
          .newTextIndexBodyElement();
      TextIndexTitleElement TextIndexTitle = textIndexBody
          .newTextIndexTitleElement("Table of Contents_Head");
      TextPElement texp = TextIndexTitle.newTextPElement();
      texp.setTextStyleNameAttribute("Contents_20_Heading");
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.text.TextTableOfContentElement

   *
   * @param textNameValue  the <code>String</code> value of <code>TextNameAttribute</code>, see {@odf.attribute  text:name} at specification
   * @return the element {@odf.element text:table-of-content}
   */
   public TextTableOfContentElement newTextTableOfContentElement(String textNameValue) {
    TextTableOfContentElement textTableOfContent = ((OdfFileDom) this.ownerDocument).newOdfElement(TextTableOfContentElement.class);
    textTableOfContent.setTextNameAttribute(textNameValue);
    this.appendChild(textTableOfContent);
    return textTableOfContent;
  }
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.