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
81258f1498
|
@ -97,6 +97,26 @@ public:
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool strikethrough() const;
|
bool strikethrough() const;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
font &outlinethrough(bool outlinethrough);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
bool outlinethrough() const;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
font &shadowthrough(bool shadowthrough);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
bool shadowthrough() const;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -172,6 +192,21 @@ public:
|
||||||
/// </summary>
|
/// </summary>
|
||||||
std::size_t family() const;
|
std::size_t family() const;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
bool has_charset() const;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
font &charset(std::size_t charset);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
std::size_t charset() const;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -238,6 +273,16 @@ private:
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool strikethrough_ = false;
|
bool strikethrough_ = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
bool outlinethrough_ = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
bool shadowthrough_ = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -253,6 +298,12 @@ private:
|
||||||
/// </summary>
|
/// </summary>
|
||||||
optional<std::size_t> family_;
|
optional<std::size_t> family_;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
optional<std::size_t> charset_;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -528,15 +528,15 @@ std::pair<int, int> cell::anchor() const
|
||||||
|
|
||||||
for (column_t column_index = 1; column_index <= d_->column_ - 1; column_index++)
|
for (column_t column_index = 1; column_index <= d_->column_ - 1; column_index++)
|
||||||
{
|
{
|
||||||
left += worksheet().cell(column_index, row()).width();
|
left += worksheet().column_width(column_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
double top = 0;
|
double top = 0;
|
||||||
|
|
||||||
for (row_t row_index = 1; row_index <= d_->row_ - 1; row_index++)
|
for (row_t row_index = 1; row_index <= d_->row_ - 1; row_index++)
|
||||||
{
|
{
|
||||||
top += worksheet().cell(column(), row_index).height();
|
top += worksheet().row_height(row_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {static_cast<int>(left), static_cast<int>(top)};
|
return {static_cast<int>(left), static_cast<int>(top)};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1345,6 +1345,28 @@ void xlsx_consumer::read_stylesheet()
|
||||||
new_font.strikethrough(true);
|
new_font.strikethrough(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (font_property_element == qn("spreadsheetml", "outline"))
|
||||||
|
{
|
||||||
|
if (parser().attribute_present("val"))
|
||||||
|
{
|
||||||
|
new_font.outlinethrough(is_true(parser().attribute("val")));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
new_font.outlinethrough(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (font_property_element == qn("spreadsheetml", "shadow"))
|
||||||
|
{
|
||||||
|
if (parser().attribute_present("val"))
|
||||||
|
{
|
||||||
|
new_font.shadowthrough(is_true(parser().attribute("val")));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
new_font.shadowthrough(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (font_property_element == qn("spreadsheetml", "i"))
|
else if (font_property_element == qn("spreadsheetml", "i"))
|
||||||
{
|
{
|
||||||
if (parser().attribute_present("val"))
|
if (parser().attribute_present("val"))
|
||||||
|
@ -1575,11 +1597,11 @@ void xlsx_consumer::read_stylesheet()
|
||||||
auto count = parser().attribute<std::size_t>("count");
|
auto count = parser().attribute<std::size_t>("count");
|
||||||
std::size_t processed = 0;
|
std::size_t processed = 0;
|
||||||
|
|
||||||
while (in_element(qn("spreadsheetml", "dxfs")))
|
while (in_element(current_style_element))
|
||||||
{
|
{
|
||||||
auto current_element = expect_start_element(xml::content::complex);
|
auto current_element = expect_start_element(xml::content::mixed);
|
||||||
skip_remaining_content(current_element);
|
skip_remaining_content(current_element);
|
||||||
|
expect_end_element(current_element);
|
||||||
++processed;
|
++processed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1600,7 +1622,7 @@ void xlsx_consumer::read_stylesheet()
|
||||||
{
|
{
|
||||||
auto current_element = expect_start_element(xml::content::complex);
|
auto current_element = expect_start_element(xml::content::complex);
|
||||||
skip_remaining_content(current_element);
|
skip_remaining_content(current_element);
|
||||||
|
expect_end_element(current_element);
|
||||||
++processed;
|
++processed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2438,7 +2460,8 @@ void xlsx_consumer::read_comments(worksheet ws)
|
||||||
{
|
{
|
||||||
expect_start_element(qn("spreadsheetml", "comment"), xml::content::complex);
|
expect_start_element(qn("spreadsheetml", "comment"), xml::content::complex);
|
||||||
|
|
||||||
auto cell_ref = parser().attribute("ref");
|
skip_attribute("shapeId");
|
||||||
|
auto cell_ref = parser().attribute("ref");
|
||||||
auto author_id = parser().attribute<std::size_t>("authorId");
|
auto author_id = parser().attribute<std::size_t>("authorId");
|
||||||
|
|
||||||
expect_start_element(qn("spreadsheetml", "text"), xml::content::complex);
|
expect_start_element(qn("spreadsheetml", "text"), xml::content::complex);
|
||||||
|
@ -2627,11 +2650,11 @@ std::vector<std::string> xlsx_consumer::read_namespaces()
|
||||||
|
|
||||||
bool xlsx_consumer::in_element(const xml::qname &name)
|
bool xlsx_consumer::in_element(const xml::qname &name)
|
||||||
{
|
{
|
||||||
if (parser().peek() == xml::parser::event_type::end_element || stack_.back() != name)
|
|
||||||
|
if ((parser().peek() == xml::parser::event_type::end_element ) && (stack_.back() == name ))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2717,6 +2740,10 @@ rich_text xlsx_consumer::read_rich_text(const xml::qname &parent)
|
||||||
{
|
{
|
||||||
run.second.get().family(parser().attribute<std::size_t>("val"));
|
run.second.get().family(parser().attribute<std::size_t>("val"));
|
||||||
}
|
}
|
||||||
|
else if (current_run_property_element == xml::qname(xmlns, "charset"))
|
||||||
|
{
|
||||||
|
run.second.get().charset(parser().attribute<std::size_t>("val"));
|
||||||
|
}
|
||||||
else if (current_run_property_element == xml::qname(xmlns, "scheme"))
|
else if (current_run_property_element == xml::qname(xmlns, "scheme"))
|
||||||
{
|
{
|
||||||
run.second.get().scheme(parser().attribute("val"));
|
run.second.get().scheme(parser().attribute("val"));
|
||||||
|
@ -2726,6 +2753,11 @@ rich_text xlsx_consumer::read_rich_text(const xml::qname &parent)
|
||||||
run.second.get().bold(
|
run.second.get().bold(
|
||||||
parser().attribute_present("val") ? is_true(parser().attribute("val")) : true);
|
parser().attribute_present("val") ? is_true(parser().attribute("val")) : true);
|
||||||
}
|
}
|
||||||
|
else if (current_run_property_element == xml::qname(xmlns, "i"))
|
||||||
|
{
|
||||||
|
run.second.get().bold(
|
||||||
|
parser().attribute_present("val") ? is_true(parser().attribute("val")) : true);
|
||||||
|
}
|
||||||
else if (current_run_property_element == xml::qname(xmlns, "u"))
|
else if (current_run_property_element == xml::qname(xmlns, "u"))
|
||||||
{
|
{
|
||||||
if (parser().attribute_present("val"))
|
if (parser().attribute_present("val"))
|
||||||
|
|
|
@ -36,6 +36,8 @@ font::font()
|
||||||
superscript_(false),
|
superscript_(false),
|
||||||
subscript_(false),
|
subscript_(false),
|
||||||
strikethrough_(false),
|
strikethrough_(false),
|
||||||
|
outlinethrough_(false),
|
||||||
|
shadowthrough_(false),
|
||||||
underline_(underline_style::none)
|
underline_(underline_style::none)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -84,6 +86,28 @@ bool font::strikethrough() const
|
||||||
return strikethrough_;
|
return strikethrough_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
font &font::outlinethrough(bool outlinethrough)
|
||||||
|
{
|
||||||
|
outlinethrough_ = outlinethrough;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool font::outlinethrough() const
|
||||||
|
{
|
||||||
|
return outlinethrough_;
|
||||||
|
}
|
||||||
|
|
||||||
|
font &font::shadowthrough(bool shadowthrough)
|
||||||
|
{
|
||||||
|
shadowthrough_ = shadowthrough;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool font::shadowthrough() const
|
||||||
|
{
|
||||||
|
return shadowthrough_;
|
||||||
|
}
|
||||||
|
|
||||||
font &font::underline(underline_style new_underline)
|
font &font::underline(underline_style new_underline)
|
||||||
{
|
{
|
||||||
underline_ = new_underline;
|
underline_ = new_underline;
|
||||||
|
@ -154,6 +178,17 @@ font &font::family(std::size_t family)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool font::has_charset() const
|
||||||
|
{
|
||||||
|
return charset_.is_set();
|
||||||
|
}
|
||||||
|
|
||||||
|
font &font::charset(std::size_t charset)
|
||||||
|
{
|
||||||
|
charset_ = charset;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
bool font::has_scheme() const
|
bool font::has_scheme() const
|
||||||
{
|
{
|
||||||
return scheme_.is_set();
|
return scheme_.is_set();
|
||||||
|
|
|
@ -793,6 +793,25 @@ void workbook::load(const std::vector<std::uint8_t> &data)
|
||||||
|
|
||||||
void workbook::load(const std::string &filename)
|
void workbook::load(const std::string &filename)
|
||||||
{
|
{
|
||||||
|
if (filename.find_last_of(".") != std::string::npos) // check extension
|
||||||
|
{
|
||||||
|
std::string file_format = path(filename).extension();
|
||||||
|
|
||||||
|
if (file_format == "xls") {
|
||||||
|
throw xlnt::exception(" xlnt does not support the old .xls file format");
|
||||||
|
}
|
||||||
|
else if (file_format == "xlsb") {
|
||||||
|
throw xlnt::exception(" xlnt does not support the .xlsb file format");
|
||||||
|
}
|
||||||
|
else if (file_format != "xlsx") {
|
||||||
|
throw xlnt::exception(" xlnt does not support the ."+file_format+ " file format");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw xlnt::exception("file has no extension .xlsx");
|
||||||
|
}
|
||||||
|
|
||||||
return load(path(filename));
|
return load(path(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -811,6 +830,25 @@ void workbook::load(const path &filename)
|
||||||
|
|
||||||
void workbook::load(const std::string &filename, const std::string &password)
|
void workbook::load(const std::string &filename, const std::string &password)
|
||||||
{
|
{
|
||||||
|
if (filename.find_last_of(".") != std::string::npos) // check extension
|
||||||
|
{
|
||||||
|
std::string file_format = path(filename).extension();
|
||||||
|
|
||||||
|
if (file_format == "xls") {
|
||||||
|
throw xlnt::exception(" xlnt does not support the old .xls file format");
|
||||||
|
}
|
||||||
|
else if (file_format == "xlsb") {
|
||||||
|
throw xlnt::exception(" xlnt does not support the .xlsb file format");
|
||||||
|
}
|
||||||
|
else if (file_format != "xlsx") {
|
||||||
|
throw xlnt::exception(" xlnt does not support the ."+file_format+ " file format");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw xlnt::exception("file has no extension .xlsx");
|
||||||
|
}
|
||||||
|
|
||||||
return load(path(filename), password);
|
return load(path(filename), password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user