xref: /AOO41X/main/slideshow/source/inc/tools.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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_TOOLS_HXX
29*cdf0e10cSrcweir #define INCLUDED_SLIDESHOW_TOOLS_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
32*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include <cppcanvas/color.hxx>
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir #include "shapeattributelayer.hxx"
37*cdf0e10cSrcweir #include "shape.hxx"
38*cdf0e10cSrcweir #include "rgbcolor.hxx"
39*cdf0e10cSrcweir #include "hslcolor.hxx"
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
42*cdf0e10cSrcweir #include <boost/current_function.hpp>
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir #include <functional>
45*cdf0e10cSrcweir #include <cstdlib>
46*cdf0e10cSrcweir #include <string.h> // for strcmp
47*cdf0e10cSrcweir #include <algorithm>
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace beans {
54*cdf0e10cSrcweir     struct NamedValue;
55*cdf0e10cSrcweir } } } }
56*cdf0e10cSrcweir namespace basegfx
57*cdf0e10cSrcweir {
58*cdf0e10cSrcweir     class B2DRange;
59*cdf0e10cSrcweir     class B2DVector;
60*cdf0e10cSrcweir     class B2IVector;
61*cdf0e10cSrcweir     class B2DHomMatrix;
62*cdf0e10cSrcweir }
63*cdf0e10cSrcweir namespace cppcanvas{ class Canvas; }
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir class GDIMetaFile;
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir /* Definition of some animation tools */
68*cdf0e10cSrcweir namespace slideshow
69*cdf0e10cSrcweir {
70*cdf0e10cSrcweir     namespace internal
71*cdf0e10cSrcweir     {
72*cdf0e10cSrcweir         class UnoView;
73*cdf0e10cSrcweir         class Shape;
74*cdf0e10cSrcweir         class ShapeAttributeLayer;
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir         typedef ::boost::shared_ptr< GDIMetaFile > GDIMetaFileSharedPtr;
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir         // xxx todo: remove with boost::hash when 1.33 is available
79*cdf0e10cSrcweir         template <typename T>
80*cdf0e10cSrcweir         struct hash : ::std::unary_function<T, ::std::size_t>
81*cdf0e10cSrcweir         {
82*cdf0e10cSrcweir             ::std::size_t operator()( T const& val ) const {
83*cdf0e10cSrcweir                 return hash_value(val);
84*cdf0e10cSrcweir             }
85*cdf0e10cSrcweir         };
86*cdf0e10cSrcweir         template <typename T>
87*cdf0e10cSrcweir         inline ::std::size_t hash_value( T * const& p )
88*cdf0e10cSrcweir         {
89*cdf0e10cSrcweir             ::std::size_t d = static_cast< ::std::size_t >(
90*cdf0e10cSrcweir                 reinterpret_cast< ::std::ptrdiff_t >(p) );
91*cdf0e10cSrcweir             return d + (d >> 3);
92*cdf0e10cSrcweir         }
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir         // xxx todo: shift to namespace com::sun::star::uno when
95*cdf0e10cSrcweir         //           1.33 is available
96*cdf0e10cSrcweir         template <typename T>
97*cdf0e10cSrcweir         inline ::std::size_t hash_value(
98*cdf0e10cSrcweir             ::com::sun::star::uno::Reference<T> const& x )
99*cdf0e10cSrcweir         {
100*cdf0e10cSrcweir             // normalize to object root, because _only_ XInterface is defined
101*cdf0e10cSrcweir             // to be stable during object lifetime:
102*cdf0e10cSrcweir             ::com::sun::star::uno::Reference<
103*cdf0e10cSrcweir                   ::com::sun::star::uno::XInterface> const xRoot(
104*cdf0e10cSrcweir                       x, ::com::sun::star::uno::UNO_QUERY );
105*cdf0e10cSrcweir             return hash<void *>()(xRoot.get());
106*cdf0e10cSrcweir         }
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir         /** Cycle mode of intrinsic animations
109*cdf0e10cSrcweir          */
110*cdf0e10cSrcweir         enum CycleMode
111*cdf0e10cSrcweir         {
112*cdf0e10cSrcweir             /// loop the animation back to back
113*cdf0e10cSrcweir             CYCLE_LOOP,
114*cdf0e10cSrcweir             /// loop, but play backwards from end to start
115*cdf0e10cSrcweir             CYCLE_PINGPONGLOOP
116*cdf0e10cSrcweir         };
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir         // Value extraction from Any
120*cdf0e10cSrcweir         // =========================
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir         /// extract unary double value from Any
123*cdf0e10cSrcweir 		bool extractValue( double&								o_rValue,
124*cdf0e10cSrcweir                            const ::com::sun::star::uno::Any& 	rSourceAny,
125*cdf0e10cSrcweir                            const boost::shared_ptr<Shape>&		rShape,
126*cdf0e10cSrcweir                            const basegfx::B2DVector&			rSlideBounds );
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir         /// extract int from Any
129*cdf0e10cSrcweir         bool extractValue( sal_Int32&							o_rValue,
130*cdf0e10cSrcweir                            const ::com::sun::star::uno::Any& 	rSourceAny,
131*cdf0e10cSrcweir                            const boost::shared_ptr<Shape>&		rShape,
132*cdf0e10cSrcweir                            const basegfx::B2DVector&			rSlideBounds );
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir         /// extract enum/constant group value from Any
135*cdf0e10cSrcweir         bool extractValue( sal_Int16&							o_rValue,
136*cdf0e10cSrcweir                            const ::com::sun::star::uno::Any& 	rSourceAny,
137*cdf0e10cSrcweir                            const boost::shared_ptr<Shape>&		rShape,
138*cdf0e10cSrcweir                            const basegfx::B2DVector&			rSlideBounds );
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir         /// extract color value from Any
141*cdf0e10cSrcweir         bool extractValue( RGBColor&							o_rValue,
142*cdf0e10cSrcweir                            const ::com::sun::star::uno::Any& 	rSourceAny,
143*cdf0e10cSrcweir                            const boost::shared_ptr<Shape>&		rShape,
144*cdf0e10cSrcweir                            const basegfx::B2DVector&			rSlideBounds );
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir         /// extract color value from Any
147*cdf0e10cSrcweir         bool extractValue( HSLColor&							o_rValue,
148*cdf0e10cSrcweir                            const ::com::sun::star::uno::Any& 	rSourceAny,
149*cdf0e10cSrcweir                            const boost::shared_ptr<Shape>&		rShape,
150*cdf0e10cSrcweir                            const basegfx::B2DVector&			rSlideBounds );
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir         /// extract plain string from Any
153*cdf0e10cSrcweir         bool extractValue( ::rtl::OUString&						o_rValue,
154*cdf0e10cSrcweir                            const ::com::sun::star::uno::Any& 	rSourceAny,
155*cdf0e10cSrcweir                            const boost::shared_ptr<Shape>&		rShape,
156*cdf0e10cSrcweir                            const basegfx::B2DVector&			rSlideBounds );
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir         /// extract bool value from Any
159*cdf0e10cSrcweir         bool extractValue( bool&								o_rValue,
160*cdf0e10cSrcweir                            const ::com::sun::star::uno::Any& 	rSourceAny,
161*cdf0e10cSrcweir                            const boost::shared_ptr<Shape>&		rShape,
162*cdf0e10cSrcweir                            const basegfx::B2DVector&			rSlideBounds );
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir         /// extract double 2-tuple from Any
165*cdf0e10cSrcweir         bool extractValue( basegfx::B2DTuple&					o_rPair,
166*cdf0e10cSrcweir                            const ::com::sun::star::uno::Any& 	rSourceAny,
167*cdf0e10cSrcweir                            const boost::shared_ptr<Shape>&		rShape,
168*cdf0e10cSrcweir                            const basegfx::B2DVector&			rSlideBounds );
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir         /** Search a sequence of NamedValues for a given element.
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir         	@return true, if the sequence contains the specified
173*cdf0e10cSrcweir         	element.
174*cdf0e10cSrcweir          */
175*cdf0e10cSrcweir         bool findNamedValue( ::com::sun::star::uno::Sequence<
176*cdf0e10cSrcweir                              	::com::sun::star::beans::NamedValue > const& rSequence,
177*cdf0e10cSrcweir                              const ::com::sun::star::beans::NamedValue&	rSearchKey );
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir         /** Search a sequence of NamedValues for an element with a given name.
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir         	@param o_pRet
182*cdf0e10cSrcweir             If non-NULL, receives the full NamedValue found (if it was
183*cdf0e10cSrcweir             found, that is).
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir         	@return true, if the sequence contains the specified
186*cdf0e10cSrcweir         	element.
187*cdf0e10cSrcweir          */
188*cdf0e10cSrcweir         bool findNamedValue( ::com::sun::star::beans::NamedValue* 		o_pRet,
189*cdf0e10cSrcweir                              const ::com::sun::star::uno::Sequence<
190*cdf0e10cSrcweir                              	::com::sun::star::beans::NamedValue >& 	rSequence,
191*cdf0e10cSrcweir                              const ::rtl::OUString&						rSearchString );
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir         basegfx::B2DRange calcRelativeShapeBounds( const basegfx::B2DVector& rPageSize,
194*cdf0e10cSrcweir                                                    const basegfx::B2DRange&  rShapeBounds );
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir         /** Get the shape transformation from the attribute set
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir 	        @param rBounds
199*cdf0e10cSrcweir             Original shape bound rect (to substitute default attribute
200*cdf0e10cSrcweir             layer values)
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir             @param pAttr
203*cdf0e10cSrcweir             Attribute set. Might be NULL (then, rBounds is used to set
204*cdf0e10cSrcweir             a simple scale and translate of the unit rect to rBounds).
205*cdf0e10cSrcweir         */
206*cdf0e10cSrcweir         basegfx::B2DHomMatrix getShapeTransformation(
207*cdf0e10cSrcweir             const basegfx::B2DRange&                      rBounds,
208*cdf0e10cSrcweir             const boost::shared_ptr<ShapeAttributeLayer>& pAttr );
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir         /** Get a shape's sprite transformation from the attribute set
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir 	        @param rPixelSize
213*cdf0e10cSrcweir             Pixel size of the sprite
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir             @param rOrigSize
216*cdf0e10cSrcweir             Original shape size (i.e. the size of the actual sprite
217*cdf0e10cSrcweir             content, in the user coordinate system)
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir             @param pAttr
220*cdf0e10cSrcweir             Attribute set. Might be NULL (then, rBounds is used to set
221*cdf0e10cSrcweir             a simple scale and translate of the unit rect to rBounds).
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir             @return the transformation to be applied to the sprite.
224*cdf0e10cSrcweir         */
225*cdf0e10cSrcweir         basegfx::B2DHomMatrix getSpriteTransformation(
226*cdf0e10cSrcweir             const basegfx::B2DVector&                     rPixelSize,
227*cdf0e10cSrcweir             const basegfx::B2DVector&                     rOrigSize,
228*cdf0e10cSrcweir             const boost::shared_ptr<ShapeAttributeLayer>& pAttr );
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir         /** Calc update area for a shape.
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir         	This method calculates the 'covered' area for the shape,
233*cdf0e10cSrcweir         	i.e. the rectangle that is affected when rendering the
234*cdf0e10cSrcweir         	shape. Apart from applying the given transformation to the
235*cdf0e10cSrcweir         	shape rectangle, this method also takes attributes into
236*cdf0e10cSrcweir         	account, which further scale the output (e.g. character
237*cdf0e10cSrcweir         	sizes).
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir             @param rUnitBounds
240*cdf0e10cSrcweir             Shape bounds, in the unit rect coordinate space
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir             @param rShapeTransform
243*cdf0e10cSrcweir             Transformation matrix the shape should undergo.
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir             @param pAttr
246*cdf0e10cSrcweir             Current shape attributes
247*cdf0e10cSrcweir          */
248*cdf0e10cSrcweir         basegfx::B2DRange getShapeUpdateArea(
249*cdf0e10cSrcweir             const basegfx::B2DRange&                      rUnitBounds,
250*cdf0e10cSrcweir             const basegfx::B2DHomMatrix&                  rShapeTransform,
251*cdf0e10cSrcweir             const boost::shared_ptr<ShapeAttributeLayer>& pAttr );
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir         /** Calc update area for a shape.
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir         	This method calculates the 'covered' area for the shape,
256*cdf0e10cSrcweir         	i.e. the rectangle that is affected when rendering the
257*cdf0e10cSrcweir         	shape. The difference from the other getShapeUpdateArea()
258*cdf0e10cSrcweir         	method is the fact that this one works without
259*cdf0e10cSrcweir         	ShapeAttributeLayer, and only scales up the given shape
260*cdf0e10cSrcweir         	user coordinate bound rect. The method is typically used
261*cdf0e10cSrcweir         	to retrieve user coordinate system bound rects for shapes
262*cdf0e10cSrcweir         	which are smaller than the default unit bound rect
263*cdf0e10cSrcweir         	(because e.g. of subsetting)
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir             @param rUnitBounds
266*cdf0e10cSrcweir             Shape bounds, in the unit rect coordinate space
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir             @param rShapeBounds
269*cdf0e10cSrcweir             Current shape bounding box in user coordinate space.
270*cdf0e10cSrcweir          */
271*cdf0e10cSrcweir         basegfx::B2DRange getShapeUpdateArea( const basegfx::B2DRange& rUnitBounds,
272*cdf0e10cSrcweir                                               const basegfx::B2DRange& rShapeBounds );
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir         /** Calc output position and size of shape, according to given
275*cdf0e10cSrcweir             attribute layer.
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir             Rotations, shears etc. and not taken into account,
278*cdf0e10cSrcweir             i.e. the returned rectangle is NOT the bounding box. Use
279*cdf0e10cSrcweir             it as if aBounds.getMinimum() is the output position and
280*cdf0e10cSrcweir             aBounds.getRange() the scaling of the shape.
281*cdf0e10cSrcweir          */
282*cdf0e10cSrcweir         basegfx::B2DRange getShapePosSize(
283*cdf0e10cSrcweir             const basegfx::B2DRange&                      rOrigBounds,
284*cdf0e10cSrcweir             const boost::shared_ptr<ShapeAttributeLayer>& pAttr );
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir         /** Convert a plain UNO API 32 bit int to RGBColor
287*cdf0e10cSrcweir          */
288*cdf0e10cSrcweir         RGBColor unoColor2RGBColor( sal_Int32 );
289*cdf0e10cSrcweir         /** Convert an IntSRGBA to plain UNO API 32 bit int
290*cdf0e10cSrcweir          */
291*cdf0e10cSrcweir         sal_Int32 RGBAColor2UnoColor( cppcanvas::Color::IntSRGBA );
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir         /** Fill a plain rectangle on the given canvas with the given color
294*cdf0e10cSrcweir          */
295*cdf0e10cSrcweir         void fillRect( const boost::shared_ptr< cppcanvas::Canvas >& rCanvas,
296*cdf0e10cSrcweir                        const basegfx::B2DRange&                      rRect,
297*cdf0e10cSrcweir                        cppcanvas::Color::IntSRGBA                    aFillColor );
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir         /** Init canvas with default background (white)
300*cdf0e10cSrcweir          */
301*cdf0e10cSrcweir         void initSlideBackground( const boost::shared_ptr< cppcanvas::Canvas >& rCanvas,
302*cdf0e10cSrcweir                                   const basegfx::B2IVector&                     rSize );
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir         /// Gets a random ordinal [0,n)
305*cdf0e10cSrcweir         inline ::std::size_t getRandomOrdinal( const ::std::size_t n )
306*cdf0e10cSrcweir         {
307*cdf0e10cSrcweir             return static_cast< ::std::size_t >(
308*cdf0e10cSrcweir                 double(n) * rand() / (RAND_MAX + 1.0) );
309*cdf0e10cSrcweir         }
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir         /// To work around ternary operator in initializer lists
312*cdf0e10cSrcweir         /// (Solaris compiler problems)
313*cdf0e10cSrcweir         template <typename T>
314*cdf0e10cSrcweir         inline T const & ternary_op(
315*cdf0e10cSrcweir             const bool cond, T const & arg1, T const & arg2 )
316*cdf0e10cSrcweir         {
317*cdf0e10cSrcweir             if (cond)
318*cdf0e10cSrcweir                 return arg1;
319*cdf0e10cSrcweir             else
320*cdf0e10cSrcweir                 return arg2;
321*cdf0e10cSrcweir         }
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir         template <typename ValueType>
324*cdf0e10cSrcweir         inline bool getPropertyValue(
325*cdf0e10cSrcweir             ValueType & rValue,
326*cdf0e10cSrcweir             com::sun::star::uno::Reference<
327*cdf0e10cSrcweir             com::sun::star::beans::XPropertySet> const & xPropSet,
328*cdf0e10cSrcweir             rtl::OUString const & propName )
329*cdf0e10cSrcweir         {
330*cdf0e10cSrcweir             try {
331*cdf0e10cSrcweir                 const com::sun::star::uno::Any& a(
332*cdf0e10cSrcweir                     xPropSet->getPropertyValue( propName ) );
333*cdf0e10cSrcweir                 bool const bRet = (a >>= rValue);
334*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
335*cdf0e10cSrcweir                 if( !bRet )
336*cdf0e10cSrcweir                     OSL_TRACE( "%s: while retrieving property %s, cannot extract Any of type %s\n",
337*cdf0e10cSrcweir                                ::rtl::OUStringToOString( propName,
338*cdf0e10cSrcweir                                                          RTL_TEXTENCODING_ASCII_US ).getStr(),
339*cdf0e10cSrcweir                                BOOST_CURRENT_FUNCTION,
340*cdf0e10cSrcweir                                ::rtl::OUStringToOString( a.getValueTypeRef()->pTypeName,
341*cdf0e10cSrcweir                                                          RTL_TEXTENCODING_ASCII_US ).getStr() );
342*cdf0e10cSrcweir #endif
343*cdf0e10cSrcweir                 return bRet;
344*cdf0e10cSrcweir             }
345*cdf0e10cSrcweir             catch (com::sun::star::uno::RuntimeException &)
346*cdf0e10cSrcweir             {
347*cdf0e10cSrcweir                 throw;
348*cdf0e10cSrcweir             }
349*cdf0e10cSrcweir             catch (com::sun::star::uno::Exception &)
350*cdf0e10cSrcweir             {
351*cdf0e10cSrcweir                 return false;
352*cdf0e10cSrcweir             }
353*cdf0e10cSrcweir         }
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir         template <typename ValueType>
356*cdf0e10cSrcweir         inline bool getPropertyValue(
357*cdf0e10cSrcweir             com::sun::star::uno::Reference< ValueType >& rIfc,
358*cdf0e10cSrcweir             com::sun::star::uno::Reference<
359*cdf0e10cSrcweir             com::sun::star::beans::XPropertySet> const & xPropSet,
360*cdf0e10cSrcweir             rtl::OUString const & propName )
361*cdf0e10cSrcweir         {
362*cdf0e10cSrcweir             try
363*cdf0e10cSrcweir             {
364*cdf0e10cSrcweir                 const com::sun::star::uno::Any& a(
365*cdf0e10cSrcweir                     xPropSet->getPropertyValue( propName ));
366*cdf0e10cSrcweir                 rIfc.set( a,
367*cdf0e10cSrcweir                           com::sun::star::uno::UNO_QUERY );
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir                 bool const bRet = rIfc.is();
370*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
371*cdf0e10cSrcweir                 if( !bRet )
372*cdf0e10cSrcweir                     OSL_TRACE( "%s: while retrieving property %s, cannot extract Any of type %s to interface\n",
373*cdf0e10cSrcweir                                ::rtl::OUStringToOString( propName,
374*cdf0e10cSrcweir                                                          RTL_TEXTENCODING_ASCII_US ).getStr(),
375*cdf0e10cSrcweir                                BOOST_CURRENT_FUNCTION,
376*cdf0e10cSrcweir                                ::rtl::OUStringToOString( a.getValueTypeRef()->pTypeName,
377*cdf0e10cSrcweir                                                          RTL_TEXTENCODING_ASCII_US ).getStr() );
378*cdf0e10cSrcweir #endif
379*cdf0e10cSrcweir                 return bRet;
380*cdf0e10cSrcweir             }
381*cdf0e10cSrcweir             catch (com::sun::star::uno::RuntimeException &)
382*cdf0e10cSrcweir             {
383*cdf0e10cSrcweir                 throw;
384*cdf0e10cSrcweir             }
385*cdf0e10cSrcweir             catch (com::sun::star::uno::Exception &)
386*cdf0e10cSrcweir             {
387*cdf0e10cSrcweir                 return false;
388*cdf0e10cSrcweir             }
389*cdf0e10cSrcweir         }
390*cdf0e10cSrcweir 
391*cdf0e10cSrcweir         /// Get the content of the BoundRect shape property
392*cdf0e10cSrcweir         basegfx::B2DRange getAPIShapeBounds( const ::com::sun::star::uno::Reference<
393*cdf0e10cSrcweir                                                 ::com::sun::star::drawing::XShape >& xShape );
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir         /// Get the content of the ZOrder shape property
396*cdf0e10cSrcweir         double getAPIShapePrio( const ::com::sun::star::uno::Reference<
397*cdf0e10cSrcweir                                       ::com::sun::star::drawing::XShape >& xShape );
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir         basegfx::B2IVector getSlideSizePixel( const basegfx::B2DVector&         rSize,
400*cdf0e10cSrcweir                                               const boost::shared_ptr<UnoView>& pView );
401*cdf0e10cSrcweir     }
402*cdf0e10cSrcweir }
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir #endif /* INCLUDED_SLIDESHOW_TOOLS_HXX */
405