Commit 9a9ba4cc authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatWriter - animations

parent 5b4c6363
This diff is collapsed.
......@@ -56,9 +56,11 @@ public:
static const ElementType type = typeAnimPar;
CPDOCCORE_DEFINE_VISITABLE();
office_element_ptr anim_par_;
office_element_ptr_array anim_seq_array_;
office_element_ptr_array content_;
odf_types::common_anim_smil_attlist attlist_;
office_element_ptr anim_par_;
office_element_ptr_array anim_seq_array_;
office_element_ptr_array content_;
virtual void pptx_convert(oox::pptx_conversion_context & Context);
......@@ -79,7 +81,8 @@ public:
static const ElementType type = typeAnimSeq;
CPDOCCORE_DEFINE_VISITABLE();
office_element_ptr_array anim_par_array_;
odf_types::common_anim_smil_attlist attlist_;
office_element_ptr_array anim_par_array_;
virtual void pptx_convert(oox::pptx_conversion_context & Context);
......@@ -103,12 +106,12 @@ class anim_transition_filter_attlist
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
_CP_OPT(std::wstring) smil_direction_;
_CP_OPT(std::wstring) smil_subtype_;
_CP_OPT(std::wstring) smil_direction_;
_CP_OPT(std::wstring) smil_subtype_;
_CP_OPT(odf_types::smil_transition_type) smil_type_;
_CP_OPT(std::wstring) smil_mode_;
_CP_OPT(odf_types::color) smil_fadeColor_;
_CP_OPT(odf_types::clockvalue) smil_dur_;
_CP_OPT(std::wstring) smil_mode_;
_CP_OPT(odf_types::color) smil_fadeColor_;
_CP_OPT(odf_types::clockvalue) smil_dur_;
};
//anim:transitionFilter
......@@ -122,11 +125,8 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
virtual void pptx_convert(oox::pptx_conversion_context & Context);
///////////////////////////////////////////////////////////
odf_types::common_anim_smil_attlist common_anim_smil_attlist_;
anim_transition_filter_attlist anim_transition_filter_attlist_;
anim_transition_filter_attlist attlist_;
private:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
......
......@@ -804,18 +804,28 @@ void common_presentation_attlist::serialize(CP_ATTR_NODE)
void common_anim_smil_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
//CP_APPLY_ATTR(L"smil:direction", smil_direction_);
// CP_APPLY_ATTR(L"smil:subtype", smil_subtype_);
// CP_APPLY_ATTR(L"smil:type", smil_type_);
//CP_APPLY_ATTR(L"smil:dur", smil_dur_);
CP_APPLY_ATTR(L"smil:direction", smil_direction_);
CP_APPLY_ATTR(L"smil:subtype", smil_subtype_);
CP_APPLY_ATTR(L"smil:type", smil_type_);
CP_APPLY_ATTR(L"smil:dur", smil_dur_);
}
void common_anim_smil_attlist::apply_from(const common_anim_smil_attlist & Other)
{
//_CP_APPLY_PROP(smil_direction_, Other.smil_direction_);
//_CP_APPLY_PROP(smil_subtype_, Other.smil_subtype_);
//_CP_APPLY_PROP(smil_type_, Other.smil_type_);
// _CP_APPLY_PROP(smil_dur_, Other.smil_dur_);
_CP_APPLY_PROP(smil_direction_, Other.smil_direction_);
_CP_APPLY_PROP(smil_subtype_, Other.smil_subtype_);
_CP_APPLY_PROP(smil_type_, Other.smil_type_);
_CP_APPLY_PROP(smil_dur_, Other.smil_dur_);
}
void common_anim_smil_attlist::serialize(CP_ATTR_NODE)
{
CP_XML_ATTR_OPT(L"smil:direction", smil_direction_);
CP_XML_ATTR_OPT(L"smil:subtype", smil_subtype_);
CP_XML_ATTR_OPT(L"smil:type", smil_type_);
CP_XML_ATTR_OPT(L"smil:restart", smil_restart_);
CP_XML_ATTR_OPT(L"smil:dur", smil_dur_);
CP_XML_ATTR_OPT(L"presentation:node-type", presentation_node_type_);
CP_XML_ATTR_OPT(L"smil:begin", smil_begin_);
}
void union_common_draw_attlists::serialize(CP_ATTR_NODE)
{
......
......@@ -575,14 +575,18 @@ class common_anim_smil_attlist
public:
void add_attributes ( const xml::attributes_wc_ptr & Attributes );
void apply_from (const common_anim_smil_attlist & Other);
void serialize (CP_ATTR_NODE){}
void serialize (CP_ATTR_NODE);
_CP_OPT(std::wstring) presentation_node_type_;
_CP_OPT(std::wstring) smil_direction_;
_CP_OPT(std::wstring) smil_restart_;
_CP_OPT(std::wstring) smil_subtype_;
_CP_OPT(std::wstring) smil_type_;
_CP_OPT(std::wstring) smil_dur_;
//_CP_OPT(std::wstring) smil_direction_;
//_CP_OPT(std::wstring) smil_subtype_;
//_CP_OPT(std::wstring) smil_type_;
//_CP_OPT(std::wstring) smil_dur_;
_CP_OPT(std::wstring) smil_begin_;
//_CP_OPT(color) smil_fadeColor;
_CP_OPT(color) smil_fadeColor;
};
......
......@@ -74,6 +74,8 @@ void anim_par::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
attlist_.serialize(CP_GET_XML_NODE());
if (anim_par_)
anim_par_->serialize(CP_XML_STREAM());
......@@ -98,6 +100,8 @@ void anim_seq::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
attlist_.serialize(CP_GET_XML_NODE());
for (size_t i = 0; i < anim_par_array_.size(); i++)
{
anim_par_array_[i]->serialize(CP_XML_STREAM());
......@@ -136,8 +140,7 @@ void anim_transitionFilter::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
common_anim_smil_attlist_.serialize(CP_GET_XML_NODE());
anim_transition_filter_attlist_.serialize(CP_GET_XML_NODE());
attlist_.serialize(CP_GET_XML_NODE());
}
}
}
......
......@@ -53,9 +53,10 @@ public:
static const ElementType type = typeAnimPar;
CPDOCCORE_DEFINE_VISITABLE();
office_element_ptr anim_par_;
office_element_ptr_array anim_seq_array_;
office_element_ptr_array content_;
odf_types::common_anim_smil_attlist attlist_;
office_element_ptr anim_par_;
office_element_ptr_array anim_seq_array_;
office_element_ptr_array content_;
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
virtual void add_child_element( const office_element_ptr & child);
......@@ -73,7 +74,8 @@ public:
static const ElementType type = typeAnimSeq;
CPDOCCORE_DEFINE_VISITABLE();
office_element_ptr_array anim_par_array_;
odf_types::common_anim_smil_attlist attlist_;
office_element_ptr_array anim_par_array_;
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
virtual void add_child_element( const office_element_ptr & child);
......@@ -81,14 +83,11 @@ public:
virtual void serialize(std::wostream & strm);
};
CP_REGISTER_OFFICE_ELEMENT2(anim_seq);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//anim:iterate
//class anim_iterate : public office_element_impl<anim_iterate>//Итеративные анимации
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------------------------------------------/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class anim_transition_filter_attlist
{
public:
......@@ -117,8 +116,7 @@ public:
virtual void serialize(std::wostream & strm);
///////////////////////////////////////////////////////////
odf_types::common_anim_smil_attlist common_anim_smil_attlist_;
anim_transition_filter_attlist anim_transition_filter_attlist_;
anim_transition_filter_attlist attlist_;
};
CP_REGISTER_OFFICE_ELEMENT2(anim_transitionFilter);
......
......@@ -36,6 +36,7 @@
#include "odp_conversion_context.h"
#include "office_presentation.h"
#include "draw_page.h"
#include "styles.h"
......@@ -213,6 +214,17 @@ void odp_conversion_context::end_note()
current_slide().drawing_context()->end_element();
current_slide().drawing_context()->end_drawing();
}
void odp_conversion_context::start_timing()
{
anim_state anim;
anim.elm = current_slide().page_elm_;
current_slide().anim_levels.push_back(anim);
}
void odp_conversion_context::end_timing()
{
current_slide().anim_levels.pop_back();
}
}
}
......@@ -80,6 +80,9 @@ public:
void start_note(bool bMaster = false);
void end_note();
void start_timing();
void end_timing();
private:
odp_slide_context slide_context_;
......
......@@ -40,6 +40,7 @@
#include "odp_conversion_context.h"
#include "draw_page.h"
#include "anim_elements.h"
#include "office_annotation.h"
#include "styles.h"
......@@ -63,12 +64,15 @@ odp_page_state::odp_page_state(odf_conversion_context * Context, office_element_
page_elm_ = elm;
}
void odp_page_state::set_page_id(int id)
{
page_id_ = id;
}
void odp_page_state::set_page_name(std::wstring name)
{
if (name.empty()) return;
office_page_name_ = name;
page_name_ = name;
draw_page* page = dynamic_cast<draw_page*>(page_elm_.get());
if (page)
......@@ -129,6 +133,129 @@ void odp_page_state::add_child_element( const office_element_ptr & child_element
{
page_elm_->add_child_element(child_element);
}
void odp_page_state::set_anim_id (int val)
{
if (anim_levels.empty()) return;
if (!anim_levels.back().attlist)return;
anim_levels.back().id = val;
//anim_levels.back().attlist->smil_begin_ = L"id" + std::to_wstring(val) + L".begin";
}
void odp_page_state::set_anim_type(std::wstring val)
{
if (anim_levels.empty()) return;
if (!anim_levels.back().attlist)return;
if (val == L"tmRoot")
{
anim_levels.back().attlist->presentation_node_type_ = L"timing-root";
if (page_transaction)
{
std::wstring slide_id = L"slide_id" + std::to_wstring(page_id_);
draw_page* page = dynamic_cast<draw_page*>(page_elm_.get());
if (page)
{
page->attlist_.draw_id_ = slide_id;
start_timing_par();
anim_levels.back().attlist->smil_begin_ = slide_id + L".begin";
anim_levels.back().elm->add_child_element( page_transaction );
end_timing_par();
}
}
}
}
void odp_page_state::set_anim_duration(std::wstring val)
{
if (anim_levels.empty()) return;
if (!anim_levels.back().attlist)return;
//if (val == L"indefinite")
anim_levels.back().attlist->smil_dur_ = val;
}
void odp_page_state::set_anim_restart(std::wstring val)
{
if (anim_levels.empty()) return;
if (!anim_levels.back().attlist)return;
anim_levels.back().attlist->smil_restart_ = val;
}
void odp_page_state::start_transition()
{
create_element(L"anim", L"transitionFilter", page_transaction, context_);
}
void odp_page_state::set_transition_type(int val)
{
anim_transitionFilter *trans = dynamic_cast<anim_transitionFilter*>(page_transaction.get());
if (trans)
trans->attlist_.smil_type_ = odf_types::smil_transition_type(odf_types::smil_transition_type::dissolve);
}
void odp_page_state::set_transition_subtype(std::wstring val)
{
anim_transitionFilter *trans = dynamic_cast<anim_transitionFilter*>(page_transaction.get());
if (trans)
trans->attlist_.smil_subtype_ = val;
}
void odp_page_state::set_transition_speed(int val)
{
anim_transitionFilter *trans = dynamic_cast<anim_transitionFilter*>(page_transaction.get());
if (trans)
{
if (val == 0) trans->attlist_.smil_dur_ = odf_types::clockvalue(3000);
if (val == 1) trans->attlist_.smil_dur_ = odf_types::clockvalue(4000);
if (val == 2) trans->attlist_.smil_dur_ = odf_types::clockvalue(5000);
}
}
void odp_page_state::set_transition_duration(int val)
{
anim_transitionFilter *trans = dynamic_cast<anim_transitionFilter*>(page_transaction.get());
if (trans)
trans->attlist_.smil_dur_ = odf_types::clockvalue(val * 1000);
}
void odp_page_state::start_timing_seq()
{
if (anim_levels.empty()) return;
anim_state anim;
create_element(L"anim", L"seq", anim.elm, context_);
if (!anim.elm) return;
anim_seq *seq = dynamic_cast<anim_seq*>(anim.elm.get());
if (seq) anim.attlist = &seq->attlist_;
anim_levels.back().empty = false;
anim_levels.back().elm->add_child_element(anim.elm);
anim_levels.push_back(anim);
}
void odp_page_state::end_timing_seq()
{
anim_levels.pop_back();
}
void odp_page_state::start_timing_par()
{
if (anim_levels.empty()) return;
anim_state anim;
create_element(L"anim", L"par", anim.elm, context_);
if (!anim.elm) return;
anim_par *par = dynamic_cast<anim_par*>(anim.elm.get());
if (par) anim.attlist = &par->attlist_;
anim_levels.back().empty = false;
anim_levels.back().elm->add_child_element(anim.elm);
anim_levels.push_back(anim);
}
void odp_page_state::end_timing_par()
{
anim_levels.pop_back();
}
}
}
......@@ -60,13 +60,15 @@ class odf_text_context;
class style;
struct odp_element_state
struct anim_state
{
office_element_ptr elm;
anim_state() : empty(true), attlist(NULL), id(-1) {}
short repeated;
std::wstring style_name;
office_element_ptr style_elm;
int id;
office_element_ptr elm;
odf_types::common_anim_smil_attlist* attlist;
bool empty;
};
......@@ -74,8 +76,9 @@ class odp_page_state
{
public:
odp_page_state(odf_conversion_context * Context, office_element_ptr & elm);
void set_page_name(std::wstring name);
void set_page_style(office_element_ptr & _style);
void set_page_name (std::wstring name);
void set_page_id (int id);
void set_page_style (office_element_ptr & _style);
void set_master_page(std::wstring name);
void set_layout_page(std::wstring name);
......@@ -86,9 +89,31 @@ public:
odf_drawing_context * drawing_context(){return &drawing_context_;}
odf_comment_context * comment_context(){return &comment_context_;}
std::wstring office_page_name_;
office_element_ptr page_elm_;
office_element_ptr page_style_elm_;
std::wstring page_name_;
int page_id_;
office_element_ptr page_elm_;
office_element_ptr page_style_elm_;
std::vector<anim_state> anim_levels;
office_element_ptr page_transaction;
void set_anim_id (int val);
void set_anim_type (std::wstring val);
void set_anim_duration (std::wstring val);
void set_anim_restart (std::wstring val);
void start_timing_par();
void end_timing_par();
void start_timing_seq();
void end_timing_seq();
void start_transition();
void set_transition_type (int val);
void set_transition_subtype (std::wstring val);
void set_transition_speed (int val);
void set_transition_duration(int val);
void end_transition(){}
private:
odf_conversion_context * context_;
......
......@@ -73,6 +73,7 @@ void odp_slide_context::start_page(office_element_ptr & elm)
office_element_ptr & style = styles_context_->add_or_find(style_name_new, style_family::DrawingPage, true);
style->create_child_element(L"style", L"drawing-page-properties");
state().set_page_id(count_slides_);
state().set_page_style(style);
state().drawing_context()->set_styles_context(styles_context_);
}
......
......@@ -38,6 +38,9 @@
#include "../../../ASCOfficePPTXFile/PPTXFormat/NotesMaster.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Table/Table.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Par.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Seq.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/CTn.h"
#include <boost/lexical_cast.hpp>
......@@ -411,7 +414,8 @@ void PptxConverter::convert_slides()
convert (slide->comments.operator->());
convert (slide->Note.operator->());
convert (slide->timing.GetPointer(), slide->transition.GetPointer());
convert (slide->transition.GetPointer());
convert (slide->timing.GetPointer());
odp_context->end_slide();
......@@ -527,15 +531,109 @@ void PptxConverter::convert(PPTX::Comments *oox_comments)
odp_context->end_comment();
}
}
void PptxConverter::convert(PPTX::Logic::Timing *oox_timing, PPTX::Logic::Transition *oox_transition)
void PptxConverter::convert( PPTX::Logic::Transition *oox_transition )
{
if (!oox_transition) return;
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);
odp_context->current_slide().set_transition_type(5);
//convert(oox_transition->base.operator->());
//if (oox_transition->sndAc.is_init() && oox_transition->sndAc->stSnd.is_init())
//{
// std::wstring sID = oox_transition->sndAc->stSnd->embed->get();
// pathAudio = find_link_by_id(sID, 1);
//
// std::wstring odf_ref = odf_context()->add_media(pathAudio);
// odp_context->current_slide().set_transition_sound(odf_ref, oox_transition->sndAc->stSnd->loop.get_value_or(false));
//}
odp_context->current_slide().end_transition();
}
void PptxConverter::convert(PPTX::Logic::Timing *oox_timing)
{
if (!oox_timing) return;
if (!oox_timing->tnLst.IsInit()) return;
odp_context->start_timing();
for (size_t i = 0; i < oox_timing->tnLst->list.size(); i++)
{
//oox_timing->tnLst[0]
if (oox_timing->tnLst->list[i].is_init() == false) continue;
convert(&oox_timing->tnLst->list[i]);
}
odp_context->end_timing();
}
void PptxConverter::convert(PPTX::Logic::TimeNodeBase *oox_time_base)
{
if (!oox_time_base) return;
if (oox_time_base->is<PPTX::Logic::Par>()) //Parallel Time
{
PPTX::Logic::Par & par = oox_time_base->as<PPTX::Logic::Par>();
odp_context->current_slide().start_timing_par();
convert(&par.cTn);
odp_context->current_slide().end_timing_par();
}
else if (oox_time_base->is<PPTX::Logic::Seq>()) //Sequence Time
{
PPTX::Logic::Seq & seq = oox_time_base->as<PPTX::Logic::Seq>();
odp_context->current_slide().start_timing_seq();
convert(&seq.cTn);
odp_context->current_slide().end_timing_seq();
}
}
void PptxConverter::convert(PPTX::Logic::CTn *oox_time_common)
{
if (!oox_time_common) return;
if (oox_time_common->id.IsInit())
{
odp_context->current_slide().set_anim_id(*oox_time_common->id);
}
if (oox_time_common->nodeType.IsInit())
{
odp_context->current_slide().set_anim_type(oox_time_common->nodeType->get());
}
if (oox_time_common->dur.IsInit())
{
odp_context->current_slide().set_anim_duration(*oox_time_common->dur);
}
if (oox_time_common->restart.IsInit())
{
odp_context->current_slide().set_anim_restart(oox_time_common->restart->get());
}
//nullable<CondLst> stCondLst;
//nullable<CondLst> endCondLst;
//nullable<Cond> endSync;
//nullable<Iterate> iterate;
if (oox_time_common->childTnLst.IsInit())
{
for (size_t i = 0; i < oox_time_common->childTnLst->list.size(); i++)
{
if (oox_time_common->childTnLst->list[i].is_init() == false) continue;
convert(&oox_time_common->childTnLst->list[i]);
}
}
//if (oox_time_common->subTnLst.IsInit())
//{
// for (size_t i = 0; i < oox_time_common->subTnLst->list.size(); i++)
// {
// if (oox_time_common->subTnLst->list[i].is_init() == false) continue;
// convert(&oox_time_common->subTnLst->list[i]);
// }
//}
}
void PptxConverter::convert(PPTX::Logic::TableProperties *oox_table_pr)
{
......
......@@ -67,6 +67,9 @@ namespace PPTX
class TableCellProperties;
class TcBdr;
class TxStyles;
class TimeNodeBase;
class CTn;
}
}
......@@ -115,7 +118,10 @@ namespace Oox2Odf
void convert (PPTX::NotesMaster *oox_notes);
void convert(PPTX::Logic::Bg *oox_background);
void convert(PPTX::Logic::Timing *oox_timing, PPTX::Logic::Transition *oox_transition);
void convert(PPTX::Logic::Timing *oox_timing);
void convert(PPTX::Logic::Transition *oox_transition);
void convert(PPTX::Logic::TimeNodeBase *oox_base_time);
void convert(PPTX::Logic::CTn *oox_common_time);
void convert(PPTX::Logic::Table *oox_table);
void convert(PPTX::Logic::TableRow *oox_table_row);
......
......@@ -49,7 +49,6 @@ namespace PPTX
explicit TransitionBase(XmlUtils::CXmlNode& node);
const TransitionBase& operator =(XmlUtils::CXmlNode& node);
public:
virtual void fromXML(XmlUtils::CXmlNode& node);
virtual void GetTransitionTypeFrom(XmlUtils::CXmlNode& element);
virtual bool is_init()const{return (base.IsInit());};
......@@ -59,8 +58,7 @@ namespace PPTX
template<class T> const T& as() const { return base.as<T>(); }
virtual std::wstring toXML() const;
//public:
private:
smart_ptr<WrapperWritingElement> base;
protected:
virtual void FillParentPointersForChilds(){};
......
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