Exemplo n.º 1
0
  private void generateTOC() {
    if (myNCXTOCFileName != null) {
      final NCXReader ncxReader = new NCXReader(myModelReader);
      if (ncxReader.readFile(myFilePrefix + myNCXTOCFileName)) {
        final Map<Integer, NCXReader.NavPoint> navigationMap = ncxReader.navigationMap();
        if (!navigationMap.isEmpty()) {
          int level = 0;
          for (NCXReader.NavPoint point : navigationMap.values()) {
            final BookModel.Label label = getTOCLabel(point.ContentHRef);
            int index = (label != null) ? label.ParagraphIndex : -1;
            while (level > point.Level) {
              myModelReader.endContentsParagraph();
              --level;
            }
            while (++level <= point.Level) {
              myModelReader.beginContentsParagraph(-2);
              myModelReader.addContentsData(Dots);
              myModelReader.addPathData(Dots);
            }
            myModelReader.beginContentsParagraph(index);
            myModelReader.addContentsData(point.Text.toCharArray());
            myModelReader.addPathData(point.ContentHRef.toCharArray());
          }
          while (level > 0) {
            myModelReader.endContentsParagraph();
            --level;
          }
          return;
        }
      }
    }

    for (Reference ref : myTourTOC.isEmpty() ? myGuideTOC : myTourTOC) {
      final BookModel.Label label = getTOCLabel(ref.HRef);
      if (label != null) {
        final int index = label.ParagraphIndex;
        if (index != -1) {
          myModelReader.beginContentsParagraph(index);
          myModelReader.addContentsData(ref.Title.toCharArray());
          myModelReader.addPathData(ref.HRef.toCharArray());
          myModelReader.endContentsParagraph();
        }
      }
    }
  }
Exemplo n.º 2
0
 @Override
 public void namespaceMapChangedHandler(Map<String, String> namespaceMap) {
   myOPFSchemePrefix = null;
   for (Map.Entry<String, String> entry : namespaceMap.entrySet()) {
     if (OpenPackagingFormat.equals(entry.getValue())) {
       myOPFSchemePrefix = entry.getKey() + ":";
       break;
     }
   }
 }