mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 17:59:33 +02:00
native fb2 support (in progress)
This commit is contained in:
parent
4d90732a37
commit
e80b6e8015
10 changed files with 35 additions and 16 deletions
|
@ -90,6 +90,12 @@ LOCAL_SRC_FILES := \
|
|||
NativeFormats/fbreader/src/formats/EncodedTextReader.cpp \
|
||||
NativeFormats/fbreader/src/formats/FormatPlugin.cpp \
|
||||
NativeFormats/fbreader/src/formats/PluginCollection.cpp \
|
||||
NativeFormats/fbreader/src/formats/fb2/FB2BookReader.cpp \
|
||||
NativeFormats/fbreader/src/formats/fb2/FB2CoverReader.cpp \
|
||||
NativeFormats/fbreader/src/formats/fb2/FB2MetaInfoReader.cpp \
|
||||
NativeFormats/fbreader/src/formats/fb2/FB2Plugin.cpp \
|
||||
NativeFormats/fbreader/src/formats/fb2/FB2Reader.cpp \
|
||||
NativeFormats/fbreader/src/formats/fb2/FB2TagManager.cpp \
|
||||
NativeFormats/fbreader/src/formats/rtf/RtfBookReader.cpp \
|
||||
NativeFormats/fbreader/src/formats/rtf/RtfDescriptionReader.cpp \
|
||||
NativeFormats/fbreader/src/formats/rtf/RtfPlugin.cpp \
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include <ZLInputStream.h>
|
||||
#include <ZLStringUtil.h>
|
||||
#include <ZLBase64EncodedImage.h>
|
||||
//#include <ZLBase64EncodedImage.h>
|
||||
|
||||
#include <ZLTextParagraph.h>
|
||||
|
||||
|
@ -37,7 +37,7 @@ FB2BookReader::FB2BookReader(BookModel &model) : myModelReader(model) {
|
|||
mySectionDepth = 0;
|
||||
myBodyCounter = 0;
|
||||
myReadMainText = false;
|
||||
myCurrentImage = 0;
|
||||
//myCurrentImage = 0;
|
||||
myProcessingImage = false;
|
||||
mySectionStarted = false;
|
||||
myInsideTitle = false;
|
||||
|
@ -189,7 +189,7 @@ void FB2BookReader::startElementHandler(int tag, const char **xmlattributes) {
|
|||
++ref;
|
||||
if ((myCoverImageReference != ref) ||
|
||||
(myParagraphsBeforeBodyNumber != myModelReader.model().bookTextModel()->paragraphsNumber())) {
|
||||
myModelReader.addImageReference(ref);
|
||||
//myModelReader.addImageReference(ref);
|
||||
}
|
||||
if (myInsideCoverpage) {
|
||||
myCoverImageReference = ref;
|
||||
|
@ -202,7 +202,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);
|
||||
//myCurrentImage = new ZLBase64EncodedImage(contentType);
|
||||
myCurrentImageId.assign(id);
|
||||
myProcessingImage = true;
|
||||
}
|
||||
|
@ -302,12 +302,12 @@ 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);
|
||||
if (!myImageBuffer.empty() && !myCurrentImageId.empty() /*&& myCurrentImage != 0*/) {
|
||||
//myCurrentImage->addData(myImageBuffer);
|
||||
//myModelReader.addImage(myCurrentImageId, myCurrentImage);
|
||||
myImageBuffer.clear();
|
||||
myCurrentImageId.clear();
|
||||
myCurrentImage = 0;
|
||||
//myCurrentImage = 0;
|
||||
}
|
||||
myProcessingImage = false;
|
||||
break;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "../../bookmodel/BookReader.h"
|
||||
|
||||
class BookModel;
|
||||
class ZLBase64EncodedImage;
|
||||
//class ZLBase64EncodedImage;
|
||||
|
||||
class FB2BookReader : public FB2Reader {
|
||||
|
||||
|
@ -46,7 +46,7 @@ private:
|
|||
bool myInsidePoem;
|
||||
BookReader myModelReader;
|
||||
|
||||
ZLBase64EncodedImage *myCurrentImage;
|
||||
//ZLBase64EncodedImage *myCurrentImage;
|
||||
std::string myCurrentImageId;
|
||||
bool myProcessingImage;
|
||||
std::vector<std::string> myImageBuffer;
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
*/
|
||||
|
||||
#include <ZLFile.h>
|
||||
#include <ZLBase64EncodedImage.h>
|
||||
#include <ZLImage.h>
|
||||
//#include <ZLBase64EncodedImage.h>
|
||||
|
||||
#include "FB2CoverReader.h"
|
||||
|
||||
|
@ -53,7 +54,7 @@ void FB2CoverReader::startElementHandler(int tag, const char **attributes) {
|
|||
const char *id = attributeValue(attributes, "id");
|
||||
const char *contentType = attributeValue(attributes, "content-type");
|
||||
if (id != 0 && contentType != 0 && myImageReference == id) {
|
||||
myImage = new ZLBase64EncodedImage(contentType);
|
||||
//myImage = new ZLBase64EncodedImage(contentType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +73,7 @@ void FB2CoverReader::endElementHandler(int tag) {
|
|||
case _BINARY:
|
||||
if (!myImage.isNull()) {
|
||||
if (!myImageBuffer.empty()) {
|
||||
((ZLBase64EncodedImage&)*myImage).addData(myImageBuffer);
|
||||
//((ZLBase64EncodedImage&)*myImage).addData(myImageBuffer);
|
||||
myImageBuffer.clear();
|
||||
} else {
|
||||
myImage = 0;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "FB2Reader.h"
|
||||
|
||||
class Book;
|
||||
class ZLfile;
|
||||
class ZLFile;
|
||||
class ZLImage;
|
||||
|
||||
class FB2CoverReader : public FB2Reader {
|
||||
|
|
|
@ -22,10 +22,10 @@
|
|||
#include <ZLibrary.h>
|
||||
|
||||
#include <ZLStringUtil.h>
|
||||
#include <ZLXMLNamespace.h>
|
||||
//#include <ZLXMLNamespace.h>
|
||||
|
||||
#include "FB2Reader.h"
|
||||
#include "../util/EntityFilesCollector.h"
|
||||
//#include "../util/EntityFilesCollector.h"
|
||||
|
||||
void FB2Reader::startElementHandler(const char *t, const char **attributes) {
|
||||
startElementHandler(tag(t), attributes);
|
||||
|
@ -88,10 +88,12 @@ bool FB2Reader::processNamespaces() const {
|
|||
void FB2Reader::namespaceListChangedHandler() {
|
||||
const std::map<std::string,std::string> namespaceMap = namespaces();
|
||||
for (std::map<std::string,std::string>::const_iterator it = namespaceMap.begin(); it != namespaceMap.end(); ++it) {
|
||||
/*
|
||||
if (ZLStringUtil::stringStartsWith(it->second, ZLXMLNamespace::XLink)) {
|
||||
myXLinkNamespace = it->first;
|
||||
return;
|
||||
}
|
||||
*/
|
||||
}
|
||||
myXLinkNamespace.erase();
|
||||
}
|
||||
|
|
|
@ -220,3 +220,7 @@ void ZLXMLReader::setErrorMessage(const std::string &message) {
|
|||
myErrorMessage = message;
|
||||
interrupt();
|
||||
}
|
||||
|
||||
size_t ZLXMLReader::getCurrentPosition() const {
|
||||
return myInternalReader != 0 ? myInternalReader->getCurrentPosition() : (size_t)-1;
|
||||
}
|
||||
|
|
|
@ -94,6 +94,7 @@ protected:
|
|||
virtual void collectExternalEntities(std::map<std::string,std::string> &entityMap);
|
||||
|
||||
bool isInterrupted() const;
|
||||
size_t getCurrentPosition() const;
|
||||
|
||||
protected:
|
||||
void interrupt();
|
||||
|
|
|
@ -163,3 +163,7 @@ void ZLXMLReaderInternal::init(const char *encoding) {
|
|||
bool ZLXMLReaderInternal::parseBuffer(const char *buffer, size_t len) {
|
||||
return XML_Parse(myParser, buffer, len, 0) != XML_STATUS_ERROR;
|
||||
}
|
||||
|
||||
size_t ZLXMLReaderInternal::getCurrentPosition() const {
|
||||
return XML_GetCurrentByteIndex(myParser);
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ public:
|
|||
~ZLXMLReaderInternal();
|
||||
void init(const char *encoding = 0);
|
||||
bool parseBuffer(const char *buffer, size_t len);
|
||||
size_t getCurrentPosition() const;
|
||||
|
||||
private:
|
||||
void setupEntities();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue