1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "sal/config.h"
30 #include "sal/precppunit.hxx"
32 #include <cppunit/TestAssert.h>
33 #include <cppunit/TestFixture.h>
34 #include <cppunit/extensions/HelperMacros.h>
36 #include <cppuhelper/compbase1.hxx>
37 #include <cppuhelper/basemutex.hxx>
38 #include <comphelper/make_shared_from_uno.hxx>
40 #include <basegfx/matrix/b2dhommatrix.hxx>
41 #include <basegfx/range/b2drange.hxx>
45 #include "com/sun/star/presentation/XSlideShowView.hpp"
47 #include <o3tl/compat_functional.hxx>
49 #include <boost/bind.hpp>
51 namespace target
= slideshow::internal
;
52 using namespace ::com::sun::star
;
54 // our test shape subject
55 typedef ::cppu::WeakComponentImplHelper1
< drawing::XShape
> ShapeBase
;
56 class ImplTestShape
: public TestShape
,
57 private cppu::BaseMutex
,
60 typedef std::vector
<std::pair
<target::ViewLayerSharedPtr
,bool> > ViewVector
;
61 ViewVector maViewLayers
;
62 const basegfx::B2DRange maRect
;
65 mutable sal_Int32 mnNumUpdates
;
66 mutable sal_Int32 mnNumRenders
;
69 ImplTestShape( const basegfx::B2DRange
& rRect
,
71 ShapeBase( m_aMutex
),
83 virtual std::vector
<std::pair
<target::ViewLayerSharedPtr
,bool> > getViewLayers() const
87 virtual sal_Int32
getNumUpdates() const
91 virtual sal_Int32
getNumRenders() const
95 virtual sal_Int32
getAnimationCount() const
102 virtual ::rtl::OUString SAL_CALL
getShapeType( ) throw (uno::RuntimeException
)
104 CPPUNIT_ASSERT_MESSAGE( "TestShape::getShapeType: unexpected method call", false );
105 return ::rtl::OUString();
108 virtual awt::Point SAL_CALL
getPosition( ) throw (uno::RuntimeException
)
110 CPPUNIT_ASSERT_MESSAGE( "TestShape::getPosition: unexpected method call", false );
114 virtual void SAL_CALL
setPosition( const awt::Point
& ) throw (uno::RuntimeException
)
116 CPPUNIT_ASSERT_MESSAGE( "TestShape::setPosition: unexpected method call", false );
119 virtual awt::Size SAL_CALL
getSize( ) throw (uno::RuntimeException
)
121 CPPUNIT_ASSERT_MESSAGE( "TestShape::getSize: unexpected method call", false );
125 virtual void SAL_CALL
setSize( const awt::Size
& /*aSize*/ ) throw (beans::PropertyVetoException
, uno::RuntimeException
)
127 CPPUNIT_ASSERT_MESSAGE( "TestShape::setSize: unexpected method call", false );
131 //////////////////////////////////////////////////////////////////////////
135 virtual uno::Reference
< drawing::XShape
> getXShape() const
137 return uno::Reference
< drawing::XShape
>( const_cast<ImplTestShape
*>(this) );
139 virtual void addViewLayer( const target::ViewLayerSharedPtr
& rNewLayer
,
142 maViewLayers
.push_back( std::make_pair(rNewLayer
,bRedrawLayer
) );
144 virtual bool removeViewLayer( const target::ViewLayerSharedPtr
& rNewLayer
)
147 maViewLayers
.begin(),
149 boost::bind( std::equal_to
< target::ViewLayerSharedPtr
>(),
150 boost::cref( rNewLayer
),
151 boost::bind( o3tl::select1st
<ViewVector::value_type
>(),
152 _1
))) == maViewLayers
.end() )
153 throw std::exception();
157 maViewLayers
.begin(),
159 boost::bind( std::equal_to
< target::ViewLayerSharedPtr
>(),
160 boost::cref( rNewLayer
),
161 boost::bind( o3tl::select1st
<ViewVector::value_type
>(),
165 virtual bool clearAllViewLayers()
167 maViewLayers
.clear();
171 virtual bool update() const
176 virtual bool render() const
181 virtual bool isContentChanged() const
185 virtual ::basegfx::B2DRectangle
getBounds() const
189 virtual ::basegfx::B2DRectangle
getDomBounds() const
193 virtual ::basegfx::B2DRectangle
getUpdateArea() const
198 virtual bool isVisible() const
202 virtual double getPriority() const
206 virtual bool isBackgroundDetached() const
208 return mnAnimated
!= 0;
212 virtual void enterAnimationMode()
217 virtual void leaveAnimationMode()
224 TestShapeSharedPtr
createTestShape(const basegfx::B2DRange
& rRect
,
227 return TestShapeSharedPtr(
228 comphelper::make_shared_from_UNO(
229 new ImplTestShape(rRect
,nPrio
)) );
232 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */