merge the formfield patch from ooo-build
[ooovba.git] / slideshow / test / testview.cxx
blob19618ff27ec800d9a979e06c92eedfc086ff4a9b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: testview.cxx,v $
10 * $Revision: 1.3 $
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/b1drange.hxx>
38 #include <basegfx/range/b2drectangle.hxx>
39 #include <basegfx/polygon/b2dpolypolygon.hxx>
40 #include <cppcanvas/spritecanvas.hxx>
42 #include "tests.hxx"
43 #include "view.hxx"
44 #include "unoview.hxx"
45 #include "com/sun/star/presentation/XSlideShowView.hpp"
47 #include <vector>
48 #include <exception>
51 namespace target = slideshow::internal;
52 using namespace ::com::sun::star;
54 // our test view subject
55 typedef ::cppu::WeakComponentImplHelper1< presentation::XSlideShowView > ViewBase;
56 class ImplTestView : public TestView,
57 private cppu::BaseMutex,
58 public ViewBase
60 mutable std::vector<std::pair<basegfx::B2DVector,double> > maCreatedSprites;
61 mutable std::vector<TestViewSharedPtr> maViewLayers;
62 basegfx::B2DRange maBounds;
63 basegfx::B1DRange maPriority;
64 bool mbIsClipSet;
65 bool mbIsClipEmptied;
66 bool mbIsClearCalled;
67 bool mbDisposed;
70 public:
71 ImplTestView() :
72 ViewBase(m_aMutex),
73 maCreatedSprites(),
74 maViewLayers(),
75 maBounds(),
76 maPriority(),
77 mbIsClipSet(false),
78 mbIsClipEmptied(false),
79 mbIsClearCalled(false),
80 mbDisposed( false )
84 virtual ~ImplTestView()
88 // XSlideShowView
89 virtual uno::Reference< rendering::XSpriteCanvas > SAL_CALL getCanvas( ) throw (uno::RuntimeException)
91 return uno::Reference< rendering::XSpriteCanvas >();
94 virtual void SAL_CALL clear( ) throw (uno::RuntimeException)
98 virtual geometry::AffineMatrix2D SAL_CALL getTransformation( ) throw (uno::RuntimeException)
100 return geometry::AffineMatrix2D();
103 virtual void SAL_CALL addTransformationChangedListener( const uno::Reference< util::XModifyListener >& ) throw (uno::RuntimeException)
107 virtual void SAL_CALL removeTransformationChangedListener( const uno::Reference< util::XModifyListener >& ) throw (uno::RuntimeException)
111 virtual void SAL_CALL addPaintListener( const uno::Reference< awt::XPaintListener >& ) throw (uno::RuntimeException)
115 virtual void SAL_CALL removePaintListener( const uno::Reference< awt::XPaintListener >& ) throw (uno::RuntimeException)
119 virtual void SAL_CALL addMouseListener( const uno::Reference< awt::XMouseListener >& ) throw (uno::RuntimeException)
123 virtual void SAL_CALL removeMouseListener( const uno::Reference< awt::XMouseListener >& ) throw (uno::RuntimeException)
127 virtual void SAL_CALL addMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& ) throw (uno::RuntimeException)
131 virtual void SAL_CALL removeMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& ) throw (uno::RuntimeException)
135 virtual void SAL_CALL setMouseCursor( ::sal_Int16 ) throw (uno::RuntimeException)
139 // TestView
140 virtual bool isClearCalled() const
142 return mbIsClearCalled;
145 virtual std::vector<std::pair<basegfx::B2DVector,double> > getCreatedSprites() const
147 return maCreatedSprites;
150 virtual basegfx::B1DRange getPriority() const
152 return maPriority;
155 virtual bool wasClipSet() const
157 return mbIsClipEmptied;
160 virtual basegfx::B2DRange getBounds() const
162 return maBounds;
165 virtual std::vector<boost::shared_ptr<TestView> > getViewLayers() const
167 return maViewLayers;
170 // ViewLayer
171 virtual bool isOnView(target::ViewSharedPtr const& /*rView*/) const
173 return true;
176 virtual ::cppcanvas::CanvasSharedPtr getCanvas() const
178 return ::cppcanvas::CanvasSharedPtr();
181 virtual ::cppcanvas::CustomSpriteSharedPtr createSprite( const ::basegfx::B2DSize& rSpriteSizePixel,
182 double nPriority ) const
184 maCreatedSprites.push_back( std::make_pair(rSpriteSizePixel,nPriority) );
186 return ::cppcanvas::CustomSpriteSharedPtr();
189 virtual void setPriority( const basegfx::B1DRange& rRange )
191 maPriority = rRange;
194 virtual ::basegfx::B2DHomMatrix getTransformation() const
196 return ::basegfx::B2DHomMatrix();
199 virtual ::basegfx::B2DHomMatrix getSpriteTransformation() const
201 return ::basegfx::B2DHomMatrix();
204 virtual void setClip( const ::basegfx::B2DPolyPolygon& rClip )
206 if( !mbIsClipSet )
208 if( rClip.count() > 0 )
209 mbIsClipSet = true;
211 else if( !mbIsClipEmptied )
213 if( rClip.count() == 0 )
214 mbIsClipEmptied = true;
216 else if( rClip.count() > 0 )
218 mbIsClipSet = true;
219 mbIsClipEmptied = false;
221 else
223 // unexpected call
224 throw std::exception();
228 virtual bool resize( const basegfx::B2DRange& rArea )
230 const bool bRet( maBounds != rArea );
231 maBounds = rArea;
232 return bRet;
235 virtual target::ViewLayerSharedPtr createViewLayer(
236 const basegfx::B2DRange& rLayerBounds ) const
238 maViewLayers.push_back( TestViewSharedPtr(new ImplTestView()));
239 maViewLayers.back()->resize( rLayerBounds );
241 return maViewLayers.back();
244 virtual bool updateScreen() const
246 // misusing updateScreen for state reporting
247 return !mbDisposed;
250 virtual bool paintScreen() const
252 // misusing updateScreen for state reporting
253 return !mbDisposed;
256 virtual void clear() const
260 virtual void clearAll() const
264 virtual void setViewSize( const ::basegfx::B2DSize& )
268 virtual void setCursorShape( sal_Int16 /*nPointerShape*/ )
272 virtual uno::Reference< presentation::XSlideShowView > getUnoView() const
274 return uno::Reference< presentation::XSlideShowView >( const_cast<ImplTestView*>(this) );
277 virtual void _dispose()
279 mbDisposed = true;
284 TestViewSharedPtr createTestView()
286 return TestViewSharedPtr(
287 comphelper::make_shared_from_UNO(
288 new ImplTestView()) );