Commit d3f4a212 authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormat, PptxFormat - presentation transitions

parent 4d5f328c
...@@ -184,104 +184,100 @@ namespace DocFileFormat ...@@ -184,104 +184,100 @@ namespace DocFileFormat
std::vector<PathSegment>::const_iterator end = m_arSegments.end(); std::vector<PathSegment>::const_iterator end = m_arSegments.end();
for (std::vector<PathSegment>::const_iterator iter = m_arSegments.begin(); iter != end; ++iter, cc++) for (std::vector<PathSegment>::const_iterator iter = m_arSegments.begin(); iter != end; ++iter, cc++)
{ {
try switch (iter->Type)
{ {
switch (iter->Type) case PathSegment::msopathLineTo:
{ {
case PathSegment::msopathLineTo: for (int i = 0; i < iter->Count; ++i)
{ {
for (int i = 0; i < iter->Count; ++i) if (valuePointer + 1 > (int)m_arPoints.size())
{ {
if (valuePointer >= (int)m_arPoints.size()) break;
{
break;
strVmlPath += L"l"; strVmlPath += L"l";
strVmlPath += FormatUtils::IntToWideString(m_arPoints[0].x); strVmlPath += FormatUtils::IntToWideString(m_arPoints[0].x);
strVmlPath += L","; strVmlPath += L",";
strVmlPath += FormatUtils::IntToWideString(m_arPoints[0].y); strVmlPath += FormatUtils::IntToWideString(m_arPoints[0].y);
++valuePointer; ++valuePointer;
//break; //break;
}
else
{
strVmlPath += L"l";
strVmlPath += FormatUtils::IntToWideString(m_arPoints[valuePointer].x );
strVmlPath += L",";
strVmlPath += FormatUtils::IntToWideString(m_arPoints[valuePointer].y );
++valuePointer;
}
} }
} else
break;
case PathSegment::msopathCurveTo:
{
for (int i = 0; i < iter->Count; ++i)
{ {
strVmlPath += L"c"; strVmlPath += L"l";
strVmlPath += FormatUtils::IntToWideString(m_arPoints[valuePointer].x ); strVmlPath += FormatUtils::IntToWideString(m_arPoints[valuePointer].x );
strVmlPath += L","; strVmlPath += L",";
strVmlPath += FormatUtils::IntToWideString(m_arPoints[valuePointer].y ); strVmlPath += FormatUtils::IntToWideString(m_arPoints[valuePointer].y );
strVmlPath += L",";
strVmlPath += FormatUtils::IntToWideString(m_arPoints[valuePointer + 1].x ); ++valuePointer;
strVmlPath += L",";
strVmlPath += FormatUtils::IntToWideString(m_arPoints[valuePointer + 1].y );
strVmlPath += L",";
strVmlPath += FormatUtils::IntToWideString(m_arPoints[valuePointer + 2].x );
strVmlPath += L",";
strVmlPath += FormatUtils::IntToWideString(m_arPoints[valuePointer + 2].y );
valuePointer += 3;
} }
} }
break; }
break;
case PathSegment::msopathMoveTo: case PathSegment::msopathCurveTo:
{
for (int i = 0; i < iter->Count; ++i)
{ {
strVmlPath += L"m"; if (valuePointer + 3 > (int)m_arPoints.size())
break;
strVmlPath += L"c";
strVmlPath += FormatUtils::IntToWideString(m_arPoints[valuePointer].x ); strVmlPath += FormatUtils::IntToWideString(m_arPoints[valuePointer].x );
strVmlPath += L","; strVmlPath += L",";
strVmlPath += FormatUtils::IntToWideString(m_arPoints[valuePointer].y ); strVmlPath += FormatUtils::IntToWideString(m_arPoints[valuePointer].y );
strVmlPath += L",";
++valuePointer; strVmlPath += FormatUtils::IntToWideString(m_arPoints[valuePointer + 1].x );
strVmlPath += L",";
strVmlPath += FormatUtils::IntToWideString(m_arPoints[valuePointer + 1].y );
strVmlPath += L",";
strVmlPath += FormatUtils::IntToWideString(m_arPoints[valuePointer + 2].x );
strVmlPath += L",";
strVmlPath += FormatUtils::IntToWideString(m_arPoints[valuePointer + 2].y );
valuePointer += 3;
} }
break; }
break;
case PathSegment::msopathClose: case PathSegment::msopathMoveTo:
{
if (valuePointer < (int)m_arPoints.size())
{ {
strVmlPath += L"x"; strVmlPath += L"m";
strVmlPath += FormatUtils::IntToWideString(m_arPoints[valuePointer].x );
strVmlPath += L",";
strVmlPath += FormatUtils::IntToWideString(m_arPoints[valuePointer].y );
++valuePointer;
} }
break; }
break;
case PathSegment::msopathEnd: case PathSegment::msopathClose:
{ {
strVmlPath += L"e"; strVmlPath += L"x";
} }
break; break;
case PathSegment::msopathEscape: case PathSegment::msopathEnd:
{ {
if (PathSegment::msopathEscapeNoFill == iter->EscapeCode) strVmlPath += L"e";
strVmlPath += L"nf"; }
break;
if (PathSegment::msopathEscapeNoLine == iter->EscapeCode)
strVmlPath += L"ns"; case PathSegment::msopathEscape:
} {
case PathSegment::msopathClientEscape: if (PathSegment::msopathEscapeNoFill == iter->EscapeCode)
case PathSegment::msopathInvalid: strVmlPath += L"nf";
{
//ignore escape segments and invalid segments if (PathSegment::msopathEscapeNoLine == iter->EscapeCode)
} strVmlPath += L"ns";
break; }
case PathSegment::msopathClientEscape:
case PathSegment::msopathInvalid:
{
//ignore escape segments and invalid segments
} }
}
catch (...)
{
// Sometimes there are more Segments than available m_arPoints.
// Accordingly to the spec this should never happen :)
break; break;
} }
} }
......
...@@ -33,9 +33,6 @@ ...@@ -33,9 +33,6 @@
#include "mediaitems.h" #include "mediaitems.h"
#include <boost/regex.hpp> #include <boost/regex.hpp>
#include <boost/foreach.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/lexical_cast.hpp>
#include <cpdoccore/xml/utils.h> #include <cpdoccore/xml/utils.h>
...@@ -92,12 +89,18 @@ std::wstring static get_default_file_name(RelsType type) ...@@ -92,12 +89,18 @@ std::wstring static get_default_file_name(RelsType type)
return L"image"; return L"image";
case typeChart: case typeChart:
return L"chart"; return L"chart";
case typeMedia:
return L"media";
case typeMsObject: case typeMsObject:
return L"msObject"; return L"msObject";
case typeOleObject: case typeOleObject:
return L"oleObject"; return L"oleObject";
case typeMedia:
return L"media";
case typeSlide:
return L"slide";
case typeVideo:
return L"video";
case typeAudio:
return L"audio";
default: default:
return L""; return L"";
} }
...@@ -142,8 +145,7 @@ std::wstring mediaitems::create_file_name(const std::wstring & uri, RelsType typ ...@@ -142,8 +145,7 @@ std::wstring mediaitems::create_file_name(const std::wstring & uri, RelsType typ
return get_default_file_name(type) + std::to_wstring(Num) + sExt; return get_default_file_name(type) + std::to_wstring(Num) + sExt;
} }
std::wstring mediaitems::detectImageFileExtension(const std::wstring &fileName)
std::wstring mediaitems::detectImageFileExtension(std::wstring &fileName)
{ {
CFile file; CFile file;
...@@ -187,6 +189,9 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b ...@@ -187,6 +189,9 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
else if ( type == typeImage) number = count_image + 1; else if ( type == typeImage) number = count_image + 1;
else if ( type == typeShape) number = count_shape + 1; else if ( type == typeShape) number = count_shape + 1;
else if ( type == typeMedia) number = count_media + 1; else if ( type == typeMedia) number = count_media + 1;
else if ( type == typeAudio) number = count_audio + 1;
else if ( type == typeVideo) number = count_video + 1;
else if ( type == typeSlide) number = count_slide + 1;
else if ( type == typeMsObject || else if ( type == typeMsObject ||
type == typeOleObject) number = count_object + 1; type == typeOleObject) number = count_object + 1;
else else
...@@ -240,6 +245,21 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b ...@@ -240,6 +245,21 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
id = std::wstring(L"objId") + std::to_wstring(count_object + 1); id = std::wstring(L"objId") + std::to_wstring(count_object + 1);
count_object++; count_object++;
} }
else if ( type == typeAudio)
{
id = std::wstring(L"aId") + std::to_wstring(count_audio + 1);
count_audio++;
}
else if ( type == typeVideo)
{
id = std::wstring(L"vId") + std::to_wstring(count_video + 1);
count_video++;
}
else if ( type == typeMedia)
{
id = std::wstring(L"mId") + std::to_wstring(count_media + 1);
count_media++;
}
else else
{ {
id = std::wstring(L"rId") + std::to_wstring(count_shape + 1); id = std::wstring(L"rId") + std::to_wstring(count_shape + 1);
......
...@@ -31,11 +31,10 @@ ...@@ -31,11 +31,10 @@
*/ */
#pragma once #pragma once
#include <vector>
#include <string>
#include "oox_rels.h" #include "oox_rels.h"
#include "../../../Common/DocxFormat/Source/XML/utils.h"
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
...@@ -50,6 +49,9 @@ public: ...@@ -50,6 +49,9 @@ public:
count_tables = 0; count_tables = 0;
count_media = 0; count_media = 0;
count_object = 0; count_object = 0;
count_audio = 0;
count_video = 0;
count_slide = 0;
} }
struct item struct item
...@@ -74,6 +76,9 @@ public: ...@@ -74,6 +76,9 @@ public:
size_t count_charts; size_t count_charts;
size_t count_image; size_t count_image;
size_t count_media; size_t count_media;
size_t count_audio;
size_t count_video;
size_t count_slide;
size_t count_shape; size_t count_shape;
size_t count_tables; size_t count_tables;
size_t count_object; size_t count_object;
...@@ -93,7 +98,7 @@ public: ...@@ -93,7 +98,7 @@ public:
case typeMsObject: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"; 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 typeOleObject: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
case typeHyperlink: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"; case typeHyperlink: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
case typeMedia: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/media"; case typeMedia: return L"http://schemas.microsoft.com/office/2007/relationships/media";
case typeAudio: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio"; case typeAudio: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio";
case typeVideo: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/video"; case typeVideo: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/video";
case typeSlide: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide"; case typeSlide: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide";
...@@ -101,10 +106,34 @@ public: ...@@ -101,10 +106,34 @@ public:
return L""; return L"";
} }
} }
static RelsType detectMediaType(const std::wstring & fileName)
{
int pos = fileName.rfind(L".");
std::wstring sExt = (pos >=0 ? fileName.substr(pos + 1) : L"");
if (sExt.empty()) return typeMedia;
sExt = XmlUtils::GetLower(sExt);
if (sExt == L"wmv") return typeVideo;
if (sExt == L"avi") return typeVideo;
if (sExt == L"wmv") return typeVideo;
if (sExt == L"wma") return typeAudio;
if (sExt == L"wav") return typeAudio;
if (sExt == L"mp3") return typeAudio;
if (sExt == L"m4a") return typeAudio;
if (sExt == L"m4v") return typeVideo;
if (sExt == L"mp4") return typeVideo;
if (sExt == L"mov") return typeVideo;
return typeMedia;
}
private: private:
std::wstring create_file_name (const std::wstring & uri, RelsType type, bool & isInternal, size_t Num); std::wstring create_file_name (const std::wstring & uri, RelsType type, bool & isInternal, size_t Num);
std::wstring detectImageFileExtension (std::wstring &fileName); std::wstring detectImageFileExtension (const std::wstring &fileName);
items_array items_; items_array items_;
std::wstring odf_packet_; std::wstring odf_packet_;
......
...@@ -526,14 +526,23 @@ void oox_serialize_action(std::wostream & strm, _action_desc const & val) ...@@ -526,14 +526,23 @@ void oox_serialize_action(std::wostream & strm, _action_desc const & val)
{ {
//CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships"); //CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
//CP_XML_ATTR(L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main"); //CP_XML_ATTR(L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main");
CP_XML_ATTR(L"r:id", val.hId);
if (!val.action.empty()) if (!val.action.empty())
CP_XML_ATTR(L"action", val.action); CP_XML_ATTR(L"action", val.action);
if (val.highlightClick) if (val.highlightClick)
CP_XML_ATTR(L"highlightClick", val.highlightClick); CP_XML_ATTR(L"highlightClick", val.highlightClick);
CP_XML_ATTR(L"r:id", val.hId);
if (!val.hSoundId.empty())
{
CP_XML_NODE(L"a:snd")
{
CP_XML_ATTR(L"r:embed", val.hSoundId);
CP_XML_ATTR(L"name", L"sound");
}
}
} }
} }
} }
......
...@@ -60,15 +60,22 @@ namespace oox { ...@@ -60,15 +60,22 @@ namespace oox {
enabled = false; enabled = false;
highlightClick = false; highlightClick = false;
hSoundId.clear();
hSoundRef.clear();
hId.clear(); hId.clear();
hRef.clear(); hRef.clear();
action.clear(); action.clear();
} }
bool enabled; bool enabled;
std::wstring action;
std::wstring hSoundId;
std::wstring hSoundRef;
std::wstring hId; std::wstring hId;
std::wstring hRef; std::wstring hRef;
std::wstring action;
RelsType typeRels; RelsType typeRels;
bool highlightClick; bool highlightClick;
...@@ -95,6 +102,8 @@ namespace oox { ...@@ -95,6 +102,8 @@ namespace oox {
std::wstring objectId; std::wstring objectId;
std::wstring objectProgId; std::wstring objectProgId;
std::wstring extId;
_action_desc action; _action_desc action;
std::vector<_hlink_desc> hlinks; std::vector<_hlink_desc> hlinks;
......
...@@ -71,7 +71,18 @@ static std::wstring get_mime_type(const std::wstring & extension) ...@@ -71,7 +71,18 @@ static std::wstring get_mime_type(const std::wstring & extension)
else if (L"tif" == extension) return L"image/x-tiff"; else if (L"tif" == extension) return L"image/x-tiff";
else if (L"tiff" == extension) return L"image/x-tiff"; else if (L"tiff" == extension) return L"image/x-tiff";
else if (L"pdf" == extension) return L"application/pdf"; else if (L"pdf" == extension) return L"application/pdf";
else if (L"wav" == extension) return L"audio/wav"; else if (L"wav" == extension) return L"audio/wav";
else if (L"mp3" == extension) return L"audio/mpeg";
else if (L"wma" == extension) return L"audio/x-ms-wma";
else if (L"m4a" == extension) return L"audio/unknown";
else if (L"avi" == extension) return L"video/avi";
else if (L"wmv" == extension) return L"video/x-ms-wmv";
else if (L"mov" == extension) return L"video/unknown";
else if (L"mp4" == extension) return L"video/unknown";
else if (L"m4v" == extension) return L"video/unknown";
else if (L"bin" == extension) return L"application/vnd.openxmlformats-officedocument.oleObject"; 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"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"docx" == extension) return L"application/vnd.openxmlformats-officedocument.wordprocessingml.document";
...@@ -130,7 +141,7 @@ bool content_types_file::add_or_find_override(const std::wstring & fileName) ...@@ -130,7 +141,7 @@ bool content_types_file::add_or_find_override(const std::wstring & fileName)
{ {
std::vector<override_content_type> & override_ = content_type_content_.get_override(); std::vector<override_content_type> & override_ = content_type_content_.get_override();
for (int i = 0 ; i < override_.size(); i++) for (size_t i = 0 ; i < override_.size(); i++)
{ {
if (override_[i].part_name() == fileName) if (override_[i].part_name() == fileName)
return true; return true;
...@@ -158,14 +169,18 @@ bool content_types_file::add_or_find_override(const std::wstring & fileName) ...@@ -158,14 +169,18 @@ bool content_types_file::add_or_find_override(const std::wstring & fileName)
void content_types_file::set_media(mediaitems & _Mediaitems) void content_types_file::set_media(mediaitems & _Mediaitems)
{ {
BOOST_FOREACH( mediaitems::item & item, _Mediaitems.items() ) std::vector<mediaitems::item> & items_ = _Mediaitems.items();
for (size_t i = 0; i < items_.size(); i++)
{ {
if ((item.type == typeImage || item.type == typeMedia) && item.mediaInternal) if ((items_[i].type == typeImage ||
items_[i].type == typeMedia ||
items_[i].type == typeVideo ||
items_[i].type == typeAudio) && items_[i].mediaInternal)
{ {
int n = item.outputName.rfind(L"."); int n = items_[i].outputName.rfind(L".");
if (n > 0) if (n > 0)
{ {
add_or_find_default(item.outputName.substr(n+1, item.outputName.length() - n)); add_or_find_default(items_[i].outputName.substr(n + 1, items_[i].outputName.length() - n));
} }
} }
} }
...@@ -320,9 +335,12 @@ void media::write(const std::wstring & RootPath) ...@@ -320,9 +335,12 @@ void media::write(const std::wstring & RootPath)
NSDirectory::CreateDirectory(path.c_str()); NSDirectory::CreateDirectory(path.c_str());
mediaitems::items_array & items = mediaitems_.items(); mediaitems::items_array & items = mediaitems_.items();
for (int i = 0; i < items.size(); i++ ) for (size_t i = 0; i < items.size(); i++ )
{ {
if (items[i].mediaInternal && items[i].valid && (items[i].type == typeImage || items[i].type == typeMedia)) if (items[i].mediaInternal && items[i].valid && ( items[i].type == typeImage ||
items[i].type == typeMedia ||
items[i].type == typeAudio ||
items[i].type == typeVideo ))
{ {
std::wstring & file_name = items[i].href; std::wstring & file_name = items[i].href;
std::wstring file_name_out = RootPath + FILE_SEPARATOR_STR + items[i].outputName; std::wstring file_name_out = RootPath + FILE_SEPARATOR_STR + items[i].outputName;
...@@ -359,7 +377,7 @@ void embeddings::write(const std::wstring & RootPath) ...@@ -359,7 +377,7 @@ void embeddings::write(const std::wstring & RootPath)
content_types_file & content_types = get_main_document()->get_content_types_file(); content_types_file & content_types = get_main_document()->get_content_types_file();
mediaitems::items_array & items = embeddingsitems_.items(); mediaitems::items_array & items = embeddingsitems_.items();
for (int i = 0; i < items.size(); i++ ) for (size_t i = 0; i < items.size(); i++ )
{ {
if ( items[i].mediaInternal && items[i].valid && if ( items[i].mediaInternal && items[i].valid &&
(items[i].type == typeMsObject || items[i].type == typeOleObject)) (items[i].type == typeMsObject || items[i].type == typeOleObject))
......
...@@ -130,9 +130,29 @@ void pptx_serialize_media(std::wostream & strm, _pptx_drawing & val) ...@@ -130,9 +130,29 @@ void pptx_serialize_media(std::wostream & strm, _pptx_drawing & val)
} }
CP_XML_NODE(L"p:nvPr") CP_XML_NODE(L"p:nvPr")
{ {
CP_XML_NODE(L"a:videoFile") std::wstring strNode;
if (val.type == typeVideo) strNode = L"a:videoFile";
else if (val.type == typeAudio) strNode = L"a:audioFile";
if (strNode.empty() == false)
{
CP_XML_NODE(strNode)
{
CP_XML_ATTR(L"r:link", val.objectId);
}
}
CP_XML_NODE(L"p:extLst")
{ {
CP_XML_ATTR(L"r:link", val.objectId); CP_XML_NODE(L"p:ext")
{
CP_XML_ATTR(L"uri", L"{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}");
CP_XML_NODE(L"p14:media")
{
CP_XML_ATTR(L"xmlns:p14", L"http://schemas.microsoft.com/office/powerpoint/2010/main");
CP_XML_ATTR(L"r:embed", val.extId);
}
}
} }
} }
} }
...@@ -359,12 +379,11 @@ void _pptx_drawing::serialize(std::wostream & strm) ...@@ -359,12 +379,11 @@ void _pptx_drawing::serialize(std::wostream & strm)
{ {
pptx_serialize_table(strm, *this); pptx_serialize_table(strm, *this);
} }
else if (type == typeMsObject || else if (type == typeMsObject || type == typeOleObject)
type == typeOleObject)
{ {
pptx_serialize_object(strm, *this); pptx_serialize_object(strm, *this);
} }
else if (type == typeMedia) else if (type == typeMedia || type == typeAudio || type == typeVideo )
{ {
pptx_serialize_media(strm, *this); pptx_serialize_media(strm, *this);
} }
......
...@@ -71,7 +71,8 @@ public: ...@@ -71,7 +71,8 @@ public:
} }
if (!d.action.hId.empty()) if (!d.action.hId.empty())
{ {
pptx_drawing_rels_.push_back(_rel(false, d.action.hId, d.action.hRef, d.action.typeRels)); bool bInternal = (d.action.typeRels != typeHyperlink);
pptx_drawing_rels_.push_back(_rel(bInternal, d.action.hId, d.action.hRef, d.action.typeRels));
} }
} }
...@@ -124,10 +125,13 @@ public: ...@@ -124,10 +125,13 @@ public:
} }
else else
{ {
std::wstring ref = pptx_drawing_rels_[i].ref;
if (pptx_drawing_rels_[i].is_internal && ref != L"NULL")
{
ref = L"../" + ref;
}
Rels.add(relationship( pptx_drawing_rels_[i].rid, Rels.add(relationship( pptx_drawing_rels_[i].rid,
mediaitems::get_rel_type(pptx_drawing_rels_[i].type), mediaitems::get_rel_type(pptx_drawing_rels_[i].type), ref, (pptx_drawing_rels_[i].is_internal ? L"" : L"External")) );
(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")) );
} }
} }
} }
......
...@@ -54,7 +54,7 @@ std::wstring pptx_xml_slide::rId() const ...@@ -54,7 +54,7 @@ std::wstring pptx_xml_slide::rId() const
pptx_xml_slide_ptr pptx_xml_slide::create(std::wstring const & name,int id) pptx_xml_slide_ptr pptx_xml_slide::create(std::wstring const & name,int id)
{ {
const std::wstring rId = std::wstring(L"sId") + std::to_wstring(id); const std::wstring rId = std::wstring(L"sId") + std::to_wstring(id);
return boost::make_shared<pptx_xml_slide>(name,rId); return boost::make_shared<pptx_xml_slide>(name, rId);
} }
pptx_xml_slide::pptx_xml_slide(std::wstring const & name,std::wstring const & id) pptx_xml_slide::pptx_xml_slide(std::wstring const & name,std::wstring const & id)
......
...@@ -60,6 +60,7 @@ public: ...@@ -60,6 +60,7 @@ public:
_CP_OPT(std::wstring) Speed; _CP_OPT(std::wstring) Speed;
_CP_OPT(int) Time; _CP_OPT(int) Time;
_CP_OPT(int) PageTime;
_CP_OPT(std::wstring) Dir; _CP_OPT(std::wstring) Dir;
_CP_OPT(std::wstring) Param; _CP_OPT(std::wstring) Param;
bool onClick; bool onClick;
...@@ -135,6 +136,7 @@ private: ...@@ -135,6 +136,7 @@ private:
void process_chart (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_table (drawing_object_description& obj, _pptx_drawing & drawing);
void process_object (drawing_object_description& obj, _pptx_drawing & drawing); void process_object (drawing_object_description& obj, _pptx_drawing & drawing);
void process_media (drawing_object_description& obj, _pptx_drawing & drawing);
size_t rId_; size_t rId_;
mediaitems mediaitems_; mediaitems mediaitems_;
...@@ -160,7 +162,7 @@ void pptx_slide_context::Impl::process_drawings() ...@@ -160,7 +162,7 @@ void pptx_slide_context::Impl::process_drawings()
case typeChart: process_chart(objects_[i], drawing); break; case typeChart: process_chart(objects_[i], drawing); break;
case typeShape: process_shape(objects_[i], drawing); break; case typeShape: process_shape(objects_[i], drawing); break;
case typeTable: process_table(objects_[i], drawing); break; case typeTable: process_table(objects_[i], drawing); break;
case typeMedia: case typeMedia: process_media(objects_[i], drawing); break;
case typeMsObject: case typeMsObject:
case typeOleObject: process_object(objects_[i], drawing); break; case typeOleObject: process_object(objects_[i], drawing); break;
} }
...@@ -369,6 +371,7 @@ void pptx_slide_context::start_action(std::wstring action) ...@@ -369,6 +371,7 @@ void pptx_slide_context::start_action(std::wstring action)
if (action == L"sound") if (action == L"sound")
{ {
impl_->object_description_.action_.action = L"ppaction://noaction";
impl_->object_description_.action_.typeRels = typeAudio; impl_->object_description_.action_.typeRels = typeAudio;
impl_->object_description_.action_.highlightClick = true; impl_->object_description_.action_.highlightClick = true;
} }
...@@ -403,18 +406,29 @@ void pptx_slide_context::start_action(std::wstring action) ...@@ -403,18 +406,29 @@ void pptx_slide_context::start_action(std::wstring action)
void pptx_slide_context::set_link(std::wstring link, RelsType typeRels) void pptx_slide_context::set_link(std::wstring link, RelsType typeRels)
{ {
++hlinks_size_; ++hlinks_size_;
std::wstring hId = L"hId" + std::to_wstring(hlinks_size_);
link = xml::utils::replace_text_to_xml(link);
if (typeRels == typeHyperlink)
XmlUtils::replace_all( link, L" .", L"."); //1 (130).odt
impl_->object_description_.action_.highlightClick = true; impl_->object_description_.action_.highlightClick = true;
impl_->object_description_.action_.hId = hId; if (typeRels == typeAudio)
impl_->object_description_.action_.hRef = link; {
impl_->object_description_.action_.typeRels = typeRels; bool isMediaInternal = true;
impl_->object_description_.action_.hSoundId = get_mediaitems().add_or_find(link, typeAudio, isMediaInternal, impl_->object_description_.action_.hSoundRef);
impl_->add_additional_rels(isMediaInternal, impl_->object_description_.action_.hSoundId, impl_->object_description_.action_.hSoundRef, typeAudio);
}
else
{
impl_->object_description_.action_.typeRels = typeRels;
std::wstring hId = L"hId" + std::to_wstring(hlinks_size_);
link = xml::utils::replace_text_to_xml(link);
if (typeRels == typeHyperlink)
XmlUtils::replace_all( link, L" .", L"."); //1 (130).odt
impl_->object_description_.action_.hId = hId;
impl_->object_description_.action_.hRef = link;
}
} }
void pptx_slide_context::end_action() void pptx_slide_context::end_action()
{ {
...@@ -620,7 +634,26 @@ void pptx_slide_context::Impl::process_object(drawing_object_description& obj, _ ...@@ -620,7 +634,26 @@ void pptx_slide_context::Impl::process_object(drawing_object_description& obj, _
add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage); add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);
} }
} }
void pptx_slide_context::Impl::process_media(drawing_object_description& obj, _pptx_drawing & drawing)
{
std::wstring ref;
bool isMediaInternal = true;
drawing.type = mediaitems::detectMediaType(obj.xlink_href_); //reset from Media to Audio, Video, ... QuickTime? AudioCD? ...
drawing.objectId = get_mediaitems().add_or_find(obj.xlink_href_, drawing.type, isMediaInternal, ref);
drawing.extId = L"ext" + drawing.objectId;
add_drawing(drawing, false, drawing.objectId, L"NULL", drawing.type);
add_additional_rels( true, drawing.extId, ref, typeMedia);
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) void pptx_slide_context::Impl::process_common_properties(drawing_object_description & pic, _pptx_drawing & drawing)
{ {
if (pic.svg_rect_) if (pic.svg_rect_)
...@@ -714,8 +747,12 @@ void pptx_slide_context::serialize_animations(std::wostream & strm) ...@@ -714,8 +747,12 @@ void pptx_slide_context::serialize_animations(std::wostream & strm)
} }
if (impl_->transition_.Time) if (impl_->transition_.Time)
{ {
CP_XML_ATTR(L"advTm",impl_->transition_.Time.get()); CP_XML_ATTR(L"p14:dur", impl_->transition_.Time.get());
} }
if (impl_->transition_.PageTime)
{
CP_XML_ATTR(L"advTm", impl_->transition_.PageTime.get());
}
CP_XML_ATTR(L"advClick", impl_->transition_.onClick); CP_XML_ATTR(L"advClick", impl_->transition_.onClick);
CP_XML_NODE(std::wstring(L"p:" + impl_->transition_.Type)) CP_XML_NODE(std::wstring(L"p:" + impl_->transition_.Type))
...@@ -738,9 +775,22 @@ void pptx_slide_context::serialize_animations(std::wostream & strm) ...@@ -738,9 +775,22 @@ void pptx_slide_context::serialize_animations(std::wostream & strm)
//p:sndAc //p:sndAc
} }
} }
//CP_XML_NODE(L"p:timing")- последовательности p:par CP_XML_NODE(L"p:timing")
//{ {
//} CP_XML_NODE(L"p:tnLst")
{
CP_XML_NODE(L"p:par")
{
CP_XML_NODE(L"p:cTn")
{
CP_XML_ATTR(L"nodeType", L"tmRoot");
CP_XML_ATTR(L"id", 1);
CP_XML_ATTR(L"dur", L"indefinite");
CP_XML_ATTR(L"restart", L"never");
}
}
}
}
} }
} }
......
...@@ -368,18 +368,18 @@ void draw_param::pptx_convert(oox::pptx_conversion_context & Context) ...@@ -368,18 +368,18 @@ void draw_param::pptx_convert(oox::pptx_conversion_context & Context)
void draw_plugin::pptx_convert(oox::pptx_conversion_context & Context) void draw_plugin::pptx_convert(oox::pptx_conversion_context & Context)
{ {
// Context.get_slide_context().set_use_image_replacement(); Context.get_slide_context().set_use_image_replacement();
//
// std::wstring href = common_xlink_attlist_.href_.get_value_or(L""); std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
// std::wstring folderPath = Context.root()->get_folder(); std::wstring folderPath = Context.root()->get_folder();
// std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href; std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
//
// Context.get_slide_context().set_media(href); Context.get_slide_context().set_media(href);
////params //params
// for (size_t i = 0; i < content_.size(); i++) for (size_t i = 0; i < content_.size(); i++)
// { {
// content_[i]->pptx_convert(Context); content_[i]->pptx_convert(Context);
// } }
} }
} }
} }
......
...@@ -161,10 +161,10 @@ struct anchor_settings ...@@ -161,10 +161,10 @@ struct anchor_settings
enum _drawing_part enum _drawing_part
{ {
Unknown=0, Unknown = 0,
Area, Area = 1,
Line, Line = 2,
Shadow Shadow = 3
}; };
struct odf_drawing_state struct odf_drawing_state
{ {
...@@ -192,6 +192,7 @@ struct odf_drawing_state ...@@ -192,6 +192,7 @@ struct odf_drawing_state
view_box_ = L""; view_box_ = L"";
path_last_command_ = L""; path_last_command_ = L"";
replacement_ = L"";
oox_shape_preset_ = -1; oox_shape_preset_ = -1;
oox_shape_.reset(); oox_shape_.reset();
...@@ -222,12 +223,12 @@ struct odf_drawing_state ...@@ -222,12 +223,12 @@ struct odf_drawing_state
_CP_OPT(presentation_class) presentation_class_; _CP_OPT(presentation_class) presentation_class_;
_CP_OPT(std::wstring) presentation_placeholder_; _CP_OPT(std::wstring) presentation_placeholder_;
std::wstring replacement_;
std::wstring path_; std::wstring path_;
std::wstring view_box_; std::wstring view_box_;
std::wstring path_last_command_; std::wstring path_last_command_;
oox_shape_ptr oox_shape_; oox_shape_ptr oox_shape_;
/////////////////////// //----------------------------------------------------------
int oox_shape_preset_; int oox_shape_preset_;
bool in_group_; bool in_group_;
bool text_box_tableframe_; bool text_box_tableframe_;
...@@ -236,7 +237,7 @@ struct odf_drawing_state ...@@ -236,7 +237,7 @@ struct odf_drawing_state
class odf_drawing_context::Impl class odf_drawing_context::Impl
{ {
public: public:
Impl(odf_conversion_context *odf_context) :odf_context_(odf_context) Impl(odf_conversion_context *odf_context) : odf_context_(odf_context)
{ {
current_drawing_state_.clear(); current_drawing_state_.clear();
styles_context_ = odf_context_->styles_context(); styles_context_ = odf_context_->styles_context();
...@@ -250,7 +251,7 @@ public: ...@@ -250,7 +251,7 @@ public:
is_header_ = false; is_header_ = false;
is_footer_ = false; is_footer_ = false;
is_background_ = false; is_background_ = false;
//некоторые свойства для объектов графики не поддерживаюися в редакторах Liber && OpenOffice.net //некоторые свойства для объектов графики не поддерживаюися в редакторах Libre && OpenOffice.net
//в MS Office и в нашем - проблем таких нет. //в MS Office и в нашем - проблем таких нет.
} }
...@@ -295,8 +296,7 @@ public: ...@@ -295,8 +296,7 @@ public:
}; };
//////////////////////////////////////////////////////////////////////////// //-----------------------------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////
odf_drawing_context::odf_drawing_context(odf_conversion_context *odf_context) odf_drawing_context::odf_drawing_context(odf_conversion_context *odf_context)
: impl_(new odf_drawing_context::Impl(odf_context)) : impl_(new odf_drawing_context::Impl(odf_context))
{ {
...@@ -2277,9 +2277,7 @@ void odf_drawing_context::set_textarea_padding(_CP_OPT(double) & left, _CP_OPT(d ...@@ -2277,9 +2277,7 @@ void odf_drawing_context::set_textarea_padding(_CP_OPT(double) & left, _CP_OPT(d
if (right) impl_->current_graphic_properties->common_padding_attlist_.fo_padding_right_ = length(*right,length::pt); if (right) impl_->current_graphic_properties->common_padding_attlist_.fo_padding_right_ = length(*right,length::pt);
if (bottom) impl_->current_graphic_properties->common_padding_attlist_.fo_padding_bottom_ = length(*bottom,length::pt); if (bottom) impl_->current_graphic_properties->common_padding_attlist_.fo_padding_bottom_ = length(*bottom,length::pt);
} }
//------------------------------------------------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//вложенные элементы
void odf_drawing_context::start_image(std::wstring odf_path) void odf_drawing_context::start_image(std::wstring odf_path)
{ {
if (impl_->is_footer_ || impl_->is_header_ || impl_->is_background_) if (impl_->is_footer_ || impl_->is_header_ || impl_->is_background_)
...@@ -2359,9 +2357,31 @@ void odf_drawing_context::start_media(std::wstring name) ...@@ -2359,9 +2357,31 @@ void odf_drawing_context::start_media(std::wstring name)
start_element(plugin_elm); start_element(plugin_elm);
} }
void odf_drawing_context::add_image_replacement()
{
if (impl_->current_drawing_state_.replacement_.empty()) return;
office_element_ptr image_elm;
create_element(L"draw", L"image", image_elm, impl_->odf_context_);
draw_image* image = dynamic_cast<draw_image*>(image_elm.get());
if (image == NULL)return;
image->common_xlink_attlist_.href_ = impl_->current_drawing_state_.replacement_;
image->common_xlink_attlist_.type_ = xlink_type::Simple;
image->common_xlink_attlist_.show_ = xlink_show::Embed;
image->common_xlink_attlist_.actuate_ = xlink_actuate::OnLoad;
start_element(image_elm);
set_image_style_repeat(1);//default
end_element();
}
void odf_drawing_context::end_media() void odf_drawing_context::end_media()
{ {
end_element(); end_element();
add_image_replacement();
end_frame(); end_frame();
} }
void odf_drawing_context::start_text_box() void odf_drawing_context::start_text_box()
...@@ -2475,8 +2495,10 @@ void odf_drawing_context::add_sound(std::wstring href) ...@@ -2475,8 +2495,10 @@ void odf_drawing_context::add_sound(std::wstring href)
presentation_event_listener * event_ = dynamic_cast<presentation_event_listener*>(impl_->current_level_.back().get()); presentation_event_listener * event_ = dynamic_cast<presentation_event_listener*>(impl_->current_level_.back().get());
if (event_) if (event_)
{ {
event_->attlist_.script_event_name_ = L"dom:click"; event_->attlist_.script_event_name_ = L"dom:click";
event_->attlist_.presentation_action_ = L"sound";
if (!event_->attlist_.presentation_action_)
event_->attlist_.presentation_action_ = L"sound";
} }
office_element_ptr elm; office_element_ptr elm;
...@@ -2619,6 +2641,36 @@ void odf_drawing_context::end_object() ...@@ -2619,6 +2641,36 @@ void odf_drawing_context::end_object()
end_frame(); end_frame();
} }
void odf_drawing_context::start_object_ole(std::wstring ref)
{
start_frame();
office_element_ptr object_elm;
create_element(L"draw", L"object-ole", object_elm, impl_->odf_context_);
draw_object_ole* object = dynamic_cast<draw_object_ole*>(object_elm.get());
if (object == NULL)return;
object->common_xlink_attlist_.href_ = ref;
object->common_xlink_attlist_.type_ = xlink_type::Simple;
object->common_xlink_attlist_.show_ = xlink_show::Embed;
object->common_xlink_attlist_.actuate_ = xlink_actuate::OnLoad;
start_element(object_elm);
}
void odf_drawing_context::end_object_ole()
{
end_element();
add_image_replacement();
end_frame();
}
void odf_drawing_context::set_image_replacement(std::wstring ref)
{
impl_->current_drawing_state_.replacement_ = ref;
}
bool odf_drawing_context::is_exist_content() bool odf_drawing_context::is_exist_content()
{ {
......
...@@ -141,12 +141,18 @@ public: ...@@ -141,12 +141,18 @@ public:
void set_text_box_tableframe (bool val); void set_text_box_tableframe (bool val);
void end_text_box (); void end_text_box ();
void start_object(std::wstring name); void start_object(std::wstring ref); //формулы, диаграммы ...
void end_object(); void end_object();
void start_media(std::wstring name); void start_object_ole(std::wstring ref);
void end_object_ole();
void start_media(std::wstring ref);
void end_media(); void end_media();
void add_image_replacement();
void set_image_replacement(std::wstring ref);
bool isLineShape(); bool isLineShape();
void corrected_line_fill(); void corrected_line_fill();
......
...@@ -84,6 +84,12 @@ void odp_page_state::set_page_name(std::wstring name) ...@@ -84,6 +84,12 @@ void odp_page_state::set_page_name(std::wstring name)
// master_page->attlist_.style_display_name_ = name; // master_page->attlist_.style_display_name_ = name;
} }
} }
void odp_page_state::set_page_duration(int id)
{
if (!page_properties_) return;
page_properties_->content_.presentation_page_duration_ = id;
}
void odp_page_state::set_layout_page(std::wstring name) void odp_page_state::set_layout_page(std::wstring name)
{ {
...@@ -224,6 +230,14 @@ void odp_page_state::set_transition_subtype(std::wstring val) ...@@ -224,6 +230,14 @@ void odp_page_state::set_transition_subtype(std::wstring val)
if (trans) if (trans)
trans->filter_attlist_.smil_subtype_ = val; trans->filter_attlist_.smil_subtype_ = val;
} }
void odp_page_state::set_transition_direction(std::wstring val)
{
if (transactions.empty()) return;
anim_transitionFilter *trans = dynamic_cast<anim_transitionFilter*>(transactions.back().get());
if (trans)
trans->common_attlist_.smil_direction_ = val;
}
void odp_page_state::set_transition_speed(int val) void odp_page_state::set_transition_speed(int val)
{ {
if (transactions.empty()) return; if (transactions.empty()) return;
......
...@@ -70,9 +70,10 @@ class odp_page_state ...@@ -70,9 +70,10 @@ class odp_page_state
{ {
public: public:
odp_page_state(odf_conversion_context * Context, office_element_ptr & elm); odp_page_state(odf_conversion_context * Context, office_element_ptr & elm);
void set_page_name (std::wstring name); void set_page_name (std::wstring name);
void set_page_id (int id); void set_page_id (int id);
void set_page_style (office_element_ptr & _style); void set_page_style (office_element_ptr & _style);
void set_page_duration (int id);
void set_master_page(std::wstring name); void set_master_page(std::wstring name);
void set_layout_page(std::wstring name); void set_layout_page(std::wstring name);
...@@ -107,6 +108,7 @@ public: ...@@ -107,6 +108,7 @@ public:
void start_transition(); void start_transition();
void set_transition_type (int val); void set_transition_type (int val);
void set_transition_subtype (std::wstring val); void set_transition_subtype (std::wstring val);
void set_transition_direction(std::wstring val);
void set_transition_speed (int val); void set_transition_speed (int val);
void set_transition_duration(int val); void set_transition_duration(int val);
void set_transition_sound (std::wstring ref, bool loop); void set_transition_sound (std::wstring ref, bool loop);
......
...@@ -119,7 +119,7 @@ public: ...@@ -119,7 +119,7 @@ public:
_CP_OPT(bool) presentation_display_page_number_; _CP_OPT(bool) presentation_display_page_number_;
_CP_OPT(bool) presentation_display_date_time_; _CP_OPT(bool) presentation_display_date_time_;
_CP_OPT(bool) presentation_display_header_; _CP_OPT(bool) presentation_display_header_;
_CP_OPT(std::wstring) presentation_page_duration_; _CP_OPT(odf_types::clockvalue) presentation_page_duration_;
office_element_ptr presentation_sound_; office_element_ptr presentation_sound_;
......
...@@ -202,6 +202,25 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture) ...@@ -202,6 +202,25 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
return; return;
} }
} }
//--------------------------------------------------------------------------------------
std::wstring odf_ref_image;
std::wstring pathImage;
if (oox_picture->blipFill.blip.IsInit())
{
bool bEmbedded = true;
if (oox_picture->blipFill.blip->embed.IsInit())
{
std::wstring sID = oox_picture->blipFill.blip->embed->get();
pathImage = find_link_by_id(sID, 1);
odf_ref_image = odf_context()->add_image(pathImage);
}
else if (oox_picture->blipFill.blip->link.IsInit())
{
odf_ref_image = oox_picture->blipFill.blip->link->get();
bEmbedded = false;
}
}
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
if (oox_picture->nvPicPr.nvPr.media.is_init()) if (oox_picture->nvPicPr.nvPr.media.is_init())
{ {
...@@ -226,15 +245,17 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture) ...@@ -226,15 +245,17 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
if (ext.end.IsInit()) end = *ext.end; if (ext.end.IsInit()) end = *ext.end;
} }
std::wstring odf_ref = odf_context()->add_media(pathMedia); std::wstring odf_ref_media = odf_context()->add_media(pathMedia);
if (!odf_ref.empty()) if (!odf_ref_media.empty())
{ {
odf_context()->drawing_context()->start_media(odf_ref); odf_context()->drawing_context()->start_media(odf_ref_media);
//... params //... params
OoxConverter::convert(&oox_picture->nvPicPr.cNvPr); OoxConverter::convert(&oox_picture->nvPicPr.cNvPr);
OoxConverter::convert(&oox_picture->spPr, oox_picture->style.GetPointer()); OoxConverter::convert(&oox_picture->spPr, oox_picture->style.GetPointer());
odf_context()->drawing_context()->set_image_replacement(odf_ref_image);
odf_context()->drawing_context()->end_media(); odf_context()->drawing_context()->end_media();
...@@ -242,26 +263,18 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture) ...@@ -242,26 +263,18 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
} }
} }
} }
//-------------------------------------------------------------------------------------- if (oox_picture->oleObject.IsInit())
std::wstring odf_ref;
std::wstring pathImage;
if (oox_picture->blipFill.blip.IsInit())
{ {
bool bEmbedded = true; //nullable_limit<Limit::OLEDrawAspectType>m_oDrawAspect;
if (oox_picture->blipFill.blip->embed.IsInit()) //nullable<OOX::RId> m_oId;
{ //nullable_string m_sObjectId;
std::wstring sID = oox_picture->blipFill.blip->embed->get(); //nullable_string m_sProgId;
pathImage = find_link_by_id(sID, 1); //nullable_string m_sShapeId;
//nullable_limit<Limit::OLEType> m_oType;
odf_ref = odf_context()->add_image(pathImage); //nullable_limit<Limit::OLEUpdateMode> m_oUpdateMode;
}
else if (oox_picture->blipFill.blip->link.IsInit())
{
odf_ref = oox_picture->blipFill.blip->link->get();
bEmbedded = false;
}
} }
odf_context()->drawing_context()->start_image(odf_ref); //--------------------------------------------------------------------------------------
odf_context()->drawing_context()->start_image(odf_ref_image);
{ {
double Width = 0, Height = 0; double Width = 0, Height = 0;
_graphics_utils_::GetResolution(pathImage.c_str(), Width, Height); _graphics_utils_::GetResolution(pathImage.c_str(), Width, Height);
......
...@@ -544,14 +544,24 @@ void PptxConverter::convert(PPTX::Comments *oox_comments) ...@@ -544,14 +544,24 @@ void PptxConverter::convert(PPTX::Comments *oox_comments)
void PptxConverter::convert( PPTX::Logic::Transition *oox_transition ) void PptxConverter::convert( PPTX::Logic::Transition *oox_transition )
{ {
if (!oox_transition) return; if (!oox_transition) return;
if (oox_transition->base.is_init() == false) return;
if (oox_transition->advTm.is_init())
{
odp_context->current_slide().set_page_duration(*oox_transition->dur);
}
if (oox_transition->base.is_init() == false) return;
odp_context->current_slide().start_transition(); odp_context->current_slide().start_transition();
if (oox_transition->spd.is_init()) if (oox_transition->spd.is_init())
{
odp_context->current_slide().set_transition_speed(oox_transition->spd->GetBYTECode()); odp_context->current_slide().set_transition_speed(oox_transition->spd->GetBYTECode());
}
if (oox_transition->dur.is_init()) if (oox_transition->dur.is_init())
{
odp_context->current_slide().set_transition_duration(*oox_transition->dur); odp_context->current_slide().set_transition_duration(*oox_transition->dur);
}
convert(oox_transition->base.base.operator->()); convert(oox_transition->base.base.operator->());
if (oox_transition->sndAc.is_init() && oox_transition->sndAc->stSnd.is_init()) if (oox_transition->sndAc.is_init() && oox_transition->sndAc->stSnd.is_init())
...@@ -606,27 +616,47 @@ void PptxConverter::convert(PPTX::Logic::EmptyTransition *oox_transition) ...@@ -606,27 +616,47 @@ void PptxConverter::convert(PPTX::Logic::EmptyTransition *oox_transition)
if (oox_transition->name == L"random") if (oox_transition->name == L"random")
odp_context->current_slide().set_transition_type(40); odp_context->current_slide().set_transition_type(40);
if (oox_transition->name == L"circle") else if (oox_transition->name == L"circle")
{ {
odp_context->current_slide().set_transition_type(16); odp_context->current_slide().set_transition_type(16);
odp_context->current_slide().set_transition_subtype(L"circle"); odp_context->current_slide().set_transition_subtype(L"circle");
} }
if (oox_transition->name == L"dissolve") else if (oox_transition->name == L"dissolve")
odp_context->current_slide().set_transition_type(39); odp_context->current_slide().set_transition_type(39);
if (oox_transition->name == L"diamond") else if (oox_transition->name == L"diamond")
{ {
odp_context->current_slide().set_transition_type(11); odp_context->current_slide().set_transition_type(11);
odp_context->current_slide().set_transition_subtype(L"diamond"); odp_context->current_slide().set_transition_subtype(L"diamond");
} }
if (oox_transition->name == L"newsflash") else if (oox_transition->name == L"newsflash")
odp_context->current_slide().set_transition_type(24); odp_context->current_slide().set_transition_type(24); //fanWipe
if (oox_transition->name == L"plus") else if (oox_transition->name == L"plus")
{ {
odp_context->current_slide().set_transition_type(19); odp_context->current_slide().set_transition_type(19); //starWipe
odp_context->current_slide().set_transition_subtype(L"fourPoint"); odp_context->current_slide().set_transition_subtype(L"fourPoint");
} }
if (oox_transition->name == L"wedge") else if (oox_transition->name == L"wedge")
odp_context->current_slide().set_transition_type(24); odp_context->current_slide().set_transition_type(24); //fanWipe
else if (oox_transition->name == L"vortex")
{
odp_context->current_slide().set_transition_type(20); //miscShapeWipe
odp_context->current_slide().set_transition_subtype(L"vertical");
}
else if (oox_transition->name == L"doors")
{
odp_context->current_slide().set_transition_type(0); //barWipe
odp_context->current_slide().set_transition_subtype(L"topToBottom");
odp_context->current_slide().set_transition_direction(L"reverse");
}
else if (oox_transition->name == L"prism")
{
odp_context->current_slide().set_transition_type(20); //miscShapeWipe
odp_context->current_slide().set_transition_subtype(L"cornersOut");
}
else
{
odp_context->current_slide().set_transition_type(36); //fade
}
} }
void PptxConverter::convert(PPTX::Logic::OrientationTransition *oox_transition) void PptxConverter::convert(PPTX::Logic::OrientationTransition *oox_transition)
{ {
......
...@@ -48,17 +48,36 @@ namespace PPTX ...@@ -48,17 +48,36 @@ namespace PPTX
public: public:
PPTX_LOGIC_BASE(Transition) PPTX_LOGIC_BASE(Transition)
public:
virtual void fromXML(XmlUtils::CXmlNode& node) virtual void fromXML(XmlUtils::CXmlNode& node)
{ {
node.ReadAttributeBase(L"advClick", advClick); node.ReadAttributeBase(L"advClick", advClick);
node.ReadAttributeBase(L"advTm", advTm); node.ReadAttributeBase(L"advTm", advTm);
node.ReadAttributeBase(L"p14:dur", dur); node.ReadAttributeBase(L"p14:dur", dur);
node.ReadAttributeBase(L"spd", spd); node.ReadAttributeBase(L"spd", spd);
XmlUtils::CXmlNodes oNodes;
if (node.GetNodes(_T("*"), oNodes))
{
int count = oNodes.GetCount();
for (int i = 0; i < count; ++i)
{
XmlUtils::CXmlNode oNode;
oNodes.GetAt(i, oNode);
std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName());
base.GetTransitionTypeFrom(node); if (strName == L"sndAc")
trSerialize.GetTransitionTypeFrom(node); sndAc = oNode;
sndAc = node.ReadNode(_T("p:sndAc")); else
{
trSerialize.fromXML(oNode);
base.fromXML(oNode);
}
}
}
FillParentPointersForChilds(); FillParentPointersForChilds();
} }
...@@ -136,7 +155,6 @@ namespace PPTX ...@@ -136,7 +155,6 @@ namespace PPTX
} }
} }
} }
pReader->Seek(end); pReader->Seek(end);
} }
...@@ -174,16 +192,14 @@ namespace PPTX ...@@ -174,16 +192,14 @@ namespace PPTX
pWriter->WriteString(_T("</mc:Fallback></mc:AlternateContent>")); pWriter->WriteString(_T("</mc:Fallback></mc:AlternateContent>"));
} }
TransitionBase base;
nullable<SndAc> sndAc;
public: TransitionSerialize trSerialize;
/*nullable<*/TransitionBase/*>*/ base;
nullable<SndAc> sndAc;
TransitionSerialize trSerialize;
nullable_bool advClick; nullable_bool advClick;
nullable_int advTm; nullable_int advTm;
nullable_int dur; nullable_int dur;
nullable_limit<Limit::TransitionSpeed> spd; nullable_limit<Limit::TransitionSpeed> spd;
protected: protected:
virtual void FillParentPointersForChilds() virtual void FillParentPointersForChilds()
......
...@@ -66,103 +66,53 @@ namespace PPTX ...@@ -66,103 +66,53 @@ namespace PPTX
return *this; return *this;
} }
void TransitionBase::fromXML(XmlUtils::CXmlNode& node) void TransitionBase::fromXML(XmlUtils::CXmlNode& oNode)
{ {
std::wstring name = XmlUtils::GetNameNoNS(node.GetName()); std::wstring strName = oNode.GetName();
if (name == _T("random")) if ( strName == L"p:blinds" ||
base.reset(new Logic::EmptyTransition(node)); strName == L"p:checker" ||
else if (name == _T("circle")) strName == L"p:comb" ||
base.reset(new Logic::EmptyTransition(node)); strName == L"p:randomBar")
else if (name == _T("dissolve")) {
base.reset(new Logic::EmptyTransition(node));
else if (name == _T("diamond"))
base.reset(new Logic::EmptyTransition(node));
else if (name == _T("newsflash"))
base.reset(new Logic::EmptyTransition(node));
else if (name == _T("plus"))
base.reset(new Logic::EmptyTransition(node));
else if (name == _T("wedge"))
base.reset(new Logic::EmptyTransition(node));
else if (name == _T("blinds"))
base.reset(new Logic::OrientationTransition(node));
else if (name == _T("checker"))
base.reset(new Logic::OrientationTransition(node));
else if (name == _T("comb"))
base.reset(new Logic::OrientationTransition(node));
else if (name == _T("randomBar"))
base.reset(new Logic::OrientationTransition(node));
else if (name == _T("cover"))
base.reset(new Logic::EightDirectionTransition(node));
else if (name == _T("pull"))
base.reset(new Logic::EightDirectionTransition(node));
else if (name == _T("cut"))
base.reset(new Logic::OptionalBlackTransition(node));
else if (name == _T("fade"))
base.reset(new Logic::OptionalBlackTransition(node));
else if (name == _T("push"))
base.reset(new Logic::SideDirectionTransition(node));
else if (name == _T("wipe"))
base.reset(new Logic::SideDirectionTransition(node));
else if (name == _T("strips"))
base.reset(new Logic::CornerDirectionTransition(node));
else if (name == _T("wheel"))
base.reset(new Logic::WheelTransition(node));
else if (name == _T("split"))
base.reset(new Logic::SplitTransition(node));
else if (name == _T("zoom"))
base.reset(new Logic::ZoomTransition(node));
else base.reset();
}
void TransitionBase::GetTransitionTypeFrom(XmlUtils::CXmlNode& element)
{
XmlUtils::CXmlNode oNode;
if(element.GetNode(_T("p:random"), oNode))
base.reset(new Logic::EmptyTransition(oNode));
else if(element.GetNode(_T("p:circle"), oNode))
base.reset(new Logic::EmptyTransition(oNode));
else if(element.GetNode(_T("p:dissolve"), oNode))
base.reset(new Logic::EmptyTransition(oNode));
else if(element.GetNode(_T("p:diamond"), oNode))
base.reset(new Logic::EmptyTransition(oNode));
else if(element.GetNode(_T("p:newsflash"), oNode))
base.reset(new Logic::EmptyTransition(oNode));
else if(element.GetNode(_T("p:plus"), oNode))
base.reset(new Logic::EmptyTransition(oNode));
else if(element.GetNode(_T("p:wedge"), oNode))
base.reset(new Logic::EmptyTransition(oNode));
else if(element.GetNode(_T("p:blinds"), oNode))
base.reset(new Logic::OrientationTransition(oNode));
else if(element.GetNode(_T("p:checker"), oNode))
base.reset(new Logic::OrientationTransition(oNode));
else if(element.GetNode(_T("p:comb"), oNode))
base.reset(new Logic::OrientationTransition(oNode));
else if(element.GetNode(_T("p:randomBar"), oNode))
base.reset(new Logic::OrientationTransition(oNode)); base.reset(new Logic::OrientationTransition(oNode));
else if(element.GetNode(_T("p:cover"), oNode)) }
base.reset(new Logic::EightDirectionTransition(oNode)); else if ( strName == L"p:cover" ||
else if(element.GetNode(_T("p:pull"), oNode)) strName == L"p:pull")
{
base.reset(new Logic::EightDirectionTransition(oNode)); base.reset(new Logic::EightDirectionTransition(oNode));
else if(element.GetNode(_T("p:cut"), oNode)) }
base.reset(new Logic::OptionalBlackTransition(oNode)); else if ( strName == L"p:cut" ||
else if(element.GetNode(_T("p:fade"), oNode)) strName == L"p:fade")
{
base.reset(new Logic::OptionalBlackTransition(oNode)); base.reset(new Logic::OptionalBlackTransition(oNode));
else if(element.GetNode(_T("p:push"), oNode)) }
base.reset(new Logic::SideDirectionTransition(oNode)); else if ( strName == L"p:push" ||
else if(element.GetNode(_T("p:wipe"), oNode)) strName == L"p:wipe")
{
base.reset(new Logic::SideDirectionTransition(oNode)); base.reset(new Logic::SideDirectionTransition(oNode));
else if(element.GetNode(_T("p:strips"), oNode)) }
else if ( strName == L"p:strips")
{
base.reset(new Logic::CornerDirectionTransition(oNode)); base.reset(new Logic::CornerDirectionTransition(oNode));
else if(element.GetNode(_T("p:wheel"), oNode)) }
else if ( strName == L"p:wheel")
{
base.reset(new Logic::WheelTransition(oNode)); base.reset(new Logic::WheelTransition(oNode));
else if(element.GetNode(_T("p:split"), oNode)) }
else if ( strName == L"p:split")
{
base.reset(new Logic::SplitTransition(oNode)); base.reset(new Logic::SplitTransition(oNode));
else if(element.GetNode(_T("p:zoom"), oNode)) }
else if ( strName == L"p:zoom")
{
base.reset(new Logic::ZoomTransition(oNode)); base.reset(new Logic::ZoomTransition(oNode));
else base.reset(); }
else
{
base.reset(new Logic::EmptyTransition(oNode));
}
} }
std::wstring TransitionBase::toXML() const std::wstring TransitionBase::toXML() const
{ {
if (base.IsInit()) if (base.IsInit())
...@@ -189,25 +139,6 @@ namespace PPTX ...@@ -189,25 +139,6 @@ namespace PPTX
node.ReadAllAttributes(m_strAttributesNames, m_strAttributesValues); node.ReadAllAttributes(m_strAttributesNames, m_strAttributesValues);
} }
void TransitionSerialize::GetTransitionTypeFrom(XmlUtils::CXmlNode& element)
{
XmlUtils::CXmlNodes oNodes;
element.GetNodes(_T("*"), oNodes);
if (!oNodes.IsValid())
return;
int nCount = oNodes.GetCount();
if (1 == nCount)
{
XmlUtils::CXmlNode oNode;
oNodes.GetAt(0, oNode);
m_strNodeName = oNode.GetName();
oNode.ReadAllAttributes(m_strAttributesNames, m_strAttributesValues);
}
}
std::wstring TransitionSerialize::toXML() const std::wstring TransitionSerialize::toXML() const
{ {
return _T(""); return _T("");
......
...@@ -50,7 +50,6 @@ namespace PPTX ...@@ -50,7 +50,6 @@ namespace PPTX
const TransitionBase& operator =(XmlUtils::CXmlNode& node); const TransitionBase& operator =(XmlUtils::CXmlNode& node);
virtual void fromXML(XmlUtils::CXmlNode& node); virtual void fromXML(XmlUtils::CXmlNode& node);
virtual void GetTransitionTypeFrom(XmlUtils::CXmlNode& element);
virtual bool is_init()const{return (base.IsInit());}; virtual bool is_init()const{return (base.IsInit());};
template<class T> const bool is() const { return base.is<T>(); } template<class T> const bool is() const { return base.is<T>(); }
...@@ -75,7 +74,6 @@ namespace PPTX ...@@ -75,7 +74,6 @@ namespace PPTX
public: public:
TransitionSerialize() TransitionSerialize()
{ {
m_strNodeName = _T("");
} }
virtual ~TransitionSerialize() virtual ~TransitionSerialize()
{ {
...@@ -94,10 +92,7 @@ namespace PPTX ...@@ -94,10 +92,7 @@ namespace PPTX
m_strAttributesValues = src.m_strAttributesValues; m_strAttributesValues = src.m_strAttributesValues;
return *this; return *this;
} }
public:
virtual void fromXML(XmlUtils::CXmlNode& node); virtual void fromXML(XmlUtils::CXmlNode& node);
virtual void GetTransitionTypeFrom(XmlUtils::CXmlNode& element);
virtual std::wstring toXML() const; virtual std::wstring toXML() const;
...@@ -253,8 +248,9 @@ namespace PPTX ...@@ -253,8 +248,9 @@ namespace PPTX
pWriter->EndNode(name); pWriter->EndNode(name);
} }
public:
std::wstring m_strNodeName; std::wstring m_strNodeName;
std::list<std::wstring> m_strAttributesNames; std::list<std::wstring> m_strAttributesNames;
std::list<std::wstring> m_strAttributesValues; std::list<std::wstring> m_strAttributesValues;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment