1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-04 18:29:23 +02:00

XHTMLReader reused

This commit is contained in:
Nikolay Pultsin 2012-05-11 19:45:05 +01:00
parent e3f3be547b
commit 24d649c9d1
6 changed files with 18 additions and 3 deletions

View file

@ -5,6 +5,7 @@ Larger icon on the site
litres: top/hot lists (what's happen?)
litres: author photos
* Hyperlinks in the SJ book
* Network library initialization in ProcessHyperlinkAction :(
* "Use embedded fonts" option
* "Scan hidden directories" option

View file

@ -248,3 +248,9 @@ shared_ptr<ZLTextStyleEntry> StyleSheetTable::createControl(const AttributeMap &
return entry;
}
void StyleSheetTable::clear() {
myControlMap.clear();
myPageBreakBeforeMap.clear();
myPageBreakAfterMap.clear();
}

View file

@ -47,6 +47,8 @@ public:
bool doBreakAfter(const std::string &tag, const std::string &aClass) const;
shared_ptr<ZLTextStyleEntry> control(const std::string &tag, const std::string &aClass) const;
void clear();
private:
struct Key {
Key(const std::string &tag, const std::string &aClass);

View file

@ -153,6 +153,7 @@ bool OEBBookReader::readBook(const ZLFile &file) {
myModelReader.setMainTextModel();
myModelReader.pushKind(REGULAR);
XHTMLReader xhtmlReader(myModelReader);
bool firstFile = true;
for (std::vector<std::string>::const_iterator it = myHtmlFileNames.begin(); it != myHtmlFileNames.end(); ++it) {
const ZLFile xhtmlFile(myFilePrefix + *it);
@ -162,7 +163,6 @@ bool OEBBookReader::readBook(const ZLFile &file) {
if (!firstFile) {
myModelReader.insertEndOfSectionParagraph();
}
XHTMLReader xhtmlReader(myModelReader);
xhtmlReader.readFile(xhtmlFile, *it);
firstFile = false;
}

View file

@ -500,11 +500,17 @@ bool XHTMLReader::readFile(const ZLFile &file, const std::string &referenceName)
myPreformatted = false;
myNewParagraphInProgress = false;
myReadState = READ_NOTHING;
myCurrentParagraphIsEmpty = true;
myStyleSheetTable.clear();
myCSSStack.clear();
myStyleEntryStack.clear();
myStylesToRemove = 0;
myDoPageBreakAfterStack.clear();
myStyleParser = new StyleSheetSingleStyleParser();
myTableParser.reset();
return readDocument(file);
}
@ -547,7 +553,7 @@ void XHTMLReader::startElementHandler(const char *tag, const char **attributes)
const char *style = attributeValue(attributes, "style");
if (style != 0) {
ZLLogger::Instance().println("CSS", std::string("parsing style attribute: ") + style);
shared_ptr<ZLTextStyleEntry> entry = myStyleParser.parseString(style);
shared_ptr<ZLTextStyleEntry> entry = myStyleParser->parseString(style);
myModelReader.addStyleEntry(*entry);
myStyleEntryStack.push_back(entry);
} else {

View file

@ -88,7 +88,7 @@ private:
int myStylesToRemove;
std::vector<bool> myDoPageBreakAfterStack;
bool myCurrentParagraphIsEmpty;
StyleSheetSingleStyleParser myStyleParser;
shared_ptr<StyleSheetSingleStyleParser> myStyleParser;
shared_ptr<StyleSheetTableParser> myTableParser;
enum {
READ_NOTHING,