xref: /aoo4110/main/slideshow/test/testview.cxx (revision b1cdbd2c)
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 
23 
24 #include <testshl/simpleheader.hxx>
25 #include <cppuhelper/compbase1.hxx>
26 #include <cppuhelper/basemutex.hxx>
27 #include <comphelper/make_shared_from_uno.hxx>
28 
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>
34 
35 #include "tests.hxx"
36 #include "view.hxx"
37 #include "unoview.hxx"
38 #include "com/sun/star/presentation/XSlideShowView.hpp"
39 
40 #include <vector>
41 #include <exception>
42 
43 
44 namespace target = slideshow::internal;
45 using namespace ::com::sun::star;
46 
47 // our test view subject
48 typedef ::cppu::WeakComponentImplHelper1< presentation::XSlideShowView > ViewBase;
49 class ImplTestView : public TestView,
50                      private cppu::BaseMutex,
51                      public ViewBase
52 {
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;
61 
62 
63 public:
ImplTestView()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 )
74     {
75     }
76 
~ImplTestView()77     virtual ~ImplTestView()
78     {
79     }
80 
81     // XSlideShowView
getCanvas()82     virtual uno::Reference< rendering::XSpriteCanvas > SAL_CALL getCanvas(  ) throw (uno::RuntimeException)
83     {
84         return uno::Reference< rendering::XSpriteCanvas >();
85     }
86 
clear()87     virtual void SAL_CALL clear(  ) throw (uno::RuntimeException)
88     {
89     }
90 
getTransformation()91     virtual geometry::AffineMatrix2D SAL_CALL getTransformation(  ) throw (uno::RuntimeException)
92     {
93         return geometry::AffineMatrix2D();
94     }
95 
addTransformationChangedListener(const uno::Reference<util::XModifyListener> &)96     virtual void SAL_CALL addTransformationChangedListener( const uno::Reference< util::XModifyListener >& ) throw (uno::RuntimeException)
97     {
98     }
99 
removeTransformationChangedListener(const uno::Reference<util::XModifyListener> &)100     virtual void SAL_CALL removeTransformationChangedListener( const uno::Reference< util::XModifyListener >& ) throw (uno::RuntimeException)
101     {
102     }
103 
addPaintListener(const uno::Reference<awt::XPaintListener> &)104     virtual void SAL_CALL addPaintListener( const uno::Reference< awt::XPaintListener >& ) throw (uno::RuntimeException)
105     {
106     }
107 
removePaintListener(const uno::Reference<awt::XPaintListener> &)108     virtual void SAL_CALL removePaintListener( const uno::Reference< awt::XPaintListener >& ) throw (uno::RuntimeException)
109     {
110     }
111 
addMouseListener(const uno::Reference<awt::XMouseListener> &)112     virtual void SAL_CALL addMouseListener( const uno::Reference< awt::XMouseListener >& ) throw (uno::RuntimeException)
113     {
114     }
115 
removeMouseListener(const uno::Reference<awt::XMouseListener> &)116     virtual void SAL_CALL removeMouseListener( const uno::Reference< awt::XMouseListener >& ) throw (uno::RuntimeException)
117     {
118     }
119 
addMouseMotionListener(const uno::Reference<awt::XMouseMotionListener> &)120     virtual void SAL_CALL addMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& ) throw (uno::RuntimeException)
121     {
122     }
123 
removeMouseMotionListener(const uno::Reference<awt::XMouseMotionListener> &)124     virtual void SAL_CALL removeMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& ) throw (uno::RuntimeException)
125     {
126     }
127 
setMouseCursor(::sal_Int16)128     virtual void SAL_CALL setMouseCursor( ::sal_Int16 ) throw (uno::RuntimeException)
129     {
130     }
131 
132     // TestView
isClearCalled() const133     virtual bool isClearCalled() const
134     {
135         return mbIsClearCalled;
136     }
137 
getCreatedSprites() const138     virtual std::vector<std::pair<basegfx::B2DVector,double> > getCreatedSprites() const
139     {
140         return maCreatedSprites;
141     }
142 
getPriority() const143     virtual basegfx::B1DRange getPriority() const
144     {
145         return maPriority;
146     }
147 
wasClipSet() const148     virtual bool wasClipSet() const
149     {
150         return mbIsClipEmptied;
151     }
152 
getBounds() const153     virtual basegfx::B2DRange getBounds() const
154     {
155         return maBounds;
156     }
157 
getViewLayers() const158     virtual std::vector<boost::shared_ptr<TestView> > getViewLayers() const
159     {
160         return maViewLayers;
161     }
162 
163     // ViewLayer
isOnView(target::ViewSharedPtr const &) const164     virtual bool isOnView(target::ViewSharedPtr const& /*rView*/) const
165     {
166         return true;
167     }
168 
getCanvas() const169     virtual ::cppcanvas::CanvasSharedPtr getCanvas() const
170     {
171         return ::cppcanvas::CanvasSharedPtr();
172     }
173 
createSprite(const::basegfx::B2DSize & rSpriteSizePixel,double nPriority) const174     virtual ::cppcanvas::CustomSpriteSharedPtr createSprite( const ::basegfx::B2DSize& rSpriteSizePixel,
175                                                              double                    nPriority ) const
176     {
177         maCreatedSprites.push_back( std::make_pair(rSpriteSizePixel,nPriority) );
178 
179         return ::cppcanvas::CustomSpriteSharedPtr();
180     }
181 
setPriority(const basegfx::B1DRange & rRange)182     virtual void setPriority( const basegfx::B1DRange& rRange )
183     {
184         maPriority = rRange;
185     }
186 
getTransformation() const187     virtual ::basegfx::B2DHomMatrix getTransformation() const
188     {
189         return ::basegfx::B2DHomMatrix();
190     }
191 
getSpriteTransformation() const192     virtual ::basegfx::B2DHomMatrix getSpriteTransformation() const
193     {
194         return ::basegfx::B2DHomMatrix();
195     }
196 
setClip(const::basegfx::B2DPolyPolygon & rClip)197     virtual void setClip( const ::basegfx::B2DPolyPolygon& rClip )
198     {
199         if( !mbIsClipSet )
200         {
201             if( rClip.count() > 0 )
202                 mbIsClipSet = true;
203         }
204         else if( !mbIsClipEmptied )
205         {
206             if( rClip.count() == 0 )
207                 mbIsClipEmptied = true;
208         }
209         else if( rClip.count() > 0 )
210         {
211             mbIsClipSet = true;
212             mbIsClipEmptied = false;
213         }
214         else
215         {
216             // unexpected call
217             throw std::exception();
218         }
219     }
220 
resize(const basegfx::B2DRange & rArea)221     virtual bool resize( const basegfx::B2DRange& rArea )
222     {
223         const bool bRet( maBounds != rArea );
224         maBounds = rArea;
225         return bRet;
226     }
227 
createViewLayer(const basegfx::B2DRange & rLayerBounds) const228     virtual target::ViewLayerSharedPtr createViewLayer(
229         const basegfx::B2DRange& rLayerBounds ) const
230     {
231         maViewLayers.push_back( TestViewSharedPtr(new ImplTestView()));
232         maViewLayers.back()->resize( rLayerBounds );
233 
234         return maViewLayers.back();
235     }
236 
updateScreen() const237     virtual bool updateScreen() const
238     {
239         // misusing updateScreen for state reporting
240         return !mbDisposed;
241     }
242 
paintScreen() const243     virtual bool paintScreen() const
244     {
245         // misusing updateScreen for state reporting
246         return !mbDisposed;
247     }
248 
clear() const249     virtual void clear() const
250     {
251     }
252 
clearAll() const253     virtual void clearAll() const
254     {
255     }
256 
setViewSize(const::basegfx::B2DSize &)257     virtual void setViewSize( const ::basegfx::B2DSize& )
258     {
259     }
260 
setCursorShape(sal_Int16)261     virtual void setCursorShape( sal_Int16 /*nPointerShape*/ )
262     {
263     }
264 
getUnoView() const265     virtual uno::Reference< presentation::XSlideShowView > getUnoView() const
266     {
267         return uno::Reference< presentation::XSlideShowView >( const_cast<ImplTestView*>(this) );
268     }
269 
_dispose()270     virtual void _dispose()
271     {
272         mbDisposed = true;
273     }
274 };
275 
276 
createTestView()277 TestViewSharedPtr createTestView()
278 {
279     return TestViewSharedPtr(
280         comphelper::make_shared_from_UNO(
281             new ImplTestView()) );
282 }
283