Commit bf0b5a4b authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormat - fix formulas

parent 4f92ab53
...@@ -242,6 +242,10 @@ namespace formulasconvert { ...@@ -242,6 +242,10 @@ namespace formulasconvert {
if (boost::regex_search(expr, res, boost::wregex(L"(?:[\\w]+:)?=(.+)"), boost::match_default)) if (boost::regex_search(expr, res, boost::wregex(L"(?:[\\w]+:)?=(.+)"), boost::match_default))
{ {
expr = res[1].str(); expr = res[1].str();
while (expr.find(L"=") == 0)
{
expr.erase(expr.begin(), expr.begin() + 1);
}
return true; return true;
} }
else else
...@@ -305,6 +309,37 @@ namespace formulasconvert { ...@@ -305,6 +309,37 @@ namespace formulasconvert {
else if (what[3].matched) else if (what[3].matched)
return what[3].str(); return what[3].str();
} }
std::wstring convert_scobci(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
boost::algorithm::replace_all(inner, L"(", L"SCOBCAIN");
boost::algorithm::replace_all(inner, L")", L"SCOBCAOUT");
boost::algorithm::replace_all(inner, L"[", L"KVADRATIN");
boost::algorithm::replace_all(inner, L"]", L"KVADRATOUT");
boost::algorithm::replace_all(inner, L" ", L"PROBEL");
boost::algorithm::replace_all(inner, L"'", L"APOSTROF");
return inner;
}
else if (what[2].matched)
{
std::wstring inner = what[2].str();
boost::algorithm::replace_all(inner, L"(", L"SCOBCAIN");
boost::algorithm::replace_all(inner, L")", L"SCOBCAOUT");
boost::algorithm::replace_all(inner, L"[", L"KVADRATIN");
boost::algorithm::replace_all(inner, L"]", L"KVADRATOUT");
boost::algorithm::replace_all(inner, L" ", L"PROBEL");
boost::algorithm::replace_all(inner, L"\"", L"KAVYCHKA");
return inner;
}
else if (what[3].matched)
return what[3].str();
}
std::wstring replace_space_formater(boost::wsmatch const & what) std::wstring replace_space_formater(boost::wsmatch const & what)
{ {
if (what[1].matched) if (what[1].matched)
...@@ -380,12 +415,19 @@ namespace formulasconvert { ...@@ -380,12 +415,19 @@ namespace formulasconvert {
&replace_point_space, &replace_point_space,
boost::match_default | boost::format_all); boost::match_default | boost::format_all);
boost::algorithm::replace_all(workstr, L"'", L"APOSTROF");
check_formula(workstr); check_formula(workstr);
replace_cells_range(workstr, true);
replace_semicolons(workstr); workstr = boost::regex_replace(
replace_vertical(workstr); workstr,
boost::wregex(L"('.*?')|(\".*?\")"),
&convert_scobci, boost::match_default | boost::format_all);
//boost::algorithm::replace_all(workstr, L"'", L"APOSTROF");
replace_cells_range (workstr, true);
replace_semicolons (workstr);
replace_vertical (workstr);
int res_find=0; int res_find=0;
if ((res_find = workstr.find(L"CONCATINATE")) > 0) if ((res_find = workstr.find(L"CONCATINATE")) > 0)
...@@ -397,6 +439,15 @@ namespace formulasconvert { ...@@ -397,6 +439,15 @@ namespace formulasconvert {
boost::algorithm::replace_all(workstr, L"PROBEL" , L" "); boost::algorithm::replace_all(workstr, L"PROBEL" , L" ");
boost::algorithm::replace_all(workstr, L"APOSTROF" , L"'"); boost::algorithm::replace_all(workstr, L"APOSTROF" , L"'");
boost::algorithm::replace_all(workstr, L"TOCHKA" , L"."); boost::algorithm::replace_all(workstr, L"TOCHKA" , L".");
boost::algorithm::replace_all(workstr, L"SCOBCAIN", L"(");
boost::algorithm::replace_all(workstr, L"SCOBCAOUT", L")");
boost::algorithm::replace_all(workstr, L"KVADRATIN", L"[");
boost::algorithm::replace_all(workstr, L"KVADRATOUT", L"]");
boost::algorithm::replace_all(workstr, L"PROBEL", L" ");
boost::algorithm::replace_all(workstr, L"KAVYCHKA", L"\"");
return workstr; return workstr;
} }
...@@ -495,6 +546,7 @@ namespace formulasconvert { ...@@ -495,6 +546,7 @@ namespace formulasconvert {
boost::match_default | boost::format_all); boost::match_default | boost::format_all);
boost::algorithm::replace_all(workstr, L"'", L"APOSTROF"); boost::algorithm::replace_all(workstr, L"'", L"APOSTROF");
//boost::algorithm::replace_all(workstr, L"", L"APOSTROF");
impl_->replace_named_ref(workstr, withTableName); impl_->replace_named_ref(workstr, withTableName);
......
...@@ -468,6 +468,9 @@ std::wstring oox2odf_converter::Impl::convert_scobci(boost::wsmatch const & what ...@@ -468,6 +468,9 @@ std::wstring oox2odf_converter::Impl::convert_scobci(boost::wsmatch const & what
boost::algorithm::replace_all(inner, L"(", L"SCOBCAIN"); boost::algorithm::replace_all(inner, L"(", L"SCOBCAIN");
boost::algorithm::replace_all(inner, L")", L"SCOBCAOUT"); boost::algorithm::replace_all(inner, L")", L"SCOBCAOUT");
boost::algorithm::replace_all(inner, L"[", L"KVADRATIN");
boost::algorithm::replace_all(inner, L"]", L"KVADRATOUT");
boost::algorithm::replace_all(inner, L" ", L"PROBEL"); boost::algorithm::replace_all(inner, L" ", L"PROBEL");
boost::algorithm::replace_all(inner, L"'", L"APOSTROF"); boost::algorithm::replace_all(inner, L"'", L"APOSTROF");
return inner; return inner;
...@@ -478,6 +481,9 @@ std::wstring oox2odf_converter::Impl::convert_scobci(boost::wsmatch const & what ...@@ -478,6 +481,9 @@ std::wstring oox2odf_converter::Impl::convert_scobci(boost::wsmatch const & what
boost::algorithm::replace_all(inner, L"(", L"SCOBCAIN"); boost::algorithm::replace_all(inner, L"(", L"SCOBCAIN");
boost::algorithm::replace_all(inner, L")", L"SCOBCAOUT"); boost::algorithm::replace_all(inner, L")", L"SCOBCAOUT");
boost::algorithm::replace_all(inner, L"[", L"KVADRATIN");
boost::algorithm::replace_all(inner, L"]", L"KVADRATOUT");
boost::algorithm::replace_all(inner, L" ", L"PROBEL"); boost::algorithm::replace_all(inner, L" ", L"PROBEL");
boost::algorithm::replace_all(inner, L"\"", L"KAVYCHKA"); boost::algorithm::replace_all(inner, L"\"", L"KAVYCHKA");
return inner; return inner;
...@@ -567,6 +573,9 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr) ...@@ -567,6 +573,9 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
boost::algorithm::replace_all(res, L"SCOBCAIN", L"("); boost::algorithm::replace_all(res, L"SCOBCAIN", L"(");
boost::algorithm::replace_all(res, L"SCOBCAOUT", L")"); boost::algorithm::replace_all(res, L"SCOBCAOUT", L")");
boost::algorithm::replace_all(res, L"KVADRATIN", L"[");
boost::algorithm::replace_all(res, L"KVADRATOUT", L"]");
boost::algorithm::replace_all(res, L"PROBEL", L" "); boost::algorithm::replace_all(res, L"PROBEL", L" ");
boost::algorithm::replace_all(res, L"APOSTROF", L"'"); boost::algorithm::replace_all(res, L"APOSTROF", L"'");
......
...@@ -64,6 +64,8 @@ void xlsx_data_range::serialize_sort (std::wostream & _Wostream) ...@@ -64,6 +64,8 @@ void xlsx_data_range::serialize_sort (std::wostream & _Wostream)
{ {
if (bySort.empty()) return; if (bySort.empty()) return;
if (byRow) return;
CP_XML_WRITER(_Wostream) CP_XML_WRITER(_Wostream)
{ {
CP_XML_NODE(L"sortState") CP_XML_NODE(L"sortState")
......
...@@ -133,7 +133,7 @@ public: ...@@ -133,7 +133,7 @@ public:
virtual void visit(const table_table_column& val) virtual void visit(const table_table_column& val)
{ {
const unsigned int columnsRepeated = val.table_table_column_attlist_.table_number_columns_repeated_; const unsigned int columnsRepeated = val.table_table_column_attlist_.table_number_columns_repeated_;
const std::wstring defaultCellStyleName = val.table_table_column_attlist_.table_default_cell_style_name_.get_value_or(style_ref(L"")).style_name(); const std::wstring defaultCellStyleName = val.table_table_column_attlist_.table_default_cell_style_name_.get_value_or(L"");
visit_column(columnsRepeated, defaultCellStyleName); visit_column(columnsRepeated, defaultCellStyleName);
} }
virtual void visit(const table_calculation_settings & val) virtual void visit(const table_calculation_settings & val)
...@@ -202,9 +202,7 @@ public: ...@@ -202,9 +202,7 @@ public:
virtual void visit(const table_table_row& val) virtual void visit(const table_table_row& val)
{ {
unsigned int repeated = val.table_table_row_attlist_.table_number_rows_repeated_; unsigned int repeated = val.table_table_row_attlist_.table_number_rows_repeated_;
std::wstring defaultCellStyle = val. std::wstring defaultCellStyle = val.table_table_row_attlist_.table_default_cell_style_name_.get_value_or(L"");
table_table_row_attlist_.
table_default_cell_style_name_.get_value_or(style_ref(L"")).style_name();
if (visit_rows(repeated, defaultCellStyle)) if (visit_rows(repeated, defaultCellStyle))
{ {
......
...@@ -582,10 +582,25 @@ void table_rows_and_groups::add_child_element( xml::sax * Reader, const std::wst ...@@ -582,10 +582,25 @@ void table_rows_and_groups::add_child_element( xml::sax * Reader, const std::wst
CP_CREATE_ELEMENT_SIMPLE(content_); CP_CREATE_ELEMENT_SIMPLE(content_);
} }
else if (L"table" == Ns && (L"table-rows" == Name || L"table-row" == Name || L"table-header-rows" == Name) ) else if (L"table" == Ns && (L"table-rows" == Name || L"table-row" == Name || L"table-header-rows" == Name) )
{
bool add_new_no_group = false;
if (content_.empty()) add_new_no_group = true;
else
{
if (content_.back()->get_type() != typeTableTableRowNoGroup)
add_new_no_group = true;
}
if (add_new_no_group)
{ {
_CP_PTR(table_rows_no_group) elm = table_rows_no_group::create(); _CP_PTR(table_rows_no_group) elm = table_rows_no_group::create();
elm->add_child_element(Reader, Ns, Name, Context); elm->add_child_element(Reader, Ns, Name, Context);
content_.push_back(elm); content_.push_back(elm);
}
else
{
table_rows_no_group* rows_no_group = static_cast<table_rows_no_group*>(content_.back().get());
rows_no_group->add_child_element(Reader, Ns, Name, Context);
}
} }
else else
not_applicable_element(L"table-rows-and-groups", Reader, Ns, Name); not_applicable_element(L"table-rows-and-groups", Reader, Ns, Name);
......
...@@ -44,8 +44,8 @@ ...@@ -44,8 +44,8 @@
#include "datatypes/tablemode.h" #include "datatypes/tablemode.h"
#include "datatypes/common_attlists.h" #include "datatypes/common_attlists.h"
#include "datatypes/style_ref.h"
#include "datatypes/tablevisibility.h" #include "datatypes/tablevisibility.h"
namespace cpdoccore { namespace cpdoccore {
namespace odf_reader { namespace odf_reader {
...@@ -58,7 +58,7 @@ public: ...@@ -58,7 +58,7 @@ public:
public: public:
_CP_OPT(bool) table_is_sub_table_; _CP_OPT(bool) table_is_sub_table_;
_CP_OPT(std::wstring) table_name_; _CP_OPT(std::wstring) table_name_;
_CP_OPT(odf_types::style_ref) table_style_name_; _CP_OPT(std::wstring) table_style_name_;
_CP_OPT(std::wstring) table_template_name_; _CP_OPT(std::wstring) table_template_name_;
bool table_protected_; // default false bool table_protected_; // default false
...@@ -82,8 +82,8 @@ public: ...@@ -82,8 +82,8 @@ public:
public: public:
unsigned int table_number_rows_repeated_; // default 1 unsigned int table_number_rows_repeated_; // default 1
_CP_OPT(odf_types::style_ref) table_style_name_; _CP_OPT(std::wstring) table_style_name_;
_CP_OPT(odf_types::style_ref) table_default_cell_style_name_; _CP_OPT(std::wstring) table_default_cell_style_name_;
odf_types::table_visibility table_visibility_; // default Visible odf_types::table_visibility table_visibility_; // default Visible
}; };
...@@ -96,7 +96,7 @@ public: ...@@ -96,7 +96,7 @@ public:
public: public:
unsigned int table_number_columns_repeated_; // default 1 unsigned int table_number_columns_repeated_; // default 1
_CP_OPT(odf_types::style_ref) table_style_name_; _CP_OPT(std::wstring) table_style_name_;
_CP_OPT(std::wstring) table_content_validation_name_; _CP_OPT(std::wstring) table_content_validation_name_;
_CP_OPT(std::wstring) table_formula_; _CP_OPT(std::wstring) table_formula_;
...@@ -248,9 +248,9 @@ public: ...@@ -248,9 +248,9 @@ public:
public: public:
unsigned int table_number_columns_repeated_; // default 1 unsigned int table_number_columns_repeated_; // default 1
_CP_OPT(odf_types::style_ref) table_style_name_; _CP_OPT(std::wstring) table_style_name_;
odf_types::table_visibility table_visibility_; // default Visible odf_types::table_visibility table_visibility_; // default Visible
_CP_OPT(odf_types::style_ref) table_default_cell_style_name_; _CP_OPT(std::wstring) table_default_cell_style_name_;
}; };
......
...@@ -67,8 +67,8 @@ void table_table_row::docx_convert(oox::docx_conversion_context & Context) ...@@ -67,8 +67,8 @@ void table_table_row::docx_convert(oox::docx_conversion_context & Context)
{ {
std::wostream & _Wostream = Context.output_stream(); std::wostream & _Wostream = Context.output_stream();
const std::wstring styleName = table_table_row_attlist_.table_style_name_.get_value_or( style_ref(L"") ).style_name(); const std::wstring styleName = table_table_row_attlist_.table_style_name_.get_value_or(L"");
const std::wstring defaultCellStyle = table_table_row_attlist_.table_default_cell_style_name_.get_value_or( style_ref(L"") ).style_name(); const std::wstring defaultCellStyle = table_table_row_attlist_.table_default_cell_style_name_.get_value_or(L"");
for (unsigned int i = 0; i < table_table_row_attlist_.table_number_rows_repeated_; ++i) for (unsigned int i = 0; i < table_table_row_attlist_.table_number_rows_repeated_; ++i)
{ {
...@@ -148,9 +148,7 @@ void table_table::docx_convert(oox::docx_conversion_context & Context) ...@@ -148,9 +148,7 @@ void table_table::docx_convert(oox::docx_conversion_context & Context)
bool sub_table = table_table_attlist_.table_is_sub_table_.get_value_or(false); bool sub_table = table_table_attlist_.table_is_sub_table_.get_value_or(false);
//todooo придумать как сделать внешние границы sub-таблицы границами внешней ячейки (чтоб слияние произошло) //todooo придумать как сделать внешние границы sub-таблицы границами внешней ячейки (чтоб слияние произошло)
std::wstring tableStyleName = L""; std::wstring tableStyleName = table_table_attlist_.table_style_name_.get_value_or(L"");
if (table_table_attlist_.table_style_name_)
tableStyleName = table_table_attlist_.table_style_name_->style_name() ;
_Wostream << L"<w:tbl>"; _Wostream << L"<w:tbl>";
...@@ -249,14 +247,14 @@ void table_table_column::docx_convert(oox::docx_conversion_context & Context) ...@@ -249,14 +247,14 @@ void table_table_column::docx_convert(oox::docx_conversion_context & Context)
{ {
std::wostream & _Wostream = Context.output_stream(); std::wostream & _Wostream = Context.output_stream();
const unsigned int columnsRepeated = table_table_column_attlist_.table_number_columns_repeated_; const unsigned int columnsRepeated = table_table_column_attlist_.table_number_columns_repeated_;
const std::wstring defaultCellStyle = table_table_column_attlist_.table_default_cell_style_name_.get_value_or(style_ref(L"")).style_name(); const std::wstring defaultCellStyle = table_table_column_attlist_.table_default_cell_style_name_.get_value_or(L"");
Context.get_table_context().start_column(columnsRepeated, defaultCellStyle); Context.get_table_context().start_column(columnsRepeated, defaultCellStyle);
for (unsigned int i = 0; i < columnsRepeated; ++i) for (unsigned int i = 0; i < columnsRepeated; ++i)
{ {
if (table_table_column_attlist_.table_style_name_) if (table_table_column_attlist_.table_style_name_)
{ {
const std::wstring colStyleName = table_table_column_attlist_.table_style_name_->style_name(); const std::wstring colStyleName = table_table_column_attlist_.table_style_name_.get();
if (style_instance * inst = if (style_instance * inst =
Context.root()->odf_context().styleContainer().style_by_name( colStyleName , style_family::TableColumn,Context.process_headers_footers_ )) Context.root()->odf_context().styleContainer().style_by_name( colStyleName , style_family::TableColumn,Context.process_headers_footers_ ))
{ {
...@@ -281,8 +279,7 @@ void table_table_cell::docx_convert(oox::docx_conversion_context & Context) ...@@ -281,8 +279,7 @@ void table_table_cell::docx_convert(oox::docx_conversion_context & Context)
_Wostream << L"<w:tc>"; _Wostream << L"<w:tc>";
_Wostream << L"<w:tcPr>"; _Wostream << L"<w:tcPr>";
const std::wstring styleName = table_table_cell_attlist_.table_style_name_ ? const std::wstring styleName = table_table_cell_attlist_.table_style_name_.get_value_or(L"");
table_table_cell_attlist_.table_style_name_->style_name() : L"";
//_Wostream << L"<w:tcW w:w=\"0\" w:type=\"auto\" />"; //_Wostream << L"<w:tcW w:w=\"0\" w:type=\"auto\" />";
......
...@@ -70,8 +70,8 @@ void table_table_row::pptx_convert(oox::pptx_conversion_context & Context) ...@@ -70,8 +70,8 @@ void table_table_row::pptx_convert(oox::pptx_conversion_context & Context)
{ {
std::wostream & _Wostream = Context.get_table_context().tableData(); std::wostream & _Wostream = Context.get_table_context().tableData();
const std::wstring styleName = table_table_row_attlist_.table_style_name_.get_value_or( style_ref(L"") ).style_name(); const std::wstring styleName = table_table_row_attlist_.table_style_name_.get_value_or(L"");
const std::wstring defaultCellStyle = table_table_row_attlist_.table_default_cell_style_name_.get_value_or( style_ref(L"") ).style_name(); const std::wstring defaultCellStyle = table_table_row_attlist_.table_default_cell_style_name_.get_value_or(L"");
for (unsigned int i = 0; i < table_table_row_attlist_.table_number_rows_repeated_; ++i) for (unsigned int i = 0; i < table_table_row_attlist_.table_number_rows_repeated_; ++i)
{ {
...@@ -160,9 +160,7 @@ void table_table::pptx_convert(oox::pptx_conversion_context & Context) ...@@ -160,9 +160,7 @@ void table_table::pptx_convert(oox::pptx_conversion_context & Context)
Context.get_slide_context().start_table(); Context.get_slide_context().start_table();
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
std::wstring tableStyleName = L""; std::wstring tableStyleName = table_table_attlist_.table_style_name_.get_value_or(L"");
if (table_table_attlist_.table_style_name_)
tableStyleName = table_table_attlist_.table_style_name_->style_name() ;
Context.get_table_context().start_table(tableStyleName); Context.get_table_context().start_table(tableStyleName);
...@@ -295,7 +293,7 @@ void table_table_column::pptx_convert(oox::pptx_conversion_context & Context) ...@@ -295,7 +293,7 @@ void table_table_column::pptx_convert(oox::pptx_conversion_context & Context)
std::wostream & _Wostream = Context.get_table_context().tableData(); std::wostream & _Wostream = Context.get_table_context().tableData();
const unsigned int columnsRepeated = table_table_column_attlist_.table_number_columns_repeated_; const unsigned int columnsRepeated = table_table_column_attlist_.table_number_columns_repeated_;
const std::wstring defaultCellStyle = table_table_column_attlist_.table_default_cell_style_name_.get_value_or(style_ref(L"")).style_name(); const std::wstring defaultCellStyle = table_table_column_attlist_.table_default_cell_style_name_.get_value_or(L"");
Context.get_table_context().start_column(columnsRepeated, defaultCellStyle); Context.get_table_context().start_column(columnsRepeated, defaultCellStyle);
...@@ -303,7 +301,7 @@ void table_table_column::pptx_convert(oox::pptx_conversion_context & Context) ...@@ -303,7 +301,7 @@ void table_table_column::pptx_convert(oox::pptx_conversion_context & Context)
{ {
if (table_table_column_attlist_.table_style_name_) if (table_table_column_attlist_.table_style_name_)
{ {
const std::wstring colStyleName = table_table_column_attlist_.table_style_name_->style_name(); const std::wstring colStyleName = table_table_column_attlist_.table_style_name_.get();
style_instance * inst = Context.root()->odf_context().styleContainer().style_by_name( colStyleName , style_family::TableColumn,false ); style_instance * inst = Context.root()->odf_context().styleContainer().style_by_name( colStyleName , style_family::TableColumn,false );
if ((inst) && (inst->content())) if ((inst) && (inst->content()))
...@@ -353,7 +351,7 @@ void table_table_cell::pptx_convert(oox::pptx_conversion_context & Context) ...@@ -353,7 +351,7 @@ void table_table_cell::pptx_convert(oox::pptx_conversion_context & Context)
style_inst = Context.root()->odf_context().styleContainer().style_by_name(style_name, style_family::TableCell,false); style_inst = Context.root()->odf_context().styleContainer().style_by_name(style_name, style_family::TableCell,false);
if (style_inst) style_instances.push_back(style_inst); if (style_inst) style_instances.push_back(style_inst);
} }
style_name = table_table_cell_attlist_.table_style_name_ ? table_table_cell_attlist_.table_style_name_->style_name() : L""; style_name = table_table_cell_attlist_.table_style_name_.get_value_or(L"");
if (!style_name.empty()) if (!style_name.empty())
{ {
style_inst = Context.root()->odf_context().styleContainer().style_by_name(style_name, style_family::TableCell,false); style_inst = Context.root()->odf_context().styleContainer().style_by_name(style_name, style_family::TableCell,false);
......
...@@ -80,8 +80,8 @@ void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -80,8 +80,8 @@ void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context)
///обработка чтилей для роу - ///обработка чтилей для роу -
size_t Default_Cell_style_in_row_ = 0; size_t Default_Cell_style_in_row_ = 0;
const std::wstring rowStyleName = table_table_row_attlist_.table_style_name_.get_value_or( style_ref(L"") ).style_name(); const std::wstring rowStyleName = table_table_row_attlist_.table_style_name_.get_value_or(L"");
const std::wstring defaultCellStyleName = table_table_row_attlist_.table_default_cell_style_name_.get_value_or( style_ref(L"") ).style_name(); const std::wstring defaultCellStyleName = table_table_row_attlist_.table_default_cell_style_name_.get_value_or( L"");
style_instance * instStyle_CellDefault = style_instance * instStyle_CellDefault =
Context.root()->odf_context().styleContainer().style_by_name(defaultCellStyleName, style_family::TableCell,false/*false*/); Context.root()->odf_context().styleContainer().style_by_name(defaultCellStyleName, style_family::TableCell,false/*false*/);
...@@ -211,10 +211,10 @@ void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -211,10 +211,10 @@ void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context)
if (Context.is_empty_row()) if (Context.is_empty_row())
{ {
skip_next_row = true; skip_next_row = true;
if (table_table_row_attlist_.table_number_rows_repeated_ > 0xff00) if (table_table_row_attlist_.table_number_rows_repeated_ > 0xf000)
break;//Уведомление_о_вручении.ods (1 лист) break;//Уведомление_о_вручении.ods (1 лист)
} }
if (content_.size() > 0 && table_table_row_attlist_.table_number_rows_repeated_ > 0xff00) if (content_.size() > 0 && table_table_row_attlist_.table_number_rows_repeated_ > 1000)
{ {
table_table_cell * table_cell = dynamic_cast<table_table_cell *>(content_[0].get()); table_table_cell * table_cell = dynamic_cast<table_table_cell *>(content_[0].get());
if ((table_cell) && (table_cell->table_table_cell_attlist_.table_number_columns_repeated_ > 1000)) if ((table_cell) && (table_cell->table_table_cell_attlist_.table_number_columns_repeated_ > 1000))
...@@ -250,6 +250,27 @@ void table_rows::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -250,6 +250,27 @@ void table_rows::xlsx_convert(oox::xlsx_conversion_context & Context)
table_table_rows_->xlsx_convert(Context); table_table_rows_->xlsx_convert(Context);
else else
{ {
if (table_table_row_.size() > 1)
{
//check 2 last rows for repeate > 65000 & 1024
table_table_row* row_last = dynamic_cast<table_table_row*>(table_table_row_[table_table_row_.size() - 1].get());
table_table_row* row_last_1 = dynamic_cast<table_table_row*>(table_table_row_[table_table_row_.size() - 2].get());
if (row_last->table_table_row_attlist_.table_number_rows_repeated_ > 1000 &&
row_last_1->table_table_row_attlist_.table_number_rows_repeated_ > 1000 ||
row_last_1->table_table_row_attlist_.table_number_rows_repeated_ > 0xf000)
{
std::wstring style = row_last->table_table_row_attlist_.table_style_name_.get_value_or(L"");
std::wstring style_1 = row_last->table_table_row_attlist_.table_style_name_.get_value_or(L"");
if (style == style_1)//check for empty also ????
{
row_last_1->table_table_row_attlist_.table_number_rows_repeated_ = 1024;
table_table_row_.pop_back();
}
}
}
for (int i = 0; i < table_table_row_.size(); i++) for (int i = 0; i < table_table_row_.size(); i++)
{ {
table_table_row_[i]->xlsx_convert(Context); table_table_row_[i]->xlsx_convert(Context);
...@@ -287,7 +308,7 @@ void table_table_row_group::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -287,7 +308,7 @@ void table_table_row_group::xlsx_convert(oox::xlsx_conversion_context & Context)
void table_table::xlsx_convert(oox::xlsx_conversion_context & Context) void table_table::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
const std::wstring tableStyleName = table_table_attlist_.table_style_name_ ? table_table_attlist_.table_style_name_->style_name() : L""; const std::wstring tableStyleName = table_table_attlist_.table_style_name_.get_value_or(L"");
const std::wstring tableName = table_table_attlist_.table_name_.get_value_or(L""); const std::wstring tableName = table_table_attlist_.table_name_.get_value_or(L"");
_CP_LOG << L"[info][xlsx] process table \"" << tableName << L"\"\n" << std::endl; _CP_LOG << L"[info][xlsx] process table \"" << tableName << L"\"\n" << std::endl;
...@@ -389,8 +410,8 @@ void table_table_column::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -389,8 +410,8 @@ void table_table_column::xlsx_convert(oox::xlsx_conversion_context & Context)
std::wostream & strm = Context.current_sheet().cols(); std::wostream & strm = Context.current_sheet().cols();
const unsigned int columnsRepeated = table_table_column_attlist_.table_number_columns_repeated_; const unsigned int columnsRepeated = table_table_column_attlist_.table_number_columns_repeated_;
const std::wstring styleName = table_table_column_attlist_.table_style_name_.get_value_or(style_ref(L"")).style_name(); const std::wstring styleName = table_table_column_attlist_.table_style_name_.get_value_or(L"");
const std::wstring defaultCellStyleName = table_table_column_attlist_.table_default_cell_style_name_.get_value_or(style_ref(L"")).style_name(); const std::wstring defaultCellStyleName = table_table_column_attlist_.table_default_cell_style_name_.get_value_or(L"");
int cMin = 0, cMax = 0; int cMin = 0, cMax = 0;
...@@ -447,7 +468,7 @@ void table_table_column::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -447,7 +468,7 @@ void table_table_column::xlsx_convert(oox::xlsx_conversion_context & Context)
} }
} }
_CP_OPT(double) width; _CP_OPT(double) width;
const std::wstring colStyleName = table_table_column_attlist_.table_style_name_->style_name(); const std::wstring colStyleName = table_table_column_attlist_.table_style_name_.get_value_or(L"");
if (style_instance * inst = Context.root()->odf_context().styleContainer().style_by_name(colStyleName, style_family::TableColumn,false)) if (style_instance * inst = Context.root()->odf_context().styleContainer().style_by_name(colStyleName, style_family::TableColumn,false))
{ {
if (inst->content()) if (inst->content())
...@@ -471,7 +492,9 @@ void table_table_column::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -471,7 +492,9 @@ void table_table_column::xlsx_convert(oox::xlsx_conversion_context & Context)
//const double width = cmToChars(prop->style_table_column_properties_attlist_.style_column_width_->get_value_unit(length::cm)); //const double width = cmToChars(prop->style_table_column_properties_attlist_.style_column_width_->get_value_unit(length::cm));
// see ECMA-376 page 1768 // see ECMA-376 page 1768
if (in_width > 0)
CP_XML_ATTR(L"width", *width); CP_XML_ATTR(L"width", *width);
CP_XML_ATTR(L"customWidth", true); CP_XML_ATTR(L"customWidth", true);
Context.table_column_last_width(*width); Context.table_column_last_width(*width);
} }
...@@ -582,7 +605,7 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -582,7 +605,7 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
std::wostream & strm = Context.current_sheet().sheetData(); std::wostream & strm = Context.current_sheet().sheetData();
const std::wstring formula = table_table_cell_attlist_.table_formula_.get_value_or(L""); const std::wstring formula = table_table_cell_attlist_.table_formula_.get_value_or(L"");
const std::wstring styleName = table_table_cell_attlist_.table_style_name_.get_value_or(style_ref(L"")).style_name(); const std::wstring styleName = table_table_cell_attlist_.table_style_name_.get_value_or(L"");
const common_value_and_type_attlist & attr = table_table_cell_attlist_.common_value_and_type_attlist_; const common_value_and_type_attlist & attr = table_table_cell_attlist_.common_value_and_type_attlist_;
office_value_type::type odf_value_type = office_value_type::Custom; office_value_type::type odf_value_type = office_value_type::Custom;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment