|
|
@ -36,7 +36,6 @@ import me.ag2s.epublib.util.StringUtil; |
|
|
|
* Reads the opf package document as defined by namespace http://www.idpf.org/2007/opf
|
|
|
|
* Reads the opf package document as defined by namespace http://www.idpf.org/2007/opf
|
|
|
|
* |
|
|
|
* |
|
|
|
* @author paul |
|
|
|
* @author paul |
|
|
|
* |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class PackageDocumentReader extends PackageDocumentBase { |
|
|
|
public class PackageDocumentReader extends PackageDocumentBase { |
|
|
|
|
|
|
|
|
|
|
@ -201,7 +200,7 @@ public class PackageDocumentReader extends PackageDocumentBase { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Strips off the package prefixes up to the href of the packageHref. |
|
|
|
* Strips off the package prefixes up to the href of the packageHref. |
|
|
|
* |
|
|
|
* <p> |
|
|
|
* Example: |
|
|
|
* Example: |
|
|
|
* If the packageHref is "OEBPS/content.opf" then a resource href like "OEBPS/foo/bar.html" will be turned into "foo/bar.html" |
|
|
|
* If the packageHref is "OEBPS/content.opf" then a resource href like "OEBPS/foo/bar.html" will be turned into "foo/bar.html" |
|
|
|
* |
|
|
|
* |
|
|
@ -308,7 +307,7 @@ public class PackageDocumentReader extends PackageDocumentBase { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* The spine tag should contain a 'toc' attribute with as value the resource id of the table of contents resource. |
|
|
|
* The spine tag should contain a 'toc' attribute with as value the resource id of the table of contents resource. |
|
|
|
* |
|
|
|
* <p> |
|
|
|
* Here we try several ways of finding this table of contents resource. |
|
|
|
* Here we try several ways of finding this table of contents resource. |
|
|
|
* We try the given attribute value, some often-used ones and finally look through all resources for the first resource with the table of contents mimetype. |
|
|
|
* We try the given attribute value, some often-used ones and finally look through all resources for the first resource with the table of contents mimetype. |
|
|
|
* |
|
|
|
* |
|
|
@ -318,7 +317,13 @@ public class PackageDocumentReader extends PackageDocumentBase { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static Resource findTableOfContentsResource(String tocResourceId, |
|
|
|
static Resource findTableOfContentsResource(String tocResourceId, |
|
|
|
Resources resources) { |
|
|
|
Resources resources) { |
|
|
|
Resource tocResource = null; |
|
|
|
Resource tocResource; |
|
|
|
|
|
|
|
//一些epub3的文件为了兼容epub2,保留的epub2的目录文件,这里优先选择epub3的xml目录
|
|
|
|
|
|
|
|
tocResource = resources.getByProperties("nav"); |
|
|
|
|
|
|
|
if (tocResource != null) { |
|
|
|
|
|
|
|
return tocResource; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (StringUtil.isNotBlank(tocResourceId)) { |
|
|
|
if (StringUtil.isNotBlank(tocResourceId)) { |
|
|
|
tocResource = resources.getByIdOrHref(tocResourceId); |
|
|
|
tocResource = resources.getByIdOrHref(tocResourceId); |
|
|
|
} |
|
|
|
} |
|
|
@ -343,10 +348,7 @@ public class PackageDocumentReader extends PackageDocumentBase { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//For EPUB3
|
|
|
|
|
|
|
|
if (tocResource==null){ |
|
|
|
|
|
|
|
tocResource=resources.getByProperties("nav"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (tocResource == null) { |
|
|
|
if (tocResource == null) { |
|
|
|
Log.e(TAG, |
|
|
|
Log.e(TAG, |
|
|
|