Skip to content

Commit feb7826

Browse files
authored
Merge branch 'main' into improve-text-and-allow-editing
2 parents da207af + 28ec352 commit feb7826

7 files changed

Lines changed: 46 additions & 41 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ find_package(argon2 REQUIRED)
4949

5050
include(FetchContent)
5151
FetchContent_Declare(odr.js
52-
URL "https://github.com/opendocument-app/OpenDocument.js/releases/download/v2.0.0-pre2/build.zip"
53-
URL_HASH SHA256=f1cc3285e23231c3ef6323afc9cc3172888c5181ff059a0cc036d9fe13ac09aa
52+
URL "https://github.com/opendocument-app/OpenDocument.js/releases/download/v2.0.0/build.zip"
53+
URL_HASH SHA256=5ccbe1c5bb46d65bc0dccc6c6df6548a571eef5536fcb95f9dcb80add26800b6
5454
)
5555
FetchContent_MakeAvailable(odr.js)
5656

cli/src/server.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ int main(const int argc, char **argv) {
2323
DecodePreference decode_preference;
2424
decode_preference.engine_priority = {
2525
DecoderEngine::poppler, DecoderEngine::wvware, DecoderEngine::odr};
26+
decode_preference.as_file_type = FileType::zip;
2627

2728
DecodedFile decoded_file{input, decode_preference, *logger};
2829

src/odr/internal/html/document.cpp

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -45,40 +45,41 @@ void front(const Document &document, const WritingState &state) {
4545
"width=device-width,initial-scale=1.0,user-scalable=yes");
4646
}
4747

48-
auto odr_css_file = File(
49-
AbsPath(state.config().resource_path).join(RelPath("odr.css")).string());
50-
odr::HtmlResource odr_css_resource =
51-
HtmlResource::create(HtmlResourceType::css, "text/css", "odr.css",
52-
"odr.css", odr_css_file, true, false, true);
53-
HtmlResourceLocation odr_css_location =
54-
state.config().resource_locator(odr_css_resource, state.config());
55-
state.resources().emplace_back(std::move(odr_css_resource), odr_css_location);
56-
if (odr_css_location.has_value()) {
57-
out.write_header_style(odr_css_location.value());
48+
auto document_css_file = File(AbsPath(state.config().resource_path)
49+
.join(RelPath("document.css"))
50+
.string());
51+
odr::HtmlResource document_css_resource = HtmlResource::create(
52+
HtmlResourceType::css, "text/css", "document.css", "document.css",
53+
document_css_file, true, false, true);
54+
HtmlResourceLocation document_css_location =
55+
state.config().resource_locator(document_css_resource, state.config());
56+
state.resources().emplace_back(std::move(document_css_resource),
57+
document_css_location);
58+
if (document_css_location.has_value()) {
59+
out.write_header_style(document_css_location.value());
5860
} else {
5961
out.write_header_style_begin();
60-
util::stream::pipe(*odr_css_file.stream(), out.out());
62+
util::stream::pipe(*document_css_file.stream(), out.out());
6163
out.write_header_style_end();
6264
}
6365

6466
if (document.document_type() == DocumentType::spreadsheet) {
65-
auto odr_spreadsheet_css_file =
66-
File(AbsPath(state.config().resource_path)
67-
.join(RelPath("odr_spreadsheet.css"))
68-
.string());
69-
odr::HtmlResource odr_spreadsheet_css_resource = HtmlResource::create(
70-
HtmlResourceType::css, "text/css", "odr_spreadsheet.css",
71-
"odr_spreadsheet.css", odr_spreadsheet_css_file, true, false, true);
72-
HtmlResourceLocation odr_spreadsheet_css_location =
73-
state.config().resource_locator(odr_spreadsheet_css_resource,
67+
auto spreadsheet_css_file = File(AbsPath(state.config().resource_path)
68+
.join(RelPath("spreadsheet.css"))
69+
.string());
70+
odr::HtmlResource spreadsheet_css_resource = HtmlResource::create(
71+
HtmlResourceType::css, "text/css", "spreadsheet.css", "spreadsheet.css",
72+
spreadsheet_css_file, true, false, true);
73+
HtmlResourceLocation spreadsheet_css_location =
74+
state.config().resource_locator(spreadsheet_css_resource,
7475
state.config());
75-
state.resources().emplace_back(std::move(odr_spreadsheet_css_resource),
76-
odr_spreadsheet_css_location);
77-
if (odr_spreadsheet_css_location.has_value()) {
78-
out.write_header_style(odr_spreadsheet_css_location.value());
76+
state.resources().emplace_back(std::move(spreadsheet_css_resource),
77+
spreadsheet_css_location);
78+
if (spreadsheet_css_location.has_value()) {
79+
out.write_header_style(spreadsheet_css_location.value());
7980
} else {
8081
out.write_header_style_begin();
81-
util::stream::pipe(*odr_spreadsheet_css_file.stream(), out.out());
82+
util::stream::pipe(*spreadsheet_css_file.stream(), out.out());
8283
out.write_header_style_end();
8384
}
8485
}
@@ -124,19 +125,21 @@ void back(const Document &document, const WritingState &state) {
124125
out.write_element_end("div");
125126
}
126127

127-
auto odr_js_file = File(
128-
AbsPath(state.config().resource_path).join(RelPath("odr.js")).string());
129-
odr::HtmlResource odr_js_resource =
130-
HtmlResource::create(HtmlResourceType::js, "text/javascript", "odr.js",
131-
"odr.js", odr_js_file, true, false, true);
132-
HtmlResourceLocation odr_js_location =
133-
state.config().resource_locator(odr_js_resource, state.config());
134-
state.resources().emplace_back(std::move(odr_js_resource), odr_js_location);
135-
if (odr_js_location.has_value()) {
136-
out.write_script(odr_js_location.value());
128+
auto document_js_file = File(AbsPath(state.config().resource_path)
129+
.join(RelPath("document.js"))
130+
.string());
131+
odr::HtmlResource document_js_resource = HtmlResource::create(
132+
HtmlResourceType::js, "text/javascript", "document.js", "document.js",
133+
document_js_file, true, false, true);
134+
HtmlResourceLocation document_js_location =
135+
state.config().resource_locator(document_js_resource, state.config());
136+
state.resources().emplace_back(std::move(document_js_resource),
137+
document_js_location);
138+
if (document_js_location.has_value()) {
139+
out.write_script(document_js_location.value());
137140
} else {
138141
out.write_script_begin();
139-
util::stream::pipe(*odr_js_file.stream(), out.out());
142+
util::stream::pipe(*document_js_file.stream(), out.out());
140143
out.write_script_end();
141144
}
142145

src/odr/internal/ooxml/text/ooxml_text_parser.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ parse_any_element_tree(ElementRegistry &registry, const pugi::xml_node node) {
200200
{"w:tab", parse_text_element},
201201
{"w:p", create_default_tree_parser(ElementType::paragraph)},
202202
{"w:r", create_default_tree_parser(ElementType::span)},
203+
{"w:br", create_default_tree_parser(ElementType::line_break)},
203204
{"w:bookmarkStart", create_default_tree_parser(ElementType::bookmark)},
204205
{"w:hyperlink", create_default_tree_parser(ElementType::link)},
205206
{"w:tbl", parse_table_element},

test/data/input/odr-private

0 commit comments

Comments
 (0)