void FB2CoverReader::startElementHandler(int tag, const char **attributes) { switch (tag) { case _COVERPAGE: myReadCoverPage = true; break; case _IMAGE: if (myReadCoverPage) { const std::string hrefName = xlinkNamespace() + ":href"; const char *ref = attributeValue(attributes, hrefName.c_str()); if (ref != 0 && *ref == '#' && *(ref + 1) != '\0') { myImageReference = ref + 1; } } break; case _BINARY: { const char *id = attributeValue(attributes, "id"); const char *contentType = attributeValue(attributes, "content-type"); if (id != 0 && contentType != 0 && myImageReference == id) { myImage = new ZLBase64EncodedImage(contentType); } } } }
void FB2BookReader::startElementHandler(int tag, const char **xmlattributes) { const char *id = attributeValue(xmlattributes, "id"); if (id != 0) { if (!myReadMainText) { myModelReader.setFootnoteTextModel(id); } myModelReader.addHyperlinkLabel(id); } switch (tag) { case _P: if (mySectionStarted) { mySectionStarted = false; } else if (myInsideTitle) { static const std::string SPACE = " "; myModelReader.addContentsData(SPACE); } myModelReader.beginParagraph(); break; case _V: myModelReader.pushKind(VERSE); myModelReader.beginParagraph(); break; case _SUBTITLE: myModelReader.pushKind(SUBTITLE); myModelReader.beginParagraph(); break; case _TEXT_AUTHOR: myModelReader.pushKind(AUTHOR); myModelReader.beginParagraph(); break; case _DATE: myModelReader.pushKind(DATEKIND); myModelReader.beginParagraph(); break; case _CITE: myModelReader.pushKind(CITE); break; case _SECTION: if (myReadMainText) { myModelReader.insertEndOfSectionParagraph(); ++mySectionDepth; myModelReader.beginContentsParagraph(); mySectionStarted = true; } break; case _TITLE: if (myInsidePoem) { myModelReader.pushKind(POEM_TITLE); } else if (mySectionDepth == 0) { myModelReader.insertEndOfSectionParagraph(); myModelReader.pushKind(TITLE); } else { myModelReader.pushKind(SECTION_TITLE); myModelReader.enterTitle(); myInsideTitle = true; } break; case _POEM: myInsidePoem = true; break; case _STANZA: myModelReader.pushKind(STANZA); myModelReader.beginParagraph(ZLTextParagraph::BEFORE_SKIP_PARAGRAPH); myModelReader.endParagraph(); break; case _EPIGRAPH: myModelReader.pushKind(EPIGRAPH); break; case _ANNOTATION: if (myBodyCounter == 0) { myModelReader.setMainTextModel(); } myModelReader.pushKind(ANNOTATION); break; case _COVERPAGE: if (myBodyCounter == 0) { myInsideCoverpage = true; myModelReader.setMainTextModel(); } break; case _SUB: myModelReader.addControl(SUB, true); break; case _SUP: myModelReader.addControl(SUP, true); break; case _CODE: myModelReader.addControl(CODE, true); break; case _STRIKETHROUGH: myModelReader.addControl(STRIKETHROUGH, true); break; case _STRONG: myModelReader.addControl(STRONG, true); break; case _EMPHASIS: myModelReader.addControl(EMPHASIS, true); break; case _A: { const std::string hrefName = xlinkNamespace() + ":href"; const char *ref = attributeValue(xmlattributes, hrefName.c_str()); if (ref != 0) { if (ref[0] == '#') { const char *type = attributeValue(xmlattributes, "type"); static const std::string NOTE = "note"; if ((type != 0) && (NOTE == type)) { myHyperlinkType = FOOTNOTE; } else { myHyperlinkType = INTERNAL_HYPERLINK; } ++ref; } else { myHyperlinkType = EXTERNAL_HYPERLINK; } myModelReader.addHyperlinkControl(myHyperlinkType, ref); } else { myHyperlinkType = FOOTNOTE; myModelReader.addControl(myHyperlinkType, true); } break; } case _IMAGE: { const std::string hrefName = xlinkNamespace() + ":href"; const char *ref = attributeValue(xmlattributes, hrefName.c_str()); //const char *vOffset = attributeValue(xmlattributes, "voffset"); //char offset = (vOffset != 0) ? atoi(vOffset) : 0; if ((ref != 0) && (*ref == '#')) { ++ref; if ((myCoverImageReference != ref) || (myParagraphsBeforeBodyNumber != myModelReader.model().bookTextModel()->paragraphsNumber())) { myModelReader.addImageReference(ref); } if (myInsideCoverpage) { myCoverImageReference = ref; } } break; } case _BINARY: { static const std::string STRANGE_MIME_TYPE = "text/xml"; const char *contentType = attributeValue(xmlattributes, "content-type"); if ((contentType != 0) && (id != 0) && (STRANGE_MIME_TYPE != contentType)) { myCurrentImage = new ZLBase64EncodedImage(contentType); myCurrentImageId.assign(id); myProcessingImage = true; } break; } case _EMPTY_LINE: myModelReader.beginParagraph(ZLTextParagraph::EMPTY_LINE_PARAGRAPH); myModelReader.endParagraph(); break; case _BODY: ++myBodyCounter; myParagraphsBeforeBodyNumber = myModelReader.model().bookTextModel()->paragraphsNumber(); if ((myBodyCounter == 1) || (attributeValue(xmlattributes, "name") == 0)) { myModelReader.setMainTextModel(); myReadMainText = true; } myModelReader.pushKind(REGULAR); break; default: break; } }