From eb425467fee2522b29e686421233121e62fe7bfd Mon Sep 17 00:00:00 2001 From: Nikolay Pultsin Date: Sun, 18 Aug 2013 19:28:27 +0100 Subject: [PATCH] ePub: no empty paragraph before & after cover image --- .../fbreader/src/formats/oeb/OEBBookReader.cpp | 7 +++++++ .../fbreader/src/formats/xhtml/XHTMLReader.cpp | 15 ++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/jni/NativeFormats/fbreader/src/formats/oeb/OEBBookReader.cpp b/jni/NativeFormats/fbreader/src/formats/oeb/OEBBookReader.cpp index 59f6532fe..cc656d4b9 100644 --- a/jni/NativeFormats/fbreader/src/formats/oeb/OEBBookReader.cpp +++ b/jni/NativeFormats/fbreader/src/formats/oeb/OEBBookReader.cpp @@ -19,6 +19,7 @@ #include +//#include #include #include #include @@ -203,6 +204,7 @@ bool OEBBookReader::readBook(const ZLFile &file) { myModelReader.setMainTextModel(); myModelReader.pushKind(REGULAR); + //ZLLogger::Instance().registerClass("oeb"); XHTMLReader xhtmlReader(myModelReader); for (std::vector::const_iterator it = myHtmlFileNames.begin(); it != myHtmlFileNames.end(); ++it) { const ZLFile xhtmlFile(myFilePrefix + *it); @@ -219,7 +221,12 @@ bool OEBBookReader::readBook(const ZLFile &file) { } else { myModelReader.insertEndOfSectionParagraph(); } + //ZLLogger::Instance().println("oeb", "start " + xhtmlFile.path()); xhtmlReader.readFile(xhtmlFile, *it); + //ZLLogger::Instance().println("oeb", "end " + xhtmlFile.path()); + //std::string debug = "para count = "; + //ZLStringUtil::appendNumber(debug, myModelReader.model().bookTextModel()->paragraphsNumber()); + //ZLLogger::Instance().println("oeb", debug); } generateTOC(xhtmlReader); diff --git a/jni/NativeFormats/fbreader/src/formats/xhtml/XHTMLReader.cpp b/jni/NativeFormats/fbreader/src/formats/xhtml/XHTMLReader.cpp index aa66607af..e1e594d91 100644 --- a/jni/NativeFormats/fbreader/src/formats/xhtml/XHTMLReader.cpp +++ b/jni/NativeFormats/fbreader/src/formats/xhtml/XHTMLReader.cpp @@ -303,16 +303,21 @@ void XHTMLTagImageAction::doAtStart(XHTMLReader &reader, const char **xmlattribu return; } - bool flag = bookReader(reader).paragraphIsOpen(); - if (flag) { - endParagraph(reader); + const bool flagParagraphIsOpen = bookReader(reader).paragraphIsOpen(); + if (flagParagraphIsOpen) { + if (reader.myCurrentParagraphIsEmpty) { + bookReader(reader).addControl(IMAGE, true); + } else { + endParagraph(reader); + } } const std::string imageName = imageFile.name(false); bookReader(reader).addImageReference(imageName, 0, reader.myMarkNextImageAsCover); bookReader(reader).addImage(imageName, new ZLFileImage(imageFile, "", 0)); reader.myMarkNextImageAsCover = false; - if (flag) { - beginParagraph(reader); + if (flagParagraphIsOpen && reader.myCurrentParagraphIsEmpty) { + bookReader(reader).addControl(IMAGE, false); + endParagraph(reader); } }