xref: /aoo42x/main/sd/source/ui/dlg/dlgctrls.cxx (revision 79aad27f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 #include <tools/ref.hxx>
28 #include <tools/debug.hxx>
29 
30 #include "strings.hrc"
31 #include "dlgctrls.hxx"
32 #include "sdresid.hxx"
33 #include "fadedef.h"
34 #include "sdpage.hxx"
35 
36 using namespace ::sd;
37 using namespace ::rtl;
38 
39 struct FadeEffectLBImpl
40 {
41 	std::vector< TransitionPresetPtr > maPresets;
42 };
43 
FadeEffectLB(Window * pParent,SdResId Id)44 FadeEffectLB::FadeEffectLB( Window* pParent, SdResId Id )
45 :	ListBox( pParent, Id ),
46 	mpImpl( new FadeEffectLBImpl )
47 {
48 }
49 
~FadeEffectLB()50 FadeEffectLB::~FadeEffectLB()
51 {
52 	delete mpImpl;
53 }
54 
Fill()55 void FadeEffectLB::Fill()
56 {
57 	TransitionPresetPtr pPreset;
58 
59 	InsertEntry( String( SdResId( STR_EFFECT_NONE ) ) );
60 	mpImpl->maPresets.push_back( pPreset );
61 
62 	const TransitionPresetList& rPresetList = TransitionPreset::getTransitionPresetList();
63 	TransitionPresetList::const_iterator aIter;
64 	for( aIter = rPresetList.begin(); aIter != rPresetList.end(); aIter++ )
65 	{
66 		pPreset = (*aIter);
67 		const OUString aUIName( pPreset->getUIName() );
68 		if( aUIName.getLength() )
69 		{
70 			InsertEntry( aUIName );
71 			mpImpl->maPresets.push_back( pPreset );
72 		}
73 	}
74 
75 	SelectEntryPos(0);
76 }
77 
78 // -----------------------------------------------------------------------------
79 
80 /*
81 void FadeEffectLB::SelectEffect( presentation::FadeEffect eFE )
82 {
83 	sal_Bool bFound = sal_False;
84 
85 	for( long i = 0, nCount = sizeof( aEffects ) / sizeof( FadeEffectPair ); ( i < nCount ) && !bFound; i++ )
86 	{
87 		if( aEffects[ i ].meFE == eFE )
88 		{
89 			SelectEntryPos( (sal_uInt16) i );
90 			bFound = sal_True;
91 		}
92 	}
93 }
94 */
95 
96 // -----------------------------------------------------------------------------
97 
applySelected(SdPage * pSlide) const98 void FadeEffectLB::applySelected( SdPage* pSlide ) const
99 {
100 	const sal_uInt16 nPos = GetSelectEntryPos();
101 
102 	if( pSlide && (nPos < mpImpl->maPresets.size() ) )
103 	{
104 		TransitionPresetPtr pPreset( mpImpl->maPresets[nPos] );
105 
106 		if( pPreset.get() )
107 		{
108 			pPreset->apply( pSlide );
109 		}
110 		else
111 		{
112 			pSlide->setTransitionType( 0 );
113             pSlide->setTransitionSubtype( 0 );
114 			pSlide->setTransitionDirection( sal_True );
115 			pSlide->setTransitionFadeColor( 0 );
116 		}
117 	}
118 }
119