diff --git a/TODO.1.5 b/TODO.1.5 index efea5caec..1e2221e2b 100644 --- a/TODO.1.5 +++ b/TODO.1.5 @@ -10,7 +10,7 @@ litres: author photos * ePub: DONE reference resolver (Имя розы) ** reverence shortening in native code (like java code shortening) - ** large covers (cover mark for images in native code) + DONE large covers (cover mark for images in native code) * "modes" for wallpapers: tile, fullscreen, etc. * zip: re-use open files DONE Screen orientation by default: not selected? @@ -39,7 +39,8 @@ DONE encodings list for native plugins ** metrics: screen height & width DONE font size DONE font size: smaller and larger - ** font size: inherit + ** font modifier: smallcaps + DONE font size: inherit DONE underline DONE strikethrough ** embedded fonts @@ -49,7 +50,7 @@ DONE encodings list for native plugins ** embedded tags in selectors (h2 p { font-family: helvetica }) ** colors ** backgrounds - ** don't apply "fbreader internal" font size settings before CSS "smaller" or "larger" + DONE don't apply "fbreader internal" font size settings before CSS "smaller" or "larger" * предупреждение "не могу открыть зашифрованный файл" * API от Paragon * Two-page view diff --git a/jni/NativeFormats/fbreader/src/formats/css/StyleSheetTable.cpp b/jni/NativeFormats/fbreader/src/formats/css/StyleSheetTable.cpp index 04ee49f2c..4e095a9a4 100644 --- a/jni/NativeFormats/fbreader/src/formats/css/StyleSheetTable.cpp +++ b/jni/NativeFormats/fbreader/src/formats/css/StyleSheetTable.cpp @@ -221,6 +221,9 @@ shared_ptr StyleSheetTable::createControl(const AttributeMap & size = 144; } else if (fontSize[0] == "xx-large") { size = 173; + } else if (fontSize[0] == "inherit") { + entry->setFontModifier(ZLTextStyleEntry::FONT_MODIFIER_INHERIT, true); + doSetFontSize = false; } else if (fontSize[0] == "smaller") { entry->setFontModifier(ZLTextStyleEntry::FONT_MODIFIER_SMALLER, true); doSetFontSize = false; diff --git a/jni/NativeFormats/fbreader/src/formats/fb2/FB2BookReader.cpp b/jni/NativeFormats/fbreader/src/formats/fb2/FB2BookReader.cpp index 393d2f3fe..0d44cac01 100644 --- a/jni/NativeFormats/fbreader/src/formats/fb2/FB2BookReader.cpp +++ b/jni/NativeFormats/fbreader/src/formats/fb2/FB2BookReader.cpp @@ -58,6 +58,10 @@ void FB2BookReader::characterDataHandler(const char *text, size_t len) { } } +bool FB2BookReader::processNamespaces() const { + return true; +} + void FB2BookReader::startElementHandler(int tag, const char **xmlattributes) { const char *id = attributeValue(xmlattributes, "id"); if (id != 0 && tag != _BINARY) { @@ -158,8 +162,7 @@ void FB2BookReader::startElementHandler(int tag, const char **xmlattributes) { break; case _A: { - const std::string hrefName = xlinkNamespace() + ":href"; - const char *ref = attributeValue(xmlattributes, hrefName.c_str()); + const char *ref = attributeValue(xmlattributes, myHrefPredicate); if (ref != 0) { if (ref[0] == '#') { const char *type = attributeValue(xmlattributes, "type"); @@ -182,8 +185,7 @@ void FB2BookReader::startElementHandler(int tag, const char **xmlattributes) { } case _IMAGE: { - const std::string hrefName = xlinkNamespace() + ":href"; - const char *ref = attributeValue(xmlattributes, hrefName.c_str()); + const char *ref = attributeValue(xmlattributes, myHrefPredicate); const char *vOffset = attributeValue(xmlattributes, "voffset"); char offset = (vOffset != 0) ? atoi(vOffset) : 0; if ((ref != 0) && (*ref == '#')) { diff --git a/jni/NativeFormats/fbreader/src/formats/fb2/FB2BookReader.h b/jni/NativeFormats/fbreader/src/formats/fb2/FB2BookReader.h index 9130dc62e..e8523f47d 100644 --- a/jni/NativeFormats/fbreader/src/formats/fb2/FB2BookReader.h +++ b/jni/NativeFormats/fbreader/src/formats/fb2/FB2BookReader.h @@ -31,6 +31,7 @@ public: FB2BookReader(BookModel &model); bool readBook(); + bool processNamespaces() const; void startElementHandler(int tag, const char **attributes); void endElementHandler(int tag); void characterDataHandler(const char *text, size_t len); diff --git a/jni/NativeFormats/fbreader/src/formats/fb2/FB2CoverReader.cpp b/jni/NativeFormats/fbreader/src/formats/fb2/FB2CoverReader.cpp index ecc5e478a..bb0e623dc 100644 --- a/jni/NativeFormats/fbreader/src/formats/fb2/FB2CoverReader.cpp +++ b/jni/NativeFormats/fbreader/src/formats/fb2/FB2CoverReader.cpp @@ -37,6 +37,10 @@ shared_ptr FB2CoverReader::readCover() { return myImage; } +bool FB2CoverReader::processNamespaces() const { + return true; +} + void FB2CoverReader::startElementHandler(int tag, const char **attributes) { switch (tag) { case _COVERPAGE: @@ -44,8 +48,7 @@ void FB2CoverReader::startElementHandler(int tag, const char **attributes) { break; case _IMAGE: if (myReadCoverPage) { - const std::string hrefName = xlinkNamespace() + ":href"; - const char *ref = attributeValue(attributes, hrefName.c_str()); + const char *ref = attributeValue(attributes, myHrefPredicate); if (ref != 0 && *ref == '#' && *(ref + 1) != '\0') { myImageId = ref + 1; } diff --git a/jni/NativeFormats/fbreader/src/formats/fb2/FB2CoverReader.h b/jni/NativeFormats/fbreader/src/formats/fb2/FB2CoverReader.h index d93d3701c..5e219b82f 100644 --- a/jni/NativeFormats/fbreader/src/formats/fb2/FB2CoverReader.h +++ b/jni/NativeFormats/fbreader/src/formats/fb2/FB2CoverReader.h @@ -32,6 +32,7 @@ public: shared_ptr readCover(); private: + bool processNamespaces() const; void startElementHandler(int tag, const char **attributes); void endElementHandler(int tag); void characterDataHandler(const char *text, size_t len); diff --git a/jni/NativeFormats/fbreader/src/formats/fb2/FB2Reader.cpp b/jni/NativeFormats/fbreader/src/formats/fb2/FB2Reader.cpp index f4683962b..d72deee11 100644 --- a/jni/NativeFormats/fbreader/src/formats/fb2/FB2Reader.cpp +++ b/jni/NativeFormats/fbreader/src/formats/fb2/FB2Reader.cpp @@ -20,12 +20,14 @@ #include #include - #include #include #include "FB2Reader.h" +FB2Reader::FB2Reader() : myHrefPredicate(ZLXMLNamespace::XLink, "href") { +} + void FB2Reader::startElementHandler(const char *t, const char **attributes) { startElementHandler(tag(t), attributes); } @@ -80,21 +82,6 @@ int FB2Reader::tag(const char *name) { } } -bool FB2Reader::processNamespaces() const { - return true; -} - -void FB2Reader::namespaceListChangedHandler() { - const std::map namespaceMap = namespaces(); - for (std::map::const_iterator it = namespaceMap.begin(); it != namespaceMap.end(); ++it) { - if (it->second == ZLXMLNamespace::XLink) { - myXLinkNamespace = it->first; - return; - } - } - myXLinkNamespace.erase(); -} - void FB2Reader::collectExternalEntities(std::map &entityMap) { entityMap["FBReaderVersion"] = ZLibrary::Version(); } diff --git a/jni/NativeFormats/fbreader/src/formats/fb2/FB2Reader.h b/jni/NativeFormats/fbreader/src/formats/fb2/FB2Reader.h index 29c1b31c9..1249e63c2 100644 --- a/jni/NativeFormats/fbreader/src/formats/fb2/FB2Reader.h +++ b/jni/NativeFormats/fbreader/src/formats/fb2/FB2Reader.h @@ -36,13 +36,9 @@ protected: virtual void startElementHandler(int tag, const char **attributes) = 0; virtual void endElementHandler(int tag) = 0; - const std::string &xlinkNamespace() const; - private: void startElementHandler(const char *tag, const char **attributes); void endElementHandler(const char *tag); - bool processNamespaces() const; - void namespaceListChangedHandler(); void collectExternalEntities(std::map &entityMap); @@ -89,12 +85,10 @@ protected: FB2Reader(); ~FB2Reader(); -private: - std::string myXLinkNamespace; +protected: + const NamespaceAttributeNamePredicate myHrefPredicate; }; -inline FB2Reader::FB2Reader() {} inline FB2Reader::~FB2Reader() {} -inline const std::string &FB2Reader::xlinkNamespace() const { return myXLinkNamespace; } #endif /* __FB2READER_H__ */ diff --git a/jni/NativeFormats/fbreader/src/formats/oeb/XHTMLImageFinder.cpp b/jni/NativeFormats/fbreader/src/formats/oeb/XHTMLImageFinder.cpp index bcd2f7a42..d66c59331 100644 --- a/jni/NativeFormats/fbreader/src/formats/oeb/XHTMLImageFinder.cpp +++ b/jni/NativeFormats/fbreader/src/formats/oeb/XHTMLImageFinder.cpp @@ -19,6 +19,7 @@ #include #include +#include #include "XHTMLImageFinder.h" #include "../util/MiscUtil.h" @@ -33,13 +34,18 @@ shared_ptr XHTMLImageFinder::readImage(const ZLFile &file) { return myImage; } +bool XHTMLImageFinder::processNamespaces() const { + return true; +} + void XHTMLImageFinder::startElementHandler(const char *tag, const char **attributes) { const char *reference = 0; if (TAG_IMG == tag) { reference = attributeValue(attributes, "src"); } else if (TAG_IMAGE == tag) { - //href = getAttributeValue(attributes, XMLNamespaces.XLink, "href"); - reference = attributeValue(attributes, "href"); + reference = attributeValue( + attributes, NamespaceAttributeNamePredicate(ZLXMLNamespace::XLink, "href") + ); } if (reference != 0) { myImage = new ZLFileImage(ZLFile(myPathPrefix + reference), "", 0); diff --git a/jni/NativeFormats/fbreader/src/formats/oeb/XHTMLImageFinder.h b/jni/NativeFormats/fbreader/src/formats/oeb/XHTMLImageFinder.h index 00983be12..28e53f2ca 100644 --- a/jni/NativeFormats/fbreader/src/formats/oeb/XHTMLImageFinder.h +++ b/jni/NativeFormats/fbreader/src/formats/oeb/XHTMLImageFinder.h @@ -32,6 +32,7 @@ public: shared_ptr readImage(const ZLFile &file); private: + bool processNamespaces() const; void startElementHandler(const char *tag, const char **attributes); private: diff --git a/jni/NativeFormats/zlibrary/core/src/xml/ZLXMLReader.cpp b/jni/NativeFormats/zlibrary/core/src/xml/ZLXMLReader.cpp index 7f75fbad8..dcba6d939 100644 --- a/jni/NativeFormats/zlibrary/core/src/xml/ZLXMLReader.cpp +++ b/jni/NativeFormats/zlibrary/core/src/xml/ZLXMLReader.cpp @@ -60,9 +60,6 @@ bool ZLXMLReaderHandler::handleBuffer(const char *data, size_t len) { return myReader.readFromBuffer(data, len); } - - - static const size_t BUFFER_SIZE = 2048; void ZLXMLReader::startElementHandler(const char*, const char**) { @@ -184,13 +181,17 @@ ZLXMLReader::NamespaceAttributeNamePredicate::NamespaceAttributeNamePredicate(co } bool ZLXMLReader::NamespaceAttributeNamePredicate::accepts(const ZLXMLReader &reader, const char *name) const { + const std::string full(name); + const size_t index = full.find(':'); + const std::string namespaceId = + index == std::string::npos ? std::string() : full.substr(0, index); + const nsMap &namespaces = reader.namespaces(); - for (nsMap::const_iterator it = namespaces.begin(); it != namespaces.end(); ++it) { - if (it->second == myNamespaceName) { - return it->first + ':' + myAttributeName == name; - } - } - return false; + nsMap::const_iterator it = namespaces.find(namespaceId); + return + it != namespaces.end() && + it->second == myNamespaceName && + full.substr(index + 1) == myAttributeName; } const char *ZLXMLReader::attributeValue(const char **xmlattributes, const AttributeNamePredicate &predicate) { diff --git a/jni/NativeFormats/zlibrary/text/src/model/ZLTextStyleEntry.h b/jni/NativeFormats/zlibrary/text/src/model/ZLTextStyleEntry.h index 02a9ffc7e..e0df3ff82 100644 --- a/jni/NativeFormats/zlibrary/text/src/model/ZLTextStyleEntry.h +++ b/jni/NativeFormats/zlibrary/text/src/model/ZLTextStyleEntry.h @@ -51,8 +51,9 @@ public: FONT_MODIFIER_UNDERLINED = 1 << 2, FONT_MODIFIER_STRIKEDTHROUGH = 1 << 3, FONT_MODIFIER_SMALLCAPS = 1 << 4, - FONT_MODIFIER_SMALLER = 1 << 5, - FONT_MODIFIER_LARGER = 1 << 6, + FONT_MODIFIER_INHERIT = 1 << 5, + FONT_MODIFIER_SMALLER = 1 << 6, + FONT_MODIFIER_LARGER = 1 << 7, }; enum Feature { diff --git a/src/org/geometerplus/zlibrary/text/model/ZLTextStyleEntry.java b/src/org/geometerplus/zlibrary/text/model/ZLTextStyleEntry.java index 2fe23a9b6..86b95f5b8 100644 --- a/src/org/geometerplus/zlibrary/text/model/ZLTextStyleEntry.java +++ b/src/org/geometerplus/zlibrary/text/model/ZLTextStyleEntry.java @@ -41,8 +41,9 @@ public final class ZLTextStyleEntry { byte FONT_MODIFIER_UNDERLINED = 1 << 2; byte FONT_MODIFIER_STRIKEDTHROUGH = 1 << 3; byte FONT_MODIFIER_SMALLCAPS = 1 << 4; - byte FONT_MODIFIER_SMALLER = 1 << 5; - byte FONT_MODIFIER_LARGER = 1 << 6; + byte FONT_MODIFIER_INHERIT = 1 << 5; + byte FONT_MODIFIER_SMALLER = 1 << 6; + byte FONT_MODIFIER_LARGER = (byte)(1 << 7); } public interface SizeUnit { diff --git a/src/org/geometerplus/zlibrary/text/view/style/ZLTextExplicitlyDecoratedStyle.java b/src/org/geometerplus/zlibrary/text/view/style/ZLTextExplicitlyDecoratedStyle.java index 12ce21d7c..87ea5a088 100644 --- a/src/org/geometerplus/zlibrary/text/view/style/ZLTextExplicitlyDecoratedStyle.java +++ b/src/org/geometerplus/zlibrary/text/view/style/ZLTextExplicitlyDecoratedStyle.java @@ -42,6 +42,9 @@ public class ZLTextExplicitlyDecoratedStyle extends ZLTextStyle implements ZLTex } public int getFontSize(ZLTextMetrics metrics) { if (myEntry.isFeatureSupported(FONT_STYLE_MODIFIER)) { + if (myEntry.getFontModifier(FONT_MODIFIER_INHERIT) == ZLBoolean3.B3_TRUE) { + return Base.Base.getFontSize(metrics); + } if (myEntry.getFontModifier(FONT_MODIFIER_LARGER) == ZLBoolean3.B3_TRUE) { return Base.Base.getFontSize(metrics) * 120 / 100; }