mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 18:29:23 +02:00
'margin' property support
This commit is contained in:
parent
81e2abe85d
commit
fce3eda3a7
2 changed files with 39 additions and 3 deletions
|
@ -223,7 +223,12 @@ void StyleSheetParser::processWord(const std::string &word) {
|
|||
{
|
||||
std::string stripped = word;
|
||||
ZLStringUtil::stripWhiteSpaces(stripped);
|
||||
myMap[myAttributeName] = stripped;
|
||||
std::string ¤t = myMap[myAttributeName];
|
||||
if (current.size() == 0) {
|
||||
current = stripped;
|
||||
} else {
|
||||
current += ' ' + stripped;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -256,7 +261,7 @@ void StyleSheetMultiStyleParser::storeData(const std::string &selector, const St
|
|||
return;
|
||||
}
|
||||
|
||||
const std::vector<std::string> ids = ZLStringUtil::split(s, ",");
|
||||
const std::vector<std::string> ids = ZLStringUtil::split(s, ",", true);
|
||||
for (std::vector<std::string>::const_iterator it = ids.begin(); it != ids.end(); ++it) {
|
||||
std::string id = *it;
|
||||
ZLStringUtil::stripWhiteSpaces(id);
|
||||
|
@ -293,7 +298,7 @@ void StyleSheetMultiStyleParser::processAtRule(const std::string &name, const St
|
|||
std::string path;
|
||||
if (it != attributes.end()) {
|
||||
// TODO: better split
|
||||
const std::vector<std::string> ids = ZLStringUtil::split(it->second, " ");
|
||||
const std::vector<std::string> ids = ZLStringUtil::split(it->second, " ", true);
|
||||
for (std::vector<std::string>::const_iterator jt = ids.begin(); jt != ids.end(); ++jt) {
|
||||
if (ZLStringUtil::stringStartsWith(*jt, "url(") &&
|
||||
ZLStringUtil::stringEndsWith(*jt, ")")) {
|
||||
|
|
|
@ -243,6 +243,37 @@ shared_ptr<ZLTextStyleEntry> StyleSheetTable::createOrUpdateControl(const Attrib
|
|||
}
|
||||
}
|
||||
|
||||
StyleSheetTable::AttributeMap::const_iterator it = styles.find("margin");
|
||||
if (it != styles.end()) {
|
||||
std::vector<std::string> split = ZLStringUtil::split(it->second, " ", true);
|
||||
if (split.size() > 0) {
|
||||
switch (split.size()) {
|
||||
case 1:
|
||||
split.push_back(split[0]);
|
||||
// go through
|
||||
case 2:
|
||||
split.push_back(split[0]);
|
||||
// go through
|
||||
case 3:
|
||||
split.push_back(split[1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
short size;
|
||||
ZLTextStyleEntry::SizeUnit unit;
|
||||
if (parseLength(split[0], size, unit)) {
|
||||
entry->setLength(ZLTextStyleEntry::LENGTH_SPACE_BEFORE, size, unit);
|
||||
}
|
||||
if (parseLength(split[1], size, unit)) {
|
||||
entry->setLength(ZLTextStyleEntry::LENGTH_RIGHT_INDENT, size, unit);
|
||||
}
|
||||
if (parseLength(split[2], size, unit)) {
|
||||
entry->setLength(ZLTextStyleEntry::LENGTH_SPACE_AFTER, size, unit);
|
||||
}
|
||||
if (parseLength(split[3], size, unit)) {
|
||||
entry->setLength(ZLTextStyleEntry::LENGTH_LEFT_INDENT, size, unit);
|
||||
}
|
||||
}
|
||||
setLength(*entry, ZLTextStyleEntry::LENGTH_LEFT_INDENT, styles, "margin-left");
|
||||
setLength(*entry, ZLTextStyleEntry::LENGTH_RIGHT_INDENT, styles, "margin-right");
|
||||
setLength(*entry, ZLTextStyleEntry::LENGTH_FIRST_LINE_INDENT, styles, "text-indent");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue