Commit 4c7ab6e6 authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatWriter - fix convert named range with formulas

parent a020d3db
......@@ -87,9 +87,10 @@ public:
std::wstring convert_conditional_formula(std::wstring const & expr);
// Лист1!$A$1 -> $Лист1.$A$1
std::wstring convert_named_ref(std::wstring const & expr);
std::wstring convert_named_ref (std::wstring const & expr);
std::wstring convert_named_formula(std::wstring const & expr);
std::wstring find_base_cell(std::wstring const & expr);
std::wstring get_base_cell_formula(std::wstring const & expr);
//Sheet2!C3:C19 -> Sheet2.C3:Sheet2.C19
std::wstring convert_chart_distance(std::wstring const & expr);
......
......@@ -57,6 +57,7 @@ namespace formulasconvert {
static std::wstring replace_named_ref_formater1(boost::wsmatch const & what);
static std::wstring replace_cell_range_formater(boost::wsmatch const & what);
void replace_named_formula(std::wstring & expr, bool w = true);
void replace_named_ref(std::wstring & expr, bool w = true);
bool find_first_ref(std::wstring const & expr, std::wstring & table, std::wstring & ref);
bool find_first_last_ref(std::wstring const & expr, std::wstring & table, std::wstring & ref_first,std::wstring & ref_last);
......@@ -263,15 +264,12 @@ namespace formulasconvert {
return what[2].str();
else if (what[3].matched)
return what[3].str();
//else if (what[4].matched)
// return what[4].str();
else
return L"";
}
// TODO
// заменить точки с запятой во всех вхождениях кроме находящихся в кавычках --*и в фигурных скобках*--
// TODO: проверить как сохраняются кавычки в строке
void odf2oox_converter::Impl::replace_semicolons(std::wstring& expr)
{
const std::wstring res = boost::regex_replace(
......
......@@ -138,7 +138,8 @@ void ods_table_context::add_defined_range(const std::wstring & name, const std::
std::wstring odf_range = formulas_converter.convert_named_ref(cell_range);//todo - разделить конвертацию диапазонов/рэнжей на c [] и без
XmlUtils::replace_all( odf_range, L"[", L"");
XmlUtils::replace_all( odf_range, L"]", L"");
std::wstring odf_base_cell = formulas_converter.find_base_cell(cell_range);
std::wstring odf_base_cell = formulas_converter.get_base_cell_formula(cell_range);
named_range->table_name_ = name;
named_range->table_cell_range_address_ = odf_range;
......@@ -181,8 +182,8 @@ void ods_table_context::add_defined_expression(const std::wstring & name, const
formulasconvert::oox2odf_converter formulas_converter;
std::wstring odf_value = formulas_converter.convert_named_ref(value);
std::wstring odf_base_cell = formulas_converter.find_base_cell(value);
std::wstring odf_value = formulas_converter.convert_named_formula(value);
std::wstring odf_base_cell = formulas_converter.get_base_cell_formula(value);
named_expression->table_name_ = name;
named_expression->table_expression_ = odf_value;
......@@ -215,10 +216,9 @@ void ods_table_context::add_defined_expression(const std::wstring & name, const
table_defined_expressions_.root->add_child_element(elm);
}
if (odf_base_cell.length() > 0)
if (!odf_base_cell.empty())
named_expression->table_base_cell_address_ = odf_base_cell;
table_defined_expressions_.elements.push_back(elm);
}
......
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