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