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,15 +1487,21 @@ void odf_chart_context::set_cash(std::wstring format, std::vector<std::wstring>
impl_->data_cell_ranges_.back().ref = ref;
if (label == false)
{
chart_series *series = dynamic_cast<chart_series*>(impl_->current_chart_state_.elements_.back().elm.get());
if (series == NULL)return;
if (label == false)
{
series->chart_series_attlist_.chart_values_cell_range_address_ = ref;
}
else
{
series->chart_series_attlist_.chart_label_cell_address_ = ref;
if (!impl_->categories_.empty())
impl_->categories_.back().first = ref;
}
}
std::vector<double> data_double;
odf_cash_state state = {ref, format/*,data_double*/,label,data_str};
......@@ -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;
......@@ -1531,51 +1586,71 @@ void odf_chart_context::Impl::create_local_table()
std::vector<_cell_cash> cells_cash_label;
std::wstring table_name = L"local-table";
int max_columns=0;
int max_columns = 0;
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 (col1 < 0 && row1 < 0) //ChartDateRange2007.xlsx
{
//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
{
if (refs.size() > 1)
{
r = refs[1].rfind(L".");
if (r>=0)refs[1] = refs[1].substr(r+1,refs[1].size()-r);
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""};
......
......@@ -72,7 +72,7 @@ struct odf_group_state
{
odf_group_state(office_element_ptr elm_, int level_, odf_group_state_ptr prev)
{
shift_x = shift_y =x = y = rotate = 0;
shift_x = shift_y = x = y = cx = cy = rotate = 0;
scale_cx = scale_cy = 1.;
flipH = flipV = false;
......@@ -171,10 +171,10 @@ struct odf_drawing_state
{
elements_.clear();
svg_x_= boost::none;
svg_y_= boost::none;
svg_height_= boost::none;
svg_width_= boost::none;
svg_x_ = boost::none;
svg_y_ = boost::none;
svg_height_ = boost::none;
svg_width_ = boost::none;
name_ = L"";
z_order_ = -1;
......@@ -217,7 +217,6 @@ struct odf_drawing_state
///////////////////////
int oox_shape_preset;
bool in_group;
};
class odf_drawing_context::Impl
......@@ -233,6 +232,7 @@ public:
current_text_properties = NULL;
width = height = x = y = 0;
is_header_ = false;
is_footer_ = false;
//некоторые свойства для объектов графики не поддерживаюися в редакторах Liber && OpenOffice.net
......@@ -242,7 +242,7 @@ public:
odf_drawing_state current_drawing_state_;
_drawing_part current_drawing_part_;
std::vector<office_element_ptr> current_level_;//постоянно меняющийся список уровней наследования
std::vector<office_element_ptr> current_level_; //постоянно меняющийся список уровней наследования
odf_style_context *styles_context_;
odf_conversion_context *odf_context_;
......@@ -262,9 +262,12 @@ public:
graphic_format_properties preset_graphic_format_properties;
odf_group_state_ptr current_group_;
std::vector<odf_group_state_ptr> group_list_; //группы
std::vector<odf_drawing_state> drawing_list_; //все элементы(кроме групп) .. для удобства разделение по "топам"
std::vector<office_element_ptr> tops_elements_;
office_element_ptr root_element_;
double x;
......@@ -324,7 +327,7 @@ void odf_drawing_context::start_group()
int level = impl_->current_level_.size();
//////////////////////////
odf_group_state_ptr group_state = boost::shared_ptr<odf_group_state>(new odf_group_state(group_elm, level,impl_->current_group_));
odf_group_state_ptr group_state = boost::shared_ptr<odf_group_state>(new odf_group_state(group_elm, level, impl_->current_group_));
impl_->group_list_.push_back(group_state);
impl_->current_group_ = impl_->group_list_.back();
......@@ -381,15 +384,17 @@ void odf_drawing_context::start_group()
impl_->anchor_settings_.anchor_type_ = boost::none;
}
set_group_position(impl_->x, impl_->y,impl_->x, impl_->y);
//
if (level == 0)
{
impl_->tops_elements_.push_back(group_elm);
}
}
void odf_drawing_context::end_group()
{
if (impl_->group_list_.size() < 1)return;
if (impl_->group_list_.empty())return;
impl_->current_group_ = impl_->group_list_.back()->prev_group;
impl_->group_list_.pop_back();
impl_->current_level_.pop_back();
}
......@@ -432,7 +437,7 @@ void odf_drawing_context::start_drawing()
}
void odf_drawing_context::end_drawing()
{
if (impl_->current_drawing_state_.elements_.size() < 1) return;
if (impl_->current_drawing_state_.elements_.empty()) return;
draw_base* draw = dynamic_cast<draw_base*>(impl_->current_drawing_state_.elements_[0].elm.get());
......@@ -554,15 +559,18 @@ void odf_drawing_context::end_drawing()
///////////////////////////////////////////////////
impl_->drawing_list_.push_back(impl_->current_drawing_state_);
if (impl_->current_drawing_state_.elements_.size() > 0 && impl_->current_drawing_state_.elements_[0].level == 0 )
{
impl_->tops_elements_.push_back(impl_->current_drawing_state_.elements_[0].elm);
}
///////////////
impl_->current_drawing_state_.clear();
impl_->current_graphic_properties = NULL;
impl_->current_paragraph_properties = NULL;
impl_->current_text_properties = NULL;
}
}
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
office_element_ptr odf_drawing_context::Impl::create_draw_element(int type)
{
......@@ -676,7 +684,8 @@ bool odf_drawing_context::change_text_box_2_wordart()
{
if (impl_->current_drawing_state_.oox_shape_preset > 2000 && impl_->current_drawing_state_.oox_shape_preset < 3000)
return true;
if (impl_->current_drawing_state_.elements_.size() < 1) return false;
if (impl_->current_drawing_state_.elements_.empty()) return false;
draw_text_box* t = dynamic_cast<draw_text_box*>(impl_->current_drawing_state_.elements_.back().elm.get());
if (!t) return false;
......@@ -722,7 +731,7 @@ bool odf_drawing_context::change_text_box_2_wordart()
void odf_drawing_context::end_shape()
{
if (impl_->current_drawing_state_.elements_.size() < 1)
if (impl_->current_drawing_state_.elements_.empty())
return;
if (impl_->current_drawing_state_.oox_shape_preset == 2000) return end_text_box();
......@@ -1043,6 +1052,12 @@ void odf_drawing_context::set_no_fill()
switch(impl_->current_drawing_part_)
{
case Area:
if ((impl_->is_footer_ || impl_->is_header_) &&
(impl_->current_graphic_properties->content().common_draw_fill_attlist_.draw_fill_) &&
(impl_->current_graphic_properties->content().common_draw_fill_attlist_.draw_fill_->get_type() == draw_fill::bitmap))
{
}
else
impl_->current_graphic_properties->content().common_draw_fill_attlist_.draw_fill_ = draw_fill::none;
break;
case Line:
......@@ -1166,6 +1181,7 @@ void odf_drawing_context::set_rotate(double dVal)
double dRotate = dVal / 180. * 3.14159265358979323846;
impl_->current_drawing_state_.rotateAngle = dRotate;
}
void odf_drawing_context::set_drawings_rect(_CP_OPT(double) x_pt, _CP_OPT(double) y_pt, _CP_OPT(double) width_pt, _CP_OPT(double) height_pt)// "- 1" не задано
{
//хороший тон сохранить все размеры в см (хотя можно и в другой системе)
......@@ -1339,78 +1355,37 @@ void odf_drawing_context::set_overlap (bool val)
impl_->anchor_settings_.style_wrap_ = style_wrap(style_wrap::RunThrough);//??
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void odf_drawing_context::set_group_position(_CP_OPT(double) x, _CP_OPT(double) y, _CP_OPT(double) change_x, _CP_OPT(double) change_y)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////void odf_drawing_context::set_group_shift(double x, double y)
void odf_drawing_context::set_group_shift (double x, double y)
{
if (impl_->group_list_.size()<1)return;
if (!change_y && !change_x)
{
if (x)impl_->current_group_->x = *x;
if (y)impl_->current_group_->y = *y;
return;
}
impl_->current_group_->x = *change_x;
impl_->current_group_->y = *change_y;
if (!x || !y)return;
if (impl_->current_group_->prev_group)
{
double x1= (*x - *change_x)* impl_->current_group_->prev_group->scale_cx;
double y1= (*y - *change_y)* impl_->current_group_->prev_group->scale_cy;
double x2= impl_->current_group_->prev_group->shift_x ;
double y2= impl_->current_group_->prev_group->shift_y ;
impl_->current_group_->shift_x = x2 + x1
+(impl_->current_group_->prev_group->flipH ? (impl_->current_group_->prev_group->cx - 2 * x1) : 0) ;
impl_->current_group_->shift_y = y2 + y1
+(impl_->current_group_->prev_group->flipV ? (impl_->current_group_->prev_group->cy - 2 * y1) : 0) ;
}else
{
impl_->current_group_->shift_x = impl_->x + (*x - *change_x) ;
impl_->current_group_->shift_y = impl_->y + (*y - *change_y);
}
if ( impl_->group_list_.empty() )return;
impl_->current_group_->shift_y = y;
impl_->current_group_->shift_x = x;
}
void odf_drawing_context::set_group_scale(double cx, double cy)
void odf_drawing_context::set_group_scale (double cx, double cy)
{
if (impl_->group_list_.size()<1)return;
impl_->current_group_->scale_cy = impl_->current_group_->cy / cy;
impl_->current_group_->scale_cx = impl_->current_group_->cx / cx;
if ( impl_->group_list_.empty() )return;
if(impl_->current_group_->prev_group)
{
impl_->current_group_->scale_cx *= impl_->current_group_->prev_group->scale_cx;
impl_->current_group_->scale_cy *= impl_->current_group_->prev_group->scale_cy;
}
impl_->current_group_->scale_cy = cy;
impl_->current_group_->scale_cx = cx;
}
void odf_drawing_context::set_group_shift(double x, double y)
void odf_drawing_context::set_group_position(_CP_OPT(double) x, _CP_OPT(double) y, _CP_OPT(double) change_x, _CP_OPT(double) change_y)
{
if (impl_->group_list_.size()<1)return;
if ( impl_->group_list_.empty() )return;
impl_->current_group_->shift_y = (impl_->current_group_->y - y) * impl_->current_group_->scale_cy;
impl_->current_group_->shift_x = (impl_->current_group_->x - x) * impl_->current_group_->scale_cx;
if ( !x || !y ) return;
if(impl_->current_group_->prev_group)
{
impl_->current_group_->shift_x += impl_->current_group_->prev_group->shift_x;
impl_->current_group_->shift_y += impl_->current_group_->prev_group->shift_y;
}
impl_->current_group_->x = *change_x ;
impl_->current_group_->y = *change_y ;
impl_->current_group_->shift_x = (*x - *change_x) ;
impl_->current_group_->shift_y = (*y - *change_y) ;
}
void odf_drawing_context::set_group_size( _CP_OPT(double) cx, _CP_OPT(double) cy, _CP_OPT(double) change_cx, _CP_OPT(double) change_cy)
{
if (impl_->group_list_.size()<1)return;
if (!change_cy && !change_cx)
{
if (cx) impl_->current_group_->cx = *cx;
if (cy) impl_->current_group_->cy = *cy;
return;
}
if ( impl_->group_list_.empty() )return;
if (change_cx && cx)
impl_->current_group_->scale_cx = *cx / *change_cx;
......@@ -1418,43 +1393,19 @@ void odf_drawing_context::set_group_size( _CP_OPT(double) cx, _CP_OPT(double) cy
if (change_cy && cy)
impl_->current_group_->scale_cy = *cy / *change_cy;
if(impl_->current_group_->prev_group && change_cx && change_cy)
{
impl_->current_group_->scale_cx *= impl_->current_group_->prev_group->scale_cx;
impl_->current_group_->scale_cy *= impl_->current_group_->prev_group->scale_cy;
}
else if (change_cx && change_cy)
{
double first_scale_x = 1;
double first_scale_y = 1;
if (impl_->width > 0)
{
first_scale_x = impl_->width / *change_cx;
impl_->current_group_->scale_cx = first_scale_x;
}
if (impl_->height > 0)
{
first_scale_y = impl_->height / *change_cy;
impl_->current_group_->scale_cy = first_scale_y;
}
}
impl_->current_group_->cx = *change_cx * impl_->current_group_->scale_cx;
impl_->current_group_->cy = *change_cy * impl_->current_group_->scale_cy;
impl_->current_group_->cx = *change_cx;
impl_->current_group_->cy = *change_cy;
}
void odf_drawing_context::set_group_flip_V(bool bVal)
{
if (impl_->group_list_.size()<1)return;
if ( impl_->group_list_.empty() )return;
impl_->current_group_->flipV= bVal;
}
void odf_drawing_context::set_group_z_order(int Val)
{
if (impl_->group_list_.size()<1)return;
if ( impl_->group_list_.empty() )return;
draw_g* group = dynamic_cast<draw_g*>(impl_->current_group_->elm.get());
......@@ -1464,22 +1415,24 @@ void odf_drawing_context::set_group_z_order(int Val)
}
void odf_drawing_context::set_group_name(std::wstring name)
{
if (impl_->group_list_.size()<1)return;
if ( impl_->group_list_.empty() )return;
draw_g* group = dynamic_cast<draw_g*>(impl_->current_group_->elm.get());
if (name.length() > 0)
if ( !name.empty() )
group->common_draw_attlists_.shape_with_text_and_styles_.common_draw_shape_with_styles_attlist_.common_draw_name_attlist_.draw_name_ = name;
}
void odf_drawing_context::set_group_flip_H(bool bVal)
{
if (impl_->group_list_.size()<1)return;
if ( impl_->group_list_.empty() )return;
impl_->current_group_->flipH= bVal;
}
void odf_drawing_context::set_group_rotate(int iVal)
{
if (impl_->group_list_.size()<1)return;
if ( impl_->group_list_.empty() )return;
double dRotate = (360 - iVal/60000.)/180. * 3.14159265358979323846;
......@@ -1532,26 +1485,39 @@ void odf_drawing_context::set_position_line(_CP_OPT(double) & x_pt, _CP_OPT(doub
void odf_drawing_context::set_position(_CP_OPT(double) & x_pt, _CP_OPT(double) & y_pt)
{
double x = x_pt ? *x_pt : 0;
double y = y_pt ? *y_pt : 0;
if (x_pt)
{
double x = *x_pt;
if (impl_->current_drawing_state_.in_group && impl_->current_group_ && x_pt)
if (impl_->current_drawing_state_.in_group)
{
x_pt = *x_pt * impl_->current_group_->scale_cx + impl_->current_group_->shift_x ;
// + (impl_->current_group_->flipH ? (impl_->current_group_->cx - 2 * x_pt): 0);
for( int i = impl_->group_list_.size() - 1; i >= 0 ; i--)
{
x = (x + impl_->group_list_[i]->shift_x) * impl_->group_list_[i]->scale_cx ;
}
if (impl_->current_drawing_state_.in_group && impl_->current_group_ && y_pt)
}
if (!impl_->current_drawing_state_.svg_x_ || impl_->current_drawing_state_.in_group)
{
y_pt = *y_pt * impl_->current_group_->scale_cy + impl_->current_group_->shift_y;
//+ (impl_->current_group_->flipV ? (impl_->current_group_->cy - 2 * y_pt): 0);
impl_->current_drawing_state_.svg_x_ = length(length(x , length::pt).get_value_unit(length::cm),length::cm);
}
}
if ((!impl_->current_drawing_state_.svg_x_ || impl_->current_drawing_state_.in_group) && x_pt)
if (y_pt)
{
double y = *y_pt;
if (impl_->current_drawing_state_.in_group)
{
for( int i = impl_->group_list_.size() - 1; i >= 0 ; i--)
{
impl_->current_drawing_state_.svg_x_ = length(length(*x_pt,length::pt).get_value_unit(length::cm),length::cm);
y = (y + impl_->group_list_[i]->shift_y) * impl_->group_list_[i]->scale_cy;
}
if ((!impl_->current_drawing_state_.svg_y_ || impl_->current_drawing_state_.in_group) && y_pt)
}
if (!impl_->current_drawing_state_.svg_y_ || impl_->current_drawing_state_.in_group)
{
impl_->current_drawing_state_.svg_y_ = length(length(*y_pt,length::pt).get_value_unit(length::cm),length::cm);
impl_->current_drawing_state_.svg_y_ = length(length(y, length::pt).get_value_unit(length::cm),length::cm);
}
}
}
void odf_drawing_context::get_size( double & width_pt, double & height_pt)
......@@ -1574,12 +1540,18 @@ void odf_drawing_context::set_size( _CP_OPT(double) & width_pt, _CP_OPT(double)
{
if (width_pt)
{
width_pt = *width_pt * impl_->group_list_.back()->scale_cx;
for( int i = impl_->group_list_.size() - 1; i >= 0 ; i--)
{
width_pt = *width_pt * impl_->group_list_[i]->scale_cx;
}
impl_->current_drawing_state_.svg_width_ = length(length(*width_pt,length::pt).get_value_unit(length::cm),length::cm);
}
if (height_pt)
{
height_pt = *height_pt * impl_->group_list_.back()->scale_cy;
for( int i = impl_->group_list_.size() - 1; i >= 0 ; i--)
{
height_pt = *height_pt * impl_->group_list_[i]->scale_cy;
}
impl_->current_drawing_state_.svg_height_= length(length(*height_pt,length::pt).get_value_unit(length::cm),length::cm);
}
}else
......@@ -1734,7 +1706,7 @@ void odf_drawing_context::set_textarea_wrap(bool Val)
void odf_drawing_context::set_textarea_font(_CP_OPT(std::wstring) & latin, _CP_OPT(std::wstring) & cs, _CP_OPT(std::wstring) & ea)
{
if (!latin && !cs && !ea)return;
if (impl_->current_drawing_state_.elements_.size() < 1)return;
if (impl_->current_drawing_state_.elements_.empty())return;
if (!impl_->current_text_properties)
{
......@@ -1754,7 +1726,7 @@ void odf_drawing_context::set_textarea_font(_CP_OPT(std::wstring) & latin, _CP_O
}
void odf_drawing_context::set_textarea_fontcolor(std::wstring hexColor)
{
if (impl_->current_drawing_state_.elements_.size() < 1)return;
if (impl_->current_drawing_state_.elements_.empty())return;
if (!impl_->current_text_properties)
{
......@@ -1775,7 +1747,7 @@ void odf_drawing_context::set_textarea_fontcolor(std::wstring hexColor)
void odf_drawing_context::set_textarea_writing_mode(int mode)
{
if (mode == 1) return;//незачем
if (impl_->current_drawing_state_.elements_.size() < 1)return;
if (impl_->current_drawing_state_.elements_.empty())return;
if (!impl_->current_paragraph_properties)
{
......@@ -1928,7 +1900,8 @@ void odf_drawing_context::start_text_box()
void odf_drawing_context::set_text_box_min_size(bool val)
{
if (impl_->current_drawing_state_.elements_.size() < 1) return;
if (impl_->current_drawing_state_.elements_.empty()) return;
draw_text_box* draw = dynamic_cast<draw_text_box*>(impl_->current_drawing_state_.elements_.back().elm.get());
if (draw)
......@@ -1942,7 +1915,8 @@ void odf_drawing_context::set_text_box_min_size(bool val)
void odf_drawing_context::set_text_box_min_size(double w_pt, double h_pt)
{
if (impl_->current_drawing_state_.elements_.size() < 1) return;
if (impl_->current_drawing_state_.elements_.empty()) return;
draw_text_box* draw = dynamic_cast<draw_text_box*>(impl_->current_drawing_state_.elements_.back().elm.get());
if (draw)
......@@ -1956,7 +1930,8 @@ void odf_drawing_context::set_text_box_min_size(double w_pt, double h_pt)
void odf_drawing_context::set_text_box_parent_style(std::wstring style_name)
{
if (impl_->current_drawing_state_.elements_.size() < 1) return;
if (impl_->current_drawing_state_.elements_.empty()) return;
//добавить в стиль ссыль на базовый стиль Frame - зачемто нужно для таблиц которые не инлайн
style* style_ = dynamic_cast<style*>(impl_->current_drawing_state_.elements_[0].style_elm.get()); // на "головной" элекмент
......@@ -1983,7 +1958,8 @@ void odf_drawing_context::end_image()
}
void odf_drawing_context::end_text_box()
{
if (impl_->current_drawing_state_.elements_.size() < 1) return;
if (impl_->current_drawing_state_.elements_.empty()) return;
draw_text_box* draw = dynamic_cast<draw_text_box*>(impl_->current_drawing_state_.elements_.back().elm.get());
if (!draw->draw_text_box_attlist_.fo_min_height_)
......@@ -2045,24 +2021,14 @@ void odf_drawing_context::end_object()
bool odf_drawing_context::is_exist_content()
{
return (impl_->drawing_list_.size()>0 ? true : false);
return (impl_->drawing_list_.empty() ? false : true);
}
void odf_drawing_context::finalize(office_element_ptr & root_elm)//для привязки
{
for (int i=0; i< impl_->group_list_.size(); i++)
{
if (impl_->group_list_[i]->level ==0 )
for (int i=0; i< impl_->tops_elements_.size(); i++)
{
root_elm->add_child_element(impl_->group_list_[i]->elm);
}
}
for (int i=0; i< impl_->drawing_list_.size(); i++)
{
if (impl_->drawing_list_[i].elements_.size() > 0 && impl_->drawing_list_[i].elements_[0].level == 0 )
{
root_elm->add_child_element(impl_->drawing_list_[i].elements_[0].elm);
}
root_elm->add_child_element(impl_->tops_elements_[i]);
}
}
office_element_ptr & odf_drawing_context::get_current_style_element()
......
......@@ -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,7 +140,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_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;
......
......@@ -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