bool TxtBookReader::characterDataHandler(std::string &str) { const char *ptr = str.data(); const char *end = ptr + str.length(); for (; ptr != end; ++ptr) { if (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(); } addData(str); if (myInsideContentsParagraph) { addContentsData(str); } myNewLine = false; } return true; }
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; }
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 */ //__android_log_print(ANDROID_LOG_INFO, "love", "!!!!!,,,%d!!!!!!%d", myLineFeedCounter, myFormat.emptyLinesBeforeNewSection()); if (!myInsideContentsParagraph && (myLineFeedCounter >= myFormat.emptyLinesBeforeNewSection())) { myInsideContentsParagraph = true; paragraphBreak = false; } else if (myInsideContentsParagraph && (myLineFeedCounter <= 1)) { exitTitle(); endContentsParagraph(); popKind(); myInsideContentsParagraph = false; paragraphBreak = true; } } if (true) { internalEndParagraph(); beginParagraph(); } return true; }
void TxtBookReader::endDocumentHandler() { internalEndParagraph(); }