LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/animations - SlideTransitionPane.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 648 0.2 %
Date: 2013-07-09 Functions: 2 70 2.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <com/sun/star/animations/XAnimationNode.hpp>
      21             : 
      22             : #include "SlideTransitionPane.hxx"
      23             : #include "SlideTransitionPane.hrc"
      24             : #include "CustomAnimation.hrc"
      25             : 
      26             : #include "TransitionPreset.hxx"
      27             : #include "sdresid.hxx"
      28             : #include "ViewShellBase.hxx"
      29             : #include "DrawDocShell.hxx"
      30             : #include "SlideSorterViewShell.hxx"
      31             : #include "drawdoc.hxx"
      32             : #include "filedlg.hxx"
      33             : #include "strings.hrc"
      34             : #include "DrawController.hxx"
      35             : #include <com/sun/star/beans/XPropertySet.hpp>
      36             : 
      37             : #include <svtools/controldims.hrc>
      38             : #include <svx/gallery.hxx>
      39             : #include <unotools/pathoptions.hxx>
      40             : #include <vcl/msgbox.hxx>
      41             : #include <tools/urlobj.hxx>
      42             : #include "DrawViewShell.hxx"
      43             : #include "slideshow.hxx"
      44             : #include "drawview.hxx"
      45             : #include "sdundogr.hxx"
      46             : #include "undoanim.hxx"
      47             : #include "optsitem.hxx"
      48             : #include "sddll.hxx"
      49             : #include "framework/FrameworkHelper.hxx"
      50             : 
      51             : #include "DialogListBox.hxx"
      52             : #include <sfx2/sidebar/Theme.hxx>
      53             : 
      54             : #include <algorithm>
      55             : #include <memory>
      56             : 
      57             : 
      58             : using namespace ::com::sun::star;
      59             : 
      60             : using ::com::sun::star::uno::Reference;
      61             : using ::com::sun::star::uno::Sequence;
      62             : using ::com::sun::star::uno::RuntimeException;
      63             : 
      64             : using ::sd::framework::FrameworkHelper;
      65             : 
      66             : // ____________________________
      67             : //
      68             : // ::sd::impl::TransitionEffect
      69             : // ____________________________
      70             : 
      71             : namespace sd
      72             : {
      73             : namespace impl
      74             : {
      75           0 : struct TransitionEffect
      76             : {
      77           0 :     TransitionEffect() :
      78             :             mnType( 0 ),
      79             :             mnSubType( 0 ),
      80             :             mbDirection( sal_True ),
      81           0 :             mnFadeColor( 0 )
      82             :     {
      83           0 :         init();
      84           0 :     }
      85           0 :     explicit TransitionEffect( const ::sd::TransitionPreset & rPreset ) :
      86           0 :             mnType( rPreset.getTransition()),
      87           0 :             mnSubType( rPreset.getSubtype()),
      88           0 :             mbDirection( rPreset.getDirection()),
      89           0 :             mnFadeColor( rPreset.getFadeColor())
      90             :     {
      91           0 :         init();
      92           0 :     }
      93             :     explicit TransitionEffect( sal_Int16 nType, sal_Int16 nSubType,
      94             :                                sal_Bool  bDirection, sal_Int32 nFadeColor ) :
      95             :             mnType( nType),
      96             :             mnSubType( nSubType ),
      97             :             mbDirection( bDirection ),
      98             :             mnFadeColor( nFadeColor )
      99             :     {
     100             :         init();
     101             :     }
     102           0 :     explicit TransitionEffect( const SdPage & rPage ) :
     103           0 :             mnType( rPage.getTransitionType() ),
     104           0 :             mnSubType( rPage.getTransitionSubtype() ),
     105           0 :             mbDirection( rPage.getTransitionDirection() ),
     106           0 :             mnFadeColor( rPage.getTransitionFadeColor() )
     107             :     {
     108           0 :         init();
     109             : 
     110           0 :         mfDuration = rPage.getTransitionDuration();
     111           0 :         mfTime = rPage.GetTime();
     112           0 :         mePresChange = rPage.GetPresChange();
     113           0 :         mbSoundOn = rPage.IsSoundOn();
     114           0 :         maSound = rPage.GetSoundFile();
     115           0 :         mbLoopSound = rPage.IsLoopSound();
     116           0 :         mbStopSound = rPage.IsStopSound();
     117           0 :     }
     118             : 
     119           0 :     void init()
     120             :     {
     121           0 :         mfDuration = 2.0;
     122           0 :         mfTime = 0.0;
     123           0 :         mePresChange = PRESCHANGE_MANUAL;
     124           0 :         mbSoundOn = sal_False;
     125           0 :         mbLoopSound = sal_False;
     126           0 :         mbStopSound = sal_False;
     127             : 
     128           0 :         mbEffectAmbiguous = false;
     129           0 :         mbDurationAmbiguous = false;
     130           0 :         mbTimeAmbiguous = false;
     131           0 :         mbPresChangeAmbiguous = false;
     132           0 :         mbSoundAmbiguous = false;
     133           0 :         mbLoopSoundAmbiguous = false;
     134           0 :     }
     135             : 
     136           0 :     void setAllAmbiguous()
     137             :     {
     138           0 :         mbEffectAmbiguous = true;
     139           0 :         mbDurationAmbiguous = true;
     140           0 :         mbTimeAmbiguous = true;
     141           0 :         mbPresChangeAmbiguous = true;
     142           0 :         mbSoundAmbiguous = true;
     143           0 :         mbLoopSoundAmbiguous = true;
     144           0 :     }
     145             : 
     146           0 :     bool operator == ( const ::sd::TransitionPreset & rPreset ) const
     147             :     {
     148             :         return
     149           0 :             (mnType == rPreset.getTransition()) &&
     150           0 :             (mnSubType == rPreset.getSubtype()) &&
     151           0 :             (mbDirection == rPreset.getDirection()) &&
     152           0 :             (mnFadeColor ==  rPreset.getFadeColor());
     153             :     }
     154             : 
     155           0 :     void applyTo( SdPage & rOutPage ) const
     156             :     {
     157           0 :         if( ! mbEffectAmbiguous )
     158             :         {
     159           0 :             rOutPage.setTransitionType( mnType );
     160           0 :             rOutPage.setTransitionSubtype( mnSubType );
     161           0 :             rOutPage.setTransitionDirection( mbDirection );
     162           0 :             rOutPage.setTransitionFadeColor( mnFadeColor );
     163             :         }
     164             : 
     165           0 :         if( ! mbDurationAmbiguous )
     166           0 :             rOutPage.setTransitionDuration( mfDuration );
     167           0 :         if( ! mbTimeAmbiguous )
     168           0 :             rOutPage.SetTime( mfTime );
     169           0 :         if( ! mbPresChangeAmbiguous )
     170           0 :             rOutPage.SetPresChange( mePresChange );
     171           0 :         if( ! mbSoundAmbiguous )
     172             :         {
     173           0 :             if( mbStopSound )
     174             :             {
     175           0 :                 rOutPage.SetStopSound( sal_True );
     176           0 :                 rOutPage.SetSound( sal_False );
     177             :             }
     178             :             else
     179             :             {
     180           0 :                 rOutPage.SetStopSound( sal_False );
     181           0 :                 rOutPage.SetSound( mbSoundOn );
     182           0 :                 rOutPage.SetSoundFile( maSound );
     183             :             }
     184             :         }
     185           0 :         if( ! mbLoopSoundAmbiguous )
     186           0 :             rOutPage.SetLoopSound( mbLoopSound );
     187           0 :     }
     188             : 
     189           0 :     void compareWith( const SdPage & rPage )
     190             :     {
     191           0 :         TransitionEffect aOtherEffect( rPage );
     192           0 :         mbEffectAmbiguous = mbEffectAmbiguous || aOtherEffect.mbEffectAmbiguous
     193           0 :                                               || (mnType != aOtherEffect.mnType)
     194           0 :                                               || (mnSubType != aOtherEffect.mnSubType)
     195           0 :                                               || (mbDirection != aOtherEffect.mbDirection)
     196           0 :                                               || (mnFadeColor != aOtherEffect.mnFadeColor);
     197             : 
     198           0 :         mbDurationAmbiguous = mbDurationAmbiguous || aOtherEffect.mbDurationAmbiguous || mfDuration != aOtherEffect.mfDuration;
     199           0 :         mbTimeAmbiguous = mbTimeAmbiguous || aOtherEffect.mbTimeAmbiguous || mfTime != aOtherEffect.mfTime;
     200           0 :         mbPresChangeAmbiguous = mbPresChangeAmbiguous || aOtherEffect.mbPresChangeAmbiguous || mePresChange != aOtherEffect.mePresChange;
     201           0 :         mbSoundAmbiguous = mbSoundAmbiguous || aOtherEffect.mbSoundAmbiguous || mbSoundOn != aOtherEffect.mbSoundOn;
     202             : #if 0
     203             :                         // Weird leftover isolated expression with no effect, introduced in 2007 in
     204             :                         // CWS impress122. Ifdeffed out to avoid compiler warning, kept here in case
     205             :                         // somebody who understands this code notices and understands what the
     206             :                         // "right" thing to do might be.
     207             :                         (!mbStopSound && !aOtherEffect.mbStopSound && maSound != aOtherEffect.maSound) || (mbStopSound != aOtherEffect.mbStopSound);
     208             : #endif
     209           0 :         mbLoopSoundAmbiguous = mbLoopSoundAmbiguous || aOtherEffect.mbLoopSoundAmbiguous || mbLoopSound != aOtherEffect.mbLoopSound;
     210           0 :     }
     211             : 
     212             :     // effect
     213             :     sal_Int16 mnType;
     214             :     sal_Int16 mnSubType;
     215             :     sal_Bool  mbDirection;
     216             :     sal_Int32 mnFadeColor;
     217             : 
     218             :     // other settings
     219             :     double      mfDuration;
     220             :     double       mfTime;
     221             :     PresChange  mePresChange;
     222             :     sal_Bool        mbSoundOn;
     223             :     String      maSound;
     224             :     bool        mbLoopSound;
     225             :     bool        mbStopSound;
     226             : 
     227             :     bool mbEffectAmbiguous;
     228             :     bool mbDurationAmbiguous;
     229             :     bool mbTimeAmbiguous;
     230             :     bool mbPresChangeAmbiguous;
     231             :     bool mbSoundAmbiguous;
     232             :     bool mbLoopSoundAmbiguous;
     233             : };
     234             : 
     235             : } // namespace impl
     236             : } // namespace sd
     237             : 
     238             : // ______________________
     239             : //
     240             : // Local Helper Functions
     241             : // ______________________
     242             : 
     243             : namespace
     244             : {
     245             : 
     246           0 : void lcl_ApplyToPages(
     247             :     const ::sd::slidesorter::SharedPageSelection& rpPages,
     248             :     const ::sd::impl::TransitionEffect & rEffect )
     249             : {
     250           0 :     ::std::vector< SdPage * >::const_iterator aIt( rpPages->begin());
     251           0 :     const ::std::vector< SdPage * >::const_iterator aEndIt( rpPages->end());
     252           0 :     for( ; aIt != aEndIt; ++aIt )
     253             :     {
     254           0 :         rEffect.applyTo( *(*aIt) );
     255             :     }
     256           0 : }
     257             : 
     258           0 : void lcl_CreateUndoForPages(
     259             :     const ::sd::slidesorter::SharedPageSelection& rpPages,
     260             :     ::sd::ViewShellBase& rBase )
     261             : {
     262           0 :     ::sd::DrawDocShell* pDocSh      = rBase.GetDocShell();
     263           0 :     ::svl::IUndoManager* pManager   = pDocSh->GetUndoManager();
     264           0 :     SdDrawDocument* pDoc            = pDocSh->GetDoc();
     265           0 :     if( pManager && pDocSh && pDoc )
     266             :     {
     267           0 :         String aComment( SdResId(STR_UNDO_SLIDE_PARAMS) );
     268           0 :         pManager->EnterListAction(aComment, aComment);
     269           0 :         SdUndoGroup* pUndoGroup = new SdUndoGroup( pDoc );
     270           0 :         pUndoGroup->SetComment( aComment );
     271             : 
     272           0 :         ::std::vector< SdPage * >::const_iterator aIt( rpPages->begin());
     273           0 :         const ::std::vector< SdPage * >::const_iterator aEndIt( rpPages->end());
     274           0 :         for( ; aIt != aEndIt; ++aIt )
     275             :         {
     276           0 :             pUndoGroup->AddAction( new sd::UndoTransition( pDoc, (*aIt) ) );
     277             :         }
     278             : 
     279           0 :         pManager->AddUndoAction( pUndoGroup );
     280           0 :         pManager->LeaveListAction();
     281             :     }
     282           0 : }
     283             : 
     284           0 : sal_uInt16 lcl_getTransitionEffectIndex(
     285             :     SdDrawDocument * pDoc,
     286             :     const ::sd::impl::TransitionEffect & rTransition )
     287             : {
     288             :     // first entry: "<none>"
     289           0 :     sal_uInt16 nResultIndex = LISTBOX_ENTRY_NOTFOUND;
     290             : 
     291           0 :     if( pDoc )
     292             :     {
     293           0 :         sal_uInt16 nCurrentIndex = 0;
     294           0 :         const ::sd::TransitionPresetList & rPresetList = ::sd::TransitionPreset::getTransitionPresetList();
     295           0 :         ::sd::TransitionPresetList::const_iterator aIt( rPresetList.begin());
     296           0 :         const ::sd::TransitionPresetList::const_iterator aEndIt( rPresetList.end());
     297           0 :         for( ; aIt != aEndIt; ++aIt, ++nCurrentIndex )
     298             :         {
     299           0 :             if( rTransition.operator==( *(*aIt) ))
     300             :             {
     301           0 :                 nResultIndex = nCurrentIndex;
     302           0 :                 break;
     303             :             }
     304             :         }
     305             :     }
     306             : 
     307           0 :     return nResultIndex;
     308             : }
     309             : 
     310           0 : ::sd::TransitionPresetPtr lcl_getTransitionPresetByUIName(
     311             :     SdDrawDocument * pDoc,
     312             :     const OUString & rUIName )
     313             : {
     314           0 :     ::sd::TransitionPresetPtr pResult;
     315           0 :     if( pDoc )
     316             :     {
     317           0 :         const ::sd::TransitionPresetList& rPresetList = ::sd::TransitionPreset::getTransitionPresetList();
     318           0 :         ::sd::TransitionPresetList::const_iterator aIter( rPresetList.begin() );
     319           0 :         const ::sd::TransitionPresetList::const_iterator aEnd( rPresetList.end() );
     320           0 :         for( ; aIter != aEnd; ++aIter )
     321             :         {
     322           0 :             if( (*aIter)->getUIName().equals( rUIName ))
     323             :             {
     324           0 :                 pResult = *aIter;
     325           0 :                 break;
     326             :             }
     327             :         }
     328             :     }
     329             : 
     330           0 :     return pResult;
     331             : }
     332             : 
     333           0 : struct lcl_EqualsSoundFileName : public ::std::unary_function< String, bool >
     334             : {
     335           0 :     explicit lcl_EqualsSoundFileName( const String & rStr ) :
     336           0 :             maStr( rStr )
     337           0 :     {}
     338             : 
     339           0 :     bool operator() ( const String & rStr ) const
     340             :     {
     341             :         // note: formerly this was a case insensitive search for all
     342             :         // platforms. It seems more sensible to do this platform-dependent
     343             : #if defined( WNT )
     344             :         return maStr.EqualsIgnoreCaseAscii( rStr );
     345             : #else
     346           0 :         return maStr.Equals( rStr );
     347             : #endif
     348             :     }
     349             : 
     350             : private:
     351             :     String maStr;
     352             : };
     353             : 
     354             : // returns -1 if no object was found
     355           0 : bool lcl_findSoundInList( const ::std::vector< String > & rSoundList,
     356             :                           const String & rFileName,
     357             :                           ::std::vector< String >::size_type & rOutPosition )
     358             : {
     359             :     ::std::vector< String >::const_iterator aIt =
     360             :           ::std::find_if( rSoundList.begin(), rSoundList.end(),
     361           0 :                           lcl_EqualsSoundFileName( rFileName ));
     362           0 :     if( aIt != rSoundList.end())
     363             :     {
     364           0 :         rOutPosition = ::std::distance( rSoundList.begin(), aIt );
     365           0 :         return true;
     366             :     }
     367             : 
     368           0 :     return false;
     369             : }
     370             : 
     371           0 : String lcl_getSoundFileURL(
     372             :     const ::std::vector< String > & rSoundList,
     373             :     const ListBox & rListBox )
     374             : {
     375           0 :     String aResult;
     376             : 
     377           0 :     if( rListBox.GetSelectEntryCount() > 0 )
     378             :     {
     379           0 :         sal_uInt16 nPos = rListBox.GetSelectEntryPos();
     380             :         // the first three entries are no actual sounds
     381           0 :         if( nPos >= 3 )
     382             :         {
     383             :             DBG_ASSERT( (sal_uInt32)(rListBox.GetEntryCount() - 3) == rSoundList.size(),
     384             :                         "Sound list-box is not synchronized to sound list" );
     385           0 :             nPos -= 3;
     386           0 :             if( rSoundList.size() > nPos )
     387           0 :                 aResult = rSoundList[ nPos ];
     388             :         }
     389             :     }
     390             : 
     391           0 :     return aResult;
     392             : }
     393             : 
     394             : struct lcl_AppendSoundToListBox : public ::std::unary_function< String, void >
     395             : {
     396           0 :     lcl_AppendSoundToListBox( ListBox & rListBox ) :
     397           0 :             mrListBox( rListBox )
     398           0 :     {}
     399             : 
     400           0 :     void operator() ( const String & rString ) const
     401             :     {
     402           0 :         INetURLObject aURL( rString );
     403           0 :         mrListBox.InsertEntry( aURL.GetBase(), LISTBOX_APPEND );
     404           0 :     }
     405             : 
     406             : private:
     407             :     ListBox & mrListBox;
     408             : };
     409             : 
     410           0 : void lcl_FillSoundListBox(
     411             :     const ::std::vector< String > & rSoundList,
     412             :     ListBox & rOutListBox )
     413             : {
     414           0 :     sal_uInt16 nCount = rOutListBox.GetEntryCount();
     415             : 
     416             :     // keep first three entries
     417           0 :     for( sal_uInt16 i=nCount - 1; i>=3; --i )
     418           0 :         rOutListBox.RemoveEntry( i );
     419             : 
     420             :     ::std::for_each( rSoundList.begin(), rSoundList.end(),
     421           0 :                      lcl_AppendSoundToListBox( rOutListBox ));
     422           0 : }
     423             : 
     424             : } // anonymous namespace
     425             : 
     426             : namespace sd
     427             : {
     428             : 
     429             : // ___________________
     430             : //
     431             : // SlideTransitionPane
     432             : // ___________________
     433             : 
     434           0 : SlideTransitionPane::SlideTransitionPane(
     435             :     ::Window * pParent,
     436             :     ViewShellBase & rBase,
     437             :     const Size& rMinSize,
     438             :     SdDrawDocument* pDoc ) :
     439             :         Control( pParent, SdResId( DLG_SLIDE_TRANSITION_PANE ) ),
     440             : 
     441             :         mrBase( rBase ),
     442             :         mpDrawDoc( pDoc ),
     443             :         maMinSize( rMinSize ),
     444             :         maFL_APPLY_TRANSITION( this, SdResId( FL_APPLY_TRANSITION ) ),
     445             :         maLB_SLIDE_TRANSITIONS( this, SdResId( LB_SLIDE_TRANSITIONS ) ),
     446             :         maFL_MODIFY_TRANSITION( this, SdResId( FL_MODIFY_TRANSITION ) ),
     447             :         maFT_SPEED( this, SdResId( FT_SPEED ) ),
     448             :         maLB_SPEED( this, SdResId( LB_SPEED ) ),
     449             :         maFT_SOUND( this, SdResId( FT_SOUND ) ),
     450             :         maLB_SOUND( this, SdResId( LB_SOUND ) ),
     451             :         maCB_LOOP_SOUND( this, SdResId( CB_LOOP_SOUND ) ),
     452             :         maFL_ADVANCE_SLIDE( this, SdResId( FL_ADVANCE_SLIDE ) ),
     453             :         maRB_ADVANCE_ON_MOUSE( this, SdResId( RB_ADVANCE_ON_MOUSE ) ),
     454             :         maRB_ADVANCE_AUTO( this, SdResId( RB_ADVANCE_AUTO ) ),
     455             :         maMF_ADVANCE_AUTO_AFTER( this, SdResId( MF_ADVANCE_AUTO_AFTER ) ),
     456             :         maFL_EMPTY1( this, SdResId( FL_EMPTY1 ) ),
     457             :         maPB_APPLY_TO_ALL( this, SdResId( PB_APPLY_TO_ALL ) ),
     458             :         maPB_PLAY( this, SdResId( PB_PLAY ) ),
     459             :         maPB_SLIDE_SHOW( this, SdResId( PB_SLIDE_SHOW ) ),
     460             :         maFL_EMPTY2( this, SdResId( FL_EMPTY2 ) ),
     461             :         maCB_AUTO_PREVIEW( this, SdResId( CB_AUTO_PREVIEW ) ),
     462             : 
     463             :         maSTR_NO_TRANSITION( SdResId( STR_NO_TRANSITION ) ),
     464             :         mbHasSelection( false ),
     465             :         mbUpdatingControls( false ),
     466             :         mbIsMainViewChangePending( false ),
     467           0 :         maLateInitTimer()
     468             : {
     469             :     // use no resource ids from here on
     470           0 :     FreeResource();
     471             : 
     472             :     // use bold font for group headings (same font for all fixed lines):
     473           0 :     Font font( maFL_APPLY_TRANSITION.GetFont() );
     474           0 :     font.SetWeight( WEIGHT_BOLD );
     475           0 :     maFL_APPLY_TRANSITION.SetFont( font );
     476           0 :     maFL_MODIFY_TRANSITION.SetFont( font );
     477           0 :     maFL_ADVANCE_SLIDE.SetFont( font );
     478             : 
     479           0 :     if( pDoc )
     480           0 :         mxModel.set( pDoc->getUnoModel(), uno::UNO_QUERY );
     481             :     // TODO: get correct view
     482           0 :     if( mxModel.is())
     483           0 :         mxView.set( mxModel->getCurrentController(), uno::UNO_QUERY );
     484             : 
     485             :     // fill list box of slide transitions
     486           0 :     maLB_SLIDE_TRANSITIONS.InsertEntry( maSTR_NO_TRANSITION );
     487             : 
     488             :     // set defaults
     489           0 :     maCB_AUTO_PREVIEW.Check();      // automatic preview on
     490             : 
     491             :     // update control states before adding handlers
     492           0 :     updateLayout();
     493           0 :     updateControls();
     494             : 
     495             :     // set handlers
     496           0 :     maPB_APPLY_TO_ALL.SetClickHdl( LINK( this, SlideTransitionPane, ApplyToAllButtonClicked ));
     497           0 :     maPB_PLAY.SetClickHdl( LINK( this, SlideTransitionPane, PlayButtonClicked ));
     498           0 :     maPB_SLIDE_SHOW.SetClickHdl( LINK( this, SlideTransitionPane, SlideShowButtonClicked ));
     499             : 
     500           0 :     maLB_SLIDE_TRANSITIONS.SetSelectHdl( LINK( this, SlideTransitionPane, TransitionSelected ));
     501             : 
     502           0 :     maLB_SPEED.SetSelectHdl( LINK( this, SlideTransitionPane, SpeedListBoxSelected ));
     503           0 :     maLB_SOUND.SetSelectHdl( LINK( this, SlideTransitionPane, SoundListBoxSelected ));
     504           0 :     maCB_LOOP_SOUND.SetClickHdl( LINK( this, SlideTransitionPane, LoopSoundBoxChecked ));
     505             : 
     506           0 :     maRB_ADVANCE_ON_MOUSE.SetToggleHdl( LINK( this, SlideTransitionPane, AdvanceSlideRadioButtonToggled ));
     507           0 :     maRB_ADVANCE_AUTO.SetToggleHdl( LINK( this, SlideTransitionPane, AdvanceSlideRadioButtonToggled ));
     508           0 :     maMF_ADVANCE_AUTO_AFTER.SetModifyHdl( LINK( this, SlideTransitionPane, AdvanceTimeModified ));
     509           0 :     maCB_AUTO_PREVIEW.SetClickHdl( LINK( this, SlideTransitionPane, AutoPreviewClicked ));
     510           0 :     addListener();
     511             : 
     512           0 :     maLateInitTimer.SetTimeout(200);
     513           0 :     maLateInitTimer.SetTimeoutHdl(LINK(this, SlideTransitionPane, LateInitCallback));
     514           0 :     maLateInitTimer.Start();
     515             : 
     516           0 :     UpdateLook();
     517           0 : }
     518             : 
     519           0 : SlideTransitionPane::~SlideTransitionPane()
     520             : {
     521           0 :     maLateInitTimer.Stop();
     522           0 :     removeListener();
     523           0 : }
     524             : 
     525           0 : void SlideTransitionPane::Resize()
     526             : {
     527           0 :     updateLayout();
     528           0 : }
     529             : 
     530             : 
     531             : 
     532             : 
     533           0 : void SlideTransitionPane::DataChanged (const DataChangedEvent& rEvent)
     534             : {
     535             :     (void)rEvent;
     536           0 :     UpdateLook();
     537           0 : }
     538             : 
     539             : 
     540             : 
     541             : 
     542           0 : void SlideTransitionPane::UpdateLook (void)
     543             : {
     544           0 :     SetBackground(::sfx2::sidebar::Theme::GetWallpaper(::sfx2::sidebar::Theme::Paint_PanelBackground));
     545           0 :     maFL_APPLY_TRANSITION.SetBackground(Wallpaper());
     546           0 :     maFL_MODIFY_TRANSITION.SetBackground(Wallpaper());;
     547           0 :     maFT_SPEED.SetBackground(Wallpaper());
     548           0 :     maFT_SOUND.SetBackground(Wallpaper());
     549           0 :     maFL_ADVANCE_SLIDE.SetBackground(Wallpaper());
     550           0 :     maFL_EMPTY1.SetBackground(Wallpaper());
     551           0 :     maFL_EMPTY2.SetBackground(Wallpaper());
     552           0 : }
     553             : 
     554             : 
     555             : 
     556             : 
     557           0 : void SlideTransitionPane::onSelectionChanged()
     558             : {
     559           0 :     updateControls();
     560           0 : }
     561             : 
     562           0 : void SlideTransitionPane::onChangeCurrentPage()
     563             : {
     564           0 :     updateControls();
     565           0 : }
     566             : 
     567           0 : ::sd::slidesorter::SharedPageSelection SlideTransitionPane::getSelectedPages (void) const
     568             : {
     569             :     ::sd::slidesorter::SlideSorterViewShell * pSlideSorterViewShell
     570           0 :         = ::sd::slidesorter::SlideSorterViewShell::GetSlideSorter(mrBase);
     571           0 :     ::boost::shared_ptr<sd::slidesorter::SlideSorterViewShell::PageSelection> pSelection;
     572             : 
     573           0 :     if( pSlideSorterViewShell )
     574             :     {
     575           0 :         pSelection = pSlideSorterViewShell->GetPageSelection();
     576             :     }
     577             :     else
     578             :     {
     579           0 :         pSelection.reset(new sd::slidesorter::SlideSorterViewShell::PageSelection());
     580           0 :         if( mxView.is() )
     581             :         {
     582           0 :             SdPage* pPage = SdPage::getImplementation( mxView->getCurrentPage() );
     583           0 :             if( pPage )
     584           0 :                 pSelection->push_back(pPage);
     585             :         }
     586             :     }
     587             : 
     588           0 :     return pSelection;
     589             : }
     590             : 
     591           0 : void SlideTransitionPane::updateLayout()
     592             : {
     593           0 :     ::Size aPaneSize( GetSizePixel() );
     594           0 :     if( aPaneSize.Width() < maMinSize.Width() )
     595           0 :         aPaneSize.Width() = maMinSize.Width();
     596             : 
     597           0 :     if( aPaneSize.Height() < maMinSize.Height() )
     598           0 :         aPaneSize.Height() = maMinSize.Height();
     599             : 
     600             :     // start layouting elements from bottom to top.  The remaining space is used
     601             :     // for the topmost list box
     602           0 :     ::Point aOffset( LogicToPixel( Point( 3, 3 ), MAP_APPFONT ) );
     603           0 :     long nOffsetX = aOffset.getX();
     604           0 :     long nOffsetY = aOffset.getY();
     605           0 :     long nOffsetBtnX = LogicToPixel( Point( 6, 1 ), MAP_APPFONT ).getX();
     606             : 
     607           0 :     const long nMinCtrlWidth = LogicToPixel( ::Point( 32, 1 ), MAP_APPFONT ).getX();
     608           0 :     const long nTextIndent = LogicToPixel( ::Point( RSC_SP_CHK_TEXTINDENT, 1 ), MAP_APPFONT ).getX();
     609             : 
     610           0 :     ::Point aUpperLeft( nOffsetX, aPaneSize.getHeight() - nOffsetY );
     611           0 :     long nMaxWidth = aPaneSize.getWidth() - 2 * nOffsetX;
     612             : 
     613             :     // auto preview check-box
     614           0 :     ::Size aCtrlSize = maCB_AUTO_PREVIEW.GetSizePixel();
     615           0 :     aCtrlSize.setWidth( maCB_AUTO_PREVIEW.CalcMinimumSize( nMaxWidth ).getWidth());
     616           0 :     aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight());
     617           0 :     maCB_AUTO_PREVIEW.SetPosSizePixel( aUpperLeft, aCtrlSize );
     618             : 
     619             :     // fixed line above check-box
     620           0 :     aCtrlSize = maFL_EMPTY2.GetSizePixel();
     621           0 :     aCtrlSize.setWidth( nMaxWidth );
     622           0 :     aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight());
     623           0 :     maFL_EMPTY2.SetPosSizePixel( aUpperLeft, aCtrlSize );
     624             : 
     625             :     // buttons "Play" and "Slide Show"
     626           0 :     long nPlayButtonWidth = maPB_PLAY.CalcMinimumSize().getWidth() + 2 * nOffsetBtnX;
     627           0 :     long nSlideShowButtonWidth = maPB_SLIDE_SHOW.CalcMinimumSize().getWidth() + 2 * nOffsetBtnX;
     628             : 
     629           0 :     if( (nPlayButtonWidth + nSlideShowButtonWidth + nOffsetX) <= nMaxWidth )
     630             :     {
     631             :         // place buttons side by side
     632           0 :         aCtrlSize = maPB_PLAY.GetSizePixel();
     633           0 :         aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight());
     634           0 :         aCtrlSize.setWidth( nPlayButtonWidth );
     635           0 :         maPB_PLAY.SetPosSizePixel( aUpperLeft, aCtrlSize );
     636             : 
     637           0 :         aUpperLeft.setX( aUpperLeft.getX() + nPlayButtonWidth + nOffsetX );
     638           0 :         aCtrlSize.setWidth( nSlideShowButtonWidth );
     639           0 :         maPB_SLIDE_SHOW.SetPosSizePixel( aUpperLeft, aCtrlSize );
     640           0 :         aUpperLeft.setX( nOffsetX );
     641             :     }
     642             :     else
     643             :     {
     644             :         // place buttons on top of each other
     645           0 :         aCtrlSize = maPB_SLIDE_SHOW.GetSizePixel();
     646           0 :         aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight());
     647           0 :         aCtrlSize.setWidth( nSlideShowButtonWidth );
     648           0 :         maPB_SLIDE_SHOW.SetPosSizePixel( aUpperLeft, aCtrlSize );
     649             : 
     650           0 :         aCtrlSize = maPB_PLAY.GetSizePixel();
     651           0 :         aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight() - nOffsetY );
     652           0 :         aCtrlSize.setWidth( nPlayButtonWidth );
     653           0 :         maPB_PLAY.SetPosSizePixel( aUpperLeft, aCtrlSize );
     654             :     }
     655             : 
     656             :     // "Apply to All Slides" button
     657           0 :     aCtrlSize = maPB_APPLY_TO_ALL.GetSizePixel();
     658           0 :     aCtrlSize.setWidth( maPB_APPLY_TO_ALL.CalcMinimumSize( nMaxWidth ).getWidth() + 2 * nOffsetBtnX );
     659           0 :     aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight() - nOffsetY );
     660           0 :     maPB_APPLY_TO_ALL.SetPosSizePixel( aUpperLeft, aCtrlSize );
     661             : 
     662             :     // fixed line above "Apply to All Slides" button
     663           0 :     aCtrlSize = maFL_EMPTY1.GetSizePixel();
     664           0 :     aCtrlSize.setWidth( nMaxWidth );
     665           0 :     aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight());
     666           0 :     maFL_EMPTY1.SetPosSizePixel( aUpperLeft, aCtrlSize );
     667             : 
     668             :     // advance automatically after ... seconds
     669           0 :     long nItemWidth = maRB_ADVANCE_AUTO.CalcMinimumSize().getWidth();
     670             : 
     671           0 :     if( (nItemWidth + nMinCtrlWidth + nOffsetX) <= nMaxWidth )
     672             :     {
     673           0 :         long nBase = aUpperLeft.getY();
     674             : 
     675             :         // place controls side by side
     676           0 :         aCtrlSize = maRB_ADVANCE_AUTO.GetSizePixel();
     677           0 :         aUpperLeft.setY( nBase - aCtrlSize.getHeight());
     678           0 :         aCtrlSize.setWidth( nItemWidth );
     679           0 :         maRB_ADVANCE_AUTO.SetPosSizePixel( aUpperLeft, aCtrlSize );
     680             : 
     681           0 :         aCtrlSize = maMF_ADVANCE_AUTO_AFTER.GetSizePixel();
     682           0 :         aUpperLeft.setY( nBase - aCtrlSize.getHeight() );
     683           0 :         aUpperLeft.setX( aUpperLeft.getX() + nItemWidth + nOffsetX );
     684           0 :         aCtrlSize.setWidth( nMinCtrlWidth );
     685           0 :         maMF_ADVANCE_AUTO_AFTER.SetPosSizePixel( aUpperLeft, aCtrlSize );
     686           0 :         aUpperLeft.setX( nOffsetX );
     687             :     }
     688             :     else
     689             :     {
     690             :         // place controls on top of each other
     691           0 :         aCtrlSize = maMF_ADVANCE_AUTO_AFTER.GetSizePixel();
     692           0 :         aUpperLeft.setX( nOffsetX + nTextIndent );
     693           0 :         aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight());
     694           0 :         aCtrlSize.setWidth( nMinCtrlWidth );
     695           0 :         maMF_ADVANCE_AUTO_AFTER.SetPosSizePixel( aUpperLeft, aCtrlSize );
     696             : 
     697           0 :         aCtrlSize = maRB_ADVANCE_AUTO.GetSizePixel();
     698           0 :         aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight() - nOffsetY );
     699           0 :         aUpperLeft.setX( nOffsetX );
     700           0 :         aCtrlSize.setWidth( nItemWidth );
     701           0 :         maRB_ADVANCE_AUTO.SetPosSizePixel( aUpperLeft, aCtrlSize );
     702           0 :         aUpperLeft.setX( nOffsetX );
     703             :     }
     704             : 
     705             :     // check box "On mouse click"
     706           0 :     aCtrlSize = maRB_ADVANCE_ON_MOUSE.GetSizePixel();
     707           0 :     aCtrlSize.setWidth( nMaxWidth );
     708           0 :     aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight() - nOffsetY );
     709           0 :     maRB_ADVANCE_ON_MOUSE.SetPosSizePixel( aUpperLeft, aCtrlSize );
     710             : 
     711             :     // fixed line "Advance slide"
     712           0 :     aCtrlSize = maFL_ADVANCE_SLIDE.GetSizePixel();
     713           0 :     aCtrlSize.setWidth( nMaxWidth );
     714           0 :     aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight() - nOffsetY );
     715           0 :     maFL_ADVANCE_SLIDE.SetPosSizePixel( aUpperLeft, aCtrlSize );
     716             : 
     717             :     // check box "Loop until next sound"
     718           0 :     long nFTSpeedWidth = maFT_SPEED.CalcMinimumSize().getWidth() + 2 * nOffsetX;
     719           0 :     long nFTSoundWidth = maFT_SOUND.CalcMinimumSize().getWidth() + 2 * nOffsetX;
     720           0 :     long nIndent = ::std::max( nFTSoundWidth, nFTSpeedWidth );
     721             : 
     722           0 :     bool bStack = ( (nIndent + nMinCtrlWidth + nOffsetX) > nMaxWidth );
     723             : 
     724           0 :     if( bStack )
     725           0 :         nIndent = nTextIndent;
     726             : 
     727           0 :     aCtrlSize = maCB_LOOP_SOUND.GetSizePixel();
     728           0 :     aCtrlSize.setWidth( nMaxWidth - nIndent );
     729           0 :     aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight() - nOffsetY );
     730           0 :     aUpperLeft.setX( nIndent );
     731           0 :     maCB_LOOP_SOUND.SetPosSizePixel( aUpperLeft, aCtrlSize );
     732             : 
     733           0 :     aCtrlSize = maLB_SOUND.GetSizePixel();
     734           0 :     aCtrlSize.setWidth( ::std::max( nMaxWidth - nIndent, nMinCtrlWidth ) );
     735           0 :     aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight() - nOffsetY );
     736           0 :     maLB_SOUND.SetPosSizePixel( aUpperLeft, aCtrlSize );
     737           0 :     maLB_SOUND.SetDropDownLineCount( 8 );
     738           0 :     aUpperLeft.setX( nOffsetX );
     739             : 
     740           0 :     aCtrlSize = maFT_SOUND.GetSizePixel();
     741           0 :     if( bStack )
     742           0 :         aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight());
     743           0 :     aCtrlSize.setWidth( nFTSoundWidth - 2 * nOffsetX );
     744           0 :     maFT_SOUND.SetPosSizePixel( aUpperLeft, aCtrlSize );
     745             : 
     746           0 :     aUpperLeft.setX( nIndent );
     747           0 :     aCtrlSize = maLB_SPEED.GetSizePixel();
     748           0 :     aCtrlSize.setWidth( ::std::max( nMaxWidth - nIndent, nMinCtrlWidth ) );
     749           0 :     aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight() - nOffsetY );
     750           0 :     maLB_SPEED.SetPosSizePixel( aUpperLeft, aCtrlSize );
     751           0 :     maLB_SPEED.SetDropDownLineCount( 3 );
     752           0 :     aUpperLeft.setX( nOffsetX );
     753             : 
     754           0 :     aCtrlSize = maFT_SPEED.GetSizePixel();
     755           0 :     if( bStack )
     756           0 :         aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight());
     757           0 :     aCtrlSize.setWidth( nFTSpeedWidth - 2 * nOffsetX );
     758           0 :     maFT_SPEED.SetPosSizePixel( aUpperLeft, aCtrlSize );
     759             : 
     760             :     // fixed line "Modify Transition"
     761           0 :     aCtrlSize = maFL_MODIFY_TRANSITION.GetSizePixel();
     762           0 :     aCtrlSize.setWidth( nMaxWidth );
     763           0 :     aUpperLeft.setY( aUpperLeft.getY() - aCtrlSize.getHeight() - nOffsetY );
     764           0 :     maFL_MODIFY_TRANSITION.SetPosSizePixel( aUpperLeft, aCtrlSize );
     765             : 
     766             :     // fixed line "Apply to selected slides"
     767           0 :     aCtrlSize = maFL_APPLY_TRANSITION.GetSizePixel();
     768           0 :     aCtrlSize.setWidth( nMaxWidth );
     769           0 :     ::Point aUpperLeftCorner( nOffsetX, nOffsetY );
     770           0 :     maFL_APPLY_TRANSITION.SetPosSizePixel( aUpperLeftCorner, aCtrlSize );
     771           0 :     aUpperLeftCorner.setY( aUpperLeftCorner.getY() + aCtrlSize.getHeight() + nOffsetY );
     772           0 :     aUpperLeft.setY( aUpperLeft.getY() - nOffsetY );
     773             : 
     774             :     // list box slide transitions
     775           0 :     aCtrlSize.setWidth( nMaxWidth );
     776           0 :     aCtrlSize.setHeight( aUpperLeft.getY() - aUpperLeftCorner.getY() );
     777           0 :     maLB_SLIDE_TRANSITIONS.SetPosSizePixel( aUpperLeftCorner, aCtrlSize );
     778           0 : }
     779             : 
     780           0 : void SlideTransitionPane::updateControls()
     781             : {
     782           0 :     ::sd::slidesorter::SharedPageSelection pSelectedPages(getSelectedPages());
     783           0 :     if( pSelectedPages->empty())
     784             :     {
     785           0 :         mbHasSelection = false;
     786           0 :         return;
     787             :     }
     788           0 :     mbHasSelection = true;
     789             : 
     790             :     DBG_ASSERT( ! mbUpdatingControls, "Multiple Control Updates" );
     791           0 :     mbUpdatingControls = true;
     792             : 
     793             :     // get model data for first page
     794           0 :     SdPage * pFirstPage = pSelectedPages->front();
     795             :     DBG_ASSERT( pFirstPage, "Invalid Page" );
     796             : 
     797           0 :     impl::TransitionEffect aEffect( *pFirstPage );
     798             : 
     799             :     // merge with other pages
     800             :     ::sd::slidesorter::SlideSorterViewShell::PageSelection::const_iterator aIt(
     801           0 :         pSelectedPages->begin());
     802             :     ::sd::slidesorter::SlideSorterViewShell::PageSelection::const_iterator aEndIt(
     803           0 :         pSelectedPages->end());
     804             : 
     805             :     // start with second page (note aIt != aEndIt, because ! aSelectedPages.empty())
     806           0 :     for( ++aIt ;aIt != aEndIt; ++aIt )
     807             :     {
     808           0 :         if( *aIt )
     809           0 :             aEffect.compareWith( *(*aIt) );
     810             :     }
     811             : 
     812             :     // detect current slide effect
     813           0 :     if( aEffect.mbEffectAmbiguous )
     814           0 :         maLB_SLIDE_TRANSITIONS.SetNoSelection();
     815             :     else
     816             :     {
     817             :         // ToDo: That 0 is "no transition" is documented nowhere except in the
     818             :         // CTOR of sdpage
     819           0 :         if( aEffect.mnType == 0 )
     820           0 :             maLB_SLIDE_TRANSITIONS.SelectEntryPos( 0 );
     821             :         else
     822             :         {
     823           0 :             sal_uInt16 nEntry = lcl_getTransitionEffectIndex( mpDrawDoc, aEffect );
     824           0 :             if( nEntry == LISTBOX_ENTRY_NOTFOUND )
     825           0 :                 maLB_SLIDE_TRANSITIONS.SetNoSelection();
     826             :             else
     827             :             {
     828             :                 // first entry in list is "none", so add 1 after translation
     829           0 :                 if( m_aPresetIndexes.find( nEntry ) != m_aPresetIndexes.end())
     830           0 :                     maLB_SLIDE_TRANSITIONS.SelectEntryPos( m_aPresetIndexes[ nEntry ] + 1 );
     831             :                 else
     832           0 :                     maLB_SLIDE_TRANSITIONS.SetNoSelection();
     833             :             }
     834             :         }
     835             :     }
     836             : 
     837           0 :     if( aEffect.mbDurationAmbiguous )
     838           0 :         maLB_SPEED.SetNoSelection();
     839             :     else
     840             :         maLB_SPEED.SelectEntryPos(
     841           0 :             (aEffect.mfDuration > 2.0 )
     842           0 :             ? 0 : (aEffect.mfDuration < 2.0)
     843           0 :             ? 2 : 1 );       // else FADE_SPEED_FAST
     844             : 
     845           0 :     if( aEffect.mbSoundAmbiguous )
     846             :     {
     847           0 :         maLB_SOUND.SetNoSelection();
     848           0 :         maCurrentSoundFile.Erase();
     849             :     }
     850             :     else
     851             :     {
     852           0 :         maCurrentSoundFile.Erase();
     853           0 :         if( aEffect.mbStopSound )
     854             :         {
     855           0 :             maLB_SOUND.SelectEntryPos( 1 );
     856             :         }
     857           0 :         else if( aEffect.mbSoundOn && aEffect.maSound.Len() > 0 )
     858             :         {
     859           0 :             tSoundListType::size_type nPos = 0;
     860           0 :             if( lcl_findSoundInList( maSoundList, aEffect.maSound, nPos ))
     861             :             {
     862             :                 // skip first three entries
     863           0 :                 maLB_SOUND.SelectEntryPos( (sal_uInt16)nPos + 3 );
     864           0 :                 maCurrentSoundFile = aEffect.maSound;
     865             :             }
     866             :         }
     867             :         else
     868             :         {
     869           0 :             maLB_SOUND.SelectEntryPos( 0 );
     870             :         }
     871             :     }
     872             : 
     873           0 :     if( aEffect.mbLoopSoundAmbiguous )
     874             :     {
     875           0 :         maCB_LOOP_SOUND.SetState( STATE_DONTKNOW );
     876             :     }
     877             :     else
     878             :     {
     879           0 :         maCB_LOOP_SOUND.Check( aEffect.mbLoopSound );
     880             :     }
     881             : 
     882           0 :     if( aEffect.mbPresChangeAmbiguous )
     883             :     {
     884           0 :         maRB_ADVANCE_ON_MOUSE.Check( sal_False );
     885           0 :         maRB_ADVANCE_AUTO.Check( sal_False );
     886             :     }
     887             :     else
     888             :     {
     889           0 :         maRB_ADVANCE_ON_MOUSE.Check( aEffect.mePresChange == PRESCHANGE_MANUAL );
     890           0 :         maRB_ADVANCE_AUTO.Check( aEffect.mePresChange == PRESCHANGE_AUTO );
     891           0 :         maMF_ADVANCE_AUTO_AFTER.SetValue( aEffect.mfTime * 100.0);
     892             :     }
     893             : 
     894           0 :     SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
     895           0 :     maCB_AUTO_PREVIEW.Check( pOptions->IsPreviewTransitions() == sal_True );
     896             : 
     897           0 :     mbUpdatingControls = false;
     898             : 
     899           0 :     updateControlState();
     900             : }
     901             : 
     902           0 : void SlideTransitionPane::updateControlState()
     903             : {
     904           0 :     maLB_SLIDE_TRANSITIONS.Enable( mbHasSelection );
     905           0 :     maLB_SPEED.Enable( mbHasSelection );
     906           0 :     maLB_SOUND.Enable( mbHasSelection );
     907           0 :     maCB_LOOP_SOUND.Enable( mbHasSelection && (maLB_SOUND.GetSelectEntryPos() > 2));
     908           0 :     maRB_ADVANCE_ON_MOUSE.Enable( mbHasSelection );
     909           0 :     maRB_ADVANCE_AUTO.Enable( mbHasSelection );
     910           0 :     maMF_ADVANCE_AUTO_AFTER.Enable( mbHasSelection && maRB_ADVANCE_AUTO.IsChecked());
     911             : 
     912           0 :     maPB_APPLY_TO_ALL.Enable( mbHasSelection );
     913           0 :     maPB_PLAY.Enable( mbHasSelection );
     914           0 :     maCB_AUTO_PREVIEW.Enable( mbHasSelection );
     915           0 : }
     916             : 
     917           0 : void SlideTransitionPane::updateSoundList()
     918             : {
     919           0 :     ::std::vector< String > aSoundList;
     920             : 
     921           0 :     GalleryExplorer::FillObjList( GALLERY_THEME_SOUNDS, aSoundList );
     922           0 :     GalleryExplorer::FillObjList( GALLERY_THEME_USERSOUNDS, aSoundList );
     923             : 
     924           0 :     size_t nCount = aSoundList.size();
     925           0 :     maSoundList.clear();
     926           0 :     maSoundList.reserve( nCount );
     927           0 :     for( size_t i =0 ; i < nCount; ++i )
     928             :     {
     929             :         // store copy of string in member list
     930           0 :         maSoundList.push_back( aSoundList[ i ] );
     931             :     }
     932             : 
     933           0 :     lcl_FillSoundListBox( maSoundList, maLB_SOUND );
     934           0 : }
     935             : 
     936           0 : void SlideTransitionPane::openSoundFileDialog()
     937             : {
     938           0 :     if( ! maLB_SOUND.IsEnabled())
     939           0 :         return;
     940             : 
     941           0 :     SdOpenSoundFileDialog aFileDialog;
     942             : 
     943           0 :     String aFile;
     944             :     DBG_ASSERT( maLB_SOUND.GetSelectEntryPos() == 2,
     945             :                 "Dialog should only open when \"Other sound\" is selected" );
     946           0 :     aFile = SvtPathOptions().GetGraphicPath();
     947             : 
     948           0 :     aFileDialog.SetPath( aFile );
     949             : 
     950           0 :     bool bValidSoundFile( false );
     951           0 :     bool bQuitLoop( false );
     952             : 
     953           0 :     while( ! bQuitLoop &&
     954           0 :            aFileDialog.Execute() == ERRCODE_NONE )
     955             :     {
     956           0 :         aFile = aFileDialog.GetPath();
     957           0 :         tSoundListType::size_type nPos = 0;
     958           0 :         bValidSoundFile = lcl_findSoundInList( maSoundList, aFile, nPos );
     959             : 
     960           0 :         if( bValidSoundFile )
     961             :         {
     962           0 :             bQuitLoop = true;
     963             :         }
     964             :         else // not in sound list
     965             :         {
     966             :             // try to insert into gallery
     967           0 :             if( GalleryExplorer::InsertURL( GALLERY_THEME_USERSOUNDS, aFile ) )
     968             :             {
     969           0 :                 updateSoundList();
     970           0 :                 bValidSoundFile = lcl_findSoundInList( maSoundList, aFile, nPos );
     971             :                 DBG_ASSERT( bValidSoundFile, "Adding sound to gallery failed" );
     972             : 
     973           0 :                 bQuitLoop = true;
     974             :             }
     975             :             else
     976             :             {
     977           0 :                 String aStrWarning(SdResId(STR_WARNING_NOSOUNDFILE));
     978           0 :                 OUString aStr('%');
     979           0 :                 aStrWarning.SearchAndReplace( aStr , aFile );
     980           0 :                 WarningBox aWarningBox( NULL, WB_3DLOOK | WB_RETRY_CANCEL, aStrWarning );
     981           0 :                 aWarningBox.SetModalInputMode (sal_True);
     982           0 :                 bQuitLoop = (aWarningBox.Execute() != RET_RETRY);
     983             : 
     984           0 :                 bValidSoundFile = false;
     985             :             }
     986             :         }
     987             : 
     988           0 :         if( bValidSoundFile )
     989             :             // skip first three entries in list
     990           0 :             maLB_SOUND.SelectEntryPos( (sal_uInt16)nPos + 3 );
     991             :     }
     992             : 
     993           0 :     if( ! bValidSoundFile )
     994             :     {
     995           0 :         if( maCurrentSoundFile.Len() > 0 )
     996             :         {
     997           0 :             tSoundListType::size_type nPos = 0;
     998           0 :             if( lcl_findSoundInList( maSoundList, maCurrentSoundFile, nPos ))
     999           0 :                 maLB_SOUND.SelectEntryPos( (sal_uInt16)nPos + 3 );
    1000             :             else
    1001           0 :                 maLB_SOUND.SelectEntryPos( 0 );  // NONE
    1002             :         }
    1003             :         else
    1004           0 :             maLB_SOUND.SelectEntryPos( 0 );  // NONE
    1005           0 :     }
    1006             : }
    1007             : 
    1008           0 : impl::TransitionEffect SlideTransitionPane::getTransitionEffectFromControls() const
    1009             : {
    1010           0 :     impl::TransitionEffect aResult;
    1011           0 :     aResult.setAllAmbiguous();
    1012             : 
    1013             :     // check first (aResult might be overwritten)
    1014           0 :     if( maLB_SLIDE_TRANSITIONS.IsEnabled() &&
    1015           0 :         maLB_SLIDE_TRANSITIONS.GetSelectEntryCount() > 0 )
    1016             :     {
    1017             :         TransitionPresetPtr pPreset = lcl_getTransitionPresetByUIName(
    1018           0 :             mpDrawDoc, OUString( maLB_SLIDE_TRANSITIONS.GetSelectEntry()));
    1019             : 
    1020           0 :         if( pPreset.get())
    1021             :         {
    1022           0 :             aResult = impl::TransitionEffect( *pPreset );
    1023           0 :             aResult.setAllAmbiguous();
    1024             :         }
    1025             :         else
    1026             :         {
    1027           0 :             aResult.mnType = 0;
    1028             :         }
    1029           0 :         aResult.mbEffectAmbiguous = false;
    1030             :     }
    1031             : 
    1032             :     // speed
    1033           0 :     if( maLB_SPEED.IsEnabled() &&
    1034           0 :         maLB_SPEED.GetSelectEntryCount() > 0 )
    1035             :     {
    1036           0 :         sal_uInt16 nPos = maLB_SPEED.GetSelectEntryPos();
    1037             :         aResult.mfDuration = (nPos == 0)
    1038             :             ? 3.0
    1039             :             : (nPos == 1)
    1040             :             ? 2.0
    1041           0 :             : 1.0;   // nPos == 2
    1042             :         DBG_ASSERT( aResult.mfDuration != 1.0 || nPos == 2, "Invalid Listbox Entry" );
    1043             : 
    1044           0 :         aResult.mbDurationAmbiguous = false;
    1045             :     }
    1046             : 
    1047             :     // slide-advance mode
    1048           0 :     if( maRB_ADVANCE_ON_MOUSE.IsEnabled() && maRB_ADVANCE_AUTO.IsEnabled() &&
    1049           0 :         (maRB_ADVANCE_ON_MOUSE.IsChecked() || maRB_ADVANCE_AUTO.IsChecked()))
    1050             :     {
    1051           0 :         if( maRB_ADVANCE_ON_MOUSE.IsChecked())
    1052           0 :             aResult.mePresChange = PRESCHANGE_MANUAL;
    1053             :         else
    1054             :         {
    1055           0 :             aResult.mePresChange = PRESCHANGE_AUTO;
    1056           0 :             if( maMF_ADVANCE_AUTO_AFTER.IsEnabled())
    1057             :             {
    1058           0 :                 aResult.mfTime = static_cast<double>(maMF_ADVANCE_AUTO_AFTER.GetValue() ) / 100.0 ;
    1059           0 :                 aResult.mbTimeAmbiguous = false;
    1060             :             }
    1061             :         }
    1062             : 
    1063           0 :         aResult.mbPresChangeAmbiguous = false;
    1064             :     }
    1065             : 
    1066             :     // sound
    1067           0 :     if( maLB_SOUND.IsEnabled())
    1068             :     {
    1069           0 :         maCurrentSoundFile.Erase();
    1070           0 :         if( maLB_SOUND.GetSelectEntryCount() > 0 )
    1071             :         {
    1072           0 :             sal_uInt16 nPos = maLB_SOUND.GetSelectEntryPos();
    1073           0 :             aResult.mbStopSound = nPos == 1;
    1074           0 :             aResult.mbSoundOn = nPos > 1;
    1075           0 :             if( aResult.mbStopSound )
    1076             :             {
    1077           0 :                 aResult.maSound = OUString();
    1078           0 :                 aResult.mbSoundAmbiguous = false;
    1079             :             }
    1080             :             else
    1081             :             {
    1082           0 :                 aResult.maSound = lcl_getSoundFileURL( maSoundList, maLB_SOUND );
    1083           0 :                 aResult.mbSoundAmbiguous = false;
    1084           0 :                 maCurrentSoundFile = aResult.maSound;
    1085             :             }
    1086             :         }
    1087             :     }
    1088             : 
    1089             :     // sound loop
    1090           0 :     if( maCB_LOOP_SOUND.IsEnabled() )
    1091             :     {
    1092           0 :         aResult.mbLoopSound = maCB_LOOP_SOUND.IsChecked();
    1093           0 :         aResult.mbLoopSoundAmbiguous = false;
    1094             :     }
    1095             : 
    1096           0 :     return aResult;
    1097             : }
    1098             : 
    1099           0 : void SlideTransitionPane::applyToSelectedPages()
    1100             : {
    1101           0 :     if( ! mbUpdatingControls )
    1102             :     {
    1103           0 :         ::sd::slidesorter::SharedPageSelection pSelectedPages( getSelectedPages());
    1104           0 :         if( ! pSelectedPages->empty())
    1105             :         {
    1106           0 :             lcl_CreateUndoForPages( pSelectedPages, mrBase );
    1107           0 :             lcl_ApplyToPages( pSelectedPages, getTransitionEffectFromControls() );
    1108           0 :             mrBase.GetDocShell()->SetModified();
    1109             :         }
    1110           0 :         if( maCB_AUTO_PREVIEW.IsEnabled() &&
    1111           0 :             maCB_AUTO_PREVIEW.IsChecked())
    1112             :         {
    1113           0 :             playCurrentEffect();
    1114           0 :         }
    1115             :     }
    1116           0 : }
    1117             : 
    1118           0 : void SlideTransitionPane::playCurrentEffect()
    1119             : {
    1120           0 :     if( mxView.is() )
    1121             :     {
    1122             : 
    1123           0 :         Reference< ::com::sun::star::animations::XAnimationNode > xNode;
    1124           0 :         SlideShow::StartPreview( mrBase, mxView->getCurrentPage(), xNode );
    1125             :     }
    1126           0 : }
    1127             : 
    1128           0 : void SlideTransitionPane::addListener()
    1129             : {
    1130           0 :     Link aLink( LINK(this,SlideTransitionPane,EventMultiplexerListener) );
    1131             :     mrBase.GetEventMultiplexer()->AddEventListener (
    1132             :         aLink,
    1133             :         tools::EventMultiplexerEvent::EID_EDIT_VIEW_SELECTION
    1134             :         | tools::EventMultiplexerEvent::EID_SLIDE_SORTER_SELECTION
    1135             :         | tools::EventMultiplexerEvent::EID_CURRENT_PAGE
    1136             :         | tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED
    1137             :         | tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED
    1138           0 :         | tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED);
    1139           0 : }
    1140             : 
    1141           0 : void SlideTransitionPane::removeListener()
    1142             : {
    1143           0 :     Link aLink( LINK(this,SlideTransitionPane,EventMultiplexerListener) );
    1144           0 :     mrBase.GetEventMultiplexer()->RemoveEventListener( aLink );
    1145           0 : }
    1146             : 
    1147           0 : IMPL_LINK(SlideTransitionPane,EventMultiplexerListener,
    1148             :     tools::EventMultiplexerEvent*,pEvent)
    1149             : {
    1150           0 :     switch (pEvent->meEventId)
    1151             :     {
    1152             :         case tools::EventMultiplexerEvent::EID_EDIT_VIEW_SELECTION:
    1153           0 :             onSelectionChanged();
    1154           0 :             break;
    1155             : 
    1156             :         case tools::EventMultiplexerEvent::EID_CURRENT_PAGE:
    1157             :         case tools::EventMultiplexerEvent::EID_SLIDE_SORTER_SELECTION:
    1158           0 :             onChangeCurrentPage();
    1159           0 :             break;
    1160             : 
    1161             :         case tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED:
    1162           0 :             mxView = Reference<drawing::XDrawView>();
    1163           0 :             onSelectionChanged();
    1164           0 :             onChangeCurrentPage();
    1165           0 :             break;
    1166             : 
    1167             :         case tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED:
    1168           0 :             mbIsMainViewChangePending = true;
    1169           0 :             break;
    1170             : 
    1171             :         case tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED:
    1172           0 :             if (mbIsMainViewChangePending)
    1173             :             {
    1174           0 :                 mbIsMainViewChangePending = false;
    1175             : 
    1176             :                 // At this moment the controller may not yet been set at
    1177             :                 // model or ViewShellBase.  Take it from the view shell
    1178             :                 // passed with the event.
    1179           0 :                 if (mrBase.GetMainViewShell() != 0)
    1180             :                 {
    1181           0 :                     mxView = Reference<drawing::XDrawView>::query(mrBase.GetController());
    1182           0 :                     onSelectionChanged();
    1183           0 :                     onChangeCurrentPage();
    1184             :                 }
    1185             :             }
    1186           0 :             break;
    1187             : 
    1188             :         default:
    1189           0 :             break;
    1190             :     }
    1191           0 :     return 0;
    1192             : }
    1193             : 
    1194           0 : IMPL_LINK_NOARG(SlideTransitionPane, ApplyToAllButtonClicked)
    1195             : {
    1196             :     DBG_ASSERT( mpDrawDoc, "Invalid Draw Document!" );
    1197           0 :     if( !mpDrawDoc )
    1198           0 :         return 0;
    1199             : 
    1200             :     ::sd::slidesorter::SharedPageSelection pPages (
    1201           0 :         new ::sd::slidesorter::SlideSorterViewShell::PageSelection());
    1202             : 
    1203           0 :     sal_uInt16 nPageCount = mpDrawDoc->GetSdPageCount( PK_STANDARD );
    1204           0 :     pPages->reserve( nPageCount );
    1205           0 :     for( sal_uInt16 i=0; i<nPageCount; ++i )
    1206             :     {
    1207           0 :         SdPage * pPage = mpDrawDoc->GetSdPage( i, PK_STANDARD );
    1208           0 :         if( pPage )
    1209           0 :             pPages->push_back( pPage );
    1210             :     }
    1211             : 
    1212           0 :     if( ! pPages->empty())
    1213             :     {
    1214           0 :         lcl_CreateUndoForPages( pPages, mrBase );
    1215           0 :         lcl_ApplyToPages( pPages, getTransitionEffectFromControls() );
    1216             :     }
    1217             : 
    1218           0 :     return 0;
    1219             : }
    1220             : 
    1221             : 
    1222           0 : IMPL_LINK_NOARG(SlideTransitionPane, PlayButtonClicked)
    1223             : {
    1224           0 :     playCurrentEffect();
    1225           0 :     return 0;
    1226             : }
    1227             : 
    1228           0 : IMPL_LINK_NOARG(SlideTransitionPane, SlideShowButtonClicked)
    1229             : {
    1230           0 :     mrBase.StartPresentation();
    1231           0 :     return 0;
    1232             : }
    1233             : 
    1234           0 : IMPL_LINK_NOARG(SlideTransitionPane, TransitionSelected)
    1235             : {
    1236           0 :     applyToSelectedPages();
    1237           0 :     return 0;
    1238             : }
    1239             : 
    1240           0 : IMPL_LINK_NOARG(SlideTransitionPane, AdvanceSlideRadioButtonToggled)
    1241             : {
    1242           0 :     updateControlState();
    1243           0 :     applyToSelectedPages();
    1244           0 :     return 0;
    1245             : }
    1246             : 
    1247           0 : IMPL_LINK_NOARG(SlideTransitionPane, AdvanceTimeModified)
    1248             : {
    1249           0 :     applyToSelectedPages();
    1250           0 :     return 0;
    1251             : }
    1252             : 
    1253           0 : IMPL_LINK_NOARG(SlideTransitionPane, SpeedListBoxSelected)
    1254             : {
    1255           0 :     applyToSelectedPages();
    1256           0 :     return 0;
    1257             : }
    1258             : 
    1259           0 : IMPL_LINK_NOARG(SlideTransitionPane, SoundListBoxSelected)
    1260             : {
    1261           0 :     if( maLB_SOUND.GetSelectEntryCount() )
    1262             :     {
    1263           0 :         sal_uInt16 nPos = maLB_SOUND.GetSelectEntryPos();
    1264           0 :         if( nPos == 2 )
    1265             :         {
    1266             :             // other sound ...
    1267           0 :             openSoundFileDialog();
    1268             :         }
    1269             :     }
    1270           0 :     updateControlState();
    1271           0 :     applyToSelectedPages();
    1272           0 :     return 0;
    1273             : }
    1274             : 
    1275           0 : IMPL_LINK_NOARG(SlideTransitionPane, LoopSoundBoxChecked)
    1276             : {
    1277           0 :     applyToSelectedPages();
    1278           0 :     return 0;
    1279             : }
    1280             : 
    1281           0 : IMPL_LINK_NOARG(SlideTransitionPane, AutoPreviewClicked)
    1282             : {
    1283           0 :     SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
    1284           0 :     pOptions->SetPreviewTransitions( maCB_AUTO_PREVIEW.IsChecked() ? sal_True : sal_False );
    1285           0 :     return 0;
    1286             : }
    1287             : 
    1288           0 : IMPL_LINK_NOARG(SlideTransitionPane, LateInitCallback)
    1289             : {
    1290           0 :     const TransitionPresetList& rPresetList = TransitionPreset::getTransitionPresetList();
    1291           0 :     TransitionPresetList::const_iterator aIter( rPresetList.begin() );
    1292           0 :     const TransitionPresetList::const_iterator aEnd( rPresetList.end() );
    1293           0 :     sal_uInt16 nIndex = 0;
    1294           0 :     ::std::size_t nUIIndex = 0;
    1295           0 :     while( aIter != aEnd )
    1296             :     {
    1297           0 :         TransitionPresetPtr pPreset = (*aIter++);
    1298           0 :         const OUString aUIName( pPreset->getUIName() );
    1299           0 :          if( !aUIName.isEmpty() )
    1300             :         {
    1301           0 :             maLB_SLIDE_TRANSITIONS.InsertEntry( aUIName );
    1302           0 :             m_aPresetIndexes[ nIndex ] = (sal_uInt16)nUIIndex;
    1303           0 :             ++nUIIndex;
    1304             :         }
    1305           0 :         ++nIndex;
    1306           0 :     }
    1307             : 
    1308           0 :     updateSoundList();
    1309           0 :     updateControls();
    1310             : 
    1311           0 :     return 0;
    1312             : }
    1313             : 
    1314           0 : ::Window * createSlideTransitionPanel( ::Window* pParent, ViewShellBase& rBase )
    1315             : {
    1316           0 :     DialogListBox* pWindow = 0;
    1317             : 
    1318           0 :     DrawDocShell* pDocSh = rBase.GetDocShell();
    1319           0 :     if( pDocSh )
    1320             :     {
    1321           0 :         pWindow = new DialogListBox( pParent, WB_CLIPCHILDREN|WB_TABSTOP|WB_AUTOHSCROLL );
    1322             : 
    1323           0 :         Size aMinSize( pWindow->LogicToPixel( Size( 72, 216 ), MAP_APPFONT ) );
    1324           0 :         ::Window* pPaneWindow = new SlideTransitionPane( pWindow, rBase, aMinSize, pDocSh->GetDoc() );
    1325           0 :         pWindow->SetChildWindow( pPaneWindow, aMinSize );
    1326           0 :         pWindow->SetText( pPaneWindow->GetText() );
    1327             :     }
    1328             : 
    1329           0 :     return pWindow;
    1330             : }
    1331             : 
    1332             : 
    1333             : 
    1334             : 
    1335           0 : sal_Int32 getSlideTransitionPanelMinimumHeight (::Window* pDialog)
    1336             : {
    1337           0 :     if (pDialog != NULL)
    1338           0 :         return pDialog->LogicToPixel(Size( 72, 216 ), MAP_APPFONT).Height();
    1339             :     else
    1340           0 :         return 0;
    1341             : }
    1342             : 
    1343             : 
    1344          33 : } //  namespace sd
    1345             : 
    1346             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10