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