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

текст в диаграмах

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@56145 954022d7-b5bf-4e40-9824-e11837661b57
parent 56e43e90
......@@ -48,7 +48,7 @@ namespace odf
class odf_chart_context::Impl
{
public:
Impl(odf_conversion_context *odf_context) :odf_context_(odf_context)/*, drawing_context_(odf_context)*/, text_context_(odf_context)
Impl(odf_conversion_context *odf_context) :odf_context_(odf_context)
{
styles_context_ = NULL;
......@@ -62,8 +62,6 @@ public:
odf_style_context *styles_context_;
odf_conversion_context *odf_context_;
odf_text_context text_context_;
style_chart_properties *current_chart_properties;
chart_chart *current_chart_;
};
......@@ -81,8 +79,8 @@ odf_chart_context::~odf_chart_context()
void odf_chart_context::set_styles_context(odf_style_context * style_context)
{
impl_->styles_context_ = style_context;
impl_->odf_context_->drawing_context()->set_styles_context(style_context);
impl_->text_context_.set_styles_context(style_context);
}
odf_drawing_context * odf_chart_context::drawing_context()
......@@ -91,7 +89,7 @@ odf_drawing_context * odf_chart_context::drawing_context()
}
odf_text_context * odf_chart_context::text_context()
{
return &impl_->text_context_;
return impl_->odf_context_->text_context();
}
////////////////////////////////////////////////////////////////////////////////////////////////
void odf_chart_context::start_chart(office_element_ptr & root)
......@@ -140,8 +138,10 @@ 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->chart_three_dimensional_ = Val;
}
void odf_chart_context::start_series()
void odf_chart_context::start_series(std::wstring type)
{
office_element_ptr chart_elm;
create_element(L"chart", L"series", chart_elm, impl_->odf_context_);
......@@ -162,6 +162,7 @@ void odf_chart_context::start_series()
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;
}
start_element(chart_elm, style_elm, style_name);
}
......@@ -237,6 +238,46 @@ void odf_chart_context::start_plot_area()
}
start_element(chart_elm, style_elm, style_name);
}
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_->odf_context_->text_context()->set_single_object(true,para_props,text_props);
}
void odf_chart_context::end_text()
{
odf_text_context * text_context_ = text_context();
if (text_context_ == NULL || impl_->current_level_.size() <1 )return;
for (long i=0; i< text_context_->text_elements_list_.size(); i++)
{
if (text_context_->text_elements_list_[i].level ==0)
{
impl_->current_level_.back()->add_child_element(text_context_->text_elements_list_[i].elm);
}
int level_root = impl_->current_level_.size() + 1;
odf_element_state state={text_context_->text_elements_list_[i].elm,
text_context_->text_elements_list_[i].style_name,
text_context_->text_elements_list_[i].style_elm,
text_context_->text_elements_list_[i].level + level_root};
impl_->current_chart_state_.elements_.push_back(state);
}
impl_->odf_context_->end_text_context();
}
void odf_chart_context::start_legend()
{
......@@ -262,6 +303,70 @@ void odf_chart_context::start_legend()
start_element(chart_elm, style_elm, style_name);
}
void odf_chart_context::set_legend_position(int val)
{
chart_legend *legend = dynamic_cast<chart_legend*>(impl_->current_chart_state_.elements_.back().elm.get());
if (legend == NULL)return;
switch(val)
{
case 0: legend->chart_legend_attlist_.chart_legend_position_ = L"bottom"; break;//st_legendposB
case 1: legend->chart_legend_attlist_.chart_legend_position_ = L"top-end"; break;//st_legendposTR
case 2: legend->chart_legend_attlist_.chart_legend_position_ = L"start"; break;//st_legendposL
case 3: legend->chart_legend_attlist_.chart_legend_position_ = L"end"; break;//st_legendposR
case 4: legend->chart_legend_attlist_.chart_legend_position_ = L"top"; break;//st_legendposT
}
}
void odf_chart_context::set_layout_x(double *val,int mode)//edge, factor
{
if (!val)return;
if (mode == 0) return;
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);
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);
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);
}
void odf_chart_context::set_layout_y(double *val,int mode)
{
if (!val)return;
if (mode == 0) return;
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);
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);
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);
}
void odf_chart_context::set_layout_w(double *val,int mode)
{
if (!val)return;
if (mode == 0) return;
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);
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);
}
void odf_chart_context::set_layout_h(double *val,int mode)
{
if (!val)return;
if (mode == 0) return;
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);
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);
}
void odf_chart_context::start_element(office_element_ptr & elm, office_element_ptr & style_elm, std::wstring style_name)
{
int level = impl_->current_level_.size();
......
......@@ -33,18 +33,27 @@ public:
void set_type_chart(std::wstring type);
void set_3D(bool Val);
void start_series();
void start_series(std::wstring type);
void start_axis();
void start_title();
void start_plot_area();
void start_legend();
void set_legend_position(int val);
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();
void set_layout_x(double *val,int mode);
void set_layout_y(double *val,int mode);
void set_layout_w(double *val,int mode);
void set_layout_h(double *val,int mode);
void end_chart();
private:
......
......@@ -43,6 +43,9 @@ public:
virtual odf_drawing_context * drawing_context() = 0;
virtual odf_text_context * text_context() = 0;
virtual void start_text_context() = 0;
virtual void end_text_context() = 0;
odf_chart_context * chart_context();
odf_style_context * styles_context();
odf_number_styles_context * numbers_styles_context();
......
......@@ -100,6 +100,7 @@ public:
styles_context_ = odf_context_->styles_context();
current_graphic_properties = NULL;
current_paragraph_properties = NULL;
}
std::vector<odf_drawing_state> drawing_list_;// .. ""
......@@ -648,7 +649,7 @@ void odf_drawing_context::set_textarea_writing_mode(int mode)
if (style_)impl_->current_paragraph_properties = style_->style_content_.get_style_paragraph_properties();
}
style_paragraph_properties * paragraph_properties=NULL;
style_paragraph_properties * paragraph_properties = impl_->odf_context_->text_context()->get_paragraph_properties();
draw_base* draw = dynamic_cast<draw_base*>(impl_->current_drawing_state_.elements_[0].elm.get());
if (draw)
{
......@@ -667,7 +668,7 @@ void odf_drawing_context::set_textarea_writing_mode(int mode)
std::wstring style_name = draw->common_draw_attlists_.shape_with_text_and_styles_.common_draw_text_style_name_attlist_.draw_text_style_name_->style_name();
//
}
if (style_)
if (style_ && !paragraph_properties)
{
paragraph_properties = style_->style_content_.get_style_paragraph_properties();
}
......
......@@ -9,6 +9,8 @@
#include "odf_conversion_context.h"
#include "styles.h"
#include "style_text_properties.h"
#include "text_elements.h"
#include "paragraph_elements.h"
......@@ -20,6 +22,10 @@ odf_text_context::odf_text_context(odf_conversion_context *odf_context)
{
odf_context_ = odf_context;
styles_context_ = odf_context->styles_context();
single_paragraph_ = false;
paragraph_properties_ = NULL;
text_properties_ = NULL;
last_paragraph_ = NULL;
}
......@@ -31,6 +37,13 @@ void odf_text_context::set_styles_context(odf_style_context* styles_context)
styles_context_ = styles_context;
}
void odf_text_context::set_single_object(bool val, style_paragraph_properties *para_props, style_text_properties *text_props)
{
single_paragraph_ = val;
paragraph_properties_ = para_props;
text_properties_ = text_props;
}
void odf_text_context::add_text_content(const std::wstring & text)
{
if (current_level_.size() >=0 )
......@@ -50,7 +63,14 @@ void odf_text_context::start_paragraph(bool styled)
void odf_text_context::start_paragraph(office_element_ptr & elm, bool styled)
{
int level = current_level_.size();
if (single_paragraph_ && level >0)
{
std::wstring str_enter(L"\n");
add_text_content(str_enter);
return;
}
std::wstring style_name;
office_element_ptr style_elm;
......@@ -85,7 +105,10 @@ void odf_text_context::start_paragraph(office_element_ptr & elm, bool styled)
void odf_text_context::end_paragraph()
{
current_level_.pop_back();
if (single_paragraph_ == false)
{
current_level_.pop_back();
}
}
void odf_text_context::start_element(office_element_ptr & elm)
......@@ -102,33 +125,36 @@ void odf_text_context::start_element(office_element_ptr & elm)
}
void odf_text_context::end_element()
{
current_level_.pop_back();
if (single_paragraph_ == false)
{
current_level_.pop_back();
}
}
void odf_text_context::start_span(bool styled)
{
if (styles_context_ == NULL)return;
if (styles_context_ == NULL || single_paragraph_)return;
office_element_ptr span_elm;
create_element(L"text", L"span", span_elm, odf_context_);
int level = current_level_.size();
std::wstring style_name;
office_element_ptr style_elm;
if (styled)
{
{
style_name = styles_context_->last_state().get_name();
style_elm = styles_context_->last_state().get_office_element();
style * style_ = dynamic_cast<style*>(style_elm.get());
text_span* span = dynamic_cast<text_span*>(span_elm.get());
if (span) span->text_style_name_ = style_ref(style_name);
if (parent_span_style_.length() >0)
if (parent_span_style_.length() >0 && style_)
{
style *style_ = dynamic_cast<style*>(style_elm.get());
if (style_)style_->style_parent_style_name_ = parent_span_style_;
style_->style_parent_style_name_ = parent_span_style_;
}
}
......@@ -144,6 +170,8 @@ void odf_text_context::start_span(bool styled)
void odf_text_context::end_span()
{
if (single_paragraph_)return;
current_level_.pop_back();
}
......
......@@ -18,6 +18,8 @@ namespace odf
class odf_conversion_context;
class odf_style_context;
class paragraph;
class style_paragraph_properties;
class style_text_properties;
struct odf_text_state
{
......@@ -37,6 +39,7 @@ public:
public:
void set_styles_context(odf_style_context* styles_context);// embedded
void set_single_object(bool val, style_paragraph_properties *para_props, style_text_properties *text_props);
void add_text_content(const std::wstring & text);
void start_paragraph(bool styled = false);
......@@ -55,7 +58,14 @@ public:
void set_parent_paragraph_style (std::wstring & style_name);
void set_parent_span_style (std::wstring & style_name);
style_text_properties *get_text_properties(){return text_properties_;}
style_paragraph_properties *get_paragraph_properties(){return paragraph_properties_;}
private:
bool single_paragraph_;
style_paragraph_properties *paragraph_properties_;//- , ,
style_text_properties *text_properties_;//- , ,
paragraph * last_paragraph_;
odf_style_context * styles_context_;
......
......@@ -60,8 +60,8 @@ public:
///////////////////////////////////////////////////////
ods_table_state & current_table() { return table_context_.state();}
/////////////////////////////////////////////////////
void start_text_context();
void end_text_context();
virtual void start_text_context();
virtual void end_text_context();
virtual odf_drawing_context * drawing_context() {return current_table().drawing_context();}
virtual odf_text_context * text_context() {return current_text_context_;}
......
......@@ -183,13 +183,18 @@ const wchar_t * chart_legend::name = L"legend";
void chart_legend_attlist::serialize(CP_ATTR_NODE)
{
CP_XML_ATTR_OPT(L"chart:legend-position", chart_legend_position_);
CP_XML_ATTR_OPT(L"chart:legend-align", chart_legend_align_);
common_draw_position_attlist_.serialize(CP_GET_XML_NODE());
CP_XML_ATTR_OPT(L"chart:legend-position", chart_legend_position_);
CP_XML_ATTR_OPT(L"chart:legend-align", chart_legend_align_);
CP_XML_ATTR_OPT(L"style:legend-expansion", style_legend_expansion_);
CP_XML_ATTR_OPT(L"style:legend-expansion", style_legend_expansion_);
CP_XML_ATTR_OPT(L"style:legend-expansion-aspect-ratio", style_legend_expansion_aspect_ratio_);
common_attlist_.serialize(CP_GET_XML_NODE());
CP_XML_ATTR_OPT(L"chartooo:height", chartooo_height_);
CP_XML_ATTR_OPT(L"chartooo:width", chartooo_width_);
common_draw_position_attlist_.serialize(CP_GET_XML_NODE());
common_attlist_.serialize(CP_GET_XML_NODE());
}
void chart_legend::serialize(std::wostream & _Wostream)
{
......@@ -208,8 +213,10 @@ void chart_plot_area_attlist::serialize(CP_ATTR_NODE)
{
common_draw_position_attlist_.serialize(CP_GET_XML_NODE());
common_draw_size_attlist_.serialize(CP_GET_XML_NODE());
common_attlist_.serialize(CP_GET_XML_NODE());
CP_XML_ATTR_OPT(L"table:cell-range-address", table_cell_range_address_);
common_attlist_.serialize(CP_GET_XML_NODE());
CP_XML_ATTR_OPT(L"table:cell-range-address", table_cell_range_address_);
CP_XML_ATTR_OPT(L"chart:data-source-has-labels", chart_data_source_has_labels_);
}
......
......@@ -85,7 +85,6 @@ public:
_CP_OPT(std::wstring) table_cell_range_;
common_draw_position_attlist common_draw_position_attlist_;
common_chart_attlist common_attlist_;
};
/// \brief chart:title
......@@ -160,11 +159,14 @@ public:
_CP_OPT(std::wstring) chart_legend_position_;
_CP_OPT(std::wstring) chart_legend_align_;
common_draw_position_attlist common_draw_position_attlist_;
_CP_OPT(std::wstring) style_legend_expansion_;
_CP_OPT(double) style_legend_expansion_aspect_ratio_;
common_chart_attlist common_attlist_;
_CP_OPT(length) chartooo_height_;
_CP_OPT(length) chartooo_width_;
};
/// \brief chart:legend
......@@ -196,10 +198,12 @@ public:
common_draw_position_attlist common_draw_position_attlist_;
common_draw_size_attlist common_draw_size_attlist_;
common_chart_attlist common_attlist_;
common_chart_attlist common_attlist_;
_CP_OPT(std::wstring) table_cell_range_address_;
_CP_OPT(std::wstring) chart_data_source_has_labels_;
// dr3d-scene-attlist
// common-dr3d-transform-attlist
};
......
......@@ -308,7 +308,6 @@ void text_format_properties_content::serialize(std::wostream & _Wostream,const w
const wchar_t * style_text_properties::ns = L"style";
const wchar_t * style_text_properties::name = L"text-properties";
void style_text_properties::create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name)
{
CP_NOT_APPLICABLE_ELM();
......
......@@ -289,7 +289,6 @@ public:
style_text_properties(){};
style_text_properties(const std::wstring & rStyle){ text_format_properties_content_.set_r_style(rStyle); };
private:
text_format_properties_content text_format_properties_content_;
};
......
......@@ -152,6 +152,10 @@
RelativePath=".\Oox2OdfConverter\Converter.cpp"
>
</File>
<File
RelativePath=".\Oox2OdfConverter\ConverterChart.cpp"
>
</File>
<File
RelativePath=".\Oox2OdfConverter\DocxConverter.cpp"
>
......
......@@ -15,6 +15,8 @@ namespace cpdoccore
class odf_conversion_context;
class font_size;
class length_or_percent;
class style_paragraph_properties;
class style_text_properties;
}
}
namespace OOX
......@@ -201,6 +203,8 @@ namespace OOX
class CT_Style1;
class CT_Style;
class CT_TextLanguageID;
class CRichText;
class CTextProperties;
}
}
......@@ -250,14 +254,15 @@ public:
///////////////////////////////
void convert(OOX::Drawing::CParagraph *oox_paragraph);
void convert(OOX::Drawing::CParagraphProperty *oox_paragraph_pr);
void convert(OOX::Drawing::CParagraphProperty *oox_paragraph_pr, cpdoccore::odf::style_paragraph_properties * paragraph_properties);
void convert(OOX::Drawing::CRun *oox_run);
void convert(OOX::Drawing::CRunProperty *oox_run_pr);
void convert(OOX::Drawing::CLineSpacing *oox_spacing, cpdoccore::odf::length_or_percent & length_or_percent);
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_Title *ct_title);
void convert(OOX::Spreadsheet::CT_Legend *ct_legend);
void convert(OOX::Spreadsheet::CT_LegendEntry *ct_legend);
void convert(OOX::Spreadsheet::CT_PlotArea *ct_plotArea);
void convert(OOX::Spreadsheet::CT_Surface *ct_surface, int type);
void convert(OOX::Spreadsheet::CT_CatAx *ct_catAx);
......@@ -290,6 +295,11 @@ public:
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::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(double oox_font_size, cpdoccore::_CP_OPT(cpdoccore::odf::font_size) & odf_font_size);
};
......
This diff is collapsed.
......@@ -10,7 +10,7 @@ namespace OOX
namespace Spreadsheet
{
//--------------------------------------------------------------------------------
// 20.5.2.34 txBody (Shape Text Body)
// 20.5.2.34 txBody (Shape Text Body)
//--------------------------------------------------------------------------------
class CTextBody : public WritingElementWithChilds<Drawing::CParagraph>
{
......
......@@ -314,7 +314,8 @@ namespace Spreadsheet
et_GraphicFrameNonVisual,
et_ConnectionNonVisualGraphicFrameProps,
et_GraphicChart,
et_ChartTextProperties,
et_ChartRichText
};
class WritingElement
......
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