Look for libboostrap.uno.so and not bootstrap.uno.so on Android
[LibreOffice.git] / slideshow / test / testshape.cxx
blob5f3f3f0c5c85b37c278d71e44938f5a62fc59f47
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>
43 #include "shape.hxx"
44 #include "tests.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,
58 public ShapeBase
60 typedef std::vector<std::pair<target::ViewLayerSharedPtr,bool> > ViewVector;
61 ViewVector maViewLayers;
62 const basegfx::B2DRange maRect;
63 const double mnPrio;
64 sal_Int32 mnAnimated;
65 mutable sal_Int32 mnNumUpdates;
66 mutable sal_Int32 mnNumRenders;
68 public:
69 ImplTestShape( const basegfx::B2DRange& rRect,
70 double nPrio ) :
71 ShapeBase( m_aMutex ),
72 maViewLayers(),
73 maRect( rRect ),
74 mnPrio( nPrio ),
75 mnAnimated(0),
76 mnNumUpdates(0),
77 mnNumRenders(0)
81 private:
82 // TestShape
83 virtual std::vector<std::pair<target::ViewLayerSharedPtr,bool> > getViewLayers() const
85 return maViewLayers;
87 virtual sal_Int32 getNumUpdates() const
89 return mnNumUpdates;
91 virtual sal_Int32 getNumRenders() const
93 return mnNumRenders;
95 virtual sal_Int32 getAnimationCount() const
97 return mnAnimated;
101 // XShape
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 );
111 return awt::Point();
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 );
122 return awt::Size();
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 //////////////////////////////////////////////////////////////////////////
134 // Shape
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,
140 bool bRedrawLayer )
142 maViewLayers.push_back( std::make_pair(rNewLayer,bRedrawLayer) );
144 virtual bool removeViewLayer( const target::ViewLayerSharedPtr& rNewLayer )
146 if( std::find_if(
147 maViewLayers.begin(),
148 maViewLayers.end(),
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();
155 maViewLayers.erase(
156 std::remove_if(
157 maViewLayers.begin(),
158 maViewLayers.end(),
159 boost::bind( std::equal_to< target::ViewLayerSharedPtr >(),
160 boost::cref( rNewLayer ),
161 boost::bind( o3tl::select1st<ViewVector::value_type>(),
162 _1 ))));
163 return true;
165 virtual bool clearAllViewLayers()
167 maViewLayers.clear();
168 return true;
171 virtual bool update() const
173 ++mnNumUpdates;
174 return true;
176 virtual bool render() const
178 ++mnNumRenders;
179 return true;
181 virtual bool isContentChanged() const
183 return true;
185 virtual ::basegfx::B2DRectangle getBounds() const
187 return maRect;
189 virtual ::basegfx::B2DRectangle getDomBounds() const
191 return maRect;
193 virtual ::basegfx::B2DRectangle getUpdateArea() const
195 return maRect;
198 virtual bool isVisible() const
200 return true;
202 virtual double getPriority() const
204 return mnPrio;
206 virtual bool isBackgroundDetached() const
208 return mnAnimated != 0;
211 // AnimatableShape
212 virtual void enterAnimationMode()
214 ++mnAnimated;
217 virtual void leaveAnimationMode()
219 --mnAnimated;
224 TestShapeSharedPtr createTestShape(const basegfx::B2DRange& rRect,
225 double nPrio)
227 return TestShapeSharedPtr(
228 comphelper::make_shared_from_UNO(
229 new ImplTestShape(rRect,nPrio)) );
232 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */