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 @@
RelativePath=".\src\odf\fontweight.h"
>
</File>
<File
RelativePath=".\src\odf\gradientstyle.cpp"
>
</File>
<File
RelativePath=".\src\odf\gradientstyle.h"
>
</File>
<File
RelativePath=".\src\odf\hyphenationkeep.cpp"
>
......
......@@ -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_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)
{
......@@ -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_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)
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)
{
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)
case 2:
oox_serialize_bitmap_fill(strm, val);
break;
//case 3: oox_serialize_gradient_fill(strm, val);break;
//case 4: oox_serialize_hatch_fill(strm, val);break;
case 3:
oox_serialize_gradient_fill(strm, val);
break;
case 4: oox_serialize_hatch_fill(strm, val);
break;
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
......
......@@ -11,13 +11,14 @@ namespace cpdoccore {
namespace oox {
class oox_gradient_fill;
typedef _CP_PTR(oox_gradient_fill) oox_gradient_fill_ptr;
class oox_gradient_fill
class oox_solid_fill;
typedef _CP_PTR(oox_solid_fill) oox_solid_fill_ptr;
class oox_solid_fill
{
public:
oox_gradient_fill(){}
static oox_gradient_fill_ptr create();
std::wstring color;
static oox_solid_fill_ptr create();
};
///////////////////////////////////
......@@ -53,19 +54,33 @@ namespace oox {
static oox_hatch_fill_ptr create();
};
////////////////////////////////////////////////////////////
class oox_solid_fill;
typedef _CP_PTR(oox_solid_fill) oox_solid_fill_ptr;
class oox_solid_fill
class oox_gradient_fill;
typedef _CP_PTR(oox_gradient_fill) oox_gradient_fill_ptr;
class oox_gradient_fill
{
public:
oox_solid_fill(){}
std::wstring color;
static oox_solid_fill_ptr create();
struct _color_position
{
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_hatch_fill_ptr hatch;
oox_bitmap_fill_ptr bitmap;
......@@ -76,7 +91,18 @@ namespace oox {
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(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()
}
std::wostream & pptx_xml_slideMaster::Background()
{
return slideMasterData_;
return slideMasterBackground_;
}
rels & pptx_xml_slideMaster::Rels()
{
......
......@@ -27,7 +27,7 @@ public:
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> charts_;
......@@ -97,89 +97,91 @@ void pptx_slide_context::start_slide()
}
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_->simple_drawing_desc_.anchor_ =L"";
impl_->object_description_.additional_.clear();
impl_->object_description_.anchor_ =L"";
impl_->simple_drawing_desc_.clipping_string_= L"";
impl_->simple_drawing_desc_.svg_rect_ = boost::none;
impl_->object_description_.clipping_string_= L"";
impl_->object_description_.svg_rect_ = boost::none;
impl_->simple_drawing_desc_.hlinks_.clear();
impl_->simple_drawing_desc_.additional_.clear();
impl_->object_description_.hlinks_.clear();
impl_->object_description_.additional_.clear();
impl_->object_description_.fill_.clear();
}
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)
{
_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)
{
set_property(odf::_property(L"svg:rotate",angle));
if (impl_->simple_drawing_desc_.svg_rect_)
if (impl_->object_description_.svg_rect_)
{
// open office
_rect r = impl_->simple_drawing_desc_.svg_rect_.get();
_rect r = impl_->object_description_.svg_rect_.get();
//r.x_-=r.width_;
//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)
{
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.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)
{
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.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)
{
impl_->simple_drawing_desc_.anchor_ = anchor;
impl_->simple_drawing_desc_.anchor_x_ = x_pt;
impl_->simple_drawing_desc_.anchor_y_ = y_pt;
impl_->object_description_.anchor_ = anchor;
impl_->object_description_.anchor_x_ = x_pt;
impl_->object_description_.anchor_y_ = y_pt;
}
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()
{
return impl_->simple_drawing_desc_.additional_;
return impl_->object_description_.additional_;
}
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)
{
impl_->simple_drawing_desc_.fill_= fill;
impl_->object_description_.fill_= fill;
}
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
std::wstring hId=std::wstring(L"hId") + boost::lexical_cast<std::wstring>(hlinks_size_);
_hlink_desc desc={hId, ref, object};
impl_->simple_drawing_desc_.hlinks_.push_back(desc);
impl_->object_description_.hlinks_.push_back(desc);
return hId;
}
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)
{
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)
{
impl_->simple_drawing_desc_.xlink_href_ = path;
impl_->simple_drawing_desc_.type_ = 0; //frame
impl_->object_description_.xlink_href_ = path;
impl_->object_description_.type_ = 0; //frame
}
void pptx_slide_context::start_chart(std::wstring const & path)
{
impl_->simple_drawing_desc_.xlink_href_ = path;
impl_->simple_drawing_desc_.type_ = 0; //frame
impl_->object_description_.xlink_href_ = path;
impl_->object_description_.type_ = 0; //frame
}
void pptx_slide_context::end_shape()
{
impl_->shapes_.push_back(impl_->simple_drawing_desc_);
impl_->shapes_.push_back(impl_->object_description_);
default_set();
}
void pptx_slide_context::end_image()
{
impl_->images_.push_back(impl_->simple_drawing_desc_);
impl_->images_.push_back(impl_->object_description_);
default_set();
}
void pptx_slide_context::end_chart()
{
impl_->charts_.push_back(impl_->simple_drawing_desc_);
impl_->charts_.push_back(impl_->object_description_);
default_set();
}
bool pptx_slide_context::empty() const
......
......@@ -87,7 +87,7 @@ public:
{}
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> charts_;
......@@ -143,18 +143,18 @@ xlsx_drawing_context::xlsx_drawing_context(xlsx_drawing_context_handle & h)
}
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_->simple_drawing_desc_.anchor_ =L"";
impl_->object_description_.additional_.clear();
impl_->object_description_.anchor_ =L"";
impl_->simple_drawing_desc_.clipping_string_= L"";
impl_->simple_drawing_desc_.svg_rect_ = boost::none;
impl_->object_description_.clipping_string_= L"";
impl_->object_description_.svg_rect_ = boost::none;
impl_->simple_drawing_desc_.hlinks_.clear();
impl_->simple_drawing_desc_.additional_.clear();
impl_->object_description_.hlinks_.clear();
impl_->object_description_.additional_.clear();
}
xlsx_drawing_context::~xlsx_drawing_context()
{
......@@ -170,68 +170,68 @@ void xlsx_drawing_context::end_shapes()
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)
{
_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)
{
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.y_+=y_pt;
impl_->simple_drawing_desc_.svg_rect_= r;
impl_->object_description_.svg_rect_= r;
}
}
void xlsx_drawing_context::set_rotate(double 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.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)
{
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.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)
{
impl_->simple_drawing_desc_.anchor_ = anchor;
impl_->simple_drawing_desc_.anchor_x_ = x_pt;
impl_->simple_drawing_desc_.anchor_y_ = y_pt;
impl_->object_description_.anchor_ = anchor;
impl_->object_description_.anchor_x_ = x_pt;
impl_->object_description_.anchor_y_ = y_pt;
}
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()
{
return impl_->simple_drawing_desc_.additional_;
return impl_->object_description_.additional_;
}
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)
{
impl_->simple_drawing_desc_.fill_= fill;
impl_->object_description_.fill_= fill;
}
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
std::wstring hId=std::wstring(L"hId") + boost::lexical_cast<std::wstring>(hlinks_size_);
_hlink_desc desc={hId, ref, object};
impl_->simple_drawing_desc_.hlinks_.push_back(desc);
impl_->object_description_.hlinks_.push_back(desc);
return hId;
}
......@@ -250,32 +250,32 @@ void xlsx_drawing_context::end_drawing()
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()
{
impl_->shapes_.push_back(impl_->simple_drawing_desc_);
impl_->shapes_.push_back(impl_->object_description_);
default_set();
}
void xlsx_drawing_context::start_image(std::wstring const & path)
{
impl_->simple_drawing_desc_.type_ = 0; //frame
impl_->simple_drawing_desc_.xlink_href_ = path;
impl_->object_description_.type_ = 0; //frame
impl_->object_description_.xlink_href_ = path;
}
void xlsx_drawing_context::start_chart(std::wstring const & path)
{
impl_->simple_drawing_desc_.type_ = 0; //frame
impl_->simple_drawing_desc_.xlink_href_ = path;
impl_->object_description_.type_ = 0; //frame
impl_->object_description_.xlink_href_ = path;
}
void xlsx_drawing_context::end_image()
{
impl_->images_.push_back(impl_->simple_drawing_desc_);
impl_->images_.push_back(impl_->object_description_);
default_set();
}
void xlsx_drawing_context::end_chart()
{
impl_->charts_.push_back(impl_->simple_drawing_desc_);
impl_->charts_.push_back(impl_->object_description_);
default_set();
}
bool xlsx_drawing_context::empty() const
......
......@@ -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)
......
......@@ -183,18 +183,128 @@ int Compute_BorderWidth(const graphic_format_properties & graphicProperties, Bor
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)
{
fill.type = 0;
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_)
{
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_)
......@@ -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"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()
continue;
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_)
// {
......
......@@ -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: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-gradient-name", draw_fill_gradient_name_);
......@@ -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_end_);
_CP_APPLY_PROP2(draw_opacity_);
_CP_APPLY_PROP2(draw_image_opacity_);
_CP_APPLY_PROP2(draw_textarea_horizontal_align_);
_CP_APPLY_PROP2(draw_textarea_vertical_align_);
......
#ifndef _CPDOCCORE_ODF_STYLE_GRAPHIC_PROPERTIES_H_
#define _CPDOCCORE_ODF_STYLE_GRAPHIC_PROPERTIES_H_
#pragma once
#include <iosfwd>
#include <cpdoccore/xml/attributes.h>
......@@ -24,6 +23,7 @@
#include "markerstyle.h"
#include "verticalalign.h"
#include "drawfill.h"
#include "gradientstyle.h"
namespace cpdoccore {
......@@ -49,7 +49,8 @@ public:
_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_;
......@@ -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 &
{
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
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style::ns = L"style";
......@@ -324,16 +347,18 @@ void draw_styles::add_child_element( xml::sax * Reader, const ::std::wstring & N
{
CP_CREATE_ELEMENT_SIMPLE(draw_fill_image_);
}
// else if (L"draw" == Ns && L"marker" == Name)
// CP_CREATE_ELEMENT(draw_marker_);
// else if (L"draw" == Ns && L"stroke-dash" == Name)
// CP_CREATE_ELEMENT(draw_stroke_dash_);
// else if (L"draw" == Ns && L"opacity" == Name)
// CP_CREATE_ELEMENT(draw_opacity_);
//else if (L"svg" == Ns && L"linearGradient" == Name)
// CP_CREATE_ELEMENT(svg_linearGradient_);
//else if (L"svg" == Ns && L"radialGradient" == Name)
// CP_CREATE_ELEMENT(svg_radialGradient_);
else if CP_CHECK_NAME(L"draw", L"opacity")
{
CP_CREATE_ELEMENT_SIMPLE(draw_opacity_);
}
else if CP_CHECK_NAME(L"draw", L"marker")
{
CP_CREATE_ELEMENT_SIMPLE(draw_marker_);
}
else if CP_CHECK_NAME(L"draw", L"stroke-dash")
{
CP_CREATE_ELEMENT_SIMPLE(draw_stroke_dash_);
}
else
{
CP_NOT_APPLICABLE_ELM_SIMPLE(L"draw_styles");
......
#ifndef _CPDOCCORE_ODF_OFFCIE_STYLES_H_
#define _CPDOCCORE_ODF_OFFCIE_STYLES_H_
#pragma once
#include <string>
#include <vector>
......@@ -31,6 +30,7 @@
#include "styletype.h"
#include "common_attlists.h"
#include "noteclass.h"
#include "gradientstyle.h"
#include "styles_list.h"
......@@ -134,12 +134,12 @@ public:
_CP_OPT(percent) draw_end_intensity_;
_CP_OPT(percent) draw_start_intensity_;
_CP_OPT(length_or_percent) draw_cy_;//%
_CP_OPT(length_or_percent) draw_cx_;
_CP_OPT(percent) draw_cy_;//%
_CP_OPT(percent) draw_cx_;
_CP_OPT(percent) draw_border_;
_CP_OPT(int) draw_angle_;
_CP_OPT(std::wstring) draw_style_;//"square"
_CP_OPT(gradient_style) draw_style_;
private:
......@@ -150,10 +150,40 @@ private:
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_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 draw_fill_image : public office_element_impl<draw_fill_image>
{
......@@ -261,14 +291,13 @@ public:
private:
office_element_ptr_array draw_gradient_;
office_element_ptr_array draw_fill_image_;
office_element_ptr_array draw_opacity_;
office_element_ptr_array draw_hatch_;
office_element_ptr_array draw_marker_; // < 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_radialGradient_; // < TODO
......@@ -1047,5 +1076,3 @@ private:
CP_REGISTER_OFFICE_ELEMENT2(style_presentation_page_layout);
} // namespace odf
} // 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