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/EncodedTextReader.cpp \
|
||||||
NativeFormats/fbreader/src/formats/FormatPlugin.cpp \
|
NativeFormats/fbreader/src/formats/FormatPlugin.cpp \
|
||||||
NativeFormats/fbreader/src/formats/PluginCollection.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/RtfBookReader.cpp \
|
||||||
NativeFormats/fbreader/src/formats/rtf/RtfDescriptionReader.cpp \
|
NativeFormats/fbreader/src/formats/rtf/RtfDescriptionReader.cpp \
|
||||||
NativeFormats/fbreader/src/formats/rtf/RtfPlugin.cpp \
|
NativeFormats/fbreader/src/formats/rtf/RtfPlugin.cpp \
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#include <ZLInputStream.h>
|
#include <ZLInputStream.h>
|
||||||
#include <ZLStringUtil.h>
|
#include <ZLStringUtil.h>
|
||||||
#include <ZLBase64EncodedImage.h>
|
//#include <ZLBase64EncodedImage.h>
|
||||||
|
|
||||||
#include <ZLTextParagraph.h>
|
#include <ZLTextParagraph.h>
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ FB2BookReader::FB2BookReader(BookModel &model) : myModelReader(model) {
|
||||||
mySectionDepth = 0;
|
mySectionDepth = 0;
|
||||||
myBodyCounter = 0;
|
myBodyCounter = 0;
|
||||||
myReadMainText = false;
|
myReadMainText = false;
|
||||||
myCurrentImage = 0;
|
//myCurrentImage = 0;
|
||||||
myProcessingImage = false;
|
myProcessingImage = false;
|
||||||
mySectionStarted = false;
|
mySectionStarted = false;
|
||||||
myInsideTitle = false;
|
myInsideTitle = false;
|
||||||
|
@ -189,7 +189,7 @@ void FB2BookReader::startElementHandler(int tag, const char **xmlattributes) {
|
||||||
++ref;
|
++ref;
|
||||||
if ((myCoverImageReference != ref) ||
|
if ((myCoverImageReference != ref) ||
|
||||||
(myParagraphsBeforeBodyNumber != myModelReader.model().bookTextModel()->paragraphsNumber())) {
|
(myParagraphsBeforeBodyNumber != myModelReader.model().bookTextModel()->paragraphsNumber())) {
|
||||||
myModelReader.addImageReference(ref);
|
//myModelReader.addImageReference(ref);
|
||||||
}
|
}
|
||||||
if (myInsideCoverpage) {
|
if (myInsideCoverpage) {
|
||||||
myCoverImageReference = ref;
|
myCoverImageReference = ref;
|
||||||
|
@ -202,7 +202,7 @@ void FB2BookReader::startElementHandler(int tag, const char **xmlattributes) {
|
||||||
static const std::string STRANGE_MIME_TYPE = "text/xml";
|
static const std::string STRANGE_MIME_TYPE = "text/xml";
|
||||||
const char *contentType = attributeValue(xmlattributes, "content-type");
|
const char *contentType = attributeValue(xmlattributes, "content-type");
|
||||||
if ((contentType != 0) && (id != 0) && (STRANGE_MIME_TYPE != contentType)) {
|
if ((contentType != 0) && (id != 0) && (STRANGE_MIME_TYPE != contentType)) {
|
||||||
myCurrentImage = new ZLBase64EncodedImage(contentType);
|
//myCurrentImage = new ZLBase64EncodedImage(contentType);
|
||||||
myCurrentImageId.assign(id);
|
myCurrentImageId.assign(id);
|
||||||
myProcessingImage = true;
|
myProcessingImage = true;
|
||||||
}
|
}
|
||||||
|
@ -302,12 +302,12 @@ void FB2BookReader::endElementHandler(int tag) {
|
||||||
myModelReader.addControl(myHyperlinkType, false);
|
myModelReader.addControl(myHyperlinkType, false);
|
||||||
break;
|
break;
|
||||||
case _BINARY:
|
case _BINARY:
|
||||||
if (!myImageBuffer.empty() && !myCurrentImageId.empty() && myCurrentImage != 0) {
|
if (!myImageBuffer.empty() && !myCurrentImageId.empty() /*&& myCurrentImage != 0*/) {
|
||||||
myCurrentImage->addData(myImageBuffer);
|
//myCurrentImage->addData(myImageBuffer);
|
||||||
myModelReader.addImage(myCurrentImageId, myCurrentImage);
|
//myModelReader.addImage(myCurrentImageId, myCurrentImage);
|
||||||
myImageBuffer.clear();
|
myImageBuffer.clear();
|
||||||
myCurrentImageId.clear();
|
myCurrentImageId.clear();
|
||||||
myCurrentImage = 0;
|
//myCurrentImage = 0;
|
||||||
}
|
}
|
||||||
myProcessingImage = false;
|
myProcessingImage = false;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "../../bookmodel/BookReader.h"
|
#include "../../bookmodel/BookReader.h"
|
||||||
|
|
||||||
class BookModel;
|
class BookModel;
|
||||||
class ZLBase64EncodedImage;
|
//class ZLBase64EncodedImage;
|
||||||
|
|
||||||
class FB2BookReader : public FB2Reader {
|
class FB2BookReader : public FB2Reader {
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ private:
|
||||||
bool myInsidePoem;
|
bool myInsidePoem;
|
||||||
BookReader myModelReader;
|
BookReader myModelReader;
|
||||||
|
|
||||||
ZLBase64EncodedImage *myCurrentImage;
|
//ZLBase64EncodedImage *myCurrentImage;
|
||||||
std::string myCurrentImageId;
|
std::string myCurrentImageId;
|
||||||
bool myProcessingImage;
|
bool myProcessingImage;
|
||||||
std::vector<std::string> myImageBuffer;
|
std::vector<std::string> myImageBuffer;
|
||||||
|
|
|
@ -18,7 +18,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ZLFile.h>
|
#include <ZLFile.h>
|
||||||
#include <ZLBase64EncodedImage.h>
|
#include <ZLImage.h>
|
||||||
|
//#include <ZLBase64EncodedImage.h>
|
||||||
|
|
||||||
#include "FB2CoverReader.h"
|
#include "FB2CoverReader.h"
|
||||||
|
|
||||||
|
@ -53,7 +54,7 @@ void FB2CoverReader::startElementHandler(int tag, const char **attributes) {
|
||||||
const char *id = attributeValue(attributes, "id");
|
const char *id = attributeValue(attributes, "id");
|
||||||
const char *contentType = attributeValue(attributes, "content-type");
|
const char *contentType = attributeValue(attributes, "content-type");
|
||||||
if (id != 0 && contentType != 0 && myImageReference == id) {
|
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:
|
case _BINARY:
|
||||||
if (!myImage.isNull()) {
|
if (!myImage.isNull()) {
|
||||||
if (!myImageBuffer.empty()) {
|
if (!myImageBuffer.empty()) {
|
||||||
((ZLBase64EncodedImage&)*myImage).addData(myImageBuffer);
|
//((ZLBase64EncodedImage&)*myImage).addData(myImageBuffer);
|
||||||
myImageBuffer.clear();
|
myImageBuffer.clear();
|
||||||
} else {
|
} else {
|
||||||
myImage = 0;
|
myImage = 0;
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "FB2Reader.h"
|
#include "FB2Reader.h"
|
||||||
|
|
||||||
class Book;
|
class Book;
|
||||||
class ZLfile;
|
class ZLFile;
|
||||||
class ZLImage;
|
class ZLImage;
|
||||||
|
|
||||||
class FB2CoverReader : public FB2Reader {
|
class FB2CoverReader : public FB2Reader {
|
||||||
|
|
|
@ -22,10 +22,10 @@
|
||||||
#include <ZLibrary.h>
|
#include <ZLibrary.h>
|
||||||
|
|
||||||
#include <ZLStringUtil.h>
|
#include <ZLStringUtil.h>
|
||||||
#include <ZLXMLNamespace.h>
|
//#include <ZLXMLNamespace.h>
|
||||||
|
|
||||||
#include "FB2Reader.h"
|
#include "FB2Reader.h"
|
||||||
#include "../util/EntityFilesCollector.h"
|
//#include "../util/EntityFilesCollector.h"
|
||||||
|
|
||||||
void FB2Reader::startElementHandler(const char *t, const char **attributes) {
|
void FB2Reader::startElementHandler(const char *t, const char **attributes) {
|
||||||
startElementHandler(tag(t), attributes);
|
startElementHandler(tag(t), attributes);
|
||||||
|
@ -88,10 +88,12 @@ bool FB2Reader::processNamespaces() const {
|
||||||
void FB2Reader::namespaceListChangedHandler() {
|
void FB2Reader::namespaceListChangedHandler() {
|
||||||
const std::map<std::string,std::string> namespaceMap = namespaces();
|
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) {
|
for (std::map<std::string,std::string>::const_iterator it = namespaceMap.begin(); it != namespaceMap.end(); ++it) {
|
||||||
|
/*
|
||||||
if (ZLStringUtil::stringStartsWith(it->second, ZLXMLNamespace::XLink)) {
|
if (ZLStringUtil::stringStartsWith(it->second, ZLXMLNamespace::XLink)) {
|
||||||
myXLinkNamespace = it->first;
|
myXLinkNamespace = it->first;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
myXLinkNamespace.erase();
|
myXLinkNamespace.erase();
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,3 +220,7 @@ void ZLXMLReader::setErrorMessage(const std::string &message) {
|
||||||
myErrorMessage = message;
|
myErrorMessage = message;
|
||||||
interrupt();
|
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);
|
virtual void collectExternalEntities(std::map<std::string,std::string> &entityMap);
|
||||||
|
|
||||||
bool isInterrupted() const;
|
bool isInterrupted() const;
|
||||||
|
size_t getCurrentPosition() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void interrupt();
|
void interrupt();
|
||||||
|
|
|
@ -163,3 +163,7 @@ void ZLXMLReaderInternal::init(const char *encoding) {
|
||||||
bool ZLXMLReaderInternal::parseBuffer(const char *buffer, size_t len) {
|
bool ZLXMLReaderInternal::parseBuffer(const char *buffer, size_t len) {
|
||||||
return XML_Parse(myParser, buffer, len, 0) != XML_STATUS_ERROR;
|
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();
|
~ZLXMLReaderInternal();
|
||||||
void init(const char *encoding = 0);
|
void init(const char *encoding = 0);
|
||||||
bool parseBuffer(const char *buffer, size_t len);
|
bool parseBuffer(const char *buffer, size_t len);
|
||||||
|
size_t getCurrentPosition() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupEntities();
|
void setupEntities();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue