Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/xlnt/cell/rich_text.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ class XLNT_API rich_text
/// </summary>
bool operator!=(const std::string &rhs) const;

std::size_t unique_index{0};

private:
/// <summary>
/// The runs that make up this rich text.
Expand All @@ -171,6 +173,7 @@ class XLNT_API rich_text_hash
{
res ^= std::hash<std::string>()(r.first);
}
res ^= std::hash<std::string>()(std::to_string(k.unique_index));

return res;
}
Expand Down
4 changes: 3 additions & 1 deletion source/cell/rich_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ rich_text &rich_text::operator=(const rich_text &rhs)
runs_ = rhs.runs_;
phonetic_runs_ = rhs.phonetic_runs_;
phonetic_properties_ = rhs.phonetic_properties_;
unique_index = rhs.unique_index;
return *this;
}

Expand All @@ -69,6 +70,7 @@ void rich_text::clear()
runs_.clear();
phonetic_runs_.clear();
phonetic_properties_.clear();
unique_index = 0;
}

void rich_text::plain_text(const std::string &s, bool preserve_space = false)
Expand Down Expand Up @@ -151,7 +153,7 @@ bool rich_text::operator==(const rich_text &rhs) const

if (phonetic_properties_ != rhs.phonetic_properties_) return false;

return true;
return unique_index == rhs.unique_index;
}

bool rich_text::operator==(const std::string &rhs) const
Expand Down
2 changes: 2 additions & 0 deletions source/detail/serialization/xlsx_consumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2270,10 +2270,12 @@ void xlsx_consumer::read_shared_string_table()
unique_count = parser().attribute<std::size_t>("uniqueCount");
}

size_t unique_index = 0;
while (in_element(qn("spreadsheetml", "sst")))
{
expect_start_element(qn("spreadsheetml", "si"), xml::content::complex);
auto rt = read_rich_text(qn("spreadsheetml", "si"));
rt.unique_index = unique_index++;
target_.add_shared_string(rt, true);
expect_end_element(qn("spreadsheetml", "si"));
}
Expand Down