Commit 824586e4 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

.....

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@56147 954022d7-b5bf-4e40-9824-e11837661b57
parent b451e1d8
......@@ -42,9 +42,20 @@ namespace odf
void clear()
{
elements_.clear();
chart_width_pt = chart_height_pt = 0;
categories_.clear();
axis_id=0;
}
double chart_width_pt;
double chart_height_pt;
std::vector<std::wstring> categories_;
std::vector<odf_element_state> elements_;
int axis_id;
};
class odf_chart_context::Impl
{
......@@ -53,17 +64,24 @@ public:
{
styles_context_ = NULL;
current_chart_properties = NULL;
current_text_properties_ = NULL;
current_paragraph_properties_ = NULL;
current_graphic_properties_ = NULL;
current_chart_properties_ = NULL;
}
odf_chart_state current_chart_state_;
std::vector<office_element_ptr> current_level_;//
std::vector<office_element_ptr> current_level_; //
std::vector<odf_chart_state> chart_list_; // .. ""
odf_style_context *styles_context_;
odf_conversion_context *odf_context_;
style_chart_properties *current_chart_properties;
style_text_properties *current_text_properties_;
style_graphic_properties *current_graphic_properties_;
style_paragraph_properties *current_paragraph_properties_;
style_chart_properties *current_chart_properties_;
chart_chart *current_chart_;
};
......@@ -113,7 +131,7 @@ void odf_chart_context::start_chart(office_element_ptr & root)
if (style_)
{
style_name = style_->style_name_;
impl_->current_chart_properties = style_->style_content_.get_style_chart_properties();
impl_->current_chart_properties_ = style_->style_content_.get_style_chart_properties();
impl_->current_chart_->chart_chart_attlist_.common_attlist_.chart_style_name_ = style_name;
}
......@@ -131,6 +149,14 @@ void odf_chart_context::start_chart(office_element_ptr & root)
impl_->current_chart_state_.elements_.push_back(state);
}
void odf_chart_context::set_size_chart(double width_pt, double height_pt)
{
impl_->current_chart_state_.chart_height_pt = height_pt;
impl_->current_chart_state_.chart_width_pt = width_pt;
impl_->current_chart_->chart_chart_attlist_.common_draw_size_attlist_.svg_width_ = length(length(width_pt,length::pt).get_value_unit(length::cm),length::cm);
impl_->current_chart_->chart_chart_attlist_.common_draw_size_attlist_.svg_height_ = length(length(height_pt,length::pt).get_value_unit(length::cm),length::cm);
}
void odf_chart_context::set_type_chart(std::wstring type)
{
if (!impl_->current_chart_)return;
......@@ -139,8 +165,8 @@ void odf_chart_context::set_type_chart(std::wstring type)
}
void odf_chart_context::set_3D(bool Val)
{
if (!impl_->current_chart_properties) return;
impl_->current_chart_properties->content().chart_three_dimensional_ = Val;
if (!impl_->current_chart_properties_) return;
impl_->current_chart_properties_->content().chart_three_dimensional_ = Val;
}
void odf_chart_context::start_series(std::wstring type)
{
......@@ -160,8 +186,6 @@ void odf_chart_context::start_series(std::wstring type)
if (style_)
{
style_name = style_->style_name_;
impl_->current_chart_properties = style_->style_content_.get_style_chart_properties();
series->chart_series_attlist_.common_attlist_.chart_style_name_ = style_name;
series->chart_series_attlist_.chart_class_ = std::wstring(L"chart:") + type;
}
......@@ -185,11 +209,44 @@ void odf_chart_context::start_axis()
if (style_)
{
style_name = style_->style_name_;
impl_->current_chart_properties = style_->style_content_.get_style_chart_properties();
axis->chart_axis_attlist_.common_attlist_.chart_style_name_ = style_name;
}
start_element(chart_elm, style_elm, style_name);
if (impl_->current_chart_state_.axis_id < impl_->current_chart_state_.categories_.size() &&
impl_->current_chart_state_.categories_[impl_->current_chart_state_.axis_id].length() > 0)
{
//start_categories();
// set_categories_formula(impl_->categories_[axis_id]);
//end_element();
}
impl_->current_chart_state_.axis_id++;
}
void odf_chart_context::start_grid(int type)
{
office_element_ptr chart_elm;
create_element(L"chart", L"grid", chart_elm, impl_->odf_context_);
chart_grid *grid = dynamic_cast<chart_grid*>(chart_elm.get());
if (grid == NULL)return;
//////////
if (type == 1) grid->chart_grid_attlist_.chart_class_ = L"major";
if (type == 2) grid->chart_grid_attlist_.chart_class_ = L"minor";
impl_->styles_context_->create_style(L"",style_family::Chart, true, false, -1);
office_element_ptr & style_elm = impl_->styles_context_->last_state().get_office_element();
std::wstring style_name;
style* style_ = dynamic_cast<style*>(style_elm.get());
if (style_)
{
style_name = style_->style_name_;
grid->chart_grid_attlist_.common_attlist_.chart_style_name_ = style_name;
}
start_element(chart_elm, style_elm, style_name);
}
void odf_chart_context::start_title()
{
......@@ -209,8 +266,6 @@ void odf_chart_context::start_title()
if (style_)
{
style_name = style_->style_name_;
impl_->current_chart_properties = style_->style_content_.get_style_chart_properties();
title->chart_title_attlist_.common_attlist_.chart_style_name_ = style_name;
}
start_element(chart_elm, style_elm, style_name);
......@@ -222,6 +277,8 @@ void odf_chart_context::start_plot_area()
chart_plot_area *plot_area = dynamic_cast<chart_plot_area*>(chart_elm.get());
if (plot_area == NULL)return;
plot_area->chart_plot_area_attlist_.chart_data_source_has_labels_ = L"both";
//////////
impl_->styles_context_->create_style(L"",style_family::Chart, true, false, -1);
......@@ -233,8 +290,6 @@ void odf_chart_context::start_plot_area()
if (style_)
{
style_name = style_->style_name_;
impl_->current_chart_properties = style_->style_content_.get_style_chart_properties();
plot_area->chart_plot_area_attlist_.common_attlist_.chart_style_name_ = style_name;
}
start_element(chart_elm, style_elm, style_name);
......@@ -244,17 +299,16 @@ void odf_chart_context::start_text()
impl_->odf_context_->start_text_context();
impl_->odf_context_->text_context()->set_styles_context(impl_->styles_context_);
style_paragraph_properties *para_props = NULL;
style_text_properties *text_props = NULL;
style *style_ = dynamic_cast<style*>(impl_->current_chart_state_.elements_.back().style_elm.get());
if (style_)
{
para_props = style_->style_content_.get_style_paragraph_properties();
text_props = style_->style_content_.get_style_text_properties();
impl_->current_paragraph_properties_ = style_->style_content_.get_style_paragraph_properties();
impl_->current_text_properties_ = style_->style_content_.get_style_text_properties();
}
impl_->odf_context_->text_context()->set_single_object(true,para_props,text_props);
impl_->odf_context_->text_context()->set_single_object(true,impl_->current_paragraph_properties_,impl_->current_text_properties_);
}
void odf_chart_context::end_text()
{
......@@ -297,8 +351,6 @@ void odf_chart_context::start_legend()
if (style_)
{
style_name = style_->style_name_;
impl_->current_chart_properties = style_->style_content_.get_style_chart_properties();
legend->chart_legend_attlist_.common_attlist_.chart_style_name_ = style_name;
}
start_element(chart_elm, style_elm, style_name);
......@@ -320,52 +372,114 @@ void odf_chart_context::set_legend_position(int val)
void odf_chart_context::set_layout_x(double *val,int mode)//edge, factor
{
if (!val)return;
if (mode == 0) return;
if (mode == 0) *val = impl_->current_chart_state_.chart_width_pt * (*val);
length x_cm = length(length(*val,length::pt).get_value_unit(length::cm),length::cm);
chart_legend *legend = dynamic_cast<chart_legend*>(impl_->current_chart_state_.elements_.back().elm.get());
if (legend)legend->chart_legend_attlist_.common_draw_position_attlist_.svg_x_ = length(*val,length::pt);
if (legend)legend->chart_legend_attlist_.common_draw_position_attlist_.svg_x_ = x_cm;
chart_plot_area *plot_area = dynamic_cast<chart_plot_area*>(impl_->current_chart_state_.elements_.back().elm.get());
if (plot_area)plot_area->chart_plot_area_attlist_.common_draw_position_attlist_.svg_x_ = length(*val,length::pt);
if (plot_area)plot_area->chart_plot_area_attlist_.common_draw_position_attlist_.svg_x_ = x_cm;
chart_title *title = dynamic_cast<chart_title*>(impl_->current_chart_state_.elements_.back().elm.get());
if (title)title->chart_title_attlist_.common_draw_position_attlist_.svg_x_ = length(*val,length::pt);
if (title)title->chart_title_attlist_.common_draw_position_attlist_.svg_x_ = x_cm;
}
void odf_chart_context::set_axis_label(int type)
{
if (!impl_->current_chart_properties_)return;
if (type == 1 || type == 2)
impl_->current_chart_properties_->content().chart_display_label_ = true;
}
void odf_chart_context::set_axis_orientation(int type)
{
if (!impl_->current_chart_properties_)return;
if (type == 0) impl_->current_chart_properties_->content().chart_reverse_direction_ = true;
}
void odf_chart_context::set_axis_logarithmic(bool val)
{
if (!impl_->current_chart_properties_)return;
impl_->current_chart_properties_->content().chart_logarithmic_ = val;
}
void odf_chart_context::set_axis_dimension(std::wstring val)
{
chart_axis *axis = dynamic_cast<chart_axis*>(impl_->current_chart_state_.elements_.back().elm.get());
if (!axis)return;
axis->chart_axis_attlist_.chart_dimension_ = val;
axis->chart_axis_attlist_.chart_name_ = std::wstring(L"primary-") + val; // -
}
void odf_chart_context::set_axis_position(int type)
{
if (!impl_->current_chart_properties_)return;
//st_axposB = 0,
//st_axposL = 1,
//st_axposR = 2,
//st_axposT = 3
//if (type ==0 || type ==2)
// impl_->current_chart_properties_->content().chart_axis_position_ = L"end";
//if (type ==1 || type ==3)
// impl_->current_chart_properties_->content().chart_axis_position_ = L"start";
//a value of type double the axis line is placed at the given value on the crossing axis.
//If the crossing axis is an axis displaying categories rather than values, a value of 1 indicates that the axis should be placed at the first category, a value of 2 indicates that the axis should be placed at the second category and so forth.
}
void odf_chart_context::set_axis_label_position(int type)
{
if (!impl_->current_chart_properties_)return;
//st_ticklblposHIGH = 0,
//st_ticklblposLOW = 1,
//st_ticklblposNEXTTO = 2,
//st_ticklblposNONE = 3
if (type ==1)impl_->current_chart_properties_->content().chart_axis_label_position_ = L"outside-start";
if (type ==0)impl_->current_chart_properties_->content().chart_axis_label_position_ = L"outside-end";
if (type ==2)impl_->current_chart_properties_->content().chart_axis_label_position_ = L"near-axis";
//near-axis-other-side
//near-axis //default
}
void odf_chart_context::set_layout_y(double *val,int mode)
{
if (!val)return;
if (mode == 0) return;
if (mode == 0)*val = impl_->current_chart_state_.chart_height_pt * (*val);
length y_cm = length(length(*val,length::pt).get_value_unit(length::cm),length::cm);
chart_legend *legend = dynamic_cast<chart_legend*>(impl_->current_chart_state_.elements_.back().elm.get());
if (legend)legend->chart_legend_attlist_.common_draw_position_attlist_.svg_y_ = length(*val,length::pt);
if (legend)legend->chart_legend_attlist_.common_draw_position_attlist_.svg_y_ = y_cm;
chart_plot_area *plot_area = dynamic_cast<chart_plot_area *>(impl_->current_chart_state_.elements_.back().elm.get());
if (plot_area)plot_area->chart_plot_area_attlist_.common_draw_position_attlist_.svg_y_ = length(*val,length::pt);
if (plot_area)plot_area->chart_plot_area_attlist_.common_draw_position_attlist_.svg_y_ = y_cm;
chart_title *title = dynamic_cast<chart_title*>(impl_->current_chart_state_.elements_.back().elm.get());
if (title)title->chart_title_attlist_.common_draw_position_attlist_.svg_y_ = length(*val,length::pt);
if (title)title->chart_title_attlist_.common_draw_position_attlist_.svg_y_ = y_cm;
}
void odf_chart_context::set_layout_w(double *val,int mode)
{
if (!val)return;
if (mode == 0) return;
if (mode == 0) *val = impl_->current_chart_state_.chart_width_pt * (*val);
length width_cm = length(length(*val,length::pt).get_value_unit(length::cm),length::cm);
chart_legend *legend = dynamic_cast<chart_legend*>(impl_->current_chart_state_.elements_.back().elm.get());
if (legend)legend->chart_legend_attlist_.chartooo_width_ = length(*val,length::pt);
if (legend)legend->chart_legend_attlist_.chartooo_width_ = width_cm;
chart_plot_area *plot_area = dynamic_cast<chart_plot_area *>(impl_->current_chart_state_.elements_.back().elm.get());
if (plot_area)plot_area->chart_plot_area_attlist_.common_draw_size_attlist_.svg_width_ = length(*val,length::pt);
if (plot_area)plot_area->chart_plot_area_attlist_.common_draw_size_attlist_.svg_width_ = width_cm;
}
void odf_chart_context::set_layout_h(double *val,int mode)
{
if (!val)return;
if (mode == 0) return;
if (mode == 0) *val = impl_->current_chart_state_.chart_height_pt * (*val);
length height_cm = length(length(*val,length::pt).get_value_unit(length::cm),length::cm);
chart_legend *legend = dynamic_cast<chart_legend*>(impl_->current_chart_state_.elements_.back().elm.get());
if (legend)legend->chart_legend_attlist_.chartooo_height_ = length(*val,length::pt);
if (legend)legend->chart_legend_attlist_.chartooo_height_ = height_cm;
chart_plot_area *plot_area = dynamic_cast<chart_plot_area *>(impl_->current_chart_state_.elements_.back().elm.get());
if (plot_area)plot_area->chart_plot_area_attlist_.common_draw_size_attlist_.svg_height_ = length(*val,length::pt);
if (plot_area)plot_area->chart_plot_area_attlist_.common_draw_size_attlist_.svg_height_ = height_cm;
}
void odf_chart_context::start_element(office_element_ptr & elm, office_element_ptr & style_elm, std::wstring style_name)
......@@ -377,16 +491,50 @@ void odf_chart_context::start_element(office_element_ptr & elm, office_element_p
impl_->current_level_.push_back(elm);// current_chart_properties ????
impl_->current_text_properties_ = NULL;
impl_->current_paragraph_properties_ = NULL;
impl_->current_graphic_properties_ = NULL;
impl_->current_chart_properties_ = NULL;
style* style_ = dynamic_cast<style*>(style_elm.get());
if (style_)
{
style_name = style_->style_name_;
impl_->current_chart_properties_ = style_->style_content_.get_style_chart_properties();
}
odf_element_state state={elm, style_name, style_elm, level};
impl_->current_chart_state_.elements_.push_back(state);
}
void odf_chart_context::end_element()
{
//
{
if (impl_->current_paragraph_properties_)
{
if (impl_->current_paragraph_properties_->content().style_writing_mode_)
{
switch(impl_->current_paragraph_properties_->content().style_writing_mode_->get_type())
{
case writing_mode::LrTb:
case writing_mode::RlTb:
case writing_mode::Lr:
impl_->current_chart_properties_->content().style_direction_ = direction(direction::Ltr); break;
case writing_mode::TbRl:
case writing_mode::TbLr:
case writing_mode::Tb:
impl_->current_chart_properties_->content().style_direction_ = direction(direction::Ttb); break;
}
}
}
}
impl_->current_level_.pop_back();
drawing_context()->end_element();
impl_->current_chart_properties = NULL;
impl_->current_paragraph_properties_ = NULL;
impl_->current_graphic_properties_ = NULL;
impl_->current_chart_properties_ = NULL;
}
void odf_chart_context::end_chart()
......@@ -397,29 +545,36 @@ void odf_chart_context::end_chart()
///////////////
impl_->chart_list_.push_back(impl_->current_chart_state_);
impl_->current_chart_state_.clear();
impl_->current_chart_properties = NULL;
impl_->current_chart_ = NULL;
}
static formulasconvert::oox2odf_converter formulas_converter;
void odf_chart_context::set_series_formula(int category, std::wstring oox_formula)
void odf_chart_context::set_series_name(std::wstring name)
{
}
void odf_chart_context::set_series_value_formula(std::wstring oox_formula)
{
std::wstring odfFormula = formulas_converter.convert_chart_distance(oox_formula);
chart_series *series = dynamic_cast<chart_series*>(impl_->current_chart_state_.elements_.back().elm.get());
if (series == NULL)return;
if (category == 1)
{
series->chart_series_attlist_.chart_label_cell_address_ = odfFormula;
}
if (category == 2)
{
series->chart_series_attlist_.chart_values_cell_range_address_ = odfFormula;
}
}
void odf_chart_context::set_series_label_formula(std::wstring oox_formula)
{
std::wstring odfFormula = formulas_converter.convert_chart_distance(oox_formula);
chart_series *series = dynamic_cast<chart_series*>(impl_->current_chart_state_.elements_.back().elm.get());
if (series == NULL)return;
series->chart_series_attlist_.chart_label_cell_address_ = odfFormula + L":" + odfFormula;
}
void odf_chart_context::set_category_axis_formula(std::wstring oox_formula)
{
std::wstring odfFormula = formulas_converter.convert_chart_distance(oox_formula);
impl_->current_chart_state_.categories_.push_back(odfFormula);
}
}
......
......@@ -32,11 +32,23 @@ public:
void start_chart(office_element_ptr & root);
void set_type_chart(std::wstring type);
void set_3D(bool Val);
void set_size_chart(double width_pt, double height_pt);
void start_series(std::wstring type);
void set_series_value_formula(std::wstring oox_formula);
void set_series_label_formula(std::wstring oox_formula);
void set_series_name(std::wstring name);
void set_category_axis_formula(std::wstring oox_formula);
void start_axis();
void set_axis_dimension(std::wstring val);
void set_axis_orientation(int type);
void set_axis_logarithmic(bool val);
void set_axis_label(int type);
void set_axis_position(int type);
void set_axis_label_position(int type);
void start_title();
void start_grid(int type);
void start_plot_area();
void start_legend();
void set_legend_position(int val);
......@@ -44,8 +56,6 @@ public:
void start_element(office_element_ptr & elm, office_element_ptr & style_elm, std::wstring style_name);
void end_element();
void set_series_formula(int category, std::wstring oox_formula);
void start_text();
void end_text();
......
......@@ -493,6 +493,8 @@ void odf_drawing_context::set_no_fill()
impl_->current_graphic_properties->content().common_draw_fill_attlist_.draw_fill_ = draw_fill::none;
break;
case Line:
impl_->current_graphic_properties->content().common_draw_fill_attlist_.draw_fill_ = draw_fill::none;
impl_->current_graphic_properties->content().draw_stroke_ = line_style (line_style::None);
break;
}
}
......@@ -564,6 +566,14 @@ void odf_drawing_context::set_rect(double x_pt, double y_pt, double width_pt, do
impl_->current_drawing_state_.svg_height_ = length(length(height_pt,length::pt).get_value_unit(length::cm),length::cm);
impl_->current_drawing_state_.svg_width_ = length(length(width_pt,length::pt).get_value_unit(length::cm),length::cm);
}
void odf_drawing_context::get_size( double & width_pt, double & height_pt)
{
if (!impl_->current_drawing_state_.svg_width_ || !impl_->current_drawing_state_.svg_height_) return;
width_pt = impl_->current_drawing_state_.svg_width_->get_value_unit(length::pt);
height_pt = impl_->current_drawing_state_.svg_height_->get_value_unit(length::pt);
}
void odf_drawing_context::set_line_width(double pt)
{
if (!impl_->current_graphic_properties)return;
......
......@@ -61,6 +61,7 @@ public:
///////////////////////////////////////////////////////////////////////////////////////
void set_rect(double x_pt, double y_pt, double width_pt, double height_pt);
void get_size( double & width_pt, double & height_pt);
void set_name(std::wstring name);
void set_z_order(int id);
......
......@@ -370,7 +370,7 @@ void chart_categories::serialize(std::wostream & _Wostream)
void chart_series_attlist::serialize(CP_ATTR_NODE)
{
CP_XML_ATTR_OPT(L"chart:values-cell-range-address", chart_values_cell_range_address_);
CP_XML_ATTR_OPT(L"chart:label-cell-", chart_label_cell_address_);
CP_XML_ATTR_OPT(L"chart:label-cell-range-address", chart_label_cell_address_);
CP_XML_ATTR_OPT(L"chart:class", chart_class_);
CP_XML_ATTR_OPT(L"chart:attached-axis", chart_attached_axis_);
common_attlist_.serialize(CP_GET_XML_NODE());
......
......@@ -74,6 +74,8 @@ void chart_format_properties::serialize(std::wostream & _Wostream ,const wchar_t
CP_XML_ATTR_OPT(L"chart:regression-type", chart_regression_type_);
CP_XML_ATTR_OPT(L"chart:data-label-number", chart_data_label_number_);
CP_XML_ATTR_OPT(L"chart:error-category", chart_error_category_);
CP_XML_ATTR_OPT(L"chart:axis-label-position", chart_axis_label_position_);
CP_XML_ATTR_OPT(L"chart:axis-position", chart_axis_position_);
common_rotation_angle_attlist_.serialize(CP_GET_XML_NODE());
}
......
......@@ -81,6 +81,9 @@ public:
_CP_OPT(chart_data_label_number) chart_data_label_number_;
_CP_OPT(chart_error_category) chart_error_category_;
_CP_OPT(std::wstring) chart_axis_label_position_;
_CP_OPT(std::wstring) chart_axis_position_;
common_rotation_angle_attlist common_rotation_angle_attlist_;
};
/// \class style_chart_properties
......
......@@ -831,25 +831,4 @@ void OoxConverter::convert(double oox_font_size, _CP_OPT(odf::font_size) & odf_
odf_font_size = odf::font_size(odf_length.get());
}
void OoxConverter::convert(OOX::Spreadsheet::CChartSpace *oox_chart)
{
if ((!oox_chart) && (!oox_chart->m_oChartSpace.m_chart))return;
oox_current_chart = oox_chart;
odf_context()->start_chart();
convert(oox_chart->m_oChartSpace.m_oSpPr.GetPointer());
convert(oox_chart->m_oChartSpace.m_oTxPr.GetPointer());
convert(oox_chart->m_oChartSpace.m_chart->m_title);
convert(oox_chart->m_oChartSpace.m_chart->m_legend);
convert(oox_chart->m_oChartSpace.m_chart->m_plotArea);
convert(oox_chart->m_oChartSpace.m_chart->m_sideWall, 2);
convert(oox_chart->m_oChartSpace.m_chart->m_backWall, 3);
convert(oox_chart->m_oChartSpace.m_chart->m_floor, 1);
odf_context()->end_chart();
oox_current_chart = NULL;
}
}
\ No newline at end of file
......@@ -259,7 +259,7 @@ public:
void convert(OOX::Drawing::CRunProperty *oox_run_pr, cpdoccore::odf::style_text_properties * text_properties);
void convert(OOX::Drawing::CLineSpacing *oox_spacing, cpdoccore::odf::length_or_percent & length_or_percent);
//////////////////////////////////////////////////////////////////////////////////////////////////////////
void convert(OOX::Spreadsheet::CChartSpace *oox_chart);
void convert(OOX::Spreadsheet::CT_ChartSpace *oox_chart);
void convert(OOX::Spreadsheet::CT_Title *ct_title);
void convert(OOX::Spreadsheet::CT_Legend *ct_legend);
void convert(OOX::Spreadsheet::CT_LegendEntry *ct_legend);
......@@ -293,13 +293,15 @@ public:
void convert(OOX::Spreadsheet::CT_ScatterSer *ser);
void convert(OOX::Spreadsheet::CT_RadarSer *ser);
void convert(OOX::Spreadsheet::CT_LineSer *ser);
void convert(OOX::Spreadsheet::CT_AxDataSource *cat, int category);
void convert(OOX::Spreadsheet::CT_NumDataSource *val, int category);
void convert(OOX::Spreadsheet::CT_AxDataSource *cat);
void convert(OOX::Spreadsheet::CT_NumDataSource *val);
void convert(OOX::Spreadsheet::CRichText *rich);
void convert(OOX::Spreadsheet::CTextProperties *txPr);
void convert(OOX::Spreadsheet::CT_Tx *ct_tx);
void convert(OOX::Spreadsheet::CT_Layout *ct_layout);
void convert(OOX::Spreadsheet::CT_ManualLayout *ct_layout);
void convert(OOX::Spreadsheet::CT_ChartLines *grid, int type);
void convert(OOX::Spreadsheet::CT_SerTx *ser_tx);
//////////////////////////////////////////////////////////////////////////////////////////////////////////
void convert(double oox_font_size, cpdoccore::_CP_OPT(cpdoccore::odf::font_size) & odf_font_size);
};
......
......@@ -19,6 +19,22 @@
namespace Oox2Odf
{
void OoxConverter::convert(OOX::Spreadsheet::CT_ChartSpace *oox_chart)
{
if (!oox_chart)return;
convert(oox_chart->m_oSpPr.GetPointer());
convert(oox_chart->m_oTxPr.GetPointer());
convert(oox_chart->m_chart->m_title);
convert(oox_chart->m_chart->m_legend);
convert(oox_chart->m_chart->m_plotArea);
convert(oox_chart->m_chart->m_sideWall, 2);
convert(oox_chart->m_chart->m_backWall, 3);
convert(oox_chart->m_chart->m_floor, 1);
}
void OoxConverter::convert(OOX::Spreadsheet::CRichText* rich)
{
if (rich == NULL)return;
......@@ -56,14 +72,17 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_Layout* ct_layout)
if (ct_layout == NULL)return;
if (ct_layout->m_manualLayout == NULL)return;
if (ct_layout->m_manualLayout->m_x && ct_layout->m_manualLayout->m_xMode)
odf_context()->chart_context()->set_layout_x(ct_layout->m_manualLayout->m_x->m_val,*ct_layout->m_manualLayout->m_xMode->m_val);
if (ct_layout->m_manualLayout->m_y && ct_layout->m_manualLayout->m_yMode)
odf_context()->chart_context()->set_layout_y(ct_layout->m_manualLayout->m_y->m_val,*ct_layout->m_manualLayout->m_yMode->m_val);
if (ct_layout->m_manualLayout->m_w && ct_layout->m_manualLayout->m_wMode)
odf_context()->chart_context()->set_layout_w(ct_layout->m_manualLayout->m_w->m_val,*ct_layout->m_manualLayout->m_wMode->m_val);
if (ct_layout->m_manualLayout->m_h && ct_layout->m_manualLayout->m_hMode)
odf_context()->chart_context()->set_layout_h(ct_layout->m_manualLayout->m_h->m_val,*ct_layout->m_manualLayout->m_hMode->m_val);
int m_xMode=0, m_yMode=0, m_wMode=0,m_hMode=0;
if (ct_layout->m_manualLayout->m_xMode && ct_layout->m_manualLayout->m_xMode->m_val) m_xMode = *ct_layout->m_manualLayout->m_xMode->m_val;
if (ct_layout->m_manualLayout->m_yMode && ct_layout->m_manualLayout->m_yMode->m_val) m_yMode = *ct_layout->m_manualLayout->m_yMode->m_val;
if (ct_layout->m_manualLayout->m_hMode && ct_layout->m_manualLayout->m_hMode->m_val) m_hMode = *ct_layout->m_manualLayout->m_hMode->m_val;
if (ct_layout->m_manualLayout->m_wMode && ct_layout->m_manualLayout->m_wMode->m_val) m_wMode = *ct_layout->m_manualLayout->m_wMode->m_val;
if (ct_layout->m_manualLayout->m_x) odf_context()->chart_context()->set_layout_x(ct_layout->m_manualLayout->m_x->m_val,m_xMode);
if (ct_layout->m_manualLayout->m_y) odf_context()->chart_context()->set_layout_y(ct_layout->m_manualLayout->m_y->m_val,m_yMode);
if (ct_layout->m_manualLayout->m_w) odf_context()->chart_context()->set_layout_w(ct_layout->m_manualLayout->m_w->m_val,m_wMode);
if (ct_layout->m_manualLayout->m_h) odf_context()->chart_context()->set_layout_h(ct_layout->m_manualLayout->m_h->m_val,m_hMode);
}
void OoxConverter::convert(OOX::Spreadsheet::CT_Title* ct_title)
......@@ -72,8 +91,8 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_Title* ct_title)
odf_context()->chart_context()->start_title();
convert(ct_title->m_oSpPr.GetPointer());
convert(ct_title->m_oTxPr.GetPointer());
convert(ct_title->m_layout);
convert(ct_title->m_oTxPr.GetPointer());
///////////////////////////////
convert(ct_title->m_tx);
odf_context()->chart_context()->end_element();
......@@ -84,11 +103,11 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_Legend* ct_legend)
odf_context()->chart_context()->start_legend();
convert(ct_legend->m_oSpPr.GetPointer());
convert(ct_legend->m_oTxPr.GetPointer());
convert(ct_legend->m_layout);
if ((ct_legend->m_legendPos) && (ct_legend->m_legendPos->m_val))
odf_context()->chart_context()->set_legend_position(*ct_legend->m_legendPos->m_val);
convert(ct_legend->m_oTxPr.GetPointer());
if (ct_legend->m_legendEntry.GetCount() > 0)
{
convert(ct_legend->m_legendEntry[0]); // odf
......@@ -133,7 +152,7 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_PlotArea* ct_plotArea)
case OOX::Spreadsheet::itemschoicetype5SURFACECHART: convert((OOX::Spreadsheet::CT_SurfaceChart*) ct_plotArea->m_Items[i]);break;
}
}
for (long i=0; i< ct_plotArea->m_Items.GetCount(); i++)
for (long i=0; i< ct_plotArea->m_Items1.GetCount(); i++)
{
if (!ct_plotArea->m_ItemsElementName1[i]) continue;
switch(*ct_plotArea->m_ItemsElementName1[i])
......@@ -150,48 +169,115 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_PlotArea* ct_plotArea)
odf_context()->chart_context()->end_element();
}
//////////////////////////////////////////////////////////////////////////////////////////////
void OoxConverter::convert(OOX::Spreadsheet::CT_CatAx* ct_catAx)
void OoxConverter::convert(OOX::Spreadsheet::CT_CatAx* axis)
{
if (ct_catAx == NULL)return;
if (axis == NULL)return;
odf_context()->chart_context()->start_axis();
convert(ct_catAx->m_oSpPr.GetPointer());
convert(ct_catAx->m_oTxPr.GetPointer());
odf_context()->chart_context()->set_axis_dimension(L"x");
convert(axis->m_oSpPr.GetPointer());
if (axis->m_scaling)
{
if (axis->m_scaling->m_logBase)
odf_context()->chart_context()->set_axis_logarithmic(true);
if (axis->m_scaling->m_orientation && axis->m_scaling->m_orientation->m_val)
odf_context()->chart_context()->set_axis_orientation(*axis->m_scaling->m_orientation->m_val);
if (axis->m_scaling->m_min){}
if (axis->m_scaling->m_max){}
}
if (axis->m_majorTickMark)odf_context()->chart_context()->set_axis_label(1);
if (axis->m_minorTickMark)odf_context()->chart_context()->set_axis_label(2);
if (axis->m_axPos && axis->m_axPos->m_val)
odf_context()->chart_context()->set_axis_position(*axis->m_axPos->m_val);
if (axis->m_tickLblPos && axis->m_tickLblPos->m_val)
odf_context()->chart_context()->set_axis_label_position(*axis->m_tickLblPos->m_val);
///////////////////
convert(ct_catAx->m_title);
convert(axis->m_oTxPr.GetPointer());
convert(axis->m_title);
convert(axis->m_majorGridlines, 1);
convert(axis->m_minorGridlines, 2);
odf_context()->chart_context()->end_element();
}
void OoxConverter::convert(OOX::Spreadsheet::CT_DateAx* ct_dateAx)
void OoxConverter::convert(OOX::Spreadsheet::CT_DateAx* axis)
{
if (ct_dateAx == NULL)return;
if (axis == NULL)return;
odf_context()->chart_context()->start_axis();
convert(ct_dateAx->m_oSpPr.GetPointer());
convert(ct_dateAx->m_oTxPr.GetPointer());
odf_context()->chart_context()->set_axis_dimension(L"x");
convert(axis->m_oSpPr.GetPointer());
if (axis->m_scaling)
{
if (axis->m_scaling->m_logBase)
odf_context()->chart_context()->set_axis_logarithmic(true);
if (axis->m_scaling->m_orientation && axis->m_scaling->m_orientation->m_val)
odf_context()->chart_context()->set_axis_orientation(*axis->m_scaling->m_orientation->m_val);
if (axis->m_scaling->m_min){}
if (axis->m_scaling->m_max){}
}
if (axis->m_majorTickMark)odf_context()->chart_context()->set_axis_label(1);
if (axis->m_minorTickMark)odf_context()->chart_context()->set_axis_label(2);
if (axis->m_axPos && axis->m_axPos->m_val)
odf_context()->chart_context()->set_axis_position(*axis->m_axPos->m_val);
//////////////////
convert(ct_dateAx->m_title);
convert(axis->m_oTxPr.GetPointer());
convert(axis->m_title);
convert(axis->m_majorGridlines, 1);
convert(axis->m_minorGridlines, 2);
odf_context()->chart_context()->end_element();
}
void OoxConverter::convert(OOX::Spreadsheet::CT_SerAx* ct_serAx)
void OoxConverter::convert(OOX::Spreadsheet::CT_SerAx* axis)
{
if (ct_serAx == NULL)return;
if (axis == NULL)return;
odf_context()->chart_context()->start_axis();
convert(ct_serAx->m_oSpPr.GetPointer());
convert(ct_serAx->m_oTxPr.GetPointer());
odf_context()->chart_context()->set_axis_dimension(L"x");
convert(axis->m_oSpPr.GetPointer());
if (axis->m_scaling)
{
if (axis->m_scaling->m_logBase)
odf_context()->chart_context()->set_axis_logarithmic(true);
if (axis->m_scaling->m_orientation && axis->m_scaling->m_orientation->m_val)
odf_context()->chart_context()->set_axis_orientation(*axis->m_scaling->m_orientation->m_val);
if (axis->m_scaling->m_min){}
if (axis->m_scaling->m_max){}
}
if (axis->m_majorTickMark)odf_context()->chart_context()->set_axis_label(1);
if (axis->m_minorTickMark)odf_context()->chart_context()->set_axis_label(2);
if (axis->m_axPos && axis->m_axPos->m_val)
odf_context()->chart_context()->set_axis_position(*axis->m_axPos->m_val);
///////////////////////////
convert(ct_serAx->m_title);
convert(axis->m_oTxPr.GetPointer());
convert(axis->m_title);
convert(axis->m_majorGridlines, 1);
convert(axis->m_minorGridlines, 2);
odf_context()->chart_context()->end_element();
}
void OoxConverter::convert(OOX::Spreadsheet::CT_ValAx* ct_valAx)
void OoxConverter::convert(OOX::Spreadsheet::CT_ValAx* axis)
{
if (ct_valAx == NULL)return;
if (axis == NULL)return;
odf_context()->chart_context()->start_axis();
convert(ct_valAx->m_oSpPr.GetPointer());
convert(ct_valAx->m_oTxPr.GetPointer());
odf_context()->chart_context()->set_axis_dimension(L"y");
convert(axis->m_oSpPr.GetPointer());
if (axis->m_scaling)
{
if (axis->m_scaling->m_logBase)
odf_context()->chart_context()->set_axis_logarithmic(true);
if (axis->m_scaling->m_orientation && axis->m_scaling->m_orientation->m_val)
odf_context()->chart_context()->set_axis_orientation(*axis->m_scaling->m_orientation->m_val);
if (axis->m_scaling->m_min){}
if (axis->m_scaling->m_max){}
}
if (axis->m_majorTickMark)odf_context()->chart_context()->set_axis_label(1);
if (axis->m_minorTickMark)odf_context()->chart_context()->set_axis_label(2);
if (axis->m_axPos && axis->m_axPos->m_val)
odf_context()->chart_context()->set_axis_position(*axis->m_axPos->m_val);
/////////////////////////////
convert(ct_valAx->m_title);
convert(axis->m_oTxPr.GetPointer());
convert(axis->m_title);
convert(axis->m_majorGridlines, 1);
convert(axis->m_minorGridlines, 2);
odf_context()->chart_context()->end_element();
}
////////////////////////////////////////////////////////////////////////////////////////////
......@@ -207,6 +293,14 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_Area3DChart *chart)
convert(chart->m_ser[i]);
}
}
void OoxConverter::convert(OOX::Spreadsheet::CT_ChartLines *grid, int type)
{
if (grid == NULL)return;
odf_context()->chart_context()->start_grid(type);
convert(grid->m_oSpPr.GetPointer());
odf_context()->chart_context()->end_element();
}
void OoxConverter::convert(OOX::Spreadsheet::CT_AreaChart *chart)
{
if (chart == NULL)return;
......@@ -378,8 +472,9 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_AreaSer* ser)
{
odf_context()->chart_context()->start_series(L"area");
convert(ser->m_oSpPr.GetPointer());
convert(ser->m_cat, 1);
convert(ser->m_val, 2);
convert(ser->m_cat);
convert(ser->m_val);
convert(ser->m_tx);
odf_context()->chart_context()->end_element();
}
void OoxConverter::convert(OOX::Spreadsheet::CT_BubbleSer* ser)
......@@ -388,8 +483,9 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_BubbleSer* ser)
odf_context()->chart_context()->start_series(L"bubble");
convert(ser->m_oSpPr.GetPointer());
convert(ser->m_xVal, 1);
convert(ser->m_yVal, 2);
convert(ser->m_xVal/*, 1*/);
convert(ser->m_yVal/*, 2*/);
convert(ser->m_tx);
odf_context()->chart_context()->end_element();
}
void OoxConverter::convert(OOX::Spreadsheet::CT_SurfaceSer* ser)
......@@ -398,8 +494,9 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_SurfaceSer* ser)
odf_context()->chart_context()->start_series(L"surface");
convert(ser->m_oSpPr.GetPointer());
convert(ser->m_cat, 1);
convert(ser->m_val, 2);
convert(ser->m_cat);
convert(ser->m_val);
convert(ser->m_tx);
odf_context()->chart_context()->end_element();
}
void OoxConverter::convert(OOX::Spreadsheet::CT_PieSer* ser)
......@@ -408,8 +505,9 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_PieSer* ser)
odf_context()->chart_context()->start_series(L"circle");
convert(ser->m_oSpPr.GetPointer());
convert(ser->m_cat, 1);
convert(ser->m_val, 2);
convert(ser->m_cat);
convert(ser->m_val);
convert(ser->m_tx);
odf_context()->chart_context()->end_element();
}
void OoxConverter::convert(OOX::Spreadsheet::CT_BarSer* ser)
......@@ -418,8 +516,9 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_BarSer* ser)
odf_context()->chart_context()->start_series(L"bar");
convert(ser->m_oSpPr.GetPointer());
convert(ser->m_cat, 1);
convert(ser->m_val, 2);
convert(ser->m_cat);
convert(ser->m_val);
convert(ser->m_tx);
odf_context()->chart_context()->end_element();
}
void OoxConverter::convert(OOX::Spreadsheet::CT_ScatterSer* ser)
......@@ -428,8 +527,9 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_ScatterSer* ser)
odf_context()->chart_context()->start_series(L"scatter");
convert(ser->m_oSpPr.GetPointer());
convert(ser->m_xVal, 1);
convert(ser->m_yVal, 2);
convert(ser->m_xVal/*, 1*/);
convert(ser->m_yVal/*, 2*/);
convert(ser->m_tx);
odf_context()->chart_context()->end_element();
}
void OoxConverter::convert(OOX::Spreadsheet::CT_RadarSer* ser)
......@@ -438,8 +538,9 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_RadarSer* ser)
odf_context()->chart_context()->start_series(L"radar");
convert(ser->m_oSpPr.GetPointer());
convert(ser->m_cat, 1);
convert(ser->m_val, 2);
convert(ser->m_cat);
convert(ser->m_val);
convert(ser->m_tx);
odf_context()->chart_context()->end_element();
}
void OoxConverter::convert(OOX::Spreadsheet::CT_LineSer* ser)
......@@ -448,22 +549,39 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_LineSer* ser)
odf_context()->chart_context()->start_series(L"line");
convert(ser->m_oSpPr.GetPointer());
convert(ser->m_cat, 1);
convert(ser->m_val, 2);
convert(ser->m_cat);
convert(ser->m_val);
convert(ser->m_tx);
odf_context()->chart_context()->end_element();
}
void OoxConverter::convert(OOX::Spreadsheet::CT_AxDataSource* cat, int category)
void OoxConverter::convert(OOX::Spreadsheet::CT_SerTx* ser_tx)
{
if (cat == NULL)return;
if (ser_tx == NULL)return;
if (ser_tx->m_strRef)
{
if (ser_tx->m_strRef->m_f)odf_context()->chart_context()->set_series_label_formula(string2std_string(*ser_tx->m_strRef->m_f));
if (ser_tx->m_strRef->m_strCache){}
}
//if (ser_tx->m_v)odf_context()->chart_context()->set_series_name(string2std_string(*ser_tx->m_v));
}
void OoxConverter::convert(OOX::Spreadsheet::CT_AxDataSource* cat)
{
if (cat == NULL)
{
odf_context()->chart_context()->set_category_axis_formula(L"");
return;
}
if (cat->m_strRef)
{
if (cat->m_strRef->m_f)odf_context()->chart_context()->set_series_formula(category,string2std_string(*cat->m_strRef->m_f));
if (cat->m_strRef->m_f)odf_context()->chart_context()->set_category_axis_formula(string2std_string(*cat->m_strRef->m_f));
if (cat->m_strRef->m_strCache){}
}
else if (cat->m_numRef)
{
if (cat->m_numRef->m_f)odf_context()->chart_context()->set_series_formula(category,string2std_string(*cat->m_numRef->m_f));
if (cat->m_numRef->m_f)odf_context()->chart_context()->set_category_axis_formula(string2std_string(*cat->m_numRef->m_f));
if (cat->m_numRef->m_numCache){}
}
else if (cat->m_numLit)
......@@ -473,12 +591,12 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_AxDataSource* cat, int category)
{
}
}
void OoxConverter::convert(OOX::Spreadsheet::CT_NumDataSource* val, int category)
void OoxConverter::convert(OOX::Spreadsheet::CT_NumDataSource* val)
{
if (val == NULL)return;
if (val->m_numRef)
{
if (val->m_numRef->m_f)odf_context()->chart_context()->set_series_formula(category,string2std_string(*val->m_numRef->m_f));
if (val->m_numRef->m_f)odf_context()->chart_context()->set_series_value_formula(string2std_string(*val->m_numRef->m_f));
if (val->m_numRef->m_numCache){}
}
else if (val->m_numLit)
......
......@@ -1164,8 +1164,12 @@ void XlsxConverter::convert(OOX::Spreadsheet::CGraphicFrame* oox_graphic_frame)
{
if (!oox_graphic_frame)return;
////////////////////////////////////////////////////////////////////////////////
ods_context->drawing_context()->start_object(ods_context->get_next_name_object());
{
double width =0, height =0;
ods_context->drawing_context()->get_size(width, height);
if (oox_graphic_frame->m_oNvGraphicFramePr.IsInit())
{
if (oox_graphic_frame->m_oNvGraphicFramePr->m_oCNvPr.IsInit())
......@@ -1185,7 +1189,15 @@ void XlsxConverter::convert(OOX::Spreadsheet::CGraphicFrame* oox_graphic_frame)
{
OOX::Spreadsheet::CChartSpace* pChart = (OOX::Spreadsheet::CChartSpace*)oFile.operator->();
OoxConverter::convert(pChart);
if (pChart)
{
oox_current_chart = pChart;
odf_context()->start_chart();
odf_context()->chart_context()->set_size_chart(width, height);
OoxConverter::convert(&pChart->m_oChartSpace);
odf_context()->end_chart();
oox_current_chart = NULL; // object???
}
}
}
//
......
......@@ -2,6 +2,6 @@
//1
//2
//0
//37
#define INTVER 1,2,0,37
#define STRVER "1,2,0,37\0"
//38
#define INTVER 1,2,0,38
#define STRVER "1,2,0,38\0"
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