mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
remove potentially problematic methods on optional, fix windows build
This commit is contained in:
parent
294fc8f3b7
commit
398bf7a3bb
|
@ -40,7 +40,7 @@ public:
|
|||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
optional<bool> shrink() const;
|
||||
bool shrink() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
|
@ -50,7 +50,7 @@ public:
|
|||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
optional<bool> wrap() const;
|
||||
bool wrap() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
|
@ -111,12 +111,12 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
optional<bool> shrink_to_fit_;
|
||||
optional<bool> wrap_text_;
|
||||
bool shrink_to_fit_ = false;
|
||||
bool wrap_text_ = false;
|
||||
optional<int> indent_;
|
||||
optional<int> text_rotation_;
|
||||
optional<horizontal_alignment> horizontal_ = horizontal_alignment::general;
|
||||
optional<vertical_alignment> vertical_ = vertical_alignment::bottom;
|
||||
optional<horizontal_alignment> horizontal_;
|
||||
optional<vertical_alignment> vertical_;
|
||||
};
|
||||
|
||||
} // namespace xlnt
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
optional(const T &value) : has_value_(true), value_(value)
|
||||
explicit optional(const T &value) : has_value_(true), value_(value)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -76,38 +76,6 @@ public:
|
|||
value_ = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
T &operator*()
|
||||
{
|
||||
return get();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
const T &operator*() const
|
||||
{
|
||||
return get();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
T *operator->()
|
||||
{
|
||||
return &get();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
const T *operator->() const
|
||||
{
|
||||
return &get();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
@ -143,6 +111,14 @@ public:
|
|||
value_ = T();
|
||||
}
|
||||
|
||||
optional &operator=(const T &rhs)
|
||||
{
|
||||
has_value_ = true;
|
||||
value_ = rhs;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
|
|
@ -910,7 +910,7 @@ format cell::modifiable_format()
|
|||
throw invalid_attribute();
|
||||
}
|
||||
|
||||
return xlnt::format(*d_->format_);
|
||||
return xlnt::format(d_->format_.get());
|
||||
}
|
||||
|
||||
const format cell::format() const
|
||||
|
@ -920,7 +920,7 @@ const format cell::format() const
|
|||
throw invalid_attribute();
|
||||
}
|
||||
|
||||
return xlnt::format(*d_->format_);
|
||||
return xlnt::format(d_->format_.get());
|
||||
}
|
||||
|
||||
alignment cell::alignment() const
|
||||
|
|
|
@ -1002,14 +1002,14 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
|||
if (pattern.foreground())
|
||||
{
|
||||
serializer().start_element(xmlns, "fgColor");
|
||||
write_color(*pattern.foreground());
|
||||
write_color(pattern.foreground().get());
|
||||
serializer().end_element(xmlns, "fgColor");
|
||||
}
|
||||
|
||||
if (pattern.background())
|
||||
{
|
||||
serializer().start_element(xmlns, "bgColor");
|
||||
write_color(*pattern.background());
|
||||
write_color(pattern.background().get());
|
||||
serializer().end_element(xmlns, "bgColor");
|
||||
}
|
||||
|
||||
|
@ -1081,12 +1081,12 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
|||
|
||||
if (current_border.diagonal())
|
||||
{
|
||||
auto up = *current_border.diagonal() == diagonal_direction::both
|
||||
|| *current_border.diagonal() == diagonal_direction::up;
|
||||
auto up = current_border.diagonal().get() == diagonal_direction::both
|
||||
|| current_border.diagonal().get() == diagonal_direction::up;
|
||||
serializer().attribute("diagonalUp", write_bool(up));
|
||||
|
||||
auto down = *current_border.diagonal() == diagonal_direction::both
|
||||
|| *current_border.diagonal() == diagonal_direction::down;
|
||||
auto down = current_border.diagonal().get() == diagonal_direction::both
|
||||
|| current_border.diagonal().get() == diagonal_direction::down;
|
||||
serializer().attribute("diagonalDown", write_bool(down));
|
||||
}
|
||||
|
||||
|
@ -1094,20 +1094,20 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
|||
{
|
||||
if (current_border.side(side))
|
||||
{
|
||||
const auto current_side = *current_border.side(side);
|
||||
const auto current_side = current_border.side(side).get();
|
||||
|
||||
auto side_name = to_string(side);
|
||||
serializer().start_element(xmlns, side_name);
|
||||
|
||||
if (current_side.style())
|
||||
{
|
||||
serializer().attribute("style", *current_side.style());
|
||||
serializer().attribute("style", current_side.style().get());
|
||||
}
|
||||
|
||||
if (current_side.color())
|
||||
{
|
||||
serializer().start_element(xmlns, "color");
|
||||
write_color(*current_side.color());
|
||||
write_color(current_side.color().get());
|
||||
serializer().end_element(xmlns, "color");
|
||||
}
|
||||
|
||||
|
@ -1189,7 +1189,7 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
|||
|
||||
if (current_alignment.wrap())
|
||||
{
|
||||
serializer().attribute("wrapText", write_bool(current_alignment.wrap().get()));
|
||||
serializer().attribute("wrapText", write_bool(current_alignment.wrap()));
|
||||
}
|
||||
|
||||
if (current_alignment.indent())
|
||||
|
@ -1199,7 +1199,7 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
|||
|
||||
if (current_alignment.shrink())
|
||||
{
|
||||
serializer().attribute("shrinkToFit", write_bool(current_alignment.shrink().get()));
|
||||
serializer().attribute("shrinkToFit", write_bool(current_alignment.shrink()));
|
||||
}
|
||||
|
||||
serializer().end_element(xmlns, "alignment");
|
||||
|
@ -1301,7 +1301,7 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
|||
|
||||
if (current_alignment.wrap())
|
||||
{
|
||||
serializer().attribute("wrapText", write_bool(current_alignment.wrap().get()));
|
||||
serializer().attribute("wrapText", write_bool(current_alignment.wrap()));
|
||||
}
|
||||
|
||||
if (current_alignment.indent())
|
||||
|
@ -1311,7 +1311,7 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
|||
|
||||
if (current_alignment.shrink())
|
||||
{
|
||||
serializer().attribute("shrinkToFit", write_bool(current_alignment.shrink().get()));
|
||||
serializer().attribute("shrinkToFit", write_bool(current_alignment.shrink()));
|
||||
}
|
||||
|
||||
serializer().end_element(xmlns, "alignment");
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
namespace xlnt {
|
||||
|
||||
optional<bool> alignment::wrap() const
|
||||
bool alignment::wrap() const
|
||||
{
|
||||
return wrap_text_;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ alignment &alignment::wrap(bool wrap_text)
|
|||
return *this;
|
||||
}
|
||||
|
||||
optional<bool> alignment::shrink() const
|
||||
bool alignment::shrink() const
|
||||
{
|
||||
return shrink_to_fit_;
|
||||
}
|
||||
|
@ -133,19 +133,11 @@ XLNT_API bool operator==(const alignment &left, const alignment &right)
|
|||
}
|
||||
}
|
||||
|
||||
if (left.shrink().is_set() != right.shrink().is_set())
|
||||
if (left.shrink() != right.shrink())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (left.shrink().is_set())
|
||||
{
|
||||
if (left.shrink().get() != right.shrink().get())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (left.vertical().is_set() != right.vertical().is_set())
|
||||
{
|
||||
return false;
|
||||
|
@ -159,19 +151,11 @@ XLNT_API bool operator==(const alignment &left, const alignment &right)
|
|||
}
|
||||
}
|
||||
|
||||
if (left.wrap().is_set() != right.wrap().is_set())
|
||||
if (left.wrap() != right.wrap())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (left.wrap().is_set())
|
||||
{
|
||||
if (left.wrap().get() != right.wrap().get())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,10 +12,8 @@ public:
|
|||
{
|
||||
xlnt::alignment alignment;
|
||||
|
||||
TS_ASSERT(alignment.horizontal());
|
||||
TS_ASSERT_EQUALS(*alignment.horizontal(), xlnt::horizontal_alignment::general);
|
||||
TS_ASSERT(alignment.vertical());
|
||||
TS_ASSERT_EQUALS(*alignment.vertical(), xlnt::vertical_alignment::bottom);
|
||||
TS_ASSERT(!alignment.horizontal().is_set());
|
||||
TS_ASSERT(!alignment.vertical().is_set());
|
||||
TS_ASSERT(!alignment.shrink());
|
||||
TS_ASSERT(!alignment.wrap());
|
||||
}
|
||||
|
|
|
@ -32,11 +32,11 @@ public:
|
|||
|
||||
fill = fill.pattern_fill().foreground(xlnt::color::black());
|
||||
TS_ASSERT(fill.pattern_fill().foreground());
|
||||
TS_ASSERT_EQUALS((*fill.pattern_fill().foreground()).rgb().hex_string(), xlnt::color::black().rgb().hex_string());
|
||||
TS_ASSERT_EQUALS(fill.pattern_fill().foreground().get().rgb().hex_string(), xlnt::color::black().rgb().hex_string());
|
||||
|
||||
fill = fill.pattern_fill().background(xlnt::color::green());
|
||||
TS_ASSERT(fill.pattern_fill().background());
|
||||
TS_ASSERT_EQUALS((*fill.pattern_fill().background()).rgb().hex_string(), xlnt::color::green().rgb().hex_string());
|
||||
TS_ASSERT_EQUALS(fill.pattern_fill().background().get().rgb().hex_string(), xlnt::color::green().rgb().hex_string());
|
||||
|
||||
const auto &const_fill = fill;
|
||||
TS_ASSERT(const_fill.pattern_fill().foreground());
|
||||
|
|
|
@ -286,7 +286,7 @@ workbook::workbook(detail::workbook_impl *impl)
|
|||
{
|
||||
if (d_->stylesheet_.is_set())
|
||||
{
|
||||
d_->stylesheet_->parent = this;
|
||||
d_->stylesheet_.get().parent = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -903,7 +903,7 @@ void swap(workbook &left, workbook &right)
|
|||
|
||||
if (left.d_->stylesheet_.is_set())
|
||||
{
|
||||
left.d_->stylesheet_->parent = &left;
|
||||
left.d_->stylesheet_.get().parent = &left;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -916,7 +916,7 @@ void swap(workbook &left, workbook &right)
|
|||
|
||||
if (right.d_->stylesheet_.is_set())
|
||||
{
|
||||
right.d_->stylesheet_->parent = &right;
|
||||
right.d_->stylesheet_.get().parent = &right;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -924,7 +924,7 @@ void swap(workbook &left, workbook &right)
|
|||
workbook &workbook::operator=(workbook other)
|
||||
{
|
||||
swap(*this, other);
|
||||
d_->stylesheet_->parent = this;
|
||||
d_->stylesheet_.get().parent = this;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
@ -945,7 +945,7 @@ workbook::workbook(const workbook &other)
|
|||
ws.parent(*this);
|
||||
}
|
||||
|
||||
d_->stylesheet_->parent = this;
|
||||
d_->stylesheet_.get().parent = this;
|
||||
}
|
||||
|
||||
workbook::~workbook()
|
||||
|
@ -986,12 +986,12 @@ std::vector<named_range> workbook::named_ranges() const
|
|||
format workbook::create_format(bool default_format)
|
||||
{
|
||||
register_stylesheet_in_manifest();
|
||||
return d_->stylesheet_->create_format(default_format);
|
||||
return d_->stylesheet_.get().create_format(default_format);
|
||||
}
|
||||
|
||||
bool workbook::has_style(const std::string &name) const
|
||||
{
|
||||
return d_->stylesheet_->has_style(name);
|
||||
return d_->stylesheet_.get().has_style(name);
|
||||
}
|
||||
|
||||
void workbook::clear_styles()
|
||||
|
@ -1023,12 +1023,12 @@ void workbook::apply_to_cells(std::function<void(cell)> f)
|
|||
|
||||
format workbook::format(std::size_t format_index)
|
||||
{
|
||||
return d_->stylesheet_->format(format_index);
|
||||
return d_->stylesheet_.get().format(format_index);
|
||||
}
|
||||
|
||||
const format workbook::format(std::size_t format_index) const
|
||||
{
|
||||
return d_->stylesheet_->format(format_index);
|
||||
return d_->stylesheet_.get().format(format_index);
|
||||
}
|
||||
|
||||
manifest &workbook::manifest()
|
||||
|
@ -1099,17 +1099,17 @@ const std::vector<std::uint8_t> &workbook::thumbnail() const
|
|||
|
||||
style workbook::create_style(const std::string &name)
|
||||
{
|
||||
return d_->stylesheet_->create_style(name);
|
||||
return d_->stylesheet_.get().create_style(name);
|
||||
}
|
||||
|
||||
style workbook::style(const std::string &name)
|
||||
{
|
||||
return d_->stylesheet_->style(name);
|
||||
return d_->stylesheet_.get().style(name);
|
||||
}
|
||||
|
||||
const style workbook::style(const std::string &name) const
|
||||
{
|
||||
return d_->stylesheet_->style(name);
|
||||
return d_->stylesheet_.get().style(name);
|
||||
}
|
||||
|
||||
calendar workbook::base_date() const
|
||||
|
|
Loading…
Reference in New Issue
Block a user