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

(1.0.0.145): ASCOfficeOdfFile

презентации & таблицы - расширение типов заливок объектов 

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@53103 954022d7-b5bf-4e40-9824-e11837661b57
parent 21f84739
......@@ -2,6 +2,6 @@
//1
//0
//0
//144
#define INTVER 1,0,0,144
#define STRVER "1,0,0,144\0"
//145
#define INTVER 1,0,0,145
#define STRVER "1,0,0,145\0"
......@@ -357,6 +357,14 @@
RelativePath=".\src\odf\styles_list.h"
>
</File>
<File
RelativePath=".\src\odf\styles_lite_container.cpp"
>
</File>
<File
RelativePath=".\src\odf\styles_lite_container.h"
>
</File>
</Filter>
<Filter
Name="datatypes odf"
......@@ -1394,6 +1402,10 @@
RelativePath=".\src\conversionelement.h"
>
</File>
<File
RelativePath=".\src\docx\drawing_object_description.h"
>
</File>
<File
RelativePath=".\src\docx\measuredigits.cpp"
>
......@@ -1760,14 +1772,6 @@
RelativePath=".\src\odf\odf_document_impl.h"
>
</File>
<File
RelativePath=".\src\odf\odf_number_styles.cpp"
>
</File>
<File
RelativePath=".\src\odf\odf_number_styles.h"
>
</File>
<File
RelativePath=".\src\odf\odfcontext.cpp"
>
......
......@@ -218,18 +218,9 @@ void docx_serialize_image(std::wostream & strm, _docx_drawing const & val)
}
}
}
val.fill.bitmap->name_space = L"pic";
oox_serialize_fill(CP_XML_STREAM(), val.fill);
CP_XML_NODE(L"pic:blipFill")
{
CP_XML_NODE(L"a:blip")
{
if (val.isInternal)
CP_XML_ATTR(L"r:embed",val.rId );
else
CP_XML_ATTR(L"r:link",val.rId );
}
oox_serialize_clipping(CP_XML_STREAM(),val);
}
CP_XML_NODE(L"pic:spPr")
{
oox_serialize_xfrm(CP_XML_STREAM(),val);
......@@ -269,7 +260,7 @@ void docx_serialize_chart(std::wostream & strm, _docx_drawing const & val)
CP_XML_ATTR(L"uri", L"http://schemas.openxmlformats.org/drawingml/2006/chart");
CP_XML_NODE(L"c:chart")
{
CP_XML_ATTR(L"r:id", val.rId);
CP_XML_ATTR(L"r:id", val.chartId);
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"xmlns:c", L"http://schemas.openxmlformats.org/drawingml/2006/chart");
}
......
......@@ -15,10 +15,9 @@ namespace oox {
struct _docx_drawing : _oox_drawing
{
_docx_drawing():_oox_drawing(),isInternal(false),parallel(0),isInline(false),number_wrapped_paragraphs(0),posOffsetV(0),posOffsetH(0)
_docx_drawing():_oox_drawing(),parallel(0),isInline(false),number_wrapped_paragraphs(0),posOffsetV(0),posOffsetH(0)
{
}
bool isInternal;
unsigned int parallel;
//_CP_OPT(run_through) styleRunThrough ;
......
#pragma once
//#include "oox_drawing_fills.h"
namespace cpdoccore {
namespace oox {
struct _rect
{
double width_;
double height_;
double x_;
double y_;
};
//+ 3-
struct drawing_object_description
{
std::wstring draw_name_;
_CP_OPT(_rect) svg_rect_;
std::wstring anchor_;
double anchor_x_;
double anchor_y_;
std::vector<_hlink_desc> hlinks_;
std::vector<odf::_property> additional_;//for shapes
std::wstring xlink_href_;//
std::wstring clipping_string_;
_oox_fill fill_;
int type_; //default - frame
};
}
}
\ No newline at end of file
......@@ -57,7 +57,7 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, Type type, bool
int number=0;
if ( type == typeChart)
number= count_charts+1;// xlsx_package
number= count_charts+1;
else if ( type == typeImage)
number= count_image+1;
else if ( type == typeShape)
......
......@@ -22,30 +22,8 @@ void oox_chart_shape::oox_serialize(std::wostream & _Wostream)
{
CP_XML_NODE(L"c:spPr")
{
std::wstring fillType = L"a:solidFill";
if (odf::GetProperty(content_,L"fill",strVal))fillType = *strVal;
odf::GetProperty(content_,L"fill-color",strVal);
if (strVal && fillType != L"a:noFill")
{
CP_XML_NODE(fillType)
{
CP_XML_NODE(L"a:srgbClr")
{
CP_XML_ATTR(L"val",strVal.get());
if (odf::GetProperty(content_,L"opacity",dVal))
{
CP_XML_NODE(L"a:alpha")
{
CP_XML_ATTR(L"val",boost::lexical_cast<std::wstring>((int)(dVal.get())) + L"%");
}
}
}
}
}
oox_serialize_fill(CP_XML_STREAM(),fill);
oox_serialize_ln(CP_XML_STREAM(),content_);
}
}
......
......@@ -5,6 +5,7 @@
#include <cpdoccore/CPScopedPtr.h>
#include "..\odf\chart_objects.h"
#include "oox_drawing_fills.h"
namespace cpdoccore {
namespace oox {
......@@ -19,10 +20,15 @@ public:
std::vector<odf::_property> content_;
_oox_fill fill;
private:
//grpFill (Group Fill) 20.1.8.35
//pattFill (Pattern Fill) 20.1.8.47
//noFill (No Fill) 20.1.8.44
//blipFill (Picture Fill) 20.1.8.14
//solidFill (Solid Fill) 20.1.8.54
//gradFill (Gradient Fill) 20.1.8.33
//ln (Outline) 20.1.2.2.24
......@@ -31,14 +37,12 @@ private:
//friend void xlsx_serialize(std::wostream & _Wostream, const oox_chart_shape & legend_);
//noFill (No Fill) 20.1.8.44
//blipFill (Picture Fill) 20.1.8.14
//custGeom (Custom Geometry) 20.1.9.8
//effectDag (Effect Container) 20.1.8.25
//effectLst (Effect Container) 20.1.8.26
//extLst (Extension List) 20.1.2.2.15
//grpFill (Group Fill) 20.1.8.35
//pattFill (Pattern Fill) 20.1.8.47
//prstGeom (Preset geometry) 20.1.9.18
//scene3d (3D Scene Properties) 20.1.4.1.26
//sp3d (Apply 3D shape properties) 20.1.5.12
......
......@@ -264,56 +264,11 @@ void oox_serialize_shape(std::wostream & strm, _oox_drawing const & val)
oox_serialize_aLst(CP_XML_STREAM(),val.additional);
}
}
oox_serialize_fill(strm,val.fill);
//////////////////////////////////////////////
//if (val.drawing.fill_Id.length()>0)
//{
// CP_XML_NODE(L"a:blipFill")
// {
// CP_XML_ATTR(L"rotWithShape", L"1");
// CP_XML_NODE(L"a:blip")
// {
// CP_XML_ATTR(L"r:embed", val.fill_Id);
// CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
// }
// oox_serialize_clipping(CP_XML_STREAM(),val);
// } // xdr:blipFill
//}
//else
{
std::wstring fillType;
if (odf::GetProperty(val.additional,L"fill",strVal))fillType = *strVal;
if (val.sub_type ==6)fillType = L"a:noFill";// ods ... !!
odf::GetProperty(val.additional,L"fill-color",strVal);
if ((strVal) && (strVal->length()>0 && fillType.length()<1))fillType = L"a:solidFill";
if (fillType.length()>0)
{
CP_XML_NODE(fillType)
{
if (strVal && fillType != L"a:noFill")
{
CP_XML_NODE(L"a:srgbClr")
{
CP_XML_ATTR(L"val",strVal.get());
if (odf::GetProperty(val.additional,L"opacity",dVal))
{
CP_XML_NODE(L"a:alpha")
{
CP_XML_ATTR(L"val",boost::lexical_cast<std::wstring>((int)(dVal.get())) + L"%");
}
}
}
}
}
}
}
}
}
void oox_serialize_xfrm(std::wostream & strm, _oox_drawing const & val)
{
CP_XML_WRITER(strm)
......@@ -391,26 +346,6 @@ void oox_serialize_hlink(std::wostream & strm, std::vector<_hlink_desc> const &
}
}
}
void oox_serialize_clipping(std::wostream & strm, _oox_drawing const & val)
{
CP_XML_WRITER(strm)
{
if (val.clipping_enabled)
{
CP_XML_NODE(L"a:srcRect")// :(
{
CP_XML_ATTR(L"l", static_cast<size_t>(val.clipping_rect[0]*1000));
CP_XML_ATTR(L"t", static_cast<size_t>(val.clipping_rect[1]*1000));
CP_XML_ATTR(L"r", static_cast<size_t>(val.clipping_rect[2]*1000));
CP_XML_ATTR(L"b", static_cast<size_t>(val.clipping_rect[3]*1000));
}
}
CP_XML_NODE(L"a:stretch")
{
if (!val.clipping_enabled)CP_XML_NODE(L"a:fillRect");
}
}
}
......
......@@ -7,6 +7,7 @@
#include <cpdoccore/xml/attributes.h>
#include "mediaitems.h"
#include "oox_drawing_fills.h"
static const int _odf_to_oox_ShapeType[]=
{ 4,4,4,34,};
......@@ -35,7 +36,7 @@ struct _hlink_desc
};
struct _oox_drawing
{
_oox_drawing():type(mediaitems::typeUnknown),id(0),x(0),y(0),cx(0),cy(0),sub_type(0),clipping_enabled(false),name(L"object")
_oox_drawing():type(mediaitems::typeUnknown),id(0),x(0),y(0),cx(0),cy(0),sub_type(0),name(L"object")
{
}
mediaitems::Type type;
......@@ -43,18 +44,13 @@ struct _oox_drawing
size_t id;
std::wstring name;
std::wstring rId;
//std::wstring fill_Id;
//std::wstring fill_Ref_Out;
//std::wstring fill_Ref_Inp;
size_t x, y;
size_t cx, cy;
bool clipping_enabled;
double clipping_rect[4];//0-left, 1 -top, 2- right, 3 - bottom
_oox_fill fill;
int sub_type;
std::wstring chartId;
std::vector<_hlink_desc> hlinks;
......@@ -64,7 +60,6 @@ struct _oox_drawing
friend void oox_serialize_shape(std::wostream & strm, _oox_drawing const & val);
friend void oox_serialize_ln (std::wostream & _Wostream, const std::vector<odf::_property> & val);
friend void oox_serialize_hlink (std::wostream & _Wostream, const std::vector<_hlink_desc> & val);
friend void oox_serialize_clipping(std::wostream & strm, _oox_drawing const & val);
friend void oox_serialize_bodyPr(std::wostream & strm, const std::vector<odf::_property> & val);
};
......
#include "precompiled_cpodf.h"
#include "oox_drawing_fills.h"
#include <cpdoccore/xml/simple_xml_writer.h>
namespace cpdoccore {
namespace oox {
oox_bitmap_fill::oox_bitmap_fill() : name_space(L"a"), bStretch(false), bCrop(false),bTile(false),isInternal(true)
{
memset(cropRect,0,sizeof(double)*4);
}
oox_bitmap_fill_ptr oox_bitmap_fill::create(){return boost::make_shared<oox_bitmap_fill>();}
oox_hatch_fill_ptr oox_hatch_fill::create(){return boost::make_shared<oox_hatch_fill>();}
oox_solid_fill_ptr oox_solid_fill::create(){return boost::make_shared<oox_solid_fill>();}
oox_gradient_fill_ptr oox_gradient_fill::create(){return boost::make_shared<oox_gradient_fill>();}
//////////////////////////////////////////////////////////////////////////////////////////////////////
void oox_serialize_none_fill(std::wostream & strm)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:noFill");
}
}
void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(double) opacity)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:srgbClr")
{
CP_XML_ATTR(L"val",color);
if (opacity)
{
CP_XML_NODE(L"a:alpha")
{
CP_XML_ATTR(L"val",boost::lexical_cast<std::wstring>(*opacity) + L"%");
}
}
}
}
}
void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(odf::length_or_percent) opacity)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:srgbClr")
{
CP_XML_ATTR(L"val",color);
if (opacity)
{
CP_XML_NODE(L"a:alpha")
{
CP_XML_ATTR(L"val",boost::lexical_cast<std::wstring>(opacity->get_percent().get_value()) + L"%");
}
}
}
}
}
void oox_serialize_solid_fill(std::wostream & strm, const _oox_fill & val)
{
if (!val.solid)return;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:solidFill")
{
oox_serialize_srgb(CP_XML_STREAM(),val.solid->color,val.opacity);
}
}
}
void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val)
{
if (!val.bitmap)return;
CP_XML_WRITER(strm)
{
CP_XML_NODE(std::wstring(val.bitmap->name_space + L":blipFill"))
{
if (val.bitmap->rotate) CP_XML_ATTR(L"a:rotWithShape",*(val.bitmap->rotate));
else CP_XML_ATTR(L"a:rotWithShape",1);
if (val.bitmap->dpi) CP_XML_ATTR(L"a:dpi",*val.bitmap->dpi);
CP_XML_NODE(L"a:blip")
{
if (val.bitmap->isInternal)
{
CP_XML_ATTR(L"r:embed",val.bitmap->rId );
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
}
else
CP_XML_ATTR(L"r:link",val.bitmap->rId );
if (val.opacity)
{
CP_XML_NODE(L"a:alpha")
{
CP_XML_ATTR(L"val",boost::lexical_cast<std::wstring>(*val.opacity) + L"%");
}
}
}
if (val.bitmap->bStretch)
{
CP_XML_NODE(L"a:stretch")
{
if (!val.bitmap->bCrop)
{
CP_XML_NODE(L"a:fillRect");
}
}
}
if (val.bitmap->bCrop)
{
CP_XML_NODE(L"a:srcRect")
{
CP_XML_ATTR(L"l", static_cast<size_t>(val.bitmap->cropRect[0]*1000));
CP_XML_ATTR(L"t", static_cast<size_t>(val.bitmap->cropRect[1]*1000));
CP_XML_ATTR(L"r", static_cast<size_t>(val.bitmap->cropRect[2]*1000));
CP_XML_ATTR(L"b", static_cast<size_t>(val.bitmap->cropRect[3]*1000));
}
}
if (val.bitmap->bTile)
{
CP_XML_NODE(L"a:tile")
{
}
}
}
}
}
void oox_serialize_fill(std::wostream & strm, const _oox_fill & val)
{
switch (val.type)
{
case 0:
oox_serialize_none_fill(strm);
break;
case 1:
oox_serialize_solid_fill(strm, val);
break;
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;
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
\ No newline at end of file
......@@ -2,12 +2,83 @@
#include <string>
#include <cpdoccore/CPOptional.h>
#include <cpdoccore/CPSharedPtr.h>
#include "../odf/lengthorpercent.h"
namespace cpdoccore {
namespace oox {
struct
class oox_gradient_fill;
typedef _CP_PTR(oox_gradient_fill) oox_gradient_fill_ptr;
class oox_gradient_fill
{
public:
oox_gradient_fill(){}
static oox_gradient_fill_ptr create();
};
///////////////////////////////////
class oox_bitmap_fill;
typedef _CP_PTR(oox_bitmap_fill) oox_bitmap_fill_ptr;
class oox_bitmap_fill
{
public:
oox_bitmap_fill();
static oox_bitmap_fill_ptr create();
std::wstring xlink_href_;
bool isInternal;
std::wstring name_space;
std::wstring rId;
bool bStretch;
bool bCrop;
bool bTile;
double cropRect[4];//0-left, 1 -top, 2- right, 3 - bottom
_CP_OPT(int) dpi;
_CP_OPT(bool) rotate;
};
/////////////////////////////////////////////////////////
class oox_hatch_fill;
typedef _CP_PTR(oox_hatch_fill) oox_hatch_fill_ptr;
class oox_hatch_fill
{
public:
oox_hatch_fill(){}
static oox_hatch_fill_ptr create();
};
////////////////////////////////////////////////////////////
class oox_solid_fill;
typedef _CP_PTR(oox_solid_fill) oox_solid_fill_ptr;
class oox_solid_fill
{
public:
oox_solid_fill(){}
std::wstring color;
static oox_solid_fill_ptr create();
};
struct _oox_fill
{
oox_gradient_fill_ptr gradient;
oox_hatch_fill_ptr hatch;
oox_bitmap_fill_ptr bitmap;
oox_solid_fill_ptr solid;
_CP_OPT(double) opacity;
int type;
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);
};
}
}
\ No newline at end of file
......@@ -149,7 +149,7 @@ void pptx_conversion_context::end_document()
package::slide_content_ptr content = package::slide_content::create();
slideM->write_to(content->content());
content->add_rels(slideM->slideMasterRels());//media & links rels
content->add_rels(slideM->Rels());//media & links rels
output_document_->get_ppt_files().add_slideMaster(content);//slideMaster.xml
......@@ -170,7 +170,7 @@ void pptx_conversion_context::end_document()
package::slide_content_ptr content = package::slide_content::create();
slide->write_to(content->content());
content->add_rels(slide->slideRels());//media & links rels
content->add_rels(slide->Rels());//media & links rels
output_document_->get_ppt_files().add_slide(content);//slide.xml
......@@ -190,7 +190,7 @@ void pptx_conversion_context::end_document()
package::slide_content_ptr content = package::slide_content::create();
slideL->write_to(content->content());
content->add_rels(slideL->slideLayoutRels());//media & links rels
content->add_rels(slideL->Rels());//media & links rels
output_document_->get_ppt_files().add_slideLayout(content);//slideMaster.xml
}
......@@ -319,7 +319,7 @@ bool pptx_conversion_context::start_page(const std::wstring & pageName, const st
std::pair<int,std::wstring> layout_id =
root()->odf_context().styleContainer().presentation_layouts().add_or_find(pageLayoutName,pageMasterName);
current_slide().slideRels().add(relationship(layout_id.second, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout",
current_slide().Rels().add(relationship(layout_id.second, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout",
std::wstring(L"../slideLayouts/slideLayout") + boost::lexical_cast<std::wstring>(layout_id.first) + L".xml"));
return true;
......@@ -341,7 +341,7 @@ bool pptx_conversion_context::start_layout(int layout_index)
root()->odf_context().styleContainer().presentation_masters().add_layout_to(layouts.content[layout_index].master_name,layouts.content[layout_index]);
current_layout().slideLayoutRels().add(relationship(master_id.second, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster",
current_layout().Rels().add(relationship(master_id.second, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster",
std::wstring(L"../slideMasters/slideMaster") + boost::lexical_cast<std::wstring>(master_id.first) + L".xml"));
//layout type
......@@ -409,23 +409,25 @@ bool pptx_conversion_context::start_master(int master_index)
}
void pptx_conversion_context::end_page()
{
get_slide_context().serialize(current_slide().slideData());
get_slide_context().dump_rels(current_slide().slideRels());//hyperlinks, mediaitems, ...
get_slide_context().serialize_background(current_slide().Background());
get_slide_context().serialize(current_slide().Data());
get_slide_context().dump_rels(current_slide().Rels());//hyperlinks, mediaitems, ...
get_slide_context().end_slide();
}
void pptx_conversion_context::end_layout()
{
get_slide_context().serialize(current_layout().slideLayoutData());
get_slide_context().dump_rels(current_layout().slideLayoutRels());//hyperlinks, mediaitems, ...
get_slide_context().serialize(current_layout().Data());
get_slide_context().dump_rels(current_layout().Rels());//hyperlinks, mediaitems, ...
get_slide_context().end_slide();
}
void pptx_conversion_context::end_master()
{
get_slide_context().serialize(current_master().slideMasterData());
get_slide_context().dump_rels(current_master().slideMasterRels());//hyperlinks, mediaitems, ...
get_slide_context().serialize_background(current_master().Background());
get_slide_context().serialize(current_master().Data());
get_slide_context().dump_rels(current_master().Rels());//hyperlinks, mediaitems, ...
get_slide_context().end_slide();
}
......
......@@ -59,24 +59,15 @@ void pptx_serialize_image(std::wostream & strm, _pptx_drawing const & val)
}
CP_XML_NODE(L"p:cNvPicPr")
{
if (val.clipping_enabled)
if (val.fill.bitmap->bCrop)
{
CP_XML_NODE(L"a:picLocks"){}
}
}
CP_XML_NODE(L"p:nvPr");
}
CP_XML_NODE(L"p:blipFill")
{
CP_XML_ATTR(L"rotWithShape", L"1");
CP_XML_NODE(L"a:blip")
{
CP_XML_ATTR(L"r:embed", val.rId);
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
}
oox_serialize_clipping(CP_XML_STREAM(),val);
} // p:blipFill
val.fill.bitmap->name_space = L"p";
oox_serialize_fill(CP_XML_STREAM(), val.fill);
CP_XML_NODE(L"p:spPr")
{
......@@ -184,7 +175,7 @@ void pptx_serialize_chart(std::wostream & strm, _pptx_drawing const & val)
CP_XML_NODE(L"c:chart")
{
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"r:id", val.rId);
CP_XML_ATTR(L"r:id", val.chartId);
CP_XML_ATTR(L"xmlns:c", L"http://schemas.openxmlformats.org/drawingml/2006/chart");
}
}
......
......@@ -54,7 +54,24 @@ public:
}
}
void add(/**/
bool isInternal,
std::wstring const & rid,
std::wstring const & ref,
mediaitems::Type type)
{
bool present = false;
BOOST_FOREACH(rel_ const & r, pptx_drawing_rels_)
{
if (r.rid_ == rid && r.ref_ == ref)
present = true;
}
if (!present)
{
pptx_drawing_rels_.push_back(rel_(isInternal, rid, ref, type));
}
}
void serialize(std::wostream & strm)
{
BOOST_FOREACH(_pptx_drawing const & d, pptx_drawings_)
......@@ -130,7 +147,14 @@ void pptx_drawings::add(_pptx_drawing const & d,
{
impl_->add(d, isInternal, rid, ref, type);
}
void pptx_drawings::add(/**/
bool isInternal,
std::wstring const & rid,
std::wstring const & ref,
mediaitems::Type type)
{
impl_->add(isInternal, rid, ref, type);
}
void pptx_drawings::serialize(std::wostream & _Wostream)
{
impl_->serialize(_Wostream);
......
......@@ -28,7 +28,12 @@ public:
std::wstring const & ref,
mediaitems::Type type
);
void add(/**/
bool isInternal,
std::wstring const & rid,
std::wstring const & ref,
mediaitems::Type type
);
bool empty() const;
void dump_rels(rels & Rels);
......
......@@ -34,11 +34,15 @@ pptx_xml_slide::pptx_xml_slide(std::wstring const & name,std::wstring const & id
pptx_xml_slide::~pptx_xml_slide()
{
}
std::wostream & pptx_xml_slide::slideData()
std::wostream & pptx_xml_slide::Data()
{
return slideData_;
}
rels & pptx_xml_slide::slideRels()
std::wostream & pptx_xml_slide::Background()
{
return slideBackground_;
}
rels & pptx_xml_slide::Rels()
{
return rels_;
}
......@@ -56,6 +60,9 @@ void pptx_xml_slide::write_to(std::wostream & strm)
CP_XML_NODE(L"p:cSld")
{
CP_XML_ATTR(L"name", name());
CP_XML_STREAM() << slideBackground_.str();
CP_XML_NODE(L"p:spTree")
{
CP_XML_STREAM() << slideData_.str();
......@@ -88,11 +95,11 @@ pptx_xml_slideLayout::pptx_xml_slideLayout(std::wstring const & id)
pptx_xml_slideLayout::~pptx_xml_slideLayout()
{
}
std::wostream & pptx_xml_slideLayout::slideLayoutData()
std::wostream & pptx_xml_slideLayout::Data()
{
return slideLayoutData_;
}
rels & pptx_xml_slideLayout::slideLayoutRels()
rels & pptx_xml_slideLayout::Rels()
{
return rels_;
}
......@@ -158,11 +165,15 @@ pptx_xml_slideMaster::pptx_xml_slideMaster(std::wstring const & id)
pptx_xml_slideMaster::~pptx_xml_slideMaster()
{
}
std::wostream & pptx_xml_slideMaster::slideMasterData()
std::wostream & pptx_xml_slideMaster::Data()
{
return slideMasterData_;
}
std::wostream & pptx_xml_slideMaster::Background()
{
return slideMasterData_;
}
rels & pptx_xml_slideMaster::slideMasterRels()
rels & pptx_xml_slideMaster::Rels()
{
return rels_;
}
......@@ -192,14 +203,8 @@ void pptx_xml_slideMaster::write_to(std::wostream & strm)
CP_XML_NODE(L"p:cSld")
{
CP_XML_NODE(L"p:bg")
{
CP_XML_NODE(L"p:bgPr")
{
CP_XML_NODE(L"a:noFill");
CP_XML_NODE(L"a:effectLst");
}
}
CP_XML_STREAM() << slideMasterBackground_.str();
CP_XML_NODE(L"p:spTree")
{
CP_XML_STREAM() << slideMasterData_.str();
......
......@@ -22,8 +22,9 @@ public:
std::wstring name() const;
std::wstring rId() const;
std::wostream & slideData();
rels & slideRels();
std::wostream & Data();
std::wostream & Background();
rels & Rels();
//slideTiming
......@@ -34,6 +35,7 @@ public:
private:
std::wstring name_;
std::wstringstream slideData_;
std::wstringstream slideBackground_;
std::wstring rId_;
rels rels_;
......@@ -77,8 +79,8 @@ public:
public:
std::wstring rId() const;
std::wostream & slideLayoutData();
rels & slideLayoutRels();
std::wostream & Data();
rels & Rels();
//slideTiming
......@@ -104,8 +106,9 @@ public:
public:
std::wstring rId() const;
std::wostream & slideMasterData();
rels & slideMasterRels();
std::wostream & Data();
std::wostream & Background();
rels & Rels();
void add_layout(int id, const std::wstring & rId);
void add_theme(int id, const std::wstring & tId);
......@@ -116,6 +119,7 @@ public:
private:
std::wstringstream slideMasterData_;
std::wstringstream slideMasterBackground_;
std::vector<std::wstring> layoutsId_;
std::wstring rId_;
......
......@@ -11,10 +11,9 @@
#include "pptx_drawings.h"
#include "pptx_slide_context.h"
#include "../odf/length.h"
#include "../odf/draw_common.h"
#include "drawing_object_description.h"
namespace cpdoccore {
namespace oox {
......@@ -22,50 +21,17 @@ namespace oox {
class pptx_drawings;
typedef _CP_PTR(pptx_drawings) pptx_drawings_ptr;
struct _rect
{
double width_;
double height_;
double x_;
double y_;
};
//+ 3-
struct simple_drawing_desc
{
std::wstring draw_name_;
_CP_OPT(_rect) svg_rect_;
std::wstring anchor_;
double anchor_x_;
double anchor_y_;
std::wstring xlink_href_; // (external)
std::vector<_hlink_desc> hlinks_;
std::vector<odf::_property> additional_;//for shapes
std::wstring clipping_string_;
int type_; //default - frame
};
class pptx_slide_context::Impl
{
public:
Impl(const std::wstring & odfPacket) : pptx_drawings_(pptx_drawings::create()), mediaitems_(odfPacket),rId_(1),odfPacket_(odfPacket)
{}
simple_drawing_desc simple_drawing_desc_;
drawing_object_description simple_drawing_desc_;
std::vector<simple_drawing_desc> images_;
std::vector<simple_drawing_desc> charts_;
std::vector<simple_drawing_desc> shapes_;
std::vector<drawing_object_description> images_;
std::vector<drawing_object_description> charts_;
std::vector<drawing_object_description> shapes_;
void add_drawing(_pptx_drawing const & d,
bool isInternal,
......@@ -75,7 +41,14 @@ public:
{
pptx_drawings_->add(d, isInternal, rid, ref, type);
}
void add_drawing(/**/
bool isInternal,
std::wstring const & rid,
std::wstring const & ref,
mediaitems::Type type)
{
pptx_drawings_->add(isInternal, rid, ref, type);
}
mediaitems & get_mediaitems() { return mediaitems_; }
bool empty() const
......@@ -149,6 +122,21 @@ void pptx_slide_context::set_rect(double width_pt, double height_pt, double x_pt
_rect r = {width_pt,height_pt,x_pt,y_pt};
impl_->simple_drawing_desc_.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_)
{
// open office
_rect r = impl_->simple_drawing_desc_.svg_rect_.get();
//r.x_-=r.width_;
//r.y_-=r.height_;
impl_->simple_drawing_desc_.svg_rect_= r;
}
}
void pptx_slide_context::set_translate(double x_pt, double y_pt)
{
if (impl_->simple_drawing_desc_.svg_rect_)
......@@ -189,6 +177,10 @@ void pptx_slide_context::set_clipping(std::wstring & str)
{
impl_->simple_drawing_desc_.clipping_string_= str;
}
void pptx_slide_context::set_fill(_oox_fill & fill)
{
impl_->simple_drawing_desc_.fill_= fill;
}
std::wstring pptx_slide_context::add_hyperlink(std::wstring const & ref,bool object)
{
++hlinks_size_;
......@@ -248,40 +240,40 @@ void pptx_slide_context::process_images()
using boost::filesystem::wpath;
int pos_replaicement=0;
BOOST_FOREACH(simple_drawing_desc & pic, impl_->images_)
BOOST_FOREACH(drawing_object_description & pic, impl_->images_)
{
pos_replaicement= pic.xlink_href_.find(L"ObjectReplacements");
if (pos_replaicement <0)//,
{
_pptx_drawing drawing=_pptx_drawing();
process_common_properties(pic,drawing);
drawing.fill.bitmap = oox_bitmap_fill::create();
drawing.fill.type = 2;
_CP_OPT(std::wstring) sTextContent;
GetProperty(pic.additional_,L"text-content",sTextContent);
//if (sTextContent)// ms office -
//{
// drawing.type = mediaitems::typeShape;
// drawing.sub_type = 2;//rect
// drawing.fillRef_inp = pic.xlink_href_; // ==
//}
//else
if (sTextContent)// ms office -
{
drawing.type = mediaitems::typeShape;
drawing.sub_type = 2;//rect
}
else
drawing.type = mediaitems::typeImage;
drawing.id = impl_->next_rId();
drawing.id = impl_->next_rId();
drawing.name = pic.draw_name_;
std::wstring fileName = BOOST_STRING_PATH(wpath(impl_->odfPacket_) / pic.xlink_href_);
drawing.fill.bitmap->bCrop = odf::parse_clipping(pic.clipping_string_,fileName,drawing.fill.bitmap->cropRect);
///////////////////////////////////////////////////////////////////////////////////////////////////
std::wstring ref;///
bool isMediaInternal = false;
drawing.rId = impl_->get_mediaitems().add_or_find(pic.xlink_href_, drawing.type, isMediaInternal, ref);
//drawing.fillId = impl_->get_mediaitems().add_or_find(drawing.fillRef_inp, mediaitems::typeImage, isMediaInternal, fillRef_out);
process_common_properties(pic,drawing);
std::wstring fileName = BOOST_STRING_PATH(wpath(impl_->odfPacket_) / pic.xlink_href_);
drawing.clipping_enabled = odf::parse_clipping(pic.clipping_string_,fileName,drawing.clipping_rect);
impl_->add_drawing(drawing, isMediaInternal, drawing.rId , ref, drawing.type);
drawing.fill.bitmap->rId = impl_->get_mediaitems().add_or_find(pic.xlink_href_, drawing.type, isMediaInternal, ref);
impl_->add_drawing(drawing, isMediaInternal, drawing.fill.bitmap->rId , ref, drawing.type);
}
}
......@@ -290,26 +282,25 @@ void pptx_slide_context::process_charts()
{
using boost::filesystem::wpath;
BOOST_FOREACH(simple_drawing_desc & pic, impl_->charts_)
BOOST_FOREACH(drawing_object_description & pic, impl_->charts_)
{
_pptx_drawing drawing=_pptx_drawing();
process_common_properties(pic,drawing);
drawing.type = mediaitems::typeChart;
drawing.name = pic.draw_name_;
drawing.id = impl_->next_rId();
const size_t id = impl_->next_rId();
////////////////////////////////////////////////////////////////
std::wstring ref;
bool isMediaInternal = true;
drawing.rId = impl_->get_mediaitems().add_or_find(pic.xlink_href_, mediaitems::typeChart, isMediaInternal, ref);
drawing.id = id;
process_common_properties(pic,drawing);
////////////////////////////////////////////////////////////////
impl_->add_drawing(drawing, isMediaInternal, drawing.rId, ref, mediaitems::typeChart);
drawing.chartId = impl_->get_mediaitems().add_or_find(pic.xlink_href_, mediaitems::typeChart, isMediaInternal, ref);
impl_->add_drawing(drawing, isMediaInternal, drawing.chartId, ref, mediaitems::typeChart);
}
}
void pptx_slide_context::process_common_properties(simple_drawing_desc & pic,_pptx_drawing & drawing)
void pptx_slide_context::process_common_properties(drawing_object_description & pic,_pptx_drawing & drawing)
{
if (pic.svg_rect_)
{
......@@ -319,28 +310,35 @@ void pptx_slide_context::process_common_properties(simple_drawing_desc & pic,_pp
drawing.cy = odf::length(pic.svg_rect_.get().height_, odf::length::pt).get_value_unit(odf::length::emu);
}
drawing.additional=pic.additional_;
drawing.additional = pic.additional_;
drawing.hlinks=pic.hlinks_;
drawing.hlinks = pic.hlinks_;
drawing.fill = pic.fill_;
}
void pptx_slide_context::process_shapes()
{
BOOST_FOREACH(simple_drawing_desc & pic, impl_->shapes_)
BOOST_FOREACH(drawing_object_description & pic, impl_->shapes_)
{
_pptx_drawing drawing=_pptx_drawing();
std::wstring ref;
process_common_properties(pic,drawing);
std::wstring ref;
bool isMediaInternal = true;
drawing.type = mediaitems::typeShape;
drawing.name = pic.draw_name_;
const size_t id = impl_->next_rId();
drawing.id = impl_->next_rId();
drawing.rId = impl_->get_mediaitems().add_or_find(pic.xlink_href_, mediaitems::typeShape, isMediaInternal, ref);
drawing.id = id;
if (drawing.fill.bitmap)
{
drawing.fill.bitmap->rId = impl_->get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, mediaitems::typeImage, isMediaInternal, ref);
impl_->add_drawing(isMediaInternal, drawing.fill.bitmap->rId, ref, mediaitems::typeImage);// , ref
}
std::wstring rId = impl_->get_mediaitems().add_or_find(L"", mediaitems::typeShape, isMediaInternal, ref);
process_common_properties(pic,drawing);
////////////////////////////////////////////////////////////////
_CP_OPT(std::wstring) sPlaceHolderType;
GetProperty(pic.additional_,L"PlaceHolderType",sPlaceHolderType);
......@@ -348,7 +346,7 @@ void pptx_slide_context::process_shapes()
drawing.sub_type = pic.type_;
impl_->add_drawing(drawing, isMediaInternal, drawing.rId, ref, mediaitems::typeShape);
impl_->add_drawing(drawing, isMediaInternal, rId, ref, mediaitems::typeShape);
}
}
void pptx_slide_context::dump_rels(rels & Rels)
......@@ -359,13 +357,28 @@ mediaitems & pptx_slide_context::get_mediaitems()
{
return impl_->get_mediaitems();
}
void pptx_slide_context::serialize_background(std::wostream & strm)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"p:bg")
{
CP_XML_NODE(L"p:bgPr")
{
CP_XML_NODE(L"a:noFill");
CP_XML_NODE(L"a:effectLst");
}
}
}
}
void pptx_slide_context::serialize(std::wostream & strm)
{
int next_id = impl_->next_rId();
// noGroup
CP_XML_WRITER(strm)
{
// noGroup
CP_XML_NODE(L"p:nvGrpSpPr")
{
CP_XML_NODE(L"p:cNvPr")
......@@ -388,7 +401,7 @@ void pptx_slide_context::serialize(std::wostream & strm)
}
}
process_drawings();
impl_->get_drawings()->serialize(strm);
impl_->get_drawings()->serialize(strm);
}
}
......
......@@ -7,9 +7,10 @@ namespace cpdoccore {
namespace oox {
class pptx_conversion_context;
struct simple_drawing_desc;
struct drawing_object_description;
class mediaitems;
class pptx_drawings;
struct _oox_fill;
class pptx_slide_context
......@@ -24,12 +25,14 @@ public:
void set_translate(double x_pt, double y_pt);
void set_scale(double cx_pt, double cy_pt);
void set_rotate(double angle);
void set_name(std::wstring const & name);
void set_anchor(std::wstring anchor, double x_pt, double y_pt);
void set_property(odf::_property p);
std::vector<odf::_property> & get_properties();
void set_clipping(std::wstring & str );
void set_fill(_oox_fill & fill);
void set_placeHolder_type(std::wstring typeHolder);
std::wstring add_hyperlink(std::wstring const & ref, bool object);
......@@ -48,6 +51,8 @@ public:
//std::wstring dump_path(std::vector<svg_path::_polyline> & path, double w,double h);
void serialize(std::wostream & strm);
void serialize_background(std::wostream & strm);
void dump_rels(rels & Rels);
void process_drawings();
......@@ -55,7 +60,7 @@ public:
mediaitems & get_mediaitems();
private:
void process_common_properties(simple_drawing_desc& pic,_pptx_drawing & drawing);
void process_common_properties(drawing_object_description& pic,_pptx_drawing & drawing);
void default_set();
void process_shapes();
void process_images();
......
......@@ -89,24 +89,15 @@ void xlsx_serialize_image(std::wostream & strm, _xlsx_drawing const & val)
}
CP_XML_NODE(L"xdr:cNvPicPr")
{
if (val.clipping_enabled)
if (val.fill.bitmap->bCrop)
{
CP_XML_ATTR(L"preferRelativeResize", L"0");
CP_XML_NODE(L"a:picLocks"){}
}
}
}
CP_XML_NODE(L"xdr:blipFill")
{
CP_XML_ATTR(L"rotWithShape", L"1");
CP_XML_NODE(L"a:blip")
{
CP_XML_ATTR(L"r:embed", val.rId);
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
}
oox_serialize_clipping(CP_XML_STREAM(),val);
}
val.fill.bitmap->name_space = L"xdr";
oox_serialize_fill(CP_XML_STREAM(), val.fill);
CP_XML_NODE(L"xdr:spPr")
{
......@@ -206,7 +197,7 @@ void xlsx_serialize_chart(std::wostream & strm, _xlsx_drawing const & val)
CP_XML_NODE(L"c:chart")
{
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"r:id", val.rId);
CP_XML_ATTR(L"r:id", val.chartId);
CP_XML_ATTR(L"xmlns:c", L"http://schemas.openxmlformats.org/drawingml/2006/chart");
}
}
......
......@@ -12,49 +12,13 @@
#include "xlsx_drawing_context.h"
#include "xlsx_table_metrics.h"
#include "../odf/length.h"
#include "../odf/draw_common.h"
#include "drawing_object_description.h"
namespace cpdoccore {
namespace oox {
class xlsx_drawings;
typedef _CP_PTR(xlsx_drawings) xlsx_drawings_ptr;
struct _rect
{
double width_;
double height_;
double x_;
double y_;
};
//+ 3-
struct simple_drawing_desc
{
std::wstring draw_name_;
_CP_OPT(_rect) svg_rect_;
std::wstring anchor_;
double anchor_x_;
double anchor_y_;
std::wstring xlink_href_; // (external)
std::vector<_hlink_desc> hlinks_;
std::vector<odf::_property> additional_;//for shapes
std::wstring clipping_string_;
int type_; //default - frame
};
class xlsx_drawing_context_handle::Impl
{
public:
......@@ -112,6 +76,9 @@ const std::vector<drawing_elm> & xlsx_drawing_context_handle::content() const
return impl_->content();
}
class xlsx_drawing_context::Impl
{
public:
......@@ -120,11 +87,11 @@ public:
{}
xlsx_drawing_context_handle & handle_;
simple_drawing_desc simple_drawing_desc_;
drawing_object_description simple_drawing_desc_;
std::vector<simple_drawing_desc> images_;
std::vector<simple_drawing_desc> charts_;
std::vector<simple_drawing_desc> shapes_;
std::vector<drawing_object_description> images_;
std::vector<drawing_object_description> charts_;
std::vector<drawing_object_description> shapes_;
void add_drawing(_xlsx_drawing const & d,
bool isInternal,
......@@ -134,7 +101,14 @@ public:
{
xlsx_drawings_->add(d, isInternal, rid, ref, type);
}
void add_drawing(/**/
bool isInternal,
std::wstring const & rid,
std::wstring const & ref,
mediaitems::Type type)
{
xlsx_drawings_->add(isInternal, rid, ref, type);
}
mediaitems & get_mediaitems() { return handle_.impl_->get_mediaitems(); }
......@@ -214,6 +188,18 @@ void xlsx_drawing_context::set_translate(double x_pt, double y_pt)
impl_->simple_drawing_desc_.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_)
{
_rect r = impl_->simple_drawing_desc_.svg_rect_.get();
//r.x_-=r.width_/2;
//r.y_-=r.height_/2;
impl_->simple_drawing_desc_.svg_rect_= r;
}
}
void xlsx_drawing_context::set_scale(double cx_pt, double cy_pt)
{
if (impl_->simple_drawing_desc_.svg_rect_)
......@@ -243,6 +229,10 @@ void xlsx_drawing_context::set_clipping(std::wstring & str)
{
impl_->simple_drawing_desc_.clipping_string_= str;
}
void xlsx_drawing_context::set_fill(_oox_fill & fill)
{
impl_->simple_drawing_desc_.fill_= fill;
}
std::wstring xlsx_drawing_context::add_hyperlink(std::wstring const & ref,bool object)
{
++hlinks_size_;
......@@ -297,24 +287,30 @@ void xlsx_drawing_context::process_images(xlsx_table_metrics & table_metrics)
using boost::filesystem::wpath;
int pos_replaicement=0;
BOOST_FOREACH(simple_drawing_desc & pic, impl_->images_)
BOOST_FOREACH(drawing_object_description & pic, impl_->images_)
{
pos_replaicement= pic.xlink_href_.find(L"ObjectReplacements");
if (pos_replaicement <0)//,
{
_xlsx_drawing drawing=_xlsx_drawing();
_xlsx_drawing drawing=_xlsx_drawing();
drawing.fill = pic.fill_;
process_common_properties(pic,drawing,table_metrics);
drawing.fill.bitmap = oox_bitmap_fill::create();
drawing.fill.type = 2;
_CP_OPT(std::wstring) sTextContent;
GetProperty(pic.additional_,L"text-content",sTextContent);
//if (sTextContent)// ms office -
//{
// drawing.type = mediaitems::typeShape;
// drawing.sub_type = 2;//rect
// drawing.fillRef_inp = pic.xlink_href_; // ==
//}
//else
if (sTextContent)// ms office -
{
drawing.type = mediaitems::typeShape;
drawing.sub_type = 2;//rect
}
else
drawing.type = mediaitems::typeImage;
drawing.id = impl_->next_rId();
drawing.name = pic.draw_name_;
......@@ -322,15 +318,12 @@ void xlsx_drawing_context::process_images(xlsx_table_metrics & table_metrics)
std::wstring ref;///
bool isMediaInternal = false;
drawing.rId = impl_->get_mediaitems().add_or_find(pic.xlink_href_, drawing.type, isMediaInternal, ref);
//drawing.fillId = impl_->get_mediaitems().add_or_find(drawing.fillRef_inp, mediaitems::typeImage, isMediaInternal, fillRef_out);
process_common_properties(pic,drawing,table_metrics);
std::wstring fileName = BOOST_STRING_PATH(wpath(odf_packet_path_) / pic.xlink_href_);
drawing.clipping_enabled = odf::parse_clipping(pic.clipping_string_,fileName,drawing.clipping_rect);
drawing.fill.bitmap->bCrop = odf::parse_clipping(pic.clipping_string_,fileName,drawing.fill.bitmap->cropRect);
impl_->add_drawing(drawing, isMediaInternal, drawing.rId , ref, drawing.type);
drawing.fill.bitmap->rId = impl_->get_mediaitems().add_or_find(pic.xlink_href_, drawing.type, isMediaInternal, ref);
impl_->add_drawing(drawing, isMediaInternal, drawing.fill.bitmap->rId , ref, drawing.type);
}
}
......@@ -340,26 +333,25 @@ void xlsx_drawing_context::process_charts(xlsx_table_metrics & table_metrics)
{
using boost::filesystem::wpath;
BOOST_FOREACH(simple_drawing_desc & pic, impl_->charts_)
BOOST_FOREACH(drawing_object_description & pic, impl_->charts_)
{
_xlsx_drawing drawing=_xlsx_drawing();
drawing.type = mediaitems::typeChart;
drawing.name = pic.draw_name_;
const size_t id = impl_->next_rId();
drawing.id = impl_->next_rId();
std::wstring ref;
bool isMediaInternal = true;
drawing.rId = impl_->get_mediaitems().add_or_find(pic.xlink_href_, mediaitems::typeChart, isMediaInternal, ref);
drawing.id = id;
drawing.chartId = impl_->get_mediaitems().add_or_find(pic.xlink_href_, mediaitems::typeChart, isMediaInternal, ref);
process_common_properties(pic,drawing,table_metrics);
impl_->add_drawing(drawing, isMediaInternal, drawing.rId, ref, mediaitems::typeChart);
impl_->add_drawing(drawing, isMediaInternal, drawing.chartId, ref, mediaitems::typeChart);
}
}
void xlsx_drawing_context::process_common_properties(simple_drawing_desc & pic,_xlsx_drawing & drawing,xlsx_table_metrics & table_metrics)
void xlsx_drawing_context::process_common_properties(drawing_object_description & pic,_xlsx_drawing & drawing,xlsx_table_metrics & table_metrics)
{
xlsx_table_position from, to;
......@@ -389,7 +381,7 @@ void xlsx_drawing_context::process_common_properties(simple_drawing_desc & pic,_
drawing.hlinks=pic.hlinks_;
}
void xlsx_drawing_context::process_position_properties(simple_drawing_desc & pic,xlsx_table_metrics & table_metrics,xlsx_table_position & from,xlsx_table_position & to)
void xlsx_drawing_context::process_position_properties(drawing_object_description & pic,xlsx_table_metrics & table_metrics,xlsx_table_position & from,xlsx_table_position & to)
{
size_t last_col=0, last_row=0;
......@@ -436,9 +428,10 @@ void xlsx_drawing_context::process_position_properties(simple_drawing_desc & pic
void xlsx_drawing_context::process_shapes(xlsx_table_metrics & table_metrics)
{
BOOST_FOREACH(simple_drawing_desc & pic, impl_->shapes_)
BOOST_FOREACH(drawing_object_description & pic, impl_->shapes_)
{
_xlsx_drawing drawing=_xlsx_drawing();
drawing.fill = pic.fill_;
std::wstring ref;
bool isMediaInternal = true;
......@@ -448,14 +441,19 @@ void xlsx_drawing_context::process_shapes(xlsx_table_metrics & table_metrics)
const size_t id = impl_->next_rId();
drawing.rId = impl_->get_mediaitems().add_or_find(pic.xlink_href_, mediaitems::typeShape, isMediaInternal, ref);
if (drawing.fill.bitmap)
{
drawing.fill.bitmap->rId = impl_->get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, mediaitems::typeImage, isMediaInternal, ref);
impl_->add_drawing(isMediaInternal, drawing.fill.bitmap->rId, ref, mediaitems::typeImage);// , ref
}
std::wstring rId = impl_->get_mediaitems().add_or_find(L"", mediaitems::typeShape, isMediaInternal, ref);
drawing.id = id;
process_common_properties(pic,drawing,table_metrics);
drawing.sub_type = pic.type_;
impl_->add_drawing(drawing, isMediaInternal, drawing.rId, ref, mediaitems::typeShape);
impl_->add_drawing(drawing, isMediaInternal, rId, ref, mediaitems::typeShape);
}
}
......
......@@ -16,11 +16,12 @@ namespace cpdoccore {
namespace oox {
struct simple_drawing_desc;
struct drawing_object_description;
struct xlsx_table_position;
class xlsx_table_metrics;
class mediaitems;
class xlsx_drawings;
struct _oox_fill;
typedef _CP_PTR(xlsx_drawings) xlsx_drawings_ptr;
......@@ -51,21 +52,22 @@ public:
void set_odf_packet_path(std::wstring path){odf_packet_path_ = path;}//
void start_shapes();
void end_shapes();
void start_drawing(std::wstring const & name);
void set_rect(double width_pt, double height_pt, double x_pt, double y_pt);
void set_translate(double x_pt, double y_pt);
void set_scale(double cx_pt, double cy_pt);
void set_rotate(double angle);
void set_anchor(std::wstring anchor, double x_pt, double y_pt);
void set_property(odf::_property p);
std::vector<odf::_property> & get_properties();
void set_clipping(std::wstring & str );
//...
void set_fill(_oox_fill & fill);
void end_drawing();
void end_shapes();
std::wstring add_hyperlink(std::wstring const & ref, bool object);
......@@ -90,8 +92,8 @@ public:
void process_charts(xlsx_table_metrics & table_metrics);
void process_shapes(xlsx_table_metrics & table_metrics);
void process_position_properties(simple_drawing_desc & pic,xlsx_table_metrics & table_metrics,xlsx_table_position & from,xlsx_table_position & to);
void process_common_properties(simple_drawing_desc& pic,_xlsx_drawing & drawing,xlsx_table_metrics & table_metrics);
void process_position_properties(drawing_object_description & pic,xlsx_table_metrics & table_metrics,xlsx_table_position & from,xlsx_table_position & to);
void process_common_properties(drawing_object_description& pic,_xlsx_drawing & drawing,xlsx_table_metrics & table_metrics);
private:
void default_set();
......
......@@ -51,7 +51,23 @@ public:
xlsx_drawing_rels_.push_back(rel_(false, h.hId, h.hRef, mediaitems::typeHyperlink));
}
}
void add(/**/
bool isInternal,
std::wstring const & rid,
std::wstring const & ref,
mediaitems::Type type)
{
bool present = false;
BOOST_FOREACH(rel_ const & r, xlsx_drawing_rels_)
{
if (r.rid_ == rid && r.ref_ == ref)
present = true;
}
if (!present)
{
xlsx_drawing_rels_.push_back(rel_(isInternal, rid, ref, type));
}
}
void serialize(std::wostream & strm) const
......@@ -139,7 +155,14 @@ void xlsx_drawings::add(_xlsx_drawing const & d,
{
impl_->add(d, isInternal, rid, ref, type);
}
void xlsx_drawings::add(/**/
bool isInternal,
std::wstring const & rid,
std::wstring const & ref,
mediaitems::Type type)
{
impl_->add(isInternal, rid, ref, type);
}
void xlsx_serialize(std::wostream & _Wostream, xlsx_drawings const & val)
{
val.impl_->serialize(_Wostream);
......
#ifndef CPDOCCORE_XLSX_DRAWINGS_H_
#define CPDOCCORE_XLSX_DRAWINGS_H_
#pragma once
#include <iosfwd>
#include <cpdoccore/CPScopedPtr.h>
......@@ -10,10 +9,6 @@
namespace cpdoccore {
namespace oox {
struct _xlsx_drawing;
class rels;
class xlsx_drawings;
typedef _CP_PTR(xlsx_drawings) xlsx_drawings_ptr;
......@@ -28,6 +23,9 @@ struct drawing_elm
xlsx_drawings_ptr drawings;
};
struct _xlsx_drawing;
class rels;
class xlsx_drawings
{
public:
......@@ -42,7 +40,12 @@ public:
std::wstring const & ref,
mediaitems::Type type
);
void add(/**/
bool isInternal,
std::wstring const & rid,
std::wstring const & ref,
mediaitems::Type type
);
bool empty() const;
void dump_rels(rels & Rels);
......@@ -56,5 +59,3 @@ private:
}
}
#endif
......@@ -141,11 +141,11 @@ void common_writing_mode_attlist::add_attributes( const xml::attributes_wc_ptr &
bool common_xlink_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
bool b = CP_APPLY_ATTR(L"xlink:href", xlink_href_);
CP_APPLY_ATTR(L"xlink:type", xlink_type_);
CP_APPLY_ATTR(L"xlink:show", xlink_show_);
CP_APPLY_ATTR(L"xlink:actuate", xlink_actuate_);
return b;
CP_APPLY_ATTR(L"xlink:href", href_);
CP_APPLY_ATTR(L"xlink:type", type_);
CP_APPLY_ATTR(L"xlink:show", show_);
CP_APPLY_ATTR(L"xlink:actuate", actuate_);
return true;
}
//////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -248,8 +248,15 @@ void common_draw_rel_size_attlist::apply_from(const common_draw_rel_size_attlist
void common_text_anchor_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:anchor-type", text_anchor_type_);
CP_APPLY_ATTR(L"text:anchor-page-number", text_anchor_page_number_);
CP_APPLY_ATTR(L"text:anchor-type", type_);
CP_APPLY_ATTR(L"text:anchor-page-number", page_number_);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
void common_text_animation_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
// CP_APPLY_ATTR(L"text:animation", type_);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
......
......@@ -177,17 +177,17 @@ public:
bool add_attributes( const xml::attributes_wc_ptr & Attributes );
void apply_from(const common_xlink_attlist & Other)
{
_CP_APPLY_PROP(xlink_href_, Other.xlink_href_);
_CP_APPLY_PROP(xlink_type_, Other.xlink_type_);
_CP_APPLY_PROP(xlink_show_, Other.xlink_show_);
_CP_APPLY_PROP(xlink_actuate_, Other.xlink_actuate_);
_CP_APPLY_PROP(href_, Other.href_);
_CP_APPLY_PROP(type_, Other.type_);
_CP_APPLY_PROP(show_, Other.show_);
_CP_APPLY_PROP(actuate_, Other.actuate_);
}
public:
_CP_OPT(std::wstring) xlink_href_;
_CP_OPT(xlink_type) xlink_type_;
_CP_OPT(xlink_show) xlink_show_;
_CP_OPT(xlink_actuate) xlink_actuate_;
_CP_OPT(std::wstring) href_;
_CP_OPT(xlink_type) type_;
_CP_OPT(xlink_show) show_;
_CP_OPT(xlink_actuate) actuate_;
};
......@@ -397,15 +397,37 @@ public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
void apply_from(const common_text_anchor_attlist & Other)
{
_CP_APPLY_PROP2(text_anchor_type_);
_CP_APPLY_PROP2(text_anchor_page_number_);
_CP_APPLY_PROP2(type_);
_CP_APPLY_PROP2(page_number_);
}
public:
_CP_OPT(anchor_type) text_anchor_type_;
_CP_OPT(unsigned int) text_anchor_page_number_;
_CP_OPT(anchor_type) type_;
_CP_OPT(unsigned int) page_number_;
};
/// common-text-animation-attlist
class common_text_animation_attlist
{
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
void apply_from(const common_text_anchor_attlist & Other)
{
//_CP_APPLY_PROP2(type_);
//_CP_APPLY_PROP2(direction_);
}
public:
// _CP_OPT(animation_type) type_;
//_CP_OPT(animation_direction) direction_;
//text:animation
//text:animation-direction
//text:animation-start-inside
//text:animation-stop-inside
//text:animation-repeat
};
/// \class common_draw_rel_size_attlist
/// common-draw-rel-size-attlist
class common_draw_rel_size_attlist
......
#include "precompiled_cpodf.h"
#include "draw_common.h"
#include <ostream>
#include <sstream>
......@@ -16,6 +15,7 @@
#include "serialize_elements.h"
#include <cpdoccore/odf/odf_document.h>
#include "draw_common.h"
#include "length.h"
#include "borderstyle.h"
#include "odfcontext.h"
......@@ -34,7 +34,7 @@ namespace _image_file_
Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
Gdiplus::Bitmap *file = new Gdiplus::Bitmap(fileName,false);
if ((file) && (file->GetLastStatus()==Gdiplus::Status::Ok))
if ((file) && (file->GetLastStatus()==Gdiplus::Ok))
{
Height = file->GetHeight();
Width = file->GetWidth();
......@@ -183,6 +183,45 @@ int Compute_BorderWidth(const graphic_format_properties & graphicProperties, Bor
return get_value_emu(lengthValue);
}
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_name_)
{
fill.opacity = 1;
// -
}
////////////////////////////////////////////////////////////
if (props.draw_fill_color_)
{
fill.solid = oox::oox_solid_fill::create();
fill.solid->color = props.draw_fill_color_->get_hex_value();
if (fill.type==0)fill.type = 1; //
}
if (props.draw_fill_image_name_)
{
const std::wstring style_name = L"bitmap:" + *props.draw_fill_image_name_;
if (office_element_ptr style = styles.find_by_style_name(style_name))
{
if (draw_fill_image * image_style = dynamic_cast<draw_fill_image *>(style.get()))
{
fill.bitmap = oox::oox_bitmap_fill::create();
fill.bitmap->xlink_href_ = image_style->xlink_attlist_.href_.get_value_or(L"");
}
}
}
if (props.style_repeat_ && fill.bitmap)
{
if (*props.style_repeat_== L"repeat") fill.bitmap->bTile = true;
if (*props.style_repeat_== L"stretch") fill.bitmap->bStretch = true;
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using xml::xml_char_wc;
......@@ -208,7 +247,7 @@ void draw_a::add_attributes( const xml::attributes_wc_ptr & Attributes )
void draw_a::xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.get_drawing_context().add_hyperlink(common_xlink_attlist_.xlink_href_.get_value_or(L""),true);
Context.get_drawing_context().add_hyperlink(common_xlink_attlist_.href_.get_value_or(L""),true);
// .. -
BOOST_FOREACH(const office_element_ptr & elm, content_)
......@@ -218,7 +257,7 @@ void draw_a::xlsx_convert(oox::xlsx_conversion_context & Context)
}
void draw_a::pptx_convert(oox::pptx_conversion_context & Context)
{
Context.get_slide_context().add_hyperlink(common_xlink_attlist_.xlink_href_.get_value_or(L""),true);// .. -
Context.get_slide_context().add_hyperlink(common_xlink_attlist_.href_.get_value_or(L""),true);// .. -
BOOST_FOREACH(const office_element_ptr & elm, content_)
{
......@@ -227,7 +266,7 @@ void draw_a::pptx_convert(oox::pptx_conversion_context & Context)
}
void draw_a::docx_convert(oox::docx_conversion_context & Context)
{
std::wstring rId = Context.add_hyperlink(common_xlink_attlist_.xlink_href_.get_value_or(L""), true);// , ..
std::wstring rId = Context.add_hyperlink(common_xlink_attlist_.href_.get_value_or(L""), true);// , ..
BOOST_FOREACH(const office_element_ptr & elm, content_)
{
......@@ -350,15 +389,14 @@ void xlsx_convert_transforms(std::wstring transformStr, oox::xlsx_conversion_con
}
else if ((res = transform[0].find(L"rotate"))>=0)//
{
double angle = boost::lexical_cast<double>(transform[1]);
Context.get_drawing_context().set_property(_property(L"svg:rotate",angle));
Context.get_drawing_context().set_rotate(boost::lexical_cast<double>(transform[1]));
}
else if ((res = transform[0].find(L"skewX"))>=0)//
else if ((res = transform[0].find(L"skewX"))>=0)//
{
double angle = boost::lexical_cast<double>(transform[1]);
Context.get_drawing_context().set_property(_property(L"svg:skewX",angle));
}
else if ((res = transform[0].find(L"skewY"))>=0)//
else if ((res = transform[0].find(L"skewY"))>=0)//
{
double angle = boost::lexical_cast<double>(transform[1]);
Context.get_drawing_context().set_property(_property(L"svg:skewY",angle));
......@@ -411,8 +449,7 @@ void pptx_convert_transforms(std::wstring transformStr, oox::pptx_conversion_con
}
else if ((res = transform[0].find(L"rotate"))>=0)//
{
double angle = boost::lexical_cast<double>(transform[1]);
Context.get_slide_context().set_property(_property(L"svg:rotate",angle));
Context.get_slide_context().set_rotate( boost::lexical_cast<double>(transform[1]));
}
else if ((res = transform[0].find(L"skewX"))>=0)//
{
......
......@@ -23,6 +23,8 @@ namespace _image_file_
namespace cpdoccore {
namespace odf {
class styles_lite_container;
enum BorderSide { sideTop, sideBottom, sideLeft, sideRight, sideMiddle };
......@@ -33,6 +35,8 @@ int Compute_BorderWidth(const graphic_format_properties & graphicProperties, Bor
int GetMargin(const graphic_format_properties & graphicProperties, BorderSide borderSide);//emu
void Compute_GraphicFill(graphic_format_properties & props, styles_lite_container &styles, oox::_oox_fill & fill);
typedef double double_4[4];
bool parse_clipping(std::wstring strClipping,std::wstring fileName,double_4 & clip_rect);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......
......@@ -137,7 +137,7 @@ int ComputeMarginX(const style_page_layout_properties * pagePropertiesNode,
common_draw_shape_with_styles_attlist_.
common_text_spreadsheet_shape_attlist_.
common_text_anchor_attlist_.
text_anchor_type_;
type_;
_CP_OPT(horizontal_rel) styleHorizontalRel = graphicProperties.common_horizontal_rel_attlist_.style_horizontal_rel_;
_CP_OPT(horizontal_pos) styleHorizontalPos = graphicProperties.common_horizontal_pos_attlist_.style_horizontal_pos_;
......@@ -531,7 +531,7 @@ int ComputeMarginY(const style_page_layout_properties_attlist & pageProperties,
common_draw_shape_with_styles_attlist_.
common_text_spreadsheet_shape_attlist_.
common_text_anchor_attlist_.
text_anchor_type_;
type_;
_CP_OPT(vertical_rel) styleVerticalRel = graphicProperties.common_vertical_rel_attlist_.style_vertical_rel_;
_CP_OPT(vertical_pos) styleVerticallPos = graphicProperties.common_vertical_pos_attlist_.style_vertical_pos_;
......@@ -738,7 +738,7 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, const unio
common_draw_shape_with_styles_attlist_.
common_text_spreadsheet_shape_attlist_.
common_text_anchor_attlist_.
text_anchor_type_;
type_;
int level_drawing = Context.get_drawing_context().get_current_level();
......@@ -880,9 +880,6 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context)
drawing.type = oox::mediaitems::typeShape;
drawing.isInternal = true;
drawing.rId = L"";// -
drawing.id = Context.get_drawing_context().get_current_shape_id();
drawing.name = Context.get_drawing_context().get_current_object_name();
......@@ -912,10 +909,10 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context)
void draw_image::docx_convert(oox::docx_conversion_context & Context)
{
if (!common_xlink_attlist_.xlink_href_)
if (!common_xlink_attlist_.href_)
return;
std::wstring href = common_xlink_attlist_.xlink_href_.get_value_or(L"");
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
int pos_replaicement= href.find(L"ObjectReplacements");
if (pos_replaicement >=0)
return;//
......@@ -949,11 +946,11 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
/////////////////////////////////////////////////////////////////////////////////////////////////////
oox::_docx_drawing drawing = oox::_docx_drawing();
drawing.fill.bitmap = oox::oox_bitmap_fill::create();
drawing.type = oox::mediaitems::typeImage;
drawing.isInternal = false;
drawing.rId = Context.add_mediaitem(href, oox::mediaitems::typeImage, drawing.isInternal,href);
drawing.fill.bitmap->isInternal = false;
drawing.fill.bitmap->rId = Context.add_mediaitem(href, oox::mediaitems::typeImage,drawing.fill.bitmap->isInternal,href);
drawing.id = Context.get_drawing_context().get_current_frame_id();
drawing.name = Context.get_drawing_context().get_current_object_name();
......@@ -989,14 +986,14 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
if (properties)
{
using boost::filesystem::wpath;
if (properties->content().fo_clip_)
if (properties->content().fo_clip_ && drawing.fill.bitmap)
{
std::wstring strRectClip = properties->content().fo_clip_.get();
strRectClip = strRectClip.substr(5,strRectClip.length()-6);
std::wstring fileName = BOOST_STRING_PATH(wpath(Context.root()->get_folder()) / href);
drawing.clipping_enabled = parse_clipping(strRectClip,fileName,drawing.clipping_rect);
drawing.fill.bitmap->bCrop = parse_clipping(strRectClip,fileName,drawing.fill.bitmap->cropRect);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -1050,9 +1047,6 @@ void draw_text_box::docx_convert(oox::docx_conversion_context & Context)
drawing.type = oox::mediaitems::typeShape;
drawing.isInternal = true;
drawing.rId = L"";// -
drawing.id = Context.get_drawing_context().get_current_frame_id();
drawing.name = Context.get_drawing_context().get_current_object_name();
......@@ -1136,7 +1130,7 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
{
try
{
std::wstring href = common_xlink_attlist_.xlink_href_.get_value_or(L"");
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
odf::odf_document * odf = Context.root();
const std::wstring folder = odf->get_folder();
......@@ -1175,9 +1169,8 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
drawing.id = Context.get_drawing_context().get_current_frame_id();
drawing.name = Context.get_drawing_context().get_current_object_name();
bool isMediaInternal = true;
drawing.rId = Context.add_mediaitem(href, oox::mediaitems::typeChart, drawing.isInternal, href);
bool isMediaInternal = true;
drawing.chartId = Context.add_mediaitem(href, oox::mediaitems::typeChart, isMediaInternal, href);
common_draw_docx_convert(Context, frame->common_draw_attlists_, drawing);
......
......@@ -122,6 +122,10 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
////////////////////////////////////////////////////////////////////
properties.apply_to(Context.get_slide_context().get_properties());
oox::_oox_fill fill;
Compute_GraphicFill(properties, Context.root()->odf_context().drawStyles() ,fill);
Context.get_slide_context().set_fill(fill);
Context.get_slide_context().set_property(odf::_property(L"border_width_left", Compute_BorderWidth(properties, sideLeft)));
Context.get_slide_context().set_property(odf::_property(L"border_width_top", Compute_BorderWidth(properties, sideTop)));
......@@ -154,7 +158,7 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
void draw_image::pptx_convert(oox::pptx_conversion_context & Context)
{
const std::wstring href = common_xlink_attlist_.xlink_href_.get_value_or(L"");
const std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
Context.get_slide_context().start_image(href);
//////////////////////////////////// ...
......@@ -179,7 +183,7 @@ void draw_image::pptx_convert(oox::pptx_conversion_context & Context)
}
void draw_chart::pptx_convert(oox::pptx_conversion_context & Context)
{
const std::wstring href = common_xlink_attlist_.xlink_href_.get_value_or(L"");
const std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
Context.get_slide_context().start_chart(href);
//BOOST_FOREACH(office_element_ptr const & elm, content_)
......@@ -220,7 +224,7 @@ void draw_text_box::pptx_convert(oox::pptx_conversion_context & Context)
void draw_object::pptx_convert(oox::pptx_conversion_context & Context)
{
try {
const std::wstring href = common_xlink_attlist_.xlink_href_.get_value_or(L"");
const std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
odf::odf_document::Impl * odfImpl = Context.root()->get_impl();
const std::wstring folder = odfImpl->get_folder();
......@@ -252,7 +256,7 @@ void draw_object::pptx_convert(oox::pptx_conversion_context & Context)
if (chartBuild.object_type_ == 1)//
{
const std::wstring href_draw = common_xlink_attlist_.xlink_href_.get_value_or(L"");
const std::wstring href_draw = common_xlink_attlist_.href_.get_value_or(L"");
chartBuild.pptx_convert(Context);
Context.get_slide_context().start_chart(href_draw); // , ...
......
......@@ -123,6 +123,9 @@ void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context)
std::wstring strRectClip = properties.fo_clip_.get();
Context.get_drawing_context().set_clipping(strRectClip.substr(5,strRectClip.length()-6));
}
oox::_oox_fill fill;
Compute_GraphicFill(properties, Context.root()->odf_context().drawStyles() ,fill);
Context.get_drawing_context().set_fill(fill);
////////////////////////////////////////////////
//BOOST_FOREACH(office_element_ptr const & elm, content_)
//{
......@@ -142,7 +145,7 @@ void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context)
void draw_image::xlsx_convert(oox::xlsx_conversion_context & Context)
{
const std::wstring href = common_xlink_attlist_.xlink_href_.get_value_or(L"");
const std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
Context.get_drawing_context().start_image(href);
//////////////////////////////////// ...
Context.get_text_context().start_drawing_content();//... -
......@@ -166,7 +169,7 @@ void draw_image::xlsx_convert(oox::xlsx_conversion_context & Context)
}
void draw_chart::xlsx_convert(oox::xlsx_conversion_context & Context)
{
const std::wstring href = common_xlink_attlist_.xlink_href_.get_value_or(L"");
const std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
Context.get_drawing_context().start_chart(href);
//BOOST_FOREACH(office_element_ptr const & elm, content_)
......@@ -211,7 +214,7 @@ void draw_text_box::xlsx_convert(oox::xlsx_conversion_context & Context)
void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context)
{
try {
const std::wstring href = common_xlink_attlist_.xlink_href_.get_value_or(L"");
const std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
odf::odf_document::Impl * odfImpl = Context.root()->get_impl();
const std::wstring folder = odfImpl->get_folder();
......@@ -243,7 +246,7 @@ void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context)
if (chartBuild.object_type_ == 1)//
{
const std::wstring href_draw = common_xlink_attlist_.xlink_href_.get_value_or(L"");
const std::wstring href_draw = common_xlink_attlist_.href_.get_value_or(L"");
chartBuild.xlsx_convert(Context);
Context.get_drawing_context().start_chart(href_draw); // , ...
......
......@@ -108,6 +108,11 @@ void draw_shape::common_pptx_convert(oox::pptx_conversion_context & Context)
{
Context.get_slide_context().set_property(p);
}
///////////////////////////////////////////////////////////////////////////////////////
oox::_oox_fill fill;
Compute_GraphicFill(properties, Context.root()->odf_context().drawStyles() ,fill);
Context.get_slide_context().set_fill(fill);
////////////////////////////////////////////////////////////////////////////////////
//////Context.get_text_context().start_drawing_content();
BOOST_FOREACH(office_element_ptr const & elm, content_)
{
......
......@@ -88,7 +88,7 @@ void draw_shape::common_xlsx_convert(oox::xlsx_conversion_context & Context)
instances.push_back(styleInst);
}
graphic_format_properties properties = calc_graphic_properties_content(instances);
////////////////////////////////////////////////////////////////////////////////////
properties.apply_to(Context.get_drawing_context().get_properties());
......@@ -96,7 +96,13 @@ void draw_shape::common_xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.get_drawing_context().set_property(p);
}
oox::_oox_fill fill;
Compute_GraphicFill(properties, Context.root()->odf_context().drawStyles() ,fill);
Context.get_drawing_context().set_fill(fill);
//////////////////////////////////////////////////////////////////////////////////////
Context.get_text_context().start_drawing_content();
BOOST_FOREACH(office_element_ptr const & elm, content_)
{
elm->xlsx_convert(Context);
......
#include "precompiled_cpodf.h"
#include "drawfill.h"
#include <ostream>
namespace cpdoccore {
namespace odf {
//std::wstring draw_fill::get_type_ms()
//{
// std::wstring fillType;
// switch(type_)
// {
// case draw_fill::none: fillType = L"a:noFill";break;
// case draw_fill::hatch: fillType = L"a:pattFill";break;
// case draw_fill::solid: fillType = L"a:solidFill";break;
// case draw_fill::gradient: fillType = L"a:gradFill";break;
// case draw_fill::bitmap: fillType = L"a:imageFill";break;
// }
// return fillType;
//}
draw_fill draw_fill::parse(const std::wstring & Str)
{
std::wstring tmp = Str;
boost::algorithm::to_lower(tmp);
if (tmp == L"none")
return draw_fill( none );
else if (tmp == L"solid")
return draw_fill( solid );
else if (tmp == L"bitmap")
return draw_fill( bitmap );
else if (tmp == L"gradient")
return draw_fill( gradient );
else if (tmp == L"hatch")
return draw_fill( hatch );
else
{
BOOST_THROW_EXCEPTION( errors::invalid_attribute() );
return draw_fill( solid );
}
}
}
}
#pragma once
#include <iosfwd>
#include <string>
#include "odfattributes.h"
namespace cpdoccore {
namespace odf {
class draw_fill
{
public:
enum type
{
none,
solid,
bitmap,
gradient,
hatch
};
draw_fill() {}
draw_fill(type _Type) : type_(_Type)
{}
type get_type() const
{
return type_;
};
static draw_fill parse(const std::wstring & Str);
private:
type type_;
};
std::wostream & operator << (std::wostream & _Wostream, const draw_fill & _Val);
}
APPLY_PARSE_XML_ATTRIBUTES(odf::draw_fill);
}
#ifndef _CPDOCCORE_ODF_LENGTHORPERCENT_H_
#define _CPDOCCORE_ODF_LENGTHORPERCENT_H_
#ifdef _MSC_VER
#pragma once
#endif
#include <iosfwd>
#include <string>
......@@ -61,5 +56,3 @@ std::wostream & operator << (std::wostream & _Wostream, const length_or_percent
APPLY_PARSE_XML_ATTRIBUTES(odf::length_or_percent);
}
#endif
#ifndef _CPDOCCORE_ODF_NOTECLASS_H_
#define _CPDOCCORE_ODF_NOTECLASS_H_
#ifdef _MSC_VER
#pragma once
#endif
#include <iosfwd>
#include <string>
......@@ -44,5 +39,3 @@ std::wostream & operator << (std::wostream & _Wostream, const noteclass & _Val);
APPLY_PARSE_XML_ATTRIBUTES(odf::noteclass);
}
#endif
......@@ -410,6 +410,33 @@ void odf_document::Impl::parse_styles()
context_->numberStyles().add(style->get_style_name(), elm);
}
BOOST_FOREACH(const office_element_ptr & elm, docStyles->draw_styles_.draw_gradient_)
{
draw_gradient * style = dynamic_cast<draw_gradient *>(elm.get());
if (!style)
continue;
context_->drawStyles().add(L"gradient:" + style->get_style_name(), elm);
}
BOOST_FOREACH(const office_element_ptr & elm, docStyles->draw_styles_.draw_fill_image_)
{
draw_fill_image * style = dynamic_cast<draw_fill_image *>(elm.get());
if (!style)
continue;
context_->drawStyles().add(L"bitmap:" + style->get_style_name(), elm);
}
// BOOST_FOREACH(const office_element_ptr & elm, docStyles->draw_styles_.draw_hatch_)
// {
// const draw_hatch_image * style = dynamic_cast<const draw_hatch_image *>(elm.get());
// if (!style)
// continue;
//context_->drawStyles().add(L"hatch:" + style->get_style_name(), elm);
// }
}
while(0); // end parse styles
}
......
#ifndef _CPDOCCORE_ODF_CONTEXT_H_
#define _CPDOCCORE_ODF_CONTEXT_H_
#pragma once
#include "styles.h"
#include <vector>
#include <boost/unordered_map.hpp>
#include "stylefamily.h"
#include "noteclass.h"
#include "odf_number_styles.h"
#include "styles_lite_container.h"
#include <iosfwd>
namespace cpdoccore {
......@@ -95,6 +96,7 @@ public:
std::pair<int,std::wstring> add_or_find(const std::wstring & master_name);
};
///////////////////////////////////////////////////////////////
class styles_container
{
public:
......@@ -102,7 +104,8 @@ public:
{}
typedef std::vector<style_instance_ptr> instances_array;
void add_style(const std::wstring & Name,
void add_style(const std::wstring & Name,
style_family::type Type,
style_content * Content,
bool IsAutomatic,
......@@ -119,14 +122,12 @@ public:
const std::wstring master_page_name_by_name(const std::wstring & StyleName) const;
void add_number_style(const std::wstring & Name, office_element_ptr style_content);
instances_array & instances() { return instances_; }
std::wostream & dbg_dump(std::wostream & _Wostream);
presentation_layouts_instance & presentation_layouts() { return presentation_layouts_; }
presentation_masters_instance & presentation_masters() { return presentation_masters_; }
presentation_layouts_instance & presentation_layouts() { return presentation_layouts_; }
presentation_masters_instance & presentation_masters() { return presentation_masters_; }
private:
presentation_layouts_instance presentation_layouts_;
......@@ -324,24 +325,27 @@ private:
class odf_read_context
{
public:
styles_container & styleContainer() { return style_container_; }
styles_container & styleContainer() { return major_style_container_; }
page_layout_container & pageLayoutContainer() { return page_layout_container_; }
fonts_container & fontContainer() { return fonts_container_; }
list_style_container & listStyleContainer() { return list_style_container_; }
notes_configuration & noteConfiguration() { return notes_configuration_; }
number_styles & numberStyles() { return number_styles_; }
fonts_container & fontContainer() { return fonts_container_; }
list_style_container & listStyleContainer() { return list_style_container_; }
notes_configuration & noteConfiguration() { return notes_configuration_; }
styles_lite_container & numberStyles() { return number_style_container_; }
styles_lite_container & drawStyles() { return draw_style_container_; }
private:
styles_container style_container_;
page_layout_container page_layout_container_;
fonts_container fonts_container_;
list_style_container list_style_container_;
notes_configuration notes_configuration_;
number_styles number_styles_;
styles_container major_style_container_;
page_layout_container page_layout_container_;
fonts_container fonts_container_;
list_style_container list_style_container_;
notes_configuration notes_configuration_;
styles_lite_container number_style_container_;
styles_lite_container draw_style_container_;
};
}
}
#endif
......@@ -191,7 +191,10 @@ enum ElementType
typeDrawPage,
typeStyleGraphicPropertis,
typeStyleDrawGradientPropertis,
typeStyleDrawGradient,
typeStyleDrawFillImage,
typeStyleDrawHatch,
typeStyleDrawMarker,
typeOfficeSpreadsheet,
typeOfficeAnnotation,
......@@ -202,7 +205,8 @@ enum ElementType
typeOfficeChart,
typeOfficeEventListeners,
typePresentationEventListener,
typePresentationEventListener,
typeScriptEventListener,
typeTableCalculationSettings,
......
......@@ -70,9 +70,9 @@ void presentation_event_listener::pptx_convert(oox::pptx_conversion_context & Co
{
common_xlink_attlist & xlink = presentation_event_listener_attlist_.common_xlink_attlist_;
if (xlink.xlink_href_)
if (xlink.href_)
{
Context.get_slide_context().add_hyperlink(*xlink.xlink_href_,true);
Context.get_slide_context().add_hyperlink(*xlink.href_,true);
}
}
......
......@@ -436,7 +436,7 @@ void a::docx_convert(oox::docx_conversion_context & Context)
std::wostream & _Wostream = Context.output_stream();
std::wstring rId;
rId = Context.add_hyperlink(common_xlink_attlist_.xlink_href_.get_value_or(L""), false);
rId = Context.add_hyperlink(common_xlink_attlist_.href_.get_value_or(L""), false);
_Wostream << L"<w:hyperlink r:id=\"" << rId << L"\">";
......@@ -497,7 +497,7 @@ void a::xlsx_convert(oox::xlsx_conversion_context & Context)
{
elm->xlsx_convert(Context);
}
Context.end_hyperlink(common_xlink_attlist_.xlink_href_.get_value_or(L""));
Context.end_hyperlink(common_xlink_attlist_.href_.get_value_or(L""));
}
void a::pptx_convert(oox::pptx_conversion_context & Context)
{
......@@ -507,7 +507,7 @@ void a::pptx_convert(oox::pptx_conversion_context & Context)
elm->pptx_convert(Context);
}
std::wstring hId = Context.get_slide_context().add_hyperlink(common_xlink_attlist_.xlink_href_.get_value_or(L""),false);
std::wstring hId = Context.get_slide_context().add_hyperlink(common_xlink_attlist_.href_.get_value_or(L""),false);
Context.get_text_context().end_hyperlink(hId);
}
......
......@@ -16,15 +16,22 @@ void graphic_format_properties::add_attributes( const xml::attributes_wc_ptr & A
{
CP_APPLY_ATTR(L"draw:fill-color", draw_fill_color_);
CP_APPLY_ATTR(L"draw:fill", draw_fill_);
CP_APPLY_ATTR(L"draw:stroke", draw_stroke_);
CP_APPLY_ATTR(L"draw:stroke-dash", draw_stroke_dash_);
CP_APPLY_ATTR(L"draw:marker-start", draw_marker_start_);
CP_APPLY_ATTR(L"draw:marker-end", draw_marker_end_);
CP_APPLY_ATTR(L"draw:opacity", draw_opacity_);
CP_APPLY_ATTR(L"draw:wrap-influence-on-position", draw_wrap_influence_on_position_);
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-hatch-name", draw_fill_hatch_name_);
CP_APPLY_ATTR(L"draw:opacity-name", draw_opacity_name_);
CP_APPLY_ATTR(L"draw:wrap-influence-on-position", draw_wrap_influence_on_position_);
CP_APPLY_ATTR(L"draw:textarea-horizontal-align", draw_textarea_horizontal_align_);
CP_APPLY_ATTR(L"draw:textarea-vertical-align", draw_textarea_vertical_align_);
CP_APPLY_ATTR(L"draw:stroke", draw_stroke_);
CP_APPLY_ATTR(L"draw:stroke-dash", draw_stroke_dash_);
CP_APPLY_ATTR(L"draw:marker-start", draw_marker_start_);
CP_APPLY_ATTR(L"draw:marker-end", draw_marker_end_);
CP_APPLY_ATTR(L"svg:stroke-color", svg_stroke_color_);
CP_APPLY_ATTR(L"svg:stroke-width", svg_stroke_width_);
CP_APPLY_ATTR(L"svg:stroke-opacity",svg_stroke_opacity_);
......@@ -47,8 +54,9 @@ void graphic_format_properties::add_attributes( const xml::attributes_wc_ptr & A
CP_APPLY_ATTR(L"style:flow-with-text", style_flow_with_text_);
CP_APPLY_ATTR(L"style:overflow-behavior", style_overflow_behavior_);
CP_APPLY_ATTR(L"style:mirror", style_mirror_);
common_draw_rel_size_attlist_.add_attributes(Attributes);
CP_APPLY_ATTR(L"style:repeat", style_repeat_);
common_draw_rel_size_attlist_.add_attributes(Attributes);
common_horizontal_margin_attlist_.add_attributes(Attributes);
common_vertical_margin_attlist_.add_attributes(Attributes);
common_margin_attlist_.add_attributes(Attributes);
......@@ -68,12 +76,11 @@ void graphic_format_properties::add_attributes( const xml::attributes_wc_ptr & A
void graphic_format_properties::apply_to(std::vector<_property> & properties)
{
if (draw_fill_color_) properties.push_back(_property(L"fill-color", draw_fill_color_->get_hex_value() ));
if (svg_stroke_color_) properties.push_back(_property(L"stroke-color", svg_stroke_color_->get_hex_value() ));
if (draw_fill_) properties.push_back(_property(L"fill", draw_fill_->get_type_ms()));
if (draw_stroke_) properties.push_back(_property(L"stroke", draw_stroke_->get_type() ));
if (svg_stroke_color_) properties.push_back(_property(L"stroke-color", svg_stroke_color_->get_hex_value() ));
if (draw_stroke_dash_) properties.push_back(_property(L"stroke-dash", draw_stroke_dash_.get()));
if (svg_stroke_width_) properties.push_back(_property(L"stroke-width", svg_stroke_width_->get_length().get_value_unit(odf::length::pt) ));
if (draw_opacity_) properties.push_back(_property(L"opacity", draw_opacity_->get_percent().get_value()));
if (svg_stroke_opacity_)properties.push_back(_property(L"stroke-opacity",svg_stroke_opacity_->get_percent().get_value()));
if (draw_marker_start_) properties.push_back(_property(L"marker-start", draw_marker_start_->get() ));
if (draw_marker_end_) properties.push_back(_property(L"marker-end", draw_marker_end_->get() ));
......@@ -84,8 +91,14 @@ void graphic_format_properties::apply_to(std::vector<_property> & properties)
}
void graphic_format_properties::apply_from(const graphic_format_properties & Other)
{
_CP_APPLY_PROP2(draw_fill_color_);
_CP_APPLY_PROP2(draw_fill_);
_CP_APPLY_PROP2(draw_fill_image_name_);
_CP_APPLY_PROP2(draw_fill_gradient_name_);
_CP_APPLY_PROP2(draw_fill_hatch_name_);
_CP_APPLY_PROP2(draw_opacity_name_);
_CP_APPLY_PROP2(draw_fill_color_);
_CP_APPLY_PROP2(draw_stroke_);
_CP_APPLY_PROP2(draw_stroke_dash_);
_CP_APPLY_PROP2(draw_marker_start_);
......@@ -102,6 +115,7 @@ void graphic_format_properties::apply_from(const graphic_format_properties & Oth
_CP_APPLY_PROP2(fo_min_height_);
_CP_APPLY_PROP2(fo_max_width_);
_CP_APPLY_PROP2(fo_max_height_);
_CP_APPLY_PROP2(style_print_content_);
_CP_APPLY_PROP2(style_protect_);
_CP_APPLY_PROP2(style_editable_);
......@@ -114,6 +128,7 @@ void graphic_format_properties::apply_from(const graphic_format_properties & Oth
_CP_APPLY_PROP2(style_flow_with_text_);
_CP_APPLY_PROP2(style_overflow_behavior_);
_CP_APPLY_PROP2(style_mirror_);
_CP_APPLY_PROP2(style_repeat_);
_CP_APPLY_PROP2(fo_clip_);
_CP_APPLY_PROP2(draw_wrap_influence_on_position_);
......
......@@ -41,29 +41,40 @@ public:
// 15.27
// 1
common_draw_rel_size_attlist common_draw_rel_size_attlist_;
_CP_OPT(length_or_percent) fo_min_width_;
_CP_OPT(length_or_percent) fo_min_width_;
_CP_OPT(length_or_percent) fo_min_height_;
_CP_OPT(length_or_percent) fo_max_width_;
_CP_OPT(length_or_percent) fo_max_height_;
_CP_OPT(length_or_percent) svg_stroke_width_;
////////////////////////////////
_CP_OPT(length_or_percent) draw_opacity_;
_CP_OPT(std::wstring) draw_stroke_dash_;
_CP_OPT(draw_fill) draw_fill_;
_CP_OPT(length_or_percent) svg_stroke_opacity_;
_CP_OPT(color) svg_stroke_color_;
_CP_OPT(color) draw_fill_color_;
_CP_OPT(std::wstring) draw_fill_image_name_;
_CP_OPT(std::wstring) draw_fill_gradient_name_;
_CP_OPT(std::wstring) draw_fill_hatch_name_;
_CP_OPT(std::wstring) draw_opacity_name_;
_CP_OPT(bool) draw_fill_hatch_solid_;
_CP_OPT(std::wstring) style_repeat_;//no-repeat,repeat,stretch
///////////////////////////////
_CP_OPT(color) svg_stroke_color_;
_CP_OPT(length_or_percent) svg_stroke_opacity_;
_CP_OPT(line_style) draw_stroke_;
_CP_OPT(std::wstring) draw_stroke_dash_;
_CP_OPT(length_or_percent) svg_stroke_width_;
_CP_OPT(marker_style) draw_marker_end_;
_CP_OPT(marker_style) draw_marker_start_;
_CP_OPT(text_align) draw_textarea_horizontal_align_;
_CP_OPT(vertical_align) draw_textarea_vertical_align_;
common_horizontal_margin_attlist common_horizontal_margin_attlist_;
common_vertical_margin_attlist common_vertical_margin_attlist_;
......@@ -84,7 +95,9 @@ public:
common_text_anchor_attlist common_text_anchor_attlist_;
common_border_attlist common_border_attlist_;
common_text_animation_attlist common_text_animation_attlist_;
common_border_attlist common_border_attlist_;
common_border_line_width_attlist common_border_line_width_attlist_;
......
......@@ -54,10 +54,10 @@ public:
_CP_OPT(draw_fill) draw_fill_;
_CP_OPT(std::wstring) draw_fill_image_name_;
_CP_OPT(color) draw_fill_color_;
//draw:fill-hatch-name
//draw:fill-gradient-name
//draw:fill-color
//_CP_OPT(std::wstring) presentation_transition_type_;
//presentation:transition-style
......
......@@ -8,6 +8,8 @@
#include <cpdoccore/odf/odf_document.h>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "../docx/oox_drawing_fills.h"
namespace cpdoccore {
namespace odf {
......@@ -269,7 +271,7 @@ void text_format_properties_content::pptx_convert_as_list(oox::pptx_conversion_c
{
CP_XML_NODE(L"a:buClr")
{
CP_XML_NODE(L"a:srgbClr"){CP_XML_ATTR(L"val",fo_color_->get_hex_value());}
oox::oox_serialize_srgb(CP_XML_STREAM(),fo_color_->get_hex_value(),NULL);
}
}
if (fo_font_size_)
......
......@@ -198,7 +198,25 @@ void default_style::add_text(const std::wstring & Text)
{
}
void draw_gradient_properties::add_attributes( const xml::attributes_wc_ptr & Attributes )
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * draw_fill_image::ns = L"draw";
const wchar_t * draw_fill_image::name = L"fill-image";
void draw_fill_image::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"draw:name", draw_name_);
xlink_attlist_.add_attributes(Attributes);
}
void draw_fill_image::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name)
{
CP_NOT_APPLICABLE_ELM();
}
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * draw_gradient::ns = L"draw";
const wchar_t * draw_gradient::name = L"gradient";
void draw_gradient::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_);
......@@ -215,15 +233,7 @@ void draw_gradient_properties::add_attributes( const xml::attributes_wc_ptr & At
CP_APPLY_ATTR(L"draw:border", draw_border_);
CP_APPLY_ATTR(L"draw:angle", draw_angle_);
CP_APPLY_ATTR(L"draw:style", draw_style_);//"square"
}
// style:graphic-properties
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * draw_gradient::ns = L"draw";
const wchar_t * draw_gradient::name = L"gradient";
void draw_gradient::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
draw_gradient_properties_.add_attributes(Attributes);
}
void draw_gradient::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name)
......@@ -269,7 +279,7 @@ void style::add_text(const std::wstring & Text)
{
}
// styles
// styles & draw_styles
//////////////////////////////////////////////////////////////////////////////////////////////////
void styles::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name, document_context * Context)
......@@ -300,6 +310,37 @@ void styles::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, co
}
}
void draw_styles::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name, document_context * Context)
{
if CP_CHECK_NAME(L"draw", L"gradient")
{
CP_CREATE_ELEMENT_SIMPLE(draw_gradient_);
}
else if CP_CHECK_NAME(L"draw", L"hatch")
{
CP_CREATE_ELEMENT_SIMPLE(draw_hatch_);
}
else if CP_CHECK_NAME(L"draw", L"fill-image")
{
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
{
CP_NOT_APPLICABLE_ELM_SIMPLE(L"draw_styles");
}
}
// office:automatic-styles
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * office_automatic_styles::ns = L"office";
......@@ -372,20 +413,37 @@ void office_styles::add_attributes( const xml::attributes_wc_ptr & Attributes )
void office_styles::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name)
{
if (CP_CHECK_NAME(L"style", L"style") ||
CP_CHECK_NAME(L"text", L"list-style") ||
CP_CHECK_NAME(L"number", L"number-style") ||
CP_CHECK_NAME(L"number", L"currency-style") ||
CP_CHECK_NAME(L"number", L"text-style") ||
CP_CHECK_NAME(L"number", L"percentage-style") ||
CP_CHECK_NAME(L"number", L"date-style") ||
CP_CHECK_NAME(L"number", L"boolean-style")
if (CP_CHECK_NAME(L"style", L"style") ||
CP_CHECK_NAME(L"text", L"list-style") ||
CP_CHECK_NAME(L"number", L"number-style") ||
CP_CHECK_NAME(L"number", L"currency-style") ||
CP_CHECK_NAME(L"number", L"text-style") ||
CP_CHECK_NAME(L"number", L"percentage-style") ||
CP_CHECK_NAME(L"number", L"date-style") ||
CP_CHECK_NAME(L"number", L"boolean-style")
)
{
styles_.add_child_element(Reader, Ns, Name, getContext());
}
else if (L"style" == Ns && L"default-style" == Name)
CP_CREATE_ELEMENT(style_default_style_);
else if (L"style" == Ns && L"presentation-page-layout" == Name)
CP_CREATE_ELEMENT(style_presentation_page_layout_);
else if(CP_CHECK_NAME(L"draw", L"gradient") ||
CP_CHECK_NAME(L"draw", L"fill-image") ||
CP_CHECK_NAME(L"draw", L"hatch") ||
CP_CHECK_NAME(L"draw", L"marker") ||
CP_CHECK_NAME(L"draw", L"opacity") ||
CP_CHECK_NAME(L"draw", L"stroke-dash") ||
CP_CHECK_NAME(L"svg", L"linearGradient") ||
CP_CHECK_NAME(L"svg", L"radialGradient")
)
{
draw_styles_.add_child_element(Reader, Ns, Name, getContext());
}
else if (L"text" == Ns && L"outline-style" == Name)
CP_CREATE_ELEMENT(text_outline_style_);
else if (L"text" == Ns && L"notes-configuration" == Name)
......@@ -394,24 +452,6 @@ void office_styles::add_child_element( xml::sax * Reader, const ::std::wstring &
CP_CREATE_ELEMENT(text_bibliography_configuration_);
else if (L"text" == Ns && L"linenumbering-configuration" == Name)
CP_CREATE_ELEMENT(text_linenumbering_configuration_);
else if (L"draw" == Ns && L"gradient" == Name)
CP_CREATE_ELEMENT(draw_gradient_);
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 (L"draw" == Ns && L"hatch" == Name)
CP_CREATE_ELEMENT(draw_hatch_);
else if (L"draw" == Ns && L"fill-image" == Name)
CP_CREATE_ELEMENT(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"style" == Ns && L"presentation-page-layout" == Name)
CP_CREATE_ELEMENT(style_presentation_page_layout_);
else
{
CP_NOT_APPLICABLE_ELM();
......
......@@ -115,14 +115,18 @@ CP_REGISTER_OFFICE_ELEMENT2(default_style);
/////////////////////////////////////////////////////////////////////////////////////////////////
class draw_gradient_properties
/// \class style_draw_gradient
class draw_gradient : public office_element_impl<draw_gradient>
{
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeStyleDrawGradient;
public:
_CP_OPT(std::wstring) draw_name_;
_CP_OPT(std::wstring) draw_display_name_;
CPDOCCORE_DEFINE_VISITABLE();
std::wstring get_style_name(){return draw_name_.get_value_or(L"");}
_CP_OPT(color) draw_start_color_;
_CP_OPT(color) draw_end_color_;
......@@ -136,34 +140,45 @@ public:
_CP_OPT(percent) draw_border_;
_CP_OPT(int) draw_angle_;
_CP_OPT(std::wstring) draw_style_;//"square"
};
/// \class style_draw_gradient_properties
/// style_draw_gradient_properties
class draw_gradient : public office_element_impl<draw_gradient>
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_gradient);
/////////////////////////////////////////////////////////////////////////////////////////////////
/// \class style_draw_fill_image
class draw_fill_image : public office_element_impl<draw_fill_image>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeStyleDrawGradientPropertis;
static const ElementType type = typeStyleDrawFillImage;
CPDOCCORE_DEFINE_VISITABLE();
const draw_gradient_properties & content() const { return draw_gradient_properties_; }
std::wstring get_style_name(){return draw_name_.get_value_or(L"");}
common_xlink_attlist xlink_attlist_;
private:
_CP_OPT(std::wstring) draw_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);
draw_gradient_properties draw_gradient_properties_;
friend class odf_document;
};
CP_REGISTER_OFFICE_ELEMENT2(draw_gradient);
CP_REGISTER_OFFICE_ELEMENT2(draw_fill_image);
/////////////////////////////////////////////////////////////////////////////////////////////////
class style;
typedef shared_ptr<style>::Type style_ptr;
......@@ -239,6 +254,26 @@ private:
friend class odf_document;
};
class draw_styles
{
public:
void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name, document_context * Context);
private:
office_element_ptr_array draw_gradient_;
office_element_ptr_array draw_fill_image_;
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
friend class odf_document;
};
/// \class office_automatic_styles
/// \brief office:automatic-styles
......@@ -371,27 +406,14 @@ private:
private:
styles styles_;
office_element_ptr_array style_default_style_;
draw_styles draw_styles_;
office_element_ptr_array style_default_style_;
office_element_ptr_array style_presentation_page_layout_;
office_element_ptr text_outline_style_; // < TODO
office_element_ptr_array text_notes_configuration_; // < TODO
office_element_ptr text_bibliography_configuration_; // < TODO
office_element_ptr text_linenumbering_configuration_; // < TODO
office_element_ptr_array draw_gradient_;
office_element_ptr_array svg_linearGradient_; // < TODO
office_element_ptr_array svg_radialGradient_; // < TODO
office_element_ptr_array draw_hatch_; // < TODO
office_element_ptr_array draw_fill_image_; // < TODO
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 style_presentation_page_layout_;
friend class odf_document;
......
#include "precompiled_cpodf.h"
#include "odf_number_styles.h"
#include <vector>
#include <boost/unordered_map.hpp>
#include "styles_lite_container.h"
namespace cpdoccore {
namespace odf {
struct number_style_ref
struct style_ref_lite_container
{
std::wstring style_name;
office_element_ptr style;
};
struct number_styles::Impl
struct styles_lite_container::Impl
{
typedef std::vector<number_style_ref> array_t;
typedef std::vector<style_ref_lite_container> array_t;
array_t array_;
typedef boost::unordered_map<std::wstring, size_t> map_t;
map_t map_;
};
number_styles::number_styles(): impl_(new number_styles::Impl() )
styles_lite_container::styles_lite_container(): impl_(new styles_lite_container::Impl() )
{
}
number_styles::~number_styles()
styles_lite_container::~styles_lite_container()
{
}
void number_styles::add(const std::wstring & style_name, office_element_ptr content)
void styles_lite_container::add(const std::wstring & style_name, office_element_ptr content)
{
number_style_ref ref = {style_name, content};
style_ref_lite_container ref = {style_name, content};
impl_->array_.push_back(ref);
impl_->map_[style_name] = impl_->array_.size() - 1;
}
office_element_ptr number_styles::find_by_style_name(const std::wstring & style_name)
office_element_ptr styles_lite_container::find_by_style_name(const std::wstring & style_name)
{
number_styles::Impl::map_t::const_iterator i = impl_->map_.find(style_name);
styles_lite_container::Impl::map_t::const_iterator i = impl_->map_.find(style_name);
if (i != impl_->map_.end())
{
return impl_->array_[i->second].style;
......
#ifndef _CPDOCCORE_ODF_NUMBER_STYLES_H_
#define _CPDOCCORE_ODF_NUMBER_STYLES_H_
#pragma once
#include <cpdoccore/CPSharedPtr.h>
#include <cpdoccore/CPScopedPtr.h>
......@@ -10,11 +9,11 @@ namespace odf {
class office_element;
typedef shared_ptr<office_element>::Type office_element_ptr;
class number_styles
class styles_lite_container
{
public:
number_styles();
~number_styles();
styles_lite_container();
~styles_lite_container();
public:
void add(const std::wstring & style_name, office_element_ptr content);
office_element_ptr find_by_style_name(const std::wstring & style_name);
......@@ -27,5 +26,3 @@ private:
}
}
#endif
......@@ -217,7 +217,7 @@ void table_table::xlsx_convert(oox::xlsx_conversion_context & Context)
table_table_source* table_source = dynamic_cast<table_table_source*>( table_table_source_.get() );
if ( table_source)
{
if (table_source->table_linked_source_attlist_.common_xlink_attlist_.xlink_href_)return;
if (table_source->table_linked_source_attlist_.common_xlink_attlist_.href_)return;
}
}
......
......@@ -52,7 +52,7 @@ vertical_align vertical_align::parse(const std::wstring & Str)
return vertical_align( Justify );
else
{
//BOOST_THROW_EXCEPTION( errors::invalid_attribute() );
BOOST_THROW_EXCEPTION( errors::invalid_attribute() );
return vertical_align( Baseline );
}
}
......
......@@ -64,9 +64,11 @@ xlink_actuate xlink_actuate::parse(const std::wstring & Str)
std::wstring tmp = Str;
boost::algorithm::to_lower(tmp);
if (tmp == L"onrequest")
if (tmp == L"onrequest")
return xlink_actuate( OnRequest );
else
else if (tmp == L"onload")
return xlink_actuate( OnLoad );
else
{
BOOST_THROW_EXCEPTION( errors::invalid_attribute() );
return xlink_actuate( OnRequest );
......@@ -82,7 +84,9 @@ xlink_show xlink_show::parse(const std::wstring & Str)
return xlink_show( New );
else if (tmp == L"replace")
return xlink_show( Replace );
else
else if (tmp == L"embed")
return xlink_show( Embed );
else
{
BOOST_THROW_EXCEPTION( errors::invalid_attribute() );
return xlink_show( New );
......
......@@ -36,7 +36,8 @@ class xlink_actuate
public:
enum type
{
OnRequest
OnRequest,
OnLoad
};
xlink_actuate() {}
......@@ -60,7 +61,8 @@ public:
enum type
{
New,
Replace
Replace,
Embed
};
xlink_show() {}
xlink_show(type _Type) : type_(_Type) {}
......
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