mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
allow duplicate shared strings (why excel?). eventually we should do a garbage collection step that deduplicates shared strings after the workbook is loaded
This commit is contained in:
parent
62c00744b0
commit
720edc143f
|
@ -233,7 +233,7 @@ public:
|
|||
|
||||
const std::vector<relationship> &get_root_relationships() const;
|
||||
|
||||
void add_shared_string(const std::string &shared);
|
||||
void add_shared_string(const std::string &shared, bool allow_duplicates=false);
|
||||
std::vector<std::string> &get_shared_strings();
|
||||
const std::vector<std::string> &get_shared_strings() const;
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ bool load_workbook(xlnt::zip_file &archive, bool guess_types, bool data_only, xl
|
|||
|
||||
for (auto shared_string : shared_strings)
|
||||
{
|
||||
wb.add_shared_string(shared_string);
|
||||
wb.add_shared_string(shared_string, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1184,13 +1184,16 @@ const std::vector<std::string> &workbook::get_shared_strings() const
|
|||
return d_->shared_strings_;
|
||||
}
|
||||
|
||||
void workbook::add_shared_string(const std::string &shared)
|
||||
void workbook::add_shared_string(const std::string &shared, bool allow_duplicates)
|
||||
{
|
||||
//TODO: inefficient, use a set or something?
|
||||
for(auto &s : d_->shared_strings_)
|
||||
{
|
||||
if(s == shared) return;
|
||||
}
|
||||
if (!allow_duplicates)
|
||||
{
|
||||
//TODO: inefficient, use a set or something?
|
||||
for (auto &s : d_->shared_strings_)
|
||||
{
|
||||
if (s == shared) return;
|
||||
}
|
||||
}
|
||||
|
||||
d_->shared_strings_.push_back(shared);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user