mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
test workbook and fix mising template specialization
This commit is contained in:
parent
dfaec919ff
commit
51db47e2a8
|
@ -124,7 +124,6 @@ public:
|
|||
worksheet create_sheet(std::size_t index);
|
||||
worksheet create_sheet(const std::string &title);
|
||||
worksheet create_sheet(std::size_t index, const std::string &title);
|
||||
worksheet create_sheet(const std::string &title, const relationship &rel);
|
||||
|
||||
void copy_sheet(worksheet worksheet);
|
||||
void copy_sheet(worksheet worksheet, std::size_t index);
|
||||
|
@ -237,10 +236,8 @@ public:
|
|||
const format &get_format(std::size_t format_index) const;
|
||||
std::size_t add_format(const format &new_format);
|
||||
void clear_formats();
|
||||
std::vector<format> &get_formats();
|
||||
const std::vector<format> &get_formats() const;
|
||||
|
||||
// named styles
|
||||
// styles
|
||||
|
||||
bool has_style(const std::string &name) const;
|
||||
style &get_style(const std::string &name);
|
||||
|
|
|
@ -781,9 +781,15 @@ XLNT_FUNCTION std::uint64_t cell::get_value() const
|
|||
|
||||
#ifdef __linux
|
||||
template <>
|
||||
XLNT_FUNCTION long long int cell::get_value() const
|
||||
XLNT_FUNCTION long long cell::get_value() const
|
||||
{
|
||||
return static_cast<long long int>(d_->value_numeric_);
|
||||
return static_cast<long long>(d_->value_numeric_);
|
||||
}
|
||||
|
||||
template <>
|
||||
XLNT_FUNCTION unsigned long long cell::get_value() const
|
||||
{
|
||||
return static_cast<unsigned long long>(d_->value_numeric_);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ bool load_workbook(xlnt::zip_file &archive, bool guess_types, bool data_only, xl
|
|||
continue;
|
||||
}
|
||||
|
||||
auto ws = wb.create_sheet(sheet_node.attribute("name").value(), rel);
|
||||
auto ws = wb.create_sheet(sheet_node.attribute("name").value());
|
||||
xlnt::worksheet_serializer worksheet_serializer(ws);
|
||||
pugi::xml_document worksheet_xml;
|
||||
worksheet_xml.load(archive.read("xl/" + rel.get_target_uri()).c_str());
|
||||
|
|
|
@ -190,7 +190,7 @@ void workbook_serializer::write_properties_app(pugi::xml_document &xml) const
|
|||
root_node.append_attribute("xmlns").set_value("http://schemas.openxmlformats.org/officeDocument/2006/extended-properties");
|
||||
root_node.append_attribute("xmlns:vt").set_value("http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes");
|
||||
|
||||
auto &properties = workbook_.get_app_properties();
|
||||
const auto &properties = workbook_.get_app_properties();
|
||||
|
||||
root_node.append_child("Application").text().set(properties.application.c_str());
|
||||
root_node.append_child("DocSecurity").text().set(std::to_string(properties.doc_security).c_str());
|
||||
|
|
|
@ -103,6 +103,7 @@ public:
|
|||
new_sheet.set_title(title);
|
||||
auto found_sheet = wb.get_sheet_by_name(title);
|
||||
TS_ASSERT_EQUALS(new_sheet, found_sheet);
|
||||
TS_ASSERT_THROWS(wb.get_sheet_by_name("error"), xlnt::key_error);
|
||||
}
|
||||
|
||||
void test_get_sheet_by_name_const()
|
||||
|
@ -348,4 +349,25 @@ public:
|
|||
wb.clear();
|
||||
TS_ASSERT(wb.get_sheet_names().empty());
|
||||
}
|
||||
|
||||
void test_comparison()
|
||||
{
|
||||
xlnt::workbook wb, wb2;
|
||||
TS_ASSERT(wb == wb);
|
||||
TS_ASSERT(!(wb != wb));
|
||||
TS_ASSERT(!(wb == wb2));
|
||||
TS_ASSERT(wb != wb2)
|
||||
|
||||
const auto &wb_const = wb;
|
||||
//TODO these aren't tests...
|
||||
wb_const.get_app_properties();
|
||||
wb_const.get_manifest();
|
||||
|
||||
TS_ASSERT(!wb.has_loaded_theme());
|
||||
|
||||
wb.create_style("style1");
|
||||
wb.get_style("style1");
|
||||
wb_const.get_style("style1");
|
||||
wb.get_style_by_id(0);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -210,13 +210,7 @@ void workbook::create_named_range(const std::string &name, worksheet range_owner
|
|||
|
||||
void workbook::create_named_range(const std::string &name, worksheet range_owner, const range_reference &reference)
|
||||
{
|
||||
auto match = get_sheet_by_name(range_owner.get_title());
|
||||
if (match != nullptr)
|
||||
{
|
||||
match.create_named_range(name, reference);
|
||||
return;
|
||||
}
|
||||
throw std::runtime_error("worksheet isn't owned by this workbook");
|
||||
get_sheet_by_name(range_owner.get_title()).create_named_range(name, reference);
|
||||
}
|
||||
|
||||
void workbook::remove_named_range(const std::string &name)
|
||||
|
@ -350,20 +344,6 @@ std::size_t workbook::index_from_ws_filename(const std::string &ws_filename)
|
|||
return sheet_index;
|
||||
}
|
||||
|
||||
worksheet workbook::create_sheet(const std::string &title, const relationship &rel)
|
||||
{
|
||||
d_->worksheets_.push_back(detail::worksheet_impl(this, title));
|
||||
|
||||
auto index = index_from_ws_filename(rel.get_target_uri());
|
||||
if (index != d_->worksheets_.size() - 1)
|
||||
{
|
||||
std::swap(d_->worksheets_.back(), d_->worksheets_[index]);
|
||||
d_->worksheets_.pop_back();
|
||||
}
|
||||
|
||||
return worksheet(&d_->worksheets_[index]);
|
||||
}
|
||||
|
||||
worksheet workbook::create_sheet(std::size_t index, const std::string &title)
|
||||
{
|
||||
auto ws = create_sheet(index);
|
||||
|
@ -458,12 +438,7 @@ worksheet workbook::operator[](const std::string &name)
|
|||
|
||||
worksheet workbook::operator[](std::size_t index)
|
||||
{
|
||||
if (index > d_->worksheets_.size())
|
||||
{
|
||||
throw key_error();
|
||||
}
|
||||
|
||||
return worksheet(&d_->worksheets_[index]);
|
||||
return worksheet(&d_->worksheets_.at(index));
|
||||
}
|
||||
|
||||
void workbook::clear()
|
||||
|
@ -762,16 +737,6 @@ style &workbook::create_style(const std::string &name)
|
|||
return d_->stylesheet_.styles.back();
|
||||
}
|
||||
|
||||
std::vector<format> &workbook::get_formats()
|
||||
{
|
||||
return d_->stylesheet_.formats;
|
||||
}
|
||||
|
||||
const std::vector<format> &workbook::get_formats() const
|
||||
{
|
||||
return d_->stylesheet_.formats;
|
||||
}
|
||||
|
||||
style &workbook::get_style(const std::string &name)
|
||||
{
|
||||
return *std::find_if(d_->stylesheet_.styles.begin(), d_->stylesheet_.styles.end(),
|
||||
|
|
Loading…
Reference in New Issue
Block a user