1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: testshape.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <cppunit/simpleheader.hxx>
32 #include <cppuhelper/compbase1.hxx>
33 #include <cppuhelper/basemutex.hxx>
34 #include <comphelper/make_shared_from_uno.hxx>
36 #include <basegfx/matrix/b2dhommatrix.hxx>
37 #include <basegfx/range/b2drange.hxx>
41 #include "com/sun/star/presentation/XSlideShowView.hpp"
43 #include <boost/bind.hpp>
45 namespace target
= slideshow::internal
;
46 using namespace ::com::sun::star
;
48 // our test shape subject
49 typedef ::cppu::WeakComponentImplHelper1
< drawing::XShape
> ShapeBase
;
50 class ImplTestShape
: public TestShape
,
51 private cppu::BaseMutex
,
54 typedef std::vector
<std::pair
<target::ViewLayerSharedPtr
,bool> > ViewVector
;
55 ViewVector maViewLayers
;
56 const basegfx::B2DRange maRect
;
59 mutable sal_Int32 mnNumUpdates
;
60 mutable sal_Int32 mnNumRenders
;
63 ImplTestShape( const basegfx::B2DRange
& rRect
,
65 ShapeBase( m_aMutex
),
77 virtual std::vector
<std::pair
<target::ViewLayerSharedPtr
,bool> > getViewLayers() const
81 virtual sal_Int32
getNumUpdates() const
85 virtual sal_Int32
getNumRenders() const
89 virtual sal_Int32
getAnimationCount() const
96 virtual ::rtl::OUString SAL_CALL
getShapeType( ) throw (uno::RuntimeException
)
98 CPPUNIT_ASSERT_MESSAGE( "TestShape::getShapeType: unexpected method call", false );
99 return ::rtl::OUString();
102 virtual awt::Point SAL_CALL
getPosition( ) throw (uno::RuntimeException
)
104 CPPUNIT_ASSERT_MESSAGE( "TestShape::getPosition: unexpected method call", false );
108 virtual void SAL_CALL
setPosition( const awt::Point
& ) throw (uno::RuntimeException
)
110 CPPUNIT_ASSERT_MESSAGE( "TestShape::setPosition: unexpected method call", false );
113 virtual awt::Size SAL_CALL
getSize( ) throw (uno::RuntimeException
)
115 CPPUNIT_ASSERT_MESSAGE( "TestShape::getSize: unexpected method call", false );
119 virtual void SAL_CALL
setSize( const awt::Size
& /*aSize*/ ) throw (beans::PropertyVetoException
, uno::RuntimeException
)
121 CPPUNIT_ASSERT_MESSAGE( "TestShape::setSize: unexpected method call", false );
125 //////////////////////////////////////////////////////////////////////////
129 virtual uno::Reference
< drawing::XShape
> getXShape() const
131 return uno::Reference
< drawing::XShape
>( const_cast<ImplTestShape
*>(this) );
133 virtual void addViewLayer( const target::ViewLayerSharedPtr
& rNewLayer
,
136 maViewLayers
.push_back( std::make_pair(rNewLayer
,bRedrawLayer
) );
138 virtual bool removeViewLayer( const target::ViewLayerSharedPtr
& rNewLayer
)
141 maViewLayers
.begin(),
143 boost::bind( std::equal_to
< target::ViewLayerSharedPtr
>(),
144 boost::cref( rNewLayer
),
145 boost::bind( std::select1st
<ViewVector::value_type
>(),
146 _1
))) == maViewLayers
.end() )
147 throw std::exception();
151 maViewLayers
.begin(),
153 boost::bind( std::equal_to
< target::ViewLayerSharedPtr
>(),
154 boost::cref( rNewLayer
),
155 boost::bind( std::select1st
<ViewVector::value_type
>(),
159 virtual bool clearAllViewLayers()
161 maViewLayers
.clear();
165 virtual bool update() const
170 virtual bool render() const
175 virtual bool isContentChanged() const
179 virtual ::basegfx::B2DRectangle
getBounds() const
183 virtual ::basegfx::B2DRectangle
getDomBounds() const
187 virtual ::basegfx::B2DRectangle
getUpdateArea() const
192 virtual bool isVisible() const
196 virtual double getPriority() const
200 virtual bool isBackgroundDetached() const
202 return mnAnimated
!= 0;
206 virtual void enterAnimationMode()
211 virtual void leaveAnimationMode()
218 TestShapeSharedPtr
createTestShape(const basegfx::B2DRange
& rRect
,
221 return TestShapeSharedPtr(
222 comphelper::make_shared_from_UNO(
223 new ImplTestShape(rRect
,nPrio
)) );