fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / slideshow / test / testshape.cxx
blob46173d9dcc5aac9230c33ce30c5802183b9cfcd6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/types.h>
21 #include <cppunit/TestAssert.h>
22 #include <cppunit/TestFixture.h>
23 #include <cppunit/extensions/HelperMacros.h>
25 #include <cppuhelper/compbase1.hxx>
26 #include <cppuhelper/basemutex.hxx>
27 #include <comphelper/make_shared_from_uno.hxx>
29 #include <basegfx/matrix/b2dhommatrix.hxx>
30 #include <basegfx/range/b2drange.hxx>
32 #include "shape.hxx"
33 #include "tests.hxx"
34 #include "com/sun/star/presentation/XSlideShowView.hpp"
36 #include <o3tl/compat_functional.hxx>
38 #include <boost/bind.hpp>
40 namespace target = slideshow::internal;
41 using namespace ::com::sun::star;
43 // our test shape subject
44 typedef ::cppu::WeakComponentImplHelper1< drawing::XShape > ShapeBase;
45 class ImplTestShape : public TestShape,
46 private cppu::BaseMutex,
47 public ShapeBase
49 typedef std::vector<std::pair<target::ViewLayerSharedPtr,bool> > ViewVector;
50 ViewVector maViewLayers;
51 const basegfx::B2DRange maRect;
52 const double mnPrio;
53 sal_Int32 mnAnimated;
54 mutable sal_Int32 mnNumUpdates;
55 mutable sal_Int32 mnNumRenders;
57 public:
58 ImplTestShape( const basegfx::B2DRange& rRect,
59 double nPrio ) :
60 ShapeBase( m_aMutex ),
61 maViewLayers(),
62 maRect( rRect ),
63 mnPrio( nPrio ),
64 mnAnimated(0),
65 mnNumUpdates(0),
66 mnNumRenders(0)
70 private:
71 // TestShape
72 virtual std::vector<std::pair<target::ViewLayerSharedPtr,bool> > getViewLayers() const
74 return maViewLayers;
76 virtual sal_Int32 getNumUpdates() const
78 return mnNumUpdates;
80 virtual sal_Int32 getNumRenders() const
82 return mnNumRenders;
85 // XShape
86 virtual OUString SAL_CALL getShapeType( ) throw (uno::RuntimeException)
88 CPPUNIT_ASSERT_MESSAGE( "TestShape::getShapeType: unexpected method call", false );
89 return OUString();
92 virtual awt::Point SAL_CALL getPosition( ) throw (uno::RuntimeException)
94 CPPUNIT_ASSERT_MESSAGE( "TestShape::getPosition: unexpected method call", false );
95 return awt::Point();
98 virtual void SAL_CALL setPosition( const awt::Point& ) throw (uno::RuntimeException)
100 CPPUNIT_ASSERT_MESSAGE( "TestShape::setPosition: unexpected method call", false );
103 virtual awt::Size SAL_CALL getSize( ) throw (uno::RuntimeException)
105 CPPUNIT_ASSERT_MESSAGE( "TestShape::getSize: unexpected method call", false );
106 return awt::Size();
109 virtual void SAL_CALL setSize( const awt::Size& /*aSize*/ ) throw (beans::PropertyVetoException, uno::RuntimeException)
111 CPPUNIT_ASSERT_MESSAGE( "TestShape::setSize: unexpected method call", false );
118 // Shape
119 virtual uno::Reference< drawing::XShape > getXShape() const
121 return uno::Reference< drawing::XShape >( const_cast<ImplTestShape*>(this) );
123 virtual void addViewLayer( const target::ViewLayerSharedPtr& rNewLayer,
124 bool bRedrawLayer )
126 maViewLayers.push_back( std::make_pair(rNewLayer,bRedrawLayer) );
128 virtual bool removeViewLayer( const target::ViewLayerSharedPtr& rNewLayer )
130 if( std::none_of(
131 maViewLayers.begin(),
132 maViewLayers.end(),
133 boost::bind( std::equal_to< target::ViewLayerSharedPtr >(),
134 boost::cref( rNewLayer ),
135 boost::bind( o3tl::select1st<ViewVector::value_type>(),
136 _1 ))) )
137 throw std::exception();
139 maViewLayers.erase(
140 std::remove_if(
141 maViewLayers.begin(),
142 maViewLayers.end(),
143 boost::bind( std::equal_to< target::ViewLayerSharedPtr >(),
144 boost::cref( rNewLayer ),
145 boost::bind( o3tl::select1st<ViewVector::value_type>(),
146 _1 ))));
147 return true;
149 virtual bool clearAllViewLayers()
151 maViewLayers.clear();
152 return true;
155 virtual bool update() const
157 ++mnNumUpdates;
158 return true;
160 virtual bool render() const
162 ++mnNumRenders;
163 return true;
165 virtual bool isContentChanged() const
167 return true;
169 virtual ::basegfx::B2DRectangle getBounds() const
171 return maRect;
173 virtual ::basegfx::B2DRectangle getDomBounds() const
175 return maRect;
177 virtual ::basegfx::B2DRectangle getUpdateArea() const
179 return maRect;
182 virtual bool isVisible() const
184 return true;
186 virtual double getPriority() const
188 return mnPrio;
190 virtual bool isBackgroundDetached() const
192 return mnAnimated != 0;
195 // AnimatableShape
196 virtual void enterAnimationMode()
198 ++mnAnimated;
201 virtual void leaveAnimationMode()
203 --mnAnimated;
208 TestShapeSharedPtr createTestShape(const basegfx::B2DRange& rRect,
209 double nPrio)
211 return TestShapeSharedPtr(
212 comphelper::make_shared_from_UNO(
213 new ImplTestShape(rRect,nPrio)) );
216 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */