xref: /trunk/main/slideshow/test/testview.cxx (revision df3f5cbc)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #include <cppuhelper/compbase1.hxx>
23 #include <cppuhelper/basemutex.hxx>
24 #include <comphelper/make_shared_from_uno.hxx>
25 
26 #include <basegfx/matrix/b2dhommatrix.hxx>
27 #include <basegfx/range/b1drange.hxx>
28 #include <basegfx/range/b2drectangle.hxx>
29 #include <basegfx/polygon/b2dpolypolygon.hxx>
30 #include <cppcanvas/spritecanvas.hxx>
31 
32 #include "tests.hxx"
33 #include "view.hxx"
34 #include "unoview.hxx"
35 #include "com/sun/star/presentation/XSlideShowView.hpp"
36 
37 #include <vector>
38 #include <exception>
39 
40 
41 namespace target = slideshow::internal;
42 using namespace ::com::sun::star;
43 
44 // our test view subject
45 typedef ::cppu::WeakComponentImplHelper1< presentation::XSlideShowView > ViewBase;
46 class ImplTestView : public TestView,
47                      private cppu::BaseMutex,
48                      public ViewBase
49 {
50     mutable std::vector<std::pair<basegfx::B2DVector,double> > maCreatedSprites;
51     mutable std::vector<TestViewSharedPtr>                     maViewLayers;
52     basegfx::B2DRange                                  maBounds;
53     basegfx::B1DRange                                  maPriority;
54     bool                                               mbIsClipSet;
55     bool                                               mbIsClipEmptied;
56     bool                                               mbIsClearCalled;
57     bool                                               mbIsSoundEnabled;
58     bool                                               mbDisposed;
59 
60 
61 public:
ImplTestView()62     ImplTestView() :
63         ViewBase(m_aMutex),
64         maCreatedSprites(),
65         maViewLayers(),
66         maBounds(),
67         maPriority(),
68         mbIsClipSet(false),
69         mbIsClipEmptied(false),
70         mbIsClearCalled(false),
71         mbIsSoundEnabled(false),
72         mbDisposed( false )
73     {
74     }
75 
~ImplTestView()76     virtual ~ImplTestView()
77     {
78     }
79 
80     // XSlideShowView
getCanvas()81     virtual uno::Reference< rendering::XSpriteCanvas > SAL_CALL getCanvas(  ) throw (uno::RuntimeException)
82     {
83         return uno::Reference< rendering::XSpriteCanvas >();
84     }
85 
getCanvasArea()86     virtual ::com::sun::star::awt::Rectangle SAL_CALL getCanvasArea(  ) throw (::com::sun::star::uno::RuntimeException)
87     {
88         // FIXME:
89         ::com::sun::star::awt::Rectangle r;
90         r.X = 0;
91         r.Y = 0;
92         r.Width = 0;
93         r.Height = 0;
94         return r;
95     }
96 
clear()97     virtual void SAL_CALL clear(  ) throw (uno::RuntimeException)
98     {
99     }
100 
getTransformation()101     virtual geometry::AffineMatrix2D SAL_CALL getTransformation(  ) throw (uno::RuntimeException)
102     {
103         return geometry::AffineMatrix2D();
104     }
105 
addTransformationChangedListener(const uno::Reference<util::XModifyListener> &)106     virtual void SAL_CALL addTransformationChangedListener( const uno::Reference< util::XModifyListener >& ) throw (uno::RuntimeException)
107     {
108     }
109 
removeTransformationChangedListener(const uno::Reference<util::XModifyListener> &)110     virtual void SAL_CALL removeTransformationChangedListener( const uno::Reference< util::XModifyListener >& ) throw (uno::RuntimeException)
111     {
112     }
113 
addPaintListener(const uno::Reference<awt::XPaintListener> &)114     virtual void SAL_CALL addPaintListener( const uno::Reference< awt::XPaintListener >& ) throw (uno::RuntimeException)
115     {
116     }
117 
removePaintListener(const uno::Reference<awt::XPaintListener> &)118     virtual void SAL_CALL removePaintListener( const uno::Reference< awt::XPaintListener >& ) throw (uno::RuntimeException)
119     {
120     }
121 
addMouseListener(const uno::Reference<awt::XMouseListener> &)122     virtual void SAL_CALL addMouseListener( const uno::Reference< awt::XMouseListener >& ) throw (uno::RuntimeException)
123     {
124     }
125 
removeMouseListener(const uno::Reference<awt::XMouseListener> &)126     virtual void SAL_CALL removeMouseListener( const uno::Reference< awt::XMouseListener >& ) throw (uno::RuntimeException)
127     {
128     }
129 
addMouseMotionListener(const uno::Reference<awt::XMouseMotionListener> &)130     virtual void SAL_CALL addMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& ) throw (uno::RuntimeException)
131     {
132     }
133 
removeMouseMotionListener(const uno::Reference<awt::XMouseMotionListener> &)134     virtual void SAL_CALL removeMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& ) throw (uno::RuntimeException)
135     {
136     }
137 
setMouseCursor(::sal_Int16)138     virtual void SAL_CALL setMouseCursor( ::sal_Int16 ) throw (uno::RuntimeException)
139     {
140     }
141 
142     // TestView
isClearCalled() const143     virtual bool isClearCalled() const
144     {
145         return mbIsClearCalled;
146     }
147 
isSoundEnabled() const148     virtual bool isSoundEnabled() const
149     {
150         return mbIsSoundEnabled;
151     }
152 
setIsSoundEnabled(const bool bValue)153     virtual void setIsSoundEnabled(const bool bValue)
154     {
155         mbIsSoundEnabled = bValue;
156     }
157 
getCreatedSprites() const158     virtual std::vector<std::pair<basegfx::B2DVector,double> > getCreatedSprites() const
159     {
160         return maCreatedSprites;
161     }
162 
getPriority() const163     virtual basegfx::B1DRange getPriority() const
164     {
165         return maPriority;
166     }
167 
wasClipSet() const168     virtual bool wasClipSet() const
169     {
170         return mbIsClipEmptied;
171     }
172 
getBounds() const173     virtual basegfx::B2DRange getBounds() const
174     {
175         return maBounds;
176     }
177 
getViewLayers() const178     virtual std::vector<boost::shared_ptr<TestView> > getViewLayers() const
179     {
180         return maViewLayers;
181     }
182 
183     // ViewLayer
isOnView(target::ViewSharedPtr const &) const184     virtual bool isOnView(target::ViewSharedPtr const& /*rView*/) const
185     {
186         return true;
187     }
188 
getCanvas() const189     virtual ::cppcanvas::CanvasSharedPtr getCanvas() const
190     {
191         return ::cppcanvas::CanvasSharedPtr();
192     }
193 
createSprite(const::basegfx::B2DSize & rSpriteSizePixel,double nPriority) const194     virtual ::cppcanvas::CustomSpriteSharedPtr createSprite( const ::basegfx::B2DSize& rSpriteSizePixel,
195                                                              double                    nPriority ) const
196     {
197         maCreatedSprites.push_back( std::make_pair(rSpriteSizePixel,nPriority) );
198 
199         return ::cppcanvas::CustomSpriteSharedPtr();
200     }
201 
setPriority(const basegfx::B1DRange & rRange)202     virtual void setPriority( const basegfx::B1DRange& rRange )
203     {
204         maPriority = rRange;
205     }
206 
getTransformation() const207     virtual ::basegfx::B2DHomMatrix getTransformation() const
208     {
209         return ::basegfx::B2DHomMatrix();
210     }
211 
getSpriteTransformation() const212     virtual ::basegfx::B2DHomMatrix getSpriteTransformation() const
213     {
214         return ::basegfx::B2DHomMatrix();
215     }
216 
setClip(const::basegfx::B2DPolyPolygon & rClip)217     virtual void setClip( const ::basegfx::B2DPolyPolygon& rClip )
218     {
219         if( !mbIsClipSet )
220         {
221             if( rClip.count() > 0 )
222                 mbIsClipSet = true;
223         }
224         else if( !mbIsClipEmptied )
225         {
226             if( rClip.count() == 0 )
227                 mbIsClipEmptied = true;
228         }
229         else if( rClip.count() > 0 )
230         {
231             mbIsClipSet = true;
232             mbIsClipEmptied = false;
233         }
234         else
235         {
236             // unexpected call
237             throw std::exception();
238         }
239     }
240 
resize(const basegfx::B2DRange & rArea)241     virtual bool resize( const basegfx::B2DRange& rArea )
242     {
243         const bool bRet( maBounds != rArea );
244         maBounds = rArea;
245         return bRet;
246     }
247 
createViewLayer(const basegfx::B2DRange & rLayerBounds) const248     virtual target::ViewLayerSharedPtr createViewLayer(
249         const basegfx::B2DRange& rLayerBounds ) const
250     {
251         maViewLayers.push_back( TestViewSharedPtr(new ImplTestView()));
252         maViewLayers.back()->resize( rLayerBounds );
253 
254         return maViewLayers.back();
255     }
256 
updateScreen() const257     virtual bool updateScreen() const
258     {
259         // misusing updateScreen for state reporting
260         return !mbDisposed;
261     }
262 
paintScreen() const263     virtual bool paintScreen() const
264     {
265         // misusing updateScreen for state reporting
266         return !mbDisposed;
267     }
268 
clear() const269     virtual void clear() const
270     {
271     }
272 
clearAll() const273     virtual void clearAll() const
274     {
275     }
276 
setViewSize(const::basegfx::B2DSize &)277     virtual void setViewSize( const ::basegfx::B2DSize& )
278     {
279     }
280 
setCursorShape(sal_Int16)281     virtual void setCursorShape( sal_Int16 /*nPointerShape*/ )
282     {
283     }
284 
getUnoView() const285     virtual uno::Reference< presentation::XSlideShowView > getUnoView() const
286     {
287         return uno::Reference< presentation::XSlideShowView >( const_cast<ImplTestView*>(this) );
288     }
289 
_dispose()290     virtual void _dispose()
291     {
292         mbDisposed = true;
293     }
294 };
295 
296 
createTestView()297 TestViewSharedPtr createTestView()
298 {
299     return TestViewSharedPtr(
300         comphelper::make_shared_from_UNO(
301             new ImplTestView()) );
302 }
303