1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef INCLUDED_SLIDESHOW_GDIMTFTOOLS_HXX
29*cdf0e10cSrcweir #define INCLUDED_SLIDESHOW_GDIMTFTOOLS_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx>
32*cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPage.hpp>
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir #include <basegfx/range/b2drectangle.hxx>
37*cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include "tools.hxx"
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir #include <vector>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir class MetaAction;
44*cdf0e10cSrcweir class GDIMetaFile;
45*cdf0e10cSrcweir class Graphic;
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir // -----------------------------------------------------------------------------
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir namespace slideshow
50*cdf0e10cSrcweir {
51*cdf0e10cSrcweir     namespace internal
52*cdf0e10cSrcweir     {
53*cdf0e10cSrcweir         /// meta file loading specialities:
54*cdf0e10cSrcweir         enum mtf_load_flags {
55*cdf0e10cSrcweir             /// no flags
56*cdf0e10cSrcweir             MTF_LOAD_NONE = 0,
57*cdf0e10cSrcweir             /// annotate text actions with verbose comments,
58*cdf0e10cSrcweir             /// denoting logical and physical text entities.
59*cdf0e10cSrcweir             MTF_LOAD_VERBOSE_COMMENTS = 1,
60*cdf0e10cSrcweir             /// the source of the metafile might be a foreign
61*cdf0e10cSrcweir             /// application. The metafile is checked against unsupported
62*cdf0e10cSrcweir             /// content, and, if necessary, returned as a pre-rendererd
63*cdf0e10cSrcweir             /// bitmap.
64*cdf0e10cSrcweir             MTF_LOAD_FOREIGN_SOURCE = 2,
65*cdf0e10cSrcweir             /// retrieve a meta file for the page background only
66*cdf0e10cSrcweir             MTF_LOAD_BACKGROUND_ONLY = 4,
67*cdf0e10cSrcweir             /// retrieve the drawing layer scroll text metafile
68*cdf0e10cSrcweir             MTF_LOAD_SCROLL_TEXT_MTF = 8
69*cdf0e10cSrcweir         };
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir         // Animation info
72*cdf0e10cSrcweir         // ==============
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir         struct MtfAnimationFrame
75*cdf0e10cSrcweir         {
76*cdf0e10cSrcweir             MtfAnimationFrame( const GDIMetaFileSharedPtr& rMtf,
77*cdf0e10cSrcweir                                double					   nDuration ) :
78*cdf0e10cSrcweir                 mpMtf( rMtf ),
79*cdf0e10cSrcweir                 mnDuration( nDuration )
80*cdf0e10cSrcweir             {
81*cdf0e10cSrcweir             }
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir             /// Enables STL algos to be used for duration extraction
84*cdf0e10cSrcweir             double getDuration() const
85*cdf0e10cSrcweir             {
86*cdf0e10cSrcweir                 return mnDuration;
87*cdf0e10cSrcweir             }
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir             GDIMetaFileSharedPtr	mpMtf;
90*cdf0e10cSrcweir             double					mnDuration;
91*cdf0e10cSrcweir         };
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir         typedef ::std::vector< MtfAnimationFrame > VectorOfMtfAnimationFrames;
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir         /** Retrieve a meta file for the given shape
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir 			@param xShape
99*cdf0e10cSrcweir             XShape to retrieve a metafile for.
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir             @param xContainingPage
102*cdf0e10cSrcweir             The page that contains this shape. Needed for proper
103*cdf0e10cSrcweir             import (currently, the UnoGraphicExporter needs this
104*cdf0e10cSrcweir             information).
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir             @param o_rMtf
107*cdf0e10cSrcweir             Metafile to extract shape content into
108*cdf0e10cSrcweir         */
109*cdf0e10cSrcweir         bool getMetaFile( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >&     xSource,
110*cdf0e10cSrcweir                           const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >&	xContainingPage,
111*cdf0e10cSrcweir                           GDIMetaFile& 							                                    		o_rMtf,
112*cdf0e10cSrcweir                           int                                                                               mtfLoadFlags,
113*cdf0e10cSrcweir                           const ::com::sun::star::uno::Reference<
114*cdf0e10cSrcweir                               ::com::sun::star::uno::XComponentContext >&                                   rxContext );
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir         /** Remove all text actions from the given metafile.
117*cdf0e10cSrcweir          */
118*cdf0e10cSrcweir         void removeTextActions( GDIMetaFile& io_rMtf );
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir         /** Gets the next action offset for iterating meta actions which is most
121*cdf0e10cSrcweir             often returns 1.
122*cdf0e10cSrcweir         */
123*cdf0e10cSrcweir         sal_Int32 getNextActionOffset( MetaAction * pCurrAct );
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir         /** Extract a vector of animation frames from given Graphic.
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir         	@param o_rFrames
128*cdf0e10cSrcweir             Resulting vector of animated metafiles
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir             @param o_rLoopCount
131*cdf0e10cSrcweir             Number of times the bitmap animation shall be repeated
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir             @param o_eCycleMode
134*cdf0e10cSrcweir             Repeat mode (normal, or ping-pong mode)
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir             @param rGraphic
137*cdf0e10cSrcweir             Input graphic object, to extract animations from
138*cdf0e10cSrcweir          */
139*cdf0e10cSrcweir         bool getAnimationFromGraphic( VectorOfMtfAnimationFrames& o_rFrames,
140*cdf0e10cSrcweir                                       ::std::size_t&              o_rLoopCount,
141*cdf0e10cSrcweir                                       CycleMode&                  o_eCycleMode,
142*cdf0e10cSrcweir                                       const Graphic&              rGraphic );
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir         /** Retrieve scroll text animation rectangles from given metafile
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir             @return true, if both rectangles have been found, false
147*cdf0e10cSrcweir             otherwise.
148*cdf0e10cSrcweir          */
149*cdf0e10cSrcweir         bool getRectanglesFromScrollMtf( ::basegfx::B2DRectangle&       o_rScrollRect,
150*cdf0e10cSrcweir                                          ::basegfx::B2DRectangle&       o_rPaintRect,
151*cdf0e10cSrcweir                                          const GDIMetaFileSharedPtr&    rMtf );
152*cdf0e10cSrcweir     }
153*cdf0e10cSrcweir }
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir #endif /* INCLUDED_SLIDESHOW_GDIMTFTOOLS_HXX */
156