diff --git a/TODO.1.4.2 b/TODO.1.4.2 index 979f8345e..45c138055 100644 --- a/TODO.1.4.2 +++ b/TODO.1.4.2 @@ -9,10 +9,10 @@ litres: author photos DONE rtf: images * rtf: underline & strikethrough * native fb2 plugin: images -* native fb2 plugin: links * native fb2 plugin: underline * native fb2 plugin: strikethrough * native fb2 plugin: cover +* native fb2 plugin: cover in text * rtf: cover? * better brightness setting: no black screen, brightness "lower than system" (decrease color brightness) diff --git a/jni/NativeFormats/fbreader/src/formats/fb2/FB2BookReader.cpp b/jni/NativeFormats/fbreader/src/formats/fb2/FB2BookReader.cpp index 51e7207d0..4a675ac4a 100644 --- a/jni/NativeFormats/fbreader/src/formats/fb2/FB2BookReader.cpp +++ b/jni/NativeFormats/fbreader/src/formats/fb2/FB2BookReader.cpp @@ -22,7 +22,7 @@ #include #include -//#include +#include #include @@ -37,17 +37,18 @@ FB2BookReader::FB2BookReader(BookModel &model) : myModelReader(model) { mySectionDepth = 0; myBodyCounter = 0; myReadMainText = false; - //myCurrentImage = 0; - myProcessingImage = false; + myCurrentImageStart = -1; mySectionStarted = false; myInsideTitle = false; } void FB2BookReader::characterDataHandler(const char *text, size_t len) { - if ((len > 0) && (myProcessingImage || myModelReader.paragraphIsOpen())) { + if ((len > 0) && (!myCurrentImageId.empty() || myModelReader.paragraphIsOpen())) { std::string str(text, len); - if (myProcessingImage) { - myImageBuffer.push_back(str); + if (!myCurrentImageId.empty()) { + if (myCurrentImageStart == -1) { + myCurrentImageStart = getCurrentPosition(); + } } else { myModelReader.addData(str); if (myInsideTitle) { @@ -183,13 +184,13 @@ void FB2BookReader::startElementHandler(int tag, const char **xmlattributes) { { const std::string hrefName = xlinkNamespace() + ":href"; const char *ref = attributeValue(xmlattributes, hrefName.c_str()); - //const char *vOffset = attributeValue(xmlattributes, "voffset"); - //char offset = (vOffset != 0) ? atoi(vOffset) : 0; + const char *vOffset = attributeValue(xmlattributes, "voffset"); + char offset = (vOffset != 0) ? atoi(vOffset) : 0; if ((ref != 0) && (*ref == '#')) { ++ref; if ((myCoverImageReference != ref) || (myParagraphsBeforeBodyNumber != myModelReader.model().bookTextModel()->paragraphsNumber())) { - //myModelReader.addImageReference(ref); + myModelReader.addImageReference(ref, offset, false); } if (myInsideCoverpage) { myCoverImageReference = ref; @@ -202,9 +203,7 @@ void FB2BookReader::startElementHandler(int tag, const char **xmlattributes) { static const std::string STRANGE_MIME_TYPE = "text/xml"; const char *contentType = attributeValue(xmlattributes, "content-type"); if ((contentType != 0) && (id != 0) && (STRANGE_MIME_TYPE != contentType)) { - //myCurrentImage = new ZLBase64EncodedImage(contentType); myCurrentImageId.assign(id); - myProcessingImage = true; } break; } @@ -302,14 +301,16 @@ void FB2BookReader::endElementHandler(int tag) { myModelReader.addControl(myHyperlinkType, false); break; case _BINARY: - if (!myImageBuffer.empty() && !myCurrentImageId.empty() /*&& myCurrentImage != 0*/) { - //myCurrentImage->addData(myImageBuffer); - //myModelReader.addImage(myCurrentImageId, myCurrentImage); - myImageBuffer.clear(); - myCurrentImageId.clear(); - //myCurrentImage = 0; + if (!myCurrentImageId.empty() && myCurrentImageStart != -1) { + myModelReader.addImage(myCurrentImageId, new ZLFileImage( + myModelReader.model().book()->file(), + "base64", + myCurrentImageStart, + getCurrentPosition() + )); } - myProcessingImage = false; + myCurrentImageId.clear(); + myCurrentImageStart = -1; break; case _BODY: myModelReader.popKind(); diff --git a/jni/NativeFormats/fbreader/src/formats/fb2/FB2BookReader.h b/jni/NativeFormats/fbreader/src/formats/fb2/FB2BookReader.h index 009b6164e..9130dc62e 100644 --- a/jni/NativeFormats/fbreader/src/formats/fb2/FB2BookReader.h +++ b/jni/NativeFormats/fbreader/src/formats/fb2/FB2BookReader.h @@ -24,7 +24,6 @@ #include "../../bookmodel/BookReader.h" class BookModel; -//class ZLBase64EncodedImage; class FB2BookReader : public FB2Reader { @@ -46,10 +45,8 @@ private: bool myInsidePoem; BookReader myModelReader; - //ZLBase64EncodedImage *myCurrentImage; + int myCurrentImageStart; std::string myCurrentImageId; - bool myProcessingImage; - std::vector myImageBuffer; bool mySectionStarted; bool myInsideTitle; diff --git a/src/org/geometerplus/zlibrary/core/image/ZLFileImage.java b/src/org/geometerplus/zlibrary/core/image/ZLFileImage.java index 068d1a959..dbc8b32c7 100644 --- a/src/org/geometerplus/zlibrary/core/image/ZLFileImage.java +++ b/src/org/geometerplus/zlibrary/core/image/ZLFileImage.java @@ -31,6 +31,7 @@ public class ZLFileImage extends ZLSingleImage { public static final String ENCODING_NONE = ""; public static final String ENCODING_HEX = "hex"; + public static final String ENCODING_BASE64 = "base64"; public static ZLFileImage byUrlPath(String urlPath) { try {