Commit 26cedc30 authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatReader - embedded objects (ods in odt example)

parent 1e04770e
...@@ -76,7 +76,7 @@ public: ...@@ -76,7 +76,7 @@ public:
{} {}
std::wostream & xml_to_stream(std::wostream & _Wostream) const; std::wostream & xml_to_stream(std::wostream & _Wostream) const;
const std::wstring & part_name() const { return part_name_; } const std::wstring & part_name() const { return part_name_; }
const std::wstring & content_type() const { return content_type_; } const std::wstring & content_type() const { return content_type_; }
public: public:
......
...@@ -133,6 +133,7 @@ text_tracked_context::_state & text_tracked_context::get_tracked_change(std::wst ...@@ -133,6 +133,7 @@ text_tracked_context::_state & text_tracked_context::get_tracked_change(std::wst
docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfDocument) : docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfDocument) :
next_dump_page_properties_ (false), next_dump_page_properties_ (false),
page_break_ (false),
page_break_after_ (false), page_break_after_ (false),
page_break_before_ (false), page_break_before_ (false),
in_run_ (false), in_run_ (false),
......
...@@ -187,12 +187,10 @@ void serialize_wrap(std::wostream & strm, _docx_drawing const & val) ...@@ -187,12 +187,10 @@ void serialize_wrap(std::wostream & strm, _docx_drawing const & val)
} }
} }
void docx_serialize_text(std::wostream & strm, _docx_drawing & val) void _docx_drawing::serialize_text(std::wostream & strm)
{ {
const std::vector<odf_reader::_property> & properties = val.additional;
_CP_OPT(std::wstring) strTextContent; _CP_OPT(std::wstring) strTextContent;
odf_reader::GetProperty(properties,L"text-content",strTextContent); odf_reader::GetProperty(additional, L"text-content", strTextContent);
CP_XML_WRITER(strm) CP_XML_WRITER(strm)
{ {
...@@ -209,7 +207,7 @@ void docx_serialize_text(std::wostream & strm, _docx_drawing & val) ...@@ -209,7 +207,7 @@ void docx_serialize_text(std::wostream & strm, _docx_drawing & val)
} }
} }
oox_serialize_bodyPr(strm, val, L"wps"); serialize_bodyPr(strm, L"wps");
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
...@@ -240,11 +238,11 @@ void docx_serialize_image_child(std::wostream & strm, _docx_drawing & val) ...@@ -240,11 +238,11 @@ void docx_serialize_image_child(std::wostream & strm, _docx_drawing & val)
CP_XML_NODE(L"pic:spPr") CP_XML_NODE(L"pic:spPr")
{ {
oox_serialize_xfrm(CP_XML_STREAM(), val); val.serialize_xfrm(CP_XML_STREAM());
CP_XML_NODE(L"a:prstGeom") CP_XML_NODE(L"a:prstGeom")
{ {
CP_XML_ATTR(L"prst",L"rect"); CP_XML_ATTR(L"prst", L"rect");
CP_XML_NODE(L"a:avLst"); CP_XML_NODE(L"a:avLst");
} }
...@@ -280,13 +278,12 @@ void docx_serialize_shape_child(std::wostream & strm, _docx_drawing & val) ...@@ -280,13 +278,12 @@ void docx_serialize_shape_child(std::wostream & strm, _docx_drawing & val)
} }
CP_XML_NODE(L"wps:spPr") CP_XML_NODE(L"wps:spPr")
{ {
oox_serialize_xfrm(CP_XML_STREAM(),val); val.serialize_xfrm (CP_XML_STREAM());
val.serialize_shape (CP_XML_STREAM());
oox_serialize_shape(CP_XML_STREAM(),val);
oox_serialize_ln(CP_XML_STREAM(), val.additional); oox_serialize_ln(CP_XML_STREAM(), val.additional);
} }
docx_serialize_text(CP_XML_STREAM(),val); val.serialize_text(CP_XML_STREAM());
} }
} }
} }
...@@ -306,13 +303,14 @@ void docx_serialize_group_child(std::wostream & strm, _docx_drawing & val) ...@@ -306,13 +303,14 @@ void docx_serialize_group_child(std::wostream & strm, _docx_drawing & val)
CP_XML_NODE(L"wpg:grpSpPr") CP_XML_NODE(L"wpg:grpSpPr")
{ {
oox_serialize_xfrm(CP_XML_STREAM(),val); val.serialize_xfrm(CP_XML_STREAM());
} }
CP_XML_STREAM() << val.content_group_; CP_XML_STREAM() << val.content_group_;
} }
} }
} }
void docx_serialize_chart_child(std::wostream & strm, _docx_drawing & val) void docx_serialize_chart_child(std::wostream & strm, _docx_drawing & val)
{ {
CP_XML_WRITER(strm) CP_XML_WRITER(strm)
...@@ -321,7 +319,7 @@ void docx_serialize_chart_child(std::wostream & strm, _docx_drawing & val) ...@@ -321,7 +319,7 @@ void docx_serialize_chart_child(std::wostream & strm, _docx_drawing & val)
{ {
CP_XML_ATTR(L"xmlns:c", L"http://schemas.openxmlformats.org/drawingml/2006/chart"); CP_XML_ATTR(L"xmlns:c", L"http://schemas.openxmlformats.org/drawingml/2006/chart");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships"); CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"r:id", val.chartId); CP_XML_ATTR(L"r:id", val.objectId);
} }
} }
} }
...@@ -332,9 +330,9 @@ void docx_serialize_common(std::wostream & strm, _docx_drawing & val) ...@@ -332,9 +330,9 @@ void docx_serialize_common(std::wostream & strm, _docx_drawing & val)
{ {
CP_XML_NODE(L"wp:docPr") CP_XML_NODE(L"wp:docPr")
{ {
CP_XML_ATTR(L"name",val.name); CP_XML_ATTR(L"name", val.name);
CP_XML_ATTR(L"id", val.id + 1); CP_XML_ATTR(L"id", val.id + 1);
oox_serialize_hlink(CP_XML_STREAM(),val.hlinks); oox_serialize_hlink(CP_XML_STREAM(), val.hlinks);
} }
CP_XML_NODE(L"wp:cNvGraphicFramePr") CP_XML_NODE(L"wp:cNvGraphicFramePr")
...@@ -355,6 +353,11 @@ void docx_serialize_common(std::wostream & strm, _docx_drawing & val) ...@@ -355,6 +353,11 @@ void docx_serialize_common(std::wostream & strm, _docx_drawing & val)
CP_XML_ATTR(L"uri",L"http://schemas.microsoft.com/office/word/2010/wordprocessingShape"); CP_XML_ATTR(L"uri",L"http://schemas.microsoft.com/office/word/2010/wordprocessingShape");
docx_serialize_shape_child(CP_XML_STREAM(), val); docx_serialize_shape_child(CP_XML_STREAM(), val);
} }
else if (val.type == typeGroupShape)
{
CP_XML_ATTR(L"uri", L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
docx_serialize_group_child(CP_XML_STREAM(), val);
}
else if (val.type == typeImage) else if (val.type == typeImage)
{ {
CP_XML_ATTR(L"uri",L"http://schemas.openxmlformats.org/drawingml/2006/picture"); CP_XML_ATTR(L"uri",L"http://schemas.openxmlformats.org/drawingml/2006/picture");
...@@ -365,11 +368,6 @@ void docx_serialize_common(std::wostream & strm, _docx_drawing & val) ...@@ -365,11 +368,6 @@ void docx_serialize_common(std::wostream & strm, _docx_drawing & val)
CP_XML_ATTR(L"uri", L"http://schemas.openxmlformats.org/drawingml/2006/chart"); CP_XML_ATTR(L"uri", L"http://schemas.openxmlformats.org/drawingml/2006/chart");
docx_serialize_chart_child(CP_XML_STREAM(), val); docx_serialize_chart_child(CP_XML_STREAM(), val);
} }
else if (val.type == typeGroupShape)
{
CP_XML_ATTR(L"uri", L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
docx_serialize_group_child(CP_XML_STREAM(), val);
}
} }
} }
} }
...@@ -481,8 +479,8 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val) ...@@ -481,8 +479,8 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
} }
CP_XML_NODE(L"wp:extent") CP_XML_NODE(L"wp:extent")
{ {
CP_XML_ATTR(L"cx",val.cx); CP_XML_ATTR(L"cx", val.cx);
CP_XML_ATTR(L"cy",val.cy); CP_XML_ATTR(L"cy", val.cy);
} }
serialize_wrap(CP_XML_STREAM(), val); serialize_wrap(CP_XML_STREAM(), val);
...@@ -577,16 +575,62 @@ void docx_serialize_alt_content(std::wostream & strm, _docx_drawing & val) ...@@ -577,16 +575,62 @@ void docx_serialize_alt_content(std::wostream & strm, _docx_drawing & val)
} }
} }
} }
void docx_serialize_object(std::wostream & strm, _docx_drawing & val)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"w:object")
{
CP_XML_NODE(L"v:shape")
{
CP_XML_ATTR(L"id", L"ole_" + val.objectId);
void docx_serialize(std::wostream & strm, _docx_drawing & val, bool insideOtherDrawing) CP_XML_ATTR(L"o:ole", "");
std::wstring style_str; // = L"width:730.6pt; height:261.8pt";
style_str += L"width:" + std::to_wstring(val.cx / 12700) + L"pt;";
style_str += L"height:" + std::to_wstring(val.cy / 12700) + L"pt;";
CP_XML_ATTR(L"style", style_str);
if (val.fill.bitmap)
{
CP_XML_NODE(L"v:imagedata")
{
CP_XML_ATTR(L"o:title", L"" );
CP_XML_ATTR(L"r:id", val.fill.bitmap->rId);
}
}
}
CP_XML_NODE(L"o:OLEObject")
{
CP_XML_ATTR(L"r:id", L"ole_" + val.objectId);
CP_XML_ATTR(L"ObjectID", L"_1480208863" );
CP_XML_ATTR(L"DrawAspect", L"Content" );
CP_XML_ATTR(L"ShapeID", val.objectId);
CP_XML_ATTR(L"Type", L"Embed");
CP_XML_ATTR(L"ProgID", val.objectProgId);
}
}
}
}
void _docx_drawing::serialize(std::wostream & strm/*, bool insideOtherDrawing*/)
{ {
if (val.inGroup) if (inGroup)
return docx_serialize_child(strm, val); return docx_serialize_child(strm, *this);
//if (insideOtherDrawing) if (type == typeObject)
docx_serialize_wps(strm, val); {
//else docx_serialize_object(strm, *this);
// docx_serialize_alt_content(strm, val); }
else
{
//if (insideOtherDrawing)
docx_serialize_wps(strm, *this);
//else
// docx_serialize_alt_content(strm, val);
}
} }
......
...@@ -44,9 +44,10 @@ ...@@ -44,9 +44,10 @@
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
struct _docx_drawing : _oox_drawing class _docx_drawing : public _oox_drawing
{ {
_docx_drawing():_oox_drawing(), parallel(0), isInline(false), number_wrapped_paragraphs(0), posOffsetV(0), posOffsetH(0) public:
_docx_drawing() : _oox_drawing(), parallel(0), isInline(false), number_wrapped_paragraphs(0), posOffsetV(0), posOffsetH(0)
{ {
} }
bool isInline; bool isInline;
...@@ -72,15 +73,12 @@ struct _docx_drawing : _oox_drawing ...@@ -72,15 +73,12 @@ struct _docx_drawing : _oox_drawing
_CP_OPT(int) pctWidth; _CP_OPT(int) pctWidth;
_CP_OPT(int) pctHeight; _CP_OPT(int) pctHeight;
int margin_rect[4];//0-left, 1 -top, 2- right, 3 - bottom int margin_rect[4]; //0-left, 1 -top, 2- right, 3 - bottom
//std::wstring distB;
// std::wstring distT;
// std::wstring distL;
// std::wstring distR;
std::wstring content_group_; std::wstring content_group_;
friend void docx_serialize(std::wostream & _Wostream, _docx_drawing & val, bool insideOtherDrawing); void serialize_text (std::wostream & strm);
void serialize (std::wostream & strm/*, bool insideOtherDrawing*/);
}; };
} }
} }
...@@ -96,8 +96,13 @@ void word_files::write(const std::wstring & RootPath) ...@@ -96,8 +96,13 @@ void word_files::write(const std::wstring & RootPath)
{ {
media_->write( path ); media_->write( path );
} }
if (embeddings_)
{
embeddings_->write( path );
}
if (headers_footers_) if (headers_footers_)
{ {
headers_footers_->write( path ); headers_footers_->write( path );
} }
...@@ -136,7 +141,15 @@ void word_files::update_rels(docx_conversion_context & Context) ...@@ -136,7 +141,15 @@ void word_files::update_rels(docx_conversion_context & Context)
void word_files::set_media(mediaitems & _Mediaitems, CApplicationFonts *pAppFonts) void word_files::set_media(mediaitems & _Mediaitems, CApplicationFonts *pAppFonts)
{ {
media_ = element_ptr( new media(_Mediaitems, pAppFonts) ); if (_Mediaitems.count_image > 0)
{
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
}
if (_Mediaitems.count_object > 0)
{
embeddings_ = element_ptr( new embeddings(_Mediaitems) );
embeddings_->set_main_document( get_main_document() );
}
} }
void word_files::set_styles(element_ptr Element) void word_files::set_styles(element_ptr Element)
...@@ -197,6 +210,7 @@ void docx_charts_files::add_chart(chart_content_ptr chart) ...@@ -197,6 +210,7 @@ void docx_charts_files::add_chart(chart_content_ptr chart)
{ {
charts_.push_back(chart); charts_.push_back(chart);
} }
void docx_charts_files::write(const std::wstring & RootPath) void docx_charts_files::write(const std::wstring & RootPath)
{ {
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"charts"; std::wstring path = RootPath + FILE_SEPARATOR_STR + L"charts";
......
...@@ -148,6 +148,7 @@ private: ...@@ -148,6 +148,7 @@ private:
element_ptr fontTable_; element_ptr fontTable_;
element_ptr numbering_; element_ptr numbering_;
element_ptr media_; element_ptr media_;
element_ptr embeddings_;
element_ptr headers_footers_; element_ptr headers_footers_;
element_ptr notes_; element_ptr notes_;
element_ptr settings_; element_ptr settings_;
......
...@@ -82,6 +82,8 @@ std::wstring static get_default_file_name(RelsType type) ...@@ -82,6 +82,8 @@ std::wstring static get_default_file_name(RelsType type)
return L"chart"; return L"chart";
case typeMedia: case typeMedia:
return L"media"; return L"media";
case typeObject:
return L"oleObject";
default: default:
return L""; return L"";
} }
...@@ -156,21 +158,26 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b ...@@ -156,21 +158,26 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
{ {
sub_path = L"charts/"; sub_path = L"charts/";
} }
if ( type == typeObject)
{
sub_path = L"embeddings/";
}
int number=0; int number=0;
if ( type == typeChart) number = count_charts + 1; if ( type == typeChart) number = count_charts + 1;
else if ( type == typeImage) number = count_image + 1; else if ( type == typeImage) number = count_image + 1;
else if ( type == typeShape) number = count_shape + 1; else if ( type == typeShape) number = count_shape + 1;
else if ( type == typeMedia) number = count_media + 1; else if ( type == typeMedia) number = count_media + 1;
else if ( type == typeObject) number = count_object + 1;
else else
number = items_.size()+1; number = items_.size() + 1;
inputFileName = create_file_name(href, type, isMediaInternal, number); inputFileName = create_file_name(href, type, isMediaInternal, number);
std::wstring inputPath = isMediaInternal ? odf_packet_ + FILE_SEPARATOR_STR + href : href; std::wstring inputPath = isMediaInternal ? odf_packet_ + FILE_SEPARATOR_STR + href : href;
std::wstring outputPath = isMediaInternal ? ( sub_path + inputFileName) : href; std::wstring outputPath = isMediaInternal ? ( sub_path + inputFileName) : href;
if ( type == typeChart) outputPath= outputPath + L".xml"; if ( type == typeChart) outputPath = outputPath + L".xml";
std::wstring id; std::wstring id;
for (int i = 0 ; i < items_.size(); i++) for (int i = 0 ; i < items_.size(); i++)
...@@ -192,7 +199,7 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b ...@@ -192,7 +199,7 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
{ {
if ( type == typeChart) if ( type == typeChart)
{ {
id = std::wstring(L"chId") + std::to_wstring(count_charts+1); id = std::wstring(L"chId") + std::to_wstring(count_charts + 1);
count_charts++; count_charts++;
} }
else if ( type == typeImage) else if ( type == typeImage)
...@@ -205,12 +212,17 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b ...@@ -205,12 +212,17 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
//------------------------------------------------ //------------------------------------------------
if (inputFileName.empty()) return L""; if (inputFileName.empty()) return L"";
id = std::wstring(L"picId") + std::to_wstring(count_image+1); id = std::wstring(L"picId") + std::to_wstring(count_image + 1);
count_image++; count_image++;
} }
else if ( type == typeObject)
{
id = std::wstring(L"objId") + std::to_wstring(count_object + 1);
count_object++;
}
else else
{ {
id = std::wstring(L"rId") + std::to_wstring(count_shape+1); id = std::wstring(L"rId") + std::to_wstring(count_shape + 1);
count_shape++; count_shape++;
} }
......
...@@ -50,7 +50,7 @@ public: ...@@ -50,7 +50,7 @@ public:
count_image = 0; count_image = 0;
count_tables = 0; count_tables = 0;
count_media = 0; count_media = 0;
count_object = 0;
} }
struct item struct item
...@@ -77,6 +77,7 @@ public: ...@@ -77,6 +77,7 @@ public:
size_t count_media; size_t count_media;
size_t count_shape; size_t count_shape;
size_t count_tables; size_t count_tables;
size_t count_object;
std::wstring add_or_find(const std::wstring & href, RelsType type, bool & isInternal);//возможны ссылки на один и тот же объект std::wstring add_or_find(const std::wstring & href, RelsType type, bool & isInternal);//возможны ссылки на один и тот же объект
std::wstring add_or_find(const std::wstring & href, RelsType type, bool & isInternal, std::wstring & ref); std::wstring add_or_find(const std::wstring & href, RelsType type, bool & isInternal, std::wstring & ref);
......
...@@ -57,18 +57,26 @@ bool is_internal(const std::wstring & uri, const std::wstring & packetRoot) ...@@ -57,18 +57,26 @@ bool is_internal(const std::wstring & uri, const std::wstring & packetRoot)
std::wstring resultPath = packetRoot + FILE_SEPARATOR_STR + mediaPath; std::wstring resultPath = packetRoot + FILE_SEPARATOR_STR + mediaPath;
return FileSystem::Directory::IsExist(resultPath); return FileSystem::Directory::IsExist(resultPath) || FileSystem::Directory::IsExist(mediaPath);
} }
std::wstring get_rel_type(RelsType type) std::wstring get_rel_type(RelsType type)
{ {
switch (type) switch (type)
{ {
case typeImage: case typeImage:
{
return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"; return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image";
case typeChart: }
case typeChart:
{
return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart"; return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart";
default: }
case typeObject:
{
return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
}break;
default:
return L""; return L"";
} }
} }
......
...@@ -37,6 +37,19 @@ ...@@ -37,6 +37,19 @@
namespace cpdoccore { namespace cpdoccore {
static const std::wstring _ooxShapeType[]=
{
L"rect", //frame
L"rect", //text box
L"rect", //shape
L"ellipse",
L"ellipse",
L"line",
L"path",
L"custGeom",//uses sub-sub type,
L"polygon",
};
void svg_path::oox_serialize(std::wostream & strm, std::vector<svg_path::_polyline> & path) void svg_path::oox_serialize(std::wostream & strm, std::vector<svg_path::_polyline> & path)
{ {
CP_XML_WRITER(strm) CP_XML_WRITER(strm)
...@@ -55,7 +68,7 @@ void svg_path::oox_serialize(std::wostream & strm, svg_path::_polyline const & v ...@@ -55,7 +68,7 @@ void svg_path::oox_serialize(std::wostream & strm, svg_path::_polyline const & v
{ {
BOOST_FOREACH(svg_path::_point const & p, val.points) BOOST_FOREACH(svg_path::_point const & p, val.points)
{ {
oox_serialize(CP_XML_STREAM() ,p); oox_serialize(CP_XML_STREAM(), p);
} }
} }
} }
...@@ -235,9 +248,9 @@ void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_pro ...@@ -235,9 +248,9 @@ void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_pro
} }
} }
} }
void oox_serialize_bodyPr(std::wostream & strm, _oox_drawing & val, const std::wstring & namespace_) void _oox_drawing::serialize_bodyPr(std::wostream & strm, const std::wstring & namespace_)
{ {
const std::vector<odf_reader::_property> & prop = val.additional; const std::vector<odf_reader::_property> & prop = additional;
_CP_OPT(bool) bWordArt; _CP_OPT(bool) bWordArt;
odf_reader::GetProperty(prop,L"wordArt", bWordArt); odf_reader::GetProperty(prop,L"wordArt", bWordArt);
...@@ -257,7 +270,7 @@ void oox_serialize_bodyPr(std::wostream & strm, _oox_drawing & val, const std::w ...@@ -257,7 +270,7 @@ void oox_serialize_bodyPr(std::wostream & strm, _oox_drawing & val, const std::w
if (dPaddingTop) CP_XML_ATTR(L"tIns", (int)(*dPaddingTop)); if (dPaddingTop) CP_XML_ATTR(L"tIns", (int)(*dPaddingTop));
if (dPaddingBottom) CP_XML_ATTR(L"bIns", (int)(*dPaddingBottom)); if (dPaddingBottom) CP_XML_ATTR(L"bIns", (int)(*dPaddingBottom));
if (val.inGroup == false) if (inGroup == false)
{ {
_CP_OPT(int) iWrap; _CP_OPT(int) iWrap;
odf_reader::GetProperty(prop, L"text-wrap" , iWrap); odf_reader::GetProperty(prop, L"text-wrap" , iWrap);
...@@ -319,7 +332,7 @@ void oox_serialize_bodyPr(std::wostream & strm, _oox_drawing & val, const std::w ...@@ -319,7 +332,7 @@ void oox_serialize_bodyPr(std::wostream & strm, _oox_drawing & val, const std::w
} }
} }
void oox_serialize_shape(std::wostream & strm, _oox_drawing & val) void _oox_drawing::serialize_shape(std::wostream & strm)
{ {
_CP_OPT(std::wstring) strVal; _CP_OPT(std::wstring) strVal;
_CP_OPT(double) dVal; _CP_OPT(double) dVal;
...@@ -327,60 +340,61 @@ void oox_serialize_shape(std::wostream & strm, _oox_drawing & val) ...@@ -327,60 +340,61 @@ void oox_serialize_shape(std::wostream & strm, _oox_drawing & val)
std::wstring shapeType; std::wstring shapeType;
_CP_OPT(bool) bWordArt; _CP_OPT(bool) bWordArt;
odf_reader::GetProperty(val.additional,L"wordArt", bWordArt); odf_reader::GetProperty(additional,L"wordArt", bWordArt);
if (val.sub_type == 7)//custom if (sub_type == 7)//custom
{ {
_CP_OPT(int) iVal; _CP_OPT(int) iVal;
odf_reader::GetProperty(val.additional, L"odf-custom-draw-index",iVal); odf_reader::GetProperty(additional, L"odf-custom-draw-index",iVal);
if (iVal) if (iVal)
shapeType = _OO_OOX_custom_shapes[*iVal].oox; shapeType = _OO_OOX_custom_shapes[*iVal].oox;
else else
val.sub_type = 6; //path sub_type = 6; //path
if (shapeType == L"textBox") if (shapeType == L"textBox")
{ {
val.sub_type = 1; sub_type = 1;
shapeType = L"rect"; shapeType = L"rect";
} }
} }
else if (val.sub_type < 9 && val.sub_type >= 0) else if (sub_type < 9 && sub_type >= 0)
{ {
shapeType = _ooxShapeType[val.sub_type]; shapeType = _ooxShapeType[sub_type];
} }
if (bWordArt) val.sub_type = 1; if (bWordArt) sub_type = 1;
CP_XML_WRITER(strm) CP_XML_WRITER(strm)
{ {
if (val.sub_type == 6 || val.sub_type == 8) if (sub_type == 6 || sub_type == 8)
{ {
CP_XML_NODE(L"a:custGeom") CP_XML_NODE(L"a:custGeom")
{ {
oox_serialize_aLst(CP_XML_STREAM(), val.additional); oox_serialize_aLst(CP_XML_STREAM(), additional);
CP_XML_NODE(L"a:ahLst"); CP_XML_NODE(L"a:ahLst");
CP_XML_NODE(L"a:gdLst"); CP_XML_NODE(L"a:gdLst");
CP_XML_NODE(L"a:rect") CP_XML_NODE(L"a:rect")
{ {
CP_XML_ATTR(L"b",L"b"); CP_XML_ATTR(L"b", L"b");
CP_XML_ATTR(L"l",0); CP_XML_ATTR(L"l", 0);
CP_XML_ATTR(L"r",L"r"); CP_XML_ATTR(L"r", L"r");
CP_XML_ATTR(L"t",0); CP_XML_ATTR(L"t", 0);
} }
//<a:rect b="b" l="0" r="r" t="0"/> //<a:rect b="b" l="0" r="r" t="0"/>
if (odf_reader::GetProperty(val.additional, L"custom_path", strVal)) if (odf_reader::GetProperty(additional, L"custom_path", strVal))
{ {
_CP_OPT(int) w, h; _CP_OPT(int) w, h;
odf_reader::GetProperty(val.additional, L"custom_path_w", w); odf_reader::GetProperty(additional, L"custom_path_w", w);
odf_reader::GetProperty(val.additional, L"custom_path_h", h); odf_reader::GetProperty(additional, L"custom_path_h", h);
CP_XML_NODE(L"a:pathLst") CP_XML_NODE(L"a:pathLst")
{ {
CP_XML_NODE(L"a:path") CP_XML_NODE(L"a:path")
{ {
CP_XML_ATTR(L"w", w ? *w : val.cx); CP_XML_ATTR(L"w", w ? *w : cx);
CP_XML_ATTR(L"h", h ? *h : val.cy); CP_XML_ATTR(L"h", h ? *h : cy);
CP_XML_STREAM() << strVal.get(); CP_XML_STREAM() << strVal.get();
} }
...@@ -393,12 +407,12 @@ void oox_serialize_shape(std::wostream & strm, _oox_drawing & val) ...@@ -393,12 +407,12 @@ void oox_serialize_shape(std::wostream & strm, _oox_drawing & val)
if (shapeType.length() < 1) if (shapeType.length() < 1)
{ {
shapeType = L"rect"; shapeType = L"rect";
val.sub_type = 2; sub_type = 2;
} }
CP_XML_NODE(L"a:prstGeom")//автофигура CP_XML_NODE(L"a:prstGeom")//автофигура
{ {
CP_XML_ATTR(L"prst", shapeType); CP_XML_ATTR(L"prst", shapeType);
if (!bWordArt) oox_serialize_aLst(CP_XML_STREAM(), val.additional); if (!bWordArt) oox_serialize_aLst(CP_XML_STREAM(), additional);
} }
} }
if (bWordArt) if (bWordArt)
...@@ -407,25 +421,25 @@ void oox_serialize_shape(std::wostream & strm, _oox_drawing & val) ...@@ -407,25 +421,25 @@ void oox_serialize_shape(std::wostream & strm, _oox_drawing & val)
oox_serialize_fill(strm, no_fill); oox_serialize_fill(strm, no_fill);
} }
else else
oox_serialize_fill(strm, val.fill); oox_serialize_fill(strm, fill);
} }
} }
void oox_serialize_xfrm(std::wostream & strm, _oox_drawing & val, const std::wstring name_space) void _oox_drawing::serialize_xfrm(std::wostream & strm, const std::wstring & name_space)
{ {
CP_XML_WRITER(strm) CP_XML_WRITER(strm)
{ {
std::wstring xfrm = name_space + L":xfrm"; std::wstring xfrm = name_space + L":xfrm";
_CP_OPT(double) dRotate; _CP_OPT(double) dRotate;
odf_reader::GetProperty(val.additional, L"svg:rotate", dRotate); odf_reader::GetProperty(additional, L"svg:rotate", dRotate);
_CP_OPT(double) dSkewX; _CP_OPT(double) dSkewX;
odf_reader::GetProperty(val.additional, L"svg:skewX", dSkewX); odf_reader::GetProperty(additional, L"svg:skewX", dSkewX);
_CP_OPT(double) dSkewY; _CP_OPT(double) dSkewY;
odf_reader::GetProperty(val.additional, L"svg:skewY", dSkewY); odf_reader::GetProperty(additional, L"svg:skewY", dSkewY);
_CP_OPT(double) dRotateAngle; _CP_OPT(double) dRotateAngle;
...@@ -448,18 +462,18 @@ void oox_serialize_xfrm(std::wostream & strm, _oox_drawing & val, const std::wst ...@@ -448,18 +462,18 @@ void oox_serialize_xfrm(std::wostream & strm, _oox_drawing & val, const std::wst
CP_XML_ATTR(L"rot", (int)d); CP_XML_ATTR(L"rot", (int)d);
} }
_CP_OPT(bool)bVal; _CP_OPT(bool)bVal;
if (odf_reader::GetProperty(val.additional,L"flipH",bVal)) if (odf_reader::GetProperty(additional,L"flipH", bVal))
CP_XML_ATTR(L"flipH", bVal.get()); CP_XML_ATTR(L"flipH", bVal.get());
if (odf_reader::GetProperty(val.additional,L"flipV",bVal)) if (odf_reader::GetProperty(additional,L"flipV", bVal))
CP_XML_ATTR(L"flipV", bVal.get()); CP_XML_ATTR(L"flipV", bVal.get());
CP_XML_NODE(L"a:off") CP_XML_NODE(L"a:off")
{ {
if (val.inGroup) if (inGroup)
{ {
CP_XML_ATTR(L"x", val.x); CP_XML_ATTR(L"x", x);
CP_XML_ATTR(L"y", val.y); CP_XML_ATTR(L"y", y);
} }
else else
{ {
...@@ -468,19 +482,19 @@ void oox_serialize_xfrm(std::wostream & strm, _oox_drawing & val, const std::wst ...@@ -468,19 +482,19 @@ void oox_serialize_xfrm(std::wostream & strm, _oox_drawing & val, const std::wst
} }
} }
if (val.cx > 0 || val.cy > 0) if (cx > 0 || cy > 0)
{ {
CP_XML_NODE(L"a:ext") CP_XML_NODE(L"a:ext")
{ {
CP_XML_ATTR(L"cx", val.cx); CP_XML_ATTR(L"cx", cx);
CP_XML_ATTR(L"cy", val.cy); CP_XML_ATTR(L"cy", cy);
} }
}else }else
{ {
_CP_LOG << L"[error!!!] not set size object\n"; _CP_LOG << L"[error!!!] not set size object\n";
} }
if (val.type == typeGroupShape) if (type == typeGroupShape)
{ {
CP_XML_NODE(L"a:chOff") CP_XML_NODE(L"a:chOff")
{ {
...@@ -489,8 +503,8 @@ void oox_serialize_xfrm(std::wostream & strm, _oox_drawing & val, const std::wst ...@@ -489,8 +503,8 @@ void oox_serialize_xfrm(std::wostream & strm, _oox_drawing & val, const std::wst
} }
CP_XML_NODE(L"a:chExt") CP_XML_NODE(L"a:chExt")
{ {
CP_XML_ATTR(L"cx", val.cx); CP_XML_ATTR(L"cx", cx);
CP_XML_ATTR(L"cy", val.cy); CP_XML_ATTR(L"cy", cy);
} }
} }
} }
...@@ -502,7 +516,7 @@ void oox_serialize_hlink(std::wostream & strm, std::vector<_hlink_desc> const & ...@@ -502,7 +516,7 @@ void oox_serialize_hlink(std::wostream & strm, std::vector<_hlink_desc> const &
{ {
BOOST_FOREACH(const _hlink_desc & h, val) BOOST_FOREACH(const _hlink_desc & h, val)
{ {
if (h.object == true) if (h.in_object == true)
{ {
CP_XML_NODE(L"a:hlinkClick") CP_XML_NODE(L"a:hlinkClick")
{ {
......
...@@ -42,22 +42,6 @@ ...@@ -42,22 +42,6 @@
#include "../../../Common/DocxFormat/Source/Base/Types_32.h" #include "../../../Common/DocxFormat/Source/Base/Types_32.h"
static const int _odf_to_oox_ShapeType[]=
{ 4,4,4,34,};
static const std::wstring _ooxShapeType[]=
{
L"rect", //frame
L"rect", //text box
L"rect", //shape
L"ellipse",
L"ellipse",
L"line",
L"path",
L"custGeom",//uses sub-sub type,
L"polygon",
};
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
...@@ -65,38 +49,47 @@ namespace oox { ...@@ -65,38 +49,47 @@ namespace oox {
{ {
std::wstring hId; std::wstring hId;
std::wstring hRef; std::wstring hRef;
bool object;
bool in_object;
}; };
struct _oox_drawing
class _oox_drawing
{ {
public:
_oox_drawing() : type(typeUnknown), id(0), x(0), y(0), cx(0), cy(0), sub_type(0), inGroup(false), name(L"object") _oox_drawing() : type(typeUnknown), id(0), x(0), y(0), cx(0), cy(0), sub_type(0), inGroup(false), name(L"object")
{ {
} }
RelsType type; RelsType type;
bool inGroup; bool inGroup;
size_t id; size_t id;
std::wstring name; std::wstring name;
int sub_type; //odf
_INT32 x, y; _INT32 x, y;
_INT32 cx, cy; _INT32 cx, cy;
_oox_fill fill; _oox_fill fill;
int sub_type; //odf std::wstring objectId;
std::wstring chartId; std::wstring objectProgId;
std::vector<_hlink_desc> hlinks; std::vector<_hlink_desc> hlinks;
std::vector<odf_reader::_property> additional;
std::vector<odf_reader::_property> additional; virtual void serialize (std::wostream & strm) = 0;
void serialize_shape (std::wostream & strm);
void serialize_xfrm (std::wostream & strm, const std::wstring & namespace_ = L"a");
void serialize_bodyPr (std::wostream & strm, const std::wstring & namespace_ = L"a");
}; };
void oox_serialize_xfrm (std::wostream & strm, _oox_drawing & val, const std::wstring namespace_ = L"a");
void oox_serialize_shape (std::wostream & strm, _oox_drawing & val); typedef _CP_PTR(_oox_drawing) oox_drawing_ptr;
void oox_serialize_ln (std::wostream & strm, const std::vector<odf_reader::_property> & val, bool always_draw = false);
void oox_serialize_hlink (std::wostream & strm, const std::vector<_hlink_desc> & val); void oox_serialize_ln (std::wostream & strm, const std::vector<odf_reader::_property> & val, bool always_draw = false);
void oox_serialize_bodyPr (std::wostream & strm, _oox_drawing & val, const std::wstring & namespace_ = L"a");
void oox_serialize_aLst (std::wostream & strm, const std::vector<odf_reader::_property> & val); void oox_serialize_aLst (std::wostream & strm, const std::vector<odf_reader::_property> & val);
void oox_serialize_hlink (std::wostream & strm, const std::vector<_hlink_desc> & val);
} }
} }
...@@ -112,14 +112,39 @@ content_type_content * content_types_file::content() ...@@ -112,14 +112,39 @@ content_type_content * content_types_file::content()
bool content_types_file::add_or_find_default(const std::wstring & extension) bool content_types_file::add_or_find_default(const std::wstring & extension)
{ {
for (int i = 0 ; i < content_type_content_.get_default().size(); i++) std::vector<default_content_type> & defaults = content_type_content_.get_default();
for (int i = 0 ; i < defaults.size(); i++)
{ {
if (content_type_content_.get_default()[i].extension() == extension) if (defaults[i].extension() == extension)
return true; return true;
} }
content_type_content_.add_default(extension, get_mime_type(extension)); content_type_content_.add_default(extension, get_mime_type(extension));
return true; return true;
} }
bool content_types_file::add_or_find_override(const std::wstring & fileName)
{
std::vector<override_content_type> & override_ = content_type_content_.get_override();
for (int i = 0 ; i < override_.size(); i++)
{
if (override_[i].part_name() == fileName)
return true;
}
std::wstring content_type;
int pos = fileName.rfind(L".");
std::wstring extension = pos >= 0 ? fileName.substr(pos + 1) : L"";
if (extension == L"xlsx")
content_type = L"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
content_type_content_.add_override(fileName, content_type);
}
void content_types_file::set_media(mediaitems & _Mediaitems) void content_types_file::set_media(mediaitems & _Mediaitems)
{ {
BOOST_FOREACH( mediaitems::item & item, _Mediaitems.items() ) BOOST_FOREACH( mediaitems::item & item, _Mediaitems.items() )
...@@ -285,7 +310,7 @@ void media::write(const std::wstring & RootPath) ...@@ -285,7 +310,7 @@ void media::write(const std::wstring & RootPath)
BOOST_FOREACH( mediaitems::item & item, mediaitems_.items() ) BOOST_FOREACH( mediaitems::item & item, mediaitems_.items() )
{ {
if (item.mediaInternal && item.valid && item.type == typeImage ) if (item.mediaInternal && item.valid && (item.type == typeImage || item.type == typeMedia))
{ {
std::wstring & file_name = item.href; std::wstring & file_name = item.href;
std::wstring file_name_out = RootPath + FILE_SEPARATOR_STR + item.outputName; std::wstring file_name_out = RootPath + FILE_SEPARATOR_STR + item.outputName;
...@@ -301,9 +326,7 @@ void media::write(const std::wstring & RootPath) ...@@ -301,9 +326,7 @@ void media::write(const std::wstring & RootPath)
} }
} }
/////////////////////////////////////////////////////////////////////////////////// //------------------------------------------------------------------------------------------------------------
charts::charts(mediaitems & _ChartsItems) : chartsitems_(_ChartsItems) charts::charts(mediaitems & _ChartsItems) : chartsitems_(_ChartsItems)
{ {
} }
...@@ -312,6 +335,30 @@ void charts::write(const std::wstring & RootPath) ...@@ -312,6 +335,30 @@ void charts::write(const std::wstring & RootPath)
{ {
} }
//--------------------------------------------------------------------------------------------------------------
embeddings::embeddings(mediaitems & _EmbeddingsItems) : embeddingsitems_(_EmbeddingsItems)
{
}
void embeddings::write(const std::wstring & RootPath)
{
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"embeddings";
FileSystem::Directory::CreateDirectory(path.c_str());
content_types_file & content_types = get_main_document()->get_content_types_file();
BOOST_FOREACH( mediaitems::item & item, embeddingsitems_.items() )
{
if (item.mediaInternal && item.valid && item.type == typeObject )
{
content_types.add_or_find_override(std::wstring(L"/word/") + item.outputName);
std::wstring file_name_out = RootPath + FILE_SEPARATOR_STR + item.outputName;
NSFile::CFileBinary::Copy(item.href, file_name_out);
}
}
}
} }
} }
} }
...@@ -81,6 +81,7 @@ public: ...@@ -81,6 +81,7 @@ public:
content_types_file (); content_types_file ();
void write (const std::wstring & RootPath); void write (const std::wstring & RootPath);
bool add_or_find_default (const std::wstring & extension); bool add_or_find_default (const std::wstring & extension);
bool add_or_find_override(const std::wstring & fileName);
void set_media (mediaitems & _Mediaitems); void set_media (mediaitems & _Mediaitems);
content_type_content * content (); content_type_content * content ();
...@@ -224,7 +225,18 @@ private: ...@@ -224,7 +225,18 @@ private:
mediaitems & chartsitems_; mediaitems & chartsitems_;
}; };
class embeddings : public element
{
public:
embeddings(mediaitems & _EmbeddingsItems);
public:
virtual void write(const std::wstring & RootPath);
private:
mediaitems & embeddingsitems_;
};
} // namespace package } // namespace package
} // namespace oox } // namespace oox
} // namespace cpdoccore } // namespace cpdoccore
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
enum RelsType { typeUnknown = 0, typeImage, typeChart, typeShape, typeTable, typeHyperlink, typeComment, typeMedia, typeGroupShape}; enum RelsType { typeUnknown = 0, typeImage, typeChart, typeShape, typeTable, typeHyperlink, typeComment, typeMedia, typeGroupShape, typeObject};
struct _rel struct _rel
{ {
......
...@@ -61,7 +61,8 @@ void pptx_serialize_text(std::wostream & strm, _pptx_drawing & val) ...@@ -61,7 +61,8 @@ void pptx_serialize_text(std::wostream & strm, _pptx_drawing & val)
{ {
CP_XML_NODE(L"p:txBody") CP_XML_NODE(L"p:txBody")
{ {
oox_serialize_bodyPr(CP_XML_STREAM(), val); val.serialize_bodyPr(CP_XML_STREAM());
if (strTextContent) if (strTextContent)
{ {
CP_XML_STREAM() << strTextContent.get(); CP_XML_STREAM() << strTextContent.get();
...@@ -106,14 +107,14 @@ void pptx_serialize_image(std::wostream & strm, _pptx_drawing & val) ...@@ -106,14 +107,14 @@ void pptx_serialize_image(std::wostream & strm, _pptx_drawing & val)
CP_XML_NODE(L"p:spPr") CP_XML_NODE(L"p:spPr")
{ {
oox_serialize_xfrm(CP_XML_STREAM(),val); val.serialize_xfrm(CP_XML_STREAM());
CP_XML_NODE(L"a:prstGeom") CP_XML_NODE(L"a:prstGeom")
{ {
CP_XML_ATTR(L"prst", L"rect"); CP_XML_ATTR(L"prst", L"rect");
CP_XML_NODE(L"a:avLst"); CP_XML_NODE(L"a:avLst");
} }
oox_serialize_ln(CP_XML_STREAM(),val.additional); oox_serialize_ln(CP_XML_STREAM(), val.additional);
} }
//_CP_OPT(std::wstring) strTextContent; //_CP_OPT(std::wstring) strTextContent;
//odf::GetProperty(properties,L"text-content",strTextContent); //odf::GetProperty(properties,L"text-content",strTextContent);
...@@ -169,13 +170,13 @@ void pptx_serialize_shape(std::wostream & strm, _pptx_drawing & val) ...@@ -169,13 +170,13 @@ void pptx_serialize_shape(std::wostream & strm, _pptx_drawing & val)
if (!bNoRect) if (!bNoRect)
{ {
oox_serialize_xfrm(CP_XML_STREAM(),val); val.serialize_xfrm(CP_XML_STREAM());
val.serialize_shape(CP_XML_STREAM());
oox_serialize_shape(CP_XML_STREAM(),val);
oox_serialize_ln(CP_XML_STREAM(), val.additional); oox_serialize_ln(CP_XML_STREAM(), val.additional);
} }
} }
pptx_serialize_text(CP_XML_STREAM(), val); pptx_serialize_text(CP_XML_STREAM(), val);
} }
} // CP_XML_WRITER } // CP_XML_WRITER
} }
...@@ -197,7 +198,7 @@ void pptx_serialize_chart(std::wostream & strm, _pptx_drawing & val) ...@@ -197,7 +198,7 @@ void pptx_serialize_chart(std::wostream & strm, _pptx_drawing & val)
CP_XML_NODE(L"p:cNvGraphicFramePr"); CP_XML_NODE(L"p:cNvGraphicFramePr");
CP_XML_NODE(L"p:nvPr"); CP_XML_NODE(L"p:nvPr");
} }
oox_serialize_xfrm(CP_XML_STREAM(),val,L"p"); val.serialize_xfrm(CP_XML_STREAM(), L"p");
//oox_serialize_ln(CP_XML_STREAM(),val.additional); //oox_serialize_ln(CP_XML_STREAM(),val.additional);
...@@ -210,7 +211,7 @@ void pptx_serialize_chart(std::wostream & strm, _pptx_drawing & val) ...@@ -210,7 +211,7 @@ void pptx_serialize_chart(std::wostream & strm, _pptx_drawing & val)
{ {
CP_XML_ATTR(L"xmlns:c", L"http://schemas.openxmlformats.org/drawingml/2006/chart"); CP_XML_ATTR(L"xmlns:c", L"http://schemas.openxmlformats.org/drawingml/2006/chart");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships"); CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"r:id", val.chartId); CP_XML_ATTR(L"r:id", val.objectId);
} }
} }
} }
...@@ -235,7 +236,7 @@ void pptx_serialize_table(std::wostream & strm, _pptx_drawing & val) ...@@ -235,7 +236,7 @@ void pptx_serialize_table(std::wostream & strm, _pptx_drawing & val)
CP_XML_NODE(L"p:cNvGraphicFramePr"); CP_XML_NODE(L"p:cNvGraphicFramePr");
CP_XML_NODE(L"p:nvPr"); CP_XML_NODE(L"p:nvPr");
} }
oox_serialize_xfrm(CP_XML_STREAM(),val,L"p"); val.serialize_xfrm(CP_XML_STREAM(), L"p");
//oox_serialize_ln(CP_XML_STREAM(),val.additional); //oox_serialize_ln(CP_XML_STREAM(),val.additional);
...@@ -258,23 +259,24 @@ void pptx_serialize_table(std::wostream & strm, _pptx_drawing & val) ...@@ -258,23 +259,24 @@ void pptx_serialize_table(std::wostream & strm, _pptx_drawing & val)
} // CP_XML_WRITER } // CP_XML_WRITER
} }
void pptx_serialize(std::wostream & strm, _pptx_drawing & val)
void _pptx_drawing::serialize(std::wostream & strm)
{ {
if (val.type == typeShape) if (type == typeShape)
{ {
pptx_serialize_shape(strm,val); serialize_shape(strm);
} }
else if (val.type == typeImage) else if (type == typeImage)
{ {
pptx_serialize_image(strm,val); pptx_serialize_image(strm, *this);
} }
else if (val.type == typeChart) else if (type == typeChart)
{ {
pptx_serialize_chart(strm,val); pptx_serialize_chart(strm, *this);
} }
else if (val.type == typeTable) else if (type == typeTable)
{ {
pptx_serialize_table(strm,val); pptx_serialize_table(strm, *this);
} }
} }
......
...@@ -43,13 +43,15 @@ ...@@ -43,13 +43,15 @@
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
struct _pptx_drawing : _oox_drawing class _pptx_drawing : public _oox_drawing
{ {
_pptx_drawing(): place_holder_idx_(-1){} public:
std::wstring place_holder_type_; _pptx_drawing(): _oox_drawing(), place_holder_idx_(-1) {}
int place_holder_idx_;
std::wstring place_holder_type_;
int place_holder_idx_;
friend void pptx_serialize(std::wostream & _Wostream, _pptx_drawing & val); void serialize (std::wostream & _Wostream);
}; };
} }
......
...@@ -92,9 +92,9 @@ public: ...@@ -92,9 +92,9 @@ public:
} }
void serialize(std::wostream & strm) void serialize(std::wostream & strm)
{ {
BOOST_FOREACH(_pptx_drawing & d, pptx_drawings_) for (int i = 0; i < pptx_drawings_.size(); i++)
{ {
pptx_serialize(strm,d); pptx_drawings_[i].serialize(strm);
} }
} }
......
...@@ -40,8 +40,7 @@ ...@@ -40,8 +40,7 @@
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
struct _pptx_drawing; class _pptx_drawing;
class rels; class rels;
class pptx_drawings; class pptx_drawings;
......
...@@ -477,8 +477,8 @@ void pptx_slide_context::process_charts() ...@@ -477,8 +477,8 @@ void pptx_slide_context::process_charts()
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
std::wstring ref; std::wstring ref;
bool isMediaInternal = true; bool isMediaInternal = true;
drawing.chartId = impl_->get_mediaitems().add_or_find(pic.xlink_href_, typeChart, isMediaInternal, ref); drawing.objectId = impl_->get_mediaitems().add_or_find(pic.xlink_href_, typeChart, isMediaInternal, ref);
impl_->add_drawing(drawing, isMediaInternal, drawing.chartId, ref, typeChart); impl_->add_drawing(drawing, isMediaInternal, drawing.objectId, ref, typeChart);
} }
} }
......
...@@ -48,7 +48,7 @@ std::wostream & operator << (std::wostream & strm, xlsx_drawing_position::type_t ...@@ -48,7 +48,7 @@ std::wostream & operator << (std::wostream & strm, xlsx_drawing_position::type_t
} }
} }
void xlsx_serialize_text(std::wostream & strm, _xlsx_drawing & val ) void xlsx_serialize_text(std::wostream & strm, _xlsx_drawing & val)
{ {
_CP_OPT(std::wstring) strTextContent; _CP_OPT(std::wstring) strTextContent;
odf_reader::GetProperty ( val.additional ,L"text-content", strTextContent); odf_reader::GetProperty ( val.additional ,L"text-content", strTextContent);
...@@ -60,7 +60,8 @@ void xlsx_serialize_text(std::wostream & strm, _xlsx_drawing & val ) ...@@ -60,7 +60,8 @@ void xlsx_serialize_text(std::wostream & strm, _xlsx_drawing & val )
{ {
CP_XML_NODE(L"xdr:txBody") CP_XML_NODE(L"xdr:txBody")
{ {
oox_serialize_bodyPr(CP_XML_STREAM(), val); val.serialize_bodyPr(CP_XML_STREAM());
CP_XML_NODE(L"a:lstStyle"); CP_XML_NODE(L"a:lstStyle");
if (strTextContent) if (strTextContent)
{ {
...@@ -70,30 +71,30 @@ void xlsx_serialize_text(std::wostream & strm, _xlsx_drawing & val ) ...@@ -70,30 +71,30 @@ void xlsx_serialize_text(std::wostream & strm, _xlsx_drawing & val )
} }
} }
void xlsx_serialize(std::wostream & strm, const xlsx_drawing_position & val) void xlsx_drawing_position::serialize(std::wostream & strm)
{ {
CP_XML_WRITER(strm) CP_XML_WRITER(strm)
{ {
CP_XML_NODE(std::wstring(L"xdr:") + (val.type == xlsx_drawing_position::from ? L"from" : L"to") ) CP_XML_NODE(std::wstring(L"xdr:") + (type == xlsx_drawing_position::from ? L"from" : L"to") )
{ {
CP_XML_NODE(L"xdr:col") CP_XML_NODE(L"xdr:col")
{ {
CP_XML_CONTENT(val.position.col); CP_XML_CONTENT(position.col);
} }
CP_XML_NODE(L"xdr:colOff") CP_XML_NODE(L"xdr:colOff")
{ {
CP_XML_CONTENT(static_cast<size_t>(val.position.colOff)); CP_XML_CONTENT(static_cast<size_t>(position.colOff));
} }
CP_XML_NODE(L"xdr:row") CP_XML_NODE(L"xdr:row")
{ {
CP_XML_CONTENT(val.position.row); CP_XML_CONTENT(position.row);
} }
CP_XML_NODE(L"xdr:rowOff") CP_XML_NODE(L"xdr:rowOff")
{ {
CP_XML_CONTENT(static_cast<size_t>(val.position.rowOff)); CP_XML_CONTENT(static_cast<size_t>(position.rowOff));
} }
} }
} }
...@@ -129,7 +130,7 @@ void xlsx_serialize_image(std::wostream & strm, _xlsx_drawing & val) ...@@ -129,7 +130,7 @@ void xlsx_serialize_image(std::wostream & strm, _xlsx_drawing & val)
CP_XML_NODE(L"xdr:spPr") CP_XML_NODE(L"xdr:spPr")
{ {
oox_serialize_xfrm(CP_XML_STREAM(),val); val.serialize_xfrm(CP_XML_STREAM());
CP_XML_NODE(L"a:prstGeom") CP_XML_NODE(L"a:prstGeom")
{ {
...@@ -166,9 +167,9 @@ void xlsx_serialize_shape(std::wostream & strm, _xlsx_drawing & val) ...@@ -166,9 +167,9 @@ void xlsx_serialize_shape(std::wostream & strm, _xlsx_drawing & val)
} // xdr:nv_Pr } // xdr:nv_Pr
CP_XML_NODE(L"xdr:spPr") CP_XML_NODE(L"xdr:spPr")
{ {
oox_serialize_xfrm(CP_XML_STREAM(),val); val.serialize_xfrm(CP_XML_STREAM());
oox_serialize_shape(CP_XML_STREAM(),val); val.serialize_shape(CP_XML_STREAM());
bool draw_always = false; bool draw_always = false;
if (val.sub_type == 5 || val.sub_type == 6)//line собственно ) - если ее нет - в свойствах будет if (val.sub_type == 5 || val.sub_type == 6)//line собственно ) - если ее нет - в свойствах будет
...@@ -198,7 +199,7 @@ void xlsx_serialize_group(std::wostream & strm, _xlsx_drawing & val) ...@@ -198,7 +199,7 @@ void xlsx_serialize_group(std::wostream & strm, _xlsx_drawing & val)
} }
CP_XML_NODE(L"xdr:grpSpPr") CP_XML_NODE(L"xdr:grpSpPr")
{ {
oox_serialize_xfrm(CP_XML_STREAM(),val); val.serialize_xfrm(CP_XML_STREAM());
} }
CP_XML_STREAM() << val.content_group_; CP_XML_STREAM() << val.content_group_;
...@@ -222,7 +223,7 @@ void xlsx_serialize_chart(std::wostream & strm, _xlsx_drawing & val) ...@@ -222,7 +223,7 @@ void xlsx_serialize_chart(std::wostream & strm, _xlsx_drawing & val)
CP_XML_NODE(L"xdr:cNvGraphicFramePr"); CP_XML_NODE(L"xdr:cNvGraphicFramePr");
} }
oox_serialize_xfrm(CP_XML_STREAM(),val,L"xdr"); val.serialize_xfrm(CP_XML_STREAM(), L"xdr");
//oox_serialize_ln(CP_XML_STREAM(),val.additional); //oox_serialize_ln(CP_XML_STREAM(),val.additional);
...@@ -235,7 +236,7 @@ void xlsx_serialize_chart(std::wostream & strm, _xlsx_drawing & val) ...@@ -235,7 +236,7 @@ void xlsx_serialize_chart(std::wostream & strm, _xlsx_drawing & val)
{ {
CP_XML_ATTR(L"xmlns:c", L"http://schemas.openxmlformats.org/drawingml/2006/chart"); CP_XML_ATTR(L"xmlns:c", L"http://schemas.openxmlformats.org/drawingml/2006/chart");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships"); CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"r:id", val.chartId); CP_XML_ATTR(L"r:id", val.objectId);
} }
} }
} }
...@@ -261,22 +262,24 @@ void xlsx_serialize_object(std::wostream & strm, _xlsx_drawing & val) ...@@ -261,22 +262,24 @@ void xlsx_serialize_object(std::wostream & strm, _xlsx_drawing & val)
xlsx_serialize_group(strm, val); xlsx_serialize_group(strm, val);
} }
} }
void xlsx_serialize(std::wostream & strm, _xlsx_drawing & val)
void _xlsx_drawing::serialize(std::wostream & strm)
{ {
if (val.inGroup) return xlsx_serialize_object(strm, val); if (inGroup)
return xlsx_serialize_object(strm, *this);
CP_XML_WRITER(strm) CP_XML_WRITER(strm)
{ {
if (val.type_anchor == 1) if (type_anchor == 1)
{ {
CP_XML_NODE(L"xdr:twoCellAnchor") CP_XML_NODE(L"xdr:twoCellAnchor")
{ {
CP_XML_ATTR(L"editAs", L"oneCell");//"absolute");oneCell CP_XML_ATTR(L"editAs", L"oneCell");//"absolute");oneCell
xlsx_serialize (CP_XML_STREAM(), val.from_); from_.serialize (CP_XML_STREAM());
xlsx_serialize (CP_XML_STREAM(), val.to_); to_.serialize (CP_XML_STREAM());
xlsx_serialize_object (CP_XML_STREAM(),val); xlsx_serialize_object (CP_XML_STREAM(), *this);
CP_XML_NODE(L"xdr:clientData"); CP_XML_NODE(L"xdr:clientData");
} }
...@@ -287,17 +290,17 @@ void xlsx_serialize(std::wostream & strm, _xlsx_drawing & val) ...@@ -287,17 +290,17 @@ void xlsx_serialize(std::wostream & strm, _xlsx_drawing & val)
{ {
CP_XML_NODE(L"xdr:pos") CP_XML_NODE(L"xdr:pos")
{ {
CP_XML_ATTR(L"x", val.x); CP_XML_ATTR(L"x", x);
CP_XML_ATTR(L"y", val.y); CP_XML_ATTR(L"y", y);
} }
CP_XML_NODE(L"xdr:ext") CP_XML_NODE(L"xdr:ext")
{ {
CP_XML_ATTR(L"cx", val.cx); CP_XML_ATTR(L"cx", cx);
CP_XML_ATTR(L"cy", val.cy); CP_XML_ATTR(L"cy", cy);
} }
xlsx_serialize_object (CP_XML_STREAM(),val); xlsx_serialize_object (CP_XML_STREAM(), *this);
CP_XML_NODE(L"xdr:clientData"); CP_XML_NODE(L"xdr:clientData");
} }
......
...@@ -46,16 +46,16 @@ namespace oox { ...@@ -46,16 +46,16 @@ namespace oox {
struct xlsx_drawing_position struct xlsx_drawing_position
{ {
enum type_t {from, to}; enum type_t {from, to} type;
type_t type; xlsx_table_position position;
xlsx_table_position position;
friend void xlsx_serialize(std::wostream & _Wostream, xlsx_drawing_position const & val); void serialize(std::wostream & _Wostream);
}; };
struct _xlsx_drawing : _oox_drawing class _xlsx_drawing : public _oox_drawing
{ {
public:
_xlsx_drawing() : _oox_drawing(), type_anchor(1) {} _xlsx_drawing() : _oox_drawing(), type_anchor(1) {}
int type_anchor; int type_anchor;
...@@ -65,8 +65,7 @@ struct _xlsx_drawing : _oox_drawing ...@@ -65,8 +65,7 @@ struct _xlsx_drawing : _oox_drawing
std::wstring content_group_; std::wstring content_group_;
void serialize (std::wostream & _Wostream);
friend void xlsx_serialize(std::wostream & _Wostream, _xlsx_drawing & val);
}; };
} }
} }
...@@ -535,11 +535,11 @@ void xlsx_drawing_context::process_chart(drawing_object_description & obj,_xlsx_ ...@@ -535,11 +535,11 @@ void xlsx_drawing_context::process_chart(drawing_object_description & obj,_xlsx_
std::wstring ref; std::wstring ref;
bool isMediaInternal = true; bool isMediaInternal = true;
drawing.chartId = impl_->get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref); drawing.objectId = impl_->get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
xlsx_drawings_->add(drawing, isMediaInternal, drawing.chartId, ref, obj.type_); xlsx_drawings_->add(drawing, isMediaInternal, drawing.objectId, ref, obj.type_);
if (drawing.inGroup) if (drawing.inGroup)
impl_->get_drawings()->add(isMediaInternal, drawing.chartId, ref, obj.type_); // не объект impl_->get_drawings()->add(isMediaInternal, drawing.objectId, ref, obj.type_); // не объект
} }
void xlsx_drawing_context::process_shape(drawing_object_description & obj,_xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_) void xlsx_drawing_context::process_shape(drawing_object_description & obj,_xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_)
......
...@@ -86,7 +86,7 @@ public: ...@@ -86,7 +86,7 @@ public:
{ {
for (int i = 0 ; i < xlsx_drawings_.size(); i++) for (int i = 0 ; i < xlsx_drawings_.size(); i++)
{ {
xlsx_serialize(strm, xlsx_drawings_[i]); xlsx_drawings_[i].serialize(strm);
} }
} }
else else
...@@ -101,7 +101,7 @@ public: ...@@ -101,7 +101,7 @@ public:
for (int i = 0 ; i < xlsx_drawings_.size(); i++) for (int i = 0 ; i < xlsx_drawings_.size(); i++)
{ {
xlsx_serialize(CP_XML_STREAM(), xlsx_drawings_[i]); xlsx_drawings_[i].serialize(CP_XML_STREAM());
} }
} }
} }
......
...@@ -225,6 +225,10 @@ void object_odf_context::docx_convert(oox::docx_conversion_context & Context) ...@@ -225,6 +225,10 @@ void object_odf_context::docx_convert(oox::docx_conversion_context & Context)
Context.set_run_state (runState); Context.set_run_state (runState);
Context.set_paragraph_state (pState); Context.set_paragraph_state (pState);
} }
else if(object_type_ == 4 && office_spreadsheet_)
{
//office_spreadsheet_
}
} }
void object_odf_context::pptx_convert(oox::pptx_conversion_context & Context) void object_odf_context::pptx_convert(oox::pptx_conversion_context & Context)
{ {
...@@ -544,7 +548,7 @@ bool process_build_object::visit_rows(unsigned int repeated) ...@@ -544,7 +548,7 @@ bool process_build_object::visit_rows(unsigned int repeated)
////////////////////////////////////////////////// //////////////////////////////////////////////////
void process_build_object::on_not_impl(std::string const & message) void process_build_object::on_not_impl(std::string const & message)
{ {
_CP_LOG << L"[process_draw_chart visitor] : not impliment for \"" << utf8_to_utf16(message) << L"\"" << std::endl; _CP_LOG << L"[process_object visitor] : not impliment for \"" << utf8_to_utf16(message) << L"\"" << std::endl;
} }
////////////////////////////////////////////////// //////////////////////////////////////////////////
...@@ -570,14 +574,18 @@ void process_build_object::visit(office_chart& val) ...@@ -570,14 +574,18 @@ void process_build_object::visit(office_chart& val)
void process_build_object::visit(office_text& val) void process_build_object::visit(office_text& val)
{ {
object_odf_context_.object_type_ = 2; object_odf_context_.object_type_ = 2;
object_odf_context_.office_text_ = &val;//конвертация будет уровнем выше object_odf_context_.office_text_ = &val; //конвертация будет уровнем выше
} }
void process_build_object::visit(office_math& val) void process_build_object::visit(office_math& val)
{ {
object_odf_context_.object_type_ = 3; //0;//временно замещающая картинка object_odf_context_.object_type_ = 3; //= 0 - временно замещающая картинка
object_odf_context_.office_math_ = &val;//конвертация будет уровнем выше object_odf_context_.office_math_ = &val; //конвертация будет уровнем выше
}
void process_build_object::visit(office_spreadsheet& val)
{
object_odf_context_.object_type_ = 4;
object_odf_context_.office_spreadsheet_ = &val; //конвертация будет уровнем выше
} }
void process_build_object::visit(const chart_chart& val) void process_build_object::visit(const chart_chart& val)
{ {
object_odf_context_.object_type_ = 1; object_odf_context_.object_type_ = 1;
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include "office_body.h" #include "office_body.h"
#include "office_chart.h" #include "office_chart.h"
#include "office_text.h" #include "office_text.h"
#include "office_spreadsheet.h"
#include "math_elements.h" #include "math_elements.h"
#include "table.h" #include "table.h"
#include "odfcontext.h" #include "odfcontext.h"
...@@ -118,6 +119,7 @@ public: ...@@ -118,6 +119,7 @@ public:
object_type_ (0), object_type_ (0),
office_text_ (NULL), office_text_ (NULL),
office_math_ (NULL), office_math_ (NULL),
office_spreadsheet_ (NULL),
baseRef_ (ref), baseRef_ (ref),
baseFontHeight_ (12) baseFontHeight_ (12)
{ {
...@@ -159,6 +161,7 @@ public: ...@@ -159,6 +161,7 @@ public:
int object_type_; int object_type_;
office_text *office_text_; office_text *office_text_;
office_math *office_math_; office_math *office_math_;
office_spreadsheet *office_spreadsheet_;
int baseFontHeight_; int baseFontHeight_;
std::wstring baseRef_; std::wstring baseRef_;
...@@ -211,7 +214,6 @@ public: ...@@ -211,7 +214,6 @@ public:
/////////////////////////////////////////// ///////////////////////////////////////////
}; };
// Класс для обхода всех элеменов office:object для построения диаграммы
class process_build_object class process_build_object
: public base_visitor, : public base_visitor,
...@@ -222,7 +224,8 @@ class process_build_object ...@@ -222,7 +224,8 @@ class process_build_object
public visitor<office_chart>, public visitor<office_chart>,
public visitor<office_text>, public visitor<office_text>,
public visitor<office_math>, public visitor<office_math>,
public visitor<office_spreadsheet>,
public const_visitor<chart_chart>, public const_visitor<chart_chart>,
public const_visitor<chart_title>, public const_visitor<chart_title>,
...@@ -283,47 +286,48 @@ private: ...@@ -283,47 +286,48 @@ private:
public: public:
virtual void visit(const office_document_content& val); virtual void visit(const office_document_content& val);
virtual void visit(office_document_content& val); virtual void visit(office_document_content & val);
virtual void visit(office_body & val); virtual void visit(office_body & val);
virtual void visit(office_chart & val); virtual void visit(office_chart & val);
virtual void visit(office_text & val); virtual void visit(office_text & val);
virtual void visit(office_math & val); virtual void visit(office_math & val);
virtual void visit(office_spreadsheet & val);
virtual void visit(const chart_chart& val);
virtual void visit(const chart_title& val); virtual void visit(const chart_chart & val);
virtual void visit(const chart_subtitle& val); virtual void visit(const chart_title & val);
virtual void visit(const chart_footer& val); virtual void visit(const chart_subtitle & val);
virtual void visit(const chart_legend& val); virtual void visit(const chart_footer & val);
virtual void visit(const chart_legend & val);
virtual void visit(const chart_plot_area& val); virtual void visit(const chart_plot_area& val);
virtual void visit(const chart_axis& val); virtual void visit(const chart_axis & val);
virtual void visit(const chart_series& val); virtual void visit(const chart_series & val);
virtual void visit(const chart_domain& val); virtual void visit(const chart_domain & val);
virtual void visit(const chart_data_point & val); virtual void visit(const chart_data_point & val);
virtual void visit(const chart_mean_value & val); virtual void visit(const chart_mean_value & val);
virtual void visit(const chart_error_indicator & val); virtual void visit(const chart_error_indicator & val);
virtual void visit(const chart_regression_curve & val); virtual void visit(const chart_regression_curve & val);
virtual void visit(const chart_equation & val); virtual void visit(const chart_equation & val);
virtual void visit(const chart_categories& val); virtual void visit(const chart_categories & val);
virtual void visit(const chart_grid& val); virtual void visit(const chart_grid & val);
virtual void visit(const chart_wall& val); virtual void visit(const chart_wall & val);
virtual void visit(const chart_floor& val); virtual void visit(const chart_floor & val);
virtual void visit(const table_table& val); virtual void visit(const table_table & val);
virtual void visit(const table_table_rows& val); virtual void visit(const table_table_rows & val);
virtual void visit(const table_rows_no_group& val); virtual void visit(const table_rows_no_group & val);
virtual void visit(const table_table_row_group& val); virtual void visit(const table_table_row_group & val);
virtual void visit(const table_table_header_rows& val); virtual void visit(const table_table_header_rows& val);
virtual void visit(table_table_header_rows& val); virtual void visit(table_table_header_rows & val);
virtual void visit(table_table_rows& val); virtual void visit(table_table_rows & val);
virtual void visit(const table_table_row& val); virtual void visit(const table_table_row & val);
virtual void visit(const table_columns_no_group& val); virtual void visit(const table_columns_no_group & val);
virtual void visit(table_table_header_columns& val); virtual void visit(table_table_header_columns & val);
virtual void visit(table_table_columns& val); virtual void visit(table_table_columns & val);
virtual void visit(const table_table_column_group& val); virtual void visit(const table_table_column_group& val);
virtual void visit(const table_table_column& val); virtual void visit(const table_table_column & val);
virtual void visit(const table_table_cell& val); virtual void visit(const table_table_cell& val);
......
...@@ -184,7 +184,7 @@ double inch_to_pt(double Val) ...@@ -184,7 +184,7 @@ double inch_to_pt(double Val)
double emu_to_pt(double Val) double emu_to_pt(double Val)
{ {
return Val * 72.0 / (360000.0 * 2.54); return Val / 12700; // 1 / 12700 = 72.0 / (360000.0 * 2.54);
} }
double px_to_pt(double Val) double px_to_pt(double Val)
{ {
......
...@@ -35,12 +35,20 @@ ...@@ -35,12 +35,20 @@
#include <cpdoccore/CPOptional.h> #include <cpdoccore/CPOptional.h>
#include <cpdoccore/xml/xmlelement.h> #include <cpdoccore/xml/xmlelement.h>
#include <cpdoccore/xml/nodetype.h> #include <cpdoccore/xml/nodetype.h>
#include "office_elements.h" #include "office_elements.h"
#include "office_elements_create.h" #include "office_elements_create.h"
#include "datatypes/common_attlists.h" #include "datatypes/common_attlists.h"
#include "../docx/xlsxconversioncontext.h"
//#include "../docx/xlsxconversioncontext.h"
namespace cpdoccore { namespace cpdoccore {
namespace oox
{
class _oox_drawing;
}
typedef shared_ptr<oox::_oox_drawing>::Type oox_drawing_ptr;
namespace odf_reader { namespace odf_reader {
/// draw-image-attlist /// draw-image-attlist
...@@ -54,7 +62,6 @@ public: ...@@ -54,7 +62,6 @@ public:
}; };
class draw_image : public office_element_impl<draw_image> class draw_image : public office_element_impl<draw_image>
{ {
public: public:
...@@ -150,20 +157,17 @@ public: ...@@ -150,20 +157,17 @@ public:
static const ElementType type = typeDrawFrame; static const ElementType type = typeDrawFrame;
CPDOCCORE_DEFINE_VISITABLE(); CPDOCCORE_DEFINE_VISITABLE();
draw_frame() : oox_drawing_(NULL) {}
virtual void docx_convert(oox::docx_conversion_context & Context); virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context); virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context); virtual void pptx_convert(oox::pptx_conversion_context & Context);
virtual void pptx_convert_placeHolder(oox::pptx_conversion_context & Context); virtual void pptx_convert_placeHolder(oox::pptx_conversion_context & Context);
public:
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const; virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
private:
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);
public:
int idx_in_owner ; int idx_in_owner ;
odf_types::common_presentation_attlist common_presentation_attlist_; odf_types::common_presentation_attlist common_presentation_attlist_;
odf_types::union_common_draw_attlists common_draw_attlists_; odf_types::union_common_draw_attlists common_draw_attlists_;
...@@ -184,6 +188,13 @@ public: ...@@ -184,6 +188,13 @@ public:
friend class odf_document; friend class odf_document;
friend class draw_image; friend class draw_image;
friend class draw_chart; friend class draw_chart;
oox_drawing_ptr oox_drawing_;
private:
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);
}; };
CP_REGISTER_OFFICE_ELEMENT2(draw_frame); CP_REGISTER_OFFICE_ELEMENT2(draw_frame);
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
#include "odf_document_impl.h" #include "odf_document_impl.h"
#include "calcs_styles.h" #include "calcs_styles.h"
#include "../docx/oox_drawing.h" #include "../docx/pptx_drawing.h"
#include "chart_build_oox.h" #include "chart_build_oox.h"
#include "datatypes/length.h" #include "datatypes/length.h"
...@@ -198,14 +198,11 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context) ...@@ -198,14 +198,11 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
Context.get_text_context().start_base_style(baseStyleName ,odf_types::style_family::Presentation); Context.get_text_context().start_base_style(baseStyleName ,odf_types::style_family::Presentation);
//////////////////////////////////////////////// ////////////////////////////////////////////////
int i=0; oox_drawing_ = oox_drawing_ptr(new oox::_pptx_drawing());
int size = content_.size();
while(true) for (int i = 0; i < content_.size(); i++)
{ {
if (i>=size)break; content_[i]->pptx_convert(Context);
office_element_ptr const & elm = content_[i];
elm->pptx_convert(Context);
i++;
} }
Context.get_text_context().end_base_style(); Context.get_text_context().end_base_style();
...@@ -219,13 +216,9 @@ void draw_image::pptx_convert(oox::pptx_conversion_context & Context) ...@@ -219,13 +216,9 @@ void draw_image::pptx_convert(oox::pptx_conversion_context & Context)
////////////////////////////////////в принципе достаточно общая часть ... ////////////////////////////////////в принципе достаточно общая часть ...
Context.get_text_context().start_object(); Context.get_text_context().start_object();
int i=0; for (int i = 0; i < content_.size(); i++)
int size = content_.size();
while(true)
{ {
if (i>=size)break; content_[i]->pptx_convert(Context);
content_[i]->pptx_convert(Context);
i++;
} }
std::wstring text_content_ = Context.get_text_context().end_object(); std::wstring text_content_ = Context.get_text_context().end_object();
...@@ -241,13 +234,9 @@ void draw_chart::pptx_convert(oox::pptx_conversion_context & Context) ...@@ -241,13 +234,9 @@ void draw_chart::pptx_convert(oox::pptx_conversion_context & Context)
const std::wstring href = common_xlink_attlist_.href_.get_value_or(L""); const std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
Context.get_slide_context().start_chart(href); Context.get_slide_context().start_chart(href);
int i=0; for (int i = 0; i < content_.size(); i++)
int size = content_.size();
while(true)
{ {
if (i>=size)break; content_[i]->pptx_convert(Context);
content_[i]->pptx_convert(Context);
i++;
} }
Context.get_slide_context().end_chart(); Context.get_slide_context().end_chart();
} }
...@@ -256,14 +245,11 @@ void draw_text_box::pptx_convert(oox::pptx_conversion_context & Context) ...@@ -256,14 +245,11 @@ void draw_text_box::pptx_convert(oox::pptx_conversion_context & Context)
Context.get_slide_context().start_shape(2);//rect с наваротами Context.get_slide_context().start_shape(2);//rect с наваротами
Context.get_text_context().start_object(); Context.get_text_context().start_object();
int i=0; for (int i = 0; i < content_.size(); i++)
int size = content_.size();
while(true)
{ {
if (i>=size)break; content_[i]->pptx_convert(Context);
content_[i]->pptx_convert(Context);
i++;
} }
std::wstring text_content_ = Context.get_text_context().end_object(); std::wstring text_content_ = Context.get_text_context().end_object();
if (text_content_.length()>0) if (text_content_.length()>0)
...@@ -330,7 +316,7 @@ void draw_object::pptx_convert(oox::pptx_conversion_context & Context) ...@@ -330,7 +316,7 @@ void draw_object::pptx_convert(oox::pptx_conversion_context & Context)
std::wstring text_content_ = Context.get_text_context().end_object(); std::wstring text_content_ = Context.get_text_context().end_object();
Context.get_text_context().set_local_styles_container(NULL);//вытираем вручную ... Context.get_text_context().set_local_styles_container(NULL);//вытираем вручную ...
if (text_content_.length()>0) if (!text_content_.empty())
{ {
Context.get_slide_context().set_property(_property(L"text-content",text_content_)); Context.get_slide_context().set_property(_property(L"text-content",text_content_));
} }
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
#include "odf_document_impl.h" #include "odf_document_impl.h"
#include "calcs_styles.h" #include "calcs_styles.h"
#include "../docx/oox_drawing.h" #include "../docx/xlsx_drawing.h"
#include "chart_build_oox.h" #include "chart_build_oox.h"
#include "datatypes/length.h" #include "datatypes/length.h"
...@@ -190,6 +190,9 @@ void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -190,6 +190,9 @@ void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context)
Compute_GraphicFill(properties.common_draw_fill_attlist_, properties.style_background_image_, Compute_GraphicFill(properties.common_draw_fill_attlist_, properties.style_background_image_,
Context.root()->odf_context().drawStyles() ,fill); Context.root()->odf_context().drawStyles() ,fill);
Context.get_drawing_context().set_fill(fill); Context.get_drawing_context().set_fill(fill);
oox_drawing_ = oox_drawing_ptr(new oox::_xlsx_drawing());
//////////////////////////////////////////////// ////////////////////////////////////////////////
for (int i = 0 ; i < content_.size(); i++) for (int i = 0 ; i < content_.size(); i++)
{ {
......
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