Skip to content

Commit 1fb2c7e

Browse files
authored
Merge pull request #114 from virxkane/fb3_docx_android
Added fb3 and docx support into android layer.
2 parents 616b13b + fbe17b1 commit 1fb2c7e

File tree

7 files changed

+265
-3
lines changed

7 files changed

+265
-3
lines changed

android/AndroidManifest.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@
7272
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.fb2"/>
7373
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.fb2"/>
7474
<!-- end of inner files in archive -->
75+
<data android:pathPattern=".*\\.fb3"/>
76+
<data android:pathPattern=".*\\..*\\.fb3"/>
77+
<data android:pathPattern=".*\\..*\\..*\\.fb3"/>
78+
<data android:pathPattern=".*\\..*\\..*\\..*\\.fb3"/>
7579
<data android:pathPattern=".*\\.txt"/>
7680
<data android:pathPattern=".*\\.html"/>
7781
<data android:pathPattern=".*\\.xhtml"/>
@@ -87,6 +91,7 @@
8791
<data android:pathPattern=".*\\..*\\..*\\..*\\.fb2\\.epub"/>
8892
<data android:pathPattern=".*\\.pdb"/>
8993
<data android:pathPattern=".*\\.doc"/>
94+
<data android:pathPattern=".*\\.docx"/>
9095
<data android:pathPattern=".*\\.prc"/>
9196
<data android:pathPattern=".*\\.pml"/>
9297
<data android:pathPattern=".*\\.mobi"/>
@@ -118,6 +123,7 @@
118123
<data android:mimeType="application/x-chm"/>
119124
<data android:mimeType="application/fb2"/>
120125
<data android:mimeType="application/fb2.zip"/>
126+
<data android:mimeType="application/fb3"/>
121127
<data android:mimeType="application/epub"/>
122128
<data android:mimeType="application/epub+zip"/>
123129
<data android:mimeType="application/x-fictionbook"/>
@@ -132,6 +138,7 @@
132138
<data android:mimeType="application/word"/>
133139
<data android:mimeType="application/x-msw6"/>
134140
<data android:mimeType="application/x-msword"/>
141+
<data android:mimeType="application/vnd.openxmlformats-officedocument.wordprocessingml.document"/>
135142
</intent-filter>
136143
</activity>
137144

