1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _SD_PPT_EXANIMATIONS_HXX
21 #define _SD_PPT_EXANIMATIONS_HXX
23 #include <com/sun/star/animations/XTimeContainer.hpp>
24 #include <com/sun/star/drawing/XDrawPage.hpp>
25 #include <com/sun/star/animations/XAnimate.hpp>
26 #include <com/sun/star/beans/NamedValue.hpp>
27 #include "../ppt/pptanimations.hxx"
28 #include <pptexsoundcollection.hxx>
29 #include <filter/msfilter/escherex.hxx>
35 #include <boost/shared_ptr.hpp>
44 struct AfterEffectNode
46 ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
> mxNode
;
47 ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
> mxMaster
;
49 AfterEffectNode( const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xNode
,
50 const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xMaster
)
51 : mxNode( xNode
), mxMaster( xMaster
) {}
54 typedef boost::shared_ptr
< AfterEffectNode
> AfterEffectNodePtr
;
56 typedef sal_uInt32 TranslateMode
;
57 #define TRANSLATE_NONE 0
58 #define TRANSLATE_VALUE 1
59 #define TRANSLATE_ATTRIBUTE 2
60 #define TRANSLATE_MEASURE 4
61 #define TRANSLATE_NUMBER_TO_STRING 8
63 const int AFTEREFFECT_NONE
= 0;
64 const int AFTEREFFECT_COLOR
= 1;
65 const int AFTEREFFECT_SET
= 2;
67 class AnimationExporter
69 ::com::sun::star::uno::Any aTarget
;
71 void writeZString( SvStream
& rStrm
, const OUString
& rVal
);
72 sal_Bool
getColorAny( const ::com::sun::star::uno::Any
& rAny
, const sal_Int16 nColorSpace
, sal_Int32
& rMode
, sal_Int32
& rA
, sal_Int32
& rB
, sal_Int32
& rC
) const;
73 sal_Bool
exportAnimProperty( SvStream
& rStrm
, const sal_uInt16 nPropertyId
, const ::com::sun::star::uno::Any
& rAny
, const TranslateMode eTranslateMode
);
74 void exportAnimPropertyString( SvStream
& rStrm
, const sal_uInt16 nPropertyId
, const OUString
& rVal
, const TranslateMode eTranslateMode
);
75 void exportAnimPropertyFloat( SvStream
& rStrm
, const sal_uInt16 nPropertyId
, const double& rVal
, const TranslateMode eTranslateMode
);
76 void exportAnimPropertyuInt32( SvStream
& rStrm
, const sal_uInt16 nPropertyId
, const sal_uInt32 nVal
, const TranslateMode eTranslateMode
);
77 void exportAnimPropertyByte( SvStream
& rStrm
, const sal_uInt16 nPropertyId
, const sal_uInt8 nVal
, const TranslateMode eTranslateMode
);
79 /** if available exportAnimPropertySet
80 @return the ::com::sun::star::presentation::EffectNodeType*/
81 sal_Int16
exportAnimPropertySet( SvStream
& rStrm
, const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xNode
);
82 void exportAnimNode( SvStream
& rStrm
, const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xNode
,
83 const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>* pParent
, const sal_Int32 nGroupLevel
, const sal_Int16 nFillDefault
);
84 void exportAnimate( SvStream
& rStrm
, const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xNode
);
85 void exportAnimateTarget( SvStream
& rStrm
, const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xNode
, const sal_uInt32 nForceAttributeName
= 0, int nAfterEffectType
= AFTEREFFECT_NONE
);
86 void exportAnimateSet( SvStream
& rStrm
, const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xNode
, int nAfterEffectType
);
87 void exportAnimAction( SvStream
& rStrm
, const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xNode
);
88 void exportAnimEvent( SvStream
& rStrm
, const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xNode
, const sal_Int32 nFlags
= 0 );
89 void exportNode( SvStream
& rStrm
, ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
> xNode
,
90 const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>* xParent
,
91 const sal_uInt16 nContainerRecType
, const sal_uInt16 nInstance
, const sal_Int32 nGroupLevel
, const sal_Bool bTakeBackInteractiveSequenceTiming
,
92 const sal_Int16 nFillDefault
);
93 void exportAnimateTargetElement( SvStream
& rStrm
, const ::com::sun::star::uno::Any aAny
, const sal_Bool bCreate2b01Atom
);
94 void exportAnimateKeyPoints( SvStream
& rStrm
, const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimate
>& xAnimate
);
95 void exportAnimValue( SvStream
& rStrm
, const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xNode
, const sal_Bool bExportAlways
);
96 void exportTransitionFilter( SvStream
& rStrm
, const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xNode
);
97 void exportAnimateMotion( SvStream
& rStrm
, const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xNode
);
98 void exportAnimateTransform( SvStream
& rStrm
, const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xNode
);
99 void exportAnimateColor( SvStream
& rStrm
, const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xNode
, int nAfterEffectType
);
100 void exportIterate( SvStream
& rStrm
, const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xNode
);
102 const EscherSolverContainer
& mrSolverContainer
;
103 ppt::ExSoundCollection
& mrExSoundCollection
;
104 void processAfterEffectNodes( const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xNode
);
106 bool isAfterEffectNode( const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xNode
) const;
107 bool hasAfterEffectNode( const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xNode
, ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xAfterEffectNode
) const;
108 bool isEmptyNode( const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xNode
) const;
110 ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
> createAfterEffectNodeClone( const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xNode
) const;
112 std::list
< AfterEffectNodePtr
> maAfterEffectNodes
;
115 AnimationExporter( const EscherSolverContainer
& rSolverContainer
, ppt::ExSoundCollection
& rExSoundCollection
);
117 void doexport( const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XDrawPage
>& xPage
, SvStream
& rStrm
);
119 sal_Int32 mnCurrentGroup
;
121 // helper methods also used in ooxml export
122 static ::com::sun::star::uno::Any
convertAnimateValue( const ::com::sun::star::uno::Any
& rSource
, const OUString
& rAttributeName
);
123 static sal_Bool
GetNodeType( const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xNode
, sal_Int16
& nType
);
124 static sal_Int16
GetFillMode( const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xNode
, const sal_Int16 nFillDefault
);
125 static void GetUserData( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::NamedValue
>& rUserData
, const ::com::sun::star::uno::Any
** pAny
, sal_Size nLen
);
126 static sal_uInt32
TranslatePresetSubType( const sal_uInt32 nPresetClass
, const sal_uInt32 nPresetId
, const OUString
& rPresetSubType
);
127 static sal_uInt32
GetPresetID( const OUString
& rPreset
, sal_uInt32 nAPIPresetClass
, sal_Bool
& bPresetId
);
128 static sal_uInt32
GetValueTypeForAttributeName( const OUString
& rAttributeName
);
130 static const sal_Char
* FindTransitionName( const sal_Int16 nType
, const sal_Int16 nSubType
, const sal_Bool bDirection
);
131 static ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
> getTargetElementShape( const ::com::sun::star::uno::Any
& rAny
, sal_Int32
& rBegin
, sal_Int32
& rEnd
, sal_Bool
& rParagraphTarget
);
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */