mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
Merge branch 'dev' into dev
This commit is contained in:
commit
8d85ed917f
|
@ -94,12 +94,12 @@ public:
|
|||
/// <summary>
|
||||
/// The distance of the workbook window from the left side of the screen in twips.
|
||||
/// </summary>
|
||||
optional<std::size_t> x_window;
|
||||
optional<int> x_window;
|
||||
|
||||
/// <summary>
|
||||
/// The distance of the workbook window from the top of the screen in twips.
|
||||
/// </summary>
|
||||
optional<std::size_t> y_window;
|
||||
optional<int> y_window;
|
||||
};
|
||||
|
||||
} // namespace xlnt
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
// @license: http://www.opensource.org/licenses/mit-license.php
|
||||
// @author: see AUTHORS file
|
||||
|
||||
#include <locale>
|
||||
#include <cctype>
|
||||
|
||||
#include <xlnt/cell/cell_reference.hpp>
|
||||
#include <xlnt/utils/exceptions.hpp>
|
||||
|
@ -122,9 +122,9 @@ std::pair<std::string, row_t> cell_reference::split_reference(
|
|||
|
||||
for (auto character : reference_string)
|
||||
{
|
||||
char upper = std::toupper(character, std::locale::classic());
|
||||
char upper = std::toupper(character);
|
||||
|
||||
if (std::isalpha(character, std::locale::classic()))
|
||||
if (std::isalpha(character))
|
||||
{
|
||||
if (column_part)
|
||||
{
|
||||
|
@ -155,7 +155,7 @@ std::pair<std::string, row_t> cell_reference::split_reference(
|
|||
{
|
||||
column_part = false;
|
||||
}
|
||||
else if (!std::isdigit(character, std::locale::classic()))
|
||||
else if (!std::isdigit(character))
|
||||
{
|
||||
throw invalid_cell_reference(reference_string);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
//
|
||||
// @license: http://www.opensource.org/licenses/mit-license.php
|
||||
// @author: see AUTHORS file
|
||||
#include <locale>
|
||||
#include <cctype>
|
||||
|
||||
#include <xlnt/cell/index_types.hpp>
|
||||
#include <xlnt/utils/exceptions.hpp>
|
||||
|
@ -41,12 +41,12 @@ column_t::index_t column_t::column_index_from_string(const std::string &column_s
|
|||
|
||||
for (int i = static_cast<int>(column_string.length()) - 1; i >= 0; i--)
|
||||
{
|
||||
if (!std::isalpha(column_string[static_cast<std::size_t>(i)], std::locale::classic()))
|
||||
if (!std::isalpha(column_string[static_cast<std::size_t>(i)]))
|
||||
{
|
||||
throw invalid_column_index();
|
||||
}
|
||||
|
||||
auto char_index = std::toupper(column_string[static_cast<std::size_t>(i)], std::locale::classic()) - 'A';
|
||||
auto char_index = std::toupper(column_string[static_cast<std::size_t>(i)]) - 'A';
|
||||
|
||||
column_index += static_cast<column_t::index_t>((char_index + 1) * place);
|
||||
place *= 26;
|
||||
|
|
|
@ -149,6 +149,12 @@ void xlsx_consumer::open(std::istream &source)
|
|||
populate_workbook(true);
|
||||
}
|
||||
|
||||
// caching frequently used names
|
||||
static const auto sheetData_el = qn("spreadsheetml", "sheetData");
|
||||
static const auto row_el = qn("spreadsheetml", "row");
|
||||
static const auto cell_el = qn("spreadsheetml", "c");
|
||||
static const auto val_el = qn("spreadsheetml", "v");
|
||||
|
||||
cell xlsx_consumer::read_cell()
|
||||
{
|
||||
if (!has_cell())
|
||||
|
@ -158,10 +164,10 @@ cell xlsx_consumer::read_cell()
|
|||
|
||||
auto ws = worksheet(current_worksheet_);
|
||||
|
||||
if (in_element(qn("spreadsheetml", "sheetData")))
|
||||
if (in_element(sheetData_el))
|
||||
{
|
||||
expect_start_element(qn("spreadsheetml", "row"), xml::content::complex); // CT_Row
|
||||
auto row_index = parser().attribute<row_t>("r");
|
||||
expect_start_element(row_el, xml::content::complex); // CT_Row
|
||||
auto row_index = static_cast<row_t>(std::stoul(parser().attribute("r")));
|
||||
|
||||
if (parser().attribute_present("ht"))
|
||||
{
|
||||
|
@ -177,19 +183,18 @@ cell xlsx_consumer::read_cell()
|
|||
{
|
||||
ws.row_properties(row_index).hidden = true;
|
||||
}
|
||||
|
||||
skip_attributes({ qn("x14ac", "dyDescent") });
|
||||
skip_attributes({ "customFormat", "s", "customFont",
|
||||
"outlineLevel", "collapsed", "thickTop", "thickBot",
|
||||
"ph", "spans" });
|
||||
}
|
||||
|
||||
if (!in_element(qn("spreadsheetml", "row")))
|
||||
if (!in_element(row_el))
|
||||
{
|
||||
return cell(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
expect_start_element(qn("spreadsheetml", "c"), xml::content::complex);
|
||||
expect_start_element(cell_el, xml::content::complex);
|
||||
|
||||
auto cell = streaming_ ? xlnt::cell(streaming_cell_.get())
|
||||
: ws.cell(cell_reference(parser().attribute("r")));
|
||||
|
@ -211,11 +216,11 @@ cell xlsx_consumer::read_cell()
|
|||
auto has_shared_formula = false;
|
||||
auto formula_value_string = std::string();
|
||||
|
||||
while (in_element(qn("spreadsheetml", "c")))
|
||||
while (in_element(cell_el))
|
||||
{
|
||||
auto current_element = expect_start_element(xml::content::mixed);
|
||||
|
||||
if (current_element == qn("spreadsheetml", "v")) // s:ST_Xstring
|
||||
if (current_element == val_el) // s:ST_Xstring
|
||||
{
|
||||
has_value = true;
|
||||
value_string = read_text();
|
||||
|
@ -248,7 +253,7 @@ cell xlsx_consumer::read_cell()
|
|||
expect_end_element(current_element);
|
||||
}
|
||||
|
||||
expect_end_element(qn("spreadsheetml", "c"));
|
||||
expect_end_element(cell_el);
|
||||
|
||||
if (has_formula && !has_shared_formula)
|
||||
{
|
||||
|
@ -286,13 +291,13 @@ cell xlsx_consumer::read_cell()
|
|||
}
|
||||
}
|
||||
|
||||
if (!in_element(qn("spreadsheetml", "row")))
|
||||
if (!in_element(row_el))
|
||||
{
|
||||
expect_end_element(qn("spreadsheetml", "row"));
|
||||
expect_end_element(row_el);
|
||||
|
||||
if (!in_element(qn("spreadsheetml", "sheetData")))
|
||||
if (!in_element(sheetData_el))
|
||||
{
|
||||
expect_end_element(qn("spreadsheetml", "sheetData"));
|
||||
expect_end_element(sheetData_el);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1015,8 +1020,8 @@ xml::parser &xlsx_consumer::parser()
|
|||
|
||||
bool xlsx_consumer::has_cell()
|
||||
{
|
||||
return in_element(qn("spreadsheetml", "row"))
|
||||
|| in_element(qn("spreadsheetml", "sheetData"));
|
||||
return in_element(row_el)
|
||||
|| in_element(sheetData_el);
|
||||
}
|
||||
|
||||
std::vector<relationship> xlsx_consumer::read_relationships(const path &part)
|
||||
|
@ -1416,12 +1421,12 @@ void xlsx_consumer::read_office_document(const std::string &content_type) // CT_
|
|||
|
||||
if (parser().attribute_present("xWindow"))
|
||||
{
|
||||
view.x_window = parser().attribute<std::size_t>("xWindow");
|
||||
view.x_window = parser().attribute<int>("xWindow");
|
||||
}
|
||||
|
||||
if (parser().attribute_present("yWindow"))
|
||||
{
|
||||
view.y_window = parser().attribute<std::size_t>("yWindow");
|
||||
view.y_window = parser().attribute<int>("yWindow");
|
||||
}
|
||||
|
||||
if (parser().attribute_present("windowWidth"))
|
||||
|
|
Loading…
Reference in New Issue
Block a user