1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SD_PPT_97_ANIMATIONS_HXX
25 #define _SD_PPT_97_ANIMATIONS_HXX
26 
27 // header for class SvStream
28 #include <tools/stream.hxx>
29 
30 class SdrObject;
31 class Ppt97Animation;
32 
33 // helper class for reading PPT AnimationInfoAtom
34 class Ppt97AnimationInfoAtom
35 {
36     friend class Ppt97Animation;
37 
38 //-- member
39     sal_uInt32			nDimColor;
40 	sal_uInt32			nFlags; 		// 0x0004: time instead of click
41 	sal_uInt32			nSoundRef;
42 	sal_Int32			nDelayTime; 	// 1/1000 sec
43 	sal_uInt16			nOrderID;
44 	sal_uInt16			nSlideCount;
45 	sal_uInt8			nBuildType;
46 	sal_uInt8			nFlyMethod;
47 	sal_uInt8			nFlyDirection;
48 	sal_uInt8			nAfterEffect; //nAfterEffect: 0: none; 1: change color; 2: dim on next effect; 3: dim after effect;
49 	sal_uInt8			nSubEffect;
50 	sal_uInt8			nOLEVerb;
51 
52 	// unknown, because whole size needs to be 28
53 	sal_uInt8			nUnknown1;
54 	sal_uInt8			nUnknown2;
55 
56 //-- methods
57     void ReadStream( SvStream& rIn );
58 /*
59     nFlags:
60     decimal / hexadecimal / binary
61     1040 0x00000410     10000010000 mouseclick
62    17428 0x00004414 100010000010100 after previous 0 sec (animate form)
63    17412 0x00004404 100010000000100 after previous 0 sec
64     1088 0x00000440     10001000000 stop previous sound and mouseclick
65     1044 0x00000414     10000010100 play sound automatic
66     1041 0x00000411     10000010001
67                     |   |   | | | |
68                     |   |   | | | reverse order
69                     |   |   | | after previous
70                     |   |   | sound
71                     |   |   stop previous sound
72                     |   ?
73                     animate form
74 
75     nAfterEffect:
76     1: color
77     0: nothing
78     3: hide after animation
79     2: hide at next mouse click
80 */
81 };
82 
83 class Ppt97Animation
84 {
85     /** this is a helping class for import of PPT 97 animations
86         1. use the constructor Ppt97Animation( SvStream& rIn ) to import informations from the stream
87         2. use the set methods to modify and complete the data
88         3. use the method createAndSetCustomAnimationEffect( ) to create an effect in sd model
89     */
90 
91 public: //public methods
92     Ppt97Animation( SvStream& rIn );
93 
94     Ppt97Animation( const Ppt97Animation& rAnimation );
95     Ppt97Animation& operator= ( const Ppt97Animation& rAnimation );
96     bool operator < ( const Ppt97Animation& rAnimation ) const;//later is greater
97     bool operator > ( const Ppt97Animation& rAnimation ) const;//later is greater
98     ~Ppt97Animation();
99 
100     //get methods
101     bool HasEffect() const;
102     bool HasParagraphEffect() const;
103     bool HasSoundEffect() const;
104     sal_Int32 GetDimColor() const;
105     sal_uInt32 GetSoundRef() const;
106     bool HasAnimateAssociatedShape() const; //true if the shape should be animated in addition to the text
107 
108     //set methods
109     void SetDimColor( sal_Int32 nDimColor );
110     void SetSoundFileUrl( const ::rtl::OUString& rSoundFileUrl );
111     void SetAnimateAssociatedShape( bool bAnimate ); //true if the shape should be animated in addition to the text
112 
113     //action methods
114     /** this method creates a CustomAnimationEffect for the given SdrObject
115     from internal data and stores the created effect at the draw model
116     */
117     void createAndSetCustomAnimationEffect( SdrObject* pObj );
118 
119 private: //private methods
120 
121     //read methods
122     ::rtl::OUString GetPresetId() const;
123     ::rtl::OUString GetPresetSubType() const;
124     bool HasAfterEffect() const;
125     bool HasAfterEffect_ChangeColor() const;
126     bool HasAfterEffect_DimAtNextEffect() const;
127 #ifdef FUTURE
128     bool HasAfterEffect_DimAfterEffect() const;
129 #endif
130     bool HasStopPreviousSound() const;
131     bool HasReverseOrder() const; //true if the text paragraphs should be animated in reverse order
132     sal_Int32 GetParagraphLevel() const; //paragraph level that is animated ( that paragraph and higher levels )
133     sal_Int16 GetTextAnimationType() const; //see com::sun::star::presentation::TextAnimationType
134     sal_Int16 GetEffectNodeType() const; //see com::sun::star::presentation::EffectNodeType
135     double GetDelayTimeInSeconds() const;//-1 for start on mouseclick or >= 0 for a delay in seconds for automatic start
136     bool GetSpecialDuration( double& rfDurationInSeconds ) const;
137     bool GetSpecialTextIterationDelay( double& rfTextIterationDelay ) const;
138 
139     void UpdateCacheData() const;
140     void ClearCacheData() const;
141 
142 private: //private member
143     //input information:
144     Ppt97AnimationInfoAtom  m_aAtom;//pure input from stream
145     ::rtl::OUString         m_aSoundFileUrl;//this needs to be set in addition from outside as this class has not the knowledge to translate the sound bits to a file url/
146 
147     //cached generated output information:
148     mutable bool            m_bDirtyCache;
149     mutable ::rtl::OUString m_aPresetId; // m_aPresetId and m_aSubType match to the values in sd/xml/effects.xml
150     mutable ::rtl::OUString m_aSubType;
151     mutable bool            m_bHasSpecialDuration;
152     mutable double          m_fDurationInSeconds;
153 };
154 
155 #endif
156