android/app/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ set(CRENGINE_SRC_FILES
5757
${CR3_ROOT}/crengine/src/epubfmt.cpp
5858
${CR3_ROOT}/crengine/src/pdbfmt.cpp
5959
${CR3_ROOT}/crengine/src/wordfmt.cpp
60+
${CR3_ROOT}/crengine/src/lvopc.cpp
61+
${CR3_ROOT}/crengine/src/docxfmt.cpp
62+
${CR3_ROOT}/crengine/src/fb3fmt.cpp
6063
${CR3_ROOT}/crengine/src/lvstsheet.cpp
6164
${CR3_ROOT}/crengine/src/txtselector.cpp
6265
${CR3_ROOT}/crengine/src/crtest.cpp

android/app/src/main/AndroidManifest.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@
7373
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.fb2"/>
7474
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.fb2"/>
7575
<!-- end of inner files in archive -->
76+
<data android:pathPattern=".*\\.fb3"/>
77+
<data android:pathPattern=".*\\..*\\.fb3"/>
78+
<data android:pathPattern=".*\\..*\\..*\\.fb3"/>
79+
<data android:pathPattern=".*\\..*\\..*\\..*\\.fb3"/>
7680
<data android:pathPattern=".*\\.txt"/>
7781
<data android:pathPattern=".*\\.html"/>
7882
<data android:pathPattern=".*\\.xhtml"/>
@@ -88,6 +92,7 @@
8892
<data android:pathPattern=".*\\..*\\..*\\..*\\.fb2\\.epub"/>
8993
<data android:pathPattern=".*\\.pdb"/>
9094
<data android:pathPattern=".*\\.doc"/>
95+
<data android:pathPattern=".*\\.docx"/>
9196
<data android:pathPattern=".*\\.prc"/>
9297
<data android:pathPattern=".*\\.pml"/>
9398
<data android:pathPattern=".*\\.mobi"/>
@@ -119,6 +124,7 @@
119124
<data android:mimeType="application/x-chm"/>
120125
<data android:mimeType="application/fb2"/>
121126
<data android:mimeType="application/fb2.zip"/>
127+
<data android:mimeType="application/fb3"/>
122128
<data android:mimeType="application/epub"/>
123129
<data android:mimeType="application/epub+zip"/>
124130
<data android:mimeType="application/x-fictionbook"/>
@@ -133,6 +139,7 @@
133139
<data android:mimeType="application/word"/>
134140
<data android:mimeType="application/x-msw6"/>
135141
<data android:mimeType="application/x-msword"/>
142+
<data android:mimeType="application/vnd.openxmlformats-officedocument.wordprocessingml.document"/>
136143
</intent-filter>
137144
</activity>
138145

5.67 KB
Loading

android/res/raw/docx.css

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
body { text-align: left; margin: 0; text-indent: 0px }
2+
3+
p { $def.all }
4+
5+
empty-line { height: 1em }
6+
7+
a { display: inline; $link.all }
8+
a[type="note"] { $footnote-link.all }
9+
10+
image { text-align: center; text-indent: 0px; display: block }
11+
p image { display: inline }
12+
li image { display: inline }
13+
14+
li { display: list-item; text-indent: 0em; }
15+
ol { display: block; list-style-type: decimal; margin-left: 1em }
16+
17+
.h1, .h2 {
18+
$title.all
19+
}
20+
21+
.h3, .h4, .h5, .h6 {
22+
$subtitle.all
23+
}
24+
25+
.h1, .h2, .h3, .h4, .h5, .h6 {
26+
hyphenate: none;
27+
}
28+
29+
.h1, .h2, .h3, .h4, .h5, .h6 {
30+
display: block;
31+
margin-top: 0.5em;
32+
margin-bottom: 0.3em;
33+
padding: 10px ;
34+
margin-top: 0.5em;
35+
margin-bottom: 0.5em;
36+
}
37+
.h1, .h2 {
38+
page-break-inside: avoid;
39+
page-break-after: avoid;
40+
}
41+
42+
.h3, .h4, .h5, .h6 {
43+
page-break-inside: avoid;
44+
page-break-after: avoid;
45+
}
46+
47+
.h1 { font-size: 150% }
48+
.h2 { font-size: 140% }
49+
.h3 { font-size: 130% }
50+
.h4 { font-size: 120% }
51+
.h5 { font-size: 110% }
52+
53+
table { font-size: 80% }
54+
td, th { text-indent: 0px; padding: 3px }
55+
th { font-weight: bold; text-align: center; background-color: #DDD }
56+
/* #808080; */
57+
table caption { text-indent: 0px; padding: 4px; background-color: #EEE }
58+
59+
body[name="notes"] { $footnote.all }
60+
body[name="notes"] section title { display: run-in; text-align: left; $footnote-title.all page-break-before: auto; page-break-inside: auto; page-break-after: auto; }
61+
body[name="notes"] section title p { display: inline }
62+
63+
body[name="comments"] { $footnote.all }
64+
body[name="comments"] section title { display: run-in; text-align: left; $footnote-title.all page-break-before: auto; page-break-inside: auto; page-break-after: auto; }
65+
body[name="comments"] section title p { display: inline }
66+
67+
description { display: block; }
68+
title-info { display: block; }
69+
annotation { $annotation.all }
70+
date { display: block; font-size: 80%; font-style: italic; text-align: center }
71+
genre { display: none; }
72+
author { display: none; }
73+
book-title { display: none; }
74+
keywords { display: none; }
75+
lang { display: none; }
76+
src-lang { display: none; }
77+
translator { display: none; }
78+
document-info { display: none; }
79+
publish-info { display: none; }
80+
custom-info { display: none; }
81+
coverpage { display: none }
82+
83+
strong,em,u,s,sub,sup {
84+
display: inline;
85+
}
86+
87+
sub { vertical-align: sub; font-size: 70% }
88+
sup { vertical-align: super; font-size: 70% }
89+
90+
strong { font-weight: bold }
91+
em { font-style: italic }
92+
93+
u { text-decoration: underline; }
94+
s { text-decoration: line-through; }
95+
96+
97+
img {
98+
margin: 0.5em;
99+
text-align: center;
100+
text-indent: 0em;
101+
border-style: solid;
102+
border-width: medium;
103+
}

android/res/raw/fb3.css

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
body { text-align: left; margin: 0; text-indent: 0px }
2+
3+
p { $def.all }
4+
5+
empty-line { height: 1em }
6+
7+
hr { height: 1px; background-color: #808080; margin-top: 0.5em; margin-bottom: 0.5em; /* 2px */ }
8+
9+
a { display: inline; $link.all }
10+
a[type="note"] { $footnote-link.all }
11+
12+
image { text-align: center; text-indent: 0px; display: block }
13+
p image { display: inline }
14+
li image { display: inline }
15+
16+
li { display: list-item; text-indent: 0em; }
17+
ul { display: block; list-style-type: disc; margin-left: 1em }
18+
ol { display: block; list-style-type: decimal; margin-left: 1em }
19+
20+
v { text-align: left; text-align-last: right; text-indent: 1em hanging }
21+
22+
stanza { $poem.all }
23+
stanza + stanza { margin-top: 1em; }
24+
poem { margin-top: 1em; margin-bottom: 1em; text-indent: 0px }
25+
text-author { $text-author.all }
26+
27+
epigraph, epigraph p { $epigraph.all }
28+
cite, cite p { $cite.all }
29+
30+
title p, h1 p, h2 p {
31+
$title.all
32+
}
33+
34+
subtitle, subtitle p, h3 p, h4 p, h5 p, h6 p {
35+
$subtitle.all
36+
}
37+
38+
title, h1, h2, h3, h4, h5, h6, subtitle {
39+
hyphenate: none;
40+
}
41+
42+
h1, h2, h3, h4, h5, h6 {
43+
display: block;
44+
margin-top: 0.5em;
45+
margin-bottom: 0.3em;
46+
padding: 10px ;
47+
margin-top: 0.5em;
48+
margin-bottom: 0.5em;
49+
}
50+
title, h1, h2 {
51+
page-break-before: always;
52+
page-break-inside: avoid;
53+
page-break-after: avoid;
54+
}
55+
ol title, ul title {
56+
page-break-before: auto;
57+
}
58+
subtitle, h3, h4, h5, h6 {
59+
page-break-inside: avoid;
60+
page-break-after: avoid;
61+
}
62+
h1 { font-size: 150% }
63+
h2 { font-size: 140% }
64+
h3 { font-size: 130% }
65+
h4 { font-size: 120% }
66+
h5 { font-size: 110% }
67+
68+
table { font-size: 80% }
69+
td, th { text-indent: 0px; padding: 3px }
70+
th { font-weight: bold; text-align: center; background-color: #DDD }
71+
/* #808080; */
72+
table caption { text-indent: 0px; padding: 4px; background-color: #EEE }
73+
74+
tt, samp, kbd, code, pre { font-family: "Courier New", "Courier", monospace; }
75+
code, pre {
76+
display: block;
77+
white-space: pre;
78+
$pre.all
79+
}
80+
81+
body[name="notes"] { $footnote.all }
82+
body[name="notes"] section title { display: run-in; text-align: left; $footnote-title.all page-break-before: auto; page-break-inside: auto; page-break-after: auto; }
83+
body[name="notes"] section title p { display: inline }
84+
85+
body[name="comments"] { $footnote.all }
86+
body[name="comments"] section title { display: run-in; text-align: left; $footnote-title.all page-break-before: auto; page-break-inside: auto; page-break-after: auto; }
87+
body[name="comments"] section title p { display: inline }
88+
89+
description { display: block; }
90+
title-info { display: block; }
91+
annotation { $annotation.all }
92+
date { display: block; font-size: 80%; font-style: italic; text-align: center }
93+
genre { display: none; }
94+
author { display: none; }
95+
book-title { display: none; }
96+
keywords { display: none; }
97+
lang { display: none; }
98+
src-lang { display: none; }
99+
translator { display: none; }
100+
document-info { display: none; }
101+
publish-info { display: none; }
102+
custom-info { display: none; }
103+
coverpage { display: none }
104+
105+
head, form, script { display: none; }
106+
107+
b,strong,i,em,dfn,var,q,u,underline,del,s,strike,small,big,sub,sup,acronym,tt,sa mp,kbd,code {
108+
display: inline;
109+
}
110+
111+
spacing { display: inline; letter-spacing: 5px }
112+
113+
sub { vertical-align: sub; font-size: 70% }
114+
sup { vertical-align: super; font-size: 70% }
115+
116+
strong, b { font-weight: bold }
117+
emphasis, i, em, dfn, var { font-style: italic }
118+
u,underline { text-decoration: underline; }
119+
del, s, strike, strikethrough { text-decoration: line-through; }
120+
121+
small { font-size: 80%; }
122+
big { font-size: 130%; }
123+
124+
nobr { display: inline; hyphenate: none; white-space: nowrap; }
125+
126+
dl { margin-left: 0em; }
127+
dt { display: block; margin-left: 0em; margin-top:0.3em; font-weight: bold; }
128+
dd { display: block; margin-left: 1.3em; }
129+
130+
img {
131+
margin: 0.5em;
132+
text-align: center;
133+
text-indent: 0em;
134+
border-style: solid;
135+
border-width: medium;
136+
}

android/src/org/coolreader/crengine/DocumentFormat.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ public enum DocumentFormat {
88
NONE("fb2.css", R.raw.fb2, R.drawable.cr3_browser_book, false, false, 0,
99
new String[] {},
1010
new String[] {}),// doc_format_none,
11-
FB2("fb2.css", R.raw.fb2, R.drawable.cr3_browser_book_fb2, true, true, 10,
11+
FB2("fb2.css", R.raw.fb2, R.drawable.cr3_browser_book_fb2, true, true, 11,
1212
new String[] {".fb2", ".fb2.zip"},
1313
new String[] {"application/fb2+zip"}), // doc_format_fb2,
14-
TXT("txt.css", R.raw.txt, R.drawable.cr3_browser_book_txt, false, false, 3,
14+
FB3("fb3.css", R.raw.fb3, R.drawable.cr3_browser_book_fb3, true, true, 10,
15+
new String[] {".fb3" },
16+
new String[] {"application/fb3"}), // doc_format_fb3,
17+
TXT("txt.css", R.raw.txt, R.drawable.cr3_browser_book_txt, false, false, 3,
1518
new String[] {".txt", ".tcr", ".pml"},
1619
new String[] {"text/plain"}), // doc_format_txt,
1720
RTF("rtf.css", R.raw.rtf, R.drawable.cr3_browser_book_rtf, false, false, 7,
@@ -32,7 +35,10 @@ public enum DocumentFormat {
3235
DOC("doc.css", R.raw.doc, R.drawable.cr3_browser_book_doc, false, false, 5,
3336
new String[] {".doc"},
3437
new String[] {}), // doc_format_doc,
35-
PDB("htm.css", R.raw.htm, R.drawable.cr3_browser_book_pdb, false, true, 4,
38+
DOCX("docx.css", R.raw.docx, R.drawable.cr3_browser_book_doc, true, false, 4,
39+
new String[] {".docx"},
40+
new String[] {}), // doc_format_docx,
41+
PDB("htm.css", R.raw.htm, R.drawable.cr3_browser_book_pdb, false, true, 2,
3642
new String[] {".pdb", ".prc", ".mobi", ".azw"},
3743
new String[] {}); // doc_format_txt/html/...,
3844
// don't forget update getDocFormatName() when changing this enum

0 commit comments

Comments
 (0)