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; } }
bool TxtBookReader::characterDataHandler(std::string &str) { const char *ptr = str.data(); const char *end = ptr + str.length(); for (; ptr != end; ++ptr) { if (std::isspace((unsigned char)*ptr)) { if (*ptr != '\t') { ++mySpaceCounter; } else { mySpaceCounter += myFormat.ignoredIndent() + 1; // TODO: implement single option in PlainTextFormat } } else { myLastLineIsEmpty = false; break; } } if (ptr != end) { if ((myFormat.breakType() & PlainTextFormat::BREAK_PARAGRAPH_AT_LINE_WITH_INDENT) && myNewLine && (mySpaceCounter > myFormat.ignoredIndent())) { internalEndParagraph(); beginParagraph(); } if (myInsideContentsParagraph && str.length() <= 30) { if(!myHasAddedTitle) { internalEndParagraph(); insertEndOfSectionParagraph(); beginContentsParagraph(); enterTitle(); pushKind(SECTION_TITLE); beginParagraph(); myHasAddedTitle = true; } if(str[str.size() -1] == '\n') { myHasAddedTitle = false; } addContentsData(str); } addData(str); myNewLine = false; } return true; }
bool TxtBookReader::newLineHandler() { if (!myLastLineIsEmpty) { myLineFeedCounter = -1; } myLastLineIsEmpty = true; ++myLineFeedCounter; myNewLine = true; mySpaceCounter = 0; bool paragraphBreak = (myFormat.breakType() & PlainTextFormat::BREAK_PARAGRAPH_AT_NEW_LINE) || ((myFormat.breakType() & PlainTextFormat::BREAK_PARAGRAPH_AT_EMPTY_LINE) && (myLineFeedCounter > 0)); if (myFormat.createContentsTable()) { // if (!myInsideContentsParagraph && (myLineFeedCounter == myFormat.emptyLinesBeforeNewSection() + 1)) { /* Fixed by Hatred: remove '+ 1' for emptyLinesBeforeNewSection, it looks like very strange when we should point count of empty string decrised by 1 in settings dialog */ if (!myInsideContentsParagraph && (myLineFeedCounter == myFormat.emptyLinesBeforeNewSection())) { myInsideContentsParagraph = true; internalEndParagraph(); insertEndOfSectionParagraph(); beginContentsParagraph(); enterTitle(); pushKind(SECTION_TITLE); beginParagraph(); paragraphBreak = false; } if (myInsideContentsParagraph && (myLineFeedCounter == 1)) { exitTitle(); endContentsParagraph(); popKind(); myInsideContentsParagraph = false; paragraphBreak = true; } } if (paragraphBreak) { internalEndParagraph(); beginParagraph(); } return true; }
bool TxtBookReader::newLineHandler() { if (!myLastLineIsEmpty) { myLineFeedCounter = -1; } myLastLineIsEmpty = true; ++myLineFeedCounter; myNewLine = true; mySpaceCounter = 0; bool paragraphBreak = (myFormat.breakType() & PlainTextFormat::BREAK_PARAGRAPH_AT_NEW_LINE) || ((myFormat.breakType() & PlainTextFormat::BREAK_PARAGRAPH_AT_EMPTY_LINE) && (myLineFeedCounter > 0)); if (myFormat.createContentsTable()) { if (!myInsideContentsParagraph && (myLineFeedCounter == myFormat.emptyLinesBeforeNewSection() + 1)) { myInsideContentsParagraph = true; internalEndParagraph(); insertEndOfSectionParagraph(); beginContentsParagraph(); enterTitle(); pushKind(SECTION_TITLE); beginParagraph(); paragraphBreak = false; } if (myInsideContentsParagraph && (myLineFeedCounter == 1)) { exitTitle(); endContentsParagraph(); popKind(); myInsideContentsParagraph = false; paragraphBreak = true; } } if (paragraphBreak) { internalEndParagraph(); beginParagraph(); } return true; }