Search in sources :

Example 1 with OutlineLink

use of org.ebookdroid.core.codec.OutlineLink in project LibreraReader by foobnix.

the class Fb2Extractor method genetateNCXbyOutline.

public static String genetateNCXbyOutline(List<OutlineLink> titles) {
    StringBuilder navs = new StringBuilder();
    for (int i = 0; i < titles.size(); i++) {
        OutlineLink link = titles.get(i);
        String titleTxt = link.getTitle();
        if (TxtUtils.isNotEmpty(titleTxt)) {
            String createNavPoint = createNavPoint(OutlineLinkWrapper.getPageNumber(link.getLink()), link.getLevel() + DIVIDER + titleTxt);
            createNavPoint = createNavPoint.replace("fb2.fb2", "temp-reflow.html");
            navs.append(createNavPoint);
        }
    }
    return NCX.replace("%nav%", navs.toString());
}
Also used : OutlineLink(org.ebookdroid.core.codec.OutlineLink)

Example 2 with OutlineLink

use of org.ebookdroid.core.codec.OutlineLink in project LibreraReader by foobnix.

the class DjvuOutline method getOutline.

public List<OutlineLink> getOutline(final long dochandle) {
    final List<OutlineLink> ls = new ArrayList<OutlineLink>();
    docHandle = dochandle;
    final long expr = open(docHandle);
    ttOutline(ls, expr, 0);
    ls.add(new OutlineLink("", "", -1, dochandle, ""));
    return ls;
}
Also used : OutlineLink(org.ebookdroid.core.codec.OutlineLink) ArrayList(java.util.ArrayList)

Example 3 with OutlineLink

use of org.ebookdroid.core.codec.OutlineLink in project LibreraReader by foobnix.

the class Fb2Context method openDocumentInner2.

public CodecDocument openDocumentInner2(final String fileName1, String password) {
    final String fileName = cacheFile1.getPath();
    Fb2Extractor.get().convertFB2(fileName1, fileName);
    MuPdfDocument muPdfDocument2 = new MuPdfDocument(this, MuPdfDocument.FORMAT_PDF, fileName, password) {

        @Override
        public java.util.List<OutlineLink> getOutline() {
            List<OutlineLink> res = new ArrayList<OutlineLink>();
            try {
                String encoding = Fb2Extractor.findHeaderEncoding(fileName1);
                List<String> titles = Fb2Extractor.getFb2Titles(fileName1, encoding);
                for (int i = 0; i < titles.size(); i++) {
                    String string = titles.get(i).replace("~@~[title]", "###");
                    String[] full = string.split("###");
                    int level = Integer.parseInt(full[0]);
                    String title = full[1];
                    String linkUri = "#" + (i + 1);
                    res.add(new OutlineLink(title + linkUri, "", level, getDocumentHandle(), linkUri));
                }
            } catch (Exception e) {
                LOG.e(e);
            }
            return res;
        }
    };
    return muPdfDocument2;
}
Also used : OutlineLink(org.ebookdroid.core.codec.OutlineLink) MuPdfDocument(org.ebookdroid.droids.mupdf.codec.MuPdfDocument) ArrayList(java.util.ArrayList)

Example 4 with OutlineLink

use of org.ebookdroid.core.codec.OutlineLink in project LibreraReader by foobnix.

the class DjvuOutline method ttOutline.

private void ttOutline(final List<OutlineLink> ls, long expr, int level) {
    while (expConsp(expr)) {
        final String title = getTitle(expr);
        final String link = getLink(expr, docHandle);
        if (title != null) {
            ls.add(new OutlineLink(title, link, level, docHandle, ""));
        }
        final long child = getChild(expr);
        ttOutline(ls, child, level + 1);
        expr = getNext(expr);
    }
}
Also used : OutlineLink(org.ebookdroid.core.codec.OutlineLink)

Example 5 with OutlineLink

use of org.ebookdroid.core.codec.OutlineLink in project LibreraReader by foobnix.

the class MuPdfOutline method getOutline.

public List<OutlineLink> getOutline(final long dochandle) {
    final List<OutlineLink> ls = new ArrayList<OutlineLink>();
    docHandle = dochandle;
    try {
        TempHolder.lock.lock();
        final long outline = open(dochandle);
        ttOutline(ls, outline, 0);
        free(dochandle);
        ls.add(new OutlineLink("", "", -1, dochandle, ""));
    } finally {
        TempHolder.lock.unlock();
    }
    return ls;
}
Also used : OutlineLink(org.ebookdroid.core.codec.OutlineLink) ArrayList(java.util.ArrayList)

Aggregations

OutlineLink (org.ebookdroid.core.codec.OutlineLink)7 ArrayList (java.util.ArrayList)3 FileMeta (com.foobnix.dao2.FileMeta)1 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 FileWriter (java.io.FileWriter)1 CodecDocument (org.ebookdroid.core.codec.CodecDocument)1 CodecPage (org.ebookdroid.core.codec.CodecPage)1 MuPdfDocument (org.ebookdroid.droids.mupdf.codec.MuPdfDocument)1