summaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorrootavish <[email protected]>2014-11-28 23:28:15 +0530
committerinfirit <[email protected]>2014-12-08 14:01:29 +0100
commitc6fcd956edad3ed5600ad4629e020e4971de0f16 (patch)
tree147701085bb3b3895dcaea52763b21a57b204e85 /backend
parentda566d2163e49e2e017f6aece2c9689b0a1834a7 (diff)
downloadatril-c6fcd956edad3ed5600ad4629e020e4971de0f16.tar.bz2
atril-c6fcd956edad3ed5600ad4629e020e4971de0f16.tar.xz
ePub: Can open documents which do not have toc
I always thought all ePub documents had either a traditional ncx or an epub3 nav. Now as it turns out, sometimes neither of these are present. Fixed.
Diffstat (limited to 'backend')
-rw-r--r--backend/epub/epub-document.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/backend/epub/epub-document.c b/backend/epub/epub-document.c
index e4412ace..0a098e48 100644
--- a/backend/epub/epub-document.c
+++ b/backend/epub/epub-document.c
@@ -1200,6 +1200,15 @@ setup_document_index(EpubDocument *epub_document,gchar *containeruri)
if (tocfilename == NULL) {
tocfilename = epub_document_get_nav_file(containeruri);
+
+ //Apparently, sometimes authors don't even care to add a TOC!! Guess standards are just guidelines.
+
+ if (tocfilename == NULL)
+ {
+ //We didn't even find a nav file.The document has no TOC.
+ return NULL;
+ }
+
g_string_append_printf (tocpath,"/%s",tocfilename);
index = setup_index_from_navfile(tocpath->str);
g_string_free(tocpath,TRUE);
@@ -1697,8 +1706,10 @@ epub_document_load (EvDocument* document,
epub_document->contentList = setup_document_content_list (contentOpfUri,&err,epub_document->documentdir);
- epub_document_set_index_pages(epub_document->index, epub_document->contentList);
- epub_document_add_mathJax(contentOpfUri,epub_document->documentdir);
+ if (epub_document->index != NULL)
+ epub_document_set_index_pages(epub_document->index, epub_document->contentList);
+
+ epub_document_add_mathJax(contentOpfUri,epub_document->documentdir);
if ( epub_document->contentList == NULL )
{
g_propagate_error(error,err);
@@ -1719,6 +1730,7 @@ epub_document_init (EpubDocument *epub_document)
epub_document->docTitle = NULL;
}
+
static void
epub_document_finalize (GObject *object)
{
@@ -1760,6 +1772,7 @@ epub_document_finalize (GObject *object)
G_OBJECT_CLASS (epub_document_parent_class)->finalize (object);
}
+
static void
epub_document_class_init (EpubDocumentClass *klass)
{