fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / slideshow / test / testview.cxx
blob0901f1c866b9ae66ac45bcc03e7dbb1490a43c80
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/b1drange.hxx>
31 #include <basegfx/range/b2drectangle.hxx>
32 #include <basegfx/polygon/b2dpolypolygon.hxx>
33 #include <cppcanvas/spritecanvas.hxx>
35 #include "tests.hxx"
36 #include "view.hxx"
37 #include "unoview.hxx"
38 #include "com/sun/star/presentation/XSlideShowView.hpp"
40 #include <vector>
41 #include <exception>
44 namespace target = slideshow::internal;
45 using namespace ::com::sun::star;
47 // our test view subject
48 typedef ::cppu::WeakComponentImplHelper1< presentation::XSlideShowView > ViewBase;
49 class ImplTestView : public TestView,
50 private cppu::BaseMutex,
51 public ViewBase
53 mutable std::vector<std::pair<basegfx::B2DVector,double> > maCreatedSprites;
54 mutable std::vector<TestViewSharedPtr> maViewLayers;
55 basegfx::B2DRange maBounds;
56 basegfx::B1DRange maPriority;
57 bool mbIsClipSet;
58 bool mbIsClipEmptied;
59 bool mbIsClearCalled;
60 bool mbDisposed;
63 public:
64 ImplTestView() :
65 ViewBase(m_aMutex),
66 maCreatedSprites(),
67 maViewLayers(),
68 maBounds(),
69 maPriority(),
70 mbIsClipSet(false),
71 mbIsClipEmptied(false),
72 mbIsClearCalled(false),
73 mbDisposed( false )
77 virtual ~ImplTestView()
81 // XSlideShowView
82 virtual uno::Reference< rendering::XSpriteCanvas > SAL_CALL getCanvas( ) throw (uno::RuntimeException)
84 return uno::Reference< rendering::XSpriteCanvas >();
87 virtual void SAL_CALL clear( ) throw (uno::RuntimeException)
91 virtual geometry::AffineMatrix2D SAL_CALL getTransformation( ) throw (uno::RuntimeException)
93 return geometry::AffineMatrix2D();
96 virtual void SAL_CALL addTransformationChangedListener( const uno::Reference< util::XModifyListener >& ) throw (uno::RuntimeException)
100 virtual void SAL_CALL removeTransformationChangedListener( const uno::Reference< util::XModifyListener >& ) throw (uno::RuntimeException)
104 virtual void SAL_CALL addPaintListener( const uno::Reference< awt::XPaintListener >& ) throw (uno::RuntimeException)
108 virtual void SAL_CALL removePaintListener( const uno::Reference< awt::XPaintListener >& ) throw (uno::RuntimeException)
112 virtual void SAL_CALL addMouseListener( const uno::Reference< awt::XMouseListener >& ) throw (uno::RuntimeException)
116 virtual void SAL_CALL removeMouseListener( const uno::Reference< awt::XMouseListener >& ) throw (uno::RuntimeException)
120 virtual void SAL_CALL addMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& ) throw (uno::RuntimeException)
124 virtual void SAL_CALL removeMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& ) throw (uno::RuntimeException)
128 virtual void SAL_CALL setMouseCursor( ::sal_Int16 ) throw (uno::RuntimeException)
132 virtual awt::Rectangle SAL_CALL getCanvasArea( ) throw (uno::RuntimeException)
134 return awt::Rectangle(0,0,100,100);
137 // TestView
138 virtual bool isClearCalled() const
140 return mbIsClearCalled;
143 virtual std::vector<std::pair<basegfx::B2DVector,double> > getCreatedSprites() const
145 return maCreatedSprites;
148 virtual basegfx::B1DRange getPriority() const
150 return maPriority;
153 virtual bool wasClipSet() const
155 return mbIsClipEmptied;
158 virtual basegfx::B2DRange getBounds() const
160 return maBounds;
163 virtual std::vector<boost::shared_ptr<TestView> > getViewLayers() const
165 return maViewLayers;
168 // ViewLayer
169 virtual bool isOnView(target::ViewSharedPtr const& /*rView*/) const
171 return true;
174 virtual ::cppcanvas::CanvasSharedPtr getCanvas() const
176 return ::cppcanvas::CanvasSharedPtr();
179 virtual ::cppcanvas::CustomSpriteSharedPtr createSprite( const ::basegfx::B2DSize& rSpriteSizePixel,
180 double nPriority ) const
182 maCreatedSprites.push_back( std::make_pair(rSpriteSizePixel,nPriority) );
184 return ::cppcanvas::CustomSpriteSharedPtr();
187 virtual void setPriority( const basegfx::B1DRange& rRange )
189 maPriority = rRange;
192 virtual ::basegfx::B2DHomMatrix getTransformation() const
194 return ::basegfx::B2DHomMatrix();
197 virtual ::basegfx::B2DHomMatrix getSpriteTransformation() const
199 return ::basegfx::B2DHomMatrix();
202 virtual void setClip( const ::basegfx::B2DPolyPolygon& rClip )
204 if( !mbIsClipSet )
206 if( rClip.count() > 0 )
207 mbIsClipSet = true;
209 else if( !mbIsClipEmptied )
211 if( rClip.count() == 0 )
212 mbIsClipEmptied = true;
214 else if( rClip.count() > 0 )
216 mbIsClipSet = true;
217 mbIsClipEmptied = false;
219 else
221 // unexpected call
222 throw std::exception();
226 virtual bool resize( const basegfx::B2DRange& rArea )
228 const bool bRet( maBounds != rArea );
229 maBounds = rArea;
230 return bRet;
233 virtual target::ViewLayerSharedPtr createViewLayer(
234 const basegfx::B2DRange& rLayerBounds ) const
236 maViewLayers.push_back( TestViewSharedPtr(new ImplTestView()));
237 maViewLayers.back()->resize( rLayerBounds );
239 return maViewLayers.back();
242 virtual bool updateScreen() const
244 // misusing updateScreen for state reporting
245 return !mbDisposed;
248 virtual bool paintScreen() const
250 // misusing updateScreen for state reporting
251 return !mbDisposed;
254 virtual void clear() const
258 virtual void clearAll() const
262 virtual void setViewSize( const ::basegfx::B2DSize& )
266 virtual void setCursorShape( sal_Int16 /*nPointerShape*/ )
270 virtual uno::Reference< presentation::XSlideShowView > getUnoView() const
272 return uno::Reference< presentation::XSlideShowView >( const_cast<ImplTestView*>(this) );
275 virtual void _dispose()
277 mbDisposed = true;
280 virtual bool isSoundEnabled() const
282 return true;
285 virtual void setIsSoundEnabled (const bool /*bValue*/)
291 TestViewSharedPtr createTestView()
293 return TestViewSharedPtr(
294 comphelper::make_shared_from_UNO(
295 new ImplTestView()) );
298 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */