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: top/hot lists (what's happen?)
|
||||||
litres: author photos
|
litres: author photos
|
||||||
|
|
||||||
|
* Hyperlinks in the SJ book
|
||||||
* Network library initialization in ProcessHyperlinkAction :(
|
* Network library initialization in ProcessHyperlinkAction :(
|
||||||
* "Use embedded fonts" option
|
* "Use embedded fonts" option
|
||||||
* "Scan hidden directories" option
|
* "Scan hidden directories" option
|
||||||
|
|
|
@ -248,3 +248,9 @@ shared_ptr<ZLTextStyleEntry> StyleSheetTable::createControl(const AttributeMap &
|
||||||
|
|
||||||
return entry;
|
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;
|
bool doBreakAfter(const std::string &tag, const std::string &aClass) const;
|
||||||
shared_ptr<ZLTextStyleEntry> control(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:
|
private:
|
||||||
struct Key {
|
struct Key {
|
||||||
Key(const std::string &tag, const std::string &aClass);
|
Key(const std::string &tag, const std::string &aClass);
|
||||||
|
|
|
@ -153,6 +153,7 @@ bool OEBBookReader::readBook(const ZLFile &file) {
|
||||||
myModelReader.setMainTextModel();
|
myModelReader.setMainTextModel();
|
||||||
myModelReader.pushKind(REGULAR);
|
myModelReader.pushKind(REGULAR);
|
||||||
|
|
||||||
|
XHTMLReader xhtmlReader(myModelReader);
|
||||||
bool firstFile = true;
|
bool firstFile = true;
|
||||||
for (std::vector<std::string>::const_iterator it = myHtmlFileNames.begin(); it != myHtmlFileNames.end(); ++it) {
|
for (std::vector<std::string>::const_iterator it = myHtmlFileNames.begin(); it != myHtmlFileNames.end(); ++it) {
|
||||||
const ZLFile xhtmlFile(myFilePrefix + *it);
|
const ZLFile xhtmlFile(myFilePrefix + *it);
|
||||||
|
@ -162,7 +163,6 @@ bool OEBBookReader::readBook(const ZLFile &file) {
|
||||||
if (!firstFile) {
|
if (!firstFile) {
|
||||||
myModelReader.insertEndOfSectionParagraph();
|
myModelReader.insertEndOfSectionParagraph();
|
||||||
}
|
}
|
||||||
XHTMLReader xhtmlReader(myModelReader);
|
|
||||||
xhtmlReader.readFile(xhtmlFile, *it);
|
xhtmlReader.readFile(xhtmlFile, *it);
|
||||||
firstFile = false;
|
firstFile = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -500,11 +500,17 @@ bool XHTMLReader::readFile(const ZLFile &file, const std::string &referenceName)
|
||||||
myPreformatted = false;
|
myPreformatted = false;
|
||||||
myNewParagraphInProgress = false;
|
myNewParagraphInProgress = false;
|
||||||
myReadState = READ_NOTHING;
|
myReadState = READ_NOTHING;
|
||||||
|
myCurrentParagraphIsEmpty = true;
|
||||||
|
|
||||||
|
myStyleSheetTable.clear();
|
||||||
myCSSStack.clear();
|
myCSSStack.clear();
|
||||||
myStyleEntryStack.clear();
|
myStyleEntryStack.clear();
|
||||||
myStylesToRemove = 0;
|
myStylesToRemove = 0;
|
||||||
|
|
||||||
|
myDoPageBreakAfterStack.clear();
|
||||||
|
myStyleParser = new StyleSheetSingleStyleParser();
|
||||||
|
myTableParser.reset();
|
||||||
|
|
||||||
return readDocument(file);
|
return readDocument(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,7 +553,7 @@ void XHTMLReader::startElementHandler(const char *tag, const char **attributes)
|
||||||
const char *style = attributeValue(attributes, "style");
|
const char *style = attributeValue(attributes, "style");
|
||||||
if (style != 0) {
|
if (style != 0) {
|
||||||
ZLLogger::Instance().println("CSS", std::string("parsing style attribute: ") + style);
|
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);
|
myModelReader.addStyleEntry(*entry);
|
||||||
myStyleEntryStack.push_back(entry);
|
myStyleEntryStack.push_back(entry);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -88,7 +88,7 @@ private:
|
||||||
int myStylesToRemove;
|
int myStylesToRemove;
|
||||||
std::vector<bool> myDoPageBreakAfterStack;
|
std::vector<bool> myDoPageBreakAfterStack;
|
||||||
bool myCurrentParagraphIsEmpty;
|
bool myCurrentParagraphIsEmpty;
|
||||||
StyleSheetSingleStyleParser myStyleParser;
|
shared_ptr<StyleSheetSingleStyleParser> myStyleParser;
|
||||||
shared_ptr<StyleSheetTableParser> myTableParser;
|
shared_ptr<StyleSheetTableParser> myTableParser;
|
||||||
enum {
|
enum {
|
||||||
READ_NOTHING,
|
READ_NOTHING,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue