Calculate margins relative to the base style

This commit is contained in:
Slava Monich 2015-07-07 20:19:44 +03:00
parent 248b307696
commit 16ee7b07c6

View file

@ -125,34 +125,50 @@ short ZLTextForcedStyle::lineStartIndent(const ZLTextStyleEntry::Metrics &metric
ZLTextStyleEntry::Length lengthType = rtl ? ZLTextStyleEntry::Length lengthType = rtl ?
ZLTextStyleEntry::LENGTH_RIGHT_INDENT : ZLTextStyleEntry::LENGTH_RIGHT_INDENT :
ZLTextStyleEntry::LENGTH_LEFT_INDENT; ZLTextStyleEntry::LENGTH_LEFT_INDENT;
return base()->lineStartIndent(metrics, rtl) + ( if (myEntry.lengthSupported(lengthType)) {
myEntry.lengthSupported(lengthType) ? const short baseLen = base()->lineStartIndent(metrics, rtl);
myEntry.length(lengthType, metrics) : ZLTextStyleEntry::Metrics adjusted(metrics);
0); adjusted.FullWidth -= baseLen + base()->lineEndIndent(metrics, rtl);
return baseLen + myEntry.length(lengthType, adjusted);
} else {
return base()->lineStartIndent(metrics, rtl);
}
} }
short ZLTextForcedStyle::lineEndIndent(const ZLTextStyleEntry::Metrics &metrics, bool rtl) const { short ZLTextForcedStyle::lineEndIndent(const ZLTextStyleEntry::Metrics &metrics, bool rtl) const {
ZLTextStyleEntry::Length lengthType = rtl ? ZLTextStyleEntry::Length lengthType = rtl ?
ZLTextStyleEntry::LENGTH_LEFT_INDENT : ZLTextStyleEntry::LENGTH_LEFT_INDENT :
ZLTextStyleEntry::LENGTH_RIGHT_INDENT; ZLTextStyleEntry::LENGTH_RIGHT_INDENT;
return base()->lineEndIndent(metrics, rtl) + ( if (myEntry.lengthSupported(lengthType)) {
myEntry.lengthSupported(lengthType) ? const short baseLen = base()->lineEndIndent(metrics, rtl);
myEntry.length(lengthType, metrics) : ZLTextStyleEntry::Metrics adjusted(metrics);
0); adjusted.FullWidth -= baseLen + base()->lineStartIndent(metrics, rtl);
return baseLen + myEntry.length(lengthType, adjusted);
} else {
return base()->lineEndIndent(metrics, rtl);
}
} }
short ZLTextForcedStyle::spaceBefore(const ZLTextStyleEntry::Metrics &metrics) const { short ZLTextForcedStyle::spaceBefore(const ZLTextStyleEntry::Metrics &metrics) const {
return if (myEntry.lengthSupported(ZLTextStyleEntry::LENGTH_SPACE_BEFORE)) {
myEntry.lengthSupported(ZLTextStyleEntry::LENGTH_SPACE_BEFORE) ? const short baseSpace = base()->spaceBefore(metrics);
myEntry.length(ZLTextStyleEntry::LENGTH_SPACE_BEFORE, metrics) : ZLTextStyleEntry::Metrics adjusted(metrics);
base()->spaceBefore(metrics); adjusted.FullHeight -= baseSpace + base()->spaceAfter(metrics);
return baseSpace + myEntry.length(ZLTextStyleEntry::LENGTH_SPACE_BEFORE, adjusted);
} else {
return base()->spaceBefore(metrics);
}
} }
short ZLTextForcedStyle::spaceAfter(const ZLTextStyleEntry::Metrics &metrics) const { short ZLTextForcedStyle::spaceAfter(const ZLTextStyleEntry::Metrics &metrics) const {
return if (myEntry.lengthSupported(ZLTextStyleEntry::LENGTH_SPACE_AFTER)) {
myEntry.lengthSupported(ZLTextStyleEntry::LENGTH_SPACE_AFTER) ? const short baseSpace = base()->spaceBefore(metrics);
myEntry.length(ZLTextStyleEntry::LENGTH_SPACE_AFTER, metrics) : ZLTextStyleEntry::Metrics adjusted(metrics);
base()->spaceAfter(metrics); adjusted.FullHeight -= baseSpace + base()->spaceBefore(metrics);
return baseSpace + myEntry.length(ZLTextStyleEntry::LENGTH_SPACE_AFTER, adjusted);
} else {
return base()->spaceAfter(metrics);
}
} }
short ZLTextForcedStyle::firstLineIndentDelta(const ZLTextStyleEntry::Metrics &metrics) const { short ZLTextForcedStyle::firstLineIndentDelta(const ZLTextStyleEntry::Metrics &metrics) const {