diff --git a/TODO.1.5 b/TODO.1.5
index d5cc5f06e..167291400 100644
--- a/TODO.1.5
+++ b/TODO.1.5
@@ -7,17 +7,12 @@ litres: author photos
* the SJ book:
** empty pages at start (in emulator)
-* Network library initialization in ProcessHyperlinkAction :(
* "Use embedded fonts" option
* "Scan hidden directories" option
* Start position mark in navigation widget
-* fb2 native: footnote id depth
* test opensearch parser
-* update series data for ePubs
-* fb2 plugins: compare native & java
+* update series data for ePubs (?)
* language codes in ZLTextHyphenator and ZLLanguageUtil (java & cpp)
-* resources synchronization
-* in library: search more on network
* CSS:
** @page
** @import
@@ -26,9 +21,14 @@ litres: author photos
** embedded fonts
* Two-page view
* image size option (cover only full-screen, all full-screen, etc.)
+* resources synchronization
-1.6+:
+1.5.1+:
+* Network library initialization in ProcessHyperlinkAction :(
+* fb2 native: footnote id depth
+* fb2 plugins: compare native & java
+* in library: search more on network
* Link sharing
* предупреждение "не могу открыть зашифрованный файл"
* CSS:
@@ -50,7 +50,7 @@ litres: author photos
*
tag
* Better file name for shared file
* java fb2 plugin: use Base64InputStream technique
-* - namespaceMapChangedHandler
+* - namespaceMapChangedHandler (java)
* rtf:
** underline & strikethrough
** cover?
diff --git a/jni/NativeFormats/fbreader/src/formats/oeb/OEBBookReader.cpp b/jni/NativeFormats/fbreader/src/formats/oeb/OEBBookReader.cpp
index 10a86fd5c..4f1d27615 100644
--- a/jni/NativeFormats/fbreader/src/formats/oeb/OEBBookReader.cpp
+++ b/jni/NativeFormats/fbreader/src/formats/oeb/OEBBookReader.cpp
@@ -49,89 +49,124 @@ static const std::string REFERENCE = "reference";
static const std::string COVER = "cover";
static const std::string COVER_IMAGE = "other.ms-coverimage-standard";
+bool OEBBookReader::isOPFTag(const std::string &expected, const std::string &tag) const {
+ return expected == tag && testTag(ZLXMLNamespace::OpenPackagingFormat, expected, tag);
+}
+
void OEBBookReader::startElementHandler(const char *tag, const char **xmlattributes) {
std::string tagString = ZLUnicodeUtil::toLower(tag);
- if (!myOPFSchemePrefix.empty() &&
- ZLStringUtil::stringStartsWith(tagString, myOPFSchemePrefix)) {
- tagString = tagString.substr(myOPFSchemePrefix.length());
- }
- if (MANIFEST == tagString) {
- myState = READ_MANIFEST;
- } else if (SPINE == tagString) {
- const char *toc = attributeValue(xmlattributes, "toc");
- if (toc != 0) {
- myNCXTOCFileName = myIdToHref[toc];
- }
- myState = READ_SPINE;
- } else if (GUIDE == tagString) {
- myState = READ_GUIDE;
- } else if (TOUR == tagString) {
- myState = READ_TOUR;
- } else if ((myState == READ_MANIFEST) && (ITEM == tagString)) {
- const char *id = attributeValue(xmlattributes, "id");
- const char *href = attributeValue(xmlattributes, "href");
- if ((id != 0) && (href != 0)) {
- myIdToHref[id] = MiscUtil::decodeHtmlURL(href);
- }
- } else if ((myState == READ_SPINE) && (ITEMREF == tagString)) {
- const char *id = attributeValue(xmlattributes, "idref");
- if (id != 0) {
- const std::string &fileName = myIdToHref[id];
- if (!fileName.empty()) {
- myHtmlFileNames.push_back(fileName);
+
+ switch (myState) {
+ case READ_NONE:
+ if (isOPFTag(MANIFEST, tagString)) {
+ myState = READ_MANIFEST;
+ } else if (isOPFTag(SPINE, tagString)) {
+ const char *toc = attributeValue(xmlattributes, "toc");
+ if (toc != 0) {
+ myNCXTOCFileName = myIdToHref[toc];
+ }
+ myState = READ_SPINE;
+ } else if (isOPFTag(GUIDE, tagString)) {
+ myState = READ_GUIDE;
+ } else if (isOPFTag(TOUR, tagString)) {
+ myState = READ_TOUR;
}
- }
- } else if ((myState == READ_GUIDE) && (REFERENCE == tagString)) {
- const char *type = attributeValue(xmlattributes, "type");
- const char *title = attributeValue(xmlattributes, "title");
- const char *href = attributeValue(xmlattributes, "href");
- if (href != 0) {
- const std::string reference = MiscUtil::decodeHtmlURL(href);
- if (title != 0) {
- myGuideTOC.push_back(std::make_pair(std::string(title), reference));
- }
- if (type != 0) {
- if (COVER == type) {
- ZLFile imageFile(myFilePrefix + reference);
- myCoverFileName = imageFile.path();
- const std::string imageName = imageFile.name(false);
- shared_ptr image = XHTMLImageFinder().readImage(imageFile);
- if (!image.isNull()) {
- myModelReader.setMainTextModel();
- myModelReader.addImageReference(imageName, (short)0, true);
- myModelReader.addImage(imageName, image);
- myModelReader.insertEndOfSectionParagraph();
- } else {
- myCoverFileName.erase();
- }
- } else if (COVER_IMAGE == type) {
- ZLFile imageFile(myFilePrefix + reference);
- myCoverFileName = imageFile.path();
- const std::string imageName = imageFile.name(false);
- myModelReader.setMainTextModel();
- myModelReader.addImageReference(imageName, 0, true);
- myModelReader.addImage(imageName, new ZLFileImage(imageFile, "", 0));
- myModelReader.insertEndOfSectionParagraph();
+ break;
+ case READ_MANIFEST:
+ if (isOPFTag(ITEM, tagString)) {
+ const char *id = attributeValue(xmlattributes, "id");
+ const char *href = attributeValue(xmlattributes, "href");
+ if (id != 0 && href != 0) {
+ myIdToHref[id] = MiscUtil::decodeHtmlURL(href);
}
}
- }
- } else if ((myState == READ_TOUR) && (SITE == tagString)) {
- const char *title = attributeValue(xmlattributes, "title");
- const char *href = attributeValue(xmlattributes, "href");
- if ((title != 0) && (href != 0)) {
- myTourTOC.push_back(std::make_pair(title, MiscUtil::decodeHtmlURL(href)));
- }
+ break;
+ case READ_SPINE:
+ if (isOPFTag(ITEMREF, tagString)) {
+ const char *id = attributeValue(xmlattributes, "idref");
+ if (id != 0) {
+ const std::string &fileName = myIdToHref[id];
+ if (!fileName.empty()) {
+ myHtmlFileNames.push_back(fileName);
+ }
+ }
+ }
+ break;
+ case READ_GUIDE:
+ if (isOPFTag(REFERENCE, tagString)) {
+ const char *type = attributeValue(xmlattributes, "type");
+ const char *title = attributeValue(xmlattributes, "title");
+ const char *href = attributeValue(xmlattributes, "href");
+ if (href != 0) {
+ const std::string reference = MiscUtil::decodeHtmlURL(href);
+ if (title != 0) {
+ myGuideTOC.push_back(std::make_pair(std::string(title), reference));
+ }
+ if (type != 0) {
+ if (COVER == type) {
+ ZLFile imageFile(myFilePrefix + reference);
+ myCoverFileName = imageFile.path();
+ const std::string imageName = imageFile.name(false);
+ shared_ptr image = XHTMLImageFinder().readImage(imageFile);
+ if (!image.isNull()) {
+ myModelReader.setMainTextModel();
+ myModelReader.addImageReference(imageName, (short)0, true);
+ myModelReader.addImage(imageName, image);
+ myModelReader.insertEndOfSectionParagraph();
+ } else {
+ myCoverFileName.erase();
+ }
+ } else if (COVER_IMAGE == type) {
+ ZLFile imageFile(myFilePrefix + reference);
+ myCoverFileName = imageFile.path();
+ const std::string imageName = imageFile.name(false);
+ myModelReader.setMainTextModel();
+ myModelReader.addImageReference(imageName, 0, true);
+ myModelReader.addImage(imageName, new ZLFileImage(imageFile, "", 0));
+ myModelReader.insertEndOfSectionParagraph();
+ }
+ }
+ }
+ }
+ break;
+ case READ_TOUR:
+ if (isOPFTag(SITE, tagString)) {
+ const char *title = attributeValue(xmlattributes, "title");
+ const char *href = attributeValue(xmlattributes, "href");
+ if ((title != 0) && (href != 0)) {
+ myTourTOC.push_back(std::make_pair(title, MiscUtil::decodeHtmlURL(href)));
+ }
+ }
+ break;
}
}
void OEBBookReader::endElementHandler(const char *tag) {
std::string tagString = ZLUnicodeUtil::toLower(tag);
- if (!myOPFSchemePrefix.empty() &&
- ZLStringUtil::stringStartsWith(tagString, myOPFSchemePrefix)) {
- tagString = tagString.substr(myOPFSchemePrefix.length());
- }
- if ((MANIFEST == tagString) || (SPINE == tagString) || (GUIDE == tagString) || (TOUR == tagString)) {
- myState = READ_NONE;
+
+ switch (myState) {
+ case READ_MANIFEST:
+ if (isOPFTag(MANIFEST, tagString)) {
+ myState = READ_NONE;
+ }
+ break;
+ case READ_SPINE:
+ if (isOPFTag(SPINE, tagString)) {
+ myState = READ_NONE;
+ }
+ break;
+ case READ_GUIDE:
+ if (isOPFTag(GUIDE, tagString)) {
+ myState = READ_NONE;
+ }
+ break;
+ case READ_TOUR:
+ if (isOPFTag(TOUR, tagString)) {
+ myState = READ_NONE;
+ }
+ break;
+ case READ_NONE:
+ break;
}
}
@@ -217,21 +252,6 @@ bool OEBBookReader::processNamespaces() const {
return true;
}
-void OEBBookReader::namespaceListChangedHandler() {
- const std::map &namespaceMap = namespaces();
- std::map::const_iterator iter = namespaceMap.begin();
- for (; iter != namespaceMap.end(); ++iter) {
- if (iter->second == ZLXMLNamespace::OpenPackagingFormat) {
- break;
- }
- }
- if (iter != namespaceMap.end()) {
- myOPFSchemePrefix = iter->first + ":";
- } else {
- myOPFSchemePrefix.erase();
- }
-}
-
const std::vector &OEBBookReader::externalDTDs() const {
return EntityFilesCollector::Instance().externalDTDs("xhtml");
}
diff --git a/jni/NativeFormats/fbreader/src/formats/oeb/OEBBookReader.h b/jni/NativeFormats/fbreader/src/formats/oeb/OEBBookReader.h
index 27f48d43b..bcef1ee91 100644
--- a/jni/NativeFormats/fbreader/src/formats/oeb/OEBBookReader.h
+++ b/jni/NativeFormats/fbreader/src/formats/oeb/OEBBookReader.h
@@ -40,7 +40,7 @@ private:
void startElementHandler(const char *tag, const char **attributes);
void endElementHandler(const char *tag);
bool processNamespaces() const;
- void namespaceListChangedHandler();
+ bool isOPFTag(const std::string &expected, const std::string &tag) const;
const std::vector &externalDTDs() const;
void generateTOC(const XHTMLReader &xhtmlReader);
@@ -57,8 +57,6 @@ private:
BookReader myModelReader;
ReaderState myState;
- std::string myOPFSchemePrefix;
-
std::string myFilePrefix;
std::map myIdToHref;
std::vector myHtmlFileNames;
diff --git a/jni/NativeFormats/zlibrary/core/src/xml/ZLXMLReader.cpp b/jni/NativeFormats/zlibrary/core/src/xml/ZLXMLReader.cpp
index dcba6d939..883fd629d 100644
--- a/jni/NativeFormats/zlibrary/core/src/xml/ZLXMLReader.cpp
+++ b/jni/NativeFormats/zlibrary/core/src/xml/ZLXMLReader.cpp
@@ -71,9 +71,6 @@ void ZLXMLReader::endElementHandler(const char*) {
void ZLXMLReader::characterDataHandler(const char*, size_t) {
}
-void ZLXMLReader::namespaceListChangedHandler() {
-}
-
const ZLXMLReader::nsMap &ZLXMLReader::namespaces() const {
return *myNamespaces.back();
}
diff --git a/jni/NativeFormats/zlibrary/core/src/xml/ZLXMLReader.h b/jni/NativeFormats/zlibrary/core/src/xml/ZLXMLReader.h
index 6d0fbd258..08fcf36f1 100644
--- a/jni/NativeFormats/zlibrary/core/src/xml/ZLXMLReader.h
+++ b/jni/NativeFormats/zlibrary/core/src/xml/ZLXMLReader.h
@@ -90,7 +90,6 @@ protected:
virtual void endElementHandler(const char *tag);
virtual void characterDataHandler(const char *text, size_t len);
virtual bool processNamespaces() const;
- virtual void namespaceListChangedHandler();
virtual const std::vector &externalDTDs() const;
virtual void collectExternalEntities(std::map &entityMap);
diff --git a/jni/NativeFormats/zlibrary/core/src/xml/expat/ZLXMLReaderInternal.cpp b/jni/NativeFormats/zlibrary/core/src/xml/expat/ZLXMLReaderInternal.cpp
index d89930fe5..f338bb2a1 100644
--- a/jni/NativeFormats/zlibrary/core/src/xml/expat/ZLXMLReaderInternal.cpp
+++ b/jni/NativeFormats/zlibrary/core/src/xml/expat/ZLXMLReaderInternal.cpp
@@ -56,8 +56,6 @@ void ZLXMLReaderInternal::fStartElementHandler(void *userData, const char *name,
}
if (count == 0) {
reader.myNamespaces.push_back(reader.myNamespaces.back());
- } else {
- reader.namespaceListChangedHandler();
}
}
reader.startElementHandler(name, attributes);
@@ -71,9 +69,6 @@ void ZLXMLReaderInternal::fEndElementHandler(void *userData, const char *name) {
if (reader.processNamespaces()) {
shared_ptr > oldMap = reader.myNamespaces.back();
reader.myNamespaces.pop_back();
- if (reader.myNamespaces.back() != oldMap) {
- reader.namespaceListChangedHandler();
- }
}
}
}