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

(1.2.0.144): ASCOfficeOdfFileW


git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@58059 954022d7-b5bf-4e40-9824-e11837661b57
parent 2ab819f4
......@@ -2,6 +2,6 @@
//1
//0
//1
//207
#define INTVER 1,0,1,207
#define STRVER "1,0,1,207\0"
//208
#define INTVER 1,0,1,208
#define STRVER "1,0,1,208\0"
......@@ -41,7 +41,7 @@ public:
std::wstring target =target1;
int res = target.rfind(L"/");
if (res+1==target.length())
if (res >=0 && res+1==target.length())
{
target.resize(target.length()-1);
}
......
......@@ -5,7 +5,7 @@
// shapetypeDecagon,
// shapetypeDiagStripe,
// shapetypeDodecagon,
// shapetypeDoubleWave,
//+ shapetypeDoubleWave,
// shapetypeFunnel,
// shapetypeGear6,
// shapetypeGear9,
......@@ -232,4 +232,63 @@ public:
/////////////////////////////////////////////////////////
}
};
class oox_shape_DoubleWave : public oox_shape
{
public:
oox_shape_DoubleWave()
{
odf_type_name =L"ooxml-DoubleWave";
modifiers = L"6500 0";
enhanced_path = L"M ?f21 ?f10 C ?f25 ?f12 ?f27 ?f13 ?f28 ?f10 ?f29 ?f12 ?f30 ?f13 ?f23 ?f10 L ?f32 ?f14 C ?f37 ?f16 ?f36 ?f15 ?f35 ?f14 ?f34 ?f16 ?f33 ?f15 ?f31 ?f14 Z N";
text_areas = L"?f39 ?f41 ?f40 ?f42";
glue_points = L"?f35 ?f10 ?f19 ?f6 ?f28 ?f14 ?f38 ?f6";
view_box = L"0 0 21600 21600";
add(L"f0", L"left");
add(L"f1", L"right");
add(L"f2", L"top");
add(L"f3", L"bottom");
add(L"f4", L"?f3 - ?f2");
add(L"f5", L"?f4 / 2");
add(L"f6", L"?f2 + ?f5");
add(L"f7", L"?f1 - ?f0");
add(L"f8", L"$0");
add(L"f9", L"$1");
add(L"f10", L"?f4 * ?f8 / 100000");
add(L"f11", L"?f10 * 10 / 3");
add(L"f12", L"?f10 - ?f11");
add(L"f13", L"?f10 + ?f11");
add(L"f14", L"?f3 - ?f10");
add(L"f15", L"?f14 - ?f11");
add(L"f16", L"?f14 + ?f11");
add(L"f17", L"?f7 * ?f9 / 100000");
add(L"f18", L"?f7 * ?f9 / 50000");
add(L"f19", L"abs(?f17)");
add(L"f20", L"if(?f18, 0, ?f18)");
add(L"f21", L"?f0 - ?f20");
add(L"f22", L"if(?f18, ?f18, 0)");
add(L"f23", L"?f1 - ?f22");
add(L"f24", L"(?f20 + ?f23) / 6");
add(L"f25", L"?f21 + ?f24");
add(L"f26", L"(?f20 + ?f23) / 3");
add(L"f27", L"?f21 + ?f26");
add(L"f28", L"(?f21 + ?f23) / 2");
add(L"f29", L"?f28 + ?f24");
add(L"f30", L"(?f29 + ?f23) / 2");
add(L"f31", L"?f0 + ?f22");
add(L"f32", L"?f1 + ?f20");
add(L"f33", L"?f31 + ?f24");
add(L"f34", L"?f31 + ?f26");
add(L"f35", L"(?f31 + ?f32) / 2");
add(L"f36", L"?f35 + ?f24");
add(L"f37", L"(?f36 + ?f32) / 2");
add(L"f38", L"?f1 - ?f19");
add(L"f39", L"max(?f21, ?f31)");
add(L"f40", L"min(?f23, ?f32)");
add(L"f41", L"?f4 * ?f8 / 50000");
add(L"f42", L"?f3 - ?f41");
/////////////////////////////////////////////////////////
}
};
}
\ No newline at end of file
......@@ -195,6 +195,17 @@ void odf_conversion_context::process_styles(_object & object, bool isRoot)
object.style_context->process_automatic_styles(object.content_styles.back());
}
office_element_ptr odf_conversion_context::start_tabs()
{
return temporary_.elm;
}
void odf_conversion_context::end_tabs()
{
//temporary_.elm = NULL;
//temporary_.style_elm = NULL;
//temporary_.style_name = L"";
}
}
}
......@@ -73,7 +73,13 @@ public:
std::wstring get_next_name_object();
office_element_ptr & get_current_object_element();
office_element_ptr start_tabs();
void end_tabs();
private:
odf_element_state temporary_;
std::vector<_object> objects_;//"0" = root
odf_chart_context chart_context_;
......
......@@ -479,11 +479,15 @@ void odf_drawing_context::end_drawing()
if (draw && !impl_->current_drawing_state_.in_group)
draw->common_draw_attlists_.shape_with_text_and_styles_.common_draw_shape_with_styles_attlist_.common_text_spreadsheet_shape_attlist_.common_text_anchor_attlist_.type_ = impl_->anchor_settings_.anchor_type_;
//if (impl_->current_drawing_state_.in_group == false)
//{
impl_->current_graphic_properties->content().style_wrap_ = impl_->anchor_settings_.style_wrap_;
impl_->current_graphic_properties->content().style_run_through_ = impl_->anchor_settings_.run_through_;
//}
//if (impl_->anchor_settings_.anchor_type_ && impl_->anchor_settings_.anchor_type_->get_type()== anchor_type::AsChar)
//{
// draw->common_draw_attlists_.position_.svg_x_ = boost::none;
// draw->common_draw_attlists_.position_.svg_y_ = boost::none;
//}
///////////////////////////////////////////////////
impl_->drawing_list_.push_back(impl_->current_drawing_state_);
......@@ -660,6 +664,7 @@ void odf_drawing_context::end_shape()
line->draw_line_attlist_.svg_y2_ = impl_->current_drawing_state_.svg_y_.get() + impl_->current_drawing_state_.svg_height_.get();
impl_->current_drawing_state_.svg_height_ = boost::none;
impl_->current_drawing_state_.svg_width_ = boost::none;
}
//////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -903,9 +908,6 @@ void odf_drawing_context::set_solid_fill(std::wstring hexColor)
{
if (!impl_->current_graphic_properties)return;
if (hexColor.length() >0 && hexColor.substr(0,1) == std::wstring(L"#"))
hexColor = hexColor.substr(1,hexColor.length());
switch(impl_->current_drawing_part_)
{
case Area:
......@@ -933,7 +935,7 @@ void odf_drawing_context::set_z_order(int id)
// id += (impl_->current_group_->level+1) *100;
//}
impl_->current_drawing_state_.z_order_ =id;
impl_->current_drawing_state_.z_order_ = id + 1;
}
void odf_drawing_context::set_path(std::wstring path_string)
{
......@@ -1077,7 +1079,7 @@ void odf_drawing_context::set_vertical_rel(int from)
{
case 0: type = vertical_rel::Baseline; break;// relfromvBottomMargin ???
case 1: type = vertical_rel::PageContent; break;// relfromvInsideMargin ???
case 2: type = vertical_rel::Line; break;// relfromvLine
case 2: type = vertical_rel::Baseline; break;// relfromvLine
case 3: type = vertical_rel::PageContent; break;// relfromvMargin
case 4: type = vertical_rel::Baseline; break;// relfromvOutsideMargin ???
case 5: type = vertical_rel::Page; set_anchor(anchor_type::Page); break;// relfromvPage
......@@ -1214,7 +1216,7 @@ void odf_drawing_context::set_group_size( double cx, double cy, double ch_cx, do
else
{
double first_scale_x = impl_->width/ cx;
double first_scale_y = impl_->height/ cx;
double first_scale_y = impl_->height/ cy;
impl_->current_group_->scale_cx *= first_scale_x;
impl_->current_group_->scale_cy *= first_scale_y;
......@@ -1274,33 +1276,27 @@ void odf_drawing_context::set_group_rotate(int iVal)
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void odf_drawing_context::set_position(double x_pt, double y_pt)
void odf_drawing_context::set_position(_CP_OPT(double) & x_pt, _CP_OPT(double) & y_pt)
{
if (impl_->group_list_.size() < 1)return;
//if (impl_->group_list_.size() < 1)return;
if (!impl_->current_drawing_state_.svg_x_ || impl_->current_drawing_state_.in_group)
{
if (impl_->current_drawing_state_.in_group && impl_->current_group_)
{
x_pt *= impl_->current_group_->scale_cx;
x_pt += impl_->current_group_->shift_x ;
if (x_pt) x_pt = *x_pt * impl_->current_group_->scale_cx + impl_->current_group_->shift_x ;
// + (impl_->current_group_->flipH ? (impl_->current_group_->cx - 2 * x_pt): 0);
}
impl_->current_drawing_state_.svg_x_ = length(length(x_pt,length::pt).get_value_unit(length::cm),length::cm);
if (x_pt) impl_->current_drawing_state_.svg_x_ = length(length(*x_pt,length::pt).get_value_unit(length::cm),length::cm);
}
if (!impl_->current_drawing_state_.svg_y_ || impl_->current_drawing_state_.in_group)
{
if (impl_->current_drawing_state_.in_group && impl_->current_group_)
{
y_pt *= impl_->current_group_->scale_cy;
y_pt += impl_->current_group_->shift_y ;
if (y_pt) y_pt = *y_pt * impl_->current_group_->scale_cy + impl_->current_group_->shift_y;
//+ (impl_->current_group_->flipV ? (impl_->current_group_->cy - 2 * y_pt): 0);
}
impl_->current_drawing_state_.svg_y_ = length(length(y_pt,length::pt).get_value_unit(length::cm),length::cm);
if (y_pt) impl_->current_drawing_state_.svg_y_ = length(length(*y_pt,length::pt).get_value_unit(length::cm),length::cm);
}
}
void odf_drawing_context::get_size( double & width_pt, double & height_pt)
......@@ -1317,17 +1313,17 @@ void odf_drawing_context::get_size( double & width_pt, double & height_pt)
}
}
void odf_drawing_context::set_size( double width_pt, double height_pt)
void odf_drawing_context::set_size( _CP_OPT(double) & width_pt, _CP_OPT(double) & height_pt)
{
if (impl_->current_drawing_state_.in_group)
{
width_pt *= impl_->group_list_.back()->scale_cx;
height_pt *= impl_->group_list_.back()->scale_cy;
if (width_pt) width_pt = *width_pt * impl_->group_list_.back()->scale_cx;
if (height_pt)height_pt = *height_pt * impl_->group_list_.back()->scale_cy;
}
//if (!impl_->current_drawing_state_.svg_width_)
if (width_pt >= 0) impl_->current_drawing_state_.svg_width_ = length(length(width_pt,length::pt).get_value_unit(length::cm),length::cm);
if (width_pt) impl_->current_drawing_state_.svg_width_ = length(length(*width_pt,length::pt).get_value_unit(length::cm),length::cm);
//if (!impl_->current_drawing_state_.svg_height_)
if (height_pt >=0) impl_->current_drawing_state_.svg_height_= length(length(height_pt,length::pt).get_value_unit(length::cm),length::cm);
if (height_pt) impl_->current_drawing_state_.svg_height_= length(length(*height_pt,length::pt).get_value_unit(length::cm),length::cm);
}
void odf_drawing_context::set_line_width(double pt)
{
......
......@@ -102,8 +102,8 @@ public:
///////////////////////////////////////////////////////////////////////////////////////
void set_size( double width_pt, double height_pt);
void set_position(double x_pt, double y_pt);
void set_size( _CP_OPT(double) & width_pt, _CP_OPT(double) & height_pt);
void set_position(_CP_OPT(double) & x_pt, _CP_OPT(double) & y_pt);
void get_size( double & width_pt, double & height_pt);
......
......@@ -15,6 +15,9 @@
namespace cpdoccore {
namespace odf {
static int style_family_counts_[26]={};//
void calc_paragraph_properties_content(std::vector<style_paragraph_properties*> & parProps, paragraph_format_properties * result)
{
if (result == NULL)return;
......@@ -28,7 +31,7 @@ void calc_paragraph_properties_content(std::vector<style_paragraph_properties*>
odf_style_context::odf_style_context()
{
memset(style_family_counts_,0,sizeof(style_family_counts_));
//memset(style_family_counts_,0,sizeof(style_family_counts_));
}
void odf_style_context::set_odf_context(odf_conversion_context * Context)
......@@ -137,14 +140,16 @@ void odf_style_context::process_office_styles(office_element_ptr root )
lists_styles_context_.process_styles(root );
}
std::wstring odf_style_context::find_odf_style_name(int oox_id_style, style_family::type family, bool root)
std::wstring odf_style_context::find_odf_style_name(int oox_id_style, style_family::type family, bool root, bool automatic)
{
for (long i =0; i < style_state_list_.size(); i++)
{
if (style_state_list_[i]->odf_style_)
{
if (style_state_list_[i]->get_family_type() == family &&
style_state_list_[i]->root_ == root && style_state_list_[i]->conditional_ == false)
if (style_state_list_[i]->get_family_type() == family &&
style_state_list_[i]->root_ == root &&
style_state_list_[i]->automatic_ == automatic &&
style_state_list_[i]->conditional_ == false)
{
if (oox_id_style >=0 && style_state_list_[i]->style_oox_id_ == oox_id_style)
return style_state_list_[i]->get_name();
......@@ -154,24 +159,26 @@ std::wstring odf_style_context::find_odf_style_name(int oox_id_style, style_fami
}
return L"";
}
office_element_ptr odf_style_context::find_odf_style(int oox_id_style, style_family::type family, bool root)
{
//for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
for (int i=0;i<style_state_list_.size(); i++)
{
if (style_state_list_[i]->odf_style_)
{
if (style_state_list_[i]->get_family_type() == family &&
style_state_list_[i]->root_ == root && style_state_list_[i]->conditional_ == false)
{
if (oox_id_style >=0 && style_state_list_[i]->style_oox_id_ == oox_id_style)
return style_state_list_[i]->get_office_element();
}
}
}
return office_element_ptr();
}
//office_element_ptr odf_style_context::find_odf_style(int oox_id_style, style_family::type family, bool root, _CP_OPT(bool) automatic)
//{
// //for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
// for (int i=0;i<style_state_list_.size(); i++)
// {
// if (style_state_list_[i]->odf_style_)
// {
// if (style_state_list_[i]->get_family_type() == family &&
// style_state_list_[i]->root_ == root &&
// (!automatic || (automatic && style_state_list_[i]->automatic_ == *automatic)) &&
// style_state_list_[i]->conditional_ == false)
// {
// if (oox_id_style >=0 && style_state_list_[i]->style_oox_id_ == oox_id_style)
// return style_state_list_[i]->get_office_element();
// }
//
// }
// }
// return office_element_ptr();
//}
std::wstring odf_style_context::find_conditional_style_name(int oox_id_style, style_family::type family)
{
for (long i =0; i < style_state_list_.size(); i++)
......@@ -206,14 +213,17 @@ office_element_ptr odf_style_context::find_conditional_style(int oox_id_style, s
}
return office_element_ptr();
}
bool odf_style_context::find_odf_style_state(int oox_id_style, style_family::type family, odf_style_state_ptr & state, bool root)
bool odf_style_context::find_odf_style_state(int oox_id_style, style_family::type family, odf_style_state_ptr & state, bool root, bool automatic)
{
for (int i=0;i<style_state_list_.size(); i++)
{
if (style_state_list_[i]->odf_style_)
{
if (style_state_list_[i]->get_family_type() == family &&
style_state_list_[i]->root_ == root && style_state_list_[i]->conditional_ == false && style_state_list_[i]->default_ == false)
if (style_state_list_[i]->get_family_type() == family &&
style_state_list_[i]->root_ == root &&
style_state_list_[i]->automatic_ == automatic &&
style_state_list_[i]->conditional_ == false &&
style_state_list_[i]->default_ == false)
{
if (oox_id_style >=0 && style_state_list_[i]->style_oox_id_ == oox_id_style)
{
......@@ -316,6 +326,8 @@ std::wstring odf_style_context::get_name_family(style_family::type family)
}
return L"UnknownStyle";
}
std::wstring odf_style_context::find_free_name(style_family::type family)
{
std::wstring name = get_name_family(family);
......
......@@ -41,9 +41,6 @@ public:
void reset_defaults();
void add_default(odf_style_state_ptr & state) {current_default_styles_.push_back(state);}
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 (style_family::type family);
office_element_ptr find_odf_style_default (style_family::type family);
......@@ -51,12 +48,10 @@ public:
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, style_family::type family, odf_style_state_ptr & state, bool root = false);
bool find_odf_default_style_state(style_family::type family, odf_style_state_ptr & state);
bool find_odf_style(std::wstring style_name, style_family::type family, style *& style_);
odf_style_state_ptr last_state(style_family::type family = style_family::None);
odf_number_styles_context & numbers_styles() {return number_styles_context_;}
......@@ -68,6 +63,10 @@ public:
//////////////////////////////////////////////////////////////////////
void calc_paragraph_properties(std::wstring style_name, style_family::type family, paragraph_format_properties * result);
//////////////////////////////////////////////////////////////////////
std::wstring find_odf_style_name (int oox_id_style, style_family::type family, bool root, bool automatic);//xlsx only
bool find_odf_style_state(int oox_id_style, style_family::type family, odf_style_state_ptr & state, bool root, bool automatic);//xlsx only
private:
odf_table_styles_context table_styles_context_;
odf_number_styles_context number_styles_context_;
......@@ -81,7 +80,6 @@ private:
odf_conversion_context * odf_context_;
int style_family_counts_[26];//
};
......
......@@ -35,6 +35,7 @@ namespace odf
current_column = 0;
count_header_row = 0;
styled = false;
count_rows = 0;
table_width = 0;
}
......@@ -47,12 +48,18 @@ namespace odf
__int32 current_row;
__int32 current_column;
__int32 count_rows;
__int32 count_header_row;
bool styled;
double table_width;
std::wstring default_cell_properties;
_CP_OPT(std::wstring) border_inside_v_;
_CP_OPT(std::wstring) border_inside_h_;
};
class odf_table_context::Impl
......@@ -222,6 +229,30 @@ void odf_table_context::add_column(office_element_ptr &elm, bool styled)
impl_->current_table().columns.push_back(state);
}
void odf_table_context::set_table_inside_v(_CP_OPT(std::wstring) border)
{
if (impl_->empty()) return;
impl_->current_table().border_inside_v_ = border;
}
void odf_table_context::set_table_inside_h(_CP_OPT(std::wstring) border)
{
if (impl_->empty()) return;
impl_->current_table().border_inside_h_ = border;
}
_CP_OPT(std::wstring) odf_table_context::get_table_inside_v()
{
_CP_OPT(std::wstring) none;
if (impl_->empty()) return none;
return impl_->current_table().border_inside_v_;
}
_CP_OPT(std::wstring) odf_table_context::get_table_inside_h()
{
_CP_OPT(std::wstring) none;
if (impl_->empty()) return none;
return impl_->current_table().border_inside_h_;
}
void odf_table_context::set_default_cell_properties(std::wstring style_name)
{
impl_->default_cell_properties = style_name;
......@@ -284,12 +315,23 @@ int odf_table_context::current_row ()
return impl_->current_table().current_row;
}
int odf_table_context::count_column ()
int odf_table_context::count_columns ()
{
if (impl_->empty()) return 0;
return impl_->current_table().columns.size();
}
int odf_table_context::count_rows ()
{
if (impl_->empty()) return 0;
return impl_->current_table().count_rows;
}
void odf_table_context::count_rows (int count)
{
if (impl_->empty()) return;
impl_->current_table().count_rows = count;
}
void odf_table_context::start_cell(office_element_ptr &elm, bool styled)
{
......
......@@ -30,7 +30,9 @@ public:
int current_column ();
int current_row ();
int count_column ();
int count_columns ();
int count_rows ();
void count_rows (int count);
void start_table(office_element_ptr &elm, bool styled = false);
void set_default_column_width(double width);
......@@ -41,6 +43,12 @@ public:
double get_table_width();
void set_table_inside_v(_CP_OPT(std::wstring) border);
void set_table_inside_h(_CP_OPT(std::wstring) border);
_CP_OPT(std::wstring) get_table_inside_v();
_CP_OPT(std::wstring) get_table_inside_h();
void start_row(office_element_ptr &elm, bool styled = false);
void end_row();
......
......@@ -125,6 +125,16 @@ void odf_table_styles_context::add_wholeTable()
table_format_array_.back().wholeTable_.is=true;
current = &table_format_array_.back().wholeTable_;
}
void odf_table_styles_context::set_table_insideV(std::wstring border)
{
table_format_array_.back().insizeV = border;
}
void odf_table_styles_context::set_table_insideH(std::wstring border)
{
table_format_array_.back().insizeH = border;
}
bool odf_table_styles_context::start_table(std::wstring name)
{
for (long i=0; i < table_format_array_.size(); i++)
......@@ -166,6 +176,16 @@ void odf_table_styles_context::end_table()
if (current_used_.size() > 0)
current_used_.pop_back();
}
_CP_OPT(std::wstring) odf_table_styles_context::get_table_insideV()
{
table_format_state & state = table_format_array_[current_used_.back().table_style_];
return state.insizeV;
}
_CP_OPT(std::wstring) odf_table_styles_context::get_table_insideH()
{
table_format_state & state = table_format_array_[current_used_.back().table_style_];
return state.insizeH;
}
void odf_table_styles_context::get_table_cell_properties (int col, int row, style_table_cell_properties* cell_props)
{
if (current_used_.size() < 1) return;
......@@ -228,9 +248,17 @@ void odf_table_styles_context::get_table_properties (style_table_properties* tab
table_format_state & state = table_format_array_[current_used_.back().table_style_];
table_props->apply_from(dynamic_cast<style_table_properties *>(state.table_.table_props.get()));
}
void odf_table_styles_context::get_table_cell_properties (style_table_cell_properties* table_cell_props)
{
if (current_used_.size() < 1) return;
if (table_cell_props == NULL) return;
table_format_state & state = table_format_array_[current_used_.back().table_style_];
table_cell_props->apply_from(dynamic_cast<style_table_cell_properties *>(state.table_.table_cell_props.get()));
}
void odf_table_styles_context::get_text_properties (int col, int row, style_text_properties* text_props)
{
......
......@@ -49,6 +49,10 @@ struct table_format_state
_style_properties seCell_;
_style_properties swCell_;
_style_properties wholeTable_; //???
_CP_OPT(std::wstring) insizeH;
_CP_OPT(std::wstring) insizeV;
};
class odf_table_styles_context
......@@ -87,6 +91,9 @@ public:
style_text_properties *get_text_properties();
style_table_properties *get_table_properties();
void set_table_insideV(std::wstring border);
void set_table_insideH(std::wstring border);
//-----------------------------------------------
// output
//-----------------------------------------------
......@@ -95,9 +102,14 @@ public:
void set_flags(int val);
void get_table_properties ( style_table_properties *props);
void get_table_cell_properties ( style_table_cell_properties *props);
void get_table_cell_properties (int col, int row, style_table_cell_properties *props);
void get_text_properties (int col, int row, style_text_properties *props);
void get_paragraph_properties (int col, int row, style_paragraph_properties *props);
_CP_OPT(std::wstring) get_table_insideV();
_CP_OPT(std::wstring) get_table_insideH();
void end_table();
private:
......
......@@ -488,9 +488,36 @@ void odf_text_context::add_tab()
}
void odf_text_context::save_property_break()
{
if (paragraph_properties_ == NULL) return;
if (!need_break_) return;
if (paragraph_properties_ == NULL)
{
for (unsigned int i = current_level_.size()-1; i>=0; i--)
{
office_element_ptr & elm = current_level_[i].elm;
text_p* p = dynamic_cast<text_p*>(elm.get());
text_h* h = dynamic_cast<text_h*>(elm.get());
if ((p || h) && !current_level_[i].style_elm)
{
styles_context_->create_style(L"",odf::style_family::Paragraph, true, false, -1);
odf_style_state_ptr style_ = styles_context_->last_state();
if (style_)
{
paragraph_properties_ = style_->get_paragraph_properties();
current_level_[i].style_elm = style_->get_office_element();
current_level_[i].style_name = style_->get_name();
if (p) p->paragraph_.paragraph_attrs_.text_style_name_ = current_level_[i].style_name;
if (h) h->paragraph_.paragraph_attrs_.text_style_name_ = current_level_[i].style_name;
}
break;
}
}
}
if (paragraph_properties_ == NULL) return;
paragraph_properties_->content().fo_break_before_ = need_break_;
need_break_ = boost::none;
......
......@@ -279,7 +279,7 @@ void ods_conversion_context::start_cell(std::wstring & ref, int xfd_style)
if ( xfd_style >=0)
{
odf_style_state_ptr style_state;
styles_context()->find_odf_style_state(xfd_style, style_family::TableCell,style_state);
styles_context()->find_odf_style_state(xfd_style, style_family::TableCell,style_state, false, true);
if (style_state)
{
style_elm = style_state->get_office_element();
......@@ -330,7 +330,7 @@ void ods_conversion_context::end_columns()
//if (current_table().current_column() < 1 )
// add_column(current_table().current_column()+1,1024,0,true);
//else
int repeat = current_table().dimension_columns - current_table().current_column();
int repeat = max(current_table().dimension_columns,1024) - current_table().current_column();
if (repeat < 0) repeat = 1;
add_column(current_table().current_column()+1,repeat,0,true);
......@@ -341,7 +341,7 @@ void ods_conversion_context::start_rows()
void ods_conversion_context::end_rows()
{
//add default last row
int repeat = max(current_table().dimension_row,1024) - current_table().current_row();
int repeat = max(current_table().dimension_row,64) - current_table().current_row();
if (repeat < 0) repeat = 1;
start_row(current_table().current_row()+1,repeat,0,true);
......
......@@ -105,8 +105,8 @@ ods_table_state::ods_table_state(odf_conversion_context * Context, office_elemen
//default dimension
dimension_columns = 1024;
dimension_row = 1024;
dimension_columns = 64;
dimension_row = 64;
defaut_row_height_ = 9;
......
......@@ -803,7 +803,7 @@ void odt_conversion_context::end_table_cell()
}
void odt_conversion_context::end_table_row()
{
for (int i=table_context()->current_column() ; i < table_context()->count_column(); i++)
for (int i=table_context()->current_column() ; i < table_context()->count_columns(); i++)
{
add_default_cell();
}
......
......@@ -39,6 +39,8 @@ oox_shape_ptr oox_shape::create(int ooxPrstGeomType)
case SimpleTypes::shapetypeStar32: return boost::make_shared<oox_shape_star32>();
case SimpleTypes::shapetypePlaque: return boost::make_shared<oox_shape_Plaque>();
case SimpleTypes::shapetypeDoubleWave: return boost::make_shared<oox_shape_DoubleWave>();
//case (2001 + SimpleTypes::textshapetypeTextArchDown):
//case (2001 + SimpleTypes::textshapetypeTextArchDownPour):
......
......@@ -151,10 +151,9 @@ void OoxConverter::convert(SimpleTypes::Vml::CCssStyle *vml_style, bool group)
}
else
{
odf_context()->drawing_context()->set_drawings_rect(x, y, width_pt, height_pt);
//odf_context()->drawing_context()->set_size(width_pt.get_value_or(0), height_pt.get_value_or(0));
//
//odf_context()->drawing_context()->set_position(x.get_value_or(0), y.get_value_or(0));
//odf_context()->drawing_context()->set_drawings_rect(x, y, width_pt, height_pt);/// - -
odf_context()->drawing_context()->set_size (width_pt, height_pt);
odf_context()->drawing_context()->set_position (x, y);
}
......@@ -257,6 +256,16 @@ void OoxConverter::convert(OOX::Vml::CLine *vml_line)
OOX::Vml::CVmlCommonElements *vml_common = static_cast<OOX::Vml::CVmlCommonElements *>(vml_line);
convert(vml_common);
_CP_OPT(double) x = vml_line->m_oFrom.GetX();
_CP_OPT(double) y = vml_line->m_oFrom.GetY();
_CP_OPT(double) width = (vml_line->m_oTo.GetX() - vml_line->m_oFrom.GetX());
_CP_OPT(double) height = (vml_line->m_oTo.GetY() - vml_line->m_oFrom.GetY());
odf_context()->drawing_context()->set_position(x, y);
odf_context()->drawing_context()->set_size(width, height);
}
void OoxConverter::convert(OOX::Vml::COval *vml_oval)
{
......@@ -449,40 +458,41 @@ void OoxConverter::convert(OOX::VmlWord::CWrap *vml_wrap)
{
if (vml_wrap == NULL) return;
if (vml_wrap->m_oType.IsInit() == false) return;
switch(vml_wrap->m_oType->GetValue())
if (vml_wrap->m_oType.IsInit())
{
case SimpleTypes::wraptypeNone :
switch(vml_wrap->m_oType->GetValue())
{
odf_context()->drawing_context()->set_wrap_style(odf::style_wrap::None);
}break;
case SimpleTypes::wraptypeSquare:
{
if (vml_wrap->m_oSide.IsInit())
case SimpleTypes::wraptypeNone :
{
if (vml_wrap->m_oSide->GetValue() == SimpleTypes::wrapsideLargest)
odf_context()->drawing_context()->set_wrap_style(odf::style_wrap::Dynamic);
else if (vml_wrap->m_oSide->GetValue() == SimpleTypes::wrapsideLeft)
odf_context()->drawing_context()->set_wrap_style(odf::style_wrap::Left);
else if (vml_wrap->m_oSide->GetValue() == SimpleTypes::wrapsideRight)
odf_context()->drawing_context()->set_wrap_style(odf::style_wrap::Right);
else
odf_context()->drawing_context()->set_wrap_style(odf::style_wrap::Parallel);
}
}break;
case SimpleTypes::wraptypeThrough:
{
odf_context()->drawing_context()->set_wrap_style(odf::style_wrap::RunThrough);
}break;
case SimpleTypes::wraptypeTight:
{
odf_context()->drawing_context()->set_wrap_style(odf::style_wrap::Parallel);
}break;
case SimpleTypes::wraptypeTopAndBottom:
{
odf_context()->drawing_context()->set_wrap_style(odf::style_wrap::Parallel);
}break;
odf_context()->drawing_context()->set_wrap_style(odf::style_wrap::None);
}break;
case SimpleTypes::wraptypeSquare:
{
if (vml_wrap->m_oSide.IsInit())
{
if (vml_wrap->m_oSide->GetValue() == SimpleTypes::wrapsideLargest)
odf_context()->drawing_context()->set_wrap_style(odf::style_wrap::Dynamic);
else if (vml_wrap->m_oSide->GetValue() == SimpleTypes::wrapsideLeft)
odf_context()->drawing_context()->set_wrap_style(odf::style_wrap::Left);
else if (vml_wrap->m_oSide->GetValue() == SimpleTypes::wrapsideRight)
odf_context()->drawing_context()->set_wrap_style(odf::style_wrap::Right);
else
odf_context()->drawing_context()->set_wrap_style(odf::style_wrap::Parallel);
}
}break;
case SimpleTypes::wraptypeThrough:
{
odf_context()->drawing_context()->set_wrap_style(odf::style_wrap::RunThrough);
}break;
case SimpleTypes::wraptypeTight:
{
odf_context()->drawing_context()->set_wrap_style(odf::style_wrap::Parallel);
}break;
case SimpleTypes::wraptypeTopAndBottom:
{
odf_context()->drawing_context()->set_wrap_style(odf::style_wrap::Parallel);
}break;
}
}
if (vml_wrap->m_oAnchorX.IsInit())
{
......@@ -524,24 +534,55 @@ void OoxConverter::convert(OOX::Vml::CVmlCommonElements *vml_common)
if (vml_common->m_oCoordSize.IsInit())
{
odf_context()->drawing_context()->set_position(vml_common->m_oCoordSize->GetX(), vml_common->m_oCoordSize->GetY());
_CP_OPT(double) x = vml_common->m_oCoordSize->GetX();
_CP_OPT(double) y = vml_common->m_oCoordSize->GetY();
odf_context()->drawing_context()->set_position( x, y);
}
if (vml_common->m_oStrokeWeight.IsInit() || (vml_common->m_oStroked.IsInit() && vml_common->m_oStroked->GetValue()))
odf_context()->drawing_context()->start_line_properties();
{
odf_context()->drawing_context()->start_line_properties();
if (vml_common->m_oStrokeWeight.IsInit() || (vml_common->m_oStroked.IsInit() && vml_common->m_oStroked->GetValue()))
{
if (vml_common->m_oStrokeWeight.IsInit())
odf_context()->drawing_context()->set_line_width(vml_common->m_oStrokeWeight->ToPoints());
odf_context()->drawing_context()->set_solid_fill(string2std_string(vml_common->m_oStrokeColor.ToString()));
odf_context()->drawing_context()->end_line_properties();
if (vml_common->m_oStrokeColor.IsInit())
{
unsigned char ucA=0, ucR=0, ucG=0, ucB=0;
ucR = vml_common->m_oStrokeColor->Get_R();
ucB = vml_common->m_oStrokeColor->Get_B();
ucG = vml_common->m_oStrokeColor->Get_G();
SimpleTypes::CHexColor<> *oRgbColor = new SimpleTypes::CHexColor<>(ucR,ucG,ucB);
if (oRgbColor)
{
odf_context()->drawing_context()->set_solid_fill(string2std_string(oRgbColor->ToString().Right(6)));
delete oRgbColor;
}
}
}else if (vml_common->m_oStroked->GetValue() == SimpleTypes::booleanFalse)
odf_context()->drawing_context()->set_no_fill();
}
if (vml_common->m_oFillColor.IsInit() && vml_common->m_oFilled.GetValue())
odf_context()->drawing_context()->end_line_properties();
odf_context()->drawing_context()->start_area_properties();
{
odf_context()->drawing_context()->start_area_properties();
odf_context()->drawing_context()->set_solid_fill(string2std_string(vml_common->m_oFillColor->ToString()));
odf_context()->drawing_context()->end_area_properties();
if (vml_common->m_oFillColor.IsInit() && vml_common->m_oFilled.GetValue())
{
unsigned char ucA=0, ucR=0, ucG=0, ucB=0;
ucR = vml_common->m_oFillColor->Get_R();
ucB = vml_common->m_oFillColor->Get_B();
ucG = vml_common->m_oFillColor->Get_G();
SimpleTypes::CHexColor<> *oRgbColor = new SimpleTypes::CHexColor<>(ucR,ucG,ucB);
if (oRgbColor)
{
odf_context()->drawing_context()->set_solid_fill(string2std_string(oRgbColor->ToString().Right(6)));
delete oRgbColor;
}
}
else if (vml_common->m_oFilled.GetValue() == SimpleTypes::booleanFalse)
odf_context()->drawing_context()->set_no_fill();
}
odf_context()->drawing_context()->end_area_properties();
for (unsigned int i=0 ; i < vml_common->m_arrItems.size();i++)
{
convert(vml_common->m_arrItems[i]);
......
......@@ -232,11 +232,15 @@ void OoxConverter::convert(OOX::Drawing::CShape *oox_shape)
if (type == SimpleTypes::shapetypeRect && oox_shape->m_oTxSp.IsInit() && oox_shape->m_oTxSp->m_oTxBody.IsInit()) type = 2000;
if (type == 2000 && oox_shape->m_oTxSp->m_oTxBody->m_oBodyPr.IsInit() && oox_shape->m_oTxSp->m_oTxBody->m_oBodyPr->m_oFromWordArt.ToBool())
if ((type == 2000 || type == SimpleTypes::shapetypeRect ) && oox_shape->m_oTxSp->m_oTxBody->m_oBodyPr.IsInit()
&& oox_shape->m_oTxSp->m_oTxBody->m_oBodyPr->m_oPrstTxWrap.IsInit())
{
int wordart_type = convert(oox_shape->m_oTxSp->m_oTxBody->m_oBodyPr->m_oPrstTxWrap.GetPointer());
if (oox_shape->m_oTxSp->m_oTxBody->m_oBodyPr->m_oFromWordArt.ToBool())
{
int wordart_type = convert(oox_shape->m_oTxSp->m_oTxBody->m_oBodyPr->m_oPrstTxWrap.GetPointer());
if (wordart_type >0)type = wordart_type;
if (wordart_type >0)type = wordart_type;
}else type = 2000;
}
if (type < 0)return;
......@@ -443,20 +447,25 @@ void OoxConverter::convert(OOX::Drawing::CShapeProperties * oox_spPr, OOX::Dra
{
if (oox_spPr->m_oXfrm->m_oOff.IsInit())
{
odf_context()->drawing_context()->set_position(oox_spPr->m_oXfrm->m_oOff->m_oX.ToPoints(),
oox_spPr->m_oXfrm->m_oOff->m_oY.ToPoints());
_CP_OPT(double) x = oox_spPr->m_oXfrm->m_oOff->m_oX.ToPoints();
_CP_OPT(double) y = oox_spPr->m_oXfrm->m_oOff->m_oY.ToPoints();
odf_context()->drawing_context()->set_position( x, y);
}
if (oox_spPr->m_oXfrm->m_oExt.IsInit())
{
odf_context()->drawing_context()->set_size( oox_spPr->m_oXfrm->m_oExt->m_oCx.ToPoints(),
oox_spPr->m_oXfrm->m_oExt->m_oCy.ToPoints());
_CP_OPT(double) width = oox_spPr->m_oXfrm->m_oExt->m_oCx.ToPoints();
_CP_OPT(double) height = oox_spPr->m_oXfrm->m_oExt->m_oCy.ToPoints();
odf_context()->drawing_context()->set_size( width, height);
}
if (oox_spPr->m_oXfrm->m_oFlipH.GetValue() == SimpleTypes::onoffTrue)
odf_context()->drawing_context()->set_flip_H(true);
if (oox_spPr->m_oXfrm->m_oFlipV.GetValue() == SimpleTypes::onoffTrue)
odf_context()->drawing_context()->set_flip_V(true);
if (oox_spPr->m_oXfrm->m_oRot.GetValue() > 0)
odf_context()->drawing_context()->set_rotate(180. - oox_spPr->m_oXfrm->m_oRot.GetValue()/60000.);
odf_context()->drawing_context()->set_rotate(360. - oox_spPr->m_oXfrm->m_oRot.GetValue()/60000.);
}
switch(oox_spPr->m_eGeomType)
{
......@@ -1087,7 +1096,7 @@ void OoxConverter::convert(OOX::Drawing::CTextBodyProperties *oox_bodyPr)
int OoxConverter::convert(OOX::Drawing::CPresetTextShape *oox_text_preset)
{
if (oox_text_preset == NULL) return -1;
if (oox_text_preset->m_oPrst.GetValue() == SimpleTypes::textshapetypeTextNoShape) return -1;
if (oox_text_preset->m_oPrst.GetValue() == SimpleTypes::textshapetypeTextNoShape) return 2000;
return 2001 + oox_text_preset->m_oPrst.GetValue();
}
......
......@@ -17,6 +17,7 @@ namespace OOX
namespace Logic
{
class CIns;
class CParagraph;
class CParagraphProperty;
class CRun;
......@@ -135,6 +136,7 @@ namespace Oox2Odf
void convert(OOX::Logic::CText *oox_text);
void convert(OOX::Logic::CHyperlink *oox_hyperlink);
void convert(OOX::Logic::CSym *oox_sym);
void convert(OOX::Logic::CIns *oox_ins);
void convert(OOX::Logic::CAlternateContent *oox_alt_content);
void convert(OOX::Logic::CDrawing *oox_drawing);
......
......@@ -354,7 +354,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CRow *oox_row)
{
int xfd_id = oox_row->m_oS->GetValue();
style_cell_name = ods_context->styles_context()->find_odf_style_name(xfd_id,odf::style_family::TableCell);
style_cell_name = ods_context->styles_context()->find_odf_style_name(xfd_id,odf::style_family::TableCell,false,true);
}else
{
//style_cell_name = ods_context->styles_context()->find_odf_style_name_default(odf::style_family::TableCell);
......@@ -693,7 +693,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCol *oox_column)
{
int xfd_id = oox_column->m_oStyle->GetValue();
style_cell_name = ods_context->styles_context()->find_odf_style_name(xfd_id,odf::style_family::TableCell);
style_cell_name = ods_context->styles_context()->find_odf_style_name(xfd_id,odf::style_family::TableCell,false,true);
}
else
{
......@@ -797,11 +797,16 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetFormatPr *oox_sheet_format_p
//nullable<SimpleTypes::COnOff<>> m_oThickBottom;
//nullable<SimpleTypes::COnOff<>> m_oThickTop;
//nullable<SimpleTypes::COnOff<>> m_oZeroHeight;
// :(
//Cell default////////////////////////////
//// :( c - ???? - - :(
//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);
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);
ods_context->styles_context()->find_odf_style_state(0, odf::style_family::TableCell, default_cell_style, true,true);
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);
{
......@@ -868,19 +873,22 @@ void XlsxConverter::convert_styles()
/////////////
for (unsigned int i=0; xlsx_styles->m_oCellStyleXfs.IsInit() && i< xlsx_styles->m_oCellStyleXfs->m_oCount->GetValue(); i++)
{
//non automatical, root - noname -
convert(xlsx_styles->m_oCellStyleXfs->m_arrItems[i] , i, false, true);// ""
//automatical, root - noname - named
convert(xlsx_styles->m_oCellStyleXfs->m_arrItems[i] , i, true, true);
}
for (unsigned int i=0; xlsx_styles->m_oCellStyles.IsInit() && i< xlsx_styles->m_oCellStyles->m_oCount->GetValue(); i++)//styles.xml
{
//non automatical, root - named
convert(xlsx_styles->m_oCellStyles->m_arrItems[i]);
}
//
for (unsigned int i=0; xlsx_styles->m_oCellXfs.IsInit() && i< xlsx_styles->m_oCellXfs->m_oCount->GetValue(); i++)
{
//automatical, non root
convert(xlsx_styles->m_oCellXfs->m_arrItems[i],i, true,false);
}
for (unsigned int i=0; xlsx_styles->m_oCellStyles.IsInit() && i< xlsx_styles->m_oCellStyles->m_oCount->GetValue(); i++)//styles.xml
{
//non automatical, root - named -
convert(xlsx_styles->m_oCellStyles->m_arrItems[i],i);
}
////////////
for (unsigned int i=0; xlsx_styles->m_oDxfs.IsInit() && i< xlsx_styles->m_oDxfs->m_oCount->GetValue(); i++)
{
......@@ -1306,26 +1314,49 @@ void XlsxConverter::convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf::color)
}
}
}
void XlsxConverter::convert(OOX::Spreadsheet::CCellStyle * cell_style, int oox_id)
void XlsxConverter::convert(OOX::Spreadsheet::CCellStyle * cell_style)
{
if (cell_style == NULL)return;
bool automatic = false;
bool root = true;
int parent_id = cell_style->m_oXfId.IsInit() ? cell_style->m_oXfId->GetValue() : -1;
int oox_id = parent_id; //
std::wstring style_name = L"";
if (cell_style->m_oName.IsInit())style_name = string2std_string(cell_style->m_oName.get());
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);
odf::odf_style_state_ptr style_state = ods_context->styles_context()->last_state(odf::style_family::TableCell);
int parent_id = cell_style->m_oXfId.IsInit() ? cell_style->m_oXfId->GetValue() : -1;
if(!style_state)return;
if (style_name.length() > 0)style_state->set_display_name(style_name);
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));
//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, true));
//m_oBuiltinId, m_oCustomBuiltin, m_oHidden, m_oILevel; ???????
// -
// .. ( )
odf::odf_style_state_ptr parent_style_state;
if (ods_context->styles_context()->find_odf_style_state(parent_id, odf::style_family::TableCell,parent_style_state, true, true) && parent_style_state)
{
parent_style_state->set_dont_write(true);
odf::style_text_properties *text_props = style_state->get_text_properties();
odf::style_paragraph_properties *para_props = style_state->get_paragraph_properties() ;
odf::style_table_cell_properties *cell_props = style_state->get_table_cell_properties();
odf::style_text_properties *parent_text_props = parent_style_state->get_text_properties();
odf::style_paragraph_properties *parent_para_props = parent_style_state->get_paragraph_properties() ;
odf::style_table_cell_properties *parent_cell_props = parent_style_state->get_table_cell_properties();
if (text_props) text_props->apply_from(parent_text_props);
if (para_props) para_props->apply_from(parent_para_props);
if (cell_props) cell_props->apply_from(parent_cell_props);
}
}
void XlsxConverter::convert(OOX::Spreadsheet::CDxf *dxFmt, int oox_id)
{
......@@ -1403,9 +1434,9 @@ void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool
if (id_parent >=0)
{
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)
if (ods_context->styles_context()->find_odf_style_state(id_parent, odf::style_family::TableCell,parent_style_state, true, false)
&& parent_style_state) //
{
ods_context->styles_context()->last_state()->set_parent_style_name(parent_style_state->get_name());
......@@ -1414,6 +1445,19 @@ void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool
ods_context->styles_context()->last_state()->set_number_format(parent_style_state->get_number_format());
}
}
else
{
if (ods_context->styles_context()->find_odf_style_state(id_parent, odf::style_family::TableCell,parent_style_state, true, true)
&& parent_style_state)
{
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());
}
}
}
}
}
......
......@@ -142,7 +142,7 @@ namespace Oox2Odf
odf::style_table_cell_properties * cell_properties);
void convert(OOX::Spreadsheet::CXfs *cell_style, int oox_id, bool automatic=true, bool root = false);
void convert(OOX::Spreadsheet::CCellStyle *cell_style, int oox_id);
void convert(OOX::Spreadsheet::CCellStyle *cell_style);
void convert(OOX::Spreadsheet::CNumFmt *numFmt);
void convert(OOX::Spreadsheet::CDxf *dxFmt, int oox_id);
......
......@@ -2,6 +2,6 @@
//1
//2
//0
//143
#define INTVER 1,2,0,143
#define STRVER "1,2,0,143\0"
//145
#define INTVER 1,2,0,145
#define STRVER "1,2,0,145\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