1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20 #include <sal/types.h>
21 #include <cppunit/TestAssert.h>
22 #include <cppunit/TestFixture.h>
23 #include <cppunit/extensions/HelperMacros.h>
24
25 #include <cppuhelper/compbase.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::WeakComponentImplHelper< 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 mbDisposed;
60
61
62 public:
ImplTestView()63 ImplTestView() :
64 ViewBase(m_aMutex),
65 maCreatedSprites(),
66 maViewLayers(),
67 maBounds(),
68 maPriority(),
69 mbIsClipSet(false),
70 mbIsClipEmptied(false),
71 mbDisposed( false )
72 {
73 }
74
75 // XSlideShowView
getCanvas()76 virtual uno::Reference< rendering::XSpriteCanvas > SAL_CALL getCanvas( ) override
77 {
78 return uno::Reference< rendering::XSpriteCanvas >();
79 }
80
clear()81 virtual void SAL_CALL clear( ) override
82 {
83 }
84
getTransformation()85 virtual geometry::AffineMatrix2D SAL_CALL getTransformation( ) override
86 {
87 return geometry::AffineMatrix2D();
88 }
89
getTranslationOffset()90 virtual ::css::geometry::IntegerSize2D SAL_CALL getTranslationOffset() override
91 {
92 return geometry::IntegerSize2D();
93 }
94
getTranslationOffset() const95 virtual geometry::IntegerSize2D getTranslationOffset() const override
96 {
97 return geometry::IntegerSize2D();
98 }
99
addTransformationChangedListener(const uno::Reference<util::XModifyListener> &)100 virtual void SAL_CALL addTransformationChangedListener( const uno::Reference< util::XModifyListener >& ) override
101 {
102 }
103
removeTransformationChangedListener(const uno::Reference<util::XModifyListener> &)104 virtual void SAL_CALL removeTransformationChangedListener( const uno::Reference< util::XModifyListener >& ) override
105 {
106 }
107
addPaintListener(const uno::Reference<awt::XPaintListener> &)108 virtual void SAL_CALL addPaintListener( const uno::Reference< awt::XPaintListener >& ) override
109 {
110 }
111
removePaintListener(const uno::Reference<awt::XPaintListener> &)112 virtual void SAL_CALL removePaintListener( const uno::Reference< awt::XPaintListener >& ) override
113 {
114 }
115
addMouseListener(const uno::Reference<awt::XMouseListener> &)116 virtual void SAL_CALL addMouseListener( const uno::Reference< awt::XMouseListener >& ) override
117 {
118 }
119
removeMouseListener(const uno::Reference<awt::XMouseListener> &)120 virtual void SAL_CALL removeMouseListener( const uno::Reference< awt::XMouseListener >& ) override
121 {
122 }
123
addMouseMotionListener(const uno::Reference<awt::XMouseMotionListener> &)124 virtual void SAL_CALL addMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& ) override
125 {
126 }
127
removeMouseMotionListener(const uno::Reference<awt::XMouseMotionListener> &)128 virtual void SAL_CALL removeMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& ) override
129 {
130 }
131
setMouseCursor(::sal_Int16)132 virtual void SAL_CALL setMouseCursor( ::sal_Int16 ) override
133 {
134 }
135
getCanvasArea()136 virtual awt::Rectangle SAL_CALL getCanvasArea( ) override
137 {
138 return awt::Rectangle(0,0,100,100);
139 }
140
getBounds() const141 virtual basegfx::B2DRange getBounds() const override
142 {
143 return maBounds;
144 }
145
getViewLayers() const146 virtual std::vector<std::shared_ptr<TestView> > getViewLayers() const override
147 {
148 return maViewLayers;
149 }
150
151 // ViewLayer
isOnView(target::ViewSharedPtr const &) const152 virtual bool isOnView(target::ViewSharedPtr const& /*rView*/) const override
153 {
154 return true;
155 }
156
getCanvas() const157 virtual ::cppcanvas::CanvasSharedPtr getCanvas() const override
158 {
159 return ::cppcanvas::CanvasSharedPtr();
160 }
161
createSprite(const::basegfx::B2DSize & rSpriteSizePixel,double nPriority) const162 virtual ::cppcanvas::CustomSpriteSharedPtr createSprite( const ::basegfx::B2DSize& rSpriteSizePixel,
163 double nPriority ) const override
164 {
165 maCreatedSprites.push_back( std::make_pair(rSpriteSizePixel,nPriority) );
166
167 return ::cppcanvas::CustomSpriteSharedPtr();
168 }
169
setPriority(const basegfx::B1DRange & rRange)170 virtual void setPriority( const basegfx::B1DRange& rRange ) override
171 {
172 maPriority = rRange;
173 }
174
getTransformation() const175 virtual ::basegfx::B2DHomMatrix getTransformation() const override
176 {
177 return ::basegfx::B2DHomMatrix();
178 }
179
getSpriteTransformation() const180 virtual ::basegfx::B2DHomMatrix getSpriteTransformation() const override
181 {
182 return ::basegfx::B2DHomMatrix();
183 }
184
setClip(const::basegfx::B2DPolyPolygon & rClip)185 virtual void setClip( const ::basegfx::B2DPolyPolygon& rClip ) override
186 {
187 if( !mbIsClipSet )
188 {
189 if( rClip.count() > 0 )
190 mbIsClipSet = true;
191 }
192 else if( !mbIsClipEmptied )
193 {
194 if( rClip.count() == 0 )
195 mbIsClipEmptied = true;
196 }
197 else if( rClip.count() > 0 )
198 {
199 mbIsClipSet = true;
200 mbIsClipEmptied = false;
201 }
202 else
203 {
204 // unexpected call
205 throw std::exception();
206 }
207 }
208
resize(const basegfx::B2DRange & rArea)209 virtual bool resize( const basegfx::B2DRange& rArea ) override
210 {
211 const bool bRet( maBounds != rArea );
212 maBounds = rArea;
213 return bRet;
214 }
215
createViewLayer(const basegfx::B2DRange & rLayerBounds) const216 virtual target::ViewLayerSharedPtr createViewLayer(
217 const basegfx::B2DRange& rLayerBounds ) const override
218 {
219 maViewLayers.push_back( TestViewSharedPtr(new ImplTestView()));
220 maViewLayers.back()->resize( rLayerBounds );
221
222 return maViewLayers.back();
223 }
224
updateScreen() const225 virtual bool updateScreen() const override
226 {
227 // misusing updateScreen for state reporting
228 return !mbDisposed;
229 }
230
paintScreen() const231 virtual bool paintScreen() const override
232 {
233 // misusing updateScreen for state reporting
234 return !mbDisposed;
235 }
236
clear() const237 virtual void clear() const override
238 {
239 }
240
clearAll() const241 virtual void clearAll() const override
242 {
243 }
244
setViewSize(const::basegfx::B2DSize &)245 virtual void setViewSize( const ::basegfx::B2DSize& ) override
246 {
247 }
248
setCursorShape(sal_Int16)249 virtual void setCursorShape( sal_Int16 /*nPointerShape*/ ) override
250 {
251 }
252
getUnoView() const253 virtual uno::Reference< presentation::XSlideShowView > getUnoView() const override
254 {
255 return uno::Reference< presentation::XSlideShowView >( const_cast<ImplTestView*>(this) );
256 }
257
_dispose()258 virtual void _dispose() override
259 {
260 mbDisposed = true;
261 }
262
isSoundEnabled() const263 virtual bool isSoundEnabled() const override
264 {
265 return true;
266 }
267
setIsSoundEnabled(const bool)268 virtual void setIsSoundEnabled (const bool /*bValue*/) override
269 {
270 }
271 };
272
273
createTestView()274 TestViewSharedPtr createTestView()
275 {
276 return TestViewSharedPtr(
277 comphelper::make_shared_from_UNO(
278 new ImplTestView()) );
279 }
280
281 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
282