1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-05 19:42:17 +02:00

removed extra paragraph break after footnotes

This commit is contained in:
Nikolay Pultsin 2012-11-04 10:19:39 +04:00
parent d552496d2e
commit a3246a3b98
5 changed files with 30 additions and 20 deletions

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.geometerplus.zlibrary.ui.android" android:versionCode="106051" android:versionName="1.6.5" android:installLocation="auto"> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.geometerplus.zlibrary.ui.android" android:versionCode="106061" android:versionName="1.6.6" android:installLocation="auto">
<uses-sdk android:minSdkVersion="5" android:maxSdkVersion="10"/> <uses-sdk android:minSdkVersion="5" android:maxSdkVersion="10"/>
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:anyDensity="true"/> <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:anyDensity="true"/>
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>

View file

@ -1,3 +1,6 @@
===== 1.6.6 (Nov ??, 2012) =====
* Fixed 'extra paragraph break after each footnote mark' issue for RTFs (and may be some other formats)
===== 1.6.5 (Nov 04, 2012) ===== ===== 1.6.5 (Nov 04, 2012) =====
* Fixed footnotes processing in rtf's * Fixed footnotes processing in rtf's
* Updated Czech localization (by Marek Pavelka) * Updated Czech localization (by Marek Pavelka)

View file

@ -1 +1 @@
1.6.5 1.6.6

View file

@ -35,8 +35,6 @@
BookReader::BookReader(BookModel &model) : myModel(model) { BookReader::BookReader(BookModel &model) : myModel(model) {
myCurrentTextModel = 0; myCurrentTextModel = 0;
myTextParagraphExists = false;
myInsideTitle = false; myInsideTitle = false;
mySectionContainsRegularContents = false; mySectionContainsRegularContents = false;
} }
@ -61,6 +59,18 @@ void BookReader::setFootnoteTextModel(const std::string &id) {
} }
} }
bool BookReader::paragraphIsOpen() const {
if (myCurrentTextModel.isNull()) {
return false;
}
for (std::list<shared_ptr<ZLTextModel> >::const_iterator it = myModelsWithOpenParagraphs.begin(); it != myModelsWithOpenParagraphs.end(); ++it) {
if (*it == myCurrentTextModel) {
return true;
}
}
return false;
}
void BookReader::unsetTextModel() { void BookReader::unsetTextModel() {
myCurrentTextModel = 0; myCurrentTextModel = 0;
} }
@ -91,19 +101,19 @@ void BookReader::beginParagraph(ZLTextParagraph::Kind kind) {
if (!myHyperlinkReference.empty()) { if (!myHyperlinkReference.empty()) {
myCurrentTextModel->addHyperlinkControl(myHyperlinkKind, myHyperlinkType, myHyperlinkReference); myCurrentTextModel->addHyperlinkControl(myHyperlinkKind, myHyperlinkType, myHyperlinkReference);
} }
myTextParagraphExists = true; myModelsWithOpenParagraphs.push_back(myCurrentTextModel);
} }
} }
void BookReader::endParagraph() { void BookReader::endParagraph() {
if (myTextParagraphExists) { if (paragraphIsOpen()) {
flushTextBufferToParagraph(); flushTextBufferToParagraph();
myTextParagraphExists = false; myModelsWithOpenParagraphs.remove(myCurrentTextModel);
} }
} }
void BookReader::addControl(FBTextKind kind, bool start) { void BookReader::addControl(FBTextKind kind, bool start) {
if (myTextParagraphExists) { if (paragraphIsOpen()) {
flushTextBufferToParagraph(); flushTextBufferToParagraph();
myCurrentTextModel->addControl(kind, start); myCurrentTextModel->addControl(kind, start);
} }
@ -113,21 +123,21 @@ void BookReader::addControl(FBTextKind kind, bool start) {
} }
void BookReader::addStyleEntry(const ZLTextStyleEntry &entry) { void BookReader::addStyleEntry(const ZLTextStyleEntry &entry) {
if (myTextParagraphExists) { if (paragraphIsOpen()) {
flushTextBufferToParagraph(); flushTextBufferToParagraph();
myCurrentTextModel->addStyleEntry(entry); myCurrentTextModel->addStyleEntry(entry);
} }
} }
void BookReader::addStyleCloseEntry() { void BookReader::addStyleCloseEntry() {
if (myTextParagraphExists) { if (paragraphIsOpen()) {
flushTextBufferToParagraph(); flushTextBufferToParagraph();
myCurrentTextModel->addStyleCloseEntry(); myCurrentTextModel->addStyleCloseEntry();
} }
} }
void BookReader::addFixedHSpace(unsigned char length) { void BookReader::addFixedHSpace(unsigned char length) {
if (myTextParagraphExists) { if (paragraphIsOpen()) {
myCurrentTextModel->addFixedHSpace(length); myCurrentTextModel->addFixedHSpace(length);
} }
} }
@ -157,7 +167,7 @@ void BookReader::addHyperlinkControl(FBTextKind kind, const std::string &label)
"hyperlink", "hyperlink",
" + control (" + type + "): " + label " + control (" + type + "): " + label
); );
if (myTextParagraphExists) { if (paragraphIsOpen()) {
flushTextBufferToParagraph(); flushTextBufferToParagraph();
myCurrentTextModel->addHyperlinkControl(kind, myHyperlinkType, label); myCurrentTextModel->addHyperlinkControl(kind, myHyperlinkType, label);
} }
@ -167,7 +177,7 @@ void BookReader::addHyperlinkControl(FBTextKind kind, const std::string &label)
void BookReader::addHyperlinkLabel(const std::string &label) { void BookReader::addHyperlinkLabel(const std::string &label) {
if (!myCurrentTextModel.isNull()) { if (!myCurrentTextModel.isNull()) {
int paragraphNumber = myCurrentTextModel->paragraphsNumber(); int paragraphNumber = myCurrentTextModel->paragraphsNumber();
if (myTextParagraphExists) { if (paragraphIsOpen()) {
--paragraphNumber; --paragraphNumber;
} }
addHyperlinkLabel(label, paragraphNumber); addHyperlinkLabel(label, paragraphNumber);
@ -185,7 +195,7 @@ void BookReader::addHyperlinkLabel(const std::string &label, int paragraphNumber
} }
void BookReader::addData(const std::string &data) { void BookReader::addData(const std::string &data) {
if (!data.empty() && myTextParagraphExists) { if (!data.empty() && paragraphIsOpen()) {
if (!myInsideTitle) { if (!myInsideTitle) {
mySectionContainsRegularContents = true; mySectionContainsRegularContents = true;
} }
@ -240,7 +250,7 @@ void BookReader::insertEndOfTextParagraph() {
void BookReader::addImageReference(const std::string &id, short vOffset, bool isCover) { void BookReader::addImageReference(const std::string &id, short vOffset, bool isCover) {
if (myCurrentTextModel != 0) { if (myCurrentTextModel != 0) {
mySectionContainsRegularContents = true; mySectionContainsRegularContents = true;
if (myTextParagraphExists) { if (paragraphIsOpen()) {
flushTextBufferToParagraph(); flushTextBufferToParagraph();
myCurrentTextModel->addImage(id, vOffset, isCover); myCurrentTextModel->addImage(id, vOffset, isCover);
} else { } else {

View file

@ -21,6 +21,7 @@
#define __BOOKREADER_H__ #define __BOOKREADER_H__
#include <vector> #include <vector>
#include <list>
#include <stack> #include <stack>
#include <string> #include <string>
@ -89,10 +90,10 @@ private:
private: private:
BookModel &myModel; BookModel &myModel;
shared_ptr<ZLTextModel> myCurrentTextModel; shared_ptr<ZLTextModel> myCurrentTextModel;
std::list<shared_ptr<ZLTextModel> > myModelsWithOpenParagraphs;
std::vector<FBTextKind> myKindStack; std::vector<FBTextKind> myKindStack;
bool myTextParagraphExists;
bool myContentsParagraphExists; bool myContentsParagraphExists;
std::stack<shared_ptr<ContentsTree> > myContentsTreeStack; std::stack<shared_ptr<ContentsTree> > myContentsTreeStack;
@ -108,10 +109,6 @@ private:
shared_ptr<ZLCachedMemoryAllocator> myFootnotesAllocator; shared_ptr<ZLCachedMemoryAllocator> myFootnotesAllocator;
}; };
inline bool BookReader::paragraphIsOpen() const {
return myTextParagraphExists;
}
inline bool BookReader::contentsParagraphIsOpen() const { inline bool BookReader::contentsParagraphIsOpen() const {
return myContentsParagraphExists; return myContentsParagraphExists;
} }