diff --git a/jni/NativeFormats/fbreader/src/formats/css/StyleSheetParser.cpp b/jni/NativeFormats/fbreader/src/formats/css/StyleSheetParser.cpp index a2a59bcd5..8709a4837 100644 --- a/jni/NativeFormats/fbreader/src/formats/css/StyleSheetParser.cpp +++ b/jni/NativeFormats/fbreader/src/formats/css/StyleSheetParser.cpp @@ -235,7 +235,7 @@ StyleSheetSingleStyleParser::StyleSheetSingleStyleParser(const std::string &path shared_ptr StyleSheetSingleStyleParser::parseSingleEntry(const char *text) { myReadState = WAITING_FOR_ATTRIBUTE; parse(text, std::strlen(text), true); - shared_ptr control = StyleSheetTable::createControl(myMap); + shared_ptr control = StyleSheetTable::createOrUpdateControl(myMap); reset(); return control; } diff --git a/jni/NativeFormats/fbreader/src/formats/css/StyleSheetTable.cpp b/jni/NativeFormats/fbreader/src/formats/css/StyleSheetTable.cpp index 101dc9a95..7f2b16978 100644 --- a/jni/NativeFormats/fbreader/src/formats/css/StyleSheetTable.cpp +++ b/jni/NativeFormats/fbreader/src/formats/css/StyleSheetTable.cpp @@ -31,7 +31,7 @@ bool StyleSheetTable::isEmpty() const { void StyleSheetTable::addMap(const std::string &tag, const std::string &aClass, const AttributeMap &map) { if ((!tag.empty() || !aClass.empty()) && !map.empty()) { const Key key(tag, aClass); - myControlMap[key] = createControl(map); + myControlMap[key] = createOrUpdateControl(map, myControlMap[key]); const std::string &pbb = value(map, "page-break-before"); if (pbb == "always" || pbb == "left" || pbb == "right") { @@ -143,8 +143,10 @@ const std::string &StyleSheetTable::value(const AttributeMap &map, const std::st return emptyString; } -shared_ptr StyleSheetTable::createControl(const AttributeMap &styles) { - shared_ptr entry = new ZLTextStyleEntry(ZLTextStyleEntry::STYLE_CSS_ENTRY); +shared_ptr StyleSheetTable::createOrUpdateControl(const AttributeMap &styles, shared_ptr entry) { + if (entry.isNull()) { + entry = new ZLTextStyleEntry(ZLTextStyleEntry::STYLE_CSS_ENTRY); + } const std::string &alignment = value(styles, "text-align"); if (alignment == "justify") { diff --git a/jni/NativeFormats/fbreader/src/formats/css/StyleSheetTable.h b/jni/NativeFormats/fbreader/src/formats/css/StyleSheetTable.h index a7c1d623c..1ccada909 100644 --- a/jni/NativeFormats/fbreader/src/formats/css/StyleSheetTable.h +++ b/jni/NativeFormats/fbreader/src/formats/css/StyleSheetTable.h @@ -33,7 +33,7 @@ class StyleSheetTable { public: typedef std::map AttributeMap; - static shared_ptr createControl(const AttributeMap &map); + static shared_ptr createOrUpdateControl(const AttributeMap &map, shared_ptr entry = 0); private: void addMap(const std::string &tag, const std::string &aClass, const AttributeMap &map);