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