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

(1.0.0.147): ASCOfficeOdfFile

стили градиентов (odp & ods), поправлены шаблоны и мастер-пейджи (odp)
поправлено заливка битмапом (ods & odp)

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@53129 954022d7-b5bf-4e40-9824-e11837661b57
parent 296c449f
...@@ -577,6 +577,14 @@ ...@@ -577,6 +577,14 @@
RelativePath=".\src\odf\fontweight.h" RelativePath=".\src\odf\fontweight.h"
> >
</File> </File>
<File
RelativePath=".\src\odf\gradientstyle.cpp"
>
</File>
<File
RelativePath=".\src\odf\gradientstyle.h"
>
</File>
<File <File
RelativePath=".\src\odf\hyphenationkeep.cpp" RelativePath=".\src\odf\hyphenationkeep.cpp"
> >
......
...@@ -40,13 +40,13 @@ void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(double) ...@@ -40,13 +40,13 @@ void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(double)
{ {
CP_XML_NODE(L"a:alpha") CP_XML_NODE(L"a:alpha")
{ {
CP_XML_ATTR(L"val",boost::lexical_cast<std::wstring>(*opacity) + L"%"); CP_XML_ATTR(L"val",boost::lexical_cast<std::wstring>((int)(*opacity)*1000));// + L"%");
} }
} }
} }
} }
} }
void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(odf::length_or_percent) opacity) void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(odf::percent) opacity)
{ {
CP_XML_WRITER(strm) CP_XML_WRITER(strm)
{ {
...@@ -57,7 +57,7 @@ void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(odf::len ...@@ -57,7 +57,7 @@ void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(odf::len
{ {
CP_XML_NODE(L"a:alpha") CP_XML_NODE(L"a:alpha")
{ {
CP_XML_ATTR(L"val",boost::lexical_cast<std::wstring>(opacity->get_percent().get_value()) + L"%"); CP_XML_ATTR(L"val",boost::lexical_cast<std::wstring>((int)opacity->get_value()*1000));// + L"%");
} }
} }
} }
...@@ -99,9 +99,9 @@ void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val) ...@@ -99,9 +99,9 @@ void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val)
if (val.opacity) if (val.opacity)
{ {
CP_XML_NODE(L"a:alpha") CP_XML_NODE(L"a:alphaModFix")
{ {
CP_XML_ATTR(L"val",boost::lexical_cast<std::wstring>(*val.opacity) + L"%"); CP_XML_ATTR(L"amt",(int)(*val.opacity * 1000));
} }
} }
} }
...@@ -130,10 +130,81 @@ void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val) ...@@ -130,10 +130,81 @@ void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val)
{ {
CP_XML_NODE(L"a:tile") CP_XML_NODE(L"a:tile")
{ {
//tx="0" ty="0" sx="100000" sy="100000"
CP_XML_ATTR(L"flip","none");
CP_XML_ATTR(L"algn",L"ctr");
}
}
}
}
}
void oox_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val)
{
if (!val.gradient)return;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:gradFill")
{
if (val.gradient->colors.size()>0)
{
CP_XML_NODE(L"a:gsLst")
{
BOOST_FOREACH(oox_gradient_fill::_color_position & col, val.gradient->colors)
{
CP_XML_NODE(L"a:gs")
{
CP_XML_ATTR(L"pos",(int)(col.pos *1000));//%
oox_serialize_srgb(CP_XML_STREAM(),col.color_ref,col.opacity);
}
}
}
}
double angle =/*360 - */val.gradient->angle/* * 180./3.14159265358979323846*/;
angle *= 60000; //60 000 per 1 gr - 19.5.5 oox
switch(val.gradient->style)
{
case 0:
CP_XML_NODE(L"a:lin")
{
CP_XML_ATTR(L"ang",(int)angle);//gr in rad
}break;
case 1:
case 2:
case 3:
CP_XML_NODE(L"a:path")
{
if (val.gradient->style == 1) CP_XML_ATTR(L"path", L"rect");
if (val.gradient->style == 2) CP_XML_ATTR(L"path", L"circle");
if (val.gradient->style == 3) CP_XML_ATTR(L"path", L"shape");
CP_XML_NODE(L"a:fillToRect")
{
CP_XML_ATTR(L"l", (int)(val.gradient->rect[0] * 1000));
CP_XML_ATTR(L"t", (int)(val.gradient->rect[1] * 1000));
CP_XML_ATTR(L"r", (int)(val.gradient->rect[2] * 1000));
CP_XML_ATTR(L"b", (int)(val.gradient->rect[3] * 1000));
}
}break;
} }
} }
} }
//gsLst (Gradient Stop List) 20.1.8.37
//lin (Linear Gradient Fill) 20.1.8.41
//path (Path Gradient) 20.1.8.46
//tileRect (Tile Rectangle) 20.1.8.59
}
void oox_serialize_hatch_fill(std::wostream & strm, const _oox_fill & val)
{
if (!val.hatch)return;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:pattFill")
{
}
} }
} }
...@@ -150,8 +221,11 @@ void oox_serialize_fill(std::wostream & strm, const _oox_fill & val) ...@@ -150,8 +221,11 @@ void oox_serialize_fill(std::wostream & strm, const _oox_fill & val)
case 2: case 2:
oox_serialize_bitmap_fill(strm, val); oox_serialize_bitmap_fill(strm, val);
break; break;
//case 3: oox_serialize_gradient_fill(strm, val);break; case 3:
//case 4: oox_serialize_hatch_fill(strm, val);break; oox_serialize_gradient_fill(strm, val);
break;
case 4: oox_serialize_hatch_fill(strm, val);
break;
} }
} }
////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////
......
...@@ -11,13 +11,14 @@ namespace cpdoccore { ...@@ -11,13 +11,14 @@ namespace cpdoccore {
namespace oox { namespace oox {
class oox_gradient_fill; class oox_solid_fill;
typedef _CP_PTR(oox_gradient_fill) oox_gradient_fill_ptr; typedef _CP_PTR(oox_solid_fill) oox_solid_fill_ptr;
class oox_gradient_fill class oox_solid_fill
{ {
public: public:
oox_gradient_fill(){} std::wstring color;
static oox_gradient_fill_ptr create(); static oox_solid_fill_ptr create();
}; };
/////////////////////////////////// ///////////////////////////////////
...@@ -53,19 +54,33 @@ namespace oox { ...@@ -53,19 +54,33 @@ namespace oox {
static oox_hatch_fill_ptr create(); static oox_hatch_fill_ptr create();
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class oox_solid_fill; class oox_gradient_fill;
typedef _CP_PTR(oox_solid_fill) oox_solid_fill_ptr; typedef _CP_PTR(oox_gradient_fill) oox_gradient_fill_ptr;
class oox_solid_fill class oox_gradient_fill
{ {
public: public:
oox_solid_fill(){} struct _color_position
std::wstring color; {
static oox_solid_fill_ptr create(); double pos;
std::wstring color_ref;
_CP_OPT(double) opacity;
}; };
static oox_gradient_fill_ptr create();
struct _oox_fill oox_gradient_fill() : style(0), angle(0)
{ {
memset(rect,0,sizeof(double)*4);
}
int style;
double rect[4];
double angle;
std::vector<_color_position> colors;
};
//////////////////////////////////////////////////////////////////////////////
struct _oox_fill
{
oox_gradient_fill_ptr gradient; oox_gradient_fill_ptr gradient;
oox_hatch_fill_ptr hatch; oox_hatch_fill_ptr hatch;
oox_bitmap_fill_ptr bitmap; oox_bitmap_fill_ptr bitmap;
...@@ -76,7 +91,18 @@ namespace oox { ...@@ -76,7 +91,18 @@ namespace oox {
friend void oox_serialize_fill(std::wostream & strm, const _oox_fill & val); friend void oox_serialize_fill(std::wostream & strm, const _oox_fill & val);
friend void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(double) opacity); friend void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(double) opacity);
friend void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(odf::length_or_percent) opacity); friend void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(odf::percent) opacity);
void clear()
{
type=0;
opacity = boost::none;
gradient.reset();
hatch.reset();
bitmap.reset();
solid.reset();
}
}; };
......
...@@ -171,7 +171,7 @@ std::wostream & pptx_xml_slideMaster::Data() ...@@ -171,7 +171,7 @@ std::wostream & pptx_xml_slideMaster::Data()
} }
std::wostream & pptx_xml_slideMaster::Background() std::wostream & pptx_xml_slideMaster::Background()
{ {
return slideMasterData_; return slideMasterBackground_;
} }
rels & pptx_xml_slideMaster::Rels() rels & pptx_xml_slideMaster::Rels()
{ {
......
...@@ -27,7 +27,7 @@ public: ...@@ -27,7 +27,7 @@ public:
Impl(const std::wstring & odfPacket) : pptx_drawings_(pptx_drawings::create()), mediaitems_(odfPacket),rId_(1),odfPacket_(odfPacket) Impl(const std::wstring & odfPacket) : pptx_drawings_(pptx_drawings::create()), mediaitems_(odfPacket),rId_(1),odfPacket_(odfPacket)
{} {}
drawing_object_description simple_drawing_desc_; drawing_object_description object_description_;
std::vector<drawing_object_description> images_; std::vector<drawing_object_description> images_;
std::vector<drawing_object_description> charts_; std::vector<drawing_object_description> charts_;
...@@ -97,89 +97,91 @@ void pptx_slide_context::start_slide() ...@@ -97,89 +97,91 @@ void pptx_slide_context::start_slide()
} }
void pptx_slide_context::default_set() void pptx_slide_context::default_set()
{ {
impl_->simple_drawing_desc_.xlink_href_ = L""; impl_->object_description_.xlink_href_ = L"";
impl_->simple_drawing_desc_.draw_name_ = L""; impl_->object_description_.draw_name_ = L"";
impl_->simple_drawing_desc_.additional_.clear(); impl_->object_description_.additional_.clear();
impl_->simple_drawing_desc_.anchor_ =L""; impl_->object_description_.anchor_ =L"";
impl_->simple_drawing_desc_.clipping_string_= L""; impl_->object_description_.clipping_string_= L"";
impl_->simple_drawing_desc_.svg_rect_ = boost::none; impl_->object_description_.svg_rect_ = boost::none;
impl_->simple_drawing_desc_.hlinks_.clear(); impl_->object_description_.hlinks_.clear();
impl_->simple_drawing_desc_.additional_.clear(); impl_->object_description_.additional_.clear();
impl_->object_description_.fill_.clear();
} }
void pptx_slide_context::set_placeHolder_type(std::wstring typeHolder) void pptx_slide_context::set_placeHolder_type(std::wstring typeHolder)
{ {
impl_->simple_drawing_desc_.additional_.push_back(odf::_property(L"PlaceHolderType",typeHolder)); impl_->object_description_.additional_.push_back(odf::_property(L"PlaceHolderType",typeHolder));
} }
void pptx_slide_context::set_rect(double width_pt, double height_pt, double x_pt, double y_pt) void pptx_slide_context::set_rect(double width_pt, double height_pt, double x_pt, double y_pt)
{ {
_rect r = {width_pt,height_pt,x_pt,y_pt}; _rect r = {width_pt,height_pt,x_pt,y_pt};
impl_->simple_drawing_desc_.svg_rect_= r; impl_->object_description_.svg_rect_= r;
} }
void pptx_slide_context::set_rotate(double angle) void pptx_slide_context::set_rotate(double angle)
{ {
set_property(odf::_property(L"svg:rotate",angle)); set_property(odf::_property(L"svg:rotate",angle));
if (impl_->simple_drawing_desc_.svg_rect_) if (impl_->object_description_.svg_rect_)
{ {
// open office // open office
_rect r = impl_->simple_drawing_desc_.svg_rect_.get(); _rect r = impl_->object_description_.svg_rect_.get();
//r.x_-=r.width_; //r.x_-=r.width_;
//r.y_-=r.height_; //r.y_-=r.height_;
impl_->simple_drawing_desc_.svg_rect_= r; impl_->object_description_.svg_rect_= r;
} }
} }
void pptx_slide_context::set_translate(double x_pt, double y_pt) void pptx_slide_context::set_translate(double x_pt, double y_pt)
{ {
if (impl_->simple_drawing_desc_.svg_rect_) if (impl_->object_description_.svg_rect_)
{ {
_rect r = impl_->simple_drawing_desc_.svg_rect_.get(); _rect r = impl_->object_description_.svg_rect_.get();
r.x_+=x_pt; r.x_+=x_pt;
r.y_+=y_pt; r.y_+=y_pt;
impl_->simple_drawing_desc_.svg_rect_= r; impl_->object_description_.svg_rect_= r;
} }
} }
void pptx_slide_context::set_scale(double cx_pt, double cy_pt) void pptx_slide_context::set_scale(double cx_pt, double cy_pt)
{ {
if (impl_->simple_drawing_desc_.svg_rect_) if (impl_->object_description_.svg_rect_)
{ {
_rect r = impl_->simple_drawing_desc_.svg_rect_.get(); _rect r = impl_->object_description_.svg_rect_.get();
r.x_*=cx_pt; r.x_*=cx_pt;
r.y_*=cy_pt; r.y_*=cy_pt;
impl_->simple_drawing_desc_.svg_rect_= r; impl_->object_description_.svg_rect_= r;
} }
} }
void pptx_slide_context::set_anchor(std::wstring anchor, double x_pt, double y_pt) void pptx_slide_context::set_anchor(std::wstring anchor, double x_pt, double y_pt)
{ {
impl_->simple_drawing_desc_.anchor_ = anchor; impl_->object_description_.anchor_ = anchor;
impl_->simple_drawing_desc_.anchor_x_ = x_pt; impl_->object_description_.anchor_x_ = x_pt;
impl_->simple_drawing_desc_.anchor_y_ = y_pt; impl_->object_description_.anchor_y_ = y_pt;
} }
void pptx_slide_context::set_property(odf::_property p) void pptx_slide_context::set_property(odf::_property p)
{ {
impl_->simple_drawing_desc_.additional_.push_back(p); impl_->object_description_.additional_.push_back(p);
} }
std::vector<odf::_property> & pptx_slide_context::get_properties() std::vector<odf::_property> & pptx_slide_context::get_properties()
{ {
return impl_->simple_drawing_desc_.additional_; return impl_->object_description_.additional_;
} }
void pptx_slide_context::set_clipping(std::wstring & str) void pptx_slide_context::set_clipping(std::wstring & str)
{ {
impl_->simple_drawing_desc_.clipping_string_= str; impl_->object_description_.clipping_string_= str;
} }
void pptx_slide_context::set_fill(_oox_fill & fill) void pptx_slide_context::set_fill(_oox_fill & fill)
{ {
impl_->simple_drawing_desc_.fill_= fill; impl_->object_description_.fill_= fill;
} }
std::wstring pptx_slide_context::add_hyperlink(std::wstring const & ref,bool object) std::wstring pptx_slide_context::add_hyperlink(std::wstring const & ref,bool object)
{ {
...@@ -187,42 +189,42 @@ std::wstring pptx_slide_context::add_hyperlink(std::wstring const & ref,bool obj ...@@ -187,42 +189,42 @@ std::wstring pptx_slide_context::add_hyperlink(std::wstring const & ref,bool obj
std::wstring hId=std::wstring(L"hId") + boost::lexical_cast<std::wstring>(hlinks_size_); std::wstring hId=std::wstring(L"hId") + boost::lexical_cast<std::wstring>(hlinks_size_);
_hlink_desc desc={hId, ref, object}; _hlink_desc desc={hId, ref, object};
impl_->simple_drawing_desc_.hlinks_.push_back(desc); impl_->object_description_.hlinks_.push_back(desc);
return hId; return hId;
} }
void pptx_slide_context::set_name(std::wstring const & name) void pptx_slide_context::set_name(std::wstring const & name)
{ {
impl_->simple_drawing_desc_.draw_name_ = name; impl_->object_description_.draw_name_ = name;
} }
void pptx_slide_context::start_shape(int type) void pptx_slide_context::start_shape(int type)
{ {
impl_->simple_drawing_desc_.type_ = type; //2,3... impl_->object_description_.type_ = type; //2,3...
} }
void pptx_slide_context::start_image(std::wstring const & path) void pptx_slide_context::start_image(std::wstring const & path)
{ {
impl_->simple_drawing_desc_.xlink_href_ = path; impl_->object_description_.xlink_href_ = path;
impl_->simple_drawing_desc_.type_ = 0; //frame impl_->object_description_.type_ = 0; //frame
} }
void pptx_slide_context::start_chart(std::wstring const & path) void pptx_slide_context::start_chart(std::wstring const & path)
{ {
impl_->simple_drawing_desc_.xlink_href_ = path; impl_->object_description_.xlink_href_ = path;
impl_->simple_drawing_desc_.type_ = 0; //frame impl_->object_description_.type_ = 0; //frame
} }
void pptx_slide_context::end_shape() void pptx_slide_context::end_shape()
{ {
impl_->shapes_.push_back(impl_->simple_drawing_desc_); impl_->shapes_.push_back(impl_->object_description_);
default_set(); default_set();
} }
void pptx_slide_context::end_image() void pptx_slide_context::end_image()
{ {
impl_->images_.push_back(impl_->simple_drawing_desc_); impl_->images_.push_back(impl_->object_description_);
default_set(); default_set();
} }
void pptx_slide_context::end_chart() void pptx_slide_context::end_chart()
{ {
impl_->charts_.push_back(impl_->simple_drawing_desc_); impl_->charts_.push_back(impl_->object_description_);
default_set(); default_set();
} }
bool pptx_slide_context::empty() const bool pptx_slide_context::empty() const
......
...@@ -87,7 +87,7 @@ public: ...@@ -87,7 +87,7 @@ public:
{} {}
xlsx_drawing_context_handle & handle_; xlsx_drawing_context_handle & handle_;
drawing_object_description simple_drawing_desc_; drawing_object_description object_description_;
std::vector<drawing_object_description> images_; std::vector<drawing_object_description> images_;
std::vector<drawing_object_description> charts_; std::vector<drawing_object_description> charts_;
...@@ -143,18 +143,18 @@ xlsx_drawing_context::xlsx_drawing_context(xlsx_drawing_context_handle & h) ...@@ -143,18 +143,18 @@ xlsx_drawing_context::xlsx_drawing_context(xlsx_drawing_context_handle & h)
} }
void xlsx_drawing_context::default_set() void xlsx_drawing_context::default_set()
{ {
impl_->simple_drawing_desc_.xlink_href_ = L""; impl_->object_description_.xlink_href_ = L"";
impl_->simple_drawing_desc_.draw_name_ = L""; impl_->object_description_.draw_name_ = L"";
impl_->simple_drawing_desc_.additional_.clear(); impl_->object_description_.additional_.clear();
impl_->simple_drawing_desc_.anchor_ =L""; impl_->object_description_.anchor_ =L"";
impl_->simple_drawing_desc_.clipping_string_= L""; impl_->object_description_.clipping_string_= L"";
impl_->simple_drawing_desc_.svg_rect_ = boost::none; impl_->object_description_.svg_rect_ = boost::none;
impl_->simple_drawing_desc_.hlinks_.clear(); impl_->object_description_.hlinks_.clear();
impl_->simple_drawing_desc_.additional_.clear(); impl_->object_description_.additional_.clear();
} }
xlsx_drawing_context::~xlsx_drawing_context() xlsx_drawing_context::~xlsx_drawing_context()
{ {
...@@ -170,68 +170,68 @@ void xlsx_drawing_context::end_shapes() ...@@ -170,68 +170,68 @@ void xlsx_drawing_context::end_shapes()
void xlsx_drawing_context::start_drawing(std::wstring const & name) void xlsx_drawing_context::start_drawing(std::wstring const & name)
{ {
impl_->simple_drawing_desc_.draw_name_ = name; impl_->object_description_.draw_name_ = name;
} }
void xlsx_drawing_context::set_rect(double width_pt, double height_pt, double x_pt, double y_pt) void xlsx_drawing_context::set_rect(double width_pt, double height_pt, double x_pt, double y_pt)
{ {
_rect r = {width_pt,height_pt,x_pt,y_pt}; _rect r = {width_pt,height_pt,x_pt,y_pt};
impl_->simple_drawing_desc_.svg_rect_= r; impl_->object_description_.svg_rect_= r;
} }
void xlsx_drawing_context::set_translate(double x_pt, double y_pt) void xlsx_drawing_context::set_translate(double x_pt, double y_pt)
{ {
if (impl_->simple_drawing_desc_.svg_rect_) if (impl_->object_description_.svg_rect_)
{ {
_rect r = impl_->simple_drawing_desc_.svg_rect_.get(); _rect r = impl_->object_description_.svg_rect_.get();
r.x_+=x_pt; r.x_+=x_pt;
r.y_+=y_pt; r.y_+=y_pt;
impl_->simple_drawing_desc_.svg_rect_= r; impl_->object_description_.svg_rect_= r;
} }
} }
void xlsx_drawing_context::set_rotate(double angle) void xlsx_drawing_context::set_rotate(double angle)
{ {
set_property(odf::_property(L"svg:rotate",angle)); set_property(odf::_property(L"svg:rotate",angle));
if (impl_->simple_drawing_desc_.svg_rect_) if (impl_->object_description_.svg_rect_)
{ {
_rect r = impl_->simple_drawing_desc_.svg_rect_.get(); _rect r = impl_->object_description_.svg_rect_.get();
//r.x_-=r.width_/2; //r.x_-=r.width_/2;
//r.y_-=r.height_/2; //r.y_-=r.height_/2;
impl_->simple_drawing_desc_.svg_rect_= r; impl_->object_description_.svg_rect_= r;
} }
} }
void xlsx_drawing_context::set_scale(double cx_pt, double cy_pt) void xlsx_drawing_context::set_scale(double cx_pt, double cy_pt)
{ {
if (impl_->simple_drawing_desc_.svg_rect_) if (impl_->object_description_.svg_rect_)
{ {
_rect r = impl_->simple_drawing_desc_.svg_rect_.get(); _rect r = impl_->object_description_.svg_rect_.get();
r.x_*=cx_pt; r.x_*=cx_pt;
r.y_*=cy_pt; r.y_*=cy_pt;
impl_->simple_drawing_desc_.svg_rect_= r; impl_->object_description_.svg_rect_= r;
} }
} }
void xlsx_drawing_context::set_anchor(std::wstring anchor, double x_pt, double y_pt) void xlsx_drawing_context::set_anchor(std::wstring anchor, double x_pt, double y_pt)
{ {
impl_->simple_drawing_desc_.anchor_ = anchor; impl_->object_description_.anchor_ = anchor;
impl_->simple_drawing_desc_.anchor_x_ = x_pt; impl_->object_description_.anchor_x_ = x_pt;
impl_->simple_drawing_desc_.anchor_y_ = y_pt; impl_->object_description_.anchor_y_ = y_pt;
} }
void xlsx_drawing_context::set_property(odf::_property p) void xlsx_drawing_context::set_property(odf::_property p)
{ {
impl_->simple_drawing_desc_.additional_.push_back(p); impl_->object_description_.additional_.push_back(p);
} }
std::vector<odf::_property> & xlsx_drawing_context::get_properties() std::vector<odf::_property> & xlsx_drawing_context::get_properties()
{ {
return impl_->simple_drawing_desc_.additional_; return impl_->object_description_.additional_;
} }
void xlsx_drawing_context::set_clipping(std::wstring & str) void xlsx_drawing_context::set_clipping(std::wstring & str)
{ {
impl_->simple_drawing_desc_.clipping_string_= str; impl_->object_description_.clipping_string_= str;
} }
void xlsx_drawing_context::set_fill(_oox_fill & fill) void xlsx_drawing_context::set_fill(_oox_fill & fill)
{ {
impl_->simple_drawing_desc_.fill_= fill; impl_->object_description_.fill_= fill;
} }
std::wstring xlsx_drawing_context::add_hyperlink(std::wstring const & ref,bool object) std::wstring xlsx_drawing_context::add_hyperlink(std::wstring const & ref,bool object)
{ {
...@@ -239,7 +239,7 @@ std::wstring xlsx_drawing_context::add_hyperlink(std::wstring const & ref,bool o ...@@ -239,7 +239,7 @@ std::wstring xlsx_drawing_context::add_hyperlink(std::wstring const & ref,bool o
std::wstring hId=std::wstring(L"hId") + boost::lexical_cast<std::wstring>(hlinks_size_); std::wstring hId=std::wstring(L"hId") + boost::lexical_cast<std::wstring>(hlinks_size_);
_hlink_desc desc={hId, ref, object}; _hlink_desc desc={hId, ref, object};
impl_->simple_drawing_desc_.hlinks_.push_back(desc); impl_->object_description_.hlinks_.push_back(desc);
return hId; return hId;
} }
...@@ -250,32 +250,32 @@ void xlsx_drawing_context::end_drawing() ...@@ -250,32 +250,32 @@ void xlsx_drawing_context::end_drawing()
void xlsx_drawing_context::start_shape(int type) void xlsx_drawing_context::start_shape(int type)
{ {
impl_->simple_drawing_desc_.type_ = type; //2,3... impl_->object_description_.type_ = type; //2,3...
} }
void xlsx_drawing_context::end_shape() void xlsx_drawing_context::end_shape()
{ {
impl_->shapes_.push_back(impl_->simple_drawing_desc_); impl_->shapes_.push_back(impl_->object_description_);
default_set(); default_set();
} }
void xlsx_drawing_context::start_image(std::wstring const & path) void xlsx_drawing_context::start_image(std::wstring const & path)
{ {
impl_->simple_drawing_desc_.type_ = 0; //frame impl_->object_description_.type_ = 0; //frame
impl_->simple_drawing_desc_.xlink_href_ = path; impl_->object_description_.xlink_href_ = path;
} }
void xlsx_drawing_context::start_chart(std::wstring const & path) void xlsx_drawing_context::start_chart(std::wstring const & path)
{ {
impl_->simple_drawing_desc_.type_ = 0; //frame impl_->object_description_.type_ = 0; //frame
impl_->simple_drawing_desc_.xlink_href_ = path; impl_->object_description_.xlink_href_ = path;
} }
void xlsx_drawing_context::end_image() void xlsx_drawing_context::end_image()
{ {
impl_->images_.push_back(impl_->simple_drawing_desc_); impl_->images_.push_back(impl_->object_description_);
default_set(); default_set();
} }
void xlsx_drawing_context::end_chart() void xlsx_drawing_context::end_chart()
{ {
impl_->charts_.push_back(impl_->simple_drawing_desc_); impl_->charts_.push_back(impl_->object_description_);
default_set(); default_set();
} }
bool xlsx_drawing_context::empty() const bool xlsx_drawing_context::empty() const
......
...@@ -37,19 +37,6 @@ void xlsx_serialize(std::wostream & _Wostream, const xlsx_patternFill & patternF ...@@ -37,19 +37,6 @@ void xlsx_serialize(std::wostream & _Wostream, const xlsx_patternFill & patternF
} }
} }
//_Wostream << L"<patternFill ";
//if (patternFill.patternType)
// _Wostream << L"patternType=\"" << patternFill.patternType.get() << L"\" ";
//_Wostream << L">";
//if (patternFill.fgColor)
// xlsx_serialize(_Wostream, patternFill.fgColor.get(), L"fgColor");
//if (patternFill.bgColor)
// xlsx_serialize(_Wostream, patternFill.bgColor.get(), L"bgColor");
//_Wostream << L"</patternFill>";
} }
std::size_t hash_value(xlsx_patternFill const & val) std::size_t hash_value(xlsx_patternFill const & val)
......
...@@ -183,18 +183,128 @@ int Compute_BorderWidth(const graphic_format_properties & graphicProperties, Bor ...@@ -183,18 +183,128 @@ int Compute_BorderWidth(const graphic_format_properties & graphicProperties, Bor
return get_value_emu(lengthValue); return get_value_emu(lengthValue);
} }
void Compute_GradientFill(draw_gradient * image_style,oox::oox_gradient_fill_ptr fill)
{
int style =0;
if (image_style->draw_style_)style = image_style->draw_style_->get_type();
if (image_style->draw_angle_)fill->angle = 90 - *image_style->draw_angle_/10.;
if (fill->angle < 0) fill->angle +=360;
oox::oox_gradient_fill::_color_position point={};
switch(style)
{
case gradient_style::linear:
{
fill->style = 0;
point.pos = 0;
if (image_style->draw_start_color_)point.color_ref = image_style->draw_start_color_->get_hex_value();
if (image_style->draw_start_intensity_)point.opacity = image_style->draw_start_intensity_->get_value();
fill->colors.push_back(point);
point.pos = 100;
if (image_style->draw_end_color_)point.color_ref = image_style->draw_end_color_->get_hex_value();
if (image_style->draw_end_intensity_)point.opacity = image_style->draw_end_intensity_->get_value();
fill->colors.push_back(point);
}break;
case gradient_style::axial:
{
fill->style = 0;
point.pos = 0;
if (image_style->draw_end_color_)point.color_ref = image_style->draw_end_color_->get_hex_value();
if (image_style->draw_end_intensity_)point.opacity = image_style->draw_end_intensity_->get_value();
fill->colors.push_back(point);
point.pos = 50;
if (image_style->draw_start_color_)point.color_ref = image_style->draw_start_color_->get_hex_value();
if (image_style->draw_start_intensity_)point.opacity = image_style->draw_start_intensity_->get_value();
fill->colors.push_back(point);
point.pos = 100;
if (image_style->draw_end_color_)point.color_ref = image_style->draw_end_color_->get_hex_value();
if (image_style->draw_end_intensity_)point.opacity = image_style->draw_end_intensity_->get_value();
fill->colors.push_back(point);
}break;
case gradient_style::radial:
case gradient_style::ellipsoid:
case gradient_style::square:
case gradient_style::rectangular:
{
if (style == gradient_style::radial || style == gradient_style::ellipsoid) fill->style = 2;
if (style == gradient_style::square ) fill->style = 1;
if (style == gradient_style::rectangular) fill->style = 3;
point.pos = 0;
if (image_style->draw_end_color_)point.color_ref = image_style->draw_end_color_->get_hex_value();
if (image_style->draw_end_intensity_)point.opacity = image_style->draw_end_intensity_->get_value();
fill->colors.push_back(point);
point.pos = 100;
if (image_style->draw_start_color_)point.color_ref = image_style->draw_start_color_->get_hex_value();
if (image_style->draw_start_intensity_)point.opacity = image_style->draw_start_intensity_->get_value();
fill->colors.push_back(point);
if (image_style->draw_cx_)// - open-office l & r !!!
{
fill->rect[0]=image_style->draw_cx_->get_value();
fill->rect[2]=100-image_style->draw_cx_->get_value();
}
else
{
fill->rect[0]=0;
fill->rect[2]=100;
}
if (image_style->draw_cy_)
{
fill->rect[1]=image_style->draw_cy_->get_value();
fill->rect[3]=100-image_style->draw_cy_->get_value();
}
else
{
fill->rect[1]=0;
fill->rect[3]=100;
}
}break;
}
}
void Compute_GraphicFill(graphic_format_properties & props, styles_lite_container &styles, oox::_oox_fill & fill) void Compute_GraphicFill(graphic_format_properties & props, styles_lite_container &styles, oox::_oox_fill & fill)
{ {
fill.type = 0; fill.type = 0;
if (props.draw_fill_)fill.type = props.draw_fill_->get_type(); if (props.draw_fill_)fill.type = props.draw_fill_->get_type();
if (props.draw_opacity_) fill.opacity = props.draw_opacity_->get_percent().get_value(); if (props.draw_opacity_) fill.opacity = props.draw_opacity_->get_value();
if (props.draw_opacity_name_) if (props.draw_opacity_name_)
{ {
fill.opacity = 1; const std::wstring style_name = L"opacity:" + *props.draw_opacity_name_;
// - if (office_element_ptr style = styles.find_by_style_name(style_name))
{
if (draw_opacity * image_style = dynamic_cast<draw_opacity *>(style.get()))
{
// ms -
if (image_style->draw_start_ && image_style->draw_end_)
{
fill.opacity = (image_style->draw_start_->get_value() + image_style->draw_end_->get_value())/2.;
}
else if (image_style->draw_start_)fill.opacity = image_style->draw_start_->get_value();
else if (image_style->draw_end_)fill.opacity = image_style->draw_end_->get_value();
}
} }
}
if (props.draw_image_opacity_)
fill.opacity = props.draw_image_opacity_->get_value();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
if (props.draw_fill_color_) if (props.draw_fill_color_)
...@@ -220,7 +330,20 @@ void Compute_GraphicFill(graphic_format_properties & props, styles_lite_containe ...@@ -220,7 +330,20 @@ void Compute_GraphicFill(graphic_format_properties & props, styles_lite_containe
if (*props.style_repeat_== L"repeat") fill.bitmap->bTile = true; if (*props.style_repeat_== L"repeat") fill.bitmap->bTile = true;
if (*props.style_repeat_== L"stretch") fill.bitmap->bStretch = true; if (*props.style_repeat_== L"stretch") fill.bitmap->bStretch = true;
} }
if (props.draw_fill_gradient_name_)
{
const std::wstring style_name = L"gradient:" + *props.draw_fill_gradient_name_;
if (office_element_ptr style = styles.find_by_style_name(style_name))
{
if (draw_gradient * image_style = dynamic_cast<draw_gradient *>(style.get()))
{
fill.gradient = oox::oox_gradient_fill::create();
Compute_GradientFill(image_style, fill.gradient);
}
}
}
} }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......
#include "precompiled_cpodf.h"
#include "gradientstyle.h"
#include <ostream>
namespace cpdoccore {
namespace odf {
gradient_style gradient_style::parse(const std::wstring & Str)
{
std::wstring tmp = Str;
boost::algorithm::to_lower(tmp);
if (tmp == L"linear")
return gradient_style( linear );
else if (tmp == L"axial")
return gradient_style( axial );
else if (tmp == L"radial")
return gradient_style(radial );
else if (tmp == L"ellipsoid")
return gradient_style( ellipsoid);
else if (tmp == L"square")
return gradient_style( square );
else if (tmp == L"rectangular")
return gradient_style( rectangular );
else
{
BOOST_THROW_EXCEPTION( errors::invalid_attribute() );
return gradient_style( linear );
}
}
}
}
#pragma once
#include <iosfwd>
#include <string>
#include "odfattributes.h"
namespace cpdoccore {
namespace odf {
class gradient_style
{
public:
enum type
{
linear,
axial,
radial,
ellipsoid,
square,
rectangular
};
gradient_style() {}
gradient_style(type _Type) : type_(_Type)
{}
type get_type() const
{
return type_;
};
static gradient_style parse(const std::wstring & Str);
private:
type type_;
};
std::wostream & operator << (std::wostream & _Wostream, const gradient_style & _Val);
}
APPLY_PARSE_XML_ATTRIBUTES(odf::gradient_style);
}
...@@ -427,6 +427,15 @@ void odf_document::Impl::parse_styles() ...@@ -427,6 +427,15 @@ void odf_document::Impl::parse_styles()
continue; continue;
context_->drawStyles().add(L"bitmap:" + style->get_style_name(), elm); context_->drawStyles().add(L"bitmap:" + style->get_style_name(), elm);
}
BOOST_FOREACH(const office_element_ptr & elm, docStyles->draw_styles_.draw_opacity_)
{
draw_opacity * style = dynamic_cast<draw_opacity *>(elm.get());
if (!style)
continue;
context_->drawStyles().add(L"opacity:" + style->get_style_name(), elm);
} }
// BOOST_FOREACH(const office_element_ptr & elm, docStyles->draw_styles_.draw_hatch_) // BOOST_FOREACH(const office_element_ptr & elm, docStyles->draw_styles_.draw_hatch_)
// { // {
......
...@@ -18,6 +18,7 @@ void graphic_format_properties::add_attributes( const xml::attributes_wc_ptr & A ...@@ -18,6 +18,7 @@ void graphic_format_properties::add_attributes( const xml::attributes_wc_ptr & A
CP_APPLY_ATTR(L"draw:fill", draw_fill_); CP_APPLY_ATTR(L"draw:fill", draw_fill_);
CP_APPLY_ATTR(L"draw:opacity", draw_opacity_); CP_APPLY_ATTR(L"draw:opacity", draw_opacity_);
CP_APPLY_ATTR(L"draw:image-opacity",draw_image_opacity_);
CP_APPLY_ATTR(L"draw:fill-image-name", draw_fill_image_name_); CP_APPLY_ATTR(L"draw:fill-image-name", draw_fill_image_name_);
CP_APPLY_ATTR(L"draw:fill-gradient-name", draw_fill_gradient_name_); CP_APPLY_ATTR(L"draw:fill-gradient-name", draw_fill_gradient_name_);
...@@ -104,6 +105,7 @@ void graphic_format_properties::apply_from(const graphic_format_properties & Oth ...@@ -104,6 +105,7 @@ void graphic_format_properties::apply_from(const graphic_format_properties & Oth
_CP_APPLY_PROP2(draw_marker_start_); _CP_APPLY_PROP2(draw_marker_start_);
_CP_APPLY_PROP2(draw_marker_end_); _CP_APPLY_PROP2(draw_marker_end_);
_CP_APPLY_PROP2(draw_opacity_); _CP_APPLY_PROP2(draw_opacity_);
_CP_APPLY_PROP2(draw_image_opacity_);
_CP_APPLY_PROP2(draw_textarea_horizontal_align_); _CP_APPLY_PROP2(draw_textarea_horizontal_align_);
_CP_APPLY_PROP2(draw_textarea_vertical_align_); _CP_APPLY_PROP2(draw_textarea_vertical_align_);
......
#ifndef _CPDOCCORE_ODF_STYLE_GRAPHIC_PROPERTIES_H_ #pragma once
#define _CPDOCCORE_ODF_STYLE_GRAPHIC_PROPERTIES_H_
#include <iosfwd> #include <iosfwd>
#include <cpdoccore/xml/attributes.h> #include <cpdoccore/xml/attributes.h>
...@@ -24,6 +23,7 @@ ...@@ -24,6 +23,7 @@
#include "markerstyle.h" #include "markerstyle.h"
#include "verticalalign.h" #include "verticalalign.h"
#include "drawfill.h" #include "drawfill.h"
#include "gradientstyle.h"
namespace cpdoccore { namespace cpdoccore {
...@@ -49,7 +49,8 @@ public: ...@@ -49,7 +49,8 @@ public:
_CP_OPT(length_or_percent) fo_max_height_; _CP_OPT(length_or_percent) fo_max_height_;
//////////////////////////////// ////////////////////////////////
_CP_OPT(length_or_percent) draw_opacity_; _CP_OPT(percent) draw_opacity_;
_CP_OPT(percent) draw_image_opacity_;
_CP_OPT(draw_fill) draw_fill_; _CP_OPT(draw_fill) draw_fill_;
...@@ -165,4 +166,3 @@ CP_REGISTER_OFFICE_ELEMENT2(style_graphic_properties); ...@@ -165,4 +166,3 @@ CP_REGISTER_OFFICE_ELEMENT2(style_graphic_properties);
} }
} }
#endif
...@@ -240,6 +240,29 @@ void draw_gradient::add_child_element( xml::sax * Reader, const ::std::wstring & ...@@ -240,6 +240,29 @@ void draw_gradient::add_child_element( xml::sax * Reader, const ::std::wstring &
{ {
CP_NOT_APPLICABLE_ELM(); CP_NOT_APPLICABLE_ELM();
} }
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * draw_opacity::ns = L"draw";
const wchar_t * draw_opacity::name = L"opacity";
void draw_opacity::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"draw:name", draw_name_);
CP_APPLY_ATTR(L"draw:display-name", draw_display_name_);
CP_APPLY_ATTR(L"draw:start", draw_start_);
CP_APPLY_ATTR(L"draw:end", draw_end_);
CP_APPLY_ATTR(L"draw:border", draw_border_);
CP_APPLY_ATTR(L"draw:angle", draw_angle_);
CP_APPLY_ATTR(L"draw:style", draw_style_);
}
void draw_opacity::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name)
{
CP_NOT_APPLICABLE_ELM();
}
// style:style // style:style
////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style::ns = L"style"; const wchar_t * style::ns = L"style";
...@@ -324,16 +347,18 @@ void draw_styles::add_child_element( xml::sax * Reader, const ::std::wstring & N ...@@ -324,16 +347,18 @@ void draw_styles::add_child_element( xml::sax * Reader, const ::std::wstring & N
{ {
CP_CREATE_ELEMENT_SIMPLE(draw_fill_image_); CP_CREATE_ELEMENT_SIMPLE(draw_fill_image_);
} }
// else if (L"draw" == Ns && L"marker" == Name) else if CP_CHECK_NAME(L"draw", L"opacity")
// CP_CREATE_ELEMENT(draw_marker_); {
// else if (L"draw" == Ns && L"stroke-dash" == Name) CP_CREATE_ELEMENT_SIMPLE(draw_opacity_);
// CP_CREATE_ELEMENT(draw_stroke_dash_); }
// else if (L"draw" == Ns && L"opacity" == Name) else if CP_CHECK_NAME(L"draw", L"marker")
// CP_CREATE_ELEMENT(draw_opacity_); {
//else if (L"svg" == Ns && L"linearGradient" == Name) CP_CREATE_ELEMENT_SIMPLE(draw_marker_);
// CP_CREATE_ELEMENT(svg_linearGradient_); }
//else if (L"svg" == Ns && L"radialGradient" == Name) else if CP_CHECK_NAME(L"draw", L"stroke-dash")
// CP_CREATE_ELEMENT(svg_radialGradient_); {
CP_CREATE_ELEMENT_SIMPLE(draw_stroke_dash_);
}
else else
{ {
CP_NOT_APPLICABLE_ELM_SIMPLE(L"draw_styles"); CP_NOT_APPLICABLE_ELM_SIMPLE(L"draw_styles");
......
#ifndef _CPDOCCORE_ODF_OFFCIE_STYLES_H_ #pragma once
#define _CPDOCCORE_ODF_OFFCIE_STYLES_H_
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -31,6 +30,7 @@ ...@@ -31,6 +30,7 @@
#include "styletype.h" #include "styletype.h"
#include "common_attlists.h" #include "common_attlists.h"
#include "noteclass.h" #include "noteclass.h"
#include "gradientstyle.h"
#include "styles_list.h" #include "styles_list.h"
...@@ -134,12 +134,12 @@ public: ...@@ -134,12 +134,12 @@ public:
_CP_OPT(percent) draw_end_intensity_; _CP_OPT(percent) draw_end_intensity_;
_CP_OPT(percent) draw_start_intensity_; _CP_OPT(percent) draw_start_intensity_;
_CP_OPT(length_or_percent) draw_cy_;//% _CP_OPT(percent) draw_cy_;//%
_CP_OPT(length_or_percent) draw_cx_; _CP_OPT(percent) draw_cx_;
_CP_OPT(percent) draw_border_; _CP_OPT(percent) draw_border_;
_CP_OPT(int) draw_angle_; _CP_OPT(int) draw_angle_;
_CP_OPT(std::wstring) draw_style_;//"square" _CP_OPT(gradient_style) draw_style_;
private: private:
...@@ -150,10 +150,40 @@ private: ...@@ -150,10 +150,40 @@ private:
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name); virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
friend class odf_document; friend class odf_document;
}; };
CP_REGISTER_OFFICE_ELEMENT2(draw_gradient); CP_REGISTER_OFFICE_ELEMENT2(draw_gradient);
///////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////
/// \class style_draw_gradient
class draw_opacity : public office_element_impl<draw_opacity>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeStyleDrawGradient;
CPDOCCORE_DEFINE_VISITABLE();
std::wstring get_style_name(){return draw_name_.get_value_or(L"");}
_CP_OPT(gradient_style) draw_style_;//linear, radial, ..
_CP_OPT(int) draw_angle_;
_CP_OPT(percent) draw_start_;
_CP_OPT(percent) draw_end_;
_CP_OPT(percent) draw_border_;
private:
_CP_OPT(std::wstring) draw_name_;
_CP_OPT(std::wstring) draw_display_name_;
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
friend class odf_document;
};
CP_REGISTER_OFFICE_ELEMENT2(draw_opacity);
/// \class style_draw_fill_image /// \class style_draw_fill_image
class draw_fill_image : public office_element_impl<draw_fill_image> class draw_fill_image : public office_element_impl<draw_fill_image>
{ {
...@@ -261,14 +291,13 @@ public: ...@@ -261,14 +291,13 @@ public:
private: private:
office_element_ptr_array draw_gradient_; office_element_ptr_array draw_gradient_;
office_element_ptr_array draw_fill_image_; office_element_ptr_array draw_fill_image_;
office_element_ptr_array draw_opacity_;
office_element_ptr_array draw_hatch_; office_element_ptr_array draw_hatch_;
office_element_ptr_array draw_marker_; // < TODO office_element_ptr_array draw_marker_; // < TODO
office_element_ptr_array draw_stroke_dash_; // < TODO office_element_ptr_array draw_stroke_dash_; // < TODO
office_element_ptr_array draw_opacity_; // < TODO
office_element_ptr_array svg_linearGradient_; // < TODO office_element_ptr_array svg_linearGradient_; // < TODO
office_element_ptr_array svg_radialGradient_; // < TODO office_element_ptr_array svg_radialGradient_; // < TODO
...@@ -1047,5 +1076,3 @@ private: ...@@ -1047,5 +1076,3 @@ private:
CP_REGISTER_OFFICE_ELEMENT2(style_presentation_page_layout); CP_REGISTER_OFFICE_ELEMENT2(style_presentation_page_layout);
} // namespace odf } // namespace odf
} // namespace cpdoccore } // namespace cpdoccore
#endif
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