Commit 00490614 authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatWriter - fix header page, fix group shapes

parent 38ebea34
......@@ -1345,6 +1345,7 @@ void odf_chart_context::end_chart()
impl_->clear_current();
}
static formulasconvert::oox2odf_converter formulas_converter_chart;
void odf_chart_context::set_series_value_formula(std::wstring oox_formula)
......@@ -1353,30 +1354,59 @@ void odf_chart_context::set_series_value_formula(std::wstring oox_formula)
if (oox_formula.length() > 0)
odfFormula = formulas_converter_chart.convert_chart_distance(oox_formula);
//----------------------------------------------------------------------------
std::vector<std::wstring> refs;
boost::algorithm::split(refs, oox_formula, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
if (refs.size() > 0)
{
int col = -1, row = -1;
utils::parsing_ref( refs[0], col, row);
if (col < 0 && row < 0)
{
odfFormula.clear(); //reset by cash
}
}
//----------------------------------------------------------------------------
chart_series *series = dynamic_cast<chart_series*>(impl_->current_chart_state_.elements_.back().elm.get());
if (series == NULL)return;
Impl::_range r = {odfFormula, false};
impl_->data_cell_ranges_.push_back(r);
if (oox_formula.length() > 0)
if (!oox_formula.empty())
{
series->chart_series_attlist_.chart_values_cell_range_address_ = odfFormula;
impl_->current_data_points_series_count_ = formulas_converter_chart.get_count_value_points(oox_formula);
}
}
void odf_chart_context::set_series_label_formula(std::wstring oox_formula)
{
std::wstring odfFormula;
if (oox_formula.length() > 0)
odfFormula = formulas_converter_chart.convert_chart_distance(oox_formula);
//----------------------------------------------------------------------------
std::vector<std::wstring> refs;
boost::algorithm::split(refs, oox_formula, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
if (refs.size() > 0)
{
int col = -1, row = -1;
utils::parsing_ref( refs[0], col, row);
if (col < 0 && row < 0)
{
odfFormula.clear(); //reset by cash
}
}
//----------------------------------------------------------------------------
Impl::_range r = {odfFormula, true};
impl_->data_cell_ranges_.push_back(r);
if (odfFormula.length() > 0)
if (!odfFormula.empty())
{
chart_series *series = dynamic_cast<chart_series*>(impl_->current_chart_state_.elements_.back().elm.get());
if (series == NULL)return;
......@@ -1390,11 +1420,29 @@ void odf_chart_context::set_category_axis_formula(std::wstring oox_formula,int t
if (oox_formula.length() > 0)
odfFormula = formulas_converter_chart.convert_chart_distance(oox_formula);
//----------------------------------------------------------------------------
std::vector<std::wstring> refs;
boost::algorithm::split(refs, oox_formula, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
if (refs.size() > 0)
{
int col = -1, row = -1;
utils::parsing_ref( refs[0], col, row);
if (col < 0 && row < 0)
{
odfFormula.clear(); //reset by cash
}
}
//----------------------------------------------------------------------------
Impl::_range r = {odfFormula, true};
impl_->data_cell_ranges_.push_back(r);
impl_->categories_.push_back(std::pair<std::wstring,int>(odfFormula,type));
if (!odfFormula.empty())
{
impl_->categories_.push_back(std::pair<std::wstring,int>(odfFormula, type));
}
}
void odf_chart_context::set_series_pie_explosion(int val)//или точка серии
......@@ -1416,19 +1464,19 @@ void odf_chart_context::set_series_pie_explosion(int val)//или точка с
void odf_chart_context::set_cash(std::wstring format, std::vector<std::wstring> & data_str, bool label)
{
if (data_str.size() <1) return;
if (impl_->data_cell_ranges_.size()<1) return;
if (data_str.size() < 1) return;
if (impl_->data_cell_ranges_.size() < 1) return;
std::wstring ref = impl_->data_cell_ranges_.back().ref;
if (ref.length() < 1)
if (ref.empty())
{
std::wstring col;
if (label) col = L"A";
else
{
int curr_col = 0;
for (long i=0; i<impl_->data_cell_ranges_.size(); i++)
for (long i=0; i < impl_->data_cell_ranges_.size(); i++)
{
if (impl_->data_cell_ranges_[i].label)continue;
curr_col++;
......@@ -1439,14 +1487,20 @@ void odf_chart_context::set_cash(std::wstring format, std::vector<std::wstring>
impl_->data_cell_ranges_.back().ref = ref;
chart_series *series = dynamic_cast<chart_series*>(impl_->current_chart_state_.elements_.back().elm.get());
if (series == NULL)return;
if (label == false)
{
chart_series *series = dynamic_cast<chart_series*>(impl_->current_chart_state_.elements_.back().elm.get());
if (series == NULL)return;
series->chart_series_attlist_.chart_values_cell_range_address_ = ref;
}
else
impl_->categories_.back().first = ref;
{
series->chart_series_attlist_.chart_label_cell_address_ = ref;
if (!impl_->categories_.empty())
impl_->categories_.back().first = ref;
}
}
std::vector<double> data_double;
......@@ -1523,6 +1577,7 @@ void odf_chart_context::Impl::create_local_table_rows(ods_table_state * table_st
curr_cell = cells[i].col;
}
}
void odf_chart_context::Impl::create_local_table()
{
if (local_table_enabled_ == false)return;
......@@ -1530,60 +1585,80 @@ void odf_chart_context::Impl::create_local_table()
std::vector<_cell_cash> cells_cash;
std::vector<_cell_cash> cells_cash_label;
std::wstring table_name = L"local-table";
int max_columns=0;
std::wstring table_name = L"local-table";
int max_columns = 0;
bool col_header = false;
bool row_header = false;
bool col_header = false;
bool row_header = false;
//выкинем дублирующие ref
for (long i=0; i < cash_.size(); i++)
for (long i = 0; i < cash_.size(); i++)
{
for (long j=i+1; j < cash_.size(); j++)
for (long j = i + 1; j < cash_.size(); j++)
{
if (cash_[j].ref == cash_[i].ref && cash_[j].ref.length() > 1)
{
cash_.erase(cash_.begin()+j);
cash_.erase(cash_.begin() + j);
}
}
}
for (long i=0; i < cash_.size(); i++)
for (long i = 0; i < cash_.size(); i++)
{
std::vector<std::wstring> refs;
boost::algorithm::split(refs,cash_[i].ref, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
int col1 = -1, col2 = -1, row1 = -1, row2 = -1;
if (refs.size()<1) continue;
if (refs.size() < 1) continue;
int r = refs[0].rfind(L".");//в имени таблички может быть точка
if (r > 0)
{
table_name = refs[0].substr (0,r);
refs[0] = refs[0].substr(r+1,refs[0].size()-r);
table_name = refs[0].substr (0, r);
refs[0] = refs[0].substr(r + 1, refs[0].size() - r);
}
utils::parsing_ref( refs[0], col1, row1);
if (refs.size() > 1)
if (col1 < 0 && row1 < 0) //ChartDateRange2007.xlsx
{
r = refs[1].rfind(L".");
if (r>=0)refs[1] = refs[1].substr(r+1,refs[1].size()-r);
utils::parsing_ref( refs[1], col2, row2);
//recalc_refs = true;
//table_name = L"local-table";
////defined name?
//row1 = i + 1;
//col1 = 0;
//row2 = i + 1;
//col2 = cash_[i].data_str.size() - 1;
//cash_[i].ref = table_name + L"." + L"$" + utils::getColAddress(col1) + L"$" + boost::lexical_cast<std::wstring>(row1) +
// + L":" + L"." + L"$" + utils::getColAddress(col2) + L"$" + boost::lexical_cast<std::wstring>(row2);
}
else
{
col2 = col1; row2 = row1;
{
if (refs.size() > 1)
{
r = refs[1].rfind(L".");
if (r >= 0)
refs[1] = refs[1].substr(r + 1, refs[1].size() - r);
utils::parsing_ref( refs[1], col2, row2);
}
else
{
col2 = col1; row2 = row1;
}
}
for (long j=0;j<cash_[i].data_str.size(); j++)
for (long j = 0; j < cash_[i].data_str.size(); j++)
{
_cell_cash c = {0, 0, false, false, L""};
if (col1 >= 0 && row1 >= 0)
{
c.col = (col2 == col1) ? col1 : col1 + j;
c.row = (row2 == row1) ? row1 : row1 + j;
c.val = cash_[i].data_str[j];
c.col = (col2 == col1) ? col1 : col1 + j;
c.row = (row2 == row1) ? row1 : row1 + j;
c.val = cash_[i].data_str[j];
c.label = false;
}
else
......@@ -1594,8 +1669,8 @@ void odf_chart_context::Impl::create_local_table()
if (cash_[i].label && c.row == 1)
{
c.label = cash_[i].label;
row_header = true;
c.label = cash_[i].label;
row_header = true;
}
if (cash_[i].label && c.col == 1)
{
......
......@@ -692,7 +692,7 @@ style_header_footer_properties *odf_page_layout_context::get_footer_properties()
{
office_element_ptr elm;
create_element(L"style", L"footer-style", elm, odf_context_);
layout_state_list_.back().add_child(elm, office_element_ptr(),L"");
layout_state_list_.back().add_child(elm, office_element_ptr(),L"");
office_element_ptr pr;
create_element(L"style", L"header-footer-properties", pr, odf_context_);
......
......@@ -185,7 +185,7 @@ style_page_layout_properties *odf_layout_state::get_properties()
style_header_footer_properties *odf_layout_state::get_header_properties()
{
for (long i= 1; i<elements_.size(); i++)//"0" - root
for (long i = 1; i < elements_.size(); i++)//"0" - root
{
style_header_style *style_ = dynamic_cast<style_header_style *>(elements_[i].elm.get());
if (style_)
......@@ -197,7 +197,7 @@ style_header_footer_properties *odf_layout_state::get_header_properties()
}
style_header_footer_properties *odf_layout_state::get_footer_properties()
{
for (long i= 1; i<elements_.size(); i++)//"0" - root
for (long i = 1; i < elements_.size(); i++)//"0" - root
{
style_footer_style *style_ = dynamic_cast<style_footer_style *>(elements_[i].elm.get());
if (style_)
......
......@@ -140,10 +140,11 @@ 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_formula(value);
//formulas_converter.convert_named_ref(value); -> ChartDateRange2007.xlsx
std::wstring odf_base_cell = formulas_converter.find_base_cell(value);
named_expression->table_name_ = name;
named_expression->table_name_ = name;
named_expression->table_expression_ = odf_value;
if (sheet_id >=0)
......
......@@ -671,8 +671,8 @@ class style_page_layout_attlist
public:
void serialize(CP_ATTR_NODE);
_CP_OPT(std::wstring) style_name_;
_CP_OPT(odf_types::page_usage) style_page_usage_; // default All
_CP_OPT(std::wstring) style_name_;
_CP_OPT(odf_types::page_usage) style_page_usage_; // default All
};
......@@ -699,7 +699,7 @@ CP_REGISTER_OFFICE_ELEMENT2(style_header_style)
/// style:footer-style
class style_footer_style : public office_element_impl<style_header_style>
class style_footer_style : public office_element_impl<style_footer_style>
{
public:
static const wchar_t * ns;
......
......@@ -230,9 +230,9 @@ void OoxConverter::convert(SimpleTypes::Vml::CCssStyle *vml_style, bool group)
if (group)
{
_CP_OPT(double) not_set;
odf_context()->drawing_context()->set_group_size(width_pt, height_pt, not_set ,not_set);
odf_context()->drawing_context()->set_group_size(width_pt, height_pt, width_pt, height_pt);//not_set ,not_set);
odf_context()->drawing_context()->set_group_position(x, y, not_set , not_set );
odf_context()->drawing_context()->set_group_position(x, y, x, y);//not_set , not_set );
}
else
{
......
......@@ -353,6 +353,7 @@ void OoxConverter::convert(OOX::Drawing::CGroupShapeProperties * oox_group_spP
{
if (oox_group_spPr->m_oXfrm->m_oFlipH.GetValue() == SimpleTypes::onoffTrue)
odf_context()->drawing_context()->set_group_flip_H(true);
if (oox_group_spPr->m_oXfrm->m_oFlipV.GetValue() == SimpleTypes::onoffTrue)
odf_context()->drawing_context()->set_group_flip_V(true);
......@@ -362,22 +363,24 @@ void OoxConverter::convert(OOX::Drawing::CGroupShapeProperties * oox_group_spP
cx = oox_group_spPr->m_oXfrm->m_oExt->m_oCx.ToPoints();
cy = oox_group_spPr->m_oXfrm->m_oExt->m_oCy.ToPoints();
ch_cx = oox_group_spPr->m_oXfrm->m_oChExt->m_oCx.ToPoints();
ch_cy = oox_group_spPr->m_oXfrm->m_oChExt->m_oCy.ToPoints();
odf_context()->drawing_context()->set_group_size(cx,cy,ch_cx,ch_cy);
odf_context()->drawing_context()->set_group_size(cx, cy, ch_cx, ch_cy);
}
if (
oox_group_spPr->m_oXfrm->m_oOff.IsInit() && oox_group_spPr->m_oXfrm->m_oChOff.IsInit())
{
_CP_OPT(double) x,y, ch_x, ch_y;
x = oox_group_spPr->m_oXfrm->m_oOff->m_oX.ToPoints();
y = oox_group_spPr->m_oXfrm->m_oOff->m_oY.ToPoints();
ch_x = oox_group_spPr->m_oXfrm->m_oChOff->m_oX.ToPoints();
ch_y = oox_group_spPr->m_oXfrm->m_oChOff->m_oY.ToPoints();
odf_context()->drawing_context()->set_group_position( x,y, ch_x, ch_y);
odf_context()->drawing_context()->set_group_position( x, y, ch_x, ch_y);
}
if (oox_group_spPr->m_oXfrm->m_oRot.GetValue() > 0)
......
......@@ -448,7 +448,7 @@ public:
void convert(OOX::Spreadsheet::CT_Marker *marker);
void convert(OOX::Spreadsheet::CT_Marker *marker, std::vector<OOX::Spreadsheet::CT_DPt*> & dPt);
void convert(OOX::Spreadsheet::CT_ExternalData *external_data);
void convert(OOX::Spreadsheet::CT_NumData *num_data);
void convert(OOX::Spreadsheet::CT_NumData *num_data, bool label = false);
void convert(OOX::Spreadsheet::CT_StrData *str_data, bool label = false);
......
......@@ -1027,7 +1027,7 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_AxDataSource* cat, int type)
{
if (cat == NULL)
{
odf_context()->chart_context()->set_category_axis_formula(L"",type);
odf_context()->chart_context()->set_category_axis_formula(L"", type);
return;
}
if (cat->m_numLit)
......@@ -1039,19 +1039,19 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_AxDataSource* cat, int type)
else if (cat->m_strLit)
{
odf_context()->chart_context()->set_category_axis_formula(L"", type);
convert(cat->m_strLit,true);
convert(cat->m_strLit, true);
}
else if (cat->m_strRef)
{
if (cat->m_strRef->m_f)odf_context()->chart_context()->set_category_axis_formula(string2std_string(*cat->m_strRef->m_f),type);
convert(cat->m_strRef->m_strCache,true/*, type == 1 ? true:false*/);
convert(cat->m_strRef->m_strCache, true/*, type == 1 ? true:false*/);
}
else if (cat->m_numRef)
{
if (cat->m_numRef->m_f)odf_context()->chart_context()->set_category_axis_formula(string2std_string(*cat->m_numRef->m_f),type);
if (cat->m_numRef->m_f)odf_context()->chart_context()->set_category_axis_formula(string2std_string(*cat->m_numRef->m_f), type);
convert(cat->m_numRef->m_numCache);
convert(cat->m_numRef->m_numCache, true);
}
}
......@@ -1111,7 +1111,7 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_ExternalData *external_data)
odf_context()->chart_context()->set_local_table(true);//пока пользуем кэш ....
}
void OoxConverter::convert(OOX::Spreadsheet::CT_NumData *num_data)
void OoxConverter::convert(OOX::Spreadsheet::CT_NumData *num_data, bool label)
{
if (num_data == NULL)return;
......@@ -1137,8 +1137,9 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_NumData *num_data)
std::wstring format;
if (num_data->m_formatCode) format = string2std_string(*num_data->m_formatCode);
odf_context()->chart_context()->set_cash(format, data);
odf_context()->chart_context()->set_cash(format, data, label);
}
void OoxConverter::convert(OOX::Spreadsheet::CT_StrData *str_data, bool label)
{
if (str_data == NULL)return;
......@@ -1152,6 +1153,6 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_StrData *str_data, bool label)
}
std::wstring format;
odf_context()->chart_context()->set_cash(format, data,label);
odf_context()->chart_context()->set_cash(format, data, label);
}
}
......@@ -1156,14 +1156,14 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
}
}
s = oox_section_pr;
if (present_footer && s->m_arrFooterReference.size() <1 && last_section_properties)
if (present_footer && s->m_arrFooterReference.size() < 1 && last_section_properties)
s = last_section_properties; // нужно хранить ссылки на ВСЕ !!!
for (unsigned int i=0; i< s->m_arrFooterReference.size(); i++)
{
if (s->m_arrFooterReference[i] == NULL) continue;
int type =s->m_arrFooterReference[i]->m_oType.IsInit() ? s->m_arrFooterReference[i]->m_oType->GetValue() :0 ;
int type = s->m_arrFooterReference[i]->m_oType.IsInit() ? s->m_arrFooterReference[i]->m_oType->GetValue() :0 ;
if (odt_context->start_footer(type))
{
if (s->m_arrFooterReference[i]->m_oId.IsInit())
......@@ -2157,10 +2157,10 @@ void DocxConverter::convert(OOX::Drawing::CAnchor *oox_anchor)
width = oox_anchor->m_oExtent->m_oCx.ToPoints();
height = oox_anchor->m_oExtent->m_oCy.ToPoints();
}
if (oox_anchor->m_oDistL.IsInit())odt_context->drawing_context()->set_margin_left(oox_anchor->m_oDistL->ToPoints());
if (oox_anchor->m_oDistT.IsInit())odt_context->drawing_context()->set_margin_top(oox_anchor->m_oDistT->ToPoints());
if (oox_anchor->m_oDistR.IsInit())odt_context->drawing_context()->set_margin_right(oox_anchor->m_oDistR->ToPoints());
if (oox_anchor->m_oDistB.IsInit())odt_context->drawing_context()->set_margin_bottom(oox_anchor->m_oDistB->ToPoints());
if (oox_anchor->m_oDistL.IsInit())odt_context->drawing_context()->set_margin_left (oox_anchor->m_oDistL->ToPoints());
if (oox_anchor->m_oDistT.IsInit())odt_context->drawing_context()->set_margin_top (oox_anchor->m_oDistT->ToPoints());
if (oox_anchor->m_oDistR.IsInit())odt_context->drawing_context()->set_margin_right (oox_anchor->m_oDistR->ToPoints());
if (oox_anchor->m_oDistB.IsInit())odt_context->drawing_context()->set_margin_bottom (oox_anchor->m_oDistB->ToPoints());
odt_context->drawing_context()->set_drawings_rect(x, y, width, height);
......
......@@ -1702,7 +1702,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCellAnchor *oox_anchor)
ods_context->current_table().convert_position(from, x1, y1);
ods_context->current_table().convert_position(to, x2, y2);
ods_context->drawing_context()->set_drawings_rect(x1, y1, x2-x1, y2-y1);
ods_context->drawing_context()->set_drawings_rect(x1, y1, x2 - x1, y2 - y1);
}
//////////////
......
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