Commit d3f4a212 authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormat, PptxFormat - presentation transitions

parent 4d5f328c
......@@ -183,8 +183,6 @@ namespace DocFileFormat
int cc = 0;
std::vector<PathSegment>::const_iterator end = m_arSegments.end();
for (std::vector<PathSegment>::const_iterator iter = m_arSegments.begin(); iter != end; ++iter, cc++)
{
try
{
switch (iter->Type)
{
......@@ -192,7 +190,7 @@ namespace DocFileFormat
{
for (int i = 0; i < iter->Count; ++i)
{
if (valuePointer >= (int)m_arPoints.size())
if (valuePointer + 1 > (int)m_arPoints.size())
{
break;
......@@ -222,6 +220,8 @@ namespace DocFileFormat
{
for (int i = 0; i < iter->Count; ++i)
{
if (valuePointer + 3 > (int)m_arPoints.size())
break;
strVmlPath += L"c";
strVmlPath += FormatUtils::IntToWideString(m_arPoints[valuePointer].x );
strVmlPath += L",";
......@@ -240,6 +240,8 @@ namespace DocFileFormat
break;
case PathSegment::msopathMoveTo:
{
if (valuePointer < (int)m_arPoints.size())
{
strVmlPath += L"m";
strVmlPath += FormatUtils::IntToWideString(m_arPoints[valuePointer].x );
......@@ -248,6 +250,7 @@ namespace DocFileFormat
++valuePointer;
}
}
break;
case PathSegment::msopathClose:
......@@ -278,13 +281,6 @@ namespace DocFileFormat
break;
}
}
catch (...)
{
// Sometimes there are more Segments than available m_arPoints.
// Accordingly to the spec this should never happen :)
break;
}
}
// end the path
if ( !strVmlPath.empty() && ( strVmlPath[strVmlPath.size() - 1] != L'e' ) )
......
......@@ -33,9 +33,6 @@
#include "mediaitems.h"
#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>
......@@ -92,12 +89,18 @@ std::wstring static get_default_file_name(RelsType type)
return L"image";
case typeChart:
return L"chart";
case typeMedia:
return L"media";
case typeMsObject:
return L"msObject";
case typeOleObject:
return L"oleObject";
case typeMedia:
return L"media";
case typeSlide:
return L"slide";
case typeVideo:
return L"video";
case typeAudio:
return L"audio";
default:
return L"";
}
......@@ -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;
}
std::wstring mediaitems::detectImageFileExtension(std::wstring &fileName)
std::wstring mediaitems::detectImageFileExtension(const std::wstring &fileName)
{
CFile file;
......@@ -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 == typeShape) number = count_shape + 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 ||
type == typeOleObject) number = count_object + 1;
else
......@@ -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);
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
{
id = std::wstring(L"rId") + std::to_wstring(count_shape + 1);
......
......@@ -31,11 +31,10 @@
*/
#pragma once
#include <vector>
#include <string>
#include "oox_rels.h"
#include "../../../Common/DocxFormat/Source/XML/utils.h"
namespace cpdoccore {
namespace oox {
......@@ -50,6 +49,9 @@ public:
count_tables = 0;
count_media = 0;
count_object = 0;
count_audio = 0;
count_video = 0;
count_slide = 0;
}
struct item
......@@ -74,6 +76,9 @@ public:
size_t count_charts;
size_t count_image;
size_t count_media;
size_t count_audio;
size_t count_video;
size_t count_slide;
size_t count_shape;
size_t count_tables;
size_t count_object;
......@@ -93,7 +98,7 @@ public:
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";
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 typeVideo: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/video";
case typeSlide: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide";
......@@ -101,9 +106,33 @@ public:
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:
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_;
std::wstring odf_packet_;
......
......@@ -527,13 +527,22 @@ 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:a", L"http://schemas.openxmlformats.org/drawingml/2006/main");
CP_XML_ATTR(L"r:id", val.hId);
if (!val.action.empty())
CP_XML_ATTR(L"action", val.action);
if (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 {
enabled = false;
highlightClick = false;
hSoundId.clear();
hSoundRef.clear();
hId.clear();
hRef.clear();
action.clear();
}
bool enabled;
std::wstring action;
std::wstring hSoundId;
std::wstring hSoundRef;
std::wstring hId;
std::wstring hRef;
std::wstring action;
RelsType typeRels;
bool highlightClick;
......@@ -95,6 +102,8 @@ namespace oox {
std::wstring objectId;
std::wstring objectProgId;
std::wstring extId;
_action_desc action;
std::vector<_hlink_desc> hlinks;
......
......@@ -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"tiff" == extension) return L"image/x-tiff";
else if (L"pdf" == extension) return L"application/pdf";
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"xlsx" == extension) return L"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
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)
{
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)
return true;
......@@ -158,14 +169,18 @@ bool content_types_file::add_or_find_override(const std::wstring & fileName)
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)
{
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)
NSDirectory::CreateDirectory(path.c_str());
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_out = RootPath + FILE_SEPARATOR_STR + items[i].outputName;
......@@ -359,7 +377,7 @@ void embeddings::write(const std::wstring & RootPath)
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++ )
for (size_t i = 0; i < items.size(); i++ )
{
if ( items[i].mediaInternal && items[i].valid &&
(items[i].type == typeMsObject || items[i].type == typeOleObject))
......
......@@ -130,11 +130,31 @@ void pptx_serialize_media(std::wostream & strm, _pptx_drawing & val)
}
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_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);
}
}
}
}
}
if (val.fill.bitmap)
val.fill.bitmap->name_space = L"p";
......@@ -359,12 +379,11 @@ void _pptx_drawing::serialize(std::wostream & strm)
{
pptx_serialize_table(strm, *this);
}
else if (type == typeMsObject ||
type == typeOleObject)
else if (type == typeMsObject || type == typeOleObject)
{
pptx_serialize_object(strm, *this);
}
else if (type == typeMedia)
else if (type == typeMedia || type == typeAudio || type == typeVideo )
{
pptx_serialize_media(strm, *this);
}
......
......@@ -71,7 +71,8 @@ public:
}
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:
}
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,
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")) );
mediaitems::get_rel_type(pptx_drawing_rels_[i].type), ref, (pptx_drawing_rels_[i].is_internal ? L"" : L"External")) );
}
}
}
......
......@@ -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)
{
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)
......
......@@ -60,6 +60,7 @@ public:
_CP_OPT(std::wstring) Speed;
_CP_OPT(int) Time;
_CP_OPT(int) PageTime;
_CP_OPT(std::wstring) Dir;
_CP_OPT(std::wstring) Param;
bool onClick;
......@@ -135,6 +136,7 @@ private:
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);
void process_media (drawing_object_description& obj, _pptx_drawing & drawing);
size_t rId_;
mediaitems mediaitems_;
......@@ -160,7 +162,7 @@ void pptx_slide_context::Impl::process_drawings()
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 typeMedia:
case typeMedia: process_media(objects_[i], drawing); break;
case typeMsObject:
case typeOleObject: process_object(objects_[i], drawing); break;
}
......@@ -369,6 +371,7 @@ void pptx_slide_context::start_action(std::wstring action)
if (action == L"sound")
{
impl_->object_description_.action_.action = L"ppaction://noaction";
impl_->object_description_.action_.typeRels = typeAudio;
impl_->object_description_.action_.highlightClick = true;
}
......@@ -403,18 +406,29 @@ void pptx_slide_context::start_action(std::wstring action)
void pptx_slide_context::set_link(std::wstring link, RelsType typeRels)
{
++hlinks_size_;
std::wstring hId = L"hId" + std::to_wstring(hlinks_size_);
impl_->object_description_.action_.highlightClick = true;
if (typeRels == typeAudio)
{
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_.highlightClick = true;
impl_->object_description_.action_.hId = hId;
impl_->object_description_.action_.hRef = link;
impl_->object_description_.action_.typeRels = typeRels;
}
}
void pptx_slide_context::end_action()
{
......@@ -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);
}
}
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)
{
if (pic.svg_rect_)
......@@ -714,7 +747,11 @@ void pptx_slide_context::serialize_animations(std::wostream & strm)
}
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);
......@@ -738,9 +775,22 @@ void pptx_slide_context::serialize_animations(std::wostream & strm)
//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)
void draw_plugin::pptx_convert(oox::pptx_conversion_context & Context)
{
// 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().set_media(href);
////params
// for (size_t i = 0; i < content_.size(); i++)
// {
// content_[i]->pptx_convert(Context);
// }
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().set_media(href);
//params
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->pptx_convert(Context);
}
}
}
}
......
......@@ -161,10 +161,10 @@ struct anchor_settings
enum _drawing_part
{
Unknown=0,
Area,
Line,
Shadow
Unknown = 0,
Area = 1,
Line = 2,
Shadow = 3
};
struct odf_drawing_state
{
......@@ -192,6 +192,7 @@ struct odf_drawing_state
view_box_ = L"";
path_last_command_ = L"";
replacement_ = L"";
oox_shape_preset_ = -1;
oox_shape_.reset();
......@@ -222,12 +223,12 @@ struct odf_drawing_state
_CP_OPT(presentation_class) presentation_class_;
_CP_OPT(std::wstring) presentation_placeholder_;
std::wstring replacement_;
std::wstring path_;
std::wstring view_box_;
std::wstring path_last_command_;
oox_shape_ptr oox_shape_;
///////////////////////
//----------------------------------------------------------
int oox_shape_preset_;
bool in_group_;
bool text_box_tableframe_;
......@@ -236,7 +237,7 @@ struct odf_drawing_state
class odf_drawing_context::Impl
{
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();
styles_context_ = odf_context_->styles_context();
......@@ -250,7 +251,7 @@ public:
is_header_ = false;
is_footer_ = false;
is_background_ = false;
//некоторые свойства для объектов графики не поддерживаюися в редакторах Liber && OpenOffice.net
//некоторые свойства для объектов графики не поддерживаюися в редакторах Libre && OpenOffice.net
//в MS Office и в нашем - проблем таких нет.
}
......@@ -295,8 +296,7 @@ public:
};
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------------------------
odf_drawing_context::odf_drawing_context(odf_conversion_context *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
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);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//вложенные элементы
//------------------------------------------------------------------------------------------------------------------
void odf_drawing_context::start_image(std::wstring odf_path)
{
if (impl_->is_footer_ || impl_->is_header_ || impl_->is_background_)
......@@ -2359,9 +2357,31 @@ void odf_drawing_context::start_media(std::wstring name)
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()
{
end_element();
add_image_replacement();
end_frame();
}
void odf_drawing_context::start_text_box()
......@@ -2476,6 +2496,8 @@ void odf_drawing_context::add_sound(std::wstring href)
if (event_)
{
event_->attlist_.script_event_name_ = L"dom:click";
if (!event_->attlist_.presentation_action_)
event_->attlist_.presentation_action_ = L"sound";
}
......@@ -2619,6 +2641,36 @@ void odf_drawing_context::end_object()
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()
{
......
......@@ -141,12 +141,18 @@ public:
void set_text_box_tableframe (bool val);
void end_text_box ();
void start_object(std::wstring name);
void start_object(std::wstring ref); //формулы, диаграммы ...
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 add_image_replacement();
void set_image_replacement(std::wstring ref);
bool isLineShape();
void corrected_line_fill();
......
......@@ -84,6 +84,12 @@ void odp_page_state::set_page_name(std::wstring 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)
{
......@@ -224,6 +230,14 @@ void odp_page_state::set_transition_subtype(std::wstring val)
if (trans)
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)
{
if (transactions.empty()) return;
......
......@@ -73,6 +73,7 @@ public:
void set_page_name (std::wstring name);
void set_page_id (int id);
void set_page_style (office_element_ptr & _style);
void set_page_duration (int id);
void set_master_page(std::wstring name);
void set_layout_page(std::wstring name);
......@@ -107,6 +108,7 @@ public:
void start_transition();
void set_transition_type (int val);
void set_transition_subtype (std::wstring val);
void set_transition_direction(std::wstring val);
void set_transition_speed (int val);
void set_transition_duration(int val);
void set_transition_sound (std::wstring ref, bool loop);
......
......@@ -119,7 +119,7 @@ public:
_CP_OPT(bool) presentation_display_page_number_;
_CP_OPT(bool) presentation_display_date_time_;
_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_;
......
......@@ -202,6 +202,25 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
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())
{
......@@ -226,42 +245,36 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
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
OoxConverter::convert(&oox_picture->nvPicPr.cNvPr);
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();
return;
}
}
}
//--------------------------------------------------------------------------------------
std::wstring odf_ref;
std::wstring pathImage;
if (oox_picture->blipFill.blip.IsInit())
if (oox_picture->oleObject.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 = odf_context()->add_image(pathImage);
}
else if (oox_picture->blipFill.blip->link.IsInit())
{
odf_ref = oox_picture->blipFill.blip->link->get();
bEmbedded = false;
//nullable_limit<Limit::OLEDrawAspectType>m_oDrawAspect;
//nullable<OOX::RId> m_oId;
//nullable_string m_sObjectId;
//nullable_string m_sProgId;
//nullable_string m_sShapeId;
//nullable_limit<Limit::OLEType> m_oType;
//nullable_limit<Limit::OLEUpdateMode> m_oUpdateMode;
}
}
odf_context()->drawing_context()->start_image(odf_ref);
//--------------------------------------------------------------------------------------
odf_context()->drawing_context()->start_image(odf_ref_image);
{
double Width = 0, Height = 0;
_graphics_utils_::GetResolution(pathImage.c_str(), Width, Height);
......
......@@ -544,13 +544,23 @@ void PptxConverter::convert(PPTX::Comments *oox_comments)
void PptxConverter::convert( PPTX::Logic::Transition *oox_transition )
{
if (!oox_transition) 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();
if (oox_transition->spd.is_init())
{
odp_context->current_slide().set_transition_speed(oox_transition->spd->GetBYTECode());
}
if (oox_transition->dur.is_init())
{
odp_context->current_slide().set_transition_duration(*oox_transition->dur);
}
convert(oox_transition->base.base.operator->());
......@@ -606,27 +616,47 @@ void PptxConverter::convert(PPTX::Logic::EmptyTransition *oox_transition)
if (oox_transition->name == L"random")
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_subtype(L"circle");
}
if (oox_transition->name == L"dissolve")
else if (oox_transition->name == L"dissolve")
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_subtype(L"diamond");
}
if (oox_transition->name == L"newsflash")
odp_context->current_slide().set_transition_type(24);
if (oox_transition->name == L"plus")
else if (oox_transition->name == L"newsflash")
odp_context->current_slide().set_transition_type(24); //fanWipe
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");
}
if (oox_transition->name == L"wedge")
odp_context->current_slide().set_transition_type(24);
else if (oox_transition->name == L"wedge")
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)
{
......
......@@ -48,7 +48,6 @@ namespace PPTX
public:
PPTX_LOGIC_BASE(Transition)
public:
virtual void fromXML(XmlUtils::CXmlNode& node)
{
node.ReadAttributeBase(L"advClick", advClick);
......@@ -56,9 +55,29 @@ namespace PPTX
node.ReadAttributeBase(L"p14:dur", dur);
node.ReadAttributeBase(L"spd", spd);
base.GetTransitionTypeFrom(node);
trSerialize.GetTransitionTypeFrom(node);
sndAc = node.ReadNode(_T("p:sndAc"));
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());
if (strName == L"sndAc")
sndAc = oNode;
else
{
trSerialize.fromXML(oNode);
base.fromXML(oNode);
}
}
}
FillParentPointersForChilds();
}
......@@ -136,7 +155,6 @@ namespace PPTX
}
}
}
pReader->Seek(end);
}
......@@ -174,9 +192,7 @@ namespace PPTX
pWriter->WriteString(_T("</mc:Fallback></mc:AlternateContent>"));
}
public:
/*nullable<*/TransitionBase/*>*/ base;
TransitionBase base;
nullable<SndAc> sndAc;
TransitionSerialize trSerialize;
......
......@@ -66,103 +66,53 @@ namespace PPTX
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"))
base.reset(new Logic::EmptyTransition(node));
else if (name == _T("circle"))
base.reset(new Logic::EmptyTransition(node));
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)
if ( strName == L"p:blinds" ||
strName == L"p:checker" ||
strName == L"p:comb" ||
strName == L"p:randomBar")
{
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));
else if(element.GetNode(_T("p:cover"), oNode))
base.reset(new Logic::EightDirectionTransition(oNode));
else if(element.GetNode(_T("p:pull"), oNode))
}
else if ( strName == L"p:cover" ||
strName == L"p:pull")
{
base.reset(new Logic::EightDirectionTransition(oNode));
else if(element.GetNode(_T("p:cut"), oNode))
base.reset(new Logic::OptionalBlackTransition(oNode));
else if(element.GetNode(_T("p:fade"), oNode))
}
else if ( strName == L"p:cut" ||
strName == L"p:fade")
{
base.reset(new Logic::OptionalBlackTransition(oNode));
else if(element.GetNode(_T("p:push"), oNode))
base.reset(new Logic::SideDirectionTransition(oNode));
else if(element.GetNode(_T("p:wipe"), oNode))
}
else if ( strName == L"p:push" ||
strName == L"p:wipe")
{
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));
else if(element.GetNode(_T("p:wheel"), oNode))
}
else if ( strName == L"p:wheel")
{
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));
else if(element.GetNode(_T("p:zoom"), oNode))
}
else if ( strName == L"p:zoom")
{
base.reset(new Logic::ZoomTransition(oNode));
else base.reset();
}
else
{
base.reset(new Logic::EmptyTransition(oNode));
}
}
std::wstring TransitionBase::toXML() const
{
if (base.IsInit())
......@@ -189,25 +139,6 @@ namespace PPTX
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
{
return _T("");
......
......@@ -50,7 +50,6 @@ namespace PPTX
const TransitionBase& operator =(XmlUtils::CXmlNode& node);
virtual void fromXML(XmlUtils::CXmlNode& node);
virtual void GetTransitionTypeFrom(XmlUtils::CXmlNode& element);
virtual bool is_init()const{return (base.IsInit());};
template<class T> const bool is() const { return base.is<T>(); }
......@@ -75,7 +74,6 @@ namespace PPTX
public:
TransitionSerialize()
{
m_strNodeName = _T("");
}
virtual ~TransitionSerialize()
{
......@@ -94,10 +92,7 @@ namespace PPTX
m_strAttributesValues = src.m_strAttributesValues;
return *this;
}
public:
virtual void fromXML(XmlUtils::CXmlNode& node);
virtual void GetTransitionTypeFrom(XmlUtils::CXmlNode& element);
virtual std::wstring toXML() const;
......@@ -253,8 +248,9 @@ namespace PPTX
pWriter->EndNode(name);
}
public:
std::wstring m_strNodeName;
std::list<std::wstring> m_strAttributesNames;
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