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 1070f497fbSAndrew Rist * 1170f497fbSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 1270f497fbSAndrew Rist * 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. 1970f497fbSAndrew Rist * 2070f497fbSAndrew Rist *************************************************************/ 2170f497fbSAndrew Rist 22*d443ea8fSDamjan Jovanovic #include "precompiled_slideshow.hxx" 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include <sal/main.h> 25cdf0e10cSrcweir #include <rtl/ref.hxx> 26cdf0e10cSrcweir #include <rtl/bootstrap.hxx> 27*d443ea8fSDamjan Jovanovic #include <osl/process.h> 28*d443ea8fSDamjan Jovanovic #include <tools/extendapplicationenvironment.hxx> 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include <cppuhelper/bootstrap.hxx> 31cdf0e10cSrcweir #include <cppuhelper/servicefactory.hxx> 32cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.hxx> 33cdf0e10cSrcweir #include <cppuhelper/compbase1.hxx> 34cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx> 35cdf0e10cSrcweir 36cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 37cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx> 38cdf0e10cSrcweir #include <comphelper/anytostring.hxx> 39cdf0e10cSrcweir #include <cppuhelper/exc_hlp.hxx> 40cdf0e10cSrcweir 41cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 42cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 43cdf0e10cSrcweir #include <com/sun/star/rendering/XCanvas.hpp> 44cdf0e10cSrcweir #include <com/sun/star/rendering/XSpriteCanvas.hpp> 45cdf0e10cSrcweir #include <com/sun/star/presentation/XSlideShow.hpp> 46cdf0e10cSrcweir #include <com/sun/star/presentation/XSlideShowView.hpp> 47cdf0e10cSrcweir #include "com/sun/star/animations/TransitionType.hpp" 48cdf0e10cSrcweir #include "com/sun/star/animations/TransitionSubType.hpp" 49cdf0e10cSrcweir 50cdf0e10cSrcweir #include <ucbhelper/contentbroker.hxx> 51cdf0e10cSrcweir #include <ucbhelper/configurationkeys.hxx> 52cdf0e10cSrcweir 53d9ee14b8SDamjan Jovanovic #include <basegfx/matrix/b2dhommatrixtools.hxx> 54cdf0e10cSrcweir #include <basegfx/tools/canvastools.hxx> 55cdf0e10cSrcweir #include <basegfx/range/b2drectangle.hxx> 56cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx> 57cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx> 58cdf0e10cSrcweir 59cdf0e10cSrcweir #include <cppcanvas/vclfactory.hxx> 60cdf0e10cSrcweir #include <cppcanvas/basegfxfactory.hxx> 61cdf0e10cSrcweir #include <cppcanvas/polypolygon.hxx> 62cdf0e10cSrcweir 63cdf0e10cSrcweir #include <canvas/canvastools.hxx> 64cdf0e10cSrcweir 65cdf0e10cSrcweir #include <vcl/dialog.hxx> 66cdf0e10cSrcweir #include <vcl/timer.hxx> 67cdf0e10cSrcweir #include <vcl/window.hxx> 68cdf0e10cSrcweir #include <vcl/svapp.hxx> 69cdf0e10cSrcweir 70cdf0e10cSrcweir #include <stdio.h> 71cdf0e10cSrcweir #include <unistd.h> 72cdf0e10cSrcweir 73cdf0e10cSrcweir 74cdf0e10cSrcweir using namespace ::com::sun::star; 75cdf0e10cSrcweir 76cdf0e10cSrcweir namespace { 77cdf0e10cSrcweir 78cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper1< presentation::XSlideShowView > ViewBase; 79cdf0e10cSrcweir class View : public ::comphelper::OBaseMutex, 80cdf0e10cSrcweir public ViewBase 81cdf0e10cSrcweir { 82cdf0e10cSrcweir public: 83cdf0e10cSrcweir explicit View( const uno::Reference< rendering::XSpriteCanvas >& rCanvas ) : 84cdf0e10cSrcweir ViewBase( m_aMutex ), 85cdf0e10cSrcweir mxCanvas( rCanvas ), 86cdf0e10cSrcweir maPaintListeners( m_aMutex ), 87cdf0e10cSrcweir maTransformationListeners( m_aMutex ), 88cdf0e10cSrcweir maMouseListeners( m_aMutex ), 89cdf0e10cSrcweir maMouseMotionListeners( m_aMutex ), 90cdf0e10cSrcweir maTransform(), 91cdf0e10cSrcweir maSize() 92cdf0e10cSrcweir { 93cdf0e10cSrcweir } 94cdf0e10cSrcweir 95cdf0e10cSrcweir void resize( const ::Size& rNewSize ) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir maSize = rNewSize; 98cdf0e10cSrcweir const sal_Int32 nSize( std::min( rNewSize.Width(), rNewSize.Height() ) - 10); 99cdf0e10cSrcweir maTransform = basegfx::tools::createScaleTranslateB2DHomMatrix( 100cdf0e10cSrcweir nSize, nSize, (rNewSize.Width() - nSize) / 2, (rNewSize.Height() - nSize) / 2); 101cdf0e10cSrcweir 102cdf0e10cSrcweir lang::EventObject aEvent( *this ); 103cdf0e10cSrcweir maTransformationListeners.notifyEach( &util::XModifyListener::modified, 104cdf0e10cSrcweir aEvent ); 105cdf0e10cSrcweir } 106cdf0e10cSrcweir 107cdf0e10cSrcweir void repaint() 108cdf0e10cSrcweir { 109cdf0e10cSrcweir awt::PaintEvent aEvent( *this, 110cdf0e10cSrcweir awt::Rectangle(), 111cdf0e10cSrcweir 0 ); 112cdf0e10cSrcweir maPaintListeners.notifyEach( &awt::XPaintListener::windowPaint, 113cdf0e10cSrcweir aEvent ); 114cdf0e10cSrcweir } 115cdf0e10cSrcweir 116d9ee14b8SDamjan Jovanovic virtual ::com::sun::star::awt::Rectangle SAL_CALL getCanvasArea( ) throw (::com::sun::star::uno::RuntimeException) 117d9ee14b8SDamjan Jovanovic { 118d9ee14b8SDamjan Jovanovic // FIXME: 119d9ee14b8SDamjan Jovanovic ::com::sun::star::awt::Rectangle r; 120d9ee14b8SDamjan Jovanovic r.X = 0; 121d9ee14b8SDamjan Jovanovic r.Y = 0; 122d9ee14b8SDamjan Jovanovic r.Width = 0; 123d9ee14b8SDamjan Jovanovic r.Height = 0; 124d9ee14b8SDamjan Jovanovic return r; 125d9ee14b8SDamjan Jovanovic } 126d9ee14b8SDamjan Jovanovic 127cdf0e10cSrcweir private: 128cdf0e10cSrcweir virtual ~View() {} 129cdf0e10cSrcweir 130cdf0e10cSrcweir virtual uno::Reference< rendering::XSpriteCanvas > SAL_CALL getCanvas( ) throw (uno::RuntimeException) 131cdf0e10cSrcweir { 132cdf0e10cSrcweir return mxCanvas; 133cdf0e10cSrcweir } 134cdf0e10cSrcweir 135cdf0e10cSrcweir virtual void SAL_CALL clear( ) throw (uno::RuntimeException) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir ::basegfx::B2DPolygon aPoly( ::basegfx::tools::createPolygonFromRect( 138cdf0e10cSrcweir ::basegfx::B2DRectangle(0.0,0.0, 139cdf0e10cSrcweir maSize.Width(), 140cdf0e10cSrcweir maSize.Height() ))); 141cdf0e10cSrcweir ::cppcanvas::SpriteCanvasSharedPtr pCanvas( 142cdf0e10cSrcweir ::cppcanvas::VCLFactory::getInstance().createSpriteCanvas( mxCanvas )); 143cdf0e10cSrcweir if( !pCanvas ) 144cdf0e10cSrcweir return; 145cdf0e10cSrcweir 146cdf0e10cSrcweir ::cppcanvas::PolyPolygonSharedPtr pPolyPoly( 147cdf0e10cSrcweir ::cppcanvas::BaseGfxFactory::getInstance().createPolyPolygon( pCanvas, 148cdf0e10cSrcweir aPoly ) ); 149cdf0e10cSrcweir if( !pPolyPoly ) 150cdf0e10cSrcweir return; 151cdf0e10cSrcweir 152cdf0e10cSrcweir if( pPolyPoly ) 153cdf0e10cSrcweir { 154cdf0e10cSrcweir pPolyPoly->setRGBAFillColor( 0x808080FFU ); 155cdf0e10cSrcweir pPolyPoly->draw(); 156cdf0e10cSrcweir } 157cdf0e10cSrcweir } 158cdf0e10cSrcweir 159cdf0e10cSrcweir virtual geometry::AffineMatrix2D SAL_CALL getTransformation( ) throw (uno::RuntimeException) 160cdf0e10cSrcweir { 161cdf0e10cSrcweir geometry::AffineMatrix2D aRes; 162cdf0e10cSrcweir return basegfx::unotools::affineMatrixFromHomMatrix( aRes, 163cdf0e10cSrcweir maTransform ); 164cdf0e10cSrcweir } 165cdf0e10cSrcweir 166cdf0e10cSrcweir virtual void SAL_CALL addTransformationChangedListener( const uno::Reference< util::XModifyListener >& xListener ) throw (uno::RuntimeException) 167cdf0e10cSrcweir { 168cdf0e10cSrcweir maTransformationListeners.addInterface( xListener ); 169cdf0e10cSrcweir } 170cdf0e10cSrcweir 171cdf0e10cSrcweir virtual void SAL_CALL removeTransformationChangedListener( const uno::Reference< util::XModifyListener >& xListener ) throw (uno::RuntimeException) 172cdf0e10cSrcweir { 173cdf0e10cSrcweir maTransformationListeners.removeInterface( xListener ); 174cdf0e10cSrcweir } 175cdf0e10cSrcweir 176cdf0e10cSrcweir virtual void SAL_CALL addPaintListener( const uno::Reference< awt::XPaintListener >& xListener ) throw (uno::RuntimeException) 177cdf0e10cSrcweir { 178cdf0e10cSrcweir maPaintListeners.addInterface( xListener ); 179cdf0e10cSrcweir } 180cdf0e10cSrcweir 181cdf0e10cSrcweir virtual void SAL_CALL removePaintListener( const uno::Reference< awt::XPaintListener >& xListener ) throw (uno::RuntimeException) 182cdf0e10cSrcweir { 183cdf0e10cSrcweir maPaintListeners.removeInterface( xListener ); 184cdf0e10cSrcweir } 185cdf0e10cSrcweir 186cdf0e10cSrcweir virtual void SAL_CALL addMouseListener( const uno::Reference< awt::XMouseListener >& xListener ) throw (uno::RuntimeException) 187cdf0e10cSrcweir { 188cdf0e10cSrcweir maMouseListeners.addInterface( xListener ); 189cdf0e10cSrcweir } 190cdf0e10cSrcweir 191cdf0e10cSrcweir virtual void SAL_CALL removeMouseListener( const uno::Reference< awt::XMouseListener >& xListener ) throw (uno::RuntimeException) 192cdf0e10cSrcweir { 193cdf0e10cSrcweir maMouseListeners.removeInterface( xListener ); 194cdf0e10cSrcweir } 195cdf0e10cSrcweir 196cdf0e10cSrcweir virtual void SAL_CALL addMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener ) throw (uno::RuntimeException) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir maMouseMotionListeners.addInterface( xListener ); 199cdf0e10cSrcweir } 200cdf0e10cSrcweir 201cdf0e10cSrcweir virtual void SAL_CALL removeMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener ) throw (uno::RuntimeException) 202cdf0e10cSrcweir { 203cdf0e10cSrcweir maMouseMotionListeners.removeInterface( xListener ); 204cdf0e10cSrcweir } 205cdf0e10cSrcweir 206cdf0e10cSrcweir virtual void SAL_CALL setMouseCursor( ::sal_Int16 /*nPointerShape*/ ) throw (uno::RuntimeException) 207cdf0e10cSrcweir { 208cdf0e10cSrcweir } 209cdf0e10cSrcweir 210cdf0e10cSrcweir uno::Reference< rendering::XSpriteCanvas > mxCanvas; 211cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper maPaintListeners; 212cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper maTransformationListeners; 213cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper maMouseListeners; 214cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper maMouseMotionListeners; 215cdf0e10cSrcweir basegfx::B2DHomMatrix maTransform; 216cdf0e10cSrcweir Size maSize; 217cdf0e10cSrcweir }; 218cdf0e10cSrcweir 219cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper2< drawing::XDrawPage, 220cdf0e10cSrcweir beans::XPropertySet > SlideBase; 221cdf0e10cSrcweir class DummySlide : public ::comphelper::OBaseMutex, 222cdf0e10cSrcweir public SlideBase 223cdf0e10cSrcweir { 224cdf0e10cSrcweir public: 225cdf0e10cSrcweir DummySlide() : SlideBase( m_aMutex ) {} 226cdf0e10cSrcweir 227cdf0e10cSrcweir private: 228cdf0e10cSrcweir // XDrawPage 229cdf0e10cSrcweir virtual void SAL_CALL add( const uno::Reference< drawing::XShape >& /*xShape*/ ) throw (uno::RuntimeException) 230cdf0e10cSrcweir { 231cdf0e10cSrcweir } 232cdf0e10cSrcweir 233cdf0e10cSrcweir virtual void SAL_CALL remove( const uno::Reference< drawing::XShape >& /*xShape*/ ) throw (uno::RuntimeException) 234cdf0e10cSrcweir { 235cdf0e10cSrcweir } 236cdf0e10cSrcweir 237cdf0e10cSrcweir virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException) 238cdf0e10cSrcweir { 239cdf0e10cSrcweir return 0; 240cdf0e10cSrcweir } 241cdf0e10cSrcweir 242cdf0e10cSrcweir virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 /*Index*/ ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) 243cdf0e10cSrcweir { 244cdf0e10cSrcweir return uno::Any(); 245cdf0e10cSrcweir } 246cdf0e10cSrcweir 247cdf0e10cSrcweir virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir return uno::Type(); 250cdf0e10cSrcweir } 251cdf0e10cSrcweir 252cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException) 253cdf0e10cSrcweir { 254cdf0e10cSrcweir return false; 255cdf0e10cSrcweir } 256cdf0e10cSrcweir 257cdf0e10cSrcweir // XPropertySet 258cdf0e10cSrcweir virtual uno::Reference< beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw (uno::RuntimeException) 259cdf0e10cSrcweir { 260cdf0e10cSrcweir return uno::Reference< beans::XPropertySetInfo >(); 261cdf0e10cSrcweir } 262cdf0e10cSrcweir 263cdf0e10cSrcweir virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& /*aPropertyName*/, 264cdf0e10cSrcweir const uno::Any& /*aValue*/ ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 265cdf0e10cSrcweir { 266cdf0e10cSrcweir } 267cdf0e10cSrcweir 268cdf0e10cSrcweir virtual uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 269cdf0e10cSrcweir { 270cdf0e10cSrcweir typedef ::canvas::tools::ValueMap< sal_Int16 > PropMapT; 271cdf0e10cSrcweir 272cdf0e10cSrcweir // fixed PropertyValue map 273cdf0e10cSrcweir static PropMapT::MapEntry lcl_propertyMap[] = 274cdf0e10cSrcweir { 275cdf0e10cSrcweir {"Height", 100}, 276cdf0e10cSrcweir {"MinimalFrameNumber", 50}, 277cdf0e10cSrcweir {"TransitionDuration", 10}, 278cdf0e10cSrcweir {"TransitionSubtype", animations::TransitionSubType::FROMTOPLEFT}, 279cdf0e10cSrcweir {"TransitionType", animations::TransitionType::PUSHWIPE}, 280cdf0e10cSrcweir {"Width", 100} 281cdf0e10cSrcweir }; 282cdf0e10cSrcweir 283cdf0e10cSrcweir static PropMapT aMap( lcl_propertyMap, 284cdf0e10cSrcweir sizeof(lcl_propertyMap)/sizeof(*lcl_propertyMap), 285cdf0e10cSrcweir true ); 286cdf0e10cSrcweir 287cdf0e10cSrcweir sal_Int16 aRes; 288cdf0e10cSrcweir if( !aMap.lookup( PropertyName, aRes )) 289cdf0e10cSrcweir return uno::Any(); 290cdf0e10cSrcweir 291cdf0e10cSrcweir return uno::makeAny(aRes); 292cdf0e10cSrcweir } 293cdf0e10cSrcweir 294cdf0e10cSrcweir virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& /*aPropertyName*/, 295cdf0e10cSrcweir const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 296cdf0e10cSrcweir { 297cdf0e10cSrcweir } 298cdf0e10cSrcweir 299cdf0e10cSrcweir virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& /*aPropertyName*/, 300cdf0e10cSrcweir const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 301cdf0e10cSrcweir { 302cdf0e10cSrcweir } 303cdf0e10cSrcweir 304cdf0e10cSrcweir virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& /*PropertyName*/, 305cdf0e10cSrcweir const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 306cdf0e10cSrcweir { 307cdf0e10cSrcweir } 308cdf0e10cSrcweir 309cdf0e10cSrcweir virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& /*PropertyName*/, 310cdf0e10cSrcweir const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 311cdf0e10cSrcweir { 312cdf0e10cSrcweir } 313cdf0e10cSrcweir }; 314cdf0e10cSrcweir 315cdf0e10cSrcweir 316cdf0e10cSrcweir class DemoApp : public Application 317cdf0e10cSrcweir { 318cdf0e10cSrcweir public: 319cdf0e10cSrcweir virtual void Main(); 320cdf0e10cSrcweir virtual sal_uInt16 Exception( sal_uInt16 nError ); 321cdf0e10cSrcweir }; 322cdf0e10cSrcweir 323cdf0e10cSrcweir class ChildWindow : public Window 324cdf0e10cSrcweir { 325cdf0e10cSrcweir public: 326cdf0e10cSrcweir ChildWindow( Window* pParent ); 327cdf0e10cSrcweir virtual ~ChildWindow(); 328cdf0e10cSrcweir virtual void Paint( const Rectangle& rRect ); 329cdf0e10cSrcweir virtual void Resize(); 330cdf0e10cSrcweir 331cdf0e10cSrcweir void setShow( const uno::Reference< presentation::XSlideShow >& rShow ) { mxShow = rShow; init(); } 332cdf0e10cSrcweir 333cdf0e10cSrcweir private: 334cdf0e10cSrcweir void init(); 335cdf0e10cSrcweir 336cdf0e10cSrcweir rtl::Reference< View > mpView; 337cdf0e10cSrcweir uno::Reference< presentation::XSlideShow > mxShow; 338cdf0e10cSrcweir }; 339cdf0e10cSrcweir 340cdf0e10cSrcweir ChildWindow::ChildWindow( Window* pParent ) : 341cdf0e10cSrcweir Window(pParent, WB_CLIPCHILDREN | WB_BORDER| WB_3DLOOK ), 342cdf0e10cSrcweir mpView(), 343cdf0e10cSrcweir mxShow() 344cdf0e10cSrcweir { 345cdf0e10cSrcweir EnablePaint( true ); 346cdf0e10cSrcweir Show(); 347cdf0e10cSrcweir } 348cdf0e10cSrcweir 349cdf0e10cSrcweir ChildWindow::~ChildWindow() 350cdf0e10cSrcweir { 351cdf0e10cSrcweir if( mxShow.is() && mpView.is() ) 352cdf0e10cSrcweir mxShow->removeView( mpView.get() ); 353cdf0e10cSrcweir } 354cdf0e10cSrcweir 355cdf0e10cSrcweir void ChildWindow::init() 356cdf0e10cSrcweir { 357cdf0e10cSrcweir try 358cdf0e10cSrcweir { 359cdf0e10cSrcweir if( !mpView.is() ) 360cdf0e10cSrcweir { 361cdf0e10cSrcweir uno::Reference< rendering::XCanvas > xCanvas( GetCanvas(), 362cdf0e10cSrcweir uno::UNO_QUERY_THROW ); 363cdf0e10cSrcweir uno::Reference< rendering::XSpriteCanvas > xSpriteCanvas( xCanvas, 364cdf0e10cSrcweir uno::UNO_QUERY_THROW ); 365cdf0e10cSrcweir mpView = new View( xSpriteCanvas ); 366cdf0e10cSrcweir mpView->resize( GetSizePixel() ); 367cdf0e10cSrcweir 368cdf0e10cSrcweir if( mxShow.is() ) 369cdf0e10cSrcweir mxShow->addView( mpView.get() ); 370cdf0e10cSrcweir } 371cdf0e10cSrcweir } 372cdf0e10cSrcweir catch (const uno::Exception &e) 373cdf0e10cSrcweir { 374cdf0e10cSrcweir OSL_TRACE( "Exception '%s' thrown\n" , 375cdf0e10cSrcweir (const sal_Char*)::rtl::OUStringToOString( e.Message, 376cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 )); 377cdf0e10cSrcweir } 378cdf0e10cSrcweir } 379cdf0e10cSrcweir 380cdf0e10cSrcweir void ChildWindow::Paint( const Rectangle& /*rRect*/ ) 381cdf0e10cSrcweir { 382cdf0e10cSrcweir try 383cdf0e10cSrcweir { 384cdf0e10cSrcweir if( mpView.is() ) 385cdf0e10cSrcweir mpView->repaint(); 386cdf0e10cSrcweir } 387cdf0e10cSrcweir catch (const uno::Exception &e) 388cdf0e10cSrcweir { 389cdf0e10cSrcweir OSL_TRACE( "Exception '%s' thrown\n" , 390cdf0e10cSrcweir (const sal_Char*)::rtl::OUStringToOString( e.Message, 391cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 )); 392cdf0e10cSrcweir } 393cdf0e10cSrcweir } 394cdf0e10cSrcweir 395cdf0e10cSrcweir void ChildWindow::Resize() 396cdf0e10cSrcweir { 397cdf0e10cSrcweir if( mpView.is() ) 398cdf0e10cSrcweir mpView->resize( GetSizePixel() ); 399cdf0e10cSrcweir } 400cdf0e10cSrcweir 401cdf0e10cSrcweir class DemoWindow : public Dialog 402cdf0e10cSrcweir { 403cdf0e10cSrcweir public: 404cdf0e10cSrcweir DemoWindow(); 405cdf0e10cSrcweir virtual void Paint( const Rectangle& rRect ); 406cdf0e10cSrcweir virtual void Resize(); 407cdf0e10cSrcweir 408cdf0e10cSrcweir private: 409cdf0e10cSrcweir void init(); 410cdf0e10cSrcweir DECL_LINK( updateHdl, Timer* ); 411cdf0e10cSrcweir 412cdf0e10cSrcweir ChildWindow maLeftChild; 413cdf0e10cSrcweir ChildWindow maRightTopChild; 414cdf0e10cSrcweir ChildWindow maRightBottomChild; 415cdf0e10cSrcweir uno::Reference< presentation::XSlideShow > mxShow; 416cdf0e10cSrcweir AutoTimer maUpdateTimer; 417cdf0e10cSrcweir bool mbSlideDisplayed; 418cdf0e10cSrcweir }; 419cdf0e10cSrcweir 420cdf0e10cSrcweir DemoWindow::DemoWindow() : 421cdf0e10cSrcweir Dialog((Window*)NULL), 422cdf0e10cSrcweir maLeftChild( this ), 423cdf0e10cSrcweir maRightTopChild( this ), 424cdf0e10cSrcweir maRightBottomChild( this ), 425cdf0e10cSrcweir mxShow(), 426cdf0e10cSrcweir maUpdateTimer(), 427cdf0e10cSrcweir mbSlideDisplayed( false ) 428cdf0e10cSrcweir { 429cdf0e10cSrcweir SetText( rtl::OUString::createFromAscii( "Slideshow Demo" ) ); 430cdf0e10cSrcweir SetSizePixel( Size( 640, 480 ) ); 431cdf0e10cSrcweir EnablePaint( true ); 432cdf0e10cSrcweir 433cdf0e10cSrcweir maLeftChild.SetPosSizePixel( Point(), Size(320,480) ); 434cdf0e10cSrcweir maRightTopChild.SetPosSizePixel( Point(320,0), Size(320,240) ); 435cdf0e10cSrcweir maRightBottomChild.SetPosSizePixel( Point(320,240), Size(320,240) ); 436cdf0e10cSrcweir Show(); 437cdf0e10cSrcweir 438cdf0e10cSrcweir maUpdateTimer.SetTimeoutHdl(LINK(this, DemoWindow, updateHdl)); 439cdf0e10cSrcweir maUpdateTimer.SetTimeout( (sal_uLong)30 ); 440cdf0e10cSrcweir maUpdateTimer.Start(); 441cdf0e10cSrcweir } 442cdf0e10cSrcweir 443cdf0e10cSrcweir void DemoWindow::init() 444cdf0e10cSrcweir { 445cdf0e10cSrcweir try 446cdf0e10cSrcweir { 447cdf0e10cSrcweir if( !mxShow.is() ) 448cdf0e10cSrcweir { 449cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xFactory( 450cdf0e10cSrcweir ::comphelper::getProcessServiceFactory(), 451cdf0e10cSrcweir uno::UNO_QUERY_THROW ); 452cdf0e10cSrcweir 453cdf0e10cSrcweir uno::Reference< uno::XInterface > xInt( xFactory->createInstance( 454cdf0e10cSrcweir ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.SlideShow")) )); 455cdf0e10cSrcweir 456cdf0e10cSrcweir mxShow.set( xInt, 457cdf0e10cSrcweir uno::UNO_QUERY_THROW ); 458cdf0e10cSrcweir 459cdf0e10cSrcweir maLeftChild.setShow( mxShow ); 460cdf0e10cSrcweir maRightTopChild.setShow( mxShow ); 461cdf0e10cSrcweir maRightBottomChild.setShow( mxShow ); 462cdf0e10cSrcweir } 463cdf0e10cSrcweir 464cdf0e10cSrcweir if( mxShow.is() && !mbSlideDisplayed ) 465cdf0e10cSrcweir { 466cdf0e10cSrcweir uno::Reference< drawing::XDrawPage > xSlide( new DummySlide ); 467cdf0e10cSrcweir mxShow->displaySlide( xSlide, 468d9ee14b8SDamjan Jovanovic NULL, 469cdf0e10cSrcweir uno::Reference< animations::XAnimationNode >(), 470cdf0e10cSrcweir uno::Sequence< beans::PropertyValue >() ); 471cdf0e10cSrcweir mxShow->setProperty( beans::PropertyValue( 472cdf0e10cSrcweir rtl::OUString::createFromAscii("RehearseTimings"), 473cdf0e10cSrcweir 0, 474cdf0e10cSrcweir uno::makeAny( sal_True ), 475cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE )); 476cdf0e10cSrcweir mbSlideDisplayed = true; 477cdf0e10cSrcweir } 478cdf0e10cSrcweir } 479cdf0e10cSrcweir catch (const uno::Exception &e) 480cdf0e10cSrcweir { 481cdf0e10cSrcweir OSL_TRACE( "Exception '%s' thrown\n" , 482cdf0e10cSrcweir (const sal_Char*)::rtl::OUStringToOString( e.Message, 483cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 )); 484cdf0e10cSrcweir } 485cdf0e10cSrcweir } 486cdf0e10cSrcweir 487cdf0e10cSrcweir IMPL_LINK( DemoWindow, updateHdl, Timer*, EMPTYARG ) 488cdf0e10cSrcweir { 489cdf0e10cSrcweir init(); 490cdf0e10cSrcweir 491cdf0e10cSrcweir double nTimeout; 492cdf0e10cSrcweir if( mxShow.is() ) 493cdf0e10cSrcweir mxShow->update(nTimeout); 494cdf0e10cSrcweir 495cdf0e10cSrcweir return 0; 496cdf0e10cSrcweir } 497cdf0e10cSrcweir 498cdf0e10cSrcweir void DemoWindow::Paint( const Rectangle& /*rRect*/ ) 499cdf0e10cSrcweir { 500cdf0e10cSrcweir init(); 501cdf0e10cSrcweir } 502cdf0e10cSrcweir 503cdf0e10cSrcweir void DemoWindow::Resize() 504cdf0e10cSrcweir { 505cdf0e10cSrcweir // TODO 506cdf0e10cSrcweir } 507cdf0e10cSrcweir 508cdf0e10cSrcweir sal_uInt16 DemoApp::Exception( sal_uInt16 nError ) 509cdf0e10cSrcweir { 510cdf0e10cSrcweir switch( nError & EXC_MAJORTYPE ) 511cdf0e10cSrcweir { 512cdf0e10cSrcweir case EXC_RSCNOTLOADED: 513cdf0e10cSrcweir Abort( String::CreateFromAscii( "Error: could not load language resources.\nPlease check your installation.\n" ) ); 514cdf0e10cSrcweir break; 515cdf0e10cSrcweir } 516cdf0e10cSrcweir return 0; 517cdf0e10cSrcweir } 518cdf0e10cSrcweir 519cdf0e10cSrcweir void DemoApp::Main() 520cdf0e10cSrcweir { 521cdf0e10cSrcweir bool bHelp = false; 522cdf0e10cSrcweir 523cdf0e10cSrcweir for( sal_uInt16 i = 0; i < GetCommandLineParamCount(); i++ ) 524cdf0e10cSrcweir { 525cdf0e10cSrcweir ::rtl::OUString aParam = GetCommandLineParam( i ); 526cdf0e10cSrcweir 527cdf0e10cSrcweir if( aParam.equalsAscii( "--help" ) || 528cdf0e10cSrcweir aParam.equalsAscii( "-h" ) ) 529cdf0e10cSrcweir bHelp = true; 530cdf0e10cSrcweir } 531cdf0e10cSrcweir 532cdf0e10cSrcweir if( bHelp ) 533cdf0e10cSrcweir { 534cdf0e10cSrcweir printf( "demoshow - life Slideshow testbed\n" ); 535cdf0e10cSrcweir return; 536cdf0e10cSrcweir } 537cdf0e10cSrcweir 538cdf0e10cSrcweir // bootstrap UNO 539cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xFactory; 540cdf0e10cSrcweir try 541cdf0e10cSrcweir { 542cdf0e10cSrcweir uno::Reference< uno::XComponentContext > xCtx = ::cppu::defaultBootstrap_InitialComponentContext(); 543cdf0e10cSrcweir xFactory = uno::Reference< lang::XMultiServiceFactory >( xCtx->getServiceManager(), 544cdf0e10cSrcweir uno::UNO_QUERY ); 545cdf0e10cSrcweir if( xFactory.is() ) 546cdf0e10cSrcweir ::comphelper::setProcessServiceFactory( xFactory ); 547cdf0e10cSrcweir } 548cdf0e10cSrcweir catch( uno::RuntimeException& ) 549cdf0e10cSrcweir { 550cdf0e10cSrcweir throw; 551cdf0e10cSrcweir } 552cdf0e10cSrcweir catch( uno::Exception& ) 553cdf0e10cSrcweir { 554cdf0e10cSrcweir OSL_ENSURE( false, 555cdf0e10cSrcweir rtl::OUStringToOString( 556cdf0e10cSrcweir comphelper::anyToString( cppu::getCaughtException() ), 557cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 ).getStr() ); 558cdf0e10cSrcweir } 559cdf0e10cSrcweir 560cdf0e10cSrcweir if( !xFactory.is() ) 561cdf0e10cSrcweir { 562cdf0e10cSrcweir OSL_TRACE( "Could not bootstrap UNO, installation must be in disorder. Exiting.\n" ); 563cdf0e10cSrcweir exit( 1 ); 564cdf0e10cSrcweir } 565cdf0e10cSrcweir 566cdf0e10cSrcweir // Create UCB. 567cdf0e10cSrcweir uno::Sequence< uno::Any > aArgs( 2 ); 568cdf0e10cSrcweir aArgs[ 0 ] <<= rtl::OUString::createFromAscii( UCB_CONFIGURATION_KEY1_LOCAL ); 569cdf0e10cSrcweir aArgs[ 1 ] <<= rtl::OUString::createFromAscii( UCB_CONFIGURATION_KEY2_OFFICE ); 570cdf0e10cSrcweir ::ucbhelper::ContentBroker::initialize( xFactory, aArgs ); 571cdf0e10cSrcweir 572cdf0e10cSrcweir DemoWindow pWindow; 573cdf0e10cSrcweir pWindow.Execute(); 574cdf0e10cSrcweir 575cdf0e10cSrcweir // clean up UCB 576cdf0e10cSrcweir ::ucbhelper::ContentBroker::deinitialize(); 577cdf0e10cSrcweir } 578cdf0e10cSrcweir } 579cdf0e10cSrcweir 580*d443ea8fSDamjan Jovanovic sal_Bool SVMain(); 581*d443ea8fSDamjan Jovanovic 582*d443ea8fSDamjan Jovanovic int main(int argc, char **argv) 583*d443ea8fSDamjan Jovanovic { 584*d443ea8fSDamjan Jovanovic tools::extendApplicationEnvironment(); 585*d443ea8fSDamjan Jovanovic 586*d443ea8fSDamjan Jovanovic DemoApp aApp; 587*d443ea8fSDamjan Jovanovic SVMain(); 588*d443ea8fSDamjan Jovanovic 589*d443ea8fSDamjan Jovanovic return 0; 590*d443ea8fSDamjan Jovanovic } 591