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

.....

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@56081 954022d7-b5bf-4e40-9824-e11837661b57
parent 567b6128
......@@ -1158,6 +1158,14 @@
<Filter
Name="odf common"
>
<File
RelativePath=".\OdfFormat\odf_chart_context.cpp"
>
</File>
<File
RelativePath=".\OdfFormat\odf_chart_context.h"
>
</File>
<File
RelativePath=".\OdfFormat\odf_conversion_context.cpp"
>
......
#include "precompiled_cpodf.h"
#include "logging.h"
#include <boost/foreach.hpp>
#include <iostream>
#include "odf_chart_context.h"
#include "odf_text_context.h"
#include "odf_style_context.h"
#include "odf_drawing_context.h"
#include "odf_conversion_context.h"
#include "office_chart.h"
#include "styles.h"
#include "style_table_properties.h"
#include "style_text_properties.h"
#include "style_paragraph_properties.h"
#include "style_graphic_properties.h"
namespace cpdoccore
{
namespace odf
{
struct odf_element_state
{
office_element_ptr elm;
std::wstring style_name;
office_element_ptr style_elm;
int level;
};
struct odf_chart_state
{
void clear()
{
elements_.clear();
}
std::vector<odf_element_state> elements_;
};
class odf_chart_context::Impl
{
public:
Impl(odf_conversion_context *odf_context) :odf_context_(odf_context), drawing_context_(odf_context), text_context_(odf_context)
{
styles_context_ = NULL;
current_chart_properties = NULL;
}
odf_chart_state current_chart_state_;
std::vector<office_element_ptr> current_level_;//
std::vector<odf_chart_state> chart_list_; // .. ""
odf_style_context *styles_context_;
odf_conversion_context *odf_context_;
odf_drawing_context drawing_context_; //
odf_text_context text_context_;
style_chart_properties *current_chart_properties;
};
////////////////////////////////////////////////////////////////////////////
odf_chart_context::odf_chart_context(odf_conversion_context *odf_context)
: impl_(new odf_chart_context::Impl(odf_context))
{
}
odf_chart_context::~odf_chart_context()
{
}
void odf_chart_context::set_styles_context(odf_style_context * style_context)
{
impl_->styles_context_ = style_context;
impl_->drawing_context_.set_styles_context(style_context);
impl_->text_context_.set_styles_context(style_context);
}
odf_drawing_context * odf_chart_context::drawing_context()
{
return &impl_->drawing_context_;
}
odf_text_context * odf_chart_context::text_context()
{
return &impl_->text_context_;
}
////////////////////////////////////////////////////////////////////////////////////////////////
void odf_chart_context::start_chart(office_element_ptr & root)
{
office_element_ptr chart_elm;
create_element(L"chart", L"chart", chart_elm, impl_->odf_context_);
chart_chart* chart = dynamic_cast<chart_chart*>(chart_elm.get());
if (chart == NULL)return;
root->add_child_element(chart_elm);
//////////
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_;
impl_->current_chart_properties = style_->style_content_.get_style_chart_properties();
chart->chart_chart_attlist_.common_attlist_.chart_style_name_ = style_name;
}
drawing_context()->start_element(chart_elm, style_elm);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int level = impl_->current_level_.size();
if (impl_->current_level_.size()>0)
impl_->current_level_.back()->add_child_element(chart_elm);
impl_->current_level_.push_back(chart_elm);
odf_element_state state={chart_elm, style_name, style_elm, level};
impl_->current_chart_state_.elements_.push_back(state);
}
void odf_chart_context::set_type_chart(int type)
{
}
void odf_chart_context::start_series()
{
}
void odf_chart_context::end_series()
{
}
void odf_chart_context::start_axis()
{
}
void odf_chart_context::end_axis()
{
}
void odf_chart_context::end_chart()
{
if (impl_->current_chart_state_.elements_.size() < 1) return;
///////////////
impl_->chart_list_.push_back(impl_->current_chart_state_);
impl_->current_chart_state_.clear();
impl_->current_chart_properties = NULL;
}
}
}
\ No newline at end of file
#pragma once
#include <string>
#include <vector>
#include <cpdoccore/CPOptional.h>
#include "office_elements.h"
#include "office_elements_create.h"
namespace cpdoccore {
namespace odf
{
class odf_conversion_context;
class odf_style_context;
class odf_text_context;
class odf_drawing_context;
class odf_chart_context
{
public:
odf_chart_context(odf_conversion_context *odf_context);
~odf_chart_context();
void set_styles_context(odf_style_context * style_context);
odf_drawing_context *drawing_context();
odf_text_context *text_context();
void start_chart(office_element_ptr & root);
void set_type_chart(int type);
void start_series();
void end_series();
void start_axis();
void end_axis();
void end_chart();
private:
class Impl;
_CP_PTR(Impl) impl_;
};
}
}
\ No newline at end of file
......@@ -16,7 +16,7 @@ namespace odf {
//////////////////////////////////////////////////////////////////////////////////////////////////
odf_conversion_context::odf_conversion_context(package::odf_document * outputDocument)
odf_conversion_context::odf_conversion_context(package::odf_document * outputDocument) : chart_context_ (this)
{
output_document_ = outputDocument;
......@@ -25,12 +25,15 @@ odf_conversion_context::odf_conversion_context(package::odf_document * outputDoc
odf_style_context* odf_conversion_context::styles_context()
{
return objects_[current_object_].style_context.get();
if (objects_.size() > 0)
return objects_[current_object_].style_context.get();
else
return NULL;
}
odf_number_styles_context* odf_conversion_context::numbers_styles_context()
{
if (objects_[current_object_].style_context)
if (objects_.size() > 0 && objects_[current_object_].style_context)
return &(objects_[current_object_].style_context->numbers_styles());
else return NULL;
}
......@@ -102,6 +105,9 @@ void odf_conversion_context::start_chart()
{
create_object();
create_element(L"office", L"chart", objects_.back().content, this,true);
chart_context_.set_styles_context(styles_context());
chart_context_.start_chart(get_current_object_element());
}
void odf_conversion_context::start_spreadsheet()
{
......@@ -120,10 +126,26 @@ void odf_conversion_context::create_object()
current_object_ = objects_.size()-1;
}
void odf_conversion_context::end_chart()
{
chart_context_.end_chart();
end_object();
}
void odf_conversion_context::end_spreadsheet()
{
end_object();
}
void odf_conversion_context::end_object()
{
current_object_ = 0;
}
office_element_ptr & odf_conversion_context::get_current_object_element()
{
return objects_[current_object_].content;
}
std::wstring odf_conversion_context::get_next_name_object()
{
return std::wstring(L"Object ") + boost::lexical_cast<std::wstring>(objects_.size());
......
#pragma once
#include "object_package.h"
#include "odf_style_context.h"
#include "odf_drawing_context.h"
#include "odf_chart_context.h"
#include "mediaitems.h"
namespace cpdoccore {
......@@ -36,7 +39,6 @@ public:
package::odf_document * output_document_;
std::vector<_object> objects_;//"0" = root
virtual odf_drawing_context * drawing_context() = 0;
virtual odf_text_context * text_context() = 0;
......@@ -46,14 +48,24 @@ public:
_mediaitems * mediaitems();
void start_chart();
void end_chart();
void start_spreadsheet();
void end_spreadsheet();
void create_object();
void end_object();
std::wstring get_next_name_object();
std::wstring get_next_name_object();
office_element_ptr & get_current_object_element();
private:
std::vector<_object> objects_;//"0" = root
odf_chart_context chart_context_;
void process_styles(_object & object, bool isRoot);
int current_object_;
//page_layout_container & pageLayoutContainer() { return page_layout_container_; }
......@@ -62,7 +74,6 @@ private:
//notes_configuration & noteConfiguration() { return notes_configuration_; }
//styles_lite_container & drawStyles() { return draw_style_container_; }
//styles_lite_container & Templates() { return template_container_; }
......@@ -72,7 +83,6 @@ private:
//list_style_container list_style_container_;
//notes_configuration notes_configuration_;
//styles_lite_container draw_style_container_;
//styles_lite_container template_container_;
};
......
......@@ -103,8 +103,8 @@ public:
}
std::vector<odf_drawing_state> drawing_list_;// .. ""
odf_drawing_state current_drawing_state_;
_drawing_part current_drawing_part_;
odf_drawing_state current_drawing_state_;
_drawing_part current_drawing_part_;
std::vector<office_element_ptr> current_level_;//
......@@ -414,17 +414,24 @@ void odf_drawing_context::end_frame()
end_element();
}
/////////////////////
void odf_drawing_context::start_element(office_element_ptr & elm)
void odf_drawing_context::start_element(office_element_ptr & elm, office_element_ptr style_elm)
{
int level = impl_->current_level_.size();
odf_element_state state={elm, L"", office_element_ptr(), level};
impl_->current_drawing_state_.elements_.push_back(state);
if (impl_->current_level_.size()>0)
impl_->current_level_.back()->add_child_element(elm);
std::wstring style_name;
style* style_ = dynamic_cast<style*>(style_elm.get());
if (style_)
{
style_name = style_->style_name_;
impl_->current_graphic_properties = style_->style_content_.get_style_graphic_properties();
}
odf_element_state state={elm, style_name, style_elm, level};
impl_->current_drawing_state_.elements_.push_back(state);
impl_->current_level_.push_back(elm);
}
void odf_drawing_context::end_element()
......
......@@ -46,7 +46,7 @@ public:
void start_object(std::wstring name);
void end_object();
void start_element(office_element_ptr & elm);
void start_element(office_element_ptr & elm, office_element_ptr style_elm = office_element_ptr());
void end_element();
bool is_exist_content();
......
......@@ -16,10 +16,10 @@ namespace cpdoccore {
namespace odf
{
odf_text_context::odf_text_context(odf_style_context * styles_context,odf_conversion_context *odf_context)
odf_text_context::odf_text_context(odf_conversion_context *odf_context)
{
styles_context_ = styles_context;
odf_context_ = odf_context;
styles_context_ = odf_context->styles_context();
last_paragraph_ = NULL;
}
......
......@@ -32,7 +32,7 @@ struct odf_text_state
class odf_text_context: boost::noncopyable
{
public:
odf_text_context(odf_style_context * styles_context_,odf_conversion_context *odf_context);
odf_text_context(odf_conversion_context *odf_context);
~odf_text_context();
public:
void set_styles_context(odf_style_context* styles_context);// embedded
......
......@@ -84,16 +84,18 @@ ods_conversion_context::ods_conversion_context(package::odf_document * outputDoc
void ods_conversion_context::start_document()
{
start_spreadsheet();
current_spreadsheet_ = dynamic_cast<office_spreadsheet*>(objects_.back().content.get());
root_spreadsheet_ = dynamic_cast<office_spreadsheet*>(get_current_object_element().get());
}
void ods_conversion_context::start_sheet(std::wstring & name)
{
create_element(L"table", L"table",current_spreadsheet_->getContent(),this);
table_context_.start_table(current_spreadsheet_->getContent().back(),name);
create_element(L"table", L"table",root_spreadsheet_->getContent(),this);
table_context_.start_table(root_spreadsheet_->getContent().back(),name);
drawing_context()->set_styles_context(styles_context());
}
void ods_conversion_context::set_sheet_dimension(std::wstring & ref)
......@@ -392,7 +394,7 @@ void ods_conversion_context::add_column(int start_column, int repeated, int leve
}
void ods_conversion_context::start_text_context()
{
current_text_context_ = new odf_text_context(styles_context(),this);
current_text_context_ = new odf_text_context(this);
}
void ods_conversion_context::end_text_context()
......
......@@ -61,7 +61,7 @@ private:
ods_table_context table_context_;
odf_text_context* current_text_context_;
office_spreadsheet* current_spreadsheet_;
office_spreadsheet* root_spreadsheet_;
};
......
......@@ -10,7 +10,7 @@
namespace cpdoccore {
namespace odf {
ods_table_context::ods_table_context(ods_conversion_context & Context/*, xlsx_text_context & textCotnext*/): context_(Context)
ods_table_context::ods_table_context(ods_conversion_context & Context): context_(Context)
{
}
......
......@@ -50,7 +50,7 @@ public:
common_draw_size_attlist common_draw_size_attlist_;
common_chart_attlist common_attlist_;
_CP_OPT(std::wstring) chart_class_;
_CP_OPT(std::wstring) chart_class_;
_CP_OPT(std::wstring) chart_column_mapping_;
_CP_OPT(std::wstring) chart_row_mapping_;
};
......
......@@ -2,6 +2,6 @@
//1
//2
//0
//32
#define INTVER 1,2,0,32
#define STRVER "1,2,0,32\0"
//33
#define INTVER 1,2,0,33
#define STRVER "1,2,0,33\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