1
0
Fork 0
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:
Nikolay Pultsin 2014-09-18 06:25:23 +01:00
parent 81e2abe85d
commit fce3eda3a7
2 changed files with 39 additions and 3 deletions

View file

@ -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");