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