mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
Merge branch 'sukoi26-master'
This commit is contained in:
commit
c01af37da3
10
include/xlnt/styles/format.hpp
Normal file → Executable file
10
include/xlnt/styles/format.hpp
Normal file → Executable file
@ -189,6 +189,16 @@ public:
|
||||
/// </summary>
|
||||
bool protection_applied() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
bool pivot_button_applied() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
bool quote_prefix_applied() const;
|
||||
|
||||
// Style
|
||||
|
||||
/// <summary>
|
||||
|
10
include/xlnt/styles/style.hpp
Normal file → Executable file
10
include/xlnt/styles/style.hpp
Normal file → Executable file
@ -227,6 +227,16 @@ public:
|
||||
/// </summary>
|
||||
bool protection_applied() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
bool pivot_button_applied() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
bool quote_prefix_applied() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
8
source/detail/format_impl.hpp
Normal file → Executable file
8
source/detail/format_impl.hpp
Normal file → Executable file
@ -47,10 +47,14 @@ struct format_impl
|
||||
optional<std::size_t> protection_id;
|
||||
bool protection_applied = false;
|
||||
|
||||
bool pivot_button_applied = false;
|
||||
|
||||
bool quote_prefix_applied = false;
|
||||
|
||||
optional<std::string> style;
|
||||
|
||||
|
||||
std::size_t references = 0;
|
||||
|
||||
|
||||
XLNT_API friend bool operator==(const format_impl &left, const format_impl &right)
|
||||
{
|
||||
return left.parent == right.parent
|
||||
|
4
source/detail/style_impl.hpp
Normal file → Executable file
4
source/detail/style_impl.hpp
Normal file → Executable file
@ -48,6 +48,10 @@ struct style_impl
|
||||
|
||||
optional<std::size_t> protection_id;
|
||||
bool protection_applied = false;
|
||||
|
||||
bool pivot_button_applied = false;
|
||||
|
||||
bool quote_prefix_applied = false;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
@ -1521,6 +1521,14 @@ void xlsx_consumer::read_stylesheet()
|
||||
record.first.protection_applied = apply_protection_present
|
||||
&& is_true(parser().attribute("applyProtection"));
|
||||
|
||||
auto pivot_button_present = parser().attribute_present("pivotButton");
|
||||
record.first.pivot_button_applied = pivot_button_present
|
||||
&& is_true(parser().attribute("pivotButton"));
|
||||
|
||||
auto quote_prefix_present = parser().attribute_present("quotePrefix");
|
||||
record.first.quote_prefix_applied = quote_prefix_present
|
||||
&& is_true(parser().attribute("quotePrefix"));
|
||||
|
||||
if (parser().attribute_present("xfId") && parser().name() == "cellXfs")
|
||||
{
|
||||
record.second = parser().attribute<std::size_t>("xfId");
|
||||
@ -1735,6 +1743,8 @@ void xlsx_consumer::read_stylesheet()
|
||||
new_format.number_format_applied = record.first.number_format_applied;
|
||||
new_format.protection_id = record.first.protection_id;
|
||||
new_format.protection_applied = record.first.protection_applied;
|
||||
new_format.pivot_button_applied = record.first.pivot_button_applied;
|
||||
new_format.quote_prefix_applied = record.first.quote_prefix_applied;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2133,6 +2143,8 @@ void xlsx_consumer::read_worksheet(const std::string &rel_id)
|
||||
else if (current_worksheet_element == qn("spreadsheetml", "autoFilter")) // CT_AutoFilter 0-1
|
||||
{
|
||||
ws.auto_filter(xlnt::range_reference(parser().attribute("ref")));
|
||||
// auto filter complex
|
||||
skip_remaining_content(current_worksheet_element);
|
||||
}
|
||||
else if (current_worksheet_element == qn("spreadsheetml", "sortState")) // CT_SortState 0-1
|
||||
{
|
||||
@ -2461,7 +2473,7 @@ void xlsx_consumer::read_comments(worksheet ws)
|
||||
expect_start_element(qn("spreadsheetml", "comment"), xml::content::complex);
|
||||
|
||||
skip_attribute("shapeId");
|
||||
auto cell_ref = parser().attribute("ref");
|
||||
auto cell_ref = parser().attribute("ref");
|
||||
auto author_id = parser().attribute<std::size_t>("authorId");
|
||||
|
||||
expect_start_element(qn("spreadsheetml", "text"), xml::content::complex);
|
||||
@ -2743,12 +2755,12 @@ rich_text xlsx_consumer::read_rich_text(const xml::qname &parent)
|
||||
else if (current_run_property_element == xml::qname(xmlns, "b"))
|
||||
{
|
||||
run.second.get().bold(parser().attribute_present("val")
|
||||
? is_true(parser().attribute("val")) : true);
|
||||
? is_true(parser().attribute("val")) : true);
|
||||
}
|
||||
else if (current_run_property_element == xml::qname(xmlns, "i"))
|
||||
{
|
||||
run.second.get().italic(parser().attribute_present("val")
|
||||
? is_true(parser().attribute("val")) : true);
|
||||
? is_true(parser().attribute("val")) : true);
|
||||
}
|
||||
else if (current_run_property_element == xml::qname(xmlns, "u"))
|
||||
{
|
||||
|
32
source/detail/xlsx_producer.cpp
Normal file → Executable file
32
source/detail/xlsx_producer.cpp
Normal file → Executable file
@ -58,15 +58,15 @@ std::vector<std::pair<std::string, std::string>> core_property_namespace(xlnt::c
|
||||
using xlnt::core_property;
|
||||
using xlnt::constants;
|
||||
|
||||
if (type == core_property::created
|
||||
if (type == core_property::created
|
||||
|| type == core_property::modified)
|
||||
{
|
||||
return {{constants::ns("dcterms"), "dcterms"},
|
||||
{constants::ns("xsi"), "xsi"}};
|
||||
}
|
||||
else if (type == core_property::title
|
||||
|| type == core_property::subject
|
||||
|| type == core_property::creator
|
||||
else if (type == core_property::title
|
||||
|| type == core_property::subject
|
||||
|| type == core_property::creator
|
||||
|| type == core_property::description)
|
||||
{
|
||||
return {{constants::ns("dc"), "dc"}};
|
||||
@ -364,7 +364,7 @@ void xlsx_producer::write_extended_properties(const relationship &/*rel*/)
|
||||
|
||||
for (const auto &prop : source_.extended_properties())
|
||||
{
|
||||
write_property(to_string(prop), source_.extended_property(prop),
|
||||
write_property(to_string(prop), source_.extended_property(prop),
|
||||
constants::ns("extended-properties"), false, 0);
|
||||
}
|
||||
|
||||
@ -1175,6 +1175,16 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
||||
write_attribute("applyProtection", write_bool(true));
|
||||
}
|
||||
|
||||
if (current_style_impl.pivot_button_applied)
|
||||
{
|
||||
write_attribute("pivotButton", write_bool(true));
|
||||
}
|
||||
|
||||
if (current_style_impl.quote_prefix_applied)
|
||||
{
|
||||
write_attribute("quotePrefix", write_bool(true));
|
||||
}
|
||||
|
||||
if (current_style_impl.alignment_id.is_set())
|
||||
{
|
||||
const auto ¤t_alignment = stylesheet.alignments[current_style_impl.alignment_id.get()];
|
||||
@ -1229,7 +1239,7 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
||||
|
||||
write_end_element(xmlns, "cellStyleXfs");
|
||||
}
|
||||
|
||||
|
||||
// Format XFs
|
||||
|
||||
write_start_element(xmlns, "cellXfs");
|
||||
@ -1283,6 +1293,16 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
||||
write_attribute("applyProtection", write_bool(true));
|
||||
}
|
||||
|
||||
if (current_format_impl.pivot_button_applied)
|
||||
{
|
||||
write_attribute("pivotButton", write_bool(true));
|
||||
}
|
||||
|
||||
if (current_format_impl.quote_prefix_applied)
|
||||
{
|
||||
write_attribute("quotePrefix", write_bool(true));
|
||||
}
|
||||
|
||||
if (current_format_impl.style.is_set())
|
||||
{
|
||||
write_attribute("xfId", stylesheet.style_index(current_format_impl.style.get()));
|
||||
|
9
source/styles/format.cpp
Normal file → Executable file
9
source/styles/format.cpp
Normal file → Executable file
@ -210,5 +210,14 @@ bool format::protection_applied() const
|
||||
{
|
||||
return d_->protection_applied;
|
||||
}
|
||||
bool format::pivot_button_applied() const
|
||||
{
|
||||
return d_->pivot_button_applied;
|
||||
}
|
||||
|
||||
bool format::quote_prefix_applied() const
|
||||
{
|
||||
return d_->quote_prefix_applied;
|
||||
}
|
||||
|
||||
} // namespace xlnt
|
||||
|
10
source/styles/style.cpp
Normal file → Executable file
10
source/styles/style.cpp
Normal file → Executable file
@ -238,4 +238,14 @@ bool style::protection_applied() const
|
||||
return d_->protection_applied;
|
||||
}
|
||||
|
||||
bool style::pivot_button_applied() const
|
||||
{
|
||||
return d_->pivot_button_applied;
|
||||
}
|
||||
|
||||
bool style::quote_prefix_applied() const
|
||||
{
|
||||
return d_->quote_prefix_applied;
|
||||
}
|
||||
|
||||
} // namespace xlnt
|
||||
|
Loading…
x
Reference in New Issue
Block a user