mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 18:29:23 +02:00
XHTMLReader reused
This commit is contained in:
parent
e3f3be547b
commit
24d649c9d1
6 changed files with 18 additions and 3 deletions
1
TODO.1.5
1
TODO.1.5
|
@ -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
|
||||
|
|
|
@ -248,3 +248,9 @@ shared_ptr<ZLTextStyleEntry> StyleSheetTable::createControl(const AttributeMap &
|
|||
|
||||
return entry;
|
||||
}
|
||||
|
||||
void StyleSheetTable::clear() {
|
||||
myControlMap.clear();
|
||||
myPageBreakBeforeMap.clear();
|
||||
myPageBreakAfterMap.clear();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue