Esempio n. 1
0
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;
	}
}
Esempio n. 2
0
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);
	}
}
Esempio n. 3
0
void BookReader::addVideoEntry(const ZLVideoEntry &entry) {
	if (myCurrentTextModel != 0) {
		mySectionContainsRegularContents = true;
		endParagraph();
		beginParagraph();
		myCurrentTextModel->addVideoEntry(entry);
		endParagraph();
	}
}
Esempio n. 4
0
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);
	}
}
Esempio n. 5
0
void TxtBookReader::internalEndParagraph() {
	if (!myLastLineIsEmpty) {
		myLineFeedCounter = 0;
	}
	myLastLineIsEmpty = true;
	endParagraph();
}
Esempio n. 6
0
void XHTMLTagRestartParagraphAction::doAtStart(XHTMLReader &reader, const char**) {
	if (reader.myCurrentParagraphIsEmpty) {
		bookReader(reader).addData(" ");
	}
	endParagraph(reader);
	beginParagraph(reader);
}
Esempio n. 7
0
void XHTMLTagPreAction::doAtStart(XHTMLReader &reader, const char**) {
	endParagraph(reader);
	reader.myParseStack.back().kind = PREFORMATTED;
	if (++reader.myPreformatted == 1) {
		beginParagraph(reader);
	}
}
Esempio n. 8
0
void XHTMLTagBodyAction::doAtEnd(XHTMLReader &reader) {
	endParagraph(reader);
	--reader.myBodyCounter;
	if (reader.myBodyCounter <= 0) {
		reader.myReadState = XHTML_READ_NOTHING;
	}
}
Esempio n. 9
0
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);
}
Esempio n. 10
0
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();
}
Esempio n. 11
0
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;
		}
	}
}
Esempio n. 12
0
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;
	}
}
Esempio n. 14
0
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);
	}
}
Esempio n. 15
0
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();
		}
	}
}
Esempio n. 16
0
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();
		}
	}
}
Esempio n. 17
0
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;
}
Esempio n. 18
0
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;
	}
}
Esempio n. 19
0
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]);
		}
	}
}
Esempio n. 20
0
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);
}
Esempio n. 21
0
void XHTMLTagParagraphAction::doAtStart(XHTMLReader &reader, const char**) {
	endParagraph(reader);
}
Esempio n. 22
0
void XHTMLTagPreAction::doAtEnd(XHTMLReader &reader) {
	bookReader(reader).addControl(CODE, false);
	endParagraph(reader);
	reader.myPreformatted = false;
}
Esempio n. 23
0
void XHTMLTagParagraphWithControlAction::doAtEnd(XHTMLReader &reader) {
	endParagraph(reader);
	bookReader(reader).popKind();
}
Esempio n. 24
0
void XHTMLTagItemAction::doAtEnd(XHTMLReader &reader) {
	endParagraph(reader);
}
Esempio n. 25
0
void XHTMLTagPreAction::doAtEnd(XHTMLReader &reader) {
	if (!--reader.myPreformatted) {
		endParagraph(reader);
	}
}
Esempio n. 26
0
void XHTMLReader::addPageBreak() {
	myBottomMargins.resize(0);
	endParagraph();
	myModelReader.insertEndOfSectionParagraph();
}
Esempio n. 27
0
void XHTMLTagBodyAction::doAtEnd(XHTMLReader &reader) {
	endParagraph(reader);
	reader.myReadState = XHTMLReader::READ_NOTHING;
}
Esempio n. 28
0
void XHTMLTagParagraphWithControlAction::doAtEnd(XHTMLReader &reader) {
	endParagraph(reader);
}
Esempio n. 29
0
void XHTMLTagPreAction::doAtEnd(XHTMLReader &reader) {
	endParagraph(reader);
	reader.myPreformatted = false;
}
Esempio n. 30
0
void BookReader::insertEncryptedSectionParagraph() {
	beginParagraph(ZLTextParagraph::ENCRYPTED_SECTION_PARAGRAPH);
	endParagraph();
	beginParagraph(ZLTextParagraph::END_OF_SECTION_PARAGRAPH);
	endParagraph();
}