Add debug output for a relationship mismatch

This commit is contained in:
Crzyrndm 2018-07-09 15:24:03 +12:00
parent 53c193433f
commit ec02121c15

View File

@ -3,11 +3,11 @@
#include <sstream> #include <sstream>
#include <unordered_set> #include <unordered_set>
#include <xlnt/packaging/manifest.hpp>
#include <xlnt/workbook/workbook.hpp>
#include <detail/external/include_libstudxml.hpp> #include <detail/external/include_libstudxml.hpp>
#include <detail/serialization/vector_streambuf.hpp> #include <detail/serialization/vector_streambuf.hpp>
#include <detail/serialization/zstream.hpp> #include <detail/serialization/zstream.hpp>
#include <xlnt/packaging/manifest.hpp>
#include <xlnt/workbook/workbook.hpp>
class xml_helper class xml_helper
{ {
@ -63,8 +63,7 @@ public:
bool difference = false; bool difference = false;
auto right_iter = right_parser.begin(); auto right_iter = right_parser.begin();
auto is_whitespace = [](const std::string &v) auto is_whitespace = [](const std::string &v) {
{
return v.find_first_not_of("\n\r\t ") == std::string::npos; return v.find_first_not_of("\n\r\t ") == std::string::npos;
}; };
@ -290,8 +289,7 @@ public:
if (std::abs(int(left_info.size()) - int(right_info.size())) == 1) if (std::abs(int(left_info.size()) - int(right_info.size())) == 1)
{ {
auto is_calc_chain = [](const xlnt::path &p) auto is_calc_chain = [](const xlnt::path &p) {
{
return p.filename() == "calcChain.xml"; return p.filename() == "calcChain.xml";
}; };
@ -306,7 +304,7 @@ public:
} }
} }
if (left_info.size() != right_info.size() && ! difference_is_missing_calc_chain) if (left_info.size() != right_info.size() && !difference_is_missing_calc_chain)
{ {
std::cout << "left has a different number of files than right" << std::endl; std::cout << "left has a different number of files than right" << std::endl;
@ -338,6 +336,35 @@ public:
if (!compare_relationships(left_manifest, right_manifest)) if (!compare_relationships(left_manifest, right_manifest))
{ {
std::cout << "relationship mismatch\n"
<< "Left:\n";
for (const auto &part : left_manifest.parts())
{
std::cout << "-part: " << part.string() << '\n';
auto rels = left_manifest.relationships(part);
for (auto &rel : rels)
{
std::cout << rel.id() << ':'
<< static_cast<int>(rel.type())
<< ':' << static_cast<int>(rel.target_mode())
<< ':' << rel.source().path().string()
<< ':' << rel.target().path().string() << '\n';
}
}
std::cout << "\nRight:\n";
for (const auto &part : right_manifest.parts())
{
std::cout << "-part: " << part.string() << '\n';
auto rels = right_manifest.relationships(part);
for (auto &rel : rels)
{
std::cout << rel.id()
<< ':' << static_cast<int>(rel.type())
<< ':' << static_cast<int>(rel.target_mode())
<< ':' << rel.source().path().string()
<< ':' << rel.target().path().string() << '\n';
}
}
return false; return false;
} }
@ -357,9 +384,11 @@ public:
} }
auto left_content_type = left_member.string() == "[Content_Types].xml" auto left_content_type = left_member.string() == "[Content_Types].xml"
? "[Content_Types].xml" : left_manifest.content_type(left_member); ? "[Content_Types].xml"
: left_manifest.content_type(left_member);
auto right_content_type = left_member.string() == "[Content_Types].xml" auto right_content_type = left_member.string() == "[Content_Types].xml"
? "[Content_Types].xml" : right_manifest.content_type(left_member); ? "[Content_Types].xml"
: right_manifest.content_type(left_member);
if (left_content_type != right_content_type) if (left_content_type != right_content_type)
{ {