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 2270f497fbSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include <cppuhelper/compbase1.hxx> 25cdf0e10cSrcweir #include <cppuhelper/basemutex.hxx> 26cdf0e10cSrcweir #include <comphelper/make_shared_from_uno.hxx> 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 29cdf0e10cSrcweir #include <basegfx/range/b1drange.hxx> 30cdf0e10cSrcweir #include <basegfx/range/b2drectangle.hxx> 31cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygon.hxx> 32cdf0e10cSrcweir #include <cppcanvas/spritecanvas.hxx> 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include "tests.hxx" 35cdf0e10cSrcweir #include "view.hxx" 36cdf0e10cSrcweir #include "unoview.hxx" 37cdf0e10cSrcweir #include "com/sun/star/presentation/XSlideShowView.hpp" 38cdf0e10cSrcweir 39cdf0e10cSrcweir #include <vector> 40cdf0e10cSrcweir #include <exception> 41cdf0e10cSrcweir 42cdf0e10cSrcweir 43cdf0e10cSrcweir namespace target = slideshow::internal; 44cdf0e10cSrcweir using namespace ::com::sun::star; 45cdf0e10cSrcweir 46cdf0e10cSrcweir // our test view subject 47cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper1< presentation::XSlideShowView > ViewBase; 48cdf0e10cSrcweir class ImplTestView : public TestView, 49cdf0e10cSrcweir private cppu::BaseMutex, 50cdf0e10cSrcweir public ViewBase 51cdf0e10cSrcweir { 52cdf0e10cSrcweir mutable std::vector<std::pair<basegfx::B2DVector,double> > maCreatedSprites; 53cdf0e10cSrcweir mutable std::vector<TestViewSharedPtr> maViewLayers; 54cdf0e10cSrcweir basegfx::B2DRange maBounds; 55cdf0e10cSrcweir basegfx::B1DRange maPriority; 56cdf0e10cSrcweir bool mbIsClipSet; 57cdf0e10cSrcweir bool mbIsClipEmptied; 58cdf0e10cSrcweir bool mbIsClearCalled; 59*d9ee14b8SDamjan Jovanovic bool mbIsSoundEnabled; 60cdf0e10cSrcweir bool mbDisposed; 61cdf0e10cSrcweir 62cdf0e10cSrcweir 63cdf0e10cSrcweir public: 64cdf0e10cSrcweir ImplTestView() : 65cdf0e10cSrcweir ViewBase(m_aMutex), 66cdf0e10cSrcweir maCreatedSprites(), 67cdf0e10cSrcweir maViewLayers(), 68cdf0e10cSrcweir maBounds(), 69cdf0e10cSrcweir maPriority(), 70cdf0e10cSrcweir mbIsClipSet(false), 71cdf0e10cSrcweir mbIsClipEmptied(false), 72cdf0e10cSrcweir mbIsClearCalled(false), 73*d9ee14b8SDamjan Jovanovic mbIsSoundEnabled(false), 74cdf0e10cSrcweir mbDisposed( false ) 75cdf0e10cSrcweir { 76cdf0e10cSrcweir } 77cdf0e10cSrcweir 78cdf0e10cSrcweir virtual ~ImplTestView() 79cdf0e10cSrcweir { 80cdf0e10cSrcweir } 81cdf0e10cSrcweir 82cdf0e10cSrcweir // XSlideShowView 83cdf0e10cSrcweir virtual uno::Reference< rendering::XSpriteCanvas > SAL_CALL getCanvas( ) throw (uno::RuntimeException) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir return uno::Reference< rendering::XSpriteCanvas >(); 86cdf0e10cSrcweir } 87cdf0e10cSrcweir 88*d9ee14b8SDamjan Jovanovic virtual ::com::sun::star::awt::Rectangle SAL_CALL getCanvasArea( ) throw (::com::sun::star::uno::RuntimeException) 89*d9ee14b8SDamjan Jovanovic { 90*d9ee14b8SDamjan Jovanovic // FIXME: 91*d9ee14b8SDamjan Jovanovic ::com::sun::star::awt::Rectangle r; 92*d9ee14b8SDamjan Jovanovic r.X = 0; 93*d9ee14b8SDamjan Jovanovic r.Y = 0; 94*d9ee14b8SDamjan Jovanovic r.Width = 0; 95*d9ee14b8SDamjan Jovanovic r.Height = 0; 96*d9ee14b8SDamjan Jovanovic return r; 97*d9ee14b8SDamjan Jovanovic } 98*d9ee14b8SDamjan Jovanovic 99cdf0e10cSrcweir virtual void SAL_CALL clear( ) throw (uno::RuntimeException) 100cdf0e10cSrcweir { 101cdf0e10cSrcweir } 102cdf0e10cSrcweir 103cdf0e10cSrcweir virtual geometry::AffineMatrix2D SAL_CALL getTransformation( ) throw (uno::RuntimeException) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir return geometry::AffineMatrix2D(); 106cdf0e10cSrcweir } 107cdf0e10cSrcweir 108cdf0e10cSrcweir virtual void SAL_CALL addTransformationChangedListener( const uno::Reference< util::XModifyListener >& ) throw (uno::RuntimeException) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir } 111cdf0e10cSrcweir 112cdf0e10cSrcweir virtual void SAL_CALL removeTransformationChangedListener( const uno::Reference< util::XModifyListener >& ) throw (uno::RuntimeException) 113cdf0e10cSrcweir { 114cdf0e10cSrcweir } 115cdf0e10cSrcweir 116cdf0e10cSrcweir virtual void SAL_CALL addPaintListener( const uno::Reference< awt::XPaintListener >& ) throw (uno::RuntimeException) 117cdf0e10cSrcweir { 118cdf0e10cSrcweir } 119cdf0e10cSrcweir 120cdf0e10cSrcweir virtual void SAL_CALL removePaintListener( const uno::Reference< awt::XPaintListener >& ) throw (uno::RuntimeException) 121cdf0e10cSrcweir { 122cdf0e10cSrcweir } 123cdf0e10cSrcweir 124cdf0e10cSrcweir virtual void SAL_CALL addMouseListener( const uno::Reference< awt::XMouseListener >& ) throw (uno::RuntimeException) 125cdf0e10cSrcweir { 126cdf0e10cSrcweir } 127cdf0e10cSrcweir 128cdf0e10cSrcweir virtual void SAL_CALL removeMouseListener( const uno::Reference< awt::XMouseListener >& ) throw (uno::RuntimeException) 129cdf0e10cSrcweir { 130cdf0e10cSrcweir } 131cdf0e10cSrcweir 132cdf0e10cSrcweir virtual void SAL_CALL addMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& ) throw (uno::RuntimeException) 133cdf0e10cSrcweir { 134cdf0e10cSrcweir } 135cdf0e10cSrcweir 136cdf0e10cSrcweir virtual void SAL_CALL removeMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& ) throw (uno::RuntimeException) 137cdf0e10cSrcweir { 138cdf0e10cSrcweir } 139cdf0e10cSrcweir 140cdf0e10cSrcweir virtual void SAL_CALL setMouseCursor( ::sal_Int16 ) throw (uno::RuntimeException) 141cdf0e10cSrcweir { 142cdf0e10cSrcweir } 143cdf0e10cSrcweir 144cdf0e10cSrcweir // TestView 145cdf0e10cSrcweir virtual bool isClearCalled() const 146cdf0e10cSrcweir { 147cdf0e10cSrcweir return mbIsClearCalled; 148cdf0e10cSrcweir } 149cdf0e10cSrcweir 150*d9ee14b8SDamjan Jovanovic virtual bool isSoundEnabled() const 151*d9ee14b8SDamjan Jovanovic { 152*d9ee14b8SDamjan Jovanovic return mbIsSoundEnabled; 153*d9ee14b8SDamjan Jovanovic } 154*d9ee14b8SDamjan Jovanovic 155*d9ee14b8SDamjan Jovanovic virtual void setIsSoundEnabled(const bool bValue) 156*d9ee14b8SDamjan Jovanovic { 157*d9ee14b8SDamjan Jovanovic mbIsSoundEnabled = bValue; 158*d9ee14b8SDamjan Jovanovic } 159*d9ee14b8SDamjan Jovanovic 160cdf0e10cSrcweir virtual std::vector<std::pair<basegfx::B2DVector,double> > getCreatedSprites() const 161cdf0e10cSrcweir { 162cdf0e10cSrcweir return maCreatedSprites; 163cdf0e10cSrcweir } 164cdf0e10cSrcweir 165cdf0e10cSrcweir virtual basegfx::B1DRange getPriority() const 166cdf0e10cSrcweir { 167cdf0e10cSrcweir return maPriority; 168cdf0e10cSrcweir } 169cdf0e10cSrcweir 170cdf0e10cSrcweir virtual bool wasClipSet() const 171cdf0e10cSrcweir { 172cdf0e10cSrcweir return mbIsClipEmptied; 173cdf0e10cSrcweir } 174cdf0e10cSrcweir 175cdf0e10cSrcweir virtual basegfx::B2DRange getBounds() const 176cdf0e10cSrcweir { 177cdf0e10cSrcweir return maBounds; 178cdf0e10cSrcweir } 179cdf0e10cSrcweir 180cdf0e10cSrcweir virtual std::vector<boost::shared_ptr<TestView> > getViewLayers() const 181cdf0e10cSrcweir { 182cdf0e10cSrcweir return maViewLayers; 183cdf0e10cSrcweir } 184cdf0e10cSrcweir 185cdf0e10cSrcweir // ViewLayer 186cdf0e10cSrcweir virtual bool isOnView(target::ViewSharedPtr const& /*rView*/) const 187cdf0e10cSrcweir { 188cdf0e10cSrcweir return true; 189cdf0e10cSrcweir } 190cdf0e10cSrcweir 191cdf0e10cSrcweir virtual ::cppcanvas::CanvasSharedPtr getCanvas() const 192cdf0e10cSrcweir { 193cdf0e10cSrcweir return ::cppcanvas::CanvasSharedPtr(); 194cdf0e10cSrcweir } 195cdf0e10cSrcweir 196cdf0e10cSrcweir virtual ::cppcanvas::CustomSpriteSharedPtr createSprite( const ::basegfx::B2DSize& rSpriteSizePixel, 197cdf0e10cSrcweir double nPriority ) const 198cdf0e10cSrcweir { 199cdf0e10cSrcweir maCreatedSprites.push_back( std::make_pair(rSpriteSizePixel,nPriority) ); 200cdf0e10cSrcweir 201cdf0e10cSrcweir return ::cppcanvas::CustomSpriteSharedPtr(); 202cdf0e10cSrcweir } 203cdf0e10cSrcweir 204cdf0e10cSrcweir virtual void setPriority( const basegfx::B1DRange& rRange ) 205cdf0e10cSrcweir { 206cdf0e10cSrcweir maPriority = rRange; 207cdf0e10cSrcweir } 208cdf0e10cSrcweir 209cdf0e10cSrcweir virtual ::basegfx::B2DHomMatrix getTransformation() const 210cdf0e10cSrcweir { 211cdf0e10cSrcweir return ::basegfx::B2DHomMatrix(); 212cdf0e10cSrcweir } 213cdf0e10cSrcweir 214cdf0e10cSrcweir virtual ::basegfx::B2DHomMatrix getSpriteTransformation() const 215cdf0e10cSrcweir { 216cdf0e10cSrcweir return ::basegfx::B2DHomMatrix(); 217cdf0e10cSrcweir } 218cdf0e10cSrcweir 219cdf0e10cSrcweir virtual void setClip( const ::basegfx::B2DPolyPolygon& rClip ) 220cdf0e10cSrcweir { 221cdf0e10cSrcweir if( !mbIsClipSet ) 222cdf0e10cSrcweir { 223cdf0e10cSrcweir if( rClip.count() > 0 ) 224cdf0e10cSrcweir mbIsClipSet = true; 225cdf0e10cSrcweir } 226cdf0e10cSrcweir else if( !mbIsClipEmptied ) 227cdf0e10cSrcweir { 228cdf0e10cSrcweir if( rClip.count() == 0 ) 229cdf0e10cSrcweir mbIsClipEmptied = true; 230cdf0e10cSrcweir } 231cdf0e10cSrcweir else if( rClip.count() > 0 ) 232cdf0e10cSrcweir { 233cdf0e10cSrcweir mbIsClipSet = true; 234cdf0e10cSrcweir mbIsClipEmptied = false; 235cdf0e10cSrcweir } 236cdf0e10cSrcweir else 237cdf0e10cSrcweir { 238cdf0e10cSrcweir // unexpected call 239cdf0e10cSrcweir throw std::exception(); 240cdf0e10cSrcweir } 241cdf0e10cSrcweir } 242cdf0e10cSrcweir 243cdf0e10cSrcweir virtual bool resize( const basegfx::B2DRange& rArea ) 244cdf0e10cSrcweir { 245cdf0e10cSrcweir const bool bRet( maBounds != rArea ); 246cdf0e10cSrcweir maBounds = rArea; 247cdf0e10cSrcweir return bRet; 248cdf0e10cSrcweir } 249cdf0e10cSrcweir 250cdf0e10cSrcweir virtual target::ViewLayerSharedPtr createViewLayer( 251cdf0e10cSrcweir const basegfx::B2DRange& rLayerBounds ) const 252cdf0e10cSrcweir { 253cdf0e10cSrcweir maViewLayers.push_back( TestViewSharedPtr(new ImplTestView())); 254cdf0e10cSrcweir maViewLayers.back()->resize( rLayerBounds ); 255cdf0e10cSrcweir 256cdf0e10cSrcweir return maViewLayers.back(); 257cdf0e10cSrcweir } 258cdf0e10cSrcweir 259cdf0e10cSrcweir virtual bool updateScreen() const 260cdf0e10cSrcweir { 261cdf0e10cSrcweir // misusing updateScreen for state reporting 262cdf0e10cSrcweir return !mbDisposed; 263cdf0e10cSrcweir } 264cdf0e10cSrcweir 265cdf0e10cSrcweir virtual bool paintScreen() const 266cdf0e10cSrcweir { 267cdf0e10cSrcweir // misusing updateScreen for state reporting 268cdf0e10cSrcweir return !mbDisposed; 269cdf0e10cSrcweir } 270cdf0e10cSrcweir 271cdf0e10cSrcweir virtual void clear() const 272cdf0e10cSrcweir { 273cdf0e10cSrcweir } 274cdf0e10cSrcweir 275cdf0e10cSrcweir virtual void clearAll() const 276cdf0e10cSrcweir { 277cdf0e10cSrcweir } 278cdf0e10cSrcweir 279cdf0e10cSrcweir virtual void setViewSize( const ::basegfx::B2DSize& ) 280cdf0e10cSrcweir { 281cdf0e10cSrcweir } 282cdf0e10cSrcweir 283cdf0e10cSrcweir virtual void setCursorShape( sal_Int16 /*nPointerShape*/ ) 284cdf0e10cSrcweir { 285cdf0e10cSrcweir } 286cdf0e10cSrcweir 287cdf0e10cSrcweir virtual uno::Reference< presentation::XSlideShowView > getUnoView() const 288cdf0e10cSrcweir { 289cdf0e10cSrcweir return uno::Reference< presentation::XSlideShowView >( const_cast<ImplTestView*>(this) ); 290cdf0e10cSrcweir } 291cdf0e10cSrcweir 292cdf0e10cSrcweir virtual void _dispose() 293cdf0e10cSrcweir { 294cdf0e10cSrcweir mbDisposed = true; 295cdf0e10cSrcweir } 296cdf0e10cSrcweir }; 297cdf0e10cSrcweir 298cdf0e10cSrcweir 299cdf0e10cSrcweir TestViewSharedPtr createTestView() 300cdf0e10cSrcweir { 301cdf0e10cSrcweir return TestViewSharedPtr( 302cdf0e10cSrcweir comphelper::make_shared_from_UNO( 303cdf0e10cSrcweir new ImplTestView()) ); 304cdf0e10cSrcweir } 305