コード例 #1
0
void PluckerBookReader::processHeader(FontType font, bool start) {
	if (start) {
		enterTitle();
		FBTextKind kind;
		switch (font) {
			case FT_H1:
				kind = H1;
				break;
			case FT_H2:
				kind = H2;
				break;
			case FT_H3:
				kind = H3;
				break;
			case FT_H4:
				kind = H4;
				break;
			case FT_H5:
				kind = H5;
				break;
			case FT_H6:
			default:
				kind = H6;
				break;
		}
		pushKind(kind);
	} else {
		popKind();
		exitTitle();
	}
};
コード例 #2
0
ファイル: TxtBookReader.cpp プロジェクト: chenhbzl/BooxApp
void TxtBookReader::startDocumentHandler() {
	setMainTextModel();
	pushKind(REGULAR);
	beginParagraph();
	myLineFeedCounter = 0;
	myInsideContentsParagraph = false;
	enterTitle();
	myLastLineIsEmpty = true;
	myNewLine = true;
	mySpaceCounter = 0;
}
コード例 #3
0
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;
}
コード例 #4
0
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;
}
コード例 #5
0
ファイル: TxtBookReader.cpp プロジェクト: chenhbzl/BooxApp
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;
}
コード例 #6
0
void DocBookBookReader::startElementHandler(int tag, const char **) {
	switch (tag) {
		case _SECT1:
			myReadText = true;
			pushKind(REGULAR);
			beginContentsParagraph();
			break;
		case _PARA:
			if (myReadText) {
				beginParagraph();
			}
			break;
		case _TITLE:
			enterTitle();
			pushKind(SECTION_TITLE);
			if (myReadText) {
				beginParagraph();
			}
			break;
		case _EMPHASIS:
			addControl(EMPHASIS, true);
			break;
		case _CITETITLE:
			addControl(CITE, true);
			break;
		case _ULINK:
		case _EMAIL:
			addControl(CODE, true);
			break;
		case _BLOCKQUOTE:
			pushKind(STRONG);
			break;
		default:
			break;
	}
}