xref: /trunk/main/sd/source/ui/slideshow/slideshowimpl.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir 
29*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
30*cdf0e10cSrcweir #include "precompiled_sd.hxx"
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #include <boost/scoped_ptr.hpp>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include "com/sun/star/frame/XComponentLoader.hpp"
35*cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/document/XEventsSupplier.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/drawing/XMasterPageTarget.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/container/XNameReplace.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySetInfo.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/awt/SystemPointer.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatch.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/frame/XLayoutManager.hpp>
46*cdf0e10cSrcweir #include <vos/process.hxx>
47*cdf0e10cSrcweir #include <svl/aeitem.hxx>
48*cdf0e10cSrcweir #include <svl/urihelper.hxx>
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir #include <toolkit/unohlp.hxx>
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir #include <sfx2/imagemgr.hxx>
53*cdf0e10cSrcweir #include <sfx2/request.hxx>
54*cdf0e10cSrcweir #include <sfx2/docfile.hxx>
55*cdf0e10cSrcweir #include <sfx2/app.hxx>
56*cdf0e10cSrcweir #include <svx/unoapi.hxx>
57*cdf0e10cSrcweir #include <svx/svdoole2.hxx>
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir // for child window ids
60*cdf0e10cSrcweir #include <sfx2/templdlg.hxx>
61*cdf0e10cSrcweir #include <svx/f3dchild.hxx>
62*cdf0e10cSrcweir #include <svx/imapdlg.hxx>
63*cdf0e10cSrcweir #include <svx/fontwork.hxx>
64*cdf0e10cSrcweir #include <svx/colrctrl.hxx>
65*cdf0e10cSrcweir #include <svx/bmpmask.hxx>
66*cdf0e10cSrcweir #include <svx/srchdlg.hxx>
67*cdf0e10cSrcweir #include <svx/hyprlink.hxx>
68*cdf0e10cSrcweir #include <svx/hyperdlg.hxx>
69*cdf0e10cSrcweir #include <svx/galbrws.hxx>
70*cdf0e10cSrcweir #include "NavigatorChildWindow.hxx"
71*cdf0e10cSrcweir #include "AnimationChildWindow.hxx"
72*cdf0e10cSrcweir #include <slideshowimpl.hxx>
73*cdf0e10cSrcweir #include <slideshowviewimpl.hxx>
74*cdf0e10cSrcweir #include <pgjump.hxx>
75*cdf0e10cSrcweir #include "PaneHider.hxx"
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir #include "glob.hrc"
78*cdf0e10cSrcweir #include "res_bmp.hrc"
79*cdf0e10cSrcweir #include "sdresid.hxx"
80*cdf0e10cSrcweir #include "vcl/canvastools.hxx"
81*cdf0e10cSrcweir #include "comphelper/anytostring.hxx"
82*cdf0e10cSrcweir #include "cppuhelper/exc_hlp.hxx"
83*cdf0e10cSrcweir #include "rtl/ref.hxx"
84*cdf0e10cSrcweir #include "slideshow.hrc"
85*cdf0e10cSrcweir #include "canvas/elapsedtime.hxx"
86*cdf0e10cSrcweir #include "canvas/prioritybooster.hxx"
87*cdf0e10cSrcweir #include "avmedia/mediawindow.hxx"
88*cdf0e10cSrcweir #include  "svtools/colrdlg.hxx"
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir #include <boost/noncopyable.hpp>
91*cdf0e10cSrcweir #include <boost/bind.hpp>
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir using ::rtl::OUString;
94*cdf0e10cSrcweir using ::rtl::OString;
95*cdf0e10cSrcweir using ::cppu::OInterfaceContainerHelper;
96*cdf0e10cSrcweir using ::comphelper::ImplementationReference;
97*cdf0e10cSrcweir using ::com::sun::star::animations::XAnimationNode;
98*cdf0e10cSrcweir using ::com::sun::star::animations::XAnimationListener;
99*cdf0e10cSrcweir using ::com::sun::star::awt::XWindow;
100*cdf0e10cSrcweir using namespace ::com::sun::star;
101*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
102*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
103*cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
104*cdf0e10cSrcweir using namespace ::com::sun::star::container;
105*cdf0e10cSrcweir using namespace ::com::sun::star::document;
106*cdf0e10cSrcweir using namespace ::com::sun::star::presentation;
107*cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
108*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir extern void NotifyDocumentEvent( SdDrawDocument* pDocument, const rtl::OUString& rEventName );
111*cdf0e10cSrcweir extern String getUiNameFromPageApiNameImpl( const OUString& rApiName );
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir namespace sd
114*cdf0e10cSrcweir {
115*cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir // Slots, welche im Sfx verwaltet werden und in der SlideShow disabled
118*cdf0e10cSrcweir // werden sollen (muss in Reihenfolge der SIDs geordnet sein)
119*cdf0e10cSrcweir static sal_uInt16 __READONLY_DATA pAllowed[] =
120*cdf0e10cSrcweir {
121*cdf0e10cSrcweir     SID_OPENDOC                             , //     5501   // damit interne Spruenge klappen
122*cdf0e10cSrcweir     SID_JUMPTOMARK                          , //     5598
123*cdf0e10cSrcweir //  SID_SHOWPOPUPS                          , //     5929
124*cdf0e10cSrcweir //    SID_GALLERY                             , //     5960
125*cdf0e10cSrcweir     SID_OPENHYPERLINK                       , //     6676
126*cdf0e10cSrcweir //    SID_GALLERY_FORMATS                     , //    10280
127*cdf0e10cSrcweir     SID_NAVIGATOR                           , //    10366
128*cdf0e10cSrcweir //  SID_FM_DESIGN_MODE                      , //    10629
129*cdf0e10cSrcweir     SID_PRESENTATION_END                    , //    27218
130*cdf0e10cSrcweir     SID_NAVIGATOR_PAGENAME                  , //    27287
131*cdf0e10cSrcweir     SID_NAVIGATOR_STATE                     , //    27288
132*cdf0e10cSrcweir     SID_NAVIGATOR_INIT                      , //    27289
133*cdf0e10cSrcweir     SID_NAVIGATOR_PEN                       , //    27291
134*cdf0e10cSrcweir     SID_NAVIGATOR_PAGE                      , //    27292
135*cdf0e10cSrcweir     SID_NAVIGATOR_OBJECT                      //    27293
136*cdf0e10cSrcweir };
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
141*cdf0e10cSrcweir // AnimationSlideController
142*cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir class AnimationSlideController
145*cdf0e10cSrcweir {
146*cdf0e10cSrcweir public:
147*cdf0e10cSrcweir     enum Mode { ALL, FROM, CUSTOM, PREVIEW };
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir public:
150*cdf0e10cSrcweir     AnimationSlideController( Reference< XIndexAccess > xSlides, Mode eMode );
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir     void setStartSlideNumber( sal_Int32 nSlideNumber ) { mnStartSlideNumber = nSlideNumber; }
153*cdf0e10cSrcweir     sal_Int32 getStartSlideIndex() const;
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir     sal_Int32 getCurrentSlideNumber() const;
156*cdf0e10cSrcweir     sal_Int32 getCurrentSlideIndex() const;
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir     sal_Int32 getSlideIndexCount() const { return maSlideNumbers.size(); }
159*cdf0e10cSrcweir     sal_Int32 getSlideNumberCount() const { return mnSlideCount; }
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir     sal_Int32 getSlideNumber( sal_Int32 nSlideIndex ) const;
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir     void insertSlideNumber( sal_Int32 nSlideNumber, bool bVisible = true );
164*cdf0e10cSrcweir     void setPreviewNode( const Reference< XAnimationNode >& xPreviewNode );
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir     bool jumpToSlideIndex( sal_Int32 nNewSlideIndex );
167*cdf0e10cSrcweir     bool jumpToSlideNumber( sal_Int32 nNewSlideIndex );
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir     bool nextSlide();
170*cdf0e10cSrcweir     bool previousSlide();
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir     void displayCurrentSlide( const Reference< XSlideShow >& xShow,
173*cdf0e10cSrcweir                               const Reference< XDrawPagesSupplier>& xDrawPages,
174*cdf0e10cSrcweir                               const bool bSkipAllMainSequenceEffects );
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir     sal_Int32 getNextSlideIndex() const;
177*cdf0e10cSrcweir     sal_Int32 getPreviousSlideIndex() const;
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir     bool isVisibleSlideNumber( sal_Int32 nSlideNumber ) const;
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir     Reference< XDrawPage > getSlideByNumber( sal_Int32 nSlideNumber ) const;
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir     sal_Int32 getNextSlideNumber() const;
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir     bool hasSlides() const { return !maSlideNumbers.empty(); }
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir private:
188*cdf0e10cSrcweir     bool getSlideAPI( sal_Int32 nSlideNumber, Reference< XDrawPage >& xSlide, Reference< XAnimationNode >& xAnimNode );
189*cdf0e10cSrcweir     sal_Int32 findSlideIndex( sal_Int32 nSlideNumber ) const;
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir     bool isValidIndex( sal_Int32 nIndex ) const { return (nIndex >= 0) && (nIndex < (sal_Int32)maSlideNumbers.size()); }
192*cdf0e10cSrcweir     bool isValidSlideNumber( sal_Int32 nSlideNumber ) const { return (nSlideNumber >= 0) && (nSlideNumber < mnSlideCount); }
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir private:
195*cdf0e10cSrcweir     Mode meMode;
196*cdf0e10cSrcweir     sal_Int32 mnStartSlideNumber;
197*cdf0e10cSrcweir     std::vector< sal_Int32 > maSlideNumbers;
198*cdf0e10cSrcweir     std::vector< bool > maSlideVisible;
199*cdf0e10cSrcweir     std::vector< bool > maSlideVisited;
200*cdf0e10cSrcweir     Reference< XAnimationNode > mxPreviewNode;
201*cdf0e10cSrcweir     sal_Int32 mnSlideCount;
202*cdf0e10cSrcweir     sal_Int32 mnCurrentSlideIndex;
203*cdf0e10cSrcweir     sal_Int32 mnHiddenSlideNumber;
204*cdf0e10cSrcweir     Reference< XIndexAccess > mxSlides;
205*cdf0e10cSrcweir };
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir Reference< XDrawPage > AnimationSlideController::getSlideByNumber( sal_Int32 nSlideNumber ) const
208*cdf0e10cSrcweir {
209*cdf0e10cSrcweir     Reference< XDrawPage > xSlide;
210*cdf0e10cSrcweir     if( mxSlides.is() && (nSlideNumber >= 0) && (nSlideNumber < mxSlides->getCount()) )
211*cdf0e10cSrcweir         mxSlides->getByIndex( nSlideNumber ) >>= xSlide;
212*cdf0e10cSrcweir     return xSlide;
213*cdf0e10cSrcweir }
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir bool AnimationSlideController::isVisibleSlideNumber( sal_Int32 nSlideNumber ) const
216*cdf0e10cSrcweir {
217*cdf0e10cSrcweir     sal_Int32 nIndex = findSlideIndex( nSlideNumber );
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir     if( nIndex != -1 )
220*cdf0e10cSrcweir         return maSlideVisible[ nIndex ];
221*cdf0e10cSrcweir     else
222*cdf0e10cSrcweir         return false;
223*cdf0e10cSrcweir }
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir void AnimationSlideController::setPreviewNode( const Reference< XAnimationNode >& xPreviewNode )
227*cdf0e10cSrcweir {
228*cdf0e10cSrcweir     mxPreviewNode = xPreviewNode;
229*cdf0e10cSrcweir }
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir AnimationSlideController::AnimationSlideController( Reference< XIndexAccess > xSlides, Mode eMode  )
232*cdf0e10cSrcweir :   meMode( eMode )
233*cdf0e10cSrcweir ,   mnStartSlideNumber(-1)
234*cdf0e10cSrcweir ,   mnSlideCount( 0 )
235*cdf0e10cSrcweir ,   mnCurrentSlideIndex(0)
236*cdf0e10cSrcweir ,   mnHiddenSlideNumber( -1 )
237*cdf0e10cSrcweir ,   mxSlides( xSlides )
238*cdf0e10cSrcweir {
239*cdf0e10cSrcweir     if( mxSlides.is() )
240*cdf0e10cSrcweir         mnSlideCount = xSlides->getCount();
241*cdf0e10cSrcweir }
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir sal_Int32 AnimationSlideController::getStartSlideIndex() const
244*cdf0e10cSrcweir {
245*cdf0e10cSrcweir     if( mnStartSlideNumber >= 0 )
246*cdf0e10cSrcweir     {
247*cdf0e10cSrcweir         sal_Int32 nIndex;
248*cdf0e10cSrcweir         const sal_Int32 nCount = maSlideNumbers.size();
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir         for( nIndex = 0; nIndex < nCount; nIndex++ )
251*cdf0e10cSrcweir         {
252*cdf0e10cSrcweir             if( maSlideNumbers[nIndex] == mnStartSlideNumber )
253*cdf0e10cSrcweir                 return nIndex;
254*cdf0e10cSrcweir         }
255*cdf0e10cSrcweir     }
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir     return 0;
258*cdf0e10cSrcweir }
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir sal_Int32 AnimationSlideController::getCurrentSlideNumber() const
261*cdf0e10cSrcweir {
262*cdf0e10cSrcweir     if( mnHiddenSlideNumber != -1 )
263*cdf0e10cSrcweir         return mnHiddenSlideNumber;
264*cdf0e10cSrcweir     else if( !maSlideNumbers.empty() )
265*cdf0e10cSrcweir         return maSlideNumbers[mnCurrentSlideIndex];
266*cdf0e10cSrcweir     else
267*cdf0e10cSrcweir         return 0;
268*cdf0e10cSrcweir }
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir sal_Int32 AnimationSlideController::getCurrentSlideIndex() const
271*cdf0e10cSrcweir {
272*cdf0e10cSrcweir     if( mnHiddenSlideNumber != -1 )
273*cdf0e10cSrcweir         return -1;
274*cdf0e10cSrcweir     else
275*cdf0e10cSrcweir         return mnCurrentSlideIndex;
276*cdf0e10cSrcweir }
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir bool AnimationSlideController::jumpToSlideIndex( sal_Int32 nNewSlideIndex )
279*cdf0e10cSrcweir {
280*cdf0e10cSrcweir     if( isValidIndex( nNewSlideIndex ) )
281*cdf0e10cSrcweir     {
282*cdf0e10cSrcweir         mnCurrentSlideIndex = nNewSlideIndex;
283*cdf0e10cSrcweir         mnHiddenSlideNumber = -1;
284*cdf0e10cSrcweir         maSlideVisited[mnCurrentSlideIndex] = true;
285*cdf0e10cSrcweir         return true;
286*cdf0e10cSrcweir     }
287*cdf0e10cSrcweir     else
288*cdf0e10cSrcweir     {
289*cdf0e10cSrcweir         return false;
290*cdf0e10cSrcweir     }
291*cdf0e10cSrcweir }
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir bool AnimationSlideController::jumpToSlideNumber( sal_Int32 nNewSlideNumber )
294*cdf0e10cSrcweir {
295*cdf0e10cSrcweir     sal_Int32 nIndex = findSlideIndex( nNewSlideNumber );
296*cdf0e10cSrcweir     if( isValidIndex( nIndex ) )
297*cdf0e10cSrcweir     {
298*cdf0e10cSrcweir         return jumpToSlideIndex( nIndex );
299*cdf0e10cSrcweir     }
300*cdf0e10cSrcweir     else if( (nNewSlideNumber >= 0) && (nNewSlideNumber < mnSlideCount) )
301*cdf0e10cSrcweir     {
302*cdf0e10cSrcweir         // jump to a hidden slide
303*cdf0e10cSrcweir         mnHiddenSlideNumber = nNewSlideNumber;
304*cdf0e10cSrcweir         return true;
305*cdf0e10cSrcweir     }
306*cdf0e10cSrcweir     else
307*cdf0e10cSrcweir     {
308*cdf0e10cSrcweir         return false;
309*cdf0e10cSrcweir     }
310*cdf0e10cSrcweir }
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir sal_Int32 AnimationSlideController::getSlideNumber( sal_Int32 nSlideIndex ) const
313*cdf0e10cSrcweir {
314*cdf0e10cSrcweir     if( isValidIndex( nSlideIndex ) )
315*cdf0e10cSrcweir         return maSlideNumbers[nSlideIndex];
316*cdf0e10cSrcweir     else
317*cdf0e10cSrcweir         return -1;
318*cdf0e10cSrcweir }
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir void AnimationSlideController::insertSlideNumber( sal_Int32 nSlideNumber, bool bVisible /* = true */ )
321*cdf0e10cSrcweir {
322*cdf0e10cSrcweir     DBG_ASSERT( isValidSlideNumber( nSlideNumber ), "sd::AnimationSlideController::insertSlideNumber(), illegal index" );
323*cdf0e10cSrcweir     if( isValidSlideNumber( nSlideNumber ) )
324*cdf0e10cSrcweir     {
325*cdf0e10cSrcweir         maSlideNumbers.push_back( nSlideNumber );
326*cdf0e10cSrcweir         maSlideVisible.push_back( bVisible );
327*cdf0e10cSrcweir         maSlideVisited.push_back( false );
328*cdf0e10cSrcweir     }
329*cdf0e10cSrcweir }
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir bool AnimationSlideController::getSlideAPI( sal_Int32 nSlideNumber, Reference< XDrawPage >& xSlide, Reference< XAnimationNode >& xAnimNode )
332*cdf0e10cSrcweir {
333*cdf0e10cSrcweir     if( isValidSlideNumber( nSlideNumber ) ) try
334*cdf0e10cSrcweir     {
335*cdf0e10cSrcweir         xSlide = Reference< XDrawPage >( mxSlides->getByIndex(nSlideNumber), UNO_QUERY_THROW );
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir         if( meMode == PREVIEW )
338*cdf0e10cSrcweir         {
339*cdf0e10cSrcweir             xAnimNode = mxPreviewNode;
340*cdf0e10cSrcweir         }
341*cdf0e10cSrcweir         else
342*cdf0e10cSrcweir         {
343*cdf0e10cSrcweir             Reference< animations::XAnimationNodeSupplier > xAnimNodeSupplier( xSlide, UNO_QUERY_THROW );
344*cdf0e10cSrcweir             xAnimNode = xAnimNodeSupplier->getAnimationNode();
345*cdf0e10cSrcweir         }
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir         return true;
348*cdf0e10cSrcweir     }
349*cdf0e10cSrcweir     catch( Exception& e )
350*cdf0e10cSrcweir     {
351*cdf0e10cSrcweir         (void)e;
352*cdf0e10cSrcweir         DBG_ERROR(
353*cdf0e10cSrcweir             (OString("sd::AnimationSlideController::getSlideAPI(), "
354*cdf0e10cSrcweir                     "exception caught: ") +
355*cdf0e10cSrcweir             rtl::OUStringToOString(
356*cdf0e10cSrcweir                 comphelper::anyToString( cppu::getCaughtException() ),
357*cdf0e10cSrcweir                 RTL_TEXTENCODING_UTF8 )).getStr() );
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir     }
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir     return false;
362*cdf0e10cSrcweir }
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir sal_Int32 AnimationSlideController::findSlideIndex( sal_Int32 nSlideNumber ) const
365*cdf0e10cSrcweir {
366*cdf0e10cSrcweir     sal_Int32 nIndex;
367*cdf0e10cSrcweir     const sal_Int32 nCount = maSlideNumbers.size();
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir     for( nIndex = 0; nIndex < nCount; nIndex++ )
370*cdf0e10cSrcweir     {
371*cdf0e10cSrcweir         if( maSlideNumbers[nIndex] == nSlideNumber )
372*cdf0e10cSrcweir             return nIndex;
373*cdf0e10cSrcweir     }
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir     return -1;
376*cdf0e10cSrcweir }
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir sal_Int32 AnimationSlideController::getNextSlideIndex() const
379*cdf0e10cSrcweir {
380*cdf0e10cSrcweir     switch( meMode )
381*cdf0e10cSrcweir     {
382*cdf0e10cSrcweir     case ALL:
383*cdf0e10cSrcweir         {
384*cdf0e10cSrcweir             sal_Int32 nNewSlideIndex = mnCurrentSlideIndex + 1;
385*cdf0e10cSrcweir             if( isValidIndex( nNewSlideIndex ) )
386*cdf0e10cSrcweir             {
387*cdf0e10cSrcweir                 // if the current slide is not excluded, make sure the
388*cdf0e10cSrcweir                 // next slide is also not excluded.
389*cdf0e10cSrcweir                 // if the current slide is excluded, we want to go
390*cdf0e10cSrcweir                 // to the next slide, even if this is also excluded.
391*cdf0e10cSrcweir                 if( maSlideVisible[mnCurrentSlideIndex] )
392*cdf0e10cSrcweir                 {
393*cdf0e10cSrcweir                     while( isValidIndex( nNewSlideIndex ) )
394*cdf0e10cSrcweir                     {
395*cdf0e10cSrcweir                         if( maSlideVisible[nNewSlideIndex] )
396*cdf0e10cSrcweir                             break;
397*cdf0e10cSrcweir 
398*cdf0e10cSrcweir                         nNewSlideIndex++;
399*cdf0e10cSrcweir                     }
400*cdf0e10cSrcweir                 }
401*cdf0e10cSrcweir             }
402*cdf0e10cSrcweir             return isValidIndex( nNewSlideIndex ) ? nNewSlideIndex : -1;
403*cdf0e10cSrcweir         }
404*cdf0e10cSrcweir 
405*cdf0e10cSrcweir     case FROM:
406*cdf0e10cSrcweir     case CUSTOM:
407*cdf0e10cSrcweir         return mnHiddenSlideNumber == -1 ? mnCurrentSlideIndex + 1 : mnCurrentSlideIndex;
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir     default:
410*cdf0e10cSrcweir     case PREVIEW:
411*cdf0e10cSrcweir         return -1;
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir     }
414*cdf0e10cSrcweir }
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir sal_Int32 AnimationSlideController::getNextSlideNumber() const
417*cdf0e10cSrcweir {
418*cdf0e10cSrcweir     sal_Int32 nNextSlideIndex = getNextSlideIndex();
419*cdf0e10cSrcweir     if( isValidIndex( nNextSlideIndex ) )
420*cdf0e10cSrcweir     {
421*cdf0e10cSrcweir         return maSlideNumbers[nNextSlideIndex];
422*cdf0e10cSrcweir     }
423*cdf0e10cSrcweir     else
424*cdf0e10cSrcweir     {
425*cdf0e10cSrcweir         return -1;
426*cdf0e10cSrcweir     }
427*cdf0e10cSrcweir }
428*cdf0e10cSrcweir 
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir bool AnimationSlideController::nextSlide()
431*cdf0e10cSrcweir {
432*cdf0e10cSrcweir     return jumpToSlideIndex( getNextSlideIndex() );
433*cdf0e10cSrcweir }
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir sal_Int32 AnimationSlideController::getPreviousSlideIndex() const
436*cdf0e10cSrcweir {
437*cdf0e10cSrcweir     sal_Int32 nNewSlideIndex = mnCurrentSlideIndex - 1;
438*cdf0e10cSrcweir 
439*cdf0e10cSrcweir     switch( meMode )
440*cdf0e10cSrcweir     {
441*cdf0e10cSrcweir         case ALL:
442*cdf0e10cSrcweir         {
443*cdf0e10cSrcweir             // make sure the previous slide is visible
444*cdf0e10cSrcweir             // or was already visited
445*cdf0e10cSrcweir             while( isValidIndex( nNewSlideIndex ) )
446*cdf0e10cSrcweir             {
447*cdf0e10cSrcweir                 if( maSlideVisible[nNewSlideIndex] || maSlideVisited[nNewSlideIndex] )
448*cdf0e10cSrcweir                     break;
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir                 nNewSlideIndex--;
451*cdf0e10cSrcweir             }
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir             break;
454*cdf0e10cSrcweir         }
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir         case PREVIEW:
457*cdf0e10cSrcweir             return -1;
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir         default:
460*cdf0e10cSrcweir             break;
461*cdf0e10cSrcweir     }
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir     return nNewSlideIndex;
464*cdf0e10cSrcweir }
465*cdf0e10cSrcweir 
466*cdf0e10cSrcweir bool AnimationSlideController::previousSlide()
467*cdf0e10cSrcweir {
468*cdf0e10cSrcweir     return jumpToSlideIndex( getPreviousSlideIndex() );
469*cdf0e10cSrcweir }
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir void AnimationSlideController::displayCurrentSlide( const Reference< XSlideShow >& xShow,
472*cdf0e10cSrcweir                                                     const Reference< XDrawPagesSupplier>& xDrawPages,
473*cdf0e10cSrcweir                                                     const bool bSkipAllMainSequenceEffects )
474*cdf0e10cSrcweir {
475*cdf0e10cSrcweir     const sal_Int32 nCurrentSlideNumber = getCurrentSlideNumber();
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir     if( xShow.is() && (nCurrentSlideNumber != -1 ) )
478*cdf0e10cSrcweir     {
479*cdf0e10cSrcweir         Reference< XDrawPage > xSlide;
480*cdf0e10cSrcweir         Reference< XAnimationNode > xAnimNode;
481*cdf0e10cSrcweir         ::std::vector<PropertyValue> aProperties;
482*cdf0e10cSrcweir 
483*cdf0e10cSrcweir         const sal_Int32 nNextSlideNumber = getNextSlideNumber();
484*cdf0e10cSrcweir         if( getSlideAPI( nNextSlideNumber, xSlide, xAnimNode )  )
485*cdf0e10cSrcweir         {
486*cdf0e10cSrcweir             Sequence< Any > aValue(2);
487*cdf0e10cSrcweir             aValue[0] <<= xSlide;
488*cdf0e10cSrcweir             aValue[1] <<= xAnimNode;
489*cdf0e10cSrcweir             aProperties.push_back(
490*cdf0e10cSrcweir                 PropertyValue(
491*cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM( "Prefetch" ) ),
492*cdf0e10cSrcweir                     -1,
493*cdf0e10cSrcweir                     Any(aValue),
494*cdf0e10cSrcweir                     PropertyState_DIRECT_VALUE));
495*cdf0e10cSrcweir         }
496*cdf0e10cSrcweir         if (bSkipAllMainSequenceEffects)
497*cdf0e10cSrcweir         {
498*cdf0e10cSrcweir             // Add one property that prevents the slide transition from being
499*cdf0e10cSrcweir             // shown (to speed up the transition to the previous slide) and
500*cdf0e10cSrcweir             // one to show all main sequence effects so that the user can
501*cdf0e10cSrcweir             // continue to undo effects.
502*cdf0e10cSrcweir             aProperties.push_back(
503*cdf0e10cSrcweir                 PropertyValue(
504*cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM("SkipAllMainSequenceEffects")),
505*cdf0e10cSrcweir                     -1,
506*cdf0e10cSrcweir                     Any(sal_True),
507*cdf0e10cSrcweir                     PropertyState_DIRECT_VALUE));
508*cdf0e10cSrcweir             aProperties.push_back(
509*cdf0e10cSrcweir                 PropertyValue(
510*cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM("SkipSlideTransition")),
511*cdf0e10cSrcweir                     -1,
512*cdf0e10cSrcweir                     Any(sal_True),
513*cdf0e10cSrcweir                     PropertyState_DIRECT_VALUE));
514*cdf0e10cSrcweir         }
515*cdf0e10cSrcweir 
516*cdf0e10cSrcweir         // Convert vector into uno Sequence.
517*cdf0e10cSrcweir         Sequence< PropertyValue > aPropertySequence (aProperties.size());
518*cdf0e10cSrcweir         for (int nIndex=0,nCount=aProperties.size();nIndex<nCount; ++nIndex)
519*cdf0e10cSrcweir             aPropertySequence[nIndex] = aProperties[nIndex];
520*cdf0e10cSrcweir 
521*cdf0e10cSrcweir         if( getSlideAPI( nCurrentSlideNumber, xSlide, xAnimNode ) )
522*cdf0e10cSrcweir             xShow->displaySlide( xSlide, xDrawPages, xAnimNode, aPropertySequence );
523*cdf0e10cSrcweir     }
524*cdf0e10cSrcweir }
525*cdf0e10cSrcweir 
526*cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
527*cdf0e10cSrcweir // class SlideshowImpl
528*cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
529*cdf0e10cSrcweir 
530*cdf0e10cSrcweir SlideshowImpl::SlideshowImpl( const Reference< XPresentation2 >& xPresentation, ViewShell* pViewSh, ::sd::View* pView, SdDrawDocument* pDoc, ::Window* pParentWindow )
531*cdf0e10cSrcweir : SlideshowImplBase( m_aMutex )
532*cdf0e10cSrcweir , mxModel(pDoc->getUnoModel(),UNO_QUERY_THROW)
533*cdf0e10cSrcweir , mpView(pView)
534*cdf0e10cSrcweir , mpViewShell(pViewSh)
535*cdf0e10cSrcweir , mpDocSh(pDoc->GetDocSh())
536*cdf0e10cSrcweir , mpDoc(pDoc)
537*cdf0e10cSrcweir , mpNewAttr(0)
538*cdf0e10cSrcweir , mpParentWindow(pParentWindow)
539*cdf0e10cSrcweir , mpShowWindow(0)
540*cdf0e10cSrcweir , mpTimeButton(0)
541*cdf0e10cSrcweir , mnRestoreSlide(0)
542*cdf0e10cSrcweir , maPresSize( -1, -1 )
543*cdf0e10cSrcweir , meAnimationMode(ANIMATIONMODE_SHOW)
544*cdf0e10cSrcweir , mpOldActiveWindow(0)
545*cdf0e10cSrcweir , mnChildMask( 0 )
546*cdf0e10cSrcweir , mbGridVisible(false)
547*cdf0e10cSrcweir , mbBordVisible(false)
548*cdf0e10cSrcweir , mbSlideBorderVisible(false)
549*cdf0e10cSrcweir , mbSetOnlineSpelling(false)
550*cdf0e10cSrcweir , mbDisposed(false)
551*cdf0e10cSrcweir , mbRehearseTimings(false)
552*cdf0e10cSrcweir , mbDesignMode(false)
553*cdf0e10cSrcweir , mbIsPaused(false)
554*cdf0e10cSrcweir , mbInputFreeze(false)
555*cdf0e10cSrcweir , mbActive(sal_False)
556*cdf0e10cSrcweir , maPresSettings( pDoc->getPresentationSettings() )
557*cdf0e10cSrcweir , mnUserPaintColor( 0x80ff0000L )
558*cdf0e10cSrcweir , mbUsePen(false)
559*cdf0e10cSrcweir , mdUserPaintStrokeWidth ( 150.0 )
560*cdf0e10cSrcweir #ifdef ENABLE_ERASER_UI
561*cdf0e10cSrcweir , mbSwitchEraserMode(false)
562*cdf0e10cSrcweir , mnEraseInkSize(100)
563*cdf0e10cSrcweir #endif
564*cdf0e10cSrcweir , mnEntryCounter(0)
565*cdf0e10cSrcweir , mnLastSlideNumber(-1)
566*cdf0e10cSrcweir , msOnClick( RTL_CONSTASCII_USTRINGPARAM("OnClick") )
567*cdf0e10cSrcweir , msBookmark( RTL_CONSTASCII_USTRINGPARAM("Bookmark") )
568*cdf0e10cSrcweir , msVerb( RTL_CONSTASCII_USTRINGPARAM("Verb") )
569*cdf0e10cSrcweir , mnEndShowEvent(0)
570*cdf0e10cSrcweir , mnContextMenuEvent(0)
571*cdf0e10cSrcweir , mnUpdateEvent(0)
572*cdf0e10cSrcweir , mxPresentation( xPresentation )
573*cdf0e10cSrcweir {
574*cdf0e10cSrcweir     if( mpViewShell )
575*cdf0e10cSrcweir         mpOldActiveWindow = mpViewShell->GetActiveWindow();
576*cdf0e10cSrcweir 
577*cdf0e10cSrcweir     maUpdateTimer.SetTimeoutHdl(LINK(this, SlideshowImpl, updateHdl));
578*cdf0e10cSrcweir 
579*cdf0e10cSrcweir     maDeactivateTimer.SetTimeoutHdl(LINK(this, SlideshowImpl, deactivateHdl));
580*cdf0e10cSrcweir     maDeactivateTimer.SetTimeout( 20 );
581*cdf0e10cSrcweir 
582*cdf0e10cSrcweir     maInputFreezeTimer.SetTimeoutHdl( LINK( this, SlideshowImpl, ReadyForNextInputHdl ) );
583*cdf0e10cSrcweir     maInputFreezeTimer.SetTimeout( 20 );
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir     SvtSaveOptions aOptions;
586*cdf0e10cSrcweir 
587*cdf0e10cSrcweir         // no autosave during show
588*cdf0e10cSrcweir     if( aOptions.IsAutoSave() )
589*cdf0e10cSrcweir         mbAutoSaveWasOn = true;
590*cdf0e10cSrcweir 
591*cdf0e10cSrcweir     Application::AddEventListener( LINK( this, SlideshowImpl, EventListenerHdl ) );
592*cdf0e10cSrcweir 
593*cdf0e10cSrcweir     mbUsePen = maPresSettings.mbMouseAsPen;
594*cdf0e10cSrcweir 
595*cdf0e10cSrcweir     SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
596*cdf0e10cSrcweir     if( pOptions )
597*cdf0e10cSrcweir     {
598*cdf0e10cSrcweir         mnUserPaintColor = pOptions->GetPresentationPenColor();
599*cdf0e10cSrcweir         mdUserPaintStrokeWidth = pOptions->GetPresentationPenWidth();
600*cdf0e10cSrcweir     }
601*cdf0e10cSrcweir }
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir SlideshowImpl::~SlideshowImpl()
604*cdf0e10cSrcweir {
605*cdf0e10cSrcweir     SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
606*cdf0e10cSrcweir     if( pOptions )
607*cdf0e10cSrcweir     {
608*cdf0e10cSrcweir         pOptions->SetPresentationPenColor(mnUserPaintColor);
609*cdf0e10cSrcweir         pOptions->SetPresentationPenWidth(mdUserPaintStrokeWidth);
610*cdf0e10cSrcweir     }
611*cdf0e10cSrcweir 
612*cdf0e10cSrcweir     Application::RemoveEventListener( LINK( this, SlideshowImpl, EventListenerHdl ) );
613*cdf0e10cSrcweir 
614*cdf0e10cSrcweir     maDeactivateTimer.Stop();
615*cdf0e10cSrcweir 
616*cdf0e10cSrcweir     if( !mbDisposed )
617*cdf0e10cSrcweir     {
618*cdf0e10cSrcweir         DBG_ERROR("SlideshowImpl::~SlideshowImpl(), component was not disposed!");
619*cdf0e10cSrcweir         disposing();
620*cdf0e10cSrcweir     }
621*cdf0e10cSrcweir }
622*cdf0e10cSrcweir 
623*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::disposing()
624*cdf0e10cSrcweir {
625*cdf0e10cSrcweir     if( mxShow.is() && mpDoc )
626*cdf0e10cSrcweir         NotifyDocumentEvent( mpDoc, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OnEndPresentation") ) );
627*cdf0e10cSrcweir 
628*cdf0e10cSrcweir     if( mbAutoSaveWasOn )
629*cdf0e10cSrcweir         setAutoSaveState( true );
630*cdf0e10cSrcweir 
631*cdf0e10cSrcweir     if( mnEndShowEvent )
632*cdf0e10cSrcweir         Application::RemoveUserEvent( mnEndShowEvent );
633*cdf0e10cSrcweir     if( mnContextMenuEvent )
634*cdf0e10cSrcweir         Application::RemoveUserEvent( mnContextMenuEvent );
635*cdf0e10cSrcweir 
636*cdf0e10cSrcweir     maInputFreezeTimer.Stop();
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
639*cdf0e10cSrcweir 
640*cdf0e10cSrcweir     if( !mxShow.is() )
641*cdf0e10cSrcweir         return;
642*cdf0e10cSrcweir 
643*cdf0e10cSrcweir     if( mxPresentation.is() )
644*cdf0e10cSrcweir         mxPresentation->end();
645*cdf0e10cSrcweir 
646*cdf0e10cSrcweir     maUpdateTimer.Stop();
647*cdf0e10cSrcweir 
648*cdf0e10cSrcweir     if( mnUpdateEvent )
649*cdf0e10cSrcweir     {
650*cdf0e10cSrcweir         Application::RemoveUserEvent( mnUpdateEvent );
651*cdf0e10cSrcweir         mnUpdateEvent = 0;
652*cdf0e10cSrcweir     }
653*cdf0e10cSrcweir 
654*cdf0e10cSrcweir     removeShapeEvents();
655*cdf0e10cSrcweir 
656*cdf0e10cSrcweir     if( mxListenerProxy.is() )
657*cdf0e10cSrcweir         mxListenerProxy->removeAsSlideShowListener();
658*cdf0e10cSrcweir 
659*cdf0e10cSrcweir     try
660*cdf0e10cSrcweir     {
661*cdf0e10cSrcweir         if( mxView.is() )
662*cdf0e10cSrcweir             mxShow->removeView( mxView.getRef() );
663*cdf0e10cSrcweir 
664*cdf0e10cSrcweir         Reference< XComponent > xComponent( mxShow, UNO_QUERY );
665*cdf0e10cSrcweir         if( xComponent.is() )
666*cdf0e10cSrcweir             xComponent->dispose();
667*cdf0e10cSrcweir 
668*cdf0e10cSrcweir         if( mxView.is() )
669*cdf0e10cSrcweir             mxView->dispose();
670*cdf0e10cSrcweir     }
671*cdf0e10cSrcweir     catch( Exception& e )
672*cdf0e10cSrcweir     {
673*cdf0e10cSrcweir         static_cast<void>(e);
674*cdf0e10cSrcweir         DBG_ERROR(
675*cdf0e10cSrcweir             (OString("sd::SlideshowImpl::stop(), "
676*cdf0e10cSrcweir                     "exception caught: ") +
677*cdf0e10cSrcweir             rtl::OUStringToOString(
678*cdf0e10cSrcweir                 comphelper::anyToString( cppu::getCaughtException() ),
679*cdf0e10cSrcweir                 RTL_TEXTENCODING_UTF8 )).getStr() );
680*cdf0e10cSrcweir 
681*cdf0e10cSrcweir     }
682*cdf0e10cSrcweir 
683*cdf0e10cSrcweir     mxShow.clear();
684*cdf0e10cSrcweir     mxView.reset();
685*cdf0e10cSrcweir     mxListenerProxy.clear();
686*cdf0e10cSrcweir     mpSlideController.reset();
687*cdf0e10cSrcweir 
688*cdf0e10cSrcweir     // der DrawView das Praesentationfenster wegnehmen und ihr dafuer ihre alten Fenster wiedergeben
689*cdf0e10cSrcweir     if( mpShowWindow && mpView )
690*cdf0e10cSrcweir         mpView->DeleteWindowFromPaintView( mpShowWindow );
691*cdf0e10cSrcweir 
692*cdf0e10cSrcweir     if( mpView )
693*cdf0e10cSrcweir         mpView->SetAnimationPause( sal_False );
694*cdf0e10cSrcweir 
695*cdf0e10cSrcweir     if( mpViewShell )
696*cdf0e10cSrcweir     {
697*cdf0e10cSrcweir         mpViewShell->SetActiveWindow(mpOldActiveWindow);
698*cdf0e10cSrcweir         mpShowWindow->SetViewShell( NULL );
699*cdf0e10cSrcweir     }
700*cdf0e10cSrcweir 
701*cdf0e10cSrcweir     if( mpView )
702*cdf0e10cSrcweir         mpView->InvalidateAllWin();
703*cdf0e10cSrcweir 
704*cdf0e10cSrcweir     if( maPresSettings.mbFullScreen )
705*cdf0e10cSrcweir     {
706*cdf0e10cSrcweir         // restore StarBASICErrorHdl
707*cdf0e10cSrcweir         StarBASIC::SetGlobalErrorHdl(maStarBASICGlobalErrorHdl);
708*cdf0e10cSrcweir         maStarBASICGlobalErrorHdl = Link();
709*cdf0e10cSrcweir     }
710*cdf0e10cSrcweir     else
711*cdf0e10cSrcweir     {
712*cdf0e10cSrcweir         if( mpShowWindow )
713*cdf0e10cSrcweir             mpShowWindow->Hide();
714*cdf0e10cSrcweir     }
715*cdf0e10cSrcweir 
716*cdf0e10cSrcweir     if( meAnimationMode == ANIMATIONMODE_SHOW )
717*cdf0e10cSrcweir     {
718*cdf0e10cSrcweir         mpDocSh->SetSlotFilter();
719*cdf0e10cSrcweir         mpDocSh->ApplySlotFilter();
720*cdf0e10cSrcweir 
721*cdf0e10cSrcweir         Help::EnableContextHelp();
722*cdf0e10cSrcweir         Help::EnableExtHelp();
723*cdf0e10cSrcweir 
724*cdf0e10cSrcweir         showChildWindows();
725*cdf0e10cSrcweir         mnChildMask = 0UL;
726*cdf0e10cSrcweir     }
727*cdf0e10cSrcweir 
728*cdf0e10cSrcweir     // aktuelle Fenster wieder einblenden
729*cdf0e10cSrcweir     if( mpViewShell && !mpViewShell->ISA(PresentationViewShell))
730*cdf0e10cSrcweir     {
731*cdf0e10cSrcweir         if( meAnimationMode == ANIMATIONMODE_SHOW )
732*cdf0e10cSrcweir         {
733*cdf0e10cSrcweir             mpViewShell->GetViewShellBase().ShowUIControls (true);
734*cdf0e10cSrcweir             mpPaneHider.reset();
735*cdf0e10cSrcweir         }
736*cdf0e10cSrcweir         else if( meAnimationMode == ANIMATIONMODE_PREVIEW )
737*cdf0e10cSrcweir         {
738*cdf0e10cSrcweir             mpViewShell->ShowUIControls (true);
739*cdf0e10cSrcweir         }
740*cdf0e10cSrcweir     }
741*cdf0e10cSrcweir 
742*cdf0e10cSrcweir     if( mpTimeButton )
743*cdf0e10cSrcweir     {
744*cdf0e10cSrcweir         mpTimeButton->Hide();
745*cdf0e10cSrcweir         delete mpTimeButton;
746*cdf0e10cSrcweir         mpTimeButton = 0;
747*cdf0e10cSrcweir     }
748*cdf0e10cSrcweir 
749*cdf0e10cSrcweir     if( mpShowWindow )
750*cdf0e10cSrcweir         mpShowWindow->Hide();
751*cdf0e10cSrcweir 
752*cdf0e10cSrcweir     if ( mpViewShell )
753*cdf0e10cSrcweir     {
754*cdf0e10cSrcweir         if( meAnimationMode == ANIMATIONMODE_SHOW )
755*cdf0e10cSrcweir         {
756*cdf0e10cSrcweir             ::sd::Window* pActWin = mpViewShell->GetActiveWindow();
757*cdf0e10cSrcweir 
758*cdf0e10cSrcweir             if (pActWin)
759*cdf0e10cSrcweir             {
760*cdf0e10cSrcweir                 Size aVisSizePixel = pActWin->GetOutputSizePixel();
761*cdf0e10cSrcweir                 Rectangle aVisAreaWin = pActWin->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
762*cdf0e10cSrcweir                 mpViewShell->VisAreaChanged(aVisAreaWin);
763*cdf0e10cSrcweir                 mpView->VisAreaChanged(pActWin);
764*cdf0e10cSrcweir                 pActWin->GrabFocus();
765*cdf0e10cSrcweir             }
766*cdf0e10cSrcweir         }
767*cdf0e10cSrcweir 
768*cdf0e10cSrcweir         // restart the custom show dialog if he started us
769*cdf0e10cSrcweir         if( mpViewShell->IsStartShowWithDialog() && getDispatcher() )
770*cdf0e10cSrcweir         {
771*cdf0e10cSrcweir             mpViewShell->SetStartShowWithDialog( sal_False );
772*cdf0e10cSrcweir             getDispatcher()->Execute( SID_CUSTOMSHOW_DLG, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
773*cdf0e10cSrcweir         }
774*cdf0e10cSrcweir 
775*cdf0e10cSrcweir         mpViewShell->GetViewShellBase().UpdateBorder(true);
776*cdf0e10cSrcweir     }
777*cdf0e10cSrcweir 
778*cdf0e10cSrcweir     if( mpShowWindow )
779*cdf0e10cSrcweir     {
780*cdf0e10cSrcweir         delete mpShowWindow;
781*cdf0e10cSrcweir         mpShowWindow = 0;
782*cdf0e10cSrcweir     }
783*cdf0e10cSrcweir 
784*cdf0e10cSrcweir     setActiveXToolbarsVisible( sal_True );
785*cdf0e10cSrcweir 
786*cdf0e10cSrcweir     Application::EnableNoYieldMode(false);
787*cdf0e10cSrcweir     Application::RemovePostYieldListener(LINK(this, SlideshowImpl, PostYieldListener));
788*cdf0e10cSrcweir 
789*cdf0e10cSrcweir     mbDisposed = true;
790*cdf0e10cSrcweir }
791*cdf0e10cSrcweir 
792*cdf0e10cSrcweir bool SlideshowImpl::startPreview(
793*cdf0e10cSrcweir         const Reference< XDrawPage >& xDrawPage,
794*cdf0e10cSrcweir         const Reference< XAnimationNode >& xAnimationNode,
795*cdf0e10cSrcweir         ::Window* pParent )
796*cdf0e10cSrcweir {
797*cdf0e10cSrcweir     bool bRet = false;
798*cdf0e10cSrcweir 
799*cdf0e10cSrcweir     try
800*cdf0e10cSrcweir     {
801*cdf0e10cSrcweir         const Reference<lang::XServiceInfo> xServiceInfo( xDrawPage, UNO_QUERY );
802*cdf0e10cSrcweir         if (xServiceInfo.is()) {
803*cdf0e10cSrcweir             const Sequence<OUString> supportedServices(
804*cdf0e10cSrcweir                 xServiceInfo->getSupportedServiceNames() );
805*cdf0e10cSrcweir             for ( sal_Int32 pos = supportedServices.getLength(); pos--; ) {
806*cdf0e10cSrcweir                 if (supportedServices[pos].equalsAsciiL(
807*cdf0e10cSrcweir                         RTL_CONSTASCII_STRINGPARAM(
808*cdf0e10cSrcweir                             "com.sun.star.drawing.MasterPage") )) {
809*cdf0e10cSrcweir                     DBG_ERROR("sd::SlideshowImpl::startPreview() "
810*cdf0e10cSrcweir                               "not allowed on master page!");
811*cdf0e10cSrcweir                     return false;
812*cdf0e10cSrcweir                 }
813*cdf0e10cSrcweir             }
814*cdf0e10cSrcweir         }
815*cdf0e10cSrcweir 
816*cdf0e10cSrcweir         mxPreviewDrawPage = xDrawPage;
817*cdf0e10cSrcweir         mxPreviewAnimationNode = xAnimationNode;
818*cdf0e10cSrcweir         meAnimationMode = ANIMATIONMODE_PREVIEW;
819*cdf0e10cSrcweir 
820*cdf0e10cSrcweir         maPresSettings.mbAll = sal_False;
821*cdf0e10cSrcweir         maPresSettings.mbEndless = sal_False;
822*cdf0e10cSrcweir         maPresSettings.mbCustomShow = sal_False;
823*cdf0e10cSrcweir         maPresSettings.mbManual = sal_False;
824*cdf0e10cSrcweir         maPresSettings.mbMouseVisible = sal_False;
825*cdf0e10cSrcweir         maPresSettings.mbMouseAsPen = sal_False;
826*cdf0e10cSrcweir         maPresSettings.mbLockedPages = sal_False;
827*cdf0e10cSrcweir         maPresSettings.mbAlwaysOnTop = sal_False;
828*cdf0e10cSrcweir         maPresSettings.mbFullScreen = sal_False;
829*cdf0e10cSrcweir         maPresSettings.mbAnimationAllowed = sal_True;
830*cdf0e10cSrcweir         maPresSettings.mnPauseTimeout = 0;
831*cdf0e10cSrcweir         maPresSettings.mbShowPauseLogo = sal_False;
832*cdf0e10cSrcweir         maPresSettings.mbStartWithNavigator = sal_False;
833*cdf0e10cSrcweir 
834*cdf0e10cSrcweir         Reference< XDrawPagesSupplier > xDrawPages( mpDoc->getUnoModel(), UNO_QUERY_THROW );
835*cdf0e10cSrcweir         Reference< XIndexAccess > xSlides( xDrawPages->getDrawPages(), UNO_QUERY_THROW );
836*cdf0e10cSrcweir         mpSlideController.reset( new AnimationSlideController( xSlides, AnimationSlideController::PREVIEW ) );
837*cdf0e10cSrcweir 
838*cdf0e10cSrcweir         sal_Int32 nSlideNumber = 0;
839*cdf0e10cSrcweir         Reference< XPropertySet > xSet( mxPreviewDrawPage, UNO_QUERY_THROW );
840*cdf0e10cSrcweir         xSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Number" ) ) ) >>= nSlideNumber;
841*cdf0e10cSrcweir         mpSlideController->insertSlideNumber( nSlideNumber-1 );
842*cdf0e10cSrcweir         mpSlideController->setPreviewNode( xAnimationNode );
843*cdf0e10cSrcweir 
844*cdf0e10cSrcweir         mpShowWindow = new ShowWindow( this, ((pParent == 0) && mpViewShell) ?  mpParentWindow : pParent );
845*cdf0e10cSrcweir         if( mpViewShell )
846*cdf0e10cSrcweir         {
847*cdf0e10cSrcweir             mpViewShell->SetActiveWindow( mpShowWindow );
848*cdf0e10cSrcweir             mpShowWindow->SetViewShell (mpViewShell);
849*cdf0e10cSrcweir             mpViewShell->ShowUIControls (false);
850*cdf0e10cSrcweir         }
851*cdf0e10cSrcweir 
852*cdf0e10cSrcweir         if( mpView )
853*cdf0e10cSrcweir         {
854*cdf0e10cSrcweir             mpView->AddWindowToPaintView( mpShowWindow );
855*cdf0e10cSrcweir             mpView->SetAnimationPause( sal_True );
856*cdf0e10cSrcweir         }
857*cdf0e10cSrcweir 
858*cdf0e10cSrcweir         // call resize handler
859*cdf0e10cSrcweir         if( pParent )
860*cdf0e10cSrcweir         {
861*cdf0e10cSrcweir             maPresSize = pParent->GetSizePixel();
862*cdf0e10cSrcweir         }
863*cdf0e10cSrcweir         else if( mpViewShell )
864*cdf0e10cSrcweir         {
865*cdf0e10cSrcweir             Rectangle aContentRect (mpViewShell->GetViewShellBase().getClientRectangle());
866*cdf0e10cSrcweir             if (Application::GetSettings().GetLayoutRTL())
867*cdf0e10cSrcweir             {
868*cdf0e10cSrcweir                 aContentRect.nLeft = aContentRect.nRight;
869*cdf0e10cSrcweir                 aContentRect.nRight += aContentRect.nRight;
870*cdf0e10cSrcweir             }
871*cdf0e10cSrcweir             maPresSize = aContentRect.GetSize();
872*cdf0e10cSrcweir             mpShowWindow->SetPosPixel( aContentRect.TopLeft() );
873*cdf0e10cSrcweir         }
874*cdf0e10cSrcweir         else
875*cdf0e10cSrcweir         {
876*cdf0e10cSrcweir             DBG_ERROR("sd::SlideshowImpl::startPreview(), I need either a parent window or a viewshell!");
877*cdf0e10cSrcweir         }
878*cdf0e10cSrcweir         resize( maPresSize );
879*cdf0e10cSrcweir 
880*cdf0e10cSrcweir         sal_Int32 nPropertyCount = 1;
881*cdf0e10cSrcweir         if( mxPreviewAnimationNode.is() )
882*cdf0e10cSrcweir             nPropertyCount++;
883*cdf0e10cSrcweir 
884*cdf0e10cSrcweir         Sequence< beans::PropertyValue > aProperties(nPropertyCount);
885*cdf0e10cSrcweir         aProperties[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("AutomaticAdvancement") );
886*cdf0e10cSrcweir         aProperties[0].Value = uno::makeAny( (double)1.0 ); // one second timeout
887*cdf0e10cSrcweir 
888*cdf0e10cSrcweir         if( mxPreviewAnimationNode.is() )
889*cdf0e10cSrcweir         {
890*cdf0e10cSrcweir             aProperties[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("NoSlideTransitions") );
891*cdf0e10cSrcweir             aProperties[1].Value = uno::makeAny( sal_True );
892*cdf0e10cSrcweir         }
893*cdf0e10cSrcweir 
894*cdf0e10cSrcweir         bRet = startShowImpl( aProperties );
895*cdf0e10cSrcweir 
896*cdf0e10cSrcweir         if( mpShowWindow != 0 && meAnimationMode == ANIMATIONMODE_PREVIEW )
897*cdf0e10cSrcweir             mpShowWindow->SetPreviewMode();
898*cdf0e10cSrcweir 
899*cdf0e10cSrcweir     }
900*cdf0e10cSrcweir     catch( Exception& e )
901*cdf0e10cSrcweir     {
902*cdf0e10cSrcweir         (void)e;
903*cdf0e10cSrcweir         DBG_ERROR(
904*cdf0e10cSrcweir             (OString("sd::SlideshowImpl::startPreview(), "
905*cdf0e10cSrcweir                      "exception caught: ") +
906*cdf0e10cSrcweir              rtl::OUStringToOString(
907*cdf0e10cSrcweir                  comphelper::anyToString( cppu::getCaughtException() ),
908*cdf0e10cSrcweir                  RTL_TEXTENCODING_UTF8 )).getStr() );
909*cdf0e10cSrcweir         bRet = false;
910*cdf0e10cSrcweir     }
911*cdf0e10cSrcweir 
912*cdf0e10cSrcweir     return bRet;
913*cdf0e10cSrcweir }
914*cdf0e10cSrcweir 
915*cdf0e10cSrcweir bool SlideshowImpl::startShow( PresentationSettingsEx* pPresSettings )
916*cdf0e10cSrcweir {
917*cdf0e10cSrcweir     const rtl::Reference<SlideshowImpl> this_(this);
918*cdf0e10cSrcweir 
919*cdf0e10cSrcweir     DBG_ASSERT( !mxShow.is(), "sd::SlideshowImpl::startShow(), called twice!" );
920*cdf0e10cSrcweir     if( mxShow.is() )
921*cdf0e10cSrcweir         return true;
922*cdf0e10cSrcweir     DBG_ASSERT( mpParentWindow!=NULL, "sd::SlideshowImpl::startShow() called without parent window" );
923*cdf0e10cSrcweir     if (mpParentWindow == NULL)
924*cdf0e10cSrcweir         return false;
925*cdf0e10cSrcweir 
926*cdf0e10cSrcweir     bool bRet = false;
927*cdf0e10cSrcweir 
928*cdf0e10cSrcweir     try
929*cdf0e10cSrcweir     {
930*cdf0e10cSrcweir         if( pPresSettings )
931*cdf0e10cSrcweir         {
932*cdf0e10cSrcweir             maPresSettings = *pPresSettings;
933*cdf0e10cSrcweir             mbRehearseTimings = pPresSettings->mbRehearseTimings;
934*cdf0e10cSrcweir         }
935*cdf0e10cSrcweir 
936*cdf0e10cSrcweir         // ---
937*cdf0e10cSrcweir 
938*cdf0e10cSrcweir         String  aPresSlide( maPresSettings.maPresPage );
939*cdf0e10cSrcweir         SdPage* pStartPage = mpViewShell ? mpViewShell->GetActualPage() : 0;
940*cdf0e10cSrcweir         bool    bStartWithActualSlide =  pStartPage &&
941*cdf0e10cSrcweir                                         ( (meAnimationMode != ANIMATIONMODE_SHOW) ||
942*cdf0e10cSrcweir                                            SD_MOD()->GetSdOptions( mpDoc->GetDocumentType() )->IsStartWithActualPage() );
943*cdf0e10cSrcweir 
944*cdf0e10cSrcweir         // sollen Zeiten gestoppt werden?
945*cdf0e10cSrcweir         if( mbRehearseTimings )
946*cdf0e10cSrcweir         {
947*cdf0e10cSrcweir             maPresSettings.mbEndless = sal_False;
948*cdf0e10cSrcweir             maPresSettings.mbManual = sal_True;
949*cdf0e10cSrcweir             maPresSettings.mbMouseVisible = sal_True;
950*cdf0e10cSrcweir             maPresSettings.mbMouseAsPen = sal_False;
951*cdf0e10cSrcweir             maPresSettings.mnPauseTimeout = 0;
952*cdf0e10cSrcweir             maPresSettings.mbShowPauseLogo = sal_False;
953*cdf0e10cSrcweir             maPresSettings.mbStartWithNavigator = sal_False;
954*cdf0e10cSrcweir         }
955*cdf0e10cSrcweir 
956*cdf0e10cSrcweir         if( pStartPage )
957*cdf0e10cSrcweir         {
958*cdf0e10cSrcweir             if( pStartPage->GetPageKind() == PK_NOTES )
959*cdf0e10cSrcweir             {
960*cdf0e10cSrcweir                 // we are in notes page mode, so get
961*cdf0e10cSrcweir                 // the corresponding draw page
962*cdf0e10cSrcweir                 const sal_uInt16 nPgNum = ( pStartPage->GetPageNum() - 2 ) >> 1;
963*cdf0e10cSrcweir                 pStartPage = mpDoc->GetSdPage( nPgNum, PK_STANDARD );
964*cdf0e10cSrcweir             }
965*cdf0e10cSrcweir         }
966*cdf0e10cSrcweir 
967*cdf0e10cSrcweir         if( bStartWithActualSlide )
968*cdf0e10cSrcweir         {
969*cdf0e10cSrcweir             if( meAnimationMode != ANIMATIONMODE_SHOW )
970*cdf0e10cSrcweir             {
971*cdf0e10cSrcweir                 if( pStartPage->GetPageKind() == PK_STANDARD )
972*cdf0e10cSrcweir                 {
973*cdf0e10cSrcweir                     aPresSlide = pStartPage->GetName();
974*cdf0e10cSrcweir                     maPresSettings.mbAll = false;
975*cdf0e10cSrcweir                 }
976*cdf0e10cSrcweir                 else
977*cdf0e10cSrcweir                 {
978*cdf0e10cSrcweir                     bStartWithActualSlide = false;
979*cdf0e10cSrcweir                 }
980*cdf0e10cSrcweir             }
981*cdf0e10cSrcweir         }
982*cdf0e10cSrcweir         else
983*cdf0e10cSrcweir         {
984*cdf0e10cSrcweir             if( pStartPage->GetPageKind() != PK_STANDARD )
985*cdf0e10cSrcweir             {
986*cdf0e10cSrcweir                 bStartWithActualSlide = false;
987*cdf0e10cSrcweir             }
988*cdf0e10cSrcweir         }
989*cdf0e10cSrcweir 
990*cdf0e10cSrcweir         // build page list
991*cdf0e10cSrcweir         createSlideList( maPresSettings.mbAll, false, aPresSlide );
992*cdf0e10cSrcweir 
993*cdf0e10cSrcweir         if( bStartWithActualSlide )
994*cdf0e10cSrcweir         {
995*cdf0e10cSrcweir             sal_Int32 nSlideNum = ( pStartPage->GetPageNum() - 1 ) >> 1;
996*cdf0e10cSrcweir 
997*cdf0e10cSrcweir             if( !maPresSettings.mbAll && !maPresSettings.mbCustomShow )
998*cdf0e10cSrcweir             {
999*cdf0e10cSrcweir                 // its start from dia, find out if it is located before our current Slide
1000*cdf0e10cSrcweir                 const sal_Int32 nSlideCount = mpDoc->GetSdPageCount( PK_STANDARD );
1001*cdf0e10cSrcweir                 sal_Int32 nSlide;
1002*cdf0e10cSrcweir                 for( nSlide = 0; (nSlide < nSlideCount); nSlide++ )
1003*cdf0e10cSrcweir                 {
1004*cdf0e10cSrcweir                     if( mpDoc->GetSdPage( (sal_uInt16) nSlide, PK_STANDARD )->GetName() == aPresSlide )
1005*cdf0e10cSrcweir                         break;
1006*cdf0e10cSrcweir                 }
1007*cdf0e10cSrcweir 
1008*cdf0e10cSrcweir                 if( nSlide > nSlideNum )
1009*cdf0e10cSrcweir                     nSlideNum = -1;
1010*cdf0e10cSrcweir             }
1011*cdf0e10cSrcweir 
1012*cdf0e10cSrcweir             if( nSlideNum != -1 )
1013*cdf0e10cSrcweir                 mpSlideController->setStartSlideNumber( nSlideNum );
1014*cdf0e10cSrcweir         }
1015*cdf0e10cSrcweir 
1016*cdf0e10cSrcweir         // remember Slide number from where the show was started
1017*cdf0e10cSrcweir         if( pStartPage )
1018*cdf0e10cSrcweir             mnRestoreSlide = ( pStartPage->GetPageNum() - 1 ) / 2;
1019*cdf0e10cSrcweir 
1020*cdf0e10cSrcweir         if( mpSlideController->hasSlides() )
1021*cdf0e10cSrcweir         {
1022*cdf0e10cSrcweir             // hide child windows
1023*cdf0e10cSrcweir             hideChildWindows();
1024*cdf0e10cSrcweir 
1025*cdf0e10cSrcweir             mpShowWindow = new ShowWindow( this, mpParentWindow );
1026*cdf0e10cSrcweir             mpShowWindow->SetMouseAutoHide( !maPresSettings.mbMouseVisible );
1027*cdf0e10cSrcweir             if( mpViewShell )
1028*cdf0e10cSrcweir             {
1029*cdf0e10cSrcweir                 mpViewShell->SetActiveWindow( mpShowWindow );
1030*cdf0e10cSrcweir                 mpShowWindow->SetViewShell (mpViewShell);
1031*cdf0e10cSrcweir                 mpViewShell->GetViewShellBase().ShowUIControls (false);
1032*cdf0e10cSrcweir                 // Hide the side panes for in-place presentations.
1033*cdf0e10cSrcweir                 if ( ! maPresSettings.mbFullScreen)
1034*cdf0e10cSrcweir                     mpPaneHider.reset(new PaneHider(*mpViewShell,this));
1035*cdf0e10cSrcweir 
1036*cdf0e10cSrcweir                 if( getViewFrame() )
1037*cdf0e10cSrcweir                     getViewFrame()->SetChildWindow( SID_NAVIGATOR, maPresSettings.mbStartWithNavigator );
1038*cdf0e10cSrcweir             }
1039*cdf0e10cSrcweir 
1040*cdf0e10cSrcweir             // these Slots are forbiden in other views for this document
1041*cdf0e10cSrcweir             if( mpDocSh )
1042*cdf0e10cSrcweir             {
1043*cdf0e10cSrcweir                 mpDocSh->SetSlotFilter( sal_True, sizeof( pAllowed ) / sizeof( sal_uInt16 ), pAllowed );
1044*cdf0e10cSrcweir                 mpDocSh->ApplySlotFilter();
1045*cdf0e10cSrcweir             }
1046*cdf0e10cSrcweir 
1047*cdf0e10cSrcweir             Help::DisableContextHelp();
1048*cdf0e10cSrcweir             Help::DisableExtHelp();
1049*cdf0e10cSrcweir 
1050*cdf0e10cSrcweir         //  mpTimeButton = new PushButton( mpShowWindow, SdResId( RID_TIME_BUTTON ) );
1051*cdf0e10cSrcweir         //  maPencil = Pointer( POINTER_PEN );
1052*cdf0e10cSrcweir         //  mpTimeButton->Hide();
1053*cdf0e10cSrcweir 
1054*cdf0e10cSrcweir             if( maPresSettings.mbFullScreen )
1055*cdf0e10cSrcweir             {
1056*cdf0e10cSrcweir                 // disable basic ide error handling
1057*cdf0e10cSrcweir                 maStarBASICGlobalErrorHdl = StarBASIC::GetGlobalErrorHdl();
1058*cdf0e10cSrcweir                 StarBASIC::SetGlobalErrorHdl( Link() );
1059*cdf0e10cSrcweir             }
1060*cdf0e10cSrcweir 
1061*cdf0e10cSrcweir             // call resize handler
1062*cdf0e10cSrcweir             maPresSize = mpParentWindow->GetSizePixel();
1063*cdf0e10cSrcweir             if( !maPresSettings.mbFullScreen && mpViewShell )
1064*cdf0e10cSrcweir             {
1065*cdf0e10cSrcweir                 const Rectangle& aClientRect = mpViewShell->GetViewShellBase().getClientRectangle();
1066*cdf0e10cSrcweir                 maPresSize = aClientRect.GetSize();
1067*cdf0e10cSrcweir                 mpShowWindow->SetPosPixel( aClientRect.TopLeft() );
1068*cdf0e10cSrcweir                 resize( maPresSize );
1069*cdf0e10cSrcweir             }
1070*cdf0e10cSrcweir 
1071*cdf0e10cSrcweir             // #i41824#
1072*cdf0e10cSrcweir             // Note: In FullScreen Mode the OS (window manager) sends a resize to
1073*cdf0e10cSrcweir             // the WorkWindow once it actually resized it to full size.  The
1074*cdf0e10cSrcweir             // WorkWindow propagates the resize to the DrawViewShell which calls
1075*cdf0e10cSrcweir             // resize() at the SlideShow (this).  Calling resize here results in a
1076*cdf0e10cSrcweir             // temporary display of a black window in the window's default size
1077*cdf0e10cSrcweir 
1078*cdf0e10cSrcweir /*
1079*cdf0e10cSrcweir             if ( mbRehearseTimings )
1080*cdf0e10cSrcweir             {
1081*cdf0e10cSrcweir                 Size  aButtonSizePixel( pTimeButton->GetSizePixel() );
1082*cdf0e10cSrcweir                 Point aButtonPosPixel( aButtonSizePixel.Width() >> 1, pShowWindow->GetSizePixel().Height() - aButtonSizePixel.Height() * 5 / 2);
1083*cdf0e10cSrcweir 
1084*cdf0e10cSrcweir                 pTimeButton->SetPosPixel( aButtonPosPixel );
1085*cdf0e10cSrcweir                 aTimer.SetTimeoutHdl( LINK( this,FuSlideShow, TimeButtonTimeOutHdl ) );
1086*cdf0e10cSrcweir                 pTimeButton->SetClickHdl( LINK( this, FuSlideShow, TimeButtonHdl ) );
1087*cdf0e10cSrcweir             }
1088*cdf0e10cSrcweir */
1089*cdf0e10cSrcweir 
1090*cdf0e10cSrcweir             if( mpView )
1091*cdf0e10cSrcweir             {
1092*cdf0e10cSrcweir                 mpView->AddWindowToPaintView( mpShowWindow );
1093*cdf0e10cSrcweir                 mpView->SetAnimationPause( sal_True );
1094*cdf0e10cSrcweir             }
1095*cdf0e10cSrcweir 
1096*cdf0e10cSrcweir             SfxBindings* pBindings = getBindings();
1097*cdf0e10cSrcweir             if( pBindings )
1098*cdf0e10cSrcweir             {
1099*cdf0e10cSrcweir                 pBindings->Invalidate( SID_PRESENTATION );
1100*cdf0e10cSrcweir                 pBindings->Invalidate( SID_REHEARSE_TIMINGS );
1101*cdf0e10cSrcweir             }
1102*cdf0e10cSrcweir 
1103*cdf0e10cSrcweir             mpShowWindow->GrabFocus();
1104*cdf0e10cSrcweir 
1105*cdf0e10cSrcweir             std::vector<beans::PropertyValue> aProperties;
1106*cdf0e10cSrcweir             aProperties.reserve( 4 );
1107*cdf0e10cSrcweir 
1108*cdf0e10cSrcweir             aProperties.push_back(
1109*cdf0e10cSrcweir                 beans::PropertyValue(
1110*cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM("AdvanceOnClick") ),
1111*cdf0e10cSrcweir                     -1, Any( ! (maPresSettings.mbLockedPages != sal_False) ),
1112*cdf0e10cSrcweir                     beans::PropertyState_DIRECT_VALUE ) );
1113*cdf0e10cSrcweir 
1114*cdf0e10cSrcweir             aProperties.push_back(
1115*cdf0e10cSrcweir                 beans::PropertyValue(
1116*cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM("ImageAnimationsAllowed") ),
1117*cdf0e10cSrcweir                     -1, Any( maPresSettings.mbAnimationAllowed != sal_False ),
1118*cdf0e10cSrcweir                     beans::PropertyState_DIRECT_VALUE ) );
1119*cdf0e10cSrcweir 
1120*cdf0e10cSrcweir             const sal_Bool bZOrderEnabled(
1121*cdf0e10cSrcweir                 SD_MOD()->GetSdOptions( mpDoc->GetDocumentType() )->IsSlideshowRespectZOrder() );
1122*cdf0e10cSrcweir             aProperties.push_back(
1123*cdf0e10cSrcweir                 beans::PropertyValue(
1124*cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM("DisableAnimationZOrder") ),
1125*cdf0e10cSrcweir                     -1, Any( bZOrderEnabled == sal_False ),
1126*cdf0e10cSrcweir                     beans::PropertyState_DIRECT_VALUE ) );
1127*cdf0e10cSrcweir 
1128*cdf0e10cSrcweir /*
1129*cdf0e10cSrcweir             aProperties.push_back(
1130*cdf0e10cSrcweir                 beans::PropertyValue(
1131*cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM("MouseVisible") ),
1132*cdf0e10cSrcweir                     -1, Any( maPresSettings.mbMouseVisible != sal_False ),
1133*cdf0e10cSrcweir                     beans::PropertyState_DIRECT_VALUE ) );
1134*cdf0e10cSrcweir */
1135*cdf0e10cSrcweir             aProperties.push_back(
1136*cdf0e10cSrcweir                 beans::PropertyValue(
1137*cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM("ForceManualAdvance") ),
1138*cdf0e10cSrcweir                     -1, Any( maPresSettings.mbManual != sal_False ),
1139*cdf0e10cSrcweir                     beans::PropertyState_DIRECT_VALUE ) );
1140*cdf0e10cSrcweir 
1141*cdf0e10cSrcweir             if( mbUsePen )
1142*cdf0e10cSrcweir             {
1143*cdf0e10cSrcweir                 aProperties.push_back(
1144*cdf0e10cSrcweir                     beans::PropertyValue(
1145*cdf0e10cSrcweir                         OUString( RTL_CONSTASCII_USTRINGPARAM("UserPaintColor") ),
1146*cdf0e10cSrcweir                         // User paint color is black by default.
1147*cdf0e10cSrcweir                         -1, Any( mnUserPaintColor ),
1148*cdf0e10cSrcweir                         beans::PropertyState_DIRECT_VALUE ) );
1149*cdf0e10cSrcweir 
1150*cdf0e10cSrcweir                 aProperties.push_back(
1151*cdf0e10cSrcweir                     beans::PropertyValue(
1152*cdf0e10cSrcweir                         OUString( RTL_CONSTASCII_USTRINGPARAM("UserPaintStrokeWidth") ),
1153*cdf0e10cSrcweir                         // User paint color is black by default.
1154*cdf0e10cSrcweir                         -1, Any( mdUserPaintStrokeWidth ),
1155*cdf0e10cSrcweir                         beans::PropertyState_DIRECT_VALUE ) );
1156*cdf0e10cSrcweir             }
1157*cdf0e10cSrcweir 
1158*cdf0e10cSrcweir             if (mbRehearseTimings) {
1159*cdf0e10cSrcweir                 aProperties.push_back(
1160*cdf0e10cSrcweir                     beans::PropertyValue(
1161*cdf0e10cSrcweir                         OUString( RTL_CONSTASCII_USTRINGPARAM("RehearseTimings") ),
1162*cdf0e10cSrcweir                         -1, Any(true), beans::PropertyState_DIRECT_VALUE ) );
1163*cdf0e10cSrcweir             }
1164*cdf0e10cSrcweir 
1165*cdf0e10cSrcweir             bRet = startShowImpl( Sequence<beans::PropertyValue>(
1166*cdf0e10cSrcweir                                       &aProperties[0], aProperties.size() ) );
1167*cdf0e10cSrcweir 
1168*cdf0e10cSrcweir         }
1169*cdf0e10cSrcweir 
1170*cdf0e10cSrcweir         setActiveXToolbarsVisible( sal_False );
1171*cdf0e10cSrcweir     }
1172*cdf0e10cSrcweir     catch( Exception& e )
1173*cdf0e10cSrcweir     {
1174*cdf0e10cSrcweir         (void)e;
1175*cdf0e10cSrcweir         DBG_ERROR(
1176*cdf0e10cSrcweir             (OString("sd::SlideshowImpl::startShow(), "
1177*cdf0e10cSrcweir                      "exception caught: ") +
1178*cdf0e10cSrcweir              rtl::OUStringToOString(
1179*cdf0e10cSrcweir                  comphelper::anyToString( cppu::getCaughtException() ),
1180*cdf0e10cSrcweir                  RTL_TEXTENCODING_UTF8 )).getStr() );
1181*cdf0e10cSrcweir         bRet = false;
1182*cdf0e10cSrcweir     }
1183*cdf0e10cSrcweir 
1184*cdf0e10cSrcweir     return bRet;
1185*cdf0e10cSrcweir }
1186*cdf0e10cSrcweir 
1187*cdf0e10cSrcweir bool SlideshowImpl::startShowImpl( const Sequence< beans::PropertyValue >& aProperties )
1188*cdf0e10cSrcweir {
1189*cdf0e10cSrcweir     try
1190*cdf0e10cSrcweir     {
1191*cdf0e10cSrcweir         mxShow = Reference< XSlideShow >( createSlideShow(), UNO_QUERY_THROW );
1192*cdf0e10cSrcweir         mxView = mxView.createFromQuery( new SlideShowView(
1193*cdf0e10cSrcweir                                              *mpShowWindow,
1194*cdf0e10cSrcweir                                              mpDoc,
1195*cdf0e10cSrcweir                                              meAnimationMode,
1196*cdf0e10cSrcweir                                              this,
1197*cdf0e10cSrcweir                                              maPresSettings.mbFullScreen) );
1198*cdf0e10cSrcweir 
1199*cdf0e10cSrcweir         // try add wait symbol to properties:
1200*cdf0e10cSrcweir         const Reference<rendering::XSpriteCanvas> xSpriteCanvas(
1201*cdf0e10cSrcweir             mxView->getCanvas() );
1202*cdf0e10cSrcweir         if (xSpriteCanvas.is())
1203*cdf0e10cSrcweir         {
1204*cdf0e10cSrcweir             BitmapEx waitSymbolBitmap( SdResId(BMP_WAIT_ICON) );
1205*cdf0e10cSrcweir             const Reference<rendering::XBitmap> xBitmap(
1206*cdf0e10cSrcweir                 vcl::unotools::xBitmapFromBitmapEx(
1207*cdf0e10cSrcweir                     xSpriteCanvas->getDevice(), waitSymbolBitmap ) );
1208*cdf0e10cSrcweir             if (xBitmap.is())
1209*cdf0e10cSrcweir             {
1210*cdf0e10cSrcweir                 mxShow->setProperty(
1211*cdf0e10cSrcweir                     beans::PropertyValue(
1212*cdf0e10cSrcweir                         OUString( RTL_CONSTASCII_USTRINGPARAM("WaitSymbolBitmap") ),
1213*cdf0e10cSrcweir                         -1,
1214*cdf0e10cSrcweir                         makeAny( xBitmap ),
1215*cdf0e10cSrcweir                         beans::PropertyState_DIRECT_VALUE ) );
1216*cdf0e10cSrcweir             }
1217*cdf0e10cSrcweir         }
1218*cdf0e10cSrcweir 
1219*cdf0e10cSrcweir         const sal_Int32 nCount = aProperties.getLength();
1220*cdf0e10cSrcweir         sal_Int32 nIndex;
1221*cdf0e10cSrcweir         for( nIndex = 0; nIndex < nCount; nIndex++ )
1222*cdf0e10cSrcweir             mxShow->setProperty( aProperties[nIndex] );
1223*cdf0e10cSrcweir 
1224*cdf0e10cSrcweir         mxShow->addView( mxView.getRef() );
1225*cdf0e10cSrcweir 
1226*cdf0e10cSrcweir         mxListenerProxy.set( new SlideShowListenerProxy( this, mxShow ) );
1227*cdf0e10cSrcweir         mxListenerProxy->addAsSlideShowListener();
1228*cdf0e10cSrcweir 
1229*cdf0e10cSrcweir 
1230*cdf0e10cSrcweir         NotifyDocumentEvent( mpDoc, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OnStartPresentation") ) );
1231*cdf0e10cSrcweir         displaySlideIndex( mpSlideController->getStartSlideIndex() );
1232*cdf0e10cSrcweir 
1233*cdf0e10cSrcweir         return true;
1234*cdf0e10cSrcweir     }
1235*cdf0e10cSrcweir     catch( Exception& e )
1236*cdf0e10cSrcweir     {
1237*cdf0e10cSrcweir         (void)e;
1238*cdf0e10cSrcweir         DBG_ERROR(
1239*cdf0e10cSrcweir             (OString("sd::SlideshowImpl::startShowImpl(), "
1240*cdf0e10cSrcweir                      "exception caught: ") +
1241*cdf0e10cSrcweir              rtl::OUStringToOString(
1242*cdf0e10cSrcweir                  comphelper::anyToString( cppu::getCaughtException() ),
1243*cdf0e10cSrcweir                  RTL_TEXTENCODING_UTF8 )).getStr() );
1244*cdf0e10cSrcweir         return false;
1245*cdf0e10cSrcweir     }
1246*cdf0e10cSrcweir }
1247*cdf0e10cSrcweir 
1248*cdf0e10cSrcweir /** called only by the slideshow view when the first paint event occurs.
1249*cdf0e10cSrcweir     This actually starts the slideshow. */
1250*cdf0e10cSrcweir void SlideshowImpl::onFirstPaint()
1251*cdf0e10cSrcweir {
1252*cdf0e10cSrcweir     if( mpShowWindow )
1253*cdf0e10cSrcweir     {
1254*cdf0e10cSrcweir         /*
1255*cdf0e10cSrcweir         mpShowWindow->SetBackground( Wallpaper( Color( COL_BLACK ) ) );
1256*cdf0e10cSrcweir         mpShowWindow->Erase();
1257*cdf0e10cSrcweir         mpShowWindow->SetBackground();
1258*cdf0e10cSrcweir         */
1259*cdf0e10cSrcweir     }
1260*cdf0e10cSrcweir 
1261*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1262*cdf0e10cSrcweir     maUpdateTimer.SetTimeout( (sal_uLong)100 );
1263*cdf0e10cSrcweir     maUpdateTimer.Start();
1264*cdf0e10cSrcweir }
1265*cdf0e10cSrcweir 
1266*cdf0e10cSrcweir void SlideshowImpl::paint( const Rectangle& /* rRect */ )
1267*cdf0e10cSrcweir {
1268*cdf0e10cSrcweir     if( mxView.is() ) try
1269*cdf0e10cSrcweir     {
1270*cdf0e10cSrcweir         awt::PaintEvent aEvt;
1271*cdf0e10cSrcweir         // aEvt.UpdateRect = TODO
1272*cdf0e10cSrcweir         mxView->paint( aEvt );
1273*cdf0e10cSrcweir     }
1274*cdf0e10cSrcweir     catch( Exception& e )
1275*cdf0e10cSrcweir     {
1276*cdf0e10cSrcweir         static_cast<void>(e);
1277*cdf0e10cSrcweir         DBG_ERROR(
1278*cdf0e10cSrcweir             (OString("sd::SlideshowImpl::paint(), "
1279*cdf0e10cSrcweir                     "exception caught: ") +
1280*cdf0e10cSrcweir             rtl::OUStringToOString(
1281*cdf0e10cSrcweir                 comphelper::anyToString( cppu::getCaughtException() ),
1282*cdf0e10cSrcweir                 RTL_TEXTENCODING_UTF8 )).getStr() );
1283*cdf0e10cSrcweir     }
1284*cdf0e10cSrcweir }
1285*cdf0e10cSrcweir 
1286*cdf0e10cSrcweir // --------------------------------------------------------------------
1287*cdf0e10cSrcweir 
1288*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::addSlideShowListener( const Reference< XSlideShowListener >& xListener ) throw (RuntimeException)
1289*cdf0e10cSrcweir {
1290*cdf0e10cSrcweir     if( mxListenerProxy.is() )
1291*cdf0e10cSrcweir         mxListenerProxy->addSlideShowListener( xListener );
1292*cdf0e10cSrcweir }
1293*cdf0e10cSrcweir 
1294*cdf0e10cSrcweir // --------------------------------------------------------------------
1295*cdf0e10cSrcweir 
1296*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::removeSlideShowListener( const Reference< XSlideShowListener >& xListener ) throw (RuntimeException)
1297*cdf0e10cSrcweir {
1298*cdf0e10cSrcweir     if( mxListenerProxy.is() )
1299*cdf0e10cSrcweir         mxListenerProxy->removeSlideShowListener( xListener );
1300*cdf0e10cSrcweir }
1301*cdf0e10cSrcweir 
1302*cdf0e10cSrcweir // ---------------------------------------------------------
1303*cdf0e10cSrcweir 
1304*cdf0e10cSrcweir void SlideshowImpl::slideEnded(const bool bReverse)
1305*cdf0e10cSrcweir {
1306*cdf0e10cSrcweir     if (bReverse)
1307*cdf0e10cSrcweir         gotoPreviousSlide(true);
1308*cdf0e10cSrcweir     else
1309*cdf0e10cSrcweir         gotoNextSlide();
1310*cdf0e10cSrcweir }
1311*cdf0e10cSrcweir 
1312*cdf0e10cSrcweir // ---------------------------------------------------------
1313*cdf0e10cSrcweir 
1314*cdf0e10cSrcweir void SlideshowImpl::removeShapeEvents()
1315*cdf0e10cSrcweir {
1316*cdf0e10cSrcweir     if( mxShow.is() && mxListenerProxy.is() ) try
1317*cdf0e10cSrcweir     {
1318*cdf0e10cSrcweir         WrappedShapeEventImplMap::iterator aIter;
1319*cdf0e10cSrcweir         const WrappedShapeEventImplMap::iterator aEnd( maShapeEventMap.end() );
1320*cdf0e10cSrcweir 
1321*cdf0e10cSrcweir         for( aIter = maShapeEventMap.begin(); aIter != aEnd; aIter++ )
1322*cdf0e10cSrcweir         {
1323*cdf0e10cSrcweir             mxListenerProxy->removeShapeEventListener( (*aIter).first );
1324*cdf0e10cSrcweir             mxShow->setShapeCursor( (*aIter).first, awt::SystemPointer::ARROW );
1325*cdf0e10cSrcweir         }
1326*cdf0e10cSrcweir 
1327*cdf0e10cSrcweir         maShapeEventMap.clear();
1328*cdf0e10cSrcweir     }
1329*cdf0e10cSrcweir     catch( Exception& e )
1330*cdf0e10cSrcweir     {
1331*cdf0e10cSrcweir         (void)e;
1332*cdf0e10cSrcweir         DBG_ERROR(
1333*cdf0e10cSrcweir             (OString("sd::SlideshowImpl::removeShapeEvents(), "
1334*cdf0e10cSrcweir                      "exception caught: ") +
1335*cdf0e10cSrcweir              rtl::OUStringToOString(
1336*cdf0e10cSrcweir                  comphelper::anyToString( cppu::getCaughtException() ),
1337*cdf0e10cSrcweir                  RTL_TEXTENCODING_UTF8 )).getStr() );
1338*cdf0e10cSrcweir     }
1339*cdf0e10cSrcweir }
1340*cdf0e10cSrcweir 
1341*cdf0e10cSrcweir // ---------------------------------------------------------
1342*cdf0e10cSrcweir 
1343*cdf0e10cSrcweir void SlideshowImpl::registerShapeEvents(sal_Int32 nSlideNumber)
1344*cdf0e10cSrcweir {
1345*cdf0e10cSrcweir     if( nSlideNumber >= 0 ) try
1346*cdf0e10cSrcweir     {
1347*cdf0e10cSrcweir         Reference< XDrawPagesSupplier > xDrawPages( mxModel, UNO_QUERY_THROW );
1348*cdf0e10cSrcweir         Reference< XIndexAccess > xPages( xDrawPages->getDrawPages(), UNO_QUERY_THROW );
1349*cdf0e10cSrcweir 
1350*cdf0e10cSrcweir         Reference< XShapes > xDrawPage;
1351*cdf0e10cSrcweir         xPages->getByIndex(nSlideNumber) >>= xDrawPage;
1352*cdf0e10cSrcweir 
1353*cdf0e10cSrcweir         if( xDrawPage.is() )
1354*cdf0e10cSrcweir         {
1355*cdf0e10cSrcweir             Reference< XMasterPageTarget > xMasterPageTarget( xDrawPage, UNO_QUERY );
1356*cdf0e10cSrcweir             if( xMasterPageTarget.is() )
1357*cdf0e10cSrcweir             {
1358*cdf0e10cSrcweir                 Reference< XShapes > xMasterPage( xMasterPageTarget->getMasterPage(), UNO_QUERY );
1359*cdf0e10cSrcweir                 if( xMasterPage.is() )
1360*cdf0e10cSrcweir                     registerShapeEvents( xMasterPage );
1361*cdf0e10cSrcweir             }
1362*cdf0e10cSrcweir             registerShapeEvents( xDrawPage );
1363*cdf0e10cSrcweir         }
1364*cdf0e10cSrcweir     }
1365*cdf0e10cSrcweir     catch( Exception& e )
1366*cdf0e10cSrcweir     {
1367*cdf0e10cSrcweir         (void)e;
1368*cdf0e10cSrcweir         DBG_ERROR(
1369*cdf0e10cSrcweir             (OString("sd::SlideshowImpl::registerShapeEvents(), "
1370*cdf0e10cSrcweir                      "exception caught: ") +
1371*cdf0e10cSrcweir              rtl::OUStringToOString(
1372*cdf0e10cSrcweir                  comphelper::anyToString( cppu::getCaughtException() ),
1373*cdf0e10cSrcweir                  RTL_TEXTENCODING_UTF8 )).getStr() );
1374*cdf0e10cSrcweir     }
1375*cdf0e10cSrcweir }
1376*cdf0e10cSrcweir 
1377*cdf0e10cSrcweir // ---------------------------------------------------------
1378*cdf0e10cSrcweir 
1379*cdf0e10cSrcweir void SlideshowImpl::registerShapeEvents( Reference< XShapes >& xShapes ) throw( Exception )
1380*cdf0e10cSrcweir {
1381*cdf0e10cSrcweir     try
1382*cdf0e10cSrcweir     {
1383*cdf0e10cSrcweir         const sal_Int32 nShapeCount = xShapes->getCount();
1384*cdf0e10cSrcweir         sal_Int32 nShape;
1385*cdf0e10cSrcweir         for( nShape = 0; nShape < nShapeCount; nShape++ )
1386*cdf0e10cSrcweir         {
1387*cdf0e10cSrcweir             Reference< XShape > xShape;
1388*cdf0e10cSrcweir             xShapes->getByIndex( nShape ) >>= xShape;
1389*cdf0e10cSrcweir 
1390*cdf0e10cSrcweir             if( xShape.is() &&
1391*cdf0e10cSrcweir                 xShape->getShapeType().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GroupShape") ) )
1392*cdf0e10cSrcweir             {
1393*cdf0e10cSrcweir                 Reference< XShapes > xSubShapes( xShape, UNO_QUERY );
1394*cdf0e10cSrcweir                 if( xSubShapes.is() )
1395*cdf0e10cSrcweir                     registerShapeEvents( xSubShapes );
1396*cdf0e10cSrcweir             }
1397*cdf0e10cSrcweir 
1398*cdf0e10cSrcweir             Reference< XPropertySet > xSet( xShape, UNO_QUERY );
1399*cdf0e10cSrcweir             if( !xSet.is() )
1400*cdf0e10cSrcweir                 continue;
1401*cdf0e10cSrcweir 
1402*cdf0e10cSrcweir             Reference< XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
1403*cdf0e10cSrcweir             if( !xSetInfo.is() || !xSetInfo->hasPropertyByName( msOnClick ) )
1404*cdf0e10cSrcweir                 continue;
1405*cdf0e10cSrcweir 
1406*cdf0e10cSrcweir             WrappedShapeEventImplPtr pEvent( new WrappedShapeEventImpl );
1407*cdf0e10cSrcweir             xSet->getPropertyValue( msOnClick ) >>= pEvent->meClickAction;
1408*cdf0e10cSrcweir 
1409*cdf0e10cSrcweir             switch( pEvent->meClickAction )
1410*cdf0e10cSrcweir             {
1411*cdf0e10cSrcweir             case ClickAction_PREVPAGE:
1412*cdf0e10cSrcweir             case ClickAction_NEXTPAGE:
1413*cdf0e10cSrcweir             case ClickAction_FIRSTPAGE:
1414*cdf0e10cSrcweir             case ClickAction_LASTPAGE:
1415*cdf0e10cSrcweir             case ClickAction_STOPPRESENTATION:
1416*cdf0e10cSrcweir                 break;
1417*cdf0e10cSrcweir             case ClickAction_BOOKMARK:
1418*cdf0e10cSrcweir                 if( xSetInfo->hasPropertyByName( msBookmark ) )
1419*cdf0e10cSrcweir                     xSet->getPropertyValue( msBookmark ) >>= pEvent->maStrBookmark;
1420*cdf0e10cSrcweir                 if( getSlideNumberForBookmark( pEvent->maStrBookmark ) == -1 )
1421*cdf0e10cSrcweir                     continue;
1422*cdf0e10cSrcweir                 break;
1423*cdf0e10cSrcweir             case ClickAction_DOCUMENT:
1424*cdf0e10cSrcweir             case ClickAction_SOUND:
1425*cdf0e10cSrcweir             case ClickAction_PROGRAM:
1426*cdf0e10cSrcweir             case ClickAction_MACRO:
1427*cdf0e10cSrcweir                 if( xSetInfo->hasPropertyByName( msBookmark ) )
1428*cdf0e10cSrcweir                     xSet->getPropertyValue( msBookmark ) >>= pEvent->maStrBookmark;
1429*cdf0e10cSrcweir                 break;
1430*cdf0e10cSrcweir             case ClickAction_VERB:
1431*cdf0e10cSrcweir                 if( xSetInfo->hasPropertyByName( msVerb ) )
1432*cdf0e10cSrcweir                     xSet->getPropertyValue( msVerb ) >>= pEvent->mnVerb;
1433*cdf0e10cSrcweir                 break;
1434*cdf0e10cSrcweir             default:
1435*cdf0e10cSrcweir                 continue; // skip all others
1436*cdf0e10cSrcweir             }
1437*cdf0e10cSrcweir 
1438*cdf0e10cSrcweir             maShapeEventMap[ xShape ] = pEvent;
1439*cdf0e10cSrcweir 
1440*cdf0e10cSrcweir             if( mxListenerProxy.is() )
1441*cdf0e10cSrcweir                 mxListenerProxy->addShapeEventListener( xShape );
1442*cdf0e10cSrcweir             mxShow->setShapeCursor( xShape, awt::SystemPointer::REFHAND );
1443*cdf0e10cSrcweir         }
1444*cdf0e10cSrcweir     }
1445*cdf0e10cSrcweir     catch( Exception& e )
1446*cdf0e10cSrcweir     {
1447*cdf0e10cSrcweir         static_cast<void>(e);
1448*cdf0e10cSrcweir         DBG_ERROR(
1449*cdf0e10cSrcweir             (OString("sd::SlideshowImpl::registerShapeEvents(), "
1450*cdf0e10cSrcweir                     "exception caught: ") +
1451*cdf0e10cSrcweir             rtl::OUStringToOString(
1452*cdf0e10cSrcweir                 comphelper::anyToString( cppu::getCaughtException() ),
1453*cdf0e10cSrcweir                 RTL_TEXTENCODING_UTF8 )).getStr() );
1454*cdf0e10cSrcweir     }
1455*cdf0e10cSrcweir }
1456*cdf0e10cSrcweir 
1457*cdf0e10cSrcweir // ---------------------------------------------------------
1458*cdf0e10cSrcweir 
1459*cdf0e10cSrcweir void SlideshowImpl::displayCurrentSlide (const bool bSkipAllMainSequenceEffects)
1460*cdf0e10cSrcweir {
1461*cdf0e10cSrcweir     stopSound();
1462*cdf0e10cSrcweir     removeShapeEvents();
1463*cdf0e10cSrcweir 
1464*cdf0e10cSrcweir     if( mpSlideController.get() && mxShow.is() )
1465*cdf0e10cSrcweir     {
1466*cdf0e10cSrcweir         Reference< XDrawPagesSupplier > xDrawPages( mpDoc->getUnoModel(),
1467*cdf0e10cSrcweir                                                     UNO_QUERY_THROW );
1468*cdf0e10cSrcweir         mpSlideController->displayCurrentSlide( mxShow, xDrawPages, bSkipAllMainSequenceEffects );
1469*cdf0e10cSrcweir         registerShapeEvents(mpSlideController->getCurrentSlideNumber());
1470*cdf0e10cSrcweir         update();
1471*cdf0e10cSrcweir 
1472*cdf0e10cSrcweir         SfxBindings* pBindings = getBindings();
1473*cdf0e10cSrcweir         if( pBindings )
1474*cdf0e10cSrcweir         {
1475*cdf0e10cSrcweir             pBindings->Invalidate( SID_NAVIGATOR_STATE );
1476*cdf0e10cSrcweir             pBindings->Invalidate( SID_NAVIGATOR_PAGENAME );
1477*cdf0e10cSrcweir         }
1478*cdf0e10cSrcweir     }
1479*cdf0e10cSrcweir }
1480*cdf0e10cSrcweir 
1481*cdf0e10cSrcweir // ---------------------------------------------------------
1482*cdf0e10cSrcweir 
1483*cdf0e10cSrcweir void SlideshowImpl::endPresentation()
1484*cdf0e10cSrcweir {
1485*cdf0e10cSrcweir /*
1486*cdf0e10cSrcweir     if( maPresSettings.mbMouseAsPen)
1487*cdf0e10cSrcweir     {
1488*cdf0e10cSrcweir         Reference< XMultiServiceFactory > xDocFactory(mpDoc->getUnoModel(), UNO_QUERY );
1489*cdf0e10cSrcweir         if( xDocFactory.is() )
1490*cdf0e10cSrcweir             mxShow->registerUserPaintPolygons(xDocFactory);
1491*cdf0e10cSrcweir     }
1492*cdf0e10cSrcweir */
1493*cdf0e10cSrcweir     if( !mnEndShowEvent )
1494*cdf0e10cSrcweir         mnEndShowEvent = Application::PostUserEvent( LINK(this, SlideshowImpl, endPresentationHdl) );
1495*cdf0e10cSrcweir }
1496*cdf0e10cSrcweir 
1497*cdf0e10cSrcweir // ---------------------------------------------------------
1498*cdf0e10cSrcweir 
1499*cdf0e10cSrcweir IMPL_LINK( SlideshowImpl, endPresentationHdl, void*, EMPTYARG )
1500*cdf0e10cSrcweir {
1501*cdf0e10cSrcweir     mnEndShowEvent = 0;
1502*cdf0e10cSrcweir 
1503*cdf0e10cSrcweir     if( mxPresentation.is() )
1504*cdf0e10cSrcweir         mxPresentation->end();
1505*cdf0e10cSrcweir     return 0;
1506*cdf0e10cSrcweir }
1507*cdf0e10cSrcweir 
1508*cdf0e10cSrcweir // ---------------------------------------------------------
1509*cdf0e10cSrcweir 
1510*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::pause() throw (RuntimeException)
1511*cdf0e10cSrcweir {
1512*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1513*cdf0e10cSrcweir 
1514*cdf0e10cSrcweir     if( !mbIsPaused ) try
1515*cdf0e10cSrcweir     {
1516*cdf0e10cSrcweir         mbIsPaused = sal_True;
1517*cdf0e10cSrcweir         if( mxShow.is() )
1518*cdf0e10cSrcweir         {
1519*cdf0e10cSrcweir             mxShow->pause(sal_True);
1520*cdf0e10cSrcweir 
1521*cdf0e10cSrcweir             if( mxListenerProxy.is() )
1522*cdf0e10cSrcweir                 mxListenerProxy->paused();
1523*cdf0e10cSrcweir         }
1524*cdf0e10cSrcweir     }
1525*cdf0e10cSrcweir     catch( Exception& e )
1526*cdf0e10cSrcweir     {
1527*cdf0e10cSrcweir         static_cast<void>(e);
1528*cdf0e10cSrcweir         DBG_ERROR(
1529*cdf0e10cSrcweir             (OString("sd::SlideshowImpl::pause(), "
1530*cdf0e10cSrcweir                     "exception caught: ") +
1531*cdf0e10cSrcweir             rtl::OUStringToOString(
1532*cdf0e10cSrcweir                 comphelper::anyToString( cppu::getCaughtException() ),
1533*cdf0e10cSrcweir                 RTL_TEXTENCODING_UTF8 )).getStr() );
1534*cdf0e10cSrcweir     }
1535*cdf0e10cSrcweir }
1536*cdf0e10cSrcweir 
1537*cdf0e10cSrcweir // ---------------------------------------------------------
1538*cdf0e10cSrcweir 
1539*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::resume() throw (RuntimeException)
1540*cdf0e10cSrcweir {
1541*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1542*cdf0e10cSrcweir 
1543*cdf0e10cSrcweir     if( mbIsPaused ) try
1544*cdf0e10cSrcweir     {
1545*cdf0e10cSrcweir         if( mpShowWindow->GetShowWindowMode() == SHOWWINDOWMODE_BLANK )
1546*cdf0e10cSrcweir         {
1547*cdf0e10cSrcweir             mpShowWindow->RestartShow();
1548*cdf0e10cSrcweir         }
1549*cdf0e10cSrcweir         else
1550*cdf0e10cSrcweir         {
1551*cdf0e10cSrcweir             mbIsPaused = sal_False;;
1552*cdf0e10cSrcweir             if( mxShow.is() )
1553*cdf0e10cSrcweir             {
1554*cdf0e10cSrcweir                 mxShow->pause(sal_False);
1555*cdf0e10cSrcweir                 update();
1556*cdf0e10cSrcweir 
1557*cdf0e10cSrcweir                 if( mxListenerProxy.is() )
1558*cdf0e10cSrcweir                     mxListenerProxy->resumed();
1559*cdf0e10cSrcweir             }
1560*cdf0e10cSrcweir         }
1561*cdf0e10cSrcweir     }
1562*cdf0e10cSrcweir     catch( Exception& e )
1563*cdf0e10cSrcweir     {
1564*cdf0e10cSrcweir         static_cast<void>(e);
1565*cdf0e10cSrcweir         DBG_ERROR(
1566*cdf0e10cSrcweir             (OString("sd::SlideshowImpl::resume(), "
1567*cdf0e10cSrcweir                     "exception caught: ") +
1568*cdf0e10cSrcweir             rtl::OUStringToOString(
1569*cdf0e10cSrcweir                 comphelper::anyToString( cppu::getCaughtException() ),
1570*cdf0e10cSrcweir                 RTL_TEXTENCODING_UTF8 )).getStr() );
1571*cdf0e10cSrcweir     }
1572*cdf0e10cSrcweir }
1573*cdf0e10cSrcweir 
1574*cdf0e10cSrcweir // ---------------------------------------------------------
1575*cdf0e10cSrcweir 
1576*cdf0e10cSrcweir sal_Bool SAL_CALL SlideshowImpl::isPaused() throw (RuntimeException)
1577*cdf0e10cSrcweir {
1578*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1579*cdf0e10cSrcweir     return mbIsPaused;
1580*cdf0e10cSrcweir }
1581*cdf0e10cSrcweir 
1582*cdf0e10cSrcweir // ---------------------------------------------------------
1583*cdf0e10cSrcweir 
1584*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::blankScreen( sal_Int32 nColor ) throw (RuntimeException)
1585*cdf0e10cSrcweir {
1586*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1587*cdf0e10cSrcweir 
1588*cdf0e10cSrcweir     if( mpShowWindow && mpSlideController )
1589*cdf0e10cSrcweir     {
1590*cdf0e10cSrcweir         if( mpShowWindow->SetBlankMode( mpSlideController->getCurrentSlideIndex(), nColor ) )
1591*cdf0e10cSrcweir         {
1592*cdf0e10cSrcweir             pause();
1593*cdf0e10cSrcweir         }
1594*cdf0e10cSrcweir     }
1595*cdf0e10cSrcweir }
1596*cdf0e10cSrcweir 
1597*cdf0e10cSrcweir // ---------------------------------------------------------
1598*cdf0e10cSrcweir // XShapeEventListener
1599*cdf0e10cSrcweir // ---------------------------------------------------------
1600*cdf0e10cSrcweir 
1601*cdf0e10cSrcweir void SlideshowImpl::click( const Reference< XShape >& xShape, const ::com::sun::star::awt::MouseEvent& /* aOriginalEvent */ )
1602*cdf0e10cSrcweir {
1603*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1604*cdf0e10cSrcweir 
1605*cdf0e10cSrcweir     WrappedShapeEventImplPtr pEvent = maShapeEventMap[xShape];
1606*cdf0e10cSrcweir     if( !pEvent.get() )
1607*cdf0e10cSrcweir         return;
1608*cdf0e10cSrcweir 
1609*cdf0e10cSrcweir     switch( pEvent->meClickAction )
1610*cdf0e10cSrcweir     {
1611*cdf0e10cSrcweir     case ClickAction_PREVPAGE:          gotoPreviousSlide();        break;
1612*cdf0e10cSrcweir     case ClickAction_NEXTPAGE:          gotoNextSlide();            break;
1613*cdf0e10cSrcweir     case ClickAction_FIRSTPAGE:         gotoFirstSlide();           break;
1614*cdf0e10cSrcweir     case ClickAction_LASTPAGE:          gotoLastSlide();            break;
1615*cdf0e10cSrcweir     case ClickAction_STOPPRESENTATION:  endPresentation();          break;
1616*cdf0e10cSrcweir     case ClickAction_BOOKMARK:
1617*cdf0e10cSrcweir     {
1618*cdf0e10cSrcweir         gotoBookmark( pEvent->maStrBookmark );
1619*cdf0e10cSrcweir     }
1620*cdf0e10cSrcweir     break;
1621*cdf0e10cSrcweir     case ClickAction_SOUND:
1622*cdf0e10cSrcweir     {
1623*cdf0e10cSrcweir         try
1624*cdf0e10cSrcweir         {
1625*cdf0e10cSrcweir             mxPlayer.set(avmedia::MediaWindow::createPlayer(pEvent->maStrBookmark), uno::UNO_QUERY_THROW );
1626*cdf0e10cSrcweir             mxPlayer->start();
1627*cdf0e10cSrcweir         }
1628*cdf0e10cSrcweir         catch( uno::Exception& e )
1629*cdf0e10cSrcweir         {
1630*cdf0e10cSrcweir             (void)e;
1631*cdf0e10cSrcweir             DBG_ERROR("sd::SlideshowImpl::click(), exception caught!" );
1632*cdf0e10cSrcweir         }
1633*cdf0e10cSrcweir     }
1634*cdf0e10cSrcweir     break;
1635*cdf0e10cSrcweir 
1636*cdf0e10cSrcweir     case ClickAction_DOCUMENT:
1637*cdf0e10cSrcweir     {
1638*cdf0e10cSrcweir         OUString aBookmark( pEvent->maStrBookmark );
1639*cdf0e10cSrcweir 
1640*cdf0e10cSrcweir         sal_Int32 nPos = aBookmark.indexOf( sal_Unicode('#') );
1641*cdf0e10cSrcweir         if( nPos >= 0 )
1642*cdf0e10cSrcweir         {
1643*cdf0e10cSrcweir             OUString aURL( aBookmark.copy( 0, nPos+1 ) );
1644*cdf0e10cSrcweir             OUString aName( aBookmark.copy( nPos+1 ) );
1645*cdf0e10cSrcweir             aURL += getUiNameFromPageApiNameImpl( aName );
1646*cdf0e10cSrcweir             aBookmark = aURL;
1647*cdf0e10cSrcweir         }
1648*cdf0e10cSrcweir 
1649*cdf0e10cSrcweir         mpDocSh->OpenBookmark( aBookmark );
1650*cdf0e10cSrcweir     }
1651*cdf0e10cSrcweir     break;
1652*cdf0e10cSrcweir 
1653*cdf0e10cSrcweir     case ClickAction_PROGRAM:
1654*cdf0e10cSrcweir     {
1655*cdf0e10cSrcweir         INetURLObject aURL(
1656*cdf0e10cSrcweir             ::URIHelper::SmartRel2Abs(
1657*cdf0e10cSrcweir                 INetURLObject(mpDocSh->GetMedium()->GetBaseURL()),
1658*cdf0e10cSrcweir                 pEvent->maStrBookmark, ::URIHelper::GetMaybeFileHdl(), true,
1659*cdf0e10cSrcweir                 false, INetURLObject::WAS_ENCODED,
1660*cdf0e10cSrcweir                 INetURLObject::DECODE_UNAMBIGUOUS ) );
1661*cdf0e10cSrcweir 
1662*cdf0e10cSrcweir         if( INET_PROT_FILE == aURL.GetProtocol() )
1663*cdf0e10cSrcweir         {
1664*cdf0e10cSrcweir             SfxStringItem aUrl( SID_FILE_NAME, aURL.GetMainURL( INetURLObject::NO_DECODE ) );
1665*cdf0e10cSrcweir             SfxBoolItem aBrowsing( SID_BROWSE, sal_True );
1666*cdf0e10cSrcweir 
1667*cdf0e10cSrcweir             SfxViewFrame* pViewFrm = SfxViewFrame::Current();
1668*cdf0e10cSrcweir             if (pViewFrm)
1669*cdf0e10cSrcweir                 pViewFrm->GetDispatcher()->Execute( SID_OPENDOC,
1670*cdf0e10cSrcweir                                             SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
1671*cdf0e10cSrcweir                                             &aUrl,
1672*cdf0e10cSrcweir                                             &aBrowsing,
1673*cdf0e10cSrcweir                                             0L );
1674*cdf0e10cSrcweir         }
1675*cdf0e10cSrcweir     }
1676*cdf0e10cSrcweir     break;
1677*cdf0e10cSrcweir 
1678*cdf0e10cSrcweir     case presentation::ClickAction_MACRO:
1679*cdf0e10cSrcweir     {
1680*cdf0e10cSrcweir         const String aMacro( pEvent->maStrBookmark );
1681*cdf0e10cSrcweir 
1682*cdf0e10cSrcweir         if ( SfxApplication::IsXScriptURL( aMacro ) )
1683*cdf0e10cSrcweir         {
1684*cdf0e10cSrcweir             Any aRet;
1685*cdf0e10cSrcweir             Sequence< sal_Int16 > aOutArgsIndex;
1686*cdf0e10cSrcweir             Sequence< Any > aOutArgs;
1687*cdf0e10cSrcweir             Sequence< Any >* pInArgs = new Sequence< Any >(0);
1688*cdf0e10cSrcweir             mpDocSh->CallXScript( aMacro, *pInArgs, aRet, aOutArgsIndex, aOutArgs);
1689*cdf0e10cSrcweir         }
1690*cdf0e10cSrcweir         else
1691*cdf0e10cSrcweir         {
1692*cdf0e10cSrcweir             // aMacro has the following syntax:
1693*cdf0e10cSrcweir             // "Macroname.Modulname.Libname.Dokumentname" or
1694*cdf0e10cSrcweir             // "Macroname.Modulname.Libname.Applikationsname"
1695*cdf0e10cSrcweir             String aMacroName = aMacro.GetToken(0, sal_Unicode('.'));
1696*cdf0e10cSrcweir             String aModulName = aMacro.GetToken(1, sal_Unicode('.'));
1697*cdf0e10cSrcweir             String aLibName   = aMacro.GetToken(2, sal_Unicode('.'));
1698*cdf0e10cSrcweir             String aDocName   = aMacro.GetToken(3, sal_Unicode('.'));
1699*cdf0e10cSrcweir 
1700*cdf0e10cSrcweir             // todo: is the limitation still given that only
1701*cdf0e10cSrcweir             // Modulname+Macroname can be used here?
1702*cdf0e10cSrcweir             String aExecMacro(aModulName);
1703*cdf0e10cSrcweir             aExecMacro.Append( sal_Unicode('.') );
1704*cdf0e10cSrcweir             aExecMacro.Append( aMacroName );
1705*cdf0e10cSrcweir             mpDocSh->GetBasic()->Call(aExecMacro);
1706*cdf0e10cSrcweir         }
1707*cdf0e10cSrcweir     }
1708*cdf0e10cSrcweir     break;
1709*cdf0e10cSrcweir 
1710*cdf0e10cSrcweir     case ClickAction_VERB:
1711*cdf0e10cSrcweir     {
1712*cdf0e10cSrcweir         // todo, better do it async?
1713*cdf0e10cSrcweir         SdrObject* pObj = GetSdrObjectFromXShape( xShape );
1714*cdf0e10cSrcweir         SdrOle2Obj* pOleObject = PTR_CAST(SdrOle2Obj, pObj);
1715*cdf0e10cSrcweir         if (pOleObject && mpViewShell )
1716*cdf0e10cSrcweir             mpViewShell->ActivateObject(pOleObject, pEvent->mnVerb);
1717*cdf0e10cSrcweir     }
1718*cdf0e10cSrcweir     break;
1719*cdf0e10cSrcweir     default:
1720*cdf0e10cSrcweir         break;
1721*cdf0e10cSrcweir     }
1722*cdf0e10cSrcweir }
1723*cdf0e10cSrcweir 
1724*cdf0e10cSrcweir // ---------------------------------------------------------
1725*cdf0e10cSrcweir 
1726*cdf0e10cSrcweir sal_Int32 SlideshowImpl::getSlideNumberForBookmark( const OUString& rStrBookmark )
1727*cdf0e10cSrcweir {
1728*cdf0e10cSrcweir     sal_Bool bIsMasterPage;
1729*cdf0e10cSrcweir     OUString aBookmark = getUiNameFromPageApiNameImpl( rStrBookmark );
1730*cdf0e10cSrcweir     sal_uInt16 nPgNum = mpDoc->GetPageByName( aBookmark, bIsMasterPage );
1731*cdf0e10cSrcweir 
1732*cdf0e10cSrcweir     if( nPgNum == SDRPAGE_NOTFOUND )
1733*cdf0e10cSrcweir     {
1734*cdf0e10cSrcweir         // Ist das Bookmark ein Objekt?
1735*cdf0e10cSrcweir         SdrObject* pObj = mpDoc->GetObj( aBookmark );
1736*cdf0e10cSrcweir 
1737*cdf0e10cSrcweir         if( pObj )
1738*cdf0e10cSrcweir         {
1739*cdf0e10cSrcweir             nPgNum = pObj->GetPage()->GetPageNum();
1740*cdf0e10cSrcweir             bIsMasterPage = (sal_Bool)pObj->GetPage()->IsMasterPage();
1741*cdf0e10cSrcweir         }
1742*cdf0e10cSrcweir     }
1743*cdf0e10cSrcweir 
1744*cdf0e10cSrcweir     if( (nPgNum == SDRPAGE_NOTFOUND) || bIsMasterPage || static_cast<SdPage*>(mpDoc->GetPage(nPgNum))->GetPageKind() != PK_STANDARD )
1745*cdf0e10cSrcweir         return -1;
1746*cdf0e10cSrcweir 
1747*cdf0e10cSrcweir     return ( nPgNum - 1) >> 1;
1748*cdf0e10cSrcweir }
1749*cdf0e10cSrcweir 
1750*cdf0e10cSrcweir // ---------------------------------------------------------
1751*cdf0e10cSrcweir 
1752*cdf0e10cSrcweir void SlideshowImpl::hyperLinkClicked( rtl::OUString const& aHyperLink ) throw (RuntimeException)
1753*cdf0e10cSrcweir {
1754*cdf0e10cSrcweir     OUString aBookmark( aHyperLink );
1755*cdf0e10cSrcweir 
1756*cdf0e10cSrcweir     sal_Int32 nPos = aBookmark.indexOf( sal_Unicode('#') );
1757*cdf0e10cSrcweir     if( nPos >= 0 )
1758*cdf0e10cSrcweir     {
1759*cdf0e10cSrcweir         OUString aURL( aBookmark.copy( 0, nPos+1 ) );
1760*cdf0e10cSrcweir         OUString aName( aBookmark.copy( nPos+1 ) );
1761*cdf0e10cSrcweir         aURL += getUiNameFromPageApiNameImpl( aName );
1762*cdf0e10cSrcweir         aBookmark = aURL;
1763*cdf0e10cSrcweir     }
1764*cdf0e10cSrcweir 
1765*cdf0e10cSrcweir     mpDocSh->OpenBookmark( aBookmark );
1766*cdf0e10cSrcweir }
1767*cdf0e10cSrcweir 
1768*cdf0e10cSrcweir // ---------------------------------------------------------
1769*cdf0e10cSrcweir 
1770*cdf0e10cSrcweir void SlideshowImpl::displaySlideNumber( sal_Int32 nSlideNumber )
1771*cdf0e10cSrcweir {
1772*cdf0e10cSrcweir     if( mpSlideController.get() )
1773*cdf0e10cSrcweir     {
1774*cdf0e10cSrcweir         if( mpSlideController->jumpToSlideNumber( nSlideNumber ) )
1775*cdf0e10cSrcweir         {
1776*cdf0e10cSrcweir             displayCurrentSlide();
1777*cdf0e10cSrcweir         }
1778*cdf0e10cSrcweir     }
1779*cdf0e10cSrcweir }
1780*cdf0e10cSrcweir 
1781*cdf0e10cSrcweir // ---------------------------------------------------------
1782*cdf0e10cSrcweir 
1783*cdf0e10cSrcweir /** nSlideIndex == -1 displays current slide again */
1784*cdf0e10cSrcweir void SlideshowImpl::displaySlideIndex( sal_Int32 nSlideIndex )
1785*cdf0e10cSrcweir {
1786*cdf0e10cSrcweir     if( mpSlideController.get() )
1787*cdf0e10cSrcweir     {
1788*cdf0e10cSrcweir         if( (nSlideIndex == -1) || mpSlideController->jumpToSlideIndex( nSlideIndex ) )
1789*cdf0e10cSrcweir         {
1790*cdf0e10cSrcweir             displayCurrentSlide();
1791*cdf0e10cSrcweir         }
1792*cdf0e10cSrcweir     }
1793*cdf0e10cSrcweir }
1794*cdf0e10cSrcweir 
1795*cdf0e10cSrcweir // ---------------------------------------------------------
1796*cdf0e10cSrcweir 
1797*cdf0e10cSrcweir void SlideshowImpl::jumpToBookmark( const String& sBookmark )
1798*cdf0e10cSrcweir {
1799*cdf0e10cSrcweir     sal_Int32 nSlideNumber = getSlideNumberForBookmark( sBookmark );
1800*cdf0e10cSrcweir     if( nSlideNumber != -1 )
1801*cdf0e10cSrcweir         displaySlideNumber( nSlideNumber );
1802*cdf0e10cSrcweir }
1803*cdf0e10cSrcweir 
1804*cdf0e10cSrcweir // ---------------------------------------------------------
1805*cdf0e10cSrcweir 
1806*cdf0e10cSrcweir sal_Int32 SlideshowImpl::getCurrentSlideNumber()
1807*cdf0e10cSrcweir {
1808*cdf0e10cSrcweir     return mpSlideController.get() ? mpSlideController->getCurrentSlideNumber() : -1;
1809*cdf0e10cSrcweir }
1810*cdf0e10cSrcweir 
1811*cdf0e10cSrcweir // ---------------------------------------------------------
1812*cdf0e10cSrcweir 
1813*cdf0e10cSrcweir sal_Int32 SlideshowImpl::getFirstSlideNumber()
1814*cdf0e10cSrcweir {
1815*cdf0e10cSrcweir     sal_Int32 nRet = 0;
1816*cdf0e10cSrcweir     if( mpSlideController.get() )
1817*cdf0e10cSrcweir     {
1818*cdf0e10cSrcweir         sal_Int32 nSlideIndexCount = mpSlideController->getSlideIndexCount() - 1;
1819*cdf0e10cSrcweir         if( nSlideIndexCount >= 0 )
1820*cdf0e10cSrcweir         {
1821*cdf0e10cSrcweir             nRet = mpSlideController->getSlideNumber( nSlideIndexCount );
1822*cdf0e10cSrcweir             while( nSlideIndexCount-- )
1823*cdf0e10cSrcweir             {
1824*cdf0e10cSrcweir                 sal_Int32 nTemp = mpSlideController->getSlideNumber( nSlideIndexCount );
1825*cdf0e10cSrcweir                 if( nRet > nTemp )
1826*cdf0e10cSrcweir                     nRet = nTemp;
1827*cdf0e10cSrcweir             }
1828*cdf0e10cSrcweir         }
1829*cdf0e10cSrcweir     }
1830*cdf0e10cSrcweir 
1831*cdf0e10cSrcweir     return nRet;
1832*cdf0e10cSrcweir }
1833*cdf0e10cSrcweir 
1834*cdf0e10cSrcweir // ---------------------------------------------------------
1835*cdf0e10cSrcweir 
1836*cdf0e10cSrcweir sal_Int32 SlideshowImpl::getLastSlideNumber()
1837*cdf0e10cSrcweir {
1838*cdf0e10cSrcweir     sal_Int32 nRet = 0;
1839*cdf0e10cSrcweir     if( mpSlideController.get() )
1840*cdf0e10cSrcweir     {
1841*cdf0e10cSrcweir         sal_Int32 nSlideIndexCount = mpSlideController->getSlideIndexCount() - 1;
1842*cdf0e10cSrcweir         if( nSlideIndexCount >= 0 )
1843*cdf0e10cSrcweir         {
1844*cdf0e10cSrcweir             nRet = mpSlideController->getSlideNumber( nSlideIndexCount );
1845*cdf0e10cSrcweir             while( nSlideIndexCount-- )
1846*cdf0e10cSrcweir             {
1847*cdf0e10cSrcweir                 sal_Int32 nTemp = mpSlideController->getSlideNumber( nSlideIndexCount );
1848*cdf0e10cSrcweir                 if( nRet < nTemp )
1849*cdf0e10cSrcweir                     nRet = nTemp;
1850*cdf0e10cSrcweir             }
1851*cdf0e10cSrcweir         }
1852*cdf0e10cSrcweir     }
1853*cdf0e10cSrcweir 
1854*cdf0e10cSrcweir     return nRet;
1855*cdf0e10cSrcweir }
1856*cdf0e10cSrcweir 
1857*cdf0e10cSrcweir // ---------------------------------------------------------
1858*cdf0e10cSrcweir 
1859*cdf0e10cSrcweir sal_Bool SAL_CALL SlideshowImpl::isEndless() throw( RuntimeException )
1860*cdf0e10cSrcweir {
1861*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1862*cdf0e10cSrcweir     return maPresSettings.mbEndless;
1863*cdf0e10cSrcweir }
1864*cdf0e10cSrcweir 
1865*cdf0e10cSrcweir // ---------------------------------------------------------
1866*cdf0e10cSrcweir 
1867*cdf0e10cSrcweir double SlideshowImpl::update()
1868*cdf0e10cSrcweir {
1869*cdf0e10cSrcweir     startUpdateTimer();
1870*cdf0e10cSrcweir     return -1;
1871*cdf0e10cSrcweir }
1872*cdf0e10cSrcweir 
1873*cdf0e10cSrcweir // ---------------------------------------------------------
1874*cdf0e10cSrcweir 
1875*cdf0e10cSrcweir void SlideshowImpl::startUpdateTimer()
1876*cdf0e10cSrcweir {
1877*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1878*cdf0e10cSrcweir     maUpdateTimer.SetTimeout( 0 );
1879*cdf0e10cSrcweir     maUpdateTimer.Start();
1880*cdf0e10cSrcweir }
1881*cdf0e10cSrcweir 
1882*cdf0e10cSrcweir // ---------------------------------------------------------
1883*cdf0e10cSrcweir 
1884*cdf0e10cSrcweir /** this timer is called 20ms after a new slide was displayed.
1885*cdf0e10cSrcweir     This is used to unfreeze user input that was disabled after
1886*cdf0e10cSrcweir     slide change to skip input that was buffered during slide
1887*cdf0e10cSrcweir     transition preperation */
1888*cdf0e10cSrcweir IMPL_LINK( SlideshowImpl, ReadyForNextInputHdl, Timer*, EMPTYARG )
1889*cdf0e10cSrcweir {
1890*cdf0e10cSrcweir     mbInputFreeze = false;
1891*cdf0e10cSrcweir     return 0;
1892*cdf0e10cSrcweir }
1893*cdf0e10cSrcweir 
1894*cdf0e10cSrcweir // ---------------------------------------------------------
1895*cdf0e10cSrcweir 
1896*cdf0e10cSrcweir /** if I catch someone someday who calls this method by hand
1897*cdf0e10cSrcweir     and not by using the timer, I will personaly punish this
1898*cdf0e10cSrcweir     person seriously, even if this person is me.
1899*cdf0e10cSrcweir */
1900*cdf0e10cSrcweir IMPL_LINK( SlideshowImpl, updateHdl, Timer*, EMPTYARG )
1901*cdf0e10cSrcweir {
1902*cdf0e10cSrcweir     mnUpdateEvent = 0;
1903*cdf0e10cSrcweir 
1904*cdf0e10cSrcweir     return updateSlideShow();
1905*cdf0e10cSrcweir }
1906*cdf0e10cSrcweir 
1907*cdf0e10cSrcweir 
1908*cdf0e10cSrcweir 
1909*cdf0e10cSrcweir 
1910*cdf0e10cSrcweir IMPL_LINK( SlideshowImpl, PostYieldListener, void*, EMPTYARG )
1911*cdf0e10cSrcweir {
1912*cdf0e10cSrcweir     Application::EnableNoYieldMode(false);
1913*cdf0e10cSrcweir     Application::RemovePostYieldListener(LINK(this, SlideshowImpl, PostYieldListener));
1914*cdf0e10cSrcweir     if (mbDisposed)
1915*cdf0e10cSrcweir         return 0;
1916*cdf0e10cSrcweir     Application::Reschedule(true);
1917*cdf0e10cSrcweir     return updateSlideShow();
1918*cdf0e10cSrcweir }
1919*cdf0e10cSrcweir 
1920*cdf0e10cSrcweir 
1921*cdf0e10cSrcweir 
1922*cdf0e10cSrcweir 
1923*cdf0e10cSrcweir sal_Int32 SlideshowImpl::updateSlideShow (void)
1924*cdf0e10cSrcweir {
1925*cdf0e10cSrcweir     // doing some nMagic
1926*cdf0e10cSrcweir     const rtl::Reference<SlideshowImpl> this_(this);
1927*cdf0e10cSrcweir 
1928*cdf0e10cSrcweir     Reference< XSlideShow > xShow( mxShow );
1929*cdf0e10cSrcweir     if ( ! xShow.is())
1930*cdf0e10cSrcweir         return 0;
1931*cdf0e10cSrcweir 
1932*cdf0e10cSrcweir     try
1933*cdf0e10cSrcweir     {
1934*cdf0e10cSrcweir         // TODO(Q3): Evaluate under various systems and setups,
1935*cdf0e10cSrcweir         // whether this is really necessary. Under WinXP and Matrox
1936*cdf0e10cSrcweir         // G550, the frame rates were much more steadier with this
1937*cdf0e10cSrcweir         // tweak, although.
1938*cdf0e10cSrcweir 
1939*cdf0e10cSrcweir // currently no solution, because this kills sound (at least on Windows)
1940*cdf0e10cSrcweir //         // Boost our prio, as long as we're in the render loop
1941*cdf0e10cSrcweir //         ::canvas::tools::PriorityBooster aBooster(2);
1942*cdf0e10cSrcweir 
1943*cdf0e10cSrcweir         double fUpdate = 0.0;
1944*cdf0e10cSrcweir         if( !xShow->update(fUpdate) )
1945*cdf0e10cSrcweir             fUpdate = -1.0;
1946*cdf0e10cSrcweir 
1947*cdf0e10cSrcweir         if (mxShow.is() && (fUpdate >= 0.0))
1948*cdf0e10cSrcweir         {
1949*cdf0e10cSrcweir             if (::basegfx::fTools::equalZero(fUpdate))
1950*cdf0e10cSrcweir             {
1951*cdf0e10cSrcweir                 // Use post yield listener for short update intervalls.
1952*cdf0e10cSrcweir                 Application::EnableNoYieldMode(true);
1953*cdf0e10cSrcweir                 Application::AddPostYieldListener(LINK(this, SlideshowImpl, PostYieldListener));
1954*cdf0e10cSrcweir             }
1955*cdf0e10cSrcweir             else
1956*cdf0e10cSrcweir             {
1957*cdf0e10cSrcweir                 // Avoid busy loop when the previous call to update()
1958*cdf0e10cSrcweir                 // returns a small positive number but not 0 (which is
1959*cdf0e10cSrcweir                 // handled above).  Also, make sure that calls to update()
1960*cdf0e10cSrcweir                 // have a minimum frequency.
1961*cdf0e10cSrcweir                 // => Allow up to 60 frames per second.  Call at least once
1962*cdf0e10cSrcweir                 // every 4 seconds.
1963*cdf0e10cSrcweir                 const static sal_Int32 mnMaximumFrameCount (60);
1964*cdf0e10cSrcweir                 const static double mnMinimumTimeout (1.0 / mnMaximumFrameCount);
1965*cdf0e10cSrcweir                 const static double mnMaximumTimeout (4.0);
1966*cdf0e10cSrcweir                 fUpdate = ::basegfx::clamp(fUpdate, mnMinimumTimeout, mnMaximumTimeout);
1967*cdf0e10cSrcweir 
1968*cdf0e10cSrcweir                 // Make sure that the maximum frame count has not been set
1969*cdf0e10cSrcweir                 // too high (only then conversion to milliseconds and long
1970*cdf0e10cSrcweir                 // integer may lead to zero value.)
1971*cdf0e10cSrcweir                 OSL_ASSERT(static_cast<sal_uLong>(fUpdate * 1000.0) > 0);
1972*cdf0e10cSrcweir 
1973*cdf0e10cSrcweir                 Application::EnableNoYieldMode(false);
1974*cdf0e10cSrcweir                 Application::RemovePostYieldListener(LINK(this, SlideshowImpl, PostYieldListener));
1975*cdf0e10cSrcweir 
1976*cdf0e10cSrcweir                 // Use a timer for the asynchronous callback.
1977*cdf0e10cSrcweir                 maUpdateTimer.SetTimeout(static_cast<sal_uLong>(fUpdate * 1000.0));
1978*cdf0e10cSrcweir                 maUpdateTimer.Start();
1979*cdf0e10cSrcweir             }
1980*cdf0e10cSrcweir         }
1981*cdf0e10cSrcweir     }
1982*cdf0e10cSrcweir     catch( Exception& e )
1983*cdf0e10cSrcweir     {
1984*cdf0e10cSrcweir         static_cast<void>(e);
1985*cdf0e10cSrcweir         DBG_ERROR(
1986*cdf0e10cSrcweir             (OString("sd::SlideshowImpl::updateSlideShow(), exception caught: ")
1987*cdf0e10cSrcweir                 + rtl::OUStringToOString(
1988*cdf0e10cSrcweir                     comphelper::anyToString( cppu::getCaughtException() ),
1989*cdf0e10cSrcweir                     RTL_TEXTENCODING_UTF8 )).getStr() );
1990*cdf0e10cSrcweir     }
1991*cdf0e10cSrcweir     return 0;
1992*cdf0e10cSrcweir }
1993*cdf0e10cSrcweir 
1994*cdf0e10cSrcweir // ---------------------------------------------------------
1995*cdf0e10cSrcweir 
1996*cdf0e10cSrcweir bool SlideshowImpl::keyInput(const KeyEvent& rKEvt)
1997*cdf0e10cSrcweir {
1998*cdf0e10cSrcweir     if( !mxShow.is() || mbInputFreeze )
1999*cdf0e10cSrcweir         return false;
2000*cdf0e10cSrcweir 
2001*cdf0e10cSrcweir     bool bRet = true;
2002*cdf0e10cSrcweir 
2003*cdf0e10cSrcweir     try
2004*cdf0e10cSrcweir     {
2005*cdf0e10cSrcweir         const int nKeyCode = rKEvt.GetKeyCode().GetCode();
2006*cdf0e10cSrcweir         switch( nKeyCode )
2007*cdf0e10cSrcweir         {
2008*cdf0e10cSrcweir             case awt::Key::CONTEXTMENU:
2009*cdf0e10cSrcweir                 if( !mnContextMenuEvent )
2010*cdf0e10cSrcweir                 {
2011*cdf0e10cSrcweir                     if( mpShowWindow )
2012*cdf0e10cSrcweir                         maPopupMousePos = mpShowWindow->GetPointerState().maPos;
2013*cdf0e10cSrcweir                     mnContextMenuEvent = Application::PostUserEvent( LINK( this, SlideshowImpl, ContextMenuHdl ) );
2014*cdf0e10cSrcweir                 }
2015*cdf0e10cSrcweir                 break;
2016*cdf0e10cSrcweir 
2017*cdf0e10cSrcweir             // cancel show
2018*cdf0e10cSrcweir             case KEY_ESCAPE:
2019*cdf0e10cSrcweir             case KEY_SUBTRACT:
2020*cdf0e10cSrcweir                 // in case the user cancels the presentation, switch to current slide
2021*cdf0e10cSrcweir                 // in edit mode
2022*cdf0e10cSrcweir                 if( mpSlideController.get() && (ANIMATIONMODE_SHOW == meAnimationMode) )
2023*cdf0e10cSrcweir                 {
2024*cdf0e10cSrcweir                     if( mpSlideController->getCurrentSlideNumber() != -1 )
2025*cdf0e10cSrcweir                         mnRestoreSlide = mpSlideController->getCurrentSlideNumber();
2026*cdf0e10cSrcweir                 }
2027*cdf0e10cSrcweir                 endPresentation();
2028*cdf0e10cSrcweir                 break;
2029*cdf0e10cSrcweir 
2030*cdf0e10cSrcweir             // advance show
2031*cdf0e10cSrcweir             case KEY_PAGEDOWN:
2032*cdf0e10cSrcweir                 if(rKEvt.GetKeyCode().IsMod2())
2033*cdf0e10cSrcweir                 {
2034*cdf0e10cSrcweir                     gotoNextSlide();
2035*cdf0e10cSrcweir                     break;
2036*cdf0e10cSrcweir                 }
2037*cdf0e10cSrcweir                 // warning, fall through!
2038*cdf0e10cSrcweir             case KEY_SPACE:
2039*cdf0e10cSrcweir             case KEY_RIGHT:
2040*cdf0e10cSrcweir             case KEY_DOWN:
2041*cdf0e10cSrcweir             case KEY_N:
2042*cdf0e10cSrcweir                 gotoNextEffect();
2043*cdf0e10cSrcweir                 break;
2044*cdf0e10cSrcweir 
2045*cdf0e10cSrcweir             case KEY_RETURN:
2046*cdf0e10cSrcweir             {
2047*cdf0e10cSrcweir                 if( maCharBuffer.Len() )
2048*cdf0e10cSrcweir                 {
2049*cdf0e10cSrcweir                     if( mpSlideController.get() )
2050*cdf0e10cSrcweir                     {
2051*cdf0e10cSrcweir                         if( mpSlideController->jumpToSlideNumber( maCharBuffer.ToInt32() - 1 ) )
2052*cdf0e10cSrcweir                             displayCurrentSlide();
2053*cdf0e10cSrcweir                     }
2054*cdf0e10cSrcweir                     maCharBuffer.Erase();
2055*cdf0e10cSrcweir                 }
2056*cdf0e10cSrcweir                 else
2057*cdf0e10cSrcweir                 {
2058*cdf0e10cSrcweir                     gotoNextEffect();
2059*cdf0e10cSrcweir                 }
2060*cdf0e10cSrcweir             }
2061*cdf0e10cSrcweir             break;
2062*cdf0e10cSrcweir 
2063*cdf0e10cSrcweir             // numeric: add to buffer
2064*cdf0e10cSrcweir             case KEY_0:
2065*cdf0e10cSrcweir             case KEY_1:
2066*cdf0e10cSrcweir             case KEY_2:
2067*cdf0e10cSrcweir             case KEY_3:
2068*cdf0e10cSrcweir             case KEY_4:
2069*cdf0e10cSrcweir             case KEY_5:
2070*cdf0e10cSrcweir             case KEY_6:
2071*cdf0e10cSrcweir             case KEY_7:
2072*cdf0e10cSrcweir             case KEY_8:
2073*cdf0e10cSrcweir             case KEY_9:
2074*cdf0e10cSrcweir                 maCharBuffer.Append( rKEvt.GetCharCode() );
2075*cdf0e10cSrcweir                 break;
2076*cdf0e10cSrcweir 
2077*cdf0e10cSrcweir             case KEY_PAGEUP:
2078*cdf0e10cSrcweir                 if(rKEvt.GetKeyCode().IsMod2())
2079*cdf0e10cSrcweir                 {
2080*cdf0e10cSrcweir                     gotoPreviousSlide();
2081*cdf0e10cSrcweir                     break;
2082*cdf0e10cSrcweir                 }
2083*cdf0e10cSrcweir                 // warning, fall through!
2084*cdf0e10cSrcweir             case KEY_LEFT:
2085*cdf0e10cSrcweir             case KEY_UP:
2086*cdf0e10cSrcweir             case KEY_P:
2087*cdf0e10cSrcweir             case KEY_BACKSPACE:
2088*cdf0e10cSrcweir                 gotoPreviousEffect();
2089*cdf0e10cSrcweir                 break;
2090*cdf0e10cSrcweir 
2091*cdf0e10cSrcweir             case KEY_HOME:
2092*cdf0e10cSrcweir                 gotoFirstSlide();
2093*cdf0e10cSrcweir                 break;
2094*cdf0e10cSrcweir 
2095*cdf0e10cSrcweir             case KEY_END:
2096*cdf0e10cSrcweir                 gotoLastSlide();
2097*cdf0e10cSrcweir                 break;
2098*cdf0e10cSrcweir 
2099*cdf0e10cSrcweir             case KEY_B:
2100*cdf0e10cSrcweir             case KEY_W:
2101*cdf0e10cSrcweir             case KEY_POINT:
2102*cdf0e10cSrcweir             case KEY_COMMA:
2103*cdf0e10cSrcweir             {
2104*cdf0e10cSrcweir                 blankScreen( ((nKeyCode == KEY_W ) || (nKeyCode == KEY_COMMA)) ? 0x00ffffff : 0x00000000 );
2105*cdf0e10cSrcweir             }
2106*cdf0e10cSrcweir             break;
2107*cdf0e10cSrcweir 
2108*cdf0e10cSrcweir             default:
2109*cdf0e10cSrcweir                 bRet = false;
2110*cdf0e10cSrcweir             break;
2111*cdf0e10cSrcweir         }
2112*cdf0e10cSrcweir     }
2113*cdf0e10cSrcweir     catch( Exception& e )
2114*cdf0e10cSrcweir     {
2115*cdf0e10cSrcweir         bRet = false;
2116*cdf0e10cSrcweir         static_cast<void>(e);
2117*cdf0e10cSrcweir         DBG_ERROR(
2118*cdf0e10cSrcweir             (OString("sd::SlideshowImpl::keyInput(), "
2119*cdf0e10cSrcweir                     "exception caught: ") +
2120*cdf0e10cSrcweir             rtl::OUStringToOString(
2121*cdf0e10cSrcweir                 comphelper::anyToString( cppu::getCaughtException() ),
2122*cdf0e10cSrcweir                 RTL_TEXTENCODING_UTF8 )).getStr() );
2123*cdf0e10cSrcweir     }
2124*cdf0e10cSrcweir 
2125*cdf0e10cSrcweir     return bRet;
2126*cdf0e10cSrcweir }
2127*cdf0e10cSrcweir 
2128*cdf0e10cSrcweir IMPL_LINK( SlideshowImpl, EventListenerHdl, VclSimpleEvent*, pEvent )
2129*cdf0e10cSrcweir {
2130*cdf0e10cSrcweir     if( !mxShow.is() || mbInputFreeze )
2131*cdf0e10cSrcweir         return 0;
2132*cdf0e10cSrcweir 
2133*cdf0e10cSrcweir     if( pEvent && (pEvent->GetId() == VCLEVENT_WINDOW_COMMAND) && static_cast<VclWindowEvent*>(pEvent)->GetData() )
2134*cdf0e10cSrcweir     {
2135*cdf0e10cSrcweir         const CommandEvent& rEvent = *(const CommandEvent*)static_cast<VclWindowEvent*>(pEvent)->GetData();
2136*cdf0e10cSrcweir 
2137*cdf0e10cSrcweir         if( rEvent.GetCommand() == COMMAND_MEDIA )
2138*cdf0e10cSrcweir         {
2139*cdf0e10cSrcweir             switch( rEvent.GetMediaCommand() )
2140*cdf0e10cSrcweir             {
2141*cdf0e10cSrcweir #if defined( QUARTZ )
2142*cdf0e10cSrcweir             case MEDIA_COMMAND_MENU:
2143*cdf0e10cSrcweir                 if( !mnContextMenuEvent )
2144*cdf0e10cSrcweir                 {
2145*cdf0e10cSrcweir                 if( mpShowWindow )
2146*cdf0e10cSrcweir                     maPopupMousePos = mpShowWindow->GetPointerState().maPos;
2147*cdf0e10cSrcweir                 mnContextMenuEvent = Application::PostUserEvent( LINK( this, SlideshowImpl, ContextMenuHdl ) );
2148*cdf0e10cSrcweir                 }
2149*cdf0e10cSrcweir                 break;
2150*cdf0e10cSrcweir             case MEDIA_COMMAND_VOLUME_DOWN:
2151*cdf0e10cSrcweir                 gotoPreviousSlide();
2152*cdf0e10cSrcweir                 break;
2153*cdf0e10cSrcweir             case MEDIA_COMMAND_VOLUME_UP:
2154*cdf0e10cSrcweir                 gotoNextEffect();
2155*cdf0e10cSrcweir                 break;
2156*cdf0e10cSrcweir #endif
2157*cdf0e10cSrcweir             case MEDIA_COMMAND_NEXTTRACK:
2158*cdf0e10cSrcweir                 gotoNextEffect();
2159*cdf0e10cSrcweir                 break;
2160*cdf0e10cSrcweir             case MEDIA_COMMAND_PAUSE:
2161*cdf0e10cSrcweir                 if( !mbIsPaused )
2162*cdf0e10cSrcweir                     blankScreen(0);
2163*cdf0e10cSrcweir                 break;
2164*cdf0e10cSrcweir             case MEDIA_COMMAND_PLAY:
2165*cdf0e10cSrcweir                 if( mbIsPaused )
2166*cdf0e10cSrcweir                     resume();
2167*cdf0e10cSrcweir                 break;
2168*cdf0e10cSrcweir 
2169*cdf0e10cSrcweir             case MEDIA_COMMAND_PLAY_PAUSE:
2170*cdf0e10cSrcweir                 if( mbIsPaused )
2171*cdf0e10cSrcweir                     resume();
2172*cdf0e10cSrcweir                 else
2173*cdf0e10cSrcweir                     blankScreen(0);
2174*cdf0e10cSrcweir                 break;
2175*cdf0e10cSrcweir             case MEDIA_COMMAND_PREVIOUSTRACK:
2176*cdf0e10cSrcweir                 gotoPreviousSlide();
2177*cdf0e10cSrcweir                 break;
2178*cdf0e10cSrcweir             case MEDIA_COMMAND_NEXTTRACK_HOLD:
2179*cdf0e10cSrcweir                 gotoLastSlide();
2180*cdf0e10cSrcweir                 break;
2181*cdf0e10cSrcweir 
2182*cdf0e10cSrcweir             case MEDIA_COMMAND_REWIND:
2183*cdf0e10cSrcweir                 gotoFirstSlide();
2184*cdf0e10cSrcweir                 break;
2185*cdf0e10cSrcweir             case MEDIA_COMMAND_STOP:
2186*cdf0e10cSrcweir                 // in case the user cancels the presentation, switch to current slide
2187*cdf0e10cSrcweir                 // in edit mode
2188*cdf0e10cSrcweir                 if( mpSlideController.get() && (ANIMATIONMODE_SHOW == meAnimationMode) )
2189*cdf0e10cSrcweir                 {
2190*cdf0e10cSrcweir                     if( mpSlideController->getCurrentSlideNumber() != -1 )
2191*cdf0e10cSrcweir                         mnRestoreSlide = mpSlideController->getCurrentSlideNumber();
2192*cdf0e10cSrcweir                 }
2193*cdf0e10cSrcweir                 endPresentation();
2194*cdf0e10cSrcweir                 break;
2195*cdf0e10cSrcweir             }
2196*cdf0e10cSrcweir         }
2197*cdf0e10cSrcweir     }
2198*cdf0e10cSrcweir 
2199*cdf0e10cSrcweir     return 0;
2200*cdf0e10cSrcweir }
2201*cdf0e10cSrcweir 
2202*cdf0e10cSrcweir // ---------------------------------------------------------
2203*cdf0e10cSrcweir 
2204*cdf0e10cSrcweir void SlideshowImpl::mouseButtonUp(const MouseEvent& rMEvt)
2205*cdf0e10cSrcweir {
2206*cdf0e10cSrcweir     if( rMEvt.IsRight() && !mnContextMenuEvent )
2207*cdf0e10cSrcweir     {
2208*cdf0e10cSrcweir         maPopupMousePos = rMEvt.GetPosPixel();
2209*cdf0e10cSrcweir         mnContextMenuEvent = Application::PostUserEvent( LINK( this, SlideshowImpl, ContextMenuHdl ) );
2210*cdf0e10cSrcweir     }
2211*cdf0e10cSrcweir }
2212*cdf0e10cSrcweir 
2213*cdf0e10cSrcweir // ---------------------------------------------------------
2214*cdf0e10cSrcweir 
2215*cdf0e10cSrcweir IMPL_LINK( SlideshowImpl, ContextMenuHdl, void*, EMPTYARG )
2216*cdf0e10cSrcweir {
2217*cdf0e10cSrcweir     mnContextMenuEvent = 0;
2218*cdf0e10cSrcweir 
2219*cdf0e10cSrcweir     if( mpSlideController.get() == 0 )
2220*cdf0e10cSrcweir         return 0;
2221*cdf0e10cSrcweir 
2222*cdf0e10cSrcweir     mbWasPaused = mbIsPaused;
2223*cdf0e10cSrcweir     if( !mbWasPaused )
2224*cdf0e10cSrcweir         pause();
2225*cdf0e10cSrcweir 
2226*cdf0e10cSrcweir     PopupMenu* pMenu = new PopupMenu( SdResId( RID_SLIDESHOW_CONTEXTMENU ) );
2227*cdf0e10cSrcweir 
2228*cdf0e10cSrcweir     // Adding button to display if in Pen  mode
2229*cdf0e10cSrcweir     pMenu->CheckItem( CM_PEN_MODE, mbUsePen);
2230*cdf0e10cSrcweir 
2231*cdf0e10cSrcweir     const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode();
2232*cdf0e10cSrcweir     pMenu->EnableItem( CM_NEXT_SLIDE, ( mpSlideController->getNextSlideIndex() != -1 ) );
2233*cdf0e10cSrcweir     pMenu->EnableItem( CM_PREV_SLIDE, ( mpSlideController->getPreviousSlideIndex() != -1 ) || (eMode == SHOWWINDOWMODE_END) || (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) );
2234*cdf0e10cSrcweir 
2235*cdf0e10cSrcweir     PopupMenu* pPageMenu = pMenu->GetPopupMenu( CM_GOTO );
2236*cdf0e10cSrcweir 
2237*cdf0e10cSrcweir     SfxViewFrame* pViewFrame = getViewFrame();
2238*cdf0e10cSrcweir     if( pViewFrame )
2239*cdf0e10cSrcweir     {
2240*cdf0e10cSrcweir         Reference< ::com::sun::star::frame::XFrame > xFrame( pViewFrame->GetFrame().GetFrameInterface() );
2241*cdf0e10cSrcweir         if( xFrame.is() )
2242*cdf0e10cSrcweir         {
2243*cdf0e10cSrcweir             pMenu->SetItemImage( CM_NEXT_SLIDE, GetImage( xFrame, OUString( RTL_CONSTASCII_USTRINGPARAM( "slot:10617") ), sal_False, sal_False ) );
2244*cdf0e10cSrcweir             pMenu->SetItemImage( CM_PREV_SLIDE, GetImage( xFrame, OUString( RTL_CONSTASCII_USTRINGPARAM( "slot:10618") ), sal_False, sal_False ) );
2245*cdf0e10cSrcweir 
2246*cdf0e10cSrcweir             if( pPageMenu )
2247*cdf0e10cSrcweir             {
2248*cdf0e10cSrcweir                 pPageMenu->SetItemImage( CM_FIRST_SLIDE, GetImage( xFrame, OUString( RTL_CONSTASCII_USTRINGPARAM( "slot:10616") ), sal_False, sal_False ) );
2249*cdf0e10cSrcweir                 pPageMenu->SetItemImage( CM_LAST_SLIDE, GetImage( xFrame, OUString( RTL_CONSTASCII_USTRINGPARAM( "slot:10619") ), sal_False, sal_False ) );
2250*cdf0e10cSrcweir             }
2251*cdf0e10cSrcweir         }
2252*cdf0e10cSrcweir     }
2253*cdf0e10cSrcweir 
2254*cdf0e10cSrcweir     // populate slide goto list
2255*cdf0e10cSrcweir     if( pPageMenu )
2256*cdf0e10cSrcweir     {
2257*cdf0e10cSrcweir         const sal_Int32 nPageNumberCount = mpSlideController->getSlideNumberCount();
2258*cdf0e10cSrcweir         if( nPageNumberCount <= 1 )
2259*cdf0e10cSrcweir         {
2260*cdf0e10cSrcweir             pMenu->EnableItem( CM_GOTO, sal_False );
2261*cdf0e10cSrcweir         }
2262*cdf0e10cSrcweir         else
2263*cdf0e10cSrcweir         {
2264*cdf0e10cSrcweir             sal_Int32 nCurrentSlideNumber = mpSlideController->getCurrentSlideNumber();
2265*cdf0e10cSrcweir             if( (eMode == SHOWWINDOWMODE_END) || (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) )
2266*cdf0e10cSrcweir                 nCurrentSlideNumber = -1;
2267*cdf0e10cSrcweir 
2268*cdf0e10cSrcweir             pPageMenu->EnableItem( CM_FIRST_SLIDE, ( mpSlideController->getSlideNumber(0) != nCurrentSlideNumber ) );
2269*cdf0e10cSrcweir             pPageMenu->EnableItem( CM_LAST_SLIDE, ( mpSlideController->getSlideNumber( mpSlideController->getSlideIndexCount() - 1) != nCurrentSlideNumber ) );
2270*cdf0e10cSrcweir 
2271*cdf0e10cSrcweir             sal_Int32 nPageNumber;
2272*cdf0e10cSrcweir 
2273*cdf0e10cSrcweir             for( nPageNumber = 0; nPageNumber < nPageNumberCount; nPageNumber++ )
2274*cdf0e10cSrcweir             {
2275*cdf0e10cSrcweir                 if( mpSlideController->isVisibleSlideNumber( nPageNumber ) )
2276*cdf0e10cSrcweir                 {
2277*cdf0e10cSrcweir                     SdPage* pPage = mpDoc->GetSdPage((sal_uInt16)nPageNumber, PK_STANDARD);
2278*cdf0e10cSrcweir                     if (pPage)
2279*cdf0e10cSrcweir                     {
2280*cdf0e10cSrcweir                         pPageMenu->InsertItem( (sal_uInt16)(CM_SLIDES + nPageNumber), pPage->GetName() );
2281*cdf0e10cSrcweir                         if( nPageNumber == nCurrentSlideNumber )
2282*cdf0e10cSrcweir                             pPageMenu->CheckItem( (sal_uInt16)(CM_SLIDES + nPageNumber) );
2283*cdf0e10cSrcweir                     }
2284*cdf0e10cSrcweir                 }
2285*cdf0e10cSrcweir             }
2286*cdf0e10cSrcweir         }
2287*cdf0e10cSrcweir     }
2288*cdf0e10cSrcweir 
2289*cdf0e10cSrcweir     if( mpShowWindow->GetShowWindowMode() == SHOWWINDOWMODE_BLANK )
2290*cdf0e10cSrcweir     {
2291*cdf0e10cSrcweir         PopupMenu* pBlankMenu = pMenu->GetPopupMenu( CM_SCREEN );
2292*cdf0e10cSrcweir         if( pBlankMenu )
2293*cdf0e10cSrcweir         {
2294*cdf0e10cSrcweir             pBlankMenu->CheckItem( ( mpShowWindow->GetBlankColor() == Color( COL_WHITE ) ) ? CM_SCREEN_WHITE : CM_SCREEN_BLACK  );
2295*cdf0e10cSrcweir         }
2296*cdf0e10cSrcweir     }
2297*cdf0e10cSrcweir 
2298*cdf0e10cSrcweir     PopupMenu* pWidthMenu = pMenu->GetPopupMenu( CM_WIDTH_PEN);
2299*cdf0e10cSrcweir 
2300*cdf0e10cSrcweir     // populate color width list
2301*cdf0e10cSrcweir     if( pWidthMenu )
2302*cdf0e10cSrcweir     {
2303*cdf0e10cSrcweir         sal_Int32 nIterator;
2304*cdf0e10cSrcweir         double nWidth;
2305*cdf0e10cSrcweir 
2306*cdf0e10cSrcweir         nWidth = 4.0;
2307*cdf0e10cSrcweir         for( nIterator = 1; nIterator < 6; nIterator++)
2308*cdf0e10cSrcweir         {
2309*cdf0e10cSrcweir             switch(nIterator)
2310*cdf0e10cSrcweir             {
2311*cdf0e10cSrcweir                 case 1:
2312*cdf0e10cSrcweir                     nWidth = 4.0;
2313*cdf0e10cSrcweir                     break;
2314*cdf0e10cSrcweir                 case 2:
2315*cdf0e10cSrcweir                     nWidth = 100.0;
2316*cdf0e10cSrcweir                     break;
2317*cdf0e10cSrcweir                 case 3:
2318*cdf0e10cSrcweir                     nWidth = 150.0;
2319*cdf0e10cSrcweir                     break;
2320*cdf0e10cSrcweir                 case 4:
2321*cdf0e10cSrcweir                     nWidth = 200.0;
2322*cdf0e10cSrcweir                     break;
2323*cdf0e10cSrcweir                 case 5:
2324*cdf0e10cSrcweir                     nWidth = 400.0;
2325*cdf0e10cSrcweir                     break;
2326*cdf0e10cSrcweir                 default:
2327*cdf0e10cSrcweir                     break;
2328*cdf0e10cSrcweir             }
2329*cdf0e10cSrcweir 
2330*cdf0e10cSrcweir             pWidthMenu->EnableItem( (sal_uInt16)(CM_WIDTH_PEN + nIterator), sal_True);
2331*cdf0e10cSrcweir             if( nWidth ==  mdUserPaintStrokeWidth)
2332*cdf0e10cSrcweir                 pWidthMenu->CheckItem( (sal_uInt16)(CM_WIDTH_PEN + nIterator) );
2333*cdf0e10cSrcweir         }
2334*cdf0e10cSrcweir     }
2335*cdf0e10cSrcweir 
2336*cdf0e10cSrcweir     pMenu->SetSelectHdl( LINK( this, SlideshowImpl, ContextMenuSelectHdl ) );
2337*cdf0e10cSrcweir     pMenu->Execute( mpShowWindow, maPopupMousePos );
2338*cdf0e10cSrcweir     delete pMenu;
2339*cdf0e10cSrcweir 
2340*cdf0e10cSrcweir     if( mxView.is() )
2341*cdf0e10cSrcweir         mxView->ignoreNextMouseReleased();
2342*cdf0e10cSrcweir 
2343*cdf0e10cSrcweir     if( !mbWasPaused )
2344*cdf0e10cSrcweir         resume();
2345*cdf0e10cSrcweir     return 0;
2346*cdf0e10cSrcweir }
2347*cdf0e10cSrcweir 
2348*cdf0e10cSrcweir // ---------------------------------------------------------
2349*cdf0e10cSrcweir 
2350*cdf0e10cSrcweir IMPL_LINK( SlideshowImpl, ContextMenuSelectHdl, Menu *, pMenu )
2351*cdf0e10cSrcweir {
2352*cdf0e10cSrcweir     if( pMenu )
2353*cdf0e10cSrcweir     {
2354*cdf0e10cSrcweir         sal_uInt16 nMenuId = pMenu->GetCurItemId();
2355*cdf0e10cSrcweir 
2356*cdf0e10cSrcweir         switch( nMenuId )
2357*cdf0e10cSrcweir         {
2358*cdf0e10cSrcweir         case CM_PREV_SLIDE:
2359*cdf0e10cSrcweir             gotoPreviousSlide();
2360*cdf0e10cSrcweir             mbWasPaused = false;
2361*cdf0e10cSrcweir             break;
2362*cdf0e10cSrcweir         case CM_NEXT_SLIDE:
2363*cdf0e10cSrcweir             gotoNextSlide();
2364*cdf0e10cSrcweir             mbWasPaused = false;
2365*cdf0e10cSrcweir             break;
2366*cdf0e10cSrcweir         case CM_FIRST_SLIDE:
2367*cdf0e10cSrcweir             gotoFirstSlide();
2368*cdf0e10cSrcweir             mbWasPaused = false;
2369*cdf0e10cSrcweir             break;
2370*cdf0e10cSrcweir         case CM_LAST_SLIDE:
2371*cdf0e10cSrcweir             gotoLastSlide();
2372*cdf0e10cSrcweir             mbWasPaused = false;
2373*cdf0e10cSrcweir             break;
2374*cdf0e10cSrcweir         case CM_SCREEN_BLACK:
2375*cdf0e10cSrcweir         case CM_SCREEN_WHITE:
2376*cdf0e10cSrcweir         {
2377*cdf0e10cSrcweir             const Color aBlankColor( (nMenuId == CM_SCREEN_WHITE) ? COL_WHITE : COL_BLACK );
2378*cdf0e10cSrcweir             if( mbWasPaused )
2379*cdf0e10cSrcweir             {
2380*cdf0e10cSrcweir                 if( mpShowWindow->GetShowWindowMode() == SHOWWINDOWMODE_BLANK )
2381*cdf0e10cSrcweir                 {
2382*cdf0e10cSrcweir                     if( mpShowWindow->GetBlankColor() == aBlankColor )
2383*cdf0e10cSrcweir                     {
2384*cdf0e10cSrcweir                         mbWasPaused = false;
2385*cdf0e10cSrcweir                         mpShowWindow->RestartShow();
2386*cdf0e10cSrcweir                         break;
2387*cdf0e10cSrcweir                     }
2388*cdf0e10cSrcweir                 }
2389*cdf0e10cSrcweir                 mpShowWindow->RestartShow();
2390*cdf0e10cSrcweir             }
2391*cdf0e10cSrcweir             if( mpShowWindow->SetBlankMode( mpSlideController->getCurrentSlideIndex(), aBlankColor ) )
2392*cdf0e10cSrcweir             {
2393*cdf0e10cSrcweir                 pause();
2394*cdf0e10cSrcweir                 mbWasPaused = true;
2395*cdf0e10cSrcweir             }
2396*cdf0e10cSrcweir         }
2397*cdf0e10cSrcweir         break;
2398*cdf0e10cSrcweir         case CM_COLOR_PEN:
2399*cdf0e10cSrcweir             {
2400*cdf0e10cSrcweir                 //Open a color picker based on SvColorDialog
2401*cdf0e10cSrcweir                 ::Color aColor( mnUserPaintColor );
2402*cdf0e10cSrcweir                 SvColorDialog aColorDlg( mpShowWindow);
2403*cdf0e10cSrcweir                 aColorDlg.SetColor( aColor );
2404*cdf0e10cSrcweir 
2405*cdf0e10cSrcweir                 if (aColorDlg.Execute() )
2406*cdf0e10cSrcweir                 {
2407*cdf0e10cSrcweir                     aColor = aColorDlg.GetColor();
2408*cdf0e10cSrcweir                     setPenColor(aColor.GetColor());
2409*cdf0e10cSrcweir                 }
2410*cdf0e10cSrcweir                 mbWasPaused = false;
2411*cdf0e10cSrcweir             }
2412*cdf0e10cSrcweir             break;
2413*cdf0e10cSrcweir 
2414*cdf0e10cSrcweir         case CM_WIDTH_PEN_VERY_THIN:
2415*cdf0e10cSrcweir             {
2416*cdf0e10cSrcweir                 setPenWidth(4.0);
2417*cdf0e10cSrcweir                 mbWasPaused = false;
2418*cdf0e10cSrcweir             }
2419*cdf0e10cSrcweir             break;
2420*cdf0e10cSrcweir 
2421*cdf0e10cSrcweir         case CM_WIDTH_PEN_THIN:
2422*cdf0e10cSrcweir             {
2423*cdf0e10cSrcweir                 setPenWidth(100.0);
2424*cdf0e10cSrcweir                 mbWasPaused = false;
2425*cdf0e10cSrcweir             }
2426*cdf0e10cSrcweir             break;
2427*cdf0e10cSrcweir 
2428*cdf0e10cSrcweir         case CM_WIDTH_PEN_NORMAL:
2429*cdf0e10cSrcweir             {
2430*cdf0e10cSrcweir                 setPenWidth(150.0);
2431*cdf0e10cSrcweir                 mbWasPaused = false;
2432*cdf0e10cSrcweir             }
2433*cdf0e10cSrcweir             break;
2434*cdf0e10cSrcweir 
2435*cdf0e10cSrcweir         case CM_WIDTH_PEN_THICK:
2436*cdf0e10cSrcweir             {
2437*cdf0e10cSrcweir                 setPenWidth(200.0);
2438*cdf0e10cSrcweir                 mbWasPaused = false;
2439*cdf0e10cSrcweir             }
2440*cdf0e10cSrcweir             break;
2441*cdf0e10cSrcweir 
2442*cdf0e10cSrcweir         case CM_WIDTH_PEN_VERY_THICK:
2443*cdf0e10cSrcweir             {
2444*cdf0e10cSrcweir                 setPenWidth(400.0);
2445*cdf0e10cSrcweir                 mbWasPaused = false;
2446*cdf0e10cSrcweir             }
2447*cdf0e10cSrcweir             break;
2448*cdf0e10cSrcweir         case CM_ERASE_ALLINK:
2449*cdf0e10cSrcweir             {
2450*cdf0e10cSrcweir                 setEraseAllInk(true);
2451*cdf0e10cSrcweir                 mbWasPaused = false;
2452*cdf0e10cSrcweir             }
2453*cdf0e10cSrcweir             break;
2454*cdf0e10cSrcweir         case CM_PEN_MODE:
2455*cdf0e10cSrcweir             {
2456*cdf0e10cSrcweir                 setUsePen(!mbUsePen);
2457*cdf0e10cSrcweir                 mbWasPaused = false;
2458*cdf0e10cSrcweir             }
2459*cdf0e10cSrcweir             break;
2460*cdf0e10cSrcweir         case CM_ENDSHOW:
2461*cdf0e10cSrcweir             // in case the user cancels the presentation, switch to current slide
2462*cdf0e10cSrcweir             // in edit mode
2463*cdf0e10cSrcweir             if( mpSlideController.get() && (ANIMATIONMODE_SHOW == meAnimationMode) )
2464*cdf0e10cSrcweir             {
2465*cdf0e10cSrcweir                 if( mpSlideController->getCurrentSlideNumber() != -1 )
2466*cdf0e10cSrcweir                 {
2467*cdf0e10cSrcweir                     mnRestoreSlide = mpSlideController->getCurrentSlideNumber();
2468*cdf0e10cSrcweir                 }
2469*cdf0e10cSrcweir             }
2470*cdf0e10cSrcweir             endPresentation();
2471*cdf0e10cSrcweir             break;
2472*cdf0e10cSrcweir         default:
2473*cdf0e10cSrcweir             sal_Int32 nPageNumber = nMenuId - CM_SLIDES;
2474*cdf0e10cSrcweir             const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode();
2475*cdf0e10cSrcweir             if( (eMode == SHOWWINDOWMODE_END) || (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) )
2476*cdf0e10cSrcweir             {
2477*cdf0e10cSrcweir                 mpShowWindow->RestartShow( nPageNumber );
2478*cdf0e10cSrcweir             }
2479*cdf0e10cSrcweir             else if( nPageNumber != mpSlideController->getCurrentSlideNumber() )
2480*cdf0e10cSrcweir             {
2481*cdf0e10cSrcweir                 displaySlideNumber( nPageNumber );
2482*cdf0e10cSrcweir             }
2483*cdf0e10cSrcweir             mbWasPaused = false;
2484*cdf0e10cSrcweir             break;
2485*cdf0e10cSrcweir         }
2486*cdf0e10cSrcweir     }
2487*cdf0e10cSrcweir 
2488*cdf0e10cSrcweir     return 0;
2489*cdf0e10cSrcweir }
2490*cdf0e10cSrcweir 
2491*cdf0e10cSrcweir // ---------------------------------------------------------
2492*cdf0e10cSrcweir 
2493*cdf0e10cSrcweir Reference< XSlideShow > SlideshowImpl::createSlideShow() const
2494*cdf0e10cSrcweir {
2495*cdf0e10cSrcweir     Reference< XSlideShow > xShow;
2496*cdf0e10cSrcweir 
2497*cdf0e10cSrcweir     try
2498*cdf0e10cSrcweir     {
2499*cdf0e10cSrcweir         Reference< lang::XMultiServiceFactory > xFactory(
2500*cdf0e10cSrcweir             ::comphelper::getProcessServiceFactory(),
2501*cdf0e10cSrcweir             UNO_QUERY_THROW );
2502*cdf0e10cSrcweir 
2503*cdf0e10cSrcweir         Reference< XInterface > xInt( xFactory->createInstance(
2504*cdf0e10cSrcweir                 OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.SlideShow")) ) );
2505*cdf0e10cSrcweir 
2506*cdf0e10cSrcweir         xShow.set( xInt, UNO_QUERY_THROW );
2507*cdf0e10cSrcweir     }
2508*cdf0e10cSrcweir     catch( uno::Exception& e )
2509*cdf0e10cSrcweir     {
2510*cdf0e10cSrcweir         (void)e;
2511*cdf0e10cSrcweir         DBG_ERROR(
2512*cdf0e10cSrcweir             (OString("sd::SlideshowImpl::createSlideShow(), "
2513*cdf0e10cSrcweir                      "exception caught: ") +
2514*cdf0e10cSrcweir              rtl::OUStringToOString(
2515*cdf0e10cSrcweir                  comphelper::anyToString( cppu::getCaughtException() ),
2516*cdf0e10cSrcweir                  RTL_TEXTENCODING_UTF8 )).getStr() );
2517*cdf0e10cSrcweir     }
2518*cdf0e10cSrcweir 
2519*cdf0e10cSrcweir     return xShow;
2520*cdf0e10cSrcweir }
2521*cdf0e10cSrcweir 
2522*cdf0e10cSrcweir // ---------------------------------------------------------
2523*cdf0e10cSrcweir 
2524*cdf0e10cSrcweir void SlideshowImpl::createSlideList( bool bAll, bool bStartWithActualSlide, const String& rPresSlide )
2525*cdf0e10cSrcweir {
2526*cdf0e10cSrcweir     const long nSlideCount = mpDoc->GetSdPageCount( PK_STANDARD );
2527*cdf0e10cSrcweir 
2528*cdf0e10cSrcweir     if( nSlideCount )
2529*cdf0e10cSrcweir     {
2530*cdf0e10cSrcweir         SdCustomShow*   pCustomShow;
2531*cdf0e10cSrcweir 
2532*cdf0e10cSrcweir         if( !bStartWithActualSlide && mpDoc->GetCustomShowList() && maPresSettings.mbCustomShow )
2533*cdf0e10cSrcweir             pCustomShow = (SdCustomShow*) mpDoc->GetCustomShowList()->GetCurObject();
2534*cdf0e10cSrcweir         else
2535*cdf0e10cSrcweir             pCustomShow = NULL;
2536*cdf0e10cSrcweir 
2537*cdf0e10cSrcweir         // create animation slide controller
2538*cdf0e10cSrcweir         AnimationSlideController::Mode eMode =
2539*cdf0e10cSrcweir             ( pCustomShow && pCustomShow->Count() ) ? AnimationSlideController::CUSTOM :
2540*cdf0e10cSrcweir                 (bAll ? AnimationSlideController::ALL : AnimationSlideController::FROM);
2541*cdf0e10cSrcweir 
2542*cdf0e10cSrcweir         Reference< XDrawPagesSupplier > xDrawPages( mpDoc->getUnoModel(), UNO_QUERY_THROW );
2543*cdf0e10cSrcweir         Reference< XIndexAccess > xSlides( xDrawPages->getDrawPages(), UNO_QUERY_THROW );
2544*cdf0e10cSrcweir         mpSlideController.reset( new AnimationSlideController( xSlides, eMode ) );
2545*cdf0e10cSrcweir 
2546*cdf0e10cSrcweir         if( eMode != AnimationSlideController::CUSTOM )
2547*cdf0e10cSrcweir         {
2548*cdf0e10cSrcweir             sal_Int32 nFirstSlide = 0;
2549*cdf0e10cSrcweir 
2550*cdf0e10cSrcweir             // normale Praesentation
2551*cdf0e10cSrcweir             if( eMode == AnimationSlideController::FROM )
2552*cdf0e10cSrcweir             {
2553*cdf0e10cSrcweir                 if( rPresSlide.Len() )
2554*cdf0e10cSrcweir                 {
2555*cdf0e10cSrcweir                     sal_Int32 nSlide;
2556*cdf0e10cSrcweir                     sal_Bool bTakeNextAvailable = sal_False;
2557*cdf0e10cSrcweir 
2558*cdf0e10cSrcweir                     for( nSlide = 0, nFirstSlide = -1; ( nSlide < nSlideCount ) && ( -1 == nFirstSlide ); nSlide++ )
2559*cdf0e10cSrcweir                     {
2560*cdf0e10cSrcweir                         SdPage* pTestSlide = mpDoc->GetSdPage( (sal_uInt16)nSlide, PK_STANDARD );
2561*cdf0e10cSrcweir 
2562*cdf0e10cSrcweir                         if( pTestSlide->GetName() == rPresSlide )
2563*cdf0e10cSrcweir                         {
2564*cdf0e10cSrcweir                             if( pTestSlide->IsExcluded() )
2565*cdf0e10cSrcweir                                 bTakeNextAvailable = sal_True;
2566*cdf0e10cSrcweir                             else
2567*cdf0e10cSrcweir                                 nFirstSlide = nSlide;
2568*cdf0e10cSrcweir                         }
2569*cdf0e10cSrcweir                         else if( bTakeNextAvailable && !pTestSlide->IsExcluded() )
2570*cdf0e10cSrcweir                             nFirstSlide = nSlide;
2571*cdf0e10cSrcweir                     }
2572*cdf0e10cSrcweir 
2573*cdf0e10cSrcweir                     if( -1 == nFirstSlide )
2574*cdf0e10cSrcweir                         nFirstSlide = 0;
2575*cdf0e10cSrcweir                 }
2576*cdf0e10cSrcweir             }
2577*cdf0e10cSrcweir 
2578*cdf0e10cSrcweir             for( sal_Int32 i = 0; i < nSlideCount; i++ )
2579*cdf0e10cSrcweir             {
2580*cdf0e10cSrcweir                 bool bVisible = ( mpDoc->GetSdPage( (sal_uInt16)i, PK_STANDARD ) )->IsExcluded() ? false : true;
2581*cdf0e10cSrcweir                 if( bVisible || (eMode == AnimationSlideController::ALL) )
2582*cdf0e10cSrcweir                     mpSlideController->insertSlideNumber( i, bVisible );
2583*cdf0e10cSrcweir             }
2584*cdf0e10cSrcweir 
2585*cdf0e10cSrcweir             mpSlideController->setStartSlideNumber( nFirstSlide );
2586*cdf0e10cSrcweir         }
2587*cdf0e10cSrcweir         else
2588*cdf0e10cSrcweir         {
2589*cdf0e10cSrcweir             if( meAnimationMode != ANIMATIONMODE_SHOW && rPresSlide.Len() )
2590*cdf0e10cSrcweir             {
2591*cdf0e10cSrcweir                 sal_Int32 nSlide;
2592*cdf0e10cSrcweir                 for( nSlide = 0; nSlide < nSlideCount; nSlide++ )
2593*cdf0e10cSrcweir                     if( rPresSlide == mpDoc->GetSdPage( (sal_uInt16) nSlide, PK_STANDARD )->GetName() )
2594*cdf0e10cSrcweir                         break;
2595*cdf0e10cSrcweir 
2596*cdf0e10cSrcweir                 if( nSlide < nSlideCount )
2597*cdf0e10cSrcweir                     mpSlideController->insertSlideNumber( (sal_uInt16) nSlide );
2598*cdf0e10cSrcweir             }
2599*cdf0e10cSrcweir 
2600*cdf0e10cSrcweir             void* pCustomSlide;
2601*cdf0e10cSrcweir             sal_Int32 nSlideIndex;
2602*cdf0e10cSrcweir             for( pCustomSlide = pCustomShow->First(),nSlideIndex=0; pCustomSlide; pCustomSlide = pCustomShow->Next(), nSlideIndex++ )
2603*cdf0e10cSrcweir             {
2604*cdf0e10cSrcweir                 const sal_uInt16 nSdSlide = ( ( (SdPage*) pCustomSlide )->GetPageNum() - 1 ) / 2;
2605*cdf0e10cSrcweir 
2606*cdf0e10cSrcweir                 if( !( mpDoc->GetSdPage( nSdSlide, PK_STANDARD ) )->IsExcluded())
2607*cdf0e10cSrcweir                     mpSlideController->insertSlideNumber( nSdSlide );
2608*cdf0e10cSrcweir             }
2609*cdf0e10cSrcweir         }
2610*cdf0e10cSrcweir     }
2611*cdf0e10cSrcweir }
2612*cdf0e10cSrcweir 
2613*cdf0e10cSrcweir // ---------------------------------------------------------
2614*cdf0e10cSrcweir 
2615*cdf0e10cSrcweir typedef sal_uInt16 (*FncGetChildWindowId)();
2616*cdf0e10cSrcweir 
2617*cdf0e10cSrcweir FncGetChildWindowId aShowChilds[] =
2618*cdf0e10cSrcweir {
2619*cdf0e10cSrcweir     &AnimationChildWindow::GetChildWindowId,
2620*cdf0e10cSrcweir     &Svx3DChildWindow::GetChildWindowId,
2621*cdf0e10cSrcweir     &SvxFontWorkChildWindow::GetChildWindowId,
2622*cdf0e10cSrcweir     &SvxColorChildWindow::GetChildWindowId,
2623*cdf0e10cSrcweir     &SvxSearchDialogWrapper::GetChildWindowId,
2624*cdf0e10cSrcweir     &SvxBmpMaskChildWindow::GetChildWindowId,
2625*cdf0e10cSrcweir     &SvxIMapDlgChildWindow::GetChildWindowId,
2626*cdf0e10cSrcweir     &SvxHyperlinkDlgWrapper::GetChildWindowId,
2627*cdf0e10cSrcweir     &SvxHlinkDlgWrapper::GetChildWindowId,
2628*cdf0e10cSrcweir     &SfxTemplateDialogWrapper::GetChildWindowId,
2629*cdf0e10cSrcweir     &GalleryChildWindow::GetChildWindowId
2630*cdf0e10cSrcweir };
2631*cdf0e10cSrcweir 
2632*cdf0e10cSrcweir #define NAVIGATOR_CHILD_MASK        0x80000000UL
2633*cdf0e10cSrcweir 
2634*cdf0e10cSrcweir void SlideshowImpl::hideChildWindows()
2635*cdf0e10cSrcweir {
2636*cdf0e10cSrcweir     mnChildMask = 0UL;
2637*cdf0e10cSrcweir 
2638*cdf0e10cSrcweir     if( ANIMATIONMODE_SHOW == meAnimationMode )
2639*cdf0e10cSrcweir     {
2640*cdf0e10cSrcweir         SfxViewFrame* pViewFrame = getViewFrame();
2641*cdf0e10cSrcweir 
2642*cdf0e10cSrcweir         if( pViewFrame )
2643*cdf0e10cSrcweir         {
2644*cdf0e10cSrcweir             if( pViewFrame->GetChildWindow( SID_NAVIGATOR ) != NULL )
2645*cdf0e10cSrcweir                 mnChildMask |= NAVIGATOR_CHILD_MASK;
2646*cdf0e10cSrcweir 
2647*cdf0e10cSrcweir             for( sal_uLong i = 0, nCount = sizeof( aShowChilds ) / sizeof( FncGetChildWindowId ); i < nCount; i++ )
2648*cdf0e10cSrcweir             {
2649*cdf0e10cSrcweir                 const sal_uInt16 nId = ( *aShowChilds[ i ] )();
2650*cdf0e10cSrcweir 
2651*cdf0e10cSrcweir                 if( pViewFrame->GetChildWindow( nId ) )
2652*cdf0e10cSrcweir                 {
2653*cdf0e10cSrcweir                     pViewFrame->SetChildWindow( nId, sal_False );
2654*cdf0e10cSrcweir                     mnChildMask |= 1 << i;
2655*cdf0e10cSrcweir                 }
2656*cdf0e10cSrcweir             }
2657*cdf0e10cSrcweir         }
2658*cdf0e10cSrcweir     }
2659*cdf0e10cSrcweir }
2660*cdf0e10cSrcweir 
2661*cdf0e10cSrcweir // ---------------------------------------------------------
2662*cdf0e10cSrcweir 
2663*cdf0e10cSrcweir void SlideshowImpl::showChildWindows()
2664*cdf0e10cSrcweir {
2665*cdf0e10cSrcweir     if( ANIMATIONMODE_SHOW == meAnimationMode )
2666*cdf0e10cSrcweir     {
2667*cdf0e10cSrcweir         SfxViewFrame* pViewFrame = getViewFrame();
2668*cdf0e10cSrcweir         if( pViewFrame )
2669*cdf0e10cSrcweir         {
2670*cdf0e10cSrcweir             pViewFrame->SetChildWindow( SID_NAVIGATOR, ( mnChildMask & NAVIGATOR_CHILD_MASK ) != 0 );
2671*cdf0e10cSrcweir 
2672*cdf0e10cSrcweir             for( sal_uLong i = 0, nCount = sizeof( aShowChilds ) / sizeof( FncGetChildWindowId ); i < nCount; i++ )
2673*cdf0e10cSrcweir             {
2674*cdf0e10cSrcweir                 if( mnChildMask & ( 1 << i ) )
2675*cdf0e10cSrcweir                     pViewFrame->SetChildWindow( ( *aShowChilds[ i ] )(), sal_True );
2676*cdf0e10cSrcweir             }
2677*cdf0e10cSrcweir         }
2678*cdf0e10cSrcweir     }
2679*cdf0e10cSrcweir }
2680*cdf0e10cSrcweir 
2681*cdf0e10cSrcweir // ---------------------------------------------------------
2682*cdf0e10cSrcweir 
2683*cdf0e10cSrcweir SfxViewFrame* SlideshowImpl::getViewFrame() const
2684*cdf0e10cSrcweir {
2685*cdf0e10cSrcweir     return mpViewShell ? mpViewShell->GetViewFrame() : 0;
2686*cdf0e10cSrcweir }
2687*cdf0e10cSrcweir 
2688*cdf0e10cSrcweir // ---------------------------------------------------------
2689*cdf0e10cSrcweir 
2690*cdf0e10cSrcweir SfxDispatcher* SlideshowImpl::getDispatcher() const
2691*cdf0e10cSrcweir {
2692*cdf0e10cSrcweir     return (mpViewShell && mpViewShell->GetViewFrame()) ? mpViewShell->GetViewFrame()->GetDispatcher() : 0;
2693*cdf0e10cSrcweir }
2694*cdf0e10cSrcweir 
2695*cdf0e10cSrcweir // ---------------------------------------------------------
2696*cdf0e10cSrcweir 
2697*cdf0e10cSrcweir SfxBindings* SlideshowImpl::getBindings() const
2698*cdf0e10cSrcweir {
2699*cdf0e10cSrcweir     return (mpViewShell && mpViewShell->GetViewFrame()) ? &mpViewShell->GetViewFrame()->GetBindings() : 0;
2700*cdf0e10cSrcweir }
2701*cdf0e10cSrcweir 
2702*cdf0e10cSrcweir // ---------------------------------------------------------
2703*cdf0e10cSrcweir 
2704*cdf0e10cSrcweir void SlideshowImpl::resize( const Size& rSize )
2705*cdf0e10cSrcweir {
2706*cdf0e10cSrcweir     maPresSize = rSize;
2707*cdf0e10cSrcweir 
2708*cdf0e10cSrcweir     if( mpShowWindow && (ANIMATIONMODE_VIEW != meAnimationMode) )
2709*cdf0e10cSrcweir     {
2710*cdf0e10cSrcweir         mpShowWindow->SetSizePixel( maPresSize );
2711*cdf0e10cSrcweir         mpShowWindow->Show();
2712*cdf0e10cSrcweir 
2713*cdf0e10cSrcweir         // Call ToTop() to bring the window to top if
2714*cdf0e10cSrcweir         // a) the old size is not degenerate (then the window will be closed
2715*cdf0e10cSrcweir         // soon) and
2716*cdf0e10cSrcweir         // b) the animation mode is not that of a preview (on the one hand
2717*cdf0e10cSrcweir         // this leaves the old behaviour for the slide show mode unmodified
2718*cdf0e10cSrcweir         // and on the other hand does not move the focus from the document
2719*cdf0e10cSrcweir         // to the (preview) window; the ToTop() seems not to be necessary at
2720*cdf0e10cSrcweir         // least for the preview).
2721*cdf0e10cSrcweir //        if( !aOldSize.Width() && !aOldSize.Height() )
2722*cdf0e10cSrcweir //          mpShowWindow->ToTop();
2723*cdf0e10cSrcweir     }
2724*cdf0e10cSrcweir 
2725*cdf0e10cSrcweir     if( mxView.is() ) try
2726*cdf0e10cSrcweir     {
2727*cdf0e10cSrcweir         awt::WindowEvent aEvt;
2728*cdf0e10cSrcweir         mxView->windowResized(aEvt);
2729*cdf0e10cSrcweir     }
2730*cdf0e10cSrcweir     catch( Exception& e )
2731*cdf0e10cSrcweir     {
2732*cdf0e10cSrcweir         static_cast<void>(e);
2733*cdf0e10cSrcweir         DBG_ERROR(
2734*cdf0e10cSrcweir             (OString("sd::SlideshowImpl::resize(), "
2735*cdf0e10cSrcweir                     "exception caught: ") +
2736*cdf0e10cSrcweir             rtl::OUStringToOString(
2737*cdf0e10cSrcweir                 comphelper::anyToString( cppu::getCaughtException() ),
2738*cdf0e10cSrcweir                 RTL_TEXTENCODING_UTF8 )).getStr() );
2739*cdf0e10cSrcweir     }
2740*cdf0e10cSrcweir }
2741*cdf0e10cSrcweir 
2742*cdf0e10cSrcweir // -----------------------------------------------------------------------------
2743*cdf0e10cSrcweir 
2744*cdf0e10cSrcweir void SlideshowImpl::setActiveXToolbarsVisible( sal_Bool bVisible )
2745*cdf0e10cSrcweir {
2746*cdf0e10cSrcweir     // in case of ActiveX control the toolbars should not be visible if slide show runs in window mode
2747*cdf0e10cSrcweir     // actually it runs always in window mode in case of ActiveX control
2748*cdf0e10cSrcweir     if ( !maPresSettings.mbFullScreen && mpDocSh && mpDocSh->GetMedium() )
2749*cdf0e10cSrcweir     {
2750*cdf0e10cSrcweir         SFX_ITEMSET_ARG( mpDocSh->GetMedium()->GetItemSet(), pItem, SfxBoolItem, SID_VIEWONLY, sal_False );
2751*cdf0e10cSrcweir         if ( pItem && pItem->GetValue() )
2752*cdf0e10cSrcweir         {
2753*cdf0e10cSrcweir             // this is a plugin/activex mode, no toolbars should be visible during slide show
2754*cdf0e10cSrcweir             // after the end of slide show they should be visible again
2755*cdf0e10cSrcweir             SfxViewFrame* pViewFrame = getViewFrame();
2756*cdf0e10cSrcweir             if( pViewFrame )
2757*cdf0e10cSrcweir             {
2758*cdf0e10cSrcweir                 try
2759*cdf0e10cSrcweir                 {
2760*cdf0e10cSrcweir                     Reference< frame::XLayoutManager > xLayoutManager;
2761*cdf0e10cSrcweir                     Reference< beans::XPropertySet > xFrameProps( pViewFrame->GetFrame().GetTopFrame().GetFrameInterface(), UNO_QUERY_THROW );
2762*cdf0e10cSrcweir                     if ( ( xFrameProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ) ) )
2763*cdf0e10cSrcweir                                 >>= xLayoutManager )
2764*cdf0e10cSrcweir                       && xLayoutManager.is() )
2765*cdf0e10cSrcweir                     {
2766*cdf0e10cSrcweir                         xLayoutManager->setVisible( bVisible );
2767*cdf0e10cSrcweir                     }
2768*cdf0e10cSrcweir                 }
2769*cdf0e10cSrcweir                 catch( uno::Exception& )
2770*cdf0e10cSrcweir                 {}
2771*cdf0e10cSrcweir             }
2772*cdf0e10cSrcweir         }
2773*cdf0e10cSrcweir     }
2774*cdf0e10cSrcweir }
2775*cdf0e10cSrcweir 
2776*cdf0e10cSrcweir // -----------------------------------------------------------------------------
2777*cdf0e10cSrcweir 
2778*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::activate() throw (RuntimeException)
2779*cdf0e10cSrcweir {
2780*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2781*cdf0e10cSrcweir 
2782*cdf0e10cSrcweir     maDeactivateTimer.Stop();
2783*cdf0e10cSrcweir 
2784*cdf0e10cSrcweir     if( !mbActive && mxShow.is() )
2785*cdf0e10cSrcweir     {
2786*cdf0e10cSrcweir         mbActive = sal_True;
2787*cdf0e10cSrcweir 
2788*cdf0e10cSrcweir         if( ANIMATIONMODE_SHOW == meAnimationMode )
2789*cdf0e10cSrcweir         {
2790*cdf0e10cSrcweir             if( mbAutoSaveWasOn )
2791*cdf0e10cSrcweir                 setAutoSaveState( false );
2792*cdf0e10cSrcweir 
2793*cdf0e10cSrcweir             if( mpShowWindow )
2794*cdf0e10cSrcweir             {
2795*cdf0e10cSrcweir                 SfxViewFrame* pViewFrame = getViewFrame();
2796*cdf0e10cSrcweir                 SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : 0;
2797*cdf0e10cSrcweir 
2798*cdf0e10cSrcweir                 hideChildWindows();
2799*cdf0e10cSrcweir 
2800*cdf0e10cSrcweir                 if( pDispatcher )
2801*cdf0e10cSrcweir                 {
2802*cdf0e10cSrcweir                     // filter all forbiden slots
2803*cdf0e10cSrcweir                     pDispatcher->SetSlotFilter( sal_True, sizeof(pAllowed) / sizeof(sal_uInt16), pAllowed );
2804*cdf0e10cSrcweir                 }
2805*cdf0e10cSrcweir 
2806*cdf0e10cSrcweir                 if( getBindings() )
2807*cdf0e10cSrcweir                     getBindings()->InvalidateAll(sal_True);
2808*cdf0e10cSrcweir 
2809*cdf0e10cSrcweir                 mpShowWindow->GrabFocus();
2810*cdf0e10cSrcweir             }
2811*cdf0e10cSrcweir         }
2812*cdf0e10cSrcweir 
2813*cdf0e10cSrcweir         resume();
2814*cdf0e10cSrcweir     }
2815*cdf0e10cSrcweir }
2816*cdf0e10cSrcweir 
2817*cdf0e10cSrcweir // -----------------------------------------------------------------------------
2818*cdf0e10cSrcweir 
2819*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::deactivate() throw (RuntimeException)
2820*cdf0e10cSrcweir {
2821*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2822*cdf0e10cSrcweir 
2823*cdf0e10cSrcweir     if( mbActive && mxShow.is() )
2824*cdf0e10cSrcweir     {
2825*cdf0e10cSrcweir         maDeactivateTimer.Start();
2826*cdf0e10cSrcweir     }
2827*cdf0e10cSrcweir }
2828*cdf0e10cSrcweir 
2829*cdf0e10cSrcweir // -----------------------------------------------------------------------------
2830*cdf0e10cSrcweir 
2831*cdf0e10cSrcweir IMPL_LINK( SlideshowImpl, deactivateHdl, Timer*, EMPTYARG )
2832*cdf0e10cSrcweir {
2833*cdf0e10cSrcweir     if( mbActive && mxShow.is() )
2834*cdf0e10cSrcweir     {
2835*cdf0e10cSrcweir         mbActive = sal_False;
2836*cdf0e10cSrcweir 
2837*cdf0e10cSrcweir         pause();
2838*cdf0e10cSrcweir 
2839*cdf0e10cSrcweir         if( ANIMATIONMODE_SHOW == meAnimationMode )
2840*cdf0e10cSrcweir         {
2841*cdf0e10cSrcweir             if( mbAutoSaveWasOn )
2842*cdf0e10cSrcweir                 setAutoSaveState( true );
2843*cdf0e10cSrcweir 
2844*cdf0e10cSrcweir             if( mpShowWindow )
2845*cdf0e10cSrcweir             {
2846*cdf0e10cSrcweir                 showChildWindows();
2847*cdf0e10cSrcweir             }
2848*cdf0e10cSrcweir         }
2849*cdf0e10cSrcweir     }
2850*cdf0e10cSrcweir     return 0;
2851*cdf0e10cSrcweir }
2852*cdf0e10cSrcweir 
2853*cdf0e10cSrcweir // ---------------------------------------------------------
2854*cdf0e10cSrcweir 
2855*cdf0e10cSrcweir sal_Bool SAL_CALL SlideshowImpl::isActive() throw (RuntimeException)
2856*cdf0e10cSrcweir {
2857*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2858*cdf0e10cSrcweir     return mbActive;
2859*cdf0e10cSrcweir }
2860*cdf0e10cSrcweir 
2861*cdf0e10cSrcweir // -----------------------------------------------------------------------------
2862*cdf0e10cSrcweir 
2863*cdf0e10cSrcweir void SlideshowImpl::receiveRequest(SfxRequest& rReq)
2864*cdf0e10cSrcweir {
2865*cdf0e10cSrcweir     const SfxItemSet* pArgs      = rReq.GetArgs();
2866*cdf0e10cSrcweir 
2867*cdf0e10cSrcweir     switch ( rReq.GetSlot() )
2868*cdf0e10cSrcweir     {
2869*cdf0e10cSrcweir         case SID_NAVIGATOR_PEN:
2870*cdf0e10cSrcweir             setUsePen(!mbUsePen);
2871*cdf0e10cSrcweir         break;
2872*cdf0e10cSrcweir 
2873*cdf0e10cSrcweir         case SID_NAVIGATOR_PAGE:
2874*cdf0e10cSrcweir         {
2875*cdf0e10cSrcweir             PageJump    eJump = (PageJump)((SfxAllEnumItem&) pArgs->Get(SID_NAVIGATOR_PAGE)).GetValue();
2876*cdf0e10cSrcweir             switch( eJump )
2877*cdf0e10cSrcweir             {
2878*cdf0e10cSrcweir                 case PAGE_FIRST:        gotoFirstSlide(); break;
2879*cdf0e10cSrcweir                 case PAGE_LAST:         gotoLastSlide(); break;
2880*cdf0e10cSrcweir                 case PAGE_NEXT:         gotoNextSlide(); break;
2881*cdf0e10cSrcweir                 case PAGE_PREVIOUS:     gotoPreviousSlide(); break;
2882*cdf0e10cSrcweir                 case PAGE_NONE:         break;
2883*cdf0e10cSrcweir             }
2884*cdf0e10cSrcweir         }
2885*cdf0e10cSrcweir         break;
2886*cdf0e10cSrcweir 
2887*cdf0e10cSrcweir         case SID_NAVIGATOR_OBJECT:
2888*cdf0e10cSrcweir         {
2889*cdf0e10cSrcweir             const String aTarget( ((SfxStringItem&) pArgs->Get(SID_NAVIGATOR_OBJECT)).GetValue() );
2890*cdf0e10cSrcweir 
2891*cdf0e10cSrcweir             // is the bookmark a Slide?
2892*cdf0e10cSrcweir             sal_Bool        bIsMasterPage;
2893*cdf0e10cSrcweir             sal_uInt16      nPgNum = mpDoc->GetPageByName( aTarget, bIsMasterPage );
2894*cdf0e10cSrcweir             SdrObject*  pObj   = NULL;
2895*cdf0e10cSrcweir 
2896*cdf0e10cSrcweir             if( nPgNum == SDRPAGE_NOTFOUND )
2897*cdf0e10cSrcweir             {
2898*cdf0e10cSrcweir                 // is the bookmark an object?
2899*cdf0e10cSrcweir                 pObj = mpDoc->GetObj( aTarget );
2900*cdf0e10cSrcweir 
2901*cdf0e10cSrcweir                 if( pObj )
2902*cdf0e10cSrcweir                     nPgNum = pObj->GetPage()->GetPageNum();
2903*cdf0e10cSrcweir             }
2904*cdf0e10cSrcweir 
2905*cdf0e10cSrcweir             if( nPgNum != SDRPAGE_NOTFOUND )
2906*cdf0e10cSrcweir             {
2907*cdf0e10cSrcweir                 nPgNum = ( nPgNum - 1 ) >> 1;
2908*cdf0e10cSrcweir                 displaySlideNumber( nPgNum );
2909*cdf0e10cSrcweir             }
2910*cdf0e10cSrcweir         }
2911*cdf0e10cSrcweir         break;
2912*cdf0e10cSrcweir     }
2913*cdf0e10cSrcweir }
2914*cdf0e10cSrcweir 
2915*cdf0e10cSrcweir // ---------------------------------------------------------
2916*cdf0e10cSrcweir 
2917*cdf0e10cSrcweir void SlideshowImpl::setAutoSaveState( bool bOn)
2918*cdf0e10cSrcweir {
2919*cdf0e10cSrcweir     try
2920*cdf0e10cSrcweir     {
2921*cdf0e10cSrcweir         uno::Reference<lang::XMultiServiceFactory> xFac( ::comphelper::getProcessServiceFactory() );
2922*cdf0e10cSrcweir 
2923*cdf0e10cSrcweir         uno::Reference< util::XURLTransformer > xParser(
2924*cdf0e10cSrcweir             xFac->createInstance( OUString::createFromAscii("com.sun.star.util.URLTransformer" ) ),
2925*cdf0e10cSrcweir                 uno::UNO_QUERY_THROW);
2926*cdf0e10cSrcweir         util::URL aURL;
2927*cdf0e10cSrcweir         aURL.Complete = OUString::createFromAscii("vnd.sun.star.autorecovery:/setAutoSaveState");
2928*cdf0e10cSrcweir         xParser->parseStrict(aURL);
2929*cdf0e10cSrcweir 
2930*cdf0e10cSrcweir         Sequence< beans::PropertyValue > aArgs(1);
2931*cdf0e10cSrcweir         aArgs[0].Name = OUString::createFromAscii("AutoSaveState");
2932*cdf0e10cSrcweir         aArgs[0].Value <<= bOn ? sal_True : sal_False;
2933*cdf0e10cSrcweir 
2934*cdf0e10cSrcweir         uno::Reference< frame::XDispatch > xAutoSave(
2935*cdf0e10cSrcweir             xFac->createInstance(OUString::createFromAscii("com.sun.star.frame.AutoRecovery")),
2936*cdf0e10cSrcweir             uno::UNO_QUERY_THROW);
2937*cdf0e10cSrcweir         xAutoSave->dispatch(aURL, aArgs);
2938*cdf0e10cSrcweir     }
2939*cdf0e10cSrcweir     catch( Exception& )
2940*cdf0e10cSrcweir     {
2941*cdf0e10cSrcweir         DBG_ERROR("sd::SlideshowImpl::setAutoSaveState(), exception caught!");
2942*cdf0e10cSrcweir     }
2943*cdf0e10cSrcweir }
2944*cdf0e10cSrcweir 
2945*cdf0e10cSrcweir // ---------------------------------------------------------
2946*cdf0e10cSrcweir 
2947*cdf0e10cSrcweir Reference< XDrawPage > SAL_CALL SlideshowImpl::getCurrentSlide() throw (RuntimeException)
2948*cdf0e10cSrcweir {
2949*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2950*cdf0e10cSrcweir 
2951*cdf0e10cSrcweir     Reference< XDrawPage > xSlide;
2952*cdf0e10cSrcweir     if( mxShow.is() && mpSlideController.get() )
2953*cdf0e10cSrcweir     {
2954*cdf0e10cSrcweir         sal_Int32 nSlide = getCurrentSlideNumber();
2955*cdf0e10cSrcweir         if( (nSlide >= 0) && (nSlide < mpSlideController->getSlideNumberCount() ) )
2956*cdf0e10cSrcweir             xSlide = mpSlideController->getSlideByNumber( nSlide );
2957*cdf0e10cSrcweir     }
2958*cdf0e10cSrcweir 
2959*cdf0e10cSrcweir     return xSlide;
2960*cdf0e10cSrcweir }
2961*cdf0e10cSrcweir 
2962*cdf0e10cSrcweir // ---------------------------------------------------------
2963*cdf0e10cSrcweir 
2964*cdf0e10cSrcweir sal_Int32 SAL_CALL SlideshowImpl::getNextSlideIndex() throw (RuntimeException)
2965*cdf0e10cSrcweir {
2966*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2967*cdf0e10cSrcweir 
2968*cdf0e10cSrcweir     if( mxShow.is() )
2969*cdf0e10cSrcweir     {
2970*cdf0e10cSrcweir         return mpSlideController->getNextSlideIndex();
2971*cdf0e10cSrcweir     }
2972*cdf0e10cSrcweir     else
2973*cdf0e10cSrcweir     {
2974*cdf0e10cSrcweir         return -1;
2975*cdf0e10cSrcweir     }
2976*cdf0e10cSrcweir }
2977*cdf0e10cSrcweir 
2978*cdf0e10cSrcweir // ---------------------------------------------------------
2979*cdf0e10cSrcweir 
2980*cdf0e10cSrcweir sal_Int32 SAL_CALL SlideshowImpl::getCurrentSlideIndex() throw (RuntimeException)
2981*cdf0e10cSrcweir {
2982*cdf0e10cSrcweir     return mpSlideController.get() ? mpSlideController->getCurrentSlideIndex() : -1;
2983*cdf0e10cSrcweir }
2984*cdf0e10cSrcweir 
2985*cdf0e10cSrcweir // --------------------------------------------------------------------
2986*cdf0e10cSrcweir // ::com::sun::star::presentation::XSlideShowController:
2987*cdf0e10cSrcweir // --------------------------------------------------------------------
2988*cdf0e10cSrcweir 
2989*cdf0e10cSrcweir ::sal_Int32 SAL_CALL SlideshowImpl::getSlideCount() throw (RuntimeException)
2990*cdf0e10cSrcweir {
2991*cdf0e10cSrcweir     return mpSlideController.get() ? mpSlideController->getSlideIndexCount() : 0;
2992*cdf0e10cSrcweir }
2993*cdf0e10cSrcweir 
2994*cdf0e10cSrcweir // --------------------------------------------------------------------
2995*cdf0e10cSrcweir 
2996*cdf0e10cSrcweir Reference< XDrawPage > SAL_CALL SlideshowImpl::getSlideByIndex(::sal_Int32 Index) throw (RuntimeException, css::lang::IndexOutOfBoundsException)
2997*cdf0e10cSrcweir {
2998*cdf0e10cSrcweir     if( (mpSlideController.get() == 0 ) || (Index < 0) || (Index >= mpSlideController->getSlideIndexCount() ) )
2999*cdf0e10cSrcweir         throw IndexOutOfBoundsException();
3000*cdf0e10cSrcweir 
3001*cdf0e10cSrcweir     return mpSlideController->getSlideByNumber( mpSlideController->getSlideNumber( Index ) );
3002*cdf0e10cSrcweir }
3003*cdf0e10cSrcweir 
3004*cdf0e10cSrcweir sal_Bool SAL_CALL SlideshowImpl::getAlwaysOnTop() throw (RuntimeException)
3005*cdf0e10cSrcweir {
3006*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3007*cdf0e10cSrcweir     return maPresSettings.mbAlwaysOnTop;
3008*cdf0e10cSrcweir }
3009*cdf0e10cSrcweir 
3010*cdf0e10cSrcweir // --------------------------------------------------------------------
3011*cdf0e10cSrcweir 
3012*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::setAlwaysOnTop( sal_Bool bAlways ) throw (RuntimeException)
3013*cdf0e10cSrcweir {
3014*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3015*cdf0e10cSrcweir     if( maPresSettings.mbAlwaysOnTop != bAlways )
3016*cdf0e10cSrcweir     {
3017*cdf0e10cSrcweir         maPresSettings.mbAlwaysOnTop = bAlways;
3018*cdf0e10cSrcweir         // todo, can this be changed while running?
3019*cdf0e10cSrcweir     }
3020*cdf0e10cSrcweir }
3021*cdf0e10cSrcweir 
3022*cdf0e10cSrcweir // --------------------------------------------------------------------
3023*cdf0e10cSrcweir 
3024*cdf0e10cSrcweir sal_Bool SAL_CALL SlideshowImpl::isFullScreen() throw (RuntimeException)
3025*cdf0e10cSrcweir {
3026*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3027*cdf0e10cSrcweir     return maPresSettings.mbFullScreen;
3028*cdf0e10cSrcweir }
3029*cdf0e10cSrcweir 
3030*cdf0e10cSrcweir // --------------------------------------------------------------------
3031*cdf0e10cSrcweir 
3032*cdf0e10cSrcweir sal_Bool SAL_CALL SlideshowImpl::getMouseVisible() throw (RuntimeException)
3033*cdf0e10cSrcweir {
3034*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3035*cdf0e10cSrcweir     return maPresSettings.mbMouseVisible;
3036*cdf0e10cSrcweir }
3037*cdf0e10cSrcweir 
3038*cdf0e10cSrcweir // --------------------------------------------------------------------
3039*cdf0e10cSrcweir 
3040*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::setMouseVisible( sal_Bool bVisible ) throw (RuntimeException)
3041*cdf0e10cSrcweir {
3042*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3043*cdf0e10cSrcweir     if( maPresSettings.mbMouseVisible != bVisible )
3044*cdf0e10cSrcweir     {
3045*cdf0e10cSrcweir         maPresSettings.mbMouseVisible = bVisible;
3046*cdf0e10cSrcweir         if( mpShowWindow )
3047*cdf0e10cSrcweir             mpShowWindow->SetMouseAutoHide( !maPresSettings.mbMouseVisible );
3048*cdf0e10cSrcweir     }
3049*cdf0e10cSrcweir }
3050*cdf0e10cSrcweir 
3051*cdf0e10cSrcweir // --------------------------------------------------------------------
3052*cdf0e10cSrcweir 
3053*cdf0e10cSrcweir sal_Bool SAL_CALL SlideshowImpl::getUsePen() throw (RuntimeException)
3054*cdf0e10cSrcweir {
3055*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3056*cdf0e10cSrcweir     return mbUsePen;
3057*cdf0e10cSrcweir }
3058*cdf0e10cSrcweir 
3059*cdf0e10cSrcweir // --------------------------------------------------------------------
3060*cdf0e10cSrcweir 
3061*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::setUsePen( sal_Bool bMouseAsPen ) throw (RuntimeException)
3062*cdf0e10cSrcweir {
3063*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3064*cdf0e10cSrcweir     mbUsePen = bMouseAsPen;
3065*cdf0e10cSrcweir     if( mxShow.is() ) try
3066*cdf0e10cSrcweir     {
3067*cdf0e10cSrcweir         // For Pencolor;
3068*cdf0e10cSrcweir         Any aValue;
3069*cdf0e10cSrcweir         if( mbUsePen )
3070*cdf0e10cSrcweir             aValue <<= mnUserPaintColor;
3071*cdf0e10cSrcweir         beans::PropertyValue aPenProp;
3072*cdf0e10cSrcweir         aPenProp.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "UserPaintColor" ));
3073*cdf0e10cSrcweir         aPenProp.Value = aValue;
3074*cdf0e10cSrcweir         mxShow->setProperty( aPenProp );
3075*cdf0e10cSrcweir 
3076*cdf0e10cSrcweir         //for StrokeWidth :
3077*cdf0e10cSrcweir         if( mbUsePen )
3078*cdf0e10cSrcweir         {
3079*cdf0e10cSrcweir             beans::PropertyValue aPenPropWidth;
3080*cdf0e10cSrcweir             aPenPropWidth.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "UserPaintStrokeWidth" ));
3081*cdf0e10cSrcweir             aPenPropWidth.Value <<= mdUserPaintStrokeWidth;
3082*cdf0e10cSrcweir             mxShow->setProperty( aPenPropWidth );
3083*cdf0e10cSrcweir 
3084*cdf0e10cSrcweir             // for Pen Mode
3085*cdf0e10cSrcweir             beans::PropertyValue aPenPropSwitchPenMode;
3086*cdf0e10cSrcweir             aPenPropSwitchPenMode.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "SwitchPenMode" ));
3087*cdf0e10cSrcweir             aPenPropSwitchPenMode.Value <<= sal_True;
3088*cdf0e10cSrcweir             mxShow->setProperty( aPenPropSwitchPenMode );
3089*cdf0e10cSrcweir         }
3090*cdf0e10cSrcweir     }
3091*cdf0e10cSrcweir     catch( Exception& e )
3092*cdf0e10cSrcweir     {
3093*cdf0e10cSrcweir         static_cast<void>(e);
3094*cdf0e10cSrcweir         DBG_ERROR(
3095*cdf0e10cSrcweir             (OString("sd::SlideshowImpl::setUsePen(), "
3096*cdf0e10cSrcweir                     "exception caught: ") +
3097*cdf0e10cSrcweir             rtl::OUStringToOString(
3098*cdf0e10cSrcweir                 comphelper::anyToString( cppu::getCaughtException() ),
3099*cdf0e10cSrcweir                 RTL_TEXTENCODING_UTF8 )).getStr() );
3100*cdf0e10cSrcweir     }
3101*cdf0e10cSrcweir }
3102*cdf0e10cSrcweir 
3103*cdf0e10cSrcweir // --------------------------------------------------------------------
3104*cdf0e10cSrcweir 
3105*cdf0e10cSrcweir double SAL_CALL SlideshowImpl::getPenWidth() throw (RuntimeException)
3106*cdf0e10cSrcweir {
3107*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3108*cdf0e10cSrcweir     return mdUserPaintStrokeWidth;
3109*cdf0e10cSrcweir }
3110*cdf0e10cSrcweir 
3111*cdf0e10cSrcweir // --------------------------------------------------------------------
3112*cdf0e10cSrcweir 
3113*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::setPenWidth( double dStrokeWidth ) throw (RuntimeException)
3114*cdf0e10cSrcweir {
3115*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3116*cdf0e10cSrcweir     mdUserPaintStrokeWidth = dStrokeWidth;
3117*cdf0e10cSrcweir     setUsePen( true ); // enable pen mode, update color and width
3118*cdf0e10cSrcweir }
3119*cdf0e10cSrcweir 
3120*cdf0e10cSrcweir // --------------------------------------------------------------------
3121*cdf0e10cSrcweir 
3122*cdf0e10cSrcweir sal_Int32 SAL_CALL SlideshowImpl::getPenColor() throw (RuntimeException)
3123*cdf0e10cSrcweir {
3124*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3125*cdf0e10cSrcweir     return mnUserPaintColor;
3126*cdf0e10cSrcweir }
3127*cdf0e10cSrcweir 
3128*cdf0e10cSrcweir // --------------------------------------------------------------------
3129*cdf0e10cSrcweir 
3130*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::setPenColor( sal_Int32 nColor ) throw (RuntimeException)
3131*cdf0e10cSrcweir {
3132*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3133*cdf0e10cSrcweir     mnUserPaintColor = nColor;
3134*cdf0e10cSrcweir     setUsePen( true ); // enable pen mode, update color
3135*cdf0e10cSrcweir }
3136*cdf0e10cSrcweir 
3137*cdf0e10cSrcweir // --------------------------------------------------------------------
3138*cdf0e10cSrcweir 
3139*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::setUseEraser( ::sal_Bool /*_usepen*/ ) throw (css::uno::RuntimeException)
3140*cdf0e10cSrcweir {
3141*cdf0e10cSrcweir }
3142*cdf0e10cSrcweir 
3143*cdf0e10cSrcweir // --------------------------------------------------------------------
3144*cdf0e10cSrcweir 
3145*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::setPenMode( bool bSwitchPenMode ) throw (RuntimeException)
3146*cdf0e10cSrcweir {
3147*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3148*cdf0e10cSrcweir     setUsePen( bSwitchPenMode ); // SwitchPen Mode
3149*cdf0e10cSrcweir 
3150*cdf0e10cSrcweir }
3151*cdf0e10cSrcweir 
3152*cdf0e10cSrcweir // --------------------------------------------------------------------
3153*cdf0e10cSrcweir 
3154*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::setEraseAllInk(bool bEraseAllInk) throw (RuntimeException)
3155*cdf0e10cSrcweir {
3156*cdf0e10cSrcweir     if( bEraseAllInk )
3157*cdf0e10cSrcweir     {
3158*cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3159*cdf0e10cSrcweir         if( mxShow.is() ) try
3160*cdf0e10cSrcweir         {
3161*cdf0e10cSrcweir             beans::PropertyValue aPenPropEraseAllInk;
3162*cdf0e10cSrcweir             aPenPropEraseAllInk.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "EraseAllInk" ));
3163*cdf0e10cSrcweir             aPenPropEraseAllInk.Value <<= bEraseAllInk;
3164*cdf0e10cSrcweir             mxShow->setProperty( aPenPropEraseAllInk );
3165*cdf0e10cSrcweir         }
3166*cdf0e10cSrcweir         catch( Exception& e )
3167*cdf0e10cSrcweir         {
3168*cdf0e10cSrcweir             static_cast<void>(e);
3169*cdf0e10cSrcweir             DBG_ERROR(
3170*cdf0e10cSrcweir                 (OString("sd::SlideshowImpl::setEraseAllInk(), "
3171*cdf0e10cSrcweir                         "exception caught: ") +
3172*cdf0e10cSrcweir                 rtl::OUStringToOString(
3173*cdf0e10cSrcweir                     comphelper::anyToString( cppu::getCaughtException() ),
3174*cdf0e10cSrcweir                     RTL_TEXTENCODING_UTF8 )).getStr() );
3175*cdf0e10cSrcweir         }
3176*cdf0e10cSrcweir     }
3177*cdf0e10cSrcweir }
3178*cdf0e10cSrcweir 
3179*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::setEraseInk( sal_Int32 /*nEraseInkSize*/ ) throw (css::uno::RuntimeException)
3180*cdf0e10cSrcweir {
3181*cdf0e10cSrcweir }
3182*cdf0e10cSrcweir 
3183*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::setEraserMode( bool /*bSwitchEraserMode*/ ) throw (css::uno::RuntimeException)
3184*cdf0e10cSrcweir {
3185*cdf0e10cSrcweir }
3186*cdf0e10cSrcweir 
3187*cdf0e10cSrcweir // --------------------------------------------------------------------
3188*cdf0e10cSrcweir // XSlideShowController Methods
3189*cdf0e10cSrcweir // --------------------------------------------------------------------
3190*cdf0e10cSrcweir 
3191*cdf0e10cSrcweir sal_Bool SAL_CALL SlideshowImpl::isRunning(  ) throw (RuntimeException)
3192*cdf0e10cSrcweir {
3193*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3194*cdf0e10cSrcweir     return mxShow.is();
3195*cdf0e10cSrcweir }
3196*cdf0e10cSrcweir 
3197*cdf0e10cSrcweir // --------------------------------------------------------------------
3198*cdf0e10cSrcweir 
3199*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::gotoNextEffect(  ) throw (RuntimeException)
3200*cdf0e10cSrcweir {
3201*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3202*cdf0e10cSrcweir 
3203*cdf0e10cSrcweir     if( mxShow.is() && mpSlideController.get() && mpShowWindow )
3204*cdf0e10cSrcweir     {
3205*cdf0e10cSrcweir         if( mbIsPaused )
3206*cdf0e10cSrcweir             resume();
3207*cdf0e10cSrcweir 
3208*cdf0e10cSrcweir         const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode();
3209*cdf0e10cSrcweir         if( eMode == SHOWWINDOWMODE_END )
3210*cdf0e10cSrcweir         {
3211*cdf0e10cSrcweir             endPresentation();
3212*cdf0e10cSrcweir         }
3213*cdf0e10cSrcweir         else if( (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) )
3214*cdf0e10cSrcweir         {
3215*cdf0e10cSrcweir             mpShowWindow->RestartShow();
3216*cdf0e10cSrcweir         }
3217*cdf0e10cSrcweir         else
3218*cdf0e10cSrcweir         {
3219*cdf0e10cSrcweir             mxShow->nextEffect();
3220*cdf0e10cSrcweir             update();
3221*cdf0e10cSrcweir         }
3222*cdf0e10cSrcweir     }
3223*cdf0e10cSrcweir }
3224*cdf0e10cSrcweir 
3225*cdf0e10cSrcweir // --------------------------------------------------------------------
3226*cdf0e10cSrcweir 
3227*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::gotoPreviousEffect(  ) throw (RuntimeException)
3228*cdf0e10cSrcweir {
3229*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3230*cdf0e10cSrcweir 
3231*cdf0e10cSrcweir     if( mxShow.is() && mpSlideController.get() && mpShowWindow )
3232*cdf0e10cSrcweir     {
3233*cdf0e10cSrcweir         if( mbIsPaused )
3234*cdf0e10cSrcweir             resume();
3235*cdf0e10cSrcweir 
3236*cdf0e10cSrcweir         const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode();
3237*cdf0e10cSrcweir         if( (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) )
3238*cdf0e10cSrcweir         {
3239*cdf0e10cSrcweir             mpShowWindow->RestartShow();
3240*cdf0e10cSrcweir         }
3241*cdf0e10cSrcweir         else
3242*cdf0e10cSrcweir         {
3243*cdf0e10cSrcweir             mxShow->previousEffect();
3244*cdf0e10cSrcweir             update();
3245*cdf0e10cSrcweir         }
3246*cdf0e10cSrcweir     }
3247*cdf0e10cSrcweir }
3248*cdf0e10cSrcweir 
3249*cdf0e10cSrcweir // --------------------------------------------------------------------
3250*cdf0e10cSrcweir 
3251*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::gotoFirstSlide(  ) throw (RuntimeException)
3252*cdf0e10cSrcweir {
3253*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3254*cdf0e10cSrcweir 
3255*cdf0e10cSrcweir     if( mpShowWindow && mpSlideController.get() )
3256*cdf0e10cSrcweir     {
3257*cdf0e10cSrcweir         if( mbIsPaused )
3258*cdf0e10cSrcweir             resume();
3259*cdf0e10cSrcweir 
3260*cdf0e10cSrcweir         if( mpShowWindow->GetShowWindowMode() == SHOWWINDOWMODE_END )
3261*cdf0e10cSrcweir         {
3262*cdf0e10cSrcweir             if( mpSlideController->getSlideIndexCount() )
3263*cdf0e10cSrcweir                 mpShowWindow->RestartShow( 0);
3264*cdf0e10cSrcweir         }
3265*cdf0e10cSrcweir         else
3266*cdf0e10cSrcweir         {
3267*cdf0e10cSrcweir             displaySlideIndex( 0 );
3268*cdf0e10cSrcweir         }
3269*cdf0e10cSrcweir     }
3270*cdf0e10cSrcweir }
3271*cdf0e10cSrcweir 
3272*cdf0e10cSrcweir // --------------------------------------------------------------------
3273*cdf0e10cSrcweir 
3274*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::gotoNextSlide(  ) throw (RuntimeException)
3275*cdf0e10cSrcweir {
3276*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3277*cdf0e10cSrcweir 
3278*cdf0e10cSrcweir     if( mbIsPaused )
3279*cdf0e10cSrcweir         resume();
3280*cdf0e10cSrcweir 
3281*cdf0e10cSrcweir     const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode();
3282*cdf0e10cSrcweir     if( (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) )
3283*cdf0e10cSrcweir     {
3284*cdf0e10cSrcweir         mpShowWindow->RestartShow();
3285*cdf0e10cSrcweir     }
3286*cdf0e10cSrcweir     else
3287*cdf0e10cSrcweir     {
3288*cdf0e10cSrcweir         // if this is a show, ignore user inputs and
3289*cdf0e10cSrcweir         // start 20ms timer to reenable inputs to fiter
3290*cdf0e10cSrcweir         // buffered inputs during slide transition
3291*cdf0e10cSrcweir         if( meAnimationMode == ANIMATIONMODE_SHOW )
3292*cdf0e10cSrcweir         {
3293*cdf0e10cSrcweir             mbInputFreeze = true;
3294*cdf0e10cSrcweir             maInputFreezeTimer.Start();
3295*cdf0e10cSrcweir         }
3296*cdf0e10cSrcweir 
3297*cdf0e10cSrcweir         if( mpSlideController.get() )
3298*cdf0e10cSrcweir         {
3299*cdf0e10cSrcweir             if( mpSlideController->nextSlide() )
3300*cdf0e10cSrcweir             {
3301*cdf0e10cSrcweir                 displayCurrentSlide();
3302*cdf0e10cSrcweir             }
3303*cdf0e10cSrcweir             else
3304*cdf0e10cSrcweir             {
3305*cdf0e10cSrcweir                 stopSound();
3306*cdf0e10cSrcweir 
3307*cdf0e10cSrcweir                 if( meAnimationMode == ANIMATIONMODE_PREVIEW )
3308*cdf0e10cSrcweir                 {
3309*cdf0e10cSrcweir                     endPresentation();
3310*cdf0e10cSrcweir                 }
3311*cdf0e10cSrcweir                 else if( maPresSettings.mbEndless )
3312*cdf0e10cSrcweir                 {
3313*cdf0e10cSrcweir                     if( maPresSettings.mnPauseTimeout )
3314*cdf0e10cSrcweir                     {
3315*cdf0e10cSrcweir                         if( mpShowWindow )
3316*cdf0e10cSrcweir                         {
3317*cdf0e10cSrcweir                             Graphic aGraphic( SfxApplication::GetApplicationLogo().GetBitmapEx() );
3318*cdf0e10cSrcweir                             mpShowWindow->SetPauseMode( 0, maPresSettings.mnPauseTimeout, &aGraphic );
3319*cdf0e10cSrcweir                         }
3320*cdf0e10cSrcweir                     }
3321*cdf0e10cSrcweir                     else
3322*cdf0e10cSrcweir                     {
3323*cdf0e10cSrcweir                         displaySlideIndex( 0 );
3324*cdf0e10cSrcweir                     }
3325*cdf0e10cSrcweir                 }
3326*cdf0e10cSrcweir                 else
3327*cdf0e10cSrcweir                 {
3328*cdf0e10cSrcweir                     if( mpShowWindow )
3329*cdf0e10cSrcweir                     {
3330*cdf0e10cSrcweir                         mpShowWindow->SetEndMode();
3331*cdf0e10cSrcweir                         pause();
3332*cdf0e10cSrcweir                     }
3333*cdf0e10cSrcweir                 }
3334*cdf0e10cSrcweir             }
3335*cdf0e10cSrcweir         }
3336*cdf0e10cSrcweir     }
3337*cdf0e10cSrcweir }
3338*cdf0e10cSrcweir 
3339*cdf0e10cSrcweir // --------------------------------------------------------------------
3340*cdf0e10cSrcweir 
3341*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::gotoPreviousSlide(  ) throw (RuntimeException)
3342*cdf0e10cSrcweir {
3343*cdf0e10cSrcweir     gotoPreviousSlide(false);
3344*cdf0e10cSrcweir }
3345*cdf0e10cSrcweir 
3346*cdf0e10cSrcweir void SlideshowImpl::gotoPreviousSlide (const bool bSkipAllMainSequenceEffects)
3347*cdf0e10cSrcweir {
3348*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3349*cdf0e10cSrcweir 
3350*cdf0e10cSrcweir     if( mxShow.is() && mpSlideController.get() ) try
3351*cdf0e10cSrcweir     {
3352*cdf0e10cSrcweir         if( mbIsPaused )
3353*cdf0e10cSrcweir             resume();
3354*cdf0e10cSrcweir 
3355*cdf0e10cSrcweir         const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode();
3356*cdf0e10cSrcweir         if( eMode == SHOWWINDOWMODE_END )
3357*cdf0e10cSrcweir         {
3358*cdf0e10cSrcweir             const sal_Int32 nLastSlideIndex = mpSlideController->getSlideIndexCount() - 1;
3359*cdf0e10cSrcweir             if( nLastSlideIndex >= 0 )
3360*cdf0e10cSrcweir                 mpShowWindow->RestartShow( nLastSlideIndex );
3361*cdf0e10cSrcweir         }
3362*cdf0e10cSrcweir         else if( (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) )
3363*cdf0e10cSrcweir         {
3364*cdf0e10cSrcweir             mpShowWindow->RestartShow();
3365*cdf0e10cSrcweir         }
3366*cdf0e10cSrcweir         else
3367*cdf0e10cSrcweir         {
3368*cdf0e10cSrcweir             if( mpSlideController->previousSlide())
3369*cdf0e10cSrcweir                 displayCurrentSlide(bSkipAllMainSequenceEffects);
3370*cdf0e10cSrcweir             else if (bSkipAllMainSequenceEffects)
3371*cdf0e10cSrcweir             {
3372*cdf0e10cSrcweir                 // We could not go to the previous slide (probably because
3373*cdf0e10cSrcweir                 // the current slide is already the first one).  We still
3374*cdf0e10cSrcweir                 // have to call displayCurrentSlide because the calling
3375*cdf0e10cSrcweir                 // slideshow can not determine whether there is a previous
3376*cdf0e10cSrcweir                 // slide or not and has already prepared for a slide change.
3377*cdf0e10cSrcweir                 // This slide change has to be completed now, even when
3378*cdf0e10cSrcweir                 // changing to the same slide.
3379*cdf0e10cSrcweir                 // Note that in this special case we do NOT pass
3380*cdf0e10cSrcweir                 // bSkipAllMainSequenceEffects because we display the same
3381*cdf0e10cSrcweir                 // slide as before and do not want to show all its effects.
3382*cdf0e10cSrcweir                 displayCurrentSlide(false);
3383*cdf0e10cSrcweir             }
3384*cdf0e10cSrcweir         }
3385*cdf0e10cSrcweir     }
3386*cdf0e10cSrcweir     catch( Exception& e )
3387*cdf0e10cSrcweir     {
3388*cdf0e10cSrcweir         static_cast<void>(e);
3389*cdf0e10cSrcweir         DBG_ERROR(
3390*cdf0e10cSrcweir             (OString("sd::SlideshowImpl::gotoPreviousSlide(), "
3391*cdf0e10cSrcweir                     "exception caught: ") +
3392*cdf0e10cSrcweir             rtl::OUStringToOString(
3393*cdf0e10cSrcweir                 comphelper::anyToString( cppu::getCaughtException() ),
3394*cdf0e10cSrcweir                 RTL_TEXTENCODING_UTF8 )).getStr() );
3395*cdf0e10cSrcweir     }
3396*cdf0e10cSrcweir }
3397*cdf0e10cSrcweir 
3398*cdf0e10cSrcweir // --------------------------------------------------------------------
3399*cdf0e10cSrcweir 
3400*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::gotoLastSlide() throw (RuntimeException)
3401*cdf0e10cSrcweir {
3402*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3403*cdf0e10cSrcweir 
3404*cdf0e10cSrcweir     if( mpSlideController.get() )
3405*cdf0e10cSrcweir     {
3406*cdf0e10cSrcweir         if( mbIsPaused )
3407*cdf0e10cSrcweir             resume();
3408*cdf0e10cSrcweir 
3409*cdf0e10cSrcweir         const sal_Int32 nLastSlideIndex = mpSlideController->getSlideIndexCount() - 1;
3410*cdf0e10cSrcweir         if( nLastSlideIndex >= 0 )
3411*cdf0e10cSrcweir         {
3412*cdf0e10cSrcweir             if( mpShowWindow->GetShowWindowMode() == SHOWWINDOWMODE_END )
3413*cdf0e10cSrcweir             {
3414*cdf0e10cSrcweir                 mpShowWindow->RestartShow( nLastSlideIndex );
3415*cdf0e10cSrcweir             }
3416*cdf0e10cSrcweir             else
3417*cdf0e10cSrcweir             {
3418*cdf0e10cSrcweir                 displaySlideIndex( nLastSlideIndex );
3419*cdf0e10cSrcweir             }
3420*cdf0e10cSrcweir         }
3421*cdf0e10cSrcweir     }
3422*cdf0e10cSrcweir }
3423*cdf0e10cSrcweir 
3424*cdf0e10cSrcweir // --------------------------------------------------------------------
3425*cdf0e10cSrcweir 
3426*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::gotoBookmark( const OUString& rBookmark ) throw (RuntimeException)
3427*cdf0e10cSrcweir {
3428*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3429*cdf0e10cSrcweir 
3430*cdf0e10cSrcweir     if( mbIsPaused )
3431*cdf0e10cSrcweir         resume();
3432*cdf0e10cSrcweir 
3433*cdf0e10cSrcweir     sal_Int32 nSlideNumber = getSlideNumberForBookmark( rBookmark );
3434*cdf0e10cSrcweir     if( nSlideNumber != -1 )
3435*cdf0e10cSrcweir         displaySlideNumber( nSlideNumber );
3436*cdf0e10cSrcweir }
3437*cdf0e10cSrcweir 
3438*cdf0e10cSrcweir // --------------------------------------------------------------------
3439*cdf0e10cSrcweir 
3440*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::gotoSlide( const Reference< XDrawPage >& xSlide )
3441*cdf0e10cSrcweir     throw(IllegalArgumentException, RuntimeException)
3442*cdf0e10cSrcweir {
3443*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3444*cdf0e10cSrcweir 
3445*cdf0e10cSrcweir     if( mpSlideController.get() && xSlide.is() )
3446*cdf0e10cSrcweir     {
3447*cdf0e10cSrcweir         if( mbIsPaused )
3448*cdf0e10cSrcweir             resume();
3449*cdf0e10cSrcweir 
3450*cdf0e10cSrcweir         const sal_Int32 nSlideCount = mpSlideController->getSlideNumberCount();
3451*cdf0e10cSrcweir         for( sal_Int32 nSlide = 0; nSlide < nSlideCount; nSlide++ )
3452*cdf0e10cSrcweir         {
3453*cdf0e10cSrcweir             if( mpSlideController->getSlideByNumber( nSlide ) == xSlide )
3454*cdf0e10cSrcweir             {
3455*cdf0e10cSrcweir                 displaySlideNumber( nSlide );
3456*cdf0e10cSrcweir             }
3457*cdf0e10cSrcweir         }
3458*cdf0e10cSrcweir     }
3459*cdf0e10cSrcweir }
3460*cdf0e10cSrcweir 
3461*cdf0e10cSrcweir // --------------------------------------------------------------------
3462*cdf0e10cSrcweir 
3463*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::gotoSlideIndex( sal_Int32 nIndex ) throw (RuntimeException)
3464*cdf0e10cSrcweir {
3465*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3466*cdf0e10cSrcweir 
3467*cdf0e10cSrcweir     if( mbIsPaused )
3468*cdf0e10cSrcweir         resume();
3469*cdf0e10cSrcweir 
3470*cdf0e10cSrcweir     displaySlideIndex( nIndex );
3471*cdf0e10cSrcweir }
3472*cdf0e10cSrcweir 
3473*cdf0e10cSrcweir // --------------------------------------------------------------------
3474*cdf0e10cSrcweir 
3475*cdf0e10cSrcweir void SAL_CALL SlideshowImpl::stopSound(  ) throw (RuntimeException)
3476*cdf0e10cSrcweir {
3477*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3478*cdf0e10cSrcweir 
3479*cdf0e10cSrcweir     try
3480*cdf0e10cSrcweir     {
3481*cdf0e10cSrcweir         if( mxPlayer.is() )
3482*cdf0e10cSrcweir         {
3483*cdf0e10cSrcweir             mxPlayer->stop();
3484*cdf0e10cSrcweir             mxPlayer.clear();
3485*cdf0e10cSrcweir         }
3486*cdf0e10cSrcweir     }
3487*cdf0e10cSrcweir     catch( Exception& e )
3488*cdf0e10cSrcweir     {
3489*cdf0e10cSrcweir         static_cast<void>(e);
3490*cdf0e10cSrcweir         DBG_ERROR(
3491*cdf0e10cSrcweir             (OString("sd::SlideshowImpl::stopSound(), "
3492*cdf0e10cSrcweir                     "exception caught: ") +
3493*cdf0e10cSrcweir             rtl::OUStringToOString(
3494*cdf0e10cSrcweir                 comphelper::anyToString( cppu::getCaughtException() ),
3495*cdf0e10cSrcweir                 RTL_TEXTENCODING_UTF8 )).getStr() );
3496*cdf0e10cSrcweir     }
3497*cdf0e10cSrcweir }
3498*cdf0e10cSrcweir 
3499*cdf0e10cSrcweir // --------------------------------------------------------------------
3500*cdf0e10cSrcweir // XIndexAccess
3501*cdf0e10cSrcweir // --------------------------------------------------------------------
3502*cdf0e10cSrcweir 
3503*cdf0e10cSrcweir ::sal_Int32 SAL_CALL SlideshowImpl::getCount(  ) throw (::com::sun::star::uno::RuntimeException)
3504*cdf0e10cSrcweir {
3505*cdf0e10cSrcweir     return getSlideCount();
3506*cdf0e10cSrcweir }
3507*cdf0e10cSrcweir 
3508*cdf0e10cSrcweir // --------------------------------------------------------------------
3509*cdf0e10cSrcweir 
3510*cdf0e10cSrcweir ::com::sun::star::uno::Any SAL_CALL SlideshowImpl::getByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
3511*cdf0e10cSrcweir {
3512*cdf0e10cSrcweir     return Any( getSlideByIndex( Index ) );
3513*cdf0e10cSrcweir }
3514*cdf0e10cSrcweir 
3515*cdf0e10cSrcweir // --------------------------------------------------------------------
3516*cdf0e10cSrcweir 
3517*cdf0e10cSrcweir ::com::sun::star::uno::Type SAL_CALL SlideshowImpl::getElementType(  ) throw (::com::sun::star::uno::RuntimeException)
3518*cdf0e10cSrcweir {
3519*cdf0e10cSrcweir     return XDrawPage::static_type();
3520*cdf0e10cSrcweir }
3521*cdf0e10cSrcweir 
3522*cdf0e10cSrcweir // --------------------------------------------------------------------
3523*cdf0e10cSrcweir 
3524*cdf0e10cSrcweir ::sal_Bool SAL_CALL SlideshowImpl::hasElements(  ) throw (::com::sun::star::uno::RuntimeException)
3525*cdf0e10cSrcweir {
3526*cdf0e10cSrcweir     return getSlideCount() != 0;
3527*cdf0e10cSrcweir }
3528*cdf0e10cSrcweir 
3529*cdf0e10cSrcweir // --------------------------------------------------------------------
3530*cdf0e10cSrcweir 
3531*cdf0e10cSrcweir Reference< XSlideShow > SAL_CALL SlideshowImpl::getSlideShow() throw (RuntimeException)
3532*cdf0e10cSrcweir {
3533*cdf0e10cSrcweir     return mxShow;
3534*cdf0e10cSrcweir }
3535*cdf0e10cSrcweir 
3536*cdf0e10cSrcweir // --------------------------------------------------------------------
3537*cdf0e10cSrcweir 
3538*cdf0e10cSrcweir 
3539*cdf0e10cSrcweir PresentationSettingsEx::PresentationSettingsEx( const PresentationSettingsEx& r )
3540*cdf0e10cSrcweir : PresentationSettings( r )
3541*cdf0e10cSrcweir , mbRehearseTimings(r.mbRehearseTimings)
3542*cdf0e10cSrcweir , mbPreview(r.mbPreview)
3543*cdf0e10cSrcweir , mpParentWindow( 0 )
3544*cdf0e10cSrcweir {
3545*cdf0e10cSrcweir }
3546*cdf0e10cSrcweir 
3547*cdf0e10cSrcweir PresentationSettingsEx::PresentationSettingsEx( PresentationSettings& r )
3548*cdf0e10cSrcweir : PresentationSettings( r )
3549*cdf0e10cSrcweir , mbRehearseTimings(sal_False)
3550*cdf0e10cSrcweir , mbPreview(sal_False)
3551*cdf0e10cSrcweir , mpParentWindow(0)
3552*cdf0e10cSrcweir {
3553*cdf0e10cSrcweir }
3554*cdf0e10cSrcweir 
3555*cdf0e10cSrcweir void PresentationSettingsEx::SetArguments( const Sequence< PropertyValue >& rArguments ) throw (IllegalArgumentException)
3556*cdf0e10cSrcweir {
3557*cdf0e10cSrcweir     sal_Int32 nArguments = rArguments.getLength();
3558*cdf0e10cSrcweir     const PropertyValue* pValue = rArguments.getConstArray();
3559*cdf0e10cSrcweir 
3560*cdf0e10cSrcweir     while( nArguments-- )
3561*cdf0e10cSrcweir     {
3562*cdf0e10cSrcweir         SetPropertyValue( pValue->Name, pValue->Value );
3563*cdf0e10cSrcweir         pValue++;
3564*cdf0e10cSrcweir     }
3565*cdf0e10cSrcweir }
3566*cdf0e10cSrcweir 
3567*cdf0e10cSrcweir void PresentationSettingsEx::SetPropertyValue( const OUString& rProperty, const Any& rValue ) throw (IllegalArgumentException)
3568*cdf0e10cSrcweir {
3569*cdf0e10cSrcweir     if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("RehearseTimings") ) )
3570*cdf0e10cSrcweir     {
3571*cdf0e10cSrcweir         if( rValue >>= mbRehearseTimings )
3572*cdf0e10cSrcweir             return;
3573*cdf0e10cSrcweir     }
3574*cdf0e10cSrcweir     else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Preview") ) )
3575*cdf0e10cSrcweir     {
3576*cdf0e10cSrcweir         if( rValue >>= mbPreview )
3577*cdf0e10cSrcweir             return;
3578*cdf0e10cSrcweir     }
3579*cdf0e10cSrcweir     else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("AnimationNode") ) )
3580*cdf0e10cSrcweir     {
3581*cdf0e10cSrcweir         if( rValue >>= mxAnimationNode )
3582*cdf0e10cSrcweir             return;
3583*cdf0e10cSrcweir     }
3584*cdf0e10cSrcweir     else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ParentWindow") ) )
3585*cdf0e10cSrcweir     {
3586*cdf0e10cSrcweir         Reference< XWindow > xWindow;
3587*cdf0e10cSrcweir         if( rValue >>= xWindow )
3588*cdf0e10cSrcweir         {
3589*cdf0e10cSrcweir             mpParentWindow = xWindow.is() ? VCLUnoHelper::GetWindow( xWindow ) : 0;
3590*cdf0e10cSrcweir             return;
3591*cdf0e10cSrcweir         }
3592*cdf0e10cSrcweir     }
3593*cdf0e10cSrcweir     else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("AllowAnimations") ) )
3594*cdf0e10cSrcweir     {
3595*cdf0e10cSrcweir         if( rValue >>= mbAnimationAllowed )
3596*cdf0e10cSrcweir             return;
3597*cdf0e10cSrcweir     }
3598*cdf0e10cSrcweir     else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("AllowAnimations") ) )
3599*cdf0e10cSrcweir     {
3600*cdf0e10cSrcweir         if( rValue >>= mbAnimationAllowed )
3601*cdf0e10cSrcweir             return;
3602*cdf0e10cSrcweir     }
3603*cdf0e10cSrcweir     else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("FirstPage") ) )
3604*cdf0e10cSrcweir     {
3605*cdf0e10cSrcweir         OUString aPresPage;
3606*cdf0e10cSrcweir         if( rValue >>= aPresPage )
3607*cdf0e10cSrcweir         {
3608*cdf0e10cSrcweir             maPresPage = getUiNameFromPageApiNameImpl(aPresPage);
3609*cdf0e10cSrcweir             mbCustomShow = sal_False;
3610*cdf0e10cSrcweir             mbAll = sal_False;
3611*cdf0e10cSrcweir             return;
3612*cdf0e10cSrcweir         }
3613*cdf0e10cSrcweir         else
3614*cdf0e10cSrcweir         {
3615*cdf0e10cSrcweir             if( rValue >>= mxStartPage )
3616*cdf0e10cSrcweir                 return;
3617*cdf0e10cSrcweir         }
3618*cdf0e10cSrcweir     }
3619*cdf0e10cSrcweir     else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("IsAlwaysOnTop") ) )
3620*cdf0e10cSrcweir     {
3621*cdf0e10cSrcweir         if( rValue >>= mbAlwaysOnTop )
3622*cdf0e10cSrcweir             return;
3623*cdf0e10cSrcweir     }
3624*cdf0e10cSrcweir     else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("IsAutomatic") ) )
3625*cdf0e10cSrcweir     {
3626*cdf0e10cSrcweir         if( rValue >>= mbManual )
3627*cdf0e10cSrcweir             return;
3628*cdf0e10cSrcweir     }
3629*cdf0e10cSrcweir     else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("IsEndless") ) )
3630*cdf0e10cSrcweir     {
3631*cdf0e10cSrcweir         if( rValue >>= mbEndless )
3632*cdf0e10cSrcweir             return;
3633*cdf0e10cSrcweir     }
3634*cdf0e10cSrcweir     else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("IsFullScreen") ) )
3635*cdf0e10cSrcweir     {
3636*cdf0e10cSrcweir         if( rValue >>= mbFullScreen )
3637*cdf0e10cSrcweir             return;
3638*cdf0e10cSrcweir     }
3639*cdf0e10cSrcweir     else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("IsMouseVisible") ) )
3640*cdf0e10cSrcweir     {
3641*cdf0e10cSrcweir         if( rValue >>= mbMouseVisible )
3642*cdf0e10cSrcweir             return;
3643*cdf0e10cSrcweir     }
3644*cdf0e10cSrcweir     else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Pause") ) )
3645*cdf0e10cSrcweir     {
3646*cdf0e10cSrcweir         sal_Int32 nPause = -1;
3647*cdf0e10cSrcweir         if( (rValue >>= nPause) && (nPause >= 0) )
3648*cdf0e10cSrcweir         {
3649*cdf0e10cSrcweir             mnPauseTimeout = nPause;
3650*cdf0e10cSrcweir             return;
3651*cdf0e10cSrcweir         }
3652*cdf0e10cSrcweir     }
3653*cdf0e10cSrcweir     else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("StartWithNavigator") ) )
3654*cdf0e10cSrcweir     {
3655*cdf0e10cSrcweir         if( rValue >>= mbStartWithNavigator )
3656*cdf0e10cSrcweir             return;
3657*cdf0e10cSrcweir     }
3658*cdf0e10cSrcweir     else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UsePen") ) )
3659*cdf0e10cSrcweir     {
3660*cdf0e10cSrcweir         if( rValue >>= mbMouseAsPen )
3661*cdf0e10cSrcweir             return;
3662*cdf0e10cSrcweir     }
3663*cdf0e10cSrcweir     throw IllegalArgumentException();
3664*cdf0e10cSrcweir }
3665*cdf0e10cSrcweir 
3666*cdf0e10cSrcweir ////////////////////////////////
3667*cdf0e10cSrcweir 
3668*cdf0e10cSrcweir // ---------------------------------------------------------
3669*cdf0e10cSrcweir // XAnimationListener
3670*cdf0e10cSrcweir // ---------------------------------------------------------
3671*cdf0e10cSrcweir 
3672*cdf0e10cSrcweir SlideShowListenerProxy::SlideShowListenerProxy( const rtl::Reference< SlideshowImpl >& xController, const css::uno::Reference< css::presentation::XSlideShow >& xSlideShow )
3673*cdf0e10cSrcweir : maListeners( m_aMutex )
3674*cdf0e10cSrcweir , mxController( xController )
3675*cdf0e10cSrcweir , mxSlideShow( xSlideShow )
3676*cdf0e10cSrcweir {
3677*cdf0e10cSrcweir }
3678*cdf0e10cSrcweir 
3679*cdf0e10cSrcweir // ---------------------------------------------------------
3680*cdf0e10cSrcweir 
3681*cdf0e10cSrcweir SlideShowListenerProxy::~SlideShowListenerProxy()
3682*cdf0e10cSrcweir {
3683*cdf0e10cSrcweir }
3684*cdf0e10cSrcweir 
3685*cdf0e10cSrcweir // ---------------------------------------------------------
3686*cdf0e10cSrcweir 
3687*cdf0e10cSrcweir void SlideShowListenerProxy::addAsSlideShowListener()
3688*cdf0e10cSrcweir {
3689*cdf0e10cSrcweir     if( mxSlideShow.is() )
3690*cdf0e10cSrcweir     {
3691*cdf0e10cSrcweir         Reference< XSlideShowListener > xSlideShowListener( this );
3692*cdf0e10cSrcweir         mxSlideShow->addSlideShowListener( xSlideShowListener );
3693*cdf0e10cSrcweir     }
3694*cdf0e10cSrcweir }
3695*cdf0e10cSrcweir 
3696*cdf0e10cSrcweir // ---------------------------------------------------------
3697*cdf0e10cSrcweir 
3698*cdf0e10cSrcweir void SlideShowListenerProxy::removeAsSlideShowListener()
3699*cdf0e10cSrcweir {
3700*cdf0e10cSrcweir     if( mxSlideShow.is() )
3701*cdf0e10cSrcweir     {
3702*cdf0e10cSrcweir         Reference< XSlideShowListener > xSlideShowListener( this );
3703*cdf0e10cSrcweir         mxSlideShow->removeSlideShowListener( xSlideShowListener );
3704*cdf0e10cSrcweir     }
3705*cdf0e10cSrcweir }
3706*cdf0e10cSrcweir 
3707*cdf0e10cSrcweir // ---------------------------------------------------------
3708*cdf0e10cSrcweir 
3709*cdf0e10cSrcweir void SlideShowListenerProxy::addShapeEventListener( const css::uno::Reference< css::drawing::XShape >& xShape )
3710*cdf0e10cSrcweir {
3711*cdf0e10cSrcweir     if( mxSlideShow.is() )
3712*cdf0e10cSrcweir     {
3713*cdf0e10cSrcweir         Reference< XShapeEventListener > xListener( this );
3714*cdf0e10cSrcweir         mxSlideShow->addShapeEventListener( xListener, xShape );
3715*cdf0e10cSrcweir     }
3716*cdf0e10cSrcweir }
3717*cdf0e10cSrcweir 
3718*cdf0e10cSrcweir // ---------------------------------------------------------
3719*cdf0e10cSrcweir 
3720*cdf0e10cSrcweir void SlideShowListenerProxy::removeShapeEventListener( const css::uno::Reference< css::drawing::XShape >& xShape )
3721*cdf0e10cSrcweir {
3722*cdf0e10cSrcweir     if( mxSlideShow.is() )
3723*cdf0e10cSrcweir     {
3724*cdf0e10cSrcweir         Reference< XShapeEventListener > xListener( this );
3725*cdf0e10cSrcweir         mxSlideShow->removeShapeEventListener( xListener, xShape );
3726*cdf0e10cSrcweir     }
3727*cdf0e10cSrcweir }
3728*cdf0e10cSrcweir 
3729*cdf0e10cSrcweir // ---------------------------------------------------------
3730*cdf0e10cSrcweir 
3731*cdf0e10cSrcweir void SlideShowListenerProxy::addSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& xListener )
3732*cdf0e10cSrcweir {
3733*cdf0e10cSrcweir     maListeners.addInterface(xListener);
3734*cdf0e10cSrcweir }
3735*cdf0e10cSrcweir 
3736*cdf0e10cSrcweir // ---------------------------------------------------------
3737*cdf0e10cSrcweir 
3738*cdf0e10cSrcweir void SlideShowListenerProxy::removeSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& xListener )
3739*cdf0e10cSrcweir {
3740*cdf0e10cSrcweir     maListeners.removeInterface(xListener);
3741*cdf0e10cSrcweir }
3742*cdf0e10cSrcweir 
3743*cdf0e10cSrcweir // ---------------------------------------------------------
3744*cdf0e10cSrcweir 
3745*cdf0e10cSrcweir void SAL_CALL SlideShowListenerProxy::beginEvent( const Reference< XAnimationNode >& xNode ) throw (RuntimeException)
3746*cdf0e10cSrcweir {
3747*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
3748*cdf0e10cSrcweir 
3749*cdf0e10cSrcweir     if( maListeners.getLength() >= 0 )
3750*cdf0e10cSrcweir         maListeners.forEach<XSlideShowListener>( boost::bind( &XAnimationListener::beginEvent, _1,  boost::cref(xNode) ));
3751*cdf0e10cSrcweir }
3752*cdf0e10cSrcweir 
3753*cdf0e10cSrcweir // ---------------------------------------------------------
3754*cdf0e10cSrcweir 
3755*cdf0e10cSrcweir void SAL_CALL SlideShowListenerProxy::endEvent( const Reference< XAnimationNode >& xNode ) throw (RuntimeException)
3756*cdf0e10cSrcweir {
3757*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
3758*cdf0e10cSrcweir 
3759*cdf0e10cSrcweir     if( maListeners.getLength() >= 0 )
3760*cdf0e10cSrcweir         maListeners.forEach<XSlideShowListener>( boost::bind( &XAnimationListener::endEvent, _1, boost::cref(xNode) ));
3761*cdf0e10cSrcweir }
3762*cdf0e10cSrcweir 
3763*cdf0e10cSrcweir // ---------------------------------------------------------
3764*cdf0e10cSrcweir 
3765*cdf0e10cSrcweir void SAL_CALL SlideShowListenerProxy::repeat( const Reference< XAnimationNode >& xNode, ::sal_Int32 nRepeat ) throw (RuntimeException)
3766*cdf0e10cSrcweir {
3767*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
3768*cdf0e10cSrcweir 
3769*cdf0e10cSrcweir     if( maListeners.getLength() >= 0 )
3770*cdf0e10cSrcweir         maListeners.forEach<XSlideShowListener>( boost::bind( &XAnimationListener::repeat, _1,  boost::cref(xNode), boost::cref(nRepeat) ));
3771*cdf0e10cSrcweir }
3772*cdf0e10cSrcweir 
3773*cdf0e10cSrcweir // ---------------------------------------------------------
3774*cdf0e10cSrcweir // ::com::sun::star::presentation::XSlideShowListener:
3775*cdf0e10cSrcweir // ---------------------------------------------------------
3776*cdf0e10cSrcweir 
3777*cdf0e10cSrcweir void SAL_CALL SlideShowListenerProxy::paused(  ) throw (::com::sun::star::uno::RuntimeException)
3778*cdf0e10cSrcweir {
3779*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
3780*cdf0e10cSrcweir 
3781*cdf0e10cSrcweir     if( maListeners.getLength() >= 0 )
3782*cdf0e10cSrcweir         maListeners.forEach<XSlideShowListener>( boost::mem_fn( &XSlideShowListener::paused ) );
3783*cdf0e10cSrcweir }
3784*cdf0e10cSrcweir 
3785*cdf0e10cSrcweir // ---------------------------------------------------------
3786*cdf0e10cSrcweir 
3787*cdf0e10cSrcweir void SAL_CALL SlideShowListenerProxy::resumed(  ) throw (::com::sun::star::uno::RuntimeException)
3788*cdf0e10cSrcweir {
3789*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
3790*cdf0e10cSrcweir 
3791*cdf0e10cSrcweir     if( maListeners.getLength() >= 0 )
3792*cdf0e10cSrcweir         maListeners.forEach<XSlideShowListener>( boost::mem_fn( &XSlideShowListener::resumed ) );
3793*cdf0e10cSrcweir }
3794*cdf0e10cSrcweir 
3795*cdf0e10cSrcweir // ---------------------------------------------------------
3796*cdf0e10cSrcweir 
3797*cdf0e10cSrcweir void SAL_CALL SlideShowListenerProxy::slideTransitionStarted( ) throw (RuntimeException)
3798*cdf0e10cSrcweir {
3799*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
3800*cdf0e10cSrcweir 
3801*cdf0e10cSrcweir     if( maListeners.getLength() >= 0 )
3802*cdf0e10cSrcweir         maListeners.forEach<XSlideShowListener>( boost::mem_fn( &XSlideShowListener::slideTransitionStarted ) );
3803*cdf0e10cSrcweir }
3804*cdf0e10cSrcweir 
3805*cdf0e10cSrcweir // ---------------------------------------------------------
3806*cdf0e10cSrcweir 
3807*cdf0e10cSrcweir void SAL_CALL SlideShowListenerProxy::slideTransitionEnded( ) throw (::com::sun::star::uno::RuntimeException)
3808*cdf0e10cSrcweir {
3809*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
3810*cdf0e10cSrcweir 
3811*cdf0e10cSrcweir     if( maListeners.getLength() >= 0 )
3812*cdf0e10cSrcweir         maListeners.forEach<XSlideShowListener>( boost::mem_fn( &XSlideShowListener::slideTransitionEnded ) );
3813*cdf0e10cSrcweir }
3814*cdf0e10cSrcweir 
3815*cdf0e10cSrcweir // ---------------------------------------------------------
3816*cdf0e10cSrcweir 
3817*cdf0e10cSrcweir void SAL_CALL SlideShowListenerProxy::slideAnimationsEnded(  ) throw (::com::sun::star::uno::RuntimeException)
3818*cdf0e10cSrcweir {
3819*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
3820*cdf0e10cSrcweir 
3821*cdf0e10cSrcweir     if( maListeners.getLength() >= 0 )
3822*cdf0e10cSrcweir         maListeners.forEach<XSlideShowListener>( boost::mem_fn( &XSlideShowListener::slideAnimationsEnded ) );
3823*cdf0e10cSrcweir }
3824*cdf0e10cSrcweir 
3825*cdf0e10cSrcweir // ---------------------------------------------------------
3826*cdf0e10cSrcweir 
3827*cdf0e10cSrcweir void SlideShowListenerProxy::slideEnded(sal_Bool bReverse) throw (RuntimeException)
3828*cdf0e10cSrcweir {
3829*cdf0e10cSrcweir     {
3830*cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
3831*cdf0e10cSrcweir 
3832*cdf0e10cSrcweir         if( maListeners.getLength() >= 0 )
3833*cdf0e10cSrcweir             maListeners.forEach<XSlideShowListener>(
3834*cdf0e10cSrcweir                 boost::bind( &XSlideShowListener::slideEnded, _1, bReverse) );
3835*cdf0e10cSrcweir     }
3836*cdf0e10cSrcweir 
3837*cdf0e10cSrcweir     {
3838*cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3839*cdf0e10cSrcweir         if( mxController.is() )
3840*cdf0e10cSrcweir             mxController->slideEnded(bReverse);
3841*cdf0e10cSrcweir     }
3842*cdf0e10cSrcweir }
3843*cdf0e10cSrcweir 
3844*cdf0e10cSrcweir // ---------------------------------------------------------
3845*cdf0e10cSrcweir 
3846*cdf0e10cSrcweir void SlideShowListenerProxy::hyperLinkClicked( rtl::OUString const& aHyperLink ) throw (RuntimeException)
3847*cdf0e10cSrcweir {
3848*cdf0e10cSrcweir     {
3849*cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
3850*cdf0e10cSrcweir 
3851*cdf0e10cSrcweir         if( maListeners.getLength() >= 0 )
3852*cdf0e10cSrcweir             maListeners.forEach<XSlideShowListener>( boost::bind( &XSlideShowListener::hyperLinkClicked, _1, boost::cref(aHyperLink) ));
3853*cdf0e10cSrcweir     }
3854*cdf0e10cSrcweir 
3855*cdf0e10cSrcweir     {
3856*cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3857*cdf0e10cSrcweir         if( mxController.is() )
3858*cdf0e10cSrcweir             mxController->hyperLinkClicked(aHyperLink);
3859*cdf0e10cSrcweir     }
3860*cdf0e10cSrcweir }
3861*cdf0e10cSrcweir 
3862*cdf0e10cSrcweir // ---------------------------------------------------------
3863*cdf0e10cSrcweir // XEventListener
3864*cdf0e10cSrcweir // ---------------------------------------------------------
3865*cdf0e10cSrcweir 
3866*cdf0e10cSrcweir void SAL_CALL SlideShowListenerProxy::disposing( const ::com::sun::star::lang::EventObject& aDisposeEvent ) throw (RuntimeException)
3867*cdf0e10cSrcweir {
3868*cdf0e10cSrcweir     maListeners.disposeAndClear( aDisposeEvent );
3869*cdf0e10cSrcweir     mxController.clear();
3870*cdf0e10cSrcweir     mxSlideShow.clear();
3871*cdf0e10cSrcweir }
3872*cdf0e10cSrcweir 
3873*cdf0e10cSrcweir // ---------------------------------------------------------
3874*cdf0e10cSrcweir // XShapeEventListener
3875*cdf0e10cSrcweir // ---------------------------------------------------------
3876*cdf0e10cSrcweir 
3877*cdf0e10cSrcweir void SAL_CALL SlideShowListenerProxy::click( const Reference< XShape >& xShape, const ::com::sun::star::awt::MouseEvent& aOriginalEvent ) throw (RuntimeException)
3878*cdf0e10cSrcweir {
3879*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3880*cdf0e10cSrcweir     if( mxController.is() )
3881*cdf0e10cSrcweir         mxController->click(xShape, aOriginalEvent );
3882*cdf0e10cSrcweir }
3883*cdf0e10cSrcweir 
3884*cdf0e10cSrcweir } // namespace ::sd
3885