mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-11 02:16:02 +08:00
Compare commits
32 Commits
core-windo
...
core/devel
| Author | SHA1 | Date | |
|---|---|---|---|
| 51c8ab5499 | |||
| 4176176e2b | |||
| 34d03c743e | |||
| 4cf55208b1 | |||
| fe1d48635b | |||
| db20232095 | |||
| 56ecea3ffc | |||
| 59599289af | |||
| d95c93abb2 | |||
| a9076bebd2 | |||
| 5157908b47 | |||
| 13b7306b99 | |||
| b98a545d8c | |||
| ceb2c7863b | |||
| 26cedc30fa | |||
| c0f29521c4 | |||
| 13d57361e4 | |||
| 1e04770e31 | |||
| 6666ba0236 | |||
| e6c334199f | |||
| 6d75b03cc0 | |||
| 303b62c2a1 | |||
| 5109acb888 | |||
| cbc4a5d334 | |||
| a639fc9eaf | |||
| 9cc54393a0 | |||
| 16386f4b5c | |||
| 149c0ae72a | |||
| 29b4a10435 | |||
| 1cf9401e0a | |||
| c6a05e493f | |||
| 82e82971d0 |
@ -87,19 +87,19 @@ namespace DocFileFormat
|
||||
|
||||
case sprmOldTDefTable:
|
||||
case sprmTDefTable:
|
||||
{ //table definition
|
||||
|
||||
{
|
||||
//table definition
|
||||
SprmTDefTable tDef( iter->Arguments, iter->argumentsSize );
|
||||
//Workaround for retrieving the indent of the table:
|
||||
//In some files there is a indent but no sprmTWidthIndent is set.
|
||||
//For this cases we can calculate the indent of the table by getting the
|
||||
//first boundary of the TDef and adding the padding of the cells
|
||||
|
||||
tblIndent = FormatUtils::BytesToInt16( iter->Arguments, 1, iter->argumentsSize );
|
||||
//add the gabHalf
|
||||
tblIndent += gabHalf;
|
||||
//If there follows a real sprmTWidthIndent, this value will be overwritten
|
||||
|
||||
tblIndent = (std::max)((int)tblIndent,0);
|
||||
//tblIndent = (std::max)((int)tblIndent,0); //cerere.doc
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@ -345,6 +345,18 @@
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\Common\3dParty\pole\pole.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
|
||||
@ -213,7 +213,6 @@ SOURCES += \
|
||||
../src/docx/hyperlinks.cpp \
|
||||
../src/docx/measuredigits.cpp \
|
||||
../src/docx/mediaitems.cpp \
|
||||
../src/docx/mediaitems_utils.cpp \
|
||||
../src/docx/namespaces.cpp \
|
||||
../src/docx/oox_chart_axis.cpp \
|
||||
../src/docx/oox_chart_context.cpp \
|
||||
@ -462,7 +461,6 @@ HEADERS += \
|
||||
../src/docx/hyperlinks.h \
|
||||
../src/docx/measuredigits.h \
|
||||
../src/docx/mediaitems.h \
|
||||
../src/docx/mediaitems_utils.h \
|
||||
../src/docx/namespaces.h \
|
||||
../src/docx/oox_chart_axis.h \
|
||||
../src/docx/oox_chart_context.h \
|
||||
|
||||
@ -76,7 +76,7 @@ public:
|
||||
{}
|
||||
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_; }
|
||||
|
||||
public:
|
||||
|
||||
@ -82,6 +82,8 @@ void text_tracked_context::start_changes_content()
|
||||
|
||||
void text_tracked_context::end_changes_content()
|
||||
{
|
||||
docx_context_.finish_run(); //0106GS-GettingStartedWithWriter_el.odt - удаленный заголовок
|
||||
|
||||
current_state_.content.push_back(changes_stream_.str());
|
||||
|
||||
docx_context_.set_delete_text_state (false);
|
||||
@ -130,8 +132,8 @@ text_tracked_context::_state & text_tracked_context::get_tracked_change(std::wst
|
||||
//----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfDocument) :
|
||||
mediaitems_ (OdfDocument->get_folder() ),
|
||||
next_dump_page_properties_ (false),
|
||||
page_break_ (false),
|
||||
page_break_after_ (false),
|
||||
page_break_before_ (false),
|
||||
in_run_ (false),
|
||||
@ -150,7 +152,8 @@ docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfD
|
||||
delayed_converting_ (false),
|
||||
process_headers_footers_ (false),
|
||||
process_comment_ (false),
|
||||
math_context_ (false),
|
||||
mediaitems_ (OdfDocument->get_folder() ),
|
||||
math_context_ (OdfDocument->odf_context().fontContainer(), false),
|
||||
odf_document_ (OdfDocument)
|
||||
{
|
||||
streams_man_ = streams_man::create(temp_stream_);
|
||||
@ -832,13 +835,20 @@ void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & str
|
||||
//in_styles = true -> styles.xml
|
||||
//почему то конструкция <pPr><rPr/></pPr><rPr/> "не работает" в части в rPr в ms2010 )
|
||||
{
|
||||
bool in_drawing = false;
|
||||
|
||||
if (get_drawing_context().get_current_shape() || get_drawing_context().get_current_frame())
|
||||
{
|
||||
in_drawing = true;
|
||||
}
|
||||
std::wstringstream & paragraph_style = get_styles_context().paragraph_nodes();
|
||||
std::wstringstream & run_style = get_styles_context().text_style();
|
||||
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
//Tutor_Charlotte_Tutor_the_Entire_World_.odt
|
||||
if (get_section_context().dump_.empty() == false && (!ParentId.empty() || get_section_context().get().is_dump_ || in_header_)
|
||||
&& !get_table_context().in_table())
|
||||
&& !get_table_context().in_table() && !in_drawing)
|
||||
{//две подряд секции или если стиль определен и в заголовки нельзя пихать !!!
|
||||
CP_XML_NODE(L"w:pPr")
|
||||
{
|
||||
@ -853,7 +863,7 @@ void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & str
|
||||
{
|
||||
CP_XML_NODE(L"w:pPr")
|
||||
{
|
||||
if ( !get_table_context().in_table() )
|
||||
if ( !get_table_context().in_table() && !in_drawing)
|
||||
{
|
||||
CP_XML_STREAM() << get_section_context().dump_;
|
||||
get_section_context().dump_.clear();
|
||||
|
||||
@ -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;
|
||||
odf_reader::GetProperty(properties,L"text-content",strTextContent);
|
||||
odf_reader::GetProperty(additional, L"text-content", strTextContent);
|
||||
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
@ -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)
|
||||
|
||||
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_ATTR(L"prst",L"rect");
|
||||
CP_XML_ATTR(L"prst", L"rect");
|
||||
CP_XML_NODE(L"a:avLst");
|
||||
}
|
||||
|
||||
@ -280,13 +278,12 @@ void docx_serialize_shape_child(std::wostream & strm, _docx_drawing & val)
|
||||
}
|
||||
CP_XML_NODE(L"wps:spPr")
|
||||
{
|
||||
oox_serialize_xfrm(CP_XML_STREAM(),val);
|
||||
|
||||
oox_serialize_shape(CP_XML_STREAM(),val);
|
||||
val.serialize_xfrm (CP_XML_STREAM());
|
||||
val.serialize_shape (CP_XML_STREAM());
|
||||
|
||||
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)
|
||||
|
||||
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_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void docx_serialize_chart_child(std::wostream & strm, _docx_drawing & val)
|
||||
{
|
||||
CP_XML_WRITER(strm)
|
||||
@ -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: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)
|
||||
{
|
||||
CP_XML_NODE(L"wp:docPr")
|
||||
{
|
||||
CP_XML_ATTR(L"name",val.name);
|
||||
CP_XML_ATTR(L"id", val.id + 1);
|
||||
oox_serialize_hlink(CP_XML_STREAM(),val.hlinks);
|
||||
CP_XML_ATTR(L"name", val.name);
|
||||
CP_XML_ATTR(L"id", val.id + 1);
|
||||
oox_serialize_hlink(CP_XML_STREAM(), val.hlinks);
|
||||
}
|
||||
|
||||
CP_XML_NODE(L"wp:cNvGraphicFramePr")
|
||||
@ -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");
|
||||
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)
|
||||
{
|
||||
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)
|
||||
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 == typeGroupShape)
|
||||
{
|
||||
CP_XML_ATTR(L"uri", L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
|
||||
docx_serialize_group_child(CP_XML_STREAM(), val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -440,8 +438,6 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
|
||||
std::wstring relativeFrom = L"margin";
|
||||
if (val.styleHorizontalRel) relativeFrom =val.styleHorizontalRel->get_type_str();
|
||||
|
||||
if (relativeFrom == L"column") relativeFrom = L"margin";
|
||||
|
||||
CP_XML_ATTR(L"relativeFrom", relativeFrom);
|
||||
|
||||
if (val.styleHorizontalPos &&
|
||||
@ -459,10 +455,10 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
|
||||
|
||||
CP_XML_NODE(L"wp:positionV")
|
||||
{
|
||||
std::wstring relativeFrom = L"paragraph";
|
||||
if (val.styleVerticalRel)relativeFrom = val.styleVerticalRel->get_type_str();
|
||||
|
||||
CP_XML_ATTR(L"relativeFrom",relativeFrom);
|
||||
std::wstring relativeFrom = L"margin";
|
||||
if (val.styleVerticalRel)relativeFrom = val.styleVerticalRel->get_type_str();
|
||||
|
||||
CP_XML_ATTR(L"relativeFrom", relativeFrom);
|
||||
|
||||
if (val.styleVerticalPos &&
|
||||
val.styleVerticalPos->get_type() != odf_types::vertical_pos::FromTop &&
|
||||
@ -483,8 +479,8 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
|
||||
}
|
||||
CP_XML_NODE(L"wp:extent")
|
||||
{
|
||||
CP_XML_ATTR(L"cx",val.cx);
|
||||
CP_XML_ATTR(L"cy",val.cy);
|
||||
CP_XML_ATTR(L"cx", val.cx);
|
||||
CP_XML_ATTR(L"cy", val.cy);
|
||||
}
|
||||
|
||||
serialize_wrap(CP_XML_STREAM(), val);
|
||||
@ -513,6 +509,8 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
|
||||
std::wstring relativeFrom = L"paragraph";
|
||||
if (val.styleVerticalRel)relativeFrom = val.styleVerticalRel->get_type_str();
|
||||
|
||||
if (relativeFrom == L"paragraph") relativeFrom = L"margin";
|
||||
|
||||
CP_XML_NODE(L"wp14:sizeRelV")
|
||||
{
|
||||
CP_XML_ATTR(L"relativeFrom", relativeFrom);
|
||||
@ -577,16 +575,65 @@ void docx_serialize_alt_content(std::wostream & strm, _docx_drawing & val)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void docx_serialize(std::wostream & strm, _docx_drawing & val, bool insideOtherDrawing)
|
||||
void docx_serialize_object(std::wostream & strm, _docx_drawing & val)
|
||||
{
|
||||
if (val.inGroup)
|
||||
return docx_serialize_child(strm, 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);
|
||||
|
||||
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", val.name);
|
||||
CP_XML_ATTR(L"r:id", val.fill.bitmap->rId);
|
||||
}
|
||||
}
|
||||
}
|
||||
CP_XML_NODE(L"o:OLEObject")
|
||||
{
|
||||
CP_XML_ATTR(L"Type", L"Embed");
|
||||
CP_XML_ATTR(L"ProgID", val.objectProgId);
|
||||
CP_XML_ATTR(L"ShapeID", L"ole_" + val.objectId);
|
||||
CP_XML_ATTR(L"DrawAspect", L"Content" );
|
||||
CP_XML_ATTR(L"ObjectID", 0x583A3000 + val.id );
|
||||
CP_XML_ATTR(L"r:id", val.objectId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _docx_drawing::serialize(std::wostream & strm/*, bool insideOtherDrawing*/)
|
||||
{
|
||||
if (type == typeUnknown) return;
|
||||
|
||||
if (inGroup)
|
||||
return docx_serialize_child(strm, *this);
|
||||
|
||||
//if (insideOtherDrawing)
|
||||
docx_serialize_wps(strm, val);
|
||||
//else
|
||||
// docx_serialize_alt_content(strm, val);
|
||||
if (type == typeMsObject ||
|
||||
type == typeOleObject)
|
||||
{
|
||||
docx_serialize_object(strm, *this);
|
||||
}
|
||||
else
|
||||
{
|
||||
//if (insideOtherDrawing)
|
||||
docx_serialize_wps(strm, *this);
|
||||
//else
|
||||
// docx_serialize_alt_content(strm, val);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -44,9 +44,10 @@
|
||||
namespace cpdoccore {
|
||||
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;
|
||||
@ -72,15 +73,12 @@ struct _docx_drawing : _oox_drawing
|
||||
_CP_OPT(int) pctWidth;
|
||||
_CP_OPT(int) pctHeight;
|
||||
|
||||
int margin_rect[4];//0-left, 1 -top, 2- right, 3 - bottom
|
||||
//std::wstring distB;
|
||||
// std::wstring distT;
|
||||
// std::wstring distL;
|
||||
// std::wstring distR;
|
||||
int margin_rect[4]; //0-left, 1 -top, 2- right, 3 - bottom
|
||||
|
||||
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)
|
||||
{
|
||||
media_->write( path );
|
||||
}
|
||||
|
||||
if (embeddings_)
|
||||
{
|
||||
embeddings_->write( path );
|
||||
}
|
||||
|
||||
if (headers_footers_)
|
||||
if (headers_footers_)
|
||||
{
|
||||
headers_footers_->write( path );
|
||||
}
|
||||
@ -136,7 +141,15 @@ void word_files::update_rels(docx_conversion_context & Context)
|
||||
|
||||
void word_files::set_media(mediaitems & _Mediaitems, CApplicationFonts *pAppFonts)
|
||||
{
|
||||
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
|
||||
if (_Mediaitems.count_image + _Mediaitems.count_media > 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)
|
||||
@ -197,6 +210,7 @@ void docx_charts_files::add_chart(chart_content_ptr chart)
|
||||
{
|
||||
charts_.push_back(chart);
|
||||
}
|
||||
|
||||
void docx_charts_files::write(const std::wstring & RootPath)
|
||||
{
|
||||
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"charts";
|
||||
|
||||
@ -148,6 +148,7 @@ private:
|
||||
element_ptr fontTable_;
|
||||
element_ptr numbering_;
|
||||
element_ptr media_;
|
||||
element_ptr embeddings_;
|
||||
element_ptr headers_footers_;
|
||||
element_ptr notes_;
|
||||
element_ptr settings_;
|
||||
|
||||
@ -52,6 +52,8 @@ struct drawing_object_description
|
||||
oox::RelsType type_;
|
||||
|
||||
std::wstring name_;
|
||||
std::wstring descriptor_;
|
||||
|
||||
_CP_OPT(_rect) svg_rect_;
|
||||
|
||||
std::wstring anchor_;
|
||||
@ -66,7 +68,6 @@ struct drawing_object_description
|
||||
|
||||
_oox_fill fill_;
|
||||
|
||||
bool use_image_replace_;
|
||||
bool in_group_;
|
||||
|
||||
int shape_type_; //default - frame
|
||||
|
||||
@ -97,9 +97,12 @@ void headers_footers::dump_rels(rels & Rels) const//внешние релсы
|
||||
}
|
||||
}
|
||||
|
||||
bool headers_footers::write_sectPr(const std::wstring & StyleName, std::wostream & _Wostream) const
|
||||
bool headers_footers::write_sectPr(const std::wstring & StyleName, bool next_page/*not used*/, std::wostream & _Wostream)
|
||||
{
|
||||
if (!instances_.count(StyleName))return false;
|
||||
if (!instances_.count(StyleName)) return false;
|
||||
if (last_write_style_ == StyleName) return true;
|
||||
|
||||
last_write_style_ = StyleName;
|
||||
|
||||
bool first = false, left = false;
|
||||
bool res = false;
|
||||
|
||||
@ -49,7 +49,8 @@ namespace oox {
|
||||
class headers_footers
|
||||
{
|
||||
public:
|
||||
headers_footers() : size_(0),enable_write_(false){}
|
||||
headers_footers() : size_(0) {}
|
||||
|
||||
enum Type { header, footer, headerLeft, footerLeft, headerFirst, footerFirst, none };
|
||||
std::wstring add(const std::wstring & StyleName, const std::wstring & Content, Type type,rels &_rels);
|
||||
|
||||
@ -66,18 +67,17 @@ public:
|
||||
};
|
||||
|
||||
void dump_rels(rels & Rels) const;
|
||||
bool write_sectPr(const std::wstring & StyleName, std::wostream & _Wostream) const;
|
||||
bool write_sectPr(const std::wstring & StyleName, bool next_page, std::wostream & _Wostream);
|
||||
|
||||
typedef boost::shared_ptr<instance> instance_ptr;
|
||||
typedef std::vector<instance_ptr> instances_array;
|
||||
typedef boost::unordered_map<std::wstring, instances_array> instances_map;
|
||||
const instances_map & instances() const { return instances_; }
|
||||
|
||||
bool get_enable_write(){return enable_write_;}
|
||||
void set_enable_write(bool val){enable_write_ = val;}
|
||||
|
||||
const instances_map & instances() const { return instances_; }
|
||||
|
||||
private:
|
||||
bool enable_write_;
|
||||
std::wstring last_write_style_;
|
||||
|
||||
static std::wstring create_id(size_t i);
|
||||
static std::wstring create_name(size_t i, Type _Type);
|
||||
instances_map instances_;
|
||||
|
||||
@ -39,15 +39,27 @@
|
||||
|
||||
#include <cpdoccore/xml/utils.h>
|
||||
|
||||
#include "mediaitems_utils.h"
|
||||
|
||||
#include "../../Common/DocxFormat/Source/Base/Base.h"
|
||||
#include "../../Common/DocxFormat/Source/SystemUtility/File.h"
|
||||
#include "../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h"
|
||||
|
||||
#include "../../DesktopEditor/raster/ImageFileFormatChecker.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace oox {
|
||||
|
||||
bool is_internal(const std::wstring & uri, const std::wstring & packetRoot)
|
||||
{
|
||||
if (uri.empty())return false;
|
||||
|
||||
std::wstring mediaPath = boost::regex_search(uri.begin(), uri.end(), boost::wregex(L"^/[A-Za-z]:"))
|
||||
? std::wstring(uri.begin() + 1, uri.end())
|
||||
: uri;
|
||||
|
||||
std::wstring resultPath = packetRoot + FILE_SEPARATOR_STR + mediaPath;
|
||||
|
||||
return FileSystem::Directory::IsExist(resultPath) || FileSystem::Directory::IsExist(mediaPath);
|
||||
}
|
||||
|
||||
mediaitems::item::item( std::wstring const & _href,
|
||||
RelsType _type,
|
||||
@ -55,12 +67,12 @@ mediaitems::item::item( std::wstring const & _href,
|
||||
bool _mediaInternal,
|
||||
std::wstring const & _Id
|
||||
)
|
||||
: href(_href),
|
||||
type(_type),
|
||||
outputName(_outputName),
|
||||
mediaInternal(_mediaInternal),
|
||||
Id(_Id),
|
||||
valid(true) //вообще говоря даже если файл покоцанный то мы все равно обязаны перенести "объект"
|
||||
: href(_href),
|
||||
type(_type),
|
||||
outputName(_outputName),
|
||||
mediaInternal(_mediaInternal),
|
||||
Id(_Id),
|
||||
valid(true) //вообще говоря даже если файл покоцанный то мы все равно обязаны перенести "объект"
|
||||
{
|
||||
count_add = 1;
|
||||
count_used = 0;
|
||||
@ -82,6 +94,10 @@ std::wstring static get_default_file_name(RelsType type)
|
||||
return L"chart";
|
||||
case typeMedia:
|
||||
return L"media";
|
||||
case typeMsObject:
|
||||
return L"msObject";
|
||||
case typeOleObject:
|
||||
return L"oleObject";
|
||||
default:
|
||||
return L"";
|
||||
}
|
||||
@ -120,6 +136,9 @@ std::wstring mediaitems::create_file_name(const std::wstring & uri, RelsType typ
|
||||
sExt = uri.substr(n);
|
||||
}
|
||||
}
|
||||
|
||||
if (type == typeOleObject && sExt.empty())
|
||||
sExt = L".bin";
|
||||
|
||||
return get_default_file_name(type) + std::to_wstring(Num) + sExt;
|
||||
}
|
||||
@ -147,7 +166,7 @@ std::wstring mediaitems::detectImageFileExtension(std::wstring &fileName)
|
||||
|
||||
std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, bool & isInternal, std::wstring & ref)
|
||||
{
|
||||
bool isMediaInternal = utils::media::is_internal(href, odf_packet_);
|
||||
bool isMediaInternal = is_internal(href, odf_packet_);
|
||||
|
||||
std::wstring sub_path = L"media/";
|
||||
|
||||
@ -156,21 +175,27 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
|
||||
{
|
||||
sub_path = L"charts/";
|
||||
}
|
||||
if ( type == typeMsObject || type == typeOleObject)
|
||||
{
|
||||
sub_path = L"embeddings/";
|
||||
}
|
||||
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 if ( type == typeMsObject ||
|
||||
type == typeOleObject) number = count_object + 1;
|
||||
else
|
||||
number = items_.size()+1;
|
||||
number = items_.size() + 1;
|
||||
|
||||
inputFileName = create_file_name(href, type, isMediaInternal, number);
|
||||
|
||||
std::wstring inputPath = isMediaInternal ? odf_packet_ + FILE_SEPARATOR_STR + href : 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;
|
||||
for (int i = 0 ; i < items_.size(); i++)
|
||||
@ -192,7 +217,7 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
|
||||
{
|
||||
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++;
|
||||
}
|
||||
else if ( type == typeImage)
|
||||
@ -205,12 +230,17 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
|
||||
//------------------------------------------------
|
||||
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++;
|
||||
}
|
||||
else if ( type == typeMsObject || type == typeOleObject)
|
||||
{
|
||||
id = std::wstring(L"objId") + std::to_wstring(count_object + 1);
|
||||
count_object++;
|
||||
}
|
||||
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++;
|
||||
}
|
||||
|
||||
@ -225,16 +255,17 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
|
||||
void mediaitems::dump_rels(rels & Rels)
|
||||
{
|
||||
size_t i = 0;
|
||||
BOOST_FOREACH(item & elm, items_)
|
||||
for (int i = 0; i < items_.size(); i++)
|
||||
{
|
||||
if (elm.count_used > elm.count_add)continue; // уже использовали этот релс выше(колонтитул ....)
|
||||
Rels.add( relationship(
|
||||
elm.Id,
|
||||
utils::media::get_rel_type(elm.type),
|
||||
elm.valid ? elm.outputName : L"NULL",
|
||||
elm.mediaInternal ? L"" : L"External" )
|
||||
if (items_[i].count_used > items_[i].count_add) continue; // уже использовали этот релс выше(колонтитул ....)
|
||||
|
||||
Rels.add( relationship(
|
||||
items_[i].Id,
|
||||
get_rel_type (items_[i].type),
|
||||
items_[i].valid ? items_[i].outputName : L"NULL",
|
||||
items_[i].mediaInternal ? L"" : L"External" )
|
||||
);
|
||||
elm.count_used++;
|
||||
items_[i].count_used++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -39,7 +39,6 @@
|
||||
namespace cpdoccore {
|
||||
namespace oox {
|
||||
|
||||
|
||||
class mediaitems
|
||||
{
|
||||
public:
|
||||
@ -50,7 +49,7 @@ public:
|
||||
count_image = 0;
|
||||
count_tables = 0;
|
||||
count_media = 0;
|
||||
|
||||
count_object = 0;
|
||||
}
|
||||
|
||||
struct item
|
||||
@ -77,6 +76,7 @@ public:
|
||||
size_t count_media;
|
||||
size_t count_shape;
|
||||
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 & ref);
|
||||
@ -84,6 +84,20 @@ public:
|
||||
void dump_rels(rels & Rels);
|
||||
items_array & items() { return items_; }
|
||||
|
||||
static std::wstring get_rel_type(RelsType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case typeImage: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image";
|
||||
case typeChart: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart";
|
||||
case typeMsObject: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
|
||||
case typeOleObject: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
|
||||
case typeHyperlink: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
|
||||
default:
|
||||
return L"";
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::wstring create_file_name (const std::wstring & uri, RelsType type, bool & isInternal, size_t Num);
|
||||
std::wstring detectImageFileExtension (std::wstring &fileName);
|
||||
|
||||
@ -1,91 +0,0 @@
|
||||
/*
|
||||
* (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 "mediaitems_utils.h"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#include "../../Common/DocxFormat/Source/Base/Base.h"
|
||||
#include "../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h"
|
||||
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace oox {
|
||||
namespace utils {
|
||||
|
||||
namespace media {
|
||||
|
||||
|
||||
bool is_internal(const std::wstring & uri, const std::wstring & packetRoot)
|
||||
{
|
||||
if (uri.empty())return false;
|
||||
|
||||
std::wstring mediaPath = boost::regex_search(uri.begin(), uri.end(), boost::wregex(L"^/[A-Za-z]:"))
|
||||
? std::wstring(uri.begin() + 1, uri.end())
|
||||
: uri;
|
||||
|
||||
std::wstring resultPath = packetRoot + FILE_SEPARATOR_STR + mediaPath;
|
||||
|
||||
return FileSystem::Directory::IsExist(resultPath);
|
||||
}
|
||||
|
||||
std::wstring get_rel_type(RelsType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case typeImage:
|
||||
return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image";
|
||||
case typeChart:
|
||||
return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart";
|
||||
default:
|
||||
return L"";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::wstring replace_extension(const std::wstring & ext)
|
||||
{
|
||||
// TODO
|
||||
if (ext == L"jpg")
|
||||
return L"jpeg";
|
||||
else
|
||||
return ext;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
#ifndef CPDOCCORE_MEDIAITEMS_UTILS_H_
|
||||
#define CPDOCCORE_MEDIAITEMS_UTILS_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "mediaitems.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace oox {
|
||||
namespace utils {
|
||||
namespace media {
|
||||
|
||||
bool is_internal(const std::wstring & uri, const std::wstring & packetRoot);
|
||||
std::wstring get_rel_type(RelsType type);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -31,13 +31,12 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <vector>
|
||||
#include <cpdoccore/xml/simple_xml_writer.h>
|
||||
#include "mediaitems_utils.h"
|
||||
#include "oox_rels.h"
|
||||
|
||||
#include "oox_rels.h"
|
||||
#include "oox_chart_context.h"
|
||||
#include "mediaitems.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace oox {
|
||||
@ -87,7 +86,7 @@ void oox_chart_context::dump_rels(rels & Rels)
|
||||
{
|
||||
Rels.add(relationship(
|
||||
r.rid,
|
||||
utils::media::get_rel_type(r.type),
|
||||
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
||||
r.is_internal ? std::wstring(L"../") + r.ref : r.ref,
|
||||
(r.is_internal ? L"" : L"External")
|
||||
)
|
||||
|
||||
@ -144,7 +144,7 @@ void styles_context::docx_serialize_table_style(std::wostream & strm, std::wstri
|
||||
}
|
||||
namespace oox
|
||||
{
|
||||
math_context::math_context(bool graphic) : base_font_size_(12)
|
||||
math_context::math_context(odf_reader::fonts_container & fonts, bool graphic) : base_font_size_(12), fonts_container_(fonts)
|
||||
{
|
||||
graphRPR_ = graphic;
|
||||
|
||||
|
||||
@ -44,6 +44,7 @@ namespace odf_reader
|
||||
{
|
||||
class style_instance;
|
||||
class style_text_properties;
|
||||
class fonts_container;
|
||||
typedef boost::shared_ptr<style_text_properties> style_text_properties_ptr;
|
||||
};
|
||||
|
||||
@ -90,7 +91,7 @@ namespace oox {
|
||||
class math_context : boost::noncopyable
|
||||
{
|
||||
public:
|
||||
math_context(bool graphic = false);
|
||||
math_context(odf_reader::fonts_container & fonts, bool graphic = false);
|
||||
|
||||
void start();
|
||||
std::wstring end();
|
||||
@ -99,6 +100,7 @@ namespace oox {
|
||||
|
||||
std::wstringstream & math_style_stream() { return math_style_stream_; }
|
||||
|
||||
odf_reader::fonts_container & fonts_container_;
|
||||
int base_font_size_;
|
||||
odf_reader::style_text_properties_ptr text_properties_;
|
||||
|
||||
|
||||
@ -37,6 +37,19 @@
|
||||
|
||||
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)
|
||||
{
|
||||
CP_XML_WRITER(strm)
|
||||
@ -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)
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
odf_reader::GetProperty(prop,L"wordArt", bWordArt);
|
||||
@ -257,11 +270,11 @@ void oox_serialize_bodyPr(std::wostream & strm, _oox_drawing & val, const std::w
|
||||
if (dPaddingTop) CP_XML_ATTR(L"tIns", (int)(*dPaddingTop));
|
||||
if (dPaddingBottom) CP_XML_ATTR(L"bIns", (int)(*dPaddingBottom));
|
||||
|
||||
if (val.inGroup == false)
|
||||
if (inGroup == false)
|
||||
{
|
||||
_CP_OPT(int) iWrap;
|
||||
odf_reader::GetProperty(prop,L"text-wrap" , iWrap);
|
||||
if ((iWrap) && (*iWrap == 0))CP_XML_ATTR(L"wrap", L"none");
|
||||
odf_reader::GetProperty(prop, L"text-wrap" , iWrap);
|
||||
if ((iWrap) && (*iWrap == 0)) CP_XML_ATTR(L"wrap", L"none");
|
||||
}
|
||||
|
||||
_CP_OPT(int) iAlign;
|
||||
@ -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(double) dVal;
|
||||
@ -327,60 +340,61 @@ void oox_serialize_shape(std::wostream & strm, _oox_drawing & val)
|
||||
std::wstring shapeType;
|
||||
_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;
|
||||
odf_reader::GetProperty(val.additional, L"odf-custom-draw-index",iVal);
|
||||
odf_reader::GetProperty(additional, L"odf-custom-draw-index",iVal);
|
||||
|
||||
if (iVal)
|
||||
shapeType = _OO_OOX_custom_shapes[*iVal].oox;
|
||||
else
|
||||
val.sub_type = 6; //path
|
||||
sub_type = 6; //path
|
||||
|
||||
if (shapeType == L"textBox")
|
||||
{
|
||||
val.sub_type = 1;
|
||||
sub_type = 1;
|
||||
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)
|
||||
{
|
||||
if (val.sub_type == 6 || val.sub_type == 8)
|
||||
if (sub_type == 6 || sub_type == 8)
|
||||
{
|
||||
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:gdLst");
|
||||
CP_XML_NODE(L"a:rect")
|
||||
{
|
||||
CP_XML_ATTR(L"b",L"b");
|
||||
CP_XML_ATTR(L"l",0);
|
||||
CP_XML_ATTR(L"r",L"r");
|
||||
CP_XML_ATTR(L"t",0);
|
||||
CP_XML_ATTR(L"b", L"b");
|
||||
CP_XML_ATTR(L"l", 0);
|
||||
CP_XML_ATTR(L"r", L"r");
|
||||
CP_XML_ATTR(L"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;
|
||||
odf_reader::GetProperty(val.additional, L"custom_path_w", w);
|
||||
odf_reader::GetProperty(val.additional, L"custom_path_h", h);
|
||||
odf_reader::GetProperty(additional, L"custom_path_w", w);
|
||||
odf_reader::GetProperty(additional, L"custom_path_h", h);
|
||||
|
||||
CP_XML_NODE(L"a:pathLst")
|
||||
{
|
||||
CP_XML_NODE(L"a:path")
|
||||
{
|
||||
CP_XML_ATTR(L"w", w ? *w : val.cx);
|
||||
CP_XML_ATTR(L"h", h ? *h : val.cy);
|
||||
CP_XML_ATTR(L"w", w ? *w : cx);
|
||||
CP_XML_ATTR(L"h", h ? *h : cy);
|
||||
|
||||
CP_XML_STREAM() << strVal.get();
|
||||
}
|
||||
@ -393,12 +407,12 @@ void oox_serialize_shape(std::wostream & strm, _oox_drawing & val)
|
||||
if (shapeType.length() < 1)
|
||||
{
|
||||
shapeType = L"rect";
|
||||
val.sub_type = 2;
|
||||
sub_type = 2;
|
||||
}
|
||||
CP_XML_NODE(L"a:prstGeom")//автофигура
|
||||
{
|
||||
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)
|
||||
@ -407,25 +421,25 @@ void oox_serialize_shape(std::wostream & strm, _oox_drawing & val)
|
||||
oox_serialize_fill(strm, no_fill);
|
||||
}
|
||||
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, bool always_position)
|
||||
{
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
std::wstring xfrm = name_space + L":xfrm";
|
||||
|
||||
_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;
|
||||
odf_reader::GetProperty(val.additional,L"svg:skewX",dSkewX);
|
||||
odf_reader::GetProperty(additional, L"svg:skewX", dSkewX);
|
||||
|
||||
_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;
|
||||
|
||||
@ -443,36 +457,44 @@ void oox_serialize_xfrm(std::wostream & strm, _oox_drawing & val, const std::wst
|
||||
{
|
||||
if (dRotateAngle)
|
||||
{
|
||||
double d =360-dRotateAngle.get()*180./3.14159265358979323846;
|
||||
double d =360 - dRotateAngle.get() * 180. / 3.14159265358979323846;
|
||||
d *= 60000; //60 000 per 1 gr - 19.5.5 oox
|
||||
CP_XML_ATTR(L"rot", (int)d);
|
||||
}
|
||||
_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());
|
||||
|
||||
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_NODE(L"a:off")
|
||||
{
|
||||
CP_XML_ATTR(L"x", val.x);
|
||||
CP_XML_ATTR(L"y", val.y);
|
||||
if (inGroup || always_position)
|
||||
{
|
||||
CP_XML_ATTR(L"x", x);
|
||||
CP_XML_ATTR(L"y", y);
|
||||
}
|
||||
else
|
||||
{
|
||||
CP_XML_ATTR(L"x", 0);
|
||||
CP_XML_ATTR(L"y", 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (val.cx >0 || val.cy >0)
|
||||
if (cx > 0 || cy > 0)
|
||||
{
|
||||
CP_XML_NODE(L"a:ext")
|
||||
{
|
||||
CP_XML_ATTR(L"cx", val.cx);
|
||||
CP_XML_ATTR(L"cy", val.cy);
|
||||
CP_XML_ATTR(L"cx", cx);
|
||||
CP_XML_ATTR(L"cy", cy);
|
||||
}
|
||||
}else
|
||||
{
|
||||
_CP_LOG << L"[error!!!] not set size object\n";
|
||||
}
|
||||
|
||||
if (val.type == typeGroupShape)
|
||||
if (type == typeGroupShape)
|
||||
{
|
||||
CP_XML_NODE(L"a:chOff")
|
||||
{
|
||||
@ -481,8 +503,8 @@ void oox_serialize_xfrm(std::wostream & strm, _oox_drawing & val, const std::wst
|
||||
}
|
||||
CP_XML_NODE(L"a:chExt")
|
||||
{
|
||||
CP_XML_ATTR(L"cx", val.cx);
|
||||
CP_XML_ATTR(L"cy", val.cy);
|
||||
CP_XML_ATTR(L"cx", cx);
|
||||
CP_XML_ATTR(L"cy", cy);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -494,7 +516,7 @@ void oox_serialize_hlink(std::wostream & strm, std::vector<_hlink_desc> const &
|
||||
{
|
||||
BOOST_FOREACH(const _hlink_desc & h, val)
|
||||
{
|
||||
if (h.object == true)
|
||||
if (h.in_object == true)
|
||||
{
|
||||
CP_XML_NODE(L"a:hlinkClick")
|
||||
{
|
||||
|
||||
@ -42,22 +42,6 @@
|
||||
|
||||
#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 oox {
|
||||
|
||||
@ -65,38 +49,47 @@ namespace oox {
|
||||
{
|
||||
std::wstring hId;
|
||||
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")
|
||||
{
|
||||
}
|
||||
RelsType type;
|
||||
RelsType type;
|
||||
|
||||
bool inGroup;
|
||||
size_t id;
|
||||
bool inGroup;
|
||||
size_t id;
|
||||
|
||||
std::wstring name;
|
||||
std::wstring name;
|
||||
int sub_type; //odf
|
||||
|
||||
_INT32 x, y;
|
||||
_INT32 cx, cy;
|
||||
_INT32 x, y;
|
||||
_INT32 cx, cy;
|
||||
|
||||
_oox_fill fill;
|
||||
_oox_fill fill;
|
||||
|
||||
int sub_type; //odf
|
||||
std::wstring chartId;
|
||||
std::wstring objectId;
|
||||
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", bool always_position = false);
|
||||
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);
|
||||
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_bodyPr (std::wostream & strm, _oox_drawing & val, const std::wstring & namespace_ = L"a");
|
||||
|
||||
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_aLst (std::wostream & strm, const std::vector<odf_reader::_property> & val);
|
||||
void oox_serialize_hlink (std::wostream & strm, const std::vector<_hlink_desc> & val);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -74,6 +74,8 @@ static std::wstring get_mime_type(const std::wstring & extension)
|
||||
else if (L"wav" == extension) return L"audio/wav";
|
||||
else if (L"bin" == extension) return L"application/vnd.openxmlformats-officedocument.oleObject";
|
||||
else if (L"xlsx" == extension) return L"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
||||
else if (L"docx" == extension) return L"application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
||||
else if (L"doc" == extension) return L"application/msword";
|
||||
else return L"application/octet-stream";
|
||||
|
||||
|
||||
@ -112,14 +114,48 @@ content_type_content * content_types_file::content()
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
content_type_content_.add_default(extension, get_mime_type(extension));
|
||||
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);
|
||||
}
|
||||
if (extension == L"bin")
|
||||
{
|
||||
//content_type = L"application/vnd.openxmlformats-officedocument.oleObject";
|
||||
|
||||
add_or_find_default(extension);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void content_types_file::set_media(mediaitems & _Mediaitems)
|
||||
{
|
||||
BOOST_FOREACH( mediaitems::item & item, _Mediaitems.items() )
|
||||
@ -283,12 +319,13 @@ void media::write(const std::wstring & RootPath)
|
||||
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"media";
|
||||
FileSystem::Directory::CreateDirectory(path.c_str());
|
||||
|
||||
BOOST_FOREACH( mediaitems::item & item, mediaitems_.items() )
|
||||
mediaitems::items_array & items = mediaitems_.items();
|
||||
for (int i = 0; i < items.size(); i++ )
|
||||
{
|
||||
if (item.mediaInternal && item.valid && item.type == typeImage )
|
||||
if (items[i].mediaInternal && items[i].valid && (items[i].type == typeImage || items[i].type == typeMedia))
|
||||
{
|
||||
std::wstring & file_name = item.href;
|
||||
std::wstring file_name_out = RootPath + FILE_SEPARATOR_STR + item.outputName;
|
||||
std::wstring & file_name = items[i].href;
|
||||
std::wstring file_name_out = RootPath + FILE_SEPARATOR_STR + items[i].outputName;
|
||||
|
||||
CImageFileFormatChecker svmFileChecker;
|
||||
if (svmFileChecker.isSvmFile(file_name))
|
||||
@ -296,14 +333,12 @@ void media::write(const std::wstring & RootPath)
|
||||
ConvertSvmToImage(file_name, file_name_out, appFonts_);
|
||||
}
|
||||
else
|
||||
NSFile::CFileBinary::Copy(item.href, file_name_out);
|
||||
NSFile::CFileBinary::Copy(items[i].href, file_name_out);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
charts::charts(mediaitems & _ChartsItems) : chartsitems_(_ChartsItems)
|
||||
{
|
||||
}
|
||||
@ -312,6 +347,35 @@ 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();
|
||||
|
||||
mediaitems::items_array & items = embeddingsitems_.items();
|
||||
for (int i = 0; i < items.size(); i++ )
|
||||
{
|
||||
if ( items[i].mediaInternal && items[i].valid &&
|
||||
(items[i].type == typeMsObject || items[i].type == typeOleObject))
|
||||
{
|
||||
int pos = items[i].outputName.rfind(L".");
|
||||
std::wstring extension = pos >= 0 ? items[i].outputName.substr(pos + 1) : L"";
|
||||
|
||||
content_types.add_or_find_default(extension);
|
||||
|
||||
std::wstring file_name_out = RootPath + FILE_SEPARATOR_STR + items[i].outputName;
|
||||
|
||||
NSFile::CFileBinary::Copy(items[i].href, file_name_out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,6 +81,7 @@ public:
|
||||
content_types_file ();
|
||||
void write (const std::wstring & RootPath);
|
||||
bool add_or_find_default (const std::wstring & extension);
|
||||
bool add_or_find_override(const std::wstring & fileName);
|
||||
void set_media (mediaitems & _Mediaitems);
|
||||
content_type_content * content ();
|
||||
|
||||
@ -224,7 +225,18 @@ private:
|
||||
mediaitems & chartsitems_;
|
||||
|
||||
};
|
||||
class embeddings : public element
|
||||
{
|
||||
public:
|
||||
embeddings(mediaitems & _EmbeddingsItems);
|
||||
|
||||
public:
|
||||
virtual void write(const std::wstring & RootPath);
|
||||
|
||||
private:
|
||||
mediaitems & embeddingsitems_;
|
||||
|
||||
};
|
||||
} // namespace package
|
||||
} // namespace oox
|
||||
} // namespace cpdoccore
|
||||
|
||||
@ -40,7 +40,20 @@
|
||||
namespace cpdoccore {
|
||||
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,
|
||||
typeMsObject,
|
||||
typeOleObject
|
||||
};
|
||||
|
||||
struct _rel
|
||||
{
|
||||
|
||||
@ -61,16 +61,16 @@ namespace package
|
||||
class pptx_document;
|
||||
}
|
||||
|
||||
pptx_conversion_context::pptx_conversion_context( odf_reader::odf_document * odfDocument):
|
||||
output_document_(NULL)
|
||||
,odf_document_(odfDocument)
|
||||
,pptx_text_context_(odf_document_->odf_context(),*this)
|
||||
,pptx_table_context_(*this)
|
||||
,pptx_comments_context_(comments_context_handle_)
|
||||
,pptx_slide_context_(*this/*, pptx_text_context_*/)
|
||||
,math_context_(true)
|
||||
,last_idx_placeHolder(1)
|
||||
,last_uniq_big_id(1)
|
||||
pptx_conversion_context::pptx_conversion_context( odf_reader::odf_document * odfDocument)
|
||||
:output_document_ (NULL)
|
||||
,odf_document_ (odfDocument)
|
||||
,pptx_text_context_ (odf_document_->odf_context(), *this)
|
||||
,pptx_table_context_ (*this)
|
||||
,pptx_comments_context_ (comments_context_handle_)
|
||||
,pptx_slide_context_ (*this/*, pptx_text_context_*/)
|
||||
,math_context_ (odf_document_->odf_context().fontContainer(), true)
|
||||
,last_idx_placeHolder (1)
|
||||
,last_uniq_big_id (1)
|
||||
{
|
||||
applicationFonts_ = new CApplicationFonts();
|
||||
}
|
||||
@ -514,7 +514,7 @@ void pptx_conversion_context::end_page()
|
||||
}
|
||||
|
||||
get_slide_context().serialize_background(current_slide().Background());
|
||||
get_slide_context().serialize_objects(current_slide().Data());
|
||||
get_slide_context().serialize_objects (current_slide().Data());
|
||||
get_slide_context().serialize_animations(current_slide().Timing());
|
||||
|
||||
get_slide_context().dump_rels(current_slide().Rels());//hyperlinks, mediaitems, ...
|
||||
@ -543,9 +543,9 @@ std::pair<int,int> pptx_conversion_context::add_author_comments(std::wstring aut
|
||||
|
||||
void pptx_conversion_context::end_master()
|
||||
{
|
||||
get_slide_context().serialize_background(current_master().Background(),true);
|
||||
get_slide_context().serialize_objects(current_master().Data());
|
||||
get_slide_context().serialize_HeaderFooter(current_master().DataExtra());
|
||||
get_slide_context().serialize_background (current_master().Background(),true);
|
||||
get_slide_context().serialize_objects (current_master().Data());
|
||||
get_slide_context().serialize_HeaderFooter (current_master().DataExtra());
|
||||
|
||||
get_slide_context().dump_rels(current_master().Rels());//hyperlinks, mediaitems, ...
|
||||
|
||||
|
||||
@ -61,7 +61,8 @@ void pptx_serialize_text(std::wostream & strm, _pptx_drawing & val)
|
||||
{
|
||||
CP_XML_NODE(L"p:txBody")
|
||||
{
|
||||
oox_serialize_bodyPr(CP_XML_STREAM(), val);
|
||||
val.serialize_bodyPr(CP_XML_STREAM());
|
||||
|
||||
if (strTextContent)
|
||||
{
|
||||
CP_XML_STREAM() << strTextContent.get();
|
||||
@ -86,10 +87,10 @@ void pptx_serialize_image(std::wostream & strm, _pptx_drawing & val)
|
||||
{
|
||||
CP_XML_NODE(L"p:cNvPr")
|
||||
{
|
||||
CP_XML_ATTR(L"id", val.id);
|
||||
CP_XML_ATTR(L"name", val.name);
|
||||
CP_XML_ATTR(L"id", val.id);
|
||||
CP_XML_ATTR(L"name", val.name);
|
||||
|
||||
oox_serialize_hlink(CP_XML_STREAM(),val.hlinks);
|
||||
oox_serialize_hlink(CP_XML_STREAM(), val.hlinks);
|
||||
|
||||
}
|
||||
CP_XML_NODE(L"p:cNvPicPr")
|
||||
@ -106,14 +107,14 @@ void pptx_serialize_image(std::wostream & strm, _pptx_drawing & val)
|
||||
|
||||
CP_XML_NODE(L"p:spPr")
|
||||
{
|
||||
oox_serialize_xfrm(CP_XML_STREAM(),val);
|
||||
val.serialize_xfrm(CP_XML_STREAM(), L"a", true);
|
||||
|
||||
CP_XML_NODE(L"a:prstGeom")
|
||||
{
|
||||
CP_XML_ATTR(L"prst", L"rect");
|
||||
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;
|
||||
//odf::GetProperty(properties,L"text-content",strTextContent);
|
||||
@ -169,13 +170,13 @@ void pptx_serialize_shape(std::wostream & strm, _pptx_drawing & val)
|
||||
|
||||
if (!bNoRect)
|
||||
{
|
||||
oox_serialize_xfrm(CP_XML_STREAM(),val);
|
||||
val.serialize_xfrm(CP_XML_STREAM(), L"a", true);
|
||||
val.serialize_shape(CP_XML_STREAM());
|
||||
|
||||
oox_serialize_shape(CP_XML_STREAM(),val);
|
||||
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
|
||||
}
|
||||
@ -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:nvPr");
|
||||
}
|
||||
oox_serialize_xfrm(CP_XML_STREAM(),val,L"p");
|
||||
val.serialize_xfrm(CP_XML_STREAM(), L"p", true);
|
||||
|
||||
//oox_serialize_ln(CP_XML_STREAM(),val.additional);
|
||||
|
||||
@ -210,14 +211,13 @@ 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: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);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // p:graphicFrame
|
||||
} // CP_XML_WRITER
|
||||
}
|
||||
|
||||
void pptx_serialize_table(std::wostream & strm, _pptx_drawing & val)
|
||||
{
|
||||
CP_XML_WRITER(strm)
|
||||
@ -235,7 +235,7 @@ void pptx_serialize_table(std::wostream & strm, _pptx_drawing & val)
|
||||
CP_XML_NODE(L"p:cNvGraphicFramePr");
|
||||
CP_XML_NODE(L"p:nvPr");
|
||||
}
|
||||
oox_serialize_xfrm(CP_XML_STREAM(),val,L"p");
|
||||
val.serialize_xfrm(CP_XML_STREAM(), L"p", true);
|
||||
|
||||
//oox_serialize_ln(CP_XML_STREAM(),val.additional);
|
||||
|
||||
@ -258,23 +258,73 @@ void pptx_serialize_table(std::wostream & strm, _pptx_drawing & val)
|
||||
} // CP_XML_WRITER
|
||||
}
|
||||
|
||||
void pptx_serialize(std::wostream & strm, _pptx_drawing & val)
|
||||
|
||||
void pptx_serialize_object(std::wostream & strm, _pptx_drawing & val)
|
||||
{
|
||||
if (val.type == typeShape)
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"p:graphicFrame")
|
||||
{
|
||||
CP_XML_NODE(L"p:nvGraphicFramePr")
|
||||
{
|
||||
CP_XML_NODE(L"p:cNvPr")
|
||||
{
|
||||
CP_XML_ATTR(L"id", val.id);
|
||||
CP_XML_ATTR(L"name", val.name);
|
||||
}
|
||||
|
||||
CP_XML_NODE(L"p:cNvGraphicFramePr");
|
||||
CP_XML_NODE(L"p:nvPr");
|
||||
}
|
||||
val.serialize_xfrm(CP_XML_STREAM(), L"p", true);
|
||||
|
||||
//oox_serialize_ln(CP_XML_STREAM(),val.additional);
|
||||
|
||||
CP_XML_NODE(L"a:graphic")
|
||||
{
|
||||
CP_XML_NODE(L"a:graphicData")
|
||||
{
|
||||
CP_XML_ATTR(L"uri", L"http://schemas.openxmlformats.org/presentationml/2006/ole");
|
||||
CP_XML_NODE(L"p:oleObj")
|
||||
{
|
||||
CP_XML_ATTR(L"r:id", val.objectId);
|
||||
CP_XML_ATTR(L"progId", val.objectProgId);
|
||||
CP_XML_ATTR(L"imgW", val.cx );
|
||||
CP_XML_ATTR(L"imgH", val.cy );
|
||||
CP_XML_NODE(L"p:embed");
|
||||
|
||||
val.id = 0;
|
||||
pptx_serialize_image(CP_XML_STREAM(), val);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // p:graphicFrame
|
||||
} // CP_XML_WRITER
|
||||
}
|
||||
|
||||
|
||||
void _pptx_drawing::serialize(std::wostream & strm)
|
||||
{
|
||||
if (type == typeShape)
|
||||
{
|
||||
pptx_serialize_shape(strm,val);
|
||||
pptx_serialize_shape(strm, *this);
|
||||
}
|
||||
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);
|
||||
}
|
||||
else if (type == typeMsObject ||
|
||||
type == typeOleObject)
|
||||
{
|
||||
pptx_serialize_object(strm, *this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -43,13 +43,15 @@
|
||||
namespace cpdoccore {
|
||||
namespace oox {
|
||||
|
||||
struct _pptx_drawing : _oox_drawing
|
||||
class _pptx_drawing : public _oox_drawing
|
||||
{
|
||||
_pptx_drawing(): place_holder_idx_(-1){}
|
||||
std::wstring place_holder_type_;
|
||||
int place_holder_idx_;
|
||||
public:
|
||||
_pptx_drawing(): _oox_drawing(), place_holder_idx_(-1) {}
|
||||
|
||||
std::wstring place_holder_type_;
|
||||
int place_holder_idx_;
|
||||
|
||||
friend void pptx_serialize(std::wostream & _Wostream, _pptx_drawing & val);
|
||||
void serialize (std::wostream & _Wostream);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -34,7 +34,6 @@
|
||||
#include <vector>
|
||||
#include <cpdoccore/xml/simple_xml_writer.h>
|
||||
|
||||
#include "mediaitems_utils.h"
|
||||
#include "oox_rels.h"
|
||||
|
||||
#include "pptx_drawings.h"
|
||||
@ -57,18 +56,18 @@ public:
|
||||
pptx_drawings_.push_back(d);
|
||||
|
||||
bool present = false;
|
||||
BOOST_FOREACH(_rel const & r, pptx_drawing_rels_)
|
||||
for (int i = 0; i < pptx_drawing_rels_.size(); i++)
|
||||
{
|
||||
if (r.rid == rid && r.ref == ref)
|
||||
if (pptx_drawing_rels_[i].rid == rid && pptx_drawing_rels_[i].ref == ref)
|
||||
present = true;
|
||||
}
|
||||
if (!present)
|
||||
{
|
||||
pptx_drawing_rels_.push_back(_rel(isInternal, rid, ref, type));
|
||||
}
|
||||
BOOST_FOREACH(_hlink_desc h, d.hlinks)
|
||||
for (int i = 0; i < d.hlinks.size(); i++)
|
||||
{
|
||||
pptx_drawing_rels_.push_back(_rel(false, h.hId, h.hRef, typeHyperlink));
|
||||
pptx_drawing_rels_.push_back(_rel(false, d.hlinks[i].hId, d.hlinks[i].hRef, typeHyperlink));
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,21 +79,22 @@ public:
|
||||
{
|
||||
|
||||
bool present = false;
|
||||
BOOST_FOREACH(_rel const & r, pptx_drawing_rels_)
|
||||
for (int i = 0; i < pptx_drawing_rels_.size(); i++)
|
||||
{
|
||||
if (r.rid == rid && r.ref == ref)
|
||||
if (pptx_drawing_rels_[i].rid == rid && pptx_drawing_rels_[i].ref == ref)
|
||||
present = true;
|
||||
}
|
||||
if (!present)
|
||||
{
|
||||
if (type == typeHyperlink) isInternal = false;
|
||||
pptx_drawing_rels_.push_back(_rel(isInternal, rid, ref, type));
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,47 +105,28 @@ public:
|
||||
|
||||
void dump_rels(rels & Rels)
|
||||
{
|
||||
BOOST_FOREACH(_rel const & r, pptx_drawing_rels_)
|
||||
for (int i = 0; i < pptx_drawing_rels_.size(); i++)
|
||||
{
|
||||
if (r.type == typeChart)//временно - нужно потом все загнать в релс
|
||||
if (pptx_drawing_rels_[i].type == typeUnknown ||
|
||||
pptx_drawing_rels_[i].type == typeTable ||
|
||||
pptx_drawing_rels_[i].type == typeShape ||
|
||||
pptx_drawing_rels_[i].type == typeGroupShape) continue;
|
||||
|
||||
if (pptx_drawing_rels_[i].type == typeComment)
|
||||
{
|
||||
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 == 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")
|
||||
);
|
||||
}
|
||||
else if (r.type == typeComment)
|
||||
{
|
||||
Rels.add(relationship(
|
||||
r.rid,
|
||||
Rels.add(relationship( pptx_drawing_rels_[i].rid,
|
||||
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",
|
||||
r.ref)
|
||||
);
|
||||
pptx_drawing_rels_[i].ref) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Rels.add(relationship( pptx_drawing_rels_[i].rid,
|
||||
mediaitems::get_rel_type(pptx_drawing_rels_[i].type),
|
||||
(pptx_drawing_rels_[i].is_internal ? std::wstring(L"../") + pptx_drawing_rels_[i].ref : pptx_drawing_rels_[i].ref),
|
||||
(pptx_drawing_rels_[i].is_internal ? L"" : L"External")) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@ -40,8 +40,7 @@
|
||||
namespace cpdoccore {
|
||||
namespace oox {
|
||||
|
||||
struct _pptx_drawing;
|
||||
|
||||
class _pptx_drawing;
|
||||
class rels;
|
||||
|
||||
class pptx_drawings;
|
||||
|
||||
@ -33,10 +33,6 @@
|
||||
#include "pptx_package.h"
|
||||
#include "pptx_output_xml.h"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
|
||||
#include <cpdoccore/utf8cpp/utf8.h>
|
||||
|
||||
namespace cpdoccore {
|
||||
@ -99,11 +95,13 @@ void slide_content::add_rel(relationship const & r)
|
||||
rels_->get_rels().add(r);
|
||||
}
|
||||
|
||||
void slide_content::add_rels(rels & r)
|
||||
void slide_content::add_rels(rels & _r)
|
||||
{
|
||||
BOOST_FOREACH(relationship & item, r.relationships())
|
||||
std::vector<relationship> & r = _r.relationships();
|
||||
|
||||
for (int i = 0; i < r.size(); i++)
|
||||
{
|
||||
rels_->get_rels().add(item);
|
||||
rels_->get_rels().add(r[i]);
|
||||
}
|
||||
}
|
||||
////////////
|
||||
@ -124,33 +122,29 @@ void slides_files::write(const std::wstring & RootPath)
|
||||
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
|
||||
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.slide+xml";
|
||||
|
||||
size_t count = 0;
|
||||
|
||||
BOOST_FOREACH(const slide_content_ptr & item, slides_)
|
||||
for (int i = 0; i < slides_.size(); i++)
|
||||
{
|
||||
if (item)
|
||||
if (!slides_[i]) continue;
|
||||
|
||||
const std::wstring fileName = std::wstring(L"slide") + std::to_wstring( i + 1 ) + L".xml";
|
||||
|
||||
contentTypes->add_override(std::wstring(L"/ppt/slides/") + fileName, kWSConType);
|
||||
|
||||
if (rels_)
|
||||
{
|
||||
count++;
|
||||
const std::wstring fileName = std::wstring(L"slide") + boost::lexical_cast<std::wstring>(count) + L".xml";
|
||||
|
||||
contentTypes->add_override(std::wstring(L"/ppt/slides/") + fileName, kWSConType);
|
||||
|
||||
if (rels_)
|
||||
{
|
||||
const std::wstring id = std::wstring(L"sId") + boost::lexical_cast<std::wstring>(count);
|
||||
static const std::wstring kWSRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide";
|
||||
const std::wstring fileRef = std::wstring(L"slides/") + fileName;
|
||||
rels_->add(id, kWSRel, fileRef);
|
||||
}
|
||||
|
||||
item->get_rel_file()->set_file_name(fileName + L".rels");//внитренние релсы
|
||||
|
||||
rels_files relFiles;
|
||||
relFiles.add_rel_file(item->get_rel_file());
|
||||
relFiles.write(path);
|
||||
|
||||
package::simple_element(fileName, item->str()).write(path);
|
||||
const std::wstring id = std::wstring(L"sId") + std::to_wstring( i + 1);
|
||||
static const std::wstring kWSRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide";
|
||||
const std::wstring fileRef = std::wstring(L"slides/") + fileName;
|
||||
rels_->add(id, kWSRel, fileRef);
|
||||
}
|
||||
|
||||
slides_[i]->get_rel_file()->set_file_name(fileName + L".rels");//внитренние релсы
|
||||
|
||||
rels_files relFiles;
|
||||
relFiles.add_rel_file(slides_[i]->get_rel_file());
|
||||
relFiles.write(path);
|
||||
|
||||
package::simple_element(fileName, slides_[i]->str()).write(path);
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,32 +165,28 @@ void slideMasters_files::write(const std::wstring & RootPath)
|
||||
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
|
||||
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml";
|
||||
|
||||
size_t count = 0;
|
||||
|
||||
BOOST_FOREACH(const slide_content_ptr & item, slides_)
|
||||
for (int i = 0; i < slides_.size(); i++)
|
||||
{
|
||||
if (item)
|
||||
if (!slides_[i]) continue;
|
||||
|
||||
const std::wstring fileName = std::wstring(L"slideMaster") + std::to_wstring( i + 1 ) + L".xml";
|
||||
contentTypes->add_override(std::wstring(L"/ppt/slideMasters/") + fileName, kWSConType);
|
||||
|
||||
if (rels_)
|
||||
{
|
||||
count++;
|
||||
const std::wstring fileName = std::wstring(L"slideMaster") + boost::lexical_cast<std::wstring>(count) + L".xml";
|
||||
contentTypes->add_override(std::wstring(L"/ppt/slideMasters/") + fileName, kWSConType);
|
||||
|
||||
if (rels_)
|
||||
{
|
||||
const std::wstring id = std::wstring(L"smId") + boost::lexical_cast<std::wstring>(count);
|
||||
static const std::wstring kWSRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster";
|
||||
const std::wstring fileRef = std::wstring(L"slideMasters/") + fileName;
|
||||
rels_->add(id, kWSRel, fileRef);
|
||||
}
|
||||
|
||||
item->get_rel_file()->set_file_name(fileName + L".rels");//внитренние релсы
|
||||
|
||||
rels_files relFiles;
|
||||
relFiles.add_rel_file(item->get_rel_file());
|
||||
relFiles.write(path);
|
||||
|
||||
package::simple_element(fileName, item->str()).write(path);
|
||||
const std::wstring id = std::wstring(L"smId") + std::to_wstring( i + 1);
|
||||
static const std::wstring kWSRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster";
|
||||
const std::wstring fileRef = std::wstring(L"slideMasters/") + fileName;
|
||||
rels_->add(id, kWSRel, fileRef);
|
||||
}
|
||||
|
||||
slides_[i]->get_rel_file()->set_file_name(fileName + L".rels");//внитренние релсы
|
||||
|
||||
rels_files relFiles;
|
||||
relFiles.add_rel_file(slides_[i]->get_rel_file());
|
||||
relFiles.write(path);
|
||||
|
||||
package::simple_element(fileName, slides_[i]->str()).write(path);
|
||||
}
|
||||
}
|
||||
|
||||
@ -214,27 +204,23 @@ void slideLayouts_files::write(const std::wstring & RootPath)
|
||||
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"slideLayouts" ;
|
||||
FileSystem::Directory::CreateDirectory(path.c_str());
|
||||
|
||||
size_t count = 0;
|
||||
|
||||
BOOST_FOREACH(const slide_content_ptr & item, slides_)
|
||||
for (int i = 0; i < slides_.size(); i++)
|
||||
{
|
||||
if (item)
|
||||
{
|
||||
count++;
|
||||
const std::wstring fileName = std::wstring(L"slideLayout") + boost::lexical_cast<std::wstring>(count) + L".xml";
|
||||
const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml";
|
||||
|
||||
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
|
||||
contentTypes->add_override(std::wstring(L"/ppt/slideLayouts/") + fileName, kWSConType);
|
||||
if (!slides_[i]) continue;
|
||||
|
||||
item->get_rel_file()->set_file_name(fileName + L".rels");//внитренние релсы
|
||||
|
||||
rels_files relFiles;
|
||||
relFiles.add_rel_file(item->get_rel_file());
|
||||
relFiles.write(path);
|
||||
const std::wstring fileName = std::wstring(L"slideLayout") + std::to_wstring( i + 1 ) + L".xml";
|
||||
const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml";
|
||||
|
||||
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
|
||||
contentTypes->add_override(std::wstring(L"/ppt/slideLayouts/") + fileName, kWSConType);
|
||||
|
||||
package::simple_element(fileName, item->str()).write(path);
|
||||
}
|
||||
slides_[i]->get_rel_file()->set_file_name(fileName + L".rels");//внитренние релсы
|
||||
|
||||
rels_files relFiles;
|
||||
relFiles.add_rel_file(slides_[i]->get_rel_file());
|
||||
relFiles.write(path);
|
||||
|
||||
package::simple_element(fileName, slides_[i]->str()).write(path);
|
||||
}
|
||||
}
|
||||
|
||||
@ -270,28 +256,24 @@ void ppt_charts_files::write(const std::wstring & RootPath)
|
||||
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"charts";
|
||||
FileSystem::Directory::CreateDirectory(path.c_str());
|
||||
|
||||
size_t count = 0;
|
||||
|
||||
BOOST_FOREACH(const chart_content_ptr & item, charts_)
|
||||
for (int i = 0; i < charts_.size(); i++)
|
||||
{
|
||||
if (item)
|
||||
{
|
||||
count++;
|
||||
const std::wstring fileName = std::wstring(L"chart") + boost::lexical_cast<std::wstring>(count) + L".xml";
|
||||
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
|
||||
|
||||
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml";
|
||||
contentTypes->add_override(std::wstring(L"/ppt/charts/") + fileName, kWSConType);
|
||||
if (!charts_[i]) continue;
|
||||
|
||||
const std::wstring fileName = std::wstring(L"chart") + std::to_wstring( i + 1 ) + L".xml";
|
||||
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
|
||||
|
||||
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml";
|
||||
contentTypes->add_override(std::wstring(L"/ppt/charts/") + fileName, kWSConType);
|
||||
|
||||
package::simple_element(fileName, item->str()).write(path);
|
||||
|
||||
rels_files relFiles;
|
||||
package::simple_element(fileName, charts_[i]->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);
|
||||
}
|
||||
charts_[i]->get_rel_file()->set_file_name(fileName + L".rels");
|
||||
|
||||
relFiles.add_rel_file(charts_[i]->get_rel_file());
|
||||
relFiles.write(path);
|
||||
}
|
||||
}
|
||||
///////////////////////////////////
|
||||
@ -304,24 +286,19 @@ void ppt_themes_files::write(const std::wstring & RootPath)
|
||||
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"theme" ;
|
||||
FileSystem::Directory::CreateDirectory(path.c_str());
|
||||
|
||||
size_t count = 0;
|
||||
|
||||
BOOST_FOREACH(const pptx_xml_theme_ptr & item, themes_)
|
||||
for (int i = 0; i < themes_.size(); i++)
|
||||
{
|
||||
if (item)
|
||||
{
|
||||
count++;
|
||||
if (!themes_[i]) continue;
|
||||
|
||||
const std::wstring fileName = std::wstring(L"theme") + boost::lexical_cast<std::wstring>(count) + L".xml";
|
||||
const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.theme+xml";
|
||||
|
||||
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
|
||||
contentTypes->add_override(std::wstring(L"/ppt/theme/") + fileName, kWSConType);
|
||||
const std::wstring fileName = std::wstring(L"theme") + std::to_wstring( i + 1) + L".xml";
|
||||
const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.theme+xml";
|
||||
|
||||
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
|
||||
contentTypes->add_override(std::wstring(L"/ppt/theme/") + fileName, kWSConType);
|
||||
|
||||
std::wstringstream content;
|
||||
item->write_to(content);
|
||||
package::simple_element(fileName, content.str()).write(path);
|
||||
}
|
||||
std::wstringstream content;
|
||||
themes_[i]->write_to(content);
|
||||
package::simple_element(fileName, content.str()).write(path);
|
||||
}
|
||||
}
|
||||
//////////////////////////////
|
||||
@ -335,14 +312,14 @@ void ppt_comments_files::write(const std::wstring & RootPath)
|
||||
std::wstring comm_path = RootPath + FILE_SEPARATOR_STR + L"comments";
|
||||
FileSystem::Directory::CreateDirectory(comm_path.c_str());
|
||||
|
||||
BOOST_FOREACH(pptx_comment_elm const & e, comments_)
|
||||
for (int i = 0; i < comments_.size(); i++)
|
||||
{
|
||||
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
|
||||
|
||||
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.comments+xml";
|
||||
contentTypes->add_override(std::wstring(L"/ppt/comments/") + e.filename, kWSConType);
|
||||
contentTypes->add_override(std::wstring(L"/ppt/comments/") + comments_[i].filename, kWSConType);
|
||||
|
||||
package::simple_element(e.filename, e.content).write( comm_path);
|
||||
package::simple_element(comments_[i].filename, comments_[i].content).write( comm_path);
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////
|
||||
@ -386,7 +363,12 @@ void ppt_files::write(const std::wstring & RootPath)
|
||||
media_->set_main_document(get_main_document());
|
||||
media_->write(path);
|
||||
}
|
||||
if (embeddings_)
|
||||
{
|
||||
embeddings_->set_main_document(get_main_document());
|
||||
embeddings_->write(path);
|
||||
}
|
||||
{
|
||||
charts_files_.set_main_document(get_main_document());
|
||||
charts_files_.write(path);
|
||||
}
|
||||
@ -440,7 +422,14 @@ void ppt_files::add_slideMaster(slide_content_ptr slide)
|
||||
|
||||
void ppt_files::set_media(mediaitems & _Mediaitems, CApplicationFonts *pAppFonts)
|
||||
{
|
||||
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
|
||||
if (_Mediaitems.count_image + _Mediaitems.count_media > 0)
|
||||
{
|
||||
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
|
||||
}
|
||||
if (_Mediaitems.count_object > 0)
|
||||
{
|
||||
embeddings_ = element_ptr( new embeddings(_Mediaitems) );
|
||||
}
|
||||
}
|
||||
void ppt_files::set_authors_comments(pptx_xml_authors_comments_ptr & authors_comments)
|
||||
{
|
||||
|
||||
@ -238,6 +238,7 @@ private:
|
||||
|
||||
element_ptr comments_;
|
||||
element_ptr media_;
|
||||
element_ptr embeddings_;
|
||||
};
|
||||
|
||||
// xlsx_document
|
||||
|
||||
@ -36,8 +36,6 @@
|
||||
#include <cpdoccore/xml/utils.h>
|
||||
#include <cpdoccore/odf/odf_document.h>
|
||||
|
||||
#include "mediaitems_utils.h"
|
||||
|
||||
#include "pptx_drawing.h"
|
||||
#include "pptx_drawings.h"
|
||||
#include "pptx_slide_context.h"
|
||||
@ -73,16 +71,12 @@ public:
|
||||
clear();
|
||||
}
|
||||
|
||||
drawing_object_description object_description_;
|
||||
drawing_object_description object_description_;
|
||||
std::vector<drawing_object_description> objects_;
|
||||
|
||||
std::vector<drawing_object_description> images_;
|
||||
std::vector<drawing_object_description> charts_;
|
||||
std::vector<drawing_object_description> shapes_;
|
||||
std::vector<drawing_object_description> tables_;
|
||||
|
||||
_CP_OPT(_oox_fill) background_fill_;
|
||||
|
||||
_transition transition_;
|
||||
_CP_OPT(_oox_fill) background_fill_;
|
||||
_transition transition_;
|
||||
bool use_image_replacement_;
|
||||
|
||||
bool header, footer, date_time, slideNum;
|
||||
|
||||
@ -111,10 +105,7 @@ public:
|
||||
|
||||
void clear()
|
||||
{
|
||||
images_.clear();
|
||||
charts_.clear();
|
||||
shapes_.clear();
|
||||
tables_.clear();
|
||||
objects_.clear();
|
||||
|
||||
background_fill_ = boost::none;
|
||||
|
||||
@ -142,14 +133,46 @@ public:
|
||||
return pptx_drawings_;
|
||||
}
|
||||
std::wstring odfPacket_;
|
||||
|
||||
void process_drawings();
|
||||
|
||||
private:
|
||||
void process_common_properties(drawing_object_description& obj,_pptx_drawing & drawing);
|
||||
|
||||
void process_shape (drawing_object_description& obj, _pptx_drawing & drawing);
|
||||
void process_image (drawing_object_description& obj, _pptx_drawing & drawing);
|
||||
void process_chart (drawing_object_description& obj, _pptx_drawing & drawing);
|
||||
void process_table (drawing_object_description& obj, _pptx_drawing & drawing);
|
||||
void process_object (drawing_object_description& obj, _pptx_drawing & drawing);
|
||||
|
||||
size_t rId_;
|
||||
mediaitems mediaitems_;
|
||||
pptx_drawings_ptr pptx_drawings_;
|
||||
};
|
||||
|
||||
void pptx_slide_context::Impl::process_drawings()
|
||||
{
|
||||
for (int i = 0; i < objects_.size(); i++)
|
||||
{
|
||||
_pptx_drawing drawing =_pptx_drawing();
|
||||
|
||||
drawing.type = objects_[i].type_;
|
||||
drawing.name = objects_[i].name_;
|
||||
drawing.id = next_rId();
|
||||
|
||||
process_common_properties(objects_[i], drawing);
|
||||
|
||||
switch(objects_[i].type_)
|
||||
{
|
||||
case typeImage: process_image(objects_[i], drawing); break;
|
||||
case typeChart: process_chart(objects_[i], drawing); break;
|
||||
case typeShape: process_shape(objects_[i], drawing); break;
|
||||
case typeTable: process_table(objects_[i], drawing); break;
|
||||
case typeMsObject:
|
||||
case typeOleObject: process_object(objects_[i], drawing); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pptx_slide_context::pptx_slide_context(pptx_conversion_context & Context)
|
||||
: impl_(new pptx_slide_context::Impl(Context.root()->get_folder()))
|
||||
@ -200,12 +223,11 @@ void pptx_slide_context::set_transitionSpeed(std::wstring val)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void pptx_slide_context::default_set()
|
||||
{
|
||||
impl_->object_description_.xlink_href_ = L"";
|
||||
|
||||
impl_->object_description_.name_ = L"";
|
||||
|
||||
impl_->object_description_.xlink_href_ = L"";
|
||||
impl_->object_description_.name_ = L"";
|
||||
impl_->object_description_.descriptor_ = L"";
|
||||
impl_->object_description_.anchor_ = L"";
|
||||
impl_->object_description_.additional_.clear();
|
||||
impl_->object_description_.anchor_ =L"";
|
||||
|
||||
impl_->object_description_.clipping_string_= L"";
|
||||
impl_->object_description_.svg_rect_ = boost::none;
|
||||
@ -215,7 +237,12 @@ void pptx_slide_context::default_set()
|
||||
|
||||
impl_->object_description_.fill_.clear();
|
||||
|
||||
impl_->object_description_.use_image_replace_ = false;
|
||||
impl_->use_image_replacement_ = false;
|
||||
}
|
||||
|
||||
void pptx_slide_context::set_use_image_replacement()
|
||||
{
|
||||
impl_->use_image_replacement_ = true;
|
||||
}
|
||||
|
||||
void pptx_slide_context::set_placeHolder_type(std::wstring typeHolder)
|
||||
@ -341,54 +368,72 @@ void pptx_slide_context::start_shape(int type)
|
||||
impl_->object_description_.shape_type_ = type; //2,3...
|
||||
}
|
||||
|
||||
void pptx_slide_context::start_image(std::wstring const & path)
|
||||
{
|
||||
impl_->object_description_.type_ = typeImage;
|
||||
impl_->object_description_.xlink_href_ = path;
|
||||
}
|
||||
|
||||
void pptx_slide_context::start_table()
|
||||
{
|
||||
impl_->object_description_.type_ = typeTable;
|
||||
impl_->object_description_.type_ = typeTable;
|
||||
}
|
||||
|
||||
void pptx_slide_context::set_use_image_replacement()
|
||||
void pptx_slide_context::set_text_box()
|
||||
{
|
||||
impl_->object_description_.use_image_replace_ = true;
|
||||
impl_->object_description_.type_ = typeShape;
|
||||
impl_->object_description_.shape_type_ = 2; //2,3...
|
||||
}
|
||||
|
||||
void pptx_slide_context::start_object_ole()
|
||||
void pptx_slide_context::set_ms_object(const std::wstring & path, const std::wstring & progId)
|
||||
{
|
||||
impl_->object_description_.type_ = typeMsObject;
|
||||
impl_->object_description_.xlink_href_ = path;
|
||||
impl_->object_description_.descriptor_ = progId;
|
||||
}
|
||||
void pptx_slide_context::set_ole_object(const std::wstring & path, const std::wstring & progId)
|
||||
{
|
||||
impl_->object_description_.type_ = typeOleObject;
|
||||
impl_->object_description_.xlink_href_ = path;
|
||||
impl_->object_description_.descriptor_ = progId;
|
||||
}
|
||||
|
||||
void pptx_slide_context::start_chart(std::wstring const & path)
|
||||
void pptx_slide_context::set_image(const std::wstring & path)
|
||||
{
|
||||
if (impl_->object_description_.type_ == typeUnknown)
|
||||
{
|
||||
impl_->object_description_.type_ = typeImage;
|
||||
impl_->object_description_.xlink_href_ = path;
|
||||
}
|
||||
else if (impl_->use_image_replacement_)
|
||||
{
|
||||
impl_->object_description_.fill_.type = 2;
|
||||
impl_->object_description_.fill_.bitmap = oox::oox_bitmap_fill::create();
|
||||
impl_->object_description_.fill_.bitmap->xlink_href_ = path;
|
||||
impl_->object_description_.fill_.bitmap->bStretch = true;
|
||||
}
|
||||
}
|
||||
|
||||
void pptx_slide_context::start_frame()
|
||||
{
|
||||
impl_->object_description_.type_ = typeUnknown;
|
||||
}
|
||||
|
||||
void pptx_slide_context::set_chart(const std::wstring & path)
|
||||
{
|
||||
impl_->object_description_.type_ = typeChart;
|
||||
impl_->object_description_.xlink_href_ = path;
|
||||
}
|
||||
void pptx_slide_context::end_object_ole()
|
||||
|
||||
void pptx_slide_context::end_frame()
|
||||
{
|
||||
}
|
||||
void pptx_slide_context::end_shape()
|
||||
{
|
||||
impl_->shapes_.push_back(impl_->object_description_);
|
||||
impl_->objects_.push_back(impl_->object_description_);
|
||||
default_set();
|
||||
}
|
||||
|
||||
void pptx_slide_context::end_image()
|
||||
|
||||
void pptx_slide_context::end_shape()
|
||||
{
|
||||
impl_->images_.push_back(impl_->object_description_);
|
||||
default_set();
|
||||
}
|
||||
void pptx_slide_context::end_chart()
|
||||
{
|
||||
impl_->charts_.push_back(impl_->object_description_);
|
||||
impl_->objects_.push_back(impl_->object_description_);
|
||||
default_set();
|
||||
}
|
||||
|
||||
void pptx_slide_context::end_table()
|
||||
{
|
||||
impl_->tables_.push_back(impl_->object_description_);
|
||||
impl_->objects_.push_back(impl_->object_description_);
|
||||
default_set();
|
||||
}
|
||||
|
||||
@ -399,112 +444,115 @@ bool pptx_slide_context::empty() const
|
||||
|
||||
void pptx_slide_context::process_drawings()
|
||||
{
|
||||
process_shapes();
|
||||
process_images();
|
||||
process_tables();
|
||||
process_charts();
|
||||
return impl_->process_drawings();
|
||||
}
|
||||
|
||||
void pptx_slide_context::process_images()
|
||||
void pptx_slide_context::Impl::process_image(drawing_object_description& pic, _pptx_drawing & drawing)
|
||||
{
|
||||
int pos_replaicement=0, pos_preview=0;
|
||||
int pos_replaicement = 0, pos_preview = 0;
|
||||
|
||||
BOOST_FOREACH(drawing_object_description & pic, impl_->images_)
|
||||
{
|
||||
pos_replaicement = pic.xlink_href_.find(L"ObjectReplacements");
|
||||
pos_preview = pic.xlink_href_.find(L"TablePreview");
|
||||
|
||||
if ((pos_replaicement <0 && pos_preview <0) || pic.use_image_replace_)//оригинал, а не заменяемый объект (при наличии объекта)
|
||||
{
|
||||
_pptx_drawing drawing =_pptx_drawing();
|
||||
|
||||
drawing.type = pic.type_;
|
||||
drawing.name = pic.name_;
|
||||
drawing.id = impl_->next_rId();
|
||||
|
||||
process_common_properties(pic,drawing);
|
||||
|
||||
drawing.fill.bitmap = oox_bitmap_fill::create();
|
||||
drawing.fill.type = 2;
|
||||
|
||||
_CP_OPT(std::wstring) sTextContent;
|
||||
GetProperty(pic.additional_,L"text-content",sTextContent);
|
||||
if (sTextContent)//в ms office на картинке нельзя сделать надпись - меняем тип на рект с заливкой картинкой
|
||||
{
|
||||
drawing.type = typeShape;
|
||||
drawing.sub_type = 2;//rect
|
||||
}
|
||||
|
||||
drawing.fill.bitmap = oox_bitmap_fill::create();
|
||||
drawing.fill.type = 2;
|
||||
|
||||
_CP_OPT(std::wstring) sTextContent;
|
||||
GetProperty(pic.additional_, L"text-content", sTextContent);
|
||||
if (sTextContent)//в ms office на картинке нельзя сделать надпись - меняем тип на рект с заливкой картинкой
|
||||
{
|
||||
drawing.type = typeShape;
|
||||
drawing.sub_type = 2;//rect
|
||||
}
|
||||
|
||||
std::wstring fileName = impl_->odfPacket_ + FILE_SEPARATOR_STR + pic.xlink_href_;
|
||||
drawing.fill.bitmap->bCrop = odf_reader::parse_clipping(pic.clipping_string_,fileName,drawing.fill.bitmap->cropRect, NULL);
|
||||
drawing.fill.bitmap->bStretch = true;
|
||||
std::wstring fileName = odfPacket_ + FILE_SEPARATOR_STR + pic.xlink_href_;
|
||||
drawing.fill.bitmap->bCrop = odf_reader::parse_clipping(pic.clipping_string_,fileName,drawing.fill.bitmap->cropRect, NULL);
|
||||
drawing.fill.bitmap->bStretch = true;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
std::wstring ref;/// это ссылка на выходной внешний объект
|
||||
bool isMediaInternal = false;
|
||||
|
||||
drawing.fill.bitmap->rId = impl_->get_mediaitems().add_or_find(pic.xlink_href_, typeImage, isMediaInternal, ref);
|
||||
|
||||
if (drawing.type == typeShape)
|
||||
{
|
||||
impl_->add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);//собственно это не объект, а доп рел и ref объекта
|
||||
|
||||
isMediaInternal = true;
|
||||
std::wstring rId = impl_->get_mediaitems().add_or_find(L"", typeShape, isMediaInternal, ref);
|
||||
impl_->add_drawing(drawing, isMediaInternal, rId, ref, typeShape);//объект
|
||||
std::wstring ref;/// это ссылка на выходной внешний объект
|
||||
bool isMediaInternal = false;
|
||||
|
||||
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(pic.xlink_href_, typeImage, isMediaInternal, ref);
|
||||
|
||||
if (drawing.type == typeShape)
|
||||
{
|
||||
add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);//собственно это не объект, а доп рел и ref объекта
|
||||
|
||||
isMediaInternal = true;
|
||||
std::wstring rId = get_mediaitems().add_or_find(L"", typeShape, isMediaInternal, ref);
|
||||
add_drawing(drawing, isMediaInternal, rId, ref, typeShape);//объект
|
||||
|
||||
}else if (!drawing.fill.bitmap->rId.empty())
|
||||
{
|
||||
impl_->add_drawing(drawing, isMediaInternal, drawing.fill.bitmap->rId , ref, drawing.type);//объект
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}else if (!drawing.fill.bitmap->rId.empty())
|
||||
{
|
||||
add_drawing(drawing, isMediaInternal, drawing.fill.bitmap->rId , ref, drawing.type);//объект
|
||||
}
|
||||
}
|
||||
void pptx_slide_context::process_charts()
|
||||
void pptx_slide_context::Impl::process_chart(drawing_object_description & obj, _pptx_drawing & drawing)
|
||||
{
|
||||
BOOST_FOREACH(drawing_object_description & pic, impl_->charts_)
|
||||
{
|
||||
_pptx_drawing drawing=_pptx_drawing();
|
||||
|
||||
drawing.type = pic.type_;
|
||||
drawing.name = pic.name_;
|
||||
drawing.id = impl_->next_rId();
|
||||
|
||||
process_common_properties(pic,drawing);
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
std::wstring ref;
|
||||
bool isMediaInternal = true;
|
||||
drawing.chartId = impl_->get_mediaitems().add_or_find(pic.xlink_href_, typeChart, isMediaInternal, ref);
|
||||
impl_->add_drawing(drawing, isMediaInternal, drawing.chartId, ref, typeChart);
|
||||
}
|
||||
std::wstring ref;
|
||||
bool isMediaInternal = true;
|
||||
|
||||
drawing.objectId = get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
|
||||
add_drawing(drawing, isMediaInternal, drawing.objectId, ref, drawing.type);
|
||||
}
|
||||
|
||||
void pptx_slide_context::process_tables()
|
||||
void pptx_slide_context::Impl::process_table(drawing_object_description & obj, _pptx_drawing & drawing)
|
||||
{
|
||||
BOOST_FOREACH(drawing_object_description & pic, impl_->tables_)
|
||||
{
|
||||
_pptx_drawing drawing=_pptx_drawing();
|
||||
|
||||
drawing.type = pic.type_;
|
||||
drawing.name = pic.name_;
|
||||
drawing.id = impl_->next_rId();
|
||||
|
||||
process_common_properties(pic,drawing);
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
std::wstring ref;
|
||||
bool isMediaInternal = true;
|
||||
std::wstring rId = impl_->get_mediaitems().add_or_find(L"", typeTable, isMediaInternal, ref);
|
||||
impl_->add_drawing(drawing, isMediaInternal, rId, ref, typeTable);
|
||||
}
|
||||
std::wstring ref;
|
||||
bool isMediaInternal = true;
|
||||
std::wstring rId = get_mediaitems().add_or_find(L"", obj.type_, isMediaInternal, ref);
|
||||
|
||||
add_drawing(drawing, isMediaInternal, rId, ref, drawing.type);
|
||||
}
|
||||
|
||||
void pptx_slide_context::process_common_properties(drawing_object_description & pic,_pptx_drawing & drawing)
|
||||
void pptx_slide_context::Impl::process_shape(drawing_object_description & obj, _pptx_drawing & drawing)
|
||||
{
|
||||
int PlaceHolderIndex = 1;
|
||||
|
||||
std::wstring ref;
|
||||
bool isMediaInternal = true;
|
||||
|
||||
if (drawing.fill.bitmap)
|
||||
{
|
||||
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal, ref);
|
||||
add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);
|
||||
}
|
||||
|
||||
std::wstring rId = get_mediaitems().add_or_find(L"", typeShape, isMediaInternal, ref);
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
_CP_OPT(std::wstring) sPlaceHolderType;
|
||||
GetProperty(obj.additional_, L"PlaceHolderType", sPlaceHolderType);
|
||||
if (sPlaceHolderType)
|
||||
{
|
||||
drawing.place_holder_type_ = *sPlaceHolderType;
|
||||
|
||||
_CP_OPT(int) iPlaceHolderIdx;
|
||||
GetProperty(obj.additional_, L"PlaceHolderIdx", iPlaceHolderIdx);
|
||||
if (iPlaceHolderIdx) drawing.place_holder_idx_ = *iPlaceHolderIdx;
|
||||
}
|
||||
|
||||
drawing.sub_type = obj.shape_type_;
|
||||
|
||||
add_drawing(drawing, isMediaInternal, rId, ref, typeShape);
|
||||
}
|
||||
|
||||
void pptx_slide_context::Impl::process_object(drawing_object_description& obj, _pptx_drawing & drawing)
|
||||
{
|
||||
std::wstring ref;
|
||||
bool isMediaInternal = true;
|
||||
|
||||
drawing.objectId = get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
|
||||
drawing.objectProgId = obj.descriptor_;
|
||||
|
||||
add_drawing(drawing, isMediaInternal, drawing.objectId, ref, drawing.type);
|
||||
|
||||
if (drawing.fill.bitmap)
|
||||
{
|
||||
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal, ref);
|
||||
add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);
|
||||
}
|
||||
}
|
||||
|
||||
void pptx_slide_context::Impl::process_common_properties(drawing_object_description & pic, _pptx_drawing & drawing)
|
||||
{
|
||||
if (pic.svg_rect_)
|
||||
{
|
||||
@ -529,47 +577,6 @@ void pptx_slide_context::process_common_properties(drawing_object_description &
|
||||
drawing.fill = pic.fill_;
|
||||
}
|
||||
|
||||
void pptx_slide_context::process_shapes()
|
||||
{
|
||||
int PlaceHolderIndex = 1;
|
||||
BOOST_FOREACH(drawing_object_description & pic, impl_->shapes_)
|
||||
{
|
||||
_pptx_drawing drawing=_pptx_drawing();
|
||||
|
||||
drawing.type = pic.type_;
|
||||
drawing.name = pic.name_;
|
||||
drawing.id = impl_->next_rId();
|
||||
|
||||
process_common_properties(pic,drawing);
|
||||
|
||||
std::wstring ref;
|
||||
bool isMediaInternal = true;
|
||||
|
||||
if (drawing.fill.bitmap)
|
||||
{
|
||||
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"", typeShape, isMediaInternal, ref);
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
_CP_OPT(std::wstring) sPlaceHolderType;
|
||||
GetProperty(pic.additional_,L"PlaceHolderType",sPlaceHolderType);
|
||||
if (sPlaceHolderType)
|
||||
{
|
||||
drawing.place_holder_type_ = *sPlaceHolderType;
|
||||
|
||||
_CP_OPT(int) iPlaceHolderIdx;
|
||||
GetProperty(pic.additional_,L"PlaceHolderIdx",iPlaceHolderIdx);
|
||||
if (iPlaceHolderIdx) drawing.place_holder_idx_ = *iPlaceHolderIdx;
|
||||
}
|
||||
|
||||
drawing.sub_type = pic.shape_type_;
|
||||
|
||||
impl_->add_drawing(drawing, isMediaInternal, rId, ref, typeShape);
|
||||
}
|
||||
}
|
||||
|
||||
void pptx_slide_context::dump_rels(rels & Rels)
|
||||
{
|
||||
@ -627,7 +634,6 @@ void pptx_slide_context::serialize_background(std::wostream & strm, bool always)
|
||||
|
||||
void pptx_slide_context::serialize_animations(std::wostream & strm)
|
||||
{
|
||||
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
if (impl_->transition_.Enabled)
|
||||
@ -707,10 +713,10 @@ void pptx_slide_context::serialize_objects(std::wostream & strm)
|
||||
{
|
||||
CP_XML_NODE(L"a:xfrm")
|
||||
{
|
||||
CP_XML_NODE(L"a:off") {CP_XML_ATTR(L"x",0); CP_XML_ATTR(L"y",0);}
|
||||
CP_XML_NODE(L"a:ext") {CP_XML_ATTR(L"cx",0); CP_XML_ATTR(L"cy",0);}
|
||||
CP_XML_NODE(L"a:chOff") {CP_XML_ATTR(L"x",0); CP_XML_ATTR(L"y",0);}
|
||||
CP_XML_NODE(L"a:chExt") {CP_XML_ATTR(L"cx",0); CP_XML_ATTR(L"cy",0);}
|
||||
CP_XML_NODE(L"a:off") { CP_XML_ATTR(L"x", 0); CP_XML_ATTR(L"y", 0); }
|
||||
CP_XML_NODE(L"a:ext") { CP_XML_ATTR(L"cx",0); CP_XML_ATTR(L"cy",0); }
|
||||
CP_XML_NODE(L"a:chOff") { CP_XML_ATTR(L"x", 0); CP_XML_ATTR(L"y", 0); }
|
||||
CP_XML_NODE(L"a:chExt") { CP_XML_ATTR(L"cx",0); CP_XML_ATTR(L"cy",0); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,38 +50,40 @@ public:
|
||||
pptx_slide_context(pptx_conversion_context & Context);
|
||||
|
||||
void start_slide();
|
||||
void end_slide(){}
|
||||
void end_slide (){}
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
void start_slide_animation();
|
||||
void end_slide_animation(){}
|
||||
void start_slide_animation ();
|
||||
void end_slide_animation (){}
|
||||
|
||||
void set_transitionFilter(std::wstring & type,_CP_OPT(std::wstring) & dir, _CP_OPT(std::wstring) & dop, _CP_OPT(int) & time);
|
||||
void set_transitionAction(bool val);
|
||||
void set_transitionSpeed(std::wstring val);
|
||||
void set_transitionFilter (std::wstring & type,_CP_OPT(std::wstring) & dir, _CP_OPT(std::wstring) & dop, _CP_OPT(int) & time);
|
||||
void set_transitionAction (bool val);
|
||||
void set_transitionSpeed (std::wstring val);
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
void set_rect(double width_pt, double height_pt, double x_pt, double y_pt);
|
||||
void set_rect (double width_pt, double height_pt, double x_pt, double y_pt);
|
||||
|
||||
void set_translate(double x_pt, double y_pt);
|
||||
void set_scale(double cx_pt, double cy_pt);
|
||||
void set_rotate(double angle);
|
||||
void set_translate (double x_pt, double y_pt);
|
||||
void set_scale (double cx_pt, double cy_pt);
|
||||
void set_rotate (double angle);
|
||||
|
||||
void set_name(std::wstring const & name);
|
||||
void set_anchor(std::wstring anchor, double x_pt, double y_pt);
|
||||
void set_property(odf_reader::_property p);
|
||||
void set_name (std::wstring const & name);
|
||||
void set_anchor (std::wstring anchor, double x_pt, double y_pt);
|
||||
void set_property (odf_reader::_property p);
|
||||
std::vector<odf_reader::_property> & get_properties();
|
||||
void set_clipping(const std::wstring & str );
|
||||
void set_fill(_oox_fill & fill);
|
||||
void set_clipping (const std::wstring & str );
|
||||
void set_fill (_oox_fill & fill);
|
||||
|
||||
void set_placeHolder_type(std::wstring typeHolder);
|
||||
void set_placeHolder_idx(int idx);
|
||||
void set_placeHolder_type (std::wstring typeHolder);
|
||||
void set_placeHolder_idx (int idx);
|
||||
|
||||
std::wstring add_hyperlink(std::wstring const & ref, bool object);
|
||||
|
||||
void start_image(std::wstring const & path);
|
||||
void end_image();
|
||||
|
||||
void start_chart(std::wstring const & path);
|
||||
void end_chart();
|
||||
void start_frame();
|
||||
void set_image (const std::wstring & path);
|
||||
void set_chart (const std::wstring & path);
|
||||
void set_ms_object (const std::wstring & path, const std::wstring & progId);
|
||||
void set_ole_object (const std::wstring & path, const std::wstring & progId);
|
||||
void set_text_box ();
|
||||
void end_frame();
|
||||
|
||||
void start_table();
|
||||
void end_table();
|
||||
@ -89,9 +91,6 @@ public:
|
||||
void start_shape(int type);
|
||||
void end_shape();
|
||||
|
||||
void start_object_ole();
|
||||
void end_object_ole();
|
||||
|
||||
void set_use_image_replacement();
|
||||
|
||||
bool empty() const;
|
||||
@ -109,7 +108,6 @@ public:
|
||||
|
||||
void add_background(_oox_fill & fill);
|
||||
|
||||
|
||||
void add_rels( bool isInternal,
|
||||
std::wstring const & rid,
|
||||
std::wstring const & ref,
|
||||
@ -121,13 +119,7 @@ public:
|
||||
void set_page_number();
|
||||
void set_date_time();
|
||||
private:
|
||||
void process_common_properties(drawing_object_description& pic,_pptx_drawing & drawing);
|
||||
void default_set();
|
||||
|
||||
void process_shapes();
|
||||
void process_images();
|
||||
void process_charts();
|
||||
void process_tables();
|
||||
|
||||
int hlinks_size_;
|
||||
|
||||
|
||||
@ -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;
|
||||
odf_reader::GetProperty ( val.additional ,L"text-content", strTextContent);
|
||||
@ -60,7 +60,8 @@ void xlsx_serialize_text(std::wostream & strm, _xlsx_drawing & val )
|
||||
{
|
||||
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");
|
||||
if (strTextContent)
|
||||
{
|
||||
@ -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, std::wstring ns)
|
||||
{
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(std::wstring(L"xdr:") + (val.type == xlsx_drawing_position::from ? L"from" : L"to") )
|
||||
CP_XML_NODE( ns + (type == xlsx_drawing_position::from ? L"from" : L"to") )
|
||||
{
|
||||
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_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_CONTENT(val.position.row);
|
||||
CP_XML_CONTENT(position.row);
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
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")
|
||||
{
|
||||
@ -166,9 +167,9 @@ void xlsx_serialize_shape(std::wostream & strm, _xlsx_drawing & val)
|
||||
} // xdr:nv_Pr
|
||||
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;
|
||||
if (val.sub_type == 5 || val.sub_type == 6)//line собственно ) - если ее нет - в свойствах будет
|
||||
@ -181,6 +182,34 @@ void xlsx_serialize_shape(std::wostream & strm, _xlsx_drawing & val)
|
||||
}
|
||||
} // CP_XML_WRITER
|
||||
}
|
||||
void xlsx_serialize_object(std::wostream & strm, _xlsx_drawing & val)
|
||||
{//отображательная часть
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"xdr:sp")
|
||||
{
|
||||
CP_XML_NODE(L"xdr:nvSpPr")
|
||||
{
|
||||
CP_XML_NODE(L"xdr:cNvPr")
|
||||
{
|
||||
CP_XML_ATTR(L"id", val.id); //числовое значение val.rId
|
||||
CP_XML_ATTR(L"name", val.name);
|
||||
}
|
||||
CP_XML_NODE(L"xdr:cNvSpPr");
|
||||
|
||||
}
|
||||
CP_XML_NODE(L"xdr:spPr")
|
||||
{
|
||||
val.serialize_xfrm(CP_XML_STREAM());
|
||||
|
||||
CP_XML_NODE(L"a:prstGeom")
|
||||
{
|
||||
CP_XML_ATTR(L"prst", L"rect");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void xlsx_serialize_group(std::wostream & strm, _xlsx_drawing & val)
|
||||
{
|
||||
CP_XML_WRITER(strm)
|
||||
@ -191,14 +220,14 @@ void xlsx_serialize_group(std::wostream & strm, _xlsx_drawing & val)
|
||||
{
|
||||
CP_XML_NODE(L"xdr:cNvPr")
|
||||
{
|
||||
CP_XML_ATTR(L"id", val.id);
|
||||
CP_XML_ATTR(L"name", val.name);
|
||||
CP_XML_ATTR(L"id", val.id);
|
||||
CP_XML_ATTR(L"name", val.name);
|
||||
}
|
||||
CP_XML_NODE(L"xdr:cNvGrpSpPr");
|
||||
}
|
||||
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_;
|
||||
@ -207,7 +236,7 @@ void xlsx_serialize_group(std::wostream & strm, _xlsx_drawing & val)
|
||||
}
|
||||
|
||||
void xlsx_serialize_chart(std::wostream & strm, _xlsx_drawing & val)
|
||||
{
|
||||
{//отображательная часть
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"xdr:graphicFrame")
|
||||
@ -216,14 +245,13 @@ void xlsx_serialize_chart(std::wostream & strm, _xlsx_drawing & val)
|
||||
{
|
||||
CP_XML_NODE(L"xdr:cNvPr")
|
||||
{
|
||||
CP_XML_ATTR(L"id", val.id);
|
||||
CP_XML_ATTR(L"name", val.name);
|
||||
CP_XML_ATTR(L"id", val.id);
|
||||
CP_XML_ATTR(L"name", val.name);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
CP_XML_NODE(L"a:graphic")
|
||||
@ -235,14 +263,14 @@ 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: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);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // xdr:graphicFrame
|
||||
} // CP_XML_WRITER
|
||||
}
|
||||
}
|
||||
}
|
||||
void xlsx_serialize_object(std::wostream & strm, _xlsx_drawing & val)
|
||||
void xlsx_serialize(std::wostream & strm, _xlsx_drawing & val)
|
||||
{
|
||||
if (val.type == typeShape)
|
||||
{
|
||||
@ -260,24 +288,30 @@ void xlsx_serialize_object(std::wostream & strm, _xlsx_drawing & val)
|
||||
{
|
||||
xlsx_serialize_group(strm, val);
|
||||
}
|
||||
else if (val.type == typeOleObject ||
|
||||
val.type == typeMsObject )
|
||||
{
|
||||
xlsx_serialize_object(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(strm, *this);
|
||||
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
if (val.type_anchor == 1)
|
||||
if (type_anchor == 1)
|
||||
{
|
||||
CP_XML_NODE(L"xdr:twoCellAnchor")
|
||||
{
|
||||
CP_XML_ATTR(L"editAs", L"oneCell");//"absolute");oneCell
|
||||
|
||||
xlsx_serialize (CP_XML_STREAM(), val.from_);
|
||||
xlsx_serialize (CP_XML_STREAM(), val.to_);
|
||||
from_.serialize (CP_XML_STREAM());
|
||||
to_.serialize (CP_XML_STREAM());
|
||||
|
||||
xlsx_serialize_object (CP_XML_STREAM(),val);
|
||||
|
||||
xlsx_serialize (CP_XML_STREAM(), *this);
|
||||
CP_XML_NODE(L"xdr:clientData");
|
||||
}
|
||||
}
|
||||
@ -287,18 +321,15 @@ void xlsx_serialize(std::wostream & strm, _xlsx_drawing & val)
|
||||
{
|
||||
CP_XML_NODE(L"xdr:pos")
|
||||
{
|
||||
CP_XML_ATTR(L"x", val.x);
|
||||
CP_XML_ATTR(L"y", val.y);
|
||||
CP_XML_ATTR(L"x", x);
|
||||
CP_XML_ATTR(L"y", y);
|
||||
}
|
||||
|
||||
CP_XML_NODE(L"xdr:ext")
|
||||
{
|
||||
CP_XML_ATTR(L"cx", val.cx);
|
||||
CP_XML_ATTR(L"cy", val.cy);
|
||||
CP_XML_ATTR(L"cx", cx);
|
||||
CP_XML_ATTR(L"cy", cy);
|
||||
}
|
||||
|
||||
xlsx_serialize_object (CP_XML_STREAM(),val);
|
||||
|
||||
xlsx_serialize(CP_XML_STREAM(), *this);
|
||||
CP_XML_NODE(L"xdr:clientData");
|
||||
}
|
||||
}
|
||||
@ -307,5 +338,38 @@ void xlsx_serialize(std::wostream & strm, _xlsx_drawing & val)
|
||||
}
|
||||
|
||||
|
||||
void _xlsx_drawing::serialize_object (std::wostream & strm)
|
||||
{
|
||||
if (type != typeOleObject && type != typeMsObject) return;
|
||||
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"oleObject")
|
||||
{
|
||||
CP_XML_ATTR(L"r:id", objectId);
|
||||
CP_XML_ATTR(L"shapeId", id);
|
||||
CP_XML_ATTR(L"progId", objectProgId);
|
||||
|
||||
CP_XML_NODE(L"objectPr")
|
||||
{
|
||||
CP_XML_ATTR(L"defaultSize", 0);
|
||||
if (fill.bitmap)
|
||||
{
|
||||
CP_XML_ATTR(L"r:id", fill.bitmap->rId);
|
||||
}
|
||||
CP_XML_NODE(L"anchor")
|
||||
{
|
||||
CP_XML_ATTR(L"moveWithCells", 1);
|
||||
|
||||
from_.serialize (CP_XML_STREAM(), L"");
|
||||
to_.serialize (CP_XML_STREAM(), L"");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,16 +46,16 @@ namespace oox {
|
||||
|
||||
struct xlsx_drawing_position
|
||||
{
|
||||
enum type_t {from, to};
|
||||
type_t type;
|
||||
xlsx_table_position position;
|
||||
enum type_t {from, to} type;
|
||||
xlsx_table_position position;
|
||||
|
||||
friend void xlsx_serialize(std::wostream & _Wostream, xlsx_drawing_position const & val);
|
||||
void serialize(std::wostream & _Wostream, std::wstring ns = L"xdr:");
|
||||
};
|
||||
|
||||
|
||||
struct _xlsx_drawing : _oox_drawing
|
||||
class _xlsx_drawing : public _oox_drawing
|
||||
{
|
||||
public:
|
||||
_xlsx_drawing() : _oox_drawing(), type_anchor(1) {}
|
||||
|
||||
int type_anchor;
|
||||
@ -65,8 +65,8 @@ struct _xlsx_drawing : _oox_drawing
|
||||
|
||||
std::wstring content_group_;
|
||||
|
||||
|
||||
friend void xlsx_serialize(std::wostream & _Wostream, _xlsx_drawing & val);
|
||||
void serialize (std::wostream & strm);
|
||||
void serialize_object (std::wostream & strm);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,8 +34,6 @@
|
||||
#include <iostream>
|
||||
#include <cpdoccore/xml/utils.h>
|
||||
|
||||
#include "mediaitems_utils.h"
|
||||
|
||||
#include "xlsx_drawing.h"
|
||||
#include "xlsx_drawings.h"
|
||||
#include "xlsx_utils.h"
|
||||
@ -111,7 +109,8 @@ class xlsx_drawing_context::Impl
|
||||
public:
|
||||
Impl(xlsx_drawing_context_handle & handle) : xlsx_drawings_(xlsx_drawings::create(false)), handle_(handle)
|
||||
{
|
||||
current_level_ = &objects_;
|
||||
current_level_ = &objects_;
|
||||
use_image_replacement_ = false;
|
||||
}
|
||||
|
||||
xlsx_drawing_context_handle& handle_;
|
||||
@ -121,13 +120,14 @@ public:
|
||||
std::vector<drawing_object_description*> groups_;
|
||||
|
||||
std::vector<drawing_object_description> * current_level_;
|
||||
bool use_image_replacement_;
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
||||
mediaitems & get_mediaitems() { return handle_.impl_->get_mediaitems(); }
|
||||
|
||||
void serialize(std::wostream & strm)
|
||||
{
|
||||
xlsx_serialize(strm, *xlsx_drawings_);
|
||||
xlsx_drawings_->serialize(strm);
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
@ -167,12 +167,12 @@ void xlsx_drawing_context::clear()
|
||||
impl_->object_description_.anchor_y_ = 0;
|
||||
impl_->object_description_.clipping_string_ = L"";
|
||||
impl_->object_description_.svg_rect_ = boost::none;
|
||||
impl_->object_description_.use_image_replace_ = false;
|
||||
|
||||
impl_->object_description_.additional_.clear();
|
||||
impl_->object_description_.hlinks_.clear();
|
||||
impl_->object_description_.additional_.clear();
|
||||
|
||||
impl_->use_image_replacement_ = false;
|
||||
}
|
||||
|
||||
xlsx_drawing_context::~xlsx_drawing_context()
|
||||
@ -272,37 +272,62 @@ void xlsx_drawing_context::end_shape()
|
||||
impl_->current_level_->push_back(impl_->object_description_);
|
||||
}
|
||||
|
||||
void xlsx_drawing_context::start_object_ole()
|
||||
void xlsx_drawing_context::set_use_image_replacement()
|
||||
{
|
||||
impl_->use_image_replacement_ = true;
|
||||
}
|
||||
void xlsx_drawing_context::set_text_box()
|
||||
{
|
||||
impl_->object_description_.type_ = typeShape;
|
||||
impl_->object_description_.shape_type_ = 2; //2,3...
|
||||
}
|
||||
|
||||
void xlsx_drawing_context::end_object_ole()
|
||||
void xlsx_drawing_context::set_ole_object(const std::wstring & path, const std::wstring & progId)
|
||||
{
|
||||
}
|
||||
|
||||
void xlsx_drawing_context::start_image(std::wstring const & path)
|
||||
{
|
||||
impl_->object_description_.type_ = typeImage;
|
||||
impl_->object_description_.type_ = typeOleObject;
|
||||
impl_->object_description_.xlink_href_ = path;
|
||||
impl_->object_description_.descriptor_ = progId;
|
||||
}
|
||||
void xlsx_drawing_context::end_image()
|
||||
void xlsx_drawing_context::set_ms_object(const std::wstring & path, const std::wstring & progId)
|
||||
{
|
||||
impl_->object_description_.type_ = typeMsObject;
|
||||
impl_->object_description_.xlink_href_ = path;
|
||||
impl_->object_description_.descriptor_ = progId;
|
||||
}
|
||||
void xlsx_drawing_context::set_image(const std::wstring & path)
|
||||
{
|
||||
if (impl_->object_description_.type_ == typeUnknown)
|
||||
{
|
||||
impl_->object_description_.type_ = typeImage;
|
||||
impl_->object_description_.xlink_href_ = path;
|
||||
}
|
||||
else if (impl_->use_image_replacement_)
|
||||
{
|
||||
impl_->object_description_.fill_.type = 2;
|
||||
impl_->object_description_.fill_.bitmap = oox::oox_bitmap_fill::create();
|
||||
impl_->object_description_.fill_.bitmap->xlink_href_ = path;
|
||||
}
|
||||
}
|
||||
void xlsx_drawing_context::start_frame()
|
||||
{
|
||||
impl_->object_description_.type_ = typeUnknown;
|
||||
}
|
||||
void xlsx_drawing_context::end_frame()
|
||||
{
|
||||
impl_->current_level_->push_back(impl_->object_description_);
|
||||
}
|
||||
void xlsx_drawing_context::start_chart(std::wstring const & path)
|
||||
|
||||
void xlsx_drawing_context::set_chart(const std::wstring & path)
|
||||
{
|
||||
impl_->object_description_.type_ = typeChart;
|
||||
impl_->object_description_.xlink_href_ = path;
|
||||
}
|
||||
void xlsx_drawing_context::end_chart()
|
||||
{
|
||||
impl_->current_level_->push_back(impl_->object_description_);
|
||||
}
|
||||
|
||||
void xlsx_drawing_context::set_rect(double width_pt, double height_pt, double x_pt, double y_pt)
|
||||
{
|
||||
impl_->object_description_.svg_rect_ = _rect(width_pt, height_pt, x_pt, y_pt);
|
||||
}
|
||||
|
||||
void xlsx_drawing_context::set_translate(double x_pt, double y_pt)
|
||||
{
|
||||
if (impl_->object_description_.svg_rect_)
|
||||
@ -313,6 +338,7 @@ void xlsx_drawing_context::set_translate(double x_pt, double y_pt)
|
||||
r.y += y_pt;
|
||||
}
|
||||
}
|
||||
|
||||
void xlsx_drawing_context::set_rotate(double angle)
|
||||
{
|
||||
set_property(odf_reader::_property(L"svg:rotate", angle));
|
||||
@ -369,6 +395,7 @@ void xlsx_drawing_context::set_fill(_oox_fill & fill)
|
||||
{
|
||||
impl_->object_description_.fill_= fill;
|
||||
}
|
||||
|
||||
std::wstring xlsx_drawing_context::add_hyperlink(std::wstring const & href,bool object)
|
||||
{
|
||||
++hlinks_size_;
|
||||
@ -384,11 +411,6 @@ std::wstring xlsx_drawing_context::add_hyperlink(std::wstring const & href,bool
|
||||
return hId;
|
||||
}
|
||||
|
||||
void xlsx_drawing_context::set_use_image_replacement()
|
||||
{
|
||||
impl_->object_description_.use_image_replace_ = true;
|
||||
}
|
||||
|
||||
bool xlsx_drawing_context::empty() const
|
||||
{
|
||||
return impl_->empty();
|
||||
@ -535,13 +557,26 @@ void xlsx_drawing_context::process_chart(drawing_object_description & obj,_xlsx_
|
||||
std::wstring ref;
|
||||
bool isMediaInternal = true;
|
||||
|
||||
drawing.chartId = impl_->get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
|
||||
xlsx_drawings_->add(drawing, isMediaInternal, drawing.chartId, ref, obj.type_);
|
||||
drawing.objectId = impl_->get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
|
||||
xlsx_drawings_->add(drawing, isMediaInternal, drawing.objectId, ref, obj.type_);
|
||||
|
||||
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_object(drawing_object_description & obj,_xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_)
|
||||
{
|
||||
std::wstring ref;
|
||||
bool isMediaInternal = true;
|
||||
|
||||
drawing.objectId = impl_->get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
|
||||
drawing.objectProgId = obj.descriptor_;
|
||||
|
||||
xlsx_drawings_->add(drawing, isMediaInternal, drawing.objectId, ref, obj.type_, true);
|
||||
|
||||
if (drawing.inGroup)
|
||||
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_)
|
||||
{
|
||||
std::wstring ref;
|
||||
@ -559,7 +594,7 @@ void xlsx_drawing_context::process_group(drawing_object_description & obj, xlsx_
|
||||
|
||||
std::wstringstream strm;
|
||||
|
||||
xlsx_serialize(strm, *xlsx_drawings_child);
|
||||
xlsx_drawings_child->serialize(strm);
|
||||
|
||||
drawing.content_group_ = strm.str();
|
||||
|
||||
@ -581,9 +616,6 @@ void xlsx_drawing_context::process_objects(std::vector<drawing_object_descriptio
|
||||
{
|
||||
drawing_object_description & obj = objects[i];
|
||||
|
||||
int pos_replaicement = obj.xlink_href_.find(L"ObjectReplacements");
|
||||
if (pos_replaicement >= 0 && !obj.use_image_replace_)continue; //объект
|
||||
|
||||
_xlsx_drawing drawing =_xlsx_drawing();
|
||||
|
||||
drawing.type = obj.type_;
|
||||
@ -600,7 +632,11 @@ void xlsx_drawing_context::process_objects(std::vector<drawing_object_descriptio
|
||||
bool isMediaInternal = true;
|
||||
|
||||
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 объекта
|
||||
|
||||
bool in_sheet = (obj.type_== typeOleObject || obj.type_== typeMsObject) ? true : false;
|
||||
impl_->get_drawings()->add(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage, in_sheet);//собственно это не объект, а доп рел и ref объекта
|
||||
|
||||
//object dumps in sheet rels !!
|
||||
}
|
||||
|
||||
process_common_properties(obj, drawing, table_metrics);
|
||||
@ -611,6 +647,9 @@ void xlsx_drawing_context::process_objects(std::vector<drawing_object_descriptio
|
||||
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;
|
||||
case typeMsObject:
|
||||
case typeOleObject:
|
||||
process_object ( obj, drawing, xlsx_drawings_); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,35 +80,34 @@ public:
|
||||
|
||||
void set_odf_packet_path(std::wstring path){odf_packet_path_ = path;}//для анализа картинок
|
||||
|
||||
void start_drawing(std::wstring const & name);
|
||||
void end_drawing();
|
||||
void start_drawing (std::wstring const & name);
|
||||
void end_drawing ();
|
||||
|
||||
void start_group(std::wstring const & name);
|
||||
void end_group();
|
||||
|
||||
void start_image(std::wstring const & path);
|
||||
void end_image();
|
||||
|
||||
void start_chart(std::wstring const & path);
|
||||
void end_chart();
|
||||
void end_group ();
|
||||
|
||||
void start_shape(int type);
|
||||
//...пока тока общие свойства ... частные для каждого объекта пооозже
|
||||
void end_shape();
|
||||
|
||||
void start_object_ole();
|
||||
void end_object_ole();
|
||||
void start_frame();
|
||||
void set_image (const std::wstring & path);
|
||||
void set_chart (const std::wstring & path);
|
||||
void set_ole_object (const std::wstring & path, const std::wstring & progId);
|
||||
void set_ms_object (const std::wstring & path, const std::wstring & progId);
|
||||
void set_text_box ();
|
||||
void end_frame();
|
||||
|
||||
void set_rect(double width_pt, double height_pt, double x_pt, double y_pt);
|
||||
|
||||
void set_translate(double x_pt, double y_pt);
|
||||
void set_scale(double cx_pt, double cy_pt);
|
||||
void set_rotate(double angle);
|
||||
void set_translate (double x_pt, double y_pt);
|
||||
void set_scale (double cx_pt, double cy_pt);
|
||||
void set_rotate (double angle);
|
||||
|
||||
void set_anchor(std::wstring anchor, double x_pt, double y_pt, bool group = false);
|
||||
void set_property(odf_reader::_property p);
|
||||
void set_clipping(const std::wstring & str );
|
||||
void set_fill(_oox_fill & fill);
|
||||
void set_anchor (std::wstring anchor, double x_pt, double y_pt, bool group = false);
|
||||
void set_property (odf_reader::_property p);
|
||||
void set_clipping (const std::wstring & str );
|
||||
void set_fill (_oox_fill & fill);
|
||||
|
||||
std::vector<odf_reader::_property> & get_properties();
|
||||
|
||||
@ -136,6 +135,7 @@ private:
|
||||
void process_image (drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_);
|
||||
void process_chart (drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_);
|
||||
void process_shape (drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_);
|
||||
void process_object (drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_);
|
||||
|
||||
void process_common_properties (drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_table_metrics & table_metrics);
|
||||
|
||||
|
||||
@ -36,7 +36,6 @@
|
||||
#include <vector>
|
||||
#include <cpdoccore/xml/simple_xml_writer.h>
|
||||
|
||||
#include "mediaitems_utils.h"
|
||||
#include "oox_rels.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
@ -45,40 +44,44 @@ namespace oox {
|
||||
class xlsx_drawings::Impl
|
||||
{
|
||||
public:
|
||||
void add(_xlsx_drawing const & d, bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type)
|
||||
void add(_xlsx_drawing const & d, bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel )//объект
|
||||
{
|
||||
xlsx_drawings_.push_back(d);
|
||||
|
||||
bool present = false;
|
||||
for (int i = 0 ; i < xlsx_drawing_rels_.size(); i++)
|
||||
{
|
||||
if (xlsx_drawing_rels_[i].rid == rid && xlsx_drawing_rels_[i].ref == ref)
|
||||
present = true;
|
||||
}
|
||||
if (!present)
|
||||
{
|
||||
xlsx_drawing_rels_.push_back(_rel(isInternal, rid, ref, type));
|
||||
}
|
||||
for (int i = 0 ; i < d.hlinks.size(); i++)
|
||||
add (isInternal, rid, ref, type, sheet_rel);
|
||||
|
||||
for (int i = 0 ; i < d.hlinks.size(); i++)
|
||||
{
|
||||
xlsx_drawing_rels_.push_back(_rel(false, d.hlinks[i].hId, d.hlinks[i].hRef, typeHyperlink));
|
||||
}
|
||||
}
|
||||
void add( 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 sheet_rel) //не объект
|
||||
{
|
||||
bool present = false;
|
||||
for (int i = 0 ; i < xlsx_drawing_rels_.size(); i++)
|
||||
{
|
||||
if (xlsx_drawing_rels_[i].rid == rid && xlsx_drawing_rels_[i].ref == ref)
|
||||
present = true;
|
||||
}
|
||||
if (!present)
|
||||
|
||||
if (type == typeHyperlink) isInternal = false;
|
||||
|
||||
if (sheet_rel)
|
||||
{
|
||||
xlsx_drawing_rels_.push_back(_rel(isInternal, rid, ref, type));
|
||||
for (int i = 0 ; i < xlsx_sheet_rels_.size(); i++)
|
||||
{
|
||||
if (xlsx_sheet_rels_[i].rid == rid && xlsx_sheet_rels_[i].ref == ref)
|
||||
present = true;
|
||||
}
|
||||
if (!present)
|
||||
xlsx_sheet_rels_.push_back (_rel(isInternal, rid, ref, type));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0 ; i < xlsx_drawing_rels_.size(); i++)
|
||||
{
|
||||
if (xlsx_drawing_rels_[i].rid == rid && xlsx_drawing_rels_[i].ref == ref)
|
||||
present = true;
|
||||
}
|
||||
if (!present)
|
||||
xlsx_drawing_rels_.push_back(_rel(isInternal, rid, ref, type));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void serialize(std::wostream & strm)
|
||||
{
|
||||
@ -86,7 +89,7 @@ public:
|
||||
{
|
||||
for (int i = 0 ; i < xlsx_drawings_.size(); i++)
|
||||
{
|
||||
xlsx_serialize(strm, xlsx_drawings_[i]);
|
||||
xlsx_drawings_[i].serialize(strm);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -101,60 +104,62 @@ public:
|
||||
|
||||
for (int i = 0 ; i < xlsx_drawings_.size(); i++)
|
||||
{
|
||||
xlsx_serialize(CP_XML_STREAM(), xlsx_drawings_[i]);
|
||||
xlsx_drawings_[i].serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void serialize_objects(std::wostream & strm)
|
||||
{
|
||||
for (int i = 0 ; i < xlsx_drawings_.size(); i++)
|
||||
{
|
||||
if (xlsx_drawings_[i].type != typeOleObject && xlsx_drawings_[i].type != typeMsObject) continue;
|
||||
|
||||
xlsx_drawings_[i].serialize_object(strm);
|
||||
}
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
return (xlsx_drawings_.empty());
|
||||
}
|
||||
|
||||
void dump_rels(rels & Rels)
|
||||
void dump_rels_drawing(rels & Rels)
|
||||
{
|
||||
for (int i = 0 ; i < xlsx_drawing_rels_.size(); i++)
|
||||
{
|
||||
if (xlsx_drawing_rels_[i].type == typeChart)
|
||||
if (xlsx_drawing_rels_[i].type == typeImage ||
|
||||
xlsx_drawing_rels_[i].type == typeMedia ||
|
||||
xlsx_drawing_rels_[i].type == typeChart ||
|
||||
xlsx_drawing_rels_[i].type == typeHyperlink )
|
||||
{
|
||||
Rels.add(relationship(
|
||||
xlsx_drawing_rels_[i].rid,
|
||||
utils::media::get_rel_type(xlsx_drawing_rels_[i].type),
|
||||
|
||||
Rels.add(relationship( xlsx_drawing_rels_[i].rid,
|
||||
mediaitems::get_rel_type(xlsx_drawing_rels_[i].type),
|
||||
(xlsx_drawing_rels_[i].is_internal ? std::wstring(L"../") + xlsx_drawing_rels_[i].ref : xlsx_drawing_rels_[i].ref),
|
||||
(xlsx_drawing_rels_[i].is_internal ? L"" : L"External")
|
||||
)
|
||||
);
|
||||
}
|
||||
else if (xlsx_drawing_rels_[i].type == typeImage)
|
||||
{
|
||||
Rels.add(relationship(
|
||||
xlsx_drawing_rels_[i].rid,
|
||||
utils::media::get_rel_type(xlsx_drawing_rels_[i].type),
|
||||
xlsx_drawing_rels_[i].is_internal ? std::wstring(L"../") + xlsx_drawing_rels_[i].ref : xlsx_drawing_rels_[i].ref,
|
||||
(xlsx_drawing_rels_[i].is_internal ? L"" : L"External")
|
||||
)
|
||||
);
|
||||
}
|
||||
else if (xlsx_drawing_rels_[i].type == typeHyperlink)
|
||||
{
|
||||
Rels.add(relationship(
|
||||
xlsx_drawing_rels_[i].rid,
|
||||
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
|
||||
xlsx_drawing_rels_[i].ref,
|
||||
L"External")
|
||||
);
|
||||
(xlsx_drawing_rels_[i].is_internal ? L"" : L"External")) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void dump_rels_sheet(rels & Rels)
|
||||
{
|
||||
for (int i = 0 ; i < xlsx_sheet_rels_.size(); i++)
|
||||
{
|
||||
Rels.add(relationship( xlsx_sheet_rels_[i].rid,
|
||||
mediaitems::get_rel_type(xlsx_sheet_rels_[i].type),
|
||||
(xlsx_sheet_rels_[i].is_internal ? std::wstring(L"../") + xlsx_sheet_rels_[i].ref : xlsx_sheet_rels_[i].ref),
|
||||
(xlsx_sheet_rels_[i].is_internal ? L"" : L"External")) );
|
||||
}
|
||||
}
|
||||
bool inGroup;
|
||||
|
||||
private:
|
||||
|
||||
std::vector<_xlsx_drawing> xlsx_drawings_;
|
||||
|
||||
std::vector<_rel> xlsx_drawing_rels_;
|
||||
std::vector<_rel> xlsx_sheet_rels_;
|
||||
};
|
||||
|
||||
xlsx_drawings::xlsx_drawings(bool inGroup_) : impl_( new xlsx_drawings::Impl() )
|
||||
@ -167,19 +172,24 @@ xlsx_drawings::~xlsx_drawings()
|
||||
}
|
||||
|
||||
void xlsx_drawings::add(_xlsx_drawing const & d, bool isInternal, std::wstring const & rid,
|
||||
std::wstring const & ref, RelsType type)
|
||||
std::wstring const & ref, RelsType type, bool sheet_rel)
|
||||
{
|
||||
impl_->add(d, isInternal, rid, ref, type);
|
||||
impl_->add(d, isInternal, rid, ref, type, sheet_rel);
|
||||
}
|
||||
|
||||
void xlsx_drawings::add( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type)
|
||||
void xlsx_drawings::add( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel)
|
||||
{
|
||||
impl_->add(isInternal, rid, ref, type);
|
||||
impl_->add(isInternal, rid, ref, type, sheet_rel);
|
||||
}
|
||||
|
||||
void xlsx_serialize(std::wostream & _Wostream, xlsx_drawings const & val)
|
||||
void xlsx_drawings::serialize(std::wostream & strm)
|
||||
{
|
||||
val.impl_->serialize(_Wostream);
|
||||
impl_->serialize(strm);
|
||||
}
|
||||
|
||||
void xlsx_drawings::serialize_objects(std::wostream & strm)
|
||||
{
|
||||
impl_->serialize_objects(strm);
|
||||
}
|
||||
|
||||
bool xlsx_drawings::empty() const
|
||||
@ -187,9 +197,14 @@ bool xlsx_drawings::empty() const
|
||||
return impl_->empty();
|
||||
}
|
||||
|
||||
void xlsx_drawings::dump_rels(rels & Rels)
|
||||
void xlsx_drawings::dump_rels_drawing(rels & Rels)
|
||||
{
|
||||
return impl_->dump_rels(Rels);
|
||||
return impl_->dump_rels_drawing(Rels);
|
||||
}
|
||||
|
||||
void xlsx_drawings::dump_rels_sheet(rels & Rels)
|
||||
{
|
||||
return impl_->dump_rels_sheet(Rels);
|
||||
}
|
||||
|
||||
xlsx_drawings_ptr xlsx_drawings::create(bool inGroup)
|
||||
|
||||
@ -55,7 +55,7 @@ struct drawing_elm
|
||||
xlsx_drawings_ptr drawings;
|
||||
};
|
||||
|
||||
struct _xlsx_drawing;
|
||||
class _xlsx_drawing;
|
||||
|
||||
class xlsx_drawings
|
||||
{
|
||||
@ -64,14 +64,15 @@ public:
|
||||
~xlsx_drawings ();
|
||||
static xlsx_drawings_ptr create(bool inGroup);
|
||||
|
||||
public:
|
||||
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 );
|
||||
void add ( _xlsx_drawing const & d, bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel = false );
|
||||
void add ( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel = false );
|
||||
|
||||
bool empty () const;
|
||||
void dump_rels (rels & Rels);
|
||||
bool empty () const;
|
||||
void dump_rels_sheet (rels & Rels);
|
||||
void dump_rels_drawing (rels & Rels);
|
||||
|
||||
friend void xlsx_serialize(std::wostream & _Wostream, xlsx_drawings const & val);
|
||||
void serialize (std::wostream & _Wostream);
|
||||
void serialize_objects (std::wostream & _Wostream);
|
||||
private:
|
||||
class Impl;
|
||||
_CP_SCOPED_PTR(Impl) impl_;
|
||||
|
||||
@ -54,8 +54,10 @@ public:
|
||||
std::wstringstream sort_;
|
||||
std::wstringstream autofilter_;
|
||||
std::wstringstream conditionalFormatting_;
|
||||
std::wstringstream ole_objects_;
|
||||
|
||||
rels hyperlinks_rels_;
|
||||
rels ole_objects_rels_;
|
||||
|
||||
std::wstring drawingName_;
|
||||
std::wstring drawingId_;
|
||||
@ -128,20 +130,31 @@ std::wostream & xlsx_xml_worksheet::hyperlinks()
|
||||
{
|
||||
return impl_->hyperlinks_;
|
||||
}
|
||||
std::wostream & xlsx_xml_worksheet::ole_objects()
|
||||
{
|
||||
return impl_->ole_objects_;
|
||||
}
|
||||
//---------------------------------------------------------------------------------------
|
||||
rels & xlsx_xml_worksheet::hyperlinks_rels()
|
||||
{
|
||||
return impl_->hyperlinks_rels_;
|
||||
}
|
||||
rels & xlsx_xml_worksheet::ole_objects_rels()
|
||||
{
|
||||
return impl_->ole_objects_rels_;
|
||||
}
|
||||
void xlsx_xml_worksheet::write_to(std::wostream & strm)
|
||||
{
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"worksheet")
|
||||
{
|
||||
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
|
||||
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
|
||||
CP_XML_ATTR(L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
|
||||
CP_XML_ATTR(L"mc:Ignorable", L"x14ac");
|
||||
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
|
||||
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
|
||||
CP_XML_ATTR(L"xmlns:xdr", L"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing");
|
||||
CP_XML_ATTR(L"xmlns:x14", L"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
|
||||
CP_XML_ATTR(L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
|
||||
CP_XML_ATTR(L"mc:Ignorable",L"x14ac");
|
||||
CP_XML_ATTR(L"xmlns:x14ac", L"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac");
|
||||
|
||||
CP_XML_STREAM() << impl_->sheetFormat_.str();
|
||||
@ -179,7 +192,13 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
|
||||
CP_XML_ATTR(L"r:id",impl_->vml_drawingId_);
|
||||
}
|
||||
}
|
||||
|
||||
if (!impl_->ole_objects_.str().empty())
|
||||
{
|
||||
CP_XML_NODE(L"oleObjects")
|
||||
{
|
||||
CP_XML_STREAM() << impl_->ole_objects_.str();
|
||||
}
|
||||
}
|
||||
//CP_XML_NODE(L"headerFooter){}
|
||||
|
||||
//CP_XML_NODE(L"rowBreaks){}
|
||||
@ -217,43 +236,5 @@ std::pair<std::wstring, std::wstring> xlsx_xml_worksheet::get_vml_drawing_link()
|
||||
return std::pair<std::wstring, std::wstring>(impl_->vml_drawingName_, impl_->vml_drawingId_);
|
||||
}
|
||||
|
||||
//class xlsx_xml_workbook::Impl: noncopyable
|
||||
//{
|
||||
//public:
|
||||
// std::wstringstream sheets_;
|
||||
//};
|
||||
//
|
||||
//xlsx_xml_workbook::xlsx_xml_workbook() : impl_(new xlsx_xml_workbook::Impl)
|
||||
//{
|
||||
//}
|
||||
//
|
||||
//xlsx_xml_workbook::~xlsx_xml_workbook()
|
||||
//{
|
||||
//}
|
||||
//
|
||||
//std::wostream & xlsx_xml_workbook::sheets()
|
||||
//{
|
||||
// return impl_->sheets_;
|
||||
//}
|
||||
//
|
||||
//void xlsx_xml_workbook::write_to(std::wostream & strm)
|
||||
//{
|
||||
// CP_XML_WRITER(strm)
|
||||
// {
|
||||
// CP_XML_NODE(L"workbook")
|
||||
// {
|
||||
// CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
|
||||
// CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
|
||||
//
|
||||
// CP_XML_NODE(L"sheets")
|
||||
// {
|
||||
// CP_XML_STREAM() << impl_->sheets_.str();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,8 +62,10 @@ public:
|
||||
std::wostream & autofilter();
|
||||
std::wostream & conditionalFormatting();
|
||||
std::wostream & sort();
|
||||
std::wostream & ole_objects();
|
||||
|
||||
rels & hyperlinks_rels();
|
||||
rels & ole_objects_rels();
|
||||
|
||||
void write_to(std::wostream & strm);
|
||||
|
||||
|
||||
@ -181,30 +181,30 @@ void xl_files::write(const std::wstring & RootPath)
|
||||
sharedStrings_->write(path);
|
||||
rels_files_.add( relationship( L"shId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings", L"sharedStrings.xml" ) );
|
||||
}
|
||||
|
||||
if (styles_)
|
||||
{
|
||||
styles_->write(path);
|
||||
rels_files_.add( relationship( L"stId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles", L"styles.xml" ) );
|
||||
}
|
||||
|
||||
if (workbook_)
|
||||
{
|
||||
workbook_->write(path);
|
||||
}
|
||||
|
||||
if (theme_)
|
||||
{
|
||||
theme_->write(path);
|
||||
}
|
||||
|
||||
if (media_)
|
||||
{
|
||||
media_->set_main_document(get_main_document());
|
||||
media_->write(path);
|
||||
}
|
||||
|
||||
if (embeddings_)
|
||||
{
|
||||
embeddings_->set_main_document(get_main_document());
|
||||
embeddings_->write(path);
|
||||
}
|
||||
{
|
||||
charts_files_.set_main_document(get_main_document());
|
||||
charts_files_.write(path);
|
||||
}
|
||||
@ -243,7 +243,15 @@ void xl_files::add_sheet(sheet_content_ptr sheet)
|
||||
|
||||
void xl_files::set_media(mediaitems & _Mediaitems, CApplicationFonts *pAppFonts)
|
||||
{
|
||||
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
|
||||
if (_Mediaitems.count_image + _Mediaitems.count_media > 0)
|
||||
{
|
||||
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
|
||||
}
|
||||
|
||||
if (_Mediaitems.count_object > 0)
|
||||
{
|
||||
embeddings_ = element_ptr( new embeddings(_Mediaitems) );
|
||||
}
|
||||
}
|
||||
void xl_files::set_comments(element_ptr Element)
|
||||
{
|
||||
@ -313,7 +321,7 @@ void xl_drawings::write(const std::wstring & RootPath)
|
||||
rels_files relFiles;
|
||||
rels_file_ptr r = rels_file::create(e.filename + L".rels");
|
||||
|
||||
e.drawings->dump_rels(r->get_rels());
|
||||
e.drawings->dump_rels_drawing(r->get_rels());
|
||||
|
||||
relFiles.add_rel_file(r);
|
||||
relFiles.write(path);
|
||||
|
||||
@ -169,18 +169,20 @@ public:
|
||||
void add_charts(chart_content_ptr chart);
|
||||
|
||||
private:
|
||||
rels_files rels_files_;
|
||||
sheets_files sheets_files_;
|
||||
rels_files rels_files_;
|
||||
sheets_files sheets_files_;
|
||||
xl_charts_files charts_files_;
|
||||
element_ptr theme_;
|
||||
element_ptr workbook_;
|
||||
|
||||
element_ptr theme_;
|
||||
element_ptr workbook_;
|
||||
|
||||
element_ptr styles_;
|
||||
element_ptr sharedStrings_;
|
||||
element_ptr media_;
|
||||
element_ptr drawings_;
|
||||
element_ptr vml_drawings_;
|
||||
element_ptr comments_;
|
||||
element_ptr styles_;
|
||||
element_ptr sharedStrings_;
|
||||
element_ptr media_;
|
||||
element_ptr embeddings_;
|
||||
element_ptr drawings_;
|
||||
element_ptr vml_drawings_;
|
||||
element_ptr comments_;
|
||||
|
||||
};
|
||||
|
||||
@ -191,7 +193,7 @@ public:
|
||||
xlsx_document();
|
||||
|
||||
public:
|
||||
virtual void write(const std::wstring & RootPath);
|
||||
virtual void write(const std::wstring & RootPath);
|
||||
|
||||
virtual content_types_file & get_content_types_file() { return content_type_file_; }
|
||||
xl_files & get_xl_files() { return xl_files_; }
|
||||
|
||||
@ -403,7 +403,10 @@ void xlsx_table_state::serialize_merge_cells(std::wostream & _Wostream)
|
||||
{
|
||||
return xlsx_merge_cells_.xlsx_serialize(_Wostream);
|
||||
}
|
||||
|
||||
void xlsx_table_state::serialize_ole_objects(std::wostream & _Wostream)
|
||||
{
|
||||
return xlsx_drawing_context_.get_drawings()->serialize_objects(_Wostream);
|
||||
}
|
||||
void xlsx_table_state::serialize_hyperlinks(std::wostream & _Wostream)
|
||||
{
|
||||
return xlsx_hyperlinks_.xlsx_serialize(_Wostream);
|
||||
@ -416,6 +419,10 @@ void xlsx_table_state::dump_rels_hyperlinks(rels & Rels)
|
||||
{
|
||||
return xlsx_hyperlinks_.dump_rels(Rels);
|
||||
}
|
||||
void xlsx_table_state::dump_rels_ole_objects(rels & Rels)
|
||||
{
|
||||
return get_drawing_context().get_drawings()->dump_rels_sheet(Rels);
|
||||
}
|
||||
|
||||
void xlsx_table_state::start_hyperlink()
|
||||
{
|
||||
|
||||
@ -127,7 +127,10 @@ public:
|
||||
void serialize_table_format (std::wostream & _Wostream);
|
||||
void serialize_merge_cells (std::wostream & _Wostream);
|
||||
void serialize_hyperlinks (std::wostream & _Wostream);
|
||||
void dump_rels_hyperlinks (rels & Rels);
|
||||
void serialize_ole_objects (std::wostream & _Wostream);
|
||||
|
||||
void dump_rels_hyperlinks (rels & Rels);
|
||||
void dump_rels_ole_objects (rels & Rels);
|
||||
|
||||
std::wstring get_table_name() const { return tableName_; }
|
||||
int get_table_id() const { return tableId_; }
|
||||
|
||||
@ -320,10 +320,18 @@ void xlsx_table_context::serialize_hyperlinks(std::wostream & _Wostream)
|
||||
{
|
||||
return state()->serialize_hyperlinks(_Wostream);
|
||||
}
|
||||
void xlsx_table_context::serialize_ole_objects(std::wostream & _Wostream)
|
||||
{
|
||||
return state()->serialize_ole_objects(_Wostream);
|
||||
}
|
||||
void xlsx_table_context::dump_rels_hyperlinks(rels & Rels)
|
||||
{
|
||||
return state()->dump_rels_hyperlinks(Rels);
|
||||
}
|
||||
void xlsx_table_context::dump_rels_ole_objects(rels & Rels)
|
||||
{
|
||||
return state()->dump_rels_ole_objects(Rels);
|
||||
}
|
||||
|
||||
xlsx_table_metrics & xlsx_table_context::get_table_metrics()
|
||||
{
|
||||
|
||||
@ -88,6 +88,8 @@ public:
|
||||
void serialize_merge_cells (std::wostream & _Wostream);
|
||||
void serialize_table_format (std::wostream & _Wostream);
|
||||
void serialize_conditionalFormatting(std::wostream & _Wostream);
|
||||
void serialize_hyperlinks (std::wostream & _Wostream);
|
||||
void serialize_ole_objects (std::wostream & _Wostream);
|
||||
|
||||
xlsx_table_metrics & get_table_metrics();
|
||||
|
||||
@ -103,10 +105,9 @@ public:
|
||||
void start_hyperlink();
|
||||
std::wstring end_hyperlink(std::wstring const & ref, std::wstring const & href, std::wstring const & display);
|
||||
|
||||
void dump_rels_hyperlinks(rels & Rels);
|
||||
|
||||
void serialize_hyperlinks(std::wostream & _Wostream);
|
||||
|
||||
void dump_rels_hyperlinks (rels & Rels);
|
||||
void dump_rels_ole_objects (rels & Rels);
|
||||
|
||||
void start_database_range(std::wstring table_name, std::wstring ref);
|
||||
void set_database_orientation (bool val);
|
||||
void set_database_header (bool val);
|
||||
|
||||
@ -66,7 +66,7 @@ xlsx_conversion_context::xlsx_conversion_context(odf_reader::odf_document * odfD
|
||||
num_format_context_ (odf_document_->odf_context()),
|
||||
xlsx_text_context_ (odf_document_->odf_context().styleContainer()),
|
||||
xlsx_table_context_ (this, xlsx_text_context_),
|
||||
math_context_ (true),
|
||||
math_context_ (odf_document_->odf_context().fontContainer(), true),
|
||||
xlsx_style_ (this),
|
||||
|
||||
maxDigitSize_ (std::pair<float,float>(-1.0, -1.0) ),
|
||||
@ -132,12 +132,11 @@ void xlsx_conversion_context::end_document()
|
||||
{
|
||||
std::wstringstream workbook_content;
|
||||
|
||||
unsigned int count = 0;
|
||||
// добавляем таблицы
|
||||
BOOST_FOREACH(const xlsx_xml_worksheet_ptr& sheet, sheets_)
|
||||
for (int i = 0; i < sheets_.size(); i++)
|
||||
{
|
||||
count++;
|
||||
const std::wstring id = std::wstring(L"sId") + boost::lexical_cast<std::wstring>(count);
|
||||
xlsx_xml_worksheet_ptr& sheet = sheets_[i];
|
||||
|
||||
const std::wstring id = std::wstring(L"sId") + std::to_wstring(i+1);
|
||||
|
||||
package::sheet_content_ptr content = package::sheet_content::create();
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -152,6 +151,7 @@ void xlsx_conversion_context::end_document()
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
content->add_rels(sheet->hyperlinks_rels());
|
||||
content->add_rels(sheet->ole_objects_rels());
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const std::pair<std::wstring, std::wstring> p2 = sheet->get_comments_link();
|
||||
if (!p2.first.empty())
|
||||
@ -179,24 +179,22 @@ void xlsx_conversion_context::end_document()
|
||||
{
|
||||
CP_XML_NODE(L"sheet")
|
||||
{
|
||||
CP_XML_ATTR(L"name", sheet->name()); // office 2010 ! ограничение на длину имени !!!
|
||||
CP_XML_ATTR(L"sheetId", count);
|
||||
CP_XML_ATTR(L"state", L"visible");
|
||||
CP_XML_ATTR(L"r:id", id);
|
||||
CP_XML_ATTR(L"name", sheet->name()); // office 2010 ! ограничение на длину имени !!!
|
||||
CP_XML_ATTR(L"sheetId", i + 1);
|
||||
CP_XML_ATTR(L"state", L"visible");
|
||||
CP_XML_ATTR(L"r:id", id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//добавляем диаграммы
|
||||
|
||||
count = 0;
|
||||
BOOST_FOREACH(const oox_chart_context_ptr& chart, charts_)
|
||||
for (int i = 0; i < charts_.size(); i++)
|
||||
{
|
||||
count++;
|
||||
package::chart_content_ptr content = package::chart_content::create();
|
||||
|
||||
chart->serialize(content->content());
|
||||
chart->dump_rels(content->get_rel_file()->get_rels());
|
||||
charts_[i]->serialize(content->content());
|
||||
charts_[i]->dump_rels(content->get_rel_file()->get_rels());
|
||||
|
||||
output_document_->get_xl_files().add_charts(content);
|
||||
}
|
||||
@ -322,12 +320,16 @@ void xlsx_conversion_context::end_table()
|
||||
get_table_context().serialize_autofilter (current_sheet().autofilter());
|
||||
get_table_context().serialize_sort (current_sheet().sort());
|
||||
get_table_context().serialize_merge_cells (current_sheet().mergeCells());
|
||||
get_table_context().serialize_hyperlinks (current_sheet().hyperlinks());
|
||||
|
||||
get_drawing_context().set_odf_packet_path (root()->get_folder());
|
||||
get_drawing_context().process_objects (get_table_metrics());
|
||||
|
||||
get_table_context().serialize_hyperlinks (current_sheet().hyperlinks());
|
||||
get_table_context().serialize_ole_objects (current_sheet().ole_objects());
|
||||
|
||||
get_table_context().dump_rels_hyperlinks (current_sheet().hyperlinks_rels());
|
||||
get_table_context().dump_rels_ole_objects (current_sheet().ole_objects_rels());
|
||||
|
||||
get_drawing_context().set_odf_packet_path(root()->get_folder());
|
||||
|
||||
get_drawing_context().process_objects(get_table_metrics());
|
||||
|
||||
if (!get_drawing_context().empty())
|
||||
{
|
||||
|
||||
@ -175,7 +175,7 @@ void object_odf_context::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
}
|
||||
else if (object_type_ == 2 && office_text_)
|
||||
{
|
||||
office_text_->xlsx_convert(Context);
|
||||
//embedded
|
||||
}
|
||||
else if (object_type_ == 3 && office_math_)
|
||||
{
|
||||
@ -183,6 +183,10 @@ void object_odf_context::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
Context.get_math_context().start();
|
||||
office_math_->oox_convert(Context.get_math_context());
|
||||
}
|
||||
else if(object_type_ == 4 && office_spreadsheet_)
|
||||
{
|
||||
//embedded
|
||||
}
|
||||
}
|
||||
void object_odf_context::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
@ -199,7 +203,7 @@ void object_odf_context::docx_convert(oox::docx_conversion_context & Context)
|
||||
}
|
||||
else if (object_type_ == 2 && office_text_)
|
||||
{
|
||||
office_text_->docx_convert(Context);
|
||||
//embedded
|
||||
}
|
||||
else if (object_type_ == 3 && office_math_)
|
||||
{
|
||||
@ -225,6 +229,10 @@ void object_odf_context::docx_convert(oox::docx_conversion_context & Context)
|
||||
Context.set_run_state (runState);
|
||||
Context.set_paragraph_state (pState);
|
||||
}
|
||||
else if(object_type_ == 4 && office_spreadsheet_)
|
||||
{
|
||||
//embedded
|
||||
}
|
||||
}
|
||||
void object_odf_context::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
@ -240,7 +248,7 @@ void object_odf_context::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
}
|
||||
else if (object_type_ == 2 && office_text_)
|
||||
{
|
||||
office_text_->pptx_convert(Context);
|
||||
//embedded
|
||||
}
|
||||
else if (object_type_ == 3 && office_math_)
|
||||
{
|
||||
@ -248,6 +256,10 @@ void object_odf_context::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
Context.get_math_context().start();
|
||||
office_math_->oox_convert(Context.get_math_context());
|
||||
}
|
||||
else if(object_type_ == 4 && office_spreadsheet_)
|
||||
{
|
||||
//embedded
|
||||
}
|
||||
}
|
||||
void object_odf_context::calc_cache_series(std::wstring adress, std::vector<std::wstring> & cash)
|
||||
{
|
||||
@ -544,7 +556,7 @@ bool process_build_object::visit_rows(unsigned int repeated)
|
||||
//////////////////////////////////////////////////
|
||||
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 +582,18 @@ void process_build_object::visit(office_chart& val)
|
||||
void process_build_object::visit(office_text& val)
|
||||
{
|
||||
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)
|
||||
{
|
||||
object_odf_context_.object_type_ = 3; //0;//временно замещающая картинка
|
||||
object_odf_context_.office_math_ = &val;//конвертация будет уровнем выше
|
||||
object_odf_context_.object_type_ = 3; //= 0 - временно замещающая картинка
|
||||
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)
|
||||
{
|
||||
object_odf_context_.object_type_ = 1;
|
||||
|
||||
@ -52,6 +52,7 @@
|
||||
#include "office_body.h"
|
||||
#include "office_chart.h"
|
||||
#include "office_text.h"
|
||||
#include "office_spreadsheet.h"
|
||||
#include "math_elements.h"
|
||||
#include "table.h"
|
||||
#include "odfcontext.h"
|
||||
@ -118,6 +119,7 @@ public:
|
||||
object_type_ (0),
|
||||
office_text_ (NULL),
|
||||
office_math_ (NULL),
|
||||
office_spreadsheet_ (NULL),
|
||||
baseRef_ (ref),
|
||||
baseFontHeight_ (12)
|
||||
{
|
||||
@ -159,6 +161,7 @@ public:
|
||||
int object_type_;
|
||||
office_text *office_text_;
|
||||
office_math *office_math_;
|
||||
office_spreadsheet *office_spreadsheet_;
|
||||
|
||||
int baseFontHeight_;
|
||||
std::wstring baseRef_;
|
||||
@ -211,7 +214,6 @@ public:
|
||||
///////////////////////////////////////////
|
||||
|
||||
};
|
||||
// Класс для обхода всех элеменов office:object для построения диаграммы
|
||||
|
||||
class process_build_object
|
||||
: public base_visitor,
|
||||
@ -222,7 +224,8 @@ class process_build_object
|
||||
public visitor<office_chart>,
|
||||
public visitor<office_text>,
|
||||
public visitor<office_math>,
|
||||
|
||||
public visitor<office_spreadsheet>,
|
||||
|
||||
public const_visitor<chart_chart>,
|
||||
|
||||
public const_visitor<chart_title>,
|
||||
@ -283,47 +286,48 @@ private:
|
||||
public:
|
||||
|
||||
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_chart & val);
|
||||
virtual void visit(office_text & val);
|
||||
virtual void visit(office_math & val);
|
||||
virtual void visit(office_body & val);
|
||||
virtual void visit(office_chart & val);
|
||||
virtual void visit(office_text & 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_subtitle& val);
|
||||
virtual void visit(const chart_footer& val);
|
||||
virtual void visit(const chart_legend& val);
|
||||
virtual void visit(const chart_chart & val);
|
||||
virtual void visit(const chart_title & val);
|
||||
virtual void visit(const chart_subtitle & 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_axis& val);
|
||||
virtual void visit(const chart_series& val);
|
||||
virtual void visit(const chart_domain& val);
|
||||
virtual void visit(const chart_data_point & val);
|
||||
virtual void visit(const chart_mean_value & val);
|
||||
virtual void visit(const chart_error_indicator & val);
|
||||
virtual void visit(const chart_axis & val);
|
||||
virtual void visit(const chart_series & val);
|
||||
virtual void visit(const chart_domain & val);
|
||||
virtual void visit(const chart_data_point & val);
|
||||
virtual void visit(const chart_mean_value & val);
|
||||
virtual void visit(const chart_error_indicator & val);
|
||||
virtual void visit(const chart_regression_curve & val);
|
||||
virtual void visit(const chart_equation & val);
|
||||
virtual void visit(const chart_categories& val);
|
||||
virtual void visit(const chart_grid& val);
|
||||
virtual void visit(const chart_wall& val);
|
||||
virtual void visit(const chart_floor& val);
|
||||
virtual void visit(const table_table& val);
|
||||
virtual void visit(const chart_equation & val);
|
||||
virtual void visit(const chart_categories & val);
|
||||
virtual void visit(const chart_grid & val);
|
||||
virtual void visit(const chart_wall & val);
|
||||
virtual void visit(const chart_floor & val);
|
||||
virtual void visit(const table_table & val);
|
||||
|
||||
virtual void visit(const table_table_rows& 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_rows & 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_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(const table_table_row& val);
|
||||
virtual void visit(table_table_rows & val);
|
||||
virtual void visit(const table_table_row & val);
|
||||
|
||||
virtual void visit(const table_columns_no_group& val);
|
||||
virtual void visit(table_table_header_columns& val);
|
||||
virtual void visit(table_table_columns& val);
|
||||
virtual void visit(const table_columns_no_group & val);
|
||||
virtual void visit(table_table_header_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& val);
|
||||
virtual void visit(const table_table_column & val);
|
||||
|
||||
|
||||
virtual void visit(const table_table_cell& val);
|
||||
|
||||
@ -116,7 +116,6 @@ public:
|
||||
void apply_from(const common_horizontal_margin_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(length_or_percent) fo_margin_left_;
|
||||
_CP_OPT(length_or_percent) fo_margin_right_;
|
||||
};
|
||||
@ -129,7 +128,6 @@ public:
|
||||
void apply_from(const common_vertical_margin_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(length_or_percent) fo_margin_top_;
|
||||
_CP_OPT(length_or_percent) fo_margin_bottom_;
|
||||
};
|
||||
@ -143,10 +141,7 @@ public:
|
||||
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(length_or_percent) fo_margin_;
|
||||
|
||||
friend class style_page_layout_properties_attlist;
|
||||
};
|
||||
|
||||
// common-math_style_attlist
|
||||
@ -158,9 +153,7 @@ public:
|
||||
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(math_variant) mathvariant_;
|
||||
|
||||
};
|
||||
|
||||
// common-break-attlist
|
||||
@ -171,7 +164,6 @@ public:
|
||||
void apply_from(const common_break_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(fo_break) fo_break_before_;
|
||||
_CP_OPT(fo_break) fo_break_after_;
|
||||
|
||||
@ -185,7 +177,6 @@ public:
|
||||
void apply_from(const common_page_number_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(unsigned int) style_page_number_;
|
||||
|
||||
};
|
||||
@ -198,7 +189,6 @@ public:
|
||||
void apply_from(const common_background_color_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(background_color) fo_background_color_;
|
||||
|
||||
};
|
||||
@ -211,7 +201,6 @@ public:
|
||||
void apply_from(const common_shadow_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(shadow_type) style_shadow_;
|
||||
|
||||
};
|
||||
@ -224,7 +213,6 @@ public:
|
||||
void apply_from(const common_keep_with_next_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(keep_together) keep_together_;
|
||||
|
||||
};
|
||||
@ -238,7 +226,6 @@ public:
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
_CP_OPT(writing_mode) style_writing_mode_;
|
||||
|
||||
};
|
||||
|
||||
/// common-draw-data-attlist
|
||||
@ -249,7 +236,6 @@ public:
|
||||
void apply_from(const common_xlink_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) href_;
|
||||
_CP_OPT(xlink_type) type_;
|
||||
_CP_OPT(xlink_show) show_;
|
||||
@ -265,7 +251,6 @@ public:
|
||||
void apply_from(const common_value_and_type_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(office_value_type) office_value_type_;
|
||||
_CP_OPT(std::wstring) office_value_;
|
||||
_CP_OPT(std::wstring) office_currency_;
|
||||
@ -273,7 +258,6 @@ public:
|
||||
_CP_OPT(std::wstring) office_time_value_;
|
||||
_CP_OPT(std::wstring) office_boolean_value_;
|
||||
_CP_OPT(std::wstring) office_string_value_;
|
||||
|
||||
};
|
||||
|
||||
// common-border-attlist
|
||||
@ -284,7 +268,6 @@ public:
|
||||
void apply_from(const common_border_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(border_style) fo_border_;
|
||||
_CP_OPT(border_style) fo_border_top_;
|
||||
_CP_OPT(border_style) fo_border_bottom_;
|
||||
@ -301,16 +284,10 @@ public:
|
||||
void apply_from(const common_border_line_width_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
// style:border-line-width
|
||||
_CP_OPT(border_widths) style_border_line_width_;
|
||||
// style:border-line-width-top
|
||||
_CP_OPT(border_widths) style_border_line_width_top_;
|
||||
// style:border-line-width-bottom
|
||||
_CP_OPT(border_widths) style_border_line_width_bottom_;
|
||||
// style:border-line-width-left
|
||||
_CP_OPT(border_widths) style_border_line_width_left_;
|
||||
// style:border-line-width-right
|
||||
_CP_OPT(border_widths) style_border_line_width_right_;
|
||||
|
||||
};
|
||||
@ -323,7 +300,6 @@ public:
|
||||
void apply_from(const common_padding_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(length) fo_padding_;
|
||||
|
||||
_CP_OPT(length) fo_padding_top_;
|
||||
@ -340,12 +316,11 @@ public:
|
||||
void apply_from(const common_rotation_angle_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(unsigned int) style_rotation_angle_;
|
||||
|
||||
};
|
||||
|
||||
/// common-num-format-attlist
|
||||
// common-num-format-attlist
|
||||
class common_num_format_attlist
|
||||
{
|
||||
public:
|
||||
@ -353,13 +328,12 @@ public:
|
||||
void apply_from(const common_num_format_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) style_num_format_;
|
||||
_CP_OPT(Bool) style_num_letter_sync_;
|
||||
|
||||
};
|
||||
|
||||
/// common-num-format-prefix-suffix-attlist
|
||||
// common-num-format-prefix-suffix-attlist
|
||||
class common_num_format_prefix_suffix_attlist
|
||||
{
|
||||
public:
|
||||
@ -367,13 +341,12 @@ public:
|
||||
void apply_from(const common_num_format_prefix_suffix_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) style_num_prefix_;
|
||||
_CP_OPT(std::wstring) style_num_suffix_;
|
||||
};
|
||||
|
||||
|
||||
/// common-text-align
|
||||
// common-text-align
|
||||
class common_text_align
|
||||
{
|
||||
public:
|
||||
@ -381,11 +354,10 @@ public:
|
||||
void apply_from(const common_text_align & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(text_align) fo_text_align_;
|
||||
};
|
||||
|
||||
/// common-draw-size-attlist
|
||||
// common-draw-size-attlist
|
||||
class common_draw_size_attlist
|
||||
{
|
||||
public:
|
||||
@ -393,7 +365,6 @@ public:
|
||||
void apply_from(const common_draw_size_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(length) svg_width_;
|
||||
_CP_OPT(length) svg_height_;
|
||||
|
||||
@ -407,7 +378,6 @@ public:
|
||||
void apply_from(const common_text_anchor_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(anchor_type) type_;
|
||||
_CP_OPT(unsigned int) page_number_;
|
||||
};
|
||||
@ -424,7 +394,6 @@ public:
|
||||
}
|
||||
void serialize(CP_ATTR_NODE){}
|
||||
|
||||
public:
|
||||
// _CP_OPT(animation_type) type_;
|
||||
//_CP_OPT(animation_direction) direction_;
|
||||
//text:animation
|
||||
@ -435,7 +404,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
/// common-draw-rel-size-attlist
|
||||
// common-draw-rel-size-attlist
|
||||
class common_draw_rel_size_attlist
|
||||
{
|
||||
public:
|
||||
@ -449,7 +418,7 @@ public:
|
||||
_CP_OPT(percent_or_scale) style_rel_height_;
|
||||
};
|
||||
|
||||
/// common-vertical-rel-attlist
|
||||
// common-vertical-rel-attlist
|
||||
class common_vertical_rel_attlist
|
||||
{
|
||||
public:
|
||||
@ -457,12 +426,11 @@ public:
|
||||
void apply_from(const common_vertical_rel_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(vertical_rel) style_vertical_rel_;
|
||||
|
||||
};
|
||||
|
||||
/// common-horizontal-rel-attlist
|
||||
// common-horizontal-rel-attlist
|
||||
class common_horizontal_rel_attlist
|
||||
{
|
||||
public:
|
||||
@ -470,12 +438,11 @@ public:
|
||||
void apply_from(const common_horizontal_rel_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(horizontal_rel) style_horizontal_rel_;
|
||||
|
||||
};
|
||||
|
||||
/// common-vertical-pos-attlist
|
||||
// common-vertical-pos-attlist
|
||||
class common_vertical_pos_attlist
|
||||
{
|
||||
public:
|
||||
@ -483,13 +450,12 @@ public:
|
||||
void apply_from(const common_vertical_pos_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(vertical_pos) style_vertical_pos_;
|
||||
_CP_OPT(length) svg_y_;
|
||||
|
||||
};
|
||||
|
||||
/// common-horizontal-pos-attlist
|
||||
// common-horizontal-pos-attlist
|
||||
class common_horizontal_pos_attlist
|
||||
{
|
||||
public:
|
||||
@ -498,13 +464,12 @@ public:
|
||||
void apply_from(const common_horizontal_pos_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(horizontal_pos) style_horizontal_pos_;
|
||||
_CP_OPT(length) svg_x_;
|
||||
|
||||
};
|
||||
|
||||
/// common-draw-style-name-attlist
|
||||
// common-draw-style-name-attlist
|
||||
class common_draw_style_name_attlist
|
||||
{
|
||||
public:
|
||||
@ -512,7 +477,6 @@ public:
|
||||
void apply_from(const common_draw_style_name_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(style_ref) draw_style_name_;
|
||||
_CP_OPT(std::wstring) draw_class_names_;
|
||||
_CP_OPT(style_ref) presentation_style_name_;
|
||||
@ -528,7 +492,6 @@ public:
|
||||
void apply_from(const common_draw_z_index_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(int) draw_z_index_;
|
||||
};
|
||||
|
||||
@ -540,7 +503,6 @@ public:
|
||||
void apply_from(const common_draw_id_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) draw_id_;
|
||||
};
|
||||
|
||||
@ -552,7 +514,6 @@ public:
|
||||
void apply_from(const common_draw_layer_name_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) draw_layer_;
|
||||
};
|
||||
|
||||
@ -564,7 +525,6 @@ public:
|
||||
void apply_from(const common_draw_transform_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) draw_transform_;
|
||||
};
|
||||
|
||||
@ -576,7 +536,6 @@ public:
|
||||
void apply_from(const common_draw_name_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) draw_name_;
|
||||
};
|
||||
|
||||
@ -588,7 +547,6 @@ public:
|
||||
void apply_from(const common_text_spreadsheet_shape_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) table_end_cell_address_;
|
||||
_CP_OPT(length) table_end_x_;
|
||||
_CP_OPT(length) table_end_y_;
|
||||
@ -606,7 +564,6 @@ public:
|
||||
void apply_from(const common_draw_shape_with_styles_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
common_draw_z_index_attlist common_draw_z_index_attlist_;
|
||||
common_draw_id_attlist common_draw_id_attlist_;
|
||||
common_draw_layer_name_attlist common_draw_layer_name_attlist_;
|
||||
@ -625,7 +582,6 @@ public:
|
||||
void apply_from(const common_draw_text_style_name_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(style_ref) draw_text_style_name_;
|
||||
};
|
||||
|
||||
@ -637,7 +593,6 @@ public:
|
||||
void apply_from(const common_draw_position_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(length) svg_x_;
|
||||
_CP_OPT(length) svg_y_;
|
||||
|
||||
@ -651,7 +606,6 @@ public:
|
||||
void apply_from(const common_draw_shape_with_text_and_styles_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
common_draw_shape_with_styles_attlist common_draw_shape_with_styles_attlist_;
|
||||
common_draw_text_style_name_attlist common_draw_text_style_name_attlist_;
|
||||
};
|
||||
@ -664,7 +618,6 @@ public:
|
||||
void apply_from(const presentation_shape_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) presentation_class_;
|
||||
_CP_OPT(Bool) presentation_placeholder_;
|
||||
_CP_OPT(Bool) presentation_user_transformed_;
|
||||
@ -678,7 +631,6 @@ public:
|
||||
void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(style_ref) style_name_;
|
||||
_CP_OPT(std::wstring) number_language_;
|
||||
_CP_OPT(std::wstring) number_country_;
|
||||
@ -710,7 +662,6 @@ public:
|
||||
void apply_from(const common_presentation_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
public:
|
||||
_CP_OPT(presentation_class) presentation_class_;
|
||||
_CP_OPT(std::wstring) style_name_;
|
||||
_CP_OPT(Bool) presentation_placeholder_;
|
||||
@ -726,7 +677,6 @@ public:
|
||||
void apply_from(const common_anim_smil_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE){}
|
||||
|
||||
public:
|
||||
//_CP_OPT(std::wstring) smil_direction_;
|
||||
//_CP_OPT(std::wstring) smil_subtype_;
|
||||
//_CP_OPT(std::wstring) smil_type_;
|
||||
|
||||
@ -52,10 +52,10 @@ static const _shape_converter _OO_OOX_custom_shapes[]=
|
||||
{L"hexagon" ,L"hexagon" ,0 ,0 ,0 },
|
||||
{L"octagon" ,L"octagon" ,0 ,0 ,0 },
|
||||
{L"star4" ,L"star4" ,1 ,0 ,50000 },
|
||||
{L"star5" ,L"star5" ,1 ,0 ,50000 },
|
||||
{L"star5" ,L"star5" ,0 ,0 ,50000 },//??? 19098 неверно
|
||||
{L"star8" ,L"star8" ,1 ,0 ,50000 },
|
||||
{L"star24" ,L"star24" ,1 ,0 ,50000 },
|
||||
{L"star6" ,L"star6" ,1 ,0 ,50000 },
|
||||
{L"star6" ,L"star6" ,0 ,0 ,50000 },
|
||||
{L"star12" ,L"star12" ,1 ,0 ,50000 },
|
||||
{L"round-rectangle" ,L"roundRect" ,0 ,0 ,0 },
|
||||
{L"ellipse" ,L"ellipse" ,0 ,0 ,0 },
|
||||
@ -137,6 +137,7 @@ static const _shape_converter _OO_OOX_custom_shapes[]=
|
||||
{L"mso-spt14" ,L"thickArrow" ,0 ,0 ,0 },
|
||||
{L"mso-spt17" ,L"Balloon" ,0 ,0 ,0 },
|
||||
{L"mso-spt18" ,L"irregularSeal1" ,0 ,0 ,0 },
|
||||
{L"mso-spt19" ,L"rect" ,0 ,0 ,0 },
|
||||
{L"mso-spt24" ,L"textBox" ,0 ,0 ,0 },
|
||||
{L"mso-spt25" ,L"" ,0 ,0 ,0 },
|
||||
{L"mso-spt26" ,L"" ,0 ,0 ,0 },
|
||||
|
||||
@ -184,7 +184,7 @@ double inch_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)
|
||||
{
|
||||
|
||||
@ -36,7 +36,6 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
@ -48,16 +47,20 @@
|
||||
#include "style_graphic_properties.h"
|
||||
#include "odfcontext.h"
|
||||
|
||||
#include "../docx/xlsx_package.h"
|
||||
#include "../docx/docx_package.h"
|
||||
#include "../docx/pptx_package.h"
|
||||
|
||||
#include "datatypes/length.h"
|
||||
#include "datatypes/borderstyle.h"
|
||||
|
||||
#include "../../../OfficeUtils/src/OfficeUtils.h"
|
||||
#include "../../../Common/3dParty/pole/pole.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace odf_reader {
|
||||
|
||||
|
||||
|
||||
/// draw-image-attlist
|
||||
|
||||
// draw-image-attlist
|
||||
void draw_image_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"draw:filter-name", draw_filter_name_);
|
||||
@ -85,11 +88,6 @@ void draw_chart_attlist::add_attributes( const xml::attributes_wc_ptr & Attribut
|
||||
const wchar_t * draw_image::ns = L"draw";
|
||||
const wchar_t * draw_image::name = L"image";
|
||||
|
||||
std::wostream & draw_image::text_to_stream(std::wostream & _Wostream) const
|
||||
{
|
||||
return _Wostream;
|
||||
}
|
||||
|
||||
void draw_image::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
draw_image_attlist_.add_attributes(Attributes);
|
||||
@ -288,5 +286,108 @@ void draw_object_ole::add_child_element( xml::sax * Reader, const std::wstring &
|
||||
CP_NOT_APPLICABLE_ELM();
|
||||
}
|
||||
|
||||
std::wstring draw_object_ole::detectObject(const std::wstring &fileName)
|
||||
{
|
||||
POLE::Storage *storage = new POLE::Storage(fileName.c_str());
|
||||
if (storage == NULL) return L"";
|
||||
|
||||
if (storage->open(false, false) == false)
|
||||
{
|
||||
delete storage;
|
||||
return L"";
|
||||
}
|
||||
std::wstring prog;
|
||||
POLE::Stream* pStream = new POLE::Stream(storage, "CompObj");
|
||||
if ((pStream) && (pStream->size() > 28))
|
||||
{
|
||||
//skip the CompObjHeader
|
||||
pStream->seek(28);
|
||||
|
||||
int sz_obj = pStream->size() - 28;
|
||||
|
||||
std::vector<std::string> str;
|
||||
|
||||
while (sz_obj > 0)
|
||||
{
|
||||
_UINT32 sz = 0;
|
||||
pStream->read((unsigned char*)&sz, 4); sz_obj-= 4;
|
||||
|
||||
if (sz > sz_obj)
|
||||
break;
|
||||
unsigned char *data = new unsigned char[sz];
|
||||
pStream->read(data, sz);
|
||||
|
||||
str.push_back(std::string((char*)data, sz));
|
||||
delete []data;
|
||||
|
||||
sz_obj-= sz;
|
||||
}
|
||||
if (!str.empty())
|
||||
{
|
||||
prog = std::wstring (str.back().begin(), str.back().end());
|
||||
}
|
||||
delete pStream;
|
||||
}
|
||||
delete storage;
|
||||
return prog;
|
||||
}
|
||||
|
||||
|
||||
std::wstring draw_object::office_convert(odf_document * odfDocument, int type)
|
||||
{
|
||||
std::wstring href_result;
|
||||
std::wstring folderPath = odfDocument->get_folder();
|
||||
std::wstring objectOutPath = FileSystem::Directory::CreateDirectoryWithUniqueName(folderPath);
|
||||
|
||||
if (type == 1)
|
||||
{
|
||||
oox::package::docx_document outputDocx;
|
||||
oox::docx_conversion_context conversionDocxContext ( odfDocument);
|
||||
|
||||
conversionDocxContext.set_output_document (&outputDocx);
|
||||
//conversionContext.set_font_directory (fontsPath);
|
||||
|
||||
if (odfDocument->docx_convert(conversionDocxContext))
|
||||
{
|
||||
outputDocx.write(objectOutPath);
|
||||
|
||||
href_result = common_xlink_attlist_.href_.get_value_or(L"Object");
|
||||
int pos = href_result.find(L"./");
|
||||
if (pos >= 0) href_result = href_result.substr(2);
|
||||
|
||||
href_result = L"docx" + href_result + L".docx";
|
||||
}
|
||||
}
|
||||
if (type == 2)
|
||||
{
|
||||
oox::package::xlsx_document outputXlsx;
|
||||
oox::xlsx_conversion_context conversionXlsxContext ( odfDocument);
|
||||
|
||||
conversionXlsxContext.set_output_document (&outputXlsx);
|
||||
//conversionContext.set_font_directory (fontsPath);
|
||||
|
||||
if (odfDocument->xlsx_convert(conversionXlsxContext))
|
||||
{
|
||||
outputXlsx.write(objectOutPath);
|
||||
|
||||
href_result = common_xlink_attlist_.href_.get_value_or(L"Object");
|
||||
int pos = href_result.find(L"./");
|
||||
if (pos >= 0) href_result = href_result.substr(2);
|
||||
|
||||
href_result = L"xlsx" + href_result + L".xlsx";
|
||||
}
|
||||
}
|
||||
if (!href_result.empty())
|
||||
{
|
||||
std::wstring temp_file = folderPath + FILE_SEPARATOR_STR + href_result;
|
||||
|
||||
COfficeUtils oCOfficeUtils(NULL);
|
||||
oCOfficeUtils.CompressFileOrDirectory(objectOutPath.c_str(), temp_file.c_str(), -1);
|
||||
}
|
||||
FileSystem::Directory::DeleteDirectory(objectOutPath);
|
||||
|
||||
return href_result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,12 +35,18 @@
|
||||
#include <cpdoccore/CPOptional.h>
|
||||
#include <cpdoccore/xml/xmlelement.h>
|
||||
#include <cpdoccore/xml/nodetype.h>
|
||||
|
||||
#include "office_elements.h"
|
||||
#include "office_elements_create.h"
|
||||
#include "datatypes/common_attlists.h"
|
||||
#include "../docx/xlsxconversioncontext.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace oox
|
||||
{
|
||||
class _oox_drawing;
|
||||
}
|
||||
typedef shared_ptr<oox::_oox_drawing>::Type oox_drawing_ptr;
|
||||
|
||||
namespace odf_reader {
|
||||
|
||||
/// draw-image-attlist
|
||||
@ -54,7 +60,6 @@ public:
|
||||
|
||||
};
|
||||
|
||||
|
||||
class draw_image : public office_element_impl<draw_image>
|
||||
{
|
||||
public:
|
||||
@ -68,22 +73,18 @@ public:
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
|
||||
virtual void pptx_convert(oox::pptx_conversion_context & Context);
|
||||
|
||||
public:
|
||||
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);
|
||||
|
||||
private:
|
||||
draw_image_attlist draw_image_attlist_;
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
office_element_ptr office_binary_data_;
|
||||
office_element_ptr_array content_;
|
||||
|
||||
friend class odf_document;
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_image);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//draw-chart-attlist
|
||||
class draw_chart_attlist
|
||||
@ -91,12 +92,10 @@ class draw_chart_attlist
|
||||
public:
|
||||
void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
public:
|
||||
//_CP_OPT(std::wstring) draw_filter_name_;
|
||||
|
||||
};
|
||||
|
||||
//объект рисования не нужен .. нужно только место для фрэйма - сам чарт в другом месте
|
||||
class draw_chart : public office_element_impl<draw_chart>
|
||||
{
|
||||
public:
|
||||
@ -106,7 +105,7 @@ public:
|
||||
static const ElementType type = typeDrawChart;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
//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 pptx_convert(oox::pptx_conversion_context & Context);
|
||||
|
||||
@ -117,18 +116,19 @@ private:
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
private:
|
||||
draw_chart_attlist draw_chart_attlist_;
|
||||
draw_chart_attlist draw_chart_attlist_;
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
office_element_ptr_array content_;
|
||||
|
||||
//office_element_ptr title_;
|
||||
office_element_ptr_array content_;
|
||||
//office_element_ptr title_;
|
||||
|
||||
friend class odf_document;
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_chart);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//draw-frame-attlist
|
||||
//draw-frame-attlist
|
||||
class draw_frame_attlist
|
||||
{
|
||||
public:
|
||||
@ -150,20 +150,17 @@ public:
|
||||
static const ElementType type = typeDrawFrame;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
draw_frame() : oox_drawing_(NULL) {}
|
||||
|
||||
virtual void docx_convert(oox::docx_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_placeHolder(oox::pptx_conversion_context & Context);
|
||||
|
||||
public:
|
||||
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 ;
|
||||
|
||||
odf_types::common_presentation_attlist common_presentation_attlist_;
|
||||
odf_types::union_common_draw_attlists common_draw_attlists_;
|
||||
|
||||
@ -174,7 +171,7 @@ public:
|
||||
office_element_ptr_array content_;
|
||||
|
||||
office_element_ptr office_event_listeners_;
|
||||
// в content перенести нельзя - иначе событи будет добавляться не к этому объекту а следующему
|
||||
// в content перенести нельзя - иначе событи будет добавляться не к этому объекту а следующему
|
||||
office_element_ptr draw_glue_point_;
|
||||
office_element_ptr draw_image_map_;
|
||||
//office_element_ptr draw_chart_map_;
|
||||
@ -184,12 +181,19 @@ public:
|
||||
friend class odf_document;
|
||||
friend class draw_image;
|
||||
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);
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//draw-frame-attlist
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
//draw-frame-attlist
|
||||
class draw_g_attlist
|
||||
{
|
||||
public:
|
||||
@ -211,19 +215,19 @@ public:
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
|
||||
virtual void pptx_convert(oox::pptx_conversion_context & Context);
|
||||
|
||||
public:
|
||||
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:
|
||||
odf_types::union_common_draw_attlists common_draw_attlists_;
|
||||
draw_g_attlist draw_g_attlist_;
|
||||
|
||||
office_element_ptr_array content_;
|
||||
|
||||
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_g);
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
// draw-text-box-attlist
|
||||
class draw_text_box_attlist
|
||||
{
|
||||
@ -239,7 +243,6 @@ public:
|
||||
|
||||
};
|
||||
|
||||
|
||||
class draw_text_box : public office_element_impl<draw_text_box>
|
||||
{
|
||||
public:
|
||||
@ -253,20 +256,20 @@ public:
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
|
||||
virtual void pptx_convert(oox::pptx_conversion_context & Context);
|
||||
|
||||
public:
|
||||
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
|
||||
|
||||
draw_text_box_attlist draw_text_box_attlist_;
|
||||
office_element_ptr_array content_;
|
||||
|
||||
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);
|
||||
virtual void add_text(const std::wstring & Text);
|
||||
|
||||
public:
|
||||
draw_text_box_attlist draw_text_box_attlist_;
|
||||
office_element_ptr_array content_;
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_text_box);
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
/// draw-object-attlist
|
||||
class draw_object_attlist
|
||||
{
|
||||
@ -289,17 +292,18 @@ public:
|
||||
static const ElementType type = typeDrawObject;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context);
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
|
||||
virtual void pptx_convert(oox::pptx_conversion_context & Context);
|
||||
virtual void docx_convert (oox::docx_conversion_context & Context);
|
||||
virtual void xlsx_convert (oox::xlsx_conversion_context & Context);
|
||||
virtual void pptx_convert (oox::pptx_conversion_context & Context);
|
||||
|
||||
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:
|
||||
draw_object_attlist draw_object_attlist_;
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
|
||||
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);
|
||||
|
||||
std::wstring office_convert(odf_document * odfDocument, int type);
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_object);
|
||||
@ -318,13 +322,14 @@ public:
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
|
||||
virtual void pptx_convert(oox::pptx_conversion_context & Context);
|
||||
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
_CP_OPT(std::wstring) draw_class_id_;
|
||||
|
||||
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:
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
_CP_OPT(std::wstring) draw_class_id_;
|
||||
std::wstring detectObject(const std::wstring &fileName);
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_object_ole);
|
||||
|
||||
@ -762,7 +762,7 @@ int ComputeMarginY(const style_page_layout_properties_attlist & pageProperties,
|
||||
|
||||
}
|
||||
|
||||
void common_draw_docx_convert(oox::docx_conversion_context & Context, const union_common_draw_attlists & attlists_,oox::_docx_drawing &drawing)
|
||||
void common_draw_docx_convert(oox::docx_conversion_context & Context, const union_common_draw_attlists & attlists_, oox::_docx_drawing *drawing)
|
||||
{
|
||||
const _CP_OPT(style_ref) & styleRef = attlists_.shape_with_text_and_styles_.
|
||||
common_draw_shape_with_styles_attlist_.common_draw_style_name_attlist_.draw_style_name_;
|
||||
@ -773,7 +773,7 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, const unio
|
||||
odf_reader::style_instance* styleInst = Context.root()->odf_context().styleContainer().style_by_name(styleName, odf_types::style_family::Graphic,Context.process_headers_footers_);
|
||||
if (styleInst)
|
||||
{
|
||||
if (drawing.sub_type > 1) //without text-box
|
||||
if (drawing->sub_type > 1) //without text-box
|
||||
{
|
||||
style_instance * defaultStyle = Context.root()->odf_context().styleContainer().style_default_by_type(odf_types::style_family::Graphic);
|
||||
if (defaultStyle)instances.push_back(defaultStyle);
|
||||
@ -797,20 +797,20 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, const unio
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
drawing.styleWrap = graphicProperties.style_wrap_;
|
||||
drawing->styleWrap = graphicProperties.style_wrap_;
|
||||
|
||||
if (drawing.styleWrap && drawing.styleWrap->get_type() == style_wrap::Parallel)
|
||||
if (drawing->styleWrap && drawing->styleWrap->get_type() == style_wrap::Parallel)
|
||||
{
|
||||
if (graphicProperties.style_number_wrapped_paragraphs_)
|
||||
drawing.parallel = graphicProperties.style_number_wrapped_paragraphs_->get_value();
|
||||
drawing->parallel = graphicProperties.style_number_wrapped_paragraphs_->get_value();
|
||||
}
|
||||
|
||||
_CP_OPT(run_through) styleRunThrough = graphicProperties.style_run_through_;
|
||||
|
||||
drawing.styleHorizontalRel = graphicProperties.common_horizontal_rel_attlist_.style_horizontal_rel_;
|
||||
drawing.styleHorizontalPos = graphicProperties.common_horizontal_pos_attlist_.style_horizontal_pos_;
|
||||
drawing.styleVerticalPos = graphicProperties.common_vertical_pos_attlist_.style_vertical_pos_;
|
||||
drawing.styleVerticalRel = graphicProperties.common_vertical_rel_attlist_.style_vertical_rel_;
|
||||
drawing->styleHorizontalRel = graphicProperties.common_horizontal_rel_attlist_.style_horizontal_rel_;
|
||||
drawing->styleHorizontalPos = graphicProperties.common_horizontal_pos_attlist_.style_horizontal_pos_;
|
||||
drawing->styleVerticalPos = graphicProperties.common_vertical_pos_attlist_.style_vertical_pos_;
|
||||
drawing->styleVerticalRel = graphicProperties.common_vertical_rel_attlist_.style_vertical_rel_;
|
||||
|
||||
_CP_OPT(anchor_type) anchor =
|
||||
attlists_.shape_with_text_and_styles_.
|
||||
@ -821,112 +821,116 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, const unio
|
||||
|
||||
int level_drawing = Context.get_drawing_context().get_current_level();
|
||||
|
||||
if (drawing.parallel == 1 || anchor && anchor->get_type() == anchor_type::AsChar || level_drawing >1 )
|
||||
if (drawing->parallel == 1 || anchor && anchor->get_type() == anchor_type::AsChar || level_drawing >1 )
|
||||
{
|
||||
drawing.isInline = true;
|
||||
drawing->isInline = true;
|
||||
}
|
||||
if (attlists_.shape_with_text_and_styles_.common_draw_shape_with_styles_attlist_.common_draw_transform_attlist_.draw_transform_)
|
||||
{
|
||||
std::wstring transformStr = attlists_.shape_with_text_and_styles_.common_draw_shape_with_styles_attlist_.common_draw_transform_attlist_.draw_transform_.get();
|
||||
oox_convert_transforms(transformStr, drawing.additional);
|
||||
oox_convert_transforms(transformStr, drawing->additional);
|
||||
}
|
||||
if (!drawing.isInline)
|
||||
if (!drawing->isInline)
|
||||
{
|
||||
if (!drawing.styleWrap)
|
||||
drawing.styleWrap = style_wrap(style_wrap::Parallel);//у опен офис и мс разные дефолты
|
||||
if (!drawing->styleWrap)
|
||||
drawing->styleWrap = style_wrap(style_wrap::Parallel);//у опен офис и мс разные дефолты
|
||||
|
||||
drawing.relativeHeight = L"2";
|
||||
drawing.behindDoc = L"0";
|
||||
drawing->relativeHeight = L"2";
|
||||
drawing->behindDoc = L"0";
|
||||
|
||||
_CP_OPT(int) zIndex = attlists_.shape_with_text_and_styles_.common_draw_shape_with_styles_attlist_.common_draw_z_index_attlist_.draw_z_index_;
|
||||
|
||||
if (zIndex)//порядок отрисовки объектов
|
||||
{
|
||||
if (*zIndex < 0)
|
||||
drawing.relativeHeight = L"0";
|
||||
drawing->relativeHeight = L"0";
|
||||
else
|
||||
drawing.relativeHeight = boost::lexical_cast<std::wstring>( 2 + *zIndex );
|
||||
drawing->relativeHeight = boost::lexical_cast<std::wstring>( 2 + *zIndex );
|
||||
}
|
||||
|
||||
if (drawing.styleWrap && drawing.styleWrap->get_type() == style_wrap::RunThrough
|
||||
if (drawing->styleWrap && drawing->styleWrap->get_type() == style_wrap::RunThrough
|
||||
&& styleRunThrough && styleRunThrough->get_type() == run_through::Background
|
||||
)
|
||||
{
|
||||
drawing. behindDoc = L"1";
|
||||
drawing-> behindDoc = L"1";
|
||||
}
|
||||
|
||||
drawing.margin_rect[0] = GetMargin(graphicProperties, sideLeft);
|
||||
drawing.margin_rect[1] = GetMargin(graphicProperties, sideTop);
|
||||
drawing.margin_rect[2] = GetMargin(graphicProperties, sideRight);
|
||||
drawing.margin_rect[3] = GetMargin(graphicProperties, sideBottom);
|
||||
drawing->margin_rect[0] = GetMargin(graphicProperties, sideLeft);
|
||||
drawing->margin_rect[1] = GetMargin(graphicProperties, sideTop);
|
||||
drawing->margin_rect[2] = GetMargin(graphicProperties, sideRight);
|
||||
drawing->margin_rect[3] = GetMargin(graphicProperties, sideBottom);
|
||||
|
||||
drawing.posOffsetH = ComputeMarginX(pagePropertiesNode, pageProperties, attlists_, graphicProperties, drawing.additional);
|
||||
drawing.posOffsetV = ComputeMarginY( pageProperties, attlists_, graphicProperties, drawing.additional);
|
||||
drawing->posOffsetH = ComputeMarginX(pagePropertiesNode, pageProperties, attlists_, graphicProperties, drawing->additional);
|
||||
drawing->posOffsetV = ComputeMarginY( pageProperties, attlists_, graphicProperties, drawing->additional);
|
||||
|
||||
if (attlists_.rel_size_.style_rel_width_)
|
||||
{
|
||||
int type = attlists_.rel_size_.style_rel_width_->get_type();
|
||||
drawing.pctWidth = attlists_.rel_size_.style_rel_width_->get_percent().get_value();
|
||||
int type = attlists_.rel_size_.style_rel_width_->get_type();
|
||||
|
||||
if (type == odf_types::percent_or_scale::Percent)
|
||||
drawing->pctWidth = attlists_.rel_size_.style_rel_width_->get_percent().get_value();
|
||||
}
|
||||
if (attlists_.rel_size_.style_rel_height_ )
|
||||
{
|
||||
int type = attlists_.rel_size_.style_rel_height_->get_type();
|
||||
drawing.pctHeight = attlists_.rel_size_.style_rel_height_->get_percent().get_value();
|
||||
int type = attlists_.rel_size_.style_rel_height_->get_type();
|
||||
|
||||
if (type == odf_types::percent_or_scale::Percent)
|
||||
drawing->pctHeight = attlists_.rel_size_.style_rel_height_->get_percent().get_value();
|
||||
}
|
||||
|
||||
}
|
||||
drawing.number_wrapped_paragraphs=graphicProperties.style_number_wrapped_paragraphs_.
|
||||
drawing->number_wrapped_paragraphs=graphicProperties.style_number_wrapped_paragraphs_.
|
||||
get_value_or( integer_or_nolimit( integer_or_nolimit::NoLimit) ).get_value();
|
||||
if (anchor && anchor->get_type() == anchor_type::AsChar && drawing.posOffsetV< 0)
|
||||
if (anchor && anchor->get_type() == anchor_type::AsChar && drawing->posOffsetV< 0)
|
||||
{
|
||||
drawing.posOffsetV = (int)(length(0.01, length::cm).get_value_unit(length::emu));
|
||||
drawing->posOffsetV = (int)(length(0.01, length::cm).get_value_unit(length::emu));
|
||||
}
|
||||
//////////////////////////////////////////////
|
||||
graphicProperties.apply_to(drawing.additional);
|
||||
graphicProperties.apply_to(drawing->additional);
|
||||
//////////////////////////////////////////
|
||||
bool bTxbx = (drawing.sub_type == 1);
|
||||
bool bTxbx = (drawing->sub_type == 1);
|
||||
|
||||
Compute_GraphicFill(graphicProperties.common_draw_fill_attlist_, graphicProperties.style_background_image_, Context.root()->odf_context().drawStyles() ,drawing.fill, bTxbx);
|
||||
Compute_GraphicFill(graphicProperties.common_draw_fill_attlist_, graphicProperties.style_background_image_, Context.root()->odf_context().drawStyles() ,drawing->fill, bTxbx);
|
||||
|
||||
if ((drawing.fill.bitmap) && (drawing.fill.bitmap->rId.length() < 1))
|
||||
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::typeImage, drawing.fill.bitmap->isInternal, href);
|
||||
std::wstring href = drawing->fill.bitmap->xlink_href_;
|
||||
drawing->fill.bitmap->rId = Context.add_mediaitem(href, oox::typeImage, drawing->fill.bitmap->isInternal, href);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
drawing.additional.push_back(odf_reader::_property(L"border_width_left", Compute_BorderWidth(graphicProperties, sideLeft)));
|
||||
drawing.additional.push_back(odf_reader::_property(L"border_width_top", Compute_BorderWidth(graphicProperties, sideTop)));
|
||||
drawing.additional.push_back(odf_reader::_property(L"border_width_right", Compute_BorderWidth(graphicProperties, sideRight)));
|
||||
drawing.additional.push_back(odf_reader::_property(L"border_width_bottom", Compute_BorderWidth(graphicProperties, sideBottom)));
|
||||
drawing->additional.push_back(odf_reader::_property(L"border_width_left", Compute_BorderWidth(graphicProperties, sideLeft)));
|
||||
drawing->additional.push_back(odf_reader::_property(L"border_width_top", Compute_BorderWidth(graphicProperties, sideTop)));
|
||||
drawing->additional.push_back(odf_reader::_property(L"border_width_right", Compute_BorderWidth(graphicProperties, sideRight)));
|
||||
drawing->additional.push_back(odf_reader::_property(L"border_width_bottom", Compute_BorderWidth(graphicProperties, sideBottom)));
|
||||
|
||||
if (graphicProperties.common_border_attlist_.fo_border_)
|
||||
{
|
||||
if (graphicProperties.common_border_attlist_.fo_border_->is_none() == false)
|
||||
{
|
||||
drawing.additional.push_back(_property(L"stroke-color", graphicProperties.common_border_attlist_.fo_border_->get_color().get_hex_value() ));
|
||||
drawing.additional.push_back(_property(L"stroke-width", graphicProperties.common_border_attlist_.fo_border_->get_length().get_value_unit(odf_types::length::pt) ));
|
||||
drawing->additional.push_back(_property(L"stroke-color", graphicProperties.common_border_attlist_.fo_border_->get_color().get_hex_value() ));
|
||||
drawing->additional.push_back(_property(L"stroke-width", graphicProperties.common_border_attlist_.fo_border_->get_length().get_value_unit(odf_types::length::pt) ));
|
||||
|
||||
}
|
||||
}
|
||||
///////////////////////////
|
||||
|
||||
drawing.x = get_value_emu(attlists_.position_.svg_x_);
|
||||
drawing.y = get_value_emu(attlists_.position_.svg_y_);
|
||||
drawing->x = get_value_emu(attlists_.position_.svg_x_);
|
||||
drawing->y = get_value_emu(attlists_.position_.svg_y_);
|
||||
|
||||
drawing.cx = get_value_emu(attlists_.rel_size_.common_draw_size_attlist_.svg_width_);
|
||||
drawing.cy = get_value_emu(attlists_.rel_size_.common_draw_size_attlist_.svg_height_);
|
||||
drawing->cx = get_value_emu(attlists_.rel_size_.common_draw_size_attlist_.svg_width_);
|
||||
drawing->cy = get_value_emu(attlists_.rel_size_.common_draw_size_attlist_.svg_height_);
|
||||
|
||||
if (drawing.cx < 0) //frame textbox int WORD_EXAMPLE.odt = 45 inch !!!!
|
||||
if (drawing->cx < 0) //frame textbox int WORD_EXAMPLE.odt = 45 inch !!!!
|
||||
{
|
||||
drawing.cx = -drawing.cx;
|
||||
drawing.additional.push_back(_property(L"fit-to-size", true));
|
||||
drawing->cx = -drawing->cx;
|
||||
drawing->additional.push_back(_property(L"fit-to-size", true));
|
||||
}
|
||||
|
||||
if (drawing.cy < 0)
|
||||
drawing.cy = 0;
|
||||
if (drawing->cy < 0)
|
||||
drawing->cy = 0;
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
if ((drawing.styleWrap) && (drawing.styleWrap->get_type() == style_wrap::Dynamic)) //автоподбор
|
||||
if ((drawing->styleWrap) && (drawing->styleWrap->get_type() == style_wrap::Dynamic)) //автоподбор
|
||||
{
|
||||
int max_width = get_value_emu(pageProperties.fo_page_width_);
|
||||
int max_height = get_value_emu(pageProperties.fo_page_height_);
|
||||
@ -959,49 +963,49 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, const unio
|
||||
// }
|
||||
//}
|
||||
|
||||
//if (drawing.cx<1 && max_width >0)
|
||||
//if (drawing->cx<1 && max_width >0)
|
||||
//{
|
||||
// drawing.cx = std::min(762000,max_width);
|
||||
// drawing->cx = std::min(762000,max_width);
|
||||
//}
|
||||
//if (drawing.cy <1 && max_height >0)
|
||||
//if (drawing->cy <1 && max_height >0)
|
||||
//{
|
||||
// drawing.cy = std::min(142875,max_height);
|
||||
// drawing->cy = std::min(142875,max_height);
|
||||
//}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
_CP_OPT(double) dVal;
|
||||
|
||||
GetProperty(drawing.additional, L"svg:scale_x",dVal);
|
||||
if (dVal)drawing.cx = (int)(0.5 + drawing.cx * dVal.get());
|
||||
GetProperty(drawing->additional, L"svg:scale_x",dVal);
|
||||
if (dVal)drawing->cx = (int)(0.5 + drawing->cx * dVal.get());
|
||||
|
||||
GetProperty(drawing.additional, L"svg:scale_y",dVal);
|
||||
if (dVal)drawing.cy = (int)(0.5 + drawing.cy * dVal.get());
|
||||
GetProperty(drawing->additional, L"svg:scale_y",dVal);
|
||||
if (dVal)drawing->cy = (int)(0.5 + drawing->cy * dVal.get());
|
||||
|
||||
GetProperty(drawing.additional, L"svg:translate_x", dVal);
|
||||
GetProperty(drawing->additional, L"svg:translate_x", dVal);
|
||||
if (dVal)
|
||||
{
|
||||
int val = get_value_emu(dVal.get());
|
||||
drawing.x = val >= 0 ? val : 0; //??? todooo отрицательные величины ...
|
||||
drawing->x = val >= 0 ? val : 0; //??? todooo отрицательные величины ...
|
||||
}
|
||||
|
||||
GetProperty(drawing.additional,L"svg:translate_y", dVal);
|
||||
GetProperty(drawing->additional,L"svg:translate_y", dVal);
|
||||
if (dVal)
|
||||
{
|
||||
int val = get_value_emu(dVal.get());
|
||||
drawing.y = val >= 0 ? val : 0; //??? todooo отрицательные величины ...
|
||||
drawing->y = val >= 0 ? val : 0; //??? todooo отрицательные величины ...
|
||||
}
|
||||
|
||||
if (drawing.inGroup && drawing.type != oox::typeGroupShape)
|
||||
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);
|
||||
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);
|
||||
|
||||
// ваще то тут "несовсем" всерно ... нужно сначала все стартовые позиции добавить ..
|
||||
_INT32 x_group_offset, y_group_offset;
|
||||
Context.get_drawing_context().get_position_group(x_group_offset, y_group_offset);
|
||||
|
||||
drawing.x -= x_group_offset;
|
||||
drawing.y -= y_group_offset;
|
||||
drawing->x -= x_group_offset;
|
||||
drawing->y -= y_group_offset;
|
||||
|
||||
}
|
||||
|
||||
@ -1009,7 +1013,6 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, const unio
|
||||
void draw_shape::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
oox::_docx_drawing drawing = oox::_docx_drawing();
|
||||
|
||||
drawing.type = oox::typeShape;
|
||||
@ -1028,7 +1031,7 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context)
|
||||
Context.get_drawing_context().clear_stream_shape();
|
||||
|
||||
/////////
|
||||
common_draw_docx_convert(Context, common_draw_attlists_, drawing);
|
||||
common_draw_docx_convert(Context, common_draw_attlists_, &drawing);
|
||||
/////////
|
||||
|
||||
if (bad_shape_ && drawing.fill.bitmap) // CV_Kucheruk_Maria(rus).odt - картинка по дебильному
|
||||
@ -1064,7 +1067,7 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context)
|
||||
else
|
||||
Context.add_new_run(_T(""));
|
||||
|
||||
docx_serialize(strm, drawing, Context.get_drawing_state_content());
|
||||
drawing.serialize(strm/*, Context.get_drawing_state_content()*/);
|
||||
|
||||
if (new_run) Context.finish_run();
|
||||
|
||||
@ -1085,11 +1088,18 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
|
||||
if (!frame)
|
||||
return;
|
||||
|
||||
if (pos_replaicement >=0 && !Context.get_drawing_context().get_use_image_replace())
|
||||
return;//заменяемый объект
|
||||
//--------------------------------------------------
|
||||
//тут может быть не только текст , но и таблицы, другие объекты ...
|
||||
oox::StreamsManPtr prev = Context.get_stream_man();
|
||||
oox::_docx_drawing * drawing = dynamic_cast<oox::_docx_drawing *>(frame->oox_drawing_.get());
|
||||
if (!drawing) return;
|
||||
|
||||
if (pos_replaicement >= 0 && !Context.get_drawing_context().get_use_image_replace())
|
||||
{
|
||||
return; //skip replacement image (math, chart, ...) - возможно записать как альтернативный контент - todooo ???
|
||||
}
|
||||
|
||||
if (drawing->type == oox::typeUnknown)
|
||||
drawing->type = oox::typeImage;
|
||||
|
||||
oox::StreamsManPtr prev = Context.get_stream_man();
|
||||
|
||||
std::wstringstream temp_stream(Context.get_drawing_context().get_text_stream_frame());
|
||||
Context.set_stream_man( boost::shared_ptr<oox::streams_man>( new oox::streams_man(temp_stream) ));
|
||||
@ -1110,14 +1120,7 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
|
||||
|
||||
Context.get_drawing_context().get_text_stream_frame() = temp_stream.str();
|
||||
Context.set_stream_man(prev);
|
||||
//--------------------------------------------------
|
||||
oox::_docx_drawing drawing = oox::_docx_drawing();
|
||||
|
||||
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();
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
oox::hyperlinks::_ref hyperlink = Context.last_hyperlink();
|
||||
//нужно еще систему конроля - могут придте уже "использованные" линки с картинок - из колонтитулов (но на них уже использовали релсы)
|
||||
@ -1125,20 +1128,14 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
|
||||
if (hyperlink.drawing == true && hyperlink.used_rels == false)
|
||||
{
|
||||
oox::_hlink_desc desc = {hyperlink.id, hyperlink.href, true};
|
||||
drawing.hlinks.push_back(desc);
|
||||
drawing->hlinks.push_back(desc);
|
||||
}
|
||||
|
||||
//if (Context.get_drawing_context().get_current_level() > 1)
|
||||
// drawing.isInline = true;
|
||||
|
||||
/////////
|
||||
common_draw_docx_convert(Context, frame->common_draw_attlists_, drawing);
|
||||
/////////
|
||||
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::typeImage, drawing.fill.bitmap->isInternal,href);
|
||||
drawing.fill.bitmap->bStretch = true;
|
||||
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::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_.
|
||||
common_draw_shape_with_styles_attlist_.
|
||||
@ -1154,41 +1151,16 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
|
||||
////////////////
|
||||
if (properties)
|
||||
{
|
||||
if (properties->content().fo_clip_ && drawing.fill.bitmap)
|
||||
if (properties->content().fo_clip_ && drawing->fill.bitmap)
|
||||
{
|
||||
std::wstring strRectClip = properties->content().fo_clip_.get();
|
||||
strRectClip = strRectClip.substr(5,strRectClip.length()-6);
|
||||
|
||||
std::wstring fileName = Context.root()->get_folder() + FILE_SEPARATOR_STR+ href;
|
||||
|
||||
drawing.fill.bitmap->bCrop = parse_clipping(strRectClip,fileName,drawing.fill.bitmap->cropRect, NULL/*Context.applicationFonts_*/);
|
||||
drawing->fill.bitmap->bCrop = parse_clipping(strRectClip, fileName, drawing->fill.bitmap->cropRect, NULL/*Context.applicationFonts_*/);
|
||||
}
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
std::wostream & strm = Context.output_stream();
|
||||
|
||||
runState = Context.get_run_state();
|
||||
pState = Context.get_paragraph_state();
|
||||
|
||||
if (!Context.get_drawing_context().in_group() && !pState)
|
||||
{
|
||||
Context.start_paragraph();
|
||||
Context.set_paragraph_keep(true);
|
||||
pState = Context.get_paragraph_state();
|
||||
}
|
||||
|
||||
Context.set_paragraph_state(false);
|
||||
|
||||
if (!Context.get_drawing_context().in_group())//user_test-odt.odt
|
||||
Context.add_new_run(_T(""));
|
||||
|
||||
docx_serialize(strm, drawing, Context.get_drawing_state_content());
|
||||
|
||||
if (!Context.get_drawing_context().in_group())
|
||||
Context.finish_run();
|
||||
|
||||
Context.set_paragraph_state(pState);
|
||||
|
||||
}
|
||||
|
||||
void draw_text_box::docx_convert(oox::docx_conversion_context & Context)
|
||||
@ -1223,28 +1195,24 @@ void draw_text_box::docx_convert(oox::docx_conversion_context & Context)
|
||||
Context.set_drawing_state_content (drState);
|
||||
Context.set_paragraph_keep (keepState);
|
||||
|
||||
/////...../////
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
|
||||
const draw_frame * frame = Context.get_drawing_context().get_current_frame();//owner
|
||||
if (!frame)
|
||||
return;
|
||||
oox::_docx_drawing drawing = oox::_docx_drawing();
|
||||
|
||||
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();
|
||||
oox::_docx_drawing * drawing = dynamic_cast<oox::_docx_drawing *>(frame->oox_drawing_.get());
|
||||
if (!drawing) return;
|
||||
|
||||
drawing.sub_type = 1; //textBox
|
||||
drawing->type = oox::typeShape;
|
||||
drawing->sub_type = 1; //textBox
|
||||
|
||||
const std::wstring & content = Context.get_drawing_context().get_text_stream_frame();
|
||||
|
||||
drawing.additional.push_back(_property(L"text-content",content));
|
||||
drawing->additional.push_back(_property(L"text-content",content));
|
||||
Context.get_drawing_context().clear_stream_frame();
|
||||
/////////
|
||||
common_draw_docx_convert(Context, frame->common_draw_attlists_, drawing);
|
||||
//+ локальные
|
||||
|
||||
/////////
|
||||
bool auto_fit_text = false;
|
||||
bool auto_fit_shape = false;
|
||||
|
||||
@ -1254,70 +1222,44 @@ void draw_text_box::docx_convert(oox::docx_conversion_context & Context)
|
||||
if ((draw_text_box_attlist_.fo_min_height_) && (draw_text_box_attlist_.fo_min_height_->get_type()==length_or_percent::Length))
|
||||
{
|
||||
size_t min_y = get_value_emu(draw_text_box_attlist_.fo_min_height_->get_length());
|
||||
if (drawing.cy < min_y)
|
||||
if (drawing->cy < min_y)
|
||||
{
|
||||
auto_fit_text = true;
|
||||
drawing.cy = min_y;
|
||||
drawing->cy = min_y;
|
||||
}
|
||||
if (drawing.cy < 36000) auto_fit_shape = true;
|
||||
if (drawing->cy < 36000) auto_fit_shape = true;
|
||||
}
|
||||
|
||||
|
||||
if ((draw_text_box_attlist_.fo_min_width_) && (draw_text_box_attlist_.fo_min_width_->get_type()==length_or_percent::Length))
|
||||
{
|
||||
size_t min_x = get_value_emu(draw_text_box_attlist_.fo_min_width_->get_length());
|
||||
if (drawing.cx < min_x)
|
||||
if (drawing->cx < min_x)
|
||||
{
|
||||
auto_fit_text = true;
|
||||
drawing.cx = min_x;
|
||||
drawing->cx = min_x;
|
||||
}
|
||||
if (drawing.cx < 36000) auto_fit_shape = true;
|
||||
if (drawing->cx < 36000) auto_fit_shape = true;
|
||||
}
|
||||
|
||||
|
||||
if ((draw_text_box_attlist_.fo_max_height_) && (draw_text_box_attlist_.fo_max_height_->get_type()==length_or_percent::Length))
|
||||
{
|
||||
size_t max_y = get_value_emu(draw_text_box_attlist_.fo_max_height_->get_length());
|
||||
if (drawing.cy > max_y) drawing.cy = max_y;
|
||||
if (drawing->cy > max_y) drawing->cy = max_y;
|
||||
}
|
||||
if ((draw_text_box_attlist_.fo_max_width_) && (draw_text_box_attlist_.fo_max_width_->get_type()==length_or_percent::Length))
|
||||
{
|
||||
size_t max_x = get_value_emu(draw_text_box_attlist_.fo_max_width_->get_length());
|
||||
if (drawing.cx > max_x) drawing.cy = max_x;
|
||||
if (drawing->cx > max_x) drawing->cy = max_x;
|
||||
}
|
||||
if (auto_fit_shape)
|
||||
drawing.additional.push_back(_property(L"auto-grow-height", auto_fit_shape));
|
||||
else if (auto_fit_text)
|
||||
drawing.additional.push_back(_property(L"fit-to-size", auto_fit_text));
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
std::wostream & strm = Context.output_stream();
|
||||
|
||||
runState = Context.get_run_state();
|
||||
pState = Context.get_paragraph_state();
|
||||
|
||||
if (!Context.get_drawing_context().in_group() && !pState)
|
||||
{
|
||||
Context.start_paragraph();
|
||||
Context.set_paragraph_keep(true);
|
||||
pState = Context.get_paragraph_state();
|
||||
drawing->additional.push_back(_property(L"text-wrap" , 0));
|
||||
drawing->additional.push_back(_property(L"auto-grow-height", auto_fit_shape));
|
||||
}
|
||||
keepState = Context.get_paragraph_keep();
|
||||
|
||||
Context.set_paragraph_state(false);
|
||||
|
||||
if (!Context.get_drawing_context().in_group())
|
||||
Context.add_new_run(_T(""));
|
||||
|
||||
docx_serialize(strm, drawing, Context.get_drawing_state_content());
|
||||
|
||||
if (!Context.get_drawing_context().in_group())
|
||||
Context.finish_run();
|
||||
|
||||
Context.set_paragraph_state (pState);
|
||||
Context.set_paragraph_keep (keepState);
|
||||
else if (auto_fit_text)
|
||||
drawing->additional.push_back(_property(L"fit-to-size", auto_fit_text));
|
||||
}
|
||||
void draw_g::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
@ -1326,16 +1268,6 @@ void draw_g::docx_convert(oox::docx_conversion_context & Context)
|
||||
Context.add_delayed_element(this);
|
||||
return;
|
||||
}
|
||||
|
||||
//if (Context.get_drawing_state_content())
|
||||
//{
|
||||
// BOOST_FOREACH(const office_element_ptr & elm, content_)
|
||||
// {
|
||||
// ElementType type = elm->get_type();
|
||||
// elm->docx_convert(Context);
|
||||
// }
|
||||
// return;
|
||||
//}
|
||||
|
||||
oox::_docx_drawing drawing = oox::_docx_drawing();
|
||||
|
||||
@ -1355,7 +1287,7 @@ void draw_g::docx_convert(oox::docx_conversion_context & Context)
|
||||
drawing.name = Context.get_drawing_context().get_current_object_name();
|
||||
|
||||
//--------------------------------------------------
|
||||
common_draw_docx_convert(Context, common_draw_attlists_, drawing);
|
||||
common_draw_docx_convert(Context, common_draw_attlists_, &drawing);
|
||||
//--------------------------------------------------
|
||||
oox::StreamsManPtr prev = Context.get_stream_man();
|
||||
|
||||
@ -1425,7 +1357,7 @@ void draw_g::docx_convert(oox::docx_conversion_context & Context)
|
||||
if (!Context.get_drawing_context().in_group())
|
||||
Context.add_new_run(_T(""));
|
||||
|
||||
docx_serialize(strm, drawing, Context.get_drawing_state_content());
|
||||
drawing.serialize(strm/*, Context.get_drawing_state_content()*/);
|
||||
|
||||
if (!Context.get_drawing_context().in_group())
|
||||
Context.finish_run();
|
||||
@ -1441,48 +1373,72 @@ void draw_frame::docx_convert(oox::docx_conversion_context & Context)
|
||||
return;
|
||||
}
|
||||
|
||||
oox_drawing_ = oox_drawing_ptr(new oox::_docx_drawing());
|
||||
|
||||
Context.get_drawing_context().start_frame(this);
|
||||
|
||||
const _CP_OPT(std::wstring) name =
|
||||
common_draw_attlists_.shape_with_text_and_styles_.
|
||||
common_draw_shape_with_styles_attlist_.
|
||||
common_draw_name_attlist_.draw_name_;
|
||||
|
||||
|
||||
BOOST_FOREACH(const office_element_ptr & elm, content_)
|
||||
|
||||
Context.get_drawing_context().add_name_object(name.get_value_or(L"Object"));
|
||||
|
||||
oox::_docx_drawing* drawing = dynamic_cast<oox::_docx_drawing *>(oox_drawing_.get());
|
||||
|
||||
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();
|
||||
|
||||
common_draw_docx_convert(Context, common_draw_attlists_, drawing);
|
||||
|
||||
for (int i = 0 ; i < content_.size(); i++)
|
||||
{
|
||||
ElementType type = elm->get_type();
|
||||
Context.get_drawing_context().add_name_object(name.get_value_or(L"Object"));
|
||||
elm->docx_convert(Context);
|
||||
content_[i]->docx_convert(Context);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
bool runState = Context.get_run_state();
|
||||
bool pState = Context.get_paragraph_state();
|
||||
bool keepState = Context.get_paragraph_keep();
|
||||
|
||||
Context.set_run_state (false);
|
||||
Context.set_paragraph_state (false);
|
||||
|
||||
if (!Context.get_drawing_context().in_group() && !runState)
|
||||
Context.add_new_run(_T(""));
|
||||
|
||||
drawing->serialize(Context.output_stream()/*, Context.get_drawing_state_content()*/);
|
||||
|
||||
if (!Context.get_drawing_context().in_group() && !runState)
|
||||
Context.finish_run();
|
||||
|
||||
Context.set_run_state (runState);
|
||||
Context.set_paragraph_state (pState);
|
||||
Context.set_paragraph_keep (keepState);
|
||||
|
||||
Context.get_drawing_context().stop_frame();
|
||||
}
|
||||
|
||||
void draw_object::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
|
||||
odf_reader::odf_document * odf_reader = Context.root();
|
||||
|
||||
std::wstring folderPath = odf_reader->get_folder();
|
||||
|
||||
std::wstring objectPath = folderPath +FILE_SEPARATOR_STR + href;
|
||||
std::wstring folderPath = Context.root()->get_folder();
|
||||
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
|
||||
|
||||
//normalize path ??? todooo
|
||||
boost::algorithm::replace_all(objectPath, FILE_SEPARATOR_STR + std::wstring(L"./"), FILE_SEPARATOR_STR);
|
||||
|
||||
cpdoccore::odf_reader::odf_document objectSubDoc(objectPath ,NULL);
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//функциональная часть
|
||||
office_element *contentSubDoc = objectSubDoc.get_impl()->get_content();
|
||||
draw_frame *frame = NULL;
|
||||
object_odf_context objectBuild(href);
|
||||
|
||||
//if (!contentSubDoc)//Diagramma.odt - кривые ссылки на объекты
|
||||
// return;
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
draw_frame* frame = NULL;
|
||||
oox::_docx_drawing * drawing = NULL;
|
||||
office_element* contentSubDoc = objectSubDoc.get_impl()->get_content();
|
||||
|
||||
object_odf_context objectBuild (href);
|
||||
if (contentSubDoc)
|
||||
{
|
||||
process_build_object process_build_object_(objectBuild, objectSubDoc.odf_context());
|
||||
@ -1490,83 +1446,50 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
|
||||
|
||||
objectBuild.docx_convert(Context);
|
||||
|
||||
frame = Context.get_drawing_context().get_current_frame();//owner
|
||||
frame = Context.get_drawing_context().get_current_frame(); //owner
|
||||
if (frame)
|
||||
drawing = dynamic_cast<oox::_docx_drawing *>(frame->oox_drawing_.get());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
if (objectBuild.object_type_ == 1 && frame) //диаграмма
|
||||
{
|
||||
oox::_docx_drawing drawing = oox::_docx_drawing();
|
||||
if (!frame || !drawing)
|
||||
{
|
||||
objectBuild.object_type_ = 0;
|
||||
}
|
||||
|
||||
drawing.type = oox::typeChart;
|
||||
|
||||
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();
|
||||
if (objectBuild.object_type_ == 1) //диаграмма
|
||||
{
|
||||
drawing->type = oox::typeChart;
|
||||
|
||||
bool isMediaInternal = true;
|
||||
drawing.chartId = Context.add_mediaitem(href, drawing.type, isMediaInternal, href);
|
||||
|
||||
common_draw_docx_convert(Context, frame->common_draw_attlists_, drawing);
|
||||
|
||||
bool runState = Context.get_run_state();
|
||||
bool pState = Context.get_paragraph_state();
|
||||
|
||||
Context.set_run_state(false);
|
||||
Context.set_paragraph_state(false);
|
||||
|
||||
if (!Context.get_drawing_context().in_group() && !runState)
|
||||
Context.add_new_run(_T(""));
|
||||
|
||||
docx_serialize(Context.output_stream(), drawing, Context.get_drawing_state_content());
|
||||
|
||||
if (!Context.get_drawing_context().in_group() && !runState)
|
||||
Context.finish_run();
|
||||
|
||||
Context.set_run_state (runState);
|
||||
Context.set_paragraph_state (pState);
|
||||
drawing->objectId = Context.add_mediaitem(href, drawing->type, isMediaInternal, href);
|
||||
}
|
||||
else if (objectBuild.object_type_ == 3 && frame) //мат формулы
|
||||
else if (objectBuild.object_type_ == 2 ) //embedded text
|
||||
{
|
||||
oox::_docx_drawing drawing = oox::_docx_drawing();
|
||||
|
||||
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();
|
||||
|
||||
common_draw_docx_convert(Context, frame->common_draw_attlists_, drawing);
|
||||
|
||||
//text in text not support
|
||||
}
|
||||
else if (objectBuild.object_type_ == 3) //мат формулы
|
||||
{
|
||||
const std::wstring & content = Context.get_drawing_context().get_text_stream_frame();
|
||||
|
||||
bool in_frame = !drawing.isInline;
|
||||
bool in_frame = !drawing->isInline;
|
||||
bool runState = Context.get_run_state();
|
||||
bool pState = Context.get_paragraph_state();
|
||||
|
||||
if (drawing.fill.type > 0)
|
||||
if (drawing->fill.type > 0)
|
||||
in_frame = true;
|
||||
|
||||
if (in_frame)
|
||||
{
|
||||
drawing.additional.push_back(_property(L"fit-to-size", true));
|
||||
drawing.additional.push_back(_property(L"text-content", std::wstring(L"<w:p><m:oMathPara><m:oMathParaPr/>") +
|
||||
drawing->type = oox::typeShape;
|
||||
|
||||
drawing->additional.push_back(_property(L"fit-to-size", true));
|
||||
drawing->additional.push_back(_property(L"text-content", std::wstring(L"<w:p><m:oMathPara><m:oMathParaPr/>") +
|
||||
content + std::wstring(L"</m:oMathPara></w:p>")));
|
||||
Context.set_run_state(false);
|
||||
Context.set_paragraph_state(false);
|
||||
|
||||
if (!Context.get_drawing_context().in_group())
|
||||
Context.add_new_run(_T(""));
|
||||
|
||||
docx_serialize(Context.output_stream(), drawing, Context.get_drawing_state_content());
|
||||
|
||||
if (!Context.get_drawing_context().in_group())
|
||||
Context.finish_run();
|
||||
|
||||
Context.set_run_state (runState);
|
||||
Context.set_paragraph_state (pState);
|
||||
}
|
||||
else
|
||||
{//in text
|
||||
drawing->type = oox::typeUnknown; //not drawing
|
||||
|
||||
if (runState) Context.finish_run();
|
||||
//if (pState == false)
|
||||
{
|
||||
@ -1583,10 +1506,26 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
|
||||
}
|
||||
Context.get_drawing_context().clear_stream_frame();
|
||||
}
|
||||
else if (objectBuild.object_type_ == 0)
|
||||
else if (objectBuild.object_type_ == 4) //embedded sheet
|
||||
{
|
||||
bool & use_image_replace = Context.get_drawing_context().get_use_image_replace();
|
||||
use_image_replace = true;
|
||||
|
||||
std::wstring href_new = office_convert(&objectSubDoc, 2);
|
||||
|
||||
if (!href_new.empty())
|
||||
{
|
||||
drawing->type = oox::typeMsObject;
|
||||
bool isMediaInternal = true;
|
||||
|
||||
href += FILE_SEPARATOR_STR + href_new;
|
||||
drawing->objectId = Context.add_mediaitem(href, drawing->type, isMediaInternal, href);
|
||||
drawing->objectProgId = L"Excel.Sheet.12";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//замещающая картинка(если она конечно присутствует)
|
||||
|
||||
bool & use_image_replace = Context.get_drawing_context().get_use_image_replace();
|
||||
use_image_replace = true;
|
||||
}
|
||||
@ -1599,11 +1538,28 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
|
||||
|
||||
void draw_object_ole::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
//временно - замещающая картинка(если она конечно присутствует)
|
||||
|
||||
bool & use_image_replace = Context.get_drawing_context().get_use_image_replace();
|
||||
use_image_replace = true;
|
||||
|
||||
//------------------------------------------------
|
||||
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
std::wstring folderPath = Context.root()->get_folder();
|
||||
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
|
||||
|
||||
if (href.empty()) return;
|
||||
|
||||
draw_frame* frame = Context.get_drawing_context().get_current_frame(); //owner
|
||||
if (!frame) return;
|
||||
|
||||
oox::_docx_drawing * drawing = dynamic_cast<oox::_docx_drawing *>(frame->oox_drawing_.get());
|
||||
if (!drawing) return;
|
||||
|
||||
drawing->type = oox::typeOleObject;
|
||||
|
||||
bool isMediaInternal = true;
|
||||
drawing->objectId = Context.add_mediaitem(href, drawing->type, isMediaInternal, href);
|
||||
|
||||
drawing->objectProgId = detectObject(objectPath);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -55,12 +55,14 @@
|
||||
#include "odf_document_impl.h"
|
||||
|
||||
#include "calcs_styles.h"
|
||||
#include "../docx/oox_drawing.h"
|
||||
#include "../docx/pptx_drawing.h"
|
||||
#include "chart_build_oox.h"
|
||||
|
||||
#include "datatypes/length.h"
|
||||
#include "datatypes/borderstyle.h"
|
||||
|
||||
#include "../../../OfficeUtils/src/OfficeUtils.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
|
||||
using namespace odf_types;
|
||||
@ -86,6 +88,8 @@ void draw_frame::pptx_convert_placeHolder(oox::pptx_conversion_context & Context
|
||||
}
|
||||
void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
Context.get_slide_context().start_frame();
|
||||
|
||||
common_draw_shape_with_styles_attlist common_draw_attlist_ = common_draw_attlists_.shape_with_text_and_styles_.common_draw_shape_with_styles_attlist_;
|
||||
|
||||
const int z_index = common_draw_attlist_.common_draw_z_index_attlist_.draw_z_index_.get_value_or(0);
|
||||
@ -198,147 +202,114 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
|
||||
Context.get_text_context().start_base_style(baseStyleName ,odf_types::style_family::Presentation);
|
||||
////////////////////////////////////////////////
|
||||
int i=0;
|
||||
int size = content_.size();
|
||||
while(true)
|
||||
oox_drawing_ = oox_drawing_ptr(new oox::_pptx_drawing());
|
||||
|
||||
for (int i = 0; i < content_.size(); i++)
|
||||
{
|
||||
if (i>=size)break;
|
||||
office_element_ptr const & elm = content_[i];
|
||||
elm->pptx_convert(Context);
|
||||
i++;
|
||||
content_[i]->pptx_convert(Context);
|
||||
}
|
||||
|
||||
Context.get_text_context().end_base_style();
|
||||
|
||||
Context.get_slide_context().end_frame();
|
||||
}
|
||||
|
||||
void draw_image::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
const std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
|
||||
Context.get_slide_context().start_image(href);
|
||||
Context.get_slide_context().set_image(href);
|
||||
////////////////////////////////////в принципе достаточно общая часть ...
|
||||
Context.get_text_context().start_object();
|
||||
|
||||
int i=0;
|
||||
int size = content_.size();
|
||||
while(true)
|
||||
for (int i = 0; i < content_.size(); i++)
|
||||
{
|
||||
if (i>=size)break;
|
||||
content_[i]->pptx_convert(Context);
|
||||
i++;
|
||||
content_[i]->pptx_convert(Context);
|
||||
}
|
||||
std::wstring text_content_ = Context.get_text_context().end_object();
|
||||
|
||||
if (text_content_.length()>0)
|
||||
{
|
||||
Context.get_slide_context().set_property(_property(L"text-content",text_content_));
|
||||
Context.get_slide_context().set_property(_property(L"text-content", text_content_));
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////3 раза уже повторилась Content -> Context
|
||||
Context.get_slide_context().end_image();
|
||||
}
|
||||
void draw_chart::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
const std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
Context.get_slide_context().start_chart(href);
|
||||
Context.get_slide_context().set_chart(href);
|
||||
|
||||
int i=0;
|
||||
int size = content_.size();
|
||||
while(true)
|
||||
for (int i = 0; i < content_.size(); i++)
|
||||
{
|
||||
if (i>=size)break;
|
||||
content_[i]->pptx_convert(Context);
|
||||
i++;
|
||||
content_[i]->pptx_convert(Context);
|
||||
}
|
||||
Context.get_slide_context().end_chart();
|
||||
}
|
||||
|
||||
void draw_text_box::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
Context.get_slide_context().start_shape(2);//rect с наваротами
|
||||
Context.get_slide_context().set_text_box(); //rect с наваротами
|
||||
Context.get_text_context().start_object();
|
||||
|
||||
int i=0;
|
||||
int size = content_.size();
|
||||
while(true)
|
||||
for (int i = 0; i < content_.size(); i++)
|
||||
{
|
||||
if (i>=size)break;
|
||||
content_[i]->pptx_convert(Context);
|
||||
i++;
|
||||
content_[i]->pptx_convert(Context);
|
||||
}
|
||||
|
||||
std::wstring text_content_ = Context.get_text_context().end_object();
|
||||
|
||||
if (text_content_.length()>0)
|
||||
{
|
||||
Context.get_slide_context().set_property(_property(L"text-content",text_content_));
|
||||
}
|
||||
Context.get_slide_context().end_shape();
|
||||
}
|
||||
void draw_object::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
try {
|
||||
const std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
|
||||
odf_reader::odf_document * odf_reader = Context.root();
|
||||
std::wstring folderPath = odf_reader->get_folder();
|
||||
|
||||
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
|
||||
std::wstring folderPath = Context.root()->get_folder();
|
||||
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
|
||||
|
||||
//normalize path ??? todooo
|
||||
boost::algorithm::replace_all(objectPath, FILE_SEPARATOR_STR + std::wstring(L"./"), FILE_SEPARATOR_STR);
|
||||
|
||||
cpdoccore::odf_reader::odf_document objectSubDoc(objectPath, NULL);
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//в отдельных embd объектах чаще всего диаграммы, уравнения... но МОГУТ быть и обычные объекты подтипа frame!!!
|
||||
//пример RemanejamentoOrcamentario.ods
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//функциональная часть
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
office_element *contentSubDoc = objectSubDoc.get_impl()->get_content();
|
||||
if (!contentSubDoc)
|
||||
{
|
||||
//здесь другой формат xml (не Open Office)
|
||||
//временно - замещающая картинка(если она конечно присутствует)
|
||||
Context.get_slide_context().start_object_ole();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
object_odf_context objectBuild(href);
|
||||
|
||||
process_build_object process_build_object_(objectBuild, objectSubDoc.odf_context());
|
||||
contentSubDoc->accept(process_build_object_);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//отображательная часть
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
if (objectBuild.object_type_ == 1)//диаграмма
|
||||
{
|
||||
const std::wstring href_draw = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
objectBuild.pptx_convert(Context);
|
||||
|
||||
Context.get_slide_context().start_chart(href_draw); // в рисовательной части только место объекта, рамочки ... и релсы
|
||||
Context.get_slide_context().end_chart();
|
||||
Context.get_slide_context().set_chart(href_draw); // в рисовательной части только место объекта, рамочки ... и релсы
|
||||
}
|
||||
else if (objectBuild.object_type_ == 2)//odt текст
|
||||
else if (objectBuild.object_type_ == 2)//odt text
|
||||
{
|
||||
Context.get_slide_context().start_shape(2);
|
||||
Context.get_text_context().start_object();
|
||||
Context.get_slide_context().set_use_image_replacement();
|
||||
|
||||
//сменить контекст с главного на другой ... проблема со стилями!!
|
||||
Context.get_text_context().set_local_styles_container(&objectSubDoc.odf_context().styleContainer());
|
||||
|
||||
objectBuild.pptx_convert(Context);
|
||||
std::wstring href_new = office_convert( &objectSubDoc, 1);
|
||||
|
||||
std::wstring text_content_ = Context.get_text_context().end_object();
|
||||
Context.get_text_context().set_local_styles_container(NULL);//вытираем вручную ...
|
||||
|
||||
if (text_content_.length()>0)
|
||||
if (!href_new.empty())
|
||||
{
|
||||
Context.get_slide_context().set_property(_property(L"text-content",text_content_));
|
||||
bool isMediaInternal = true;
|
||||
href += FILE_SEPARATOR_STR + href_new;
|
||||
Context.get_slide_context().set_ms_object(href, L"Word.Document");
|
||||
}
|
||||
Context.get_slide_context().end_shape();
|
||||
}
|
||||
else if (objectBuild.object_type_ == 3) //мат формулы
|
||||
else if (objectBuild.object_type_ == 3) //math
|
||||
{
|
||||
Context.get_slide_context().start_shape(2);
|
||||
Context.get_slide_context().set_text_box();
|
||||
|
||||
objectBuild.pptx_convert(Context);
|
||||
|
||||
@ -356,11 +327,23 @@ void draw_object::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
Context.get_slide_context().set_property(_property(L"fit-to-size", true));
|
||||
Context.get_slide_context().set_property(_property(L"text-content", text_content));
|
||||
}
|
||||
Context.get_slide_context().end_shape();
|
||||
}
|
||||
else if (objectBuild.object_type_ == 4) //ods sheet
|
||||
{
|
||||
Context.get_slide_context().set_use_image_replacement();
|
||||
|
||||
std::wstring href_new = office_convert( &objectSubDoc, 2);
|
||||
|
||||
if (!href_new.empty())
|
||||
{
|
||||
bool isMediaInternal = true;
|
||||
href += FILE_SEPARATOR_STR + href_new;
|
||||
Context.get_slide_context().set_ms_object(href, L"Excel.Sheet");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//временно - замещающая картинка(если она конечно присутствует)
|
||||
//замещающая картинка(если она конечно присутствует)
|
||||
Context.get_slide_context().set_use_image_replacement();
|
||||
}
|
||||
|
||||
@ -373,14 +356,14 @@ void draw_object::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
|
||||
void draw_object_ole::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
//объект бин в embeddings
|
||||
//Context.get_slide_context().start_object_ole();
|
||||
//распознать тип по guid???
|
||||
|
||||
//временно - замещающая картинка(если она конечно присутствует)
|
||||
Context.get_slide_context().set_use_image_replacement();
|
||||
|
||||
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
std::wstring folderPath = Context.root()->get_folder();
|
||||
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
|
||||
|
||||
//Context.get_slide_context().end_object_ole();
|
||||
if (!href.empty())
|
||||
Context.get_slide_context().set_ole_object(href, detectObject(objectPath));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@
|
||||
#include "odf_document_impl.h"
|
||||
|
||||
#include "calcs_styles.h"
|
||||
#include "../docx/oox_drawing.h"
|
||||
#include "../docx/xlsx_drawing.h"
|
||||
#include "chart_build_oox.h"
|
||||
|
||||
#include "datatypes/length.h"
|
||||
@ -128,6 +128,7 @@ void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Context.get_drawing_context().start_drawing( name);
|
||||
Context.get_drawing_context().start_frame();
|
||||
|
||||
const _CP_OPT(length) svg_widthVal = common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_;
|
||||
const _CP_OPT(length) svg_heightVal = common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_;
|
||||
@ -190,12 +191,16 @@ void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
Compute_GraphicFill(properties.common_draw_fill_attlist_, properties.style_background_image_,
|
||||
Context.root()->odf_context().drawStyles() ,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++)
|
||||
{
|
||||
office_element_ptr const & elm = content_[i];
|
||||
elm->xlsx_convert(Context);
|
||||
}
|
||||
Context.get_drawing_context().end_frame();
|
||||
Context.get_drawing_context().end_drawing();
|
||||
|
||||
Context.get_drawing_context().clear();
|
||||
@ -204,7 +209,8 @@ void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
void draw_image::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
const std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
Context.get_drawing_context().start_image(href);
|
||||
Context.get_drawing_context().set_image(href);
|
||||
|
||||
////////////////////////////////////в принципе достаточно общая часть ...
|
||||
Context.get_text_context().start_drawing_content();//... если в объекте есть текст он привяжется к объекту - иначе к ячейке
|
||||
|
||||
@ -216,25 +222,24 @@ void draw_image::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
|
||||
if (text_content_.length()>0)
|
||||
{
|
||||
Context.get_drawing_context().set_property(_property(L"text-content",text_content_));
|
||||
Context.get_drawing_context().set_property(_property(L"text-content", text_content_));
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////3 раза уже повторилась Content -> Context
|
||||
Context.get_drawing_context().end_image();
|
||||
}
|
||||
|
||||
void draw_chart::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
const std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
Context.get_drawing_context().start_chart(href);
|
||||
Context.get_drawing_context().set_chart(href);
|
||||
|
||||
for (int i = 0 ; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->xlsx_convert(Context);
|
||||
}
|
||||
Context.get_drawing_context().end_chart();
|
||||
}
|
||||
void draw_text_box::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
Context.get_drawing_context().start_shape(2);//rect с наваротами
|
||||
Context.get_drawing_context().set_text_box();
|
||||
|
||||
Context.get_text_context().start_drawing_content();
|
||||
|
||||
for (int i = 0 ; i < content_.size(); i++)
|
||||
@ -248,26 +253,20 @@ void draw_text_box::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
Context.get_drawing_context().set_property(_property(L"text-content",text_content_));
|
||||
}
|
||||
Context.get_drawing_context().end_shape();
|
||||
}
|
||||
void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
try {
|
||||
const std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
|
||||
odf_reader::odf_document * odf_reader = Context.root();
|
||||
|
||||
std::wstring folderPath = odf_reader->get_folder();
|
||||
std::wstring folderPath = Context.root()->get_folder();
|
||||
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
|
||||
|
||||
// normalize path ???? todooo
|
||||
boost::algorithm::replace_all(objectPath, FILE_SEPARATOR_STR + std::wstring(L"./"), FILE_SEPARATOR_STR);
|
||||
|
||||
cpdoccore::odf_reader::odf_document objectSubDoc(objectPath,NULL);
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//в отдельных embd объектах чаще всего диаграммы... но МОГУТ быть и обычные объекты подтипа frame!!! пример RemanejamentoOrcamentario.ods
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//функциональная часть
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
office_element *contentSubDoc = objectSubDoc.get_impl()->get_content();
|
||||
object_odf_context objectBuild(href);
|
||||
|
||||
@ -276,39 +275,30 @@ void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
process_build_object process_build_object_(objectBuild, objectSubDoc.odf_context());
|
||||
contentSubDoc->accept(process_build_object_);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//отображательная часть
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
if (objectBuild.object_type_ == 1) //диаграмма
|
||||
{
|
||||
const std::wstring href_draw = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
objectBuild.xlsx_convert(Context);
|
||||
|
||||
Context.get_drawing_context().start_chart(href_draw); // в рисовательной части только место объекта, рамочки ... и релсы
|
||||
Context.get_drawing_context().end_chart();
|
||||
Context.get_drawing_context().set_chart(href_draw); // в рисовательной части только место объекта, рамочки ... и релсы
|
||||
}
|
||||
else if (objectBuild.object_type_ == 2) //текст (odt text)
|
||||
{
|
||||
Context.get_drawing_context().start_shape(2);
|
||||
Context.get_text_context().start_drawing_content();
|
||||
Context.get_drawing_context().set_use_image_replacement();
|
||||
|
||||
//сменить контекст с главного на другой ... проблема со стилями!!
|
||||
Context.get_text_context().set_local_styles_container(&objectSubDoc.odf_context().styleContainer());
|
||||
|
||||
objectBuild.xlsx_convert(Context);
|
||||
std::wstring href_new = office_convert( &objectSubDoc, 1);
|
||||
|
||||
std::wstring text_content = Context.get_text_context().end_drawing_content();
|
||||
Context.get_text_context().set_local_styles_container(NULL);//вытираем вручную ...
|
||||
|
||||
if (!text_content.empty())
|
||||
if (!href_new.empty())
|
||||
{
|
||||
Context.get_drawing_context().set_property(_property(L"text-content", text_content));
|
||||
bool isMediaInternal = true;
|
||||
href += FILE_SEPARATOR_STR + href_new;
|
||||
Context.get_drawing_context().set_ms_object(href, L"Word.Document");
|
||||
}
|
||||
Context.get_drawing_context().end_shape();
|
||||
}
|
||||
else if (objectBuild.object_type_ == 3) //мат формулы
|
||||
{
|
||||
Context.get_drawing_context().start_shape(2);
|
||||
Context.get_drawing_context().set_text_box();
|
||||
|
||||
objectBuild.xlsx_convert(Context);
|
||||
|
||||
@ -326,11 +316,15 @@ void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
Context.get_drawing_context().set_property(_property(L"fit-to-size", true));
|
||||
Context.get_drawing_context().set_property(_property(L"text-content", text_content));
|
||||
}
|
||||
Context.get_drawing_context().end_shape();
|
||||
}
|
||||
else if (objectBuild.object_type_ == 4) // embedded sheet
|
||||
{
|
||||
Context.get_drawing_context().set_use_image_replacement();
|
||||
//???
|
||||
}
|
||||
else
|
||||
{
|
||||
//временно - замещающая картинка(если она конечно присутствует)
|
||||
//замещающая картинка(если она конечно присутствует)
|
||||
Context.get_drawing_context().set_use_image_replacement();
|
||||
}
|
||||
|
||||
@ -340,15 +334,20 @@ void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
_CP_LOG << "[error] : convert draw::object error" << std::endl;
|
||||
}
|
||||
}
|
||||
void draw_object_ole::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
//временно - замещающая картинка(если она конечно присутствует)
|
||||
//Context.get_drawing_context().start_object_ole();
|
||||
|
||||
void draw_object_ole::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
Context.get_drawing_context().set_use_image_replacement();
|
||||
|
||||
//Context.get_drawing_context().end_object_ole();
|
||||
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
std::wstring folderPath = Context.root()->get_folder();
|
||||
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
|
||||
|
||||
if (!href.empty())
|
||||
Context.get_drawing_context().set_ole_object(href, detectObject(objectPath));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -230,7 +230,11 @@ void draw_path::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
}
|
||||
void draw_path::reset_svg_path()
|
||||
{
|
||||
if (draw_path_attlist_.svg_d_)
|
||||
if (!draw_path_attlist_.svg_d_)
|
||||
{
|
||||
bad_shape_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<svg_path::_polyline> o_Polyline_pt;
|
||||
std::vector<svg_path::_polyline> o_Polyline_cm;
|
||||
@ -286,7 +290,11 @@ void draw_polygon::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
}
|
||||
void draw_polygon::reset_polygon_path()
|
||||
{
|
||||
if (draw_polygon_attlist_.draw_points_)
|
||||
if (!draw_polygon_attlist_.draw_points_)
|
||||
{
|
||||
bad_shape_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<svg_path::_polyline> o_Polyline_pt;
|
||||
std::vector<svg_path::_polyline> o_Polyline_cm;
|
||||
@ -338,7 +346,11 @@ void draw_polyline::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
}
|
||||
void draw_polyline::reset_polyline_path()
|
||||
{
|
||||
if (draw_polyline_attlist_.draw_points_)
|
||||
if (!draw_polyline_attlist_.draw_points_)
|
||||
{
|
||||
bad_shape_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<svg_path::_polyline> o_Polyline_pt;
|
||||
std::vector<svg_path::_polyline> o_Polyline_cm;
|
||||
@ -601,7 +613,11 @@ void draw_connector::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
}
|
||||
void draw_connector::reset_svg_path()
|
||||
{
|
||||
if (draw_connector_attlist_.svg_d_)
|
||||
if (!draw_connector_attlist_.svg_d_)
|
||||
{
|
||||
bad_shape_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<svg_path::_polyline> o_Polyline_pt;
|
||||
std::vector<svg_path::_polyline> o_Polyline_cm;
|
||||
|
||||
@ -292,7 +292,7 @@ void math_mstyle::oox_convert(oox::math_context & Context)
|
||||
{
|
||||
CP_XML_NODE(L"m:ctrlPr")
|
||||
{
|
||||
Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_);
|
||||
Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_, Context.fonts_container_);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -317,7 +317,7 @@ void math_mstyle::oox_convert(oox::math_context & Context)
|
||||
{
|
||||
CP_XML_NODE(L"m:ctrlPr")
|
||||
{
|
||||
Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_);
|
||||
Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_, Context.fonts_container_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,8 +94,10 @@ void math_mtr::oox_convert(oox::math_context & Context)
|
||||
strm << L"<m:mr>";
|
||||
for (int i = 0; i < content_.size(); i++)
|
||||
{
|
||||
strm << L"<m:e>";
|
||||
office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
|
||||
math_element->oox_convert(Context);
|
||||
strm << L"</m:e>";
|
||||
}
|
||||
strm << L"</m:mr>";
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ void math_mi::oox_convert(oox::math_context & Context)
|
||||
}
|
||||
}
|
||||
|
||||
Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_);
|
||||
Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_, Context.fonts_container_);
|
||||
|
||||
CP_XML_NODE(L"m:t")
|
||||
{
|
||||
@ -162,7 +162,7 @@ void math_mo::oox_convert(oox::math_context & Context)
|
||||
{
|
||||
// + доп стили текста ... todoooo
|
||||
|
||||
Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_);
|
||||
Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_, Context.fonts_container_);
|
||||
|
||||
CP_XML_NODE(L"m:t")
|
||||
{
|
||||
@ -203,7 +203,7 @@ void math_mn::oox_convert(oox::math_context & Context)
|
||||
{
|
||||
// + доп стили текста ... todoooo
|
||||
|
||||
Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_);
|
||||
Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_, Context.fonts_container_);
|
||||
|
||||
CP_XML_NODE(L"m:t")
|
||||
{
|
||||
|
||||
@ -128,8 +128,6 @@ void office_body::docx_convert(oox::docx_conversion_context & Context)
|
||||
if (content_)
|
||||
content_->docx_convert(Context);
|
||||
|
||||
Context.get_headers_footers().set_enable_write(true);
|
||||
|
||||
if (!Context.get_section_context().dump_.empty() && !Context.get_table_context().in_table())
|
||||
{
|
||||
Context.output_stream() << Context.get_section_context().dump_;
|
||||
|
||||
@ -102,7 +102,17 @@ enum ElementType
|
||||
typeTextUserIndex,
|
||||
typeTextAlphabeticalIndex,
|
||||
typeTextBibliography,
|
||||
|
||||
|
||||
typeTextBibliographyMark,
|
||||
|
||||
typeTextTableOfContentSource,
|
||||
typeTextIllustrationIndexSource,
|
||||
typeTextTableIndexSource,
|
||||
typeTextObjectIndexSource,
|
||||
typeTextUserIndexSource,
|
||||
typeTextAlphabeticalIndexSource,
|
||||
typeTextBibliographySource,
|
||||
|
||||
typeTextTrackedChanges,
|
||||
typeTextChangedRegion,
|
||||
typeTextChangeStart,
|
||||
|
||||
@ -87,27 +87,6 @@ bool table_format_properties::add_child_element( xml::sax * Reader, const std::w
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
[ ] w:tblStyle Referenced Table Style
|
||||
[ ] w:tblpPr Floating Table Positioning
|
||||
[ ] w:tblOverlap Floating Table Allows Other Tables to Overlap
|
||||
[ ] w:bidiVisual Visually Right to Left Table
|
||||
[ ] w:tblStyleRowBandSize Number of Rows in Row Band
|
||||
[ ] w:tblStyleColBandSize Number of Columns in Column Band
|
||||
[x] w:tblW Preferred Table Width
|
||||
[x] w:jc Table Alignment
|
||||
[ ] w:tblCellSpacing Table Cell Spacing Default
|
||||
[ ] w:tblInd Table Indent from Leading Margin
|
||||
[ ] w:tblBorders Table Borders
|
||||
[ ] w:shd Table Shading
|
||||
[ ] w:tblLayout Table Layout
|
||||
[ ] w:tblCellMar Table Cell Margin Defaults
|
||||
[ ] w:tblLook Table Style Conditional Formatting Settings
|
||||
[ ] w:tblPrChange Revision Information for Table Properties
|
||||
|
||||
*/
|
||||
|
||||
void table_format_properties::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
std::wostream & _tblPr = Context.get_styles_context().table_style();
|
||||
@ -137,7 +116,7 @@ void table_format_properties::docx_convert(oox::docx_conversion_context & Contex
|
||||
if (table_align_)
|
||||
{
|
||||
std::wstring w_val = L"left";
|
||||
if (table_align_->get_type() == table_align::Margins)
|
||||
if (table_align_->get_type() == table_align::Margins || table_align_->get_type() == table_align::Left)
|
||||
{
|
||||
if (common_horizontal_margin_attlist_.fo_margin_left_ && common_horizontal_margin_attlist_.fo_margin_right_)
|
||||
{
|
||||
@ -147,19 +126,16 @@ void table_format_properties::docx_convert(oox::docx_conversion_context & Contex
|
||||
if (w_val != L"center" && common_horizontal_margin_attlist_.fo_margin_left_ )
|
||||
{
|
||||
odf_types::length indent = common_horizontal_margin_attlist_.fo_margin_left_->get_length();
|
||||
_tblPr << L"<w:tblInd w:w=\"" << indent.get_value_unit(odf_types::length::pt) * 20<< "\" w:type=\"dxa\" />";
|
||||
|
||||
_tblPr << L"<w:tblInd w:w=\"" << indent.get_value_unit(odf_types::length::pt) * 20 << "\" w:type=\"dxa\" />";
|
||||
}
|
||||
}
|
||||
else
|
||||
else //if (table_align_->get_type() == table_align::Center)
|
||||
w_val = boost::lexical_cast<std::wstring>(*table_align_);
|
||||
|
||||
_tblPr << L"<w:jc w:val=\"" << w_val << "\" />";
|
||||
}
|
||||
|
||||
if (table_align_ && table_align_->get_type() == table_align::Center)
|
||||
{
|
||||
// TODO ()
|
||||
}
|
||||
_tblPr << "<w:tblLayout w:type=\"fixed\" />";
|
||||
|
||||
if (common_background_color_attlist_.fo_background_color_)
|
||||
|
||||
@ -276,18 +276,20 @@ void text_format_properties_content::pptx_convert_as_list(oox::pptx_conversion_c
|
||||
{
|
||||
std::wstring w_font = (fo_font_family_ ? *fo_font_family_: L"");
|
||||
|
||||
if (w_font.length() < 1)
|
||||
if (w_font.empty())
|
||||
{
|
||||
std::wstring w_ascii = (style_font_name_ ? *style_font_name_: L"");
|
||||
std::wstring w_eastAsia = (style_font_name_asian_ ? *style_font_name_asian_: L"");
|
||||
std::wstring w_cs = (style_font_name_complex_ ? *style_font_name_complex_: L"");
|
||||
std::wstring w_ascii = (style_font_name_ ? *style_font_name_ : L"");
|
||||
std::wstring w_eastAsia = (style_font_name_asian_ ? *style_font_name_asian_ : L"");
|
||||
std::wstring w_cs = (style_font_name_complex_ ? *style_font_name_complex_ : L"");
|
||||
|
||||
fonts_container & fonts = Context.root()->odf_context().fontContainer();
|
||||
|
||||
font_instance * font = fonts.font_by_style_name(w_ascii);
|
||||
if (font == NULL)font = fonts.font_by_style_name(w_eastAsia);
|
||||
if (font == NULL)font = fonts.font_by_style_name(w_cs);
|
||||
if (font)w_font = font->name();
|
||||
font_instance * font = fonts.font_by_style_name(w_ascii);
|
||||
if (font == NULL) font = fonts.font_by_style_name(w_eastAsia);
|
||||
if (font == NULL) font = fonts.font_by_style_name(w_cs);
|
||||
|
||||
if (font)
|
||||
w_font = font->name();
|
||||
|
||||
//'Arial' глючит
|
||||
removeCharsFromString(w_font, _T("'"));
|
||||
@ -436,12 +438,12 @@ void text_format_properties_content::pptx_convert(oox::pptx_conversion_context &
|
||||
if (fo_language_ || style_language_asian_ || style_language_complex_)
|
||||
{
|
||||
std::wstring w_val;
|
||||
if (fo_language_) w_val = *fo_language_;
|
||||
else if (fo_country_) w_val = *fo_country_;
|
||||
else if (style_country_asian_) w_val = *style_country_asian_;
|
||||
else if (style_language_asian_) w_val = *style_language_asian_;
|
||||
else if (style_language_complex_)w_val = *style_language_complex_;
|
||||
else if (style_country_complex_)w_val = *style_country_complex_;
|
||||
if (fo_language_) w_val = *fo_language_;
|
||||
else if (fo_country_) w_val = *fo_country_;
|
||||
else if (style_country_asian_) w_val = *style_country_asian_;
|
||||
else if (style_language_asian_) w_val = *style_language_asian_;
|
||||
else if (style_language_complex_) w_val = *style_language_complex_;
|
||||
else if (style_country_complex_) w_val = *style_country_complex_;
|
||||
|
||||
CP_XML_ATTR(L"lang", w_val);
|
||||
}
|
||||
@ -455,23 +457,45 @@ void text_format_properties_content::pptx_convert(oox::pptx_conversion_context &
|
||||
}
|
||||
if (style_font_name_ || style_font_name_asian_ || style_font_name_complex_ || fo_font_family_)
|
||||
{
|
||||
std::wstring w_font = (fo_font_family_ ? *fo_font_family_: L"");
|
||||
std::wstring w_ascii = (style_font_name_ ? *style_font_name_: w_font);
|
||||
if (w_ascii.length()>0)
|
||||
{
|
||||
CP_XML_NODE(L"a:latin"){CP_XML_ATTR(L"typeface",delete_apostroph_in_name(w_ascii));}
|
||||
}
|
||||
fonts_container & fonts = Context.root()->odf_context().fontContainer();
|
||||
|
||||
if (style_font_name_asian_)
|
||||
{
|
||||
std::wstring w_eastAsia = *style_font_name_asian_;
|
||||
CP_XML_NODE(L"a:ea"){CP_XML_ATTR(L"typeface",delete_apostroph_in_name(w_eastAsia));}
|
||||
}
|
||||
std::wstring w_eastAsia;
|
||||
std::wstring w_hAnsi;
|
||||
std::wstring w_cs;
|
||||
std::wstring w_ascii = w_hAnsi = w_cs = (fo_font_family_ ? *fo_font_family_ : L"");
|
||||
|
||||
if (style_font_name_complex_)
|
||||
{
|
||||
std::wstring w_cs = *style_font_name_complex_;
|
||||
CP_XML_NODE(L"a:cs"){CP_XML_ATTR(L"typeface",delete_apostroph_in_name(w_cs));}
|
||||
font_instance * font = fonts.font_by_style_name(*style_font_name_complex_);
|
||||
if (font)
|
||||
w_cs = font->name();
|
||||
}
|
||||
if (style_font_name_asian_)
|
||||
{
|
||||
font_instance * font = fonts.font_by_style_name(*style_font_name_asian_);
|
||||
if (font)
|
||||
w_eastAsia = font->name();
|
||||
}
|
||||
if (style_font_name_)
|
||||
{
|
||||
font_instance * font = fonts.font_by_style_name(*style_font_name_);
|
||||
if (font)
|
||||
w_ascii = w_hAnsi = font->name();
|
||||
}
|
||||
|
||||
if (!w_ascii.empty())
|
||||
{
|
||||
CP_XML_NODE(L"a:latin"){CP_XML_ATTR(L"typeface", delete_apostroph_in_name(w_ascii));}
|
||||
}
|
||||
|
||||
if (!w_eastAsia.empty())
|
||||
{
|
||||
CP_XML_NODE(L"a:ea"){CP_XML_ATTR(L"typeface", delete_apostroph_in_name(w_eastAsia));}
|
||||
}
|
||||
|
||||
if (!w_cs.empty())
|
||||
{
|
||||
CP_XML_NODE(L"a:cs"){CP_XML_ATTR(L"typeface", delete_apostroph_in_name(w_cs));}
|
||||
}
|
||||
}
|
||||
|
||||
@ -852,22 +876,38 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
|
||||
|
||||
if (style_font_name_ || style_font_name_asian_ || style_font_name_complex_ || fo_font_family_)
|
||||
{
|
||||
fonts_container & fonts = Context.root()->odf_context().fontContainer();
|
||||
|
||||
std::wstring w_eastAsia;
|
||||
std::wstring w_hAnsi;
|
||||
std::wstring w_cs;
|
||||
std::wstring w_ascii = w_hAnsi = w_cs = (style_font_name_ ? *style_font_name_: L"");
|
||||
std::wstring w_ascii = w_hAnsi = w_cs = (fo_font_family_ ? *fo_font_family_ : L"");
|
||||
|
||||
_rPr << L"<w:rFonts ";
|
||||
if (!w_ascii.empty())
|
||||
_rPr << L"w:ascii=\"" << w_ascii <<"\" ";
|
||||
if (!w_hAnsi.empty())
|
||||
_rPr << L"w:hAnsi=\"" << w_hAnsi <<"\" ";
|
||||
if (!w_eastAsia.empty())
|
||||
_rPr << L"w:eastAsia=\"" << w_eastAsia <<"\" ";
|
||||
if (!w_cs.empty())
|
||||
_rPr << L"w:cs=\"" << w_cs <<"\" ";
|
||||
if (style_font_name_complex_)
|
||||
{
|
||||
font_instance * font = fonts.font_by_style_name(*style_font_name_complex_);
|
||||
if (font)
|
||||
w_cs = font->name();
|
||||
}
|
||||
if (style_font_name_asian_)
|
||||
{
|
||||
font_instance * font = fonts.font_by_style_name(*style_font_name_asian_);
|
||||
if (font)
|
||||
w_eastAsia = font->name();
|
||||
}
|
||||
if (style_font_name_)
|
||||
{
|
||||
font_instance * font = fonts.font_by_style_name(*style_font_name_);
|
||||
if (font)
|
||||
w_ascii = w_hAnsi = font->name();
|
||||
}
|
||||
|
||||
_rPr << L" />";
|
||||
_rPr << L"<w:rFonts";
|
||||
if (!w_ascii.empty()) _rPr << L" w:ascii=\"" << w_ascii <<"\"";
|
||||
if (!w_hAnsi.empty()) _rPr << L" w:hAnsi=\"" << w_hAnsi <<"\"";
|
||||
if (!w_eastAsia.empty()) _rPr << L" w:eastAsia=\"" << w_eastAsia <<"\"";
|
||||
if (!w_cs.empty()) _rPr << L" w:cs=\"" << w_cs <<"\"";
|
||||
_rPr << L"/>";
|
||||
}
|
||||
|
||||
_CP_OPT(color) color_text = fo_color_;
|
||||
@ -974,12 +1014,12 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
|
||||
}
|
||||
|
||||
|
||||
void text_format_properties_content::oox_convert (std::wostream & _rPr, bool graphic)
|
||||
void text_format_properties_content::oox_convert (std::wostream & _rPr, bool graphic, fonts_container & fonts)
|
||||
{
|
||||
const int W = process_font_weight (fo_font_weight_);
|
||||
const int fontStyle = process_font_style (fo_font_style_);
|
||||
const int WCs = process_font_weight (style_font_weight_complex_);
|
||||
|
||||
|
||||
if (graphic)
|
||||
{
|
||||
_rPr << L"<a:rPr";
|
||||
@ -1324,19 +1364,33 @@ void text_format_properties_content::oox_convert (std::wostream & _rPr, bool gra
|
||||
std::wstring w_eastAsia;
|
||||
std::wstring w_hAnsi;
|
||||
std::wstring w_cs;
|
||||
std::wstring w_ascii = w_hAnsi = w_cs = (style_font_name_ ? *style_font_name_: L"");
|
||||
std::wstring w_ascii = w_hAnsi = w_cs = (fo_font_family_ ? *fo_font_family_ : L"");
|
||||
|
||||
if (style_font_name_complex_)
|
||||
{
|
||||
font_instance * font = fonts.font_by_style_name(*style_font_name_complex_);
|
||||
if (font)
|
||||
w_cs = font->name();
|
||||
}
|
||||
if (style_font_name_asian_)
|
||||
{
|
||||
font_instance * font = fonts.font_by_style_name(*style_font_name_asian_);
|
||||
if (font)
|
||||
w_eastAsia = font->name();
|
||||
}
|
||||
if (style_font_name_)
|
||||
{
|
||||
font_instance * font = fonts.font_by_style_name(*style_font_name_);
|
||||
if (font)
|
||||
w_ascii = w_hAnsi = font->name();
|
||||
}
|
||||
|
||||
_rPr << L"<w:rFonts ";
|
||||
if (!w_ascii.empty())
|
||||
_rPr << L"w:ascii=\"" << w_ascii <<"\" ";
|
||||
if (!w_hAnsi.empty())
|
||||
_rPr << L"w:hAnsi=\"" << w_hAnsi <<"\" ";
|
||||
if (!w_eastAsia.empty())
|
||||
_rPr << L"w:eastAsia=\"" << w_eastAsia <<"\" ";
|
||||
if (!w_cs.empty())
|
||||
_rPr << L"w:cs=\"" << w_cs <<"\" ";
|
||||
|
||||
_rPr << L" />";
|
||||
_rPr << L"<w:rFonts";
|
||||
if (!w_ascii.empty()) _rPr << L" w:ascii=\"" << w_ascii <<"\"";
|
||||
if (!w_hAnsi.empty()) _rPr << L" w:hAnsi=\"" << w_hAnsi <<"\"";
|
||||
if (!w_eastAsia.empty()) _rPr << L" w:eastAsia=\"" << w_eastAsia <<"\"";
|
||||
if (!w_cs.empty()) _rPr << L" w:cs=\"" << w_cs <<"\"";
|
||||
_rPr << L"/>";
|
||||
}
|
||||
|
||||
_CP_OPT(color) color_text = fo_color_;
|
||||
|
||||
@ -69,6 +69,7 @@ namespace cpdoccore {
|
||||
namespace odf_reader {
|
||||
|
||||
class style_instance;
|
||||
class fonts_container;
|
||||
|
||||
// 15.4
|
||||
class text_format_properties_content : public oox::conversion_element
|
||||
@ -79,7 +80,8 @@ public:
|
||||
void docx_convert (oox::docx_conversion_context & Context);
|
||||
void pptx_convert (oox::pptx_conversion_context & Context);
|
||||
void pptx_convert_as_list (oox::pptx_conversion_context & Context);
|
||||
void oox_convert (std::wostream & stream, bool graphic);
|
||||
|
||||
void oox_convert (std::wostream & stream, bool graphic, fonts_container & fonts);
|
||||
|
||||
void apply_from (const text_format_properties_content & Other);
|
||||
void apply_to (std::vector<_property> & properties);
|
||||
|
||||
@ -1134,14 +1134,14 @@ void style_page_layout_properties_attlist::docx_convert_serialize(std::wostream
|
||||
|
||||
CP_XML_NODE(L"w:pgMar")
|
||||
{
|
||||
CP_XML_ATTR(L"w:header" , process_page_margin(common_vertical_margin_attlist_.fo_margin_top_ ) );
|
||||
CP_XML_ATTR(L"w:footer" , process_page_margin(common_vertical_margin_attlist_.fo_margin_bottom_ ) );
|
||||
CP_XML_ATTR(L"w:gutter" , 0 );
|
||||
|
||||
CP_XML_ATTR(L"w:left" , process_page_margin(common_horizontal_margin_attlist_.fo_margin_left_ , margin_left_length) );
|
||||
CP_XML_ATTR(L"w:right" , process_page_margin(common_horizontal_margin_attlist_.fo_margin_right_, margin_right_length) );
|
||||
CP_XML_ATTR(L"w:top" , process_page_margin(common_vertical_margin_attlist_.fo_margin_top_ , Context.get_header_footer_context().header()) );
|
||||
CP_XML_ATTR(L"w:bottom" , process_page_margin(common_vertical_margin_attlist_.fo_margin_bottom_ , Context.get_header_footer_context().footer()) );
|
||||
|
||||
CP_XML_ATTR(L"w:header" , process_page_margin(common_vertical_margin_attlist_.fo_margin_top_ ) );
|
||||
CP_XML_ATTR(L"w:footer" , process_page_margin(common_vertical_margin_attlist_.fo_margin_bottom_ ) );
|
||||
CP_XML_ATTR(L"w:gutter" , 0 );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1286,19 +1286,17 @@ void style_page_layout_properties::docx_convert_serialize(std::wostream & strm,
|
||||
{
|
||||
Context.process_section( CP_XML_STREAM(), columns);
|
||||
|
||||
bool next_page = Context.is_next_dump_page_properties();
|
||||
|
||||
CP_XML_NODE(L"w:type")
|
||||
{
|
||||
if (Context.is_next_dump_page_properties())
|
||||
{
|
||||
CP_XML_ATTR(L"w:val", L"nextPage");
|
||||
}else
|
||||
{
|
||||
CP_XML_ATTR(L"w:val", L"continuous");
|
||||
}
|
||||
if (next_page) CP_XML_ATTR(L"w:val", L"nextPage");
|
||||
else CP_XML_ATTR(L"w:val", L"continuous");
|
||||
}
|
||||
|
||||
std::wstring masterPageName = Context.get_master_page_name();
|
||||
bool res = Context.get_headers_footers().write_sectPr(masterPageName, strm);
|
||||
bool res = Context.get_headers_footers().write_sectPr(masterPageName, next_page, strm);
|
||||
|
||||
if (res == false)
|
||||
{
|
||||
// default???
|
||||
@ -1308,7 +1306,7 @@ void style_page_layout_properties::docx_convert_serialize(std::wostream & strm,
|
||||
Context.remove_page_properties();
|
||||
Context.add_page_properties(masterPageNameLayout);
|
||||
|
||||
bool res = Context.get_headers_footers().write_sectPr(masterPageName, strm);
|
||||
bool res = Context.get_headers_footers().write_sectPr(masterPageName, next_page, strm);
|
||||
}
|
||||
|
||||
oox::section_context::_section & section = Context.get_section_context().get();
|
||||
|
||||
@ -137,7 +137,14 @@ typedef std::map<std::wstring, oox::text_tracked_context::_state>::iterator map_
|
||||
|
||||
int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_context & Context)
|
||||
{
|
||||
if (!Attr.text_style_name_.empty())
|
||||
bool in_drawing = false;
|
||||
|
||||
if (Context.get_drawing_context().get_current_shape() || Context.get_drawing_context().get_current_frame())
|
||||
{
|
||||
in_drawing = true;
|
||||
}
|
||||
|
||||
if (!Attr.text_style_name_.empty())
|
||||
{
|
||||
if (style_instance * styleInst =
|
||||
Context.root()->odf_context().styleContainer().style_by_name(Attr.text_style_name_.style_name(), style_family::Paragraph, Context.process_headers_footers_)
|
||||
@ -180,7 +187,7 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co
|
||||
Context.end_automatic_style();
|
||||
|
||||
Context.push_text_properties(styleContent->get_style_text_properties());
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -188,9 +195,10 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co
|
||||
const std::wstring id = Context.styles_map_.get( styleInst->name(), styleInst->type() );
|
||||
Context.output_stream() << L"<w:pPr>";
|
||||
//todooo причесать
|
||||
if (!Context.get_section_context().dump_.empty() &&
|
||||
!Context.get_table_context().in_table() &&
|
||||
(Context.get_process_note() == oox::docx_conversion_context::noNote))
|
||||
if (!Context.get_section_context().dump_.empty()
|
||||
&& !Context.get_table_context().in_table()
|
||||
&& (Context.get_process_note() == oox::docx_conversion_context::noNote)
|
||||
&& !in_drawing)
|
||||
{
|
||||
if (Context.is_paragraph_header() )
|
||||
{
|
||||
@ -236,9 +244,10 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!Context.get_section_context().dump_.empty() &&
|
||||
!Context.get_table_context().in_table() &&
|
||||
(Context.get_process_note() == oox::docx_conversion_context::noNote))
|
||||
if (!Context.get_section_context().dump_.empty()
|
||||
&& !Context.get_table_context().in_table()
|
||||
&& (Context.get_process_note() == oox::docx_conversion_context::noNote)
|
||||
&& !in_drawing)
|
||||
{
|
||||
Context.output_stream() << L"<w:pPr>";
|
||||
Context.output_stream() << Context.get_section_context().dump_;
|
||||
@ -361,18 +370,18 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
const std::wstring & styleName = attrs_.text_style_name_.style_name();
|
||||
|
||||
bool drawing = false;
|
||||
bool in_drawing = false;
|
||||
|
||||
if (Context.get_drawing_context().get_current_shape() || Context.get_drawing_context().get_current_frame())
|
||||
{
|
||||
drawing = true;
|
||||
in_drawing = true;
|
||||
}
|
||||
|
||||
bool bIsNewParagraph = true;
|
||||
|
||||
bool is_empty = content_.empty();
|
||||
|
||||
if (Context.get_paragraph_state() && (Context.get_process_note() == oox::docx_conversion_context::noNote) && !drawing)
|
||||
if (Context.get_paragraph_state() && (Context.get_process_note() == oox::docx_conversion_context::noNote) && !in_drawing)
|
||||
{//вложеннные элементы ... или после графики embedded_linux_kernel_and_drivers_labs_zh_TW.odt
|
||||
bIsNewParagraph = false;
|
||||
|
||||
@ -425,8 +434,6 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
|
||||
Context.remove_page_properties();
|
||||
Context.add_page_properties(masterPageNameLayout);
|
||||
|
||||
Context.set_page_break(true);
|
||||
|
||||
is_empty = false;
|
||||
}
|
||||
|
||||
@ -453,7 +460,8 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
|
||||
if (Context.get_page_break())
|
||||
{
|
||||
if (Context.process_headers_footers_ == false)
|
||||
_Wostream << L"<w:lastRenderedPageBreak/>";
|
||||
//_Wostream << L"<w:lastRenderedPageBreak/>";
|
||||
_Wostream << L"<w:br w:type=\"page\"/>";
|
||||
Context.set_page_break(false);
|
||||
}
|
||||
elm->docx_convert(Context);
|
||||
@ -482,7 +490,7 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
|
||||
|
||||
is_empty = false;
|
||||
Context.add_new_run(_T(""));
|
||||
_Wostream << L"<w:br w:type=\"page\" />";
|
||||
_Wostream << L"<w:br w:type=\"page\"/>";
|
||||
Context.finish_run();
|
||||
}
|
||||
|
||||
@ -967,9 +975,39 @@ void text_table_index::add_child_element( xml::sax * Reader, const std::wstring
|
||||
const wchar_t * text_illustration_index::ns = L"text";
|
||||
const wchar_t * text_illustration_index::name = L"illustration-index";
|
||||
|
||||
void text_illustration_index::afterCreate()
|
||||
{
|
||||
if (document_context * context = getContext())
|
||||
{
|
||||
if (paragraph * lastPar = context->get_last_paragraph())
|
||||
{
|
||||
lastPar->set_next_section(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void text_illustration_index::afterReadContent()
|
||||
{
|
||||
if (document_context * context = getContext())
|
||||
{
|
||||
if (paragraph * lastPar = context->get_last_paragraph())
|
||||
{
|
||||
lastPar->set_next_end_section(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
void text_illustration_index::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
if (text_index_body_)
|
||||
std::wstring current_page_properties = Context.get_page_properties();
|
||||
|
||||
Context.get_section_context().add_section(
|
||||
text_section_attr_.text_name_,
|
||||
text_section_attr_.text_style_name_.get_value_or(style_ref()).style_name(),
|
||||
current_page_properties
|
||||
);
|
||||
Context.add_page_properties(current_page_properties);
|
||||
|
||||
if (text_index_body_)
|
||||
text_index_body_->docx_convert(Context);
|
||||
}
|
||||
|
||||
@ -997,8 +1035,192 @@ void text_illustration_index::add_child_element( xml::sax * Reader, const std::w
|
||||
{
|
||||
CP_CREATE_ELEMENT(text_index_body_);
|
||||
}
|
||||
// TODO text-illustration-index-source
|
||||
// todooo text-illustration-index-source
|
||||
}
|
||||
|
||||
// text:alphabetical-index
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const wchar_t * text_alphabetical_index::ns = L"text";
|
||||
const wchar_t * text_alphabetical_index::name = L"alphabetical-index";
|
||||
|
||||
void text_alphabetical_index::afterCreate()
|
||||
{
|
||||
if (document_context * context = getContext())
|
||||
{
|
||||
if (paragraph * lastPar = context->get_last_paragraph())
|
||||
{
|
||||
lastPar->set_next_section(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void text_alphabetical_index::afterReadContent()
|
||||
{
|
||||
if (document_context * context = getContext())
|
||||
{
|
||||
if (paragraph * lastPar = context->get_last_paragraph())
|
||||
{
|
||||
lastPar->set_next_end_section(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
void text_alphabetical_index::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
std::wstring current_page_properties = Context.get_page_properties();
|
||||
|
||||
Context.get_section_context().add_section(
|
||||
text_section_attr_.text_name_,
|
||||
text_section_attr_.text_style_name_.get_value_or(style_ref()).style_name(),
|
||||
current_page_properties
|
||||
);
|
||||
Context.add_page_properties(current_page_properties);
|
||||
|
||||
if (text_index_body_)
|
||||
text_index_body_->docx_convert(Context);
|
||||
}
|
||||
|
||||
void text_alphabetical_index::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
if (text_index_body_)
|
||||
text_index_body_->pptx_convert(Context);
|
||||
}
|
||||
|
||||
|
||||
std::wostream & text_alphabetical_index::text_to_stream(std::wostream & _Wostream) const
|
||||
{
|
||||
CP_SERIALIZE_TEXT(text_index_body_);
|
||||
return _Wostream;
|
||||
}
|
||||
|
||||
void text_alphabetical_index::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
text_section_attr_.add_attributes( Attributes );
|
||||
}
|
||||
|
||||
void text_alphabetical_index::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if CP_CHECK_NAME(L"text", L"index-body")
|
||||
{
|
||||
CP_CREATE_ELEMENT(text_index_body_);
|
||||
}
|
||||
// todooo text-alphabetical-index-source
|
||||
}
|
||||
// text:bibliography
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const wchar_t * text_bibliography::ns = L"text";
|
||||
const wchar_t * text_bibliography::name = L"bibliography";
|
||||
|
||||
void text_bibliography::afterCreate()
|
||||
{
|
||||
if (document_context * context = getContext())
|
||||
{
|
||||
if (paragraph * lastPar = context->get_last_paragraph())
|
||||
{
|
||||
lastPar->set_next_section(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void text_bibliography::afterReadContent()
|
||||
{
|
||||
if (document_context * context = getContext())
|
||||
{
|
||||
if (paragraph * lastPar = context->get_last_paragraph())
|
||||
{
|
||||
lastPar->set_next_end_section(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
void text_bibliography::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
std::wstring current_page_properties = Context.get_page_properties();
|
||||
|
||||
Context.get_section_context().add_section(
|
||||
text_section_attr_.text_name_,
|
||||
text_section_attr_.text_style_name_.get_value_or(style_ref()).style_name(),
|
||||
current_page_properties
|
||||
);
|
||||
Context.add_page_properties(current_page_properties);
|
||||
|
||||
if (text_index_body_)
|
||||
text_index_body_->docx_convert(Context);
|
||||
}
|
||||
|
||||
void text_bibliography::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
if (text_index_body_)
|
||||
text_index_body_->pptx_convert(Context);
|
||||
}
|
||||
|
||||
|
||||
std::wostream & text_bibliography::text_to_stream(std::wostream & _Wostream) const
|
||||
{
|
||||
CP_SERIALIZE_TEXT(text_index_body_);
|
||||
return _Wostream;
|
||||
}
|
||||
|
||||
void text_bibliography::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
text_section_attr_.add_attributes( Attributes );
|
||||
}
|
||||
|
||||
void text_bibliography::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if CP_CHECK_NAME(L"text", L"index-body")
|
||||
{
|
||||
CP_CREATE_ELEMENT(text_index_body_);
|
||||
}
|
||||
// todooo text-bibliography-source
|
||||
}
|
||||
// text:bibliography
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const wchar_t * text_bibliography_mark::ns = L"text";
|
||||
const wchar_t * text_bibliography_mark::name = L"bibliography-mark";
|
||||
|
||||
void text_bibliography_attr::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"text:identifier", text_identifier_, std::wstring(L""));
|
||||
CP_APPLY_ATTR(L"text:bibliography-type", text_bibliography_type_, std::wstring(L""));
|
||||
CP_APPLY_ATTR(L"text:author", text_author_);
|
||||
CP_APPLY_ATTR(L"text:url", text_url_);
|
||||
CP_APPLY_ATTR(L"text:title", text_title_);
|
||||
CP_APPLY_ATTR(L"text:year", text_year_);
|
||||
///
|
||||
}
|
||||
|
||||
void text_bibliography_mark::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
text_bibliography_attr_.add_attributes( Attributes );
|
||||
}
|
||||
|
||||
void text_bibliography_mark::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
}
|
||||
|
||||
void text_bibliography_mark::add_text(const std::wstring & Text)
|
||||
{
|
||||
office_element_ptr elm = text::create(Text) ;
|
||||
content_ = elm;
|
||||
}
|
||||
|
||||
std::wostream & text_bibliography_mark::text_to_stream(std::wostream & _Wostream) const
|
||||
{
|
||||
CP_SERIALIZE_TEXT(content_);
|
||||
return _Wostream;
|
||||
}
|
||||
|
||||
void text_bibliography_mark::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
if (content_)
|
||||
content_->docx_convert(Context);
|
||||
}
|
||||
|
||||
void text_bibliography_mark::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
if (content_)
|
||||
content_->pptx_convert(Context);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
// text:tracked-changes
|
||||
const wchar_t * text_tracked_changes::ns = L"text";
|
||||
|
||||
@ -234,7 +234,6 @@ public:
|
||||
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
class text_section : public text_content_impl<text_section>
|
||||
{
|
||||
public:
|
||||
@ -360,6 +359,9 @@ public:
|
||||
static const ElementType type = typeTextIllustrationIndex;
|
||||
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void afterCreate();
|
||||
virtual void afterReadContent();
|
||||
|
||||
void docx_convert(oox::docx_conversion_context & Context);
|
||||
void pptx_convert(oox::pptx_conversion_context & Context) ;
|
||||
@ -377,7 +379,114 @@ public:
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(text_illustration_index);
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
class text_alphabetical_index : public text_content_impl<text_alphabetical_index>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeTextAlphabeticalIndex;
|
||||
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void afterCreate();
|
||||
virtual void afterReadContent();
|
||||
|
||||
void docx_convert(oox::docx_conversion_context & Context);
|
||||
void pptx_convert(oox::pptx_conversion_context & Context) ;
|
||||
|
||||
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:
|
||||
text_section_attr text_section_attr_;
|
||||
office_element_ptr text_alphabetical_index_source_;
|
||||
office_element_ptr text_index_body_;
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(text_alphabetical_index);
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
class text_bibliography : public text_content_impl<text_bibliography>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeTextBibliography;
|
||||
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void afterCreate();
|
||||
virtual void afterReadContent();
|
||||
|
||||
void docx_convert(oox::docx_conversion_context & Context);
|
||||
void pptx_convert(oox::pptx_conversion_context & Context) ;
|
||||
|
||||
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:
|
||||
text_section_attr text_section_attr_;
|
||||
office_element_ptr text_bibliography_source_;
|
||||
office_element_ptr text_index_body_;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(text_bibliography);
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
//typeTextTableIndex,
|
||||
//typeTextObjectIndex,
|
||||
//typeTextUserIndex,
|
||||
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
//text:bibliography-mark
|
||||
|
||||
class text_bibliography_attr
|
||||
{
|
||||
public:
|
||||
void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
std::wstring text_identifier_;
|
||||
std::wstring text_bibliography_type_; // todoooo in datatype
|
||||
|
||||
_CP_OPT(std::wstring) text_url_;
|
||||
_CP_OPT(std::wstring) text_author_;
|
||||
_CP_OPT(std::wstring) text_title_;
|
||||
_CP_OPT(std::wstring) text_year_;
|
||||
_CP_OPT(std::wstring) text_isbn_;
|
||||
_CP_OPT(std::wstring) text_chapter_;
|
||||
//todooo to map or list
|
||||
};
|
||||
|
||||
class text_bibliography_mark : public text_content_impl<text_bibliography_mark>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeTextBibliographyMark;
|
||||
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
void docx_convert(oox::docx_conversion_context & Context);
|
||||
void pptx_convert(oox::pptx_conversion_context & Context) ;
|
||||
|
||||
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
|
||||
|
||||
text_bibliography_attr text_bibliography_attr_;
|
||||
office_element_ptr content_;
|
||||
|
||||
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);
|
||||
virtual void add_text (const std::wstring & Text);
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(text_bibliography_mark);
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
class text_index_body : public text_content_impl<text_index_body>
|
||||
{
|
||||
@ -393,13 +502,11 @@ public:
|
||||
|
||||
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
|
||||
|
||||
office_element_ptr_array index_content_main_;
|
||||
|
||||
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:
|
||||
office_element_ptr_array index_content_main_;
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(text_index_body);
|
||||
|
||||
@ -428,6 +535,9 @@ public:
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(text_index_title);
|
||||
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
class text_unknown_base_change : public office_element_impl<text_unknown_base_change>
|
||||
{
|
||||
|
||||
@ -922,14 +922,6 @@
|
||||
RelativePath="..\src\docx\mediaitems.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\docx\mediaitems_utils.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\docx\mediaitems_utils.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\docx\oox_conversion_context.cpp"
|
||||
>
|
||||
|
||||
@ -116,7 +116,7 @@ namespace OOX
|
||||
}
|
||||
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
|
||||
{
|
||||
if(m_oName.IsInit())
|
||||
if(m_oName.IsInit() && m_arrItems.size() > 0)
|
||||
{
|
||||
writer.WriteString(_T("<tableStyle"));
|
||||
WritingStringNullableAttrEncodeXmlString(L"name", m_oName, m_oName.get());
|
||||
@ -249,4 +249,4 @@ namespace OOX
|
||||
} //Spreadsheet
|
||||
} // namespace OOX
|
||||
|
||||
#endif // OOX_TABLESTYLES_FILE_INCLUDE_H_
|
||||
#endif // OOX_TABLESTYLES_FILE_INCLUDE_H_
|
||||
@ -59,6 +59,7 @@ public:
|
||||
|
||||
std::wstring GetFormatExtension(const std::wstring & fileName);
|
||||
std::wstring GetExtensionByType(int type);
|
||||
static int GetFormatByExtension(const std::wstring& ext);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@ -574,6 +574,59 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
return L"";
|
||||
}
|
||||
|
||||
int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring& ext)
|
||||
{
|
||||
if (L".docx" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX;
|
||||
if (L".doc" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC;
|
||||
if (L".odt" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT;
|
||||
if (L".rtf" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_RTF;
|
||||
if (L".txt" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT;
|
||||
if (L".html" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML;
|
||||
if (L".mht" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_MHT;
|
||||
if (L".epub" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_EPUB;
|
||||
if (L".fb2" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_FB2;
|
||||
if (L".mobi" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_MOBI;
|
||||
|
||||
|
||||
if (L".pptx" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX;
|
||||
if (L".ppt" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_PRESENTATION_PPT;
|
||||
if (L".odp" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP;
|
||||
if (L".ppsx" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSX;
|
||||
|
||||
if (L".xlsx" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX;
|
||||
if (L".xls" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS;
|
||||
if (L".ods" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS;
|
||||
if (L".csv" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV;
|
||||
|
||||
|
||||
if (L".pdf" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF;
|
||||
if (L".djvu" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_DJVU;
|
||||
if (L".xps" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_XPS;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::wstring COfficeFileFormatChecker::GetFormatExtension(const std::wstring & fileName)
|
||||
{
|
||||
if (isOfficeFile(fileName))
|
||||
|
||||
@ -751,4 +751,7 @@
|
||||
#define ASC_COAUTH_EVENT_TYPE_LOST_CONNECTION 20102
|
||||
#define ASC_COAUTH_EVENT_TYPE_DROP_CONNECTION 20103
|
||||
|
||||
#define ASC_COAUTH_EVENT_TYPE_INSERT_URL_IMAGE 21000
|
||||
#define ASC_COAUTH_EVENT_TYPE_LOAD_URL_IMAGE 21001
|
||||
|
||||
#endif //_BUILD_EDITOR_DEFINES_CROSSPLATFORM_H_
|
||||
|
||||
@ -42,4 +42,5 @@
|
||||
@interface NSFileManager (Utils)
|
||||
- (BOOL)copyFolderAtPath:(NSString *)sourceFolder toDestinationFolderAtPath:(NSString*)destinationFolder;
|
||||
- (NSString*)createTemporaryDirectory;
|
||||
- (void)createDirectory:(NSString*)directory;
|
||||
@end
|
||||
|
||||
@ -68,7 +68,7 @@
|
||||
NSError *error = nil;
|
||||
NSString* path = [NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), [NSUUID UUID].UUIDString];
|
||||
|
||||
if(![[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error])
|
||||
if(![self createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error])
|
||||
{
|
||||
NSLog(@"Could not creat temp path %@. error %@", path, error);
|
||||
return @"";
|
||||
@ -77,4 +77,11 @@
|
||||
return path;
|
||||
}
|
||||
|
||||
- (void)createDirectory:(NSString*)directory {
|
||||
NSError *error = nil;
|
||||
if(![self createDirectoryAtPath:directory withIntermediateDirectories:YES attributes:nil error:&error]) {
|
||||
NSLog(@"Failed to create directory \"%@\". Error: %@", directory, error);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
//#define ONLINE_WORD_TO_PDF
|
||||
//#define TO_PDF
|
||||
#define TO_HTML_RENDERER
|
||||
//#define ONLY_TEXT
|
||||
#define ONLY_TEXT
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@ -97,7 +97,7 @@ int main(int argc, char *argv[])
|
||||
//std::wstring sFile = L"D:\\bankomats.xps";
|
||||
//std::wstring sFile = L"\\\\kirillov8\\_Office\\DJVU\\Основы разработки приложений на платформе Microsoft .NET Framework. Учебный курс Microsoft экзамен 70-536.djvu";
|
||||
//std::wstring sFile = L"D:\\TESTFILES\\Алгоритмы - построение и анализ.djvu";
|
||||
std::wstring sFile = L"D:\\knopk5_0.pdf";
|
||||
std::wstring sFile = L"D:\\TESTFILES\\PDF 1-7 (756p).pdf";
|
||||
std::wstring sDst = L"D:\\test\\Document";
|
||||
|
||||
//std::wstring sFile = L"/home/oleg/activex/Android intro(2p).pdf";
|
||||
@ -170,7 +170,5 @@ int main(int argc, char *argv[])
|
||||
oRenderer.SaveToFile(L"/home/oleg/activex/1/1.pdf");
|
||||
#endif
|
||||
|
||||
RELEASEOBJECT(pReader);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
7
Makefile
7
Makefile
@ -20,13 +20,6 @@ else
|
||||
LIB_EXT := .a
|
||||
MAKE := make -j $(shell grep -c ^processor /proc/cpuinfo)
|
||||
endif
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
PLATFORM := mac
|
||||
SHARED_EXT := .dylib*
|
||||
SHELL_EXT := .sh
|
||||
LIB_EXT := .a
|
||||
MAKE := make -j $(shell sysctl -n hw.ncpu)
|
||||
endif
|
||||
UNAME_P := $(shell uname -p)
|
||||
ifeq ($(UNAME_P),x86_64)
|
||||
ARCHITECTURE := 64
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
|
||||
[](http://www.gnu.org/licenses/agpl-3.0.ru.html)   
|
||||
[](http://www.gnu.org/licenses/agpl-3.0.ru.html)  
|
||||
|
||||
## Core
|
||||
Server core components which are a part of [ONLYOFFICE Document Server][2]. Enable the conversion between the most popular office document formats: DOC, DOCX, ODT, RTF, TXT, PDF, HTML, EPUB, XPS, DjVu, XLS, XLSX, ODS, CSV, PPT, PPTX, ODP.
|
||||
|
||||
@ -2738,7 +2738,14 @@ namespace NExtractTools
|
||||
|
||||
//clean up v8
|
||||
NSDoctRenderer::CDocBuilder::Dispose();
|
||||
return result;
|
||||
if (SUCCEEDED_X2T(result) && oInputParams.m_bOutputConvertCorrupted)
|
||||
{
|
||||
return AVS_FILEUTILS_ERROR_CONVERT_CORRUPTED;
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
int FromFile(const std::wstring& file)
|
||||
|
||||
@ -298,7 +298,6 @@ namespace NExtractTools
|
||||
}
|
||||
int apply_changes(const std::wstring &sBinFrom, const std::wstring &sToResult, NSDoctRenderer::DoctRendererFormat::FormatFile eType, const std::wstring &sThemeDir, std::wstring &sBinTo, const InputParams& params)
|
||||
{
|
||||
int nRes = 0;
|
||||
std::wstring sBinDir = FileSystem::Directory::GetFolderPath(sBinFrom);
|
||||
std::wstring sChangesDir = sBinDir + FILE_SEPARATOR_STR + _T("changes");
|
||||
if (NSDirectory::Exists(sChangesDir))
|
||||
@ -317,7 +316,7 @@ namespace NExtractTools
|
||||
if (!sResult.empty() && -1 != sResult.find(_T("error")))
|
||||
{
|
||||
std::wcerr << _T("DoctRenderer:") << sResult << std::endl;
|
||||
nRes = AVS_FILEUTILS_ERROR_CONVERT_CORRUPTED;
|
||||
params.m_bOutputConvertCorrupted = true;
|
||||
int nErrorIndex = -1;
|
||||
int nErrorIndexStart = sResult.find(_T("index"));
|
||||
if (-1 != nErrorIndexStart)
|
||||
@ -364,6 +363,6 @@ namespace NExtractTools
|
||||
}
|
||||
else
|
||||
sBinTo = sBinFrom;
|
||||
return nRes;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#define SUCCEEDED_X2T(nRes) (0 == (nRes) || AVS_FILEUTILS_ERROR_CONVERT_CORRUPTED == (nRes))
|
||||
#define SUCCEEDED_X2T(nRes) (0 == (nRes))
|
||||
|
||||
namespace NExtractTools
|
||||
{
|
||||
@ -337,6 +337,8 @@ namespace NExtractTools
|
||||
int* m_nDoctParams;
|
||||
std::wstring* m_sHtmlFileInternalPath;
|
||||
std::wstring* m_sPassword;
|
||||
//output params
|
||||
mutable bool m_bOutputConvertCorrupted;
|
||||
public:
|
||||
InputParams()
|
||||
{
|
||||
@ -358,6 +360,8 @@ namespace NExtractTools
|
||||
m_nDoctParams = NULL;
|
||||
m_sHtmlFileInternalPath = NULL;
|
||||
m_sPassword = NULL;
|
||||
|
||||
m_bOutputConvertCorrupted = false;
|
||||
}
|
||||
~InputParams()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user