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