1*70f497fbSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*70f497fbSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*70f497fbSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*70f497fbSAndrew Rist * distributed with this work for additional information
6*70f497fbSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*70f497fbSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*70f497fbSAndrew Rist * "License"); you may not use this file except in compliance
9*70f497fbSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*70f497fbSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*70f497fbSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*70f497fbSAndrew Rist * software distributed under the License is distributed on an
15*70f497fbSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*70f497fbSAndrew Rist * KIND, either express or implied. See the License for the
17*70f497fbSAndrew Rist * specific language governing permissions and limitations
18*70f497fbSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*70f497fbSAndrew Rist *************************************************************/
21*70f497fbSAndrew Rist
22*70f497fbSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #include <testshl/simpleheader.hxx>
25cdf0e10cSrcweir #include <cppuhelper/compbase1.hxx>
26cdf0e10cSrcweir #include <cppuhelper/basemutex.hxx>
27cdf0e10cSrcweir #include <comphelper/make_shared_from_uno.hxx>
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
30cdf0e10cSrcweir #include <basegfx/range/b2drange.hxx>
31cdf0e10cSrcweir
32cdf0e10cSrcweir #include "shape.hxx"
33cdf0e10cSrcweir #include "tests.hxx"
34cdf0e10cSrcweir #include "com/sun/star/presentation/XSlideShowView.hpp"
35cdf0e10cSrcweir
36cdf0e10cSrcweir #include <boost/bind.hpp>
37cdf0e10cSrcweir
38cdf0e10cSrcweir namespace target = slideshow::internal;
39cdf0e10cSrcweir using namespace ::com::sun::star;
40cdf0e10cSrcweir
41cdf0e10cSrcweir // our test shape subject
42cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper1< drawing::XShape > ShapeBase;
43cdf0e10cSrcweir class ImplTestShape : public TestShape,
44cdf0e10cSrcweir private cppu::BaseMutex,
45cdf0e10cSrcweir public ShapeBase
46cdf0e10cSrcweir {
47cdf0e10cSrcweir typedef std::vector<std::pair<target::ViewLayerSharedPtr,bool> > ViewVector;
48cdf0e10cSrcweir ViewVector maViewLayers;
49cdf0e10cSrcweir const basegfx::B2DRange maRect;
50cdf0e10cSrcweir const double mnPrio;
51cdf0e10cSrcweir sal_Int32 mnAnimated;
52cdf0e10cSrcweir mutable sal_Int32 mnNumUpdates;
53cdf0e10cSrcweir mutable sal_Int32 mnNumRenders;
54cdf0e10cSrcweir
55cdf0e10cSrcweir public:
ImplTestShape(const basegfx::B2DRange & rRect,double nPrio)56cdf0e10cSrcweir ImplTestShape( const basegfx::B2DRange& rRect,
57cdf0e10cSrcweir double nPrio ) :
58cdf0e10cSrcweir ShapeBase( m_aMutex ),
59cdf0e10cSrcweir maViewLayers(),
60cdf0e10cSrcweir maRect( rRect ),
61cdf0e10cSrcweir mnPrio( nPrio ),
62cdf0e10cSrcweir mnAnimated(0),
63cdf0e10cSrcweir mnNumUpdates(0),
64cdf0e10cSrcweir mnNumRenders(0)
65cdf0e10cSrcweir {}
66cdf0e10cSrcweir
67cdf0e10cSrcweir
68cdf0e10cSrcweir private:
69cdf0e10cSrcweir // TestShape
getViewLayers() const70cdf0e10cSrcweir virtual std::vector<std::pair<target::ViewLayerSharedPtr,bool> > getViewLayers() const
71cdf0e10cSrcweir {
72cdf0e10cSrcweir return maViewLayers;
73cdf0e10cSrcweir }
getNumUpdates() const74cdf0e10cSrcweir virtual sal_Int32 getNumUpdates() const
75cdf0e10cSrcweir {
76cdf0e10cSrcweir return mnNumUpdates;
77cdf0e10cSrcweir }
getNumRenders() const78cdf0e10cSrcweir virtual sal_Int32 getNumRenders() const
79cdf0e10cSrcweir {
80cdf0e10cSrcweir return mnNumRenders;
81cdf0e10cSrcweir }
getAnimationCount() const82cdf0e10cSrcweir virtual sal_Int32 getAnimationCount() const
83cdf0e10cSrcweir {
84cdf0e10cSrcweir return mnAnimated;
85cdf0e10cSrcweir }
86cdf0e10cSrcweir
87cdf0e10cSrcweir
88cdf0e10cSrcweir // XShape
getShapeType()89cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getShapeType( ) throw (uno::RuntimeException)
90cdf0e10cSrcweir {
91cdf0e10cSrcweir CPPUNIT_ASSERT_MESSAGE( "TestShape::getShapeType: unexpected method call", false );
92cdf0e10cSrcweir return ::rtl::OUString();
93cdf0e10cSrcweir }
94cdf0e10cSrcweir
getPosition()95cdf0e10cSrcweir virtual awt::Point SAL_CALL getPosition( ) throw (uno::RuntimeException)
96cdf0e10cSrcweir {
97cdf0e10cSrcweir CPPUNIT_ASSERT_MESSAGE( "TestShape::getPosition: unexpected method call", false );
98cdf0e10cSrcweir return awt::Point();
99cdf0e10cSrcweir }
100cdf0e10cSrcweir
setPosition(const awt::Point &)101cdf0e10cSrcweir virtual void SAL_CALL setPosition( const awt::Point& ) throw (uno::RuntimeException)
102cdf0e10cSrcweir {
103cdf0e10cSrcweir CPPUNIT_ASSERT_MESSAGE( "TestShape::setPosition: unexpected method call", false );
104cdf0e10cSrcweir }
105cdf0e10cSrcweir
getSize()106cdf0e10cSrcweir virtual awt::Size SAL_CALL getSize( ) throw (uno::RuntimeException)
107cdf0e10cSrcweir {
108cdf0e10cSrcweir CPPUNIT_ASSERT_MESSAGE( "TestShape::getSize: unexpected method call", false );
109cdf0e10cSrcweir return awt::Size();
110cdf0e10cSrcweir }
111cdf0e10cSrcweir
setSize(const awt::Size &)112cdf0e10cSrcweir virtual void SAL_CALL setSize( const awt::Size& /*aSize*/ ) throw (beans::PropertyVetoException, uno::RuntimeException)
113cdf0e10cSrcweir {
114cdf0e10cSrcweir CPPUNIT_ASSERT_MESSAGE( "TestShape::setSize: unexpected method call", false );
115cdf0e10cSrcweir }
116cdf0e10cSrcweir
117cdf0e10cSrcweir
118cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////
119cdf0e10cSrcweir
120cdf0e10cSrcweir
121cdf0e10cSrcweir // Shape
getXShape() const122cdf0e10cSrcweir virtual uno::Reference< drawing::XShape > getXShape() const
123cdf0e10cSrcweir {
124cdf0e10cSrcweir return uno::Reference< drawing::XShape >( const_cast<ImplTestShape*>(this) );
125cdf0e10cSrcweir }
addViewLayer(const target::ViewLayerSharedPtr & rNewLayer,bool bRedrawLayer)126cdf0e10cSrcweir virtual void addViewLayer( const target::ViewLayerSharedPtr& rNewLayer,
127cdf0e10cSrcweir bool bRedrawLayer )
128cdf0e10cSrcweir {
129cdf0e10cSrcweir maViewLayers.push_back( std::make_pair(rNewLayer,bRedrawLayer) );
130cdf0e10cSrcweir }
removeViewLayer(const target::ViewLayerSharedPtr & rNewLayer)131cdf0e10cSrcweir virtual bool removeViewLayer( const target::ViewLayerSharedPtr& rNewLayer )
132cdf0e10cSrcweir {
133cdf0e10cSrcweir if( std::find_if(
134cdf0e10cSrcweir maViewLayers.begin(),
135cdf0e10cSrcweir maViewLayers.end(),
136cdf0e10cSrcweir boost::bind( std::equal_to< target::ViewLayerSharedPtr >(),
137cdf0e10cSrcweir boost::cref( rNewLayer ),
138cdf0e10cSrcweir boost::bind( std::select1st<ViewVector::value_type>(),
139cdf0e10cSrcweir _1 ))) == maViewLayers.end() )
140cdf0e10cSrcweir throw std::exception();
141cdf0e10cSrcweir
142cdf0e10cSrcweir maViewLayers.erase(
143cdf0e10cSrcweir std::remove_if(
144cdf0e10cSrcweir maViewLayers.begin(),
145cdf0e10cSrcweir maViewLayers.end(),
146cdf0e10cSrcweir boost::bind( std::equal_to< target::ViewLayerSharedPtr >(),
147cdf0e10cSrcweir boost::cref( rNewLayer ),
148cdf0e10cSrcweir boost::bind( std::select1st<ViewVector::value_type>(),
149cdf0e10cSrcweir _1 ))));
150cdf0e10cSrcweir return true;
151cdf0e10cSrcweir }
clearAllViewLayers()152cdf0e10cSrcweir virtual bool clearAllViewLayers()
153cdf0e10cSrcweir {
154cdf0e10cSrcweir maViewLayers.clear();
155cdf0e10cSrcweir return true;
156cdf0e10cSrcweir }
157cdf0e10cSrcweir
update() const158cdf0e10cSrcweir virtual bool update() const
159cdf0e10cSrcweir {
160cdf0e10cSrcweir ++mnNumUpdates;
161cdf0e10cSrcweir return true;
162cdf0e10cSrcweir }
render() const163cdf0e10cSrcweir virtual bool render() const
164cdf0e10cSrcweir {
165cdf0e10cSrcweir ++mnNumRenders;
166cdf0e10cSrcweir return true;
167cdf0e10cSrcweir }
isContentChanged() const168cdf0e10cSrcweir virtual bool isContentChanged() const
169cdf0e10cSrcweir {
170cdf0e10cSrcweir return true;
171cdf0e10cSrcweir }
getBounds() const172cdf0e10cSrcweir virtual ::basegfx::B2DRectangle getBounds() const
173cdf0e10cSrcweir {
174cdf0e10cSrcweir return maRect;
175cdf0e10cSrcweir }
getDomBounds() const176cdf0e10cSrcweir virtual ::basegfx::B2DRectangle getDomBounds() const
177cdf0e10cSrcweir {
178cdf0e10cSrcweir return maRect;
179cdf0e10cSrcweir }
getUpdateArea() const180cdf0e10cSrcweir virtual ::basegfx::B2DRectangle getUpdateArea() const
181cdf0e10cSrcweir {
182cdf0e10cSrcweir return maRect;
183cdf0e10cSrcweir }
184cdf0e10cSrcweir
isVisible() const185cdf0e10cSrcweir virtual bool isVisible() const
186cdf0e10cSrcweir {
187cdf0e10cSrcweir return true;
188cdf0e10cSrcweir }
getPriority() const189cdf0e10cSrcweir virtual double getPriority() const
190cdf0e10cSrcweir {
191cdf0e10cSrcweir return mnPrio;
192cdf0e10cSrcweir }
isBackgroundDetached() const193cdf0e10cSrcweir virtual bool isBackgroundDetached() const
194cdf0e10cSrcweir {
195cdf0e10cSrcweir return mnAnimated != 0;
196cdf0e10cSrcweir }
197cdf0e10cSrcweir
198cdf0e10cSrcweir // AnimatableShape
enterAnimationMode()199cdf0e10cSrcweir virtual void enterAnimationMode()
200cdf0e10cSrcweir {
201cdf0e10cSrcweir ++mnAnimated;
202cdf0e10cSrcweir }
203cdf0e10cSrcweir
leaveAnimationMode()204cdf0e10cSrcweir virtual void leaveAnimationMode()
205cdf0e10cSrcweir {
206cdf0e10cSrcweir --mnAnimated;
207cdf0e10cSrcweir }
208cdf0e10cSrcweir };
209cdf0e10cSrcweir
210cdf0e10cSrcweir
createTestShape(const basegfx::B2DRange & rRect,double nPrio)211cdf0e10cSrcweir TestShapeSharedPtr createTestShape(const basegfx::B2DRange& rRect,
212cdf0e10cSrcweir double nPrio)
213cdf0e10cSrcweir {
214cdf0e10cSrcweir return TestShapeSharedPtr(
215cdf0e10cSrcweir comphelper::make_shared_from_UNO(
216cdf0e10cSrcweir new ImplTestShape(rRect,nPrio)) );
217cdf0e10cSrcweir }
218