Example #1
0
void XHTMLTagLinkAction::doAtStart(XHTMLReader &reader, const char **xmlattributes) {
	static const std::string REL = "stylesheet";
	const char *rel = reader.attributeValue(xmlattributes, "rel");
	if ((rel == 0) || (REL != rel)) {
		return;
	}
	static const std::string TYPE = "text/css";

	const char *type = reader.attributeValue(xmlattributes, "type");
	if ((type == 0) || (TYPE != type)) {
		return;
	}

	const char *href = reader.attributeValue(xmlattributes, "href");
	if (href == 0) {
		return;
	}

	ZLLogger::Instance().println("CSS", "style file: " + reader.myPathPrefix + MiscUtil::decodeHtmlURL(href));
	shared_ptr<ZLInputStream> cssStream = ZLFile(reader.myPathPrefix + MiscUtil::decodeHtmlURL(href)).inputStream();
	if (cssStream.isNull()) {
		return;
	}
	ZLLogger::Instance().println("CSS", "parsing file");
	StyleSheetTableParser parser(reader.myStyleSheetTable);
	parser.parse(*cssStream);
	//reader.myStyleSheetTable.dump();
}
Example #2
0
void XHTMLTagSourceAction::doAtStart(XHTMLReader &reader, const char **xmlattributes) {
	const char *mime = reader.attributeValue(xmlattributes, "type");
	const char *href = reader.attributeValue(xmlattributes, "src");
	if (mime != 0 && href != 0) {
		reader.myVideoEntry->addSource(
			mime,
			ZLFile(pathPrefix(reader) + MiscUtil::decodeHtmlURL(href)).path()
		);
	}
}
void XHTMLTagHyperlinkAction::doAtStart(XHTMLReader &reader, const char **xmlattributes) {
    const char *href = reader.attributeValue(xmlattributes, "href");
    if (href != 0) {
        const std::string link = (*href == '#') ? (reader.myReferenceName + href) : href;
        FBTextKind hyperlinkType = MiscUtil::isReference(link) ? EXTERNAL_HYPERLINK : INTERNAL_HYPERLINK;
        myHyperlinkStack.push(hyperlinkType);
        bookReader(reader).addHyperlinkControl(hyperlinkType, link);
    } else {
        myHyperlinkStack.push(REGULAR);
    }
    const char *name = reader.attributeValue(xmlattributes, "name");
    if (name != 0) {
        bookReader(reader).addHyperlinkLabel(reader.myReferenceName + "#" + name);
    }
}
Example #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;
	}

	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);
	}
}
Example #5
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);
	}
}
Example #6
0
void XHTMLTagImageAction::doAtStart(XHTMLReader &reader, const char **xmlattributes) {
	// Ignore transparent images
	if (!reader.myParseStack.back().opacity) {
		return;
	}

	const char *fileName = reader.attributeValue(xmlattributes, *myPredicate);
	if (fileName == 0) {
		return;
	}

	const std::string fullfileName = pathPrefix(reader) + MiscUtil::decodeHtmlURL(fileName);
	if (!ZLFile(fullfileName).exists()) {
		return;
	}

	if ((strlen(fileName) > 2) && strncmp(fileName, "./", 2) == 0) {
		fileName +=2;
	}

	reader.myParseStack.back().kind = IMAGE;
	reader.haveContent();
	reader.myModelReader.addImageReference(fullfileName);
	reader.myModelReader.addImage(fullfileName, new ZLFileImage(ZLFile(fullfileName), 0));
}
Example #7
0
void XHTMLTagStyleAction::doAtStart(XHTMLReader &reader, const char **xmlattributes) {
	const char *type = reader.attributeValue(xmlattributes, "type");
	if (!type || strcmp(type, "text/css")) {
		return;
	}

	if (reader.myReadState == XHTMLReader::READ_NOTHING) {
		reader.myReadState = XHTMLReader::READ_STYLE;
		reader.myTableParser = new StyleSheetTableParser(reader.myStyleSheetTable);
	}
}
Example #8
0
void XHTMLTagLinkAction::doAtStart(XHTMLReader &reader, const char **xmlattributes) {
	static const std::string REL = "stylesheet";
	const char *rel = reader.attributeValue(xmlattributes, "rel");
	if (rel == 0 || REL != rel) {
		return;
	}
	static const std::string TYPE = "text/css";

	const char *type = reader.attributeValue(xmlattributes, "type");
	if (type == 0 || TYPE != type) {
		return;
	}

	const char *href = reader.attributeValue(xmlattributes, "href");
	if (href == 0) {
		return;
	}

	std::string cssFilePath = reader.myPathPrefix + MiscUtil::decodeHtmlURL(href);
	//ZLLogger::Instance().registerClass("CSS");
	ZLLogger::Instance().println("CSS", "style file: " + cssFilePath);
	const ZLFile cssFile(cssFilePath);
	cssFilePath = cssFile.path();
	shared_ptr<StyleSheetParserWithCache> parser = reader.myFileParsers[cssFilePath];
	if (parser.isNull()) {
		parser = new StyleSheetParserWithCache(
			cssFile,
			MiscUtil::htmlDirectoryPrefix(cssFilePath),
			0,
			reader.myEncryptionMap
		);
		reader.myFileParsers[cssFilePath] = parser;
		ZLLogger::Instance().println("CSS", "creating stream");
		shared_ptr<ZLInputStream> cssStream = cssFile.inputStream(reader.myEncryptionMap);
		if (!cssStream.isNull()) {
			ZLLogger::Instance().println("CSS", "parsing file");
			parser->parseStream(cssStream);
		}
	}
	parser->applyToTables(reader.myStyleSheetTable, *reader.myFontMap);
}
Example #9
0
void XHTMLTagStyleAction::doAtStart(XHTMLReader &reader, const char **xmlattributes) {
	static const std::string TYPE = "text/css";

	const char *type = reader.attributeValue(xmlattributes, "type");
	if ((type == 0) || (TYPE != type)) {
		return;
	}

	if (reader.myReadState == XHTMLReader::READ_NOTHING) {
		reader.myReadState = XHTMLReader::READ_STYLE;
		reader.myTableParser = new StyleSheetTableParser(reader.myStyleSheetTable);
	}
}
Example #10
0
void XHTMLTagStyleAction::doAtStart(XHTMLReader &reader, const char **xmlattributes) {
	static const std::string TYPE = "text/css";

	const char *type = reader.attributeValue(xmlattributes, "type");
	if ((type == 0) || (TYPE != type)) {
		return;
	}

	if (reader.myReadState == XHTML_READ_NOTHING) {
		reader.myReadState = XHTML_READ_STYLE;
		reader.myTableParser = new StyleSheetTableParser(reader.myPathPrefix, reader.myStyleSheetTable, reader.myFontMap);
		ZLLogger::Instance().println("CSS", "parsing style tag content");
	}
}
Example #11
0
void XHTMLTagHyperlinkAction::doAtStart(XHTMLReader &reader, const char **xmlattributes) {
	const char *href = reader.attributeValue(xmlattributes, "href");
	if (href != 0 && href[0] != '\0') {
		const FBTextKind hyperlinkType = MiscUtil::referenceType(href);
		std::string link = MiscUtil::decodeHtmlURL(href);
		if (hyperlinkType == INTERNAL_HYPERLINK) {
			link = (link[0] == '#') ?
				reader.myReferenceName + link :
				reader.myReferenceDirName + link;
			link = ZLFileUtil::normalizeUnixPath(link);
		}
		myHyperlinkStack.push(hyperlinkType);
		bookReader(reader).addHyperlinkControl(hyperlinkType, link);
	} else {
		myHyperlinkStack.push(REGULAR);
	}
	const char *name = reader.attributeValue(xmlattributes, "name");
	if (name != 0) {
		bookReader(reader).addHyperlinkLabel(
			reader.myReferenceName + "#" + MiscUtil::decodeHtmlURL(name)
		);
	}
}
Example #12
0
void XHTMLTagLinkAction::doAtStart(XHTMLReader &reader, const char **xmlattributes) {
	const char *rel = reader.attributeValue(xmlattributes, "rel");
	if (!rel || strcmp(rel, "stylesheet")) {
		return;
	}

	const char *type = reader.attributeValue(xmlattributes, "type");
	if (!type || strcmp(type, "text/css")) {
		return;
	}

	const char *href = reader.attributeValue(xmlattributes, "href");
	if (href == 0) {
		return;
	}

	shared_ptr<ZLInputStream> cssStream = ZLFile(reader.myPathPrefix + MiscUtil::decodeHtmlURL(href)).inputStream();
	if (cssStream.isNull()) {
		return;
	}
	StyleSheetTableParser parser(reader.myStyleSheetTable);
	parser.parse(*cssStream);
	//reader.myStyleSheetTable.dump();
}
Example #13
0
void XHTMLTagImageAction::doAtStart(XHTMLReader &reader, const char **xmlattributes) {
    const char *fileName = reader.attributeValue(xmlattributes, myNameAttribute.c_str());
    if (fileName != 0) {
        bool flag = bookReader(reader).paragraphIsOpen();
        if (flag) {
            bookReader(reader).endParagraph();
        }
        if ((strlen(fileName) > 2) && strncmp(fileName, "./", 2) == 0) {
            fileName +=2;
        }
        const std::string fullfileName = pathPrefix(reader) + fileName;
        bookReader(reader).addImageReference(fullfileName);
        bookReader(reader).addImage(fullfileName, new ZLFileImage("image/auto", fullfileName, 0));
        if (flag) {
            bookReader(reader).beginParagraph();
        }
    }
}