mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 02:09:35 +02:00
native fb2 images support (in progress)
This commit is contained in:
parent
a213154b62
commit
42e15f1a0b
4 changed files with 22 additions and 23 deletions
|
@ -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)
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include <ZLInputStream.h>
|
||||
#include <ZLStringUtil.h>
|
||||
//#include <ZLBase64EncodedImage.h>
|
||||
#include <ZLFileImage.h>
|
||||
|
||||
#include <ZLTextParagraph.h>
|
||||
|
||||
|
@ -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();
|
||||
|
|
|
@ -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<std::string> myImageBuffer;
|
||||
|
||||
bool mySectionStarted;
|
||||
bool myInsideTitle;
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue