1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: slideshowimpl.cxx,v $
10 * $Revision: 1.57.10.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_sd.hxx"
35 #include <boost/scoped_ptr.hpp>
37 #include <com/sun/star/lang/XInitialization.hpp>
38 #include <com/sun/star/document/XEventsSupplier.hpp>
39 #include <com/sun/star/drawing/XMasterPageTarget.hpp>
40 #include <com/sun/star/container/XNameReplace.hpp>
41 #include <com/sun/star/beans/PropertyValue.hpp>
42 #include <com/sun/star/beans/XPropertySetInfo.hpp>
43 #include <com/sun/star/beans/XPropertySet.hpp>
44 #include <com/sun/star/awt/SystemPointer.hpp>
45 #include <com/sun/star/util/XURLTransformer.hpp>
46 #include <com/sun/star/frame/XDispatch.hpp>
47 #include <com/sun/star/frame/XLayoutManager.hpp>
48 #include <vos/process.hxx>
49 #include <svtools/aeitem.hxx>
50 #include <svtools/urihelper.hxx>
52 #include <toolkit/unohlp.hxx>
54 #include <sfx2/imagemgr.hxx>
55 #include <sfx2/request.hxx>
56 #include "sfx2/docfile.hxx"
57 #include <svx/unoapi.hxx>
58 #include <svx/svdoole2.hxx>
60 // for child window ids
61 #include <sfx2/templdlg.hxx>
62 #include <svx/f3dchild.hxx>
63 #include <svx/imapdlg.hxx>
64 #include <svx/fontwork.hxx>
65 #include <svx/colrctrl.hxx>
66 #include <svx/bmpmask.hxx>
67 #include <svx/srchdlg.hxx>
68 #include <svx/hyprlink.hxx>
69 #include <svx/hyperdlg.hxx>
70 #include <svx/galbrws.hxx>
71 #include "NavigatorChildWindow.hxx"
72 #include "AnimationChildWindow.hxx"
73 #include <slideshowimpl.hxx>
74 #include <slideshowviewimpl.hxx>
76 #include "PaneHider.hxx"
79 #include "res_bmp.hrc"
80 #include "sdresid.hxx"
81 #include "vcl/canvastools.hxx"
82 #include "comphelper/anytostring.hxx"
83 #include "cppuhelper/exc_hlp.hxx"
84 #include "rtl/ref.hxx"
85 #include "slideshow.hrc"
86 #include "canvas/elapsedtime.hxx"
87 #include "canvas/prioritybooster.hxx"
88 #include "avmedia/mediawindow.hxx"
89 #include "svtools/colrdlg.hxx"
91 #include <boost/noncopyable.hpp>
92 #include <boost/bind.hpp>
94 using ::rtl::OUString
;
96 using ::cppu::OInterfaceContainerHelper
;
97 using ::comphelper::ImplementationReference
;
98 using ::com::sun::star::animations::XAnimationNode
;
99 using ::com::sun::star::animations::XAnimationListener
;
100 using ::com::sun::star::awt::XWindow
;
101 using namespace ::com::sun::star
;
102 using namespace ::com::sun::star::lang
;
103 using namespace ::com::sun::star::uno
;
104 using namespace ::com::sun::star::drawing
;
105 using namespace ::com::sun::star::container
;
106 using namespace ::com::sun::star::document
;
107 using namespace ::com::sun::star::presentation
;
108 using namespace ::com::sun::star::drawing
;
109 using namespace ::com::sun::star::beans
;
111 extern void NotifyDocumentEvent( SdDrawDocument
* pDocument
, const rtl::OUString
& rEventName
);
112 extern String
getUiNameFromPageApiNameImpl( const OUString
& rApiName
);
116 ///////////////////////////////////////////////////////////////////////
118 // Slots, welche im Sfx verwaltet werden und in der SlideShow disabled
119 // werden sollen (muss in Reihenfolge der SIDs geordnet sein)
120 static USHORT __READONLY_DATA pAllowed
[] =
122 SID_OPENDOC
, // 5501 // damit interne Spruenge klappen
123 SID_JUMPTOMARK
, // 5598
124 // SID_SHOWPOPUPS , // 5929
125 // SID_GALLERY , // 5960
126 SID_OPENHYPERLINK
, // 6676
127 // SID_GALLERY_FORMATS , // 10280
128 SID_NAVIGATOR
, // 10366
129 // SID_FM_DESIGN_MODE , // 10629
130 SID_PRESENTATION_END
, // 27218
131 SID_NAVIGATOR_PAGENAME
, // 27287
132 SID_NAVIGATOR_STATE
, // 27288
133 SID_NAVIGATOR_INIT
, // 27289
134 SID_NAVIGATOR_PEN
, // 27291
135 SID_NAVIGATOR_PAGE
, // 27292
136 SID_NAVIGATOR_OBJECT
// 27293
139 ///////////////////////////////////////////////////////////////////////
141 ///////////////////////////////////////////////////////////////////////
142 // AnimationSlideController
143 ///////////////////////////////////////////////////////////////////////
145 class AnimationSlideController
148 enum Mode
{ ALL
, FROM
, CUSTOM
, PREVIEW
};
151 AnimationSlideController( Reference
< XIndexAccess
> xSlides
, Mode eMode
);
153 void setStartSlideNumber( sal_Int32 nSlideNumber
) { mnStartSlideNumber
= nSlideNumber
; }
154 sal_Int32
getStartSlideIndex() const;
156 sal_Int32
getCurrentSlideNumber() const;
157 sal_Int32
getCurrentSlideIndex() const;
159 sal_Int32
getSlideIndexCount() const { return maSlideNumbers
.size(); }
160 sal_Int32
getSlideNumberCount() const { return mnSlideCount
; }
162 sal_Int32
getSlideNumber( sal_Int32 nSlideIndex
) const;
164 void insertSlideNumber( sal_Int32 nSlideNumber
, bool bVisible
= true );
165 void setPreviewNode( const Reference
< XAnimationNode
>& xPreviewNode
);
167 bool jumpToSlideIndex( sal_Int32 nNewSlideIndex
);
168 bool jumpToSlideNumber( sal_Int32 nNewSlideIndex
);
171 bool previousSlide();
173 void displayCurrentSlide(
174 const Reference
< XSlideShow
>& xShow
,
175 const bool bSkipAllMainSequenceEffects
);
177 sal_Int32
getNextSlideIndex() const;
178 sal_Int32
getPreviousSlideIndex() const;
180 bool isVisibleSlideNumber( sal_Int32 nSlideNumber
) const;
182 Reference
< XDrawPage
> getSlideByNumber( sal_Int32 nSlideNumber
) const;
184 sal_Int32
getNextSlideNumber() const;
186 bool hasSlides() const { return !maSlideNumbers
.empty(); }
189 bool getSlideAPI( sal_Int32 nSlideNumber
, Reference
< XDrawPage
>& xSlide
, Reference
< XAnimationNode
>& xAnimNode
);
190 sal_Int32
findSlideIndex( sal_Int32 nSlideNumber
) const;
192 bool isValidIndex( sal_Int32 nIndex
) const { return (nIndex
>= 0) && (nIndex
< (sal_Int32
)maSlideNumbers
.size()); }
193 bool isValidSlideNumber( sal_Int32 nSlideNumber
) const { return (nSlideNumber
>= 0) && (nSlideNumber
< mnSlideCount
); }
197 sal_Int32 mnStartSlideNumber
;
198 std::vector
< sal_Int32
> maSlideNumbers
;
199 std::vector
< bool > maSlideVisible
;
200 std::vector
< bool > maSlideVisited
;
201 Reference
< XAnimationNode
> mxPreviewNode
;
202 sal_Int32 mnSlideCount
;
203 sal_Int32 mnCurrentSlideIndex
;
204 sal_Int32 mnHiddenSlideNumber
;
205 Reference
< XIndexAccess
> mxSlides
;
208 Reference
< XDrawPage
> AnimationSlideController::getSlideByNumber( sal_Int32 nSlideNumber
) const
210 Reference
< XDrawPage
> xSlide
;
211 if( mxSlides
.is() && (nSlideNumber
>= 0) && (nSlideNumber
< mxSlides
->getCount()) )
212 mxSlides
->getByIndex( nSlideNumber
) >>= xSlide
;
216 bool AnimationSlideController::isVisibleSlideNumber( sal_Int32 nSlideNumber
) const
218 sal_Int32 nIndex
= findSlideIndex( nSlideNumber
);
221 return maSlideVisible
[ nIndex
];
227 void AnimationSlideController::setPreviewNode( const Reference
< XAnimationNode
>& xPreviewNode
)
229 mxPreviewNode
= xPreviewNode
;
232 AnimationSlideController::AnimationSlideController( Reference
< XIndexAccess
> xSlides
, Mode eMode
)
234 , mnStartSlideNumber(-1)
236 , mnCurrentSlideIndex(0)
237 , mnHiddenSlideNumber( -1 )
238 , mxSlides( xSlides
)
241 mnSlideCount
= xSlides
->getCount();
244 sal_Int32
AnimationSlideController::getStartSlideIndex() const
246 if( mnStartSlideNumber
>= 0 )
249 const sal_Int32 nCount
= maSlideNumbers
.size();
251 for( nIndex
= 0; nIndex
< nCount
; nIndex
++ )
253 if( maSlideNumbers
[nIndex
] == mnStartSlideNumber
)
261 sal_Int32
AnimationSlideController::getCurrentSlideNumber() const
263 if( mnHiddenSlideNumber
!= -1 )
264 return mnHiddenSlideNumber
;
265 else if( !maSlideNumbers
.empty() )
266 return maSlideNumbers
[mnCurrentSlideIndex
];
271 sal_Int32
AnimationSlideController::getCurrentSlideIndex() const
273 if( mnHiddenSlideNumber
!= -1 )
276 return mnCurrentSlideIndex
;
279 bool AnimationSlideController::jumpToSlideIndex( sal_Int32 nNewSlideIndex
)
281 if( isValidIndex( nNewSlideIndex
) )
283 mnCurrentSlideIndex
= nNewSlideIndex
;
284 mnHiddenSlideNumber
= -1;
285 maSlideVisited
[mnCurrentSlideIndex
] = true;
294 bool AnimationSlideController::jumpToSlideNumber( sal_Int32 nNewSlideNumber
)
296 sal_Int32 nIndex
= findSlideIndex( nNewSlideNumber
);
297 if( isValidIndex( nIndex
) )
299 return jumpToSlideIndex( nIndex
);
301 else if( (nNewSlideNumber
>= 0) && (nNewSlideNumber
< mnSlideCount
) )
303 // jump to a hidden slide
304 mnHiddenSlideNumber
= nNewSlideNumber
;
313 sal_Int32
AnimationSlideController::getSlideNumber( sal_Int32 nSlideIndex
) const
315 if( isValidIndex( nSlideIndex
) )
316 return maSlideNumbers
[nSlideIndex
];
321 void AnimationSlideController::insertSlideNumber( sal_Int32 nSlideNumber
, bool bVisible
/* = true */ )
323 DBG_ASSERT( isValidSlideNumber( nSlideNumber
), "sd::AnimationSlideController::insertSlideNumber(), illegal index" );
324 if( isValidSlideNumber( nSlideNumber
) )
326 maSlideNumbers
.push_back( nSlideNumber
);
327 maSlideVisible
.push_back( bVisible
);
328 maSlideVisited
.push_back( false );
332 bool AnimationSlideController::getSlideAPI( sal_Int32 nSlideNumber
, Reference
< XDrawPage
>& xSlide
, Reference
< XAnimationNode
>& xAnimNode
)
334 if( isValidSlideNumber( nSlideNumber
) ) try
336 xSlide
= Reference
< XDrawPage
>( mxSlides
->getByIndex(nSlideNumber
), UNO_QUERY_THROW
);
338 if( meMode
== PREVIEW
)
340 xAnimNode
= mxPreviewNode
;
344 Reference
< animations::XAnimationNodeSupplier
> xAnimNodeSupplier( xSlide
, UNO_QUERY_THROW
);
345 xAnimNode
= xAnimNodeSupplier
->getAnimationNode();
350 catch( Exception
& e
)
354 (OString("sd::AnimationSlideController::getSlideAPI(), "
355 "exception caught: ") +
356 rtl::OUStringToOString(
357 comphelper::anyToString( cppu::getCaughtException() ),
358 RTL_TEXTENCODING_UTF8
)).getStr() );
365 sal_Int32
AnimationSlideController::findSlideIndex( sal_Int32 nSlideNumber
) const
368 const sal_Int32 nCount
= maSlideNumbers
.size();
370 for( nIndex
= 0; nIndex
< nCount
; nIndex
++ )
372 if( maSlideNumbers
[nIndex
] == nSlideNumber
)
379 sal_Int32
AnimationSlideController::getNextSlideIndex() const
385 sal_Int32 nNewSlideIndex
= mnCurrentSlideIndex
+ 1;
386 if( isValidIndex( nNewSlideIndex
) )
388 // if the current slide is not excluded, make sure the
389 // next slide is also not excluded.
390 // if the current slide is excluded, we want to go
391 // to the next slide, even if this is also excluded.
392 if( maSlideVisible
[mnCurrentSlideIndex
] )
394 while( isValidIndex( nNewSlideIndex
) )
396 if( maSlideVisible
[nNewSlideIndex
] )
403 return isValidIndex( nNewSlideIndex
) ? nNewSlideIndex
: -1;
408 return mnHiddenSlideNumber
== -1 ? mnCurrentSlideIndex
+ 1 : mnCurrentSlideIndex
;
417 sal_Int32
AnimationSlideController::getNextSlideNumber() const
419 sal_Int32 nNextSlideIndex
= getNextSlideIndex();
420 if( isValidIndex( nNextSlideIndex
) )
422 return maSlideNumbers
[nNextSlideIndex
];
431 bool AnimationSlideController::nextSlide()
433 return jumpToSlideIndex( getNextSlideIndex() );
436 sal_Int32
AnimationSlideController::getPreviousSlideIndex() const
438 sal_Int32 nNewSlideIndex
= mnCurrentSlideIndex
- 1;
444 // make sure the previous slide is visible
445 // or was already visited
446 while( isValidIndex( nNewSlideIndex
) )
448 if( maSlideVisible
[nNewSlideIndex
] || maSlideVisited
[nNewSlideIndex
] )
464 return nNewSlideIndex
;
467 bool AnimationSlideController::previousSlide()
469 return jumpToSlideIndex( getPreviousSlideIndex() );
472 void AnimationSlideController::displayCurrentSlide(
473 const Reference
< XSlideShow
>& xShow
,
474 const bool bSkipAllMainSequenceEffects
)
476 const sal_Int32 nCurrentSlideNumber
= getCurrentSlideNumber();
478 if( xShow
.is() && (nCurrentSlideNumber
!= -1 ) )
480 Reference
< XDrawPage
> xSlide
;
481 Reference
< XAnimationNode
> xAnimNode
;
482 ::std::vector
<PropertyValue
> aProperties
;
484 const sal_Int32 nNextSlideNumber
= getNextSlideNumber();
485 if( getSlideAPI( nNextSlideNumber
, xSlide
, xAnimNode
) )
487 Sequence
< Any
> aValue(2);
488 aValue
[0] <<= xSlide
;
489 aValue
[1] <<= xAnimNode
;
490 aProperties
.push_back(
492 OUString( RTL_CONSTASCII_USTRINGPARAM( "Prefetch" ) ),
495 PropertyState_DIRECT_VALUE
));
497 if (bSkipAllMainSequenceEffects
)
499 // Add one property that prevents the slide transition from being
500 // shown (to speed up the transition to the previous slide) and
501 // one to show all main sequence effects so that the user can
502 // continue to undo effects.
503 aProperties
.push_back(
505 OUString( RTL_CONSTASCII_USTRINGPARAM("SkipAllMainSequenceEffects")),
508 PropertyState_DIRECT_VALUE
));
509 aProperties
.push_back(
511 OUString( RTL_CONSTASCII_USTRINGPARAM("SkipSlideTransition")),
514 PropertyState_DIRECT_VALUE
));
517 // Convert vector into uno Sequence.
518 Sequence
< PropertyValue
> aPropertySequence (aProperties
.size());
519 for (int nIndex
=0,nCount
=aProperties
.size();nIndex
<nCount
; ++nIndex
)
520 aPropertySequence
[nIndex
] = aProperties
[nIndex
];
522 if( getSlideAPI( nCurrentSlideNumber
, xSlide
, xAnimNode
) )
523 xShow
->displaySlide( xSlide
, xAnimNode
, aPropertySequence
);
527 ///////////////////////////////////////////////////////////////////////
528 // class SlideshowImpl
529 ///////////////////////////////////////////////////////////////////////
531 SlideshowImpl::SlideshowImpl( const Reference
< XPresentation2
>& xPresentation
, ViewShell
* pViewSh
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, ::Window
* pParentWindow
)
532 : SlideshowImplBase( m_aMutex
)
533 , mxModel(pDoc
->getUnoModel(),UNO_QUERY_THROW
)
535 , mpViewShell(pViewSh
)
536 , mpDocSh(pDoc
->GetDocSh())
539 , mpParentWindow(pParentWindow
)
543 , maPresSize( -1, -1 )
544 , meAnimationMode(ANIMATIONMODE_SHOW
)
545 , mpOldActiveWindow(0)
547 , mbGridVisible(false)
548 , mbBordVisible(false)
549 , mbSlideBorderVisible(false)
550 , mbSetOnlineSpelling(false)
552 , mbRehearseTimings(false)
553 , mbDesignMode(false)
555 , mbInputFreeze(false)
556 , mbActive(sal_False
)
557 , maPresSettings( pDoc
->getPresentationSettings() )
558 , mnUserPaintColor( 0x00000000L
)
559 , mdUserPaintStrokeWidth ( 4.0 )
561 , mnLastSlideNumber(-1)
562 , msOnClick( RTL_CONSTASCII_USTRINGPARAM("OnClick") )
563 , msBookmark( RTL_CONSTASCII_USTRINGPARAM("Bookmark") )
564 , msVerb( RTL_CONSTASCII_USTRINGPARAM("Verb") )
566 , mnContextMenuEvent(0)
568 , mxPresentation( xPresentation
)
571 mpOldActiveWindow
= mpViewShell
->GetActiveWindow();
573 maUpdateTimer
.SetTimeoutHdl(LINK(this, SlideshowImpl
, updateHdl
));
575 maDeactivateTimer
.SetTimeoutHdl(LINK(this, SlideshowImpl
, deactivateHdl
));
576 maDeactivateTimer
.SetTimeout( 20 );
578 maInputFreezeTimer
.SetTimeoutHdl( LINK( this, SlideshowImpl
, ReadyForNextInputHdl
) );
579 maInputFreezeTimer
.SetTimeout( 20 );
581 SvtSaveOptions aOptions
;
583 // no autosave during show
584 if( aOptions
.IsAutoSave() )
585 mbAutoSaveWasOn
= true;
587 Application::AddEventListener( LINK( this, SlideshowImpl
, EventListenerHdl
) );
590 SlideshowImpl::~SlideshowImpl()
592 Application::RemoveEventListener( LINK( this, SlideshowImpl
, EventListenerHdl
) );
594 maDeactivateTimer
.Stop();
598 DBG_ERROR("SlideshowImpl::~SlideshowImpl(), component was not disposed!");
603 void SAL_CALL
SlideshowImpl::disposing()
605 if( mxShow
.is() && mpDoc
)
606 NotifyDocumentEvent( mpDoc
, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OnEndPresentation") ) );
608 if( mbAutoSaveWasOn
)
609 setAutoSaveState( true );
612 Application::RemoveUserEvent( mnEndShowEvent
);
613 if( mnContextMenuEvent
)
614 Application::RemoveUserEvent( mnContextMenuEvent
);
616 maInputFreezeTimer
.Stop();
618 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
623 if( mxPresentation
.is() )
624 mxPresentation
->end();
626 maUpdateTimer
.Stop();
630 Application::RemoveUserEvent( mnUpdateEvent
);
636 if( mxListenerProxy
.is() )
637 mxListenerProxy
->removeAsSlideShowListener();
642 mxShow
->removeView( mxView
.getRef() );
644 Reference
< XComponent
> xComponent( mxShow
, UNO_QUERY
);
645 if( xComponent
.is() )
646 xComponent
->dispose();
651 catch( Exception
& e
)
653 static_cast<void>(e
);
655 (OString("sd::SlideshowImpl::stop(), "
656 "exception caught: ") +
657 rtl::OUStringToOString(
658 comphelper::anyToString( cppu::getCaughtException() ),
659 RTL_TEXTENCODING_UTF8
)).getStr() );
665 mxListenerProxy
.clear();
666 mpSlideController
.reset();
668 // der DrawView das Praesentationfenster wegnehmen und ihr dafuer ihre alten Fenster wiedergeben
669 if( mpShowWindow
&& mpView
)
670 mpView
->DeleteWindowFromPaintView( mpShowWindow
);
673 mpView
->SetAnimationPause( FALSE
);
677 mpViewShell
->SetActiveWindow(mpOldActiveWindow
);
678 mpShowWindow
->SetViewShell( NULL
);
682 mpView
->InvalidateAllWin();
684 if( maPresSettings
.mbFullScreen
)
686 // restore StarBASICErrorHdl
687 StarBASIC::SetGlobalErrorHdl(maStarBASICGlobalErrorHdl
);
688 maStarBASICGlobalErrorHdl
= Link();
693 mpShowWindow
->Hide();
696 if( meAnimationMode
== ANIMATIONMODE_SHOW
)
698 mpDocSh
->SetSlotFilter();
699 mpDocSh
->ApplySlotFilter();
701 Help::EnableContextHelp();
702 Help::EnableExtHelp();
708 // aktuelle Fenster wieder einblenden
709 if( mpViewShell
&& !mpViewShell
->ISA(PresentationViewShell
))
711 if( meAnimationMode
== ANIMATIONMODE_SHOW
)
713 mpViewShell
->GetViewShellBase().ShowUIControls (true);
716 else if( meAnimationMode
== ANIMATIONMODE_PREVIEW
)
718 mpViewShell
->ShowUIControls (true);
724 mpTimeButton
->Hide();
730 mpShowWindow
->Hide();
734 if( meAnimationMode
== ANIMATIONMODE_SHOW
)
736 ::sd::Window
* pActWin
= mpViewShell
->GetActiveWindow();
740 Size aVisSizePixel
= pActWin
->GetOutputSizePixel();
741 Rectangle aVisAreaWin
= pActWin
->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel
) );
742 mpViewShell
->VisAreaChanged(aVisAreaWin
);
743 mpView
->VisAreaChanged(pActWin
);
744 pActWin
->GrabFocus();
748 // restart the custom show dialog if he started us
749 if( mpViewShell
->IsStartShowWithDialog() && getDispatcher() )
751 mpViewShell
->SetStartShowWithDialog( FALSE
);
752 getDispatcher()->Execute( SID_CUSTOMSHOW_DLG
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
755 mpViewShell
->GetViewShellBase().UpdateBorder(true);
764 setActiveXToolbarsVisible( sal_True
);
769 bool SlideshowImpl::startPreview(
770 const Reference
< XDrawPage
>& xDrawPage
,
771 const Reference
< XAnimationNode
>& xAnimationNode
,
778 const Reference
<lang::XServiceInfo
> xServiceInfo( xDrawPage
, UNO_QUERY
);
779 if (xServiceInfo
.is()) {
780 const Sequence
<OUString
> supportedServices(
781 xServiceInfo
->getSupportedServiceNames() );
782 for ( sal_Int32 pos
= supportedServices
.getLength(); pos
--; ) {
783 if (supportedServices
[pos
].equalsAsciiL(
784 RTL_CONSTASCII_STRINGPARAM(
785 "com.sun.star.drawing.MasterPage") )) {
786 DBG_ERROR("sd::SlideshowImpl::startPreview() "
787 "not allowed on master page!");
793 mxPreviewDrawPage
= xDrawPage
;
794 mxPreviewAnimationNode
= xAnimationNode
;
795 meAnimationMode
= ANIMATIONMODE_PREVIEW
;
797 maPresSettings
.mbAll
= sal_False
;
798 maPresSettings
.mbEndless
= sal_False
;
799 maPresSettings
.mbCustomShow
= sal_False
;
800 maPresSettings
.mbManual
= sal_False
;
801 maPresSettings
.mbMouseVisible
= sal_False
;
802 maPresSettings
.mbMouseAsPen
= sal_False
;
803 maPresSettings
.mbLockedPages
= sal_False
;
804 maPresSettings
.mbAlwaysOnTop
= sal_False
;
805 maPresSettings
.mbFullScreen
= sal_False
;
806 maPresSettings
.mbAnimationAllowed
= sal_True
;
807 maPresSettings
.mnPauseTimeout
= 0;
808 maPresSettings
.mbShowPauseLogo
= sal_False
;
809 maPresSettings
.mbStartWithNavigator
= sal_False
;
811 Reference
< XDrawPagesSupplier
> xDrawPages( mpDoc
->getUnoModel(), UNO_QUERY_THROW
);
812 Reference
< XIndexAccess
> xSlides( xDrawPages
->getDrawPages(), UNO_QUERY_THROW
);
813 mpSlideController
.reset( new AnimationSlideController( xSlides
, AnimationSlideController::PREVIEW
) );
815 sal_Int32 nSlideNumber
= 0;
816 Reference
< XPropertySet
> xSet( mxPreviewDrawPage
, UNO_QUERY_THROW
);
817 xSet
->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Number" ) ) ) >>= nSlideNumber
;
818 mpSlideController
->insertSlideNumber( nSlideNumber
-1 );
819 mpSlideController
->setPreviewNode( xAnimationNode
);
821 mpShowWindow
= new ShowWindow( this, ((pParent
== 0) && mpViewShell
) ? mpParentWindow
: pParent
);
824 mpViewShell
->SetActiveWindow( mpShowWindow
);
825 mpShowWindow
->SetViewShell (mpViewShell
);
826 mpViewShell
->ShowUIControls (false);
831 mpView
->AddWindowToPaintView( mpShowWindow
);
832 mpView
->SetAnimationPause( TRUE
);
835 // call resize handler
838 maPresSize
= pParent
->GetSizePixel();
840 else if( mpViewShell
)
842 Rectangle
aContentRect (mpViewShell
->GetViewShellBase().getClientRectangle());
843 if (Application::GetSettings().GetLayoutRTL())
845 aContentRect
.nLeft
= aContentRect
.nRight
;
846 aContentRect
.nRight
+= aContentRect
.nRight
;
848 maPresSize
= aContentRect
.GetSize();
849 mpShowWindow
->SetPosPixel( aContentRect
.TopLeft() );
853 DBG_ERROR("sd::SlideshowImpl::startPreview(), I need either a parent window or a viewshell!");
855 resize( maPresSize
);
857 sal_Int32 nPropertyCount
= 1;
858 if( mxPreviewAnimationNode
.is() )
861 Sequence
< beans::PropertyValue
> aProperties(nPropertyCount
);
862 aProperties
[0].Name
= OUString( RTL_CONSTASCII_USTRINGPARAM("AutomaticAdvancement") );
863 aProperties
[0].Value
= uno::makeAny( (double)1.0 ); // one second timeout
865 if( mxPreviewAnimationNode
.is() )
867 aProperties
[1].Name
= OUString( RTL_CONSTASCII_USTRINGPARAM("NoSlideTransitions") );
868 aProperties
[1].Value
= uno::makeAny( sal_True
);
871 bRet
= startShowImpl( aProperties
);
873 if( mpShowWindow
!= 0 && meAnimationMode
== ANIMATIONMODE_PREVIEW
)
874 mpShowWindow
->SetPreviewMode();
877 catch( Exception
& e
)
881 (OString("sd::SlideshowImpl::startPreview(), "
882 "exception caught: ") +
883 rtl::OUStringToOString(
884 comphelper::anyToString( cppu::getCaughtException() ),
885 RTL_TEXTENCODING_UTF8
)).getStr() );
892 bool SlideshowImpl::startShow( PresentationSettingsEx
* pPresSettings
)
894 const rtl::Reference
<SlideshowImpl
> this_(this);
896 DBG_ASSERT( !mxShow
.is(), "sd::SlideshowImpl::startShow(), called twice!" );
899 DBG_ASSERT( mpParentWindow
!=NULL
, "sd::SlideshowImpl::startShow() called without parent window" );
900 if (mpParentWindow
== NULL
)
909 maPresSettings
= *pPresSettings
;
910 mbRehearseTimings
= pPresSettings
->mbRehearseTimings
;
915 String
aPresSlide( maPresSettings
.maPresPage
);
916 SdPage
* pStartPage
= mpViewShell
? mpViewShell
->GetActualPage() : 0;
917 bool bStartWithActualSlide
= pStartPage
&&
918 ( (meAnimationMode
!= ANIMATIONMODE_SHOW
) ||
919 SD_MOD()->GetSdOptions( mpDoc
->GetDocumentType() )->IsStartWithActualPage() );
921 // sollen Zeiten gestoppt werden?
922 if( mbRehearseTimings
)
924 maPresSettings
.mbEndless
= sal_False
;
925 maPresSettings
.mbManual
= sal_True
;
926 maPresSettings
.mbMouseVisible
= sal_True
;
927 maPresSettings
.mbMouseAsPen
= sal_False
;
928 maPresSettings
.mnPauseTimeout
= 0;
929 maPresSettings
.mbShowPauseLogo
= sal_False
;
930 maPresSettings
.mbStartWithNavigator
= sal_False
;
935 if( pStartPage
->GetPageKind() == PK_NOTES
)
937 // we are in notes page mode, so get
938 // the corresponding draw page
939 const USHORT nPgNum
= ( pStartPage
->GetPageNum() - 2 ) >> 1;
940 pStartPage
= mpDoc
->GetSdPage( nPgNum
, PK_STANDARD
);
944 if( bStartWithActualSlide
)
946 if( meAnimationMode
!= ANIMATIONMODE_SHOW
)
948 if( pStartPage
->GetPageKind() == PK_STANDARD
)
950 aPresSlide
= pStartPage
->GetName();
951 maPresSettings
.mbAll
= false;
955 bStartWithActualSlide
= false;
961 if( pStartPage
->GetPageKind() != PK_STANDARD
)
963 bStartWithActualSlide
= false;
968 createSlideList( maPresSettings
.mbAll
, false, aPresSlide
);
970 if( bStartWithActualSlide
)
972 sal_Int32 nSlideNum
= ( pStartPage
->GetPageNum() - 1 ) >> 1;
974 if( !maPresSettings
.mbAll
&& !maPresSettings
.mbCustomShow
)
976 // its start from dia, find out if it is located before our current Slide
977 const sal_Int32 nSlideCount
= mpDoc
->GetSdPageCount( PK_STANDARD
);
979 for( nSlide
= 0; (nSlide
< nSlideCount
); nSlide
++ )
981 if( mpDoc
->GetSdPage( (USHORT
) nSlide
, PK_STANDARD
)->GetName() == aPresSlide
)
985 if( nSlide
> nSlideNum
)
989 if( nSlideNum
!= -1 )
990 mpSlideController
->setStartSlideNumber( nSlideNum
);
993 // remember Slide number from where the show was started
995 mnRestoreSlide
= ( pStartPage
->GetPageNum() - 1 ) / 2;
997 if( mpSlideController
->hasSlides() )
999 // hide child windows
1002 mpShowWindow
= new ShowWindow( this, mpParentWindow
);
1003 mpShowWindow
->SetMouseAutoHide( !maPresSettings
.mbMouseVisible
);
1006 mpViewShell
->SetActiveWindow( mpShowWindow
);
1007 mpShowWindow
->SetViewShell (mpViewShell
);
1008 mpViewShell
->GetViewShellBase().ShowUIControls (false);
1009 // Hide the side panes for in-place presentations.
1010 if ( ! maPresSettings
.mbFullScreen
)
1011 mpPaneHider
.reset(new PaneHider(*mpViewShell
,this));
1013 if( getViewFrame() )
1014 getViewFrame()->SetChildWindow( SID_NAVIGATOR
, maPresSettings
.mbStartWithNavigator
);
1017 // these Slots are forbiden in other views for this document
1020 mpDocSh
->SetSlotFilter( TRUE
, sizeof( pAllowed
) / sizeof( USHORT
), pAllowed
);
1021 mpDocSh
->ApplySlotFilter();
1024 Help::DisableContextHelp();
1025 Help::DisableExtHelp();
1027 // mpTimeButton = new PushButton( mpShowWindow, SdResId( RID_TIME_BUTTON ) );
1028 // maPencil = Pointer( POINTER_PEN );
1029 // mpTimeButton->Hide();
1031 if( maPresSettings
.mbFullScreen
)
1033 // disable basic ide error handling
1034 maStarBASICGlobalErrorHdl
= StarBASIC::GetGlobalErrorHdl();
1035 StarBASIC::SetGlobalErrorHdl( Link() );
1038 // call resize handler
1039 maPresSize
= mpParentWindow
->GetSizePixel();
1040 if( !maPresSettings
.mbFullScreen
&& mpViewShell
)
1042 const Rectangle
& aClientRect
= mpViewShell
->GetViewShellBase().getClientRectangle();
1043 maPresSize
= aClientRect
.GetSize();
1044 mpShowWindow
->SetPosPixel( aClientRect
.TopLeft() );
1045 resize( maPresSize
);
1049 // Note: In FullScreen Mode the OS (window manager) sends a resize to
1050 // the WorkWindow once it actually resized it to full size. The
1051 // WorkWindow propagates the resize to the DrawViewShell which calls
1052 // resize() at the SlideShow (this). Calling resize here results in a
1053 // temporary display of a black window in the window's default size
1056 if ( mbRehearseTimings )
1058 Size aButtonSizePixel( pTimeButton->GetSizePixel() );
1059 Point aButtonPosPixel( aButtonSizePixel.Width() >> 1, pShowWindow->GetSizePixel().Height() - aButtonSizePixel.Height() * 5 / 2);
1061 pTimeButton->SetPosPixel( aButtonPosPixel );
1062 aTimer.SetTimeoutHdl( LINK( this,FuSlideShow, TimeButtonTimeOutHdl ) );
1063 pTimeButton->SetClickHdl( LINK( this, FuSlideShow, TimeButtonHdl ) );
1069 mpView
->AddWindowToPaintView( mpShowWindow
);
1070 mpView
->SetAnimationPause( TRUE
);
1073 SfxBindings
* pBindings
= getBindings();
1076 pBindings
->Invalidate( SID_PRESENTATION
);
1077 pBindings
->Invalidate( SID_REHEARSE_TIMINGS
);
1080 mpShowWindow
->GrabFocus();
1082 std::vector
<beans::PropertyValue
> aProperties
;
1083 aProperties
.reserve( 4 );
1085 aProperties
.push_back(
1086 beans::PropertyValue(
1087 OUString( RTL_CONSTASCII_USTRINGPARAM("AdvanceOnClick") ),
1088 -1, Any( ! (maPresSettings
.mbLockedPages
!= sal_False
) ),
1089 beans::PropertyState_DIRECT_VALUE
) );
1091 aProperties
.push_back(
1092 beans::PropertyValue(
1093 OUString( RTL_CONSTASCII_USTRINGPARAM("ImageAnimationsAllowed") ),
1094 -1, Any( maPresSettings
.mbAnimationAllowed
!= sal_False
),
1095 beans::PropertyState_DIRECT_VALUE
) );
1097 const sal_Bool
bZOrderEnabled(
1098 SD_MOD()->GetSdOptions( mpDoc
->GetDocumentType() )->IsSlideshowRespectZOrder() );
1099 aProperties
.push_back(
1100 beans::PropertyValue(
1101 OUString( RTL_CONSTASCII_USTRINGPARAM("DisableAnimationZOrder") ),
1102 -1, Any( bZOrderEnabled
== sal_False
),
1103 beans::PropertyState_DIRECT_VALUE
) );
1106 aProperties.push_back(
1107 beans::PropertyValue(
1108 OUString( RTL_CONSTASCII_USTRINGPARAM("MouseVisible") ),
1109 -1, Any( maPresSettings.mbMouseVisible != sal_False ),
1110 beans::PropertyState_DIRECT_VALUE ) );
1112 aProperties
.push_back(
1113 beans::PropertyValue(
1114 OUString( RTL_CONSTASCII_USTRINGPARAM("ForceManualAdvance") ),
1115 -1, Any( maPresSettings
.mbManual
!= sal_False
),
1116 beans::PropertyState_DIRECT_VALUE
) );
1118 if( maPresSettings
.mbMouseAsPen
)
1120 aProperties
.push_back(
1121 beans::PropertyValue(
1122 OUString( RTL_CONSTASCII_USTRINGPARAM("UserPaintColor") ),
1123 -1, Any( static_cast<sal_Int32
>(0x0000FF00L
) ),
1124 beans::PropertyState_DIRECT_VALUE
) );
1127 if (mbRehearseTimings
) {
1128 aProperties
.push_back(
1129 beans::PropertyValue(
1130 OUString( RTL_CONSTASCII_USTRINGPARAM("RehearseTimings") ),
1131 -1, Any(true), beans::PropertyState_DIRECT_VALUE
) );
1134 bRet
= startShowImpl( Sequence
<beans::PropertyValue
>(
1135 &aProperties
[0], aProperties
.size() ) );
1139 setActiveXToolbarsVisible( sal_False
);
1141 catch( Exception
& e
)
1145 (OString("sd::SlideshowImpl::startShow(), "
1146 "exception caught: ") +
1147 rtl::OUStringToOString(
1148 comphelper::anyToString( cppu::getCaughtException() ),
1149 RTL_TEXTENCODING_UTF8
)).getStr() );
1156 bool SlideshowImpl::startShowImpl( const Sequence
< beans::PropertyValue
>& aProperties
)
1160 mxShow
= Reference
< XSlideShow
>( createSlideShow(), UNO_QUERY_THROW
);
1161 mxView
= mxView
.createFromQuery( new SlideShowView(
1166 maPresSettings
.mbFullScreen
) );
1168 // try add wait symbol to properties:
1169 const Reference
<rendering::XSpriteCanvas
> xSpriteCanvas(
1170 mxView
->getCanvas() );
1171 if (xSpriteCanvas
.is())
1173 BitmapEx
waitSymbolBitmap( SdResId(BMP_WAIT_ICON
) );
1174 const Reference
<rendering::XBitmap
> xBitmap(
1175 vcl::unotools::xBitmapFromBitmapEx(
1176 xSpriteCanvas
->getDevice(), waitSymbolBitmap
) );
1179 mxShow
->setProperty(
1180 beans::PropertyValue(
1181 OUString( RTL_CONSTASCII_USTRINGPARAM("WaitSymbolBitmap") ),
1184 beans::PropertyState_DIRECT_VALUE
) );
1188 const sal_Int32 nCount
= aProperties
.getLength();
1190 for( nIndex
= 0; nIndex
< nCount
; nIndex
++ )
1191 mxShow
->setProperty( aProperties
[nIndex
] );
1193 mxShow
->addView( mxView
.getRef() );
1195 mxListenerProxy
.set( new SlideShowListenerProxy( this, mxShow
) );
1196 mxListenerProxy
->addAsSlideShowListener();
1199 NotifyDocumentEvent( mpDoc
, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OnStartPresentation") ) );
1200 displaySlideIndex( mpSlideController
->getStartSlideIndex() );
1204 catch( Exception
& e
)
1208 (OString("sd::SlideshowImpl::startShowImpl(), "
1209 "exception caught: ") +
1210 rtl::OUStringToOString(
1211 comphelper::anyToString( cppu::getCaughtException() ),
1212 RTL_TEXTENCODING_UTF8
)).getStr() );
1217 /** called only by the slideshow view when the first paint event occurs.
1218 This actually starts the slideshow. */
1219 void SlideshowImpl::onFirstPaint()
1223 mpShowWindow
->SetBackground( Wallpaper( Color( COL_BLACK
) ) );
1224 mpShowWindow
->Erase();
1225 mpShowWindow
->SetBackground();
1228 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
1229 maUpdateTimer
.SetTimeout( (ULONG
)100 );
1230 maUpdateTimer
.Start();
1233 void SlideshowImpl::paint( const Rectangle
& /* rRect */ )
1235 if( mxView
.is() ) try
1237 awt::PaintEvent aEvt
;
1238 // aEvt.UpdateRect = TODO
1239 mxView
->paint( aEvt
);
1241 catch( Exception
& e
)
1243 static_cast<void>(e
);
1245 (OString("sd::SlideshowImpl::paint(), "
1246 "exception caught: ") +
1247 rtl::OUStringToOString(
1248 comphelper::anyToString( cppu::getCaughtException() ),
1249 RTL_TEXTENCODING_UTF8
)).getStr() );
1253 // --------------------------------------------------------------------
1255 void SAL_CALL
SlideshowImpl::addSlideShowListener( const Reference
< XSlideShowListener
>& xListener
) throw (RuntimeException
)
1257 if( mxListenerProxy
.is() )
1258 mxListenerProxy
->addSlideShowListener( xListener
);
1261 // --------------------------------------------------------------------
1263 void SAL_CALL
SlideshowImpl::removeSlideShowListener( const Reference
< XSlideShowListener
>& xListener
) throw (RuntimeException
)
1265 if( mxListenerProxy
.is() )
1266 mxListenerProxy
->removeSlideShowListener( xListener
);
1269 // ---------------------------------------------------------
1271 void SlideshowImpl::slideEnded(const bool bReverse
)
1274 gotoPreviousSlide(true);
1279 // ---------------------------------------------------------
1281 void SlideshowImpl::removeShapeEvents()
1283 if( mxShow
.is() && mxListenerProxy
.is() ) try
1285 WrappedShapeEventImplMap::iterator aIter
;
1286 const WrappedShapeEventImplMap::iterator
aEnd( maShapeEventMap
.end() );
1288 for( aIter
= maShapeEventMap
.begin(); aIter
!= aEnd
; aIter
++ )
1290 mxListenerProxy
->removeShapeEventListener( (*aIter
).first
);
1291 mxShow
->setShapeCursor( (*aIter
).first
, awt::SystemPointer::ARROW
);
1294 maShapeEventMap
.clear();
1296 catch( Exception
& e
)
1300 (OString("sd::SlideshowImpl::removeShapeEvents(), "
1301 "exception caught: ") +
1302 rtl::OUStringToOString(
1303 comphelper::anyToString( cppu::getCaughtException() ),
1304 RTL_TEXTENCODING_UTF8
)).getStr() );
1308 // ---------------------------------------------------------
1310 void SlideshowImpl::registerShapeEvents(sal_Int32 nSlideNumber
)
1312 if( nSlideNumber
>= 0 ) try
1314 Reference
< XDrawPagesSupplier
> xDrawPages( mxModel
, UNO_QUERY_THROW
);
1315 Reference
< XIndexAccess
> xPages( xDrawPages
->getDrawPages(), UNO_QUERY_THROW
);
1317 Reference
< XShapes
> xDrawPage
;
1318 xPages
->getByIndex(nSlideNumber
) >>= xDrawPage
;
1320 if( xDrawPage
.is() )
1322 Reference
< XMasterPageTarget
> xMasterPageTarget( xDrawPage
, UNO_QUERY
);
1323 if( xMasterPageTarget
.is() )
1325 Reference
< XShapes
> xMasterPage( xMasterPageTarget
->getMasterPage(), UNO_QUERY
);
1326 if( xMasterPage
.is() )
1327 registerShapeEvents( xMasterPage
);
1329 registerShapeEvents( xDrawPage
);
1332 catch( Exception
& e
)
1336 (OString("sd::SlideshowImpl::registerShapeEvents(), "
1337 "exception caught: ") +
1338 rtl::OUStringToOString(
1339 comphelper::anyToString( cppu::getCaughtException() ),
1340 RTL_TEXTENCODING_UTF8
)).getStr() );
1344 // ---------------------------------------------------------
1346 void SlideshowImpl::registerShapeEvents( Reference
< XShapes
>& xShapes
) throw( Exception
)
1350 const sal_Int32 nShapeCount
= xShapes
->getCount();
1352 for( nShape
= 0; nShape
< nShapeCount
; nShape
++ )
1354 Reference
< XShape
> xShape
;
1355 xShapes
->getByIndex( nShape
) >>= xShape
;
1358 xShape
->getShapeType().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GroupShape") ) )
1360 Reference
< XShapes
> xSubShapes( xShape
, UNO_QUERY
);
1361 if( xSubShapes
.is() )
1362 registerShapeEvents( xSubShapes
);
1365 Reference
< XPropertySet
> xSet( xShape
, UNO_QUERY
);
1369 Reference
< XPropertySetInfo
> xSetInfo( xSet
->getPropertySetInfo() );
1370 if( !xSetInfo
.is() || !xSetInfo
->hasPropertyByName( msOnClick
) )
1373 WrappedShapeEventImplPtr
pEvent( new WrappedShapeEventImpl
);
1374 xSet
->getPropertyValue( msOnClick
) >>= pEvent
->meClickAction
;
1376 switch( pEvent
->meClickAction
)
1378 case ClickAction_PREVPAGE
:
1379 case ClickAction_NEXTPAGE
:
1380 case ClickAction_FIRSTPAGE
:
1381 case ClickAction_LASTPAGE
:
1382 case ClickAction_STOPPRESENTATION
:
1384 case ClickAction_BOOKMARK
:
1385 if( xSetInfo
->hasPropertyByName( msBookmark
) )
1386 xSet
->getPropertyValue( msBookmark
) >>= pEvent
->maStrBookmark
;
1387 if( getSlideNumberForBookmark( pEvent
->maStrBookmark
) == -1 )
1390 case ClickAction_DOCUMENT
:
1391 case ClickAction_SOUND
:
1392 case ClickAction_PROGRAM
:
1393 case ClickAction_MACRO
:
1394 if( xSetInfo
->hasPropertyByName( msBookmark
) )
1395 xSet
->getPropertyValue( msBookmark
) >>= pEvent
->maStrBookmark
;
1397 case ClickAction_VERB
:
1398 if( xSetInfo
->hasPropertyByName( msVerb
) )
1399 xSet
->getPropertyValue( msVerb
) >>= pEvent
->mnVerb
;
1402 continue; // skip all others
1405 maShapeEventMap
[ xShape
] = pEvent
;
1407 if( mxListenerProxy
.is() )
1408 mxListenerProxy
->addShapeEventListener( xShape
);
1409 mxShow
->setShapeCursor( xShape
, awt::SystemPointer::REFHAND
);
1412 catch( Exception
& e
)
1414 static_cast<void>(e
);
1416 (OString("sd::SlideshowImpl::registerShapeEvents(), "
1417 "exception caught: ") +
1418 rtl::OUStringToOString(
1419 comphelper::anyToString( cppu::getCaughtException() ),
1420 RTL_TEXTENCODING_UTF8
)).getStr() );
1424 // ---------------------------------------------------------
1426 void SlideshowImpl::displayCurrentSlide (const bool bSkipAllMainSequenceEffects
)
1429 removeShapeEvents();
1431 if( mpSlideController
.get() && mxShow
.is() )
1433 mpSlideController
->displayCurrentSlide( mxShow
, bSkipAllMainSequenceEffects
);
1434 registerShapeEvents(mpSlideController
->getCurrentSlideNumber());
1437 SfxBindings
* pBindings
= getBindings();
1440 pBindings
->Invalidate( SID_NAVIGATOR_STATE
);
1441 pBindings
->Invalidate( SID_NAVIGATOR_PAGENAME
);
1446 // ---------------------------------------------------------
1448 void SlideshowImpl::endPresentation()
1450 if( !mnEndShowEvent
)
1451 mnEndShowEvent
= Application::PostUserEvent( LINK(this, SlideshowImpl
, endPresentationHdl
) );
1454 // ---------------------------------------------------------
1456 IMPL_LINK( SlideshowImpl
, endPresentationHdl
, void*, EMPTYARG
)
1460 if( mxPresentation
.is() )
1461 mxPresentation
->end();
1465 // ---------------------------------------------------------
1467 void SAL_CALL
SlideshowImpl::pause() throw (RuntimeException
)
1469 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
1471 if( !mbIsPaused
) try
1473 mbIsPaused
= sal_True
;
1476 mxShow
->pause(sal_True
);
1478 if( mxListenerProxy
.is() )
1479 mxListenerProxy
->paused();
1482 catch( Exception
& e
)
1484 static_cast<void>(e
);
1486 (OString("sd::SlideshowImpl::pause(), "
1487 "exception caught: ") +
1488 rtl::OUStringToOString(
1489 comphelper::anyToString( cppu::getCaughtException() ),
1490 RTL_TEXTENCODING_UTF8
)).getStr() );
1494 // ---------------------------------------------------------
1496 void SAL_CALL
SlideshowImpl::resume() throw (RuntimeException
)
1498 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
1500 if( mbIsPaused
) try
1502 if( mpShowWindow
->GetShowWindowMode() == SHOWWINDOWMODE_BLANK
)
1504 mpShowWindow
->RestartShow();
1508 mbIsPaused
= sal_False
;;
1511 mxShow
->pause(sal_False
);
1514 if( mxListenerProxy
.is() )
1515 mxListenerProxy
->resumed();
1519 catch( Exception
& e
)
1521 static_cast<void>(e
);
1523 (OString("sd::SlideshowImpl::resume(), "
1524 "exception caught: ") +
1525 rtl::OUStringToOString(
1526 comphelper::anyToString( cppu::getCaughtException() ),
1527 RTL_TEXTENCODING_UTF8
)).getStr() );
1531 // ---------------------------------------------------------
1533 sal_Bool SAL_CALL
SlideshowImpl::isPaused() throw (RuntimeException
)
1535 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
1539 // ---------------------------------------------------------
1541 void SAL_CALL
SlideshowImpl::blankScreen( sal_Int32 nColor
) throw (RuntimeException
)
1543 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
1545 if( mpShowWindow
&& mpSlideController
)
1547 if( mpShowWindow
->SetBlankMode( mpSlideController
->getCurrentSlideIndex(), nColor
) )
1554 // ---------------------------------------------------------
1555 // XShapeEventListener
1556 // ---------------------------------------------------------
1558 void SlideshowImpl::click( const Reference
< XShape
>& xShape
, const ::com::sun::star::awt::MouseEvent
& /* aOriginalEvent */ )
1560 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
1562 WrappedShapeEventImplPtr pEvent
= maShapeEventMap
[xShape
];
1566 switch( pEvent
->meClickAction
)
1568 case ClickAction_PREVPAGE
: gotoPreviousSlide(); break;
1569 case ClickAction_NEXTPAGE
: gotoNextSlide(); break;
1570 case ClickAction_FIRSTPAGE
: gotoFirstSlide(); break;
1571 case ClickAction_LASTPAGE
: gotoLastSlide(); break;
1572 case ClickAction_STOPPRESENTATION
: endPresentation(); break;
1573 case ClickAction_BOOKMARK
:
1575 gotoBookmark( pEvent
->maStrBookmark
);
1578 case ClickAction_SOUND
:
1582 mxPlayer
.set(avmedia::MediaWindow::createPlayer(pEvent
->maStrBookmark
), uno::UNO_QUERY_THROW
);
1585 catch( uno::Exception
& e
)
1588 DBG_ERROR("sd::SlideshowImpl::click(), exception caught!" );
1593 case ClickAction_DOCUMENT
:
1595 OUString
aBookmark( pEvent
->maStrBookmark
);
1597 sal_Int32 nPos
= aBookmark
.indexOf( sal_Unicode('#') );
1600 OUString
aURL( aBookmark
.copy( 0, nPos
+1 ) );
1601 OUString
aName( aBookmark
.copy( nPos
+1 ) );
1602 aURL
+= getUiNameFromPageApiNameImpl( aName
);
1606 mpDocSh
->OpenBookmark( aBookmark
);
1610 case ClickAction_PROGRAM
:
1613 ::URIHelper::SmartRel2Abs(
1614 INetURLObject(mpDocSh
->GetMedium()->GetBaseURL()),
1615 pEvent
->maStrBookmark
, ::URIHelper::GetMaybeFileHdl(), true,
1616 false, INetURLObject::WAS_ENCODED
,
1617 INetURLObject::DECODE_UNAMBIGUOUS
) );
1619 if( INET_PROT_FILE
== aURL
.GetProtocol() )
1621 SfxStringItem
aUrl( SID_FILE_NAME
, aURL
.GetMainURL( INetURLObject::NO_DECODE
) );
1622 SfxBoolItem
aBrowsing( SID_BROWSE
, TRUE
);
1624 SfxViewFrame
* pViewFrm
= SfxViewFrame::Current();
1626 pViewFrm
->GetDispatcher()->Execute( SID_OPENDOC
,
1627 SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
,
1635 case presentation::ClickAction_MACRO
:
1637 const String
aMacro( pEvent
->maStrBookmark
);
1639 if ( SfxApplication::IsXScriptURL( aMacro
) )
1642 Sequence
< sal_Int16
> aOutArgsIndex
;
1643 Sequence
< Any
> aOutArgs
;
1644 Sequence
< Any
>* pInArgs
= new Sequence
< Any
>(0);
1645 mpDocSh
->CallXScript( aMacro
, *pInArgs
, aRet
, aOutArgsIndex
, aOutArgs
);
1649 // aMacro has the following syntax:
1650 // "Macroname.Modulname.Libname.Dokumentname" or
1651 // "Macroname.Modulname.Libname.Applikationsname"
1652 String aMacroName
= aMacro
.GetToken(0, sal_Unicode('.'));
1653 String aModulName
= aMacro
.GetToken(1, sal_Unicode('.'));
1654 String aLibName
= aMacro
.GetToken(2, sal_Unicode('.'));
1655 String aDocName
= aMacro
.GetToken(3, sal_Unicode('.'));
1657 // todo: is the limitation still given that only
1658 // Modulname+Macroname can be used here?
1659 String
aExecMacro(aModulName
);
1660 aExecMacro
.Append( sal_Unicode('.') );
1661 aExecMacro
.Append( aMacroName
);
1662 mpDocSh
->GetBasic()->Call(aExecMacro
);
1667 case ClickAction_VERB
:
1669 // todo, better do it async?
1670 SdrObject
* pObj
= GetSdrObjectFromXShape( xShape
);
1671 SdrOle2Obj
* pOleObject
= PTR_CAST(SdrOle2Obj
, pObj
);
1672 if (pOleObject
&& mpViewShell
)
1673 mpViewShell
->ActivateObject(pOleObject
, pEvent
->mnVerb
);
1681 // ---------------------------------------------------------
1683 sal_Int32
SlideshowImpl::getSlideNumberForBookmark( const OUString
& rStrBookmark
)
1686 OUString aBookmark
= getUiNameFromPageApiNameImpl( rStrBookmark
);
1687 USHORT nPgNum
= mpDoc
->GetPageByName( aBookmark
, bIsMasterPage
);
1689 if( nPgNum
== SDRPAGE_NOTFOUND
)
1691 // Ist das Bookmark ein Objekt?
1692 SdrObject
* pObj
= mpDoc
->GetObj( aBookmark
);
1696 nPgNum
= pObj
->GetPage()->GetPageNum();
1697 bIsMasterPage
= (BOOL
)pObj
->GetPage()->IsMasterPage();
1701 if( (nPgNum
== SDRPAGE_NOTFOUND
) || bIsMasterPage
|| static_cast<SdPage
*>(mpDoc
->GetPage(nPgNum
))->GetPageKind() != PK_STANDARD
)
1704 return ( nPgNum
- 1) >> 1;
1707 // ---------------------------------------------------------
1709 void SlideshowImpl::hyperLinkClicked( rtl::OUString
const& aHyperLink
) throw (RuntimeException
)
1711 OUString
aBookmark( aHyperLink
);
1713 sal_Int32 nPos
= aBookmark
.indexOf( sal_Unicode('#') );
1716 OUString
aURL( aBookmark
.copy( 0, nPos
+1 ) );
1717 OUString
aName( aBookmark
.copy( nPos
+1 ) );
1718 aURL
+= getUiNameFromPageApiNameImpl( aName
);
1722 mpDocSh
->OpenBookmark( aBookmark
);
1725 // ---------------------------------------------------------
1727 void SlideshowImpl::displaySlideNumber( sal_Int32 nSlideNumber
)
1729 if( mpSlideController
.get() )
1731 if( mpSlideController
->jumpToSlideNumber( nSlideNumber
) )
1733 displayCurrentSlide();
1738 // ---------------------------------------------------------
1740 /** nSlideIndex == -1 displays current slide again */
1741 void SlideshowImpl::displaySlideIndex( sal_Int32 nSlideIndex
)
1743 if( mpSlideController
.get() )
1745 if( (nSlideIndex
== -1) || mpSlideController
->jumpToSlideIndex( nSlideIndex
) )
1747 displayCurrentSlide();
1752 // ---------------------------------------------------------
1754 void SlideshowImpl::jumpToBookmark( const String
& sBookmark
)
1756 sal_Int32 nSlideNumber
= getSlideNumberForBookmark( sBookmark
);
1757 if( nSlideNumber
!= -1 )
1758 displaySlideNumber( nSlideNumber
);
1761 // ---------------------------------------------------------
1763 sal_Int32
SlideshowImpl::getCurrentSlideNumber()
1765 return mpSlideController
.get() ? mpSlideController
->getCurrentSlideNumber() : -1;
1768 // ---------------------------------------------------------
1770 sal_Int32
SlideshowImpl::getFirstSlideNumber()
1773 if( mpSlideController
.get() )
1775 sal_Int32 nSlideIndexCount
= mpSlideController
->getSlideIndexCount() - 1;
1776 if( nSlideIndexCount
>= 0 )
1778 nRet
= mpSlideController
->getSlideNumber( nSlideIndexCount
);
1779 while( nSlideIndexCount
-- )
1781 sal_Int32 nTemp
= mpSlideController
->getSlideNumber( nSlideIndexCount
);
1791 // ---------------------------------------------------------
1793 sal_Int32
SlideshowImpl::getLastSlideNumber()
1796 if( mpSlideController
.get() )
1798 sal_Int32 nSlideIndexCount
= mpSlideController
->getSlideIndexCount() - 1;
1799 if( nSlideIndexCount
>= 0 )
1801 nRet
= mpSlideController
->getSlideNumber( nSlideIndexCount
);
1802 while( nSlideIndexCount
-- )
1804 sal_Int32 nTemp
= mpSlideController
->getSlideNumber( nSlideIndexCount
);
1814 // ---------------------------------------------------------
1816 sal_Bool SAL_CALL
SlideshowImpl::isEndless() throw( RuntimeException
)
1818 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
1819 return maPresSettings
.mbEndless
;
1822 // ---------------------------------------------------------
1824 double SlideshowImpl::update()
1830 // ---------------------------------------------------------
1832 void SlideshowImpl::startUpdateTimer()
1834 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
1835 maUpdateTimer
.SetTimeout( 0 );
1836 maUpdateTimer
.Start();
1839 // ---------------------------------------------------------
1841 /** this timer is called 20ms after a new slide was displayed.
1842 This is used to unfreeze user input that was disabled after
1843 slide change to skip input that was buffered during slide
1844 transition preperation */
1845 IMPL_LINK( SlideshowImpl
, ReadyForNextInputHdl
, Timer
*, EMPTYARG
)
1847 mbInputFreeze
= false;
1851 // ---------------------------------------------------------
1853 /** if I catch someone someday who calls this method by hand
1854 and not by using the timer, I will personaly punish this
1855 person seriously, even if this person is me.
1857 IMPL_LINK( SlideshowImpl
, updateHdl
, Timer
*, EMPTYARG
)
1861 // doing some nMagic
1862 const rtl::Reference
<SlideshowImpl
> this_(this);
1864 Reference
< XSlideShow
> xShow( mxShow
);
1865 if( xShow
.is() ) try
1867 // TODO(Q3): Evaluate under various systems and setups,
1868 // whether this is really necessary. Under WinXP and Matrox
1869 // G550, the frame rates were much more steadier with this
1872 // currently no solution, because this kills sound (at least on Windows)
1873 // // Boost our prio, as long as we're in the render loop
1874 // ::canvas::tools::PriorityBooster aBooster(2);
1876 double fUpdate
= 0.0;
1877 if( !xShow
->update(fUpdate
) )
1880 if( mxShow
.is() && ( fUpdate
>= 0.0 ) )
1883 if( fUpdate < 0.25 )
1885 mnUpdateEvent = Application::PostUserEvent(LINK(this, SlideshowImpl, updateHdl));
1890 // Avoid busy loop when the previous call to update()
1891 // returns 0. The minimum value is small enough to allow
1892 // high frame rates. Values larger than 0 are typically
1893 // also larger then the small minimum value and thus are
1894 // used to determine the frame rate.
1895 const float MIN_UPDATE
= 0.01f
; // 10ms corresponds to 100 frames per second.
1896 if( fUpdate
< MIN_UPDATE
)
1897 fUpdate
= MIN_UPDATE
;
1900 const float MAX_UPDATE
= 4.0f
; // do not wait longer than 4 seconds for next refresh, because dilbert said so
1901 if( fUpdate
> MAX_UPDATE
)
1902 fUpdate
= MAX_UPDATE
;
1904 maUpdateTimer
.SetTimeout(
1905 ::std::max( 1UL, static_cast<ULONG
>(fUpdate
* 1000.0) ) );
1906 maUpdateTimer
.Start();
1910 catch( Exception
& e
)
1912 static_cast<void>(e
);
1914 (OString("sd::SlideshowImpl::updateHdl(), "
1915 "exception caught: ") +
1916 rtl::OUStringToOString(
1917 comphelper::anyToString( cppu::getCaughtException() ),
1918 RTL_TEXTENCODING_UTF8
)).getStr() );
1923 // ---------------------------------------------------------
1925 bool SlideshowImpl::keyInput(const KeyEvent
& rKEvt
)
1927 if( !mxShow
.is() || mbInputFreeze
)
1934 const int nKeyCode
= rKEvt
.GetKeyCode().GetCode();
1937 case awt::Key::CONTEXTMENU
:
1938 if( !mnContextMenuEvent
)
1941 maPopupMousePos
= mpShowWindow
->GetPointerState().maPos
;
1942 mnContextMenuEvent
= Application::PostUserEvent( LINK( this, SlideshowImpl
, ContextMenuHdl
) );
1949 // in case the user cancels the presentation, switch to current slide
1951 if( mpSlideController
.get() && (ANIMATIONMODE_SHOW
== meAnimationMode
) )
1953 if( mpSlideController
->getCurrentSlideNumber() != -1 )
1954 mnRestoreSlide
= mpSlideController
->getCurrentSlideNumber();
1961 if(rKEvt
.GetKeyCode().IsMod2())
1966 // warning, fall through!
1976 if( maCharBuffer
.Len() )
1978 if( mpSlideController
.get() )
1980 if( mpSlideController
->jumpToSlideNumber( maCharBuffer
.ToInt32() - 1 ) )
1981 displayCurrentSlide();
1983 maCharBuffer
.Erase();
1992 // numeric: add to buffer
2003 maCharBuffer
.Append( rKEvt
.GetCharCode() );
2007 if(rKEvt
.GetKeyCode().IsMod2())
2009 gotoPreviousSlide();
2012 // warning, fall through!
2017 gotoPreviousEffect();
2033 blankScreen( ((nKeyCode
== KEY_W
) || (nKeyCode
== KEY_COMMA
)) ? 0x00ffffff : 0x00000000 );
2042 catch( Exception
& e
)
2045 static_cast<void>(e
);
2047 (OString("sd::SlideshowImpl::keyInput(), "
2048 "exception caught: ") +
2049 rtl::OUStringToOString(
2050 comphelper::anyToString( cppu::getCaughtException() ),
2051 RTL_TEXTENCODING_UTF8
)).getStr() );
2057 IMPL_LINK( SlideshowImpl
, EventListenerHdl
, VclSimpleEvent
*, pEvent
)
2059 if( !mxShow
.is() || mbInputFreeze
)
2062 if( pEvent
&& (pEvent
->GetId() == VCLEVENT_WINDOW_COMMAND
) && static_cast<VclWindowEvent
*>(pEvent
)->GetData() )
2064 const CommandEvent
& rEvent
= *(const CommandEvent
*)static_cast<VclWindowEvent
*>(pEvent
)->GetData();
2066 if( rEvent
.GetCommand() == COMMAND_MEDIA
)
2068 switch( rEvent
.GetMediaCommand() )
2070 #if defined( QUARTZ )
2071 case MEDIA_COMMAND_MENU
:
2072 if( !mnContextMenuEvent
)
2075 maPopupMousePos
= mpShowWindow
->GetPointerState().maPos
;
2076 mnContextMenuEvent
= Application::PostUserEvent( LINK( this, SlideshowImpl
, ContextMenuHdl
) );
2079 case MEDIA_COMMAND_VOLUME_DOWN
:
2080 gotoPreviousSlide();
2082 case MEDIA_COMMAND_VOLUME_UP
:
2086 case MEDIA_COMMAND_NEXTTRACK
:
2089 case MEDIA_COMMAND_PAUSE
:
2093 case MEDIA_COMMAND_PLAY
:
2098 case MEDIA_COMMAND_PLAY_PAUSE
:
2104 case MEDIA_COMMAND_PREVIOUSTRACK
:
2105 gotoPreviousSlide();
2107 case MEDIA_COMMAND_NEXTTRACK_HOLD
:
2111 case MEDIA_COMMAND_REWIND
:
2114 case MEDIA_COMMAND_STOP
:
2115 // in case the user cancels the presentation, switch to current slide
2117 if( mpSlideController
.get() && (ANIMATIONMODE_SHOW
== meAnimationMode
) )
2119 if( mpSlideController
->getCurrentSlideNumber() != -1 )
2120 mnRestoreSlide
= mpSlideController
->getCurrentSlideNumber();
2131 // ---------------------------------------------------------
2133 void SlideshowImpl::mouseButtonUp(const MouseEvent
& rMEvt
)
2135 if( rMEvt
.IsRight() && !mnContextMenuEvent
)
2137 maPopupMousePos
= rMEvt
.GetPosPixel();
2138 mnContextMenuEvent
= Application::PostUserEvent( LINK( this, SlideshowImpl
, ContextMenuHdl
) );
2142 // ---------------------------------------------------------
2144 IMPL_LINK( SlideshowImpl
, ContextMenuHdl
, void*, EMPTYARG
)
2146 mnContextMenuEvent
= 0;
2148 if( mpSlideController
.get() == 0 )
2151 mbWasPaused
= mbIsPaused
;
2155 PopupMenu
* pMenu
= new PopupMenu( SdResId( RID_SLIDESHOW_CONTEXTMENU
) );
2157 pMenu
->EnableItem( CM_COLOR_PEN
, (maPresSettings
.mbMouseAsPen
));
2159 const ShowWindowMode eMode
= mpShowWindow
->GetShowWindowMode();
2160 pMenu
->EnableItem( CM_NEXT_SLIDE
, ( mpSlideController
->getNextSlideIndex() != -1 ) );
2161 pMenu
->EnableItem( CM_PREV_SLIDE
, ( mpSlideController
->getPreviousSlideIndex() != -1 ) || (eMode
== SHOWWINDOWMODE_END
) || (eMode
== SHOWWINDOWMODE_PAUSE
) || (eMode
== SHOWWINDOWMODE_BLANK
) );
2163 PopupMenu
* pPageMenu
= pMenu
->GetPopupMenu( CM_GOTO
);
2165 SfxViewFrame
* pViewFrame
= getViewFrame();
2166 if( pViewFrame
&& pViewFrame
->GetFrame() )
2168 Reference
< ::com::sun::star::frame::XFrame
> xFrame( pViewFrame
->GetFrame()->GetFrameInterface() );
2171 pMenu
->SetItemImage( CM_NEXT_SLIDE
, GetImage( xFrame
, OUString( RTL_CONSTASCII_USTRINGPARAM( "slot:10617") ), FALSE
, FALSE
) );
2172 pMenu
->SetItemImage( CM_PREV_SLIDE
, GetImage( xFrame
, OUString( RTL_CONSTASCII_USTRINGPARAM( "slot:10618") ), FALSE
, FALSE
) );
2176 pPageMenu
->SetItemImage( CM_FIRST_SLIDE
, GetImage( xFrame
, OUString( RTL_CONSTASCII_USTRINGPARAM( "slot:10616") ), FALSE
, FALSE
) );
2177 pPageMenu
->SetItemImage( CM_LAST_SLIDE
, GetImage( xFrame
, OUString( RTL_CONSTASCII_USTRINGPARAM( "slot:10619") ), FALSE
, FALSE
) );
2182 // populate slide goto list
2185 const sal_Int32 nPageNumberCount
= mpSlideController
->getSlideNumberCount();
2186 if( nPageNumberCount
<= 1 )
2188 pMenu
->EnableItem( CM_GOTO
, FALSE
);
2192 sal_Int32 nCurrentSlideNumber
= mpSlideController
->getCurrentSlideNumber();
2193 if( (eMode
== SHOWWINDOWMODE_END
) || (eMode
== SHOWWINDOWMODE_PAUSE
) || (eMode
== SHOWWINDOWMODE_BLANK
) )
2194 nCurrentSlideNumber
= -1;
2196 pPageMenu
->EnableItem( CM_FIRST_SLIDE
, ( mpSlideController
->getSlideNumber(0) != nCurrentSlideNumber
) );
2197 pPageMenu
->EnableItem( CM_LAST_SLIDE
, ( mpSlideController
->getSlideNumber( mpSlideController
->getSlideIndexCount() - 1) != nCurrentSlideNumber
) );
2199 sal_Int32 nPageNumber
;
2201 for( nPageNumber
= 0; nPageNumber
< nPageNumberCount
; nPageNumber
++ )
2203 if( mpSlideController
->isVisibleSlideNumber( nPageNumber
) )
2205 SdPage
* pPage
= mpDoc
->GetSdPage((USHORT
)nPageNumber
, PK_STANDARD
);
2208 pPageMenu
->InsertItem( (USHORT
)(CM_SLIDES
+ nPageNumber
), pPage
->GetName() );
2209 if( nPageNumber
== nCurrentSlideNumber
)
2210 pPageMenu
->CheckItem( (USHORT
)(CM_SLIDES
+ nPageNumber
) );
2217 if( mpShowWindow
->GetShowWindowMode() == SHOWWINDOWMODE_BLANK
)
2219 PopupMenu
* pBlankMenu
= pMenu
->GetPopupMenu( CM_SCREEN
);
2222 pBlankMenu
->CheckItem( ( mpShowWindow
->GetBlankColor() == Color( COL_WHITE
) ) ? CM_SCREEN_WHITE
: CM_SCREEN_BLACK
);
2227 PopupMenu
* pWidthMenu
= pMenu
->GetPopupMenu( CM_WIDTH_PEN
);
2229 // populate color width list
2232 if(! maPresSettings
.mbMouseAsPen
)
2234 pMenu
->EnableItem( CM_WIDTH_PEN
, FALSE
);
2238 sal_Int32 nIterator
;
2244 for( nIterator
= 1; nIterator
< 6; nIterator
++)
2267 pWidthMenu
->EnableItem( (USHORT
)(CM_WIDTH_PEN
+ nIterator
), TRUE
);
2268 if( nWidth
== mdUserPaintStrokeWidth
)
2269 pWidthMenu
->CheckItem( (USHORT
)(CM_WIDTH_PEN
+ nIterator
) );
2275 pMenu
->SetSelectHdl( LINK( this, SlideshowImpl
, ContextMenuSelectHdl
) );
2276 pMenu
->Execute( mpShowWindow
, maPopupMousePos
);
2280 mxView
->ignoreNextMouseReleased();
2287 // ---------------------------------------------------------
2289 IMPL_LINK( SlideshowImpl
, ContextMenuSelectHdl
, Menu
*, pMenu
)
2293 sal_uInt16 nMenuId
= pMenu
->GetCurItemId();
2298 gotoPreviousSlide();
2299 mbWasPaused
= false;
2303 mbWasPaused
= false;
2305 case CM_FIRST_SLIDE
:
2307 mbWasPaused
= false;
2311 mbWasPaused
= false;
2313 case CM_SCREEN_BLACK
:
2314 case CM_SCREEN_WHITE
:
2316 const Color
aBlankColor( (nMenuId
== CM_SCREEN_WHITE
) ? COL_WHITE
: COL_BLACK
);
2319 if( mpShowWindow
->GetShowWindowMode() == SHOWWINDOWMODE_BLANK
)
2321 if( mpShowWindow
->GetBlankColor() == aBlankColor
)
2323 mbWasPaused
= false;
2324 mpShowWindow
->RestartShow();
2328 mpShowWindow
->RestartShow();
2330 if( mpShowWindow
->SetBlankMode( mpSlideController
->getCurrentSlideIndex(), aBlankColor
) )
2339 if( maPresSettings
.mbMouseAsPen
){
2341 //Open a color picker based on SvColorDialog
2342 ::Color
aColor( mnUserPaintColor
);
2343 SvColorDialog
aColorDlg( mpShowWindow
);
2344 aColorDlg
.SetColor( aColor
);
2346 if (aColorDlg
.Execute() )
2348 aColor
= aColorDlg
.GetColor();
2349 mnUserPaintColor
= aColor
.GetColor();
2350 setPenColor(mnUserPaintColor
);
2352 mbWasPaused
= false;
2356 case CM_WIDTH_PEN_VERY_THIN
:
2357 if( maPresSettings
.mbMouseAsPen
){
2359 mbWasPaused
= false;
2363 case CM_WIDTH_PEN_THIN
:
2364 if( maPresSettings
.mbMouseAsPen
){
2366 mbWasPaused
= false;
2370 case CM_WIDTH_PEN_NORMAL
:
2371 if( maPresSettings
.mbMouseAsPen
){
2373 mbWasPaused
= false;
2377 case CM_WIDTH_PEN_THICK
:
2378 if( maPresSettings
.mbMouseAsPen
){
2380 mbWasPaused
= false;
2384 case CM_WIDTH_PEN_VERY_THICK
:
2385 if( maPresSettings
.mbMouseAsPen
){
2387 mbWasPaused
= false;
2392 // in case the user cancels the presentation, switch to current slide
2394 if( mpSlideController
.get() && (ANIMATIONMODE_SHOW
== meAnimationMode
) )
2396 if( mpSlideController
->getCurrentSlideNumber() != -1 )
2398 mnRestoreSlide
= mpSlideController
->getCurrentSlideNumber();
2404 sal_Int32 nPageNumber
= nMenuId
- CM_SLIDES
;
2405 const ShowWindowMode eMode
= mpShowWindow
->GetShowWindowMode();
2406 if( (eMode
== SHOWWINDOWMODE_END
) || (eMode
== SHOWWINDOWMODE_PAUSE
) || (eMode
== SHOWWINDOWMODE_BLANK
) )
2408 mpShowWindow
->RestartShow( nPageNumber
);
2410 else if( nPageNumber
!= mpSlideController
->getCurrentSlideNumber() )
2412 displaySlideNumber( nPageNumber
);
2414 mbWasPaused
= false;
2422 // ---------------------------------------------------------
2424 Reference
< XSlideShow
> SlideshowImpl::createSlideShow() const
2426 Reference
< XSlideShow
> xShow
;
2430 Reference
< lang::XMultiServiceFactory
> xFactory(
2431 ::comphelper::getProcessServiceFactory(),
2434 Reference
< XInterface
> xInt( xFactory
->createInstance(
2435 OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.SlideShow")) ) );
2437 xShow
.set( xInt
, UNO_QUERY_THROW
);
2439 catch( uno::Exception
& e
)
2443 (OString("sd::SlideshowImpl::createSlideShow(), "
2444 "exception caught: ") +
2445 rtl::OUStringToOString(
2446 comphelper::anyToString( cppu::getCaughtException() ),
2447 RTL_TEXTENCODING_UTF8
)).getStr() );
2453 // ---------------------------------------------------------
2455 void SlideshowImpl::createSlideList( bool bAll
, bool bStartWithActualSlide
, const String
& rPresSlide
)
2457 const long nSlideCount
= mpDoc
->GetSdPageCount( PK_STANDARD
);
2461 SdCustomShow
* pCustomShow
;
2463 if( !bStartWithActualSlide
&& mpDoc
->GetCustomShowList() && maPresSettings
.mbCustomShow
)
2464 pCustomShow
= (SdCustomShow
*) mpDoc
->GetCustomShowList()->GetCurObject();
2468 // create animation slide controller
2469 AnimationSlideController::Mode eMode
=
2470 ( pCustomShow
&& pCustomShow
->Count() ) ? AnimationSlideController::CUSTOM
:
2471 (bAll
? AnimationSlideController::ALL
: AnimationSlideController::FROM
);
2473 Reference
< XDrawPagesSupplier
> xDrawPages( mpDoc
->getUnoModel(), UNO_QUERY_THROW
);
2474 Reference
< XIndexAccess
> xSlides( xDrawPages
->getDrawPages(), UNO_QUERY_THROW
);
2475 mpSlideController
.reset( new AnimationSlideController( xSlides
, eMode
) );
2477 if( eMode
!= AnimationSlideController::CUSTOM
)
2479 sal_Int32 nFirstSlide
= 0;
2481 // normale Praesentation
2482 if( eMode
== AnimationSlideController::FROM
)
2484 if( rPresSlide
.Len() )
2487 BOOL bTakeNextAvailable
= FALSE
;
2489 for( nSlide
= 0, nFirstSlide
= -1; ( nSlide
< nSlideCount
) && ( -1 == nFirstSlide
); nSlide
++ )
2491 SdPage
* pTestSlide
= mpDoc
->GetSdPage( (USHORT
)nSlide
, PK_STANDARD
);
2493 if( pTestSlide
->GetName() == rPresSlide
)
2495 if( pTestSlide
->IsExcluded() )
2496 bTakeNextAvailable
= TRUE
;
2498 nFirstSlide
= nSlide
;
2500 else if( bTakeNextAvailable
&& !pTestSlide
->IsExcluded() )
2501 nFirstSlide
= nSlide
;
2504 if( -1 == nFirstSlide
)
2509 for( sal_Int32 i
= 0; i
< nSlideCount
; i
++ )
2511 bool bVisible
= ( mpDoc
->GetSdPage( (USHORT
)i
, PK_STANDARD
) )->IsExcluded() ? false : true;
2512 if( bVisible
|| (eMode
== AnimationSlideController::ALL
) )
2513 mpSlideController
->insertSlideNumber( i
, bVisible
);
2516 mpSlideController
->setStartSlideNumber( nFirstSlide
);
2520 if( meAnimationMode
!= ANIMATIONMODE_SHOW
&& rPresSlide
.Len() )
2523 for( nSlide
= 0; nSlide
< nSlideCount
; nSlide
++ )
2524 if( rPresSlide
== mpDoc
->GetSdPage( (USHORT
) nSlide
, PK_STANDARD
)->GetName() )
2527 if( nSlide
< nSlideCount
)
2528 mpSlideController
->insertSlideNumber( (USHORT
) nSlide
);
2532 sal_Int32 nSlideIndex
;
2533 for( pCustomSlide
= pCustomShow
->First(),nSlideIndex
=0; pCustomSlide
; pCustomSlide
= pCustomShow
->Next(), nSlideIndex
++ )
2535 const USHORT nSdSlide
= ( ( (SdPage
*) pCustomSlide
)->GetPageNum() - 1 ) / 2;
2536 mpSlideController
->insertSlideNumber( nSdSlide
);
2542 // ---------------------------------------------------------
2544 typedef USHORT (*FncGetChildWindowId
)();
2546 FncGetChildWindowId aShowChilds
[] =
2548 &AnimationChildWindow::GetChildWindowId
,
2549 &Svx3DChildWindow::GetChildWindowId
,
2550 &SvxFontWorkChildWindow::GetChildWindowId
,
2551 &SvxColorChildWindow::GetChildWindowId
,
2552 &SvxSearchDialogWrapper::GetChildWindowId
,
2553 &SvxBmpMaskChildWindow::GetChildWindowId
,
2554 &SvxIMapDlgChildWindow::GetChildWindowId
,
2555 &SvxHyperlinkDlgWrapper::GetChildWindowId
,
2556 &SvxHlinkDlgWrapper::GetChildWindowId
,
2557 &SfxTemplateDialogWrapper::GetChildWindowId
,
2558 &GalleryChildWindow::GetChildWindowId
2561 #define NAVIGATOR_CHILD_MASK 0x80000000UL
2563 void SlideshowImpl::hideChildWindows()
2567 if( ANIMATIONMODE_SHOW
== meAnimationMode
)
2569 SfxViewFrame
* pViewFrame
= getViewFrame();
2573 if( pViewFrame
->GetChildWindow( SID_NAVIGATOR
) != NULL
)
2574 mnChildMask
|= NAVIGATOR_CHILD_MASK
;
2576 for( ULONG i
= 0, nCount
= sizeof( aShowChilds
) / sizeof( FncGetChildWindowId
); i
< nCount
; i
++ )
2578 const USHORT nId
= ( *aShowChilds
[ i
] )();
2580 if( pViewFrame
->GetChildWindow( nId
) )
2582 pViewFrame
->SetChildWindow( nId
, FALSE
);
2583 mnChildMask
|= 1 << i
;
2590 // ---------------------------------------------------------
2592 void SlideshowImpl::showChildWindows()
2594 if( ANIMATIONMODE_SHOW
== meAnimationMode
)
2596 SfxViewFrame
* pViewFrame
= getViewFrame();
2599 pViewFrame
->SetChildWindow( SID_NAVIGATOR
, ( mnChildMask
& NAVIGATOR_CHILD_MASK
) != 0 );
2601 for( ULONG i
= 0, nCount
= sizeof( aShowChilds
) / sizeof( FncGetChildWindowId
); i
< nCount
; i
++ )
2603 if( mnChildMask
& ( 1 << i
) )
2604 pViewFrame
->SetChildWindow( ( *aShowChilds
[ i
] )(), TRUE
);
2610 // ---------------------------------------------------------
2612 SfxViewFrame
* SlideshowImpl::getViewFrame() const
2614 return mpViewShell
? mpViewShell
->GetViewFrame() : 0;
2617 // ---------------------------------------------------------
2619 SfxDispatcher
* SlideshowImpl::getDispatcher() const
2621 return (mpViewShell
&& mpViewShell
->GetViewFrame()) ? mpViewShell
->GetViewFrame()->GetDispatcher() : 0;
2624 // ---------------------------------------------------------
2626 SfxBindings
* SlideshowImpl::getBindings() const
2628 return (mpViewShell
&& mpViewShell
->GetViewFrame()) ? &mpViewShell
->GetViewFrame()->GetBindings() : 0;
2631 // ---------------------------------------------------------
2633 void SlideshowImpl::resize( const Size
& rSize
)
2637 if( mpShowWindow
&& (ANIMATIONMODE_VIEW
!= meAnimationMode
) )
2639 mpShowWindow
->SetSizePixel( maPresSize
);
2640 mpShowWindow
->Show();
2642 // Call ToTop() to bring the window to top if
2643 // a) the old size is not degenerate (then the window will be closed
2645 // b) the animation mode is not that of a preview (on the one hand
2646 // this leaves the old behaviour for the slide show mode unmodified
2647 // and on the other hand does not move the focus from the document
2648 // to the (preview) window; the ToTop() seems not to be necessary at
2649 // least for the preview).
2650 // if( !aOldSize.Width() && !aOldSize.Height() )
2651 // mpShowWindow->ToTop();
2654 if( mxView
.is() ) try
2656 awt::WindowEvent aEvt
;
2657 mxView
->windowResized(aEvt
);
2659 catch( Exception
& e
)
2661 static_cast<void>(e
);
2663 (OString("sd::SlideshowImpl::resize(), "
2664 "exception caught: ") +
2665 rtl::OUStringToOString(
2666 comphelper::anyToString( cppu::getCaughtException() ),
2667 RTL_TEXTENCODING_UTF8
)).getStr() );
2671 // -----------------------------------------------------------------------------
2673 void SlideshowImpl::setActiveXToolbarsVisible( sal_Bool bVisible
)
2675 // in case of ActiveX control the toolbars should not be visible if slide show runs in window mode
2676 // actually it runs always in window mode in case of ActiveX control
2677 if ( !maPresSettings
.mbFullScreen
&& mpDocSh
&& mpDocSh
->GetMedium() )
2679 SFX_ITEMSET_ARG( mpDocSh
->GetMedium()->GetItemSet(), pItem
, SfxBoolItem
, SID_VIEWONLY
, sal_False
);
2680 if ( pItem
&& pItem
->GetValue() )
2682 // this is a plugin/activex mode, no toolbars should be visible during slide show
2683 // after the end of slide show they should be visible again
2684 SfxViewFrame
* pViewFrame
= getViewFrame();
2685 if( pViewFrame
&& pViewFrame
->GetFrame() && pViewFrame
->GetFrame()->GetTopFrame() )
2689 Reference
< frame::XLayoutManager
> xLayoutManager
;
2690 Reference
< beans::XPropertySet
> xFrameProps( pViewFrame
->GetFrame()->GetTopFrame()->GetFrameInterface(), UNO_QUERY_THROW
);
2691 if ( ( xFrameProps
->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ) ) )
2692 >>= xLayoutManager
)
2693 && xLayoutManager
.is() )
2695 xLayoutManager
->setVisible( bVisible
);
2698 catch( uno::Exception
& )
2705 // -----------------------------------------------------------------------------
2707 void SAL_CALL
SlideshowImpl::activate() throw (RuntimeException
)
2709 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
2711 maDeactivateTimer
.Stop();
2713 if( !mbActive
&& mxShow
.is() )
2715 mbActive
= sal_True
;
2717 if( ANIMATIONMODE_SHOW
== meAnimationMode
)
2719 if( mbAutoSaveWasOn
)
2720 setAutoSaveState( false );
2724 SfxViewFrame
* pViewFrame
= getViewFrame();
2725 SfxDispatcher
* pDispatcher
= pViewFrame
? pViewFrame
->GetDispatcher() : 0;
2731 // filter all forbiden slots
2732 pDispatcher
->SetSlotFilter( TRUE
, sizeof(pAllowed
) / sizeof(USHORT
), pAllowed
);
2736 getBindings()->InvalidateAll(TRUE
);
2738 mpShowWindow
->GrabFocus();
2746 // -----------------------------------------------------------------------------
2748 void SAL_CALL
SlideshowImpl::deactivate() throw (RuntimeException
)
2750 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
2752 if( mbActive
&& mxShow
.is() )
2754 maDeactivateTimer
.Start();
2758 // -----------------------------------------------------------------------------
2760 IMPL_LINK( SlideshowImpl
, deactivateHdl
, Timer
*, EMPTYARG
)
2762 if( mbActive
&& mxShow
.is() )
2764 mbActive
= sal_False
;
2768 if( ANIMATIONMODE_SHOW
== meAnimationMode
)
2770 if( mbAutoSaveWasOn
)
2771 setAutoSaveState( true );
2782 // ---------------------------------------------------------
2784 sal_Bool SAL_CALL
SlideshowImpl::isActive() throw (RuntimeException
)
2786 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
2790 // -----------------------------------------------------------------------------
2792 void SlideshowImpl::receiveRequest(SfxRequest
& rReq
)
2794 const SfxItemSet
* pArgs
= rReq
.GetArgs();
2796 switch ( rReq
.GetSlot() )
2798 case SID_NAVIGATOR_PEN
:
2799 setUsePen(!maPresSettings
.mbMouseAsPen
);
2802 case SID_NAVIGATOR_PAGE
:
2804 PageJump eJump
= (PageJump
)((SfxAllEnumItem
&) pArgs
->Get(SID_NAVIGATOR_PAGE
)).GetValue();
2807 case PAGE_FIRST
: gotoFirstSlide(); break;
2808 case PAGE_LAST
: gotoLastSlide(); break;
2809 case PAGE_NEXT
: gotoNextSlide(); break;
2810 case PAGE_PREVIOUS
: gotoPreviousSlide(); break;
2811 case PAGE_NONE
: break;
2816 case SID_NAVIGATOR_OBJECT
:
2818 const String
aTarget( ((SfxStringItem
&) pArgs
->Get(SID_NAVIGATOR_OBJECT
)).GetValue() );
2820 // is the bookmark a Slide?
2822 USHORT nPgNum
= mpDoc
->GetPageByName( aTarget
, bIsMasterPage
);
2823 SdrObject
* pObj
= NULL
;
2825 if( nPgNum
== SDRPAGE_NOTFOUND
)
2827 // is the bookmark an object?
2828 pObj
= mpDoc
->GetObj( aTarget
);
2831 nPgNum
= pObj
->GetPage()->GetPageNum();
2834 if( nPgNum
!= SDRPAGE_NOTFOUND
)
2836 nPgNum
= ( nPgNum
- 1 ) >> 1;
2837 displaySlideNumber( nPgNum
);
2844 // ---------------------------------------------------------
2846 void SlideshowImpl::setAutoSaveState( bool bOn
)
2850 uno::Reference
<lang::XMultiServiceFactory
> xFac( ::comphelper::getProcessServiceFactory() );
2852 uno::Reference
< util::XURLTransformer
> xParser(
2853 xFac
->createInstance( OUString::createFromAscii("com.sun.star.util.URLTransformer" ) ),
2854 uno::UNO_QUERY_THROW
);
2856 aURL
.Complete
= OUString::createFromAscii("vnd.sun.star.autorecovery:/setAutoSaveState");
2857 xParser
->parseStrict(aURL
);
2859 Sequence
< beans::PropertyValue
> aArgs(1);
2860 aArgs
[0].Name
= OUString::createFromAscii("AutoSaveState");
2861 aArgs
[0].Value
<<= bOn
? sal_True
: sal_False
;
2863 uno::Reference
< frame::XDispatch
> xAutoSave(
2864 xFac
->createInstance(OUString::createFromAscii("com.sun.star.frame.AutoRecovery")),
2865 uno::UNO_QUERY_THROW
);
2866 xAutoSave
->dispatch(aURL
, aArgs
);
2870 DBG_ERROR("sd::SlideshowImpl::setAutoSaveState(), exception caught!");
2874 // ---------------------------------------------------------
2876 Reference
< XDrawPage
> SAL_CALL
SlideshowImpl::getCurrentSlide() throw (RuntimeException
)
2878 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
2880 Reference
< XDrawPage
> xSlide
;
2881 if( mxShow
.is() && mpSlideController
.get() )
2883 sal_Int32 nSlide
= getCurrentSlideNumber();
2884 if( (nSlide
>= 0) && (nSlide
< mpSlideController
->getSlideNumberCount() ) )
2885 xSlide
= mpSlideController
->getSlideByNumber( nSlide
);
2891 // ---------------------------------------------------------
2893 sal_Int32 SAL_CALL
SlideshowImpl::getNextSlideIndex() throw (RuntimeException
)
2895 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
2899 return mpSlideController
->getNextSlideIndex();
2907 // ---------------------------------------------------------
2909 sal_Int32 SAL_CALL
SlideshowImpl::getCurrentSlideIndex() throw (RuntimeException
)
2911 return mpSlideController
.get() ? mpSlideController
->getCurrentSlideIndex() : -1;
2914 // --------------------------------------------------------------------
2915 // ::com::sun::star::presentation::XSlideShowController:
2916 // --------------------------------------------------------------------
2918 ::sal_Int32 SAL_CALL
SlideshowImpl::getSlideCount() throw (RuntimeException
)
2920 return mpSlideController
.get() ? mpSlideController
->getSlideIndexCount() : 0;
2923 // --------------------------------------------------------------------
2925 Reference
< XDrawPage
> SAL_CALL
SlideshowImpl::getSlideByIndex(::sal_Int32 Index
) throw (RuntimeException
, css::lang::IndexOutOfBoundsException
)
2927 if( (mpSlideController
.get() == 0 ) || (Index
< 0) || (Index
>= mpSlideController
->getSlideIndexCount() ) )
2928 throw IndexOutOfBoundsException();
2930 return mpSlideController
->getSlideByNumber( mpSlideController
->getSlideNumber( Index
) );
2933 sal_Bool SAL_CALL
SlideshowImpl::getAlwaysOnTop() throw (RuntimeException
)
2935 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
2936 return maPresSettings
.mbAlwaysOnTop
;
2939 // --------------------------------------------------------------------
2941 void SAL_CALL
SlideshowImpl::setAlwaysOnTop( sal_Bool bAlways
) throw (RuntimeException
)
2943 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
2944 if( maPresSettings
.mbAlwaysOnTop
!= bAlways
)
2946 maPresSettings
.mbAlwaysOnTop
= bAlways
;
2947 // todo, can this be changed while running?
2951 // --------------------------------------------------------------------
2953 sal_Bool SAL_CALL
SlideshowImpl::isFullScreen() throw (RuntimeException
)
2955 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
2956 return maPresSettings
.mbFullScreen
;
2959 // --------------------------------------------------------------------
2961 sal_Bool SAL_CALL
SlideshowImpl::getMouseVisible() throw (RuntimeException
)
2963 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
2964 return maPresSettings
.mbMouseVisible
;
2967 // --------------------------------------------------------------------
2969 void SAL_CALL
SlideshowImpl::setMouseVisible( sal_Bool bVisible
) throw (RuntimeException
)
2971 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
2972 if( maPresSettings
.mbMouseVisible
!= bVisible
)
2974 maPresSettings
.mbMouseVisible
= bVisible
;
2976 mpShowWindow
->SetMouseAutoHide( !maPresSettings
.mbMouseVisible
);
2980 // --------------------------------------------------------------------
2982 sal_Bool SAL_CALL
SlideshowImpl::getUsePen() throw (RuntimeException
)
2984 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
2985 return maPresSettings
.mbMouseAsPen
;
2988 // --------------------------------------------------------------------
2990 void SAL_CALL
SlideshowImpl::setUsePen( sal_Bool bMouseAsPen
) throw (RuntimeException
)
2992 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
2993 maPresSettings
.mbMouseAsPen
= bMouseAsPen
;
2994 if( mxShow
.is() ) try
2997 if( maPresSettings
.mbMouseAsPen
)
2998 // todo: take color from configuration
2999 aValue
<<= mnUserPaintColor
;
3001 beans::PropertyValue aPenProp
;
3002 aPenProp
.Name
= OUString( RTL_CONSTASCII_USTRINGPARAM( "UserPaintColor" ));
3003 aPenProp
.Value
= aValue
;
3005 mxShow
->setProperty( aPenProp
);
3009 if( maPresSettings
.mbMouseAsPen
)
3010 aValueWidth
<<= mdUserPaintStrokeWidth
;
3012 beans::PropertyValue aPenPropWidth
;
3013 aPenPropWidth
.Name
= OUString( RTL_CONSTASCII_USTRINGPARAM( "UserPaintStrokeWidth" ));
3014 aPenPropWidth
.Value
= aValueWidth
;
3016 mxShow
->setProperty( aPenPropWidth
);
3018 catch( Exception
& e
)
3020 static_cast<void>(e
);
3022 (OString("sd::SlideshowImpl::setUsePen(), "
3023 "exception caught: ") +
3024 rtl::OUStringToOString(
3025 comphelper::anyToString( cppu::getCaughtException() ),
3026 RTL_TEXTENCODING_UTF8
)).getStr() );
3031 // --------------------------------------------------------------------
3033 double SAL_CALL
SlideshowImpl::getPenWidth() throw (RuntimeException
)
3035 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
3036 return mdUserPaintStrokeWidth
;
3040 // --------------------------------------------------------------------
3042 void SAL_CALL
SlideshowImpl::setPenWidth( double dStrokeWidth
) throw (RuntimeException
)
3044 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
3045 mdUserPaintStrokeWidth
= dStrokeWidth
;
3046 if( maPresSettings
.mbMouseAsPen
)
3047 setUsePen( sal_True
); // update color and width
3051 // --------------------------------------------------------------------
3053 sal_Int32 SAL_CALL
SlideshowImpl::getPenColor() throw (RuntimeException
)
3055 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
3056 return mnUserPaintColor
;
3060 // --------------------------------------------------------------------
3062 void SAL_CALL
SlideshowImpl::setPenColor( sal_Int32 nColor
) throw (RuntimeException
)
3064 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
3065 mnUserPaintColor
= nColor
;
3066 if( maPresSettings
.mbMouseAsPen
)
3067 setUsePen( sal_True
); // update color and width
3070 // --------------------------------------------------------------------
3071 // XSlideShowController Methods
3072 // --------------------------------------------------------------------
3074 sal_Bool SAL_CALL
SlideshowImpl::isRunning( ) throw (RuntimeException
)
3076 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
3080 // --------------------------------------------------------------------
3082 void SAL_CALL
SlideshowImpl::gotoNextEffect( ) throw (RuntimeException
)
3084 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
3086 if( mxShow
.is() && mpSlideController
.get() && mpShowWindow
)
3091 const ShowWindowMode eMode
= mpShowWindow
->GetShowWindowMode();
3092 if( eMode
== SHOWWINDOWMODE_END
)
3096 else if( (eMode
== SHOWWINDOWMODE_PAUSE
) || (eMode
== SHOWWINDOWMODE_BLANK
) )
3098 mpShowWindow
->RestartShow();
3102 mxShow
->nextEffect();
3108 // --------------------------------------------------------------------
3110 void SAL_CALL
SlideshowImpl::gotoPreviousEffect( ) throw (RuntimeException
)
3112 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
3114 if( mxShow
.is() && mpSlideController
.get() && mpShowWindow
)
3119 const ShowWindowMode eMode
= mpShowWindow
->GetShowWindowMode();
3120 if( (eMode
== SHOWWINDOWMODE_PAUSE
) || (eMode
== SHOWWINDOWMODE_BLANK
) )
3122 mpShowWindow
->RestartShow();
3126 mxShow
->previousEffect();
3132 // --------------------------------------------------------------------
3134 void SAL_CALL
SlideshowImpl::gotoFirstSlide( ) throw (RuntimeException
)
3136 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
3138 if( mpShowWindow
&& mpSlideController
.get() )
3143 if( mpShowWindow
->GetShowWindowMode() == SHOWWINDOWMODE_END
)
3145 if( mpSlideController
->getSlideIndexCount() )
3146 mpShowWindow
->RestartShow( 0);
3150 displaySlideIndex( 0 );
3155 // --------------------------------------------------------------------
3157 void SAL_CALL
SlideshowImpl::gotoNextSlide( ) throw (RuntimeException
)
3159 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
3164 const ShowWindowMode eMode
= mpShowWindow
->GetShowWindowMode();
3165 if( (eMode
== SHOWWINDOWMODE_PAUSE
) || (eMode
== SHOWWINDOWMODE_BLANK
) )
3167 mpShowWindow
->RestartShow();
3171 // if this is a show, ignore user inputs and
3172 // start 20ms timer to reenable inputs to fiter
3173 // buffered inputs during slide transition
3174 if( meAnimationMode
== ANIMATIONMODE_SHOW
)
3176 mbInputFreeze
= true;
3177 maInputFreezeTimer
.Start();
3180 if( mpSlideController
.get() )
3182 if( mpSlideController
->nextSlide() )
3184 displayCurrentSlide();
3190 if( meAnimationMode
== ANIMATIONMODE_PREVIEW
)
3194 else if( maPresSettings
.mbEndless
)
3196 if( maPresSettings
.mnPauseTimeout
)
3198 boost::scoped_ptr
< Graphic
> pGraphic
;
3200 if( maPresSettings
.mbShowPauseLogo
)
3202 // load about image from module path
3203 String
aBmpFileName( RTL_CONSTASCII_USTRINGPARAM("about.bmp") );
3204 INetURLObject
aObj( SvtPathOptions().GetModulePath(), INET_PROT_FILE
);
3205 aObj
.insertName( aBmpFileName
);
3206 SvFileStream
aStrm( aObj
.PathToFileName(), STREAM_STD_READ
);
3207 if ( !aStrm
.GetError() )
3211 pGraphic
.reset( new Graphic(aBmp
) );
3212 pGraphic
->SetPrefMapMode(MAP_PIXEL
);
3216 //if no image is located in the module path
3217 //use default logo from iso resource:
3219 String
aMgrName( RTL_CONSTASCII_USTRINGPARAM( "iso" ) );
3220 boost::scoped_ptr
< ResMgr
> pResMgr( ResMgr::CreateResMgr( U2S( aMgrName
)) );
3221 DBG_ASSERT(pResMgr
,"No ResMgr found");
3224 pGraphic
.reset( new Graphic( Bitmap( ResId( RID_DEFAULT_ABOUT_BMP_LOGO
, *pResMgr
) ) ) );
3225 pGraphic
->SetPrefMapMode(MAP_PIXEL
);
3230 mpShowWindow
->SetPauseMode( 0, maPresSettings
.mnPauseTimeout
, pGraphic
.get() );
3234 displaySlideIndex( 0 );
3241 mpShowWindow
->SetEndMode();
3250 // --------------------------------------------------------------------
3252 void SAL_CALL
SlideshowImpl::gotoPreviousSlide( ) throw (RuntimeException
)
3254 gotoPreviousSlide(false);
3257 void SlideshowImpl::gotoPreviousSlide (const bool bSkipAllMainSequenceEffects
)
3259 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
3261 if( mxShow
.is() && mpSlideController
.get() ) try
3266 const ShowWindowMode eMode
= mpShowWindow
->GetShowWindowMode();
3267 if( eMode
== SHOWWINDOWMODE_END
)
3269 const sal_Int32 nLastSlideIndex
= mpSlideController
->getSlideIndexCount() - 1;
3270 if( nLastSlideIndex
>= 0 )
3271 mpShowWindow
->RestartShow( nLastSlideIndex
);
3273 else if( (eMode
== SHOWWINDOWMODE_PAUSE
) || (eMode
== SHOWWINDOWMODE_BLANK
) )
3275 mpShowWindow
->RestartShow();
3279 if( mpSlideController
->previousSlide())
3280 displayCurrentSlide(bSkipAllMainSequenceEffects
);
3281 else if (bSkipAllMainSequenceEffects
)
3283 // We could not go to the previous slide (probably because
3284 // the current slide is already the first one). We still
3285 // have to call displayCurrentSlide because the calling
3286 // slideshow can not determine whether there is a previous
3287 // slide or not and has already prepared for a slide change.
3288 // This slide change has to be completed now, even when
3289 // changing to the same slide.
3290 // Note that in this special case we do NOT pass
3291 // bSkipAllMainSequenceEffects because we display the same
3292 // slide as before and do not want to show all its effects.
3293 displayCurrentSlide(false);
3297 catch( Exception
& e
)
3299 static_cast<void>(e
);
3301 (OString("sd::SlideshowImpl::gotoPreviousSlide(), "
3302 "exception caught: ") +
3303 rtl::OUStringToOString(
3304 comphelper::anyToString( cppu::getCaughtException() ),
3305 RTL_TEXTENCODING_UTF8
)).getStr() );
3309 // --------------------------------------------------------------------
3311 void SAL_CALL
SlideshowImpl::gotoLastSlide() throw (RuntimeException
)
3313 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
3315 if( mpSlideController
.get() )
3320 const sal_Int32 nLastSlideIndex
= mpSlideController
->getSlideIndexCount() - 1;
3321 if( nLastSlideIndex
>= 0 )
3323 if( mpShowWindow
->GetShowWindowMode() == SHOWWINDOWMODE_END
)
3325 mpShowWindow
->RestartShow( nLastSlideIndex
);
3329 displaySlideIndex( nLastSlideIndex
);
3335 // --------------------------------------------------------------------
3337 void SAL_CALL
SlideshowImpl::gotoBookmark( const OUString
& rBookmark
) throw (RuntimeException
)
3339 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
3344 sal_Int32 nSlideNumber
= getSlideNumberForBookmark( rBookmark
);
3345 if( nSlideNumber
!= -1 )
3346 displaySlideNumber( nSlideNumber
);
3349 // --------------------------------------------------------------------
3351 void SAL_CALL
SlideshowImpl::gotoSlide( const Reference
< XDrawPage
>& xSlide
)
3352 throw(IllegalArgumentException
, RuntimeException
)
3354 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
3356 if( mpSlideController
.get() && xSlide
.is() )
3361 const sal_Int32 nSlideCount
= mpSlideController
->getSlideNumberCount();
3362 for( sal_Int32 nSlide
= 0; nSlide
< nSlideCount
; nSlide
++ )
3364 if( mpSlideController
->getSlideByNumber( nSlide
) == xSlide
)
3366 displaySlideNumber( nSlide
);
3372 // --------------------------------------------------------------------
3374 void SAL_CALL
SlideshowImpl::gotoSlideIndex( sal_Int32 nIndex
) throw (RuntimeException
)
3376 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
3381 displaySlideIndex( nIndex
);
3384 // --------------------------------------------------------------------
3386 void SAL_CALL
SlideshowImpl::stopSound( ) throw (RuntimeException
)
3388 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
3398 catch( Exception
& e
)
3400 static_cast<void>(e
);
3402 (OString("sd::SlideshowImpl::stopSound(), "
3403 "exception caught: ") +
3404 rtl::OUStringToOString(
3405 comphelper::anyToString( cppu::getCaughtException() ),
3406 RTL_TEXTENCODING_UTF8
)).getStr() );
3410 // --------------------------------------------------------------------
3412 // --------------------------------------------------------------------
3414 ::sal_Int32 SAL_CALL
SlideshowImpl::getCount( ) throw (::com::sun::star::uno::RuntimeException
)
3416 return getSlideCount();
3419 // --------------------------------------------------------------------
3421 ::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
)
3423 return Any( getSlideByIndex( Index
) );
3426 // --------------------------------------------------------------------
3428 ::com::sun::star::uno::Type SAL_CALL
SlideshowImpl::getElementType( ) throw (::com::sun::star::uno::RuntimeException
)
3430 return XDrawPage::static_type();
3433 // --------------------------------------------------------------------
3435 ::sal_Bool SAL_CALL
SlideshowImpl::hasElements( ) throw (::com::sun::star::uno::RuntimeException
)
3437 return getSlideCount() != 0;
3440 // --------------------------------------------------------------------
3442 Reference
< XSlideShow
> SAL_CALL
SlideshowImpl::getSlideShow() throw (RuntimeException
)
3447 // --------------------------------------------------------------------
3450 PresentationSettingsEx::PresentationSettingsEx()
3451 : mbRehearseTimings(sal_False
)
3452 , mbPreview(sal_False
)
3453 , mpParentWindow( 0 )
3457 PresentationSettingsEx::PresentationSettingsEx( PresentationSettingsEx
& r
)
3458 : PresentationSettings( r
)
3459 , mbRehearseTimings(r
.mbRehearseTimings
)
3460 , mbPreview(r
.mbPreview
)
3461 , mpParentWindow( 0 )
3465 PresentationSettingsEx::PresentationSettingsEx( PresentationSettings
& r
)
3466 : PresentationSettings( r
)
3467 , mbRehearseTimings(sal_False
)
3468 , mbPreview(sal_False
)
3473 void PresentationSettingsEx::SetArguments( const Sequence
< PropertyValue
>& rArguments
) throw (IllegalArgumentException
)
3475 sal_Int32 nArguments
= rArguments
.getLength();
3476 const PropertyValue
* pValue
= rArguments
.getConstArray();
3478 while( nArguments
-- )
3480 SetPropertyValue( pValue
->Name
, pValue
->Value
);
3485 void PresentationSettingsEx::SetPropertyValue( const OUString
& rProperty
, const Any
& rValue
) throw (IllegalArgumentException
)
3487 if( rProperty
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("RehearseTimings") ) )
3489 if( rValue
>>= mbRehearseTimings
)
3492 else if( rProperty
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Preview") ) )
3494 if( rValue
>>= mbPreview
)
3497 else if( rProperty
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("AnimationNode") ) )
3499 if( rValue
>>= mxAnimationNode
)
3502 else if( rProperty
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ParentWindow") ) )
3504 Reference
< XWindow
> xWindow
;
3505 if( rValue
>>= xWindow
)
3507 mpParentWindow
= xWindow
.is() ? VCLUnoHelper::GetWindow( xWindow
) : 0;
3511 else if( rProperty
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("AllowAnimations") ) )
3513 if( rValue
>>= mbAnimationAllowed
)
3516 else if( rProperty
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("AllowAnimations") ) )
3518 if( rValue
>>= mbAnimationAllowed
)
3521 else if( rProperty
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("FirstPage") ) )
3524 if( rValue
>>= aPresPage
)
3526 maPresPage
= getUiNameFromPageApiNameImpl(aPresPage
);
3527 mbCustomShow
= sal_False
;
3533 if( rValue
>>= mxStartPage
)
3537 else if( rProperty
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("IsAlwaysOnTop") ) )
3539 if( rValue
>>= mbAlwaysOnTop
)
3542 else if( rProperty
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("IsAutomatic") ) )
3544 if( rValue
>>= mbManual
)
3547 else if( rProperty
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("IsEndless") ) )
3549 if( rValue
>>= mbEndless
)
3552 else if( rProperty
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("IsFullScreen") ) )
3554 if( rValue
>>= mbFullScreen
)
3557 else if( rProperty
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("IsMouseVisible") ) )
3559 if( rValue
>>= mbMouseVisible
)
3562 else if( rProperty
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Pause") ) )
3564 sal_Int32 nPause
= -1;
3565 if( (rValue
>>= nPause
) && (nPause
>= 0) )
3567 mnPauseTimeout
= nPause
;
3571 else if( rProperty
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("StartWithNavigator") ) )
3573 if( rValue
>>= mbStartWithNavigator
)
3576 else if( rProperty
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UsePen") ) )
3578 if( rValue
>>= mbMouseAsPen
)
3581 throw IllegalArgumentException();
3584 ////////////////////////////////
3586 // ---------------------------------------------------------
3587 // XAnimationListener
3588 // ---------------------------------------------------------
3590 SlideShowListenerProxy::SlideShowListenerProxy( const rtl::Reference
< SlideshowImpl
>& xController
, const css::uno::Reference
< css::presentation::XSlideShow
>& xSlideShow
)
3591 : maListeners( m_aMutex
)
3592 , mxController( xController
)
3593 , mxSlideShow( xSlideShow
)
3597 // ---------------------------------------------------------
3599 SlideShowListenerProxy::~SlideShowListenerProxy()
3603 // ---------------------------------------------------------
3605 void SlideShowListenerProxy::addAsSlideShowListener()
3607 if( mxSlideShow
.is() )
3609 Reference
< XSlideShowListener
> xSlideShowListener( this );
3610 mxSlideShow
->addSlideShowListener( xSlideShowListener
);
3614 // ---------------------------------------------------------
3616 void SlideShowListenerProxy::removeAsSlideShowListener()
3618 if( mxSlideShow
.is() )
3620 Reference
< XSlideShowListener
> xSlideShowListener( this );
3621 mxSlideShow
->removeSlideShowListener( xSlideShowListener
);
3625 // ---------------------------------------------------------
3627 void SlideShowListenerProxy::addShapeEventListener( const css::uno::Reference
< css::drawing::XShape
>& xShape
)
3629 if( mxSlideShow
.is() )
3631 Reference
< XShapeEventListener
> xListener( this );
3632 mxSlideShow
->addShapeEventListener( xListener
, xShape
);
3636 // ---------------------------------------------------------
3638 void SlideShowListenerProxy::removeShapeEventListener( const css::uno::Reference
< css::drawing::XShape
>& xShape
)
3640 if( mxSlideShow
.is() )
3642 Reference
< XShapeEventListener
> xListener( this );
3643 mxSlideShow
->removeShapeEventListener( xListener
, xShape
);
3647 // ---------------------------------------------------------
3649 void SlideShowListenerProxy::addSlideShowListener( const css::uno::Reference
< css::presentation::XSlideShowListener
>& xListener
)
3651 maListeners
.addInterface(xListener
);
3654 // ---------------------------------------------------------
3656 void SlideShowListenerProxy::removeSlideShowListener( const css::uno::Reference
< css::presentation::XSlideShowListener
>& xListener
)
3658 maListeners
.removeInterface(xListener
);
3661 // ---------------------------------------------------------
3663 void SAL_CALL
SlideShowListenerProxy::beginEvent( const Reference
< XAnimationNode
>& xNode
) throw (RuntimeException
)
3665 ::osl::MutexGuard
aGuard( m_aMutex
);
3667 if( maListeners
.getLength() >= 0 )
3668 maListeners
.forEach
<XSlideShowListener
>( boost::bind( &XAnimationListener::beginEvent
, _1
, boost::cref(xNode
) ));
3671 // ---------------------------------------------------------
3673 void SAL_CALL
SlideShowListenerProxy::endEvent( const Reference
< XAnimationNode
>& xNode
) throw (RuntimeException
)
3675 ::osl::MutexGuard
aGuard( m_aMutex
);
3677 if( maListeners
.getLength() >= 0 )
3678 maListeners
.forEach
<XSlideShowListener
>( boost::bind( &XAnimationListener::endEvent
, _1
, boost::cref(xNode
) ));
3681 // ---------------------------------------------------------
3683 void SAL_CALL
SlideShowListenerProxy::repeat( const Reference
< XAnimationNode
>& xNode
, ::sal_Int32 nRepeat
) throw (RuntimeException
)
3685 ::osl::MutexGuard
aGuard( m_aMutex
);
3687 if( maListeners
.getLength() >= 0 )
3688 maListeners
.forEach
<XSlideShowListener
>( boost::bind( &XAnimationListener::repeat
, _1
, boost::cref(xNode
), boost::cref(nRepeat
) ));
3691 // ---------------------------------------------------------
3692 // ::com::sun::star::presentation::XSlideShowListener:
3693 // ---------------------------------------------------------
3695 void SAL_CALL
SlideShowListenerProxy::paused( ) throw (::com::sun::star::uno::RuntimeException
)
3697 ::osl::MutexGuard
aGuard( m_aMutex
);
3699 if( maListeners
.getLength() >= 0 )
3700 maListeners
.forEach
<XSlideShowListener
>( boost::mem_fn( &XSlideShowListener::paused
) );
3703 // ---------------------------------------------------------
3705 void SAL_CALL
SlideShowListenerProxy::resumed( ) throw (::com::sun::star::uno::RuntimeException
)
3707 ::osl::MutexGuard
aGuard( m_aMutex
);
3709 if( maListeners
.getLength() >= 0 )
3710 maListeners
.forEach
<XSlideShowListener
>( boost::mem_fn( &XSlideShowListener::resumed
) );
3713 // ---------------------------------------------------------
3715 void SAL_CALL
SlideShowListenerProxy::slideTransitionStarted( ) throw (RuntimeException
)
3717 ::osl::MutexGuard
aGuard( m_aMutex
);
3719 if( maListeners
.getLength() >= 0 )
3720 maListeners
.forEach
<XSlideShowListener
>( boost::mem_fn( &XSlideShowListener::slideTransitionStarted
) );
3723 // ---------------------------------------------------------
3725 void SAL_CALL
SlideShowListenerProxy::slideTransitionEnded( ) throw (::com::sun::star::uno::RuntimeException
)
3727 ::osl::MutexGuard
aGuard( m_aMutex
);
3729 if( maListeners
.getLength() >= 0 )
3730 maListeners
.forEach
<XSlideShowListener
>( boost::mem_fn( &XSlideShowListener::slideTransitionEnded
) );
3733 // ---------------------------------------------------------
3735 void SAL_CALL
SlideShowListenerProxy::slideAnimationsEnded( ) throw (::com::sun::star::uno::RuntimeException
)
3737 ::osl::MutexGuard
aGuard( m_aMutex
);
3739 if( maListeners
.getLength() >= 0 )
3740 maListeners
.forEach
<XSlideShowListener
>( boost::mem_fn( &XSlideShowListener::slideAnimationsEnded
) );
3743 // ---------------------------------------------------------
3745 void SlideShowListenerProxy::slideEnded(sal_Bool bReverse
) throw (RuntimeException
)
3748 ::osl::MutexGuard
aGuard( m_aMutex
);
3750 if( maListeners
.getLength() >= 0 )
3751 maListeners
.forEach
<XSlideShowListener
>(
3752 boost::bind( &XSlideShowListener::slideEnded
, _1
, bReverse
) );
3756 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
3757 if( mxController
.is() )
3758 mxController
->slideEnded(bReverse
);
3762 // ---------------------------------------------------------
3764 void SlideShowListenerProxy::hyperLinkClicked( rtl::OUString
const& aHyperLink
) throw (RuntimeException
)
3767 ::osl::MutexGuard
aGuard( m_aMutex
);
3769 if( maListeners
.getLength() >= 0 )
3770 maListeners
.forEach
<XSlideShowListener
>( boost::bind( &XSlideShowListener::hyperLinkClicked
, _1
, boost::cref(aHyperLink
) ));
3774 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
3775 if( mxController
.is() )
3776 mxController
->hyperLinkClicked(aHyperLink
);
3780 // ---------------------------------------------------------
3782 // ---------------------------------------------------------
3784 void SAL_CALL
SlideShowListenerProxy::disposing( const ::com::sun::star::lang::EventObject
& aDisposeEvent
) throw (RuntimeException
)
3786 maListeners
.disposeAndClear( aDisposeEvent
);
3787 mxController
.clear();
3788 mxSlideShow
.clear();
3791 // ---------------------------------------------------------
3792 // XShapeEventListener
3793 // ---------------------------------------------------------
3795 void SAL_CALL
SlideShowListenerProxy::click( const Reference
< XShape
>& xShape
, const ::com::sun::star::awt::MouseEvent
& aOriginalEvent
) throw (RuntimeException
)
3797 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
3798 if( mxController
.is() )
3799 mxController
->click(xShape
, aOriginalEvent
);