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