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

.....

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@57400 954022d7-b5bf-4e40-9824-e11837661b57
parent c85c7ddc
......@@ -43,7 +43,7 @@ std::wostream & operator << (std::wostream & _Wostream, const length::unit _Unit
std::wostream & operator << (std::wostream & _Wostream, const length & _Length)
{
_Wostream << _Length.get_value() << _Length.get_unit();
_Wostream << std::setprecision(4) << _Length.get_value() << _Length.get_unit();
return _Wostream;
}
length operator + (length & _Length1, length & _Length2)
......
......@@ -41,6 +41,15 @@ public:
return Length_;
}
percent & get_percent()
{
return Percent_;
}
length & get_length()
{
return Length_;
}
static length_or_percent parse(const std::wstring & );
private:
......
......@@ -32,5 +32,33 @@ shadow_type shadow_type::parse(const std::wstring & Str)
return shadow_type( Str );
}
//----------------------------------------------------------------------------------------
std::wostream & operator << (std::wostream & _Wostream, const shadow_type1 & _Val)
{
switch(_Val.get_type())
{
case shadow_type1::Hidden:
_Wostream << L"hidden";
break;
case shadow_type1::Visible:
_Wostream << L"visible";
break;
default:
break;
}
return _Wostream;
}
shadow_type1 shadow_type1::parse(const std::wstring & Str)
{
std::wstring tmp = Str;
boost::algorithm::to_lower(tmp);
if (tmp == L"visible")
return shadow_type1( Visible );
else
return shadow_type1( Hidden );
}
} }
#ifndef _CPDOCCORE_ODF_SHADOWTYPE_H_
#define _CPDOCCORE_ODF_SHADOWTYPE_H_
#ifdef _MSC_VER
#pragma once
#endif
#include <iosfwd>
#include <string>
......@@ -49,10 +44,46 @@ private:
std::wostream & operator << (std::wostream & _Wostream, const shadow_type & _Val);
}
APPLY_PARSE_XML_ATTRIBUTES(odf::shadow_type);
//--------------------------------------------------------------------------------------------------------------------------------
class shadow_type1
{
public:
enum type
{
Hidden,
Visible
};
}
shadow_type1() {}
shadow_type1(type _Type) : type_(_Type)
{}
shadow_type1(const std::wstring & _Name) : type_(Visible), name_(_Name)
{}
type get_type() const
{
return type_;
};
#endif
const std::wstring & get_name() const
{
return name_;
}
static shadow_type1 parse(const std::wstring & Str);
private:
type type_;
std::wstring name_;
};
std::wostream & operator << (std::wostream & _Wostream, const shadow_type1 & _Val);
}
APPLY_PARSE_XML_ATTRIBUTES(odf::shadow_type);
APPLY_PARSE_XML_ATTRIBUTES(odf::shadow_type1);
}
......@@ -296,6 +296,8 @@ namespace odf
CP_XML_ATTR(L"xmlns:of", L"urn:oasis:names:tc:opendocument:xmlns:of:1.2" );
CP_XML_ATTR(L"xmlns:xhtml", L"http://www.w3.org/1999/xhtml" );
CP_XML_ATTR(L"xmlns:grddl", L"http://www.w3.org/2003/g/data-view#" );
CP_XML_ATTR(L"xmlns:officeooo", L"http://openoffice.org/2009/office" );
CP_XML_ATTR(L"xmlns:textooo", L"http://openoffice.org/2013/office" );
CP_XML_ATTR(L"xmlns:tableooo", L"http://openoffice.org/2009/table" );
CP_XML_ATTR(L"xmlns:drawooo", L"http://openoffice.org/2010/draw" );
CP_XML_ATTR(L"xmlns:chartooo", L"http://openoffice.org/2010/chart" );
......@@ -359,6 +361,8 @@ namespace odf
CP_XML_ATTR(L"xmlns:of", L"urn:oasis:names:tc:opendocument:xmlns:of:1.2" );
CP_XML_ATTR(L"xmlns:xhtml", L"http://www.w3.org/1999/xhtml" );
CP_XML_ATTR(L"xmlns:grddl", L"http://www.w3.org/2003/g/data-view#" );
CP_XML_ATTR(L"xmlns:officeooo", L"http://openoffice.org/2009/office" );
CP_XML_ATTR(L"xmlns:textooo", L"http://openoffice.org/2013/office" );
CP_XML_ATTR(L"xmlns:tableooo", L"http://openoffice.org/2009/table" );
CP_XML_ATTR(L"xmlns:drawooo", L"http://openoffice.org/2010/draw" );
CP_XML_ATTR(L"xmlns:chartooo", L"http://openoffice.org/2010/chart" );
......
......@@ -48,6 +48,8 @@ public:
virtual void start_text_context() = 0;
virtual void end_text_context() = 0;
virtual void start_image(std::wstring & image_file_name) = 0;
odf_chart_context * chart_context();
odf_style_context * styles_context();
odf_page_layout_context * page_layout_context();
......
......@@ -729,6 +729,22 @@ void odf_drawing_context::set_opacity(double percent_)
break;
}
}
void odf_drawing_context::set_shadow(int type, std::wstring hexColor, _CP_OPT(double) opacity, double dist_pt, double dist_pt_y )
{
if (!impl_->current_graphic_properties)return;
impl_->current_graphic_properties->content().draw_shadow_ = shadow_type1(shadow_type1::Visible);
if (opacity) impl_->current_graphic_properties->content().draw_shadow_opacity_ = *opacity;
impl_->current_graphic_properties->content().draw_shadow_color_ = hexColor;
impl_->current_graphic_properties->content().draw_shadow_offset_y_ = length(length(dist_pt,length::pt).get_value_unit(length::cm),length::cm);
if (dist_pt_y > 0)
impl_->current_graphic_properties->content().draw_shadow_offset_x_ = length(length(dist_pt_y,length::pt).get_value_unit(length::cm),length::cm);
else
impl_->current_graphic_properties->content().draw_shadow_offset_x_ = length(length(dist_pt,length::pt).get_value_unit(length::cm),length::cm);
}
void odf_drawing_context::set_no_fill()
{
if (!impl_->current_graphic_properties)return;
......@@ -828,9 +844,9 @@ void odf_drawing_context::set_margin_bottom (double valPt)
{
impl_->anchor_settings_.fo_margin_bottom_ = length(length(valPt,length::pt).get_value_unit(length::cm),length::cm);
}
void odf_drawing_context::set_anchor(anchor_type::type type)
void odf_drawing_context::set_anchor(int type)
{
impl_->anchor_settings_.anchor_type_ = anchor_type(type);
impl_->anchor_settings_.anchor_type_ = anchor_type((anchor_type::type)type);
}
//////////////////////////////////////////////////////////////////////////////////////
void odf_drawing_context::set_vertical_rel(int from)
......@@ -948,9 +964,9 @@ void odf_drawing_context::set_size( double width_pt, double height_pt)
height_pt *= impl_->group_list_.back().koef_cy;
}
//if (!impl_->current_drawing_state_.svg_width_)
impl_->current_drawing_state_.svg_width_ = length(length(width_pt,length::pt).get_value_unit(length::cm),length::cm);
if (width_pt >= 0) 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_)
impl_->current_drawing_state_.svg_height_= length(length(height_pt,length::pt).get_value_unit(length::cm),length::cm);
if (height_pt >=0) 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)
{
......@@ -1141,6 +1157,13 @@ void odf_drawing_context::start_text_box()
{
start_frame();
// Frame - :(
style* style_ = dynamic_cast<style*>(impl_->current_drawing_state_.elements_.back().style_elm.get());
if (style_)
{
style_->style_parent_style_name_ = L"Frame";
}
if (impl_->current_graphic_properties)
{
......@@ -1151,6 +1174,17 @@ void odf_drawing_context::start_text_box()
start_element(text_box_elm);
}
void odf_drawing_context::set_text_box_min_size(double w_pt, double h_pt)
{
draw_text_box* draw = dynamic_cast<draw_text_box*>(impl_->current_drawing_state_.elements_.back().elm.get());
if (draw)
{
if (h_pt >=0) draw->draw_text_box_attlist_.fo_min_height_= length(length(h_pt,length::pt).get_value_unit(length::cm), length::cm);
if (w_pt >=0) draw->draw_text_box_attlist_.fo_min_width_= length(length(w_pt,length::pt).get_value_unit(length::cm), length::cm);
}
}
void odf_drawing_context::end_image()
{
end_element();
......@@ -1217,6 +1251,7 @@ void odf_drawing_context::set_text(odf_text_context* text_context)
impl_->current_graphic_properties->content().draw_auto_grow_height_ = false;
impl_->current_graphic_properties->content().draw_auto_grow_width_ = false;
impl_->current_graphic_properties->content().draw_fit_to_size_ = false;//???
}
}
void odf_drawing_context::start_gradient_style()
......
......@@ -34,7 +34,7 @@ public:
void set_margin_top (double valPt);
void set_margin_bottom (double valPt);
void set_anchor (anchor_type::type type);
void set_anchor (int type);//anchor_type
void set_vertical_rel(int from);
void set_vertical_pos(int align);
......@@ -71,6 +71,7 @@ public:
void end_image();
void start_text_box();
void set_text_box_min_size(double w_pt, double h_pt);
void end_text_box();
void start_object(std::wstring name);
......@@ -121,6 +122,8 @@ public:
void start_shadow_properies();
void end_shadow_properies();
// ..
void set_shadow(int type, std::wstring hexColor, _CP_OPT(double) opacity, double dist_pt, double dist_pt_y = -1);
void set_text(odf_text_context* text_context);
void set_textarea_vertical_align(int align);
......
......@@ -111,6 +111,8 @@ void odf_style_context::process_automatic_styles(office_element_ptr root )
{//
for (long i =0; i < style_state_list_.size(); i++)
{
if (style_state_list_[i].writable_ == false) continue;
if (style_state_list_[i].automatic_== true && style_state_list_[i].root_== true && style_state_list_[i].odf_style_)
root->add_child_element(style_state_list_[i].odf_style_);
}
......@@ -119,6 +121,8 @@ void odf_style_context::process_automatic(office_element_ptr root )
{//
for (long i =0; i < style_state_list_.size(); i++)
{
if (style_state_list_[i].writable_ == false) continue;
if (/*it->automatic_== true && */style_state_list_[i].root_== false && style_state_list_[i].odf_style_)
root->add_child_element(style_state_list_[i].odf_style_);
}
......@@ -127,6 +131,8 @@ void odf_style_context::process_master(office_element_ptr root )
{
for (long i =0; i < master_style_list_.size(); i++)
{
if (style_state_list_[i].writable_ == false) continue;
root->add_child_element(master_style_list_[i]);
}
}
......@@ -136,6 +142,8 @@ void odf_style_context::process_office(office_element_ptr root )
for (long i =0; i < style_state_list_.size(); i++)
{
if (style_state_list_[i].writable_ == false) continue;
if (style_state_list_[i].automatic_== false && style_state_list_[i].root_ == true && style_state_list_[i].odf_style_)
root->add_child_element(style_state_list_[i].odf_style_);
}
......
......@@ -20,6 +20,8 @@ odf_style_state::odf_style_state(office_element_ptr & elm, const style_family fa
num_fmt_id_ =0;
style_family_ = family;
writable_ = true;
style* style_ = dynamic_cast<style*>(elm.get());
if (style_)
{
......@@ -82,6 +84,10 @@ void odf_style_state::set_parent_style_name(std::wstring & name)
return;
style_->style_parent_style_name_ = name;
}
void odf_style_state::set_dont_write(bool Val)
{
writable_ = !Val;
}
void odf_style_state::set_data_style_name(std::wstring & name)
{
style* style_ = dynamic_cast<style*>(odf_style_.get());
......
......@@ -41,6 +41,8 @@ public:
void apply_from(style* other_style);
void set_dont_write(bool val);
void add_child(office_element_ptr & child);
/////////////////////////////////////////////////////////////////////////////////////////
void set_name(std::wstring & name);
......@@ -80,6 +82,8 @@ private:
bool default_; // root
bool conditional_; //
bool writable_;
style_family style_family_;
office_element_ptr odf_style_;
......
......@@ -13,6 +13,7 @@
#include "table.h"
#include "style_table_properties.h"
//#include "style_text_properties.h"
//#include "style_paragraph_properties.h"
//#include "style_graphic_properties.h"
......@@ -34,6 +35,8 @@ namespace odf
current_column = 0;
count_header_row = 0;
styled = false;
table_width = 0;
}
std::vector<odf_element_state> rows;
std::vector<odf_column_state> columns;
......@@ -48,6 +51,8 @@ namespace odf
bool styled;
double table_width;
std::wstring default_cell_properties;
};
class odf_table_context::Impl
......@@ -55,7 +60,7 @@ class odf_table_context::Impl
public:
Impl(odf_conversion_context *odf_context) :odf_context_(odf_context)
{
default_column_width = -1;
}
odf_table_state & current_table() {return tables_.back();}
......@@ -63,12 +68,15 @@ public:
void start_table(odf_table_state & state) {tables_.push_back(state);}
void end_table() {if (tables_.size() > 0) tables_.pop_back();}
void end_table() {if (tables_.size() > 0) tables_.pop_back(); default_column_width = -1; default_cell_properties = L"";}
odf_style_context * styles_context() {return odf_context_->styles_context();}
odf_conversion_context *odf_context_;
double default_column_width;
std::wstring default_cell_properties; // ..
private:
std::vector<odf_table_state> tables_;// current level ...
......@@ -112,14 +120,13 @@ void odf_table_context::start_table(office_element_ptr &elm, bool styled)
state.table.style_elm = style_state->get_office_element();
state.table.style_name = style_state->get_name();
table->table_table_attlist_.table_style_name_ = state.table.style_name;
// -
style_table_properties *table_properties = style_state->get_table_properties();
table_properties->table_format_properties_.table_border_model_ = odf::border_model(odf::border_model::Collapsing);
}
}
state.default_cell_properties = impl_->default_cell_properties;
impl_->default_cell_properties = L"";
impl_->start_table(state);
}
void odf_table_context::end_table()
{
......@@ -129,6 +136,19 @@ void odf_table_context::end_table()
impl_->current_table().current_column = i+1;
set_cell_row_span_restart();
}
style * style_ = dynamic_cast<style *>(impl_->current_table().table.style_elm.get());
if (style_)
{
if (impl_->current_table().table_width > 0)
{
style_table_properties * table_props = style_->style_content_.get_style_table_properties();
if (table_props)
{
table_props->table_format_properties_.style_width_ = length(length(impl_->current_table().table_width,length::pt).get_value_unit(length::cm),length::cm);
}
}
}
impl_->end_table();
}
void odf_table_context::start_row(office_element_ptr &elm, bool styled)
......@@ -199,6 +219,24 @@ void odf_table_context::add_column(office_element_ptr &elm, bool styled)
impl_->current_table().columns.push_back(state);
}
void odf_table_context::set_default_cell_properties(std::wstring style_name)
{
impl_->default_cell_properties = style_name;
}
double odf_table_context::get_table_width()
{
if (impl_->empty()) return -1;
else return impl_->current_table().table_width;
}
std::wstring odf_table_context::get_default_cell_properties()
{
if (impl_->empty()) return impl_->default_cell_properties;
else return impl_->current_table().default_cell_properties;
}
void odf_table_context::set_default_column_width(double width)
{
impl_->default_column_width = width;
}
void odf_table_context::set_column_width(double width)
{
if (impl_->empty()) return;
......@@ -213,10 +251,23 @@ void odf_table_context::set_column_width(double width)
if (width >= 0)
{
properties->style_table_column_properties_attlist_.style_column_width_ = length(length(width,length::pt).get_value_unit(length::cm),length::cm);
properties->style_table_column_properties_attlist_.style_use_optimal_column_width_ = false;
//properties->style_table_column_properties_attlist_.style_rel_column_width_ = length(length(width,length::pt).get_value_unit(length::cm),length::cm);
//properties->style_table_column_properties_attlist_.style_use_optimal_column_width_ = false;
impl_->current_table().table_width += width;
}
else
{
properties->style_table_column_properties_attlist_.style_use_optimal_column_width_ = true;
if (impl_->default_column_width >=0)
{
properties->style_table_column_properties_attlist_.style_column_width_ = length(length(impl_->default_column_width,length::pt).get_value_unit(length::cm),length::cm);
//properties->style_table_column_properties_attlist_.style_rel_column_width_ = length(length(impl_->current_table().table_width,length::pt).get_value_unit(length::cm),length::cm);
impl_->current_table().table_width += impl_->default_column_width;
}
}
}
int odf_table_context::current_column ()
{
......@@ -258,6 +309,11 @@ void odf_table_context::start_cell(office_element_ptr &elm, bool styled)
cell->table_table_cell_attlist_.table_style_name_ = state.style_name;
}
}
//if (cell)
//{
// cell->table_table_cell_attlist_.common_value_and_type_attlist_ = common_value_and_type_attlist();
// cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_ = office_value_type(office_value_type::String);
//}
impl_->current_table().cells.push_back(state);
......
......@@ -31,7 +31,13 @@ public:
int count_column ();
void start_table(office_element_ptr &elm, bool styled = false);
void set_default_column_width(double width);
void end_table();
void set_default_cell_properties(std::wstring style_name);
std::wstring get_default_cell_properties();
double get_table_width();
void start_row(office_element_ptr &elm, bool styled = false);
void end_row();
......
......@@ -54,20 +54,22 @@ void odf_text_context::set_single_object(bool val, style_paragraph_properties *p
void odf_text_context::add_text_content(const std::wstring & text)
{
//if (text == L" " && single_paragraph_ == false)
//{
// office_element_ptr elm;
// create_element(L"text", L"s", elm, odf_context_);
// current_level_.back().elm->add_child_element(elm);
//}
//else
{
if (current_level_.size() > 0 )
current_level_.back().elm->add_text(text);
if (current_level_.size() > 0 )
current_level_.back().elm->add_text(text);
}
void odf_text_context::set_symbol_font(std::wstring & font)
{
if (text_properties_ == NULL) return;
}
text_properties_->text_format_properties_content_.fo_font_family_ = font;
text_properties_->text_format_properties_content_.style_font_family_complex_ = font;
text_properties_->text_format_properties_content_.style_font_family_asian_ = font;
}
void odf_text_context::set_symbol_text(int sym)
{
char ch = char( sym ^ 0xF000);
std::wstring s;s.push_back(ch);
add_text_content(s);
}
void odf_text_context::start_paragraph(bool styled)
{
......
......@@ -35,7 +35,9 @@ public:
void set_single_object(bool val, style_paragraph_properties *para_props, style_text_properties *text_props);
void add_text_content(const std::wstring & text);
void set_symbol_font(std::wstring & font);
void set_symbol_text(int sym);
void start_paragraph(bool styled = false);
void start_paragraph(office_element_ptr & elm, bool styled = false);
void end_paragraph();
......
......@@ -70,7 +70,7 @@ public:
void start_drawings();
void end_drawings();
void start_image(std::wstring & image_file_name);
virtual void start_image(std::wstring & image_file_name);
double convert_symbol_width(double val);
......
......@@ -175,9 +175,8 @@ void odt_conversion_context::end_drawings()
if (drawing_context_.size() < 1) return;
office_element_ptr & elm = drawing_context()->get_root_element();
if (elm )
if (elm && text_context()->current_level_.size() > 0)
{
text_context()->current_level_.back().elm->add_child_element(elm);
}
drawing_context()->clear();
......@@ -556,7 +555,22 @@ void odt_conversion_context::add_table_column(double width)
office_element_ptr elm;
create_element(L"table", L"table-column",elm,this);
styles_context()->create_style(L"",odf::style_family::TableColumn, true, false, -1);
styles_context()->create_style(L"", style_family::TableColumn, true, false, -1);
// ..
//std::wstring parent_name = table_context()->get_default_cell_properties();
//if (parent_name.length() > 0)
//{
// odf::style_table_cell_properties * props = styles_context()->last_state().get_table_cell_properties();
// style * style_ = NULL;
//
// if (styles_context()->find_odf_style(parent_name,style_family::TableCell,style_))
// {
// style_table_cell_properties * parent = style_->style_content_.get_style_table_cell_properties();
// props->apply_from(parent);
// }
//}
table_context()->add_column(elm, true);
table_context()->set_column_width(width);
......
......@@ -45,7 +45,7 @@ public:
void start_drawings();
void end_drawings();
void start_image(std::wstring & image_file_name);
virtual void start_image(std::wstring & image_file_name);
void add_text_content (std::wstring & text);
void start_paragraph(bool styled = false);
......
......@@ -24,18 +24,18 @@ void graphic_format_properties::serialize(std::wostream & _Wostream ,const wchar
common_draw_fill_attlist_.serialize(CP_GET_XML_NODE());
CP_XML_ATTR_OPT(L"draw:wrap-influence-on-position", draw_wrap_influence_on_position_);
CP_XML_ATTR_OPT(L"draw:textarea-horizontal-align", draw_textarea_horizontal_align_);
CP_XML_ATTR_OPT(L"draw:textarea-vertical-align", draw_textarea_vertical_align_);
CP_XML_ATTR_OPT(L"draw:auto-grow-height", draw_auto_grow_height_);
CP_XML_ATTR_OPT(L"draw:auto-grow-width", draw_auto_grow_width_);
CP_XML_ATTR_OPT(L"draw:textarea-horizontal-align", draw_textarea_horizontal_align_);
CP_XML_ATTR_OPT(L"draw:textarea-vertical-align", draw_textarea_vertical_align_);
CP_XML_ATTR_OPT(L"draw:auto-grow-height", draw_auto_grow_height_);
CP_XML_ATTR_OPT(L"draw:auto-grow-width", draw_auto_grow_width_);
CP_XML_ATTR_OPT(L"draw:stroke", draw_stroke_);
CP_XML_ATTR_OPT(L"draw:stroke-dash",draw_stroke_dash_);
CP_XML_ATTR_OPT(L"draw:marker-start",draw_marker_start_);
CP_XML_ATTR_OPT(L"draw:marker-end", draw_marker_end_);
CP_XML_ATTR_OPT(L"svg:stroke-color",svg_stroke_color_);
CP_XML_ATTR_OPT(L"svg:stroke-width", svg_stroke_width_);
CP_XML_ATTR_OPT(L"svg:stroke-opacity",svg_stroke_opacity_);
CP_XML_ATTR_OPT(L"draw:stroke", draw_stroke_);
CP_XML_ATTR_OPT(L"draw:stroke-dash", draw_stroke_dash_);
CP_XML_ATTR_OPT(L"draw:marker-start", draw_marker_start_);
CP_XML_ATTR_OPT(L"draw:marker-end", draw_marker_end_);
CP_XML_ATTR_OPT(L"svg:stroke-color", svg_stroke_color_);
CP_XML_ATTR_OPT(L"svg:stroke-width", svg_stroke_width_);
CP_XML_ATTR_OPT(L"svg:stroke-opacity", svg_stroke_opacity_);
CP_XML_ATTR_OPT(L"fo:min-width", fo_min_width_);
CP_XML_ATTR_OPT(L"fo:min-height", fo_min_height_);
......@@ -44,20 +44,28 @@ void graphic_format_properties::serialize(std::wostream & _Wostream ,const wchar
CP_XML_ATTR_OPT(L"fo:clip", fo_clip_);
CP_XML_ATTR_OPT(L"fo:wrap-option", fo_wrap_option_);
CP_XML_ATTR_OPT(L"style:print-content", style_print_content_);
CP_XML_ATTR_OPT(L"style:protect", style_protect_);
CP_XML_ATTR_OPT(L"style:editable", style_editable_);
CP_XML_ATTR_OPT(L"style:wrap", style_wrap_);
CP_XML_ATTR_OPT(L"style:print-content", style_print_content_);
CP_XML_ATTR_OPT(L"style:protect", style_protect_);
CP_XML_ATTR_OPT(L"style:editable", style_editable_);
CP_XML_ATTR_OPT(L"style:wrap", style_wrap_);
CP_XML_ATTR_OPT(L"style:wrap-dynamic-treshold", style_wrap_dynamic_treshold_);
CP_XML_ATTR_OPT(L"style:number-wrapped-paragraphs", style_number_wrapped_paragraphs_);
CP_XML_ATTR_OPT(L"style:wrap-contour", style_wrap_contour_);
CP_XML_ATTR_OPT(L"style:wrap-contour", style_wrap_contour_);
CP_XML_ATTR_OPT(L"style:wrap-contour-mode", style_wrap_contour_mode_);
CP_XML_ATTR_OPT(L"style:run-through", style_run_through_);
CP_XML_ATTR_OPT(L"style:flow-with-text", style_flow_with_text_);
CP_XML_ATTR_OPT(L"style:run-through", style_run_through_);
CP_XML_ATTR_OPT(L"style:flow-with-text", style_flow_with_text_);
CP_XML_ATTR_OPT(L"style:overflow-behavior", style_overflow_behavior_);
CP_XML_ATTR_OPT(L"style:mirror", style_mirror_);
CP_XML_ATTR_OPT(L"style:mirror", style_mirror_);
CP_XML_ATTR_OPT(L"draw:fit-to-size", draw_fit_to_size_);
//common_shadow_attlist_.serialize(CP_GET_XML_NODE());
CP_XML_ATTR_OPT(L"draw:shadow", draw_shadow_);
CP_XML_ATTR_OPT(L"draw:shadow-opacity", draw_shadow_opacity_);
CP_XML_ATTR_OPT(L"draw:shadow-color", draw_shadow_color_);
CP_XML_ATTR_OPT(L"draw:shadow-offset-y", draw_shadow_offset_y_);
CP_XML_ATTR_OPT(L"draw:shadow-offset-x", draw_shadow_offset_x_);
common_draw_rel_size_attlist_.serialize(CP_GET_XML_NODE());
common_horizontal_margin_attlist_.serialize(CP_GET_XML_NODE());
common_vertical_margin_attlist_.serialize(CP_GET_XML_NODE());
......@@ -70,7 +78,6 @@ void graphic_format_properties::serialize(std::wostream & _Wostream ,const wchar
common_border_attlist_.serialize(CP_GET_XML_NODE());
common_border_line_width_attlist_.serialize(CP_GET_XML_NODE());
common_padding_attlist_.serialize(CP_GET_XML_NODE());
common_shadow_attlist_.serialize(CP_GET_XML_NODE());
common_background_color_attlist_.serialize(CP_GET_XML_NODE());
}
}
......
......@@ -58,6 +58,13 @@ public:
_CP_OPT(Bool) draw_auto_grow_height_;
_CP_OPT(Bool) draw_auto_grow_width_;
//common_shadow_attlist common_shadow_attlist_;
_CP_OPT(shadow_type1) draw_shadow_;
_CP_OPT(percent) draw_shadow_opacity_;
_CP_OPT(color) draw_shadow_color_;
_CP_OPT(length) draw_shadow_offset_y_;
_CP_OPT(length) draw_shadow_offset_x_;
common_draw_fill_attlist common_draw_fill_attlist_;
common_draw_rel_size_attlist common_draw_rel_size_attlist_;
......@@ -80,8 +87,6 @@ public:
common_padding_attlist common_padding_attlist_;
common_shadow_attlist common_shadow_attlist_;
common_background_color_attlist common_background_color_attlist_;
_CP_OPT(style_wrap) style_wrap_;
......
......@@ -33,7 +33,6 @@ void table_format_properties::serialize(std::wostream & _Wostream,const wchar_t
{
CP_XML_ATTR_OPT(L"style:width", style_width_);
CP_XML_ATTR_OPT(L"style:rel-width", style_rel_width_);
CP_XML_ATTR_OPT(L"table:align", table_align_);
CP_XML_ATTR_OPT(L"style:may-break-between-rows", style_may_break_between_rows_);
CP_XML_ATTR_OPT(L"table:border-model", table_border_model_);
CP_XML_ATTR_OPT(L"table:display", table_display_);
......@@ -51,6 +50,7 @@ void table_format_properties::serialize(std::wostream & _Wostream,const wchar_t
common_border_attlist_.serialize(CP_GET_XML_NODE());
if (style_background_image_) style_background_image_->serialize(_Wostream);
CP_XML_ATTR_OPT(L"table:align", table_align_);
}
}
}
......
......@@ -156,6 +156,10 @@
RelativePath=".\Oox2OdfConverter\ConverterChart.cpp"
>
</File>
<File
RelativePath=".\Oox2OdfConverter\ConvertVml.cpp"
>
</File>
<File
RelativePath=".\Oox2OdfConverter\DocxConverter.cpp"
>
......@@ -180,6 +184,10 @@
/>
</FileConfiguration>
</File>
<File
RelativePath=".\Oox2OdfConverter\VmlShapeTypes2Oox.h"
>
</File>
<File
RelativePath=".\Oox2OdfConverter\XlsxConverter.cpp"
>
......
#include "stdAfx.h"
#include "Converter.h"
#include "../utils.h"
#include "XlsxConverter.h"
#include "DocxConverter.h"
#include "odf_conversion_context.h"
#include "odf_text_context.h"
#include "odf_drawing_context.h"
#include "style_text_properties.h"
#include "style_paragraph_properties.h"
#include <DocxFormat\Logic\Vml.h>
#include "VmlShapeTypes2Oox.h"
namespace Oox2Odf
{
void OoxConverter::convert(OOX::Vml::CVmlShapeElements *unknown)
{
if (unknown == NULL) return;
switch(unknown->getType())
{
case OOX::et_v_image:
{
OOX::Vml::CImage *vml = static_cast<OOX::Vml::CImage*>(unknown);
convert(vml);
}break;
//et_v_f, // <v:f>
//et_v_formulas, // <v:formulas>
//et_v_group, // <v:group>
//et_v_h, // <v:h>
//et_v_handles, // <v:handles>
//et_v_shadow, // <v:shadow>
default:
{
std::wstringstream ss;
ss << L"[warning] : no convert vml element(" << unknown->getType() << L")\n";
_CP_LOG(error) << ss.str();
}
}
}
void OoxConverter::convert(OOX::Vml::CShapeType *vml_shape_type)
{
if (vml_shape_type == NULL) return;
//custom shape
for (long i=0 ; i < vml_shape_type->m_arrItems.GetSize();i++)
{
convert(vml_shape_type->m_arrItems[i]);
}
//o:spt
//nullable<CString> m_oAdj;
//nullable<SimpleTypes::Vml::CVmlPath> m_oPath;
//SimpleTypes::CTrueFalse<SimpleTypes::booleanFalse> m_oMaster;
//m_arrItems
//CVmlAttributes
}
void OoxConverter::convert(SimpleTypes::Vml::CCssStyle *vml_style)
{
if (vml_style == NULL) return;
double width_pt = -1, height_pt = -1;
for (long i=0; i < vml_style->m_arrProperties.GetSize(); i++)
{
switch(vml_style->m_arrProperties[i].get_Type())
{
case SimpleTypes::Vml::cssptHeight:
height_pt = vml_style->m_arrProperties[i].get_Value().oValue.dValue;
break;
case SimpleTypes::Vml::cssptWidth:
width_pt = vml_style->m_arrProperties[i].get_Value().oValue.dValue;
break;
case SimpleTypes::Vml::cssptMarginBottom:
odf_context()->drawing_context()->set_margin_bottom(vml_style->m_arrProperties[i].get_Value().oValue.dValue);
break;
case SimpleTypes::Vml::cssptMarginLeft:
odf_context()->drawing_context()->set_margin_left (vml_style->m_arrProperties[i].get_Value().oValue.dValue);
break;
case SimpleTypes::Vml::cssptMarginRight:
odf_context()->drawing_context()->set_margin_right(vml_style->m_arrProperties[i].get_Value().oValue.dValue);
break;
case SimpleTypes::Vml::cssptMarginTop:
odf_context()->drawing_context()->set_margin_top(vml_style->m_arrProperties[i].get_Value().oValue.dValue);
break;
}
}
odf_context()->drawing_context()->set_drawings_rect(-1, -1, width_pt, height_pt);
}
void OoxConverter::convert(OOX::Vml::CShape *vml_shape)
{
if (vml_shape == NULL) return;
for (long i=0 ; i < vml_shape->m_arrItems.GetSize();i++)
{
convert(vml_shape->m_arrItems[i]);
}
}
void OoxConverter::convert(OOX::Vml::CImage *vml_image)
{
if (vml_image == NULL) return;
}
void OoxConverter::convert(OOX::Vml::CImageData *vml_image_data)
{
if (vml_image_data == NULL) return;
CString pathImage;
double Width=0, Height = 0;
if (vml_image_data->m_rId.IsInit())
{
CString sID = vml_image_data->m_rId->GetValue();
pathImage = find_link_by_id(sID,1);
}
if (pathImage.GetLength() < 1)return;
_gdi_graphics_::GetResolution(pathImage, Width, Height);
odf_context()->drawing_context()->start_area_properies();
odf_context()->drawing_context()->start_bitmap_style();
odf_context()->drawing_context()->set_bitmap_link(string2std_string(pathImage));
odf_context()->drawing_context()->set_image_style_repeat(1);//stretch
odf_context()->drawing_context()->end_bitmap_style();
odf_context()->drawing_context()->end_area_properies();
}
void OoxConverter::convert(OOX::Vml::CArc *vml_arc)
{
}
void OoxConverter::convert(OOX::Vml::CBackground *vml_background)
{
}
void OoxConverter::convert(OOX::Vml::CFill *vml_fill)
{
if (vml_fill == NULL) return;
odf_context()->drawing_context()->start_area_properies();
odf_context()->drawing_context()->end_area_properies();
}
void OoxConverter::convert(OOX::Vml::CLine *vml_line)
{
if (vml_line == NULL) return;
convert(vml_line->m_oStyle.GetPointer());
}
void OoxConverter::convert(OOX::Vml::COval *vml_oval)
{
if (vml_oval == NULL) return;
convert(vml_oval->m_oStyle.GetPointer());
}
void OoxConverter::convert(OOX::Vml::CPath *vml_path)
{
}
void OoxConverter::convert(OOX::Vml::CPolyLine *vml_polyline)
{
}
void OoxConverter::convert(OOX::Vml::CRect *vml_rect)
{
if (vml_rect == NULL) return;
convert(vml_rect->m_oStyle.GetPointer());
}
void OoxConverter::convert(OOX::Vml::CRoundRect *vml_roundrect)
{
if (vml_roundrect == NULL) return;
convert(vml_roundrect->m_oStyle.GetPointer());
}
void OoxConverter::convert(OOX::Vml::CCurve *vml_curve)
{
if (vml_curve == NULL) return;
}
void OoxConverter::convert(OOX::Vml::CShadow *vml_shadow)
{
if (vml_shadow == NULL) return;
if (vml_shadow->m_oOn.GetValue() == false) return;
std::wstring hexColor = string2std_string(vml_shadow->m_oColor.ToString());
_CP_OPT(double) opacity = vml_shadow->m_oOpacity.GetValue();
double offset_x = vml_shadow->m_oOffset.IsXinPoints() ? vml_shadow->m_oOffset.GetX() : -1;
double offset_y = vml_shadow->m_oOffset.IsYinPoints() ? vml_shadow->m_oOffset.GetY() : -1;
odf_context()->drawing_context()->set_shadow(1,hexColor,opacity,offset_x, offset_y);
}
void OoxConverter::convert(OOX::Vml::CStroke *vml_stroke)
{
if (vml_stroke == NULL) return;
if (vml_stroke->m_oOn.GetValue() == false) return;
//nullable<SimpleTypes::CColorType<SimpleTypes::colortypeBlack>> m_oColor2;
//SimpleTypes::Vml::CVmlDashStyle<SimpleTypes::Vml::vmldashstyleSolid> m_oDahsStyle;
//SimpleTypes::CStrokeEndCap<SimpleTypes::strokeendcapFlat> m_oEndCap;
//SimpleTypes::CFillType<SimpleTypes::filltypeSolid, 0> m_oFillType;
//SimpleTypes::CTrueFalse<SimpleTypes::booleanFalse> m_oForceDash;
//SimpleTypes::CStrokeJoinStyle<SimpleTypes::strokejoinstyleRound> m_oJoinStyle;
odf_context()->drawing_context()->start_line_properies();
//switch(vml_stroke->m_oFillType){}
std::wstring hexColor = string2std_string(vml_stroke->m_oColor.ToString());
if (hexColor.length() < 1)hexColor = L"000000";
odf_context()->drawing_context()->set_solid_fill(hexColor);
odf_context()->drawing_context()->set_opacity(vml_stroke->m_oOpacity.GetValue());
odf_context()->drawing_context()->set_line_width(vml_stroke->m_oWeight.GetValue());
switch(vml_stroke->m_oStartArrow.GetValue())
{
case SimpleTypes::strokearrowtypeBlock:
odf_context()->drawing_context()->set_line_head(SimpleTypes::lineendtypeStealth,vml_stroke->m_oStartArrowLength.GetValue(),vml_stroke->m_oStartArrowWidth.GetValue()); break;
case SimpleTypes::strokearrowtypeClassic:
odf_context()->drawing_context()->set_line_head(SimpleTypes::lineendtypeArrow,vml_stroke->m_oStartArrowLength.GetValue(),vml_stroke->m_oStartArrowWidth.GetValue()); break;
case SimpleTypes::strokearrowtypeDiamond:
odf_context()->drawing_context()->set_line_head(SimpleTypes::lineendtypeDiamond,vml_stroke->m_oStartArrowLength.GetValue(),vml_stroke->m_oStartArrowWidth.GetValue()); break;
case SimpleTypes::strokearrowtypeOpen:
odf_context()->drawing_context()->set_line_head(SimpleTypes::lineendtypeTriangle,vml_stroke->m_oStartArrowLength.GetValue(),vml_stroke->m_oStartArrowWidth.GetValue()); break;
case SimpleTypes::strokearrowtypeOval:
odf_context()->drawing_context()->set_line_head(SimpleTypes::lineendtypeOval,vml_stroke->m_oStartArrowLength.GetValue(),vml_stroke->m_oStartArrowWidth.GetValue()); break;
case SimpleTypes::strokearrowtypeNone:
default:
break;
}
switch(vml_stroke->m_oEndArrow.GetValue())
{
case SimpleTypes::strokearrowtypeBlock:
odf_context()->drawing_context()->set_line_tail(SimpleTypes::lineendtypeStealth,vml_stroke->m_oEndArrowLength.GetValue(),vml_stroke->m_oEndArrowWidth.GetValue()); break;
case SimpleTypes::strokearrowtypeClassic:
odf_context()->drawing_context()->set_line_tail(SimpleTypes::lineendtypeArrow,vml_stroke->m_oEndArrowLength.GetValue(),vml_stroke->m_oEndArrowWidth.GetValue()); break;
case SimpleTypes::strokearrowtypeDiamond:
odf_context()->drawing_context()->set_line_tail(SimpleTypes::lineendtypeDiamond,vml_stroke->m_oEndArrowLength.GetValue(),vml_stroke->m_oEndArrowWidth.GetValue()); break;
case SimpleTypes::strokearrowtypeOpen:
odf_context()->drawing_context()->set_line_tail(SimpleTypes::lineendtypeTriangle,vml_stroke->m_oEndArrowLength.GetValue(),vml_stroke->m_oEndArrowWidth.GetValue()); break;
case SimpleTypes::strokearrowtypeOval:
odf_context()->drawing_context()->set_line_tail(SimpleTypes::lineendtypeOval,vml_stroke->m_oEndArrowLength.GetValue(),vml_stroke->m_oEndArrowWidth.GetValue()); break;
case SimpleTypes::strokearrowtypeNone:
default:
break;
}
odf_context()->drawing_context()->end_line_properies();
}
void OoxConverter::convert(OOX::Vml::CTextbox *vml_textbox)
{
if (vml_textbox == NULL) return;
if (vml_textbox->m_oTxtbxContent.IsInit() == false) return;
if (vml_textbox->m_oTxtbxContent->m_arrItems.GetSize() < 1) return;
convert(vml_textbox->m_oStyle.GetPointer());
DocxConverter *docx_converter = dynamic_cast<DocxConverter*>(this);
odf_context()->start_text_context();
for (long i=0 ; i < vml_textbox->m_oTxtbxContent->m_arrItems.GetSize();i++)
{
if (docx_converter)docx_converter->convert(vml_textbox->m_oTxtbxContent->m_arrItems[i]);
}
odf_context()->drawing_context()->set_text( odf_context()->text_context());
odf_context()->end_text_context();
odf_context()->drawing_context()->set_textarea_wrap(true);
}
void OoxConverter::convert(OOX::Vml::CTextPath *vml_textpath)
{
}
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())
{
case SimpleTypes::wraptypeNone :
{
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())
{
switch(vml_wrap->m_oAnchorX->GetValue())
{
case SimpleTypes::horizontalanchorMargin:
odf_context()->drawing_context()->set_horizontal_rel(4); break;
case SimpleTypes::horizontalanchorPage:
odf_context()->drawing_context()->set_horizontal_rel(6); break;
case SimpleTypes::horizontalanchorText:
odf_context()->drawing_context()->set_horizontal_rel(1); break;//???? paragraph ????
case SimpleTypes::horizontalanchorChar:
default :
odf_context()->drawing_context()->set_horizontal_rel(0);
}
}
if (vml_wrap->m_oAnchorY.IsInit())
{
switch(vml_wrap->m_oAnchorY->GetValue())
{
case SimpleTypes::verticalanchorMargin:
odf_context()->drawing_context()->set_vertical_rel(0); break;
case SimpleTypes::verticalanchorPage:
odf_context()->drawing_context()->set_anchor(0); //page
odf_context()->drawing_context()->set_vertical_rel(5); break;
case SimpleTypes::verticalanchorText:
odf_context()->drawing_context()->set_vertical_rel(0); break;
case SimpleTypes::verticalanchorLine:
default :
odf_context()->drawing_context()->set_vertical_rel(2);//Line
}
}
}
void OoxConverter::convert(OOX::Vml::CGroup * vml_group)
{
if (vml_group == NULL) return;
odf_context()->drawing_context()->start_group(L"",1);
if (vml_group->m_oShapeGroup.IsInit())
{
convert(vml_group->m_oShapeGroup.GetPointer());
}
else
{
odf_context()->drawing_context()->start_drawing();
if (vml_group->m_oShapeOval.IsInit())
{
odf_context()->drawing_context()->start_shape(SimpleTypes::shapetypeEllipse);
convert(vml_group->m_oShapeOval.GetPointer());
convert(vml_group->m_oShape.GetPointer());
odf_context()->drawing_context()->end_shape();
}
else if (vml_group->m_oShapeLine.IsInit())
{
odf_context()->drawing_context()->start_shape(SimpleTypes::shapetypeLine);
convert(vml_group->m_oShapeLine.GetPointer());
convert(vml_group->m_oShape.GetPointer());
odf_context()->drawing_context()->end_shape();
}
else if (vml_group->m_oShapePolyLine.IsInit())
{
odf_context()->drawing_context()->start_shape(SimpleTypes::shapetypeLine);
convert(vml_group->m_oShapePolyLine.GetPointer());
convert(vml_group->m_oShape.GetPointer());
odf_context()->drawing_context()->end_shape();
}
else if (vml_group->m_oShapeArc.IsInit())
{
odf_context()->drawing_context()->start_shape(SimpleTypes::shapetypeLine);
convert(vml_group->m_oShapeArc.GetPointer());
convert(vml_group->m_oShape.GetPointer());
odf_context()->drawing_context()->end_shape();
}
else if (vml_group->m_oShapeRoundRect.IsInit())
{
odf_context()->drawing_context()->start_shape(SimpleTypes::shapetypeRoundRect);
convert(vml_group->m_oShapeRoundRect.GetPointer());
convert(vml_group->m_oShape.GetPointer());
odf_context()->drawing_context()->end_shape();
}
else if (vml_group->m_oShapeCurve.IsInit())
{
odf_context()->drawing_context()->start_shape(1000);
convert(vml_group->m_oShapeCurve.GetPointer());
convert(vml_group->m_oShape.GetPointer());
odf_context()->drawing_context()->end_shape();
}
else if (vml_group->m_oShapeType.IsInit())
{
OOX::Vml::SptType sptType = static_cast<OOX::Vml::SptType>(vml_group->m_oShapeType->m_oSpt.GetValue());
odf_context()->drawing_context()->start_shape(OOX::Spt2ShapeType(sptType));
convert(vml_group->m_oShapeType.GetPointer());
convert(vml_group->m_oShape.GetPointer());
odf_context()->drawing_context()->end_shape();
}
else // and oox_pic->m_oShapeRect
{
odf_context()->drawing_context()->start_shape(SimpleTypes::shapetypeRect);
OoxConverter::convert(vml_group->m_oShape.GetPointer());
odf_context()->drawing_context()->end_shape();
}
odf_context()->drawing_context()->end_drawing();
}
odf_context()->drawing_context()->end_group();
}
}
\ No newline at end of file
......@@ -69,6 +69,7 @@ BOOL OoxConverter::UpdateProgress(long nComplete)
return FALSE;
}
void OoxConverter::convert(OOX::WritingElement *oox_unknown)
{
if (oox_unknown == NULL)return;
......@@ -128,11 +129,52 @@ void OoxConverter::convert(OOX::WritingElement *oox_unknown)
odf_context()->drawing_context()->set_opacity(pAlpha->m_oAmt.GetValue());
}
}break;
case OOX::et_v_imagedata:
{
OOX::Vml::CImageData *vml = static_cast<OOX::Vml::CImageData*>(oox_unknown);
convert(vml);
}break;
case OOX::et_v_textbox:
{
OOX::Vml::CTextbox *vml = static_cast<OOX::Vml::CTextbox*>(oox_unknown);
convert(vml);
}break;
//case OOX::et_v_background:
//{
// OOX::Vml::CBackground *vml = static_cast<OOX::Vml::CBackground*>(oox_unknown);
// convert(vml);
//}break;
case OOX::et_v_path:
{
OOX::Vml::CPath *vml = static_cast<OOX::Vml::CPath*>(oox_unknown);
convert(vml);
}break;
case OOX::et_v_fill:
{
OOX::Vml::CFill *vml = static_cast<OOX::Vml::CFill*>(oox_unknown);
convert(vml);
}break;
case OOX::et_v_stroke:
{
OOX::Vml::CStroke *vml = static_cast<OOX::Vml::CStroke*>(oox_unknown);
convert(vml);
}break;
case OOX::et_wd_wrap:
{
OOX::VmlWord::CWrap *vml = static_cast<OOX::VmlWord::CWrap*>(oox_unknown);
convert(vml);
}break;
default:
{
std::wstringstream ss;
ss << L"[warning] : no convert element(" << oox_unknown->getType() << L")\n";
_CP_LOG(error) << ss.str();
OOX::Vml::CVmlShapeElements *vml = dynamic_cast<OOX::Vml::CVmlShapeElements*>(oox_unknown);
if (vml)convert( vml);
else
{
int ttt = (int) oox_unknown->getType();
std::wstringstream ss;
ss << L"[warning] : no convert element(" << oox_unknown->getType() << L")\n";
_CP_LOG(error) << ss.str();
}
}
}
}
......@@ -177,21 +219,41 @@ void OoxConverter::convert(OOX::Drawing::CStyleMatrixReference *style_matrix_ref
if (!theme || fmt_index <0) return;
CString color = style_matrix_ref->m_oShemeClr.m_oVal.ToString();
if (style_matrix_ref->getType() == OOX::et_a_fillRef && fmt_index < theme->m_oThemeElements.m_oFmtScheme.m_oFillStyleLst.m_arrItems.GetSize())
if (style_matrix_ref->getType() == OOX::et_a_fillRef)
{
switch(theme->m_oThemeElements.m_oFmtScheme.m_oFillStyleLst.m_arrItems[fmt_index]->getType())
if (fmt_index < 1000 && fmt_index < theme->m_oThemeElements.m_oFmtScheme.m_oFillStyleLst.m_arrItems.GetSize())
{
switch(theme->m_oThemeElements.m_oFmtScheme.m_oFillStyleLst.m_arrItems[fmt_index]->getType())
{
case OOX::et_a_blipFill:
convert((OOX::Drawing::CBlipFillProperties *)theme->m_oThemeElements.m_oFmtScheme.m_oFillStyleLst.m_arrItems[fmt_index], &color);break;
case OOX::et_a_gradFill:
convert((OOX::Drawing::CGradientFillProperties *)theme->m_oThemeElements.m_oFmtScheme.m_oFillStyleLst.m_arrItems[fmt_index], &color);break;
case OOX::et_a_pattFill:
convert((OOX::Drawing::CPatternFillProperties *)theme->m_oThemeElements.m_oFmtScheme.m_oFillStyleLst.m_arrItems[fmt_index], &color);break;
case OOX::et_a_solidFill:
convert((OOX::Drawing::CSolidColorFillProperties *)theme->m_oThemeElements.m_oFmtScheme.m_oFillStyleLst.m_arrItems[fmt_index], &color);break;
case OOX::Drawing::filltypeNo:
odf_context()->drawing_context()->set_no_fill();break;
}
}
else if (fmt_index > 1000 && ((fmt_index-1000) < theme->m_oThemeElements.m_oFmtScheme.m_oBgFillStyleLst.m_arrItems.GetSize()))
{
case OOX::et_a_blipFill:
convert((OOX::Drawing::CBlipFillProperties *)theme->m_oThemeElements.m_oFmtScheme.m_oFillStyleLst.m_arrItems[fmt_index], &color);break;
case OOX::et_a_gradFill:
convert((OOX::Drawing::CGradientFillProperties *)theme->m_oThemeElements.m_oFmtScheme.m_oFillStyleLst.m_arrItems[fmt_index], &color);break;
case OOX::et_a_pattFill:
convert((OOX::Drawing::CPatternFillProperties *)theme->m_oThemeElements.m_oFmtScheme.m_oFillStyleLst.m_arrItems[fmt_index], &color);break;
case OOX::et_a_solidFill:
convert((OOX::Drawing::CSolidColorFillProperties *)theme->m_oThemeElements.m_oFmtScheme.m_oFillStyleLst.m_arrItems[fmt_index], &color);break;
case OOX::Drawing::filltypeNo:
odf_context()->drawing_context()->set_no_fill();break;
fmt_index -= 1000;
switch(theme->m_oThemeElements.m_oFmtScheme.m_oBgFillStyleLst.m_arrItems[fmt_index]->getType())
{
case OOX::et_a_blipFill:
convert((OOX::Drawing::CBlipFillProperties *)theme->m_oThemeElements.m_oFmtScheme.m_oBgFillStyleLst.m_arrItems[fmt_index], &color);break;
case OOX::et_a_gradFill:
convert((OOX::Drawing::CGradientFillProperties *)theme->m_oThemeElements.m_oFmtScheme.m_oBgFillStyleLst.m_arrItems[fmt_index], &color);break;
case OOX::et_a_pattFill:
convert((OOX::Drawing::CPatternFillProperties *)theme->m_oThemeElements.m_oFmtScheme.m_oBgFillStyleLst.m_arrItems[fmt_index], &color);break;
case OOX::et_a_solidFill:
convert((OOX::Drawing::CSolidColorFillProperties *)theme->m_oThemeElements.m_oFmtScheme.m_oBgFillStyleLst.m_arrItems[fmt_index], &color);break;
case OOX::Drawing::filltypeNo:
odf_context()->drawing_context()->set_no_fill();break;
}
}
}
......@@ -200,7 +262,17 @@ void OoxConverter::convert(OOX::Drawing::CStyleMatrixReference *style_matrix_ref
convert(&theme->m_oThemeElements.m_oFmtScheme.m_oLineStyleLst.m_arrLn[fmt_index], &color);
}
if (style_matrix_ref->getType() == OOX::et_a_effectRef && fmt_index < theme->m_oThemeElements.m_oFmtScheme.m_oEffectStyleLst.m_arrEffectStyle.GetSize())
{
convert(theme->m_oThemeElements.m_oFmtScheme.m_oEffectStyleLst.m_arrEffectStyle[fmt_index].m_oEffectList.GetPointer(), &color);
//todooo
//convert(theme->m_oThemeElements.m_oFmtScheme.m_oEffectStyleLst.m_arrEffectStyle[fmt_index].m_oEffectDag.GetPointer(), &color);
//convert(theme->m_oThemeElements.m_oFmtScheme.m_oEffectStyleLst.m_arrEffectStyle[fmt_index].m_oScene3D.GetPointer(), &color);
//convert(theme->m_oThemeElements.m_oFmtScheme.m_oEffectStyleLst.m_arrEffectStyle[fmt_index].m_oSp3D.GetPointer(), &color);
}
}
void OoxConverter::convert(OOX::Drawing::CShapeProperties * oox_spPr, OOX::Drawing::CShapeStyle* oox_sp_style)
{
if (!oox_spPr) return;
......@@ -249,11 +321,20 @@ void OoxConverter::convert(OOX::Drawing::CShapeProperties * oox_spPr, OOX::Dra
}
}
odf_context()->drawing_context()->end_line_properies();
////////
//-----------------------------------------------------------------------------------------------------------------------------
if (oox_spPr->m_oEffectList.IsInit())
convert(oox_spPr->m_oEffectList.GetPointer());
else if ((oox_sp_style) && (oox_sp_style->m_oEffectRef.getType() == OOX::et_a_effectRef))
{
convert(&oox_sp_style->m_oEffectRef);
}
//shadow
///////////
//nullable<OOX::Drawing::CEffectContainer> m_oEffectDag;
//nullable<OOX::Drawing::COfficeArtExtensionList> m_oExtLst;
//nullable<OOX::Drawing::CScene3D> m_oScene3D;
//nullable<OOX::Drawing::CShape3D> m_oSp3D;
//-----------------------------------------------------------------------------------------------------------------------------
if (oox_spPr->m_oXfrm.IsInit()) //CTransform2D
{
if (oox_spPr->m_oXfrm->m_oOff.IsInit())
......@@ -274,12 +355,6 @@ void OoxConverter::convert(OOX::Drawing::CShapeProperties * oox_spPr, OOX::Dra
odf_context()->drawing_context()->set_rotate(oox_spPr->m_oXfrm->m_oRot.GetValue());
}
//nullable<OOX::Drawing::CEffectContainer> m_oEffectDag;
//nullable<OOX::Drawing::CEffectList> m_oEffectList;
//nullable<OOX::Drawing::COfficeArtExtensionList> m_oExtLst;
//nullable<OOX::Drawing::CScene3D> m_oScene3D;
//nullable<OOX::Drawing::CShape3D> m_oSp3D;
}
void OoxConverter::convert(OOX::Drawing::CNonVisualDrawingProps * oox_cnvPr)
......@@ -389,10 +464,90 @@ void OoxConverter::convert(OOX::Drawing::CPath2D *oox_geom_path)
convert(oox_geom_path->m_arrItems[i]);
}
}
//////////////////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------------------------------------------
void OoxConverter::convert(OOX::Drawing::CEffectList *oox_effect_list, CString *change_sheme_color)
{
if (oox_effect_list == NULL) return;
for (long i=0;i< oox_effect_list->m_arrEffects.GetSize(); i++)
{
switch(oox_effect_list->m_arrEffects[i]->getType())
{
case OOX::et_a_outerShdw:
{
OOX::Drawing::COuterShadowEffect * shadow = static_cast<OOX::Drawing::COuterShadowEffect *>(oox_effect_list->m_arrEffects[i]);
convert(shadow, change_sheme_color);
}break;
case OOX::et_a_innerShdw:
{
OOX::Drawing::CInnerShadowEffect * shadow = static_cast<OOX::Drawing::CInnerShadowEffect *>(oox_effect_list->m_arrEffects[i]);
convert(shadow, change_sheme_color);
}break;
case OOX::et_a_prstShdw:
{
OOX::Drawing::CPresetShadowEffect * shadow = static_cast<OOX::Drawing::CPresetShadowEffect *>(oox_effect_list->m_arrEffects[i]);
//convert(shadow, change_sheme_color);
}break;
case OOX::et_a_reflection:
{
OOX::Drawing::CReflectionEffect * refelection = static_cast<OOX::Drawing::CReflectionEffect *>(oox_effect_list->m_arrEffects[i]);
}
//CGlowEffect, CBlurEffect, CFillOverlayEffect, CSoftEdgesEffect
}
}
}
void OoxConverter::convert(OOX::Drawing::COuterShadowEffect *oox_shadow, CString *change_sheme_color)
{
if (oox_shadow == NULL) return;
std::wstring hexColor;
_CP_OPT(double) opacity;
CString keep_sheme_color;
if (oox_shadow->m_eType == OOX::Drawing::colorSheme && change_sheme_color)
{
keep_sheme_color = oox_shadow->m_oShemeClr.m_oVal.ToString();
oox_shadow->m_oShemeClr.m_oVal.FromString(*change_sheme_color);
}
convert(static_cast<OOX::Drawing::CColor*>(oox_shadow), hexColor, opacity);
if (keep_sheme_color.GetLength() > 0) oox_shadow->m_oShemeClr.m_oVal.FromString(keep_sheme_color);
odf_context()->drawing_context()->set_shadow(1, hexColor, opacity, oox_shadow->m_oDist.ToPoints());
//SimpleTypes::CPositiveFixedAngle<0> m_oDir;
//SimpleTypes::CPositiveCoordinate<0> m_oBlurRad;
//-------------
//SimpleTypes::CRectAlignment<SimpleTypes::rectalignmentB> m_oAlgn;
//SimpleTypes::CFixedAngle<> m_oKx;
//SimpleTypes::CFixedAngle<> m_oKy;
//SimpleTypes::COnOff<SimpleTypes::onoffTrue> m_oRotWithShape;
//SimpleTypes::CPercentage m_oSx;
//SimpleTypes::CPercentage m_oSy;
}
void OoxConverter::convert(OOX::Drawing::CInnerShadowEffect *oox_shadow, CString *change_sheme_color)
{
if (oox_shadow == NULL) return;
std::wstring hexColor;
_CP_OPT(double) opacity;
CString keep_sheme_color;
if (oox_shadow->m_eType == OOX::Drawing::colorSheme && change_sheme_color)
{
keep_sheme_color = oox_shadow->m_oShemeClr.m_oVal.ToString();
oox_shadow->m_oShemeClr.m_oVal.FromString(*change_sheme_color);
}
convert(static_cast<OOX::Drawing::CColor*>(oox_shadow), hexColor, opacity);
if (keep_sheme_color.GetLength() > 0) oox_shadow->m_oShemeClr.m_oVal.FromString(keep_sheme_color);
odf_context()->drawing_context()->set_shadow(2, hexColor, opacity, oox_shadow->m_oDist.ToPoints());
}
//-----------------------------------------------------------------------------------------------------------------
void OoxConverter::convert(OOX::Drawing::CBlipFillProperties *oox_bitmap_fill, CString *change_sheme_color)
{
if (!oox_bitmap_fill)return;
if (oox_bitmap_fill == NULL)return;
odf_context()->drawing_context()->start_bitmap_style();
{
......
......@@ -8,7 +8,6 @@
#include "..\progressCallback.h"
static std::wstring string2std_string(CString val)
{
return std::wstring(val.GetBuffer());
......@@ -83,6 +82,9 @@ namespace OOX
class CColor;
class CShapeStyle;
class CStyleMatrixReference;
class CEffectList;
class COuterShadowEffect;
class CInnerShadowEffect;
namespace Colors
{
......@@ -233,6 +235,42 @@ namespace OOX
class CRichText;
class CTextProperties;
}
namespace Vml
{
class CVmlShapeElements;
class CShapeType;
class CShape;
class CImage;
class CImageData;
class CArc;
class CBackground;
class CCurve;
class CFill;
class CLine;
class COval;
class CPath ;
class CPolyLine ;
class CRect;
class CRoundRect;
class CShadow;
class CStroke;
class CTextbox;
class CTextPath;
class CGroup;
}
namespace VmlWord
{
class CWrap;
}
}
namespace SimpleTypes
{
namespace Vml
{
class CCssStyle;
}
}
namespace Oox2Odf
......@@ -244,16 +282,21 @@ public:
virtual void write(const std::wstring & path) = 0;
OoxConverter(const ProgressCallback* CallBack = NULL){oox_current_chart = NULL; pCallBack = CallBack;bUserStopConvert = 0;}
const ProgressCallback* pCallBack;
short bUserStopConvert;
BOOL UpdateProgress(long nComplete);
//.......................................................................................................................
virtual cpdoccore::odf::odf_conversion_context *odf_context() = 0;
virtual OOX::CTheme *oox_theme() = 0;
virtual CString find_link_by_id(CString sId, int t) = 0;
OOX::Spreadsheet::CChartSpace *oox_current_chart;
//.......................................................................................................................
void convert(OOX::WritingElement *oox_unknown);
void convert(double oox_font_size, cpdoccore::_CP_OPT(cpdoccore::odf::font_size) & odf_font_size);
//.drawing......................................................................................................................
void convert(OOX::Drawing::CNonVisualDrawingProps *oox_cnvPr);
void convert(OOX::Drawing::CShapeProperties *oox_spPr, OOX::Drawing::CShapeStyle* oox_sp_style = NULL);
void convert(OOX::Drawing::CGroupShapeProperties *oox_groupSpPr);
......@@ -268,8 +311,12 @@ public:
void convert(OOX::Drawing::CGradientFillProperties *oox_grad_fill , CString *change_sheme_color = NULL);
void convert(OOX::Drawing::CPatternFillProperties *oox_pattern_fill, CString *change_sheme_color = NULL);
void convert(OOX::Drawing::CSolidColorFillProperties *oox_solid_fill , CString *change_sheme_color = NULL);
void convert(OOX::Drawing::CEffectList *oox_effect_list, CString *change_sheme_color = NULL);
void convert(OOX::Drawing::COuterShadowEffect *oox_shadow, CString *change_sheme_color = NULL);
void convert(OOX::Drawing::CInnerShadowEffect *oox_shadow, CString *change_sheme_color = NULL);
void convert(OOX::Drawing::CStyleMatrixReference *style_matrix_ref);
//////////////////////////////////////////////
void convert(OOX::Drawing::CPath2D *oox_geom_path);
void convert(OOX::Drawing::CPath2DLineTo *oox_geom_path);
void convert(OOX::Drawing::CPath2DMoveTo *oox_geom_path);
......@@ -277,19 +324,17 @@ public:
void convert(OOX::Drawing::CPath2DQuadBezierTo *oox_geom_path);
void convert(OOX::Drawing::CPath2DCubicBezierTo *oox_geom_path);
void convert(OOX::Drawing::CPath2DClose *oox_geom_path);
/////////////////////////////////////////
void convert(OOX::Drawing::CColor *oox_color, std::wstring & hexColor , cpdoccore::_CP_OPT(double) &opacity);
void convert(OOX::Drawing::CSchemeColor *oox_ShemeClr, std::wstring & hexString, cpdoccore::_CP_OPT(double) &opacity);
void convert(OOX::Drawing::Colors::CColorTransform *oox_ScrgbClr, std::wstring & hexString, cpdoccore::_CP_OPT(double) &opacity);
void convert(OOX::Drawing::CSolidColorFillProperties *oox_solid_fill,std::wstring & hexColor , cpdoccore::_CP_OPT(double) &opacity);
///////////////////////////////
void convert(OOX::Drawing::CParagraph *oox_paragraph);
void convert(OOX::Drawing::CParagraphProperty *oox_paragraph_pr, cpdoccore::odf::style_paragraph_properties * paragraph_properties);
void convert(OOX::Drawing::CRun *oox_run);
void convert(OOX::Drawing::CRunProperty *oox_run_pr, cpdoccore::odf::style_text_properties * text_properties);
void convert(OOX::Drawing::CLineSpacing *oox_spacing, cpdoccore::odf::length_or_percent & length_or_percent);
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//.chart............................................................................................................................
void convert(OOX::Spreadsheet::CT_ChartSpace *oox_chart);
void convert(OOX::Spreadsheet::CT_Title *ct_title);
void convert(OOX::Spreadsheet::CT_Legend *ct_legend);
......@@ -340,11 +385,31 @@ public:
void convert(OOX::Spreadsheet::CT_NumData *num_data);
void convert(OOX::Spreadsheet::CT_StrData *str_data, bool label = false);
//////////////////////////////////////////////////////////////////////////////////////////////////////////
void convert(double oox_font_size, cpdoccore::_CP_OPT(cpdoccore::odf::font_size) & odf_font_size);
const ProgressCallback* pCallBack;
short bUserStopConvert;
//.vml............................................................................................................................
void convert(OOX::Vml::CVmlShapeElements *vml);
void convert(OOX::Vml::CShapeType *vml_shape_type);
void convert(OOX::Vml::CShape *vml_shape);
void convert(OOX::Vml::CImage *vml_image);
void convert(OOX::Vml::CImageData *vml_image_data);
void convert(OOX::Vml::CArc *vml_arc);
void convert(OOX::Vml::CBackground *vml_background);
void convert(OOX::Vml::CCurve *vml_curve);
void convert(OOX::Vml::CFill *vml_fill);
void convert(OOX::Vml::CLine *vml_line);
void convert(OOX::Vml::COval *vml_oval);
void convert(OOX::Vml::CPath *vml_path);
void convert(OOX::Vml::CPolyLine *vml_polyline);
void convert(OOX::Vml::CRect *vml_rect);
void convert(OOX::Vml::CRoundRect *vml_roundrect);
void convert(OOX::Vml::CShadow *vml_shadow);
void convert(OOX::Vml::CStroke *vml_stroke);
void convert(OOX::Vml::CTextbox *vml_textbox);
void convert(OOX::Vml::CTextPath *vml_textpath);
void convert(SimpleTypes::Vml::CCssStyle *vml_style);
void convert(OOX::VmlWord::CWrap *vml_wrap);
void convert(OOX::Vml::CGroup *vml_group);
};
class Converter
......
......@@ -9,9 +9,10 @@
#include <DocxFormat\External\Hyperlink.h>
#include <XlsxFormat\Chart\Chart.h>
#include "VmlShapeTypes2Oox.h"
#include <boost/foreach.hpp>
#include "odf_conversion_context.h"
#include "odt_conversion_context.h"
#include "odf_text_context.h"
......@@ -191,6 +192,11 @@ void DocxConverter::convert(OOX::WritingElement *oox_unknown)
OOX::Logic::CShape* pShape = static_cast<OOX::Logic::CShape*>(oox_unknown);
convert(pShape);
}break;
case OOX::et_w_pict:
{
OOX::Logic::CPicture* pPic = static_cast<OOX::Logic::CPicture*>(oox_unknown);
convert(pPic);
}break;
case OOX::et_w_GroupShape:
{
OOX::Logic::CGroupShape* pGroupShape= static_cast<OOX::Logic::CGroupShape*>(oox_unknown);
......@@ -384,6 +390,18 @@ void DocxConverter::convert(OOX::Logic::CRun *oox_run)//wordprocessing 22.1.2.87
}
odt_context->end_run();
}
void DocxConverter::convert(OOX::Logic::CSym *oox_sym)
{
if (oox_sym == NULL) return;
if (oox_sym->m_oChar.IsInit() == false) return;
if (oox_sym->m_oFont.IsInit())
odt_context->text_context()->set_symbol_font(string2std_string(*oox_sym->m_oFont));
odt_context->text_context()->set_symbol_text(oox_sym->m_oChar->GetValue());
//odt_context->text_context()->add_text_content(std::wstring(L"/") + string2std_string(oox_sym->m_oChar->ToString()));
}
void DocxConverter::convert(OOX::Logic::CFldChar *oox_fld)
{
if (oox_fld == NULL) return;
......@@ -563,7 +581,6 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp
void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool root)
{
if (oox_section_pr == NULL) return;
bool needGenerateSection = true; //
odt_context->page_layout_context()->create_master_page(L"");
......@@ -624,11 +641,10 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
case SimpleTypes::sectionmarkEvenPage :
case SimpleTypes::sectionmarkNextPage :
case SimpleTypes::sectionmarkOddPage :
odt_context->add_section();
needGenerateSection = false; //???
break;
}
}
if (!root)odt_context->add_section();
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oBidi;
//nullable<ComplexTypes::Word::CDocGrid > m_oDocGrid;
......@@ -645,12 +661,12 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
//--------------------------------------------------------------------------------------------------------------------------------------------
if (oox_section_pr->m_oCols.IsInit() && oox_section_pr->m_oCols->m_oNum.IsInit())//
if ((oox_section_pr->m_oCols.IsInit()) && (oox_section_pr->m_oCols->m_oNum.IsInit()) && (oox_section_pr->m_oCols->m_oNum->GetValue() > 1))//
{
if (needGenerateSection) odt_context->add_section(); // /???
if (root)odt_context->add_section();
int count = oox_section_pr->m_oCols->m_oNum->GetValue();
double default_space_pt = -1;
if (oox_section_pr->m_oCols->m_oSpace.IsInit()) default_space_pt = oox_section_pr->m_oCols->m_oSpace->ToPoints();
......@@ -711,26 +727,23 @@ void DocxConverter::convert(OOX::Logic::CTblBorders *oox_border, odf::style_tabl
if (oox_border == NULL) return;
if (table_cell_properties == NULL) return;
std::wstring odf_border;
if (oox_border->m_oBottom.IsInit())
{
convert(oox_border->m_oBottom.GetPointer(), odf_border);
if (odf_border.length() >0 ) table_cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_bottom_ = odf_border;
}
if (oox_border->m_oTop.IsInit())
{
convert(oox_border->m_oTop.GetPointer(), odf_border);
if (odf_border.length() >0 ) table_cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_top_ = odf_border;
}
if (oox_border->m_oStart.IsInit())
std::wstring left,right,top,bottom, other;
convert(oox_border->m_oBottom.GetPointer() , bottom);
convert(oox_border->m_oTop.GetPointer() , top);
convert(oox_border->m_oStart.GetPointer() , left);
convert(oox_border->m_oEnd.GetPointer() , right);
if (bottom == top && top == left && left== right && bottom.length() > 0)
{
convert(oox_border->m_oStart.GetPointer(), odf_border);
if (odf_border.length() >0 ) table_cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_left_ = odf_border;
table_cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_ = left;
}
if (oox_border->m_oEnd.IsInit())
else
{
convert(oox_border->m_oEnd.GetPointer(), odf_border);
if (odf_border.length() >0 ) table_cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_right_ = odf_border;
if (bottom.length() >0 )table_cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_bottom_ = bottom;
if (top.length() >0 ) table_cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_top_ = top;
if (left.length() >0 ) table_cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_left_ = left;
if (right.length() >0 ) table_cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_right_ = right;
}
//nullable<ComplexTypes::Word::CBorder > m_oInsideH;
//nullable<ComplexTypes::Word::CBorder > m_oInsideV;
......@@ -740,32 +753,35 @@ void DocxConverter::convert(OOX::Logic::CTcBorders *oox_border, odf::style_tabl
if (oox_border == NULL) return;
if (table_cell_properties == NULL) return;
std::wstring odf_border;
if (oox_border->m_oBottom.IsInit())
{
convert(oox_border->m_oBottom.GetPointer(), odf_border);
if (odf_border.length() >0 ) table_cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_bottom_ = odf_border;
}
if (oox_border->m_oTop.IsInit())
std::wstring left,right,top,bottom, other;
convert(oox_border->m_oBottom.GetPointer() , bottom);
convert(oox_border->m_oTop.GetPointer() , top);
convert(oox_border->m_oStart.GetPointer() , left);
convert(oox_border->m_oEnd.GetPointer() , right);
if (bottom == top && top == left && left== right && bottom.length() > 0)
{
convert(oox_border->m_oTop.GetPointer(), odf_border);
if (odf_border.length() >0 ) table_cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_top_ = odf_border;
table_cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_ = left;
}
if (oox_border->m_oStart.IsInit())
else
{
convert(oox_border->m_oStart.GetPointer(), odf_border);
if (odf_border.length() >0 ) table_cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_left_ = odf_border;
if (bottom.length() >0 )table_cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_bottom_ = bottom;
if (top.length() >0 ) table_cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_top_ = top;
if (left.length() >0 ) table_cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_left_ = left;
if (right.length() >0 ) table_cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_right_ = right;
}
if (oox_border->m_oEnd.IsInit())
convert(oox_border->m_oTL2BR.GetPointer() , other);
if (other.length() >0 ) table_cell_properties->style_table_cell_properties_attlist_.style_diagonal_tl_br_ = other;
convert(oox_border->m_oTR2BL.GetPointer() , other);
if (other.length() >0 )
{
convert(oox_border->m_oEnd.GetPointer(), odf_border);
if (odf_border.length() >0 ) table_cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_right_ = odf_border;
table_cell_properties->style_table_cell_properties_attlist_.style_diagonal_bl_tr_ = other;
}
//nullable<ComplexTypes::Word::CBorder > m_oInsideH;
//nullable<ComplexTypes::Word::CBorder > m_oInsideV;
//nullable<ComplexTypes::Word::CBorder > m_oTL2BR;
//nullable<ComplexTypes::Word::CBorder > m_oTR2BL;
}
void DocxConverter::convert(OOX::Logic::CPBdr *oox_border, odf::style_paragraph_properties *paragraph_properties)
......@@ -773,27 +789,25 @@ void DocxConverter::convert(OOX::Logic::CPBdr *oox_border, odf::style_paragraph_
if (oox_border == NULL) return;
if (paragraph_properties == NULL) return;
std::wstring odf_border;
if (oox_border->m_oBottom.IsInit())
{
convert(oox_border->m_oBottom.GetPointer(), odf_border);
if (odf_border.length() >0 ) paragraph_properties->content().common_border_attlist_.fo_border_bottom_ = odf_border;
}
if (oox_border->m_oTop.IsInit())
{
convert(oox_border->m_oTop.GetPointer(), odf_border);
if (odf_border.length() >0 ) paragraph_properties->content().common_border_attlist_.fo_border_top_ = odf_border;
}
if (oox_border->m_oLeft.IsInit())
std::wstring left,right,top,bottom, other;
convert(oox_border->m_oBottom.GetPointer() , bottom);
convert(oox_border->m_oTop.GetPointer() , top);
convert(oox_border->m_oLeft.GetPointer() , left);
convert(oox_border->m_oRight.GetPointer() , right);
if (bottom == top && top == left && left== right && bottom.length() > 0)
{
convert(oox_border->m_oLeft.GetPointer(), odf_border);
if (odf_border.length() >0 ) paragraph_properties->content().common_border_attlist_.fo_border_left_ = odf_border;
paragraph_properties->content().common_border_attlist_.fo_border_ = left;
}
if (oox_border->m_oRight.IsInit())
else
{
convert(oox_border->m_oRight.GetPointer(), odf_border);
if (odf_border.length() >0 ) paragraph_properties->content().common_border_attlist_.fo_border_right_ = odf_border;
if (bottom.length() >0 )paragraph_properties->content().common_border_attlist_.fo_border_bottom_ = bottom;
if (top.length() >0 ) paragraph_properties->content().common_border_attlist_.fo_border_top_ = top;
if (left.length() >0 ) paragraph_properties->content().common_border_attlist_.fo_border_left_ = left;
if (right.length() >0 ) paragraph_properties->content().common_border_attlist_.fo_border_right_ = right;
}
//if (oox_border->m_oTL2BR.IsInit())
//{
// convert(oox_border->m_oTL2BR.GetPointer(), odf_border);
......@@ -803,42 +817,46 @@ void DocxConverter::convert(OOX::Logic::CPBdr *oox_border, odf::style_paragraph_
}
void DocxConverter::convert(ComplexTypes::Word::CBorder *borderProp, std::wstring & odf_border_prop)
{
odf_border_prop = L"";
if (!borderProp)return;
std::wstring border_style;
std::wstringstream border_style;
std::wstring border_color;
//nullable<SimpleTypes::COnOff<> > m_oFrame;
//nullable<SimpleTypes::COnOff<> > m_oShadow;
//nullable<SimpleTypes::CPointMeasure<> > m_oSpace;
//nullable<SimpleTypes::CUcharHexNumber<> > m_oThemeShade;
if (borderProp->m_oSz.IsInit()) border_style = boost::lexical_cast<std::wstring>(borderProp->m_oSz->ToPoints()) + L"pt";
else border_style = L"1pt";
odf::length length;
length = odf::length(borderProp->m_oSz.IsInit() ? borderProp->m_oSz->ToPoints() : 1 , odf::length::pt);
length = odf::length( length.get_value_unit(odf::length::cm), odf::length::cm);
border_style << length;
if (borderProp->m_oVal.IsInit())//266 styles oO
{
switch(borderProp->m_oVal->GetValue())
{
case SimpleTypes::bordervalueDotDash:
border_style += L" dashed";
border_style << L" dashed";
break;
case SimpleTypes::bordervalueDashed:
border_style += L" dashed";
border_style << L" dashed";
break;
case SimpleTypes::bordervalueDotted:
border_style += L" dotted";
border_style << L" dotted";
break;
case SimpleTypes::bordervalueDouble:
border_style += L" double";
border_style << L" double";
break;
case SimpleTypes::bordervalueSingle:
border_style += L" solid";
border_style << L" solid";
break;
case SimpleTypes::bordervalueNone:
border_style == L" none";
odf_border_prop == L"none";
return;
break;
}
}else border_style += L" solid";
}else border_style << L" solid";
///////////////////////////////////////////////////////////////////
_CP_OPT(odf::color) color;
......@@ -850,7 +868,7 @@ void DocxConverter::convert(ComplexTypes::Word::CBorder *borderProp, std::wstrin
if (color) border_color = color->get_hex_value();
else border_color = L"000000";
odf_border_prop = border_style + L" #" + border_color;
odf_border_prop = border_style.str() + L" #" + border_color;
}
void DocxConverter::convert(ComplexTypes::Word::CJc * oox_jc, _CP_OPT(odf::text_align) & align)
{
......@@ -875,19 +893,37 @@ void DocxConverter::convert(ComplexTypes::Word::CJc * oox_jc, _CP_OPT(odf::text
}
void DocxConverter::convert(SimpleTypes::CUniversalMeasure *oox_size, _CP_OPT(odf::length) & odf_size)
{
odf_size = boost::none;
if (oox_size == NULL)return;
odf_size = odf::length(oox_size->ToPoints(), odf::length::pt);
}
void DocxConverter::convert(SimpleTypes::CUniversalMeasure* oox_size, _CP_OPT(odf::length_or_percent) & odf_size)
{
odf_size = boost::none;
if (oox_size == NULL)return;
//odf_size = odf::percent(oox_size->ToPoints(());
odf_size = odf::length(oox_size->ToPoints(), odf::length::pt);
}
void DocxConverter::convert(ComplexTypes::Word::CTblWidth *oox_size, _CP_OPT(odf::length) & odf_size)
{
odf_size = boost::none;
if (oox_size == NULL)return;
if (oox_size->m_oW.IsInit() == false) return;
if (oox_size->m_oType.IsInit() && oox_size->m_oType->GetValue() == SimpleTypes::tblwidthDxa)
{
odf_size = odf::length(oox_size->m_oW->GetValue() / 20., odf::length::pt);
}
//tblwidthAuto = 0,
//tblwidthDxa = 1,
//tblwidthNil = 2,
//tblwidthPct = 3
}
void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf::style_text_properties * text_properties)
{
if (oox_run_pr == NULL) return;
......@@ -1037,15 +1073,113 @@ void DocxConverter::convert(OOX::Logic::CAlternateContent *oox_alt_content)
{
if (oox_alt_content == NULL)return;
for(int i = 0; i < oox_alt_content->m_arrChoiceItems.GetSize(); ++i)
for(int i = 0; i < oox_alt_content->m_arrChoiceItems.GetSize(); ++i) //
{
convert(oox_alt_content->m_arrChoiceItems[i]);
}
for(int i = 0; i < oox_alt_content->m_arrFallbackItems.GetSize(); ++i)
if (oox_alt_content->m_arrChoiceItems.GetSize() > 0) return; //
for(int i = 0; i < oox_alt_content->m_arrFallbackItems.GetSize(); ++i) //
// todooo ... choice ( )
{
convert(oox_alt_content->m_arrFallbackItems[i]);
}
}
///////////////////////////////////////
//old formating vml
void DocxConverter::convert(OOX::Logic::CPicture* oox_pic)
{
if (oox_pic == NULL) return;
odt_context->start_drawings();
odt_context->drawing_context()->set_anchor(odf::anchor_type::AsChar); //???
if (oox_pic->m_oShapeGroup.IsInit())
{
OoxConverter::convert(oox_pic->m_oShapeGroup.GetPointer());
}
else
{
if (oox_pic->m_oShape.IsInit())
OoxConverter::convert(oox_pic->m_oShape->m_oStyle.GetPointer());
odf_context()->drawing_context()->start_drawing();
if (oox_pic->m_oShapeOval.IsInit())
{
odf_context()->drawing_context()->start_shape(SimpleTypes::shapetypeEllipse);
OoxConverter::convert(oox_pic->m_oShape.GetPointer());
OoxConverter::convert(oox_pic->m_oShapeOval.GetPointer());
odf_context()->drawing_context()->end_shape();
}
else if (oox_pic->m_oShapeCurve.IsInit())
{
odf_context()->drawing_context()->start_shape(1000);
OoxConverter::convert(oox_pic->m_oShape.GetPointer());
OoxConverter::convert(oox_pic->m_oShapeCurve.GetPointer());
odf_context()->drawing_context()->end_shape();
}
else if (oox_pic->m_oShapeLine.IsInit())
{
odf_context()->drawing_context()->start_shape(SimpleTypes::shapetypeLine);
OoxConverter::convert(oox_pic->m_oShape.GetPointer());
OoxConverter::convert(oox_pic->m_oShapeLine.GetPointer());
odf_context()->drawing_context()->end_shape();
}
else if (oox_pic->m_oShapePolyLine.IsInit())
{
odf_context()->drawing_context()->start_shape(SimpleTypes::shapetypeLine);
OoxConverter::convert(oox_pic->m_oShape.GetPointer());
OoxConverter::convert(oox_pic->m_oShapePolyLine.GetPointer());
odf_context()->drawing_context()->end_shape();
}
else if (oox_pic->m_oShapeArc.IsInit())
{
odf_context()->drawing_context()->start_shape(SimpleTypes::shapetypeLine);
OoxConverter::convert(oox_pic->m_oShape.GetPointer());
OoxConverter::convert(oox_pic->m_oShapeArc.GetPointer());
odf_context()->drawing_context()->end_shape();
}
else if (oox_pic->m_oShapeRoundRect.IsInit())
{
odf_context()->drawing_context()->start_shape(SimpleTypes::shapetypeRoundRect);
OoxConverter::convert(oox_pic->m_oShape.GetPointer());
OoxConverter::convert(oox_pic->m_oShapeRoundRect.GetPointer());
odf_context()->drawing_context()->end_shape();
}
else if (oox_pic->m_oShapeType.IsInit())
{
OOX::Vml::SptType sptType = static_cast<OOX::Vml::SptType>(oox_pic->m_oShapeType->m_oSpt.GetValue());
odf_context()->drawing_context()->start_shape(OOX::Spt2ShapeType(sptType));
OoxConverter::convert(oox_pic->m_oShape.GetPointer());
OoxConverter::convert(oox_pic->m_oShapeType.GetPointer());
odf_context()->drawing_context()->end_shape();
}
else // and oox_pic->m_oShapeRect
{
odf_context()->drawing_context()->start_shape(SimpleTypes::shapetypeRect);
OoxConverter::convert(oox_pic->m_oShape.GetPointer());
odf_context()->drawing_context()->end_shape();
}
odf_context()->drawing_context()->end_drawing();
}
odt_context->end_drawings();
}
///////////////////////////////////////////////
void DocxConverter::convert(OOX::Logic::CDrawing *oox_drawing)
{
if (oox_drawing == NULL) return;
......@@ -1152,7 +1286,6 @@ void DocxConverter::convert(OOX::Drawing::CGraphic *oox_graphic)
convert(oox_graphic->m_oShape.GetPointer());
convert(oox_graphic->m_oGroupShape.GetPointer());
}
void DocxConverter::convert(OOX::Drawing::CPicture * oox_picture)
{
if (!oox_picture)return;
......@@ -1474,6 +1607,20 @@ void DocxConverter::convert(OOX::CDocDefaults *def_style)
convert(def_style->m_oRunPr.GetPointer(), text_properties);
}
///////////////////////////////////////////////////////////////////////////
odt_context->styles_context()->create_default_style(odf::style_family::Table);
odf::style_table_properties * table_properties = odt_context->styles_context()->last_state().get_table_properties();
// -
table_properties->table_format_properties_.table_border_model_ = odf::border_model(odf::border_model::Collapsing);
odt_context->styles_context()->create_default_style(odf::style_family::TableRow);
odf::style_table_row_properties * row_properties = odt_context->styles_context()->last_state().get_table_row_properties();
row_properties->style_table_row_properties_attlist_.fo_keep_together_ = odf::keep_together(odf::keep_together::Auto);
/////////////////////////////////////////////////////////////////////////////////////////////////
// ?! OpenOffice / - oO !!!
odt_context->styles_context()->create_style(L"Frame", odf::style_family::Graphic,false,true);
}
......@@ -1684,6 +1831,24 @@ void DocxConverter::convert(OOX::Logic::CTbl *oox_table)
m_bKeepNextParagraph = false;
}
bool in_frame = false;
if(oox_table->m_oTableProperties && oox_table->m_oTableProperties->m_oTblpPr.IsInit() &&
(oox_table->m_oTableProperties->m_oTblpPr->m_oTblpX.IsInit() && oox_table->m_oTableProperties->m_oTblpPr->m_oTblpY.IsInit()))
{
in_frame = true;
odt_context->start_paragraph();
odt_context->start_drawings();
odt_context->drawing_context()->set_anchor(odf::anchor_type::Paragraph);
odt_context->drawing_context()->set_drawings_rect(oox_table->m_oTableProperties->m_oTblpPr->m_oTblpX->ToPoints(),
oox_table->m_oTableProperties->m_oTblpPr->m_oTblpY->ToPoints(), -1, -1);
odt_context->drawing_context()->start_drawing();
odt_context->drawing_context()->start_text_box();
odt_context->drawing_context()->set_name(L"TableFrame");
odt_context->drawing_context()->set_no_fill();
odt_context->start_text_context();
}
convert(oox_table->m_oTableProperties);
odt_context->start_table(true);
......@@ -1724,11 +1889,28 @@ void DocxConverter::convert(OOX::Logic::CTbl *oox_table)
convert(oox_table->m_arrItems[i]);
}
}
if (in_frame)
{
odt_context->drawing_context()->set_size(odt_context->table_context()->get_table_width(), -1);
odt_context->drawing_context()->set_text_box_min_size(-1,0);
}
odt_context->end_table();
if (odt_context->table_context()->is_styled())
odt_context->styles_context()->table_styles().end_table();
if (in_frame)
{
odt_context->drawing_context()->set_text( odt_context->text_context());
odt_context->end_text_context();
odt_context->drawing_context()->end_text_box();
odt_context->drawing_context()->end_drawing();
odt_context->end_drawings();
odt_context->end_paragraph();
}
}
void DocxConverter::convert(OOX::Logic::CTblGrid *oox_table_grid)
{
......@@ -1833,48 +2015,122 @@ bool DocxConverter::convert(OOX::Logic::CTableProperty *oox_table_pr, odf::style
if (oox_table_pr == NULL) return false;
if (table_properties == NULL) return false;
if (oox_table_pr->m_oTblW.IsInit())
{
if ((oox_table_pr->m_oTblW->m_oType.IsInit() && oox_table_pr->m_oTblW->m_oType->GetValue() == SimpleTypes::tblwidthDxa) &&
(oox_table_pr->m_oTblW->m_oW.IsInit() && oox_table_pr->m_oTblW->m_oW->GetValue() >0))
{
if (oox_table_pr->m_oTblW->m_oW->IsPercent() == false)
odt_context->table_context()->set_default_column_width(oox_table_pr->m_oTblW->m_oW->GetValue()/20.);
}
}
if (oox_table_pr->m_oTblStyleColBandSize.IsInit())
{
}
if (oox_table_pr->m_oTblStyleRowBandSize.IsInit())
{
}
if (oox_table_pr->m_oTblInd.IsInit())// -
{
_CP_OPT(odf::length) length;
convert(oox_table_pr->m_oTblInd.GetPointer(), length);
table_properties->table_format_properties_.common_horizontal_margin_attlist_.fo_margin_left_ = odf::length(length->get_value_unit(odf::length::cm),odf::length::cm);
table_properties->table_format_properties_.table_align_ = odf::table_align(odf::table_align::Left);
}
else if(oox_table_pr->m_oTblpPr.IsInit()) //,
{
table_properties->table_format_properties_.table_align_ = odf::table_align(odf::table_align::Left);
if (oox_table_pr->m_oTblpPr->m_oTblpX.IsInit() && oox_table_pr->m_oTblpPr->m_oTblpY.IsInit()){}//floating position
else
{
_CP_OPT(odf::length) length;
convert(static_cast<SimpleTypes::CUniversalMeasure *>(oox_table_pr->m_oTblpPr->m_oLeftFromText.GetPointer()), length);
table_properties->table_format_properties_.common_horizontal_margin_attlist_.fo_margin_left_ = odf::length(length->get_value_unit(odf::length::cm),odf::length::cm);
convert(static_cast<SimpleTypes::CUniversalMeasure *>(oox_table_pr->m_oTblpPr->m_oRightFromText.GetPointer()), length);
table_properties->table_format_properties_.common_horizontal_margin_attlist_.fo_margin_right_= odf::length(length->get_value_unit(odf::length::cm),odf::length::cm);
convert(static_cast<SimpleTypes::CUniversalMeasure *>(oox_table_pr->m_oTblpPr->m_oTopFromText.GetPointer()), length);
table_properties->table_format_properties_.common_vertical_margin_attlist_.fo_margin_top_= odf::length(length->get_value_unit(odf::length::cm),odf::length::cm);
convert(static_cast<SimpleTypes::CUniversalMeasure *>(oox_table_pr->m_oTblpPr->m_oBottomFromText.GetPointer()), length);
table_properties->table_format_properties_.common_vertical_margin_attlist_.fo_margin_bottom_= odf::length(length->get_value_unit(odf::length::cm),odf::length::cm);
}
}
else if (oox_table_pr->m_oTblLayout.IsInit() && oox_table_pr->m_oTblLayout->m_oType.IsInit())
{
table_properties->table_format_properties_.common_horizontal_margin_attlist_.fo_margin_left_ = odf::length(0,odf::length::cm);
table_properties->table_format_properties_.table_align_ = odf::table_align(odf::table_align::Left);
}
//if(oox_table_pr->m_oJc.IsInit() && oox_table_pr->m_oJc->m_oVal.IsInit())
//{
//}
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oBidiVisual;
//nullable<ComplexTypes::Word::CJcTable > m_oJc;
//nullable<ComplexTypes::Word::CShading > m_oShade;
//nullable<OOX::Logic::CTblBorders > m_oTblBorders;
//nullable<ComplexTypes::Word::CString_ > m_oTblCaption;
//nullable<OOX::Logic::CTblCellMar > m_oTblCellMar;
//nullable<ComplexTypes::Word::CTblWidth > m_oTblCellSpacing;
//nullable<ComplexTypes::Word::CString_ > m_oTblDescription;
//nullable<ComplexTypes::Word::CTblWidth > m_oTblInd;
//nullable<ComplexTypes::Word::CTblLayoutType > m_oTblLayout;
//nullable<ComplexTypes::Word::CTblLook > m_oTblLook;
//nullable<ComplexTypes::Word::CTblOverlap > m_oTblOverlap;
//nullable<ComplexTypes::Word::CTblPPr > m_oTblpPr;
//nullable<OOX::Logic::CTblPrChange > m_oTblPrChange;
//nullable<ComplexTypes::Word::CString_ > m_oTblStyle;
//nullable<ComplexTypes::Word::CDecimalNumber > m_oTblStyleColBandSize;
//nullable<ComplexTypes::Word::CDecimalNumber > m_oTblStyleRowBandSize;
//nullable<ComplexTypes::Word::CTblWidth > m_oTblW;
return true;
}
void DocxConverter::convert(OOX::Logic::CTableProperty *oox_table_pr, odf::style_table_cell_properties * table_cell_properties)
{
if (oox_table_pr == NULL || oox_table_pr == NULL) return;
convert(oox_table_pr->m_oTblBorders.GetPointer(), table_cell_properties);
if (oox_table_pr->m_oTblCellMar.IsInit())
{
_CP_OPT(odf::length) length;
convert(oox_table_pr->m_oTblCellMar->m_oStart.GetPointer(), length);
if (length)table_cell_properties->style_table_cell_properties_attlist_.common_padding_attlist_.fo_padding_left_ = odf::length(length->get_value_unit(odf::length::cm),odf::length::cm);
convert(oox_table_pr->m_oTblCellMar->m_oEnd.GetPointer(), length);
if (length)table_cell_properties->style_table_cell_properties_attlist_.common_padding_attlist_.fo_padding_right_ = odf::length(length->get_value_unit(odf::length::cm),odf::length::cm);
convert(oox_table_pr->m_oTblCellMar->m_oTop.GetPointer(), length);
if (length)table_cell_properties->style_table_cell_properties_attlist_.common_padding_attlist_.fo_padding_top_ = odf::length(length->get_value_unit(odf::length::cm),odf::length::cm);
convert(oox_table_pr->m_oTblCellMar->m_oBottom.GetPointer(), length);
if (length)table_cell_properties->style_table_cell_properties_attlist_.common_padding_attlist_.fo_padding_bottom_ = odf::length(length->get_value_unit(odf::length::cm),odf::length::cm);
}
}
bool DocxConverter::convert(OOX::Logic::CTableProperty *oox_table_pr)
{
odt_context->styles_context()->create_style(L"",odf::style_family::Table, true, false, -1); // cells
if (oox_table_pr == NULL) return false;
odf::style_table_properties * table_properties = odt_context->styles_context()->last_state().get_table_properties();
convert(oox_table_pr, table_properties);
if (oox_table_pr->m_oTblBorders.IsInit())
{// cell_prop - default-cell-style-name columns & row
//
odt_context->styles_context()->create_style(L"",odf::style_family::TableCell, true, false, -1); // cells
odt_context->styles_context()->last_state().set_dont_write(true);
odf::style_table_cell_properties * table_cell_properties = odt_context->styles_context()->last_state().get_table_cell_properties();
convert(oox_table_pr->m_oTblBorders.GetPointer(), table_cell_properties);
}
///////////////////////////////////////////////////////////////////////////
// -
table_properties->table_format_properties_.table_border_model_ = odf::border_model(odf::border_model::Collapsing);
convert(oox_table_pr, table_cell_properties);
odt_context->table_context()->set_default_cell_properties(odt_context->styles_context()->last_state().get_name());
}
odt_context->styles_context()->create_style(L"",odf::style_family::Table, true, false, -1); // cells
if (oox_table_pr == NULL) return false;
odf::style_table_properties * table_properties = odt_context->styles_context()->last_state().get_table_properties();
convert(oox_table_pr, table_properties);
return true;
}
void DocxConverter::convert(OOX::Logic::CTableRowProperties *oox_table_row_pr, odf::style_table_row_properties * table_row_properties)
......@@ -1942,26 +2198,70 @@ bool DocxConverter::convert(OOX::Logic::CTableCellProperties *oox_table_cell_pr,
table_cell_properties->style_table_cell_properties_attlist_.common_background_color_attlist_.fo_background_color_ = *odf_color;
}
if (oox_table_cell_pr->m_oTextDirection.IsInit())
if (oox_table_cell_pr->m_oTextDirection.IsInit() && oox_table_cell_pr->m_oTextDirection->m_oVal.IsInit())
{
switch(oox_table_cell_pr->m_oTextDirection->m_oVal->GetValue())
{
case SimpleTypes::textdirectionLr :
table_cell_properties->style_table_cell_properties_attlist_.style_direction_ = odf::direction(odf::direction::Ltr);break;
case SimpleTypes::textdirectionLrV :
case SimpleTypes::textdirectionTb ://
case SimpleTypes::textdirectionTbV :
case SimpleTypes::textdirectionRlV :
table_cell_properties->style_table_cell_properties_attlist_.style_direction_ = odf::direction(odf::direction::Ttb);break;
case SimpleTypes::textdirectionRl ://rtl
break;
}
}
convert(oox_table_cell_pr->m_oTcBorders.GetPointer() , table_cell_properties);
if (oox_table_cell_pr->m_oTcMar.IsInit())
{
_CP_OPT(odf::length) length;
convert(oox_table_cell_pr->m_oTcMar->m_oStart.GetPointer(), length);
if (length)table_cell_properties->style_table_cell_properties_attlist_.common_padding_attlist_.fo_padding_left_ = odf::length(length->get_value_unit(odf::length::cm),odf::length::cm);
convert(oox_table_cell_pr->m_oTcMar->m_oEnd.GetPointer(), length);
if (length)table_cell_properties->style_table_cell_properties_attlist_.common_padding_attlist_.fo_padding_right_ = odf::length(length->get_value_unit(odf::length::cm),odf::length::cm);
convert(oox_table_cell_pr->m_oTcMar->m_oTop.GetPointer(), length);
if (length)table_cell_properties->style_table_cell_properties_attlist_.common_padding_attlist_.fo_padding_top_ = odf::length(length->get_value_unit(odf::length::cm),odf::length::cm);
convert(oox_table_cell_pr->m_oTcMar->m_oBottom.GetPointer(), length);
if (length)table_cell_properties->style_table_cell_properties_attlist_.common_padding_attlist_.fo_padding_bottom_ = odf::length(length->get_value_unit(odf::length::cm),odf::length::cm);
}
if (oox_table_cell_pr->m_oVAlign.IsInit() && oox_table_cell_pr->m_oVAlign->m_oVal.IsInit())
{
switch(oox_table_cell_pr->m_oVAlign->m_oVal->GetValue())
{
case SimpleTypes::verticaljcBoth : //??????
table_cell_properties->style_table_cell_properties_attlist_.style_vertical_align_ = odf::vertical_align(odf::vertical_align::Justify); break;
case SimpleTypes::verticaljcBottom :
table_cell_properties->style_table_cell_properties_attlist_.style_vertical_align_ = odf::vertical_align(odf::vertical_align::Bottom); break;
case SimpleTypes::verticaljcCenter :
table_cell_properties->style_table_cell_properties_attlist_.style_vertical_align_ = odf::vertical_align(odf::vertical_align::Middle); break;
case SimpleTypes::verticaljcTop :
table_cell_properties->style_table_cell_properties_attlist_.style_vertical_align_ = odf::vertical_align(odf::vertical_align::Top); break;
}
}
if (oox_table_cell_pr->m_oTcFitText.IsInit() )
{
table_cell_properties->style_table_cell_properties_attlist_.style_shrink_to_fit_ = oox_table_cell_pr->m_oTcFitText->m_oVal.ToBool();
}
if (oox_table_cell_pr->m_oNoWrap.IsInit())
{
if (oox_table_cell_pr->m_oNoWrap->m_oVal.ToBool() == true)
table_cell_properties->style_table_cell_properties_attlist_.fo_wrap_option_ = odf::wrap_option(odf::wrap_option::NoWrap);
else
table_cell_properties->style_table_cell_properties_attlist_.fo_wrap_option_ = odf::wrap_option(odf::wrap_option::Wrap);
}
//nullable<ComplexTypes::Word::CTrackChange > m_oCellDel;
//nullable<ComplexTypes::Word::CTrackChange > m_oCellIns;
//nullable<ComplexTypes::Word::CCellMergeTrackChange > m_oCellMerge;
//nullable<ComplexTypes::Word::CCnf > m_oCnfStyle;
//nullable<OOX::Logic::CHeaders > m_oHeaders;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oHideMark;
//nullable<ComplexTypes::Word::CHMerge > m_oHMerge;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oNoWrap;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oTcFitText;
//nullable<OOX::Logic::CTcMar > m_oTcMar;
//nullable<OOX::Logic::CTcPrChange > m_oTcPrChange;
//nullable<ComplexTypes::Word::CTblWidth > m_oTcW;
//nullable<ComplexTypes::Word::CTextDirection > m_oTextDirection;
//nullable<ComplexTypes::Word::CVerticalJc > m_oVAlign;
return true;
}
bool DocxConverter::convert(OOX::Logic::CTableCellProperties *oox_table_cell_pr, int col)
......@@ -1973,9 +2273,15 @@ bool DocxConverter::convert(OOX::Logic::CTableCellProperties *oox_table_cell_pr,
odf::style_table_cell_properties * parent_cell_properties = NULL;
odf::odf_style_state * state = odt_context->styles_context()->last_state(odf::style_family::Table); //
// ,
if (state)parent_cell_properties = state->get_table_cell_properties();
std::wstring parent_name = odt_context->table_context()->get_default_cell_properties();
if (parent_name.length() > 0)
{
odf::style * style_ = NULL;
if (odt_context->styles_context()->find_odf_style(parent_name,odf::style_family::TableCell,style_))
{
parent_cell_properties = style_->style_content_.get_style_table_cell_properties();
}
}
if (oox_table_cell_pr == NULL && is_base_styled == false && parent_cell_properties == NULL) return false;
......
......@@ -20,6 +20,7 @@ namespace OOX
class CParagraph;
class CParagraphProperty;
class CRun;
class CSym;
class CRunProperty;
class CSectionProperty;
class CText;
......@@ -27,6 +28,7 @@ namespace OOX
class CDrawing;
class CGroupShape;
class CShape;
class CPicture;
class CPBdr;
class CHyperlink;
class CFldChar;
......@@ -57,6 +59,7 @@ namespace ComplexTypes
class CBorder;
class CShading;
class CFramePr;
class CTblWidth;
}
}
namespace cpdoccore
......@@ -89,6 +92,7 @@ namespace Oox2Odf
virtual OOX::CTheme *oox_theme();
virtual CString find_link_by_id (CString sId, int t);
void convert(OOX::WritingElement *oox_unknown);
private:
OOX::CDocx *docx_document;
cpdoccore::odf::package::odf_document *output_document;
......@@ -100,8 +104,6 @@ namespace Oox2Odf
void convert_styles();
void convert_comment(int oox_comm_id);
void convert(OOX::WritingElement *oox_unknown);
void convert(OOX::Logic::CSectionProperty *oox_section_pr, bool root = false);
void convert(OOX::Logic::CParagraph *oox_paragraph);
void convert(OOX::Logic::CRun *oox_run);
......@@ -113,18 +115,24 @@ namespace Oox2Odf
void convert(OOX::Logic::CInstrText *oox_instr);
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::CAlternateContent *oox_alt_content);
void convert(OOX::Logic::CDrawing *oox_drawing);
void convert(OOX::Drawing::CAnchor *oox_anchor);
void convert(OOX::Drawing::CInline *oox_inline);
void convert(OOX::Drawing::CGraphic *oox_graphic);
void convert(OOX::Logic::CGroupShape *oox_group_shape);
void convert(OOX::Logic::CShape *oox_shape);
void convert(OOX::Logic::CPicture *oox_picture);
void convert(OOX::Drawing::CAnchor *oox_anchor);
void convert(OOX::Drawing::CInline *oox_inline);
void convert(OOX::Drawing::CGraphic *oox_graphic);
void convert(OOX::Drawing::CChart *oox_chart);
void convert(OOX::Drawing::CPicture *oox_picture);
void convert(ComplexTypes::Word::CColor *color, _CP_OPT(odf::color) & odf_color);
void convert(SimpleTypes::CUniversalMeasure *oox_size, _CP_OPT(odf::length) & odf_size);
void convert(SimpleTypes::CUniversalMeasure *oox_size, _CP_OPT(odf::length_or_percent) & odf_size);
void convert(ComplexTypes::Word::CTblWidth *oox_size, _CP_OPT(odf::length) & odf_size);
void convert(ComplexTypes::Word::CJc *oox_jc, _CP_OPT(odf::text_align) & align);
void convert(ComplexTypes::Word::CBorder *borderProp, std::wstring & odf_border_prop);
......@@ -153,6 +161,7 @@ namespace Oox2Odf
bool convert(OOX::Logic::CTableCellProperties *oox_table_cell_pr, odf::style_table_cell_properties *table_cell_properties/*,odf::style_table_cell_properties * table_cell_properties = NULL*/);
bool convert(OOX::Logic::CTableProperty *oox_table_pr);
bool convert(OOX::Logic::CTableProperty *oox_table_pr, odf::style_table_properties *table_properties);
void convert(OOX::Logic::CTableProperty *oox_table_pr, odf::style_table_cell_properties *table_cell_properties);
void convert(OOX::Logic::CTableRowProperties *oox_table_row_pr);
void convert(OOX::Logic::CTableRowProperties *oox_table_row_pr, odf::style_table_row_properties *table_row_properties);
//--------------------------------------------------------------------------------
......
......@@ -1102,52 +1102,35 @@ void XlsxConverter::convert(OOX::Spreadsheet::CAligment *aligment, odf::style_pa
//nullable<SimpleTypes::CDecimalNumber<>> m_oRelativeIndent;
}
void XlsxConverter::convert(OOX::Spreadsheet::CBorder *border, odf::style_table_cell_properties * cell_properties)
void XlsxConverter::convert(OOX::Spreadsheet::CBorder *oox_border, odf::style_table_cell_properties * table_cell_properties)
{
if (!border)return;
if (!oox_border)return;
if (border->m_oBottom.IsInit())
{
std::wstring odf_border;
convert(border->m_oBottom.GetPointer(), odf_border);
cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_bottom_ = odf_border;
}
if (border->m_oTop.IsInit())
{
std::wstring odf_border;
convert(border->m_oTop.GetPointer(), odf_border);
cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_top_ = odf_border;
}
if (border->m_oStart.IsInit())
{
std::wstring odf_border;
convert(border->m_oStart.GetPointer(), odf_border);
if (odf_border.length()>0)
cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_left_ = odf_border;
}
if (border->m_oEnd.IsInit())
{
std::wstring odf_border;
convert(border->m_oEnd.GetPointer(), odf_border);
if (odf_border.length()>0)
cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_right_ = odf_border;
}
if (border->m_oEnd.IsInit())
std::wstring left,right,top,bottom, other;
convert(oox_border->m_oBottom.GetPointer() , bottom);
convert(oox_border->m_oTop.GetPointer() , top);
convert(oox_border->m_oStart.GetPointer() , left);
convert(oox_border->m_oEnd.GetPointer() , right);
if (bottom == top && top == left && left== right && bottom.length() > 0)
{
std::wstring odf_border;
convert(border->m_oEnd.GetPointer(), odf_border);
if (odf_border.length()>0)
cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_right_ = odf_border;
table_cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_ = left;
}
if (border->m_oDiagonal.IsInit())
else
{
std::wstring odf_border;
convert(border->m_oDiagonal.GetPointer(), odf_border);
if (border->m_oDiagonalDown.IsInit() && odf_border.length()>0) //and true???
cell_properties->style_table_cell_properties_attlist_.style_diagonal_tl_br_= odf_border;
if (border->m_oDiagonalUp.IsInit() && odf_border.length()>0) //and true???
cell_properties->style_table_cell_properties_attlist_.style_diagonal_bl_tr_= odf_border;
if (bottom.length() >0 )table_cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_bottom_ = bottom;
if (top.length() >0 ) table_cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_top_ = top;
if (left.length() >0 ) table_cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_left_ = left;
if (right.length() >0 ) table_cell_properties->style_table_cell_properties_attlist_.common_border_attlist_.fo_border_right_ = right;
}
convert(oox_border->m_oDiagonal.GetPointer(), other);
if (oox_border->m_oDiagonalDown.IsInit() && other.length()>0) //and true???
table_cell_properties->style_table_cell_properties_attlist_.style_diagonal_tl_br_= other;
if (oox_border->m_oDiagonalUp.IsInit() && other.length()>0) //and true???
table_cell_properties->style_table_cell_properties_attlist_.style_diagonal_bl_tr_= other;
//nullable<CBorderProp> m_oHorizontal;
//nullable<CBorderProp> m_oVertical;
//nullable<SimpleTypes::COnOff<>> m_oOutline;
......
......@@ -99,6 +99,7 @@ namespace Oox2Odf
virtual OOX::CTheme *oox_theme();
virtual CString find_link_by_id (CString sId, int t);
void convert(OOX::Spreadsheet::WritingElement *oox_unknown);
private:
OOX::Spreadsheet::CXlsx *xlsx_document;
odf::package::odf_document *output_document;
......@@ -107,9 +108,7 @@ namespace Oox2Odf
odf::ods_conversion_context *ods_context;
void convert_sheets();
void convert_styles();
void convert(OOX::Spreadsheet::WritingElement *oox_unknown);
void convert_styles();
void convert(OOX::Spreadsheet::CWorksheet *oox_sheet);
void convert(OOX::Spreadsheet::CDefinedName *oox_defined);
......
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