Commit c3da9a66 authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatReader - convert pilots ...

parent f907a90b
...@@ -51,6 +51,7 @@ public: ...@@ -51,6 +51,7 @@ public:
// $Лист1.$A$1 -> Лист1!$A$1 // $Лист1.$A$1 -> Лист1!$A$1
std::wstring convert_named_ref(std::wstring const & expr, bool withTableName = true, std::wstring separator = L" "); std::wstring convert_named_ref(std::wstring const & expr, bool withTableName = true, std::wstring separator = L" ");
std::wstring get_table_name();
//a-la convert without check formula //a-la convert without check formula
std::wstring convert_named_expr(std::wstring const & expr, bool withTableName = true); std::wstring convert_named_expr(std::wstring const & expr, bool withTableName = true);
...@@ -90,7 +91,7 @@ public: ...@@ -90,7 +91,7 @@ public:
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 convert_named_formula(std::wstring const & expr);
std::wstring get_base_cell_formula(std::wstring const & expr); std::wstring get_base_cell_formula();
//Sheet2!C3:C19 -> Sheet2.C3:Sheet2.C19 //Sheet2!C3:C19 -> Sheet2.C3:Sheet2.C19
std::wstring convert_chart_distance(std::wstring const & expr); std::wstring convert_chart_distance(std::wstring const & expr);
......
...@@ -43,7 +43,6 @@ namespace formulasconvert { ...@@ -43,7 +43,6 @@ namespace formulasconvert {
class odf2oox_converter::Impl class odf2oox_converter::Impl
{ {
public: public:
static bool convert_with_TableName;
std::wstring convert(const std::wstring& expr); std::wstring convert(const std::wstring& expr);
std::wstring convert_chart_distance(const std::wstring& expr); std::wstring convert_chart_distance(const std::wstring& expr);
...@@ -61,8 +60,12 @@ namespace formulasconvert { ...@@ -61,8 +60,12 @@ namespace formulasconvert {
void replace_named_ref(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_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); bool find_first_last_ref(std::wstring const & expr, std::wstring & table, std::wstring & ref_first,std::wstring & ref_last);
static bool convert_with_TableName;
static std::wstring table_name_;
}; };
bool odf2oox_converter::Impl::convert_with_TableName = true; bool odf2oox_converter::Impl::convert_with_TableName = true;
std::wstring odf2oox_converter::Impl::table_name_ = L"";
bool odf2oox_converter::Impl::find_first_last_ref(std::wstring const & expr, std::wstring & table,std::wstring & ref_first,std::wstring & ref_last) bool odf2oox_converter::Impl::find_first_last_ref(std::wstring const & expr, std::wstring & table,std::wstring & ref_first,std::wstring & ref_last)
{ {
...@@ -152,6 +155,8 @@ namespace formulasconvert { ...@@ -152,6 +155,8 @@ namespace formulasconvert {
std::wstring sheet1 = what[1].str(); std::wstring sheet1 = what[1].str();
XmlUtils::replace_all( sheet1, L"$", L""); XmlUtils::replace_all( sheet1, L"$", L"");
table_name_ = sheet1;
const std::wstring c1 = what[2].str(); const std::wstring c1 = what[2].str();
const std::wstring c2 = what[3].str(); const std::wstring c2 = what[3].str();
...@@ -180,6 +185,8 @@ namespace formulasconvert { ...@@ -180,6 +185,8 @@ namespace formulasconvert {
const std::wstring c2 = what[3].str(); //sheet name 2 const std::wstring c2 = what[3].str(); //sheet name 2
const std::wstring c3 = what[4].str(); const std::wstring c3 = what[4].str();
table_name_ = sheet1;
if (convert_with_TableName) if (convert_with_TableName)
{ {
return (sheet1 + L"!") + c1 + (c2.empty() ? L"" : (L":" + c3) ); return (sheet1 + L"!") + c1 + (c2.empty() ? L"" : (L":" + c3) );
...@@ -559,6 +566,11 @@ namespace formulasconvert { ...@@ -559,6 +566,11 @@ namespace formulasconvert {
{ {
} }
std::wstring odf2oox_converter::get_table_name()
{
return impl_->table_name_;
}
std::wstring odf2oox_converter::convert(const std::wstring& expr) std::wstring odf2oox_converter::convert(const std::wstring& expr)
{ {
return impl_->convert(expr); return impl_->convert(expr);
......
...@@ -614,7 +614,7 @@ std::wstring oox2odf_converter::convert_named_formula(const std::wstring& expr) ...@@ -614,7 +614,7 @@ std::wstring oox2odf_converter::convert_named_formula(const std::wstring& expr)
impl_->replace_named_formula(workstr); impl_->replace_named_formula(workstr);
return workstr; return workstr;
} }
std::wstring oox2odf_converter::get_base_cell_formula(const std::wstring& expr) std::wstring oox2odf_converter::get_base_cell_formula()
{ {
return impl_->base_cell_formula_; return impl_->base_cell_formula_;
} }
......
...@@ -65,6 +65,14 @@ public: ...@@ -65,6 +65,14 @@ public:
std::wstringstream view_; std::wstringstream view_;
std::wstringstream cache_; std::wstringstream cache_;
struct _desc
{
void clear()
{
}
std::wstring name;
}current_;
}; };
xlsx_pivots_context::xlsx_pivots_context() : impl_(new xlsx_pivots_context::Impl()) xlsx_pivots_context::xlsx_pivots_context() : impl_(new xlsx_pivots_context::Impl())
...@@ -131,6 +139,7 @@ void xlsx_pivots_context::write_table_view_to(int index, std::wostream & strm) ...@@ -131,6 +139,7 @@ void xlsx_pivots_context::write_table_view_to(int index, std::wostream & strm)
void xlsx_pivots_context::start_table() void xlsx_pivots_context::start_table()
{ {
impl_->current_.clear();
impl_->fields_.clear(); impl_->fields_.clear();
} }
...@@ -143,7 +152,7 @@ int xlsx_pivots_context::end_table() ...@@ -143,7 +152,7 @@ int xlsx_pivots_context::end_table()
{ {
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main"); CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
//CP_XML_ATTR(L"name", view->stTable.value()); CP_XML_ATTR(L"name", impl_->current_.name);
//CP_XML_ATTR(L"cacheId", view->iCache); //CP_XML_ATTR(L"cacheId", view->iCache);
//CP_XML_ATTR(L"dataOnRows", view->sxaxis4Data.bRw); //CP_XML_ATTR(L"dataOnRows", view->sxaxis4Data.bRw);
//CP_XML_ATTR(L"applyNumberFormats", view->fAtrNum); //CP_XML_ATTR(L"applyNumberFormats", view->fAtrNum);
...@@ -180,7 +189,7 @@ int xlsx_pivots_context::end_table() ...@@ -180,7 +189,7 @@ int xlsx_pivots_context::end_table()
CP_XML_ATTR(L"count", impl_->fields_.size()); CP_XML_ATTR(L"count", impl_->fields_.size());
for (size_t i = 0; i < impl_->fields_.size(); i++) for (size_t i = 0; i < impl_->fields_.size(); i++)
{ {
impl_->fields_[i].view_; CP_XML_STREAM() << impl_->fields_[i].view_;
} }
} }
} }
...@@ -191,6 +200,11 @@ int xlsx_pivots_context::end_table() ...@@ -191,6 +200,11 @@ int xlsx_pivots_context::end_table()
return impl_->views_.size(); return impl_->views_.size();
} }
void xlsx_pivots_context::set_view_name(std::wstring name)
{
impl_->current_.name = name;
}
void xlsx_pivots_context::start_field() void xlsx_pivots_context::start_field()
{ {
} }
......
...@@ -52,11 +52,12 @@ public: ...@@ -52,11 +52,12 @@ public:
void start_field(); void start_field();
void end_field(); void end_field();
//int add_view(int indexCache); int get_view_count();//equal in libre
int get_view_count(); int get_cache_count();
void set_view_name(std::wstring name);
void add_cache(std::wstring definitions, std::wstring records); void add_cache(std::wstring definitions, std::wstring records);
int get_cache_count();
void write_cache_definitions_to (int index, std::wostream & strm); void write_cache_definitions_to (int index, std::wostream & strm);
void write_cache_records_to (int index, std::wostream & strm); void write_cache_records_to (int index, std::wostream & strm);
......
...@@ -48,7 +48,6 @@ class xlsx_table_context ...@@ -48,7 +48,6 @@ class xlsx_table_context
public: public:
xlsx_table_context(xlsx_conversion_context * Context, xlsx_text_context & textCotnext); xlsx_table_context(xlsx_conversion_context * Context, xlsx_text_context & textCotnext);
public:
void start_table(std::wstring tableName, std::wstring tableStyleName, int id); void start_table(std::wstring tableName, std::wstring tableStyleName, int id);
void end_table(); void end_table();
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
*/ */
#include "table_data_pilot_tables.h" #include "table_data_pilot_tables.h"
#include "../formulasconvert/formulasconvert.h"
#include <cpdoccore/xml/xmlchar.h> #include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h> #include <cpdoccore/xml/attributes.h>
...@@ -72,7 +73,7 @@ void table_data_pilot_table::add_attributes( const xml::attributes_wc_ptr & Attr ...@@ -72,7 +73,7 @@ void table_data_pilot_table::add_attributes( const xml::attributes_wc_ptr & Attr
CP_APPLY_ATTR(L"table:identify-categories" , table_identify_categories_); CP_APPLY_ATTR(L"table:identify-categories" , table_identify_categories_);
CP_APPLY_ATTR(L"table:ignore-empty-rows" , table_ignore_empty_rows_); CP_APPLY_ATTR(L"table:ignore-empty-rows" , table_ignore_empty_rows_);
CP_APPLY_ATTR(L"table:show-filter-button" , table_show_filter_button_); CP_APPLY_ATTR(L"table:show-filter-button" , table_show_filter_button_);
CP_APPLY_ATTR(L"table:show-target-range-address", table_show_target_range_address_); CP_APPLY_ATTR(L"table:target-range-address" , table_target_range_address_);
} }
...@@ -90,6 +91,20 @@ void table_data_pilot_table::xlsx_convert(oox::xlsx_conversion_context & Context ...@@ -90,6 +91,20 @@ void table_data_pilot_table::xlsx_convert(oox::xlsx_conversion_context & Context
Context.get_pivots_context().start_table(); Context.get_pivots_context().start_table();
if (table_name_) Context.get_pivots_context().set_view_name(*table_name_);
if (table_target_range_address_)
{
formulasconvert::odf2oox_converter formulas_converter;
std::wstring ref = formulas_converter.convert_named_ref(*table_target_range_address_, false);
std::wstring table_name = formulas_converter.get_table_name();
//Context.get_table_context()
//Context.get_pivots_context()->set_view_target_range(ref);
//Context.get_pivots_context()->set_view_target_table(table_index);
}
source_->xlsx_convert(Context); source_->xlsx_convert(Context);
for (size_t i = 0; i < fields_.size(); i++) for (size_t i = 0; i < fields_.size(); i++)
......
...@@ -88,6 +88,7 @@ private: ...@@ -88,6 +88,7 @@ private:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name); virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
_CP_OPT(std::wstring) table_name_; _CP_OPT(std::wstring) table_name_;
_CP_OPT(std::wstring) table_target_range_address_;
_CP_OPT(std::wstring) table_application_data_; _CP_OPT(std::wstring) table_application_data_;
_CP_OPT(std::wstring) table_buttons_; _CP_OPT(std::wstring) table_buttons_;
_CP_OPT(odf_types::Bool) table_drill_down_ondouble_click_; _CP_OPT(odf_types::Bool) table_drill_down_ondouble_click_;
...@@ -95,7 +96,6 @@ private: ...@@ -95,7 +96,6 @@ private:
_CP_OPT(odf_types::Bool) table_identify_categories_; _CP_OPT(odf_types::Bool) table_identify_categories_;
_CP_OPT(odf_types::Bool) table_ignore_empty_rows_; _CP_OPT(odf_types::Bool) table_ignore_empty_rows_;
_CP_OPT(odf_types::Bool) table_show_filter_button_; _CP_OPT(odf_types::Bool) table_show_filter_button_;
_CP_OPT(odf_types::Bool) table_show_target_range_address_;
office_element_ptr source_; office_element_ptr source_;
office_element_ptr_array fields_; office_element_ptr_array fields_;
......
...@@ -138,7 +138,7 @@ void ods_table_context::add_defined_range(const std::wstring & name, const std:: ...@@ -138,7 +138,7 @@ void ods_table_context::add_defined_range(const std::wstring & name, const std::
XmlUtils::replace_all( odf_range, L"[", L""); XmlUtils::replace_all( odf_range, L"[", L"");
XmlUtils::replace_all( odf_range, L"]", L""); XmlUtils::replace_all( odf_range, L"]", L"");
std::wstring odf_base_cell = formulas_converter.get_base_cell_formula(cell_range); std::wstring odf_base_cell = formulas_converter.get_base_cell_formula();
named_range->table_name_ = name; named_range->table_name_ = name;
named_range->table_cell_range_address_ = odf_range; named_range->table_cell_range_address_ = odf_range;
...@@ -182,7 +182,7 @@ void ods_table_context::add_defined_expression(const std::wstring & name, const ...@@ -182,7 +182,7 @@ void ods_table_context::add_defined_expression(const std::wstring & name, const
formulasconvert::oox2odf_converter formulas_converter; formulasconvert::oox2odf_converter formulas_converter;
std::wstring odf_value = formulas_converter.convert_named_formula(value); std::wstring odf_value = formulas_converter.convert_named_formula(value);
std::wstring odf_base_cell = formulas_converter.get_base_cell_formula(value); std::wstring odf_base_cell = formulas_converter.get_base_cell_formula();
named_expression->table_name_ = name; named_expression->table_name_ = name;
named_expression->table_expression_ = odf_value; named_expression->table_expression_ = odf_value;
......
...@@ -219,6 +219,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CDefinedName *oox_defined) ...@@ -219,6 +219,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CDefinedName *oox_defined)
bool printable = false; bool printable = false;
if (name == L"_xlnm.Print_Area")printable = true; if (name == L"_xlnm.Print_Area")printable = true;
//todoooo !!!! сделать анализ на функцию, диапазон, константы .... !!!
if (false)//если простой - range, составной - выражение if (false)//если простой - range, составной - выражение
ods_context->add_defined_range (name, oox_defined->m_oRef.get2(), sheet_id, printable); ods_context->add_defined_range (name, oox_defined->m_oRef.get2(), sheet_id, printable);
else else
......
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