Ejemplo n.º 1
0
void XHTMLReader::endElementHandler(const char *tag) {
	bool pageBreak = false;
	ParseContext &context(myParseStack.back());
	if (context.styleIndex >= 0) {
		if (myStyleStack[context.styleIndex].PageBreakAfter == B3_TRUE) {
			// If we are about to have a page break, we don't want
			// endParagraph() to apply pending bottom margins.
			myBottomMargins.resize(0);
			pageBreak = true;
		}
	}

	XHTMLTagAction *action = ourTagActions[ZLUnicodeUtil::toLower(tag)];
	if (action != 0) {
		action->doAtEnd(*this);
	}

	if (pageBreak) {
		addPageBreak();
	}

	if (myModelReader.paragraphIsOpen()) {
		if (context.styleIndex >= 0) {
			myModelReader.addControl(REGULAR, false);
		}
		if (context.kind >= 0) {
			myModelReader.addControl((FBTextKind)context.kind, false);
		}
	}

	if (!context.bottomMarginApplied && elementHasBottomMargin(context)) {
		ZLTextStyleEntry::SizeUnit unit = ZLTextStyleEntry::SIZE_UNIT_PIXEL;
		short size = 0;
		if (context.styleIndex >= 0 && myStyleStack[context.styleIndex].TextStyle.lengthSupported(ZLTextStyleEntry::LENGTH_SPACE_AFTER)) {
			size = myStyleStack[context.styleIndex].TextStyle.length(ZLTextStyleEntry::LENGTH_SPACE_AFTER, unit);
		} else if (context.decoration) {
			const ZLTextFullStyleDecoration *decoration = context.decoration->fullDecoration();
			if (decoration) {
				size = decoration->SpaceAfterOption.value();
				unit = decoration->SpaceAfterOptionUnit;
			}
		}
		if (size > 0) {
			addBottomMargin(size, unit);
		}
	}

	if (!myModelReader.paragraphIsOpen()) {
		applyBottomMargins();
	}

	if (context.styleIndex >= 0) {
		myStyleStack.pop_back();
	}
	myElementStack.pop_back();
	myParseStack.pop_back();
}
Ejemplo n.º 2
0
void XHTMLReader::endElementHandler(const char *tag) {
	for (int i = myCSSStack.back(); i > 0; --i) {
		myModelReader.addStyleCloseEntry();
	}
	myStylesToRemove = myCSSStack.back();
	myCSSStack.pop_back();

	XHTMLTagAction *action = ourTagActions[ZLUnicodeUtil::toLower(tag)];
	if (action != 0) {
		action->doAtEnd(*this);
		myNewParagraphInProgress = false;
	}

	for (; myStylesToRemove > 0; --myStylesToRemove) {
		myStyleEntryStack.pop_back();
	}

	if (myDoPageBreakAfterStack.back()) {
		myModelReader.insertEndOfSectionParagraph();
	}
	myDoPageBreakAfterStack.pop_back();
}
Ejemplo n.º 3
0
void XHTMLReader::endElementHandler(const char *tag) {
	const std::string sTag = ZLUnicodeUtil::toLower(tag);
	if (sTag == "br") {
		return;
	}

	XHTMLTagAction *action = getAction(sTag);
	if (action != 0 && action->isEnabled(myReadState)) {
		action->doAtEnd(*this);
		myNewParagraphInProgress = false;
	}

	for (int i = myTagDataStack.back()->StyleEntries.size(); i > 0; --i) {
		myModelReader.addStyleCloseEntry();
	}

	if (myTagDataStack.back()->PageBreakAfter) {
		myModelReader.insertEndOfSectionParagraph();
	}

	myTagDataStack.pop_back();
}
Ejemplo n.º 4
0
void XHTMLReader::endElementHandler(const char *tag) {
    XHTMLTagAction *action = ourTagActions[ZLUnicodeUtil::toLower(tag)];
    if (action != 0) {
        action->doAtEnd(*this);
    }
}