Package com.adobe.dp.epub.util

Examples of com.adobe.dp.epub.util.TOCLevel


  }

  public void generateTOCFromHeadings(Stack headings, int depth) {
    if (elementName.startsWith("h") && elementName.length() == 2 && Character.isDigit(elementName.charAt(1))) {
      int headingLevel = elementName.charAt(1) - '0';
      TOCLevel level;
      while (true) {
        level = (TOCLevel) headings.pop();
        if (headings.isEmpty() || level.getHeadingLevel() < headingLevel) {
          headings.push(level);
          break;
        }
      }
      if (headings.size() < depth + 1) {
        String title = getText();
        TOCEntry entry = new TOCEntry(title, getSelfRef());
        level.getTOCEntry().add(entry);
        TOCLevel myLevel = new TOCLevel(headingLevel, entry);
        headings.push(myLevel);
      }
    }
    super.generateTOCFromHeadings(headings, depth);
  }
View Full Code Here


  public void generateTOCFromHeadings(int depth) {
    TOCEntry entry = getTOC().getRootTOCEntry();
    entry.removeAll();
    Iterator spine = spine();
    Stack headings = new Stack();
    headings.push(new TOCLevel(0, entry));
    while (spine.hasNext()) {
      Resource r = (Resource) spine.next();
      if (r instanceof OPSResource)
        ((OPSResource) r).generateTOCFromHeadings(headings, depth);
    }
View Full Code Here

    public void addTocEntry(String title, int headingLevel, Element dstElem) {
        TOCEntry te = getToc().createTOCEntry(title, dstElem.getSelfRef());
        boolean found = false;
        for (int j = getTocEntriesBuffer().size() - 1; j >= 0; j--) {

            TOCLevel target = getTocEntriesBuffer().get(j);
            if (target.getHeadingLevel() < headingLevel) {
                target.getTOCEntry().add(te);
                found = true;
                break;
            }
        }
        if (!found) {
            getToc().getRootTOCEntry().add(te);
        }
        getTocEntriesBuffer().add(new TOCLevel(headingLevel, te));

    }
View Full Code Here

TOP

Related Classes of com.adobe.dp.epub.util.TOCLevel

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.