Commit 4ea68435 authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatReader - charts - поправлены тектурные заливки. Небольшой рефакторинг.

parent f0941c0c
......@@ -269,7 +269,6 @@ SOURCES += \
../src/docx/docx_conversion_context.cpp \
../src/docx/docx_drawing.cpp \
../src/docx/docx_package.cpp \
../src/docx/docx_rels.cpp \
../src/docx/docx_table_context.cpp \
../src/docx/headers_footers.cpp \
../src/docx/hyperlinks.cpp \
......@@ -291,6 +290,7 @@ SOURCES += \
../src/docx/oox_plot_area.cpp \
../src/docx/oox_title.cpp \
../src/docx/oox_types_chart.cpp \
../src/docx/oox_rels.cpp \
../src/docx/pptx_comments.cpp \
../src/docx/pptx_comments_context.cpp \
../src/docx/pptx_conversion_context.cpp \
......@@ -517,7 +517,6 @@ HEADERS += \
../src/docx/docx_conversion_state.h \
../src/docx/docx_drawing.h \
../src/docx/docx_package.h \
../src/docx/docx_rels.h \
../src/docx/docx_table_context.h \
../src/docx/drawing_object_description.h \
../src/docx/headers_footers.h \
......@@ -542,6 +541,7 @@ HEADERS += \
../src/docx/ooxtablerowspanned.h \
../src/docx/oox_title.h \
../src/docx/oox_types_chart.h \
../src/docx/oox_rels.h \
../src/docx/pptx_comments.h \
../src/docx/pptx_comments_context.h \
../src/docx/pptx_conversion_context.h \
......
......@@ -47,7 +47,7 @@
#include "../odf/datatypes/style_ref.h"
#include "docx_package.h"
#include "docx_rels.h"
#include "oox_rels.h"
#include "logging.h"
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
......@@ -193,10 +193,9 @@ void docx_conversion_context::end_math_formula()
process_math_formula_ = false;
}
void docx_conversion_context::start_chart(std::wstring const & name)
void docx_conversion_context::start_chart(std::wstring name)
{
charts_.push_back(oox_chart_context::create(name));
charts_.push_back(oox_chart_context_ptr(new oox_chart_context(mediaitems_, name)));
}
void docx_conversion_context::end_chart()
{
......@@ -264,7 +263,7 @@ void docx_conversion_context::dump_notes(rels & Rels) const
notes_context_.dump_rels(Rels);
}
std::wstring docx_conversion_context::add_mediaitem(const std::wstring & uri, mediaitems::Type type, bool & isInternal, std::wstring & ref)
std::wstring docx_conversion_context::add_mediaitem(const std::wstring & uri, RelsType type, bool & isInternal, std::wstring & ref)
{
return mediaitems_.add_or_find(uri, type, isInternal, ref);
}
......@@ -324,6 +323,7 @@ void docx_conversion_context::end_document()
package::chart_content_ptr content = package::chart_content::create();
chart->serialize(content->content());
chart->dump_rels(content->get_rel_file()->get_rels());
output_document_->get_word_files().add_charts(content);
......
......@@ -510,7 +510,7 @@ public:
hyperlinks::_ref last_hyperlink ();
void dump_hyperlinks (rels & Rels, hyperlinks::_type_place type);
std::wstring add_mediaitem(const std::wstring & uri, mediaitems::Type type, bool & isInternal, std::wstring & ref);
std::wstring add_mediaitem(const std::wstring & uri, RelsType type, bool & isInternal, std::wstring & ref);
void dump_mediaitems (rels & Rels);
void dump_headers_footers (rels & Rels) const;
......@@ -626,7 +626,7 @@ public:
void add_note_reference();
oox_chart_context & current_chart();
void start_chart(std::wstring const & name);
void start_chart(std::wstring name);
void end_chart();
void start_comment() {process_comment_ = true;}
......@@ -645,6 +645,7 @@ public:
drop_cap_context & get_drop_cap_context(){return drop_cap_context_;}
styles_map styles_map_;
private:
std::wstringstream document_xml_;
std::wstringstream styles_xml_;
......@@ -680,9 +681,7 @@ private:
bool page_break_before_;
bool page_break_;
bool in_automatic_style_;
bool in_automatic_style_;
std::wstring text_list_style_name_;
std::list<std::wstring> list_style_stack_;
......
......@@ -350,22 +350,22 @@ void docx_serialize_common(std::wostream & strm, _docx_drawing & val)
CP_XML_ATTR(L"xmlns:a",L"http://schemas.openxmlformats.org/drawingml/2006/main");
CP_XML_NODE(L"a:graphicData")
{
if (val.type == mediaitems::typeShape)
if (val.type == typeShape)
{
CP_XML_ATTR(L"uri",L"http://schemas.microsoft.com/office/word/2010/wordprocessingShape");
docx_serialize_shape_child(CP_XML_STREAM(), val);
}
else if (val.type == mediaitems::typeImage)
else if (val.type == typeImage)
{
CP_XML_ATTR(L"uri",L"http://schemas.openxmlformats.org/drawingml/2006/picture");
docx_serialize_image_child(CP_XML_STREAM(), val);
}
else if (val.type == mediaitems::typeChart)
else if (val.type == typeChart)
{
CP_XML_ATTR(L"uri", L"http://schemas.openxmlformats.org/drawingml/2006/chart");
docx_serialize_chart_child(CP_XML_STREAM(), val);
}
else if (val.type == mediaitems::typeGroup)
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);
......@@ -376,19 +376,19 @@ void docx_serialize_common(std::wostream & strm, _docx_drawing & val)
}
void docx_serialize_child(std::wostream & strm, _docx_drawing & val)
{
if (val.type == mediaitems::typeShape)
if (val.type == typeShape)
{
docx_serialize_shape_child(strm,val);
}
else if (val.type == mediaitems::typeImage)
else if (val.type == typeImage)
{
docx_serialize_image_child(strm,val);
}
else if (val.type == mediaitems::typeChart)
else if (val.type == typeChart)
{
docx_serialize_chart_child(strm,val);
}
else if (val.type == mediaitems::typeGroup)
else if (val.type == typeGroupShape)
{
docx_serialize_group_child(strm,val);
}
......
......@@ -216,6 +216,13 @@ void docx_charts_files::write(const std::wstring & RootPath)
contentTypes->add_override(std::wstring(L"/word/charts/") + fileName, kWSConType);
package::simple_element(fileName, item->str()).write(path);
rels_files relFiles;
item->get_rel_file()->set_file_name(fileName + L".rels");
relFiles.add_rel_file(item->get_rel_file());
relFiles.write(path);
}
}
}
......
......@@ -37,7 +37,7 @@
#include <cpdoccore/CPSharedPtr.h>
#include "docx_rels.h"
#include "oox_rels.h"
#include "docx_content_type.h"
#include "oox_package.h"
......
......@@ -47,10 +47,12 @@ public:
docx_table_state(docx_conversion_context & Context, const std::wstring & StyleName);
std::wstring current_style() const { return table_style_; }
void start_column(unsigned int repeated, const std::wstring & defaultCellStyleName);
std::wstring get_default_cell_style_col(unsigned int column);
void start_column(unsigned int repeated, const std::wstring & defaultCellStyleName);
std::wstring get_default_cell_style_col(unsigned int column);
std::wstring get_default_cell_style_row();
void start_row(const std::wstring & StyleName, const std::wstring & defaultCellStyleName);
void start_row(const std::wstring & StyleName, const std::wstring & defaultCellStyleName);
void end_row();
std::wstring current_row_style() const;
......
......@@ -49,7 +49,7 @@ struct _rect
struct drawing_object_description
{
oox::mediaitems::Type type_;
oox::RelsType type_;
std::wstring name_;
_CP_OPT(_rect) svg_rect_;
......
......@@ -35,7 +35,7 @@
#include <string>
#include <boost/unordered_map.hpp>
#include "docx_rels.h"
#include "oox_rels.h"
namespace cpdoccore {
namespace odf_reader {
......
......@@ -31,7 +31,7 @@
*/
#include "hyperlinks.h"
#include "docx_rels.h"
#include "oox_rels.h"
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
......
......@@ -39,7 +39,6 @@
#include <cpdoccore/xml/utils.h>
#include "docx_rels.h"
#include "mediaitems_utils.h"
#include "../../Common/DocxFormat/Source/Base/Base.h"
......@@ -51,7 +50,7 @@ namespace oox {
mediaitems::item::item( std::wstring const & _href,
Type _type,
RelsType _type,
std::wstring const & _outputName,
bool _mediaInternal,
std::wstring const & _Id
......@@ -67,27 +66,27 @@ mediaitems::item::item( std::wstring const & _href,
count_used = 0;
}
std::wstring mediaitems::add_or_find(const std::wstring & href, Type type, bool & isInternal)
std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, bool & isInternal)
{
std::wstring ref;
return add_or_find(href, type, isInternal, ref);
}
std::wstring static get_default_file_name(mediaitems::Type type)
std::wstring static get_default_file_name(RelsType type)
{
switch (type)
{
case mediaitems::typeImage:
case typeImage:
return L"image";
case mediaitems::typeChart:
case typeChart:
return L"chart";
case mediaitems::typeMedia:
case typeMedia:
return L"media";
default:
return L"";
}
}
std::wstring mediaitems::create_file_name(const std::wstring & uri, mediaitems::Type type, size_t Num)
std::wstring mediaitems::create_file_name(const std::wstring & uri, RelsType type, size_t Num)
{
if (uri.empty()) return L"";
......@@ -126,7 +125,7 @@ std::wstring mediaitems::create_file_name(const std::wstring & uri, mediaitems::
std::wstring mediaitems::add_or_find(const std::wstring & href, Type type, bool & isInternal, std::wstring & ref)
std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, bool & isInternal, std::wstring & ref)
{
const bool isMediaInternal = utils::media::is_internal(href, odf_packet_);
......@@ -139,14 +138,10 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, Type type, bool
}
int number=0;
if ( type == typeChart)
number= count_charts+1;
else if ( type == typeImage)
number= count_image+1;
else if ( type == typeShape)
number= count_shape+1;
else if ( type == typeMedia)
number= count_media+1;
if ( type == typeChart) number= count_charts+1;
else if ( type == typeImage) number= count_image+1;
else if ( type == typeShape) number= count_shape+1;
else if ( type == typeMedia) number= count_media+1;
else
number= items_.size()+1;
......
......@@ -34,43 +34,41 @@
#include <vector>
#include <string>
#include "oox_rels.h"
namespace cpdoccore {
namespace oox {
class rels;
class mediaitems
{
public:
enum Type { typeUnknown = 0, typeImage, typeChart, typeShape, typeTable, typeHyperlink, typeComment, typeMedia, typeGroup};
mediaitems(const std::wstring & odfPacket) : odf_packet_(odfPacket)
{
count_charts =0;
count_shape =0;
count_image =0;
count_tables =0;
count_media =0;
count_charts = 0;
count_shape = 0;
count_image = 0;
count_tables = 0;
count_media = 0;
}
struct item
{
item(
std::wstring const & _href,
Type _type,
std::wstring const & _outputName,
bool _mediaInternal,
std::wstring const & _Id);
item( std::wstring const & _href,
RelsType _type,
std::wstring const & _outputName,
bool _mediaInternal,
std::wstring const & _Id);
std::wstring href;
Type type;
std::wstring outputName;
bool mediaInternal;
bool valid;
std::wstring Id;
int count_used;
int count_add;
std::wstring href;
RelsType type;
std::wstring outputName;
bool mediaInternal;
bool valid;
std::wstring Id;
int count_used;
int count_add;
};
typedef std::vector< item > items_array;
......@@ -80,14 +78,14 @@ public:
size_t count_shape;
size_t count_tables;
std::wstring add_or_find(const std::wstring & href, Type type, bool & isInternal);//возможны ссылки на один и тот же объект
std::wstring add_or_find(const std::wstring & href, Type type, bool & isInternal, std::wstring & ref);
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);
void dump_rels(rels & Rels);
items_array & items() { return items_; }
private:
std::wstring create_file_name(const std::wstring & uri, mediaitems::Type type, size_t Num);
std::wstring create_file_name(const std::wstring & uri, RelsType type, size_t Num);
items_array items_;
std::wstring odf_packet_;
......
......@@ -60,13 +60,13 @@ bool is_internal(const std::wstring & uri, const std::wstring & packetRoot)
return FileSystem::Directory::IsExist(resultPath);
}
std::wstring get_rel_type(mediaitems::Type type)
std::wstring get_rel_type(RelsType type)
{
switch (type)
{
case mediaitems::typeImage:
case typeImage:
return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image";
case mediaitems::typeChart:
case typeChart:
return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart";
default:
return L"";
......
......@@ -42,7 +42,7 @@ namespace utils {
namespace media {
bool is_internal(const std::wstring & uri, const std::wstring & packetRoot);
std::wstring get_rel_type(mediaitems::Type type);
std::wstring get_rel_type(RelsType type);
}
}
......
......@@ -35,7 +35,7 @@
#include <vector>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "mediaitems_utils.h"
#include "docx_rels.h"
#include "oox_rels.h"
#include "oox_chart_context.h"
......@@ -45,8 +45,7 @@ namespace oox {
class oox_chart_context::Impl
{
public:
Impl(){}
Impl(std::wstring const & name){}
Impl(std::wstring name){}
std::wstring name_;
std::wstringstream chartData_;
......@@ -55,26 +54,57 @@ public:
std::wstring drawingId_;
};
oox_chart_context_ptr oox_chart_context::create()
{
return boost::make_shared<oox_chart_context>();
}
oox_chart_context_ptr oox_chart_context::create(std::wstring const & name)
{
return boost::make_shared<oox_chart_context>(name);
}
oox_chart_context::oox_chart_context() : impl_(new oox_chart_context::Impl())
oox_chart_context::oox_chart_context(mediaitems & m, std::wstring name) :
impl_(new oox_chart_context::Impl( name)), mediaitems_(m)
{
}
oox_chart_context::oox_chart_context(std::wstring const & name) : impl_(new oox_chart_context::Impl(name))
void oox_chart_context::reset_fill(oox::_oox_fill &f)
{
if (f.bitmap)
{
bool isInternal = true;
std::wstring ref;
f.bitmap->rId = mediaitems_.add_or_find(f.bitmap->xlink_href_, typeImage, isInternal, ref);
rels_.push_back(_rel(isInternal, f.bitmap->rId, ref, typeImage));
}
}
std::wostream & oox_chart_context::chartData()
{
return impl_->chartData_;
}
void oox_chart_context::dump_rels(rels & Rels)
{
for (int i = 0; i < rels_.size(); i++)
{
_rel & r = rels_[i];
if (r.type == typeImage)
{
Rels.add(relationship(
r.rid,
utils::media::get_rel_type(r.type),
r.is_internal ? std::wstring(L"../") + r.ref : r.ref,
(r.is_internal ? L"" : L"External")
)
);
}
else if (r.type == typeHyperlink)
{
Rels.add(relationship(
r.rid,
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
r.ref,
L"External")
);
}
}
}
void oox_chart_context::serialize(std::wostream & strm)
{
CP_XML_WRITER(strm)
......@@ -97,9 +127,9 @@ void oox_chart_context::serialize(std::wostream & strm)
CP_XML_NODE(L"c:floor");
CP_XML_NODE(L"c:backWall");
}
title_.oox_serialize(CP_XML_STREAM());
title_.oox_serialize (CP_XML_STREAM());
plot_area_.oox_serialize(CP_XML_STREAM());
legend_.oox_serialize(CP_XML_STREAM());
legend_.oox_serialize (CP_XML_STREAM());
CP_XML_NODE(L"c:plotVisOnly")
{
......@@ -115,7 +145,7 @@ void oox_chart_context::serialize(std::wostream & strm)
}
}
oox_chart_shape shape;
shape.set(graphic_properties_, fill_);
shape.set(graphic_properties_, fill_);
shape.oox_serialize(CP_XML_STREAM());
......@@ -129,11 +159,6 @@ oox_chart_context::~oox_chart_context()
{
}
bool oox_chart_context::empty() const
{
return false;//impl_->empty();
}
void oox_chart_context::set_cache_only (bool val)
{
for (int i = 0 ; i < plot_area_.charts_.size(); i++)
......
......@@ -40,6 +40,7 @@
#include "oox_title.h"
#include "oox_plot_area.h"
#include "oox_chart_legend.h"
#include "oox_rels.h"
namespace cpdoccore {
namespace oox {
......@@ -49,22 +50,19 @@ class oox_chart_context;
typedef _CP_PTR(oox_chart_context) oox_chart_context_ptr;
class oox_chart_context/*: noncopyable*/
class oox_chart_context
{
public:
oox_chart_context();
oox_chart_context(std::wstring const & name);
oox_chart_context(mediaitems & mediaitems_, std::wstring name);
~oox_chart_context();
std::wostream & chartData();
bool empty() const;
void reset_fill(oox::_oox_fill &fill_);
void serialize(std::wostream & strm);
void dump_rels(rels & Rels);
static oox_chart_context_ptr create(std::wstring const & name);
static oox_chart_context_ptr create();
void set_title(odf_reader::chart::title & t)
{
title_.set_content(t);
......@@ -91,26 +89,31 @@ public:
}
void set_wall(odf_reader::chart::simple & l)
{
reset_fill(l.fill_);
//plot_area_.wall_graphic_properties_ = l.graphic_properties_;
plot_area_.graphic_properties_ = l.graphic_properties_;
plot_area_.fill_ = l.fill_;
}
void set_floor(odf_reader::chart::simple & l)
{
reset_fill(l.fill_);
//floor_.content_= l;
}
void set_legend(odf_reader::chart::simple & l)
{
reset_fill(l.fill_);
legend_.content_= l;
}
void set_chart_graphic_properties(std::vector<odf_reader::_property> & prop, _oox_fill &fill)
{
reset_fill(fill);
graphic_properties_= prop;
fill_ = fill;
}
void set_plot_area_properties(std::vector<odf_reader::_property> & prop, _oox_fill &fill)
{
reset_fill(fill);
plot_area_.properties_ = prop;
plot_area_.fill_ = fill;
}
......@@ -120,13 +123,15 @@ private:
class Impl;
_CP_SCOPED_PTR(Impl) impl_;
mediaitems &mediaitems_;
std::vector<_rel> rels_;
cpdoccore::oox::oox_title title_;
cpdoccore::oox::oox_plot_area plot_area_;
cpdoccore::oox::oox_chart_legend legend_;
std::vector<odf_reader::_property> graphic_properties_;
_oox_fill fill_;
};
//autoTitleDeleted (Auto Title Is Deleted) §21.2.2.7
//backWall (Back Wall) §21.2.2.11
......
......@@ -40,16 +40,14 @@
namespace cpdoccore {
namespace oox {
void oox_chart_shape::oox_serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE(L"c:spPr")
{
oox_serialize_fill(CP_XML_STREAM(),fill_);
oox_serialize_ln(CP_XML_STREAM(),content_);
oox_serialize_fill(CP_XML_STREAM(), fill_);
oox_serialize_ln(CP_XML_STREAM(), content_);
}
}
......
......@@ -43,46 +43,18 @@ namespace oox {
void oox_serialize_default_text(std::wostream & _Wostream, std::vector<odf_reader::_property>& properties);
class oox_chart_shape: boost::noncopyable
class oox_chart_shape : boost::noncopyable
{
public:
oox_chart_shape(){}
~oox_chart_shape(){}
void set(std::vector<odf_reader::_property> & prop,_oox_fill & fill);
void set(std::vector<odf_reader::_property> & prop,_oox_fill & fill);
void oox_serialize(std::wostream & _Wostream);
private:
std::vector<odf_reader::_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
//friend void xlsx_serialize(std::wostream & _Wostream, const oox_chart_shape & legend_);
//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
//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
//xfrm (2D Transform for Individual Objects) §20.1.7.6
};
}
......
......@@ -462,7 +462,7 @@ void oox_serialize_xfrm(std::wostream & strm, _oox_drawing & val, const std::wst
_CP_LOG << L"[error!!!] not set size object\n";
}
if (val.type == mediaitems::typeGroup)
if (val.type == typeGroupShape)
{
CP_XML_NODE(L"a:chOff")
{
......
......@@ -69,10 +69,10 @@ namespace oox {
};
struct _oox_drawing
{
_oox_drawing() : type(mediaitems::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")
{
}
mediaitems::Type type;
RelsType type;
bool inGroup;
size_t id;
......
......@@ -121,7 +121,7 @@ void content_types_file::set_media(mediaitems & _Mediaitems)
{
BOOST_FOREACH( mediaitems::item & item, _Mediaitems.items() )
{
if ((item.type == mediaitems::typeImage || item.type == mediaitems::typeMedia) && item.mediaInternal)
if ((item.type == typeImage || item.type == typeMedia) && item.mediaInternal)
{
int n = item.outputName.rfind(L".");
if (n > 0)
......@@ -282,7 +282,7 @@ void media::write(const std::wstring & RootPath)
BOOST_FOREACH( mediaitems::item & item, mediaitems_.items() )
{
if (item.mediaInternal && item.valid && item.type == mediaitems::typeImage )
if (item.mediaInternal && item.valid && item.type == typeImage )
{
std::wstring & file_name = item.href;
std::wstring file_name_out = RootPath + FILE_SEPARATOR_STR + item.outputName;
......
......@@ -37,7 +37,7 @@
#include <cpdoccore/CPNoncopyable.h>
#include "docx_content_type.h"
#include "docx_rels.h"
#include "oox_rels.h"
#include "../../../Common/DocxFormat/Source/Base/Base.h"
#include "../../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h"
......
/*
* (c) Copyright Ascensio System SIA 2010-2016
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "docx_rels.h"
#include <cpdoccore/xml/attributes.h>
#include <boost/foreach.hpp>
#include "namespaces.h"
#include <cpdoccore/xml/simple_xml_writer.h>
namespace cpdoccore {
namespace oox {
const wchar_t * relationship::ns = L"";
const wchar_t * relationship::name = L"Relationship";
::std::wostream & relationship::xml_to_stream(::std::wostream & _Wostream) const
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE(L"Relationship")
{
CP_XML_ATTR(L"Id", id());
CP_XML_ATTR(L"Type", type());
CP_XML_ATTR(L"Target", target());
if (!target_mode().empty())
CP_XML_ATTR(L"TargetMode", target_mode());
}
}
//_Wostream << L"<Relationship ";
//CP_XML_SERIALIZE_ATTR(L"Id", id());
//CP_XML_SERIALIZE_ATTR(L"Type", type());
//CP_XML_SERIALIZE_ATTR(L"Target", target());
//
//if (!target_mode().empty())
//{
// CP_XML_SERIALIZE_ATTR(L"TargetMode", target_mode());
//}
//_Wostream << L" />";
return _Wostream;
}
const wchar_t * rels::ns = L"";
const wchar_t * rels::name = L"Relationships";
::std::wostream & rels::xml_to_stream(::std::wostream & _Wostream) const
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE(L"Relationships")
{
CP_XML_ATTR(L"xmlns", xmlns::rels.value);
BOOST_FOREACH(const relationship & r, relationship_)
{
r.xml_to_stream(CP_XML_STREAM());
}
} // "Relationships"
}
//_Wostream << L"<Relationships ";
//CP_XML_SERIALIZE_ATTR(L"xmlns", xmlns::rels.value);
//_Wostream << L">";
//BOOST_FOREACH(const relationship & r, relationship_)
//{
// r.xml_to_stream(_Wostream);
//}
//_Wostream << L"</Relationships>";
return _Wostream;
}
void rels::add(relationship const & r)
{
relationships().push_back(r);
}
}
}
/*
* (c) Copyright Ascensio System SIA 2010-2016
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "oox_rels.h"
#include <cpdoccore/xml/attributes.h>
#include <boost/foreach.hpp>
#include "namespaces.h"
#include <cpdoccore/xml/simple_xml_writer.h>
namespace cpdoccore {
namespace oox {
const wchar_t * relationship::ns = L"";
const wchar_t * relationship::name = L"Relationship";
::std::wostream & relationship::xml_to_stream(::std::wostream & _Wostream) const
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE(L"Relationship")
{
CP_XML_ATTR(L"Id", id());
CP_XML_ATTR(L"Type", type());
CP_XML_ATTR(L"Target", target());
if (!target_mode().empty())
CP_XML_ATTR(L"TargetMode", target_mode());
}
}
//_Wostream << L"<Relationship ";
//CP_XML_SERIALIZE_ATTR(L"Id", id());
//CP_XML_SERIALIZE_ATTR(L"Type", type());
//CP_XML_SERIALIZE_ATTR(L"Target", target());
//
//if (!target_mode().empty())
//{
// CP_XML_SERIALIZE_ATTR(L"TargetMode", target_mode());
//}
//_Wostream << L" />";
return _Wostream;
}
const wchar_t * rels::ns = L"";
const wchar_t * rels::name = L"Relationships";
::std::wostream & rels::xml_to_stream(::std::wostream & _Wostream) const
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE(L"Relationships")
{
CP_XML_ATTR(L"xmlns", xmlns::rels.value);
BOOST_FOREACH(const relationship & r, relationship_)
{
r.xml_to_stream(CP_XML_STREAM());
}
} // "Relationships"
}
//_Wostream << L"<Relationships ";
//CP_XML_SERIALIZE_ATTR(L"xmlns", xmlns::rels.value);
//_Wostream << L">";
//BOOST_FOREACH(const relationship & r, relationship_)
//{
// r.xml_to_stream(_Wostream);
//}
//_Wostream << L"</Relationships>";
return _Wostream;
}
void rels::add(relationship const & r)
{
relationships().push_back(r);
}
}
}
/*
* (c) Copyright Ascensio System SIA 2010-2016
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include <string>
#include <vector>
#include <iosfwd>
#include <cpdoccore/xml/xmlelement.h>
#include <cpdoccore/CPSharedPtr.h>
namespace cpdoccore {
namespace oox {
class relationship : public xml::element_impl<relationship>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
public:
relationship() {}
relationship(const std::wstring & Id,
const std::wstring & Type,
const std::wstring & Target,
const std::wstring & TargetMode = L"") : id_(Id), type_(Type), target_(Target), target_mode_(TargetMode)
{}
virtual ::std::wostream & xml_to_stream(::std::wostream & _Wostream) const;
public:
const std::wstring & id() const { return id_; }
const std::wstring & type() const { return type_; }
const std::wstring & target() const { return target_; }
const std::wstring & target_mode() const { return target_mode_; }
private:
std::wstring id_;
std::wstring type_;
std::wstring target_;
std::wstring target_mode_;
};
class rels;
typedef _CP_PTR(rels) rels_ptr;
// rels
class rels : public xml::element_impl<rels>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
public:
virtual ::std::wostream & xml_to_stream(::std::wostream & _Wostream) const;
std::vector<relationship> & relationships() { return relationship_; }
void add(relationship const & r);
bool empty() { return relationship_.empty(); }
private:
std::vector<relationship> relationship_;
};
}
}
/*
* (c) Copyright Ascensio System SIA 2010-2016
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include <string>
#include <vector>
#include <iosfwd>
#include <cpdoccore/xml/xmlelement.h>
#include <cpdoccore/CPSharedPtr.h>
namespace cpdoccore {
namespace oox {
enum RelsType { typeUnknown = 0, typeImage, typeChart, typeShape, typeTable, typeHyperlink, typeComment, typeMedia, typeGroupShape};
struct _rel
{
_rel(bool is_internal_, std::wstring const & rid_, std::wstring const & ref_, RelsType const & type_) :
is_internal(is_internal_),
rid(rid_),
ref(ref_),
type(type_)
{}
bool is_internal;
std::wstring rid;
std::wstring ref;
RelsType type;
};
class relationship : public xml::element_impl<relationship>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
relationship() {}
relationship(const std::wstring & Id,
const std::wstring & Type,
const std::wstring & Target,
const std::wstring & TargetMode = L"") : id_(Id), type_(Type), target_(Target), target_mode_(TargetMode)
{}
virtual ::std::wostream & xml_to_stream(::std::wostream & _Wostream) const;
const std::wstring & id() const { return id_; }
const std::wstring & type() const { return type_; }
const std::wstring & target() const { return target_; }
const std::wstring & target_mode() const { return target_mode_; }
private:
std::wstring id_;
std::wstring type_;
std::wstring target_;
std::wstring target_mode_;
};
class rels;
typedef _CP_PTR(rels) rels_ptr;
// rels
class rels : public xml::element_impl<rels>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
public:
virtual ::std::wostream & xml_to_stream(::std::wostream & _Wostream) const;
std::vector<relationship> & relationships() { return relationship_; }
void add(relationship const & r);
bool empty() { return relationship_.empty(); }
private:
std::vector<relationship> relationship_;
};
}
}
......@@ -34,7 +34,7 @@
#include <boost/foreach.hpp>
#include <vector>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "docx_rels.h"
#include "oox_rels.h"
namespace cpdoccore {
namespace oox {
......
......@@ -90,21 +90,6 @@ void pptx_conversion_context::set_font_directory(std::wstring pathFonts)
if (applicationFonts_ )
applicationFonts_->InitializeFromFolder(pathFonts);
}
//
//void pptx_conversion_context::start_chart(std::wstring const & name)
//{
// charts_.push_back(oox_chart_context::create(name));
// //добавляем новую форму для диаграммы
// //в ней будет информационная часть - и она пишется каждый раз в свою xml (их - по числу диаграмм)
// //этот контекст нужно передавать в файл
//
//}
//
//void pptx_conversion_context::end_chart()
//{
// //current_chart().set_drawing_link(current_sheet().get_drawing_link());
// //излишняя инфа
//}
void pptx_conversion_context::process_layouts()
{
......@@ -299,6 +284,7 @@ void pptx_conversion_context::end_document()
package::chart_content_ptr content = package::chart_content::create();
chart->serialize(content->content());
chart->dump_rels(content->get_rel_file()->get_rels());
output_document_->get_ppt_files().add_charts(content);
......@@ -523,7 +509,7 @@ void pptx_conversion_context::end_page()
const std::pair<std::wstring, std::wstring> commentsName =
comments_context_handle_.add_comments_xml(strm.str(), get_comments_context().get_comments() );
get_slide_context().add_rels(false, commentsName.second, L"../comments/" + commentsName.first,mediaitems::typeComment);
get_slide_context().add_rels(false, commentsName.second, L"../comments/" + commentsName.first, typeComment);
}
get_slide_context().serialize_background(current_slide().Background());
......@@ -578,9 +564,9 @@ void pptx_conversion_context::start_office_presentation()
void pptx_conversion_context::end_office_presentation()
{
}
void pptx_conversion_context::start_chart(std::wstring const & name)
void pptx_conversion_context::start_chart(std::wstring name)
{
charts_.push_back(oox_chart_context::create(name));
charts_.push_back(oox_chart_context_ptr(new oox_chart_context(get_mediaitems(), name)));
//добавляем новую форму для диаграммы
//в ней будет информационная часть - и она пишется каждый раз в свою xml (их - по числу диаграмм)
//этот контекст нужно передавать в файл
......
......@@ -73,7 +73,7 @@ public:
void start_document();
void end_document();
void start_chart(std::wstring const & name);
void start_chart(std::wstring name);
void end_chart();
void start_body();
......
......@@ -260,19 +260,19 @@ void pptx_serialize_table(std::wostream & strm, _pptx_drawing & val)
void pptx_serialize(std::wostream & strm, _pptx_drawing & val)
{
if (val.type == mediaitems::typeShape)
if (val.type == typeShape)
{
pptx_serialize_shape(strm,val);
}
else if (val.type == mediaitems::typeImage)
else if (val.type == typeImage)
{
pptx_serialize_image(strm,val);
}
else if (val.type == mediaitems::typeChart)
else if (val.type == typeChart)
{
pptx_serialize_chart(strm,val);
}
else if (val.type == mediaitems::typeTable)
else if (val.type == typeTable)
{
pptx_serialize_table(strm,val);
}
......
......@@ -30,12 +30,12 @@
*
*/
#include <boost/foreach.hpp>
#include <vector>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "mediaitems_utils.h"
#include "docx_rels.h"
#include "oox_rels.h"
#include "pptx_drawings.h"
#include "pptx_drawing.h"
......@@ -45,43 +45,30 @@ namespace oox {
class pptx_drawings::Impl
{
struct rel_
{
rel_(bool is_internal, std::wstring const & rid, std::wstring const & ref, mediaitems::Type type) :
is_internal_(is_internal),
rid_(rid),
ref_(ref),
type_(type)
{}
bool is_internal_;
std::wstring rid_;
std::wstring ref_;
mediaitems::Type type_;
};
public:
void add(_pptx_drawing const & d,
bool isInternal,
std::wstring const & rid,
std::wstring const & ref,
mediaitems::Type type)
RelsType type)
{
pptx_drawings_.push_back(d);
bool present = false;
BOOST_FOREACH(rel_ const & r, pptx_drawing_rels_)
BOOST_FOREACH(_rel const & r, pptx_drawing_rels_)
{
if (r.rid_ == rid && r.ref_ == ref)
if (r.rid == rid && r.ref == ref)
present = true;
}
if (!present)
{
pptx_drawing_rels_.push_back(rel_(isInternal, rid, ref, type));
pptx_drawing_rels_.push_back(_rel(isInternal, rid, ref, type));
}
BOOST_FOREACH(_hlink_desc h, d.hlinks)
{
pptx_drawing_rels_.push_back(rel_(false, h.hId, h.hRef, mediaitems::typeHyperlink));
pptx_drawing_rels_.push_back(_rel(false, h.hId, h.hRef, typeHyperlink));
}
}
......@@ -89,18 +76,18 @@ public:
bool isInternal,
std::wstring const & rid,
std::wstring const & ref,
mediaitems::Type type)
RelsType type)
{
bool present = false;
BOOST_FOREACH(rel_ const & r, pptx_drawing_rels_)
BOOST_FOREACH(_rel const & r, pptx_drawing_rels_)
{
if (r.rid_ == rid && r.ref_ == ref)
if (r.rid == rid && r.ref == ref)
present = true;
}
if (!present)
{
pptx_drawing_rels_.push_back(rel_(isInternal, rid, ref, type));
pptx_drawing_rels_.push_back(_rel(isInternal, rid, ref, type));
}
}
void serialize(std::wostream & strm)
......@@ -118,43 +105,43 @@ public:
void dump_rels(rels & Rels)
{
BOOST_FOREACH(rel_ const & r, pptx_drawing_rels_)
BOOST_FOREACH(_rel const & r, pptx_drawing_rels_)
{
if (r.type_ == mediaitems::typeChart)//временно - нужно потом все загнать в релс
if (r.type == typeChart)//временно - нужно потом все загнать в релс
{
Rels.add(relationship(
r.rid_,
utils::media::get_rel_type(r.type_),
(r.is_internal_ ? std::wstring(L"../") + r.ref_ : r.ref_),
(r.is_internal_ ? L"" : L"External")
r.rid,
utils::media::get_rel_type(r.type),
(r.is_internal ? std::wstring(L"../") + r.ref : r.ref),
(r.is_internal ? L"" : L"External")
)
);
}
else if (r.type_ == mediaitems::typeImage)
else if (r.type == typeImage)
{
Rels.add(relationship(
r.rid_,
utils::media::get_rel_type(r.type_),
r.is_internal_ ? std::wstring(L"../") + r.ref_ : r.ref_,
(r.is_internal_ ? L"" : L"External")
r.rid,
utils::media::get_rel_type(r.type),
r.is_internal ? std::wstring(L"../") + r.ref : r.ref,
(r.is_internal ? L"" : L"External")
)
);
}
else if (r.type_ == mediaitems::typeHyperlink)
else if (r.type == typeHyperlink)
{
Rels.add(relationship(
r.rid_,
r.rid,
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
r.ref_,
r.ref,
L"External")
);
}
else if (r.type_ == mediaitems::typeComment)
else if (r.type == typeComment)
{
Rels.add(relationship(
r.rid_,
r.rid,
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",
r.ref_)
r.ref)
);
}
}
......@@ -162,9 +149,8 @@ public:
private:
std::vector<_pptx_drawing> pptx_drawings_;
std::vector<rel_> pptx_drawing_rels_;
std::vector<_pptx_drawing> pptx_drawings_;
std::vector<_rel> pptx_drawing_rels_;
};
pptx_drawings::pptx_drawings() : impl_( new pptx_drawings::Impl() )
......@@ -179,7 +165,7 @@ void pptx_drawings::add(_pptx_drawing const & d,
bool isInternal,
std::wstring const & rid,
std::wstring const & ref,
mediaitems::Type type)
RelsType type)
{
impl_->add(d, isInternal, rid, ref, type);
}
......@@ -187,7 +173,7 @@ void pptx_drawings::add(/**/
bool isInternal,
std::wstring const & rid,
std::wstring const & ref,
mediaitems::Type type)
RelsType type)
{
impl_->add(isInternal, rid, ref, type);
}
......
......@@ -57,13 +57,13 @@ public:
bool isInternal,
std::wstring const & rid,
std::wstring const & ref,
mediaitems::Type type
RelsType type
);
void add(/**/
bool isInternal,
std::wstring const & rid,
std::wstring const & ref,
mediaitems::Type type
RelsType type
);
bool empty() const;
......
......@@ -36,7 +36,7 @@
#include <cpdoccore/CPScopedPtr.h>
#include <cpdoccore/CPNoncopyable.h>
#include "docx_rels.h"
#include "oox_rels.h"
namespace cpdoccore {
namespace oox {
......
......@@ -284,6 +284,13 @@ void ppt_charts_files::write(const std::wstring & RootPath)
contentTypes->add_override(std::wstring(L"/ppt/charts/") + fileName, kWSConType);
package::simple_element(fileName, item->str()).write(path);
rels_files relFiles;
item->get_rel_file()->set_file_name(fileName + L".rels");
relFiles.add_rel_file(item->get_rel_file());
relFiles.write(path);
}
}
}
......
......@@ -90,7 +90,7 @@ public:
bool isInternal,
std::wstring const & rid,
std::wstring const & ref,
mediaitems::Type type)
RelsType type)
{
pptx_drawings_->add(d, isInternal, rid, ref, type);
}
......@@ -98,7 +98,7 @@ public:
bool isInternal,
std::wstring const & rid,
std::wstring const & ref,
mediaitems::Type type)
RelsType type)
{
pptx_drawings_->add(isInternal, rid, ref, type);
}
......@@ -322,8 +322,8 @@ void pptx_slide_context::add_background(_oox_fill & fill)
bool isMediaInternal = false;
std::wstring ref;
fill.bitmap->rId = get_mediaitems().add_or_find(fill.bitmap->xlink_href_, oox::mediaitems::typeImage, isMediaInternal, ref);
add_rels(isMediaInternal, fill.bitmap->rId, ref, oox::mediaitems::typeImage);
fill.bitmap->rId = get_mediaitems().add_or_find(fill.bitmap->xlink_href_, typeImage, isMediaInternal, ref);
add_rels(isMediaInternal, fill.bitmap->rId, ref, typeImage);
}
impl_->background_fill_ = fill;
......@@ -337,19 +337,19 @@ void pptx_slide_context::set_name(std::wstring const & name)
void pptx_slide_context::start_shape(int type)
{
impl_->object_description_.type_ = mediaitems::typeShape;
impl_->object_description_.type_ = typeShape;
impl_->object_description_.shape_type_ = type; //2,3...
}
void pptx_slide_context::start_image(std::wstring const & path)
{
impl_->object_description_.type_ = mediaitems::typeImage;
impl_->object_description_.type_ = typeImage;
impl_->object_description_.xlink_href_ = path;
}
void pptx_slide_context::start_table()
{
impl_->object_description_.type_ = mediaitems::typeTable;
impl_->object_description_.type_ = typeTable;
}
void pptx_slide_context::set_use_image_replacement()
......@@ -363,7 +363,7 @@ void pptx_slide_context::start_object_ole()
void pptx_slide_context::start_chart(std::wstring const & path)
{
impl_->object_description_.type_ = mediaitems::typeChart;
impl_->object_description_.type_ = typeChart;
impl_->object_description_.xlink_href_ = path;
}
void pptx_slide_context::end_object_ole()
......@@ -431,8 +431,8 @@ void pptx_slide_context::process_images()
GetProperty(pic.additional_,L"text-content",sTextContent);
if (sTextContent)//в ms office на картинке нельзя сделать надпись - меняем тип на рект с заливкой картинкой
{
drawing.type = mediaitems::typeShape;
drawing.sub_type = 2;//rect
drawing.type = typeShape;
drawing.sub_type = 2;//rect
}
......@@ -444,15 +444,15 @@ void pptx_slide_context::process_images()
std::wstring ref;/// это ссылка на выходной внешний объект
bool isMediaInternal = false;
drawing.fill.bitmap->rId = impl_->get_mediaitems().add_or_find(pic.xlink_href_, mediaitems::typeImage, isMediaInternal, ref);
drawing.fill.bitmap->rId = impl_->get_mediaitems().add_or_find(pic.xlink_href_, typeImage, isMediaInternal, ref);
if (drawing.type == mediaitems::typeShape)
if (drawing.type == typeShape)
{
impl_->add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, mediaitems::typeImage);//собственно это не объект, а доп рел и ref объекта
impl_->add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);//собственно это не объект, а доп рел и ref объекта
isMediaInternal=true;
std::wstring rId = impl_->get_mediaitems().add_or_find(L"", mediaitems::typeShape, isMediaInternal, ref);
impl_->add_drawing(drawing, isMediaInternal, rId, ref, mediaitems::typeShape);//объект
isMediaInternal = true;
std::wstring rId = impl_->get_mediaitems().add_or_find(L"", typeShape, isMediaInternal, ref);
impl_->add_drawing(drawing, isMediaInternal, rId, ref, typeShape);//объект
}else
{
......@@ -477,8 +477,8 @@ void pptx_slide_context::process_charts()
////////////////////////////////////////////////////////////////
std::wstring ref;
bool isMediaInternal = true;
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);
drawing.chartId = impl_->get_mediaitems().add_or_find(pic.xlink_href_, typeChart, isMediaInternal, ref);
impl_->add_drawing(drawing, isMediaInternal, drawing.chartId, ref, typeChart);
}
}
......@@ -499,8 +499,8 @@ void pptx_slide_context::process_tables()
////////////////////////////////////////////////////////////////
std::wstring ref;
bool isMediaInternal = true;
std::wstring rId = impl_->get_mediaitems().add_or_find(L"", mediaitems::typeTable, isMediaInternal, ref);
impl_->add_drawing(drawing, isMediaInternal, rId, ref, mediaitems::typeTable);
std::wstring rId = impl_->get_mediaitems().add_or_find(L"", typeTable, isMediaInternal, ref);
impl_->add_drawing(drawing, isMediaInternal, rId, ref, typeTable);
}
}
......@@ -547,11 +547,11 @@ void pptx_slide_context::process_shapes()
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_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, mediaitems::typeImage);
drawing.fill.bitmap->rId = impl_->get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal, ref);
impl_->add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);
}
std::wstring rId = impl_->get_mediaitems().add_or_find(L"", mediaitems::typeShape, isMediaInternal, ref);
std::wstring rId = impl_->get_mediaitems().add_or_find(L"", typeShape, isMediaInternal, ref);
////////////////////////////////////////////////////////////////
_CP_OPT(std::wstring) sPlaceHolderType;
......@@ -567,7 +567,7 @@ void pptx_slide_context::process_shapes()
drawing.sub_type = pic.type_;
impl_->add_drawing(drawing, isMediaInternal, rId, ref, mediaitems::typeShape);
impl_->add_drawing(drawing, isMediaInternal, rId, ref, typeShape);
}
}
......@@ -581,7 +581,7 @@ mediaitems & pptx_slide_context::get_mediaitems()
return impl_->get_mediaitems();
}
void pptx_slide_context::add_rels( bool isInternal, std::wstring const & rid, std::wstring const & ref, mediaitems::Type type)
void pptx_slide_context::add_rels( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type)
{
impl_->add_additional_rels(isInternal, rid, ref, type);
}
......
......@@ -113,7 +113,7 @@ public:
void add_rels( bool isInternal,
std::wstring const & rid,
std::wstring const & ref,
mediaitems::Type type);
RelsType type);
void set_footer();
void set_header();
......
......@@ -378,8 +378,8 @@ void oox_serialize_tcPr(std::wostream & strm, std::vector<const odf_reader::styl
{
bool isMediaInternal = false;
std::wstring ref;
fill.bitmap->rId = Context.get_slide_context().get_mediaitems().add_or_find(fill.bitmap->xlink_href_, oox::mediaitems::typeImage, isMediaInternal, ref);
Context.get_slide_context().add_rels(isMediaInternal,fill.bitmap->rId, ref, oox::mediaitems::typeImage);
fill.bitmap->rId = Context.get_slide_context().get_mediaitems().add_or_find(fill.bitmap->xlink_href_, oox::typeImage, isMediaInternal, ref);
Context.get_slide_context().add_rels(isMediaInternal, fill.bitmap->rId, ref, oox::typeImage);
}
oox::oox_serialize_fill(CP_XML_STREAM(), fill);
/////////////////////////////////////////////////////////////////////////////////
......
......@@ -76,18 +76,18 @@ public:
void start_paragraph(const std::wstring & styleName);
void end_paragraph();
void start_span(const std::wstring & styleName);
void end_span();
std::wstring end_span2();
void start_span(const std::wstring & styleName);
void end_span();
std::wstring end_span2();
void start_comment_content();
std::wstring end_comment_content();
void start_comment_content();
std::wstring end_comment_content();
void start_base_style(const std::wstring baseStyleName, const odf_types::style_family::type baseStyleType);
void end_base_style();
void start_object();
std::wstring end_object();
void start_object();
std::wstring end_object();
void start_hyperlink();
void end_hyperlink(std::wstring hId);
......
......@@ -31,7 +31,7 @@
*/
#include "xlsx_comments.h"
#include "docx_rels.h"
#include "oox_rels.h"
#include <vector>
#include <cpdoccore/xml/simple_xml_writer.h>
......
......@@ -36,13 +36,9 @@
#include "../odf/datatypes/custom_shape_types_convert.h"
namespace cpdoccore {
namespace oox {
namespace {
std::wostream & operator << (std::wostream & strm, xlsx_drawing_position::type_t t)
......@@ -248,19 +244,19 @@ void xlsx_serialize_chart(std::wostream & strm, _xlsx_drawing & val)
}
void xlsx_serialize_object(std::wostream & strm, _xlsx_drawing & val)
{
if (val.type == mediaitems::typeShape)
if (val.type == typeShape)
{
xlsx_serialize_shape(strm, val);
}
else if (val.type == mediaitems::typeImage)
else if (val.type == typeImage)
{
xlsx_serialize_image(strm, val);
}
else if (val.type == mediaitems::typeChart)
else if (val.type == typeChart)
{
xlsx_serialize_chart(strm, val);
}
else if (val.type == mediaitems::typeGroup)
else if (val.type == typeGroupShape)
{
xlsx_serialize_group(strm, val);
}
......
......@@ -158,7 +158,7 @@ xlsx_drawing_context::xlsx_drawing_context(xlsx_drawing_context_handle & h)
void xlsx_drawing_context::clear()
{
impl_->object_description_.type_ = mediaitems::typeUnknown;
impl_->object_description_.type_ = typeUnknown;
impl_->object_description_.in_group_ = false;
impl_->object_description_.xlink_href_ = L"";
impl_->object_description_.name_ = L"";
......@@ -183,7 +183,7 @@ void xlsx_drawing_context::start_group(std::wstring const & name)
{
start_drawing(name);
impl_->object_description_.type_ = mediaitems::typeGroup;
impl_->object_description_.type_ = typeGroupShape;
impl_->object_description_.svg_rect_ = _rect();
impl_->object_description_.svg_rect_->x = impl_->object_description_.svg_rect_->y = 0x7fffffff;
......@@ -263,7 +263,7 @@ void xlsx_drawing_context::end_drawing()
void xlsx_drawing_context::start_shape(int type)
{
impl_->object_description_.type_ = mediaitems::typeShape;
impl_->object_description_.type_ = typeShape;
impl_->object_description_.shape_type_ = type; //2,3...
}
......@@ -282,7 +282,7 @@ void xlsx_drawing_context::end_object_ole()
void xlsx_drawing_context::start_image(std::wstring const & path)
{
impl_->object_description_.type_ = mediaitems::typeImage;
impl_->object_description_.type_ = typeImage;
impl_->object_description_.xlink_href_ = path;
}
void xlsx_drawing_context::end_image()
......@@ -291,7 +291,7 @@ void xlsx_drawing_context::end_image()
}
void xlsx_drawing_context::start_chart(std::wstring const & path)
{
impl_->object_description_.type_ = mediaitems::typeChart;
impl_->object_description_.type_ = typeChart;
impl_->object_description_.xlink_href_ = path;
}
void xlsx_drawing_context::end_chart()
......@@ -496,7 +496,7 @@ void xlsx_drawing_context::process_image(drawing_object_description & obj,_xlsx_
if (sTextContent)//в ms office на картинке нельзя сделать надпись - меняем тип на рект с заливкой картинкой
{
drawing.type = mediaitems::typeShape;
drawing.type = typeShape;
drawing.sub_type = 2;//rect
}
std::wstring fileName = odf_packet_path_ + FILE_SEPARATOR_STR + obj.xlink_href_;
......@@ -507,20 +507,20 @@ void xlsx_drawing_context::process_image(drawing_object_description & obj,_xlsx_
std::wstring ref;/// это ссылка на выходной внешний объект
bool isMediaInternal = false;
drawing.fill.bitmap->rId = impl_->get_mediaitems().add_or_find(obj.xlink_href_, mediaitems::typeImage, isMediaInternal, ref);
drawing.fill.bitmap->rId = impl_->get_mediaitems().add_or_find(obj.xlink_href_, typeImage, isMediaInternal, ref);
if (drawing.type == mediaitems::typeShape)
if (drawing.type == typeShape)
{
impl_->get_drawings()->add(isMediaInternal, drawing.fill.bitmap->rId, ref, mediaitems::typeImage);//собственно это не объект, а доп рел и ref объекта
impl_->get_drawings()->add(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);//собственно это не объект, а доп рел и ref объекта
isMediaInternal=true;
std::wstring rId = impl_->get_mediaitems().add_or_find(L"", mediaitems::typeShape, isMediaInternal, ref);
std::wstring rId = impl_->get_mediaitems().add_or_find(L"", typeShape, isMediaInternal, ref);
xlsx_drawings_->add(drawing, isMediaInternal, rId, ref, mediaitems::typeShape);//объект
xlsx_drawings_->add(drawing, isMediaInternal, rId, ref, typeShape);//объект
}else
{
xlsx_drawings_->add(drawing, isMediaInternal, drawing.fill.bitmap->rId , ref, mediaitems::typeImage);//объект
xlsx_drawings_->add(drawing, isMediaInternal, drawing.fill.bitmap->rId , ref, typeImage);//объект
if (drawing.inGroup)
impl_->get_drawings()->add(isMediaInternal, drawing.fill.bitmap->rId, ref, obj.type_); // не объект
......@@ -596,18 +596,18 @@ void xlsx_drawing_context::process_objects(std::vector<drawing_object_descriptio
std::wstring ref;
bool isMediaInternal = true;
drawing.fill.bitmap->rId = impl_->get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, mediaitems::typeImage, isMediaInternal, ref);
impl_->get_drawings()->add(isMediaInternal, drawing.fill.bitmap->rId, ref, mediaitems::typeImage);//собственно это не объект, а доп рел и ref объекта
drawing.fill.bitmap->rId = impl_->get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal, ref);
impl_->get_drawings()->add(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);//собственно это не объект, а доп рел и ref объекта
}
process_common_properties(obj, drawing, table_metrics);
switch(obj.type_)
{
case mediaitems::typeChart: process_chart ( obj, drawing, xlsx_drawings_); break;
case mediaitems::typeImage: process_image ( obj, drawing, xlsx_drawings_); break;
case mediaitems::typeShape: process_shape ( obj, drawing, xlsx_drawings_); break;
case mediaitems::typeGroup: process_group ( obj, table_metrics, drawing, xlsx_drawings_); break;
case typeChart: process_chart ( obj, drawing, xlsx_drawings_); break;
case typeImage: process_image ( obj, drawing, xlsx_drawings_); break;
case typeShape: process_shape ( obj, drawing, xlsx_drawings_); break;
case typeGroupShape: process_group ( obj, table_metrics, drawing, xlsx_drawings_); break;
}
}
}
......
......@@ -32,63 +32,50 @@
#include "xlsx_drawings.h"
#include "xlsx_drawing.h"
#include <boost/foreach.hpp>
#include <vector>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "mediaitems_utils.h"
#include "docx_rels.h"
#include "oox_rels.h"
namespace cpdoccore {
namespace oox {
class xlsx_drawings::Impl
{
struct rel_
{
rel_(bool is_internal, std::wstring const & rid, std::wstring const & ref, mediaitems::Type type) :
is_internal_(is_internal),
rid_(rid),
ref_(ref),
type_(type)
{}
bool is_internal_;
std::wstring rid_;
std::wstring ref_;
mediaitems::Type type_;
};
public:
void add(_xlsx_drawing const & d, bool isInternal, std::wstring const & rid, std::wstring const & ref, mediaitems::Type type)
void add(_xlsx_drawing const & d, bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type)
{
xlsx_drawings_.push_back(d);
bool present = false;
BOOST_FOREACH(rel_ const & r, xlsx_drawing_rels_)
BOOST_FOREACH(_rel const & r, xlsx_drawing_rels_)
{
if (r.rid_ == rid && r.ref_ == ref)
if (r.rid == rid && r.ref == ref)
present = true;
}
if (!present)
{
xlsx_drawing_rels_.push_back(rel_(isInternal, rid, ref, type));
xlsx_drawing_rels_.push_back(_rel(isInternal, rid, ref, type));
}
BOOST_FOREACH(_hlink_desc h, d.hlinks)
{
xlsx_drawing_rels_.push_back(rel_(false, h.hId, h.hRef, mediaitems::typeHyperlink));
xlsx_drawing_rels_.push_back(_rel(false, h.hId, h.hRef, typeHyperlink));
}
}
void add( bool isInternal, std::wstring const & rid, std::wstring const & ref, mediaitems::Type type)
void add( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type)
{
bool present = false;
BOOST_FOREACH(rel_ const & r, xlsx_drawing_rels_)
BOOST_FOREACH(_rel const & r, xlsx_drawing_rels_)
{
if (r.rid_ == rid && r.ref_ == ref)
if (r.rid == rid && r.ref == ref)
present = true;
}
if (!present)
{
xlsx_drawing_rels_.push_back(rel_(isInternal, rid, ref, type));
xlsx_drawing_rels_.push_back(_rel(isInternal, rid, ref, type));
}
}
......@@ -129,35 +116,34 @@ public:
void dump_rels(rels & Rels)
{
BOOST_FOREACH(rel_ const & r, xlsx_drawing_rels_)
BOOST_FOREACH(_rel const & r, xlsx_drawing_rels_)
{
if (r.type_ == mediaitems::typeChart)//временно - нужно потом все загнать в релс
if (r.type == typeChart)
{
Rels.add(relationship(
r.rid_,
utils::media::get_rel_type(r.type_),
(r.is_internal_ ? std::wstring(L"../") + r.ref_ : r.ref_),
(r.is_internal_ ? L"" : L"External")
r.rid,
utils::media::get_rel_type(r.type),
(r.is_internal ? std::wstring(L"../") + r.ref : r.ref),
(r.is_internal ? L"" : L"External")
)
);
}
else if (r.type_ == mediaitems::typeImage)
else if (r.type == typeImage)
{
Rels.add(relationship(
r.rid_,
utils::media::get_rel_type(r.type_),
r.is_internal_ ? std::wstring(L"../") + r.ref_ : r.ref_,
(r.is_internal_ ? L"" : L"External")
r.rid,
utils::media::get_rel_type(r.type),
r.is_internal ? std::wstring(L"../") + r.ref : r.ref,
(r.is_internal ? L"" : L"External")
)
);
}
//typeShape внутренний рисованый объект - релсов нет
else if (r.type_ == mediaitems::typeHyperlink)//заместо гипрелинка пользуем неизвестный ... поменять ... временно .. сделать красиво
else if (r.type == typeHyperlink)
{
Rels.add(relationship(
r.rid_,
r.rid,
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
r.ref_,
r.ref,
L"External")
);
}
......@@ -169,7 +155,7 @@ public:
private:
std::vector<_xlsx_drawing> xlsx_drawings_;
std::vector<rel_> xlsx_drawing_rels_;
std::vector<_rel> xlsx_drawing_rels_;
};
xlsx_drawings::xlsx_drawings(bool inGroup_) : impl_( new xlsx_drawings::Impl() )
......@@ -182,12 +168,12 @@ xlsx_drawings::~xlsx_drawings()
}
void xlsx_drawings::add(_xlsx_drawing const & d, bool isInternal, std::wstring const & rid,
std::wstring const & ref, mediaitems::Type type)
std::wstring const & ref, RelsType type)
{
impl_->add(d, isInternal, rid, ref, type);
}
void xlsx_drawings::add( bool isInternal, std::wstring const & rid, std::wstring const & ref, mediaitems::Type type)
void xlsx_drawings::add( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type)
{
impl_->add(isInternal, rid, ref, type);
}
......
......@@ -35,7 +35,8 @@
#include <cpdoccore/CPScopedPtr.h>
#include <cpdoccore/CPSharedPtr.h>
#include <cpdoccore/xml/attributes.h>
#include "mediaitems.h"
#include "oox_rels.h"
namespace cpdoccore {
namespace oox {
......@@ -55,7 +56,6 @@ struct drawing_elm
};
struct _xlsx_drawing;
class rels;
class xlsx_drawings
{
......@@ -65,8 +65,8 @@ public:
static xlsx_drawings_ptr create(bool inGroup);
public:
void add (_xlsx_drawing const & d, bool isInternal, std::wstring const & rid, std::wstring const & ref, mediaitems::Type type);
void add (bool isInternal, std::wstring const & rid, std::wstring const & ref, mediaitems::Type type );
void add (_xlsx_drawing const & d, bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type);
void add (bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type );
bool empty () const;
void dump_rels (rels & Rels);
......
......@@ -37,7 +37,7 @@
#include <cpdoccore/xml/simple_xml_writer.h>
#include "xlsx_hyperlinks.h"
#include "docx_rels.h"
#include "oox_rels.h"
#include "../formulasconvert/formulasconvert.h"
namespace cpdoccore {
......
......@@ -36,7 +36,7 @@
#include <cpdoccore/CPScopedPtr.h>
#include <cpdoccore/CPNoncopyable.h>
#include "docx_rels.h"
#include "oox_rels.h"
namespace cpdoccore {
namespace oox {
......
......@@ -285,7 +285,14 @@ void xl_charts_files::write(const std::wstring & RootPath)
contentTypes->add_override(std::wstring(L"/xl/charts/") + fileName, kWSConType);
package::simple_element(fileName, item->str()).write(path);
}
rels_files relFiles;
item->get_rel_file()->set_file_name(fileName + L".rels");
relFiles.add_rel_file(item->get_rel_file());
relFiles.write(path);
}
}
}
//////////////////////////
......
......@@ -94,9 +94,9 @@ void xlsx_conversion_context::set_font_directory(std::wstring pathFonts)
applicationFonts_->InitializeFromFolder(pathFonts);
}
void xlsx_conversion_context::start_chart(std::wstring const & name)
void xlsx_conversion_context::start_chart(std::wstring name)
{
charts_.push_back(oox_chart_context::create(name));
charts_.push_back(oox_chart_context_ptr(new oox_chart_context(mediaitems_, name)));
//добавляем новую форму для диаграммы
//в ней будет информационная часть - и она пишется каждый раз в свою xml (их - по числу диаграмм)
//этот контекст нужно передавать в файл
......@@ -198,9 +198,9 @@ void xlsx_conversion_context::end_document()
package::chart_content_ptr content = package::chart_content::create();
chart->serialize(content->content());
chart->dump_rels(content->get_rel_file()->get_rels());
output_document_->get_xl_files().add_charts(content);
}
//workbook_content << L"<calcPr iterateCount=\"100\" refMode=\"A1\" iterate=\"false\" iterateDelta=\"0.0001\" />";
......
......@@ -81,7 +81,7 @@ public:
void start_document();
void end_document();
void start_chart(std::wstring const & name);
void start_chart(std::wstring name);
void end_chart();
void start_body();
......
......@@ -496,7 +496,7 @@ void process_build_chart::ApplyChartProperties(std::wstring style, std::vector<_
}
}
}
void process_build_chart::ApplyTextProperties(std::wstring style,std::vector<_property> & propertiesOut)
void process_build_chart::ApplyTextProperties(std::wstring style, std::vector<_property> & propertiesOut)
{
style_instance* styleInst = styles_.style_by_name(style, odf_types::style_family::Chart, false/*Context.process_headers_footers_*/);
if(styleInst)
......@@ -505,14 +505,19 @@ void process_build_chart::ApplyTextProperties(std::wstring style,std::vector<_pr
properties.apply_to(propertiesOut);
}
}
void process_build_chart::ApplyGraphicProperties(std::wstring style,std::vector<_property> & propertiesOut,oox::_oox_fill & fill)
void process_build_chart::ApplyGraphicProperties(std::wstring style, std::vector<_property> & propertiesOut, oox::_oox_fill & fill)
{
style_instance* styleInst = styles_.style_by_name(style, odf_types::style_family::Chart,false/*Context.process_headers_footers_*/);
style_instance* styleInst = styles_.style_by_name(style, odf_types::style_family::Chart, false/*Context.process_headers_footers_*/);
if(styleInst)
{
graphic_format_properties properties = calc_graphic_properties_content(styleInst);
Compute_GraphicFill(properties.common_draw_fill_attlist_, properties.style_background_image_ , draw_styles_ , fill);
Compute_GraphicFill(properties.common_draw_fill_attlist_, properties.style_background_image_ , draw_styles_ , fill);
if (fill.bitmap)
{
fill.bitmap->xlink_href_ = chart_build_.baseRef_ + FILE_SEPARATOR_STR + fill.bitmap->xlink_href_;
}
properties.apply_to(propertiesOut);
}
}
......
......@@ -106,7 +106,10 @@ public:
std::wstring val;
};
chart_build() : width_pt_(0), height_pt_(0), in_axis_(false),
chart_build(std::wstring ref) :
width_pt_(0),
height_pt_(0),
in_axis_(false),
current_table_column_(0),
current_table_row_(0),
columns_spanned_num_(0),
......@@ -115,6 +118,7 @@ public:
object_type_(0),
office_text_(NULL),
office_math_(NULL),
baseRef_(ref),
baseFontHeight_(12)
{
}
......@@ -156,8 +160,8 @@ public:
office_text *office_text_;
office_math *office_math_;
int baseFontHeight_;
int baseFontHeight_;
std::wstring baseRef_;
//---------------------------------------------------------------
std::wstring str_class_;
chart::class_type class_;
......
......@@ -364,10 +364,15 @@ void Compute_GraphicFill(const common_draw_fill_attlist & props, const office_el
{
if (fill.type < 1) fill.type = 0;
if (props.draw_opacity_) fill.opacity = props.draw_opacity_->get_value();
if (props.draw_opacity_)
{
fill.opacity = props.draw_opacity_->get_value();
}
if (props.draw_opacity_name_)
{
const std::wstring style_name = L"opacity:" + *props.draw_opacity_name_;
if (office_element_ptr style = styles.find_by_style_name(style_name))
{
if (draw_opacity * image_style = dynamic_cast<draw_opacity *>(style.get()))
......@@ -392,16 +397,18 @@ void Compute_GraphicFill(const common_draw_fill_attlist & props, const office_el
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 * fill_image = dynamic_cast<draw_fill_image *>(style.get()))
{
fill.bitmap = oox::oox_bitmap_fill::create();
fill.bitmap->xlink_href_ = fill_image->xlink_attlist_.href_.get_value_or(L"");
fill.bitmap->bTile = true;
fill.bitmap->xlink_href_ = fill_image->xlink_attlist_.href_.get_value_or(L"");
}
}
}
......
......@@ -860,7 +860,7 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, const unio
if ((drawing.fill.bitmap) && (drawing.fill.bitmap->rId.length() < 1))
{
std::wstring href = drawing.fill.bitmap->xlink_href_;
drawing.fill.bitmap->rId = Context.add_mediaitem(href, oox::mediaitems::typeImage,drawing.fill.bitmap->isInternal,href);
drawing.fill.bitmap->rId = Context.add_mediaitem(href, oox::typeImage, drawing.fill.bitmap->isInternal, href);
}
////////////////////////////////////////////////////
......@@ -965,7 +965,7 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, const unio
drawing.y = val >=0 ? val : 0; //??? todooo отрицательные величины ...
}
if (drawing.inGroup && drawing.type != oox::mediaitems::typeGroup)
if (drawing.inGroup && drawing.type != oox::typeGroupShape)
{
Context.get_drawing_context().set_position_child_group(drawing.x, drawing.y);
Context.get_drawing_context().set_size_child_group(drawing.cx + drawing.x, drawing.cy + drawing.y);
......@@ -986,7 +986,7 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context)
oox::_docx_drawing drawing = oox::_docx_drawing();
drawing.type = oox::mediaitems::typeShape;
drawing.type = oox::typeShape;
drawing.id = Context.get_drawing_context().get_current_shape_id();
drawing.name = Context.get_drawing_context().get_current_object_name();
drawing.inGroup = Context.get_drawing_context().in_group();
......@@ -1074,7 +1074,7 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
//--------------------------------------------------
oox::_docx_drawing drawing = oox::_docx_drawing();
drawing.type = oox::mediaitems::typeImage;
drawing.type = oox::typeImage;
drawing.id = Context.get_drawing_context().get_current_frame_id();
drawing.name = Context.get_drawing_context().get_current_object_name();
drawing.inGroup = Context.get_drawing_context().in_group();
......@@ -1098,7 +1098,7 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
drawing.fill.bitmap = oox::oox_bitmap_fill::create();
drawing.fill.type = 2;
drawing.fill.bitmap->isInternal = false;
drawing.fill.bitmap->rId = Context.add_mediaitem(href, oox::mediaitems::typeImage,drawing.fill.bitmap->isInternal,href);
drawing.fill.bitmap->rId = Context.add_mediaitem(href, oox::typeImage, drawing.fill.bitmap->isInternal,href);
drawing.fill.bitmap->bStretch = true;
const _CP_OPT(style_ref) & styleRef = frame->common_draw_attlists_.shape_with_text_and_styles_.
......@@ -1183,7 +1183,7 @@ void draw_text_box::docx_convert(oox::docx_conversion_context & Context)
return;
oox::_docx_drawing drawing = oox::_docx_drawing();
drawing.type = oox::mediaitems::typeShape;
drawing.type = oox::typeShape;
drawing.id = Context.get_drawing_context().get_current_frame_id();
drawing.name = Context.get_drawing_context().get_current_object_name();
drawing.inGroup = Context.get_drawing_context().in_group();
......@@ -1262,7 +1262,7 @@ void draw_g::docx_convert(oox::docx_conversion_context & Context)
oox::_docx_drawing drawing = oox::_docx_drawing();
drawing.inGroup = Context.get_drawing_context().in_group();
drawing.type = oox::mediaitems::typeGroup;
drawing.type = oox::typeGroupShape;
Context.get_drawing_context().start_group();
......@@ -1390,7 +1390,7 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
//функциональная часть
office_element *contentSubDoc = objectSubDoc.get_impl()->get_content();
draw_frame *frame = NULL;
chart_build objectBuild;
chart_build objectBuild(href);
//if (!contentSubDoc)//Diagramma.odt - кривые ссылки на объекты
// return;
......@@ -1410,7 +1410,7 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
{
oox::_docx_drawing drawing = oox::_docx_drawing();
drawing.type = oox::mediaitems::typeChart;
drawing.type = oox::typeChart;
drawing.id = Context.get_drawing_context().get_current_frame_id();
drawing.name = Context.get_drawing_context().get_current_object_name();
......@@ -1442,7 +1442,7 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
{
oox::_docx_drawing drawing = oox::_docx_drawing();
drawing.type = oox::mediaitems::typeShape;
drawing.type = oox::typeShape;
drawing.id = Context.get_drawing_context().get_current_frame_id();
drawing.name = Context.get_drawing_context().get_current_object_name();
drawing.inGroup = Context.get_drawing_context().in_group();
......
......@@ -301,7 +301,7 @@ void draw_object::pptx_convert(oox::pptx_conversion_context & Context)
}
chart_build objectBuild;
chart_build objectBuild(href);
process_build_chart process_build_object_(objectBuild, objectSubDoc.odf_context());
contentSubDoc->accept(process_build_object_);
......
......@@ -269,7 +269,7 @@ void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context)
///////////////////////////////////////////////////////////////////////////
//функциональная часть
const office_element *contentSubDoc = objectSubDoc.get_impl()->get_content();
chart_build objectBuild;
chart_build objectBuild(href);
if (contentSubDoc)
{
......
......@@ -213,8 +213,8 @@ void table_table::pptx_convert(oox::pptx_conversion_context & Context)
{
bool isMediaInternal = false;
std::wstring ref;
fill.bitmap->rId = Context.get_slide_context().get_mediaitems().add_or_find(fill.bitmap->xlink_href_, oox::mediaitems::typeImage, isMediaInternal, ref);
Context.get_slide_context().add_rels(isMediaInternal, fill.bitmap->rId, ref, oox::mediaitems::typeImage);
fill.bitmap->rId = Context.get_slide_context().get_mediaitems().add_or_find(fill.bitmap->xlink_href_, oox::typeImage, isMediaInternal, ref);
Context.get_slide_context().add_rels(isMediaInternal, fill.bitmap->rId, ref, oox::typeImage);
}
oox::oox_serialize_fill(_Wostream, fill);
}
......
......@@ -518,14 +518,6 @@
RelativePath="..\src\docx\docx_package.h"
>
</File>
<File
RelativePath="..\src\docx\docx_rels.cpp"
>
</File>
<File
RelativePath="..\src\docx\docx_rels.h"
>
</File>
<File
RelativePath="..\src\docx\docx_table_context.cpp"
>
......@@ -974,6 +966,14 @@
RelativePath="..\src\docx\oox_package.h"
>
</File>
<File
RelativePath="..\src\docx\oox_rels.cpp"
>
</File>
<File
RelativePath="..\src\docx\oox_rels.h"
>
</File>
<File
RelativePath="..\src\docx\ooxtablerowspanned.h"
>
......
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