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