mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 01:39:18 +02:00
fixed <ul>/<ol> top/bottom margin behaviour
This commit is contained in:
parent
aae8cd8365
commit
83e3cb355d
5 changed files with 60 additions and 7 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
===== 2.1.4 (Sep ??, 2014) =====
|
||||
* (planned) Fixed authors list/tags list editing
|
||||
* CSS: fixed <ul>/<ol> top/bottom margin behaviour
|
||||
|
||||
===== 2.1.3 (Sep 18, 2014) =====
|
||||
* CSS: fixed multiple entries for same selector
|
||||
|
|
|
@ -329,17 +329,25 @@ XHTMLTagListAction::XHTMLTagListAction(int startIndex) : myStartIndex(startIndex
|
|||
|
||||
void XHTMLTagListAction::doAtStart(XHTMLReader &reader, const char**) {
|
||||
reader.myListNumStack.push(myStartIndex);
|
||||
beginParagraph(reader);
|
||||
}
|
||||
|
||||
void XHTMLTagListAction::doAtEnd(XHTMLReader &reader) {
|
||||
endParagraph(reader);
|
||||
if (!reader.myListNumStack.empty()) {
|
||||
reader.myListNumStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
void XHTMLTagItemAction::doAtStart(XHTMLReader &reader, const char**) {
|
||||
endParagraph(reader);
|
||||
beginParagraph(reader);
|
||||
bool restart = true;
|
||||
if (reader.myTagDataStack.size() >= 2) {
|
||||
restart = reader.myTagDataStack[reader.myTagDataStack.size() - 2]->ChildCount > 1;
|
||||
}
|
||||
if (restart) {
|
||||
endParagraph(reader);
|
||||
beginParagraph(reader);
|
||||
}
|
||||
if (!reader.myListNumStack.empty()) {
|
||||
bookReader(reader).addFixedHSpace(3 * reader.myListNumStack.size());
|
||||
int &index = reader.myListNumStack.top();
|
||||
|
@ -355,7 +363,6 @@ void XHTMLTagItemAction::doAtStart(XHTMLReader &reader, const char**) {
|
|||
}
|
||||
|
||||
void XHTMLTagItemAction::doAtEnd(XHTMLReader &reader) {
|
||||
endParagraph(reader);
|
||||
}
|
||||
|
||||
bool XHTMLTagVideoAction::isEnabled(XHTMLReadingState state) {
|
||||
|
@ -673,7 +680,7 @@ bool XHTMLReader::readFile(const ZLFile &file, const std::string &referenceName)
|
|||
bool XHTMLReader::addTextStyleEntry(const std::string tag, const std::string aClass) {
|
||||
shared_ptr<ZLTextStyleEntry> entry = myStyleSheetTable.control(tag, aClass);
|
||||
if (!entry.isNull()) {
|
||||
addTextStyleEntry(*entry);
|
||||
addTextStyleEntry(*(entry->start()));
|
||||
myTagDataStack.back()->StyleEntries.push_back(entry);
|
||||
return true;
|
||||
}
|
||||
|
@ -725,6 +732,9 @@ void XHTMLReader::startElementHandler(const char *tag, const char **attributes)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!myTagDataStack.empty()) {
|
||||
myTagDataStack.back()->ChildCount += 1;
|
||||
}
|
||||
myTagDataStack.push_back(new TagData());
|
||||
|
||||
static const std::string HASH = "#";
|
||||
|
@ -783,17 +793,28 @@ void XHTMLReader::endElementHandler(const char *tag) {
|
|||
return;
|
||||
}
|
||||
|
||||
const TagData &tagData = *myTagDataStack.back();
|
||||
const std::vector<shared_ptr<ZLTextStyleEntry> > &entries = tagData.StyleEntries;
|
||||
size_t entryCount = entries.size();
|
||||
for (std::vector<shared_ptr<ZLTextStyleEntry> >::const_iterator jt = entries.begin(); jt != entries.end(); ++jt) {
|
||||
shared_ptr<ZLTextStyleEntry> endEntry = (*jt)->end();
|
||||
if (!endEntry.isNull()) {
|
||||
addTextStyleEntry(*endEntry);
|
||||
++entryCount;
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
for (; entryCount > 0; --entryCount) {
|
||||
myModelReader.addStyleCloseEntry();
|
||||
}
|
||||
|
||||
if (myTagDataStack.back()->PageBreakAfter) {
|
||||
if (tagData.PageBreakAfter) {
|
||||
myModelReader.insertEndOfSectionParagraph();
|
||||
}
|
||||
|
||||
|
@ -811,7 +832,7 @@ void XHTMLReader::beginParagraph(bool restarted) {
|
|||
const std::vector<shared_ptr<ZLTextStyleEntry> > &entries = (*it)->StyleEntries;
|
||||
bool inheritedOnly = !restarted || it + 1 != myTagDataStack.end();
|
||||
for (std::vector<shared_ptr<ZLTextStyleEntry> >::const_iterator jt = entries.begin(); jt != entries.end(); ++jt) {
|
||||
shared_ptr<ZLTextStyleEntry> entry = inheritedOnly ? (*jt)->inherited() : *jt;
|
||||
shared_ptr<ZLTextStyleEntry> entry = inheritedOnly ? (*jt)->inherited() : (*jt)->start();
|
||||
addTextStyleEntry(*entry);
|
||||
}
|
||||
}
|
||||
|
@ -929,3 +950,6 @@ const std::string &XHTMLReader::fileAlias(const std::string &fileName) const {
|
|||
it = myFileNumbers.find(correctedFileName);
|
||||
return it->second;
|
||||
}
|
||||
|
||||
XHTMLReader::TagData::TagData() : PageBreakAfter(false), ChildCount(0) {
|
||||
}
|
||||
|
|
|
@ -70,6 +70,9 @@ public:
|
|||
std::vector<FBTextKind> TextKinds;
|
||||
std::vector<shared_ptr<ZLTextStyleEntry> > StyleEntries;
|
||||
bool PageBreakAfter;
|
||||
size_t ChildCount;
|
||||
|
||||
TagData();
|
||||
};
|
||||
|
||||
public:
|
||||
|
|
|
@ -19,6 +19,29 @@
|
|||
|
||||
#include "ZLTextStyleEntry.h"
|
||||
|
||||
shared_ptr<ZLTextStyleEntry> ZLTextStyleEntry::start() const {
|
||||
ZLTextStyleEntry *clone = new ZLTextStyleEntry(myEntryKind);
|
||||
clone->myFeatureMask = myFeatureMask & ~(1 << LENGTH_SPACE_AFTER);
|
||||
for (int i = 0; i < NUMBER_OF_LENGTHS; ++i) {
|
||||
clone->myLengths[i] = myLengths[i];
|
||||
}
|
||||
clone->myAlignmentType = myAlignmentType;
|
||||
clone->mySupportedFontModifier = mySupportedFontModifier;
|
||||
clone->myFontModifier = myFontModifier;
|
||||
clone->myFontFamilies = myFontFamilies;
|
||||
return clone;
|
||||
}
|
||||
|
||||
shared_ptr<ZLTextStyleEntry> ZLTextStyleEntry::end() const {
|
||||
if ((myFeatureMask & (1 << LENGTH_SPACE_AFTER)) == 0) {
|
||||
return 0;
|
||||
}
|
||||
ZLTextStyleEntry *clone = new ZLTextStyleEntry(myEntryKind);
|
||||
clone->myFeatureMask = 1 << LENGTH_SPACE_AFTER;
|
||||
clone->myLengths[LENGTH_SPACE_AFTER] = myLengths[LENGTH_SPACE_AFTER];
|
||||
return clone;
|
||||
}
|
||||
|
||||
shared_ptr<ZLTextStyleEntry> ZLTextStyleEntry::inherited() const {
|
||||
ZLTextStyleEntry *clone = new ZLTextStyleEntry(myEntryKind);
|
||||
clone->myFeatureMask = myFeatureMask & ~(1 << LENGTH_SPACE_BEFORE) & ~(1 << LENGTH_SPACE_AFTER);
|
||||
|
|
|
@ -102,6 +102,8 @@ public:
|
|||
const std::vector<std::string> &fontFamilies() const;
|
||||
void setFontFamilies(const std::vector<std::string> &fontFamilies);
|
||||
|
||||
shared_ptr<ZLTextStyleEntry> start() const;
|
||||
shared_ptr<ZLTextStyleEntry> end() const;
|
||||
shared_ptr<ZLTextStyleEntry> inherited() const;
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue