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

(1.2.0.100): ASCOfficeOdfFileW


git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@57459 954022d7-b5bf-4e40-9824-e11837661b57
parent d7a504eb
......@@ -50,8 +50,8 @@ public:
{std::wstringstream str; str <<L"Non add child in "; str << ns; str << L":"; str <<name; _CP_LOG(error) << str.str();}
virtual void serialize(std::wostream & strm);
style_header_footer_properties_attlist style_header_footer_properties_attlist_;
office_element_ptr style_background_image_;
style_header_footer_properties_attlist style_header_footer_properties_attlist_;
office_element_ptr style_background_image_;
};
CP_REGISTER_OFFICE_ELEMENT2(style_header_footer_properties);
......
......@@ -37,8 +37,8 @@ struct odf_group_state
{
odf_group_state(office_element_ptr elm_, int level_, odf_group_state_ptr prev)
{
delta_x = delta_y =x = y = rotate = 0;
koef_cx = koef_cy = 1.;
shift_x = shift_y =x = y = rotate = 0;
scale_cx = scale_cy = 1.;
flipH = flipV = false;
elm = elm_;
......@@ -50,14 +50,17 @@ struct odf_group_state
int level;
double delta_x;
double delta_y;
double shift_x;
double shift_y;
double x;
double y;
double koef_cx;
double koef_cy;
double cx;
double cy;
double scale_cx;
double scale_cy;
double rotate;
......@@ -280,23 +283,6 @@ void odf_drawing_context::end_group()
impl_->current_level_.pop_back();
}
void odf_drawing_context::set_group_flip_H(bool bVal)
{
if (impl_->group_list_.size()<1)return;
odf_group_state_ptr gr = impl_->current_group_;
int step = 2;
while (gr && step > 0)
{
bVal += gr->flipH;
gr = gr->prev_group;
step--;
}
impl_->group_list_.back()->flipH= bVal;
}
void odf_drawing_context::clear()
{
......@@ -315,12 +301,12 @@ void odf_drawing_context::start_drawing()
impl_->current_drawing_state_.svg_x_ = impl_->anchor_settings_.svg_x_;
impl_->current_drawing_state_.svg_y_ = impl_->anchor_settings_.svg_y_;
if (impl_->anchor_settings_.svg_x_ && impl_->anchor_settings_.style_horizontal_pos_svg_x_)//?????
if (impl_->anchor_settings_.style_horizontal_pos_svg_x_)//?????
{
impl_->current_drawing_state_.svg_x_ = /**impl_->current_drawing_state_.svg_x_ +*/ *impl_->anchor_settings_.style_horizontal_pos_svg_x_;
impl_->anchor_settings_.style_horizontal_pos_svg_x_= boost::none;
}
if (impl_->anchor_settings_.svg_x_ && impl_->anchor_settings_.style_vertical_pos_svg_y_)
if (impl_->anchor_settings_.style_vertical_pos_svg_y_)
{
impl_->current_drawing_state_.svg_y_ = /**impl_->current_drawing_state_.svg_y_ +*/ *impl_->anchor_settings_.style_vertical_pos_svg_y_;
impl_->anchor_settings_.style_vertical_pos_svg_y_= boost::none;
......@@ -955,68 +941,66 @@ void odf_drawing_context::set_group_position(double x, double y, double ch_x, do
{
if (impl_->group_list_.size()<1)return;
impl_->group_list_.back()->x = x;
impl_->group_list_.back()->y = y;
double back_x = 0;
double back_y = 0;
double k_x = 1;
double k_y = 1;
impl_->group_list_.back()->x = ch_x;
impl_->group_list_.back()->y = ch_y;
if (impl_->current_group_->prev_group)
{
back_x = /*impl_->current_group_->prev_group->koef_cx * */impl_->current_group_->prev_group->delta_x;
back_y = /*impl_->current_group_->prev_group->koef_cy **/ impl_->current_group_->prev_group->delta_y ;
impl_->group_list_.back()->x *= impl_->current_group_->prev_group->scale_cx;
impl_->group_list_.back()->y *= impl_->current_group_->prev_group->scale_cy;
double x1= (x-ch_x)* impl_->current_group_->prev_group->scale_cx;
double y1= (y-ch_y)* impl_->current_group_->prev_group->scale_cy;
k_x = impl_->current_group_->prev_group->koef_cx;
k_y = impl_->current_group_->prev_group->koef_cy;
impl_->current_group_->shift_x = impl_->current_group_->prev_group->shift_x + x1 +
(impl_->current_group_->prev_group->flipH ? (impl_->current_group_->prev_group->cx - 2 *x1) : 0) ;
impl_->current_group_->shift_y = impl_->current_group_->prev_group->shift_y + y1 +
(impl_->current_group_->prev_group->flipV ? (impl_->current_group_->prev_group->cy - 2 *y1) : 0) ;
}else
{
back_x = impl_->x;
back_y = impl_->y;
impl_->current_group_->shift_x = impl_->x + (x-ch_x) ;
impl_->current_group_->shift_y = impl_->y + (y-ch_y);
}
impl_->current_group_->delta_x = back_x /** k_x*/+ (x-ch_x)* k_x ;
impl_->current_group_->delta_y = back_y /** k_y*/+ (y-ch_y)* k_y ;
}
void odf_drawing_context::set_group_size( double cx, double cy, double ch_cx, double ch_cy)
{
if (impl_->group_list_.size()<1)return;
impl_->current_group_->koef_cx = cx / ch_cx;
impl_->current_group_->koef_cy = cy / ch_cy;
impl_->current_group_->scale_cx = cx / ch_cx;
impl_->current_group_->scale_cy = cy / ch_cy;
if(impl_->current_group_->prev_group)
{
impl_->current_group_->koef_cx *= impl_->current_group_->prev_group->koef_cx;
impl_->current_group_->koef_cy *= impl_->current_group_->prev_group->koef_cy;
impl_->current_group_->scale_cx *= impl_->current_group_->prev_group->scale_cx;
impl_->current_group_->scale_cy *= impl_->current_group_->prev_group->scale_cy;
}
else
{
double first_koef_x = impl_->width/ cx;
double first_koef_y = impl_->height/ cx;
double first_scale_x = impl_->width/ cx;
double first_scale_y = impl_->height/ cx;
impl_->current_group_->koef_cx *= first_koef_x;
impl_->current_group_->koef_cy *= first_koef_y;
impl_->current_group_->scale_cx *= first_scale_x;
impl_->current_group_->scale_cy *= first_scale_y;
}
impl_->current_group_->cx = ch_cx * impl_->current_group_->scale_cx;
impl_->current_group_->cy = ch_cy * impl_->current_group_->scale_cy;
}
void odf_drawing_context::set_group_flip_V(bool bVal)
{
if (impl_->group_list_.size()<1)return;
odf_group_state_ptr gr = impl_->current_group_;
//impl_->current_group_->flipV= bVal;
}
int step = 2;
while (gr && step > 0)
{
bVal += gr->flipV;
gr = gr->prev_group;
step--;
}
void odf_drawing_context::set_group_flip_H(bool bVal)
{
if (impl_->group_list_.size()<1)return;
impl_->current_group_->flipV= bVal;
//impl_->current_group_->flipH= bVal;
}
void odf_drawing_context::set_group_rotate(int iVal)
{
if (impl_->group_list_.size()<1)return;
......@@ -1044,8 +1028,8 @@ void odf_drawing_context::set_position(double x_pt, double y_pt)
{
if (impl_->current_drawing_state_.in_group && impl_->current_group_)
{
x_pt *= impl_->current_group_->koef_cx;
x_pt += impl_->current_group_->delta_x;
x_pt *= impl_->current_group_->scale_cx;
x_pt += impl_->current_group_->shift_x + impl_->current_group_->flipH ? (impl_->current_group_->cx - 2 * x_pt): 0;
}
impl_->current_drawing_state_.svg_x_ = length(length(x_pt,length::pt).get_value_unit(length::cm),length::cm);
......@@ -1054,8 +1038,8 @@ void odf_drawing_context::set_position(double x_pt, double y_pt)
{
if (impl_->current_drawing_state_.in_group && impl_->current_group_)
{
y_pt *= impl_->current_group_->koef_cy;
y_pt += impl_->current_group_->delta_y;
y_pt *= impl_->current_group_->scale_cy;
y_pt += impl_->current_group_->shift_y + impl_->current_group_->flipV ? (impl_->current_group_->cy - 2 * y_pt): 0;
}
impl_->current_drawing_state_.svg_y_ = length(length(y_pt,length::pt).get_value_unit(length::cm),length::cm);
......@@ -1072,8 +1056,8 @@ void odf_drawing_context::set_size( double width_pt, double height_pt)
{
if (impl_->current_drawing_state_.in_group)
{
width_pt *= impl_->group_list_.back()->koef_cx;
height_pt *= impl_->group_list_.back()->koef_cy;
width_pt *= impl_->group_list_.back()->scale_cx;
height_pt *= impl_->group_list_.back()->scale_cy;
}
//if (!impl_->current_drawing_state_.svg_width_)
if (width_pt >= 0) impl_->current_drawing_state_.svg_width_ = length(length(width_pt,length::pt).get_value_unit(length::cm),length::cm);
......
......@@ -41,9 +41,9 @@ odf_master_state & odf_page_layout_context::last_master()
void odf_page_layout_context::create_master_page(std::wstring oox_name)
{
std::wstring odf_name = oox_name;
style_family family = style_family::MasterPage;
office_element_ptr elm;
style_family family = style_family::MasterPage;
create_element(L"style", L"master-page", elm, odf_context_);
if (!elm) return;
......@@ -125,18 +125,50 @@ void odf_page_layout_context::set_page_margin(_CP_OPT(length) top, _CP_OPT(lengt
if (right)
props->style_page_layout_properties_attlist_.common_horizontal_margin_attlist_.fo_margin_right_ =
length(right->get_value_unit(length::cm),length::cm);
//if (header)
// props->style_page_layout_properties_attlist_.common_horizontal_margin_attlist_.fo_margin_right_ =
// length(header->get_value_unit(length::cm),length::cm);
//if (footer)
// props->style_page_layout_properties_attlist_.common_horizontal_margin_attlist_.fo_margin_right_ =
// length(footer->get_value_unit(length::cm),length::cm);
}
void odf_page_layout_context::set_page_gutter(_CP_OPT(length) length_)
{
if (!length_) return;
}
void odf_page_layout_context::set_page_footer(_CP_OPT(length) length_)
{
if (!length_) return;
style_page_layout_properties * props = get_properties();
if (!props)return;
if (props->style_page_layout_properties_attlist_.common_vertical_margin_attlist_.fo_margin_bottom_)
{
props->style_page_layout_properties_attlist_.common_vertical_margin_attlist_.fo_margin_bottom_=
props->style_page_layout_properties_attlist_.common_vertical_margin_attlist_.fo_margin_bottom_->get_length() + length(length_->get_value_unit(length::cm),length::cm);
}
else
props->style_page_layout_properties_attlist_.common_vertical_margin_attlist_.fo_margin_bottom_= length(length_->get_value_unit(length::cm),length::cm);
///////////////////////////////////////////////////////////////
office_element_ptr elm;
create_element(L"style", L"footer", elm, odf_context_);
master_state_list_.back().add_footer(elm);
}
void odf_page_layout_context::set_page_header(_CP_OPT(length) length_)
{
if (!length_) return;
style_page_layout_properties * props = get_properties();
if (!props)return;
if (props->style_page_layout_properties_attlist_.common_vertical_margin_attlist_.fo_margin_top_)
{
props->style_page_layout_properties_attlist_.common_vertical_margin_attlist_.fo_margin_top_=
props->style_page_layout_properties_attlist_.common_vertical_margin_attlist_.fo_margin_top_->get_length() + length(length_->get_value_unit(length::cm),length::cm);
}
else
props->style_page_layout_properties_attlist_.common_vertical_margin_attlist_.fo_margin_top_= length(length_->get_value_unit(length::cm),length::cm);
office_element_ptr elm;
create_element(L"style", L"header", elm, odf_context_);
master_state_list_.back().add_header(elm);
}
void odf_page_layout_context::set_page_border_shadow(bool val)
{
......
......@@ -32,6 +32,9 @@ public:
void set_page_margin(_CP_OPT(double) top, _CP_OPT(double) left, _CP_OPT(double) bottom, _CP_OPT(double) right, _CP_OPT(double) header, _CP_OPT(double) footer);
void set_page_margin(_CP_OPT(length) top, _CP_OPT(length) left, _CP_OPT(length) bottom, _CP_OPT(length) right);
void set_page_gutter(_CP_OPT(length) length_);
void set_page_header(_CP_OPT(length) length_);
void set_page_footer(_CP_OPT(length) length_);
void set_page_border(std::wstring top, std::wstring left, std::wstring bottom, std::wstring right);
void set_page_border_shadow(bool val);
void set_page_orientation(int type);
......
......@@ -55,6 +55,28 @@ std::wstring odf_master_state::get_name()
return style_->style_master_page_attlist_.style_name_->style_name();
else return L"";
}
void odf_master_state::add_footer(office_element_ptr & elm)
{
style_master_page* style_ = dynamic_cast<style_master_page*>(elements_[0].elm.get());
if (!style_)return;
style_->add_child_element(elm);
odf_element_state state = {elm,L"",office_element_ptr(), 1};
elements_.push_back(state);
}
void odf_master_state::add_header(office_element_ptr & elm)
{
style_master_page* style_ = dynamic_cast<style_master_page*>(elements_[0].elm.get());
if (!style_)return;
style_->add_child_element(elm);
odf_element_state state = {elm,L"",office_element_ptr(), 1};
elements_.push_back(state);
}
///////////////////////////////////////////////////////////////////////////////
odf_layout_state::odf_layout_state(office_element_ptr & layout_elm )
{
......
......@@ -34,6 +34,9 @@ public:
void set_name(std::wstring & name);
std::wstring get_name();
void add_footer(office_element_ptr & elm);
void add_header(office_element_ptr & elm);
void set_layout_name(std::wstring & name);
......
......@@ -1153,16 +1153,16 @@ void style_master_page::serialize(std::wostream & strm)
{
style_master_page_attlist_.serialize( CP_GET_XML_NODE());
if (style_header_) style_footer_->serialize(strm);
if (style_footer_) style_header_->serialize(strm);
if (style_header_) style_footer_->serialize(CP_XML_STREAM());
if (style_footer_) style_header_->serialize(CP_XML_STREAM());
if (style_header_left_) style_header_left_->serialize(strm);
if (style_header_first_) style_header_first_->serialize(strm);
if (style_header_left_) style_header_left_->serialize(CP_XML_STREAM());
if (style_header_first_) style_header_first_->serialize(CP_XML_STREAM());
if (style_footer_left_) style_footer_left_->serialize(strm);
if (style_footer_first_) style_footer_first_->serialize(strm);
if (style_footer_left_) style_footer_left_->serialize(CP_XML_STREAM());
if (style_footer_first_) style_footer_first_->serialize(CP_XML_STREAM());
if (office_forms_) office_forms_->serialize(strm);
if (office_forms_) office_forms_->serialize(CP_XML_STREAM());
BOOST_FOREACH(const office_element_ptr & elm, style_style_)
{
......
......@@ -478,27 +478,27 @@ public:
CP_REGISTER_OFFICE_ELEMENT2(office_styles);
class header_footer_content_impl
class header_footer_content_common
{
public:
common_style_header_footer_attlist common_style_header_footer_attlist_;
header_footer_content header_footer_content_;
common_style_header_footer_attlist common_style_header_footer_attlist_;
header_footer_content header_footer_content_;
};
class header_footer_impl
class header_footer_common
{
public:
header_footer_content_impl & content() { return content_; }
const header_footer_content_impl & content() const { return content_; }
virtual ~header_footer_impl() {}
header_footer_content_common & content() { return content_; }
const header_footer_content_common & content() const { return content_; }
virtual ~header_footer_common() {}
private:
header_footer_content_impl content_;
header_footer_content_common content_;
};
/// style:header
class style_header : public office_element_impl<style_header>, public header_footer_impl
class style_header : public office_element_impl<style_header>, public header_footer_common
{
public:
static const wchar_t * ns;
......@@ -512,13 +512,13 @@ public:
virtual void serialize(std::wostream & strm);
header_footer_content_impl content_;
header_footer_content_common content_;
};
CP_REGISTER_OFFICE_ELEMENT2(style_header);
/// style:footer
class style_footer : public office_element_impl<style_footer>, public header_footer_impl
class style_footer : public office_element_impl<style_footer>, public header_footer_common
{
public:
static const wchar_t * ns;
......@@ -532,14 +532,14 @@ public:
virtual void create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_child_element(office_element_ptr & child);
header_footer_content_impl content_;
header_footer_content_common content_;
};
CP_REGISTER_OFFICE_ELEMENT2(style_footer);
/// style:header-first
class style_header_first : public office_element_impl<style_header_first>, public header_footer_impl
class style_header_first : public office_element_impl<style_header_first>, public header_footer_common
{
public:
static const wchar_t * ns;
......@@ -553,13 +553,13 @@ public:
virtual void create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_child_element(office_element_ptr & child);
header_footer_content_impl content_;
header_footer_content_common content_;
};
CP_REGISTER_OFFICE_ELEMENT2(style_header_first);
/// style:footer_first
class style_footer_first : public office_element_impl<style_footer_first>, public header_footer_impl
class style_footer_first : public office_element_impl<style_footer_first>, public header_footer_common
{
public:
static const wchar_t * ns;
......@@ -573,13 +573,13 @@ public:
virtual void serialize(std::wostream & strm);
header_footer_content_impl content_;
header_footer_content_common content_;
};
CP_REGISTER_OFFICE_ELEMENT2(style_footer_first);
/// style:header-left
class style_header_left : public office_element_impl<style_header_left>, public header_footer_impl
class style_header_left : public office_element_impl<style_header_left>, public header_footer_common
{
public:
static const wchar_t * ns;
......@@ -593,13 +593,13 @@ public:
virtual void serialize(std::wostream & strm);
header_footer_content_impl content_;
header_footer_content_common content_;
};
CP_REGISTER_OFFICE_ELEMENT2(style_header_left);
/// style:footer-left
class style_footer_left : public office_element_impl<style_footer_left>, public header_footer_impl
class style_footer_left : public office_element_impl<style_footer_left>, public header_footer_common
{
public:
static const wchar_t * ns;
......@@ -613,7 +613,7 @@ public:
virtual void serialize(std::wostream & strm);
header_footer_content_impl content_;
header_footer_content_common content_;
};
CP_REGISTER_OFFICE_ELEMENT2(style_footer_left);
......
......@@ -51,6 +51,11 @@ void OoxConverter::convert(OOX::Vml::CShapeType *vml_shape_type)
if (vml_shape_type == NULL) return;
//custom shape
if (vml_shape_type->m_oCoordSize.IsInit())
{
odf_context()->drawing_context()->set_position(vml_shape_type->m_oCoordSize->GetX(), vml_shape_type->m_oCoordSize->GetY());
}
for (long i=0 ; i < vml_shape_type->m_arrItems.GetSize();i++)
{
convert(vml_shape_type->m_arrItems[i]);
......
......@@ -184,6 +184,11 @@ void OoxConverter::convert(OOX::Drawing::CGroupShapeProperties * oox_group_spP
if (oox_group_spPr->m_oXfrm.IsInit()) //CTransform2D
{
if (oox_group_spPr->m_oXfrm->m_oFlipH.GetValue() == SimpleTypes::onoffTrue)
odf_context()->drawing_context()->set_group_flip_H(true);
if (oox_group_spPr->m_oXfrm->m_oFlipV.GetValue() == SimpleTypes::onoffTrue)
odf_context()->drawing_context()->set_group_flip_V(true);
if (oox_group_spPr->m_oXfrm->m_oChExt.IsInit() && oox_group_spPr->m_oXfrm->m_oExt.IsInit())
{
odf_context()->drawing_context()->set_group_size( oox_group_spPr->m_oXfrm->m_oExt->m_oCx.ToPoints(),
......@@ -199,11 +204,6 @@ void OoxConverter::convert(OOX::Drawing::CGroupShapeProperties * oox_group_spP
oox_group_spPr->m_oXfrm->m_oChOff->m_oY.ToPoints());
}
//???
if (oox_group_spPr->m_oXfrm->m_oFlipH.GetValue() == SimpleTypes::onoffTrue)
odf_context()->drawing_context()->set_group_flip_H(true);
if (oox_group_spPr->m_oXfrm->m_oFlipV.GetValue() == SimpleTypes::onoffTrue)
odf_context()->drawing_context()->set_group_flip_V(true);
if (oox_group_spPr->m_oXfrm->m_oRot.GetValue() > 0)
odf_context()->drawing_context()->set_group_rotate(oox_group_spPr->m_oXfrm->m_oRot.GetValue());
}
......
......@@ -621,8 +621,11 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
convert(oox_section_pr->m_oPgMar->m_oGutter.GetPointer(), other);
odt_context->page_layout_context()->set_page_gutter(other);
//nullable<SimpleTypes::CTwipsMeasure > m_oFooter;
//nullable<SimpleTypes::CTwipsMeasure > m_oHeader;
convert(oox_section_pr->m_oPgMar->m_oFooter.GetPointer(), other);
odt_context->page_layout_context()->set_page_footer(other);
convert(oox_section_pr->m_oPgMar->m_oFooter.GetPointer(), other);
odt_context->page_layout_context()->set_page_header(other);
}
if (oox_section_pr->m_oPgBorders.IsInit())
{
......
......@@ -2,6 +2,6 @@
//1
//2
//0
//100
#define INTVER 1,2,0,100
#define STRVER "1,2,0,100\0"
//101
#define INTVER 1,2,0,101
#define STRVER "1,2,0,101\0"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment