Skip to content

Commit c029e63

Browse files
authored
fix new odf crypto meta reading (#432)
1 parent 97637f0 commit c029e63

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

src/odr/internal/odf/odf_meta.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ FileMeta parse_file_meta(const abstract::ReadableFilesystem &filesystem,
6363
const bool decrypted) {
6464
FileMeta result;
6565

66+
result.password_encrypted = decrypted;
67+
6668
if (!filesystem.is_file(common::Path("content.xml")) && manifest == nullptr &&
6769
!filesystem.is_file(common::Path("mimetype"))) {
6870
throw NoOpenDocumentFile();
@@ -99,6 +101,16 @@ FileMeta parse_file_meta(const abstract::ReadableFilesystem &filesystem,
99101

100102
DocumentMeta document_meta;
101103

104+
if (result.type == FileType::opendocument_text) {
105+
document_meta.document_type = DocumentType::text;
106+
} else if (result.type == FileType::opendocument_presentation) {
107+
document_meta.document_type = DocumentType::presentation;
108+
} else if (result.type == FileType::opendocument_spreadsheet) {
109+
document_meta.document_type = DocumentType::spreadsheet;
110+
} else if (result.type == FileType::opendocument_graphics) {
111+
document_meta.document_type = DocumentType::drawing;
112+
}
113+
102114
if ((result.password_encrypted == decrypted) &&
103115
filesystem.is_file(common::Path("meta.xml"))) {
104116
const auto meta_xml =
@@ -109,19 +121,13 @@ FileMeta parse_file_meta(const abstract::ReadableFilesystem &filesystem,
109121
.child("meta:document-statistic");
110122

111123
if (result.type == FileType::opendocument_text) {
112-
document_meta.document_type = DocumentType::text;
113124
if (auto page_count = statistics.attribute("meta:page-count")) {
114125
document_meta.entry_count = page_count.as_uint();
115126
}
116-
} else if (result.type == FileType::opendocument_presentation) {
117-
document_meta.document_type = DocumentType::presentation;
118127
} else if (result.type == FileType::opendocument_spreadsheet) {
119-
document_meta.document_type = DocumentType::spreadsheet;
120128
if (auto table_count = statistics.attribute("meta:table-count")) {
121129
document_meta.entry_count = table_count.as_uint();
122130
}
123-
} else if (result.type == FileType::opendocument_graphics) {
124-
document_meta.document_type = DocumentType::drawing;
125131
}
126132
}
127133

0 commit comments

Comments
 (0)