Update ooo320-m1
[ooovba.git] / sd / source / ui / dlg / dlgctrls.cxx
blobeeeb5861b6ab1df2da9e5ece06808641e47abafe
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: dlgctrls.cxx,v $
10 * $Revision: 1.9 $
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"
34 #include <tools/ref.hxx>
35 #include <tools/debug.hxx>
37 #include "strings.hrc"
38 #include "dlgctrls.hxx"
39 #include "sdresid.hxx"
40 #include "fadedef.h"
41 #include "sdpage.hxx"
43 using namespace ::sd;
44 using namespace ::rtl;
46 struct FadeEffectLBImpl
48 std::vector< TransitionPresetPtr > maPresets;
51 FadeEffectLB::FadeEffectLB( Window* pParent, SdResId Id )
52 : ListBox( pParent, Id ),
53 mpImpl( new FadeEffectLBImpl )
57 FadeEffectLB::FadeEffectLB( Window* pParent, WinBits aWB )
58 : ListBox( pParent, aWB ),
59 mpImpl( new FadeEffectLBImpl )
63 FadeEffectLB::~FadeEffectLB()
65 delete mpImpl;
68 void FadeEffectLB::Fill()
70 TransitionPresetPtr pPreset;
72 InsertEntry( String( SdResId( STR_EFFECT_NONE ) ) );
73 mpImpl->maPresets.push_back( pPreset );
75 const TransitionPresetList& rPresetList = TransitionPreset::getTransitionPresetList();
76 TransitionPresetList::const_iterator aIter;
77 for( aIter = rPresetList.begin(); aIter != rPresetList.end(); aIter++ )
79 pPreset = (*aIter);
80 const OUString aUIName( pPreset->getUIName() );
81 if( aUIName.getLength() )
83 InsertEntry( aUIName );
84 mpImpl->maPresets.push_back( pPreset );
88 SelectEntryPos(0);
91 // -----------------------------------------------------------------------------
94 void FadeEffectLB::SelectEffect( presentation::FadeEffect eFE )
96 BOOL bFound = FALSE;
98 for( long i = 0, nCount = sizeof( aEffects ) / sizeof( FadeEffectPair ); ( i < nCount ) && !bFound; i++ )
100 if( aEffects[ i ].meFE == eFE )
102 SelectEntryPos( (USHORT) i );
103 bFound = TRUE;
109 // -----------------------------------------------------------------------------
111 void FadeEffectLB::applySelected( SdPage* pSlide ) const
113 const USHORT nPos = GetSelectEntryPos();
115 if( pSlide && (nPos < mpImpl->maPresets.size() ) )
117 TransitionPresetPtr pPreset( mpImpl->maPresets[nPos] );
119 if( pPreset.get() )
121 pPreset->apply( pSlide );
123 else
125 pSlide->setTransitionType( 0 );
126 pSlide->setTransitionSubtype( 0 );
127 pSlide->setTransitionDirection( sal_True );
128 pSlide->setTransitionFadeColor( 0 );