Skip to content

Commit da98b72

Browse files
committed
fix images
1 parent 7b82044 commit da98b72

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

src/odr/internal/odf/odf_element.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,11 @@ bool Image::is_internal(const abstract::Document *document) const {
441441
return false;
442442
}
443443
try {
444-
return doc->as_filesystem()->is_file(common::Path(href(document)));
444+
common::Path path(href(document));
445+
if (path.relative()) {
446+
path = common::Path("/").join(path);
447+
}
448+
return doc->as_filesystem()->is_file(path);
445449
} catch (...) {
446450
}
447451
return false;
@@ -452,7 +456,11 @@ std::optional<odr::File> Image::file(const abstract::Document *document) const {
452456
if (!doc || !is_internal(document)) {
453457
return {};
454458
}
455-
return File(doc->as_filesystem()->open(common::Path(href(document))));
459+
common::Path path(href(document));
460+
if (path.relative()) {
461+
path = common::Path("/").join(path);
462+
}
463+
return File(doc->as_filesystem()->open(path));
456464
}
457465

458466
std::string Image::href(const abstract::Document *) const {

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <odr/internal/ooxml/text/ooxml_text_document.hpp>
99
#include <odr/internal/util/xml_util.hpp>
1010

11-
#include <functional>
1211
#include <optional>
1312

1413
#include <pugixml.hpp>
@@ -285,7 +284,11 @@ std::optional<odr::File> Image::file(const abstract::Document *document) const {
285284
if (!doc || !is_internal(document)) {
286285
return {};
287286
}
288-
return File(doc->as_filesystem()->open(common::Path(href(document))));
287+
common::Path path(href(document));
288+
if (path.relative()) {
289+
path = common::Path("/").join(path);
290+
}
291+
return File(doc->as_filesystem()->open(path));
289292
}
290293

291294
std::string Image::href(const abstract::Document *document) const {

0 commit comments

Comments
 (0)