mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 02:39:23 +02:00
Merge branch 'master' into positions
This commit is contained in:
commit
79fe7b5b57
2 changed files with 21 additions and 25 deletions
|
@ -109,7 +109,7 @@ void OEBBookReader::startElementHandler(const char *tag, const char **xmlattribu
|
||||||
if (title != 0) {
|
if (title != 0) {
|
||||||
myGuideTOC.push_back(std::make_pair(std::string(title), reference));
|
myGuideTOC.push_back(std::make_pair(std::string(title), reference));
|
||||||
}
|
}
|
||||||
if ((type != 0) && (COVER == type || COVER_IMAGE == type)) {
|
if (type != 0 && (COVER == type || COVER_IMAGE == type)) {
|
||||||
ZLFile imageFile(myFilePrefix + reference);
|
ZLFile imageFile(myFilePrefix + reference);
|
||||||
myCoverFileName = imageFile.path();
|
myCoverFileName = imageFile.path();
|
||||||
myCoverFileType = type;
|
myCoverFileType = type;
|
||||||
|
@ -133,31 +133,24 @@ void OEBBookReader::startElementHandler(const char *tag, const char **xmlattribu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OEBBookReader::coverIsSingleImage() const {
|
||||||
|
return
|
||||||
|
COVER_IMAGE == myCoverFileType ||
|
||||||
|
(COVER == myCoverFileType &&
|
||||||
|
ZLStringUtil::stringStartsWith(myCoverMimeType, "image/"));
|
||||||
|
}
|
||||||
|
|
||||||
void OEBBookReader::addCoverImage() {
|
void OEBBookReader::addCoverImage() {
|
||||||
if (COVER == myCoverFileType) {
|
|
||||||
ZLFile imageFile(myCoverFileName);
|
ZLFile imageFile(myCoverFileName);
|
||||||
shared_ptr<const ZLImage> image;
|
shared_ptr<const ZLImage> image = coverIsSingleImage()
|
||||||
if (ZLStringUtil::stringStartsWith(myCoverMimeType, "image/")) {
|
? new ZLFileImage(imageFile, "", 0) : XHTMLImageFinder().readImage(imageFile);
|
||||||
image = new ZLFileImage(imageFile, "", 0);
|
|
||||||
} else {
|
|
||||||
image = XHTMLImageFinder().readImage(imageFile);
|
|
||||||
}
|
|
||||||
if (!image.isNull()) {
|
if (!image.isNull()) {
|
||||||
const std::string imageName = imageFile.name(false);
|
const std::string imageName = imageFile.name(false);
|
||||||
myModelReader.setMainTextModel();
|
myModelReader.setMainTextModel();
|
||||||
myModelReader.addImageReference(imageName, (short)0, true);
|
myModelReader.addImageReference(imageName, (short)0, true);
|
||||||
myModelReader.addImage(imageName, image);
|
myModelReader.addImage(imageName, image);
|
||||||
myModelReader.insertEndOfSectionParagraph();
|
myModelReader.insertEndOfSectionParagraph();
|
||||||
} else {
|
|
||||||
myCoverFileName.erase();
|
|
||||||
}
|
|
||||||
} else if (COVER_IMAGE == myCoverFileType) {
|
|
||||||
ZLFile imageFile(myCoverFileName);
|
|
||||||
const std::string imageName = imageFile.name(false);
|
|
||||||
myModelReader.setMainTextModel();
|
|
||||||
myModelReader.addImageReference(imageName, 0, true);
|
|
||||||
myModelReader.addImage(imageName, new ZLFileImage(imageFile, "", 0));
|
|
||||||
myModelReader.insertEndOfSectionParagraph();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,11 +204,14 @@ bool OEBBookReader::readBook(const ZLFile &file) {
|
||||||
myModelReader.pushKind(REGULAR);
|
myModelReader.pushKind(REGULAR);
|
||||||
|
|
||||||
XHTMLReader xhtmlReader(myModelReader);
|
XHTMLReader xhtmlReader(myModelReader);
|
||||||
bool firstFile = true;
|
|
||||||
for (std::vector<std::string>::const_iterator it = myHtmlFileNames.begin(); it != myHtmlFileNames.end(); ++it) {
|
for (std::vector<std::string>::const_iterator it = myHtmlFileNames.begin(); it != myHtmlFileNames.end(); ++it) {
|
||||||
const ZLFile xhtmlFile(myFilePrefix + *it);
|
const ZLFile xhtmlFile(myFilePrefix + *it);
|
||||||
if (firstFile) {
|
if (it == myHtmlFileNames.begin()) {
|
||||||
if (myCoverFileName == xhtmlFile.path()) {
|
if (myCoverFileName == xhtmlFile.path()) {
|
||||||
|
if (coverIsSingleImage()) {
|
||||||
|
addCoverImage();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
xhtmlReader.setMarkFirstImageAsCover();
|
xhtmlReader.setMarkFirstImageAsCover();
|
||||||
} else {
|
} else {
|
||||||
addCoverImage();
|
addCoverImage();
|
||||||
|
@ -224,7 +220,6 @@ bool OEBBookReader::readBook(const ZLFile &file) {
|
||||||
myModelReader.insertEndOfSectionParagraph();
|
myModelReader.insertEndOfSectionParagraph();
|
||||||
}
|
}
|
||||||
xhtmlReader.readFile(xhtmlFile, *it);
|
xhtmlReader.readFile(xhtmlFile, *it);
|
||||||
firstFile = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
generateTOC(xhtmlReader);
|
generateTOC(xhtmlReader);
|
||||||
|
|
|
@ -44,6 +44,7 @@ private:
|
||||||
const std::vector<std::string> &externalDTDs() const;
|
const std::vector<std::string> &externalDTDs() const;
|
||||||
|
|
||||||
void generateTOC(const XHTMLReader &xhtmlReader);
|
void generateTOC(const XHTMLReader &xhtmlReader);
|
||||||
|
bool coverIsSingleImage() const;
|
||||||
void addCoverImage();
|
void addCoverImage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue