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 <vcl/builderfactory.hxx>
21 :
22 : #include "strings.hrc"
23 : #include "dlgctrls.hxx"
24 : #include "sdresid.hxx"
25 : #include "fadedef.h"
26 : #include "sdpage.hxx"
27 :
28 : using namespace ::sd;
29 :
30 0 : struct FadeEffectLBImpl
31 : {
32 : std::vector< TransitionPresetPtr > maPresets;
33 : };
34 :
35 0 : FadeEffectLB::FadeEffectLB(vcl::Window* pParent, WinBits nStyle)
36 : : ListBox(pParent, nStyle)
37 0 : , mpImpl(new FadeEffectLBImpl)
38 : {
39 0 : }
40 :
41 0 : FadeEffectLB::~FadeEffectLB()
42 : {
43 0 : disposeOnce();
44 0 : }
45 :
46 0 : void FadeEffectLB::dispose()
47 : {
48 0 : delete mpImpl;
49 0 : ListBox::dispose();
50 0 : }
51 :
52 0 : void FadeEffectLB::Fill()
53 : {
54 0 : TransitionPresetPtr pPreset;
55 :
56 0 : InsertEntry( SD_RESSTR( STR_EFFECT_NONE ) );
57 0 : mpImpl->maPresets.push_back( pPreset );
58 :
59 0 : const TransitionPresetList& rPresetList = TransitionPreset::getTransitionPresetList();
60 0 : TransitionPresetList::const_iterator aIter;
61 0 : for( aIter = rPresetList.begin(); aIter != rPresetList.end(); ++aIter )
62 : {
63 0 : pPreset = (*aIter);
64 0 : const OUString aUIName( pPreset->getUIName() );
65 0 : if( !aUIName.isEmpty() )
66 : {
67 0 : InsertEntry( aUIName );
68 0 : mpImpl->maPresets.push_back( pPreset );
69 : }
70 0 : }
71 :
72 0 : SelectEntryPos(0);
73 0 : }
74 :
75 0 : VCL_BUILDER_DECL_FACTORY(FadeEffectLB)
76 : {
77 0 : WinBits nBits = WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK;
78 :
79 0 : bool bDropdown = VclBuilder::extractDropdown(rMap);
80 :
81 0 : if (bDropdown)
82 0 : nBits |= WB_DROPDOWN;
83 :
84 0 : rRet = VclPtr<FadeEffectLB>::Create(pParent, nBits);
85 0 : }
86 :
87 0 : void FadeEffectLB::applySelected( SdPage* pSlide ) const
88 : {
89 0 : const sal_uInt16 nPos = GetSelectEntryPos();
90 :
91 0 : if( pSlide && (nPos < mpImpl->maPresets.size() ) )
92 : {
93 0 : TransitionPresetPtr pPreset( mpImpl->maPresets[nPos] );
94 :
95 0 : if( pPreset.get() )
96 : {
97 0 : pPreset->apply( pSlide );
98 : }
99 : else
100 : {
101 0 : pSlide->setTransitionType( 0 );
102 0 : pSlide->setTransitionSubtype( 0 );
103 0 : pSlide->setTransitionDirection( true );
104 0 : pSlide->setTransitionFadeColor( 0 );
105 0 : }
106 : }
107 0 : }
108 :
109 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|