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

(1.2.0.98): ASCOfficeOdfFileW


git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@57438 954022d7-b5bf-4e40-9824-e11837661b57
parent 2451eeb6
......@@ -37,7 +37,7 @@ struct odf_group_state
{
odf_group_state(office_element_ptr elm_, int level_, odf_group_state_ptr prev)
{
delta_x = delta_y = rotate = 0;
delta_x = delta_y =x = y = rotate = 0;
koef_cx = koef_cy = 1.;
flipH = flipV = false;
......@@ -53,6 +53,9 @@ struct odf_group_state
double delta_x;
double delta_y;
double x;
double y;
double koef_cx;
double koef_cy;
......@@ -156,6 +159,7 @@ struct odf_drawing_state
_CP_OPT(length) svg_height_;
_CP_OPT(length) svg_width_;
std::wstring name_;
int z_order_;
......@@ -182,6 +186,8 @@ public:
current_graphic_properties = NULL;
current_paragraph_properties = NULL;
width = height = x = y = 0;
}
odf_drawing_state current_drawing_state_;
......@@ -208,6 +214,12 @@ public:
office_element_ptr root_element_;
double x;
double y;
double width;
double height;
};
////////////////////////////////////////////////////////////////////////////
......@@ -262,43 +274,46 @@ void odf_drawing_context::end_group()
impl_->current_level_.pop_back();
}
void odf_drawing_context::set_group_size_koef( double cx, double cy)
{
if (impl_->group_list_.size()<1)return;
odf_group_state_ptr gr = impl_->current_group_;
// 2 !!! - 1,
int step = 2;
while (gr && step > 0)
{
cx *= gr->koef_cx;
cy *= gr->koef_cy;
gr = gr->prev_group;
step--;
}
impl_->group_list_.back()->koef_cx = cx;
impl_->group_list_.back()->koef_cy = cy;
}
void odf_drawing_context::set_group_position_delta(double x_pt, double y_pt)
{
if (impl_->group_list_.size()<1)return;
odf_group_state_ptr gr = impl_->current_group_;
int step = 2;
while (gr && step > 0)
{
x_pt += gr->delta_x;
y_pt += gr->delta_y;
gr = gr->prev_group;
step--;
}
impl_->group_list_.back()->delta_x = x_pt;
impl_->group_list_.back()->delta_y = y_pt;
}
//void odf_drawing_context::set_group_size_koef( double cx, double cy)
//{
// if (impl_->group_list_.size()<1)return;
//
// odf_group_state_ptr gr = impl_->current_group_;
// // 2 !!! - 1,
// int step = 2;
// while (gr && step > 0)
// {
// cx *= gr->koef_cx;
// cy *= gr->koef_cy;
//
// gr = gr->prev_group;
// step--;
// }
// impl_->group_list_.back()->koef_cx = cx;
// impl_->group_list_.back()->koef_cy = cy;
//}
//void odf_drawing_context::set_group_position_delta(double x_pt, double y_pt)
//{
// if (impl_->group_list_.size()<1)return;
//
// odf_group_state_ptr gr = impl_->current_group_;
//
// x_pt*=20;//1000;
// y_pt*=20;//127;//00;
//
// int step = 2;
// while (gr && step > 0)
// {
// x_pt += gr->delta_x;
// y_pt += gr->delta_y;
//
// gr = gr->prev_group;
// step--;
// }
// impl_->group_list_.back()->delta_x = x_pt;
// impl_->group_list_.back()->delta_y = y_pt;
//}
void odf_drawing_context::set_group_flip_H(bool bVal)
{
......@@ -412,13 +427,13 @@ void odf_drawing_context::end_drawing()
impl_->current_drawing_state_.svg_x_ = boost::none;
impl_->current_drawing_state_.svg_y_ = boost::none;
}else if (impl_->current_drawing_state_.in_group)
}/*else if (impl_->current_drawing_state_.in_group)
{
strTransform += std::wstring(L"translate(") + boost::lexical_cast<std::wstring>(impl_->current_drawing_state_.svg_x_.get())
+ std::wstring(L",") + boost::lexical_cast<std::wstring>(impl_->current_drawing_state_.svg_y_.get()) + std::wstring(L")") ;
impl_->current_drawing_state_.svg_x_ = boost::none;
impl_->current_drawing_state_.svg_y_ = boost::none;
}
}*/
if (strTransform.length()>0)
draw->common_draw_attlists_.shape_with_text_and_styles_.common_draw_shape_with_styles_attlist_.common_draw_transform_attlist_.draw_transform_ = strTransform;
......@@ -865,6 +880,12 @@ void odf_drawing_context::set_drawings_rect(double x_pt, double y_pt, double wid
if (x_pt >= 0) impl_->anchor_settings_.svg_x_ = length(length(x_pt,length::pt).get_value_unit(length::cm),length::cm);
if (y_pt >= 0) impl_->anchor_settings_.svg_y_ = length(length(y_pt,length::pt).get_value_unit(length::cm),length::cm);
impl_->x = x_pt >=0 ? x_pt :0 ;
impl_->y = y_pt >=0 ? y_pt :0;
impl_->width = width_pt;
impl_->height = height_pt;
if (width_pt >= 0) impl_->anchor_settings_.svg_height_ = length(length(height_pt,length::pt).get_value_unit(length::cm),length::cm);
if (height_pt >= 0)impl_->anchor_settings_.svg_width_ = length(length(width_pt,length::pt).get_value_unit(length::cm),length::cm);
}
......@@ -968,25 +989,79 @@ void odf_drawing_context::set_wrap_style(style_wrap::type type)
{
impl_->anchor_settings_.style_wrap_ = style_wrap(type);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void odf_drawing_context::set_group_position(double x, double y, double ch_x, double ch_y)
{
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;
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 ;
k_x = impl_->current_group_->prev_group->koef_cx;
k_y = impl_->current_group_->prev_group->koef_cy;
}else
{
back_x = impl_->x;
back_y = impl_->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_x;
}
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;
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;
}
else
{
double first_koef_x = impl_->width/ cx;
double first_koef_y = impl_->height/ cx;
impl_->current_group_->koef_cx *= first_koef_x;
impl_->current_group_->koef_cy *= first_koef_y;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void odf_drawing_context::set_position(double x_pt, double y_pt)
{
x_pt*=20;
y_pt*=20;
if (impl_->group_list_.size() < 1)return;
if (!impl_->current_drawing_state_.svg_x_)
{
if (impl_->current_drawing_state_.in_group)
x_pt += impl_->group_list_.back()->delta_x;
if (impl_->current_drawing_state_.in_group && impl_->current_group_)
{
x_pt *= impl_->current_group_->koef_cx;
x_pt += impl_->current_group_->delta_x;
}
impl_->current_drawing_state_.svg_x_ = length(length(x_pt,length::pt).get_value_unit(length::cm),length::cm);
}
if (!impl_->current_drawing_state_.svg_y_)
{
if (impl_->current_drawing_state_.in_group)
y_pt += impl_->group_list_.back()->delta_y;
if (impl_->current_drawing_state_.in_group && impl_->current_group_)
{
y_pt *= impl_->current_group_->koef_cy;
y_pt += impl_->current_group_->delta_y;
}
impl_->current_drawing_state_.svg_y_ = length(length(y_pt,length::pt).get_value_unit(length::cm),length::cm);
}
......
......@@ -55,13 +55,16 @@ public:
void end_drawing();
void start_group(std::wstring name, int id);
void set_group_size_koef( double cx, double cy);
void set_group_position_delta(double x_pt, double y_pt);
//void set_group_size_koef( double cx, double cy);
//void set_group_position_delta(double x_pt, double y_pt);
//void set_group_child_position (double x_pt, double y_pt);
void set_group_flip_H(bool bVal);
void set_group_flip_V(bool bVal);
void set_group_rotate(int iVal);
void set_group_size( double cx, double cy, double ch_cx, double ch_cy);
void set_group_position(double x, double y, double ch_x, double ch_y);
void end_group();
void start_shape(int type);
......@@ -95,6 +98,7 @@ public:
void set_size( double width_pt, double height_pt);
void set_position(double x_pt, double y_pt);
void get_size( double & width_pt, double & height_pt);
void set_name(std::wstring name);
......
......@@ -184,20 +184,21 @@ void OoxConverter::convert(OOX::Drawing::CGroupShapeProperties * oox_group_spP
if (oox_group_spPr->m_oXfrm.IsInit()) //CTransform2D
{
if (oox_group_spPr->m_oXfrm->m_oChOff.IsInit() && oox_group_spPr->m_oXfrm->m_oOff.IsInit())
if (oox_group_spPr->m_oXfrm->m_oChExt.IsInit() && oox_group_spPr->m_oXfrm->m_oExt.IsInit())
{
double x =oox_group_spPr->m_oXfrm->m_oOff->m_oX.GetValue()/ oox_group_spPr->m_oXfrm->m_oChOff->m_oX.GetValue();
double y =oox_group_spPr->m_oXfrm->m_oOff->m_oY.GetValue()/ oox_group_spPr->m_oXfrm->m_oChOff->m_oY.GetValue();
odf_context()->drawing_context()->set_group_position_delta(x, y);
odf_context()->drawing_context()->set_group_size( oox_group_spPr->m_oXfrm->m_oExt->m_oCx.ToPoints(),
oox_group_spPr->m_oXfrm->m_oExt->m_oCy.ToPoints(),
oox_group_spPr->m_oXfrm->m_oChExt->m_oCx.ToPoints(),
oox_group_spPr->m_oXfrm->m_oChExt->m_oCy.ToPoints());
}
if (oox_group_spPr->m_oXfrm->m_oExt.IsInit() && oox_group_spPr->m_oXfrm->m_oChExt.IsInit())
if (oox_group_spPr->m_oXfrm->m_oOff.IsInit() && oox_group_spPr->m_oXfrm->m_oChOff.IsInit())
{
double x =oox_group_spPr->m_oXfrm->m_oExt->m_oCx.ToPoints()/ oox_group_spPr->m_oXfrm->m_oChExt->m_oCx.ToPoints();
double y =oox_group_spPr->m_oXfrm->m_oExt->m_oCy.ToPoints()/ oox_group_spPr->m_oXfrm->m_oChExt->m_oCy.ToPoints();
if (x != 0 && y != 0) odf_context()->drawing_context()->set_group_size_koef(x, y);
odf_context()->drawing_context()->set_group_position( oox_group_spPr->m_oXfrm->m_oOff->m_oX.ToPoints(),
oox_group_spPr->m_oXfrm->m_oOff->m_oY.ToPoints(),
oox_group_spPr->m_oXfrm->m_oChOff->m_oX.ToPoints(),
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);
......@@ -339,8 +340,8 @@ void OoxConverter::convert(OOX::Drawing::CShapeProperties * oox_spPr, OOX::Dra
{
if (oox_spPr->m_oXfrm->m_oOff.IsInit())
{
odf_context()->drawing_context()->set_position(oox_spPr->m_oXfrm->m_oOff->m_oX.GetValue(),
oox_spPr->m_oXfrm->m_oOff->m_oY.GetValue());
odf_context()->drawing_context()->set_position(oox_spPr->m_oXfrm->m_oOff->m_oX.ToPoints(),
oox_spPr->m_oXfrm->m_oOff->m_oY.ToPoints());
}
if (oox_spPr->m_oXfrm->m_oExt.IsInit())
{
......
......@@ -1514,12 +1514,12 @@ void DocxConverter::convert(OOX::Logic::CGroupShape *oox_group_shape)
std::wstring name;
int id = -1;
//if (oox_group_shape->m_oCNvPr.IsInit())
if (oox_group_shape->m_oCNvPr.IsInit())
{
//if (oox_group_shape->m_oCNvPr->m_sName.IsInit())
// name = string2std_string(*oox_group_shape->m_oCNvPr->m_sName);
//if (oox_group_shape->m_oCNvPr->m_oId.IsInit())
// id = oox_group_shape->m_oCNvPr->m_oId->GetValue();
if (oox_group_shape->m_oCNvPr->m_sName.IsInit())
name = string2std_string(*oox_group_shape->m_oCNvPr->m_sName);
if (oox_group_shape->m_oCNvPr->m_oId.IsInit())
id = oox_group_shape->m_oCNvPr->m_oId->GetValue();
}
odt_context->drawing_context()->start_group(name,id);
......@@ -1603,7 +1603,7 @@ void DocxConverter::convert(SimpleTypes::CHexColor<> *color,
unsigned char ucA=0, ucR=0, ucG=0, ucB=0;
bool result = false;
if(color)//easy, faster,realy !!
if(color && color->GetValue() == SimpleTypes::hexcolorRGB)//easy, faster,realy !!
{
ucR = color->Get_R();
ucB = color->Get_B();
......
......@@ -2,6 +2,6 @@
//1
//2
//0
//96
#define INTVER 1,2,0,96
#define STRVER "1,2,0,96\0"
//99
#define INTVER 1,2,0,99
#define STRVER "1,2,0,99\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