handle absolute relationship targets the correct way

This commit is contained in:
Thomas Fussell 2017-06-16 09:11:24 -04:00
parent 2c5d579a1b
commit eb201f5f70

View File

@ -165,10 +165,16 @@ std::vector<relationship> xlsx_consumer::read_relationships(const path &part)
const auto target_mode = parser.attribute_present("TargetMode") const auto target_mode = parser.attribute_present("TargetMode")
? parser.attribute<xlnt::target_mode>("TargetMode") ? parser.attribute<xlnt::target_mode>("TargetMode")
: xlnt::target_mode::internal; : 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"), relationships.emplace_back(parser.attribute("Id"),
parser.attribute<xlnt::relationship_type>("Type"), parser.attribute<xlnt::relationship_type>("Type"),
xlnt::uri(part.string()), xlnt::uri(parser.attribute("Target")), xlnt::uri(part.string()), target, target_mode);
target_mode);
expect_end_element(qn("relationships", "Relationship")); expect_end_element(qn("relationships", "Relationship"));
} }