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

(1.2.0.109): ASCOfficeOdfFileW

небольшой рефакторинг+оптимизация

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@57567 954022d7-b5bf-4e40-9824-e11837661b57
parent 6f9b1c58
......@@ -8,14 +8,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OdfFormat", "source\OdfForm
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Oox2OdfConverter", "source\Oox2OdfConverter.vcproj", "{BEE01B53-244A-44E6-8947-ED9342D9247E}"
ProjectSection(ProjectDependencies) = postProject
{E5A67556-44DA-4481-8F87-0A3AEDBD20DD} = {E5A67556-44DA-4481-8F87-0A3AEDBD20DD}
{A100103A-353E-45E8-A9B8-90B87CC5C0B0} = {A100103A-353E-45E8-A9B8-90B87CC5C0B0}
{E5A67556-44DA-4481-8F87-0A3AEDBD20DD} = {E5A67556-44DA-4481-8F87-0A3AEDBD20DD}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ASCOfficeOdfFileWTest", "ASCOfficeOdfFileWTest\ASCOfficeOdfFileWTest.vcproj", "{FBA8446A-150F-4A10-B4DA-1022048D6473}"
ProjectSection(ProjectDependencies) = postProject
{6258296E-ABCE-4BC6-9F4A-8522CD615603} = {6258296E-ABCE-4BC6-9F4A-8522CD615603}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpformulasconvert", "..\ASCOfficeOdfFile\formulasconvert\formulasconvert.vcproj", "{94954A67-A853-43B1-A727-6EF2774C5A6A}"
EndProject
......
......@@ -203,7 +203,7 @@ void odf_chart_context::start_chart(office_element_ptr & root)
//////////
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();
office_element_ptr & style_elm = impl_->styles_context_->last_state()->get_office_element();
int level = impl_->current_level_.size();
std::wstring style_name;
......@@ -480,7 +480,7 @@ void odf_chart_context::start_series(std::wstring type)
//////////
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();
office_element_ptr & style_elm = impl_->styles_context_->last_state()->get_office_element();
std::wstring style_name;
......@@ -663,7 +663,7 @@ void odf_chart_context::start_axis()
//////////
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();
office_element_ptr & style_elm = impl_->styles_context_->last_state()->get_office_element();
std::wstring style_name;
......@@ -693,7 +693,7 @@ void odf_chart_context::start_grid(int type)
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();
office_element_ptr & style_elm = impl_->styles_context_->last_state()->get_office_element();
std::wstring style_name;
......@@ -717,7 +717,7 @@ void odf_chart_context::start_title()
//////////
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();
office_element_ptr & style_elm = impl_->styles_context_->last_state()->get_office_element();
std::wstring style_name;
......@@ -741,7 +741,7 @@ void odf_chart_context::start_plot_area()
//////////
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();
office_element_ptr & style_elm = impl_->styles_context_->last_state()->get_office_element();
std::wstring style_name;
......@@ -819,7 +819,7 @@ void odf_chart_context::start_floor()
//////////
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();
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());
......@@ -844,7 +844,7 @@ void odf_chart_context::start_wall()
//////////
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();
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());
......@@ -871,7 +871,7 @@ void odf_chart_context::start_legend()
//////////
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();
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());
......@@ -891,7 +891,7 @@ void odf_chart_context::start_stock_range_line()
//////////
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();
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());
......@@ -914,7 +914,7 @@ void odf_chart_context::start_stock_gain_marker()
//////////
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();
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());
......@@ -937,7 +937,7 @@ void odf_chart_context::start_stock_loss_marker()
//////////
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();
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());
......@@ -992,7 +992,7 @@ void odf_chart_context::start_data_point_series(int count)
//////////
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();
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());
......
......@@ -493,7 +493,7 @@ void odf_drawing_context::Impl::create_draw_base(int type)
//////////
styles_context_->create_style(L"",style_family::Graphic, true, false, -1);
office_element_ptr & style_shape_elm = styles_context_->last_state().get_office_element();
office_element_ptr & style_shape_elm = styles_context_->last_state()->get_office_element();
std::wstring style_name;
style* style_ = dynamic_cast<style*>(style_shape_elm.get());
......@@ -1207,7 +1207,7 @@ void odf_drawing_context::set_textarea_writing_mode(int mode)
{
impl_->styles_context_->create_style(L"",style_family::Paragraph, true, false, -1);
office_element_ptr & style_shape_elm = impl_->styles_context_->last_state().get_office_element();
office_element_ptr & style_shape_elm = impl_->styles_context_->last_state()->get_office_element();
style_ = dynamic_cast<style*>(style_shape_elm.get());
if (style_)
draw->common_draw_attlists_.shape_with_text_and_styles_.common_draw_text_style_name_attlist_.draw_text_style_name_ = style_->style_name_;
......@@ -1428,7 +1428,7 @@ void odf_drawing_context::end_gradient_style()
}
void odf_drawing_context::set_gradient_type(int type)
{
draw_gradient * gradient = dynamic_cast<draw_gradient *>(impl_->styles_context_->last_state().get_office_element().get());
draw_gradient * gradient = dynamic_cast<draw_gradient *>(impl_->styles_context_->last_state()->get_office_element().get());
if (!gradient) return;
switch(type)
......@@ -1441,7 +1441,7 @@ void odf_drawing_context::set_gradient_type(int type)
}
void odf_drawing_context::set_gradient_start(std::wstring hexColor, _CP_OPT(double) & intensiv)
{
draw_gradient * gradient = dynamic_cast<draw_gradient *>(impl_->styles_context_->last_state().get_office_element().get());
draw_gradient * gradient = dynamic_cast<draw_gradient *>(impl_->styles_context_->last_state()->get_office_element().get());
if (!gradient) return;
gradient->draw_start_color_ = color(std::wstring(L"#") + hexColor);
......@@ -1449,7 +1449,7 @@ void odf_drawing_context::set_gradient_start(std::wstring hexColor, _CP_OPT(doub
}
void odf_drawing_context::set_gradient_end (std::wstring hexColor, _CP_OPT(double) & intensiv)
{
draw_gradient * gradient = dynamic_cast<draw_gradient *>(impl_->styles_context_->last_state().get_office_element().get());
draw_gradient * gradient = dynamic_cast<draw_gradient *>(impl_->styles_context_->last_state()->get_office_element().get());
if (!gradient) return;
gradient->draw_end_color_ = color(std::wstring(L"#") + hexColor);
......@@ -1457,7 +1457,7 @@ void odf_drawing_context::set_gradient_end (std::wstring hexColor, _CP_OPT(doub
}
void odf_drawing_context::set_gradient_center(double x, double y)
{
draw_gradient * gradient = dynamic_cast<draw_gradient *>(impl_->styles_context_->last_state().get_office_element().get());
draw_gradient * gradient = dynamic_cast<draw_gradient *>(impl_->styles_context_->last_state()->get_office_element().get());
if (!gradient) return;
gradient->draw_cy_ = percent(x);
......@@ -1465,7 +1465,7 @@ void odf_drawing_context::set_gradient_center(double x, double y)
}
void odf_drawing_context::set_gradient_rect(double l, double t, double r,double b)
{
draw_gradient * gradient = dynamic_cast<draw_gradient *>(impl_->styles_context_->last_state().get_office_element().get());
draw_gradient * gradient = dynamic_cast<draw_gradient *>(impl_->styles_context_->last_state()->get_office_element().get());
if (!gradient) return;
gradient->draw_cy_ = percent((b-t)/2. + 50.);
......@@ -1500,7 +1500,7 @@ void odf_drawing_context::set_opacity(_CP_OPT(double) & start, _CP_OPT(double) &
opacity->draw_start_ = *start;
opacity->draw_end_ = *end;
draw_gradient * gradient = dynamic_cast<draw_gradient *>(impl_->styles_context_->last_state().get_office_element().get());
draw_gradient * gradient = dynamic_cast<draw_gradient *>(impl_->styles_context_->last_state()->get_office_element().get());
if (gradient)
{
opacity->draw_style_ = gradient->draw_style_;
......@@ -1513,7 +1513,7 @@ void odf_drawing_context::set_opacity(_CP_OPT(double) & start, _CP_OPT(double) &
}
void odf_drawing_context::set_gradient_angle(double angle)
{
draw_gradient * gradient = dynamic_cast<draw_gradient *>(impl_->styles_context_->last_state().get_office_element().get());
draw_gradient * gradient = dynamic_cast<draw_gradient *>(impl_->styles_context_->last_state()->get_office_element().get());
if (!gradient) return;
gradient->draw_angle_ = (int)((360 - angle)/180. * 3.14159265358979323846);
......@@ -1541,7 +1541,7 @@ void odf_drawing_context::set_hatch_line_color(std::wstring hexColor)
//impl_->current_graphic_properties->content().svg_stroke_color_ = color(std::wstring(L"#") + hexColor);
//impl_->current_graphic_properties->content().draw_stroke_=line_style(line_style::Solid);//default
draw_hatch * hatch = dynamic_cast<draw_hatch *>(impl_->styles_context_->last_state().get_office_element().get());
draw_hatch * hatch = dynamic_cast<draw_hatch *>(impl_->styles_context_->last_state()->get_office_element().get());
if (!hatch) return;
hatch->draw_color_ = color(std::wstring(L"#") + hexColor);
......@@ -1556,7 +1556,7 @@ void odf_drawing_context::set_hatch_area_color(std::wstring hexColor)
}
void odf_drawing_context::set_hatch_type(int type)
{
draw_hatch * hatch = dynamic_cast<draw_hatch *>(impl_->styles_context_->last_state().get_office_element().get());
draw_hatch * hatch = dynamic_cast<draw_hatch *>(impl_->styles_context_->last_state()->get_office_element().get());
if (!hatch) return;
switch(type)
......@@ -1917,7 +1917,7 @@ void odf_drawing_context::set_bitmap_link(std::wstring link)
impl_->odf_context_->mediaitems()->add_or_find(link,_mediaitems::typeImage,odf_ref_name);
draw_fill_image * fill_image = dynamic_cast<draw_fill_image *>(impl_->styles_context_->last_state().get_office_element().get());
draw_fill_image * fill_image = dynamic_cast<draw_fill_image *>(impl_->styles_context_->last_state()->get_office_element().get());
if (!fill_image) return;
fill_image->xlink_attlist_.href_= odf_ref_name;
......
......@@ -21,13 +21,12 @@ odf_page_layout_context::odf_page_layout_context(odf_conversion_context * Contex
odf_context_ = Context;
style_context_ = Context->styles_context();
local_style_context_ = new odf_style_context();
local_style_context_ = boost::shared_ptr<odf_style_context>(new odf_style_context());
local_style_context_->set_odf_context(odf_context_);
}
odf_page_layout_context::~odf_page_layout_context()
{
delete local_style_context_;
}
......
......@@ -5,12 +5,15 @@
#include "odf_page_layout_state.h"
#include "length.h"
namespace cpdoccore {
namespace odf {
class odf_style_context;
class odf_conversion_context;
class odf_style_context;
typedef shared_ptr<odf_style_context>::Type odf_style_context_ptr;
class office_element;
typedef shared_ptr<office_element>::Type office_element_ptr;
......@@ -36,8 +39,8 @@ public:
odf_layout_state & last_layout();
odf_master_state & last_master();
odf_style_context *get_local_styles_context() //
{return local_style_context_;}
odf_style_context* get_local_styles_context() //
{return local_style_context_.get();}
void set_page_margin(_CP_OPT(double) top, _CP_OPT(double) left, _CP_OPT(double) bottom, _CP_OPT(double) right, _CP_OPT(double) header, _CP_OPT(double) footer);
void set_page_margin(_CP_OPT(length) top, _CP_OPT(length) left, _CP_OPT(length) bottom, _CP_OPT(length) right);
......@@ -59,7 +62,7 @@ private:
odf_conversion_context * odf_context_;
odf_style_context * style_context_;
odf_style_context * local_style_context_;
odf_style_context_ptr local_style_context_;
std::vector<odf_layout_state> layout_state_list_;
std::vector<odf_master_state> master_state_list_;
......
......@@ -27,40 +27,39 @@ public:
odf_style_context();
void set_odf_context(odf_conversion_context * Context);
void create_style(std::wstring name, const style_family style_family, bool automatic = false, bool root = false, int oox_id = -1);
void create_default_style(const style_family style_family);
void create_style(std::wstring name, style_family::type family, bool automatic = false, bool root = false, int oox_id = -1);
void create_default_style(style_family::type family);
void add_style(office_element_ptr elm, bool automatic = false, bool root = false, style_family style_family=style_family::None);
void add_style(office_element_ptr elm, bool automatic = false, bool root = false, style_family::type family=style_family::None);
office_element_ptr & add_or_find(std::wstring name, const style_family family, bool automatic = false, bool root = false, int id = -1);
office_element_ptr & add_or_find(std::wstring name, style_family::type family, bool automatic = false, bool root = false, int id = -1);
void process_automatic_for_styles(office_element_ptr root );
void process_automatic(office_element_ptr root );
void process_office(office_element_ptr root );
void reset_defaults();
void add_default(odf_style_state & state) {current_default_styles_.push_back(state);}
void add_default(odf_style_state_ptr & state) {current_default_styles_.push_back(state);}
std::wstring find_odf_style_name (int oox_id_style, const style_family family, bool root = false);
office_element_ptr find_odf_style (int oox_id_style, const style_family family, bool root = false);
std::wstring find_odf_style_name (int oox_id_style, style_family::type family, bool root = false);
office_element_ptr find_odf_style (int oox_id_style, style_family::type family, bool root = false);
std::wstring find_odf_style_name_default (const style_family family);
office_element_ptr find_odf_style_default (const style_family family);
std::wstring find_odf_style_name_default (style_family::type family);
office_element_ptr find_odf_style_default (style_family::type family);
std::wstring find_conditional_style_name (int oox_id_style, const style_family family);
office_element_ptr find_conditional_style (int oox_id_style, const style_family family);
std::wstring find_conditional_style_name (int oox_id_style, style_family::type family);
office_element_ptr find_conditional_style (int oox_id_style, style_family::type family);
bool find_odf_style_state(int oox_id_style, const style_family family, odf_style_state *& state, bool root = false);
bool find_odf_style_state(int oox_id_style, style_family::type family, odf_style_state_ptr & state, bool root = false);
bool find_odf_style(std::wstring style_name, style_family::type family, style *& style_);
odf_style_state & last_state();
odf_style_state * last_state(style_family family);
odf_style_state_ptr last_state(style_family::type family = style_family::None);
odf_number_styles_context & numbers_styles() {return number_styles_context_;}
odf_table_styles_context & table_styles() {return table_styles_context_;}
std::wstring find_free_name(const style_family family);
std::wstring find_free_name(style_family::type family);
//////////////////////////////////////////////////////////////////////
void calc_paragraph_properties(std::wstring style_name, style_family::type family, paragraph_format_properties * result);
......@@ -70,12 +69,11 @@ private:
odf_number_styles_context number_styles_context_;
odf_conversion_context * odf_context_;
std::vector<odf_style_state> style_state_list_;
std::vector<odf_style_state> current_default_styles_;// ..
std::vector<odf_style_state_ptr> style_state_list_;
std::vector<odf_style_state_ptr> current_default_styles_;// ..
std::wstring get_name_family(const style_family & family);
std::wstring get_name_family(style_family::type family);
};
......
......@@ -9,29 +9,29 @@
namespace cpdoccore {
namespace odf {
odf_style_state::odf_style_state(office_element_ptr & elm, const style_family family )
odf_style_state::odf_style_state(office_element_ptr & elm, style_family::type family )
{
odf_style_ = elm;
automatic_ = false;
default_ = false;
conditional_ = false;
automatic_ = false;
default_ = false;
conditional_ = false;
num_fmt_id_ =0;
style_family_ = family;
num_fmt_id_ = 0;
style_family_ = family;
writable_ = true;
writable_ = true;
style* style_ = dynamic_cast<style*>(elm.get());
if (style_)
{
style_->style_family_ = style_family_;
style_->style_family_ = style_family(style_family_);
}
default_style* default_style_ = dynamic_cast<default_style*>(elm.get());
if (default_style_)
{
default_style_->style_family_ = style_family_;
default_style_->style_family_ = style_family(style_family_);
}
}
......@@ -64,15 +64,13 @@ void odf_style_state::set_display_name(std::wstring & name)
std::wstring odf_style_state::get_name()
{
style* style_ = dynamic_cast<style*>(odf_style_.get());
if (!style_)return L"";
if (!style_)
return L"";
return style_->style_name_;
}
style_family & odf_style_state::get_family()
style_family::type odf_style_state::get_family_type()
{
style* style_ = dynamic_cast<style*>(odf_style_.get());
if (!style_)return style_family(style_family::None);
return style_family_;
}
void odf_style_state::set_parent_style_name(std::wstring & name)
......
......@@ -26,11 +26,13 @@ class style_table_column_properties;
class style_chart_properties;
//class style_drawing_page_properties;
class odf_style_state;
typedef shared_ptr<odf_style_state>::Type odf_style_state_ptr;
class odf_style_state
{
public:
odf_style_state(office_element_ptr & elm, const style_family style_family );
odf_style_state(office_element_ptr & elm, const style_family::type family );
void set_automatic(bool val);
void set_root(bool val);
......@@ -48,7 +50,7 @@ public:
void set_name(std::wstring & name);
std::wstring get_name();
style_family & get_family();
style_family::type get_family_type();
void set_number_format(int id) {num_fmt_id_ = id;}
int get_number_format() {return num_fmt_id_;}
......@@ -84,7 +86,7 @@ private:
bool writable_;
style_family style_family_;
style_family::type style_family_;
office_element_ptr odf_style_;
......
......@@ -114,7 +114,7 @@ void odf_table_context::start_table(office_element_ptr &elm, bool styled)
if (styled)
{
odf_style_state * style_state = impl_->styles_context()->last_state(style_family::Table);
odf_style_state_ptr style_state = impl_->styles_context()->last_state(style_family::Table);
if (style_state)
{
state.table.style_elm = style_state->get_office_element();
......@@ -163,7 +163,7 @@ void odf_table_context::start_row(office_element_ptr &elm, bool styled)
state.elm = elm;
if (styled)
{
odf_style_state * style_state = impl_->styles_context()->last_state(style_family::TableRow);
odf_style_state_ptr style_state = impl_->styles_context()->last_state(style_family::TableRow);
if (style_state)
{
state.style_elm = style_state->get_office_element();
......@@ -207,7 +207,7 @@ void odf_table_context::add_column(office_element_ptr &elm, bool styled)
state.elm = elm;
if (styled)
{
odf_style_state * style_state = impl_->styles_context()->last_state(style_family::TableColumn);
odf_style_state_ptr style_state = impl_->styles_context()->last_state(style_family::TableColumn);
if (style_state)
{
state.style_elm = style_state->get_office_element();
......@@ -301,7 +301,7 @@ void odf_table_context::start_cell(office_element_ptr &elm, bool styled)
state.elm = elm;
if (styled && cell)
{
odf_style_state * style_state = impl_->styles_context()->last_state(style_family::TableCell);
odf_style_state_ptr style_state = impl_->styles_context()->last_state(style_family::TableCell);
if (style_state)
{
state.style_elm = style_state->get_office_element();
......
......@@ -171,7 +171,7 @@ void odf_text_context::start_paragraph(office_element_ptr & elm, bool styled)
if (styled)
{
odf_style_state *style_state = styles_context_->last_state(style_family::Paragraph);
odf_style_state_ptr style_state = styles_context_->last_state(style_family::Paragraph);
if (style_state)
{
......@@ -256,7 +256,7 @@ void odf_text_context::start_span(bool styled)
if (styled)
{
odf_style_state *style_state = styles_context_->last_state(style_family::Text);
odf_style_state_ptr style_state = styles_context_->last_state(style_family::Text);
if (style_state)
{
......
......@@ -37,7 +37,7 @@ void calculate_size_font_symbols(_font_metrix & metrix)
}
}
ods_conversion_context::ods_conversion_context(package::odf_document * outputDocument)
: odf_conversion_context(outputDocument), table_context_(*this), current_text_context_(NULL), page_layout_context_(this)
: odf_conversion_context(outputDocument), table_context_(*this), current_text_context_(NULL)
{
font_metrix_ = _font_metrix();
}
......@@ -155,7 +155,7 @@ void ods_conversion_context::start_row(int _start_row, int repeated, int level,
else
{
styles_context()->create_style(L"",style_family::TableRow, true, false, -1);
style_elm = styles_context()->last_state().get_office_element();
style_elm = styles_context()->last_state()->get_office_element();
style* _style = dynamic_cast<style*>(style_elm.get());
if (!_style)return;
......@@ -276,7 +276,7 @@ void ods_conversion_context::start_cell(std::wstring & ref, int xfd_style)
if ( xfd_style >=0)
{
odf_style_state *style_state=NULL;
odf_style_state_ptr style_state;
styles_context()->find_odf_style_state(xfd_style, style_family::TableCell,style_state);
if (style_state)
{
......@@ -375,7 +375,7 @@ void ods_conversion_context::add_column(int start_column, int repeated, int leve
// .. - , .
// 2 ( , )
styles_context()->create_style(L"",style_family::TableColumn, true, false, -1);
style_elm = styles_context()->last_state().get_office_element();
style_elm = styles_context()->last_state()->get_office_element();
style* _style = dynamic_cast<style*>(style_elm.get());
if (!_style)return;
......
......@@ -86,7 +86,6 @@ public:
private:
_font_metrix font_metrix_;
ods_table_context table_context_;
odf_page_layout_context page_layout_context_;
odf_text_context* current_text_context_;
office_spreadsheet* root_spreadsheet_;
......
......@@ -36,7 +36,7 @@ double calculate_size_font_symbols(std::wstring str_test, std::wstring font_name
}
}
odt_conversion_context::odt_conversion_context(package::odf_document * outputDocument)
: odf_conversion_context(outputDocument),comment_context_(this), page_layout_context_(this), main_text_context_(NULL),table_context_(this)
: odf_conversion_context(outputDocument),comment_context_(this), main_text_context_(NULL),table_context_(this)
{
current_field_.enabled = false;
current_field_.started = false;
......@@ -229,11 +229,15 @@ void odt_conversion_context::add_page_break()
//styles_context()->last_state().apply_from(style_);
if (style_ )
{
style_paragraph_properties * new_props = styles_context()->last_state().get_paragraph_properties();
if (new_props)new_props->apply_from(style_->style_content_.get_style_paragraph_properties());
if (style_->style_parent_style_name_)
styles_context()->last_state().set_parent_style_name(*style_->style_parent_style_name_);
style_paragraph_properties * new_props = NULL;
if (styles_context()->last_state())
{
new_props = styles_context()->last_state()->get_paragraph_properties();
if (new_props)new_props->apply_from(style_->style_content_.get_style_paragraph_properties());
if (style_->style_parent_style_name_)
styles_context()->last_state()->set_parent_style_name(*style_->style_parent_style_name_);
}
}
start_paragraph(true);
}
......@@ -317,8 +321,8 @@ void odt_conversion_context::add_section(bool continuous)
styles_context()->create_style(L"",odf::style_family::Section, true, false, -1);
create_element(L"text", L"section",state.elm,this);
state.style_elm = styles_context()->last_state().get_office_element();
state.style_name = styles_context()->last_state().get_name();
state.style_elm = styles_context()->last_state()->get_office_element();
state.style_name = styles_context()->last_state()->get_name();
text_section* section = dynamic_cast<text_section*>(state.elm.get());
if (section)section->text_section_attr_.text_style_name_ = style_ref(state.style_name);
......@@ -564,7 +568,7 @@ void odt_conversion_context::start_table(bool styled)
std::wstring style_name;
if (styled)
{
odf_style_state * style_state = styles_context()->last_state(style_family::Table);
odf_style_state_ptr style_state = styles_context()->last_state(style_family::Table);
if (style_state)
{
style_elm = style_state->get_office_element();
......
......@@ -109,7 +109,6 @@ private:
odf_text_context* main_text_context_;
odf_page_layout_context page_layout_context_;
odf_table_context table_context_;
odf_comment_context comment_context_;
......
......@@ -1006,7 +1006,7 @@ void OoxConverter::convert(OOX::Drawing::CRun *oox_run)
if (!text_properties)
{
odf_context()->styles_context()->create_style(L"",odf::style_family::Text, true, false, -1);
text_properties = odf_context()->styles_context()->last_state().get_text_properties();
text_properties = odf_context()->styles_context()->last_state()->get_text_properties();
styled = true;
}
convert(oox_run->m_oRunProperty.GetPointer(), text_properties);
......@@ -1114,7 +1114,7 @@ void OoxConverter::convert(OOX::Drawing::CParagraph *oox_paragraph)
if (!paragraph_properties)
{
odf_context()->styles_context()->create_style(L"",odf::style_family::Paragraph, true, false, -1);
paragraph_properties = odf_context()->styles_context()->last_state().get_paragraph_properties();
paragraph_properties = odf_context()->styles_context()->last_state()->get_paragraph_properties();
styled = true;
}
convert(oox_paragraph->m_oParagraphProperty.GetPointer(), paragraph_properties);
......
......@@ -501,7 +501,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CRPr *oox_run_pr)
ods_context->styles_context()->create_style(L"",odf::style_family::Text, automatic, root, -1);
odf::style_text_properties * text_properties = ods_context->styles_context()->last_state().get_text_properties();
odf::style_text_properties * text_properties = ods_context->styles_context()->last_state()->get_text_properties();
if (text_properties == NULL)return;
if (oox_run_pr->m_oBold.IsInit())
......@@ -789,16 +789,15 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetFormatPr *oox_sheet_format_p
//nullable<SimpleTypes::COnOff<>> m_oZeroHeight;
// :(
//Cell default////////////////////////////
odf::odf_style_state *default_cell_style=NULL;
odf::odf_style_state_ptr default_cell_style;
ods_context->styles_context()->find_odf_style_state(0,odf::style_family::TableCell, default_cell_style, true);
if (default_cell_style)
ods_context->styles_context()->add_default(*default_cell_style);
if (default_cell_style) ods_context->styles_context()->add_default(default_cell_style);
///Column///////////////////////////////////////////////////////////////////////////////////////
ods_context->styles_context()->create_style(L"",odf::style_family::TableColumn, true, false, -1);
{
double width = 8.1; // MS Office 2010
// xlsx () - . oo -
odf::style* style = dynamic_cast<odf::style*>(ods_context->styles_context()->last_state().get_office_element().get());
odf::style* style = dynamic_cast<odf::style*>(ods_context->styles_context()->last_state()->get_office_element().get());
if (style)
{
odf::style_table_column_properties * column_properties = style->style_content_.get_style_table_column_properties();
......@@ -819,7 +818,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetFormatPr *oox_sheet_format_p
//Row default //////////////////////////////////////////////////////////////////////////////////////////////////////////////
{
ods_context->styles_context()->create_style(L"",odf::style_family::TableRow, true, false, -1);
odf::style* style = dynamic_cast<odf::style*>(ods_context->styles_context()->last_state().get_office_element().get());
odf::style* style = dynamic_cast<odf::style*>(ods_context->styles_context()->last_state()->get_office_element().get());
if (style)
{
odf::style_table_row_properties * row_properties = style->style_content_.get_style_table_row_properties();
......@@ -1093,7 +1092,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CAligment *aligment, odf::style_pa
}
if (aligment->m_oShrinkToFit.IsInit())
{
cell_properties->style_table_cell_properties_attlist_.style_shrink_to_fit_ = aligment->m_oShrinkToFit->GetValue();
cell_properties->style_table_cell_properties_attlist_.style_shrink_to_fit_ = aligment->m_oShrinkToFit->ToBool();
}
if (aligment->m_oIndent.IsInit())
{
......@@ -1309,12 +1308,12 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCellStyle * cell_style, int oox_i
ods_context->styles_context()->create_style(style_name,odf::style_family::TableCell, automatic, root, oox_id);
if (style_name.length() > 0)ods_context->styles_context()->last_state().set_display_name(style_name);
if (style_name.length() > 0)ods_context->styles_context()->last_state()->set_display_name(style_name);
int parent_id = cell_style->m_oXfId.IsInit() ? cell_style->m_oXfId->GetValue() : -1;
if (parent_id >=0)
ods_context->styles_context()->last_state().set_parent_style_name(ods_context->styles_context()->find_odf_style_name(parent_id, odf::style_family::TableCell,true));
ods_context->styles_context()->last_state()->set_parent_style_name(ods_context->styles_context()->find_odf_style_name(parent_id, odf::style_family::TableCell,true));
//m_oBuiltinId, m_oCustomBuiltin, m_oHidden, m_oILevel; ???????
}
......@@ -1322,10 +1321,10 @@ void XlsxConverter::convert(OOX::Spreadsheet::CDxf *dxFmt, int oox_id)
{
if (!dxFmt)return;
ods_context->styles_context()->create_style(L"",odf::style_family::TableCell, false, true, oox_id);
ods_context->styles_context()->last_state().set_conditional(true);
ods_context->styles_context()->last_state()->set_conditional(true);
odf::style_text_properties * text_properties = ods_context->styles_context()->last_state().get_text_properties();
odf::style_table_cell_properties * table_cell_properties = ods_context->styles_context()->last_state().get_table_cell_properties();
odf::style_text_properties * text_properties = ods_context->styles_context()->last_state()->get_text_properties();
odf::style_table_cell_properties * table_cell_properties = ods_context->styles_context()->last_state()->get_table_cell_properties();
convert(dxFmt->m_oBorder.GetPointer(), table_cell_properties);
convert(dxFmt->m_oFill.GetPointer(), table_cell_properties);
......@@ -1336,13 +1335,13 @@ void XlsxConverter::convert(OOX::Spreadsheet::CDxf *dxFmt, int oox_id)
int numFmt_id = dxFmt->m_oNumFmt->m_oNumFmtId.IsInit() ? dxFmt->m_oNumFmt->m_oNumFmtId->GetValue() : -1;
if (numFmt_id >=0)
{
ods_context->styles_context()->last_state().set_data_style_name(ods_context->numbers_styles_context()->add_or_find(numFmt_id).style_name);
ods_context->styles_context()->last_state().set_number_format(numFmt_id);
ods_context->styles_context()->last_state()->set_data_style_name(ods_context->numbers_styles_context()->add_or_find(numFmt_id).style_name);
ods_context->styles_context()->last_state()->set_number_format(numFmt_id);
}
}
if (dxFmt->m_oAlignment.IsInit())
{
odf::style_paragraph_properties * paragraph_properties = ods_context->styles_context()->last_state().get_paragraph_properties();
odf::style_paragraph_properties * paragraph_properties = ods_context->styles_context()->last_state()->get_paragraph_properties();
paragraph_properties->content().style_writing_mode_ = odf::writing_mode(odf::writing_mode::Page);
convert(dxFmt->m_oAlignment.GetPointer(), paragraph_properties, table_cell_properties);
......@@ -1361,8 +1360,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool
ods_context->styles_context()->create_style(L"",odf::style_family::TableCell, automatic, root, oox_id);
odf::style_text_properties * text_properties = ods_context->styles_context()->last_state().get_text_properties();
odf::style_table_cell_properties * table_cell_properties = ods_context->styles_context()->last_state().get_table_cell_properties();
odf::style_text_properties * text_properties = ods_context->styles_context()->last_state()->get_text_properties();
odf::style_table_cell_properties * table_cell_properties = ods_context->styles_context()->last_state()->get_table_cell_properties();
if (xlsx_styles->m_oFonts.IsInit() && font_id >=0 && (id_parent < 0 || xfc_style->m_oApplyFont.IsInit()))
{
......@@ -1374,15 +1373,15 @@ void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool
}
if (numFmt_id>=0/* && (id_parent < 0 || xfc_style->m_oApplyNumberFormat.IsInit())*/)
{
ods_context->styles_context()->last_state().set_data_style_name(ods_context->numbers_styles_context()->add_or_find(numFmt_id).style_name);
ods_context->styles_context()->last_state().set_number_format(numFmt_id);
ods_context->styles_context()->last_state()->set_data_style_name(ods_context->numbers_styles_context()->add_or_find(numFmt_id).style_name);
ods_context->styles_context()->last_state()->set_number_format(numFmt_id);
}
if (xlsx_styles->m_oBorders.IsInit() && border_id >=0 && (id_parent < 0 || xfc_style->m_oApplyBorder.IsInit()))
{
convert(xlsx_styles->m_oBorders->m_arrItems[border_id], table_cell_properties);
}
odf::style_paragraph_properties * paragraph_properties = ods_context->styles_context()->last_state().get_paragraph_properties();
odf::style_paragraph_properties * paragraph_properties = ods_context->styles_context()->last_state()->get_paragraph_properties();
paragraph_properties->content().style_writing_mode_ = odf::writing_mode(odf::writing_mode::Page);
if (xfc_style->m_oAligment.IsInit() && xfc_style->m_oApplyAlignment.IsInit())
......@@ -1393,16 +1392,16 @@ void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool
if (id_parent >=0)
{
odf::odf_style_state *parent_style_state=NULL;
odf::odf_style_state_ptr parent_style_state;
ods_context->styles_context()->find_odf_style_state(id_parent, odf::style_family::TableCell,parent_style_state, true );
if (parent_style_state)
{
ods_context->styles_context()->last_state().set_parent_style_name(parent_style_state->get_name());
ods_context->styles_context()->last_state()->set_parent_style_name(parent_style_state->get_name());
if (numFmt_id < 0)
{
ods_context->styles_context()->last_state().set_number_format(parent_style_state->get_number_format());
ods_context->styles_context()->last_state()->set_number_format(parent_style_state->get_number_format());
}
}
}
......
......@@ -2,6 +2,6 @@
//1
//2
//0
//108
#define INTVER 1,2,0,108
#define STRVER "1,2,0,108\0"
//109
#define INTVER 1,2,0,109
#define STRVER "1,2,0,109\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