fix some failing tests

This commit is contained in:
Thomas Fussell 2015-11-04 22:03:18 -05:00
parent 665f8fbebc
commit 4919e7ea00
9 changed files with 47 additions and 18 deletions

View File

@ -291,6 +291,9 @@ public:
friend std::ostream &operator<<(std::ostream &left, string &right);
friend string operator+(const char *left, const string &right);
friend bool operator==(const char *left, const string &right) { return right == left; }
friend bool operator!=(const char *left, const string &right) { return right != left; }
private:
explicit string(size_type initial_size);

View File

@ -174,6 +174,7 @@ class XLNT_CLASS workbook
// named ranges
std::vector<named_range> get_named_ranges() const;
void create_named_range(const string &name, worksheet worksheet, const range_reference &reference);
void create_named_range(const string &name, worksheet worksheet, const string &reference_string);
bool has_named_range(const string &name) const;
range get_named_range(const string &name);
void remove_named_range(const string &name);

View File

@ -37,9 +37,9 @@ class XLNT_CLASS range_reference
static range_reference make_absolute(const range_reference &relative_reference);
range_reference();
range_reference(const string &range_string);
range_reference(const char *range_string);
range_reference(const std::pair<cell_reference, cell_reference> &reference_pair);
explicit range_reference(const string &range_string);
explicit range_reference(const char *range_string);
explicit range_reference(const std::pair<cell_reference, cell_reference> &reference_pair);
range_reference(const cell_reference &start, const cell_reference &end);
range_reference(column_t column_index_start, row_t row_index_start, column_t column_index_end, row_t row_index_end);
@ -71,19 +71,24 @@ class XLNT_CLASS range_reference
string to_string() const;
bool operator==(const range_reference &comparand) const;
bool operator==(const string &reference_string) const
{
return *this == range_reference(reference_string);
}
bool operator==(const char *reference_string) const
{
return *this == string(reference_string);
}
bool operator!=(const range_reference &comparand) const;
bool operator!=(const string &reference_string) const
{
return *this != range_reference(reference_string);
}
bool operator!=(const char *reference_string) const
{
return *this != string(reference_string);

View File

@ -292,6 +292,8 @@ class XLNT_CLASS worksheet
const cell get_cell(const cell_reference &reference) const;
range get_range(const range_reference &reference);
const range get_range(const range_reference &reference) const;
range get_range(const string &reference_string);
const range get_range(const string &reference_string) const;
range get_squared_range(column_t min_col, row_t min_row, column_t max_col, row_t max_row);
const range get_squared_range(column_t min_col, row_t min_row, column_t max_col, row_t max_row) const;
range rows() const;
@ -341,8 +343,10 @@ class XLNT_CLASS worksheet
// cell merge
void merge_cells(const range_reference &reference);
void merge_cells(const string &reference_string);
void merge_cells(column_t start_column, row_t start_row, column_t end_column, row_t end_row);
void unmerge_cells(const range_reference &reference);
void unmerge_cells(const string &reference_string);
void unmerge_cells(column_t start_column, row_t start_row, column_t end_column, row_t end_row);
std::vector<range_reference> get_merged_ranges() const;
@ -382,6 +386,7 @@ class XLNT_CLASS worksheet
range_reference get_auto_filter() const;
void auto_filter(const xlnt::range &range);
void auto_filter(const range_reference &reference);
void auto_filter(const string &reference_string);
void unset_auto_filter();
bool has_auto_filter() const;

View File

@ -1071,7 +1071,7 @@ bool cell::has_hyperlink() const
void cell::set_hyperlink(const string &hyperlink)
{
if (hyperlink.length() == 0 || std::find(hyperlink.begin(), hyperlink.end(), ':') == hyperlink.end())
if (hyperlink.length() == 0 || hyperlink.find(':') == std::string::npos)
{
throw data_type_exception();
}

View File

@ -16,7 +16,7 @@ public:
xlnt::workbook wb;
auto ws = wb.create_sheet();
ws.get_cell("F42").set_value("hello");
ws.get_auto_filter() = "A1:F1";
ws.auto_filter("A1:F1");
xlnt::workbook_serializer serializer(wb);
auto observed = serializer.write_workbook();

View File

@ -540,22 +540,12 @@ void string::append(code_point c)
string::code_point string::at(size_type index)
{
auto iter = begin();
size_type i = 0;
while (i < index) ++iter;
return *iter;
return *(begin() + index);
}
const string::code_point string::at(size_type index) const
{
auto iter = begin();
size_type i = 0;
while (i < index) ++iter;
return *iter;
return *(begin() + index);
}
bool string::operator==(const_byte_pointer str) const

View File

@ -924,4 +924,9 @@ void workbook::add_shared_string(const string &shared)
d_->shared_strings_.push_back(shared);
}
void workbook::create_named_range(const string &name, worksheet owner, const string &reference_string)
{
create_named_range(name, owner, range_reference(reference_string));
}
} // namespace xlnt

View File

@ -63,7 +63,7 @@ void worksheet::create_named_range(const string &name, const range_reference &re
range worksheet::operator()(const xlnt::cell_reference &top_left, const xlnt::cell_reference &bottom_right)
{
return get_range({ top_left, bottom_right });
return get_range(range_reference(top_left, bottom_right));
}
cell worksheet::operator[](const cell_reference &ref)
@ -91,6 +91,26 @@ void worksheet::auto_filter(const range_reference &reference)
d_->auto_filter_ = reference;
}
void worksheet::auto_filter(const string &reference_string)
{
auto_filter(range_reference(reference_string));
}
void worksheet::merge_cells(const string &reference_string)
{
merge_cells(range_reference(reference_string));
}
void worksheet::unmerge_cells(const string &reference_string)
{
unmerge_cells(range_reference(reference_string));
}
range worksheet::get_range(const string &reference_string)
{
return get_range(range_reference(reference_string));
}
void worksheet::auto_filter(const xlnt::range &range)
{
auto_filter(range.get_reference());