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