1*aaef562fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*aaef562fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*aaef562fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*aaef562fSAndrew Rist  * distributed with this work for additional information
6*aaef562fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*aaef562fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*aaef562fSAndrew Rist  * "License"); you may not use this file except in compliance
9*aaef562fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*aaef562fSAndrew Rist  *
11*aaef562fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*aaef562fSAndrew Rist  *
13*aaef562fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*aaef562fSAndrew Rist  * software distributed under the License is distributed on an
15*aaef562fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*aaef562fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*aaef562fSAndrew Rist  * specific language governing permissions and limitations
18*aaef562fSAndrew Rist  * under the License.
19*aaef562fSAndrew Rist  *
20*aaef562fSAndrew Rist  *************************************************************/
21*aaef562fSAndrew Rist 
22*aaef562fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef INCLUDED_SLIDESHOW_GDIMTFTOOLS_HXX
25cdf0e10cSrcweir #define INCLUDED_SLIDESHOW_GDIMTFTOOLS_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx>
28cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
29cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
30cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPage.hpp>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <basegfx/range/b2drectangle.hxx>
33cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include "tools.hxx"
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include <vector>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir class MetaAction;
40cdf0e10cSrcweir class GDIMetaFile;
41cdf0e10cSrcweir class Graphic;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir // -----------------------------------------------------------------------------
44cdf0e10cSrcweir 
45cdf0e10cSrcweir namespace slideshow
46cdf0e10cSrcweir {
47cdf0e10cSrcweir     namespace internal
48cdf0e10cSrcweir     {
49cdf0e10cSrcweir         /// meta file loading specialities:
50cdf0e10cSrcweir         enum mtf_load_flags {
51cdf0e10cSrcweir             /// no flags
52cdf0e10cSrcweir             MTF_LOAD_NONE = 0,
53cdf0e10cSrcweir             /// annotate text actions with verbose comments,
54cdf0e10cSrcweir             /// denoting logical and physical text entities.
55cdf0e10cSrcweir             MTF_LOAD_VERBOSE_COMMENTS = 1,
56cdf0e10cSrcweir             /// the source of the metafile might be a foreign
57cdf0e10cSrcweir             /// application. The metafile is checked against unsupported
58cdf0e10cSrcweir             /// content, and, if necessary, returned as a pre-rendererd
59cdf0e10cSrcweir             /// bitmap.
60cdf0e10cSrcweir             MTF_LOAD_FOREIGN_SOURCE = 2,
61cdf0e10cSrcweir             /// retrieve a meta file for the page background only
62cdf0e10cSrcweir             MTF_LOAD_BACKGROUND_ONLY = 4,
63cdf0e10cSrcweir             /// retrieve the drawing layer scroll text metafile
64cdf0e10cSrcweir             MTF_LOAD_SCROLL_TEXT_MTF = 8
65cdf0e10cSrcweir         };
66cdf0e10cSrcweir 
67cdf0e10cSrcweir         // Animation info
68cdf0e10cSrcweir         // ==============
69cdf0e10cSrcweir 
70cdf0e10cSrcweir         struct MtfAnimationFrame
71cdf0e10cSrcweir         {
MtfAnimationFrameslideshow::internal::MtfAnimationFrame72cdf0e10cSrcweir             MtfAnimationFrame( const GDIMetaFileSharedPtr& rMtf,
73cdf0e10cSrcweir                                double					   nDuration ) :
74cdf0e10cSrcweir                 mpMtf( rMtf ),
75cdf0e10cSrcweir                 mnDuration( nDuration )
76cdf0e10cSrcweir             {
77cdf0e10cSrcweir             }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir             /// Enables STL algos to be used for duration extraction
getDurationslideshow::internal::MtfAnimationFrame80cdf0e10cSrcweir             double getDuration() const
81cdf0e10cSrcweir             {
82cdf0e10cSrcweir                 return mnDuration;
83cdf0e10cSrcweir             }
84cdf0e10cSrcweir 
85cdf0e10cSrcweir             GDIMetaFileSharedPtr	mpMtf;
86cdf0e10cSrcweir             double					mnDuration;
87cdf0e10cSrcweir         };
88cdf0e10cSrcweir 
89cdf0e10cSrcweir         typedef ::std::vector< MtfAnimationFrame > VectorOfMtfAnimationFrames;
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 
92cdf0e10cSrcweir         /** Retrieve a meta file for the given shape
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 			@param xShape
95cdf0e10cSrcweir             XShape to retrieve a metafile for.
96cdf0e10cSrcweir 
97cdf0e10cSrcweir             @param xContainingPage
98cdf0e10cSrcweir             The page that contains this shape. Needed for proper
99cdf0e10cSrcweir             import (currently, the UnoGraphicExporter needs this
100cdf0e10cSrcweir             information).
101cdf0e10cSrcweir 
102cdf0e10cSrcweir             @param o_rMtf
103cdf0e10cSrcweir             Metafile to extract shape content into
104cdf0e10cSrcweir         */
105cdf0e10cSrcweir         bool getMetaFile( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >&     xSource,
106cdf0e10cSrcweir                           const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >&	xContainingPage,
107cdf0e10cSrcweir                           GDIMetaFile& 							                                    		o_rMtf,
108cdf0e10cSrcweir                           int                                                                               mtfLoadFlags,
109cdf0e10cSrcweir                           const ::com::sun::star::uno::Reference<
110cdf0e10cSrcweir                               ::com::sun::star::uno::XComponentContext >&                                   rxContext );
111cdf0e10cSrcweir 
112cdf0e10cSrcweir         /** Remove all text actions from the given metafile.
113cdf0e10cSrcweir          */
114cdf0e10cSrcweir         void removeTextActions( GDIMetaFile& io_rMtf );
115cdf0e10cSrcweir 
116cdf0e10cSrcweir         /** Gets the next action offset for iterating meta actions which is most
117cdf0e10cSrcweir             often returns 1.
118cdf0e10cSrcweir         */
119cdf0e10cSrcweir         sal_Int32 getNextActionOffset( MetaAction * pCurrAct );
120cdf0e10cSrcweir 
121cdf0e10cSrcweir         /** Extract a vector of animation frames from given Graphic.
122cdf0e10cSrcweir 
123cdf0e10cSrcweir         	@param o_rFrames
124cdf0e10cSrcweir             Resulting vector of animated metafiles
125cdf0e10cSrcweir 
126cdf0e10cSrcweir             @param o_rLoopCount
127cdf0e10cSrcweir             Number of times the bitmap animation shall be repeated
128cdf0e10cSrcweir 
129cdf0e10cSrcweir             @param o_eCycleMode
130cdf0e10cSrcweir             Repeat mode (normal, or ping-pong mode)
131cdf0e10cSrcweir 
132cdf0e10cSrcweir             @param rGraphic
133cdf0e10cSrcweir             Input graphic object, to extract animations from
134cdf0e10cSrcweir          */
135cdf0e10cSrcweir         bool getAnimationFromGraphic( VectorOfMtfAnimationFrames& o_rFrames,
136cdf0e10cSrcweir                                       ::std::size_t&              o_rLoopCount,
137cdf0e10cSrcweir                                       CycleMode&                  o_eCycleMode,
138cdf0e10cSrcweir                                       const Graphic&              rGraphic );
139cdf0e10cSrcweir 
140cdf0e10cSrcweir         /** Retrieve scroll text animation rectangles from given metafile
141cdf0e10cSrcweir 
142cdf0e10cSrcweir             @return true, if both rectangles have been found, false
143cdf0e10cSrcweir             otherwise.
144cdf0e10cSrcweir          */
145cdf0e10cSrcweir         bool getRectanglesFromScrollMtf( ::basegfx::B2DRectangle&       o_rScrollRect,
146cdf0e10cSrcweir                                          ::basegfx::B2DRectangle&       o_rPaintRect,
147cdf0e10cSrcweir                                          const GDIMetaFileSharedPtr&    rMtf );
148cdf0e10cSrcweir     }
149cdf0e10cSrcweir }
150cdf0e10cSrcweir 
151cdf0e10cSrcweir #endif /* INCLUDED_SLIDESHOW_GDIMTFTOOLS_HXX */
152