mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 02:39:23 +02:00
fixed multiple CSS enries for same selector
This commit is contained in:
parent
7f6266fad1
commit
e8f554c4ca
3 changed files with 7 additions and 5 deletions
|
@ -235,7 +235,7 @@ StyleSheetSingleStyleParser::StyleSheetSingleStyleParser(const std::string &path
|
|||
shared_ptr<ZLTextStyleEntry> StyleSheetSingleStyleParser::parseSingleEntry(const char *text) {
|
||||
myReadState = WAITING_FOR_ATTRIBUTE;
|
||||
parse(text, std::strlen(text), true);
|
||||
shared_ptr<ZLTextStyleEntry> control = StyleSheetTable::createControl(myMap);
|
||||
shared_ptr<ZLTextStyleEntry> control = StyleSheetTable::createOrUpdateControl(myMap);
|
||||
reset();
|
||||
return control;
|
||||
}
|
||||
|
|
|
@ -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<ZLTextStyleEntry> StyleSheetTable::createControl(const AttributeMap &styles) {
|
||||
shared_ptr<ZLTextStyleEntry> entry = new ZLTextStyleEntry(ZLTextStyleEntry::STYLE_CSS_ENTRY);
|
||||
shared_ptr<ZLTextStyleEntry> StyleSheetTable::createOrUpdateControl(const AttributeMap &styles, shared_ptr<ZLTextStyleEntry> entry) {
|
||||
if (entry.isNull()) {
|
||||
entry = new ZLTextStyleEntry(ZLTextStyleEntry::STYLE_CSS_ENTRY);
|
||||
}
|
||||
|
||||
const std::string &alignment = value(styles, "text-align");
|
||||
if (alignment == "justify") {
|
||||
|
|
|
@ -33,7 +33,7 @@ class StyleSheetTable {
|
|||
|
||||
public:
|
||||
typedef std::map<std::string,std::string> AttributeMap;
|
||||
static shared_ptr<ZLTextStyleEntry> createControl(const AttributeMap &map);
|
||||
static shared_ptr<ZLTextStyleEntry> createOrUpdateControl(const AttributeMap &map, shared_ptr<ZLTextStyleEntry> entry = 0);
|
||||
|
||||
private:
|
||||
void addMap(const std::string &tag, const std::string &aClass, const AttributeMap &map);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue