From 1c04d1b5e5406856e29e897b5425a6839b12db62 Mon Sep 17 00:00:00 2001 From: Nikolay Pultsin Date: Sun, 12 Jul 2015 21:57:01 +0100 Subject: [PATCH] fixed footnotes processing (do not trim footnotes if several paragraphs have ids) --- .../fbreader/src/formats/fb2/FB2BookReader.cpp | 12 +++++++++++- .../fbreader/src/formats/fb2/FB2BookReader.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/jni/NativeFormats/fbreader/src/formats/fb2/FB2BookReader.cpp b/jni/NativeFormats/fbreader/src/formats/fb2/FB2BookReader.cpp index 0a9035a24..1cc6d5c97 100644 --- a/jni/NativeFormats/fbreader/src/formats/fb2/FB2BookReader.cpp +++ b/jni/NativeFormats/fbreader/src/formats/fb2/FB2BookReader.cpp @@ -37,6 +37,7 @@ FB2BookReader::FB2BookReader(BookModel &model) : myModelReader(model) { mySectionDepth = 0; myBodyCounter = 0; myReadMainText = false; + myFootnoteTagDepth = 0; myCurrentImageStart = -1; mySectionStarted = false; myInsideTitle = false; @@ -64,10 +65,15 @@ bool FB2BookReader::processNamespaces() const { } void FB2BookReader::startElementHandler(int tag, const char **xmlattributes) { + if (!myReadMainText && myFootnoteTagDepth > 0) { + ++myFootnoteTagDepth; + } + const char *id = attributeValue(xmlattributes, "id"); if (id != 0 && tag != _BINARY) { - if (!myReadMainText) { + if (!myReadMainText && myFootnoteTagDepth == 0) { myModelReader.setFootnoteTextModel(id); + myFootnoteTagDepth = 1; } myModelReader.addHyperlinkLabel(id); } @@ -255,6 +261,10 @@ void FB2BookReader::startElementHandler(int tag, const char **xmlattributes) { } void FB2BookReader::endElementHandler(int tag) { + if (!myReadMainText && myFootnoteTagDepth > 0) { + --myFootnoteTagDepth; + } + switch (tag) { case _P: case _LI: diff --git a/jni/NativeFormats/fbreader/src/formats/fb2/FB2BookReader.h b/jni/NativeFormats/fbreader/src/formats/fb2/FB2BookReader.h index ec97b436f..8f59bd100 100644 --- a/jni/NativeFormats/fbreader/src/formats/fb2/FB2BookReader.h +++ b/jni/NativeFormats/fbreader/src/formats/fb2/FB2BookReader.h @@ -40,6 +40,7 @@ private: int mySectionDepth; int myBodyCounter; bool myReadMainText; + int myFootnoteTagDepth; bool myInsideCoverpage; std::size_t myParagraphsBeforeBodyNumber; std::string myCoverImageReference;