1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_framework.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #ifndef __FRAMEWORK_UIELEMENT_COMBOBOXTOOLBARCONTROLLER_HXX
32*cdf0e10cSrcweir #include "uielement/comboboxtoolbarcontroller.hxx"
33*cdf0e10cSrcweir #endif
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
36*cdf0e10cSrcweir //	my own includes
37*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #ifndef __FRAMEWORK_TOOLBAR_HXX_
40*cdf0e10cSrcweir #include "uielement/toolbar.hxx"
41*cdf0e10cSrcweir #endif
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
44*cdf0e10cSrcweir //	interface includes
45*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
46*cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp>
47*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp>
48*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
49*cdf0e10cSrcweir #include <com/sun/star/frame/status/ItemStatus.hpp>
50*cdf0e10cSrcweir #include <com/sun/star/frame/status/ItemState.hpp>
51*cdf0e10cSrcweir #include <com/sun/star/frame/status/Visibility.hpp>
52*cdf0e10cSrcweir #include <com/sun/star/frame/XControlNotificationListener.hpp>
53*cdf0e10cSrcweir #include <com/sun/star/util/Color.hpp>
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
56*cdf0e10cSrcweir //	other includes
57*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
58*cdf0e10cSrcweir #include <svtools/toolboxcontroller.hxx>
59*cdf0e10cSrcweir #include <vos/mutex.hxx>
60*cdf0e10cSrcweir #include <vcl/svapp.hxx>
61*cdf0e10cSrcweir #ifndef _VCL_MNEMONIC_HXX_
62*cdf0e10cSrcweir #include <vcl/mnemonic.hxx>
63*cdf0e10cSrcweir #endif
64*cdf0e10cSrcweir #include <vcl/toolbox.hxx>
65*cdf0e10cSrcweir #include <vcl/combobox.hxx>
66*cdf0e10cSrcweir #include <tools/urlobj.hxx>
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir using namespace ::com::sun::star;
69*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
70*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
71*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
72*cdf0e10cSrcweir using namespace ::com::sun::star::frame;
73*cdf0e10cSrcweir using namespace ::com::sun::star::frame::status;
74*cdf0e10cSrcweir using namespace ::com::sun::star::util;
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir namespace framework
77*cdf0e10cSrcweir {
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir // ------------------------------------------------------------------
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir // Wrapper class to notify controller about events from combobox.
82*cdf0e10cSrcweir // Unfortunaltly the events are notifed through virtual methods instead
83*cdf0e10cSrcweir // of Listeners.
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir class ComboBoxControl : public ComboBox
86*cdf0e10cSrcweir {
87*cdf0e10cSrcweir     public:
88*cdf0e10cSrcweir         ComboBoxControl( Window* pParent, WinBits nStyle, IComboBoxListener* pComboBoxListener );
89*cdf0e10cSrcweir         virtual ~ComboBoxControl();
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir         virtual void Select();
92*cdf0e10cSrcweir         virtual void DoubleClick();
93*cdf0e10cSrcweir         virtual void Modify();
94*cdf0e10cSrcweir         virtual void KeyInput( const ::KeyEvent& rKEvt );
95*cdf0e10cSrcweir 	    virtual void GetFocus();
96*cdf0e10cSrcweir 	    virtual void LoseFocus();
97*cdf0e10cSrcweir         virtual long PreNotify( NotifyEvent& rNEvt );
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir     private:
100*cdf0e10cSrcweir         IComboBoxListener* m_pComboBoxListener;
101*cdf0e10cSrcweir };
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir ComboBoxControl::ComboBoxControl( Window* pParent, WinBits nStyle, IComboBoxListener* pComboBoxListener ) :
104*cdf0e10cSrcweir     ComboBox( pParent, nStyle )
105*cdf0e10cSrcweir     , m_pComboBoxListener( pComboBoxListener )
106*cdf0e10cSrcweir {
107*cdf0e10cSrcweir }
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir ComboBoxControl::~ComboBoxControl()
110*cdf0e10cSrcweir {
111*cdf0e10cSrcweir     m_pComboBoxListener = 0;
112*cdf0e10cSrcweir }
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir void ComboBoxControl::Select()
115*cdf0e10cSrcweir {
116*cdf0e10cSrcweir     ComboBox::Select();
117*cdf0e10cSrcweir     if ( m_pComboBoxListener )
118*cdf0e10cSrcweir         m_pComboBoxListener->Select();
119*cdf0e10cSrcweir }
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir void ComboBoxControl::DoubleClick()
122*cdf0e10cSrcweir {
123*cdf0e10cSrcweir     ComboBox::DoubleClick();
124*cdf0e10cSrcweir     if ( m_pComboBoxListener )
125*cdf0e10cSrcweir         m_pComboBoxListener->DoubleClick();
126*cdf0e10cSrcweir }
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir void ComboBoxControl::Modify()
129*cdf0e10cSrcweir {
130*cdf0e10cSrcweir     ComboBox::Modify();
131*cdf0e10cSrcweir     if ( m_pComboBoxListener )
132*cdf0e10cSrcweir         m_pComboBoxListener->Modify();
133*cdf0e10cSrcweir }
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir void ComboBoxControl::KeyInput( const ::KeyEvent& rKEvt )
136*cdf0e10cSrcweir {
137*cdf0e10cSrcweir     ComboBox::KeyInput( rKEvt );
138*cdf0e10cSrcweir     if ( m_pComboBoxListener )
139*cdf0e10cSrcweir         m_pComboBoxListener->KeyInput( rKEvt );
140*cdf0e10cSrcweir }
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir void ComboBoxControl::GetFocus()
143*cdf0e10cSrcweir {
144*cdf0e10cSrcweir     ComboBox::GetFocus();
145*cdf0e10cSrcweir     if ( m_pComboBoxListener )
146*cdf0e10cSrcweir         m_pComboBoxListener->GetFocus();
147*cdf0e10cSrcweir }
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir void ComboBoxControl::LoseFocus()
150*cdf0e10cSrcweir {
151*cdf0e10cSrcweir     ComboBox::LoseFocus();
152*cdf0e10cSrcweir     if ( m_pComboBoxListener )
153*cdf0e10cSrcweir         m_pComboBoxListener->LoseFocus();
154*cdf0e10cSrcweir }
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir long ComboBoxControl::PreNotify( NotifyEvent& rNEvt )
157*cdf0e10cSrcweir {
158*cdf0e10cSrcweir     long nRet( 0 );
159*cdf0e10cSrcweir     if ( m_pComboBoxListener )
160*cdf0e10cSrcweir         nRet = m_pComboBoxListener->PreNotify( rNEvt );
161*cdf0e10cSrcweir     if ( nRet == 0 )
162*cdf0e10cSrcweir         nRet = ComboBox::PreNotify( rNEvt );
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir     return nRet;
165*cdf0e10cSrcweir }
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir // ------------------------------------------------------------------
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir ComboboxToolbarController::ComboboxToolbarController(
170*cdf0e10cSrcweir     const Reference< XMultiServiceFactory >& rServiceManager,
171*cdf0e10cSrcweir     const Reference< XFrame >&               rFrame,
172*cdf0e10cSrcweir     ToolBox*                                 pToolbar,
173*cdf0e10cSrcweir     sal_uInt16                                   nID,
174*cdf0e10cSrcweir     sal_Int32                                nWidth,
175*cdf0e10cSrcweir     const ::rtl::OUString&                          aCommand ) :
176*cdf0e10cSrcweir     ComplexToolbarController( rServiceManager, rFrame, pToolbar, nID, aCommand )
177*cdf0e10cSrcweir     ,   m_pComboBox( 0 )
178*cdf0e10cSrcweir {
179*cdf0e10cSrcweir     m_pComboBox = new ComboBoxControl( m_pToolbar, WB_DROPDOWN, this );
180*cdf0e10cSrcweir     if ( nWidth == 0 )
181*cdf0e10cSrcweir         nWidth = 100;
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir     // default dropdown size
184*cdf0e10cSrcweir     ::Size aLogicalSize( 8, 160 );
185*cdf0e10cSrcweir     ::Size aPixelSize = m_pComboBox->LogicToPixel( aLogicalSize, MAP_APPFONT );
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir     m_pComboBox->SetSizePixel( ::Size( nWidth, aPixelSize.Height() ));
188*cdf0e10cSrcweir     m_pToolbar->SetItemWindow( m_nID, m_pComboBox );
189*cdf0e10cSrcweir }
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir // ------------------------------------------------------------------
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir ComboboxToolbarController::~ComboboxToolbarController()
194*cdf0e10cSrcweir {
195*cdf0e10cSrcweir }
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir // ------------------------------------------------------------------
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir void SAL_CALL ComboboxToolbarController::dispose()
200*cdf0e10cSrcweir throw ( RuntimeException )
201*cdf0e10cSrcweir {
202*cdf0e10cSrcweir     vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir     m_pToolbar->SetItemWindow( m_nID, 0 );
205*cdf0e10cSrcweir     delete m_pComboBox;
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir     ComplexToolbarController::dispose();
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir     m_pComboBox = 0;
210*cdf0e10cSrcweir }
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir // ------------------------------------------------------------------
213*cdf0e10cSrcweir Sequence<PropertyValue> ComboboxToolbarController::getExecuteArgs(sal_Int16 KeyModifier) const
214*cdf0e10cSrcweir {
215*cdf0e10cSrcweir     Sequence<PropertyValue> aArgs( 2 );
216*cdf0e10cSrcweir     ::rtl::OUString aSelectedText = m_pComboBox->GetText();
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir     // Add key modifier to argument list
219*cdf0e10cSrcweir     aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "KeyModifier" ));
220*cdf0e10cSrcweir     aArgs[0].Value <<= KeyModifier;
221*cdf0e10cSrcweir     aArgs[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ));
222*cdf0e10cSrcweir     aArgs[1].Value <<= aSelectedText;
223*cdf0e10cSrcweir     return aArgs;
224*cdf0e10cSrcweir }
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir // ------------------------------------------------------------------
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir void ComboboxToolbarController::Select()
229*cdf0e10cSrcweir {
230*cdf0e10cSrcweir     if ( m_pComboBox->GetEntryCount() > 0 )
231*cdf0e10cSrcweir     {
232*cdf0e10cSrcweir         Window::PointerState aState = m_pComboBox->GetPointerState();
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir         sal_uInt16 nKeyModifier = sal_uInt16( aState.mnState & KEY_MODTYPE );
235*cdf0e10cSrcweir         execute( nKeyModifier );
236*cdf0e10cSrcweir     }
237*cdf0e10cSrcweir }
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir void ComboboxToolbarController::DoubleClick()
240*cdf0e10cSrcweir {
241*cdf0e10cSrcweir }
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir void ComboboxToolbarController::Modify()
244*cdf0e10cSrcweir {
245*cdf0e10cSrcweir     notifyTextChanged( m_pComboBox->GetText() );
246*cdf0e10cSrcweir }
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir void ComboboxToolbarController::KeyInput( const ::KeyEvent& )
249*cdf0e10cSrcweir {
250*cdf0e10cSrcweir }
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir void ComboboxToolbarController::GetFocus()
253*cdf0e10cSrcweir {
254*cdf0e10cSrcweir     notifyFocusGet();
255*cdf0e10cSrcweir }
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir void ComboboxToolbarController::LoseFocus()
258*cdf0e10cSrcweir {
259*cdf0e10cSrcweir     notifyFocusLost();
260*cdf0e10cSrcweir }
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir long ComboboxToolbarController::PreNotify( NotifyEvent& rNEvt )
263*cdf0e10cSrcweir {
264*cdf0e10cSrcweir     switch ( rNEvt.GetType() )
265*cdf0e10cSrcweir     {
266*cdf0e10cSrcweir         case EVENT_KEYINPUT :
267*cdf0e10cSrcweir             {
268*cdf0e10cSrcweir                 const ::KeyEvent* pKeyEvent = rNEvt.GetKeyEvent();
269*cdf0e10cSrcweir                 const KeyCode& rKeyCode = pKeyEvent->GetKeyCode();
270*cdf0e10cSrcweir                 if(( rKeyCode.GetModifier() | rKeyCode.GetCode()) == KEY_RETURN )
271*cdf0e10cSrcweir                 {
272*cdf0e10cSrcweir                     // Call execute only with non-empty text
273*cdf0e10cSrcweir                     if ( m_pComboBox->GetText().Len() > 0 )
274*cdf0e10cSrcweir                         execute( rKeyCode.GetModifier() );
275*cdf0e10cSrcweir                     return 1;
276*cdf0e10cSrcweir                 }
277*cdf0e10cSrcweir             }
278*cdf0e10cSrcweir             break;
279*cdf0e10cSrcweir         case EVENT_GETFOCUS :
280*cdf0e10cSrcweir             notifyFocusGet();
281*cdf0e10cSrcweir             break;
282*cdf0e10cSrcweir         case EVENT_LOSEFOCUS :
283*cdf0e10cSrcweir             notifyFocusLost();
284*cdf0e10cSrcweir             break;
285*cdf0e10cSrcweir         default :
286*cdf0e10cSrcweir             break;
287*cdf0e10cSrcweir     }
288*cdf0e10cSrcweir     return 0;
289*cdf0e10cSrcweir }
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir // --------------------------------------------------------
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir void ComboboxToolbarController::executeControlCommand( const ::com::sun::star::frame::ControlCommand& rControlCommand )
294*cdf0e10cSrcweir {
295*cdf0e10cSrcweir     if ( rControlCommand.Command.equalsAsciiL( "SetText", 7 ))
296*cdf0e10cSrcweir     {
297*cdf0e10cSrcweir         for ( sal_Int32 i = 0; i < rControlCommand.Arguments.getLength(); i++ )
298*cdf0e10cSrcweir         {
299*cdf0e10cSrcweir             if ( rControlCommand.Arguments[i].Name.equalsAsciiL( "Text", 4 ))
300*cdf0e10cSrcweir             {
301*cdf0e10cSrcweir                 rtl::OUString aText;
302*cdf0e10cSrcweir                 rControlCommand.Arguments[i].Value >>= aText;
303*cdf0e10cSrcweir                 m_pComboBox->SetText( aText );
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir                 // send notification
306*cdf0e10cSrcweir                 notifyTextChanged( aText );
307*cdf0e10cSrcweir                 break;
308*cdf0e10cSrcweir             }
309*cdf0e10cSrcweir         }
310*cdf0e10cSrcweir     }
311*cdf0e10cSrcweir     else if ( rControlCommand.Command.equalsAsciiL( "SetList", 7 ))
312*cdf0e10cSrcweir     {
313*cdf0e10cSrcweir         for ( sal_Int32 i = 0; i < rControlCommand.Arguments.getLength(); i++ )
314*cdf0e10cSrcweir         {
315*cdf0e10cSrcweir             if ( rControlCommand.Arguments[i].Name.equalsAsciiL( "List", 4 ))
316*cdf0e10cSrcweir             {
317*cdf0e10cSrcweir                 Sequence< ::rtl::OUString > aList;
318*cdf0e10cSrcweir                 m_pComboBox->Clear();
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir                 rControlCommand.Arguments[i].Value >>= aList;
321*cdf0e10cSrcweir                 for ( sal_Int32 j = 0; j < aList.getLength(); j++ )
322*cdf0e10cSrcweir                     m_pComboBox->InsertEntry( aList[j] );
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir                 // send notification
325*cdf0e10cSrcweir                 uno::Sequence< beans::NamedValue > aInfo( 1 );
326*cdf0e10cSrcweir                 aInfo[0].Name  = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ));
327*cdf0e10cSrcweir                 aInfo[0].Value <<= aList;
328*cdf0e10cSrcweir                 addNotifyInfo( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ListChanged" )),
329*cdf0e10cSrcweir                                getDispatchFromCommand( m_aCommandURL ),
330*cdf0e10cSrcweir                                aInfo );
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir                 break;
333*cdf0e10cSrcweir             }
334*cdf0e10cSrcweir         }
335*cdf0e10cSrcweir     }
336*cdf0e10cSrcweir     else if ( rControlCommand.Command.equalsAsciiL( "AddEntry", 8 ))
337*cdf0e10cSrcweir     {
338*cdf0e10cSrcweir         sal_uInt16      nPos( COMBOBOX_APPEND );
339*cdf0e10cSrcweir         rtl::OUString   aText;
340*cdf0e10cSrcweir         for ( sal_Int32 i = 0; i < rControlCommand.Arguments.getLength(); i++ )
341*cdf0e10cSrcweir         {
342*cdf0e10cSrcweir             if ( rControlCommand.Arguments[i].Name.equalsAsciiL( "Text", 4 ))
343*cdf0e10cSrcweir             {
344*cdf0e10cSrcweir                 if ( rControlCommand.Arguments[i].Value >>= aText )
345*cdf0e10cSrcweir                     m_pComboBox->InsertEntry( aText, nPos );
346*cdf0e10cSrcweir                 break;
347*cdf0e10cSrcweir             }
348*cdf0e10cSrcweir         }
349*cdf0e10cSrcweir     }
350*cdf0e10cSrcweir     else if ( rControlCommand.Command.equalsAsciiL( "InsertEntry", 11 ))
351*cdf0e10cSrcweir     {
352*cdf0e10cSrcweir         sal_uInt16      nPos( COMBOBOX_APPEND );
353*cdf0e10cSrcweir         rtl::OUString   aText;
354*cdf0e10cSrcweir         for ( sal_Int32 i = 0; i < rControlCommand.Arguments.getLength(); i++ )
355*cdf0e10cSrcweir         {
356*cdf0e10cSrcweir             if ( rControlCommand.Arguments[i].Name.equalsAsciiL( "Pos", 3 ))
357*cdf0e10cSrcweir             {
358*cdf0e10cSrcweir                 sal_Int32 nTmpPos = 0;
359*cdf0e10cSrcweir                 if ( rControlCommand.Arguments[i].Value >>= nTmpPos )
360*cdf0e10cSrcweir                 {
361*cdf0e10cSrcweir                     if (( nTmpPos >= 0 ) &&
362*cdf0e10cSrcweir                         ( nTmpPos < sal_Int32( m_pComboBox->GetEntryCount() )))
363*cdf0e10cSrcweir                         nPos = sal_uInt16( nTmpPos );
364*cdf0e10cSrcweir                 }
365*cdf0e10cSrcweir             }
366*cdf0e10cSrcweir             else if ( rControlCommand.Arguments[i].Name.equalsAsciiL( "Text", 4 ))
367*cdf0e10cSrcweir                 rControlCommand.Arguments[i].Value >>= aText;
368*cdf0e10cSrcweir         }
369*cdf0e10cSrcweir 
370*cdf0e10cSrcweir         m_pComboBox->InsertEntry( aText, nPos );
371*cdf0e10cSrcweir     }
372*cdf0e10cSrcweir     else if ( rControlCommand.Command.equalsAsciiL( "RemoveEntryPos", 14 ))
373*cdf0e10cSrcweir     {
374*cdf0e10cSrcweir         for ( sal_Int32 i = 0; i < rControlCommand.Arguments.getLength(); i++ )
375*cdf0e10cSrcweir         {
376*cdf0e10cSrcweir             if ( rControlCommand.Arguments[i].Name.equalsAsciiL( "Pos", 3 ))
377*cdf0e10cSrcweir             {
378*cdf0e10cSrcweir                 sal_Int32 nPos( -1 );
379*cdf0e10cSrcweir                 if ( rControlCommand.Arguments[i].Value >>= nPos )
380*cdf0e10cSrcweir                 {
381*cdf0e10cSrcweir                     if ( nPos < sal_Int32( m_pComboBox->GetEntryCount() ))
382*cdf0e10cSrcweir                         m_pComboBox->RemoveEntry( sal_uInt16( nPos ));
383*cdf0e10cSrcweir                 }
384*cdf0e10cSrcweir                 break;
385*cdf0e10cSrcweir             }
386*cdf0e10cSrcweir         }
387*cdf0e10cSrcweir     }
388*cdf0e10cSrcweir     else if ( rControlCommand.Command.equalsAsciiL( "RemoveEntryText", 15 ))
389*cdf0e10cSrcweir     {
390*cdf0e10cSrcweir         for ( sal_Int32 i = 0; i < rControlCommand.Arguments.getLength(); i++ )
391*cdf0e10cSrcweir         {
392*cdf0e10cSrcweir             if ( rControlCommand.Arguments[i].Name.equalsAsciiL( "Text", 4 ))
393*cdf0e10cSrcweir             {
394*cdf0e10cSrcweir                 rtl::OUString aText;
395*cdf0e10cSrcweir                 if ( rControlCommand.Arguments[i].Value >>= aText )
396*cdf0e10cSrcweir                     m_pComboBox->RemoveEntry( aText );
397*cdf0e10cSrcweir                 break;
398*cdf0e10cSrcweir             }
399*cdf0e10cSrcweir         }
400*cdf0e10cSrcweir     }
401*cdf0e10cSrcweir     else if ( rControlCommand.Command.equalsAsciiL( "SetDropDownLines", 16 ))
402*cdf0e10cSrcweir     {
403*cdf0e10cSrcweir         for ( sal_Int32 i = 0; i < rControlCommand.Arguments.getLength(); i++ )
404*cdf0e10cSrcweir         {
405*cdf0e10cSrcweir             if ( rControlCommand.Arguments[i].Name.equalsAsciiL( "Lines", 5 ))
406*cdf0e10cSrcweir             {
407*cdf0e10cSrcweir                 sal_Int32 nValue( 5 );
408*cdf0e10cSrcweir                 rControlCommand.Arguments[i].Value >>= nValue;
409*cdf0e10cSrcweir                 m_pComboBox->SetDropDownLineCount( sal_uInt16( nValue ));
410*cdf0e10cSrcweir                 break;
411*cdf0e10cSrcweir             }
412*cdf0e10cSrcweir         }
413*cdf0e10cSrcweir     }
414*cdf0e10cSrcweir     else if ( rControlCommand.Command.equalsAsciiL( "SetBackgroundColor", 18 ))
415*cdf0e10cSrcweir     {
416*cdf0e10cSrcweir         for ( sal_Int32 i = 0; i < rControlCommand.Arguments.getLength(); i++ )
417*cdf0e10cSrcweir         {
418*cdf0e10cSrcweir             if ( rControlCommand.Arguments[i].Name.equalsAsciiL( "Color", 5 ))
419*cdf0e10cSrcweir             {
420*cdf0e10cSrcweir                 com::sun::star::util::Color aColor(0);
421*cdf0e10cSrcweir                 if ( rControlCommand.Arguments[i].Value >>= aColor )
422*cdf0e10cSrcweir                 {
423*cdf0e10cSrcweir                     ::Color aBackColor( static_cast< sal_uInt32 >( aColor ));
424*cdf0e10cSrcweir                     m_pComboBox->SetControlBackground( aBackColor );
425*cdf0e10cSrcweir                 }
426*cdf0e10cSrcweir                 break;
427*cdf0e10cSrcweir             }
428*cdf0e10cSrcweir         }
429*cdf0e10cSrcweir     }
430*cdf0e10cSrcweir     else if ( rControlCommand.Command.equalsAsciiL( "SetTextColor", 12 ))
431*cdf0e10cSrcweir     {
432*cdf0e10cSrcweir         for ( sal_Int32 i = 0; i < rControlCommand.Arguments.getLength(); i++ )
433*cdf0e10cSrcweir         {
434*cdf0e10cSrcweir             if ( rControlCommand.Arguments[i].Name.equalsAsciiL( "Color", 5 ))
435*cdf0e10cSrcweir             {
436*cdf0e10cSrcweir                 com::sun::star::util::Color aColor(0);
437*cdf0e10cSrcweir                 if ( rControlCommand.Arguments[i].Value >>= aColor )
438*cdf0e10cSrcweir                 {
439*cdf0e10cSrcweir                     ::Color aForeColor( static_cast< sal_uInt32 >( aColor ));
440*cdf0e10cSrcweir                     m_pComboBox->SetControlForeground( aForeColor );
441*cdf0e10cSrcweir                 }
442*cdf0e10cSrcweir                 break;
443*cdf0e10cSrcweir             }
444*cdf0e10cSrcweir         }
445*cdf0e10cSrcweir     }
446*cdf0e10cSrcweir }
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir } // namespace
449*cdf0e10cSrcweir 
450