void DocBookBookReader::endElementHandler(int tag) { switch (tag) { case _SECT1: myReadText = false; popKind(); endContentsParagraph(); insertEndOfSectionParagraph(); break; case _PARA: endParagraph(); break; case _TITLE: endParagraph(); popKind(); endContentsParagraph(); exitTitle(); break; case _EMPHASIS: addControl(EMPHASIS, false); break; case _CITETITLE: addControl(CITE, false); break; case _ULINK: case _EMAIL: addControl(CODE, false); break; case _BLOCKQUOTE: popKind(); break; default: break; } }
void XHTMLTagImageAction::doAtStart(XHTMLReader &reader, const char **xmlattributes) { const char *fileName = reader.attributeValue(xmlattributes, *myPredicate); if (fileName == 0) { return; } const std::string fullfileName = pathPrefix(reader) + MiscUtil::decodeHtmlURL(fileName); ZLFile imageFile(fullfileName); if (!imageFile.exists()) { return; } const bool flagParagraphIsOpen = bookReader(reader).paragraphIsOpen(); if (flagParagraphIsOpen) { if (reader.myCurrentParagraphIsEmpty) { bookReader(reader).addControl(IMAGE, true); } else { endParagraph(reader); } } const std::string imageName = imageFile.name(false); bookReader(reader).addImageReference(imageName, 0, reader.myMarkNextImageAsCover); bookReader(reader).addImage(imageName, new ZLFileImage(imageFile, "", 0, 0, reader.myEncryptionMap->info(imageFile.path()))); reader.myMarkNextImageAsCover = false; if (flagParagraphIsOpen && reader.myCurrentParagraphIsEmpty) { bookReader(reader).addControl(IMAGE, false); endParagraph(reader); } }
void BookReader::addVideoEntry(const ZLVideoEntry &entry) { if (myCurrentTextModel != 0) { mySectionContainsRegularContents = true; endParagraph(); beginParagraph(); myCurrentTextModel->addVideoEntry(entry); endParagraph(); } }
void XHTMLTagImageAction::doAtStart(XHTMLReader &reader, const char **xmlattributes) { const char *fileName = reader.attributeValue(xmlattributes, *myPredicate); if (fileName == 0) { return; } const std::string fullfileName = pathPrefix(reader) + MiscUtil::decodeHtmlURL(fileName); ZLFile imageFile(fullfileName); if (!imageFile.exists()) { return; } bool flag = bookReader(reader).paragraphIsOpen(); if (flag) { endParagraph(reader); } if (std::strlen(fileName) > 2 && std::strncmp(fileName, "./", 2) == 0) { fileName +=2; } bookReader(reader).addImageReference(fullfileName); bookReader(reader).addImage(fullfileName, new ZLFileImage(ZLFile(fullfileName), 0)); if (flag) { beginParagraph(reader); } }
void TxtBookReader::internalEndParagraph() { if (!myLastLineIsEmpty) { myLineFeedCounter = 0; } myLastLineIsEmpty = true; endParagraph(); }
void XHTMLTagRestartParagraphAction::doAtStart(XHTMLReader &reader, const char**) { if (reader.myCurrentParagraphIsEmpty) { bookReader(reader).addData(" "); } endParagraph(reader); beginParagraph(reader); }
void XHTMLTagPreAction::doAtStart(XHTMLReader &reader, const char**) { endParagraph(reader); reader.myParseStack.back().kind = PREFORMATTED; if (++reader.myPreformatted == 1) { beginParagraph(reader); } }
void XHTMLTagBodyAction::doAtEnd(XHTMLReader &reader) { endParagraph(reader); --reader.myBodyCounter; if (reader.myBodyCounter <= 0) { reader.myReadState = XHTML_READ_NOTHING; } }
void XHTMLTagItemAction::doAtStart(XHTMLReader &reader, const char**) { endParagraph(reader); // TODO: increase left indent beginParagraph(reader); // TODO: replace bullet sign by number inside OL tag const std::string bullet = "\xE2\x80\xA2\xC0\xA0"; bookReader(reader).addData(bullet); }
void TxtBookReader::internalEndParagraph() { if (!myLastLineIsEmpty) { //myLineFeedCounter = 0; myLineFeedCounter = -1; /* Fixed by Hatred: zero value was break LINE INDENT formater - second line print with indent like new paragraf */ } myLastLineIsEmpty = true; endParagraph(); }
void BookReader::insertEndParagraph(ZLTextParagraph::Kind kind) { if (myCurrentTextModel != 0 && mySectionContainsRegularContents) { std::size_t size = myCurrentTextModel->paragraphsNumber(); if ((size > 0) && (((*myCurrentTextModel)[(std::size_t)-1])->kind() != kind)) { endParagraph(); ((ZLTextPlainModel&)*myCurrentTextModel).createParagraph(kind); mySectionContainsRegularContents = false; } } }
void XHTMLTagLineBreakAction::doAtEnd(XHTMLReader& reader) { BookReader &br = bookReader(reader); if (br.paragraphIsOpen()) { br.addLineBreak(); } else { beginParagraph(reader); br.addLineBreak(); endParagraph(reader); } }
void PluckerBookReader::safeEndParagraph() { if (myParagraphStarted) { if (myBufferIsEmpty) { static const std::string SPACE = " "; addData(SPACE); } endParagraph(); myParagraphStarted = false; } }
void BookReader::beginParagraph(ZLTextParagraph::Kind kind) { endParagraph(); if (myCurrentTextModel != 0) { ((ZLTextPlainModel&)*myCurrentTextModel).createParagraph(kind); for (std::vector<FBTextKind>::const_iterator it = myKindStack.begin(); it != myKindStack.end(); ++it) { myCurrentTextModel->addControl(*it, true); } if (!myHyperlinkReference.empty()) { myCurrentTextModel->addHyperlinkControl(myHyperlinkKind, myHyperlinkType, myHyperlinkReference); } myModelsWithOpenParagraphs.push_back(myCurrentTextModel); } }
void BookReader::addImageReference(const std::string &id, short vOffset) { if (myCurrentTextModel != 0) { mySectionContainsRegularContents = true; if (myTextParagraphExists) { flushTextBufferToParagraph(); myCurrentTextModel->addImage(id, myModel.imageMap(), vOffset); } else { beginParagraph(); myCurrentTextModel->addControl(IMAGE, true); myCurrentTextModel->addImage(id, myModel.imageMap(), vOffset); myCurrentTextModel->addControl(IMAGE, false); endParagraph(); } } }
void BookReader::addImageReference(const std::string &id, short vOffset, bool isCover) { if (myCurrentTextModel != 0) { mySectionContainsRegularContents = true; if (paragraphIsOpen()) { flushTextBufferToParagraph(); myCurrentTextModel->addImage(id, vOffset, isCover); } else { beginParagraph(); myCurrentTextModel->addControl(IMAGE, true); myCurrentTextModel->addImage(id, vOffset, isCover); myCurrentTextModel->addControl(IMAGE, false); endParagraph(); } } }
void XHTMLTagItemAction::doAtStart(XHTMLReader &reader, const char**) { endParagraph(reader); beginParagraph(reader); if (!reader.myListNumStack.empty()) { bookReader(reader).addFixedHSpace(3 * reader.myListNumStack.size()); int &index = reader.myListNumStack.top(); if (index == 0) { static const std::string bullet = "\xE2\x80\xA2\xC0\xA0"; bookReader(reader).addData(bullet); } else { bookReader(reader).addData(ZLStringUtil::numberToString(index++) + "."); } bookReader(reader).addFixedHSpace(1); } reader.myNewParagraphInProgress = true; }
void XHTMLReader::characterDataHandler(const char *text, std::size_t len) { switch (myReadState) { case XHTML_READ_NOTHING: case XHTML_READ_VIDEO: break; case XHTML_READ_STYLE: if (!myTableParser.isNull()) { myTableParser->parseString(text, len); } break; case XHTML_READ_BODY: if (myPreformatted) { if (*text == '\r' || *text == '\n') { endParagraph(); text += 1; len -= 1; beginParagraph(); myModelReader.addControl(PREFORMATTED, true); } std::size_t spaceCounter = 0; while (spaceCounter < len && std::isspace((unsigned char)*(text + spaceCounter))) { ++spaceCounter; } myModelReader.addFixedHSpace(spaceCounter); text += spaceCounter; len -= spaceCounter; } else if (myNewParagraphInProgress || !myModelReader.paragraphIsOpen()) { while (std::isspace((unsigned char)*text)) { ++text; if (--len == 0) { break; } } } if (len > 0) { myCurrentParagraphIsEmpty = false; if (!myModelReader.paragraphIsOpen()) { myModelReader.beginParagraph(); } myModelReader.addData(std::string(text, len)); myNewParagraphInProgress = false; } break; } }
void printWbePage(char *buffer, int size) { int i; for (i = 0; i < size - 3; ++i) { if (startParagraph(buffer[i], buffer[i + 1], buffer[i + 2])) { print = true; i = i + 3; printf("\n"); } if (endParagraph(buffer[i], buffer[i + 1], buffer[i + 2])) { print = false; printf("\n"); } if (print) { printf("%c", buffer[i]); } } }
void XHTMLReader::restartParagraph() { if (myCurrentParagraphIsEmpty) { myModelReader.addFixedHSpace(1); } ZLTextStyleEntry spaceAfterBlocker(ZLTextStyleEntry::STYLE_OTHER_ENTRY); spaceAfterBlocker.setLength( ZLTextStyleEntry::LENGTH_SPACE_AFTER, 0, ZLTextStyleEntry::SIZE_UNIT_PIXEL ); addTextStyleEntry(spaceAfterBlocker); endParagraph(); beginParagraph(true); ZLTextStyleEntry spaceBeforeBlocker(ZLTextStyleEntry::STYLE_OTHER_ENTRY); spaceBeforeBlocker.setLength( ZLTextStyleEntry::LENGTH_SPACE_BEFORE, 0, ZLTextStyleEntry::SIZE_UNIT_PIXEL ); addTextStyleEntry(spaceBeforeBlocker); }
void XHTMLTagParagraphAction::doAtStart(XHTMLReader &reader, const char**) { endParagraph(reader); }
void XHTMLTagPreAction::doAtEnd(XHTMLReader &reader) { bookReader(reader).addControl(CODE, false); endParagraph(reader); reader.myPreformatted = false; }
void XHTMLTagParagraphWithControlAction::doAtEnd(XHTMLReader &reader) { endParagraph(reader); bookReader(reader).popKind(); }
void XHTMLTagItemAction::doAtEnd(XHTMLReader &reader) { endParagraph(reader); }
void XHTMLTagPreAction::doAtEnd(XHTMLReader &reader) { if (!--reader.myPreformatted) { endParagraph(reader); } }
void XHTMLReader::addPageBreak() { myBottomMargins.resize(0); endParagraph(); myModelReader.insertEndOfSectionParagraph(); }
void XHTMLTagBodyAction::doAtEnd(XHTMLReader &reader) { endParagraph(reader); reader.myReadState = XHTMLReader::READ_NOTHING; }
void XHTMLTagParagraphWithControlAction::doAtEnd(XHTMLReader &reader) { endParagraph(reader); }
void XHTMLTagPreAction::doAtEnd(XHTMLReader &reader) { endParagraph(reader); reader.myPreformatted = false; }
void BookReader::insertEncryptedSectionParagraph() { beginParagraph(ZLTextParagraph::ENCRYPTED_SECTION_PARAGRAPH); endParagraph(); beginParagraph(ZLTextParagraph::END_OF_SECTION_PARAGRAPH); endParagraph(); }