merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / animations / SlideTransitionPane.cxx
bloba63f5278aa329c143f0d8382b2624af85bf47a1a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SlideTransitionPane.cxx,v $
10 * $Revision: 1.19 $
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 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
33 #include <com/sun/star/animations/XAnimationNode.hpp>
35 #include "SlideTransitionPane.hxx"
36 #include "SlideTransitionPane.hrc"
37 #include "CustomAnimation.hrc"
39 #include "TransitionPreset.hxx"
40 #include "sdresid.hxx"
41 #include "ViewShellBase.hxx"
42 #include "DrawDocShell.hxx"
43 #include "SlideSorterViewShell.hxx"
44 #include "drawdoc.hxx"
45 #include "filedlg.hxx"
46 #include "strings.hrc"
47 #include "DrawController.hxx"
48 #include <com/sun/star/beans/XPropertySet.hpp>
50 #ifndef _SVT_CONTROLDIMS_HRC_
51 #include <svtools/controldims.hrc>
52 #endif
53 #include <svx/gallery.hxx>
54 #include <svtools/pathoptions.hxx>
55 #include <vcl/msgbox.hxx>
56 #include <tools/urlobj.hxx>
57 #include "DrawViewShell.hxx"
58 #include "slideshow.hxx"
59 #include "drawview.hxx"
60 #include "sdundogr.hxx"
61 #include "undoanim.hxx"
62 #include "optsitem.hxx"
63 #include "sddll.hxx"
64 #include "framework/FrameworkHelper.hxx"
66 #include "DialogListBox.hxx"
68 #include <algorithm>
69 #include <memory>
72 using namespace ::com::sun::star;
74 using ::com::sun::star::uno::Reference;
75 using ::com::sun::star::uno::Sequence;
76 using ::rtl::OUString;
77 using ::com::sun::star::uno::RuntimeException;
79 using ::sd::framework::FrameworkHelper;
81 // ____________________________
83 // ::sd::impl::TransitionEffect
84 // ____________________________
86 namespace sd
88 namespace impl
90 struct TransitionEffect
92 TransitionEffect() :
93 mnType( 0 ),
94 mnSubType( 0 ),
95 mbDirection( sal_True ),
96 mnFadeColor( 0 )
98 init();
100 explicit TransitionEffect( const ::sd::TransitionPreset & rPreset ) :
101 mnType( rPreset.getTransition()),
102 mnSubType( rPreset.getSubtype()),
103 mbDirection( rPreset.getDirection()),
104 mnFadeColor( rPreset.getFadeColor())
106 init();
108 explicit TransitionEffect( sal_Int16 nType, sal_Int16 nSubType,
109 sal_Bool bDirection, sal_Int32 nFadeColor ) :
110 mnType( nType),
111 mnSubType( nSubType ),
112 mbDirection( bDirection ),
113 mnFadeColor( nFadeColor )
115 init();
117 explicit TransitionEffect( const SdPage & rPage ) :
118 mnType( rPage.getTransitionType() ),
119 mnSubType( rPage.getTransitionSubtype() ),
120 mbDirection( rPage.getTransitionDirection() ),
121 mnFadeColor( rPage.getTransitionFadeColor() )
123 init();
125 mfDuration = rPage.getTransitionDuration();
126 mnTime = rPage.GetTime();
127 mePresChange = rPage.GetPresChange();
128 mbSoundOn = rPage.IsSoundOn();
129 maSound = rPage.GetSoundFile();
130 mbLoopSound = rPage.IsLoopSound();
131 mbStopSound = rPage.IsStopSound();
134 void init()
136 mfDuration = 2.0;
137 mnTime = 0;
138 mePresChange = PRESCHANGE_MANUAL;
139 mbSoundOn = FALSE;
140 mbLoopSound = FALSE;
141 mbStopSound = FALSE;
143 mbEffectAmbiguous = false;
144 mbDurationAmbiguous = false;
145 mbTimeAmbiguous = false;
146 mbPresChangeAmbiguous = false;
147 mbSoundAmbiguous = false;
148 mbLoopSoundAmbiguous = false;
151 void setAllAmbiguous()
153 mbEffectAmbiguous = true;
154 mbDurationAmbiguous = true;
155 mbTimeAmbiguous = true;
156 mbPresChangeAmbiguous = true;
157 mbSoundAmbiguous = true;
158 mbLoopSoundAmbiguous = true;
161 bool operator == ( const ::sd::TransitionPreset & rPreset ) const
163 return
164 (mnType == rPreset.getTransition()) &&
165 (mnSubType == rPreset.getSubtype()) &&
166 (mbDirection == rPreset.getDirection()) &&
167 (mnFadeColor == rPreset.getFadeColor());
170 void applyTo( SdPage & rOutPage ) const
172 if( ! mbEffectAmbiguous )
174 rOutPage.setTransitionType( mnType );
175 rOutPage.setTransitionSubtype( mnSubType );
176 rOutPage.setTransitionDirection( mbDirection );
177 rOutPage.setTransitionFadeColor( mnFadeColor );
180 if( ! mbDurationAmbiguous )
181 rOutPage.setTransitionDuration( mfDuration );
182 if( ! mbTimeAmbiguous )
183 rOutPage.SetTime( mnTime );
184 if( ! mbPresChangeAmbiguous )
185 rOutPage.SetPresChange( mePresChange );
186 if( ! mbSoundAmbiguous )
188 if( mbStopSound )
190 rOutPage.SetStopSound( TRUE );
191 rOutPage.SetSound( FALSE );
193 else
195 rOutPage.SetStopSound( FALSE );
196 rOutPage.SetSound( mbSoundOn );
197 rOutPage.SetSoundFile( maSound );
200 if( ! mbLoopSoundAmbiguous )
201 rOutPage.SetLoopSound( mbLoopSound );
204 void compareWith( const SdPage & rPage )
206 TransitionEffect aOtherEffect( rPage );
207 mbEffectAmbiguous = mbEffectAmbiguous || aOtherEffect.mbEffectAmbiguous
208 || (mnType != aOtherEffect.mnType)
209 || (mnSubType != aOtherEffect.mnSubType)
210 || (mbDirection != aOtherEffect.mbDirection)
211 || (mnFadeColor != aOtherEffect.mnFadeColor);
213 mbDurationAmbiguous = mbDurationAmbiguous || aOtherEffect.mbDurationAmbiguous || mfDuration != aOtherEffect.mfDuration;
214 mbTimeAmbiguous = mbTimeAmbiguous || aOtherEffect.mbTimeAmbiguous || mnTime != aOtherEffect.mnTime;
215 mbPresChangeAmbiguous = mbPresChangeAmbiguous || aOtherEffect.mbPresChangeAmbiguous || mePresChange != aOtherEffect.mePresChange;
216 mbSoundAmbiguous = mbSoundAmbiguous || aOtherEffect.mbSoundAmbiguous || mbSoundOn != aOtherEffect.mbSoundOn;
217 (!mbStopSound && !aOtherEffect.mbStopSound && maSound != aOtherEffect.maSound) || (mbStopSound != aOtherEffect.mbStopSound);
218 mbLoopSoundAmbiguous = mbLoopSoundAmbiguous || aOtherEffect.mbLoopSoundAmbiguous || mbLoopSound != aOtherEffect.mbLoopSound;
221 // effect
222 sal_Int16 mnType;
223 sal_Int16 mnSubType;
224 sal_Bool mbDirection;
225 sal_Int32 mnFadeColor;
227 // other settings
228 double mfDuration;
229 ULONG mnTime;
230 PresChange mePresChange;
231 BOOL mbSoundOn;
232 String maSound;
233 bool mbLoopSound;
234 bool mbStopSound;
236 bool mbEffectAmbiguous;
237 bool mbDurationAmbiguous;
238 bool mbTimeAmbiguous;
239 bool mbPresChangeAmbiguous;
240 bool mbSoundAmbiguous;
241 bool mbLoopSoundAmbiguous;
244 } // namespace impl
245 } // namespace sd
247 // ______________________
249 // Local Helper Functions
250 // ______________________
252 namespace
255 void lcl_ApplyToPages(
256 const ::sd::slidesorter::SharedPageSelection& rpPages,
257 const ::sd::impl::TransitionEffect & rEffect )
259 ::std::vector< SdPage * >::const_iterator aIt( rpPages->begin());
260 const ::std::vector< SdPage * >::const_iterator aEndIt( rpPages->end());
261 for( ; aIt != aEndIt; ++aIt )
263 rEffect.applyTo( *(*aIt) );
267 void lcl_CreateUndoForPages(
268 const ::sd::slidesorter::SharedPageSelection& rpPages,
269 ::sd::ViewShellBase& rBase )
271 ::sd::DrawDocShell* pDocSh = rBase.GetDocShell();
272 SfxUndoManager* pManager = pDocSh->GetUndoManager();
273 SdDrawDocument* pDoc = pDocSh->GetDoc();
274 if( pManager && pDocSh && pDoc )
276 String aComment( SdResId(STR_UNDO_SLIDE_PARAMS) );
277 pManager->EnterListAction(aComment, aComment);
278 SdUndoGroup* pUndoGroup = new SdUndoGroup( pDoc );
279 pUndoGroup->SetComment( aComment );
281 ::std::vector< SdPage * >::const_iterator aIt( rpPages->begin());
282 const ::std::vector< SdPage * >::const_iterator aEndIt( rpPages->end());
283 for( ; aIt != aEndIt; ++aIt )
285 pUndoGroup->AddAction( new sd::UndoTransition( pDoc, (*aIt) ) );
288 pManager->AddUndoAction( pUndoGroup );
289 pManager->LeaveListAction();
293 sal_uInt16 lcl_getTransitionEffectIndex(
294 SdDrawDocument * pDoc,
295 const ::sd::impl::TransitionEffect & rTransition )
297 // first entry: "<none>"
298 sal_uInt16 nResultIndex = LISTBOX_ENTRY_NOTFOUND;
300 if( pDoc )
302 sal_uInt16 nCurrentIndex = 0;
303 const ::sd::TransitionPresetList & rPresetList = ::sd::TransitionPreset::getTransitionPresetList();
304 ::sd::TransitionPresetList::const_iterator aIt( rPresetList.begin());
305 const ::sd::TransitionPresetList::const_iterator aEndIt( rPresetList.end());
306 for( ; aIt != aEndIt; ++aIt, ++nCurrentIndex )
308 if( rTransition.operator==( *(*aIt) ))
310 nResultIndex = nCurrentIndex;
311 break;
316 return nResultIndex;
319 ::sd::TransitionPresetPtr lcl_getTransitionPresetByUIName(
320 SdDrawDocument * pDoc,
321 const OUString & rUIName )
323 ::sd::TransitionPresetPtr pResult;
324 if( pDoc )
326 const ::sd::TransitionPresetList& rPresetList = ::sd::TransitionPreset::getTransitionPresetList();
327 ::sd::TransitionPresetList::const_iterator aIter( rPresetList.begin() );
328 const ::sd::TransitionPresetList::const_iterator aEnd( rPresetList.end() );
329 for( ; aIter != aEnd; ++aIter )
331 if( (*aIter)->getUIName().equals( rUIName ))
333 pResult = *aIter;
334 break;
339 return pResult;
342 struct lcl_EqualsSoundFileName : public ::std::unary_function< String, bool >
344 explicit lcl_EqualsSoundFileName( const String & rStr ) :
345 maStr( rStr )
348 bool operator() ( const String & rStr ) const
350 // note: formerly this was a case insensitive search for all
351 // platforms. It seems more sensible to do this platform-dependent
352 #if defined( WIN ) || defined( WNT )
353 return maStr.EqualsIgnoreCaseAscii( rStr );
354 #else
355 return maStr.Equals( rStr );
356 #endif
359 private:
360 String maStr;
363 // returns -1 if no object was found
364 bool lcl_findSoundInList( const ::std::vector< String > & rSoundList,
365 const String & rFileName,
366 ::std::vector< String >::size_type & rOutPosition )
368 ::std::vector< String >::const_iterator aIt =
369 ::std::find_if( rSoundList.begin(), rSoundList.end(),
370 lcl_EqualsSoundFileName( rFileName ));
371 if( aIt != rSoundList.end())
373 rOutPosition = ::std::distance( rSoundList.begin(), aIt );
374 return true;
377 return false;
380 String lcl_getSoundFileURL(
381 const ::std::vector< String > & rSoundList,
382 const ListBox & rListBox )
384 String aResult;
386 if( rListBox.GetSelectEntryCount() > 0 )
388 sal_uInt16 nPos = rListBox.GetSelectEntryPos();
389 // the first three entries are no actual sounds
390 if( nPos >= 3 )
392 DBG_ASSERT( (sal_uInt32)(rListBox.GetEntryCount() - 3) == rSoundList.size(),
393 "Sound list-box is not synchronized to sound list" );
394 nPos -= 3;
395 if( rSoundList.size() > nPos )
396 aResult = rSoundList[ nPos ];
400 return aResult;
403 struct lcl_AppendSoundToListBox : public ::std::unary_function< String, void >
405 lcl_AppendSoundToListBox( ListBox & rListBox ) :
406 mrListBox( rListBox )
409 void operator() ( const String & rString ) const
411 INetURLObject aURL( rString );
412 mrListBox.InsertEntry( aURL.GetBase(), LISTBOX_APPEND );
415 private:
416 ListBox & mrListBox;
419 void lcl_FillSoundListBox(
420 const ::std::vector< String > & rSoundList,
421 ListBox & rOutListBox )
423 sal_uInt16 nCount = rOutListBox.GetEntryCount();
425 // keep first three entries
426 for( sal_uInt16 i=nCount - 1; i>=3; --i )
427 rOutListBox.RemoveEntry( i );
429 ::std::for_each( rSoundList.begin(), rSoundList.end(),
430 lcl_AppendSoundToListBox( rOutListBox ));
433 } // anonymous namespace
435 namespace sd
438 // ___________________
440 // SlideTransitionPane
441 // ___________________
443 SlideTransitionPane::SlideTransitionPane(
444 ::Window * pParent,
445 ViewShellBase & rBase,
446 const Size& rMinSize,
447 SdDrawDocument* pDoc ) :
448 Control( pParent, SdResId( DLG_SLIDE_TRANSITION_PANE ) ),
450 mrBase( rBase ),
451 mpDrawDoc( pDoc ),
452 maMinSize( rMinSize ),
453 maFL_APPLY_TRANSITION( this, SdResId( FL_APPLY_TRANSITION ) ),
454 maLB_SLIDE_TRANSITIONS( this, SdResId( LB_SLIDE_TRANSITIONS ) ),
455 maFL_MODIFY_TRANSITION( this, SdResId( FL_MODIFY_TRANSITION ) ),
456 maFT_SPEED( this, SdResId( FT_SPEED ) ),
457 maLB_SPEED( this, SdResId( LB_SPEED ) ),
458 maFT_SOUND( this, SdResId( FT_SOUND ) ),
459 maLB_SOUND( this, SdResId( LB_SOUND ) ),
460 maCB_LOOP_SOUND( this, SdResId( CB_LOOP_SOUND ) ),
461 maFL_ADVANCE_SLIDE( this, SdResId( FL_ADVANCE_SLIDE ) ),
462 maRB_ADVANCE_ON_MOUSE( this, SdResId( RB_ADVANCE_ON_MOUSE ) ),
463 maRB_ADVANCE_AUTO( this, SdResId( RB_ADVANCE_AUTO ) ),
464 maMF_ADVANCE_AUTO_AFTER( this, SdResId( MF_ADVANCE_AUTO_AFTER ) ),
465 maFL_EMPTY1( this, SdResId( FL_EMPTY1 ) ),
466 maPB_APPLY_TO_ALL( this, SdResId( PB_APPLY_TO_ALL ) ),
467 maPB_PLAY( this, SdResId( PB_PLAY ) ),
468 maPB_SLIDE_SHOW( this, SdResId( PB_SLIDE_SHOW ) ),
469 maFL_EMPTY2( this, SdResId( FL_EMPTY2 ) ),
470 maCB_AUTO_PREVIEW( this, SdResId( CB_AUTO_PREVIEW ) ),
472 maSTR_NO_TRANSITION( SdResId( STR_NO_TRANSITION ) ),
473 mbHasSelection( false ),
474 mbUpdatingControls( false ),
475 mbIsMainViewChangePending( false ),
476 maLateInitTimer()
478 // use no resource ids from here on
479 FreeResource();
481 // use bold font for group headings (same font for all fixed lines):
482 Font font( maFL_APPLY_TRANSITION.GetFont() );
483 font.SetWeight( WEIGHT_BOLD );
484 maFL_APPLY_TRANSITION.SetFont( font );
485 maFL_MODIFY_TRANSITION.SetFont( font );
486 maFL_ADVANCE_SLIDE.SetFont( font );
488 if( pDoc )
489 mxModel.set( pDoc->getUnoModel(), uno::UNO_QUERY );
490 // TODO: get correct view
491 if( mxModel.is())
492 mxView.set( mxModel->getCurrentController(), uno::UNO_QUERY );
494 // fill list box of slide transitions
495 maLB_SLIDE_TRANSITIONS.InsertEntry( maSTR_NO_TRANSITION );
497 // set defaults
498 maCB_AUTO_PREVIEW.Check(); // automatic preview on
500 // update control states before adding handlers
501 updateLayout();
502 // updateSoundList();
503 updateControls();
505 // set handlers
506 maPB_APPLY_TO_ALL.SetClickHdl( LINK( this, SlideTransitionPane, ApplyToAllButtonClicked ));
507 maPB_PLAY.SetClickHdl( LINK( this, SlideTransitionPane, PlayButtonClicked ));
508 maPB_SLIDE_SHOW.SetClickHdl( LINK( this, SlideTransitionPane, SlideShowButtonClicked ));
510 maLB_SLIDE_TRANSITIONS.SetSelectHdl( LINK( this, SlideTransitionPane, TransitionSelected ));
512 maLB_SPEED.SetSelectHdl( LINK( this, SlideTransitionPane, SpeedListBoxSelected ));
513 maLB_SOUND.SetSelectHdl( LINK( this, SlideTransitionPane, SoundListBoxSelected ));
514 maCB_LOOP_SOUND.SetClickHdl( LINK( this, SlideTransitionPane, LoopSoundBoxChecked ));
516 maRB_ADVANCE_ON_MOUSE.SetToggleHdl( LINK( this, SlideTransitionPane, AdvanceSlideRadioButtonToggled ));
517 maRB_ADVANCE_AUTO.SetToggleHdl( LINK( this, SlideTransitionPane, AdvanceSlideRadioButtonToggled ));
518 maMF_ADVANCE_AUTO_AFTER.SetModifyHdl( LINK( this, SlideTransitionPane, AdvanceTimeModified ));
519 maCB_AUTO_PREVIEW.SetClickHdl( LINK( this, SlideTransitionPane, AutoPreviewClicked ));
520 addListener();
522 maLateInitTimer.SetTimeout(200);
523 maLateInitTimer.SetTimeoutHdl(LINK(this, SlideTransitionPane, LateInitCallback));
524 maLateInitTimer.Start();
527 SlideTransitionPane::~SlideTransitionPane()
529 maLateInitTimer.Stop();
530 removeListener();
533 void SlideTransitionPane::Resize()
535 updateLayout();
538 void SlideTransitionPane::onSelectionChanged()
540 updateControls();
543 void SlideTransitionPane::onChangeCurrentPage()
545 updateControls();
548 ::sd::slidesorter::SharedPageSelection SlideTransitionPane::getSelectedPages (void) const
550 ::sd::slidesorter::SlideSorterViewShell * pSlideSorterViewShell
551 = ::sd::slidesorter::SlideSorterViewShell::GetSlideSorter(mrBase);
552 // DBG_ASSERT( pSlideSorterViewShell, "No Slide-Sorter available" );
553 ::boost::shared_ptr<sd::slidesorter::SlideSorterViewShell::PageSelection> pSelection;
555 if( pSlideSorterViewShell )
557 pSelection = pSlideSorterViewShell->GetPageSelection();
559 else
561 pSelection.reset(new sd::slidesorter::SlideSorterViewShell::PageSelection());
562 if( mxView.is() )
564 SdPage* pPage = SdPage::getImplementation( mxView->getCurrentPage() );
565 if( pPage )
566 pSelection->push_back(pPage);
570 return pSelection;
573 void SlideTransitionPane::updateLayout()
575 ::Size aPaneSize( GetSizePixel() );
576 if( aPaneSize.Width() < maMinSize.Width() )
577 aPaneSize.Width() = maMinSize.Width();
579 if( aPaneSize.Height() < maMinSize.Height() )
580 aPaneSize.Height() = maMinSize.Height();
582 // start layouting elements from bottom to top. The remaining space is used
583 // for the topmost list box
584 ::Point aOffset( LogicToPixel( Point( 3, 3 ), MAP_APPFONT ) );
585 long nOffsetX = aOffset.getX();
586 long nOffsetY = aOffset.getY();
587 long nOffsetBtnX = LogicToPixel( Point( 6, 1 ), MAP_APPFONT ).getX();
589 const long nMinCtrlWidth = LogicToPixel( ::Point( 32, 1 ), MAP_APPFONT ).getX();
590 const long nTextIndent = LogicToPixel( ::Point( RSC_SP_CHK_TEXTINDENT, 1 ), MAP_APPFONT ).getX();
592 ::Point aUpperLeft( nOffsetX, aPaneSize.getHeight() - nOffsetY );
593 long nMaxWidth = aPaneSize.getWidth() - 2 * nOffsetX;
595 // auto preview check-box
596 ::Size aCtrlSize = maCB_AUTO_PREVIEW.GetSizePixel();
597 aCtrlSize.setWidth( maCB_AUTO_PREVIEW.CalcMinimumSize( nMaxWidth ).getWidth());
598 aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight());
599 maCB_AUTO_PREVIEW.SetPosSizePixel( aUpperLeft, aCtrlSize );
601 // fixed line above check-box
602 aCtrlSize = maFL_EMPTY2.GetSizePixel();
603 aCtrlSize.setWidth( nMaxWidth );
604 aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight());
605 maFL_EMPTY2.SetPosSizePixel( aUpperLeft, aCtrlSize );
607 // buttons "Play" and "Slide Show"
608 long nPlayButtonWidth = maPB_PLAY.CalcMinimumSize().getWidth() + 2 * nOffsetBtnX;
609 long nSlideShowButtonWidth = maPB_SLIDE_SHOW.CalcMinimumSize().getWidth() + 2 * nOffsetBtnX;
611 if( (nPlayButtonWidth + nSlideShowButtonWidth + nOffsetX) <= nMaxWidth )
613 // place buttons side by side
614 aCtrlSize = maPB_PLAY.GetSizePixel();
615 aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight());
616 aCtrlSize.setWidth( nPlayButtonWidth );
617 maPB_PLAY.SetPosSizePixel( aUpperLeft, aCtrlSize );
619 aUpperLeft.setX( aUpperLeft.getX() + nPlayButtonWidth + nOffsetX );
620 aCtrlSize.setWidth( nSlideShowButtonWidth );
621 maPB_SLIDE_SHOW.SetPosSizePixel( aUpperLeft, aCtrlSize );
622 aUpperLeft.setX( nOffsetX );
624 else
626 // place buttons on top of each other
627 aCtrlSize = maPB_SLIDE_SHOW.GetSizePixel();
628 aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight());
629 aCtrlSize.setWidth( nSlideShowButtonWidth );
630 maPB_SLIDE_SHOW.SetPosSizePixel( aUpperLeft, aCtrlSize );
632 aCtrlSize = maPB_PLAY.GetSizePixel();
633 aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight() - nOffsetY );
634 aCtrlSize.setWidth( nPlayButtonWidth );
635 maPB_PLAY.SetPosSizePixel( aUpperLeft, aCtrlSize );
638 // "Apply to All Slides" button
639 aCtrlSize = maPB_APPLY_TO_ALL.GetSizePixel();
640 aCtrlSize.setWidth( maPB_APPLY_TO_ALL.CalcMinimumSize( nMaxWidth ).getWidth() + 2 * nOffsetBtnX );
641 aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight() - nOffsetY );
642 maPB_APPLY_TO_ALL.SetPosSizePixel( aUpperLeft, aCtrlSize );
644 // fixed line above "Apply to All Slides" button
645 aCtrlSize = maFL_EMPTY1.GetSizePixel();
646 aCtrlSize.setWidth( nMaxWidth );
647 aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight());
648 maFL_EMPTY1.SetPosSizePixel( aUpperLeft, aCtrlSize );
650 // advance automatically after ... seconds
651 long nItemWidth = maRB_ADVANCE_AUTO.CalcMinimumSize().getWidth();
653 if( (nItemWidth + nMinCtrlWidth + nOffsetX) <= nMaxWidth )
655 long nBase = aUpperLeft.getY();
657 // place controls side by side
658 aCtrlSize = maRB_ADVANCE_AUTO.GetSizePixel();
659 aUpperLeft.setY( nBase - aCtrlSize.getHeight());
660 aCtrlSize.setWidth( nItemWidth );
661 maRB_ADVANCE_AUTO.SetPosSizePixel( aUpperLeft, aCtrlSize );
663 aCtrlSize = maMF_ADVANCE_AUTO_AFTER.GetSizePixel();
664 aUpperLeft.setY( nBase - aCtrlSize.getHeight() );
665 aUpperLeft.setX( aUpperLeft.getX() + nItemWidth + nOffsetX );
666 aCtrlSize.setWidth( nMinCtrlWidth );
667 maMF_ADVANCE_AUTO_AFTER.SetPosSizePixel( aUpperLeft, aCtrlSize );
668 aUpperLeft.setX( nOffsetX );
670 else
672 // place controls on top of each other
673 aCtrlSize = maMF_ADVANCE_AUTO_AFTER.GetSizePixel();
674 aUpperLeft.setX( nOffsetX + nTextIndent );
675 aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight());
676 aCtrlSize.setWidth( nMinCtrlWidth );
677 maMF_ADVANCE_AUTO_AFTER.SetPosSizePixel( aUpperLeft, aCtrlSize );
679 aCtrlSize = maRB_ADVANCE_AUTO.GetSizePixel();
680 aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight() - nOffsetY );
681 aUpperLeft.setX( nOffsetX );
682 aCtrlSize.setWidth( nItemWidth );
683 maRB_ADVANCE_AUTO.SetPosSizePixel( aUpperLeft, aCtrlSize );
684 aUpperLeft.setX( nOffsetX );
687 // check box "On mouse click"
688 aCtrlSize = maRB_ADVANCE_ON_MOUSE.GetSizePixel();
689 aCtrlSize.setWidth( nMaxWidth );
690 aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight() - nOffsetY );
691 maRB_ADVANCE_ON_MOUSE.SetPosSizePixel( aUpperLeft, aCtrlSize );
693 // fixed line "Advance slide"
694 aCtrlSize = maFL_ADVANCE_SLIDE.GetSizePixel();
695 aCtrlSize.setWidth( nMaxWidth );
696 aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight() - nOffsetY );
697 maFL_ADVANCE_SLIDE.SetPosSizePixel( aUpperLeft, aCtrlSize );
699 // check box "Loop until next sound"
700 long nFTSpeedWidth = maFT_SPEED.CalcMinimumSize().getWidth() + 2 * nOffsetX;
701 long nFTSoundWidth = maFT_SOUND.CalcMinimumSize().getWidth() + 2 * nOffsetX;
702 long nIndent = ::std::max( nFTSoundWidth, nFTSpeedWidth );
704 bool bStack = ( (nIndent + nMinCtrlWidth + nOffsetX) > nMaxWidth );
706 if( bStack )
707 nIndent = nTextIndent;
709 aCtrlSize = maCB_LOOP_SOUND.GetSizePixel();
710 aCtrlSize.setWidth( nMaxWidth - nIndent );
711 aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight() - nOffsetY );
712 aUpperLeft.setX( nIndent );
713 maCB_LOOP_SOUND.SetPosSizePixel( aUpperLeft, aCtrlSize );
715 aCtrlSize = maLB_SOUND.GetSizePixel();
716 aCtrlSize.setWidth( ::std::max( nMaxWidth - nIndent, nMinCtrlWidth ) );
717 aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight() - nOffsetY );
718 maLB_SOUND.SetPosSizePixel( aUpperLeft, aCtrlSize );
719 maLB_SOUND.SetDropDownLineCount( 8 );
720 aUpperLeft.setX( nOffsetX );
722 aCtrlSize = maFT_SOUND.GetSizePixel();
723 if( bStack )
724 aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight());
725 aCtrlSize.setWidth( nFTSoundWidth );
726 maFT_SOUND.SetPosSizePixel( aUpperLeft, aCtrlSize );
728 aUpperLeft.setX( nIndent );
729 aCtrlSize = maLB_SPEED.GetSizePixel();
730 aCtrlSize.setWidth( ::std::max( nMaxWidth - nIndent, nMinCtrlWidth ) );
731 aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight() - nOffsetY );
732 maLB_SPEED.SetPosSizePixel( aUpperLeft, aCtrlSize );
733 maLB_SPEED.SetDropDownLineCount( 3 );
734 aUpperLeft.setX( nOffsetX );
736 aCtrlSize = maFT_SPEED.GetSizePixel();
737 if( bStack )
738 aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight());
739 aCtrlSize.setWidth( nFTSpeedWidth );
740 maFT_SPEED.SetPosSizePixel( aUpperLeft, aCtrlSize );
742 // fixed line "Modify Transition"
743 aCtrlSize = maFL_MODIFY_TRANSITION.GetSizePixel();
744 aCtrlSize.setWidth( nMaxWidth );
745 aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight() - nOffsetY );
746 maFL_MODIFY_TRANSITION.SetPosSizePixel( aUpperLeft, aCtrlSize );
748 // fixed line "Apply to selected slides"
749 aCtrlSize = maFL_APPLY_TRANSITION.GetSizePixel();
750 aCtrlSize.setWidth( nMaxWidth );
751 ::Point aUpperLeftCorner( nOffsetX, nOffsetY );
752 maFL_APPLY_TRANSITION.SetPosSizePixel( aUpperLeftCorner, aCtrlSize );
753 aUpperLeftCorner.setY( aUpperLeftCorner.getY() + aCtrlSize.getHeight() + nOffsetY );
754 aUpperLeft.setY( aUpperLeft.getY() - nOffsetY );
756 // list box slide transitions
757 aCtrlSize.setWidth( nMaxWidth );
758 aCtrlSize.setHeight( aUpperLeft.getY() - aUpperLeftCorner.getY() );
759 maLB_SLIDE_TRANSITIONS.SetPosSizePixel( aUpperLeftCorner, aCtrlSize );
762 void SlideTransitionPane::updateControls()
764 ::sd::slidesorter::SharedPageSelection pSelectedPages(getSelectedPages());
765 if( pSelectedPages->empty())
767 mbHasSelection = false;
768 return;
770 mbHasSelection = true;
772 DBG_ASSERT( ! mbUpdatingControls, "Multiple Control Updates" );
773 mbUpdatingControls = true;
775 // get model data for first page
776 SdPage * pFirstPage = pSelectedPages->front();
777 DBG_ASSERT( pFirstPage, "Invalid Page" );
779 impl::TransitionEffect aEffect( *pFirstPage );
781 // merge with other pages
782 ::sd::slidesorter::SlideSorterViewShell::PageSelection::const_iterator aIt(
783 pSelectedPages->begin());
784 ::sd::slidesorter::SlideSorterViewShell::PageSelection::const_iterator aEndIt(
785 pSelectedPages->end());
787 // start with second page (note aIt != aEndIt, because ! aSelectedPages.empty())
788 for( ++aIt ;aIt != aEndIt; ++aIt )
790 if( *aIt )
791 aEffect.compareWith( *(*aIt) );
794 // detect current slide effect
795 if( aEffect.mbEffectAmbiguous )
796 maLB_SLIDE_TRANSITIONS.SetNoSelection();
797 else
799 // ToDo: That 0 is "no transition" is documented nowhere except in the
800 // CTOR of sdpage
801 if( aEffect.mnType == 0 )
802 maLB_SLIDE_TRANSITIONS.SelectEntryPos( 0 );
803 else
805 sal_uInt16 nEntry = lcl_getTransitionEffectIndex( mpDrawDoc, aEffect );
806 if( nEntry == LISTBOX_ENTRY_NOTFOUND )
807 maLB_SLIDE_TRANSITIONS.SetNoSelection();
808 else
810 // first entry in list is "none", so add 1 after translation
811 if( m_aPresetIndexes.find( nEntry ) != m_aPresetIndexes.end())
812 maLB_SLIDE_TRANSITIONS.SelectEntryPos( m_aPresetIndexes[ nEntry ] + 1 );
813 else
814 maLB_SLIDE_TRANSITIONS.SetNoSelection();
819 if( aEffect.mbDurationAmbiguous )
820 maLB_SPEED.SetNoSelection();
821 else
822 maLB_SPEED.SelectEntryPos(
823 (aEffect.mfDuration > 2.0 )
824 ? 0 : (aEffect.mfDuration < 2.0)
825 ? 2 : 1 ); // else FADE_SPEED_FAST
827 if( aEffect.mbSoundAmbiguous )
829 maLB_SOUND.SetNoSelection();
830 maCurrentSoundFile.Erase();
832 else
834 maCurrentSoundFile.Erase();
835 if( aEffect.mbStopSound )
837 maLB_SOUND.SelectEntryPos( 1 );
839 else if( aEffect.mbSoundOn && aEffect.maSound.Len() > 0 )
841 tSoundListType::size_type nPos = 0;
842 if( lcl_findSoundInList( maSoundList, aEffect.maSound, nPos ))
844 // skip first three entries
845 maLB_SOUND.SelectEntryPos( (USHORT)nPos + 3 );
846 maCurrentSoundFile = aEffect.maSound;
849 else
851 maLB_SOUND.SelectEntryPos( 0 );
855 if( aEffect.mbLoopSoundAmbiguous )
857 maCB_LOOP_SOUND.SetState( STATE_DONTKNOW );
859 else
861 maCB_LOOP_SOUND.Check( aEffect.mbLoopSound );
864 if( aEffect.mbPresChangeAmbiguous )
866 maRB_ADVANCE_ON_MOUSE.Check( FALSE );
867 maRB_ADVANCE_AUTO.Check( FALSE );
869 else
871 maRB_ADVANCE_ON_MOUSE.Check( aEffect.mePresChange == PRESCHANGE_MANUAL );
872 maRB_ADVANCE_AUTO.Check( aEffect.mePresChange == PRESCHANGE_AUTO );
873 maMF_ADVANCE_AUTO_AFTER.SetValue( aEffect.mnTime );
876 SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
877 maCB_AUTO_PREVIEW.Check( pOptions->IsPreviewTransitions() == sal_True );
879 mbUpdatingControls = false;
881 updateControlState();
884 void SlideTransitionPane::updateControlState()
886 maLB_SLIDE_TRANSITIONS.Enable( mbHasSelection );
887 maLB_SPEED.Enable( mbHasSelection );
888 maLB_SOUND.Enable( mbHasSelection );
889 maCB_LOOP_SOUND.Enable( mbHasSelection && (maLB_SOUND.GetSelectEntryPos() > 2));
890 maRB_ADVANCE_ON_MOUSE.Enable( mbHasSelection );
891 maRB_ADVANCE_AUTO.Enable( mbHasSelection );
892 maMF_ADVANCE_AUTO_AFTER.Enable( mbHasSelection && maRB_ADVANCE_AUTO.IsChecked());
894 maPB_APPLY_TO_ALL.Enable( mbHasSelection );
895 maPB_PLAY.Enable( mbHasSelection );
896 // maPB_SLIDE_SHOW.Enable( TRUE );
897 maCB_AUTO_PREVIEW.Enable( mbHasSelection );
900 void SlideTransitionPane::updateSoundList()
902 List aSoundList;
904 GalleryExplorer::FillObjList( GALLERY_THEME_SOUNDS, aSoundList );
905 GalleryExplorer::FillObjList( GALLERY_THEME_USERSOUNDS, aSoundList );
907 sal_uInt32 nCount = aSoundList.Count();
908 maSoundList.clear();
909 maSoundList.reserve( nCount );
910 for( sal_uInt32 i=0; i<nCount; ++i )
912 String * pEntry = reinterpret_cast< String * >( aSoundList.GetObject( i ));
913 if( pEntry )
915 // store copy of string in member list
916 maSoundList.push_back( *pEntry );
917 // delete pointer in temporary List
918 delete pEntry;
922 lcl_FillSoundListBox( maSoundList, maLB_SOUND );
925 void SlideTransitionPane::openSoundFileDialog()
927 if( ! maLB_SOUND.IsEnabled())
928 return;
930 SdOpenSoundFileDialog aFileDialog;
932 String aFile;
933 DBG_ASSERT( maLB_SOUND.GetSelectEntryPos() == 2,
934 "Dialog should only open when \"Other sound\" is selected" );
935 aFile = SvtPathOptions().GetGraphicPath();
937 aFileDialog.SetPath( aFile );
939 bool bValidSoundFile( false );
940 bool bQuitLoop( false );
942 while( ! bQuitLoop &&
943 aFileDialog.Execute() == ERRCODE_NONE )
945 aFile = aFileDialog.GetPath();
946 tSoundListType::size_type nPos = 0;
947 bValidSoundFile = lcl_findSoundInList( maSoundList, aFile, nPos );
949 if( bValidSoundFile )
951 bQuitLoop = true;
953 else // not in sound list
955 // try to insert into gallery
956 if( GalleryExplorer::InsertURL( GALLERY_THEME_USERSOUNDS, aFile, SGA_FORMAT_SOUND ) )
958 updateSoundList();
959 bValidSoundFile = lcl_findSoundInList( maSoundList, aFile, nPos );
960 DBG_ASSERT( bValidSoundFile, "Adding sound to gallery failed" );
962 bQuitLoop = true;
964 else
966 String aStrWarning(SdResId(STR_WARNING_NOSOUNDFILE));
967 String aStr( sal_Unicode( '%' ));
968 aStrWarning.SearchAndReplace( aStr , aFile );
969 WarningBox aWarningBox( NULL, WB_3DLOOK | WB_RETRY_CANCEL, aStrWarning );
970 aWarningBox.SetModalInputMode (TRUE);
971 bQuitLoop = (aWarningBox.Execute() != RET_RETRY);
973 bValidSoundFile = false;
977 if( bValidSoundFile )
978 // skip first three entries in list
979 maLB_SOUND.SelectEntryPos( (USHORT)nPos + 3 );
982 if( ! bValidSoundFile )
984 if( maCurrentSoundFile.Len() > 0 )
986 tSoundListType::size_type nPos = 0;
987 if( lcl_findSoundInList( maSoundList, maCurrentSoundFile, nPos ))
988 maLB_SOUND.SelectEntryPos( (USHORT)nPos + 3 );
989 else
990 maLB_SOUND.SelectEntryPos( 0 ); // NONE
992 else
993 maLB_SOUND.SelectEntryPos( 0 ); // NONE
997 impl::TransitionEffect SlideTransitionPane::getTransitionEffectFromControls() const
999 impl::TransitionEffect aResult;
1000 aResult.setAllAmbiguous();
1002 // check first (aResult might be overwritten)
1003 if( maLB_SLIDE_TRANSITIONS.IsEnabled() &&
1004 maLB_SLIDE_TRANSITIONS.GetSelectEntryCount() > 0 )
1006 TransitionPresetPtr pPreset = lcl_getTransitionPresetByUIName(
1007 mpDrawDoc, OUString( maLB_SLIDE_TRANSITIONS.GetSelectEntry()));
1009 if( pPreset.get())
1011 aResult = impl::TransitionEffect( *pPreset );
1012 aResult.setAllAmbiguous();
1014 else
1016 aResult.mnType = 0;
1018 aResult.mbEffectAmbiguous = false;
1021 // speed
1022 if( maLB_SPEED.IsEnabled() &&
1023 maLB_SPEED.GetSelectEntryCount() > 0 )
1025 sal_uInt16 nPos = maLB_SPEED.GetSelectEntryPos();
1026 aResult.mfDuration = (nPos == 0)
1027 ? 3.0
1028 : (nPos == 1)
1029 ? 2.0
1030 : 1.0; // nPos == 2
1031 DBG_ASSERT( aResult.mfDuration != 1.0 || nPos == 2, "Invalid Listbox Entry" );
1033 aResult.mbDurationAmbiguous = false;
1036 // slide-advance mode
1037 if( maRB_ADVANCE_ON_MOUSE.IsEnabled() && maRB_ADVANCE_AUTO.IsEnabled() &&
1038 (maRB_ADVANCE_ON_MOUSE.IsChecked() || maRB_ADVANCE_AUTO.IsChecked()))
1040 if( maRB_ADVANCE_ON_MOUSE.IsChecked())
1041 aResult.mePresChange = PRESCHANGE_MANUAL;
1042 else
1044 aResult.mePresChange = PRESCHANGE_AUTO;
1045 if( maMF_ADVANCE_AUTO_AFTER.IsEnabled())
1047 // sal_uInt16 nDigits = maMF_ADVANCE_AUTO_AFTER.GetDecimalDigits();
1048 aResult.mnTime = static_cast<long>(maMF_ADVANCE_AUTO_AFTER.GetValue());
1049 // / static_cast< sal_uInt16 >( pow( 10.0, static_cast< double >( nDigits )));
1050 aResult.mbTimeAmbiguous = false;
1054 aResult.mbPresChangeAmbiguous = false;
1057 // sound
1058 if( maLB_SOUND.IsEnabled())
1060 maCurrentSoundFile.Erase();
1061 if( maLB_SOUND.GetSelectEntryCount() > 0 )
1063 sal_uInt16 nPos = maLB_SOUND.GetSelectEntryPos();
1064 aResult.mbStopSound = nPos == 1;
1065 aResult.mbSoundOn = nPos > 1;
1066 if( aResult.mbStopSound )
1068 aResult.maSound = OUString();
1069 aResult.mbSoundAmbiguous = false;
1071 else
1073 aResult.maSound = lcl_getSoundFileURL( maSoundList, maLB_SOUND );
1074 aResult.mbSoundAmbiguous = false;
1075 maCurrentSoundFile = aResult.maSound;
1080 // sound loop
1081 if( maCB_LOOP_SOUND.IsEnabled() )
1083 aResult.mbLoopSound = maCB_LOOP_SOUND.IsChecked();
1084 aResult.mbLoopSoundAmbiguous = false;
1087 return aResult;
1090 void SlideTransitionPane::applyToSelectedPages()
1092 if( ! mbUpdatingControls )
1094 ::sd::slidesorter::SharedPageSelection pSelectedPages( getSelectedPages());
1095 if( ! pSelectedPages->empty())
1097 lcl_CreateUndoForPages( pSelectedPages, mrBase );
1098 lcl_ApplyToPages( pSelectedPages, getTransitionEffectFromControls() );
1099 mrBase.GetDocShell()->SetModified();
1101 if( maCB_AUTO_PREVIEW.IsEnabled() &&
1102 maCB_AUTO_PREVIEW.IsChecked())
1104 playCurrentEffect();
1109 void SlideTransitionPane::playCurrentEffect()
1111 if( mxView.is() )
1114 Reference< ::com::sun::star::animations::XAnimationNode > xNode;
1115 SlideShow::StartPreview( mrBase, mxView->getCurrentPage(), xNode );
1119 void SlideTransitionPane::addListener()
1121 Link aLink( LINK(this,SlideTransitionPane,EventMultiplexerListener) );
1122 mrBase.GetEventMultiplexer()->AddEventListener (
1123 aLink,
1124 tools::EventMultiplexerEvent::EID_EDIT_VIEW_SELECTION
1125 | tools::EventMultiplexerEvent::EID_SLIDE_SORTER_SELECTION
1126 | tools::EventMultiplexerEvent::EID_CURRENT_PAGE
1127 | tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED
1128 | tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED
1129 | tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED);
1132 void SlideTransitionPane::removeListener()
1134 Link aLink( LINK(this,SlideTransitionPane,EventMultiplexerListener) );
1135 mrBase.GetEventMultiplexer()->RemoveEventListener( aLink );
1138 IMPL_LINK(SlideTransitionPane,EventMultiplexerListener,
1139 tools::EventMultiplexerEvent*,pEvent)
1141 switch (pEvent->meEventId)
1143 case tools::EventMultiplexerEvent::EID_EDIT_VIEW_SELECTION:
1144 onSelectionChanged();
1145 break;
1147 case tools::EventMultiplexerEvent::EID_CURRENT_PAGE:
1148 case tools::EventMultiplexerEvent::EID_SLIDE_SORTER_SELECTION:
1149 onChangeCurrentPage();
1150 break;
1152 case tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED:
1153 mxView = Reference<drawing::XDrawView>();
1154 onSelectionChanged();
1155 onChangeCurrentPage();
1156 break;
1158 case tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED:
1159 mbIsMainViewChangePending = true;
1160 break;
1162 case tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED:
1163 if (mbIsMainViewChangePending)
1165 mbIsMainViewChangePending = false;
1167 // At this moment the controller may not yet been set at
1168 // model or ViewShellBase. Take it from the view shell
1169 // passed with the event.
1170 if (mrBase.GetMainViewShell() != NULL)
1172 mxView = Reference<drawing::XDrawView>::query(mrBase.GetController());
1173 onSelectionChanged();
1174 onChangeCurrentPage();
1177 break;
1179 default:
1180 break;
1182 return 0;
1185 IMPL_LINK( SlideTransitionPane, ApplyToAllButtonClicked, void *, EMPTYARG )
1187 DBG_ASSERT( mpDrawDoc, "Invalid Draw Document!" );
1188 if( !mpDrawDoc )
1189 return 0;
1191 ::sd::slidesorter::SharedPageSelection pPages (
1192 new ::sd::slidesorter::SlideSorterViewShell::PageSelection());
1194 sal_uInt16 nPageCount = mpDrawDoc->GetSdPageCount( PK_STANDARD );
1195 pPages->reserve( nPageCount );
1196 for( sal_uInt16 i=0; i<nPageCount; ++i )
1198 SdPage * pPage = mpDrawDoc->GetSdPage( i, PK_STANDARD );
1199 if( pPage )
1200 pPages->push_back( pPage );
1203 if( ! pPages->empty())
1205 lcl_CreateUndoForPages( pPages, mrBase );
1206 lcl_ApplyToPages( pPages, getTransitionEffectFromControls() );
1209 return 0;
1213 IMPL_LINK( SlideTransitionPane, PlayButtonClicked, void *, EMPTYARG )
1215 playCurrentEffect();
1216 return 0;
1219 IMPL_LINK( SlideTransitionPane, SlideShowButtonClicked, void *, EMPTYARG )
1221 mrBase.StartPresentation();
1222 return 0;
1225 IMPL_LINK( SlideTransitionPane, TransitionSelected, void *, EMPTYARG )
1227 applyToSelectedPages();
1228 return 0;
1231 IMPL_LINK( SlideTransitionPane, AdvanceSlideRadioButtonToggled, void *, EMPTYARG )
1233 updateControlState();
1234 applyToSelectedPages();
1235 return 0;
1238 IMPL_LINK( SlideTransitionPane, AdvanceTimeModified, void *, EMPTYARG )
1240 applyToSelectedPages();
1241 return 0;
1244 IMPL_LINK( SlideTransitionPane, SpeedListBoxSelected, void *, EMPTYARG )
1246 applyToSelectedPages();
1247 return 0;
1250 IMPL_LINK( SlideTransitionPane, SoundListBoxSelected, void *, EMPTYARG )
1252 if( maLB_SOUND.GetSelectEntryCount() )
1254 sal_uInt16 nPos = maLB_SOUND.GetSelectEntryPos();
1255 if( nPos == 2 )
1257 // other sound ...
1258 openSoundFileDialog();
1261 updateControlState();
1262 applyToSelectedPages();
1263 return 0;
1266 IMPL_LINK( SlideTransitionPane, LoopSoundBoxChecked, void *, EMPTYARG )
1268 applyToSelectedPages();
1269 return 0;
1272 IMPL_LINK( SlideTransitionPane, AutoPreviewClicked, void *, EMPTYARG )
1274 SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
1275 pOptions->SetPreviewTransitions( maCB_AUTO_PREVIEW.IsChecked() ? sal_True : sal_False );
1276 return 0;
1279 IMPL_LINK( SlideTransitionPane, LateInitCallback, Timer*, EMPTYARG )
1281 const TransitionPresetList& rPresetList = TransitionPreset::getTransitionPresetList();
1282 TransitionPresetList::const_iterator aIter( rPresetList.begin() );
1283 const TransitionPresetList::const_iterator aEnd( rPresetList.end() );
1284 sal_uInt16 nIndex = 0;
1285 ::std::size_t nUIIndex = 0;
1286 while( aIter != aEnd )
1288 TransitionPresetPtr pPreset = (*aIter++);
1289 const OUString aUIName( pPreset->getUIName() );
1290 if( aUIName.getLength() )
1292 maLB_SLIDE_TRANSITIONS.InsertEntry( aUIName );
1293 m_aPresetIndexes[ nIndex ] = (sal_uInt16)nUIIndex;
1294 ++nUIIndex;
1296 ++nIndex;
1299 updateSoundList();
1300 updateControls();
1302 return 0;
1305 ::Window * createSlideTransitionPanel( ::Window* pParent, ViewShellBase& rBase )
1307 DialogListBox* pWindow = 0;
1309 DrawDocShell* pDocSh = rBase.GetDocShell();
1310 if( pDocSh )
1312 pWindow = new DialogListBox( pParent, WB_CLIPCHILDREN|WB_TABSTOP|WB_AUTOHSCROLL );
1314 Size aMinSize( pWindow->LogicToPixel( Size( 72, 216 ), MAP_APPFONT ) );
1315 ::Window* pPaneWindow = new SlideTransitionPane( pWindow, rBase, aMinSize, pDocSh->GetDoc() );
1316 pWindow->SetChildWindow( pPaneWindow, aMinSize );
1317 pWindow->SetText( pPaneWindow->GetText() );
1320 return pWindow;
1324 } // namespace sd