void readFile(ZLFile file) throws BookReadingException {
   myLocalPathPrefix = MiscUtil.archiveEntryName(MiscUtil.htmlDirectoryPrefix(file));
   try {
     read(file);
   } catch (IOException e) {
     throw new BookReadingException(e, file);
   }
 }
Beispiel #2
0
  boolean readBook(ZLFile file) {
    myFilePrefix = MiscUtil.htmlDirectoryPrefix(file);

    myIdToHref.clear();
    myHtmlFileNames.clear();
    myParagraphIndexList.clear();
    myNCXTOCFileName = null;
    myTourTOC.clear();
    myGuideTOC.clear();
    myState = READ_NONE;

    if (!read(file)) {
      return false;
    }

    myModelReader.setMainTextModel();
    myModelReader.pushKind(FBTextKind.REGULAR);

    int count = 0;
    for (String name : myHtmlFileNames) {
      final ZLFile xhtmlFile = ZLFile.createFileByPath(myFilePrefix + name);
      if (xhtmlFile == null) {
        // NPE fix: null for bad attributes in .opf XML file
        return false;
      }
      if (count++ == 0 && xhtmlFile.getPath().equals(myCoverFileName)) {
        continue;
      }
      final XHTMLReader reader = new XHTMLReader(myModelReader, myFileNumbers);
      final String referenceName =
          reader.getFileAlias(MiscUtil.archiveEntryName(xhtmlFile.getPath()));

      myModelReader.addHyperlinkLabel(referenceName);
      myParagraphIndexList.add(myModelReader.Model.BookTextModel.getParagraphsNumber());
      myTOCLabels.put(referenceName, myModelReader.Model.BookTextModel.getParagraphsNumber());
      reader.readFile(xhtmlFile, referenceName + '#');
      myModelReader.insertEndOfSectionParagraph();
    }

    final FBReaderApp fbreader = (FBReaderApp) ZLApplication.Instance();
    //		fbreader.setTOCLabels(myTOCLabels);
    fbreader.setParagraphIndexList(myParagraphIndexList);
    fbreader.setHtmlFileNames(myHtmlFileNames, myFilePrefix, myCoverFileName);
    generateTOC();

    return true;
  }
Beispiel #3
0
 boolean readFile(String filePath) {
   final ZLFile file = ZLFile.createFileByPath(filePath);
   myLocalPathPrefix = MiscUtil.archiveEntryName(MiscUtil.htmlDirectoryPrefix(file));
   return read(file);
 }
 ZLFileImage readImage(ZLFile file) {
   myXHTMLPathPrefix = MiscUtil.htmlDirectoryPrefix(file);
   myImage = null;
   readQuietly(file);
   return myImage;
 }