void ZLTextStyleReader::startElementHandler(const char *tag, const char **attributes) { static const std::string BASE = "base"; static const std::string STYLE = "style"; if (BASE == tag) { myCollection.myBaseStyle.reset(new ZLTextBaseStyle(attributeValue(attributes, "family"), intValue(attributes, "fontSize"))); } else if (STYLE == tag) { const char *idString = attributeValue(attributes, "id"); const char *name = attributeValue(attributes, "name"); if ((idString != 0) && (name != 0)) { ZLTextKind id = (ZLTextKind)atoi(idString); ZLTextStyleDecoration *decoration; int fontSizeDelta = intValue(attributes, "fontSizeDelta"); ZLBoolean3 bold = b3Value(attributes, "bold"); ZLBoolean3 italic = b3Value(attributes, "italic"); int verticalShift = intValue(attributes, "vShift"); ZLBoolean3 allowHyphenations = b3Value(attributes, "allowHyphenations"); if (booleanValue(attributes, "partial")) { decoration = new ZLTextStyleDecoration(name, fontSizeDelta, bold, italic, verticalShift, allowHyphenations); } else { int spaceBefore = intValue(attributes, "spaceBefore"); int spaceAfter = intValue(attributes, "spaceAfter"); int leftIndent = intValue(attributes, "leftIndent"); int rightIndent = intValue(attributes, "rightIndent"); int firstLineIndentDelta = intValue(attributes, "firstLineIndentDelta"); ZLTextAlignmentType alignment = ALIGN_UNDEFINED; const char *alignmentString = attributeValue(attributes, "alignment"); if (alignmentString != 0) { if (strcmp(alignmentString, "left") == 0) { alignment = ALIGN_LEFT; } else if (strcmp(alignmentString, "rigth") == 0) { alignment = ALIGN_RIGHT; } else if (strcmp(alignmentString, "center") == 0) { alignment = ALIGN_CENTER; } else if (strcmp(alignmentString, "justify") == 0) { alignment = ALIGN_JUSTIFY; } } const int lineSpacingPercent = intValue(attributes, "lineSpacingPercent", -1); const double lineSpace = (lineSpacingPercent == -1) ? 0.0 : (lineSpacingPercent / 100.0); decoration = new ZLTextFullStyleDecoration(name, fontSizeDelta, bold, italic, spaceBefore, spaceAfter, leftIndent, rightIndent, firstLineIndentDelta, verticalShift, alignment, lineSpace, allowHyphenations); } const char *hyperlink = attributeValue(attributes, "hyperlink"); if (hyperlink != 0) { decoration->setHyperlinkStyle(hyperlink); } const char *fontFamily = attributeValue(attributes, "family"); if (fontFamily != 0) { decoration->FontFamilyOption.setValue(fontFamily); } myCollection.myDecorationMap.insert(std::pair<ZLTextKind,ZLTextStyleDecoration*>(id, decoration)); } } }
void StyleReader::startElementHandler(const char *tag, const char **attributes) { static const std::string BASE = "base"; static const std::string STYLE = "style"; if (BASE == tag) { myCollection.myBaseStyle = new BaseTextStyle(attributeValue(attributes, "family"), intValue(attributes, "fontSize")); } else if (STYLE == tag) { const char *idString = attributeValue(attributes, "id"); const char *name = attributeValue(attributes, "name"); if ((idString != 0) && (name != 0)) { TextKind id = (TextKind)atoi(idString); TextStyleDecoration *decoration; int fontSizeDelta = intValue(attributes, "fontSizeDelta"); Boolean3 bold = b3Value(attributes, "bold"); Boolean3 italic = b3Value(attributes, "italic"); int verticalShift = intValue(attributes, "vShift"); Boolean3 allowHyphenations = b3Value(attributes, "allowHyphenations"); bool isHyperlink = booleanValue(attributes, "isHyperlink"); if (booleanValue(attributes, "partial")) { decoration = new TextStyleDecoration(name, fontSizeDelta, bold, italic, verticalShift, allowHyphenations); } else { int spaceBefore = intValue(attributes, "spaceBefore"); int spaceAfter = intValue(attributes, "spaceAfter"); int leftIndent = intValue(attributes, "leftIndent"); int rightIndent = intValue(attributes, "rightIndent"); int firstLineIndentDelta = intValue(attributes, "firstLineIndentDelta"); AlignmentType alignment = ALIGN_UNDEFINED; const char *alignmentString = attributeValue(attributes, "alignment"); if (alignmentString != 0) { if (strcmp(alignmentString, "left") == 0) { alignment = ALIGN_LEFT; } else if (strcmp(alignmentString, "rigth") == 0) { alignment = ALIGN_RIGHT; } else if (strcmp(alignmentString, "center") == 0) { alignment = ALIGN_CENTER; } else if (strcmp(alignmentString, "justify") == 0) { alignment = ALIGN_JUSTIFY; } } double lineSpace = doubleValue(attributes, "lineSpace"); decoration = new FullTextStyleDecoration(name, fontSizeDelta, bold, italic, spaceBefore, spaceAfter, leftIndent, rightIndent, firstLineIndentDelta, verticalShift, alignment, lineSpace, allowHyphenations); } if (isHyperlink) { decoration->setHyperlinkStyle(); } myCollection.myDecorationMap.insert(std::pair<TextKind,TextStyleDecoration*>(id, decoration)); } } }
ZLBoolean3 StyleSheetTable::doBreakAfter(const std::string &tag, const std::string &aClass) const { std::map<CSSSelector,bool>::const_iterator it = myPageBreakAfterMap.find(CSSSelector(tag, aClass)); if (it != myPageBreakAfterMap.end()) { return b3Value(it->second); } it = myPageBreakAfterMap.find(CSSSelector("", aClass)); if (it != myPageBreakAfterMap.end()) { return b3Value(it->second); } it = myPageBreakAfterMap.find(CSSSelector(tag, "")); if (it != myPageBreakAfterMap.end()) { return b3Value(it->second); } return B3_UNDEFINED; }