1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include <testshl/simpleheader.hxx> 29 #include <cppuhelper/compbase1.hxx> 30 #include <cppuhelper/basemutex.hxx> 31 #include <comphelper/make_shared_from_uno.hxx> 32 33 #include <basegfx/matrix/b2dhommatrix.hxx> 34 #include <basegfx/range/b1drange.hxx> 35 #include <basegfx/range/b2drectangle.hxx> 36 #include <basegfx/polygon/b2dpolypolygon.hxx> 37 #include <cppcanvas/spritecanvas.hxx> 38 39 #include "tests.hxx" 40 #include "view.hxx" 41 #include "unoview.hxx" 42 #include "com/sun/star/presentation/XSlideShowView.hpp" 43 44 #include <vector> 45 #include <exception> 46 47 48 namespace target = slideshow::internal; 49 using namespace ::com::sun::star; 50 51 // our test view subject 52 typedef ::cppu::WeakComponentImplHelper1< presentation::XSlideShowView > ViewBase; 53 class ImplTestView : public TestView, 54 private cppu::BaseMutex, 55 public ViewBase 56 { 57 mutable std::vector<std::pair<basegfx::B2DVector,double> > maCreatedSprites; 58 mutable std::vector<TestViewSharedPtr> maViewLayers; 59 basegfx::B2DRange maBounds; 60 basegfx::B1DRange maPriority; 61 bool mbIsClipSet; 62 bool mbIsClipEmptied; 63 bool mbIsClearCalled; 64 bool mbDisposed; 65 66 67 public: 68 ImplTestView() : 69 ViewBase(m_aMutex), 70 maCreatedSprites(), 71 maViewLayers(), 72 maBounds(), 73 maPriority(), 74 mbIsClipSet(false), 75 mbIsClipEmptied(false), 76 mbIsClearCalled(false), 77 mbDisposed( false ) 78 { 79 } 80 81 virtual ~ImplTestView() 82 { 83 } 84 85 // XSlideShowView 86 virtual uno::Reference< rendering::XSpriteCanvas > SAL_CALL getCanvas( ) throw (uno::RuntimeException) 87 { 88 return uno::Reference< rendering::XSpriteCanvas >(); 89 } 90 91 virtual void SAL_CALL clear( ) throw (uno::RuntimeException) 92 { 93 } 94 95 virtual geometry::AffineMatrix2D SAL_CALL getTransformation( ) throw (uno::RuntimeException) 96 { 97 return geometry::AffineMatrix2D(); 98 } 99 100 virtual void SAL_CALL addTransformationChangedListener( const uno::Reference< util::XModifyListener >& ) throw (uno::RuntimeException) 101 { 102 } 103 104 virtual void SAL_CALL removeTransformationChangedListener( const uno::Reference< util::XModifyListener >& ) throw (uno::RuntimeException) 105 { 106 } 107 108 virtual void SAL_CALL addPaintListener( const uno::Reference< awt::XPaintListener >& ) throw (uno::RuntimeException) 109 { 110 } 111 112 virtual void SAL_CALL removePaintListener( const uno::Reference< awt::XPaintListener >& ) throw (uno::RuntimeException) 113 { 114 } 115 116 virtual void SAL_CALL addMouseListener( const uno::Reference< awt::XMouseListener >& ) throw (uno::RuntimeException) 117 { 118 } 119 120 virtual void SAL_CALL removeMouseListener( const uno::Reference< awt::XMouseListener >& ) throw (uno::RuntimeException) 121 { 122 } 123 124 virtual void SAL_CALL addMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& ) throw (uno::RuntimeException) 125 { 126 } 127 128 virtual void SAL_CALL removeMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& ) throw (uno::RuntimeException) 129 { 130 } 131 132 virtual void SAL_CALL setMouseCursor( ::sal_Int16 ) throw (uno::RuntimeException) 133 { 134 } 135 136 // TestView 137 virtual bool isClearCalled() const 138 { 139 return mbIsClearCalled; 140 } 141 142 virtual std::vector<std::pair<basegfx::B2DVector,double> > getCreatedSprites() const 143 { 144 return maCreatedSprites; 145 } 146 147 virtual basegfx::B1DRange getPriority() const 148 { 149 return maPriority; 150 } 151 152 virtual bool wasClipSet() const 153 { 154 return mbIsClipEmptied; 155 } 156 157 virtual basegfx::B2DRange getBounds() const 158 { 159 return maBounds; 160 } 161 162 virtual std::vector<boost::shared_ptr<TestView> > getViewLayers() const 163 { 164 return maViewLayers; 165 } 166 167 // ViewLayer 168 virtual bool isOnView(target::ViewSharedPtr const& /*rView*/) const 169 { 170 return true; 171 } 172 173 virtual ::cppcanvas::CanvasSharedPtr getCanvas() const 174 { 175 return ::cppcanvas::CanvasSharedPtr(); 176 } 177 178 virtual ::cppcanvas::CustomSpriteSharedPtr createSprite( const ::basegfx::B2DSize& rSpriteSizePixel, 179 double nPriority ) const 180 { 181 maCreatedSprites.push_back( std::make_pair(rSpriteSizePixel,nPriority) ); 182 183 return ::cppcanvas::CustomSpriteSharedPtr(); 184 } 185 186 virtual void setPriority( const basegfx::B1DRange& rRange ) 187 { 188 maPriority = rRange; 189 } 190 191 virtual ::basegfx::B2DHomMatrix getTransformation() const 192 { 193 return ::basegfx::B2DHomMatrix(); 194 } 195 196 virtual ::basegfx::B2DHomMatrix getSpriteTransformation() const 197 { 198 return ::basegfx::B2DHomMatrix(); 199 } 200 201 virtual void setClip( const ::basegfx::B2DPolyPolygon& rClip ) 202 { 203 if( !mbIsClipSet ) 204 { 205 if( rClip.count() > 0 ) 206 mbIsClipSet = true; 207 } 208 else if( !mbIsClipEmptied ) 209 { 210 if( rClip.count() == 0 ) 211 mbIsClipEmptied = true; 212 } 213 else if( rClip.count() > 0 ) 214 { 215 mbIsClipSet = true; 216 mbIsClipEmptied = false; 217 } 218 else 219 { 220 // unexpected call 221 throw std::exception(); 222 } 223 } 224 225 virtual bool resize( const basegfx::B2DRange& rArea ) 226 { 227 const bool bRet( maBounds != rArea ); 228 maBounds = rArea; 229 return bRet; 230 } 231 232 virtual target::ViewLayerSharedPtr createViewLayer( 233 const basegfx::B2DRange& rLayerBounds ) const 234 { 235 maViewLayers.push_back( TestViewSharedPtr(new ImplTestView())); 236 maViewLayers.back()->resize( rLayerBounds ); 237 238 return maViewLayers.back(); 239 } 240 241 virtual bool updateScreen() const 242 { 243 // misusing updateScreen for state reporting 244 return !mbDisposed; 245 } 246 247 virtual bool paintScreen() const 248 { 249 // misusing updateScreen for state reporting 250 return !mbDisposed; 251 } 252 253 virtual void clear() const 254 { 255 } 256 257 virtual void clearAll() const 258 { 259 } 260 261 virtual void setViewSize( const ::basegfx::B2DSize& ) 262 { 263 } 264 265 virtual void setCursorShape( sal_Int16 /*nPointerShape*/ ) 266 { 267 } 268 269 virtual uno::Reference< presentation::XSlideShowView > getUnoView() const 270 { 271 return uno::Reference< presentation::XSlideShowView >( const_cast<ImplTestView*>(this) ); 272 } 273 274 virtual void _dispose() 275 { 276 mbDisposed = true; 277 } 278 }; 279 280 281 TestViewSharedPtr createTestView() 282 { 283 return TestViewSharedPtr( 284 comphelper::make_shared_from_UNO( 285 new ImplTestView()) ); 286 } 287