xref: /trunk/main/sd/source/ui/dlg/dlgctrls.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
30 
31 #include <tools/ref.hxx>
32 #include <tools/debug.hxx>
33 
34 #include "strings.hrc"
35 #include "dlgctrls.hxx"
36 #include "sdresid.hxx"
37 #include "fadedef.h"
38 #include "sdpage.hxx"
39 
40 using namespace ::sd;
41 using namespace ::rtl;
42 
43 struct FadeEffectLBImpl
44 {
45     std::vector< TransitionPresetPtr > maPresets;
46 };
47 
48 FadeEffectLB::FadeEffectLB( Window* pParent, SdResId Id )
49 :   ListBox( pParent, Id ),
50     mpImpl( new FadeEffectLBImpl )
51 {
52 }
53 
54 FadeEffectLB::~FadeEffectLB()
55 {
56     delete mpImpl;
57 }
58 
59 void FadeEffectLB::Fill()
60 {
61     TransitionPresetPtr pPreset;
62 
63     InsertEntry( String( SdResId( STR_EFFECT_NONE ) ) );
64     mpImpl->maPresets.push_back( pPreset );
65 
66     const TransitionPresetList& rPresetList = TransitionPreset::getTransitionPresetList();
67     TransitionPresetList::const_iterator aIter;
68     for( aIter = rPresetList.begin(); aIter != rPresetList.end(); aIter++ )
69     {
70         pPreset = (*aIter);
71         const OUString aUIName( pPreset->getUIName() );
72         if( aUIName.getLength() )
73         {
74             InsertEntry( aUIName );
75             mpImpl->maPresets.push_back( pPreset );
76         }
77     }
78 
79     SelectEntryPos(0);
80 }
81 
82 // -----------------------------------------------------------------------------
83 
84 /*
85 void FadeEffectLB::SelectEffect( presentation::FadeEffect eFE )
86 {
87     sal_Bool bFound = sal_False;
88 
89     for( long i = 0, nCount = sizeof( aEffects ) / sizeof( FadeEffectPair ); ( i < nCount ) && !bFound; i++ )
90     {
91         if( aEffects[ i ].meFE == eFE )
92         {
93             SelectEntryPos( (sal_uInt16) i );
94             bFound = sal_True;
95         }
96     }
97 }
98 */
99 
100 // -----------------------------------------------------------------------------
101 
102 void FadeEffectLB::applySelected( SdPage* pSlide ) const
103 {
104     const sal_uInt16 nPos = GetSelectEntryPos();
105 
106     if( pSlide && (nPos < mpImpl->maPresets.size() ) )
107     {
108         TransitionPresetPtr pPreset( mpImpl->maPresets[nPos] );
109 
110         if( pPreset.get() )
111         {
112             pPreset->apply( pSlide );
113         }
114         else
115         {
116             pSlide->setTransitionType( 0 );
117             pSlide->setTransitionSubtype( 0 );
118             pSlide->setTransitionDirection( sal_True );
119             pSlide->setTransitionFadeColor( 0 );
120         }
121     }
122 }
123