handle absolute relationship targets the correct way

This commit is contained in:
Thomas Fussell 2017-06-16 09:11:24 -04:00
parent 7b391321f6
commit 7834b564f4
2 changed files with 8 additions and 7 deletions

View File

@ -187,10 +187,16 @@ std::vector<relationship> xlsx_consumer::read_relationships(const path &part)
const auto target_mode = parser.attribute_present("TargetMode")
? parser.attribute<xlnt::target_mode>("TargetMode")
: xlnt::target_mode::internal;
auto target = xlnt::uri(parser.attribute("Target"));
if (target.path().is_absolute() && target_mode == target_mode::internal)
{
target = uri(target.path().relative_to(path(part.string()).resolve(path("/"))).string());
}
relationships.emplace_back(parser.attribute("Id"),
parser.attribute<xlnt::relationship_type>("Type"),
xlnt::uri(part.string()), xlnt::uri(parser.attribute("Target")),
target_mode);
xlnt::uri(part.string()), target, target_mode);
expect_end_element(qn("relationships", "Relationship"));
}

View File

@ -39,11 +39,6 @@ void manifest::clear()
path manifest::canonicalize(const std::vector<xlnt::relationship> &rels) const
{
if (rels.back().target().path().is_absolute())
{
return rels.back().target().path().relative_to(path("/"));
}
xlnt::path relative;
for (auto component : rels)