Skip to content

Commit 00bf3b4

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 2d0852b + ab18623 commit 00bf3b4

File tree

65 files changed

+993
-234
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+993
-234
lines changed

android/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
55
package="org.coolreader"
66
android:installLocation="auto"
7-
android:versionName="3.2.36-1" android:versionCode="32360">
7+
android:versionName="3.2.38-1" android:versionCode="32380">
88
<supports-screens
99
android:xlargeScreens="true"
1010
android:largeScreens="true"

android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ android {
1010
multiDexEnabled true
1111
// When new version released, version code must be incremented at least by 8
1212
// for compatibility with ABI versioning of split apk (see below).
13-
versionCode 32360
14-
versionName "3.2.36-1"
13+
versionCode 32380
14+
versionName "3.2.38-1"
1515
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1616
externalNativeBuild {
1717
cmake {

android/jni/cr3engine.cpp

Lines changed: 125 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "docview.h"
2020
#include "../../crengine/include/crengine.h"
2121
#include "../../crengine/include/epubfmt.h"
22+
#include "../../crengine/include/fb3fmt.h"
2223
#include "../../crengine/include/pdbfmt.h"
2324
#include "../../crengine/include/lvstream.h"
2425

@@ -30,6 +31,7 @@
3031
#define XS_IMPLEMENT_SCHEME 1
3132
#include <../../crengine/include/fb2def.h>
3233
#include <sys/stat.h>
34+
#include <lvopc.h>
3335

3436
#if defined(__arm__) || defined(__aarch64__) || defined(__i386__) || defined(__mips__)
3537
#define USE_COFFEECATCH 1
@@ -152,7 +154,7 @@ static bool GetEPUBBookProperties(const char *name, LVStreamRef stream, BookProp
152154
{
153155
LVContainerRef m_arc = LVOpenArchieve( stream );
154156
if ( m_arc.isNull() )
155-
return false; // not a ZIP archive
157+
return false; // not a ZIP` archive
156158

157159
// check root media type
158160
lString16 rootfilePath = EpubGetRootFilePath(m_arc);
@@ -179,10 +181,22 @@ static bool GetEPUBBookProperties(const char *name, LVStreamRef stream, BookProp
179181
lString16 author = doc->textFromXPath( lString16("package/metadata/creator")).trim();
180182
lString16 title = doc->textFromXPath( lString16("package/metadata/title")).trim();
181183
lString16 language = doc->textFromXPath( lString16("package/metadata/language")).trim();
184+
lString16 bookdate = doc->textFromXPath( lString16("package/metadata/date")).trim();
185+
lString16 annotation = doc->textFromXPath( lString16("package/metadata/description")).trim();
186+
lString16 publisher = doc->textFromXPath( lString16("package/metadata/publisher")).trim();
187+
lString16 genre = doc->textFromXPath( lString16("package/metadata/subject")).trim();
188+
lString16 docsrcurl = doc->textFromXPath( lString16("package/metadata/identifier")).trim();
189+
lString16 docsrcocr = doc->textFromXPath( lString16("package/metadata/source")).trim();
182190

183191
pBookProps->author = author;
184192
pBookProps->title = title;
185193
pBookProps->language = language;
194+
pBookProps->bookdate = bookdate;
195+
pBookProps->annotation = annotation;
196+
pBookProps->publisher = publisher;
197+
pBookProps->genre = genre;
198+
pBookProps->docsrcurl = docsrcurl;
199+
pBookProps->docsrcocr = docsrcocr;
186200

187201
for ( int i=1; i<20; i++ ) {
188202
ldomNode * item = doc->nodeFromXPath( lString16("package/metadata/meta[") << fmt::decimal(i) << "]" );
@@ -205,6 +219,110 @@ static bool GetEPUBBookProperties(const char *name, LVStreamRef stream, BookProp
205219
return true;
206220
}
207221

222+
static bool GetFB3BookProperties(const char *name, LVStreamRef stream, BookProperties * pBookProps)
223+
{
224+
ldomDocument * descDoc = NULL;
225+
descDoc = Fb3GetDescDoc( stream );
226+
227+
if ( !descDoc )
228+
return false;
229+
230+
lString16 title = descDoc->textFromXPath( lString16("title/main"));
231+
lString16 authors;
232+
lString16 annotation = descDoc->textFromXPath( lString16("annotation"));
233+
lString16 language = descDoc->textFromXPath( lString16("lang"));
234+
lString16 translators;
235+
lString16 publishers;
236+
lString16 genres;
237+
lString16 srclang = descDoc->textFromXPath( lString16("written/lang"));
238+
lString16 bookdate = descDoc->textFromXPath( lString16("written/date"));
239+
240+
for ( int i=1; i<30; i++ ) {
241+
ldomNode * item = descDoc->nodeFromXPath(lString16("fb3-relations/subject[") << fmt::decimal(i) << "]");
242+
if ( !item ) break;
243+
lString16 name = item->getAttributeValue("link");
244+
if (name == "author") {
245+
lString16 author = descDoc->textFromXPath( lString16("fb3-relations/subject[") << fmt::decimal(i) << "]/title/main");
246+
if ( !authors.empty() ) {
247+
authors += " |";
248+
}
249+
authors += author;
250+
}
251+
if (name == "translator") {
252+
lString16 translator = descDoc->textFromXPath( lString16("fb3-relations/subject[") << fmt::decimal(i) << "]/title/main");
253+
if ( !translators.empty() ) {
254+
translators += " | ";
255+
}
256+
translators += translator;
257+
}
258+
if (name == "publisher") {
259+
lString16 publisher = descDoc->textFromXPath( lString16("fb3-relations/subject[") << fmt::decimal(i) << "]/title/main");
260+
if ( !publishers.empty() ) {
261+
publishers += " | ";
262+
}
263+
publishers += publisher;
264+
}
265+
}
266+
for ( int i=1; i<30; i++ ) {
267+
ldomNode * item = descDoc->nodeFromXPath(lString16("fb3-classification/subject[") << fmt::decimal(i) << "]");
268+
if ( !item ) break;
269+
lString16 genre = descDoc->textFromXPath( lString16("fb3-classification/subject[") << fmt::decimal(i) << "]");
270+
if ( !genres.empty() ) {
271+
genres += " | ";
272+
}
273+
genres += genre;
274+
}
275+
276+
ldomNode * item = descDoc->nodeFromXPath(lString16("document-info"));
277+
lString16 created = item->getAttributeValue("created");
278+
lString16 docprogram = item->getAttributeValue("program-used");
279+
lString16 docauthor = item->getAttributeValue("editor");
280+
lString16 docsrcurl = item->getAttributeValue("src-url");
281+
lString16 docsrcocr = item->getAttributeValue("ocr");
282+
lString16 series = descDoc->textFromXPath(lString16("fb3-description/sequence/title/main"));
283+
ldomNode * item2 = descDoc->nodeFromXPath(lString16("paper-publish-info"));
284+
lString16 publisher = item2->getAttributeValue("publisher");
285+
lString16 city = item2->getAttributeValue("city");
286+
lString16 year = item2->getAttributeValue("year");
287+
lString16 publisbn = descDoc->textFromXPath(lString16("paper-publish-info/isbn"));
288+
lString16 publsequence = descDoc->textFromXPath(lString16("paper-publish-info/sequence"));
289+
290+
pBookProps-> title = title;
291+
pBookProps-> author = authors;
292+
pBookProps-> annotation = annotation;
293+
pBookProps-> language = language;
294+
pBookProps-> translator = translators;
295+
pBookProps-> publisher = publishers;
296+
pBookProps-> genre = genres;
297+
pBookProps-> srclang = srclang;
298+
pBookProps-> bookdate = bookdate;
299+
pBookProps-> docdate = created;
300+
pBookProps->docprogram = docprogram;
301+
pBookProps->series = series;
302+
pBookProps->publisher = publisher;
303+
pBookProps->publcity = city;
304+
pBookProps->publyear = year;
305+
pBookProps->publisbn = publisbn;
306+
pBookProps->publseries = publsequence;
307+
pBookProps->docauthor = docauthor;
308+
pBookProps->docsrcurl = docsrcurl;
309+
pBookProps->docsrcocr = docsrcocr;
310+
311+
time_t t = (time_t)time(0);
312+
struct stat fs;
313+
if ( !stat( name, &fs ) ) {
314+
t = fs.st_mtime;
315+
}
316+
317+
pBookProps->filesize = (long)stream->GetSize();
318+
pBookProps->filename = lString16(name);
319+
pBookProps->filedate = getDateTimeString( t );
320+
321+
delete descDoc;
322+
323+
return true;
324+
}
325+
208326
static bool GetBookProperties(const char *name, BookProperties * pBookProps)
209327
{
210328
CRLog::trace("GetBookProperties( %s )", name);
@@ -227,6 +345,11 @@ static bool GetBookProperties(const char *name, BookProperties * pBookProps)
227345
return GetEPUBBookProperties( name, stream, pBookProps );
228346
}
229347

348+
if ( DetectFb3Format( stream ) ) {
349+
CRLog::trace("GetBookProperties() : fb3 format detected");
350+
return GetFB3BookProperties( name, stream, pBookProps );
351+
}
352+
230353
time_t t = (time_t)time(0);
231354

232355
if ( isArchiveFile ) {
@@ -259,7 +382,7 @@ static bool GetBookProperties(const char *name, BookProperties * pBookProps)
259382
doc.setNameSpaceTypes( fb2_ns_table );
260383
LVXMLParser parser( stream, &writer );
261384
CRLog::trace( "checking format..." );
262-
if ( !parser.CheckFormat() ) {
385+
if ( !parser.CheckFormat() ) {
263386
return false;
264387
}
265388
CRLog::trace( "parsing..." );

android/jni/docview.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ CRTimerUtil _timeoutControl;
157157

158158
#define DECL_DEF_CR_FONT_SIZES static int cr_font_sizes[] = \
159159
{ 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, \
160-
31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 44, 48, 52, 56, 60, 64, 68, 72, 78, 84, 90, 110, 130, 150, 170, 200, 230, 260, 300, 340 }
160+
31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 44, 48, 50, 52, 54, 56, 60, 64, 68, 72, 78, 84, 90, 110, 130, 150, 170, 200, 230, 260, 300, 340 }
161161

162162
DECL_DEF_CR_FONT_SIZES;
163163

@@ -2137,10 +2137,10 @@ JNIEXPORT jint JNICALL Java_org_coolreader_crengine_DocView_getPageCountInternal
21372137
DocViewNative * p = getNative(_env, _this);
21382138
if (!p) {
21392139
CRLog::error("Cannot get native view");
2140-
return NULL;
2140+
return 0; //NULL;
21412141
}
21422142
if ( !p->_docview->isDocumentOpened() )
2143-
return NULL;
2143+
return 0; //NULL;
21442144
DocViewCallback callback( _env, p->_docview, _this );
21452145

21462146
return p->_docview->getPageCount();
@@ -2158,10 +2158,10 @@ JNIEXPORT jint JNICALL Java_org_coolreader_crengine_DocView_getVisiblePageCountI
21582158
DocViewNative * p = getNative(_env, _this);
21592159
if (!p) {
21602160
CRLog::error("Cannot get native view");
2161-
return NULL;
2161+
return 0; //NULL;
21622162
}
21632163
if ( !p->_docview->isDocumentOpened() )
2164-
return NULL;
2164+
return 0; //NULL;
21652165
DocViewCallback callback( _env, p->_docview, _this );
21662166

21672167
return p->_docview->getVisiblePageCount();
@@ -2174,10 +2174,10 @@ JNIEXPORT jint JNICALL Java_org_coolreader_crengine_DocView_getCurPageInternal
21742174
DocViewNative * p = getNative(_env, _this);
21752175
if (!p) {
21762176
CRLog::error("Cannot get native view");
2177-
return NULL;
2177+
return 0; //NULL;
21782178
}
21792179
if ( !p->_docview->isDocumentOpened() )
2180-
return NULL;
2180+
return 0; //NULL;
21812181
DocViewCallback callback( _env, p->_docview, _this );
21822182

21832183
return p->_docview->getCurPage();
917 Bytes
Loading
518 Bytes
Loading
591 Bytes
Loading
568 Bytes
Loading
602 Bytes
Loading
427 Bytes
Loading

0 commit comments

Comments
 (0)