Handle "margin" element
This commit is contained in:
parent
a6a17622d7
commit
562c507a75
2 changed files with 36 additions and 2 deletions
|
@ -76,10 +76,15 @@ void StyleSheetTable::setLength(ZLTextStyleEntry &entry, ZLTextStyleEntry::Lengt
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const std::vector<std::string> &values = it->second;
|
const std::vector<std::string> &values = it->second;
|
||||||
if (!values.empty() && !values[0].empty()) {
|
if (!values.empty())
|
||||||
|
setLength(entry, name, values[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void StyleSheetTable::setLength(ZLTextStyleEntry &entry, ZLTextStyleEntry::Length name, const std::string &value) {
|
||||||
|
if (!value.empty()) {
|
||||||
short size;
|
short size;
|
||||||
ZLTextStyleEntry::SizeUnit unit;
|
ZLTextStyleEntry::SizeUnit unit;
|
||||||
parseLength(values[0], size, unit);
|
parseLength(value, size, unit);
|
||||||
entry.setLength(name, size, unit);
|
entry.setLength(name, size, unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,6 +213,34 @@ shared_ptr<ZLTextStyleEntry> StyleSheetTable::createControl(const AttributeMap &
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::vector<std::string> &margins = values(styles, "margin");
|
||||||
|
switch (margins.size()) {
|
||||||
|
case 1:
|
||||||
|
setLength(*entry, ZLTextStyleEntry::LENGTH_SPACE_BEFORE, margins[0]);
|
||||||
|
setLength(*entry, ZLTextStyleEntry::LENGTH_RIGHT_INDENT, margins[0]);
|
||||||
|
setLength(*entry, ZLTextStyleEntry::LENGTH_SPACE_AFTER, margins[0]);
|
||||||
|
setLength(*entry, ZLTextStyleEntry::LENGTH_LEFT_INDENT, margins[0]);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
setLength(*entry, ZLTextStyleEntry::LENGTH_SPACE_BEFORE, margins[0]);
|
||||||
|
setLength(*entry, ZLTextStyleEntry::LENGTH_SPACE_AFTER, margins[0]);
|
||||||
|
setLength(*entry, ZLTextStyleEntry::LENGTH_RIGHT_INDENT, margins[1]);
|
||||||
|
setLength(*entry, ZLTextStyleEntry::LENGTH_LEFT_INDENT, margins[1]);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
setLength(*entry, ZLTextStyleEntry::LENGTH_SPACE_BEFORE, margins[0]);
|
||||||
|
setLength(*entry, ZLTextStyleEntry::LENGTH_RIGHT_INDENT, margins[1]);
|
||||||
|
setLength(*entry, ZLTextStyleEntry::LENGTH_LEFT_INDENT, margins[1]);
|
||||||
|
setLength(*entry, ZLTextStyleEntry::LENGTH_SPACE_AFTER, margins[2]);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
setLength(*entry, ZLTextStyleEntry::LENGTH_SPACE_BEFORE, margins[0]);
|
||||||
|
setLength(*entry, ZLTextStyleEntry::LENGTH_RIGHT_INDENT, margins[1]);
|
||||||
|
setLength(*entry, ZLTextStyleEntry::LENGTH_SPACE_AFTER, margins[2]);
|
||||||
|
setLength(*entry, ZLTextStyleEntry::LENGTH_LEFT_INDENT, margins[3]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
setLength(*entry, ZLTextStyleEntry::LENGTH_LEFT_INDENT, styles, "margin-left");
|
setLength(*entry, ZLTextStyleEntry::LENGTH_LEFT_INDENT, styles, "margin-left");
|
||||||
setLength(*entry, ZLTextStyleEntry::LENGTH_RIGHT_INDENT, styles, "margin-right");
|
setLength(*entry, ZLTextStyleEntry::LENGTH_RIGHT_INDENT, styles, "margin-right");
|
||||||
setLength(*entry, ZLTextStyleEntry::LENGTH_FIRST_LINE_INDENT_DELTA, styles, "text-indent");
|
setLength(*entry, ZLTextStyleEntry::LENGTH_FIRST_LINE_INDENT_DELTA, styles, "text-indent");
|
||||||
|
|
|
@ -38,6 +38,7 @@ private:
|
||||||
void addMap(const std::string &tag, const std::string &aClass, const AttributeMap &map);
|
void addMap(const std::string &tag, const std::string &aClass, const AttributeMap &map);
|
||||||
|
|
||||||
static void setLength(ZLTextStyleEntry &entry, ZLTextStyleEntry::Length name, const AttributeMap &map, const std::string &attributeName);
|
static void setLength(ZLTextStyleEntry &entry, ZLTextStyleEntry::Length name, const AttributeMap &map, const std::string &attributeName);
|
||||||
|
static void setLength(ZLTextStyleEntry &entry, ZLTextStyleEntry::Length name, const std::string &value);
|
||||||
static const std::vector<std::string> &values(const AttributeMap &map, const std::string &name);
|
static const std::vector<std::string> &values(const AttributeMap &map, const std::string &name);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue