void XHTMLReader::startElementHandler(const char *tag, const char **attributes) { static const std::string HASH = "#"; const char *id = attributeValue(attributes, "id"); if (id != 0) { myModelReader.addHyperlinkLabel(myReferenceAlias + HASH + id); } const std::string sTag = ZLUnicodeUtil::toLower(tag); std::vector<std::string> classesList; const char *aClasses = attributeValue(attributes, "class"); if (aClasses != 0) { const std::vector<std::string> split = ZLStringUtil::split(aClasses, " "); for (std::vector<std::string>::const_iterator it = split.begin(); it != split.end(); ++it) { if (!it->empty()) { classesList.push_back(*it); } } } if (classesList.empty()) { classesList.push_back(""); } bool breakBefore = false; bool breakAfter = false; for (std::vector<std::string>::const_iterator it = classesList.begin(); it != classesList.end(); ++it) { // TODO: use 3-value logic (yes, no, inherit) if (myStyleSheetTable.doBreakBefore(sTag, *it)) { breakBefore = true; } // TODO: use 3-value logic (yes, no, inherit) if (myStyleSheetTable.doBreakAfter(sTag, *it)) { breakAfter = true; } } if (breakBefore) { myModelReader.insertEndOfSectionParagraph(); } myDoPageBreakAfterStack.push_back(breakAfter); XHTMLTagAction *action = getAction(sTag); if (action != 0 && action->isEnabled(myReadState)) { action->doAtStart(*this, attributes); } const int sizeBefore = myStyleEntryStack.size(); addTextStyleEntry(sTag, ""); for (std::vector<std::string>::const_iterator it = classesList.begin(); it != classesList.end(); ++it) { addTextStyleEntry("", *it); addTextStyleEntry(sTag, *it); const char *style = attributeValue(attributes, "style"); if (style != 0) { //ZLLogger::Instance().println("CSS", std::string("parsing style attribute: ") + style); shared_ptr<ZLTextStyleEntry> entry = myStyleParser->parseSingleEntry(style); addTextStyleEntry(*entry); myStyleEntryStack.push_back(entry); } } myCSSStack.push_back(myStyleEntryStack.size() - sizeBefore); }
void XHTMLReader::startElementHandler(const char *tag, const char **attributes) { static const std::string HASH = "#"; const char *id = attributeValue(attributes, "id"); if (id != 0) { myModelReader.addHyperlinkLabel(myReferenceName + HASH + id); } const std::string sTag = ZLUnicodeUtil::toLower(tag); const char *aClass = attributeValue(attributes, "class"); const std::string sClass = (aClass != 0) ? aClass : ""; if (myStyleSheetTable.doBreakBefore(sTag, sClass)) { myModelReader.insertEndOfSectionParagraph(); } myDoPageBreakAfterStack.push_back(myStyleSheetTable.doBreakAfter(sTag, sClass)); XHTMLTagAction *action = ourTagActions[sTag]; if (action != 0) { action->doAtStart(*this, attributes); } const int sizeBefore = myStyleEntryStack.size(); addStyleEntry(sTag, ""); addStyleEntry("", sClass); addStyleEntry(sTag, sClass); const char *style = attributeValue(attributes, "style"); if (style != 0) { shared_ptr<ZLTextStyleEntry> entry = myStyleParser.parseString(style); myModelReader.addControl(*entry); myStyleEntryStack.push_back(entry); } myCSSStack.push_back(myStyleEntryStack.size() - sizeBefore); }
void XHTMLReader::startElementHandler(const char *tag, const char **attributes) { static const std::string HASH = "#"; const char *id = attributeValue(attributes, "id"); const char *inlineStyle = attributeValue(attributes, "style"); const char *klass = attributeValue(attributes, "class"); if (id != 0) { myModelReader.addHyperlinkLabel(myReferenceName + HASH + id); } const std::string sTag = ZLUnicodeUtil::toLower(tag); myElementStack.push_back(StyleSheetTable::Element(sTag, klass, id)); myStyleStack.resize(myStyleStack.size() + 1); StyleSheetTable::Style *style = &myStyleStack.back(); if (myStyleStack.size() > 1) { style->inherit(myStyleStack.at(myStyleStack.size()-2)); } myStyleSheetTable.applyStyles(myElementStack, *style); if (inlineStyle) { style->apply(myStyleParser.parseString(inlineStyle)); } myParseStack.resize(myParseStack.size() + 1); ParseContext &prev(myParseStack.at(myParseStack.size()-2)); ParseContext &context(myParseStack.back()); if (style->TextStyle.opacitySupported()) { int opacity = prev.opacity; opacity *= style->TextStyle.opacity(); opacity /= 255; context.opacity = opacity; } else { context.opacity = prev.opacity; } // Don't collect empty styles if (style->empty()) { myStyleStack.resize(myStyleStack.size()-1); style = NULL; } else { context.styleIndex = myStyleStack.size() - 1; if (style->PageBreakBefore == B3_TRUE) { addPageBreak(); } } XHTMLTagAction *action = ourTagActions[sTag]; if (action != 0) { action->doAtStart(*this, attributes); } if (context.kind >= 0) { context.decoration = ZLTextStyleCollection::Instance().decoration(context.kind); } if (myModelReader.paragraphIsOpen()) { applyStyles(myParseStack.back()); } }
void XHTMLReader::startElementHandler(const char *tag, const char **attributes) { static const std::string HASH = "#"; const char *id = attributeValue(attributes, "id"); if (id != 0) { myModelReader.addHyperlinkLabel(myReferenceName + HASH + id); } XHTMLTagAction *action = ourTagActions[ZLUnicodeUtil::toLower(tag)]; if (action != 0) { action->doAtStart(*this, attributes); } }