mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
tmRoot par animation test
This commit is contained in:
@ -32,7 +32,6 @@
|
|||||||
|
|
||||||
#include "pptx_animation_context.h"
|
#include "pptx_animation_context.h"
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <xml/simple_xml_writer.h>
|
#include <xml/simple_xml_writer.h>
|
||||||
|
|
||||||
#include "../../DataTypes/clockvalue.h"
|
#include "../../DataTypes/clockvalue.h"
|
||||||
@ -40,227 +39,23 @@
|
|||||||
namespace cpdoccore {
|
namespace cpdoccore {
|
||||||
namespace oox {
|
namespace oox {
|
||||||
|
|
||||||
class pptx_animation_context::Impl
|
pptx_animation_context::Impl::Impl()
|
||||||
{
|
{
|
||||||
public:
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
struct _animation_element;
|
void pptx_animation_context::Impl::clear()
|
||||||
typedef shared_ptr<_animation_element>::Type _animation_element_ptr;
|
{
|
||||||
typedef std::vector<_animation_element_ptr> _animation_element_array;
|
par_animation_levels_.clear();
|
||||||
struct _animation_element
|
root_animation_element_ = nullptr;
|
||||||
{
|
animate_motion_description_ = nullptr;
|
||||||
virtual void serialize(std::wostream& strm) = 0;
|
set_description_ = nullptr;
|
||||||
};
|
anim_effect_description_ = nullptr;
|
||||||
|
anim_description_ = nullptr;
|
||||||
struct _par_animation;
|
anim_clr_description_ = nullptr;
|
||||||
typedef shared_ptr<_par_animation>::Type _par_animation_ptr;
|
anim_scale_description_ = nullptr;
|
||||||
typedef std::vector<_par_animation_ptr> _par_animation_array;
|
anim_rotate_description_ = nullptr;
|
||||||
|
}
|
||||||
struct _seq_animation;
|
|
||||||
typedef shared_ptr<_seq_animation>::Type _seq_animation_ptr;
|
|
||||||
typedef std::vector<_seq_animation_ptr> _seq_animation_array;
|
|
||||||
|
|
||||||
struct _par_animation : _animation_element
|
|
||||||
{
|
|
||||||
_CP_OPT(std::wstring) NodeType;
|
|
||||||
_CP_OPT(std::wstring) Direction;
|
|
||||||
_CP_OPT(std::wstring) Restart;
|
|
||||||
_CP_OPT(int) Duration; // in ms
|
|
||||||
_CP_OPT(std::wstring) Delay;
|
|
||||||
_CP_OPT(std::wstring) End;
|
|
||||||
_CP_OPT(std::wstring) PresetClass;
|
|
||||||
_CP_OPT(int) PresetID;
|
|
||||||
|
|
||||||
_par_animation_array AnimParArray;
|
|
||||||
_seq_animation_ptr AnimSeq;
|
|
||||||
_animation_element_array AnimationActionArray;
|
|
||||||
|
|
||||||
void serialize(std::wostream & strm) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _seq_animation : _animation_element
|
|
||||||
{
|
|
||||||
_CP_OPT(std::wstring) PresentationNodeType;
|
|
||||||
_CP_OPT(std::wstring) Direction;
|
|
||||||
_CP_OPT(std::wstring) Restart;
|
|
||||||
_CP_OPT(int) Duration; // in ms
|
|
||||||
_CP_OPT(std::wstring) Delay;
|
|
||||||
_CP_OPT(std::wstring) End;
|
|
||||||
|
|
||||||
_par_animation_array AnimParArray;
|
|
||||||
|
|
||||||
void serialize(std::wostream& strm) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _set;
|
|
||||||
typedef shared_ptr<_set>::Type _set_ptr;
|
|
||||||
struct _set : _animation_element
|
|
||||||
{
|
|
||||||
_CP_OPT(std::wstring) Direction;
|
|
||||||
_CP_OPT(std::wstring) Restart;
|
|
||||||
_CP_OPT(int) Duration; // in ms
|
|
||||||
_CP_OPT(std::wstring) Delay;
|
|
||||||
_CP_OPT(std::wstring) End;
|
|
||||||
_CP_OPT(std::wstring) Fill;
|
|
||||||
_CP_OPT(size_t) ShapeID;
|
|
||||||
_CP_OPT(std::wstring) AttributeName;
|
|
||||||
_CP_OPT(std::wstring) ToValue;
|
|
||||||
|
|
||||||
void serialize(std::wostream& strm) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _anim_effect;
|
|
||||||
typedef shared_ptr<_anim_effect>::Type _anim_effect_ptr;
|
|
||||||
struct _anim_effect : _animation_element
|
|
||||||
{
|
|
||||||
_CP_OPT(std::wstring) Filter;
|
|
||||||
_CP_OPT(std::wstring) Transition;
|
|
||||||
_CP_OPT(int) Duration; // in ms
|
|
||||||
_CP_OPT(size_t) ShapeID;
|
|
||||||
|
|
||||||
void serialize(std::wostream & strm) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _animate_motion;
|
|
||||||
typedef shared_ptr<_animate_motion>::Type _animate_motion_ptr;
|
|
||||||
typedef std::vector<_animate_motion_ptr> _animate_motion_array;
|
|
||||||
struct _animate_motion : _animation_element
|
|
||||||
{
|
|
||||||
_CP_OPT(std::wstring) PresentationNodeType;
|
|
||||||
_CP_OPT(std::wstring) SmilDirection;
|
|
||||||
_CP_OPT(std::wstring) SmilRestart;
|
|
||||||
_CP_OPT(int) SmilDurMs;
|
|
||||||
_CP_OPT(std::wstring) SmilBegin;
|
|
||||||
_CP_OPT(std::wstring) SmilEnd;
|
|
||||||
|
|
||||||
_CP_OPT(std::wstring) SmilFill;
|
|
||||||
_CP_OPT(std::wstring) AnimSubItem;
|
|
||||||
_CP_OPT(size_t) ShapeID;
|
|
||||||
_CP_OPT(std::wstring) SvgPath;
|
|
||||||
|
|
||||||
void serialize(std::wostream & strm) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _anim_clr;
|
|
||||||
typedef shared_ptr<_anim_clr>::Type _anim_clr_ptr;
|
|
||||||
struct _anim_clr : _animation_element
|
|
||||||
{
|
|
||||||
_CP_OPT(std::wstring) PresentationNodeType;
|
|
||||||
_CP_OPT(std::wstring) Direction;
|
|
||||||
_CP_OPT(std::wstring) Restart;
|
|
||||||
_CP_OPT(int) Duration; // in ms
|
|
||||||
_CP_OPT(std::wstring) Begin;
|
|
||||||
_CP_OPT(std::wstring) End;
|
|
||||||
|
|
||||||
_CP_OPT(std::wstring) Fill;
|
|
||||||
_CP_OPT(size_t) ShapeID;
|
|
||||||
_CP_OPT(std::wstring) AttributeName;
|
|
||||||
_CP_OPT(std::wstring) Delay;
|
|
||||||
_CP_OPT(std::wstring) ToValue;
|
|
||||||
_CP_OPT(std::wstring) ColorSpace;
|
|
||||||
|
|
||||||
void serialize(std::wostream& strm) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _anim;
|
|
||||||
typedef shared_ptr<_anim>::Type _anim_ptr;
|
|
||||||
struct _anim : _animation_element
|
|
||||||
{
|
|
||||||
struct _keypoint
|
|
||||||
{
|
|
||||||
int Time;
|
|
||||||
std::wstring Value;
|
|
||||||
_CP_OPT(std::wstring) Fmla; // Formula
|
|
||||||
|
|
||||||
_keypoint(int time, const std::wstring& value, _CP_OPT(std::wstring) formula)
|
|
||||||
: Time(time), Value(value), Fmla(formula)
|
|
||||||
{}
|
|
||||||
};
|
|
||||||
|
|
||||||
_CP_OPT(std::wstring) CalcMode;
|
|
||||||
_CP_OPT(std::wstring) ValueType;
|
|
||||||
_CP_OPT(size_t) ShapeID;
|
|
||||||
_CP_OPT(int) Duration; // in ms
|
|
||||||
_CP_OPT(std::wstring) AttributeName;
|
|
||||||
_CP_OPT(std::wstring) From;
|
|
||||||
_CP_OPT(std::wstring) To;
|
|
||||||
_CP_OPT(std::wstring) By;
|
|
||||||
_CP_OPT(std::wstring) Additive;
|
|
||||||
_CP_OPT(bool) AutoReverse;
|
|
||||||
_CP_OPT(std::wstring) Delay;
|
|
||||||
_CP_OPT(std::vector<_keypoint>) KeypointArray;
|
|
||||||
|
|
||||||
void serialize(std::wostream& strm) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _anim_scale;
|
|
||||||
typedef shared_ptr<_anim_scale>::Type _anim_scale_ptr;
|
|
||||||
struct _anim_scale : _animation_element
|
|
||||||
{
|
|
||||||
struct vec2
|
|
||||||
{
|
|
||||||
int x, y;
|
|
||||||
|
|
||||||
vec2(int x, int y)
|
|
||||||
: x(x), y(y)
|
|
||||||
{}
|
|
||||||
};
|
|
||||||
|
|
||||||
_CP_OPT(size_t) ShapeID;
|
|
||||||
_CP_OPT(int) Duration; // in ms
|
|
||||||
_CP_OPT(std::wstring) Fill;
|
|
||||||
_CP_OPT(vec2) From;
|
|
||||||
_CP_OPT(vec2) To;
|
|
||||||
//_CP_OPT(std::wstring) By;
|
|
||||||
_CP_OPT(std::wstring) Delay;
|
|
||||||
_CP_OPT(bool) AutoReverse;
|
|
||||||
|
|
||||||
void serialize(std::wostream& strm) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _anim_rotate;
|
|
||||||
typedef shared_ptr<_anim_rotate>::Type _anim_rotate_ptr;
|
|
||||||
struct _anim_rotate : _animation_element
|
|
||||||
{
|
|
||||||
_CP_OPT(size_t) ShapeID;
|
|
||||||
_CP_OPT(int) Duration; // in ms
|
|
||||||
_CP_OPT(std::wstring) Fill;
|
|
||||||
_CP_OPT(int) By;
|
|
||||||
_CP_OPT(std::wstring) Delay;
|
|
||||||
_CP_OPT(bool) AutoReverse;
|
|
||||||
|
|
||||||
void serialize(std::wostream& strm) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
_par_animation_ptr root_animation_element_;
|
|
||||||
_par_animation_array par_animation_levels_;
|
|
||||||
|
|
||||||
_animate_motion_ptr animate_motion_description_;
|
|
||||||
_set_ptr set_description_;
|
|
||||||
_anim_effect_ptr anim_effect_description_;
|
|
||||||
_anim_ptr anim_description_;
|
|
||||||
_anim_clr_ptr anim_clr_description_;
|
|
||||||
_anim_scale_ptr anim_scale_description_;
|
|
||||||
_anim_rotate_ptr anim_rotate_description_;
|
|
||||||
|
|
||||||
void clear()
|
|
||||||
{
|
|
||||||
par_animation_levels_.clear();
|
|
||||||
root_animation_element_ = nullptr;
|
|
||||||
animate_motion_description_ = nullptr;
|
|
||||||
set_description_ = nullptr;
|
|
||||||
anim_effect_description_ = nullptr;
|
|
||||||
anim_description_ = nullptr;
|
|
||||||
anim_clr_description_ = nullptr;
|
|
||||||
anim_scale_description_ = nullptr;
|
|
||||||
anim_rotate_description_ = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
Impl()
|
|
||||||
{
|
|
||||||
clear();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
pptx_animation_context::pptx_animation_context()
|
pptx_animation_context::pptx_animation_context()
|
||||||
: impl_(new pptx_animation_context::Impl())
|
: impl_(new pptx_animation_context::Impl())
|
||||||
@ -865,6 +660,11 @@ namespace oox {
|
|||||||
impl_->clear();
|
impl_->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const pptx_animation_context::Impl::_par_animation_ptr& pptx_animation_context::get_root_par_animation() const
|
||||||
|
{
|
||||||
|
return impl_->root_animation_element_;
|
||||||
|
}
|
||||||
|
|
||||||
void pptx_animation_context::Impl::_par_animation::serialize(std::wostream& strm)
|
void pptx_animation_context::Impl::_par_animation::serialize(std::wostream& strm)
|
||||||
{
|
{
|
||||||
CP_XML_WRITER(strm)
|
CP_XML_WRITER(strm)
|
||||||
|
|||||||
@ -32,6 +32,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
#include <CPSharedPtr.h>
|
#include <CPSharedPtr.h>
|
||||||
#include <CPOptional.h>
|
#include <CPOptional.h>
|
||||||
|
|
||||||
@ -40,6 +41,214 @@ namespace oox {
|
|||||||
|
|
||||||
class pptx_animation_context
|
class pptx_animation_context
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
class Impl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
struct _animation_element;
|
||||||
|
typedef shared_ptr<_animation_element>::Type _animation_element_ptr;
|
||||||
|
typedef std::vector<_animation_element_ptr> _animation_element_array;
|
||||||
|
struct _animation_element
|
||||||
|
{
|
||||||
|
virtual void serialize(std::wostream& strm) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _par_animation;
|
||||||
|
typedef shared_ptr<_par_animation>::Type _par_animation_ptr;
|
||||||
|
typedef std::vector<_par_animation_ptr> _par_animation_array;
|
||||||
|
|
||||||
|
struct _seq_animation;
|
||||||
|
typedef shared_ptr<_seq_animation>::Type _seq_animation_ptr;
|
||||||
|
typedef std::vector<_seq_animation_ptr> _seq_animation_array;
|
||||||
|
|
||||||
|
struct _par_animation : _animation_element
|
||||||
|
{
|
||||||
|
_CP_OPT(std::wstring) NodeType;
|
||||||
|
_CP_OPT(std::wstring) Direction;
|
||||||
|
_CP_OPT(std::wstring) Restart;
|
||||||
|
_CP_OPT(int) Duration; // in ms
|
||||||
|
_CP_OPT(std::wstring) Delay;
|
||||||
|
_CP_OPT(std::wstring) End;
|
||||||
|
_CP_OPT(std::wstring) PresetClass;
|
||||||
|
_CP_OPT(int) PresetID;
|
||||||
|
|
||||||
|
_par_animation_array AnimParArray;
|
||||||
|
_seq_animation_ptr AnimSeq;
|
||||||
|
_animation_element_array AnimationActionArray;
|
||||||
|
|
||||||
|
void serialize(std::wostream& strm) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _seq_animation : _animation_element
|
||||||
|
{
|
||||||
|
_CP_OPT(std::wstring) PresentationNodeType;
|
||||||
|
_CP_OPT(std::wstring) Direction;
|
||||||
|
_CP_OPT(std::wstring) Restart;
|
||||||
|
_CP_OPT(int) Duration; // in ms
|
||||||
|
_CP_OPT(std::wstring) Delay;
|
||||||
|
_CP_OPT(std::wstring) End;
|
||||||
|
|
||||||
|
_par_animation_array AnimParArray;
|
||||||
|
|
||||||
|
void serialize(std::wostream& strm) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _set;
|
||||||
|
typedef shared_ptr<_set>::Type _set_ptr;
|
||||||
|
struct _set : _animation_element
|
||||||
|
{
|
||||||
|
_CP_OPT(std::wstring) Direction;
|
||||||
|
_CP_OPT(std::wstring) Restart;
|
||||||
|
_CP_OPT(int) Duration; // in ms
|
||||||
|
_CP_OPT(std::wstring) Delay;
|
||||||
|
_CP_OPT(std::wstring) End;
|
||||||
|
_CP_OPT(std::wstring) Fill;
|
||||||
|
_CP_OPT(size_t) ShapeID;
|
||||||
|
_CP_OPT(std::wstring) AttributeName;
|
||||||
|
_CP_OPT(std::wstring) ToValue;
|
||||||
|
|
||||||
|
void serialize(std::wostream& strm) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _anim_effect;
|
||||||
|
typedef shared_ptr<_anim_effect>::Type _anim_effect_ptr;
|
||||||
|
struct _anim_effect : _animation_element
|
||||||
|
{
|
||||||
|
_CP_OPT(std::wstring) Filter;
|
||||||
|
_CP_OPT(std::wstring) Transition;
|
||||||
|
_CP_OPT(int) Duration; // in ms
|
||||||
|
_CP_OPT(size_t) ShapeID;
|
||||||
|
|
||||||
|
void serialize(std::wostream& strm) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _animate_motion;
|
||||||
|
typedef shared_ptr<_animate_motion>::Type _animate_motion_ptr;
|
||||||
|
typedef std::vector<_animate_motion_ptr> _animate_motion_array;
|
||||||
|
struct _animate_motion : _animation_element
|
||||||
|
{
|
||||||
|
_CP_OPT(std::wstring) PresentationNodeType;
|
||||||
|
_CP_OPT(std::wstring) SmilDirection;
|
||||||
|
_CP_OPT(std::wstring) SmilRestart;
|
||||||
|
_CP_OPT(int) SmilDurMs;
|
||||||
|
_CP_OPT(std::wstring) SmilBegin;
|
||||||
|
_CP_OPT(std::wstring) SmilEnd;
|
||||||
|
|
||||||
|
_CP_OPT(std::wstring) SmilFill;
|
||||||
|
_CP_OPT(std::wstring) AnimSubItem;
|
||||||
|
_CP_OPT(size_t) ShapeID;
|
||||||
|
_CP_OPT(std::wstring) SvgPath;
|
||||||
|
|
||||||
|
void serialize(std::wostream& strm) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _anim_clr;
|
||||||
|
typedef shared_ptr<_anim_clr>::Type _anim_clr_ptr;
|
||||||
|
struct _anim_clr : _animation_element
|
||||||
|
{
|
||||||
|
_CP_OPT(std::wstring) PresentationNodeType;
|
||||||
|
_CP_OPT(std::wstring) Direction;
|
||||||
|
_CP_OPT(std::wstring) Restart;
|
||||||
|
_CP_OPT(int) Duration; // in ms
|
||||||
|
_CP_OPT(std::wstring) Begin;
|
||||||
|
_CP_OPT(std::wstring) End;
|
||||||
|
|
||||||
|
_CP_OPT(std::wstring) Fill;
|
||||||
|
_CP_OPT(size_t) ShapeID;
|
||||||
|
_CP_OPT(std::wstring) AttributeName;
|
||||||
|
_CP_OPT(std::wstring) Delay;
|
||||||
|
_CP_OPT(std::wstring) ToValue;
|
||||||
|
_CP_OPT(std::wstring) ColorSpace;
|
||||||
|
|
||||||
|
void serialize(std::wostream& strm) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _anim;
|
||||||
|
typedef shared_ptr<_anim>::Type _anim_ptr;
|
||||||
|
struct _anim : _animation_element
|
||||||
|
{
|
||||||
|
struct _keypoint
|
||||||
|
{
|
||||||
|
int Time;
|
||||||
|
std::wstring Value;
|
||||||
|
_CP_OPT(std::wstring) Fmla; // Formula
|
||||||
|
|
||||||
|
_keypoint(int time, const std::wstring& value, _CP_OPT(std::wstring) formula)
|
||||||
|
: Time(time), Value(value), Fmla(formula)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
_CP_OPT(std::wstring) CalcMode;
|
||||||
|
_CP_OPT(std::wstring) ValueType;
|
||||||
|
_CP_OPT(size_t) ShapeID;
|
||||||
|
_CP_OPT(int) Duration; // in ms
|
||||||
|
_CP_OPT(std::wstring) AttributeName;
|
||||||
|
_CP_OPT(std::wstring) From;
|
||||||
|
_CP_OPT(std::wstring) To;
|
||||||
|
_CP_OPT(std::wstring) By;
|
||||||
|
_CP_OPT(std::wstring) Additive;
|
||||||
|
_CP_OPT(bool) AutoReverse;
|
||||||
|
_CP_OPT(std::wstring) Delay;
|
||||||
|
_CP_OPT(std::vector<_keypoint>) KeypointArray;
|
||||||
|
|
||||||
|
void serialize(std::wostream& strm) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _anim_scale;
|
||||||
|
typedef shared_ptr<_anim_scale>::Type _anim_scale_ptr;
|
||||||
|
struct _anim_scale : _animation_element
|
||||||
|
{
|
||||||
|
struct vec2
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
vec2(int x, int y)
|
||||||
|
: x(x), y(y)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
_CP_OPT(size_t) ShapeID;
|
||||||
|
_CP_OPT(int) Duration; // in ms
|
||||||
|
_CP_OPT(std::wstring) Fill;
|
||||||
|
_CP_OPT(vec2) From;
|
||||||
|
_CP_OPT(vec2) To;
|
||||||
|
//_CP_OPT(std::wstring) By;
|
||||||
|
_CP_OPT(std::wstring) Delay;
|
||||||
|
_CP_OPT(bool) AutoReverse;
|
||||||
|
|
||||||
|
void serialize(std::wostream& strm) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _anim_rotate;
|
||||||
|
typedef shared_ptr<_anim_rotate>::Type _anim_rotate_ptr;
|
||||||
|
struct _anim_rotate : _animation_element
|
||||||
|
{
|
||||||
|
_CP_OPT(size_t) ShapeID;
|
||||||
|
_CP_OPT(int) Duration; // in ms
|
||||||
|
_CP_OPT(std::wstring) Fill;
|
||||||
|
_CP_OPT(int) By;
|
||||||
|
_CP_OPT(std::wstring) Delay;
|
||||||
|
_CP_OPT(bool) AutoReverse;
|
||||||
|
|
||||||
|
void serialize(std::wostream& strm) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
_par_animation_ptr root_animation_element_;
|
||||||
|
_par_animation_array par_animation_levels_;
|
||||||
|
|
||||||
|
_animate_motion_ptr animate_motion_description_;
|
||||||
|
_set_ptr set_description_;
|
||||||
|
_anim_effect_ptr anim_effect_description_;
|
||||||
|
_anim_ptr anim_description_;
|
||||||
|
_anim_clr_ptr anim_clr_description_;
|
||||||
|
_anim_scale_ptr anim_scale_description_;
|
||||||
|
_anim_rotate_ptr anim_rotate_description_;
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
Impl();
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
pptx_animation_context();
|
pptx_animation_context();
|
||||||
|
|
||||||
@ -140,8 +349,9 @@ namespace oox {
|
|||||||
void serialize(std::wostream & strm);
|
void serialize(std::wostream & strm);
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
const Impl::_par_animation_ptr& get_root_par_animation() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Impl;
|
|
||||||
_CP_PTR(Impl) impl_;
|
_CP_PTR(Impl) impl_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
BIN
OdfFile/Test/ExampleFiles/enterence.odp
Normal file
BIN
OdfFile/Test/ExampleFiles/enterence.odp
Normal file
Binary file not shown.
@ -10,76 +10,127 @@
|
|||||||
#include "../../DesktopEditor/common/Directory.h"
|
#include "../../DesktopEditor/common/Directory.h"
|
||||||
#include "../../OfficeUtils/src/OfficeUtils.h"
|
#include "../../OfficeUtils/src/OfficeUtils.h"
|
||||||
|
|
||||||
|
#define CH_DIR(x) FILE_SEPARATOR_STR + _T(x)
|
||||||
|
|
||||||
|
class TestEnvironment : public ::testing::Environment {
|
||||||
|
public:
|
||||||
|
|
||||||
|
~TestEnvironment() override {}
|
||||||
|
|
||||||
|
void SetUp() override
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
mInputOdf = ReadOdfDocument();
|
||||||
|
mConverionContext = Convert(mInputOdf);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TearDown() override
|
||||||
|
{ }
|
||||||
|
|
||||||
|
static boost::shared_ptr<cpdoccore::oox::pptx_conversion_context> GetConversionContext()
|
||||||
|
{
|
||||||
|
return mConverionContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const cpdoccore::oox::pptx_animation_context& GetAnimationContext()
|
||||||
|
{
|
||||||
|
return mConverionContext->get_slide_context().get_animation_context();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void Init()
|
||||||
|
{
|
||||||
|
std::wstring exampleFilename = L"enter_exit";
|
||||||
|
|
||||||
|
std::wstring rootDir = NSFile::GetProcessDirectory() + CH_DIR("..");
|
||||||
|
std::wstring sExampleFilesDirectory = rootDir + CH_DIR("ExampleFiles");
|
||||||
|
|
||||||
|
sFrom = sExampleFilesDirectory + FILE_SEPARATOR_STR + exampleFilename + L".odp";
|
||||||
|
sTo = sExampleFilesDirectory + FILE_SEPARATOR_STR + exampleFilename + L".pptx";
|
||||||
|
sTemp = rootDir + CH_DIR("tmp");
|
||||||
|
sTempUnpackedOdf = sTemp + CH_DIR("odf_unpacked");
|
||||||
|
sTempUnpackedOox = sTemp + CH_DIR("oox_unpacked");
|
||||||
|
|
||||||
|
NSDirectory::CreateDirectory(sTemp);
|
||||||
|
NSDirectory::CreateDirectory(sTempUnpackedOdf);
|
||||||
|
NSDirectory::CreateDirectory(sTempUnpackedOox);
|
||||||
|
|
||||||
|
mOutputPptx = boost::make_shared<cpdoccore::oox::package::pptx_document>();
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::shared_ptr<cpdoccore::odf_reader::odf_document> ReadOdfDocument()
|
||||||
|
{
|
||||||
|
COfficeUtils oCOfficeUtils(NULL);
|
||||||
|
if (S_OK == oCOfficeUtils.ExtractToDirectory(sFrom, sTempUnpackedOdf, NULL, 0))
|
||||||
|
return boost::make_shared<cpdoccore::odf_reader::odf_document>(sTempUnpackedOdf, sTemp, L"");
|
||||||
|
else
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::shared_ptr<cpdoccore::oox::pptx_conversion_context> Convert(boost::shared_ptr<cpdoccore::odf_reader::odf_document> inputOdf)
|
||||||
|
{
|
||||||
|
boost::shared_ptr<cpdoccore::oox::pptx_conversion_context> conversionContext = boost::make_shared<cpdoccore::oox::pptx_conversion_context>(mInputOdf.get());
|
||||||
|
|
||||||
|
conversionContext->set_output_document(mOutputPptx.get());
|
||||||
|
conversionContext->set_font_directory(L"");
|
||||||
|
|
||||||
|
mInputOdf->pptx_convert(*conversionContext);
|
||||||
|
|
||||||
|
return conversionContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::wstring sFrom;
|
||||||
|
std::wstring sTo;
|
||||||
|
std::wstring sTemp;
|
||||||
|
std::wstring sTempUnpackedOdf;
|
||||||
|
std::wstring sTempUnpackedOox;
|
||||||
|
|
||||||
|
static boost::shared_ptr<cpdoccore::oox::package::pptx_document> mOutputPptx;
|
||||||
|
static boost::shared_ptr<cpdoccore::oox::pptx_conversion_context> mConverionContext;
|
||||||
|
static boost::shared_ptr<cpdoccore::odf_reader::odf_document> mInputOdf;
|
||||||
|
};
|
||||||
|
|
||||||
|
boost::shared_ptr<cpdoccore::oox::package::pptx_document> TestEnvironment::mOutputPptx;
|
||||||
|
boost::shared_ptr<cpdoccore::oox::pptx_conversion_context> TestEnvironment::mConverionContext;
|
||||||
|
boost::shared_ptr<cpdoccore::odf_reader::odf_document> TestEnvironment::mInputOdf;
|
||||||
|
|
||||||
class ODP2OOX_EnterExitAnimationTest : public testing::Test
|
class ODP2OOX_EnterExitAnimationTest : public testing::Test
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void SetUp() override
|
void SetUp() override
|
||||||
{
|
{
|
||||||
Init();
|
mAnimationContext = &TestEnvironment::GetAnimationContext();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TearDown() override
|
void TearDown() override
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public:
|
||||||
|
const cpdoccore::oox::pptx_animation_context* mAnimationContext;
|
||||||
|
|
||||||
void Init()
|
|
||||||
{
|
|
||||||
sTmpDirectory = NSFile::GetProcessDirectory() + FILE_SEPARATOR_STR + _T("../tmp");
|
|
||||||
sExampleFilesDirectory = NSFile::GetProcessDirectory() + FILE_SEPARATOR_STR + _T("../ExampleFiles");
|
|
||||||
sExampleFile = sExampleFilesDirectory + FILE_SEPARATOR_STR + _T("enter_exit.odp");
|
|
||||||
|
|
||||||
NSDirectory::CreateDirectory(sTmpDirectory);
|
|
||||||
|
|
||||||
mOdfDocument = ReadOdfDocument();
|
|
||||||
mContext = Convert(mOdfDocument);
|
|
||||||
}
|
|
||||||
|
|
||||||
boost::shared_ptr<cpdoccore::odf_reader::odf_document> ReadOdfDocument()
|
|
||||||
{
|
|
||||||
std::wstring sTempUnpackedOdf = sTmpDirectory + FILE_SEPARATOR_STR + _T("odf_unpacked");
|
|
||||||
std::wstring sTempUnpackedOox = sTmpDirectory + FILE_SEPARATOR_STR + _T("oox_unpacked");
|
|
||||||
|
|
||||||
NSDirectory::CreateDirectory(sTempUnpackedOdf);
|
|
||||||
NSDirectory::CreateDirectory(sTempUnpackedOox);
|
|
||||||
|
|
||||||
COfficeUtils oCOfficeUtils(NULL);
|
|
||||||
if (S_OK == oCOfficeUtils.ExtractToDirectory(sExampleFile, sTempUnpackedOdf, NULL, 0))
|
|
||||||
{
|
|
||||||
return boost::make_shared<cpdoccore::odf_reader::odf_document>(sTempUnpackedOdf, sTmpDirectory, L"");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
boost::shared_ptr<cpdoccore::oox::pptx_conversion_context> Convert(boost::shared_ptr<cpdoccore::odf_reader::odf_document> inputOdf)
|
|
||||||
{
|
|
||||||
mOutputPptx = boost::make_shared<cpdoccore::oox::package::pptx_document>();
|
|
||||||
boost::shared_ptr<cpdoccore::oox::pptx_conversion_context> context = boost::make_shared<cpdoccore::oox::pptx_conversion_context>(inputOdf.get());
|
|
||||||
|
|
||||||
context->set_output_document(mOutputPptx.get());
|
|
||||||
context->set_font_directory(L"");
|
|
||||||
|
|
||||||
inputOdf->pptx_convert(*(context.get()));
|
|
||||||
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::wstring sTmpDirectory;
|
|
||||||
std::wstring sExampleFilesDirectory;
|
|
||||||
std::wstring sExampleFile;
|
|
||||||
|
|
||||||
boost::shared_ptr<cpdoccore::oox::package::pptx_document> mOutputPptx;
|
|
||||||
boost::shared_ptr<cpdoccore::oox::pptx_conversion_context> mContext;
|
|
||||||
boost::shared_ptr<cpdoccore::odf_reader::odf_document> mOdfDocument;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(ODP2OOX_EnterExitAnimationTest, qwe)
|
TEST_F(ODP2OOX_EnterExitAnimationTest, timing_root_par)
|
||||||
{
|
{
|
||||||
|
using namespace cpdoccore::oox;
|
||||||
|
const pptx_animation_context::Impl::_par_animation_ptr& root = mAnimationContext->get_root_par_animation();
|
||||||
|
|
||||||
EXPECT_EQ(1, 1);
|
const std::wstring expectedNodeType = L"tmRoot";
|
||||||
|
|
||||||
|
EXPECT_EQ(root->Delay.value(), expectedNodeType);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ODP2OOX_EnterExitAnimationTest, asd)
|
||||||
|
{
|
||||||
|
EXPECT_EQ(1, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
::testing::AddGlobalTestEnvironment(new TestEnvironment);
|
||||||
|
return RUN_ALL_TESTS();
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user