xref: /trunk/main/toolkit/source/awt/vclxwindows.cxx (revision c3ef676a)
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_toolkit.hxx"
26 #include <toolkit/awt/vclxwindows.hxx>
27 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
28 #include <com/sun/star/graphic/XGraphicProvider.hpp>
29 #include <toolkit/helper/vclunohelper.hxx>
30 #include <toolkit/helper/macros.hxx>
31 #include <toolkit/helper/property.hxx>
32 #include <toolkit/helper/convert.hxx>
33 #include <toolkit/helper/imagealign.hxx>
34 #include <toolkit/helper/accessibilityclient.hxx>
35 #include <toolkit/helper/fixedhyperbase.hxx>
36 #include <toolkit/helper/tkresmgr.hxx>
37 #include <cppuhelper/typeprovider.hxx>
38 #include <com/sun/star/awt/VisualEffect.hpp>
39 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
40 #include <com/sun/star/system/SystemShellExecute.hpp>
41 #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
42 #include <com/sun/star/resource/XStringResourceResolver.hpp>
43 #include <com/sun/star/awt/ImageScaleMode.hpp>
44 #include <com/sun/star/awt/XItemList.hpp>
45 #include <comphelper/componentcontext.hxx>
46 #include <comphelper/namedvaluecollection.hxx>
47 #include <comphelper/processfactory.hxx>
48 
49 #ifndef _SV_BUTTON_HXX
50 #include <vcl/button.hxx>
51 #endif
52 #include <vcl/lstbox.hxx>
53 #include <vcl/combobox.hxx>
54 #include <vcl/field.hxx>
55 #include <vcl/longcurr.hxx>
56 #include <vcl/imgctrl.hxx>
57 #include <vcl/dialog.hxx>
58 #include <vcl/msgbox.hxx>
59 #include <vcl/scrbar.hxx>
60 #include <vcl/svapp.hxx>
61 #include <vcl/tabpage.hxx>
62 #include <vcl/tabctrl.hxx>
63 #include <tools/diagnose_ex.h>
64 
65 #include <boost/bind.hpp>
66 #include <boost/function.hpp>
67 
68 using ::com::sun::star::uno::Any;
69 using ::com::sun::star::uno::Reference;
70 using ::com::sun::star::uno::makeAny;
71 using ::com::sun::star::uno::RuntimeException;
72 using ::com::sun::star::lang::EventObject;
73 using ::com::sun::star::awt::ItemListEvent;
74 using ::com::sun::star::awt::XItemList;
75 using ::com::sun::star::graphic::XGraphic;
76 using ::com::sun::star::graphic::XGraphicProvider;
77 
78 using namespace ::com::sun::star;
79 using namespace ::com::sun::star::awt::VisualEffect;
80 namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode;
81 
ImplCalcLongValue(double nValue,sal_uInt16 nDigits)82 static double ImplCalcLongValue( double nValue, sal_uInt16 nDigits )
83 {
84 	double n = nValue;
85 	for ( sal_uInt16 d = 0; d < nDigits; d++ )
86 		n *= 10;
87 	return n;
88 }
89 
ImplCalcDoubleValue(double nValue,sal_uInt16 nDigits)90 static double ImplCalcDoubleValue( double nValue, sal_uInt16 nDigits )
91 {
92 	double n = nValue;
93 	for ( sal_uInt16 d = 0; d < nDigits; d++ )
94 		n /= 10;
95 	return n;
96 }
97 
98 namespace toolkit
99 {
100     /** sets the "face color" for button like controls (scroll bar, spin button)
101     */
setButtonLikeFaceColor(Window * _pWindow,const::com::sun::star::uno::Any & _rColorValue)102     void setButtonLikeFaceColor( Window* _pWindow, const ::com::sun::star::uno::Any& _rColorValue )
103     {
104         AllSettings aSettings = _pWindow->GetSettings();
105 	    StyleSettings aStyleSettings = aSettings.GetStyleSettings();
106 
107         if ( !_rColorValue.hasValue() )
108         {
109 	        const StyleSettings& aAppStyle = Application::GetSettings().GetStyleSettings();
110             aStyleSettings.SetFaceColor( aAppStyle.GetFaceColor( ) );
111             aStyleSettings.SetCheckedColor( aAppStyle.GetCheckedColor( ) );
112             aStyleSettings.SetLightBorderColor( aAppStyle.GetLightBorderColor() );
113             aStyleSettings.SetLightColor( aAppStyle.GetLightColor() );
114             aStyleSettings.SetShadowColor( aAppStyle.GetShadowColor() );
115             aStyleSettings.SetDarkShadowColor( aAppStyle.GetDarkShadowColor() );
116         }
117         else
118         {
119 			sal_Int32 nBackgroundColor = 0;
120             _rColorValue >>= nBackgroundColor;
121             aStyleSettings.SetFaceColor( nBackgroundColor );
122 
123             // for the real background (everything except the buttons and the thumb),
124             // use an average between the desired color and "white"
125             Color aWhite( COL_WHITE );
126             Color aBackground( nBackgroundColor );
127             aBackground.SetRed( ( aBackground.GetRed() + aWhite.GetRed() ) / 2 );
128             aBackground.SetGreen( ( aBackground.GetGreen() + aWhite.GetGreen() ) / 2 );
129             aBackground.SetBlue( ( aBackground.GetBlue() + aWhite.GetBlue() ) / 2 );
130             aStyleSettings.SetCheckedColor( aBackground );
131 
132             sal_Int32 nBackgroundLuminance = Color( nBackgroundColor ).GetLuminance();
133             sal_Int32 nWhiteLuminance = Color( COL_WHITE ).GetLuminance();
134 
135             Color aLightShadow( nBackgroundColor );
136             aLightShadow.IncreaseLuminance( (sal_uInt8)( ( nWhiteLuminance - nBackgroundLuminance ) * 2 / 3 ) );
137             aStyleSettings.SetLightBorderColor( aLightShadow );
138 
139             Color aLight( nBackgroundColor );
140             aLight.IncreaseLuminance( (sal_uInt8)( ( nWhiteLuminance - nBackgroundLuminance ) * 1 / 3 ) );
141             aStyleSettings.SetLightColor( aLight );
142 
143             Color aShadow( nBackgroundColor );
144             aShadow.DecreaseLuminance( (sal_uInt8)( nBackgroundLuminance * 1 / 3 ) );
145             aStyleSettings.SetShadowColor( aShadow );
146 
147             Color aDarkShadow( nBackgroundColor );
148             aDarkShadow.DecreaseLuminance( (sal_uInt8)( nBackgroundLuminance * 2 / 3 ) );
149             aStyleSettings.SetDarkShadowColor( aDarkShadow );
150         }
151 
152         aSettings.SetStyleSettings( aStyleSettings );
153         _pWindow->SetSettings( aSettings, sal_True );
154     }
155 
getButtonLikeFaceColor(const Window * _pWindow)156     Any getButtonLikeFaceColor( const Window* _pWindow )
157     {
158 		sal_Int32 nBackgroundColor = _pWindow->GetSettings().GetStyleSettings().GetFaceColor().GetColor();
159         return makeAny( nBackgroundColor );
160     }
161 
adjustBooleanWindowStyle(const Any & _rValue,Window * _pWindow,WinBits _nBits,sal_Bool _bInverseSemantics)162     static void adjustBooleanWindowStyle( const Any& _rValue, Window* _pWindow, WinBits _nBits, sal_Bool _bInverseSemantics )
163     {
164         WinBits nStyle = _pWindow->GetStyle();
165         sal_Bool bValue( sal_False );
166         OSL_VERIFY( _rValue >>= bValue );
167         if ( bValue != _bInverseSemantics )
168             nStyle |= _nBits;
169         else
170             nStyle &= ~_nBits;
171         _pWindow->SetStyle( nStyle );
172     }
173 
setVisualEffect(const Any & _rValue,Window * _pWindow)174     static void setVisualEffect( const Any& _rValue, Window* _pWindow )
175     {
176         AllSettings aSettings = _pWindow->GetSettings();
177 	    StyleSettings aStyleSettings = aSettings.GetStyleSettings();
178 
179         sal_Int16 nStyle = LOOK3D;
180         OSL_VERIFY( _rValue >>= nStyle );
181         switch ( nStyle )
182         {
183         case FLAT:
184             aStyleSettings.SetOptions( aStyleSettings.GetOptions() & ~STYLE_OPTION_MONO );
185             break;
186         case LOOK3D:
187         default:
188             aStyleSettings.SetOptions( aStyleSettings.GetOptions() | STYLE_OPTION_MONO );
189         }
190         aSettings.SetStyleSettings( aStyleSettings );
191         _pWindow->SetSettings( aSettings );
192     }
193 
getVisualEffect(Window * _pWindow)194     static Any getVisualEffect( Window* _pWindow )
195     {
196         Any aEffect;
197 
198         StyleSettings aStyleSettings = _pWindow->GetSettings().GetStyleSettings();
199         if ( (aStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
200             aEffect <<= (sal_Int16)FLAT;
201         else
202             aEffect <<= (sal_Int16)LOOK3D;
203         return aEffect;
204     }
205 }
206 
207 //	----------------------------------------------------
208 //	class VCLXGraphicControl
209 //	----------------------------------------------------
210 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)211 void VCLXGraphicControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
212 {
213     VCLXWindow::ImplGetPropertyIds( rIds );
214 }
215 
ImplSetNewImage()216 void VCLXGraphicControl::ImplSetNewImage()
217 {
218     OSL_PRECOND( GetWindow(), "VCLXGraphicControl::ImplSetNewImage: window is required to be not-NULL!" );
219 	Button* pButton = static_cast< Button* >( GetWindow() );
220 	pButton->SetModeImage( GetImage() );
221 }
222 
setPosSize(sal_Int32 X,sal_Int32 Y,sal_Int32 Width,sal_Int32 Height,short Flags)223 void VCLXGraphicControl::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, short Flags ) throw(::com::sun::star::uno::RuntimeException)
224 {
225 	::vos::OGuard aGuard( GetMutex() );
226 
227 	if ( GetWindow() )
228 	{
229 		Size aOldSize = GetWindow()->GetSizePixel();
230 		VCLXWindow::setPosSize( X, Y, Width, Height, Flags );
231 		if ( ( aOldSize.Width() != Width ) || ( aOldSize.Height() != Height ) )
232 			ImplSetNewImage();
233 	}
234 }
235 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)236 void VCLXGraphicControl::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
237 {
238 	::vos::OGuard aGuard( GetMutex() );
239 
240 	Button* pButton = static_cast< Button* >( GetWindow() );
241     if ( !pButton )
242         return;
243     sal_uInt16 nPropType = GetPropertyId( PropertyName );
244     switch ( nPropType )
245     {
246         case BASEPROPERTY_GRAPHIC:
247         {
248             Reference< XGraphic > xGraphic;
249             OSL_VERIFY( Value >>= xGraphic );
250             maImage = Image( xGraphic );
251             ImplSetNewImage();
252         }
253         break;
254 
255         case BASEPROPERTY_IMAGEALIGN:
256         {
257             WindowType eType = GetWindow()->GetType();
258             if (  ( eType == WINDOW_PUSHBUTTON )
259                || ( eType == WINDOW_RADIOBUTTON )
260                || ( eType == WINDOW_CHECKBOX )
261                )
262             {
263                 sal_Int16 nAlignment = sal_Int16();
264                 if ( Value >>= nAlignment )
265                     pButton->SetImageAlign( static_cast< ImageAlign >( nAlignment ) );
266             }
267         }
268         break;
269         case BASEPROPERTY_IMAGEPOSITION:
270         {
271             WindowType eType = GetWindow()->GetType();
272             if (  ( eType == WINDOW_PUSHBUTTON )
273                || ( eType == WINDOW_RADIOBUTTON )
274                || ( eType == WINDOW_CHECKBOX )
275                )
276             {
277                 sal_Int16 nImagePosition = 2;
278                 OSL_VERIFY( Value >>= nImagePosition );
279                 pButton->SetImageAlign( ::toolkit::translateImagePosition( nImagePosition ) );
280             }
281         }
282         break;
283         default:
284             VCLXWindow::setProperty( PropertyName, Value );
285             break;
286 	}
287 }
288 
getProperty(const::rtl::OUString & PropertyName)289 ::com::sun::star::uno::Any VCLXGraphicControl::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
290 {
291 	::vos::OGuard aGuard( GetMutex() );
292 
293 	::com::sun::star::uno::Any aProp;
294     if ( !GetWindow() )
295         return aProp;
296 
297     sal_uInt16 nPropType = GetPropertyId( PropertyName );
298 	switch ( nPropType )
299 	{
300         case BASEPROPERTY_GRAPHIC:
301             aProp <<= maImage.GetXGraphic();
302             break;
303 		case BASEPROPERTY_IMAGEALIGN:
304 		{
305             WindowType eType = GetWindow()->GetType();
306             if  (  ( eType == WINDOW_PUSHBUTTON )
307                 || ( eType == WINDOW_RADIOBUTTON )
308                 || ( eType == WINDOW_CHECKBOX )
309                 )
310             {
311  				aProp <<= ::toolkit::getCompatibleImageAlign( static_cast< Button* >( GetWindow() )->GetImageAlign() );
312             }
313 		}
314 		break;
315 		case BASEPROPERTY_IMAGEPOSITION:
316         {
317             WindowType eType = GetWindow()->GetType();
318             if  (  ( eType == WINDOW_PUSHBUTTON )
319                 || ( eType == WINDOW_RADIOBUTTON )
320                 || ( eType == WINDOW_CHECKBOX )
321                 )
322             {
323                 aProp <<= ::toolkit::translateImagePosition( static_cast< Button* >( GetWindow() )->GetImageAlign() );
324             }
325         }
326         break;
327 		default:
328 		{
329 			aProp <<= VCLXWindow::getProperty( PropertyName );
330 		}
331         break;
332 	}
333 	return aProp;
334 }
335 
336 //--------------------------------------------------------------------
337 //	class VCLXButton
338 //	----------------------------------------------------
339 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)340 void VCLXButton::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
341 {
342     PushPropertyIds( rIds,
343                      BASEPROPERTY_BACKGROUNDCOLOR,
344                      BASEPROPERTY_DEFAULTBUTTON,
345                      BASEPROPERTY_DEFAULTCONTROL,
346                      BASEPROPERTY_ENABLED,
347                      BASEPROPERTY_ENABLEVISIBLE,
348                      BASEPROPERTY_FONTDESCRIPTOR,
349                      BASEPROPERTY_GRAPHIC,
350                      BASEPROPERTY_HELPTEXT,
351                      BASEPROPERTY_HELPURL,
352                      BASEPROPERTY_IMAGEALIGN,
353                      BASEPROPERTY_IMAGEPOSITION,
354                      BASEPROPERTY_IMAGEURL,
355                      BASEPROPERTY_LABEL,
356                      BASEPROPERTY_PRINTABLE,
357                      BASEPROPERTY_PUSHBUTTONTYPE,
358                      BASEPROPERTY_REPEAT,
359                      BASEPROPERTY_REPEAT_DELAY,
360                      BASEPROPERTY_STATE,
361                      BASEPROPERTY_TABSTOP,
362                      BASEPROPERTY_TOGGLE,
363                      BASEPROPERTY_FOCUSONCLICK,
364                      BASEPROPERTY_MULTILINE,
365                      BASEPROPERTY_ALIGN,
366                      BASEPROPERTY_VERTICALALIGN,
367                      BASEPROPERTY_WRITING_MODE,
368                      BASEPROPERTY_CONTEXT_WRITING_MODE,
369                      BASEPROPERTY_REFERENCE_DEVICE,
370                      0);
371     VCLXGraphicControl::ImplGetPropertyIds( rIds );
372 }
373 
VCLXButton()374 VCLXButton::VCLXButton()
375     :maActionListeners( *this )
376     ,maItemListeners( *this )
377 {
378 }
379 
~VCLXButton()380 VCLXButton::~VCLXButton()
381 {
382 }
383 
CreateAccessibleContext()384 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXButton::CreateAccessibleContext()
385 {
386     return getAccessibleFactory().createAccessibleContext( this );
387 }
388 
dispose()389 void VCLXButton::dispose() throw(::com::sun::star::uno::RuntimeException)
390 {
391 	::vos::OGuard aGuard( GetMutex() );
392 
393 	::com::sun::star::lang::EventObject aObj;
394 	aObj.Source = (::cppu::OWeakObject*)this;
395 	maActionListeners.disposeAndClear( aObj );
396 	maItemListeners.disposeAndClear( aObj );
397 	VCLXGraphicControl::dispose();
398 }
399 
addActionListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XActionListener> & l)400 void VCLXButton::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l  )throw(::com::sun::star::uno::RuntimeException)
401 {
402 	::vos::OGuard aGuard( GetMutex() );
403 	maActionListeners.addInterface( l );
404 }
405 
removeActionListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XActionListener> & l)406 void VCLXButton::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException)
407 {
408 	::vos::OGuard aGuard( GetMutex() );
409 	maActionListeners.removeInterface( l );
410 }
411 
addItemListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XItemListener> & l)412 void VCLXButton::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l  )throw(::com::sun::star::uno::RuntimeException)
413 {
414 	::vos::OGuard aGuard( GetMutex() );
415 	maItemListeners.addInterface( l );
416 }
417 
removeItemListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XItemListener> & l)418 void VCLXButton::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException)
419 {
420 	::vos::OGuard aGuard( GetMutex() );
421 	maItemListeners.removeInterface( l );
422 }
423 
setLabel(const::rtl::OUString & rLabel)424 void VCLXButton::setLabel( const ::rtl::OUString& rLabel ) throw(::com::sun::star::uno::RuntimeException)
425 {
426 	::vos::OGuard aGuard( GetMutex() );
427 
428 	Window* pWindow = GetWindow();
429 	if ( pWindow )
430 		pWindow->SetText( rLabel );
431 }
432 
setActionCommand(const::rtl::OUString & rCommand)433 void VCLXButton::setActionCommand( const ::rtl::OUString& rCommand ) throw(::com::sun::star::uno::RuntimeException)
434 {
435 	::vos::OGuard aGuard( GetMutex() );
436 
437 	maActionCommand = rCommand;
438 }
439 
getMinimumSize()440 ::com::sun::star::awt::Size VCLXButton::getMinimumSize(  ) throw(::com::sun::star::uno::RuntimeException)
441 {
442 	::vos::OGuard aGuard( GetMutex() );
443 
444 	Size aSz;
445 	PushButton* pButton = (PushButton*) GetWindow();
446 	if ( pButton )
447 		aSz = pButton->CalcMinimumSize();
448 	return AWTSize(aSz);
449 }
450 
getPreferredSize()451 ::com::sun::star::awt::Size VCLXButton::getPreferredSize(  ) throw(::com::sun::star::uno::RuntimeException)
452 {
453 	::com::sun::star::awt::Size aSz = getMinimumSize();
454 	aSz.Width += 16;
455 	aSz.Height += 10;
456 	return aSz;
457 }
458 
calcAdjustedSize(const::com::sun::star::awt::Size & rNewSize)459 ::com::sun::star::awt::Size VCLXButton::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException)
460 {
461 	::vos::OGuard aGuard( GetMutex() );
462 
463 	Size aSz = VCLSize(rNewSize);
464 	PushButton* pButton = (PushButton*) GetWindow();
465 	if ( pButton )
466 	{
467 		Size aMinSz = pButton->CalcMinimumSize();
468 		// Kein Text, also Image
469 		if ( !pButton->GetText().Len() )
470 		{
471 			if ( aSz.Width() < aMinSz.Width() )
472 				aSz.Width() = aMinSz.Width();
473 			if ( aSz.Height() < aMinSz.Height() )
474 				aSz.Height() = aMinSz.Height();
475 		}
476 		else
477 		{
478 			if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
479 				aSz.Height() = aMinSz.Height();
480 			else
481 				aSz = aMinSz;
482 		}
483 	}
484 	return AWTSize(aSz);
485 }
486 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)487 void VCLXButton::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
488 {
489 	::vos::OGuard aGuard( GetMutex() );
490 
491 	Button* pButton = (Button*)GetWindow();
492 	if ( pButton )
493 	{
494 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
495 		switch ( nPropType )
496 		{
497             case BASEPROPERTY_FOCUSONCLICK:
498                 ::toolkit::adjustBooleanWindowStyle( Value, pButton, WB_NOPOINTERFOCUS, sal_True );
499                 break;
500 
501             case BASEPROPERTY_TOGGLE:
502                 ::toolkit::adjustBooleanWindowStyle( Value, pButton, WB_TOGGLE, sal_False );
503                 break;
504 
505             case BASEPROPERTY_DEFAULTBUTTON:
506 			{
507 				WinBits nStyle = pButton->GetStyle() | WB_DEFBUTTON;
508 				sal_Bool b = sal_Bool();
509 				if ( ( Value >>= b ) && !b )
510 					nStyle &= ~WB_DEFBUTTON;
511 				pButton->SetStyle( nStyle );
512 			}
513 			break;
514 			case BASEPROPERTY_STATE:
515 			{
516                 if ( GetWindow()->GetType() == WINDOW_PUSHBUTTON )
517                 {
518 				    sal_Int16 n = sal_Int16();
519 				    if ( Value >>= n )
520 					    ((PushButton*)pButton)->SetState( (TriState)n );
521                 }
522 			}
523 			break;
524 			default:
525 			{
526 				VCLXGraphicControl::setProperty( PropertyName, Value );
527 			}
528 		}
529 	}
530 }
531 
getProperty(const::rtl::OUString & PropertyName)532 ::com::sun::star::uno::Any VCLXButton::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
533 {
534 	::vos::OGuard aGuard( GetMutex() );
535 
536 	::com::sun::star::uno::Any aProp;
537 	Button* pButton = (Button*)GetWindow();
538 	if ( pButton )
539 	{
540 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
541 		switch ( nPropType )
542 		{
543             case BASEPROPERTY_FOCUSONCLICK:
544                 aProp <<= (sal_Bool)( ( pButton->GetStyle() & WB_NOPOINTERFOCUS ) == 0 );
545                 break;
546 
547             case BASEPROPERTY_TOGGLE:
548                 aProp <<= (sal_Bool)( ( pButton->GetStyle() & WB_TOGGLE ) != 0 );
549                 break;
550 
551 			case BASEPROPERTY_DEFAULTBUTTON:
552 			{
553 				aProp <<= (sal_Bool) ( ( pButton->GetStyle() & WB_DEFBUTTON ) ? sal_True : sal_False );
554 			}
555 			break;
556 			case BASEPROPERTY_STATE:
557 			{
558                 if ( GetWindow()->GetType() == WINDOW_PUSHBUTTON )
559                 {
560  				    aProp <<= (sal_Int16)((PushButton*)pButton)->GetState();
561                 }
562 			}
563 			break;
564 			default:
565 			{
566 				aProp <<= VCLXGraphicControl::getProperty( PropertyName );
567 			}
568 		}
569 	}
570 	return aProp;
571 }
572 
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)573 void VCLXButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
574 {
575 	switch ( rVclWindowEvent.GetId() )
576 	{
577 		case VCLEVENT_BUTTON_CLICK:
578         {
579             ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
580                 // since we call listeners below, there is a potential that we will be destroyed
581                 // during the listener call. To prevent the resulting crashs, we keep us
582                 // alive as long as we're here
583                 // #20178# - 2003-10-01 - fs@openoffice.org
584 
585 			if ( maActionListeners.getLength() )
586 			{
587 				::com::sun::star::awt::ActionEvent aEvent;
588 				aEvent.Source = (::cppu::OWeakObject*)this;
589 				aEvent.ActionCommand = maActionCommand;
590 
591                 Callback aCallback = ::boost::bind(
592                     &ActionListenerMultiplexer::actionPerformed,
593                     &maActionListeners,
594                     aEvent
595                 );
596                 ImplExecuteAsyncWithoutSolarLock( aCallback );
597 			}
598         }
599 		break;
600 
601         case VCLEVENT_PUSHBUTTON_TOGGLE:
602         {
603 	        PushButton& rButton = dynamic_cast< PushButton& >( *rVclWindowEvent.GetWindow() );
604 
605             ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
606 			if ( maItemListeners.getLength() )
607 			{
608 				::com::sun::star::awt::ItemEvent aEvent;
609 				aEvent.Source = (::cppu::OWeakObject*)this;
610                 aEvent.Selected = ( rButton.GetState() == STATE_CHECK ) ? 1 : 0;
611 				maItemListeners.itemStateChanged( aEvent );
612 			}
613         }
614 		break;
615 
616 		default:
617 			VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent );
618 			break;
619 	}
620 }
621 
622 //	----------------------------------------------------
623 //	class VCLXImageControl
624 //	----------------------------------------------------
625 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)626 void VCLXImageControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
627 {
628     PushPropertyIds( rIds,
629                      BASEPROPERTY_BACKGROUNDCOLOR,
630                      BASEPROPERTY_BORDER,
631                      BASEPROPERTY_BORDERCOLOR,
632                      BASEPROPERTY_DEFAULTCONTROL,
633                      BASEPROPERTY_ENABLED,
634                      BASEPROPERTY_ENABLEVISIBLE,
635                      BASEPROPERTY_GRAPHIC,
636                      BASEPROPERTY_HELPTEXT,
637                      BASEPROPERTY_HELPURL,
638                      BASEPROPERTY_IMAGEURL,
639                      BASEPROPERTY_PRINTABLE,
640                      BASEPROPERTY_SCALEIMAGE,
641                      BASEPROPERTY_IMAGE_SCALE_MODE,
642                      BASEPROPERTY_TABSTOP,
643                      BASEPROPERTY_WRITING_MODE,
644                      BASEPROPERTY_CONTEXT_WRITING_MODE,
645                      0);
646     VCLXGraphicControl::ImplGetPropertyIds( rIds );
647 }
648 
VCLXImageControl()649 VCLXImageControl::VCLXImageControl()
650 {
651 }
652 
~VCLXImageControl()653 VCLXImageControl::~VCLXImageControl()
654 {
655 }
656 
ImplSetNewImage()657 void VCLXImageControl::ImplSetNewImage()
658 {
659     OSL_PRECOND( GetWindow(), "VCLXImageControl::ImplSetNewImage: window is required to be not-NULL!" );
660 	ImageControl* pControl = static_cast< ImageControl* >( GetWindow() );
661 	pControl->SetImage( GetImage() );
662 }
663 
getMinimumSize()664 ::com::sun::star::awt::Size VCLXImageControl::getMinimumSize(  ) throw(::com::sun::star::uno::RuntimeException)
665 {
666 	::vos::OGuard aGuard( GetMutex() );
667 
668 	Size aSz = GetImage().GetSizePixel();
669 	aSz = ImplCalcWindowSize( aSz );
670 
671 	return AWTSize(aSz);
672 }
673 
getPreferredSize()674 ::com::sun::star::awt::Size VCLXImageControl::getPreferredSize(  ) throw(::com::sun::star::uno::RuntimeException)
675 {
676 	return getMinimumSize();
677 }
678 
calcAdjustedSize(const::com::sun::star::awt::Size & rNewSize)679 ::com::sun::star::awt::Size VCLXImageControl::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException)
680 {
681 	::vos::OGuard aGuard( GetMutex() );
682 
683 	::com::sun::star::awt::Size aSz = rNewSize;
684 	::com::sun::star::awt::Size aMinSz = getMinimumSize();
685 	if ( aSz.Width < aMinSz.Width )
686 		aSz.Width = aMinSz.Width;
687 	if ( aSz.Height < aMinSz.Height )
688 		aSz.Height = aMinSz.Height;
689 	return aSz;
690 }
691 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)692 void VCLXImageControl::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
693 {
694 	::vos::OGuard aGuard( GetMutex() );
695 
696 	ImageControl* pImageControl = (ImageControl*)GetWindow();
697 
698     sal_uInt16 nPropType = GetPropertyId( PropertyName );
699 	switch ( nPropType )
700 	{
701         case BASEPROPERTY_IMAGE_SCALE_MODE:
702         {
703             sal_Int16 nScaleMode( ImageScaleMode::ANISOTROPIC );
704             if ( pImageControl && ( Value >>= nScaleMode ) )
705             {
706                 pImageControl->SetScaleMode( nScaleMode );
707             }
708         }
709         break;
710 
711 		case BASEPROPERTY_SCALEIMAGE:
712 		{
713             // this is for compatibility only, nowadays, the ImageScaleMode property should be used
714 			sal_Bool bScaleImage = sal_False;
715             if ( pImageControl && ( Value >>= bScaleImage ) )
716             {
717                 pImageControl->SetScaleMode( bScaleImage ? ImageScaleMode::ANISOTROPIC : ImageScaleMode::NONE );
718             }
719 		}
720 		break;
721 
722         default:
723 			VCLXGraphicControl::setProperty( PropertyName, Value );
724             break;
725 	}
726 }
727 
getProperty(const::rtl::OUString & PropertyName)728 ::com::sun::star::uno::Any VCLXImageControl::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
729 {
730 	::vos::OGuard aGuard( GetMutex() );
731 
732 	::com::sun::star::uno::Any aProp;
733 	ImageControl* pImageControl = (ImageControl*)GetWindow();
734 	sal_uInt16 nPropType = GetPropertyId( PropertyName );
735 
736     switch ( nPropType )
737 	{
738         case BASEPROPERTY_IMAGE_SCALE_MODE:
739             aProp <<= ( pImageControl ? pImageControl->GetScaleMode() : ImageScaleMode::ANISOTROPIC );
740             break;
741 
742 		case BASEPROPERTY_SCALEIMAGE:
743             aProp <<= ( pImageControl && pImageControl->GetScaleMode() != ImageScaleMode::NONE ) ? sal_True : sal_False;
744 		    break;
745 
746 		default:
747 			aProp = VCLXGraphicControl::getProperty( PropertyName );
748             break;
749 	}
750 	return aProp;
751 }
752 
753 //	----------------------------------------------------
754 //	class VCLXCheckBox
755 //	----------------------------------------------------
756 
757 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)758 void VCLXCheckBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
759 {
760     PushPropertyIds( rIds,
761                      BASEPROPERTY_DEFAULTCONTROL,
762                      BASEPROPERTY_ENABLED,
763                      BASEPROPERTY_ENABLEVISIBLE,
764                      BASEPROPERTY_FONTDESCRIPTOR,
765                      BASEPROPERTY_GRAPHIC,
766                      BASEPROPERTY_HELPTEXT,
767                      BASEPROPERTY_HELPURL,
768                      BASEPROPERTY_IMAGEPOSITION,
769                      BASEPROPERTY_IMAGEURL,
770                      BASEPROPERTY_LABEL,
771                      BASEPROPERTY_PRINTABLE,
772                      BASEPROPERTY_STATE,
773                      BASEPROPERTY_TABSTOP,
774                      BASEPROPERTY_TRISTATE,
775                      BASEPROPERTY_VISUALEFFECT,
776                      BASEPROPERTY_MULTILINE,
777                      BASEPROPERTY_BACKGROUNDCOLOR,
778                      BASEPROPERTY_ALIGN,
779                      BASEPROPERTY_VERTICALALIGN,
780                      BASEPROPERTY_WRITING_MODE,
781                      BASEPROPERTY_CONTEXT_WRITING_MODE,
782                      BASEPROPERTY_REFERENCE_DEVICE,
783                      0);
784     VCLXGraphicControl::ImplGetPropertyIds( rIds );
785 }
786 
VCLXCheckBox()787 VCLXCheckBox::VCLXCheckBox() :  maActionListeners( *this ), maItemListeners( *this )
788 {
789 }
790 
791 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)792 ::com::sun::star::uno::Any VCLXCheckBox::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
793 {
794 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
795 										SAL_STATIC_CAST( ::com::sun::star::awt::XButton*, this ),
796 										SAL_STATIC_CAST( ::com::sun::star::awt::XCheckBox*, this ) );
797 	return (aRet.hasValue() ? aRet : VCLXGraphicControl::queryInterface( rType ));
798 }
799 
800 // ::com::sun::star::lang::XTypeProvider
801 IMPL_XTYPEPROVIDER_START( VCLXCheckBox )
802 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XButton>* ) NULL ),
803 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XCheckBox>* ) NULL ),
804 	VCLXGraphicControl::getTypes()
805 IMPL_XTYPEPROVIDER_END
806 
807 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXCheckBox::CreateAccessibleContext()
808 {
809     return getAccessibleFactory().createAccessibleContext( this );
810 }
811 
dispose()812 void VCLXCheckBox::dispose() throw(::com::sun::star::uno::RuntimeException)
813 {
814 	::vos::OGuard aGuard( GetMutex() );
815 
816 	::com::sun::star::lang::EventObject aObj;
817 	aObj.Source = (::cppu::OWeakObject*)this;
818 	maItemListeners.disposeAndClear( aObj );
819 	VCLXGraphicControl::dispose();
820 }
821 
addItemListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XItemListener> & l)822 void VCLXCheckBox::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException)
823 {
824 	::vos::OGuard aGuard( GetMutex() );
825 	maItemListeners.addInterface( l );
826 }
827 
removeItemListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XItemListener> & l)828 void VCLXCheckBox::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException)
829 {
830 	::vos::OGuard aGuard( GetMutex() );
831 	maItemListeners.removeInterface( l );
832 }
833 
addActionListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XActionListener> & l)834 void VCLXCheckBox::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l  )throw(::com::sun::star::uno::RuntimeException)
835 {
836 	::vos::OGuard aGuard( GetMutex() );
837 	maActionListeners.addInterface( l );
838 }
839 
removeActionListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XActionListener> & l)840 void VCLXCheckBox::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException)
841 {
842 	::vos::OGuard aGuard( GetMutex() );
843 	maActionListeners.removeInterface( l );
844 }
845 
setActionCommand(const::rtl::OUString & rCommand)846 void VCLXCheckBox::setActionCommand( const ::rtl::OUString& rCommand ) throw(::com::sun::star::uno::RuntimeException)
847 {
848 	::vos::OGuard aGuard( GetMutex() );
849 	maActionCommand = rCommand;
850 }
851 
setLabel(const::rtl::OUString & rLabel)852 void VCLXCheckBox::setLabel( const ::rtl::OUString& rLabel ) throw(::com::sun::star::uno::RuntimeException)
853 {
854 	::vos::OGuard aGuard( GetMutex() );
855 
856 	Window* pWindow = GetWindow();
857 	if ( pWindow )
858 		pWindow->SetText( rLabel );
859 }
860 
setState(short n)861 void VCLXCheckBox::setState( short n ) throw(::com::sun::star::uno::RuntimeException)
862 {
863 	::vos::OGuard aGuard( GetMutex() );
864 
865 	CheckBox* pCheckBox = (CheckBox*)GetWindow();
866 	if ( pCheckBox)
867 	{
868         TriState eState;
869         switch ( n )
870         {
871             case 0:     eState = STATE_NOCHECK;     break;
872             case 1:     eState = STATE_CHECK;       break;
873             case 2:     eState = STATE_DONTKNOW;    break;
874             default:    eState = STATE_NOCHECK;
875         }
876 		pCheckBox->SetState( eState );
877 
878         // #105198# call C++ click listeners (needed for accessibility)
879         // pCheckBox->GetClickHdl().Call( pCheckBox );
880 
881         // #107218# Call same virtual methods and listeners like VCL would do after user interaction
882         SetSynthesizingVCLEvent( sal_True );
883         pCheckBox->Toggle();
884         pCheckBox->Click();
885         SetSynthesizingVCLEvent( sal_False );
886 	}
887 }
888 
getState()889 short VCLXCheckBox::getState() throw(::com::sun::star::uno::RuntimeException)
890 {
891     ::vos::OGuard aGuard( GetMutex() );
892 
893     short nState = -1;
894     CheckBox* pCheckBox = (CheckBox*)GetWindow();
895     if ( pCheckBox )
896     {
897         switch ( pCheckBox->GetState() )
898         {
899             case STATE_NOCHECK:     nState = 0; break;
900             case STATE_CHECK:       nState = 1; break;
901             case STATE_DONTKNOW:    nState = 2; break;
902             default:                DBG_ERROR( "VCLXCheckBox::getState(): unknown TriState!" );
903         }
904     }
905 
906     return nState;
907 }
908 
enableTriState(sal_Bool b)909 void VCLXCheckBox::enableTriState( sal_Bool b ) throw(::com::sun::star::uno::RuntimeException)
910 {
911 	::vos::OGuard aGuard( GetMutex() );
912 
913 	CheckBox* pCheckBox = (CheckBox*)GetWindow();
914 	if ( pCheckBox)
915 		pCheckBox->EnableTriState( b );
916 }
917 
getMinimumSize()918 ::com::sun::star::awt::Size VCLXCheckBox::getMinimumSize(  ) throw(::com::sun::star::uno::RuntimeException)
919 {
920 	::vos::OGuard aGuard( GetMutex() );
921 
922 	Size aSz;
923 	CheckBox* pCheckBox = (CheckBox*) GetWindow();
924 	if ( pCheckBox )
925 		aSz = pCheckBox->CalcMinimumSize();
926 	return AWTSize(aSz);
927 }
928 
getPreferredSize()929 ::com::sun::star::awt::Size VCLXCheckBox::getPreferredSize(  ) throw(::com::sun::star::uno::RuntimeException)
930 {
931 	return getMinimumSize();
932 }
933 
calcAdjustedSize(const::com::sun::star::awt::Size & rNewSize)934 ::com::sun::star::awt::Size VCLXCheckBox::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException)
935 {
936 	::vos::OGuard aGuard( GetMutex() );
937 
938 	Size aSz = VCLSize(rNewSize);
939 	CheckBox* pCheckBox = (CheckBox*) GetWindow();
940 	if ( pCheckBox )
941 	{
942 		Size aMinSz = pCheckBox->CalcMinimumSize();
943 		if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
944 			aSz.Height() = aMinSz.Height();
945 		else
946 			aSz = aMinSz;
947 	}
948 	return AWTSize(aSz);
949 }
950 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)951 void VCLXCheckBox::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
952 {
953 	::vos::OGuard aGuard( GetMutex() );
954 
955 	CheckBox* pCheckBox = (CheckBox*)GetWindow();
956 	if ( pCheckBox )
957 	{
958 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
959 		switch ( nPropType )
960 		{
961             case BASEPROPERTY_VISUALEFFECT:
962                 ::toolkit::setVisualEffect( Value, pCheckBox );
963                 break;
964 
965 			case BASEPROPERTY_TRISTATE:
966 			{
967 				sal_Bool b = sal_Bool();
968 				if ( Value >>= b )
969  					pCheckBox->EnableTriState( b );
970 			}
971 			break;
972 			case BASEPROPERTY_STATE:
973 			{
974 				sal_Int16 n = sal_Int16();
975 				if ( Value >>= n )
976 					setState( n );
977 			}
978 			break;
979 			default:
980 			{
981 				VCLXGraphicControl::setProperty( PropertyName, Value );
982 			}
983 		}
984 	}
985 }
986 
getProperty(const::rtl::OUString & PropertyName)987 ::com::sun::star::uno::Any VCLXCheckBox::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
988 {
989 	::vos::OGuard aGuard( GetMutex() );
990 
991 	::com::sun::star::uno::Any aProp;
992 	CheckBox* pCheckBox = (CheckBox*)GetWindow();
993 	if ( pCheckBox )
994 	{
995 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
996 		switch ( nPropType )
997 		{
998             case BASEPROPERTY_VISUALEFFECT:
999                 aProp = ::toolkit::getVisualEffect( pCheckBox );
1000                 break;
1001 			case BASEPROPERTY_TRISTATE:
1002  				aProp <<= (sal_Bool)pCheckBox->IsTriStateEnabled();
1003     			break;
1004 			case BASEPROPERTY_STATE:
1005  				aProp <<= (sal_Int16)pCheckBox->GetState();
1006     			break;
1007 			default:
1008 			{
1009 				aProp <<= VCLXGraphicControl::getProperty( PropertyName );
1010 			}
1011 		}
1012 	}
1013 	return aProp;
1014 }
1015 
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)1016 void VCLXCheckBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1017 {
1018 	switch ( rVclWindowEvent.GetId() )
1019 	{
1020 		case VCLEVENT_CHECKBOX_TOGGLE:
1021         {
1022             ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
1023                 // since we call listeners below, there is a potential that we will be destroyed
1024                 // in during the listener call. To prevent the resulting crashs, we keep us
1025                 // alive as long as we're here
1026                 // #20178# - 2003-10-01 - fs@openoffice.org
1027 
1028 			CheckBox* pCheckBox = (CheckBox*)GetWindow();
1029 			if ( pCheckBox )
1030 			{
1031     			if ( maItemListeners.getLength() )
1032     			{
1033     				::com::sun::star::awt::ItemEvent aEvent;
1034     				aEvent.Source = (::cppu::OWeakObject*)this;
1035     				aEvent.Highlighted = sal_False;
1036     				aEvent.Selected = pCheckBox->GetState();
1037     				maItemListeners.itemStateChanged( aEvent );
1038     			}
1039     			if ( !IsSynthesizingVCLEvent() && maActionListeners.getLength() )
1040     			{
1041     				::com::sun::star::awt::ActionEvent aEvent;
1042     				aEvent.Source = (::cppu::OWeakObject*)this;
1043     				aEvent.ActionCommand = maActionCommand;
1044     				maActionListeners.actionPerformed( aEvent );
1045     			}
1046 			}
1047 		}
1048 		break;
1049 
1050 		default:
1051 			VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent );
1052 			break;
1053 	}
1054 }
1055 
1056 //	----------------------------------------------------
1057 //	class VCLXRadioButton
1058 //	----------------------------------------------------
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)1059 void VCLXRadioButton::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1060 {
1061     PushPropertyIds( rIds,
1062                      BASEPROPERTY_DEFAULTCONTROL,
1063                      BASEPROPERTY_ENABLED,
1064                      BASEPROPERTY_ENABLEVISIBLE,
1065                      BASEPROPERTY_FONTDESCRIPTOR,
1066                      BASEPROPERTY_GRAPHIC,
1067                      BASEPROPERTY_HELPTEXT,
1068                      BASEPROPERTY_HELPURL,
1069                      BASEPROPERTY_IMAGEPOSITION,
1070                      BASEPROPERTY_IMAGEURL,
1071                      BASEPROPERTY_LABEL,
1072                      BASEPROPERTY_PRINTABLE,
1073                      BASEPROPERTY_STATE,
1074                      BASEPROPERTY_TABSTOP,
1075                      BASEPROPERTY_VISUALEFFECT,
1076                      BASEPROPERTY_MULTILINE,
1077                      BASEPROPERTY_BACKGROUNDCOLOR,
1078                      BASEPROPERTY_ALIGN,
1079                      BASEPROPERTY_VERTICALALIGN,
1080                      BASEPROPERTY_WRITING_MODE,
1081                      BASEPROPERTY_CONTEXT_WRITING_MODE,
1082                      BASEPROPERTY_REFERENCE_DEVICE,
1083                      0);
1084     VCLXGraphicControl::ImplGetPropertyIds( rIds );
1085 }
1086 
1087 
VCLXRadioButton()1088 VCLXRadioButton::VCLXRadioButton() : maItemListeners( *this ), maActionListeners( *this )
1089 {
1090 }
1091 
1092 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)1093 ::com::sun::star::uno::Any VCLXRadioButton::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
1094 {
1095 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
1096 										SAL_STATIC_CAST( ::com::sun::star::awt::XRadioButton*, this ),
1097 										SAL_STATIC_CAST( ::com::sun::star::awt::XButton*, this ) );
1098 	return (aRet.hasValue() ? aRet : VCLXGraphicControl::queryInterface( rType ));
1099 }
1100 
1101 // ::com::sun::star::lang::XTypeProvider
1102 IMPL_XTYPEPROVIDER_START( VCLXRadioButton )
1103 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRadioButton>* ) NULL ),
1104 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XButton>* ) NULL ),
1105 	VCLXGraphicControl::getTypes()
1106 IMPL_XTYPEPROVIDER_END
1107 
1108 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXRadioButton::CreateAccessibleContext()
1109 {
1110     return getAccessibleFactory().createAccessibleContext( this );
1111 }
1112 
dispose()1113 void VCLXRadioButton::dispose() throw(::com::sun::star::uno::RuntimeException)
1114 {
1115 	::vos::OGuard aGuard( GetMutex() );
1116 
1117 	::com::sun::star::lang::EventObject aObj;
1118 	aObj.Source = (::cppu::OWeakObject*)this;
1119 	maItemListeners.disposeAndClear( aObj );
1120 	VCLXGraphicControl::dispose();
1121 }
1122 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)1123 void VCLXRadioButton::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
1124 {
1125 	::vos::OGuard aGuard( GetMutex() );
1126 
1127 	RadioButton* pButton = (RadioButton*)GetWindow();
1128 	if ( pButton )
1129 	{
1130 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
1131 		switch ( nPropType )
1132 		{
1133             case BASEPROPERTY_VISUALEFFECT:
1134                 ::toolkit::setVisualEffect( Value, pButton );
1135                 break;
1136 
1137 			case BASEPROPERTY_STATE:
1138 			{
1139 				sal_Int16 n = sal_Int16();
1140 				if ( Value >>= n )
1141 				{
1142 					sal_Bool b = n ? sal_True : sal_False;
1143 					if ( pButton->IsRadioCheckEnabled() )
1144 						pButton->Check( b );
1145 					else
1146 						pButton->SetState( b );
1147 				}
1148 			}
1149 			break;
1150 			case BASEPROPERTY_AUTOTOGGLE:
1151 			{
1152 				sal_Bool b = sal_Bool();
1153 				if ( Value >>= b )
1154 					pButton->EnableRadioCheck( b );
1155 			}
1156 			break;
1157 			default:
1158 			{
1159 				VCLXGraphicControl::setProperty( PropertyName, Value );
1160 			}
1161 		}
1162 	}
1163 }
1164 
getProperty(const::rtl::OUString & PropertyName)1165 ::com::sun::star::uno::Any VCLXRadioButton::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
1166 {
1167 	::vos::OGuard aGuard( GetMutex() );
1168 
1169 	::com::sun::star::uno::Any aProp;
1170 	RadioButton* pButton = (RadioButton*)GetWindow();
1171 	if ( pButton )
1172 	{
1173 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
1174 		switch ( nPropType )
1175 		{
1176             case BASEPROPERTY_VISUALEFFECT:
1177                 aProp = ::toolkit::getVisualEffect( pButton );
1178                 break;
1179 			case BASEPROPERTY_STATE:
1180 				aProp <<= (sal_Int16) ( pButton->IsChecked() ? 1 : 0 );
1181     			break;
1182 			case BASEPROPERTY_AUTOTOGGLE:
1183 				aProp <<= (sal_Bool) pButton->IsRadioCheckEnabled();
1184     			break;
1185 			default:
1186 			{
1187 				aProp <<= VCLXGraphicControl::getProperty( PropertyName );
1188 			}
1189 		}
1190 	}
1191 	return aProp;
1192 }
1193 
addItemListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XItemListener> & l)1194 void VCLXRadioButton::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException)
1195 {
1196 	::vos::OGuard aGuard( GetMutex() );
1197 	maItemListeners.addInterface( l );
1198 }
1199 
removeItemListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XItemListener> & l)1200 void VCLXRadioButton::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException)
1201 {
1202 	::vos::OGuard aGuard( GetMutex() );
1203 	maItemListeners.removeInterface( l );
1204 }
1205 
addActionListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XActionListener> & l)1206 void VCLXRadioButton::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l  )throw(::com::sun::star::uno::RuntimeException)
1207 {
1208 	::vos::OGuard aGuard( GetMutex() );
1209 	maActionListeners.addInterface( l );
1210 }
1211 
removeActionListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XActionListener> & l)1212 void VCLXRadioButton::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException)
1213 {
1214 	::vos::OGuard aGuard( GetMutex() );
1215 	maActionListeners.removeInterface( l );
1216 }
1217 
setLabel(const::rtl::OUString & rLabel)1218 void VCLXRadioButton::setLabel( const ::rtl::OUString& rLabel ) throw(::com::sun::star::uno::RuntimeException)
1219 {
1220 	::vos::OGuard aGuard( GetMutex() );
1221 
1222 	Window* pWindow = GetWindow();
1223 	if ( pWindow )
1224 		pWindow->SetText( rLabel );
1225 }
1226 
setActionCommand(const::rtl::OUString & rCommand)1227 void VCLXRadioButton::setActionCommand( const ::rtl::OUString& rCommand ) throw(::com::sun::star::uno::RuntimeException)
1228 {
1229 	::vos::OGuard aGuard( GetMutex() );
1230 	maActionCommand = rCommand;
1231 }
1232 
setState(sal_Bool b)1233 void VCLXRadioButton::setState( sal_Bool b ) throw(::com::sun::star::uno::RuntimeException)
1234 {
1235 	::vos::OGuard aGuard( GetMutex() );
1236 
1237 	RadioButton* pRadioButton = (RadioButton*)GetWindow();
1238 	if ( pRadioButton)
1239     {
1240 		pRadioButton->Check( b );
1241         // #102717# item listeners are called, but not C++ click listeners in StarOffice code => call click hdl
1242         // But this is needed in old code because Accessibility API uses it.
1243         // pRadioButton->GetClickHdl().Call( pRadioButton );
1244 
1245         // #107218# Call same virtual methods and listeners like VCL would do after user interaction
1246         SetSynthesizingVCLEvent( sal_True );
1247         pRadioButton->Click();
1248         SetSynthesizingVCLEvent( sal_False );
1249     }
1250 }
1251 
getState()1252 sal_Bool VCLXRadioButton::getState() throw(::com::sun::star::uno::RuntimeException)
1253 {
1254 	::vos::OGuard aGuard( GetMutex() );
1255 
1256 	RadioButton* pRadioButton = (RadioButton*)GetWindow();
1257 	return pRadioButton ? pRadioButton->IsChecked() : sal_False;
1258 }
1259 
getMinimumSize()1260 ::com::sun::star::awt::Size VCLXRadioButton::getMinimumSize(  ) throw(::com::sun::star::uno::RuntimeException)
1261 {
1262 	::vos::OGuard aGuard( GetMutex() );
1263 
1264 	Size aSz;
1265 	RadioButton* pRadioButton = (RadioButton*) GetWindow();
1266 	if ( pRadioButton )
1267 		aSz = pRadioButton->CalcMinimumSize();
1268 	return AWTSize(aSz);
1269 }
1270 
getPreferredSize()1271 ::com::sun::star::awt::Size VCLXRadioButton::getPreferredSize(  ) throw(::com::sun::star::uno::RuntimeException)
1272 {
1273 	return getMinimumSize();
1274 }
1275 
calcAdjustedSize(const::com::sun::star::awt::Size & rNewSize)1276 ::com::sun::star::awt::Size VCLXRadioButton::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException)
1277 {
1278 	::vos::OGuard aGuard( GetMutex() );
1279 
1280 	Size aSz = VCLSize(rNewSize);
1281 	RadioButton* pRadioButton = (RadioButton*) GetWindow();
1282 	if ( pRadioButton )
1283 	{
1284 		Size aMinSz = pRadioButton->CalcMinimumSize();
1285 		if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
1286 			aSz.Height() = aMinSz.Height();
1287 		else
1288 			aSz = aMinSz;
1289 	}
1290 	return AWTSize(aSz);
1291 }
1292 
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)1293 void VCLXRadioButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1294 {
1295     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
1296         // since we call listeners below, there is a potential that we will be destroyed
1297         // in during the listener call. To prevent the resulting crashs, we keep us
1298         // alive as long as we're here
1299         // #20178# - 2003-10-01 - fs@openoffice.org
1300 
1301 	switch ( rVclWindowEvent.GetId() )
1302 	{
1303 		case VCLEVENT_BUTTON_CLICK:
1304 			if ( !IsSynthesizingVCLEvent() && maActionListeners.getLength() )
1305 			{
1306 				::com::sun::star::awt::ActionEvent aEvent;
1307 				aEvent.Source = (::cppu::OWeakObject*)this;
1308 				aEvent.ActionCommand = maActionCommand;
1309 				maActionListeners.actionPerformed( aEvent );
1310 			}
1311 			ImplClickedOrToggled( sal_False );
1312             break;
1313 
1314 		case VCLEVENT_RADIOBUTTON_TOGGLE:
1315 		    ImplClickedOrToggled( sal_True );
1316             break;
1317 
1318 		default:
1319 			VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent );
1320 			break;
1321 	}
1322 }
1323 
ImplClickedOrToggled(sal_Bool bToggled)1324 void VCLXRadioButton::ImplClickedOrToggled( sal_Bool bToggled )
1325 {
1326 	// In the formulars, RadioChecked is not enabled, call itemStateChanged only for click
1327 	// In the dialog editor, RadioChecked is enabled, call itemStateChanged only for bToggled
1328 	RadioButton* pRadioButton = (RadioButton*)GetWindow();
1329 	if ( pRadioButton && ( pRadioButton->IsRadioCheckEnabled() == bToggled ) && ( bToggled || pRadioButton->IsStateChanged() ) && maItemListeners.getLength() )
1330 	{
1331 		::com::sun::star::awt::ItemEvent aEvent;
1332 		aEvent.Source = (::cppu::OWeakObject*)this;
1333 		aEvent.Highlighted = sal_False;
1334 		aEvent.Selected = pRadioButton->IsChecked();
1335 		maItemListeners.itemStateChanged( aEvent );
1336 	}
1337 }
1338 
getFirstActionListener()1339 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > VCLXRadioButton::getFirstActionListener ()
1340 {
1341     if (!maItemListeners.getLength ())
1342         return ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > ();
1343     return maActionListeners.getElements()[0];
1344 }
1345 
1346 //	----------------------------------------------------
1347 //	class VCLXSpinField
1348 //	----------------------------------------------------
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)1349 void VCLXSpinField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1350 {
1351     PushPropertyIds( rIds,
1352                      BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
1353                      0 );
1354     VCLXEdit::ImplGetPropertyIds( rIds );
1355 }
1356 
VCLXSpinField()1357 VCLXSpinField::VCLXSpinField() : maSpinListeners( *this )
1358 {
1359 }
1360 
1361 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)1362 ::com::sun::star::uno::Any VCLXSpinField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
1363 {
1364 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
1365 										SAL_STATIC_CAST( ::com::sun::star::awt::XSpinField*, this ) );
1366 	return (aRet.hasValue() ? aRet : VCLXEdit::queryInterface( rType ));
1367 }
1368 
1369 // ::com::sun::star::lang::XTypeProvider
1370 IMPL_XTYPEPROVIDER_START( VCLXSpinField )
1371 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinField>* ) NULL ),
1372 	VCLXEdit::getTypes()
1373 IMPL_XTYPEPROVIDER_END
1374 
1375 void VCLXSpinField::addSpinListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinListener > & l ) throw(::com::sun::star::uno::RuntimeException)
1376 {
1377 	::vos::OGuard aGuard( GetMutex() );
1378 	maSpinListeners.addInterface( l );
1379 }
1380 
removeSpinListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XSpinListener> & l)1381 void VCLXSpinField::removeSpinListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinListener > & l ) throw(::com::sun::star::uno::RuntimeException)
1382 {
1383 	::vos::OGuard aGuard( GetMutex() );
1384 	maSpinListeners.removeInterface( l );
1385 }
1386 
up()1387 void VCLXSpinField::up() throw(::com::sun::star::uno::RuntimeException)
1388 {
1389 	::vos::OGuard aGuard( GetMutex() );
1390 
1391 	SpinField* pSpinField = (SpinField*) GetWindow();
1392 	if ( pSpinField )
1393 		pSpinField->Up();
1394 }
1395 
down()1396 void VCLXSpinField::down() throw(::com::sun::star::uno::RuntimeException)
1397 {
1398 	::vos::OGuard aGuard( GetMutex() );
1399 
1400 	SpinField* pSpinField = (SpinField*) GetWindow();
1401 	if ( pSpinField )
1402 		pSpinField->Down();
1403 }
1404 
first()1405 void VCLXSpinField::first() throw(::com::sun::star::uno::RuntimeException)
1406 {
1407 	::vos::OGuard aGuard( GetMutex() );
1408 
1409 	SpinField* pSpinField = (SpinField*) GetWindow();
1410 	if ( pSpinField )
1411 		pSpinField->First();
1412 }
1413 
last()1414 void VCLXSpinField::last() throw(::com::sun::star::uno::RuntimeException)
1415 {
1416 	::vos::OGuard aGuard( GetMutex() );
1417 
1418 	SpinField* pSpinField = (SpinField*) GetWindow();
1419 	if ( pSpinField )
1420 		pSpinField->Last();
1421 }
1422 
enableRepeat(sal_Bool bRepeat)1423 void VCLXSpinField::enableRepeat( sal_Bool bRepeat ) throw(::com::sun::star::uno::RuntimeException)
1424 {
1425 	::vos::OGuard aGuard( GetMutex() );
1426 
1427 	Window* pWindow = GetWindow();
1428 	if ( pWindow )
1429 	{
1430 		WinBits nStyle = pWindow->GetStyle();
1431 		if ( bRepeat )
1432 			nStyle |= WB_REPEAT;
1433 		else
1434 			nStyle &= ~WB_REPEAT;
1435 		pWindow->SetStyle( nStyle );
1436 	}
1437 }
1438 
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)1439 void VCLXSpinField::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1440 {
1441 	switch ( rVclWindowEvent.GetId() )
1442 	{
1443 		case VCLEVENT_SPINFIELD_UP:
1444 		case VCLEVENT_SPINFIELD_DOWN:
1445 		case VCLEVENT_SPINFIELD_FIRST:
1446 		case VCLEVENT_SPINFIELD_LAST:
1447         {
1448             ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
1449                 // since we call listeners below, there is a potential that we will be destroyed
1450                 // in during the listener call. To prevent the resulting crashs, we keep us
1451                 // alive as long as we're here
1452                 // #20178# - 2003-10-01 - fs@openoffice.org
1453 
1454 			if ( maSpinListeners.getLength() )
1455 			{
1456 				::com::sun::star::awt::SpinEvent aEvent;
1457 				aEvent.Source = (::cppu::OWeakObject*)this;
1458 				switch ( rVclWindowEvent.GetId() )
1459 				{
1460 					case VCLEVENT_SPINFIELD_UP:     maSpinListeners.up( aEvent );
1461 													break;
1462 					case VCLEVENT_SPINFIELD_DOWN:   maSpinListeners.down( aEvent );
1463 													break;
1464 					case VCLEVENT_SPINFIELD_FIRST:  maSpinListeners.first( aEvent );
1465 													break;
1466 					case VCLEVENT_SPINFIELD_LAST:   maSpinListeners.last( aEvent );
1467 													break;
1468 				}
1469 
1470 			}
1471 		}
1472 		break;
1473 
1474 		default:
1475 			VCLXEdit::ProcessWindowEvent( rVclWindowEvent );
1476 			break;
1477 	}
1478 }
1479 
1480 
1481 //	----------------------------------------------------
1482 //	class VCLXListBox
1483 //	----------------------------------------------------
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)1484 void VCLXListBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1485 {
1486     PushPropertyIds( rIds,
1487                      BASEPROPERTY_BACKGROUNDCOLOR,
1488                      BASEPROPERTY_BORDER,
1489                      BASEPROPERTY_BORDERCOLOR,
1490                      BASEPROPERTY_DEFAULTCONTROL,
1491                      BASEPROPERTY_DROPDOWN,
1492                      BASEPROPERTY_ENABLED,
1493                      BASEPROPERTY_ENABLEVISIBLE,
1494                      BASEPROPERTY_FONTDESCRIPTOR,
1495                      BASEPROPERTY_HELPTEXT,
1496                      BASEPROPERTY_HELPURL,
1497                      BASEPROPERTY_LINECOUNT,
1498                      BASEPROPERTY_MULTISELECTION,
1499                      BASEPROPERTY_MULTISELECTION_SIMPLEMODE,
1500                      BASEPROPERTY_ITEM_SEPARATOR_POS,
1501                      BASEPROPERTY_PRINTABLE,
1502                      BASEPROPERTY_SELECTEDITEMS,
1503                      BASEPROPERTY_STRINGITEMLIST,
1504                      BASEPROPERTY_TABSTOP,
1505                      BASEPROPERTY_READONLY,
1506                      BASEPROPERTY_ALIGN,
1507                      BASEPROPERTY_WRITING_MODE,
1508                      BASEPROPERTY_CONTEXT_WRITING_MODE,
1509                      BASEPROPERTY_REFERENCE_DEVICE,
1510                      BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
1511                      0);
1512     VCLXWindow::ImplGetPropertyIds( rIds );
1513 }
1514 
1515 
VCLXListBox()1516 VCLXListBox::VCLXListBox()
1517 	: maActionListeners( *this ),
1518 	  maItemListeners( *this )
1519 {
1520 }
1521 
dispose()1522 void VCLXListBox::dispose() throw(::com::sun::star::uno::RuntimeException)
1523 {
1524 	::vos::OGuard aGuard( GetMutex() );
1525 
1526 	::com::sun::star::lang::EventObject aObj;
1527 	aObj.Source = (::cppu::OWeakObject*)this;
1528 	maItemListeners.disposeAndClear( aObj );
1529 	maActionListeners.disposeAndClear( aObj );
1530 	VCLXWindow::dispose();
1531 }
1532 
addItemListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XItemListener> & l)1533 void VCLXListBox::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException)
1534 {
1535 	::vos::OGuard aGuard( GetMutex() );
1536 	maItemListeners.addInterface( l );
1537 }
1538 
removeItemListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XItemListener> & l)1539 void VCLXListBox::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException)
1540 {
1541 	::vos::OGuard aGuard( GetMutex() );
1542 	maItemListeners.removeInterface( l );
1543 }
1544 
addActionListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XActionListener> & l)1545 void VCLXListBox::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException)
1546 {
1547 	::vos::OGuard aGuard( GetMutex() );
1548 	maActionListeners.addInterface( l );
1549 }
1550 
removeActionListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XActionListener> & l)1551 void VCLXListBox::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException)
1552 {
1553 	::vos::OGuard aGuard( GetMutex() );
1554 	maActionListeners.removeInterface( l );
1555 }
1556 
addItem(const::rtl::OUString & aItem,sal_Int16 nPos)1557 void VCLXListBox::addItem( const ::rtl::OUString& aItem, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException)
1558 {
1559 	::vos::OGuard aGuard( GetMutex() );
1560 
1561 	ListBox* pBox = (ListBox*) GetWindow();
1562 	if ( pBox )
1563 		pBox->InsertEntry( aItem, nPos );
1564 }
1565 
addItems(const::com::sun::star::uno::Sequence<::rtl::OUString> & aItems,sal_Int16 nPos)1566 void VCLXListBox::addItems( const ::com::sun::star::uno::Sequence< ::rtl::OUString>& aItems, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException)
1567 {
1568 	::vos::OGuard aGuard( GetMutex() );
1569 
1570 	ListBox* pBox = (ListBox*) GetWindow();
1571 	if ( pBox )
1572 	{
1573 	    sal_uInt16 nP = nPos;
1574         const ::rtl::OUString* pItems = aItems.getConstArray();
1575         const ::rtl::OUString* pItemsEnd = aItems.getConstArray() + aItems.getLength();
1576 		while ( pItems != pItemsEnd )
1577 		{
1578 			if ( (sal_uInt16)nP == 0xFFFF )
1579             {
1580                 OSL_ENSURE( false, "VCLXListBox::addItems: too many entries!" );
1581                 // skip remaining entries, list cannot hold them, anyway
1582                 break;
1583             }
1584 
1585             pBox->InsertEntry( *pItems++, nP++ );
1586 		}
1587 	}
1588 }
1589 
removeItems(sal_Int16 nPos,sal_Int16 nCount)1590 void VCLXListBox::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(::com::sun::star::uno::RuntimeException)
1591 {
1592 	::vos::OGuard aGuard( GetMutex() );
1593 
1594 	ListBox* pBox = (ListBox*) GetWindow();
1595 	if ( pBox )
1596 	{
1597 		for ( sal_uInt16 n = nCount; n; )
1598 			pBox->RemoveEntry( nPos + (--n) );
1599 	}
1600 }
1601 
getItemCount()1602 sal_Int16 VCLXListBox::getItemCount() throw(::com::sun::star::uno::RuntimeException)
1603 {
1604 	::vos::OGuard aGuard( GetMutex() );
1605 
1606 	ListBox* pBox = (ListBox*) GetWindow();
1607 	return pBox ? pBox->GetEntryCount() : 0;
1608 }
1609 
getItem(sal_Int16 nPos)1610 ::rtl::OUString VCLXListBox::getItem( sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException)
1611 {
1612 	::vos::OGuard aGuard( GetMutex() );
1613 
1614 	String aItem;
1615 	ListBox* pBox = (ListBox*) GetWindow();
1616 	if ( pBox )
1617 		aItem = pBox->GetEntry( nPos );
1618 	return aItem;
1619 }
1620 
getItems()1621 ::com::sun::star::uno::Sequence< ::rtl::OUString> VCLXListBox::getItems() throw(::com::sun::star::uno::RuntimeException)
1622 {
1623 	::vos::OGuard aGuard( GetMutex() );
1624 
1625 	::com::sun::star::uno::Sequence< ::rtl::OUString> aSeq;
1626 	ListBox* pBox = (ListBox*) GetWindow();
1627 	if ( pBox )
1628 	{
1629 		sal_uInt16 nEntries = pBox->GetEntryCount();
1630 		aSeq = ::com::sun::star::uno::Sequence< ::rtl::OUString>( nEntries );
1631 		for ( sal_uInt16 n = nEntries; n; )
1632 		{
1633 			--n;
1634 			aSeq.getArray()[n] = ::rtl::OUString( pBox->GetEntry( n ) );
1635 		}
1636 	}
1637 	return aSeq;
1638 }
1639 
getSelectedItemPos()1640 sal_Int16 VCLXListBox::getSelectedItemPos() throw(::com::sun::star::uno::RuntimeException)
1641 {
1642 	::vos::OGuard aGuard( GetMutex() );
1643 
1644 	ListBox* pBox = (ListBox*) GetWindow();
1645 	return pBox ? pBox->GetSelectEntryPos() : 0;
1646 }
1647 
getSelectedItemsPos()1648 ::com::sun::star::uno::Sequence<sal_Int16> VCLXListBox::getSelectedItemsPos() throw(::com::sun::star::uno::RuntimeException)
1649 {
1650 	::vos::OGuard aGuard( GetMutex() );
1651 
1652 	::com::sun::star::uno::Sequence<sal_Int16> aSeq;
1653 	ListBox* pBox = (ListBox*) GetWindow();
1654 	if ( pBox )
1655 	{
1656 		sal_uInt16 nSelEntries = pBox->GetSelectEntryCount();
1657 		aSeq = ::com::sun::star::uno::Sequence<sal_Int16>( nSelEntries );
1658 		for ( sal_uInt16 n = 0; n < nSelEntries; n++ )
1659 			aSeq.getArray()[n] = pBox->GetSelectEntryPos( n );
1660 	}
1661 	return aSeq;
1662 }
1663 
getSelectedItem()1664 ::rtl::OUString VCLXListBox::getSelectedItem() throw(::com::sun::star::uno::RuntimeException)
1665 {
1666 	::vos::OGuard aGuard( GetMutex() );
1667 
1668 	String aItem;
1669 	ListBox* pBox = (ListBox*) GetWindow();
1670 	if ( pBox )
1671 		aItem = pBox->GetSelectEntry();
1672 	return aItem;
1673 }
1674 
getSelectedItems()1675 ::com::sun::star::uno::Sequence< ::rtl::OUString> VCLXListBox::getSelectedItems() throw(::com::sun::star::uno::RuntimeException)
1676 {
1677 	::vos::OGuard aGuard( GetMutex() );
1678 
1679 	::com::sun::star::uno::Sequence< ::rtl::OUString> aSeq;
1680 	ListBox* pBox = (ListBox*) GetWindow();
1681 	if ( pBox )
1682 	{
1683 		sal_uInt16 nSelEntries = pBox->GetSelectEntryCount();
1684 		aSeq = ::com::sun::star::uno::Sequence< ::rtl::OUString>( nSelEntries );
1685 		for ( sal_uInt16 n = 0; n < nSelEntries; n++ )
1686 			aSeq.getArray()[n] = ::rtl::OUString( pBox->GetSelectEntry( n ) );
1687 	}
1688 	return aSeq;
1689 }
1690 
selectItemPos(sal_Int16 nPos,sal_Bool bSelect)1691 void VCLXListBox::selectItemPos( sal_Int16 nPos, sal_Bool bSelect ) throw(::com::sun::star::uno::RuntimeException)
1692 {
1693 	::vos::OGuard aGuard( GetMutex() );
1694 
1695 	ListBox* pBox = (ListBox*) GetWindow();
1696 	if ( pBox && ( pBox->IsEntryPosSelected( nPos ) != bSelect ) )
1697     {
1698 		pBox->SelectEntryPos( nPos, bSelect );
1699 
1700         // VCL doesn't call select handler after API call.
1701         // ImplCallItemListeners();
1702 
1703         // #107218# Call same listeners like VCL would do after user interaction
1704         SetSynthesizingVCLEvent( sal_True );
1705         pBox->Select();
1706         SetSynthesizingVCLEvent( sal_False );
1707     }
1708 }
1709 
selectItemsPos(const::com::sun::star::uno::Sequence<sal_Int16> & aPositions,sal_Bool bSelect)1710 void VCLXListBox::selectItemsPos( const ::com::sun::star::uno::Sequence<sal_Int16>& aPositions, sal_Bool bSelect ) throw(::com::sun::star::uno::RuntimeException)
1711 {
1712 	::vos::OGuard aGuard( GetMutex() );
1713 
1714 	ListBox* pBox = (ListBox*) GetWindow();
1715 	if ( pBox )
1716 	{
1717         sal_Bool bChanged = sal_False;
1718 		for ( sal_uInt16 n = (sal_uInt16)aPositions.getLength(); n; )
1719         {
1720             sal_uInt16 nPos = (sal_uInt16) aPositions.getConstArray()[--n];
1721             if ( pBox->IsEntryPosSelected( nPos ) != bSelect )
1722             {
1723 			    pBox->SelectEntryPos( nPos, bSelect );
1724                 bChanged = sal_True;
1725             }
1726         }
1727 
1728         if ( bChanged )
1729         {
1730             // VCL doesn't call select handler after API call.
1731             // ImplCallItemListeners();
1732 
1733             // #107218# Call same listeners like VCL would do after user interaction
1734             SetSynthesizingVCLEvent( sal_True );
1735             pBox->Select();
1736             SetSynthesizingVCLEvent( sal_False );
1737         }
1738 	}
1739 }
1740 
selectItem(const::rtl::OUString & rItemText,sal_Bool bSelect)1741 void VCLXListBox::selectItem( const ::rtl::OUString& rItemText, sal_Bool bSelect ) throw(::com::sun::star::uno::RuntimeException)
1742 {
1743 	::vos::OGuard aGuard( GetMutex() );
1744 
1745 	ListBox* pBox = (ListBox*) GetWindow();
1746 	if ( pBox )
1747     {
1748         String aItemText( rItemText );
1749 		selectItemPos( pBox->GetEntryPos( aItemText ), bSelect );
1750     }
1751 }
1752 
1753 
setDropDownLineCount(sal_Int16 nLines)1754 void VCLXListBox::setDropDownLineCount( sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException)
1755 {
1756 	::vos::OGuard aGuard( GetMutex() );
1757 
1758 	ListBox* pBox = (ListBox*) GetWindow();
1759 	if ( pBox )
1760 		pBox->SetDropDownLineCount( nLines );
1761 }
1762 
getDropDownLineCount()1763 sal_Int16 VCLXListBox::getDropDownLineCount() throw(::com::sun::star::uno::RuntimeException)
1764 {
1765 	::vos::OGuard aGuard( GetMutex() );
1766 
1767 	sal_Int16 nLines = 0;
1768 	ListBox* pBox = (ListBox*) GetWindow();
1769 	if ( pBox )
1770 		nLines = pBox->GetDropDownLineCount();
1771 	return nLines;
1772 }
1773 
isMutipleMode()1774 sal_Bool VCLXListBox::isMutipleMode() throw(::com::sun::star::uno::RuntimeException)
1775 {
1776 	::vos::OGuard aGuard( GetMutex() );
1777 
1778 	sal_Bool bMulti = sal_False;
1779 	ListBox* pBox = (ListBox*) GetWindow();
1780 	if ( pBox )
1781 		bMulti = pBox->IsMultiSelectionEnabled();
1782 	return bMulti;
1783 }
1784 
setMultipleMode(sal_Bool bMulti)1785 void VCLXListBox::setMultipleMode( sal_Bool bMulti ) throw(::com::sun::star::uno::RuntimeException)
1786 {
1787 	::vos::OGuard aGuard( GetMutex() );
1788 
1789 	ListBox* pBox = (ListBox*) GetWindow();
1790 	if ( pBox )
1791 		pBox->EnableMultiSelection( bMulti );
1792 }
1793 
makeVisible(sal_Int16 nEntry)1794 void VCLXListBox::makeVisible( sal_Int16 nEntry ) throw(::com::sun::star::uno::RuntimeException)
1795 {
1796 	::vos::OGuard aGuard( GetMutex() );
1797 
1798 	ListBox* pBox = (ListBox*) GetWindow();
1799 	if ( pBox )
1800 		pBox->SetTopEntry( nEntry );
1801 }
1802 
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)1803 void VCLXListBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1804 {
1805     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
1806         // since we call listeners below, there is a potential that we will be destroyed
1807         // in during the listener call. To prevent the resulting crashs, we keep us
1808         // alive as long as we're here
1809         // #20178# - 2003-10-01 - fs@openoffice.org
1810 
1811 	switch ( rVclWindowEvent.GetId() )
1812 	{
1813 		case VCLEVENT_LISTBOX_SELECT:
1814 		{
1815 			ListBox* pListBox = (ListBox*)GetWindow();
1816 
1817             if( pListBox )
1818             {
1819 			    sal_Bool bDropDown = ( pListBox->GetStyle() & WB_DROPDOWN ) ? sal_True : sal_False;
1820 			    if ( bDropDown && !IsSynthesizingVCLEvent() && maActionListeners.getLength() )
1821 			    {
1822 				    // Bei DropDown den ActionListener rufen...
1823 				    ::com::sun::star::awt::ActionEvent aEvent;
1824 				    aEvent.Source = (::cppu::OWeakObject*)this;
1825 				    aEvent.ActionCommand = pListBox->GetSelectEntry();
1826 				    maActionListeners.actionPerformed( aEvent );
1827 			    }
1828 
1829 			    if ( maItemListeners.getLength() )
1830 			    {
1831                     ImplCallItemListeners();
1832 			    }
1833             }
1834 		}
1835 		break;
1836 
1837 		case VCLEVENT_LISTBOX_DOUBLECLICK:
1838 			if ( GetWindow() && maActionListeners.getLength() )
1839 			{
1840 				::com::sun::star::awt::ActionEvent aEvent;
1841 				aEvent.Source = (::cppu::OWeakObject*)this;
1842 				aEvent.ActionCommand = ((ListBox*)GetWindow())->GetSelectEntry();
1843 				maActionListeners.actionPerformed( aEvent );
1844 			}
1845     		break;
1846 
1847 		default:
1848             VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
1849 			break;
1850 	}
1851 }
1852 
CreateAccessibleContext()1853 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXListBox::CreateAccessibleContext()
1854 {
1855 	::vos::OGuard aGuard( GetMutex() );
1856 
1857     return getAccessibleFactory().createAccessibleContext( this );
1858 }
1859 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)1860 void VCLXListBox::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
1861 {
1862 	::vos::OGuard aGuard( GetMutex() );
1863 
1864 	ListBox* pListBox = (ListBox*)GetWindow();
1865 	if ( pListBox )
1866 	{
1867 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
1868 		switch ( nPropType )
1869 		{
1870             case BASEPROPERTY_ITEM_SEPARATOR_POS:
1871             {
1872                 sal_Int16 nSeparatorPos(0);
1873                 if ( Value >>= nSeparatorPos )
1874                     pListBox->SetSeparatorPos( nSeparatorPos );
1875             }
1876             break;
1877 			case BASEPROPERTY_READONLY:
1878 			{
1879 				sal_Bool b = sal_Bool();
1880 				if ( Value >>= b )
1881  					pListBox->SetReadOnly( b);
1882 			}
1883 			break;
1884 			case BASEPROPERTY_MULTISELECTION:
1885 			{
1886 				sal_Bool b = sal_Bool();
1887 				if ( Value >>= b )
1888  					pListBox->EnableMultiSelection( b );
1889 			}
1890 			break;
1891 			case BASEPROPERTY_MULTISELECTION_SIMPLEMODE:
1892                 ::toolkit::adjustBooleanWindowStyle( Value, pListBox, WB_SIMPLEMODE, sal_False );
1893 			    break;
1894 			case BASEPROPERTY_LINECOUNT:
1895 			{
1896 				sal_Int16 n = sal_Int16();
1897 				if ( Value >>= n )
1898  					pListBox->SetDropDownLineCount( n );
1899 			}
1900 			break;
1901 			case BASEPROPERTY_STRINGITEMLIST:
1902 			{
1903 				::com::sun::star::uno::Sequence< ::rtl::OUString> aItems;
1904 				if ( Value >>= aItems )
1905 				{
1906 					pListBox->Clear();
1907 					addItems( aItems, 0 );
1908 				}
1909 			}
1910 			break;
1911 			case BASEPROPERTY_SELECTEDITEMS:
1912 			{
1913 				::com::sun::star::uno::Sequence<sal_Int16> aItems;
1914 				if ( Value >>= aItems )
1915 				{
1916 					for ( sal_uInt16 n = pListBox->GetEntryCount(); n; )
1917 						pListBox->SelectEntryPos( --n, sal_False );
1918 
1919                     if ( aItems.getLength() )
1920 					    selectItemsPos( aItems, sal_True );
1921                     else
1922                         pListBox->SetNoSelection();
1923 
1924 					if ( !pListBox->GetSelectEntryCount() )
1925 						pListBox->SetTopEntry( 0 );
1926 				}
1927 			}
1928 			break;
1929 			default:
1930 			{
1931 				VCLXWindow::setProperty( PropertyName, Value );
1932 			}
1933 		}
1934 	}
1935 }
1936 
getProperty(const::rtl::OUString & PropertyName)1937 ::com::sun::star::uno::Any VCLXListBox::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
1938 {
1939 	::vos::OGuard aGuard( GetMutex() );
1940 
1941 	::com::sun::star::uno::Any aProp;
1942 	ListBox* pListBox = (ListBox*)GetWindow();
1943 	if ( pListBox )
1944 	{
1945 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
1946 		switch ( nPropType )
1947 		{
1948             case BASEPROPERTY_ITEM_SEPARATOR_POS:
1949                 aProp <<= sal_Int16( pListBox->GetSeparatorPos() );
1950                 break;
1951 			case BASEPROPERTY_READONLY:
1952 			{
1953  				aProp <<= (sal_Bool) pListBox->IsReadOnly();
1954 			}
1955 			break;
1956 			case BASEPROPERTY_MULTISELECTION:
1957 			{
1958  				aProp <<= (sal_Bool) pListBox->IsMultiSelectionEnabled();
1959 			}
1960 			break;
1961 			case BASEPROPERTY_MULTISELECTION_SIMPLEMODE:
1962             {
1963                 aProp <<= (sal_Bool)( ( pListBox->GetStyle() & WB_SIMPLEMODE ) == 0 );
1964             }
1965             break;
1966 			case BASEPROPERTY_LINECOUNT:
1967 			{
1968  				aProp <<= (sal_Int16) pListBox->GetDropDownLineCount();
1969 			}
1970 			break;
1971 			case BASEPROPERTY_STRINGITEMLIST:
1972 			{
1973 				sal_uInt16 nItems = pListBox->GetEntryCount();
1974 				::com::sun::star::uno::Sequence< ::rtl::OUString> aSeq( nItems );
1975 				::rtl::OUString* pStrings = aSeq.getArray();
1976 				for ( sal_uInt16 n = 0; n < nItems; n++ )
1977 					pStrings[n] = pListBox->GetEntry( n );
1978 				aProp <<= aSeq;
1979 
1980 			}
1981 			break;
1982 			default:
1983 			{
1984 				aProp <<= VCLXWindow::getProperty( PropertyName );
1985 			}
1986 		}
1987 	}
1988 	return aProp;
1989 }
1990 
getMinimumSize()1991 ::com::sun::star::awt::Size VCLXListBox::getMinimumSize(  ) throw(::com::sun::star::uno::RuntimeException)
1992 {
1993 	::vos::OGuard aGuard( GetMutex() );
1994 
1995 	Size aSz;
1996 	ListBox* pListBox = (ListBox*) GetWindow();
1997 	if ( pListBox )
1998 		aSz = pListBox->CalcMinimumSize();
1999 	return AWTSize(aSz);
2000 }
2001 
getPreferredSize()2002 ::com::sun::star::awt::Size VCLXListBox::getPreferredSize(  ) throw(::com::sun::star::uno::RuntimeException)
2003 {
2004 	::vos::OGuard aGuard( GetMutex() );
2005 
2006 	Size aSz;
2007 	ListBox* pListBox = (ListBox*) GetWindow();
2008 	if ( pListBox )
2009 	{
2010 		aSz = pListBox->CalcMinimumSize();
2011 		if ( pListBox->GetStyle() & WB_DROPDOWN )
2012 			aSz.Height() += 4;
2013 	}
2014 	return AWTSize(aSz);
2015 }
2016 
calcAdjustedSize(const::com::sun::star::awt::Size & rNewSize)2017 ::com::sun::star::awt::Size VCLXListBox::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException)
2018 {
2019 	::vos::OGuard aGuard( GetMutex() );
2020 
2021 	Size aSz = VCLSize(rNewSize);
2022 	ListBox* pListBox = (ListBox*) GetWindow();
2023 	if ( pListBox )
2024 		aSz = pListBox->CalcAdjustedSize( aSz );
2025 	return AWTSize(aSz);
2026 }
2027 
getMinimumSize(sal_Int16 nCols,sal_Int16 nLines)2028 ::com::sun::star::awt::Size VCLXListBox::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException)
2029 {
2030 	::vos::OGuard aGuard( GetMutex() );
2031 
2032 	Size aSz;
2033 	ListBox* pListBox = (ListBox*) GetWindow();
2034 	if ( pListBox )
2035 		aSz = pListBox->CalcSize( nCols, nLines );
2036 	return AWTSize(aSz);
2037 }
2038 
getColumnsAndLines(sal_Int16 & nCols,sal_Int16 & nLines)2039 void VCLXListBox::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException)
2040 {
2041 	::vos::OGuard aGuard( GetMutex() );
2042 
2043 	nCols = nLines = 0;
2044 	ListBox* pListBox = (ListBox*) GetWindow();
2045 	if ( pListBox )
2046 	{
2047 		sal_uInt16 nC, nL;
2048 		pListBox->GetMaxVisColumnsAndLines( nC, nL );
2049 		nCols = nC;
2050 		nLines = nL;
2051 	}
2052 }
2053 
ImplCallItemListeners()2054 void VCLXListBox::ImplCallItemListeners()
2055 {
2056 	ListBox* pListBox = (ListBox*) GetWindow();
2057     if ( pListBox && maItemListeners.getLength() )
2058     {
2059 	    ::com::sun::star::awt::ItemEvent aEvent;
2060 	    aEvent.Source = (::cppu::OWeakObject*)this;
2061 	    aEvent.Highlighted = sal_False;
2062 
2063 	    // Bei Mehrfachselektion 0xFFFF, sonst die ID
2064 	    aEvent.Selected = (pListBox->GetSelectEntryCount() == 1 ) ? pListBox->GetSelectEntryPos() : 0xFFFF;
2065 
2066 	    maItemListeners.itemStateChanged( aEvent );
2067     }
2068 }
2069 namespace
2070 {
lcl_getImageFromURL(const::rtl::OUString & i_rImageURL)2071 	 Image lcl_getImageFromURL( const ::rtl::OUString& i_rImageURL )
2072 	 {
2073 		 if ( !i_rImageURL.getLength() )
2074 			 return Image();
2075 
2076 		try
2077 		{
2078 			 ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
2079 			 Reference< XGraphicProvider > xProvider;
2080 			 if ( aContext.createComponent( "com.sun.star.graphic.GraphicProvider", xProvider ) )
2081 			 {
2082 				 ::comphelper::NamedValueCollection aMediaProperties;
2083 				 aMediaProperties.put( "URL", i_rImageURL );
2084 				 Reference< XGraphic > xGraphic = xProvider->queryGraphic( aMediaProperties.getPropertyValues() );
2085 				return Image( xGraphic );
2086 			 }
2087 		 }
2088 		 catch( const uno::Exception& )
2089 		 {
2090 			 DBG_UNHANDLED_EXCEPTION();
2091 		 }
2092 		 return Image();
2093 	 }
2094 }
listItemInserted(const ItemListEvent & i_rEvent)2095 void SAL_CALL VCLXListBox::listItemInserted( const ItemListEvent& i_rEvent ) throw (RuntimeException)
2096 {
2097 	::vos::OGuard aGuard( GetMutex() );
2098 
2099     ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() );
2100 
2101     ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemInserted: no ListBox?!" );
2102     ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition <= sal_Int32( pListBox->GetEntryCount() ) ),
2103         "VCLXListBox::listItemInserted: illegal (inconsistent) item position!" );
2104     pListBox->InsertEntry(
2105         i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : ::rtl::OUString(),
2106         i_rEvent.ItemImageURL.IsPresent ? TkResMgr::getImageFromURL( i_rEvent.ItemImageURL.Value ) : Image(),
2107         i_rEvent.ItemPosition );
2108 }
2109 
listItemRemoved(const ItemListEvent & i_rEvent)2110 void SAL_CALL VCLXListBox::listItemRemoved( const ItemListEvent& i_rEvent ) throw (RuntimeException)
2111 {
2112 	::vos::OGuard aGuard( GetMutex() );
2113 
2114     ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() );
2115 
2116     ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemRemoved: no ListBox?!" );
2117     ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pListBox->GetEntryCount() ) ),
2118         "VCLXListBox::listItemRemoved: illegal (inconsistent) item position!" );
2119 
2120     pListBox->RemoveEntry( i_rEvent.ItemPosition );
2121 }
2122 
listItemModified(const ItemListEvent & i_rEvent)2123 void SAL_CALL VCLXListBox::listItemModified( const ItemListEvent& i_rEvent ) throw (RuntimeException)
2124 {
2125 	::vos::OGuard aGuard( GetMutex() );
2126 
2127     ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() );
2128 
2129     ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" );
2130     ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pListBox->GetEntryCount() ) ),
2131         "VCLXListBox::listItemModified: illegal (inconsistent) item position!" );
2132 
2133     // VCL's ListBox does not support changing an entry's text or image, so remove and re-insert
2134 
2135     const ::rtl::OUString sNewText = i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : ::rtl::OUString( pListBox->GetEntry( i_rEvent.ItemPosition ) );
2136     const Image aNewImage( i_rEvent.ItemImageURL.IsPresent ? TkResMgr::getImageFromURL( i_rEvent.ItemImageURL.Value ) : pListBox->GetEntryImage( i_rEvent.ItemPosition  ) );
2137 
2138     pListBox->RemoveEntry( i_rEvent.ItemPosition );
2139     pListBox->InsertEntry( sNewText, aNewImage, i_rEvent.ItemPosition );
2140 }
2141 
allItemsRemoved(const EventObject & i_rEvent)2142 void SAL_CALL VCLXListBox::allItemsRemoved( const EventObject& i_rEvent ) throw (RuntimeException)
2143 {
2144 	::vos::OGuard aGuard( GetMutex() );
2145 
2146     ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() );
2147     ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" );
2148 
2149     pListBox->Clear();
2150 
2151     (void)i_rEvent;
2152 }
2153 
itemListChanged(const EventObject & i_rEvent)2154 void SAL_CALL VCLXListBox::itemListChanged( const EventObject& i_rEvent ) throw (RuntimeException)
2155 {
2156 	::vos::OGuard aGuard( GetMutex() );
2157 
2158     ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() );
2159     ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" );
2160 
2161     pListBox->Clear();
2162 
2163     uno::Reference< beans::XPropertySet > xPropSet( i_rEvent.Source, uno::UNO_QUERY_THROW );
2164     uno::Reference< beans::XPropertySetInfo > xPSI( xPropSet->getPropertySetInfo(), uno::UNO_QUERY_THROW );
2165     uno::Reference< resource::XStringResourceResolver > xStringResourceResolver;
2166     if ( xPSI->hasPropertyByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" ) ) ) )
2167     {
2168         xStringResourceResolver.set(
2169             xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" ) ) ),
2170             uno::UNO_QUERY
2171         );
2172     }
2173 
2174 
2175     Reference< XItemList > xItemList( i_rEvent.Source, uno::UNO_QUERY_THROW );
2176     uno::Sequence< beans::Pair< ::rtl::OUString, ::rtl::OUString > > aItems = xItemList->getAllItems();
2177     for ( sal_Int32 i=0; i<aItems.getLength(); ++i )
2178     {
2179         ::rtl::OUString aLocalizationKey( aItems[i].First );
2180         if ( xStringResourceResolver.is() && aLocalizationKey.getLength() != 0 && aLocalizationKey[0] == '&' )
2181         {
2182             aLocalizationKey = xStringResourceResolver->resolveString(aLocalizationKey.copy( 1 ));
2183         }
2184         pListBox->InsertEntry( aLocalizationKey, lcl_getImageFromURL( aItems[i].Second ) );
2185     }
2186 }
2187 
disposing(const EventObject & i_rEvent)2188 void SAL_CALL VCLXListBox::disposing( const EventObject& i_rEvent ) throw (RuntimeException)
2189 {
2190     // just disambiguate
2191     VCLXWindow::disposing( i_rEvent );
2192 }
2193 
2194 //	----------------------------------------------------
2195 //	class VCLXMessageBox
2196 //	----------------------------------------------------
2197 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)2198 void VCLXMessageBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2199 {
2200     VCLXTopWindow::ImplGetPropertyIds( rIds );
2201 }
2202 
VCLXMessageBox()2203 VCLXMessageBox::VCLXMessageBox()
2204 {
2205 }
2206 
~VCLXMessageBox()2207 VCLXMessageBox::~VCLXMessageBox()
2208 {
2209 }
2210 
2211 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)2212 ::com::sun::star::uno::Any VCLXMessageBox::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
2213 {
2214 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
2215 										SAL_STATIC_CAST( ::com::sun::star::awt::XMessageBox*, this ) );
2216 	return (aRet.hasValue() ? aRet : VCLXTopWindow::queryInterface( rType ));
2217 }
2218 
2219 // ::com::sun::star::lang::XTypeProvider
2220 IMPL_XTYPEPROVIDER_START( VCLXMessageBox )
2221 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMessageBox>* ) NULL ),
2222 	VCLXTopWindow::getTypes()
2223 IMPL_XTYPEPROVIDER_END
2224 
2225 void VCLXMessageBox::setCaptionText( const ::rtl::OUString& rText ) throw(::com::sun::star::uno::RuntimeException)
2226 {
2227 	::vos::OGuard aGuard( GetMutex() );
2228 
2229 	Window* pWindow = GetWindow();
2230 	if ( pWindow )
2231 		pWindow->SetText( rText );
2232 }
2233 
getCaptionText()2234 ::rtl::OUString VCLXMessageBox::getCaptionText() throw(::com::sun::star::uno::RuntimeException)
2235 {
2236 	::vos::OGuard aGuard( GetMutex() );
2237 
2238 	String aText;
2239 	Window* pWindow = GetWindow();
2240 	if ( pWindow )
2241 		aText = pWindow->GetText();
2242 	return aText;
2243 }
2244 
setMessageText(const::rtl::OUString & rText)2245 void VCLXMessageBox::setMessageText( const ::rtl::OUString& rText ) throw(::com::sun::star::uno::RuntimeException)
2246 {
2247 	::vos::OGuard aGuard( GetMutex() );
2248 
2249 	MessBox* pBox = (MessBox*)GetWindow();
2250 	if ( pBox )
2251 		pBox->SetMessText( rText );
2252 }
2253 
getMessageText()2254 ::rtl::OUString VCLXMessageBox::getMessageText() throw(::com::sun::star::uno::RuntimeException)
2255 {
2256 	::vos::OGuard aGuard( GetMutex() );
2257 
2258 	::rtl::OUString aText;
2259 	MessBox* pBox = (MessBox*)GetWindow();
2260 	if ( pBox )
2261 		aText = pBox->GetMessText();
2262 	return aText;
2263 }
2264 
execute()2265 sal_Int16 VCLXMessageBox::execute() throw(::com::sun::star::uno::RuntimeException)
2266 {
2267 	::vos::OGuard aGuard( GetMutex() );
2268 
2269 	MessBox* pBox = (MessBox*)GetWindow();
2270 	return pBox ? pBox->Execute() : 0;
2271 }
2272 
getMinimumSize()2273 ::com::sun::star::awt::Size SAL_CALL VCLXMessageBox::getMinimumSize() throw(::com::sun::star::uno::RuntimeException)
2274 {
2275     ::vos::OGuard aGuard( GetMutex() );
2276     return ::com::sun::star::awt::Size( 250, 100 );
2277 }
2278 
2279 //	----------------------------------------------------
2280 //	class VCLXDialog
2281 //	----------------------------------------------------
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)2282 void VCLXDialog::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2283 {
2284     VCLXTopWindow::ImplGetPropertyIds( rIds );
2285 }
2286 
VCLXDialog()2287 VCLXDialog::VCLXDialog()
2288 {
2289 }
2290 
~VCLXDialog()2291 VCLXDialog::~VCLXDialog()
2292 {
2293 #ifndef __SUNPRO_CC
2294     OSL_TRACE ("%s", __FUNCTION__);
2295 #endif
2296 }
2297 
2298 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)2299 ::com::sun::star::uno::Any VCLXDialog::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
2300 {
2301 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
2302 										SAL_STATIC_CAST( ::com::sun::star::awt::XDialog2*, this ),
2303 										SAL_STATIC_CAST( ::com::sun::star::awt::XDialog*, this ) );
2304 	return (aRet.hasValue() ? aRet : VCLXTopWindow::queryInterface( rType ));
2305 }
2306 
2307 // ::com::sun::star::lang::XTypeProvider
2308 IMPL_XTYPEPROVIDER_START( VCLXDialog )
2309 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDialog2>* ) NULL ),
2310 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDialog>* ) NULL ),
2311 	VCLXTopWindow::getTypes()
2312 IMPL_XTYPEPROVIDER_END
2313 
2314 void SAL_CALL VCLXDialog::endDialog( ::sal_Int32 i_result ) throw (RuntimeException)
2315 {
2316     ::vos::OGuard aGuard( GetMutex() );
2317 
2318     Dialog* pDialog = dynamic_cast< Dialog* >( GetWindow() );
2319     if ( pDialog )
2320         pDialog->EndDialog( i_result );
2321 }
2322 
setHelpId(const::rtl::OUString & rId)2323 void SAL_CALL VCLXDialog::setHelpId( const ::rtl::OUString& rId ) throw (RuntimeException)
2324 {
2325     ::vos::OGuard aGuard( GetMutex() );
2326 
2327     Window* pWindow = GetWindow();
2328     if ( pWindow )
2329         pWindow->SetHelpId( rtl::OUStringToOString( rId, RTL_TEXTENCODING_UTF8 ) );
2330 }
2331 
setTitle(const::rtl::OUString & Title)2332 void VCLXDialog::setTitle( const ::rtl::OUString& Title ) throw(::com::sun::star::uno::RuntimeException)
2333 {
2334 	::vos::OGuard aGuard( GetMutex() );
2335 
2336 	Window* pWindow = GetWindow();
2337 	if ( pWindow )
2338 		pWindow->SetText( Title );
2339 }
2340 
getTitle()2341 ::rtl::OUString VCLXDialog::getTitle() throw(::com::sun::star::uno::RuntimeException)
2342 {
2343 	::vos::OGuard aGuard( GetMutex() );
2344 
2345 	::rtl::OUString aTitle;
2346 	Window* pWindow = GetWindow();
2347 	if ( pWindow )
2348 		aTitle = pWindow->GetText();
2349 	return aTitle;
2350 }
2351 
execute()2352 sal_Int16 VCLXDialog::execute() throw(::com::sun::star::uno::RuntimeException)
2353 {
2354 	::vos::OGuard aGuard( GetMutex() );
2355 
2356 	sal_Int16 nRet = 0;
2357 	if ( GetWindow() )
2358 	{
2359 		Dialog* pDlg = (Dialog*) GetWindow();
2360 		Window* pParent = pDlg->GetWindow( WINDOW_PARENTOVERLAP );
2361 		Window* pOldParent = NULL;
2362         Window* pSetParent = NULL;
2363 		if ( pParent && !pParent->IsReallyVisible() )
2364 		{
2365 			pOldParent = pDlg->GetParent();
2366             Window* pFrame = pDlg->GetWindow( WINDOW_FRAME );
2367             if( pFrame != pDlg )
2368             {
2369                 pDlg->SetParent( pFrame );
2370                 pSetParent = pFrame;
2371             }
2372 		}
2373 
2374 		nRet = pDlg->Execute();
2375 
2376         // set the parent back only in case no new parent was set from outside
2377         // in other words, revert only own changes
2378 		if ( pOldParent && pDlg->GetParent() == pSetParent )
2379 			pDlg->SetParent( pOldParent );
2380 	}
2381 	return nRet;
2382 }
2383 
endExecute()2384 void VCLXDialog::endExecute() throw(::com::sun::star::uno::RuntimeException)
2385 {
2386     endDialog(0);
2387 }
2388 
draw(sal_Int32 nX,sal_Int32 nY)2389 void SAL_CALL VCLXDialog::draw( sal_Int32 nX, sal_Int32 nY ) throw(::com::sun::star::uno::RuntimeException)
2390 {
2391 	::vos::OGuard aGuard( GetMutex() );
2392 	Window* pWindow = GetWindow();
2393 
2394 	if ( pWindow )
2395 	{
2396 		OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
2397 		if ( !pDev )
2398 			pDev = pWindow->GetParent();
2399 
2400 		Size aSize = pDev->PixelToLogic( pWindow->GetSizePixel() );
2401 		Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
2402 
2403 		pWindow->Draw( pDev, aPos, aSize, WINDOW_DRAW_NOCONTROLS );
2404     }
2405 }
2406 
getInfo()2407 ::com::sun::star::awt::DeviceInfo VCLXDialog::getInfo() throw(::com::sun::star::uno::RuntimeException)
2408 {
2409 	::com::sun::star::awt::DeviceInfo aInfo = VCLXDevice::getInfo();
2410 
2411 	::vos::OGuard aGuard( GetMutex() );
2412 	Dialog* pDlg = (Dialog*) GetWindow();
2413 	if ( pDlg )
2414 	    pDlg->GetDrawWindowBorder( aInfo.LeftInset, aInfo.TopInset, aInfo.RightInset, aInfo.BottomInset );
2415 
2416 	return aInfo;
2417 }
2418 
2419 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)2420 void SAL_CALL VCLXDialog::setProperty(
2421     const ::rtl::OUString& PropertyName,
2422     const ::com::sun::star::uno::Any& Value )
2423 throw(::com::sun::star::uno::RuntimeException)
2424 {
2425 	::vos::OGuard aGuard( GetMutex() );
2426 
2427 	Dialog* pDialog = (Dialog*)GetWindow();
2428 	if ( pDialog )
2429 	{
2430 		sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
2431 
2432 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
2433 		switch ( nPropType )
2434 		{
2435 			case BASEPROPERTY_GRAPHIC:
2436             {
2437                 Reference< XGraphic > xGraphic;
2438                 if (( Value >>= xGraphic ) && xGraphic.is() )
2439                 {
2440                     Image aImage( xGraphic );
2441 
2442                     Wallpaper aWallpaper( aImage.GetBitmapEx());
2443                     aWallpaper.SetStyle( WALLPAPER_SCALE );
2444                     pDialog->SetBackground( aWallpaper );
2445                 }
2446                 else if ( bVoid || !xGraphic.is() )
2447                 {
2448                     Color aColor = pDialog->GetControlBackground().GetColor();
2449                     if ( aColor == COL_AUTO )
2450                         aColor = pDialog->GetSettings().GetStyleSettings().GetDialogColor();
2451 
2452                     Wallpaper aWallpaper( aColor );
2453                     pDialog->SetBackground( aWallpaper );
2454                 }
2455             }
2456             break;
2457 
2458             default:
2459 			{
2460 				VCLXWindow::setProperty( PropertyName, Value );
2461 			}
2462         }
2463     }
2464 }
2465 
2466 //	----------------------------------------------------
2467 //	class VCLXTabPage
2468 //	----------------------------------------------------
VCLXTabPage()2469 VCLXTabPage::VCLXTabPage()
2470 {
2471 }
2472 
~VCLXTabPage()2473 VCLXTabPage::~VCLXTabPage()
2474 {
2475 }
2476 
queryInterface(const::com::sun::star::uno::Type & rType)2477 ::com::sun::star::uno::Any SAL_CALL VCLXTabPage::queryInterface(const ::com::sun::star::uno::Type & rType )
2478 throw(::com::sun::star::uno::RuntimeException)
2479 {
2480 	return VCLXContainer::queryInterface( rType );
2481 }
2482 
2483 // ::com::sun::star::lang::XTypeProvider
IMPL_XTYPEPROVIDER_START(VCLXTabPage)2484 IMPL_XTYPEPROVIDER_START( VCLXTabPage )
2485 	VCLXContainer::getTypes()
2486 IMPL_XTYPEPROVIDER_END
2487 
2488 // ::com::sun::star::awt::XView
2489 void SAL_CALL VCLXTabPage::draw( sal_Int32 nX, sal_Int32 nY )
2490 throw(::com::sun::star::uno::RuntimeException)
2491 {
2492 	::vos::OGuard aGuard( GetMutex() );
2493 	Window* pWindow = GetWindow();
2494 
2495 	if ( pWindow )
2496 	{
2497 		OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
2498 		if ( !pDev )
2499 			pDev = pWindow->GetParent();
2500 
2501 		Size aSize = pDev->PixelToLogic( pWindow->GetSizePixel() );
2502 		Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
2503 
2504 		pWindow->Draw( pDev, aPos, aSize, WINDOW_DRAW_NOCONTROLS );
2505     }
2506 }
2507 
2508 // ::com::sun::star::awt::XDevice,
getInfo()2509 ::com::sun::star::awt::DeviceInfo SAL_CALL VCLXTabPage::getInfo()
2510 throw(::com::sun::star::uno::RuntimeException)
2511 {
2512 	::com::sun::star::awt::DeviceInfo aInfo = VCLXDevice::getInfo();
2513 	return aInfo;
2514 }
2515 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)2516 void SAL_CALL VCLXTabPage::setProperty(
2517     const ::rtl::OUString& PropertyName,
2518     const ::com::sun::star::uno::Any& Value )
2519 throw(::com::sun::star::uno::RuntimeException)
2520 {
2521 	::vos::OGuard aGuard( GetMutex() );
2522 
2523 	TabPage* pTabPage = (TabPage*)GetWindow();
2524 	if ( pTabPage )
2525 	{
2526 		sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
2527 
2528 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
2529 		switch ( nPropType )
2530 		{
2531 			case BASEPROPERTY_GRAPHIC:
2532             {
2533                 Reference< XGraphic > xGraphic;
2534                 if (( Value >>= xGraphic ) && xGraphic.is() )
2535                 {
2536                     Image aImage( xGraphic );
2537 
2538                     Wallpaper aWallpaper( aImage.GetBitmapEx());
2539                     aWallpaper.SetStyle( WALLPAPER_SCALE );
2540                     pTabPage->SetBackground( aWallpaper );
2541                 }
2542                 else if ( bVoid || !xGraphic.is() )
2543                 {
2544                     Color aColor = pTabPage->GetControlBackground().GetColor();
2545                     if ( aColor == COL_AUTO )
2546                         aColor = pTabPage->GetSettings().GetStyleSettings().GetDialogColor();
2547 
2548                     Wallpaper aWallpaper( aColor );
2549                     pTabPage->SetBackground( aWallpaper );
2550                 }
2551             }
2552             break;
2553             case BASEPROPERTY_TITLE:
2554                 {
2555                     ::rtl::OUString sTitle;
2556                     if ( Value >>= sTitle )
2557                     {
2558                         pTabPage->SetText(sTitle);
2559                     }
2560                 }
2561                 break;
2562 
2563             default:
2564 			{
2565 				VCLXContainer::setProperty( PropertyName, Value );
2566 			}
2567         }
2568     }
2569 }
2570 
2571 //	----------------------------------------------------
2572 //  class VCLXFixedHyperlink
2573 //	----------------------------------------------------
VCLXFixedHyperlink()2574 VCLXFixedHyperlink::VCLXFixedHyperlink() :
2575 
2576     maActionListeners( *this )
2577 
2578 {
2579 }
2580 
~VCLXFixedHyperlink()2581 VCLXFixedHyperlink::~VCLXFixedHyperlink()
2582 {
2583 }
2584 
2585 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)2586 ::com::sun::star::uno::Any VCLXFixedHyperlink::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
2587 {
2588 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
2589                                         SAL_STATIC_CAST( ::com::sun::star::awt::XFixedHyperlink*, this ) );
2590 	return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
2591 }
2592 
dispose()2593 void VCLXFixedHyperlink::dispose() throw(::com::sun::star::uno::RuntimeException)
2594 {
2595         ::vos::OGuard aGuard( GetMutex() );
2596 
2597         ::com::sun::star::lang::EventObject aObj;
2598         aObj.Source = (::cppu::OWeakObject*)this;
2599         maActionListeners.disposeAndClear( aObj );
2600         VCLXWindow::dispose();
2601 }
2602 
2603 // ::com::sun::star::lang::XTypeProvider
2604 IMPL_XTYPEPROVIDER_START( VCLXFixedHyperlink )
2605     getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFixedHyperlink>* ) NULL ),
2606 	VCLXWindow::getTypes()
2607 IMPL_XTYPEPROVIDER_END
2608 
2609 void VCLXFixedHyperlink::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
2610 {
2611     switch ( rVclWindowEvent.GetId() )
2612     {
2613         case VCLEVENT_BUTTON_CLICK:
2614         {
2615             if ( maActionListeners.getLength() )
2616             {
2617                 ::com::sun::star::awt::ActionEvent aEvent;
2618                 aEvent.Source = (::cppu::OWeakObject*)this;
2619                 maActionListeners.actionPerformed( aEvent );
2620             }
2621             else
2622             {
2623                 // open the URL
2624                 ::rtl::OUString sURL;
2625                 ::toolkit::FixedHyperlinkBase* pBase = (::toolkit::FixedHyperlinkBase*)GetWindow();
2626                 if ( pBase )
2627                     sURL = pBase->GetURL();
2628                 Reference< ::com::sun::star::system::XSystemShellExecute > xSystemShellExecute(
2629                     ::com::sun::star::system::SystemShellExecute::create(
2630                         ::comphelper::getProcessComponentContext() ) );
2631                 if ( sURL.getLength() > 0 && xSystemShellExecute.is() )
2632                 {
2633                     try
2634                     {
2635                         // start browser
2636                         xSystemShellExecute->execute(
2637                             sURL, ::rtl::OUString(), ::com::sun::star::system::SystemShellExecuteFlags::DEFAULTS );
2638                     }
2639                     catch( uno::Exception& )
2640                     {
2641                     }
2642                 }
2643             }
2644         }
2645 
2646         default:
2647             VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
2648             break;
2649     }
2650 }
2651 
CreateAccessibleContext()2652 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXFixedHyperlink::CreateAccessibleContext()
2653 {
2654     return getAccessibleFactory().createAccessibleContext( this );
2655 }
2656 
setText(const::rtl::OUString & Text)2657 void VCLXFixedHyperlink::setText( const ::rtl::OUString& Text ) throw(::com::sun::star::uno::RuntimeException)
2658 {
2659 	::vos::OGuard aGuard( GetMutex() );
2660 
2661     ::toolkit::FixedHyperlinkBase* pBase = (::toolkit::FixedHyperlinkBase*)GetWindow();
2662     if ( pBase )
2663         pBase->SetDescription( Text );
2664 }
2665 
getText()2666 ::rtl::OUString VCLXFixedHyperlink::getText() throw(::com::sun::star::uno::RuntimeException)
2667 {
2668 	::vos::OGuard aGuard( GetMutex() );
2669 
2670 	::rtl::OUString aText;
2671     Window* pWindow = GetWindow();
2672     if ( pWindow )
2673         aText = pWindow->GetText();
2674 	return aText;
2675 }
2676 
setURL(const::rtl::OUString & URL)2677 void VCLXFixedHyperlink::setURL( const ::rtl::OUString& URL ) throw(::com::sun::star::uno::RuntimeException)
2678 {
2679     ::vos::OGuard aGuard( GetMutex() );
2680 
2681     ::toolkit::FixedHyperlinkBase* pBase = (::toolkit::FixedHyperlinkBase*)GetWindow();
2682     if ( pBase )
2683         pBase->SetURL( URL );
2684 }
2685 
getURL()2686 ::rtl::OUString VCLXFixedHyperlink::getURL(  ) throw(::com::sun::star::uno::RuntimeException)
2687 {
2688     ::vos::OGuard aGuard( GetMutex() );
2689 
2690     ::rtl::OUString aText;
2691     ::toolkit::FixedHyperlinkBase* pBase = (::toolkit::FixedHyperlinkBase*)GetWindow();
2692     if ( pBase )
2693         aText = pBase->GetURL();
2694     return aText;
2695 }
2696 
setAlignment(short nAlign)2697 void VCLXFixedHyperlink::setAlignment( short nAlign ) throw(::com::sun::star::uno::RuntimeException)
2698 {
2699 	::vos::OGuard aGuard( GetMutex() );
2700 
2701 	Window* pWindow = GetWindow();
2702 	if ( pWindow )
2703 	{
2704 		WinBits nNewBits = 0;
2705 		if ( nAlign == ::com::sun::star::awt::TextAlign::LEFT )
2706 			nNewBits = WB_LEFT;
2707 		else if ( nAlign == ::com::sun::star::awt::TextAlign::CENTER )
2708 			nNewBits = WB_CENTER;
2709 		else
2710 			nNewBits = WB_RIGHT;
2711 
2712 		WinBits nStyle = pWindow->GetStyle();
2713 		nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT);
2714 		pWindow->SetStyle( nStyle | nNewBits );
2715 	}
2716 }
2717 
getAlignment()2718 short VCLXFixedHyperlink::getAlignment() throw(::com::sun::star::uno::RuntimeException)
2719 {
2720 	::vos::OGuard aGuard( GetMutex() );
2721 
2722 	short nAlign = 0;
2723 	Window* pWindow = GetWindow();
2724 	if ( pWindow )
2725 	{
2726 		WinBits nStyle = pWindow->GetStyle();
2727 		if ( nStyle & WB_LEFT )
2728 			nAlign = ::com::sun::star::awt::TextAlign::LEFT;
2729 		else if ( nStyle & WB_CENTER )
2730 			nAlign = ::com::sun::star::awt::TextAlign::CENTER;
2731 		else
2732 			nAlign = ::com::sun::star::awt::TextAlign::RIGHT;
2733 	}
2734 	return nAlign;
2735 }
2736 
addActionListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XActionListener> & l)2737 void VCLXFixedHyperlink::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l  )throw(::com::sun::star::uno::RuntimeException)
2738 {
2739         ::vos::OGuard aGuard( GetMutex() );
2740         maActionListeners.addInterface( l );
2741 }
2742 
removeActionListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XActionListener> & l)2743 void VCLXFixedHyperlink::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException)
2744 {
2745         ::vos::OGuard aGuard( GetMutex() );
2746         maActionListeners.removeInterface( l );
2747 }
2748 
getMinimumSize()2749 ::com::sun::star::awt::Size VCLXFixedHyperlink::getMinimumSize(  ) throw(::com::sun::star::uno::RuntimeException)
2750 {
2751 	::vos::OGuard aGuard( GetMutex() );
2752 
2753 	Size aSz;
2754     FixedText* pFixedText = (FixedText*)GetWindow();
2755     if ( pFixedText )
2756         aSz = pFixedText->CalcMinimumSize();
2757 	return AWTSize(aSz);
2758 }
2759 
getPreferredSize()2760 ::com::sun::star::awt::Size VCLXFixedHyperlink::getPreferredSize(  ) throw(::com::sun::star::uno::RuntimeException)
2761 {
2762 	return getMinimumSize();
2763 }
2764 
calcAdjustedSize(const::com::sun::star::awt::Size & rNewSize)2765 ::com::sun::star::awt::Size VCLXFixedHyperlink::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException)
2766 {
2767 	::vos::OGuard aGuard( GetMutex() );
2768 
2769 	::com::sun::star::awt::Size aSz = rNewSize;
2770 	::com::sun::star::awt::Size aMinSz = getMinimumSize();
2771 	if ( aSz.Height != aMinSz.Height )
2772 		aSz.Height = aMinSz.Height;
2773 
2774 	return aSz;
2775 }
2776 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)2777 void VCLXFixedHyperlink::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
2778 {
2779     ::vos::OGuard aGuard( GetMutex() );
2780 
2781     ::toolkit::FixedHyperlinkBase* pBase = (::toolkit::FixedHyperlinkBase*)GetWindow();
2782     if ( pBase )
2783     {
2784         sal_uInt16 nPropType = GetPropertyId( PropertyName );
2785         switch ( nPropType )
2786         {
2787             case BASEPROPERTY_LABEL:
2788             {
2789                 ::rtl::OUString sNewLabel;
2790                 if ( Value >>= sNewLabel )
2791                     pBase->SetDescription( sNewLabel );
2792                 break;
2793             }
2794 
2795             case BASEPROPERTY_URL:
2796             {
2797                 ::rtl::OUString sNewURL;
2798                 if ( Value >>= sNewURL )
2799                     pBase->SetURL( sNewURL );
2800                 break;
2801             }
2802 
2803             default:
2804             {
2805                 VCLXWindow::setProperty( PropertyName, Value );
2806             }
2807         }
2808     }
2809 }
2810 
getProperty(const::rtl::OUString & PropertyName)2811 ::com::sun::star::uno::Any VCLXFixedHyperlink::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
2812 {
2813     ::vos::OGuard aGuard( GetMutex() );
2814 
2815     ::com::sun::star::uno::Any aProp;
2816     ::toolkit::FixedHyperlinkBase* pBase = (::toolkit::FixedHyperlinkBase*)GetWindow();
2817     if ( pBase )
2818     {
2819         sal_uInt16 nPropType = GetPropertyId( PropertyName );
2820         switch ( nPropType )
2821         {
2822             case BASEPROPERTY_URL:
2823             {
2824                 aProp = makeAny( ::rtl::OUString( pBase->GetURL() ) );
2825                 break;
2826             }
2827 
2828             default:
2829             {
2830                 aProp <<= VCLXWindow::getProperty( PropertyName );
2831             }
2832         }
2833     }
2834     return aProp;
2835 }
2836 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)2837 void VCLXFixedHyperlink::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2838 {
2839     PushPropertyIds( rIds,
2840                      BASEPROPERTY_ALIGN,
2841                      BASEPROPERTY_BACKGROUNDCOLOR,
2842                      BASEPROPERTY_BORDER,
2843                      BASEPROPERTY_BORDERCOLOR,
2844                      BASEPROPERTY_DEFAULTCONTROL,
2845                      BASEPROPERTY_ENABLED,
2846                      BASEPROPERTY_ENABLEVISIBLE,
2847                      BASEPROPERTY_FONTDESCRIPTOR,
2848                      BASEPROPERTY_HELPTEXT,
2849                      BASEPROPERTY_HELPURL,
2850                      BASEPROPERTY_LABEL,
2851                      BASEPROPERTY_MULTILINE,
2852                      BASEPROPERTY_NOLABEL,
2853                      BASEPROPERTY_PRINTABLE,
2854                      BASEPROPERTY_TABSTOP,
2855                      BASEPROPERTY_VERTICALALIGN,
2856                      BASEPROPERTY_URL,
2857                      BASEPROPERTY_WRITING_MODE,
2858                      BASEPROPERTY_CONTEXT_WRITING_MODE,
2859                      0);
2860     VCLXWindow::ImplGetPropertyIds( rIds );
2861 }
2862 
2863 //  ----------------------------------------------------
2864 //  class VCLXFixedText
2865 //  ----------------------------------------------------
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)2866 void VCLXFixedText::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2867 {
2868     PushPropertyIds( rIds,
2869                      BASEPROPERTY_ALIGN,
2870                      BASEPROPERTY_BACKGROUNDCOLOR,
2871                      BASEPROPERTY_BORDER,
2872                      BASEPROPERTY_BORDERCOLOR,
2873                      BASEPROPERTY_DEFAULTCONTROL,
2874                      BASEPROPERTY_ENABLED,
2875                      BASEPROPERTY_ENABLEVISIBLE,
2876                      BASEPROPERTY_FONTDESCRIPTOR,
2877                      BASEPROPERTY_HELPTEXT,
2878                      BASEPROPERTY_HELPURL,
2879                      BASEPROPERTY_LABEL,
2880                      BASEPROPERTY_MULTILINE,
2881                      BASEPROPERTY_NOLABEL,
2882                      BASEPROPERTY_PRINTABLE,
2883                      BASEPROPERTY_TABSTOP,
2884                      BASEPROPERTY_VERTICALALIGN,
2885                      BASEPROPERTY_WRITING_MODE,
2886                      BASEPROPERTY_CONTEXT_WRITING_MODE,
2887                      BASEPROPERTY_REFERENCE_DEVICE,
2888                      0);
2889     VCLXWindow::ImplGetPropertyIds( rIds );
2890 }
2891 
VCLXFixedText()2892 VCLXFixedText::VCLXFixedText()
2893 {
2894 }
2895 
~VCLXFixedText()2896 VCLXFixedText::~VCLXFixedText()
2897 {
2898 }
2899 
2900 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)2901 ::com::sun::star::uno::Any VCLXFixedText::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
2902 {
2903     ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
2904                                         SAL_STATIC_CAST( ::com::sun::star::awt::XFixedText*, this ) );
2905     return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
2906 }
2907 
2908 // ::com::sun::star::lang::XTypeProvider
2909 IMPL_XTYPEPROVIDER_START( VCLXFixedText )
2910     getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFixedText>* ) NULL ),
2911     VCLXWindow::getTypes()
2912 IMPL_XTYPEPROVIDER_END
2913 
2914 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXFixedText::CreateAccessibleContext()
2915 {
2916     return getAccessibleFactory().createAccessibleContext( this );
2917 }
2918 
setText(const::rtl::OUString & Text)2919 void VCLXFixedText::setText( const ::rtl::OUString& Text ) throw(::com::sun::star::uno::RuntimeException)
2920 {
2921     ::vos::OGuard aGuard( GetMutex() );
2922 
2923     Window* pWindow = GetWindow();
2924     if ( pWindow )
2925         pWindow->SetText( Text );
2926 }
2927 
getText()2928 ::rtl::OUString VCLXFixedText::getText() throw(::com::sun::star::uno::RuntimeException)
2929 {
2930     ::vos::OGuard aGuard( GetMutex() );
2931 
2932     ::rtl::OUString aText;
2933     Window* pWindow = GetWindow();
2934     if ( pWindow )
2935         aText = pWindow->GetText();
2936     return aText;
2937 }
2938 
setAlignment(short nAlign)2939 void VCLXFixedText::setAlignment( short nAlign ) throw(::com::sun::star::uno::RuntimeException)
2940 {
2941     ::vos::OGuard aGuard( GetMutex() );
2942 
2943     Window* pWindow = GetWindow();
2944     if ( pWindow )
2945     {
2946         WinBits nNewBits = 0;
2947         if ( nAlign == ::com::sun::star::awt::TextAlign::LEFT )
2948             nNewBits = WB_LEFT;
2949         else if ( nAlign == ::com::sun::star::awt::TextAlign::CENTER )
2950             nNewBits = WB_CENTER;
2951         else
2952             nNewBits = WB_RIGHT;
2953 
2954         WinBits nStyle = pWindow->GetStyle();
2955         nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT);
2956         pWindow->SetStyle( nStyle | nNewBits );
2957     }
2958 }
2959 
getAlignment()2960 short VCLXFixedText::getAlignment() throw(::com::sun::star::uno::RuntimeException)
2961 {
2962     ::vos::OGuard aGuard( GetMutex() );
2963 
2964     short nAlign = 0;
2965     Window* pWindow = GetWindow();
2966     if ( pWindow )
2967     {
2968         WinBits nStyle = pWindow->GetStyle();
2969         if ( nStyle & WB_LEFT )
2970             nAlign = ::com::sun::star::awt::TextAlign::LEFT;
2971         else if ( nStyle & WB_CENTER )
2972             nAlign = ::com::sun::star::awt::TextAlign::CENTER;
2973         else
2974             nAlign = ::com::sun::star::awt::TextAlign::RIGHT;
2975     }
2976     return nAlign;
2977 }
2978 
getMinimumSize()2979 ::com::sun::star::awt::Size VCLXFixedText::getMinimumSize(  ) throw(::com::sun::star::uno::RuntimeException)
2980 {
2981     ::vos::OGuard aGuard( GetMutex() );
2982 
2983     Size aSz;
2984     FixedText* pFixedText = (FixedText*)GetWindow();
2985     if ( pFixedText )
2986         aSz = pFixedText->CalcMinimumSize();
2987     return AWTSize(aSz);
2988 }
2989 
getPreferredSize()2990 ::com::sun::star::awt::Size VCLXFixedText::getPreferredSize(  ) throw(::com::sun::star::uno::RuntimeException)
2991 {
2992     return getMinimumSize();
2993 }
2994 
calcAdjustedSize(const::com::sun::star::awt::Size & rMaxSize)2995 ::com::sun::star::awt::Size VCLXFixedText::calcAdjustedSize( const ::com::sun::star::awt::Size& rMaxSize ) throw(::com::sun::star::uno::RuntimeException)
2996 {
2997     ::vos::OGuard aGuard( GetMutex() );
2998 
2999     Size aAdjustedSize( VCLUnoHelper::ConvertToVCLSize( rMaxSize ) );
3000     FixedText* pFixedText = (FixedText*)GetWindow();
3001     if ( pFixedText )
3002         aAdjustedSize = pFixedText->CalcMinimumSize( rMaxSize.Width );
3003     return VCLUnoHelper::ConvertToAWTSize( aAdjustedSize );
3004 }
3005 
3006 //	----------------------------------------------------
3007 //	class VCLXScrollBar
3008 //	----------------------------------------------------
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)3009 void VCLXScrollBar::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
3010 {
3011     PushPropertyIds( rIds,
3012                      BASEPROPERTY_BACKGROUNDCOLOR,
3013                      BASEPROPERTY_BLOCKINCREMENT,
3014                      BASEPROPERTY_BORDER,
3015                      BASEPROPERTY_BORDERCOLOR,
3016                      BASEPROPERTY_DEFAULTCONTROL,
3017                      BASEPROPERTY_ENABLED,
3018                      BASEPROPERTY_ENABLEVISIBLE,
3019                      BASEPROPERTY_HELPTEXT,
3020                      BASEPROPERTY_HELPURL,
3021                      BASEPROPERTY_LINEINCREMENT,
3022                      BASEPROPERTY_LIVE_SCROLL,
3023                      BASEPROPERTY_ORIENTATION,
3024                      BASEPROPERTY_PRINTABLE,
3025                      BASEPROPERTY_REPEAT_DELAY,
3026                      BASEPROPERTY_SCROLLVALUE,
3027                      BASEPROPERTY_SCROLLVALUE_MAX,
3028                      BASEPROPERTY_SCROLLVALUE_MIN,
3029                      BASEPROPERTY_SYMBOL_COLOR,
3030                      BASEPROPERTY_TABSTOP,
3031                      BASEPROPERTY_VISIBLESIZE,
3032                      BASEPROPERTY_WRITING_MODE,
3033                      BASEPROPERTY_CONTEXT_WRITING_MODE,
3034                      0);
3035     VCLXWindow::ImplGetPropertyIds( rIds );
3036 }
3037 
VCLXScrollBar()3038 VCLXScrollBar::VCLXScrollBar() : maAdjustmentListeners( *this )
3039 {
3040 }
3041 
3042 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)3043 ::com::sun::star::uno::Any VCLXScrollBar::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
3044 {
3045 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
3046 										SAL_STATIC_CAST( ::com::sun::star::awt::XScrollBar*, this ) );
3047 	return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
3048 }
3049 
3050 // ::com::sun::star::lang::XTypeProvider
3051 IMPL_XTYPEPROVIDER_START( VCLXScrollBar )
3052 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XScrollBar>* ) NULL ),
3053 	VCLXWindow::getTypes()
3054 IMPL_XTYPEPROVIDER_END
3055 
3056 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXScrollBar::CreateAccessibleContext()
3057 {
3058     return getAccessibleFactory().createAccessibleContext( this );
3059 }
3060 
3061 // ::com::sun::star::lang::XComponent
dispose()3062 void VCLXScrollBar::dispose() throw(::com::sun::star::uno::RuntimeException)
3063 {
3064 	::vos::OGuard aGuard( GetMutex() );
3065 
3066 	::com::sun::star::lang::EventObject aObj;
3067 	aObj.Source = (::cppu::OWeakObject*)this;
3068 	maAdjustmentListeners.disposeAndClear( aObj );
3069 	VCLXWindow::dispose();
3070 }
3071 
3072 // ::com::sun::star::awt::XScrollbar
addAdjustmentListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XAdjustmentListener> & l)3073 void VCLXScrollBar::addAdjustmentListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XAdjustmentListener > & l ) throw(::com::sun::star::uno::RuntimeException)
3074 {
3075 	::vos::OGuard aGuard( GetMutex() );
3076 	maAdjustmentListeners.addInterface( l );
3077 }
3078 
removeAdjustmentListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XAdjustmentListener> & l)3079 void VCLXScrollBar::removeAdjustmentListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XAdjustmentListener > & l ) throw(::com::sun::star::uno::RuntimeException)
3080 {
3081 	::vos::OGuard aGuard( GetMutex() );
3082 	maAdjustmentListeners.removeInterface( l );
3083 }
3084 
setValue(sal_Int32 n)3085 void VCLXScrollBar::setValue( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException)
3086 {
3087 	::vos::OGuard aGuard( GetMutex() );
3088 
3089 	ScrollBar* pScrollBar = (ScrollBar*) GetWindow();
3090 	if ( pScrollBar )
3091 		pScrollBar->DoScroll( n );
3092 }
3093 
setValues(sal_Int32 nValue,sal_Int32 nVisible,sal_Int32 nMax)3094 void VCLXScrollBar::setValues( sal_Int32 nValue, sal_Int32 nVisible, sal_Int32 nMax ) throw(::com::sun::star::uno::RuntimeException)
3095 {
3096 	::vos::OGuard aGuard( GetMutex() );
3097 
3098 	ScrollBar* pScrollBar = (ScrollBar*) GetWindow();
3099 	if ( pScrollBar )
3100 	{
3101 		pScrollBar->SetVisibleSize( nVisible );
3102 		pScrollBar->SetRangeMax( nMax );
3103 		pScrollBar->DoScroll( nValue );
3104 	}
3105 }
3106 
getValue()3107 sal_Int32 VCLXScrollBar::getValue() throw(::com::sun::star::uno::RuntimeException)
3108 {
3109 	::vos::OGuard aGuard( GetMutex() );
3110 
3111 	ScrollBar* pScrollBar = (ScrollBar*) GetWindow();
3112 	return pScrollBar ? pScrollBar->GetThumbPos() : 0;
3113 }
3114 
setMaximum(sal_Int32 n)3115 void VCLXScrollBar::setMaximum( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException)
3116 {
3117 	::vos::OGuard aGuard( GetMutex() );
3118 
3119 	ScrollBar* pScrollBar = (ScrollBar*) GetWindow();
3120 	if ( pScrollBar )
3121 		pScrollBar->SetRangeMax( n );
3122 }
3123 
getMaximum()3124 sal_Int32 VCLXScrollBar::getMaximum() throw(::com::sun::star::uno::RuntimeException)
3125 {
3126 	::vos::OGuard aGuard( GetMutex() );
3127 
3128 	ScrollBar* pScrollBar = (ScrollBar*) GetWindow();
3129 	return pScrollBar ? pScrollBar->GetRangeMax() : 0;
3130 }
3131 
setMinimum(sal_Int32 n)3132 void VCLXScrollBar::setMinimum( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException)
3133 {
3134 	::vos::OGuard aGuard( GetMutex() );
3135 
3136 	ScrollBar* pScrollBar = static_cast< ScrollBar* >( GetWindow() );
3137 	if ( pScrollBar )
3138 		pScrollBar->SetRangeMin( n );
3139 }
3140 
getMinimum()3141 sal_Int32 VCLXScrollBar::getMinimum() throw(::com::sun::star::uno::RuntimeException)
3142 {
3143 	::vos::OGuard aGuard( GetMutex() );
3144 
3145 	ScrollBar* pScrollBar = static_cast< ScrollBar* >( GetWindow() );
3146 	return pScrollBar ? pScrollBar->GetRangeMin() : 0;
3147 }
3148 
setLineIncrement(sal_Int32 n)3149 void VCLXScrollBar::setLineIncrement( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException)
3150 {
3151 	::vos::OGuard aGuard( GetMutex() );
3152 
3153 	ScrollBar* pScrollBar = (ScrollBar*) GetWindow();
3154 	if ( pScrollBar )
3155 		pScrollBar->SetLineSize( n );
3156 }
3157 
getLineIncrement()3158 sal_Int32 VCLXScrollBar::getLineIncrement() throw(::com::sun::star::uno::RuntimeException)
3159 {
3160 	::vos::OGuard aGuard( GetMutex() );
3161 
3162 	ScrollBar* pScrollBar = (ScrollBar*) GetWindow();
3163 	return pScrollBar ? pScrollBar->GetLineSize() : 0;
3164 }
3165 
setBlockIncrement(sal_Int32 n)3166 void VCLXScrollBar::setBlockIncrement( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException)
3167 {
3168 	::vos::OGuard aGuard( GetMutex() );
3169 
3170 	ScrollBar* pScrollBar = (ScrollBar*) GetWindow();
3171 	if ( pScrollBar )
3172 		pScrollBar->SetPageSize( n );
3173 }
3174 
getBlockIncrement()3175 sal_Int32 VCLXScrollBar::getBlockIncrement() throw(::com::sun::star::uno::RuntimeException)
3176 {
3177 	::vos::OGuard aGuard( GetMutex() );
3178 
3179 	ScrollBar* pScrollBar = (ScrollBar*) GetWindow();
3180 	return pScrollBar ? pScrollBar->GetPageSize() : 0;
3181 }
3182 
setVisibleSize(sal_Int32 n)3183 void VCLXScrollBar::setVisibleSize( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException)
3184 {
3185 	::vos::OGuard aGuard( GetMutex() );
3186 
3187 	ScrollBar* pScrollBar = (ScrollBar*) GetWindow();
3188 	if ( pScrollBar )
3189 		pScrollBar->SetVisibleSize( n );
3190 }
3191 
getVisibleSize()3192 sal_Int32 VCLXScrollBar::getVisibleSize() throw(::com::sun::star::uno::RuntimeException)
3193 {
3194 	::vos::OGuard aGuard( GetMutex() );
3195 
3196 	ScrollBar* pScrollBar = (ScrollBar*) GetWindow();
3197 	return pScrollBar ? pScrollBar->GetVisibleSize() : 0;
3198 }
3199 
setOrientation(sal_Int32 n)3200 void VCLXScrollBar::setOrientation( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException)
3201 {
3202 	::vos::OGuard aGuard( GetMutex() );
3203 
3204 	Window* pWindow = GetWindow();
3205 	if ( pWindow )
3206 	{
3207 		WinBits nStyle = pWindow->GetStyle();
3208 		nStyle &= ~(WB_HORZ|WB_VERT);
3209 		if ( n == ::com::sun::star::awt::ScrollBarOrientation::HORIZONTAL )
3210 			nStyle |= WB_HORZ;
3211 		else
3212 			nStyle |= WB_VERT;
3213 
3214 		pWindow->SetStyle( nStyle );
3215         pWindow->Resize();
3216 	}
3217 }
3218 
getOrientation()3219 sal_Int32 VCLXScrollBar::getOrientation() throw(::com::sun::star::uno::RuntimeException)
3220 {
3221 	::vos::OGuard aGuard( GetMutex() );
3222 
3223 	sal_Int32 n = 0;
3224 	Window* pWindow = GetWindow();
3225 	if ( pWindow )
3226 	{
3227 		WinBits nStyle = pWindow->GetStyle();
3228 		if ( nStyle & WB_HORZ )
3229 			n = ::com::sun::star::awt::ScrollBarOrientation::HORIZONTAL;
3230 		else
3231 			n = ::com::sun::star::awt::ScrollBarOrientation::VERTICAL;
3232 	}
3233 	return n;
3234 
3235 }
3236 
3237 // ::com::sun::star::awt::VclWindowPeer
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)3238 void VCLXScrollBar::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
3239 {
3240 	::vos::OGuard aGuard( GetMutex() );
3241 
3242 	ScrollBar* pScrollBar = (ScrollBar*)GetWindow();
3243 	if ( pScrollBar )
3244 	{
3245 		sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
3246 
3247 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
3248 		switch ( nPropType )
3249 		{
3250 			case BASEPROPERTY_LIVE_SCROLL:
3251             {
3252                 sal_Bool bDo = sal_False;
3253                 if ( !bVoid )
3254                 {
3255                     OSL_VERIFY( Value >>= bDo );
3256                 }
3257                 AllSettings aSettings( pScrollBar->GetSettings() );
3258                 StyleSettings aStyle( aSettings.GetStyleSettings() );
3259                 sal_uLong nDragOptions = aStyle.GetDragFullOptions();
3260                 if ( bDo )
3261                     nDragOptions |= DRAGFULL_OPTION_SCROLL;
3262                 else
3263                     nDragOptions &= ~DRAGFULL_OPTION_SCROLL;
3264                 aStyle.SetDragFullOptions( nDragOptions );
3265                 aSettings.SetStyleSettings( aStyle );
3266                 pScrollBar->SetSettings( aSettings );
3267             }
3268             break;
3269 
3270 			case BASEPROPERTY_SCROLLVALUE:
3271 			{
3272 				if ( !bVoid )
3273 				{
3274 					sal_Int32 n = 0;
3275 					if ( Value >>= n )
3276 						setValue( n );
3277 				}
3278 			}
3279 			break;
3280 			case BASEPROPERTY_SCROLLVALUE_MAX:
3281             case BASEPROPERTY_SCROLLVALUE_MIN:
3282 			{
3283 				if ( !bVoid )
3284 				{
3285 					sal_Int32 n = 0;
3286 					if ( Value >>= n )
3287                     {
3288                         if ( nPropType == BASEPROPERTY_SCROLLVALUE_MAX )
3289 						    setMaximum( n );
3290                         else
3291 						    setMinimum( n );
3292                     }
3293 				}
3294 			}
3295 			break;
3296 			case BASEPROPERTY_LINEINCREMENT:
3297 			{
3298 				if ( !bVoid )
3299 				{
3300 					sal_Int32 n = 0;
3301 					if ( Value >>= n )
3302 						setLineIncrement( n );
3303 				}
3304 			}
3305 			break;
3306 			case BASEPROPERTY_BLOCKINCREMENT:
3307 			{
3308 				if ( !bVoid )
3309 				{
3310 					sal_Int32 n = 0;
3311 					if ( Value >>= n )
3312 						setBlockIncrement( n );
3313 				}
3314 			}
3315 			break;
3316 			case BASEPROPERTY_VISIBLESIZE:
3317 			{
3318 				if ( !bVoid )
3319 				{
3320 					sal_Int32 n = 0;
3321 					if ( Value >>= n )
3322 						setVisibleSize( n );
3323 				}
3324 			}
3325 			break;
3326 			case BASEPROPERTY_ORIENTATION:
3327 			{
3328 				if ( !bVoid )
3329 				{
3330 					sal_Int32 n = 0;
3331 					if ( Value >>= n )
3332 						setOrientation( n );
3333 				}
3334 			}
3335 			break;
3336 
3337             case BASEPROPERTY_BACKGROUNDCOLOR:
3338             {
3339                 // the default implementation of the base class doesn't work here, since our
3340                 // interpretation for this property is slightly different
3341                 ::toolkit::setButtonLikeFaceColor( pScrollBar, Value);
3342             }
3343             break;
3344 
3345 			default:
3346 			{
3347 				VCLXWindow::setProperty( PropertyName, Value );
3348 			}
3349 		}
3350 	}
3351 }
3352 
getProperty(const::rtl::OUString & PropertyName)3353 ::com::sun::star::uno::Any VCLXScrollBar::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
3354 {
3355 	::vos::OGuard aGuard( GetMutex() );
3356 
3357 	::com::sun::star::uno::Any aProp;
3358 	ScrollBar* pScrollBar = (ScrollBar*)GetWindow();
3359 	if ( pScrollBar )
3360 	{
3361 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
3362 
3363 		switch ( nPropType )
3364 		{
3365 			case BASEPROPERTY_LIVE_SCROLL:
3366             {
3367                 aProp <<= (sal_Bool)( 0 != ( pScrollBar->GetSettings().GetStyleSettings().GetDragFullOptions() & DRAGFULL_OPTION_SCROLL ) );
3368             }
3369             break;
3370 			case BASEPROPERTY_SCROLLVALUE:
3371 			{
3372 				aProp <<= (sal_Int32) getValue();
3373 			}
3374 			break;
3375 			case BASEPROPERTY_SCROLLVALUE_MAX:
3376 			{
3377 				aProp <<= (sal_Int32) getMaximum();
3378 			}
3379 			break;
3380             case BASEPROPERTY_SCROLLVALUE_MIN:
3381 			{
3382 				aProp <<= (sal_Int32) getMinimum();
3383 			}
3384 			break;
3385 			case BASEPROPERTY_LINEINCREMENT:
3386 			{
3387 				aProp <<= (sal_Int32) getLineIncrement();
3388 			}
3389 			break;
3390 			case BASEPROPERTY_BLOCKINCREMENT:
3391 			{
3392 				aProp <<= (sal_Int32) getBlockIncrement();
3393 			}
3394 			break;
3395 			case BASEPROPERTY_VISIBLESIZE:
3396 			{
3397 				aProp <<= (sal_Int32) getVisibleSize();
3398 			}
3399 			break;
3400 			case BASEPROPERTY_ORIENTATION:
3401 			{
3402 				aProp <<= (sal_Int32) getOrientation();
3403 			}
3404 			break;
3405             case BASEPROPERTY_BACKGROUNDCOLOR:
3406             {
3407                 // the default implementation of the base class doesn't work here, since our
3408                 // interpretation for this property is slightly different
3409                 aProp = ::toolkit::getButtonLikeFaceColor( pScrollBar );
3410             }
3411             break;
3412 
3413 			default:
3414 			{
3415 				aProp <<= VCLXWindow::getProperty( PropertyName );
3416 			}
3417 		}
3418 	}
3419 	return aProp;
3420 }
3421 
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)3422 void VCLXScrollBar::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
3423 {
3424 	switch ( rVclWindowEvent.GetId() )
3425 	{
3426 		case VCLEVENT_SCROLLBAR_SCROLL:
3427         {
3428             ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
3429                 // since we call listeners below, there is a potential that we will be destroyed
3430                 // in during the listener call. To prevent the resulting crashs, we keep us
3431                 // alive as long as we're here
3432                 // #20178# - 2003-10-01 - fs@openoffice.org
3433 
3434 			if ( maAdjustmentListeners.getLength() )
3435 			{
3436     			ScrollBar* pScrollBar = (ScrollBar*)GetWindow();
3437 
3438                 if( pScrollBar )
3439                 {
3440 				    ::com::sun::star::awt::AdjustmentEvent aEvent;
3441 				    aEvent.Source = (::cppu::OWeakObject*)this;
3442 				    aEvent.Value = pScrollBar->GetThumbPos();
3443 
3444 				    // set adjustment type
3445 				    ScrollType aType = pScrollBar->GetType();
3446 				    if ( aType == SCROLL_LINEUP || aType == SCROLL_LINEDOWN )
3447 				    {
3448 					    aEvent.Type = ::com::sun::star::awt::AdjustmentType_ADJUST_LINE;
3449 				    }
3450 				    else if ( aType == SCROLL_PAGEUP || aType == SCROLL_PAGEDOWN )
3451 				    {
3452 					    aEvent.Type = ::com::sun::star::awt::AdjustmentType_ADJUST_PAGE;
3453 				    }
3454 				    else if ( aType == SCROLL_DRAG )
3455 				    {
3456 					    aEvent.Type = ::com::sun::star::awt::AdjustmentType_ADJUST_ABS;
3457 				    }
3458 
3459 				    maAdjustmentListeners.adjustmentValueChanged( aEvent );
3460                 }
3461 			}
3462         }
3463         break;
3464 
3465 		default:
3466 			VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
3467 			break;
3468 	}
3469 }
3470 
implGetMinimumSize(Window * p)3471 ::com::sun::star::awt::Size SAL_CALL VCLXScrollBar::implGetMinimumSize( Window* p ) throw(::com::sun::star::uno::RuntimeException)
3472 {
3473     long n = p->GetSettings().GetStyleSettings().GetScrollBarSize();
3474     return ::com::sun::star::awt::Size( n, n );
3475 }
3476 
getMinimumSize()3477 ::com::sun::star::awt::Size SAL_CALL VCLXScrollBar::getMinimumSize() throw(::com::sun::star::uno::RuntimeException)
3478 {
3479 	::vos::OGuard aGuard( GetMutex() );
3480     return implGetMinimumSize( GetWindow() );
3481 }
3482 
3483 
3484 //	----------------------------------------------------
3485 //	class VCLXEdit
3486 //	----------------------------------------------------
3487 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)3488 void VCLXEdit::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
3489 {
3490     PushPropertyIds( rIds,
3491                      BASEPROPERTY_ALIGN,
3492                      BASEPROPERTY_BACKGROUNDCOLOR,
3493                      BASEPROPERTY_BORDER,
3494                      BASEPROPERTY_BORDERCOLOR,
3495                      BASEPROPERTY_DEFAULTCONTROL,
3496                      BASEPROPERTY_ECHOCHAR,
3497                      BASEPROPERTY_ENABLED,
3498                      BASEPROPERTY_ENABLEVISIBLE,
3499                      BASEPROPERTY_FONTDESCRIPTOR,
3500                      BASEPROPERTY_HARDLINEBREAKS,
3501                      BASEPROPERTY_HELPTEXT,
3502                      BASEPROPERTY_HELPURL,
3503                      BASEPROPERTY_HSCROLL,
3504                      BASEPROPERTY_LINE_END_FORMAT,
3505                      BASEPROPERTY_MAXTEXTLEN,
3506                      BASEPROPERTY_MULTILINE,
3507                      BASEPROPERTY_PRINTABLE,
3508                      BASEPROPERTY_READONLY,
3509                      BASEPROPERTY_TABSTOP,
3510                      BASEPROPERTY_TEXT,
3511                      BASEPROPERTY_VSCROLL,
3512                      BASEPROPERTY_HIDEINACTIVESELECTION,
3513                      BASEPROPERTY_PAINTTRANSPARENT,
3514                      BASEPROPERTY_AUTOHSCROLL,
3515                      BASEPROPERTY_AUTOVSCROLL,
3516                      BASEPROPERTY_VERTICALALIGN,
3517                      BASEPROPERTY_WRITING_MODE,
3518                      BASEPROPERTY_CONTEXT_WRITING_MODE,
3519                      0);
3520     VCLXWindow::ImplGetPropertyIds( rIds );
3521 }
3522 
VCLXEdit()3523 VCLXEdit::VCLXEdit() : maTextListeners( *this )
3524 {
3525 }
3526 
3527 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)3528 ::com::sun::star::uno::Any VCLXEdit::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
3529 {
3530 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
3531 										SAL_STATIC_CAST( ::com::sun::star::awt::XTextComponent*, this ),
3532 										SAL_STATIC_CAST( ::com::sun::star::awt::XTextEditField*, this ),
3533 										SAL_STATIC_CAST( ::com::sun::star::awt::XTextLayoutConstrains*, this ) );
3534 	return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
3535 }
3536 
3537 // ::com::sun::star::lang::XTypeProvider
3538 IMPL_XTYPEPROVIDER_START( VCLXEdit )
3539 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent>* ) NULL ),
3540 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextEditField>* ) NULL ),
3541 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextLayoutConstrains>* ) NULL ),
3542 	VCLXWindow::getTypes()
3543 IMPL_XTYPEPROVIDER_END
3544 
3545 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXEdit::CreateAccessibleContext()
3546 {
3547     return getAccessibleFactory().createAccessibleContext( this );
3548 }
3549 
dispose()3550 void VCLXEdit::dispose() throw(::com::sun::star::uno::RuntimeException)
3551 {
3552 	::vos::OGuard aGuard( GetMutex() );
3553 
3554 	::com::sun::star::lang::EventObject aObj;
3555 	aObj.Source = (::cppu::OWeakObject*)this;
3556 	maTextListeners.disposeAndClear( aObj );
3557 	VCLXWindow::dispose();
3558 }
3559 
addTextListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XTextListener> & l)3560 void VCLXEdit::addTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException)
3561 {
3562 	::vos::OGuard aGuard( GetMutex() );
3563 	GetTextListeners().addInterface( l );
3564 }
3565 
removeTextListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XTextListener> & l)3566 void VCLXEdit::removeTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException)
3567 {
3568 	::vos::OGuard aGuard( GetMutex() );
3569 	GetTextListeners().removeInterface( l );
3570 }
3571 
setText(const::rtl::OUString & aText)3572 void VCLXEdit::setText( const ::rtl::OUString& aText ) throw(::com::sun::star::uno::RuntimeException)
3573 {
3574 	::vos::OGuard aGuard( GetMutex() );
3575 
3576 	Edit* pEdit = (Edit*)GetWindow();
3577 	if ( pEdit )
3578 	{
3579 		pEdit->SetText( aText );
3580 
3581         // #107218# Call same listeners like VCL would do after user interaction
3582         SetSynthesizingVCLEvent( sal_True );
3583         pEdit->SetModifyFlag();
3584         pEdit->Modify();
3585         SetSynthesizingVCLEvent( sal_False );
3586 	}
3587 }
3588 
insertText(const::com::sun::star::awt::Selection & rSel,const::rtl::OUString & aText)3589 void VCLXEdit::insertText( const ::com::sun::star::awt::Selection& rSel, const ::rtl::OUString& aText ) throw(::com::sun::star::uno::RuntimeException)
3590 {
3591 	::vos::OGuard aGuard( GetMutex() );
3592 
3593 	Edit* pEdit = (Edit*)GetWindow();
3594 	if ( pEdit )
3595 	{
3596 		pEdit->SetSelection( Selection( rSel.Min, rSel.Max ) );
3597 		pEdit->ReplaceSelected( aText );
3598 
3599         // #107218# Call same listeners like VCL would do after user interaction
3600         SetSynthesizingVCLEvent( sal_True );
3601         pEdit->SetModifyFlag();
3602         pEdit->Modify();
3603         SetSynthesizingVCLEvent( sal_False );
3604 	}
3605 }
3606 
getText()3607 ::rtl::OUString VCLXEdit::getText() throw(::com::sun::star::uno::RuntimeException)
3608 {
3609 	::vos::OGuard aGuard( GetMutex() );
3610 
3611 	::rtl::OUString aText;
3612 	Window* pWindow = GetWindow();
3613 	if ( pWindow )
3614 		aText = pWindow->GetText();
3615 	return aText;
3616 }
3617 
getSelectedText()3618 ::rtl::OUString VCLXEdit::getSelectedText() throw(::com::sun::star::uno::RuntimeException)
3619 {
3620 	::vos::OGuard aGuard( GetMutex() );
3621 
3622 	::rtl::OUString aText;
3623 	Edit* pEdit = (Edit*) GetWindow();
3624 	if ( pEdit)
3625 		aText = pEdit->GetSelected();
3626 	return aText;
3627 
3628 }
3629 
setSelection(const::com::sun::star::awt::Selection & aSelection)3630 void VCLXEdit::setSelection( const ::com::sun::star::awt::Selection& aSelection ) throw(::com::sun::star::uno::RuntimeException)
3631 {
3632 	::vos::OGuard aGuard( GetMutex() );
3633 
3634 	Edit* pEdit = (Edit*) GetWindow();
3635 	if ( pEdit )
3636 		pEdit->SetSelection( Selection( aSelection.Min, aSelection.Max ) );
3637 }
3638 
getSelection()3639 ::com::sun::star::awt::Selection VCLXEdit::getSelection() throw(::com::sun::star::uno::RuntimeException)
3640 {
3641 	::vos::OGuard aGuard( GetMutex() );
3642 
3643 	Selection aSel;
3644 	Edit* pEdit = (Edit*) GetWindow();
3645 	if ( pEdit )
3646 		aSel = pEdit->GetSelection();
3647 	return ::com::sun::star::awt::Selection( aSel.Min(), aSel.Max() );
3648 }
3649 
isEditable()3650 sal_Bool VCLXEdit::isEditable() throw(::com::sun::star::uno::RuntimeException)
3651 {
3652 	::vos::OGuard aGuard( GetMutex() );
3653 
3654 	Edit* pEdit = (Edit*) GetWindow();
3655 	return ( pEdit && !pEdit->IsReadOnly() && pEdit->IsEnabled() ) ? sal_True : sal_False;
3656 }
3657 
setEditable(sal_Bool bEditable)3658 void VCLXEdit::setEditable( sal_Bool bEditable ) throw(::com::sun::star::uno::RuntimeException)
3659 {
3660 	::vos::OGuard aGuard( GetMutex() );
3661 
3662 	Edit* pEdit = (Edit*) GetWindow();
3663 	if ( pEdit )
3664 		pEdit->SetReadOnly( !bEditable );
3665 }
3666 
3667 
setMaxTextLen(sal_Int16 nLen)3668 void VCLXEdit::setMaxTextLen( sal_Int16 nLen ) throw(::com::sun::star::uno::RuntimeException)
3669 {
3670 	::vos::OGuard aGuard( GetMutex() );
3671 
3672 	Edit* pEdit = (Edit*) GetWindow();
3673 	if ( pEdit )
3674 		pEdit->SetMaxTextLen( nLen );
3675 }
3676 
getMaxTextLen()3677 sal_Int16 VCLXEdit::getMaxTextLen() throw(::com::sun::star::uno::RuntimeException)
3678 {
3679 	::vos::OGuard aGuard( GetMutex() );
3680 
3681 	Edit* pEdit = (Edit*) GetWindow();
3682 	return pEdit ? pEdit->GetMaxTextLen() : 0;
3683 }
3684 
setEchoChar(sal_Unicode cEcho)3685 void VCLXEdit::setEchoChar( sal_Unicode cEcho ) throw(::com::sun::star::uno::RuntimeException)
3686 {
3687 	::vos::OGuard aGuard( GetMutex() );
3688 
3689 	Edit* pEdit = (Edit*) GetWindow();
3690 	if ( pEdit )
3691 		pEdit->SetEchoChar( cEcho );
3692 }
3693 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)3694 void VCLXEdit::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
3695 {
3696 	::vos::OGuard aGuard( GetMutex() );
3697 
3698 	Edit* pEdit = (Edit*)GetWindow();
3699 	if ( pEdit )
3700 	{
3701 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
3702 		switch ( nPropType )
3703 		{
3704             case BASEPROPERTY_HIDEINACTIVESELECTION:
3705                 ::toolkit::adjustBooleanWindowStyle( Value, pEdit, WB_NOHIDESELECTION, sal_True );
3706                 if ( pEdit->GetSubEdit() )
3707                     ::toolkit::adjustBooleanWindowStyle( Value, pEdit->GetSubEdit(), WB_NOHIDESELECTION, sal_True );
3708                 break;
3709 
3710             case BASEPROPERTY_READONLY:
3711 			{
3712 				sal_Bool b = sal_Bool();
3713 				if ( Value >>= b )
3714  					pEdit->SetReadOnly( b );
3715 			}
3716 			break;
3717 			case BASEPROPERTY_ECHOCHAR:
3718 			{
3719 				sal_Int16 n = sal_Int16();
3720 				if ( Value >>= n )
3721  					pEdit->SetEchoChar( n );
3722 			}
3723 			break;
3724 			case BASEPROPERTY_MAXTEXTLEN:
3725 			{
3726 				sal_Int16 n = sal_Int16();
3727 				if ( Value >>= n )
3728  					pEdit->SetMaxTextLen( n );
3729 			}
3730 			break;
3731 			default:
3732 			{
3733 				VCLXWindow::setProperty( PropertyName, Value );
3734 			}
3735 		}
3736 	}
3737 }
3738 
getProperty(const::rtl::OUString & PropertyName)3739 ::com::sun::star::uno::Any VCLXEdit::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
3740 {
3741 	::vos::OGuard aGuard( GetMutex() );
3742 
3743 	::com::sun::star::uno::Any aProp;
3744 	Edit* pEdit = (Edit*)GetWindow();
3745 	if ( pEdit )
3746 	{
3747 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
3748 		switch ( nPropType )
3749 		{
3750             case BASEPROPERTY_HIDEINACTIVESELECTION:
3751                 aProp <<= (sal_Bool)( ( pEdit->GetStyle() & WB_NOHIDESELECTION ) == 0 );
3752                 break;
3753 			case BASEPROPERTY_READONLY:
3754  				aProp <<= (sal_Bool) pEdit->IsReadOnly();
3755     			break;
3756 			case BASEPROPERTY_ECHOCHAR:
3757  				aProp <<= (sal_Int16) pEdit->GetEchoChar();
3758     			break;
3759 			case BASEPROPERTY_MAXTEXTLEN:
3760  				aProp <<= (sal_Int16) pEdit->GetMaxTextLen();
3761     			break;
3762 			default:
3763 			{
3764 				aProp = VCLXWindow::getProperty( PropertyName );
3765 			}
3766 		}
3767 	}
3768 	return aProp;
3769 }
3770 
getMinimumSize()3771 ::com::sun::star::awt::Size VCLXEdit::getMinimumSize(  ) throw(::com::sun::star::uno::RuntimeException)
3772 {
3773 	::vos::OGuard aGuard( GetMutex() );
3774 
3775 	Size aSz;
3776 	Edit* pEdit = (Edit*) GetWindow();
3777 	if ( pEdit )
3778 		aSz = pEdit->CalcMinimumSize();
3779 	return AWTSize(aSz);
3780 }
3781 
getPreferredSize()3782 ::com::sun::star::awt::Size VCLXEdit::getPreferredSize(  ) throw(::com::sun::star::uno::RuntimeException)
3783 {
3784 	::vos::OGuard aGuard( GetMutex() );
3785 
3786 	Size aSz;
3787 	Edit* pEdit = (Edit*) GetWindow();
3788 	if ( pEdit )
3789 	{
3790 		aSz = pEdit->CalcMinimumSize();
3791 		aSz.Height() += 4;
3792 	}
3793 	return AWTSize(aSz);
3794 }
3795 
calcAdjustedSize(const::com::sun::star::awt::Size & rNewSize)3796 ::com::sun::star::awt::Size VCLXEdit::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException)
3797 {
3798 	::vos::OGuard aGuard( GetMutex() );
3799 
3800 	::com::sun::star::awt::Size aSz = rNewSize;
3801 	::com::sun::star::awt::Size aMinSz = getMinimumSize();
3802 	if ( aSz.Height != aMinSz.Height )
3803 		aSz.Height = aMinSz.Height;
3804 
3805 	return aSz;
3806 }
3807 
getMinimumSize(sal_Int16 nCols,sal_Int16)3808 ::com::sun::star::awt::Size VCLXEdit::getMinimumSize( sal_Int16 nCols, sal_Int16 ) throw(::com::sun::star::uno::RuntimeException)
3809 {
3810 	::vos::OGuard aGuard( GetMutex() );
3811 
3812 	Size aSz;
3813 	Edit* pEdit = (Edit*) GetWindow();
3814 	if ( pEdit )
3815 	{
3816 		if ( nCols )
3817 			aSz = pEdit->CalcSize( nCols );
3818 		else
3819 			aSz = pEdit->CalcMinimumSize();
3820 	}
3821 	return AWTSize(aSz);
3822 }
3823 
getColumnsAndLines(sal_Int16 & nCols,sal_Int16 & nLines)3824 void VCLXEdit::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException)
3825 {
3826 	::vos::OGuard aGuard( GetMutex() );
3827 
3828 	nLines = 1;
3829 	nCols = 0;
3830 	Edit* pEdit = (Edit*) GetWindow();
3831 	if ( pEdit )
3832 		nCols = pEdit->GetMaxVisChars();
3833 }
3834 
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)3835 void VCLXEdit::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
3836 {
3837 	switch ( rVclWindowEvent.GetId() )
3838 	{
3839 		case VCLEVENT_EDIT_MODIFY:
3840         {
3841             ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
3842                 // since we call listeners below, there is a potential that we will be destroyed
3843                 // during the listener call. To prevent the resulting crashs, we keep us
3844                 // alive as long as we're here
3845                 // #20178# - 2003-10-01 - fs@openoffice.org
3846 
3847 			if ( GetTextListeners().getLength() )
3848 			{
3849 				::com::sun::star::awt::TextEvent aEvent;
3850 				aEvent.Source = (::cppu::OWeakObject*)this;
3851 				GetTextListeners().textChanged( aEvent );
3852 			}
3853         }
3854 		break;
3855 
3856 		default:
3857 			VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
3858 			break;
3859 	}
3860 }
3861 
3862 //	----------------------------------------------------
3863 //	class VCLXComboBox
3864 //	----------------------------------------------------
3865 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)3866 void VCLXComboBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
3867 {
3868     PushPropertyIds( rIds,
3869                      BASEPROPERTY_AUTOCOMPLETE,
3870                      BASEPROPERTY_BACKGROUNDCOLOR,
3871                      BASEPROPERTY_BORDER,
3872                      BASEPROPERTY_BORDERCOLOR,
3873                      BASEPROPERTY_DEFAULTCONTROL,
3874                      BASEPROPERTY_DROPDOWN,
3875                      BASEPROPERTY_ENABLED,
3876                      BASEPROPERTY_ENABLEVISIBLE,
3877                      BASEPROPERTY_FONTDESCRIPTOR,
3878                      BASEPROPERTY_HELPTEXT,
3879                      BASEPROPERTY_HELPURL,
3880                      BASEPROPERTY_LINECOUNT,
3881                      BASEPROPERTY_MAXTEXTLEN,
3882                      BASEPROPERTY_PRINTABLE,
3883                      BASEPROPERTY_READONLY,
3884                      BASEPROPERTY_STRINGITEMLIST,
3885                      BASEPROPERTY_TABSTOP,
3886                      BASEPROPERTY_TEXT,
3887                      BASEPROPERTY_HIDEINACTIVESELECTION,
3888                      BASEPROPERTY_ALIGN,
3889                      BASEPROPERTY_WRITING_MODE,
3890                      BASEPROPERTY_CONTEXT_WRITING_MODE,
3891                      BASEPROPERTY_REFERENCE_DEVICE,
3892                      BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
3893                      0);
3894     // no, don't call VCLXEdit here - it has properties which we do *not* want to have at at combo box
3895     // #i92690# / 2008-08-12 / frank.schoenheit@sun.com
3896     // VCLXEdit::ImplGetPropertyIds( rIds );
3897     VCLXWindow::ImplGetPropertyIds( rIds );
3898 }
3899 
VCLXComboBox()3900 VCLXComboBox::VCLXComboBox()
3901 	: maActionListeners( *this ), maItemListeners( *this )
3902 {
3903 }
3904 
~VCLXComboBox()3905 VCLXComboBox::~VCLXComboBox()
3906 {
3907 #ifndef __SUNPRO_CC
3908     OSL_TRACE ("%s", __FUNCTION__);
3909 #endif
3910 }
3911 
CreateAccessibleContext()3912 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXComboBox::CreateAccessibleContext()
3913 {
3914 	::vos::OGuard aGuard( GetMutex() );
3915 
3916     return getAccessibleFactory().createAccessibleContext( this );
3917 }
3918 
dispose()3919 void VCLXComboBox::dispose() throw(::com::sun::star::uno::RuntimeException)
3920 {
3921 	::vos::OGuard aGuard( GetMutex() );
3922 
3923 	::com::sun::star::lang::EventObject aObj;
3924 	aObj.Source = (::cppu::OWeakObject*)this;
3925 	maItemListeners.disposeAndClear( aObj );
3926 	maActionListeners.disposeAndClear( aObj );
3927 	VCLXEdit::dispose();
3928 }
3929 
3930 
addItemListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XItemListener> & l)3931 void VCLXComboBox::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException)
3932 {
3933 	::vos::OGuard aGuard( GetMutex() );
3934 	maItemListeners.addInterface( l );
3935 }
3936 
removeItemListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XItemListener> & l)3937 void VCLXComboBox::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException)
3938 {
3939 	::vos::OGuard aGuard( GetMutex() );
3940 	maItemListeners.removeInterface( l );
3941 }
3942 
addActionListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XActionListener> & l)3943 void VCLXComboBox::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException)
3944 {
3945 	::vos::OGuard aGuard( GetMutex() );
3946 	maActionListeners.addInterface( l );
3947 }
3948 
removeActionListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XActionListener> & l)3949 void VCLXComboBox::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException)
3950 {
3951 	::vos::OGuard aGuard( GetMutex() );
3952 	maActionListeners.removeInterface( l );
3953 }
3954 
addItem(const::rtl::OUString & aItem,sal_Int16 nPos)3955 void VCLXComboBox::addItem( const ::rtl::OUString& aItem, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException)
3956 {
3957 	::vos::OGuard aGuard( GetMutex() );
3958 
3959 	ComboBox* pBox = (ComboBox*) GetWindow();
3960 	if ( pBox )
3961 		pBox->InsertEntry( aItem, nPos );
3962 }
3963 
addItems(const::com::sun::star::uno::Sequence<::rtl::OUString> & aItems,sal_Int16 nPos)3964 void VCLXComboBox::addItems( const ::com::sun::star::uno::Sequence< ::rtl::OUString>& aItems, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException)
3965 {
3966 	::vos::OGuard aGuard( GetMutex() );
3967 
3968 	ComboBox* pBox = (ComboBox*) GetWindow();
3969 	if ( pBox )
3970 	{
3971 		sal_uInt16 nP = nPos;
3972 		for ( sal_uInt16 n = 0; n < aItems.getLength(); n++ )
3973 		{
3974 			pBox->InsertEntry( aItems.getConstArray()[n], nP );
3975 			if ( nP == 0xFFFF )
3976             {
3977                 OSL_ENSURE( false, "VCLXComboBox::addItems: too many entries!" );
3978                 // skip remaining entries, list cannot hold them, anyway
3979                 break;
3980             }
3981 		}
3982 	}
3983 }
3984 
removeItems(sal_Int16 nPos,sal_Int16 nCount)3985 void VCLXComboBox::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(::com::sun::star::uno::RuntimeException)
3986 {
3987 	::vos::OGuard aGuard( GetMutex() );
3988 
3989 	ComboBox* pBox = (ComboBox*) GetWindow();
3990 	if ( pBox )
3991 	{
3992 		for ( sal_uInt16 n = nCount; n; )
3993 			pBox->RemoveEntry( nPos + (--n) );
3994 	}
3995 }
3996 
getItemCount()3997 sal_Int16 VCLXComboBox::getItemCount() throw(::com::sun::star::uno::RuntimeException)
3998 {
3999 	::vos::OGuard aGuard( GetMutex() );
4000 
4001 	ComboBox* pBox = (ComboBox*) GetWindow();
4002 	return pBox ? pBox->GetEntryCount() : 0;
4003 }
4004 
getItem(sal_Int16 nPos)4005 ::rtl::OUString VCLXComboBox::getItem( sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException)
4006 {
4007 	::vos::OGuard aGuard( GetMutex() );
4008 
4009 	::rtl::OUString aItem;
4010 	ComboBox* pBox = (ComboBox*) GetWindow();
4011 	if ( pBox )
4012 		aItem = pBox->GetEntry( nPos );
4013 	return aItem;
4014 }
4015 
getItems()4016 ::com::sun::star::uno::Sequence< ::rtl::OUString> VCLXComboBox::getItems() throw(::com::sun::star::uno::RuntimeException)
4017 {
4018 	::vos::OGuard aGuard( GetMutex() );
4019 
4020 	::com::sun::star::uno::Sequence< ::rtl::OUString> aSeq;
4021 	ComboBox* pBox = (ComboBox*) GetWindow();
4022 	if ( pBox )
4023 	{
4024 		sal_uInt16 nEntries = pBox->GetEntryCount();
4025 		aSeq = ::com::sun::star::uno::Sequence< ::rtl::OUString>( nEntries );
4026 		for ( sal_uInt16 n = nEntries; n; )
4027 		{
4028 			--n;
4029 			aSeq.getArray()[n] = pBox->GetEntry( n );
4030 		}
4031 	}
4032 	return aSeq;
4033 }
4034 
setDropDownLineCount(sal_Int16 nLines)4035 void VCLXComboBox::setDropDownLineCount( sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException)
4036 {
4037 	::vos::OGuard aGuard( GetMutex() );
4038 
4039 	ComboBox* pBox = (ComboBox*) GetWindow();
4040 	if ( pBox )
4041 		pBox->SetDropDownLineCount( nLines );
4042 }
4043 
getDropDownLineCount()4044 sal_Int16 VCLXComboBox::getDropDownLineCount() throw(::com::sun::star::uno::RuntimeException)
4045 {
4046 	::vos::OGuard aGuard( GetMutex() );
4047 
4048 	sal_Int16 nLines = 0;
4049 	ComboBox* pBox = (ComboBox*) GetWindow();
4050 	if ( pBox )
4051 		nLines = pBox->GetDropDownLineCount();
4052 	return nLines;
4053 }
4054 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)4055 void VCLXComboBox::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
4056 {
4057 	::vos::OGuard aGuard( GetMutex() );
4058 
4059 	ComboBox* pComboBox = (ComboBox*)GetWindow();
4060 	if ( pComboBox )
4061 	{
4062 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
4063 		switch ( nPropType )
4064 		{
4065 			case BASEPROPERTY_LINECOUNT:
4066 			{
4067 				sal_Int16 n = sal_Int16();
4068 				if ( Value >>= n )
4069  					pComboBox->SetDropDownLineCount( n );
4070 			}
4071 			break;
4072 			case BASEPROPERTY_AUTOCOMPLETE:
4073 			{
4074 				sal_Int16 n = sal_Int16();
4075 				if ( Value >>= n )
4076  					pComboBox->EnableAutocomplete( n != 0 );
4077  				else
4078  				{
4079 					sal_Bool b = sal_Bool();
4080 					if ( Value >>= b )
4081 						pComboBox->EnableAutocomplete( b );
4082 				}
4083 			}
4084 			break;
4085 			case BASEPROPERTY_STRINGITEMLIST:
4086 			{
4087                 ::com::sun::star::uno::Sequence< ::rtl::OUString> aItems;
4088 				if ( Value >>= aItems )
4089 				{
4090 					pComboBox->Clear();
4091 					addItems( aItems, 0 );
4092 				}
4093 			}
4094 			break;
4095 			default:
4096 			{
4097 				VCLXEdit::setProperty( PropertyName, Value );
4098 
4099 				// #109385# SetBorderStyle is not virtual
4100 				if ( nPropType == BASEPROPERTY_BORDER )
4101 				{
4102 					sal_uInt16 nBorder = sal_uInt16();
4103 					if ( (Value >>= nBorder) && nBorder != 0 )
4104 						pComboBox->SetBorderStyle( nBorder );
4105 				}
4106 			}
4107 		}
4108 	}
4109 }
4110 
getProperty(const::rtl::OUString & PropertyName)4111 ::com::sun::star::uno::Any VCLXComboBox::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
4112 {
4113 	::vos::OGuard aGuard( GetMutex() );
4114 
4115 	::com::sun::star::uno::Any aProp;
4116 	ComboBox* pComboBox = (ComboBox*)GetWindow();
4117 	if ( pComboBox )
4118 	{
4119 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
4120 		switch ( nPropType )
4121 		{
4122 			case BASEPROPERTY_LINECOUNT:
4123 			{
4124  				aProp <<= (sal_Int16)  pComboBox->GetDropDownLineCount();
4125 			}
4126 			break;
4127 			case BASEPROPERTY_AUTOCOMPLETE:
4128 			{
4129  				aProp <<= (sal_Bool) pComboBox->IsAutocompleteEnabled();
4130 			}
4131 			break;
4132 			case BASEPROPERTY_STRINGITEMLIST:
4133 			{
4134 				sal_uInt16 nItems = pComboBox->GetEntryCount();
4135 				::com::sun::star::uno::Sequence< ::rtl::OUString> aSeq( nItems );
4136 				::rtl::OUString* pStrings = aSeq.getArray();
4137 				for ( sal_uInt16 n = 0; n < nItems; n++ )
4138 					pStrings[n] = pComboBox->GetEntry( n );
4139 				aProp <<= aSeq;
4140 
4141 			}
4142 			break;
4143 			default:
4144 			{
4145 				aProp <<= VCLXEdit::getProperty( PropertyName );
4146 			}
4147 		}
4148 	}
4149 	return aProp;
4150 }
4151 
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)4152 void VCLXComboBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
4153 {
4154     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
4155         // since we call listeners below, there is a potential that we will be destroyed
4156         // during the listener call. To prevent the resulting crashs, we keep us
4157         // alive as long as we're here
4158         // #20178# - 2003-10-01 - fs@openoffice.org
4159 
4160 	switch ( rVclWindowEvent.GetId() )
4161 	{
4162 		case VCLEVENT_COMBOBOX_SELECT:
4163 			if ( maItemListeners.getLength() )
4164 			{
4165 				ComboBox* pComboBox = (ComboBox*)GetWindow();
4166                 if( pComboBox )
4167                 {
4168 				    if ( !pComboBox->IsTravelSelect() )
4169 				    {
4170 					    ::com::sun::star::awt::ItemEvent aEvent;
4171 					    aEvent.Source = (::cppu::OWeakObject*)this;
4172 					    aEvent.Highlighted = sal_False;
4173 
4174 					    // Bei Mehrfachselektion 0xFFFF, sonst die ID
4175 					    aEvent.Selected = pComboBox->GetEntryPos( pComboBox->GetText() );
4176 
4177 					    maItemListeners.itemStateChanged( aEvent );
4178 				    }
4179                 }
4180 			}
4181 			break;
4182 
4183 		case VCLEVENT_COMBOBOX_DOUBLECLICK:
4184 			if ( maActionListeners.getLength() )
4185 			{
4186 				::com::sun::star::awt::ActionEvent aEvent;
4187 				aEvent.Source = (::cppu::OWeakObject*)this;
4188 //				aEvent.ActionCommand = ...;
4189 				maActionListeners.actionPerformed( aEvent );
4190 			}
4191 			break;
4192 
4193 		default:
4194 			VCLXEdit::ProcessWindowEvent( rVclWindowEvent );
4195 			break;
4196 	}
4197 }
4198 
getMinimumSize()4199 ::com::sun::star::awt::Size VCLXComboBox::getMinimumSize(  ) throw(::com::sun::star::uno::RuntimeException)
4200 {
4201 	::vos::OGuard aGuard( GetMutex() );
4202 
4203 	Size aSz;
4204 	ComboBox* pComboBox = (ComboBox*) GetWindow();
4205 	if ( pComboBox )
4206 		aSz = pComboBox->CalcMinimumSize();
4207 	return AWTSize(aSz);
4208 }
4209 
getPreferredSize()4210 ::com::sun::star::awt::Size VCLXComboBox::getPreferredSize(  ) throw(::com::sun::star::uno::RuntimeException)
4211 {
4212 	::vos::OGuard aGuard( GetMutex() );
4213 
4214 	Size aSz;
4215 	ComboBox* pComboBox = (ComboBox*) GetWindow();
4216 	if ( pComboBox )
4217 	{
4218 		aSz = pComboBox->CalcMinimumSize();
4219 		if ( pComboBox->GetStyle() & WB_DROPDOWN )
4220 			aSz.Height() += 4;
4221 	}
4222 	return AWTSize(aSz);
4223 }
4224 
calcAdjustedSize(const::com::sun::star::awt::Size & rNewSize)4225 ::com::sun::star::awt::Size VCLXComboBox::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException)
4226 {
4227 	::vos::OGuard aGuard( GetMutex() );
4228 
4229 	Size aSz = VCLSize(rNewSize);
4230 	ComboBox* pComboBox = (ComboBox*) GetWindow();
4231 	if ( pComboBox )
4232 		aSz = pComboBox->CalcAdjustedSize( aSz );
4233 	return AWTSize(aSz);
4234 }
4235 
getMinimumSize(sal_Int16 nCols,sal_Int16 nLines)4236 ::com::sun::star::awt::Size VCLXComboBox::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException)
4237 {
4238 	::vos::OGuard aGuard( GetMutex() );
4239 
4240 	Size aSz;
4241 	ComboBox* pComboBox = (ComboBox*) GetWindow();
4242 	if ( pComboBox )
4243 		aSz = pComboBox->CalcSize( nCols, nLines );
4244 	return AWTSize(aSz);
4245 }
4246 
getColumnsAndLines(sal_Int16 & nCols,sal_Int16 & nLines)4247 void VCLXComboBox::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException)
4248 {
4249 	::vos::OGuard aGuard( GetMutex() );
4250 
4251 	nCols = nLines = 0;
4252 	ComboBox* pComboBox = (ComboBox*) GetWindow();
4253 	if ( pComboBox )
4254 	{
4255 		sal_uInt16 nC, nL;
4256 		pComboBox->GetMaxVisColumnsAndLines( nC, nL );
4257 		nCols = nC;
4258 		nLines = nL;
4259 	}
4260 }
listItemInserted(const ItemListEvent & i_rEvent)4261 void SAL_CALL VCLXComboBox::listItemInserted( const ItemListEvent& i_rEvent ) throw (RuntimeException)
4262 {
4263 	::vos::OGuard aGuard( GetMutex() );
4264 
4265     ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() );
4266 
4267     ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemInserted: no ComboBox?!" );
4268     ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition <= sal_Int32( pComboBox->GetEntryCount() ) ),
4269         "VCLXComboBox::listItemInserted: illegal (inconsistent) item position!" );
4270     pComboBox->InsertEntry(
4271         i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : ::rtl::OUString(),
4272         i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : Image(),
4273         i_rEvent.ItemPosition );
4274 }
4275 
listItemRemoved(const ItemListEvent & i_rEvent)4276 void SAL_CALL VCLXComboBox::listItemRemoved( const ItemListEvent& i_rEvent ) throw (RuntimeException)
4277 {
4278 	::vos::OGuard aGuard( GetMutex() );
4279 
4280     ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() );
4281 
4282     ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemRemoved: no ComboBox?!" );
4283     ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pComboBox->GetEntryCount() ) ),
4284         "VCLXComboBox::listItemRemoved: illegal (inconsistent) item position!" );
4285 
4286     pComboBox->RemoveEntry( i_rEvent.ItemPosition );
4287 }
4288 
listItemModified(const ItemListEvent & i_rEvent)4289 void SAL_CALL VCLXComboBox::listItemModified( const ItemListEvent& i_rEvent ) throw (RuntimeException)
4290 {
4291 	::vos::OGuard aGuard( GetMutex() );
4292 
4293     ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() );
4294 
4295     ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" );
4296     ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pComboBox->GetEntryCount() ) ),
4297         "VCLXComboBox::listItemModified: illegal (inconsistent) item position!" );
4298 
4299     // VCL's ComboBox does not support changing an entry's text or image, so remove and re-insert
4300 
4301     const ::rtl::OUString sNewText = i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : ::rtl::OUString( pComboBox->GetEntry( i_rEvent.ItemPosition ) );
4302     const Image aNewImage( i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : pComboBox->GetEntryImage( i_rEvent.ItemPosition  ) );
4303 
4304     pComboBox->RemoveEntry( i_rEvent.ItemPosition );
4305     pComboBox->InsertEntry( sNewText, aNewImage, i_rEvent.ItemPosition );
4306 }
4307 
allItemsRemoved(const EventObject & i_rEvent)4308 void SAL_CALL VCLXComboBox::allItemsRemoved( const EventObject& i_rEvent ) throw (RuntimeException)
4309 {
4310 	::vos::OGuard aGuard( GetMutex() );
4311 
4312     ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() );
4313     ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" );
4314 
4315     pComboBox->Clear();
4316 
4317     (void)i_rEvent;
4318 }
4319 
itemListChanged(const EventObject & i_rEvent)4320 void SAL_CALL VCLXComboBox::itemListChanged( const EventObject& i_rEvent ) throw (RuntimeException)
4321 {
4322 	::vos::OGuard aGuard( GetMutex() );
4323 
4324     ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() );
4325     ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" );
4326 
4327     pComboBox->Clear();
4328 
4329     uno::Reference< beans::XPropertySet > xPropSet( i_rEvent.Source, uno::UNO_QUERY_THROW );
4330     uno::Reference< beans::XPropertySetInfo > xPSI( xPropSet->getPropertySetInfo(), uno::UNO_QUERY_THROW );
4331     // bool localize = xPSI->hasPropertyByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" ) ) );
4332     uno::Reference< resource::XStringResourceResolver > xStringResourceResolver;
4333     if ( xPSI->hasPropertyByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" ) ) ) )
4334     {
4335         xStringResourceResolver.set(
4336             xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" ) ) ),
4337             uno::UNO_QUERY
4338         );
4339     }
4340 
4341 
4342     Reference< XItemList > xItemList( i_rEvent.Source, uno::UNO_QUERY_THROW );
4343     uno::Sequence< beans::Pair< ::rtl::OUString, ::rtl::OUString > > aItems = xItemList->getAllItems();
4344     for ( sal_Int32 i=0; i<aItems.getLength(); ++i )
4345     {
4346         ::rtl::OUString aLocalizationKey( aItems[i].First );
4347         if ( xStringResourceResolver.is() && aLocalizationKey.getLength() != 0 && aLocalizationKey[0] == '&' )
4348         {
4349             aLocalizationKey = xStringResourceResolver->resolveString(aLocalizationKey.copy( 1 ));
4350         }
4351         pComboBox->InsertEntry( aLocalizationKey, lcl_getImageFromURL( aItems[i].Second ) );
4352     }
4353 }
disposing(const EventObject & i_rEvent)4354 void SAL_CALL VCLXComboBox::disposing( const EventObject& i_rEvent ) throw (RuntimeException)
4355 {
4356     // just disambiguate
4357     VCLXEdit::disposing( i_rEvent );
4358 }
4359 
4360 //	----------------------------------------------------
4361 //	class VCLXFormattedSpinField
4362 //	----------------------------------------------------
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)4363 void VCLXFormattedSpinField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
4364 {
4365     // Interestingly in the UnoControl API this is
4366     // - not derived from XEdit ultimately, (correct ?) - so cut this here ...
4367 //    VCLXSpinField::ImplGetPropertyIds( rIds );
4368     VCLXWindow::ImplGetPropertyIds( rIds );
4369 }
4370 
VCLXFormattedSpinField()4371 VCLXFormattedSpinField::VCLXFormattedSpinField()
4372 {
4373 }
4374 
~VCLXFormattedSpinField()4375 VCLXFormattedSpinField::~VCLXFormattedSpinField()
4376 {
4377 }
4378 
setStrictFormat(sal_Bool bStrict)4379 void VCLXFormattedSpinField::setStrictFormat( sal_Bool bStrict )
4380 {
4381 	::vos::OGuard aGuard( GetMutex() );
4382 
4383 	FormatterBase* pFormatter = GetFormatter();
4384 	if ( pFormatter )
4385 		pFormatter->SetStrictFormat( bStrict );
4386 }
4387 
isStrictFormat()4388 sal_Bool VCLXFormattedSpinField::isStrictFormat()
4389 {
4390 	FormatterBase* pFormatter = GetFormatter();
4391 	return pFormatter ? pFormatter->IsStrictFormat() : sal_False;
4392 }
4393 
4394 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)4395 void VCLXFormattedSpinField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
4396 {
4397 	::vos::OGuard aGuard( GetMutex() );
4398 
4399 	FormatterBase* pFormatter = GetFormatter();
4400 	if ( pFormatter )
4401 	{
4402 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
4403 		switch ( nPropType )
4404 		{
4405 			case BASEPROPERTY_SPIN:
4406 			{
4407 				sal_Bool b = sal_Bool();
4408 				if ( Value >>= b )
4409 				{
4410 					WinBits nStyle = GetWindow()->GetStyle() | WB_SPIN;
4411 					if ( !b )
4412 						nStyle &= ~WB_SPIN;
4413 					GetWindow()->SetStyle( nStyle );
4414 				}
4415 			}
4416 			break;
4417 			case BASEPROPERTY_STRICTFORMAT:
4418 			{
4419 				sal_Bool b = sal_Bool();
4420 				if ( Value >>= b )
4421 				{
4422 	 				pFormatter->SetStrictFormat( b );
4423 				}
4424 			}
4425 			break;
4426 			default:
4427 			{
4428 				VCLXSpinField::setProperty( PropertyName, Value );
4429 			}
4430 		}
4431 	}
4432 }
4433 
getProperty(const::rtl::OUString & PropertyName)4434 ::com::sun::star::uno::Any VCLXFormattedSpinField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
4435 {
4436 	::vos::OGuard aGuard( GetMutex() );
4437 
4438 	::com::sun::star::uno::Any aProp;
4439 	FormatterBase* pFormatter = GetFormatter();
4440 	if ( pFormatter )
4441 	{
4442 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
4443 		switch ( nPropType )
4444 		{
4445 			case BASEPROPERTY_TABSTOP:
4446 			{
4447                 aProp <<= (sal_Bool) ( ( GetWindow()->GetStyle() & WB_SPIN ) ? sal_True : sal_False );
4448 			}
4449 			break;
4450 			case BASEPROPERTY_STRICTFORMAT:
4451 			{
4452 				aProp <<= (sal_Bool) pFormatter->IsStrictFormat();
4453 			}
4454 			break;
4455 			default:
4456 			{
4457 				aProp <<= VCLXSpinField::getProperty( PropertyName );
4458 			}
4459 		}
4460 	}
4461 	return aProp;
4462 }
4463 
4464 
4465 //	----------------------------------------------------
4466 //	class VCLXDateField
4467 //	----------------------------------------------------
4468 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)4469 void VCLXDateField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
4470 {
4471     PushPropertyIds( rIds,
4472                      BASEPROPERTY_ALIGN,
4473                      BASEPROPERTY_BACKGROUNDCOLOR,
4474                      BASEPROPERTY_BORDER,
4475                      BASEPROPERTY_BORDERCOLOR,
4476                      BASEPROPERTY_DATE,
4477                      BASEPROPERTY_DATEMAX,
4478                      BASEPROPERTY_DATEMIN,
4479                      BASEPROPERTY_DATESHOWCENTURY,
4480                      BASEPROPERTY_DEFAULTCONTROL,
4481                      BASEPROPERTY_DROPDOWN,
4482                      BASEPROPERTY_ENABLED,
4483                      BASEPROPERTY_ENABLEVISIBLE,
4484                      BASEPROPERTY_EXTDATEFORMAT,
4485                      BASEPROPERTY_FONTDESCRIPTOR,
4486                      BASEPROPERTY_HELPTEXT,
4487                      BASEPROPERTY_HELPURL,
4488                      BASEPROPERTY_PRINTABLE,
4489                      BASEPROPERTY_READONLY,
4490                      BASEPROPERTY_REPEAT,
4491                      BASEPROPERTY_REPEAT_DELAY,
4492                      BASEPROPERTY_SPIN,
4493                      BASEPROPERTY_STRICTFORMAT,
4494                      BASEPROPERTY_TABSTOP,
4495                      BASEPROPERTY_ENFORCE_FORMAT,
4496                      BASEPROPERTY_TEXT,
4497                      BASEPROPERTY_HIDEINACTIVESELECTION,
4498                      BASEPROPERTY_VERTICALALIGN,
4499                      BASEPROPERTY_WRITING_MODE,
4500                      BASEPROPERTY_CONTEXT_WRITING_MODE,
4501                      BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
4502                      0);
4503     VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
4504 }
4505 
VCLXDateField()4506 VCLXDateField::VCLXDateField()
4507 {
4508 }
4509 
~VCLXDateField()4510 VCLXDateField::~VCLXDateField()
4511 {
4512 }
4513 
4514 //change the window type here to match the role
CreateAccessibleContext()4515 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXDateField::CreateAccessibleContext()
4516 {
4517 	Window* pWindow = GetWindow();
4518 	if ( pWindow )
4519 	{
4520 		pWindow->SetType( WINDOW_DATEFIELD );
4521 	}
4522 	return getAccessibleFactory().createAccessibleContext( this );
4523 }
4524 
4525 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)4526 ::com::sun::star::uno::Any VCLXDateField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
4527 {
4528 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
4529 										SAL_STATIC_CAST( ::com::sun::star::awt::XDateField*, this ) );
4530 	return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
4531 }
4532 
4533 // ::com::sun::star::lang::XTypeProvider
4534 IMPL_XTYPEPROVIDER_START( VCLXDateField )
4535 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDateField>* ) NULL ),
4536 	VCLXFormattedSpinField::getTypes()
4537 IMPL_XTYPEPROVIDER_END
4538 
4539 void VCLXDateField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
4540 {
4541 	::vos::OGuard aGuard( GetMutex() );
4542 
4543 	if ( GetWindow() )
4544 	{
4545 		sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
4546 
4547 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
4548 		switch ( nPropType )
4549 		{
4550 			case BASEPROPERTY_DATE:
4551 			{
4552 				if ( bVoid )
4553 				{
4554 					((DateField*)GetWindow())->EnableEmptyFieldValue( sal_True );
4555 					((DateField*)GetWindow())->SetEmptyFieldValue();
4556 				}
4557 				else
4558 				{
4559 					sal_Int32 n = 0;
4560 					if ( Value >>= n )
4561  						setDate( n );
4562 				}
4563 			}
4564 			break;
4565 			case BASEPROPERTY_DATEMIN:
4566 			{
4567 				sal_Int32 n = 0;
4568 				if ( Value >>= n )
4569  					setMin( n );
4570 			}
4571 			break;
4572 			case BASEPROPERTY_DATEMAX:
4573 			{
4574 				sal_Int32 n = 0;
4575 				if ( Value >>= n )
4576  					setMax( n );
4577 			}
4578 			break;
4579 			case BASEPROPERTY_EXTDATEFORMAT:
4580 			{
4581 				sal_Int16 n = sal_Int16();
4582 				if ( Value >>= n )
4583 					((DateField*)GetWindow())->SetExtDateFormat( (ExtDateFieldFormat) n );
4584 			}
4585 			break;
4586 			case BASEPROPERTY_DATESHOWCENTURY:
4587 			{
4588 				sal_Bool b = sal_Bool();
4589 				if ( Value >>= b )
4590  					((DateField*)GetWindow())->SetShowDateCentury( b );
4591 			}
4592 			break;
4593             case BASEPROPERTY_ENFORCE_FORMAT:
4594             {
4595 				sal_Bool bEnforce( sal_True );
4596 				OSL_VERIFY( Value >>= bEnforce );
4597                 static_cast< DateField* >( GetWindow() )->EnforceValidValue( bEnforce );
4598             }
4599             break;
4600 			default:
4601 			{
4602 				VCLXFormattedSpinField::setProperty( PropertyName, Value );
4603 			}
4604 		}
4605 	}
4606 }
4607 
getProperty(const::rtl::OUString & PropertyName)4608 ::com::sun::star::uno::Any VCLXDateField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
4609 {
4610 	::vos::OGuard aGuard( GetMutex() );
4611 
4612 	::com::sun::star::uno::Any aProp;
4613 	FormatterBase* pFormatter = GetFormatter();
4614 	if ( pFormatter )
4615 	{
4616 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
4617 		switch ( nPropType )
4618 		{
4619 			case BASEPROPERTY_DATE:
4620 			{
4621 				aProp <<= (sal_Int32) getDate();
4622 			}
4623 			break;
4624 			case BASEPROPERTY_DATEMIN:
4625 			{
4626 				aProp <<= (sal_Int32) getMin();
4627 			}
4628 			break;
4629 			case BASEPROPERTY_DATEMAX:
4630 			{
4631 				aProp <<= (sal_Int32) getMax();
4632 			}
4633 			break;
4634 			case BASEPROPERTY_DATESHOWCENTURY:
4635 			{
4636 			    aProp <<= ((DateField*)GetWindow())->IsShowDateCentury();
4637 			}
4638 			break;
4639             case BASEPROPERTY_ENFORCE_FORMAT:
4640             {
4641                 aProp <<= (sal_Bool)static_cast< DateField* >( GetWindow() )->IsEnforceValidValue( );
4642             }
4643             break;
4644 			default:
4645 			{
4646 				aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
4647 			}
4648 		}
4649 	}
4650 	return aProp;
4651 }
4652 
4653 
setDate(sal_Int32 nDate)4654 void VCLXDateField::setDate( sal_Int32 nDate ) throw(::com::sun::star::uno::RuntimeException)
4655 {
4656 	::vos::OGuard aGuard( GetMutex() );
4657 
4658 	DateField* pDateField = (DateField*) GetWindow();
4659 	if ( pDateField )
4660     {
4661 		pDateField->SetDate( nDate );
4662 
4663         // #107218# Call same listeners like VCL would do after user interaction
4664         SetSynthesizingVCLEvent( sal_True );
4665         pDateField->SetModifyFlag();
4666         pDateField->Modify();
4667         SetSynthesizingVCLEvent( sal_False );
4668     }
4669 }
4670 
getDate()4671 sal_Int32 VCLXDateField::getDate() throw(::com::sun::star::uno::RuntimeException)
4672 {
4673 	::vos::OGuard aGuard( GetMutex() );
4674 
4675 	sal_Int32 nDate = 0;
4676 	DateField* pDateField = (DateField*) GetWindow();
4677 	if ( pDateField )
4678 		nDate = pDateField->GetDate().GetDate();
4679 
4680 	return nDate;
4681 }
4682 
setMin(sal_Int32 nDate)4683 void VCLXDateField::setMin( sal_Int32 nDate ) throw(::com::sun::star::uno::RuntimeException)
4684 {
4685 	::vos::OGuard aGuard( GetMutex() );
4686 
4687 	DateField* pDateField = (DateField*) GetWindow();
4688 	if ( pDateField )
4689 		pDateField->SetMin( nDate );
4690 }
4691 
getMin()4692 sal_Int32 VCLXDateField::getMin() throw(::com::sun::star::uno::RuntimeException)
4693 {
4694 	::vos::OGuard aGuard( GetMutex() );
4695 
4696 	sal_Int32 nDate = 0;
4697 	DateField* pDateField = (DateField*) GetWindow();
4698 	if ( pDateField )
4699 		nDate = pDateField->GetMin().GetDate();
4700 
4701 	return nDate;
4702 }
4703 
setMax(sal_Int32 nDate)4704 void VCLXDateField::setMax( sal_Int32 nDate ) throw(::com::sun::star::uno::RuntimeException)
4705 {
4706 	::vos::OGuard aGuard( GetMutex() );
4707 
4708 	DateField* pDateField = (DateField*) GetWindow();
4709 	if ( pDateField )
4710 		pDateField->SetMax( nDate );
4711 }
4712 
getMax()4713 sal_Int32 VCLXDateField::getMax() throw(::com::sun::star::uno::RuntimeException)
4714 {
4715 	::vos::OGuard aGuard( GetMutex() );
4716 
4717 	sal_Int32 nDate = 0;
4718 	DateField* pDateField = (DateField*) GetWindow();
4719 	if ( pDateField )
4720 		nDate = pDateField->GetMax().GetDate();
4721 
4722 	return nDate;
4723 }
4724 
setFirst(sal_Int32 nDate)4725 void VCLXDateField::setFirst( sal_Int32 nDate ) throw(::com::sun::star::uno::RuntimeException)
4726 {
4727 	::vos::OGuard aGuard( GetMutex() );
4728 
4729 	DateField* pDateField = (DateField*) GetWindow();
4730 	if ( pDateField )
4731 		pDateField->SetFirst( nDate );
4732 }
4733 
getFirst()4734 sal_Int32 VCLXDateField::getFirst() throw(::com::sun::star::uno::RuntimeException)
4735 {
4736 	::vos::OGuard aGuard( GetMutex() );
4737 
4738 	sal_Int32 nDate = 0;
4739 	DateField* pDateField = (DateField*) GetWindow();
4740 	if ( pDateField )
4741 		nDate = pDateField->GetFirst().GetDate();
4742 
4743 	return nDate;
4744 }
4745 
setLast(sal_Int32 nDate)4746 void VCLXDateField::setLast( sal_Int32 nDate ) throw(::com::sun::star::uno::RuntimeException)
4747 {
4748 	::vos::OGuard aGuard( GetMutex() );
4749 
4750 	DateField* pDateField = (DateField*) GetWindow();
4751 	if ( pDateField )
4752 		pDateField->SetLast( nDate );
4753 }
4754 
getLast()4755 sal_Int32 VCLXDateField::getLast() throw(::com::sun::star::uno::RuntimeException)
4756 {
4757 	::vos::OGuard aGuard( GetMutex() );
4758 
4759 	sal_Int32 nDate = 0;
4760 	DateField* pDateField = (DateField*) GetWindow();
4761 	if ( pDateField )
4762 		nDate = pDateField->GetLast().GetDate();
4763 
4764 	return nDate;
4765 }
4766 
setLongFormat(sal_Bool bLong)4767 void VCLXDateField::setLongFormat( sal_Bool bLong ) throw(::com::sun::star::uno::RuntimeException)
4768 {
4769 	::vos::OGuard aGuard( GetMutex() );
4770 
4771 	DateField* pDateField = (DateField*) GetWindow();
4772 	if ( pDateField )
4773 		pDateField->SetLongFormat( bLong );
4774 }
4775 
isLongFormat()4776 sal_Bool VCLXDateField::isLongFormat() throw(::com::sun::star::uno::RuntimeException)
4777 {
4778 	::vos::OGuard aGuard( GetMutex() );
4779 
4780 	DateField* pDateField = (DateField*) GetWindow();
4781 	return pDateField ? pDateField->IsLongFormat() : sal_False;
4782 }
4783 
setEmpty()4784 void VCLXDateField::setEmpty() throw(::com::sun::star::uno::RuntimeException)
4785 {
4786 	::vos::OGuard aGuard( GetMutex() );
4787 
4788 	DateField* pDateField = (DateField*) GetWindow();
4789 	if ( pDateField )
4790     {
4791 		pDateField->SetEmptyDate();
4792 
4793         // #107218# Call same listeners like VCL would do after user interaction
4794         SetSynthesizingVCLEvent( sal_True );
4795         pDateField->SetModifyFlag();
4796         pDateField->Modify();
4797         SetSynthesizingVCLEvent( sal_False );
4798     }
4799 }
4800 
isEmpty()4801 sal_Bool VCLXDateField::isEmpty() throw(::com::sun::star::uno::RuntimeException)
4802 {
4803 	::vos::OGuard aGuard( GetMutex() );
4804 
4805 	DateField* pDateField = (DateField*) GetWindow();
4806 	return pDateField ? pDateField->IsEmptyDate() : sal_False;
4807 }
4808 
setStrictFormat(sal_Bool bStrict)4809 void VCLXDateField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException)
4810 {
4811 	VCLXFormattedSpinField::setStrictFormat( bStrict );
4812 }
4813 
isStrictFormat()4814 sal_Bool VCLXDateField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException)
4815 {
4816 	return VCLXFormattedSpinField::isStrictFormat();
4817 }
4818 
4819 
4820 //	----------------------------------------------------
4821 //	class VCLXTimeField
4822 //	----------------------------------------------------
4823 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)4824 void VCLXTimeField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
4825 {
4826     PushPropertyIds( rIds,
4827                      BASEPROPERTY_ALIGN,
4828                      BASEPROPERTY_BACKGROUNDCOLOR,
4829                      BASEPROPERTY_BORDER,
4830                      BASEPROPERTY_BORDERCOLOR,
4831                      BASEPROPERTY_DEFAULTCONTROL,
4832                      BASEPROPERTY_ENABLED,
4833                      BASEPROPERTY_ENABLEVISIBLE,
4834                      BASEPROPERTY_EXTTIMEFORMAT,
4835                      BASEPROPERTY_FONTDESCRIPTOR,
4836                      BASEPROPERTY_HELPTEXT,
4837                      BASEPROPERTY_HELPURL,
4838                      BASEPROPERTY_PRINTABLE,
4839                      BASEPROPERTY_READONLY,
4840                      BASEPROPERTY_REPEAT,
4841                      BASEPROPERTY_REPEAT_DELAY,
4842                      BASEPROPERTY_SPIN,
4843                      BASEPROPERTY_STRICTFORMAT,
4844                      BASEPROPERTY_TABSTOP,
4845                      BASEPROPERTY_TIME,
4846                      BASEPROPERTY_TIMEMAX,
4847                      BASEPROPERTY_TIMEMIN,
4848                      BASEPROPERTY_ENFORCE_FORMAT,
4849                      BASEPROPERTY_TEXT,
4850                      BASEPROPERTY_HIDEINACTIVESELECTION,
4851                      BASEPROPERTY_VERTICALALIGN,
4852                      BASEPROPERTY_WRITING_MODE,
4853                      BASEPROPERTY_CONTEXT_WRITING_MODE,
4854                      BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
4855                      0);
4856     VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
4857 }
4858 
VCLXTimeField()4859 VCLXTimeField::VCLXTimeField()
4860 {
4861 }
4862 
~VCLXTimeField()4863 VCLXTimeField::~VCLXTimeField()
4864 {
4865 }
4866 //change the window type here to match the role
CreateAccessibleContext()4867 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXTimeField::CreateAccessibleContext()
4868 {
4869 	Window* pWindow = GetWindow();
4870 	if ( pWindow )
4871 	{
4872 		pWindow->SetType( WINDOW_TIMEFIELD );
4873 	}
4874 	return getAccessibleFactory().createAccessibleContext( this );
4875 }
4876 
4877 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)4878 ::com::sun::star::uno::Any VCLXTimeField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
4879 {
4880 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
4881 										SAL_STATIC_CAST( ::com::sun::star::awt::XTimeField*, this ) );
4882 	return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
4883 }
4884 
4885 // ::com::sun::star::lang::XTypeProvider
4886 IMPL_XTYPEPROVIDER_START( VCLXTimeField )
4887 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTimeField>* ) NULL ),
4888 	VCLXFormattedSpinField::getTypes()
4889 IMPL_XTYPEPROVIDER_END
4890 
4891 void VCLXTimeField::setTime( sal_Int32 nTime ) throw(::com::sun::star::uno::RuntimeException)
4892 {
4893 	::vos::OGuard aGuard( GetMutex() );
4894 
4895 	TimeField* pTimeField = (TimeField*) GetWindow();
4896 	if ( pTimeField )
4897     {
4898 		pTimeField->SetTime( nTime );
4899 
4900         // #107218# Call same listeners like VCL would do after user interaction
4901         SetSynthesizingVCLEvent( sal_True );
4902         pTimeField->SetModifyFlag();
4903         pTimeField->Modify();
4904         SetSynthesizingVCLEvent( sal_False );
4905     }
4906 }
4907 
getTime()4908 sal_Int32 VCLXTimeField::getTime() throw(::com::sun::star::uno::RuntimeException)
4909 {
4910 	::vos::OGuard aGuard( GetMutex() );
4911 
4912 	sal_Int32 nTime = 0;
4913 	TimeField* pTimeField = (TimeField*) GetWindow();
4914 	if ( pTimeField )
4915 		nTime = pTimeField->GetTime().GetTime();
4916 
4917 	return nTime;
4918 }
4919 
setMin(sal_Int32 nTime)4920 void VCLXTimeField::setMin( sal_Int32 nTime ) throw(::com::sun::star::uno::RuntimeException)
4921 {
4922 	::vos::OGuard aGuard( GetMutex() );
4923 
4924 	TimeField* pTimeField = (TimeField*) GetWindow();
4925 	if ( pTimeField )
4926 		pTimeField->SetMin( nTime );
4927 }
4928 
getMin()4929 sal_Int32 VCLXTimeField::getMin() throw(::com::sun::star::uno::RuntimeException)
4930 {
4931 	::vos::OGuard aGuard( GetMutex() );
4932 
4933 	sal_Int32 nTime = 0;
4934 	TimeField* pTimeField = (TimeField*) GetWindow();
4935 	if ( pTimeField )
4936 		nTime = pTimeField->GetMin().GetTime();
4937 
4938 	return nTime;
4939 }
4940 
setMax(sal_Int32 nTime)4941 void VCLXTimeField::setMax( sal_Int32 nTime ) throw(::com::sun::star::uno::RuntimeException)
4942 {
4943 	::vos::OGuard aGuard( GetMutex() );
4944 
4945 	TimeField* pTimeField = (TimeField*) GetWindow();
4946 	if ( pTimeField )
4947 		pTimeField->SetMax( nTime );
4948 }
4949 
getMax()4950 sal_Int32 VCLXTimeField::getMax() throw(::com::sun::star::uno::RuntimeException)
4951 {
4952 	::vos::OGuard aGuard( GetMutex() );
4953 
4954 	sal_Int32 nTime = 0;
4955 	TimeField* pTimeField = (TimeField*) GetWindow();
4956 	if ( pTimeField )
4957 		nTime = pTimeField->GetMax().GetTime();
4958 
4959 	return nTime;
4960 }
4961 
setFirst(sal_Int32 nTime)4962 void VCLXTimeField::setFirst( sal_Int32 nTime ) throw(::com::sun::star::uno::RuntimeException)
4963 {
4964 	::vos::OGuard aGuard( GetMutex() );
4965 
4966 	TimeField* pTimeField = (TimeField*) GetWindow();
4967 	if ( pTimeField )
4968 		pTimeField->SetFirst( nTime );
4969 }
4970 
getFirst()4971 sal_Int32 VCLXTimeField::getFirst() throw(::com::sun::star::uno::RuntimeException)
4972 {
4973 	::vos::OGuard aGuard( GetMutex() );
4974 
4975 	sal_Int32 nTime = 0;
4976 	TimeField* pTimeField = (TimeField*) GetWindow();
4977 	if ( pTimeField )
4978 		nTime = pTimeField->GetFirst().GetTime();
4979 
4980 	return nTime;
4981 }
4982 
setLast(sal_Int32 nTime)4983 void VCLXTimeField::setLast( sal_Int32 nTime ) throw(::com::sun::star::uno::RuntimeException)
4984 {
4985 	::vos::OGuard aGuard( GetMutex() );
4986 
4987 	TimeField* pTimeField = (TimeField*) GetWindow();
4988 	if ( pTimeField )
4989 		pTimeField->SetLast( nTime );
4990 }
4991 
getLast()4992 sal_Int32 VCLXTimeField::getLast() throw(::com::sun::star::uno::RuntimeException)
4993 {
4994 	::vos::OGuard aGuard( GetMutex() );
4995 
4996 	sal_Int32 nTime = 0;
4997 	TimeField* pTimeField = (TimeField*) GetWindow();
4998 	if ( pTimeField )
4999 		nTime = pTimeField->GetLast().GetTime();
5000 
5001 	return nTime;
5002 }
5003 
setEmpty()5004 void VCLXTimeField::setEmpty() throw(::com::sun::star::uno::RuntimeException)
5005 {
5006 	::vos::OGuard aGuard( GetMutex() );
5007 
5008 	TimeField* pTimeField = (TimeField*) GetWindow();
5009 	if ( pTimeField )
5010 		pTimeField->SetEmptyTime();
5011 }
5012 
isEmpty()5013 sal_Bool VCLXTimeField::isEmpty() throw(::com::sun::star::uno::RuntimeException)
5014 {
5015 	::vos::OGuard aGuard( GetMutex() );
5016 
5017 	TimeField* pTimeField = (TimeField*) GetWindow();
5018 	return pTimeField ? pTimeField->IsEmptyTime() : sal_False;
5019 }
5020 
setStrictFormat(sal_Bool bStrict)5021 void VCLXTimeField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException)
5022 {
5023 	VCLXFormattedSpinField::setStrictFormat( bStrict );
5024 }
5025 
isStrictFormat()5026 sal_Bool VCLXTimeField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException)
5027 {
5028 	return VCLXFormattedSpinField::isStrictFormat();
5029 }
5030 
5031 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)5032 void VCLXTimeField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
5033 {
5034 	::vos::OGuard aGuard( GetMutex() );
5035 
5036 	if ( GetWindow() )
5037 	{
5038 		sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
5039 
5040 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
5041 		switch ( nPropType )
5042 		{
5043 			case BASEPROPERTY_TIME:
5044 			{
5045 				if ( bVoid )
5046 				{
5047 					((TimeField*)GetWindow())->EnableEmptyFieldValue( sal_True );
5048 					((TimeField*)GetWindow())->SetEmptyFieldValue();
5049 				}
5050 				else
5051 				{
5052 					sal_Int32 n = 0;
5053 					if ( Value >>= n )
5054  						setTime( n );
5055 				}
5056 			}
5057 			break;
5058 			case BASEPROPERTY_TIMEMIN:
5059 			{
5060 				sal_Int32 n = 0;
5061 				if ( Value >>= n )
5062  					setMin( n );
5063 			}
5064 			break;
5065 			case BASEPROPERTY_TIMEMAX:
5066 			{
5067 				sal_Int32 n = 0;
5068 				if ( Value >>= n )
5069  					setMax( n );
5070 			}
5071 			break;
5072 			case BASEPROPERTY_EXTTIMEFORMAT:
5073 			{
5074 				sal_Int16 n = sal_Int16();
5075 				if ( Value >>= n )
5076 					((TimeField*)GetWindow())->SetExtFormat( (ExtTimeFieldFormat) n );
5077 			}
5078 			break;
5079             case BASEPROPERTY_ENFORCE_FORMAT:
5080             {
5081 				sal_Bool bEnforce( sal_True );
5082 				OSL_VERIFY( Value >>= bEnforce );
5083                 static_cast< TimeField* >( GetWindow() )->EnforceValidValue( bEnforce );
5084             }
5085             break;
5086 			default:
5087 			{
5088 				VCLXFormattedSpinField::setProperty( PropertyName, Value );
5089 			}
5090 		}
5091 	}
5092 }
5093 
getProperty(const::rtl::OUString & PropertyName)5094 ::com::sun::star::uno::Any VCLXTimeField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
5095 {
5096 	::vos::OGuard aGuard( GetMutex() );
5097 
5098 	::com::sun::star::uno::Any aProp;
5099 	if ( GetWindow() )
5100 	{
5101 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
5102 		switch ( nPropType )
5103 		{
5104 			case BASEPROPERTY_TIME:
5105 			{
5106 				aProp <<= (sal_Int32) getTime();
5107 			}
5108 			break;
5109 			case BASEPROPERTY_TIMEMIN:
5110 			{
5111 				aProp <<= (sal_Int32) getMin();
5112 			}
5113 			break;
5114 			case BASEPROPERTY_TIMEMAX:
5115 			{
5116 				aProp <<= (sal_Int32) getMax();
5117 			}
5118 			break;
5119             case BASEPROPERTY_ENFORCE_FORMAT:
5120             {
5121                 aProp <<= (sal_Bool)static_cast< TimeField* >( GetWindow() )->IsEnforceValidValue( );
5122             }
5123             break;
5124 			default:
5125 			{
5126 				aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
5127 			}
5128 		}
5129 	}
5130 	return aProp;
5131 }
5132 
5133 //	----------------------------------------------------
5134 //	class VCLXNumericField
5135 //	----------------------------------------------------
5136 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)5137 void VCLXNumericField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
5138 {
5139     PushPropertyIds( rIds,
5140                      BASEPROPERTY_ALIGN,
5141                      BASEPROPERTY_BACKGROUNDCOLOR,
5142                      BASEPROPERTY_BORDER,
5143                      BASEPROPERTY_BORDERCOLOR,
5144                      BASEPROPERTY_DECIMALACCURACY,
5145                      BASEPROPERTY_DEFAULTCONTROL,
5146                      BASEPROPERTY_ENABLED,
5147                      BASEPROPERTY_ENABLEVISIBLE,
5148                      BASEPROPERTY_FONTDESCRIPTOR,
5149                      BASEPROPERTY_HELPTEXT,
5150                      BASEPROPERTY_HELPURL,
5151                      BASEPROPERTY_NUMSHOWTHOUSANDSEP,
5152                      BASEPROPERTY_PRINTABLE,
5153                      BASEPROPERTY_READONLY,
5154                      BASEPROPERTY_REPEAT,
5155                      BASEPROPERTY_REPEAT_DELAY,
5156                      BASEPROPERTY_SPIN,
5157                      BASEPROPERTY_STRICTFORMAT,
5158                      BASEPROPERTY_TABSTOP,
5159                      BASEPROPERTY_VALUEMAX_DOUBLE,
5160                      BASEPROPERTY_VALUEMIN_DOUBLE,
5161                      BASEPROPERTY_VALUESTEP_DOUBLE,
5162                      BASEPROPERTY_VALUE_DOUBLE,
5163                      BASEPROPERTY_ENFORCE_FORMAT,
5164                      BASEPROPERTY_HIDEINACTIVESELECTION,
5165                      BASEPROPERTY_VERTICALALIGN,
5166                      BASEPROPERTY_WRITING_MODE,
5167                      BASEPROPERTY_CONTEXT_WRITING_MODE,
5168                      BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
5169                      0);
5170     VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5171 }
5172 
VCLXNumericField()5173 VCLXNumericField::VCLXNumericField()
5174 {
5175 }
5176 
~VCLXNumericField()5177 VCLXNumericField::~VCLXNumericField()
5178 {
5179 }
5180 
5181 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)5182 ::com::sun::star::uno::Any VCLXNumericField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
5183 {
5184 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
5185 										SAL_STATIC_CAST( ::com::sun::star::awt::XNumericField*, this ) );
5186 	return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
5187 }
5188 
5189 // ::com::sun::star::lang::XTypeProvider
5190 IMPL_XTYPEPROVIDER_START( VCLXNumericField )
5191 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XNumericField>* ) NULL ),
5192 	VCLXFormattedSpinField::getTypes()
5193 IMPL_XTYPEPROVIDER_END
5194 
5195 void VCLXNumericField::setValue( double Value ) throw(::com::sun::star::uno::RuntimeException)
5196 {
5197 	::vos::OGuard aGuard( GetMutex() );
5198 
5199 	NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5200 	if ( pNumericFormatter )
5201 	{
5202 		// z.B. 105, 2 Digits => 1,05
5203 		// ein float 1,05 muss also eine 105 einstellen...
5204 		pNumericFormatter->SetValue(
5205 			(long)ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() ) );
5206 
5207         // #107218# Call same listeners like VCL would do after user interaction
5208 	    Edit* pEdit = (Edit*)GetWindow();
5209 	    if ( pEdit )
5210         {
5211             SetSynthesizingVCLEvent( sal_True );
5212             pEdit->SetModifyFlag();
5213             pEdit->Modify();
5214             SetSynthesizingVCLEvent( sal_False );
5215         }
5216 	}
5217 }
5218 
getValue()5219 double VCLXNumericField::getValue() throw(::com::sun::star::uno::RuntimeException)
5220 {
5221 	::vos::OGuard aGuard( GetMutex() );
5222 
5223 	NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5224 	return pNumericFormatter
5225 		? ImplCalcDoubleValue( (double)pNumericFormatter->GetValue(), pNumericFormatter->GetDecimalDigits() )
5226 		: 0;
5227 }
5228 
setMin(double Value)5229 void VCLXNumericField::setMin( double Value ) throw(::com::sun::star::uno::RuntimeException)
5230 {
5231 	::vos::OGuard aGuard( GetMutex() );
5232 
5233 	NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5234 	if ( pNumericFormatter )
5235 		pNumericFormatter->SetMin(
5236 			(long)ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() ) );
5237 }
5238 
getMin()5239 double VCLXNumericField::getMin() throw(::com::sun::star::uno::RuntimeException)
5240 {
5241 	::vos::OGuard aGuard( GetMutex() );
5242 
5243 	NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5244 	return pNumericFormatter
5245 		? ImplCalcDoubleValue( (double)pNumericFormatter->GetMin(), pNumericFormatter->GetDecimalDigits() )
5246 		: 0;
5247 }
5248 
setMax(double Value)5249 void VCLXNumericField::setMax( double Value ) throw(::com::sun::star::uno::RuntimeException)
5250 {
5251 	::vos::OGuard aGuard( GetMutex() );
5252 
5253 	NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5254 	if ( pNumericFormatter )
5255 		pNumericFormatter->SetMax(
5256 			(long)ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() ) );
5257 }
5258 
getMax()5259 double VCLXNumericField::getMax() throw(::com::sun::star::uno::RuntimeException)
5260 {
5261 	::vos::OGuard aGuard( GetMutex() );
5262 
5263 	NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5264 	return pNumericFormatter
5265 		? ImplCalcDoubleValue( (double)pNumericFormatter->GetMax(), pNumericFormatter->GetDecimalDigits() )
5266 		: 0;
5267 }
5268 
setFirst(double Value)5269 void VCLXNumericField::setFirst( double Value ) throw(::com::sun::star::uno::RuntimeException)
5270 {
5271 	::vos::OGuard aGuard( GetMutex() );
5272 
5273 	NumericField* pNumericField = (NumericField*) GetWindow();
5274 	if ( pNumericField )
5275 		pNumericField->SetFirst(
5276 			(long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) );
5277 }
5278 
getFirst()5279 double VCLXNumericField::getFirst() throw(::com::sun::star::uno::RuntimeException)
5280 {
5281 	::vos::OGuard aGuard( GetMutex() );
5282 
5283 	NumericField* pNumericField = (NumericField*) GetWindow();
5284 	return pNumericField
5285 		? ImplCalcDoubleValue( (double)pNumericField->GetFirst(), pNumericField->GetDecimalDigits() )
5286 		: 0;
5287 }
5288 
setLast(double Value)5289 void VCLXNumericField::setLast( double Value ) throw(::com::sun::star::uno::RuntimeException)
5290 {
5291 	::vos::OGuard aGuard( GetMutex() );
5292 
5293 	NumericField* pNumericField = (NumericField*) GetWindow();
5294 	if ( pNumericField )
5295 		pNumericField->SetLast(
5296 			(long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) );
5297 }
5298 
getLast()5299 double VCLXNumericField::getLast() throw(::com::sun::star::uno::RuntimeException)
5300 {
5301 	::vos::OGuard aGuard( GetMutex() );
5302 
5303 	NumericField* pNumericField = (NumericField*) GetWindow();
5304 	return pNumericField
5305 		? ImplCalcDoubleValue( (double)pNumericField->GetLast(), pNumericField->GetDecimalDigits() )
5306 		: 0;
5307 }
5308 
setStrictFormat(sal_Bool bStrict)5309 void VCLXNumericField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException)
5310 {
5311 	VCLXFormattedSpinField::setStrictFormat( bStrict );
5312 }
5313 
isStrictFormat()5314 sal_Bool VCLXNumericField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException)
5315 {
5316 	return VCLXFormattedSpinField::isStrictFormat();
5317 }
5318 
5319 
setSpinSize(double Value)5320 void VCLXNumericField::setSpinSize( double Value ) throw(::com::sun::star::uno::RuntimeException)
5321 {
5322 	::vos::OGuard aGuard( GetMutex() );
5323 
5324 	NumericField* pNumericField = (NumericField*) GetWindow();
5325 	if ( pNumericField )
5326 		pNumericField->SetSpinSize(
5327 			(long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) );
5328 }
5329 
getSpinSize()5330 double VCLXNumericField::getSpinSize() throw(::com::sun::star::uno::RuntimeException)
5331 {
5332 	::vos::OGuard aGuard( GetMutex() );
5333 
5334 	NumericField* pNumericField = (NumericField*) GetWindow();
5335 	return pNumericField
5336 		? ImplCalcDoubleValue( (double)pNumericField->GetSpinSize(), pNumericField->GetDecimalDigits() )
5337 		: 0;
5338 }
5339 
setDecimalDigits(sal_Int16 Value)5340 void VCLXNumericField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException)
5341 {
5342 	::vos::OGuard aGuard( GetMutex() );
5343 
5344 	NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5345 	if ( pNumericFormatter )
5346 	{
5347 		double n = getValue();
5348 		pNumericFormatter->SetDecimalDigits( Value );
5349 		setValue( n );
5350    	}
5351 }
5352 
getDecimalDigits()5353 sal_Int16 VCLXNumericField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException)
5354 {
5355 	::vos::OGuard aGuard( GetMutex() );
5356 
5357 	NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5358 	return pNumericFormatter ? pNumericFormatter->GetDecimalDigits() : 0;
5359 }
5360 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)5361 void VCLXNumericField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
5362 {
5363 	::vos::OGuard aGuard( GetMutex() );
5364 
5365 	if ( GetWindow() )
5366 	{
5367 		sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
5368 
5369 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
5370 		switch ( nPropType )
5371 		{
5372 			case BASEPROPERTY_VALUE_DOUBLE:
5373 			{
5374 				if ( bVoid )
5375 				{
5376 					((NumericField*)GetWindow())->EnableEmptyFieldValue( sal_True );
5377 					((NumericField*)GetWindow())->SetEmptyFieldValue();
5378 				}
5379 				else
5380 				{
5381 					double d = 0;
5382 					if ( Value >>= d )
5383  						setValue( d );
5384 				}
5385 			}
5386 			break;
5387 			case BASEPROPERTY_VALUEMIN_DOUBLE:
5388 			{
5389 				double d = 0;
5390 				if ( Value >>= d )
5391  					setMin( d );
5392 			}
5393 			break;
5394 			case BASEPROPERTY_VALUEMAX_DOUBLE:
5395 			{
5396 				double d = 0;
5397 				if ( Value >>= d )
5398  					setMax( d );
5399 			}
5400 			break;
5401 			case BASEPROPERTY_VALUESTEP_DOUBLE:
5402 			{
5403 				double d = 0;
5404 				if ( Value >>= d )
5405  					setSpinSize( d );
5406 			}
5407 			break;
5408 			case BASEPROPERTY_DECIMALACCURACY:
5409 			{
5410 				sal_Int16 n = sal_Int16();
5411 				if ( Value >>= n )
5412  					setDecimalDigits( n );
5413 			}
5414 			break;
5415 			case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5416 			{
5417 				sal_Bool b = sal_Bool();
5418 				if ( Value >>= b )
5419  					((NumericField*)GetWindow())->SetUseThousandSep( b );
5420 			}
5421 			break;
5422 			default:
5423 			{
5424 				VCLXFormattedSpinField::setProperty( PropertyName, Value );
5425 			}
5426 		}
5427 	}
5428 }
5429 
getProperty(const::rtl::OUString & PropertyName)5430 ::com::sun::star::uno::Any VCLXNumericField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
5431 {
5432 	::vos::OGuard aGuard( GetMutex() );
5433 
5434 	::com::sun::star::uno::Any aProp;
5435 	FormatterBase* pFormatter = GetFormatter();
5436 	if ( pFormatter )
5437 	{
5438 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
5439 		switch ( nPropType )
5440 		{
5441 			case BASEPROPERTY_VALUE_DOUBLE:
5442 			{
5443 				aProp <<= (double) getValue();
5444 			}
5445 			break;
5446 			case BASEPROPERTY_VALUEMIN_DOUBLE:
5447 			{
5448 				aProp <<= (double) getMin();
5449 			}
5450 			break;
5451 			case BASEPROPERTY_VALUEMAX_DOUBLE:
5452 			{
5453 				aProp <<= (double) getMax();
5454 			}
5455 			break;
5456 			case BASEPROPERTY_VALUESTEP_DOUBLE:
5457 			{
5458 				aProp <<= (double) getSpinSize();
5459 			}
5460 			break;
5461 			case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5462 			{
5463 			    aProp <<= (sal_Bool) ((NumericField*)GetWindow())->IsUseThousandSep();
5464 			}
5465 			break;
5466 			default:
5467 			{
5468 				aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
5469 			}
5470 		}
5471 	}
5472 	return aProp;
5473 }
5474 
5475 
5476 //    ----------------------------------------------------
5477 //    class VCLXMetricField
5478 //    ----------------------------------------------------
5479 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)5480 void VCLXMetricField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
5481 {
5482     PushPropertyIds( rIds,
5483                      BASEPROPERTY_ALIGN,
5484                      BASEPROPERTY_BACKGROUNDCOLOR,
5485                      BASEPROPERTY_BORDER,
5486                      BASEPROPERTY_BORDERCOLOR,
5487                      BASEPROPERTY_DECIMALACCURACY,
5488                      BASEPROPERTY_DEFAULTCONTROL,
5489                      BASEPROPERTY_ENABLED,
5490                      BASEPROPERTY_ENABLEVISIBLE,
5491                      BASEPROPERTY_FONTDESCRIPTOR,
5492                      BASEPROPERTY_HELPTEXT,
5493                      BASEPROPERTY_HELPURL,
5494                      BASEPROPERTY_NUMSHOWTHOUSANDSEP,
5495                      BASEPROPERTY_PRINTABLE,
5496                      BASEPROPERTY_READONLY,
5497                      BASEPROPERTY_REPEAT,
5498                      BASEPROPERTY_REPEAT_DELAY,
5499                      BASEPROPERTY_SPIN,
5500                      BASEPROPERTY_STRICTFORMAT,
5501                      BASEPROPERTY_TABSTOP,
5502                      BASEPROPERTY_ENFORCE_FORMAT,
5503                      BASEPROPERTY_HIDEINACTIVESELECTION,
5504                      BASEPROPERTY_UNIT,
5505                      BASEPROPERTY_CUSTOMUNITTEXT,
5506                      BASEPROPERTY_WRITING_MODE,
5507                      BASEPROPERTY_CONTEXT_WRITING_MODE,
5508                      BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
5509                      0);
5510     VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5511 }
5512 
VCLXMetricField()5513 VCLXMetricField::VCLXMetricField()
5514 {
5515 }
5516 
~VCLXMetricField()5517 VCLXMetricField::~VCLXMetricField()
5518 {
5519 }
5520 
GetMetricFormatter()5521 MetricFormatter *VCLXMetricField::GetMetricFormatter() throw(::com::sun::star::uno::RuntimeException)
5522 {
5523     MetricFormatter *pFormatter = (MetricFormatter *) GetFormatter();
5524     if (!pFormatter)
5525         throw ::com::sun::star::uno::RuntimeException();
5526     return pFormatter;
5527 }
5528 
GetMetricField()5529 MetricField *VCLXMetricField::GetMetricField() throw(::com::sun::star::uno::RuntimeException)
5530 {
5531     MetricField *pField = (MetricField *) GetWindow();
5532     if (!pField)
5533         throw ::com::sun::star::uno::RuntimeException();
5534     return pField;
5535 }
5536 
5537 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)5538 ::com::sun::star::uno::Any VCLXMetricField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
5539 {
5540     ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
5541                                                               SAL_STATIC_CAST( ::com::sun::star::awt::XMetricField*, this ) );
5542     return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
5543 }
5544 
5545 // ::com::sun::star::lang::XTypeProvider
5546 IMPL_XTYPEPROVIDER_START( VCLXMetricField )
5547     getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMetricField>* ) NULL ),
5548     VCLXFormattedSpinField::getTypes()
5549 IMPL_XTYPEPROVIDER_END
5550 
5551 // FIXME: later ...
5552 #define MetricUnitUnoToVcl(a) ((FieldUnit)(a))
5553 
5554 #define METRIC_MAP_PAIR(method,parent) \
5555     sal_Int64 VCLXMetricField::get##method( sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException) \
5556     { \
5557         ::vos::OGuard aGuard( GetMutex() ); \
5558         return GetMetric##parent()->Get##method( MetricUnitUnoToVcl( nUnit ) ); \
5559     } \
5560     void VCLXMetricField::set##method( sal_Int64 nValue, sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException) \
5561     { \
5562         ::vos::OGuard aGuard( GetMutex() ); \
5563         GetMetric##parent()->Set##method( nValue, MetricUnitUnoToVcl( nUnit ) ); \
5564     }
5565 
5566 METRIC_MAP_PAIR(Min, Formatter)
5567 METRIC_MAP_PAIR(Max, Formatter)
5568 METRIC_MAP_PAIR(First, Field)
5569 METRIC_MAP_PAIR(Last,  Field)
5570 
5571 #undef METRIC_MAP_PAIR
5572 
5573 ::sal_Int64 VCLXMetricField::getValue( ::sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException)
5574 {
5575     ::vos::OGuard aGuard( GetMutex() );
5576     return GetMetricFormatter()->GetValue( MetricUnitUnoToVcl( nUnit ) );
5577 }
5578 
getCorrectedValue(::sal_Int16 nUnit)5579 ::sal_Int64 VCLXMetricField::getCorrectedValue( ::sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException)
5580 {
5581     ::vos::OGuard aGuard( GetMutex() );
5582     return GetMetricFormatter()->GetCorrectedValue( MetricUnitUnoToVcl( nUnit ) );
5583 }
5584 
5585 // FIXME: acute cut/paste evilness - move this to the parent Edit class ?
CallListeners()5586 void VCLXMetricField::CallListeners()
5587 {
5588     // #107218# Call same listeners like VCL would do after user interaction
5589     Edit* pEdit = (Edit*)GetWindow();
5590     if ( pEdit )
5591     {
5592         SetSynthesizingVCLEvent( sal_True );
5593         pEdit->SetModifyFlag();
5594         pEdit->Modify();
5595         SetSynthesizingVCLEvent( sal_False );
5596     }
5597 }
5598 
setValue(::sal_Int64 Value,::sal_Int16 Unit)5599 void VCLXMetricField::setValue( ::sal_Int64 Value, ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException)
5600 {
5601     ::vos::OGuard aGuard( GetMutex() );
5602     GetMetricFormatter()->SetValue( Value, MetricUnitUnoToVcl( Unit ) );
5603     CallListeners();
5604 }
5605 
setUserValue(::sal_Int64 Value,::sal_Int16 Unit)5606 void VCLXMetricField::setUserValue( ::sal_Int64 Value, ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException)
5607 {
5608     ::vos::OGuard aGuard( GetMutex() );
5609     GetMetricFormatter()->SetUserValue( Value, MetricUnitUnoToVcl( Unit ) );
5610     CallListeners();
5611 }
5612 
setStrictFormat(sal_Bool bStrict)5613 void VCLXMetricField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException)
5614 {
5615     VCLXFormattedSpinField::setStrictFormat( bStrict );
5616 }
5617 
isStrictFormat()5618 sal_Bool VCLXMetricField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException)
5619 {
5620     return VCLXFormattedSpinField::isStrictFormat();
5621 }
5622 
setSpinSize(sal_Int64 Value)5623 void VCLXMetricField::setSpinSize( sal_Int64 Value ) throw(::com::sun::star::uno::RuntimeException)
5624 {
5625     ::vos::OGuard aGuard( GetMutex() );
5626     GetMetricField()->SetSpinSize( Value );
5627 }
5628 
getSpinSize()5629 sal_Int64 VCLXMetricField::getSpinSize() throw(::com::sun::star::uno::RuntimeException)
5630 {
5631     ::vos::OGuard aGuard( GetMutex() );
5632     return GetMetricField()->GetSpinSize();
5633 }
5634 
setDecimalDigits(sal_Int16 Value)5635 void VCLXMetricField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException)
5636 {
5637     ::vos::OGuard aGuard( GetMutex() );
5638     GetMetricFormatter()->SetDecimalDigits( Value );
5639 }
5640 
getDecimalDigits()5641 sal_Int16 VCLXMetricField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException)
5642 {
5643     ::vos::OGuard aGuard( GetMutex() );
5644 
5645     NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5646     return pNumericFormatter ? pNumericFormatter->GetDecimalDigits() : 0;
5647 }
5648 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)5649 void VCLXMetricField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
5650 {
5651     ::vos::OGuard aGuard( GetMutex() );
5652 
5653     if ( GetWindow() )
5654     {
5655         sal_uInt16 nPropType = GetPropertyId( PropertyName );
5656         switch ( nPropType )
5657         {
5658             case BASEPROPERTY_DECIMALACCURACY:
5659             {
5660                 sal_Int16 n = 0;
5661                 if ( Value >>= n )
5662                      setDecimalDigits( n );
5663                 break;
5664             }
5665             case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5666             {
5667                 sal_Bool b = sal_False;
5668                 if ( Value >>= b )
5669                      ((NumericField*)GetWindow())->SetUseThousandSep( b );
5670             }
5671             break;
5672             case BASEPROPERTY_UNIT:
5673             {
5674                 sal_uInt16 nVal = 0;
5675                 if ( Value >>= nVal )
5676                     ((MetricField*)GetWindow())->SetUnit( (FieldUnit) nVal );
5677                 break;
5678             }
5679             case BASEPROPERTY_CUSTOMUNITTEXT:
5680             {
5681                 rtl::OUString aStr;
5682                 if ( Value >>= aStr )
5683                     ((MetricField*)GetWindow())->SetCustomUnitText( aStr );
5684                 break;
5685             }
5686             default:
5687             {
5688                 VCLXFormattedSpinField::setProperty( PropertyName, Value );
5689                 break;
5690             }
5691         }
5692     }
5693 }
5694 
getProperty(const::rtl::OUString & PropertyName)5695 ::com::sun::star::uno::Any VCLXMetricField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
5696 {
5697     ::vos::OGuard aGuard( GetMutex() );
5698 
5699     ::com::sun::star::uno::Any aProp;
5700     FormatterBase* pFormatter = GetFormatter();
5701     if ( pFormatter )
5702     {
5703         sal_uInt16 nPropType = GetPropertyId( PropertyName );
5704         switch ( nPropType )
5705         {
5706             case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5707                 aProp <<= (sal_Bool) ((NumericField*)GetWindow())->IsUseThousandSep();
5708                 break;
5709             case BASEPROPERTY_UNIT:
5710                 aProp <<= (sal_uInt16) ((MetricField*)GetWindow())->GetUnit();
5711                 break;
5712             case BASEPROPERTY_CUSTOMUNITTEXT:
5713                 aProp <<= rtl::OUString (((MetricField*)GetWindow())->GetCustomUnitText());
5714                 break;
5715             default:
5716             {
5717                 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
5718                 break;
5719             }
5720         }
5721     }
5722     return aProp;
5723 }
5724 
5725 
5726 //	----------------------------------------------------
5727 //	class VCLXCurrencyField
5728 //	----------------------------------------------------
5729 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)5730 void VCLXCurrencyField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
5731 {
5732     PushPropertyIds( rIds,
5733                      BASEPROPERTY_ALIGN,
5734                      BASEPROPERTY_BACKGROUNDCOLOR,
5735                      BASEPROPERTY_BORDER,
5736                      BASEPROPERTY_BORDERCOLOR,
5737                      BASEPROPERTY_CURRENCYSYMBOL,
5738                      BASEPROPERTY_CURSYM_POSITION,
5739                      BASEPROPERTY_DECIMALACCURACY,
5740                      BASEPROPERTY_DEFAULTCONTROL,
5741                      BASEPROPERTY_ENABLED,
5742                      BASEPROPERTY_ENABLEVISIBLE,
5743                      BASEPROPERTY_FONTDESCRIPTOR,
5744                      BASEPROPERTY_HELPTEXT,
5745                      BASEPROPERTY_HELPURL,
5746                      BASEPROPERTY_NUMSHOWTHOUSANDSEP,
5747                      BASEPROPERTY_PRINTABLE,
5748                      BASEPROPERTY_READONLY,
5749                      BASEPROPERTY_REPEAT,
5750                      BASEPROPERTY_REPEAT_DELAY,
5751                      BASEPROPERTY_SPIN,
5752                      BASEPROPERTY_STRICTFORMAT,
5753                      BASEPROPERTY_TABSTOP,
5754                      BASEPROPERTY_VALUEMAX_DOUBLE,
5755                      BASEPROPERTY_VALUEMIN_DOUBLE,
5756                      BASEPROPERTY_VALUESTEP_DOUBLE,
5757                      BASEPROPERTY_VALUE_DOUBLE,
5758                      BASEPROPERTY_ENFORCE_FORMAT,
5759                      BASEPROPERTY_HIDEINACTIVESELECTION,
5760                      BASEPROPERTY_VERTICALALIGN,
5761                      BASEPROPERTY_WRITING_MODE,
5762                      BASEPROPERTY_CONTEXT_WRITING_MODE,
5763                      BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
5764                      0);
5765     VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5766 }
5767 
VCLXCurrencyField()5768 VCLXCurrencyField::VCLXCurrencyField()
5769 {
5770 }
5771 
~VCLXCurrencyField()5772 VCLXCurrencyField::~VCLXCurrencyField()
5773 {
5774 }
5775 
5776 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)5777 ::com::sun::star::uno::Any VCLXCurrencyField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
5778 {
5779 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
5780 										SAL_STATIC_CAST( ::com::sun::star::awt::XCurrencyField*, this ) );
5781 	return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
5782 }
5783 
5784 // ::com::sun::star::lang::XTypeProvider
5785 IMPL_XTYPEPROVIDER_START( VCLXCurrencyField )
5786 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XCurrencyField>* ) NULL ),
5787 	VCLXFormattedSpinField::getTypes()
5788 IMPL_XTYPEPROVIDER_END
5789 
5790 void VCLXCurrencyField::setValue( double Value ) throw(::com::sun::star::uno::RuntimeException)
5791 {
5792 	::vos::OGuard aGuard( GetMutex() );
5793 
5794 	LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter();
5795 	if ( pCurrencyFormatter )
5796 	{
5797 		// z.B. 105, 2 Digits => 1,05
5798 		// ein float 1,05 muss also eine 105 einstellen...
5799 		pCurrencyFormatter->SetValue(
5800 			ImplCalcLongValue( Value, pCurrencyFormatter->GetDecimalDigits() ) );
5801 
5802         // #107218# Call same listeners like VCL would do after user interaction
5803 	    Edit* pEdit = (Edit*)GetWindow();
5804 	    if ( pEdit )
5805         {
5806             SetSynthesizingVCLEvent( sal_True );
5807             pEdit->SetModifyFlag();
5808             pEdit->Modify();
5809             SetSynthesizingVCLEvent( sal_False );
5810         }
5811 	}
5812 }
5813 
getValue()5814 double VCLXCurrencyField::getValue() throw(::com::sun::star::uno::RuntimeException)
5815 {
5816 	::vos::OGuard aGuard( GetMutex() );
5817 
5818 	LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter();
5819 	return pCurrencyFormatter
5820 		? ImplCalcDoubleValue( (double)pCurrencyFormatter->GetValue(), pCurrencyFormatter->GetDecimalDigits() )
5821 		: 0;
5822 }
5823 
setMin(double Value)5824 void VCLXCurrencyField::setMin( double Value ) throw(::com::sun::star::uno::RuntimeException)
5825 {
5826 	::vos::OGuard aGuard( GetMutex() );
5827 
5828 	LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter();
5829 	if ( pCurrencyFormatter )
5830 		pCurrencyFormatter->SetMin(
5831 			ImplCalcLongValue( Value, pCurrencyFormatter->GetDecimalDigits() ) );
5832 }
5833 
getMin()5834 double VCLXCurrencyField::getMin() throw(::com::sun::star::uno::RuntimeException)
5835 {
5836 	::vos::OGuard aGuard( GetMutex() );
5837 
5838 	LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter();
5839 	return pCurrencyFormatter
5840 		? ImplCalcDoubleValue( (double)pCurrencyFormatter->GetMin(), pCurrencyFormatter->GetDecimalDigits() )
5841 		: 0;
5842 }
5843 
setMax(double Value)5844 void VCLXCurrencyField::setMax( double Value ) throw(::com::sun::star::uno::RuntimeException)
5845 {
5846 	::vos::OGuard aGuard( GetMutex() );
5847 
5848 	LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter();
5849 	if ( pCurrencyFormatter )
5850 		pCurrencyFormatter->SetMax(
5851 			ImplCalcLongValue( Value, pCurrencyFormatter->GetDecimalDigits() ) );
5852 }
5853 
getMax()5854 double VCLXCurrencyField::getMax() throw(::com::sun::star::uno::RuntimeException)
5855 {
5856 	::vos::OGuard aGuard( GetMutex() );
5857 
5858 	LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter();
5859 	return pCurrencyFormatter
5860 		? ImplCalcDoubleValue( (double)pCurrencyFormatter->GetMax(), pCurrencyFormatter->GetDecimalDigits() )
5861 		: 0;
5862 }
5863 
setFirst(double Value)5864 void VCLXCurrencyField::setFirst( double Value ) throw(::com::sun::star::uno::RuntimeException)
5865 {
5866 	::vos::OGuard aGuard( GetMutex() );
5867 
5868 	LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow();
5869 	if ( pCurrencyField )
5870 		pCurrencyField->SetFirst(
5871 			ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) );
5872 }
5873 
getFirst()5874 double VCLXCurrencyField::getFirst() throw(::com::sun::star::uno::RuntimeException)
5875 {
5876 	::vos::OGuard aGuard( GetMutex() );
5877 
5878 	LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow();
5879 	return pCurrencyField
5880 		? ImplCalcDoubleValue( (double)pCurrencyField->GetFirst(), pCurrencyField->GetDecimalDigits() )
5881 		: 0;
5882 }
5883 
setLast(double Value)5884 void VCLXCurrencyField::setLast( double Value ) throw(::com::sun::star::uno::RuntimeException)
5885 {
5886 	::vos::OGuard aGuard( GetMutex() );
5887 
5888 	LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow();
5889 	if ( pCurrencyField )
5890 		pCurrencyField->SetLast(
5891 			ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) );
5892 }
5893 
getLast()5894 double VCLXCurrencyField::getLast() throw(::com::sun::star::uno::RuntimeException)
5895 {
5896 	::vos::OGuard aGuard( GetMutex() );
5897 
5898 	LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow();
5899 	return pCurrencyField
5900 		? ImplCalcDoubleValue( (double)pCurrencyField->GetLast(), pCurrencyField->GetDecimalDigits() )
5901 		: 0;
5902 }
5903 
setSpinSize(double Value)5904 void VCLXCurrencyField::setSpinSize( double Value ) throw(::com::sun::star::uno::RuntimeException)
5905 {
5906 	::vos::OGuard aGuard( GetMutex() );
5907 
5908 	LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow();
5909 	if ( pCurrencyField )
5910 		pCurrencyField->SetSpinSize(
5911 			ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) );
5912 }
5913 
getSpinSize()5914 double VCLXCurrencyField::getSpinSize() throw(::com::sun::star::uno::RuntimeException)
5915 {
5916 	::vos::OGuard aGuard( GetMutex() );
5917 
5918 	LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow();
5919 	return pCurrencyField
5920 		? ImplCalcDoubleValue( (double)pCurrencyField->GetSpinSize(), pCurrencyField->GetDecimalDigits() )
5921 		: 0;
5922 }
5923 
setStrictFormat(sal_Bool bStrict)5924 void VCLXCurrencyField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException)
5925 {
5926 	VCLXFormattedSpinField::setStrictFormat( bStrict );
5927 }
5928 
isStrictFormat()5929 sal_Bool VCLXCurrencyField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException)
5930 {
5931 	return VCLXFormattedSpinField::isStrictFormat();
5932 }
5933 
5934 
setDecimalDigits(sal_Int16 Value)5935 void VCLXCurrencyField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException)
5936 {
5937 	::vos::OGuard aGuard( GetMutex() );
5938 
5939 	LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter();
5940 	if ( pCurrencyFormatter )
5941 	{
5942 		double n = getValue();
5943 		pCurrencyFormatter->SetDecimalDigits( Value );
5944 		setValue( n );
5945    	}
5946 }
5947 
getDecimalDigits()5948 sal_Int16 VCLXCurrencyField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException)
5949 {
5950 	::vos::OGuard aGuard( GetMutex() );
5951 
5952 	LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter();
5953 	return pCurrencyFormatter ? pCurrencyFormatter->GetDecimalDigits() : 0;
5954 }
5955 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)5956 void VCLXCurrencyField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
5957 {
5958 	::vos::OGuard aGuard( GetMutex() );
5959 
5960 	if ( GetWindow() )
5961 	{
5962 		sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
5963 
5964 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
5965 		switch ( nPropType )
5966 		{
5967 			case BASEPROPERTY_VALUE_DOUBLE:
5968 			{
5969 				if ( bVoid )
5970 				{
5971 					((LongCurrencyField*)GetWindow())->EnableEmptyFieldValue( sal_True );
5972 					((LongCurrencyField*)GetWindow())->SetEmptyFieldValue();
5973 				}
5974 				else
5975 				{
5976 					double d = 0;
5977 					if ( Value >>= d )
5978  						setValue( d );
5979 				}
5980 			}
5981 			break;
5982 			case BASEPROPERTY_VALUEMIN_DOUBLE:
5983 			{
5984 				double d = 0;
5985 				if ( Value >>= d )
5986  					setMin( d );
5987 			}
5988 			break;
5989 			case BASEPROPERTY_VALUEMAX_DOUBLE:
5990 			{
5991 				double d = 0;
5992 				if ( Value >>= d )
5993  					setMax( d );
5994 			}
5995 			break;
5996 			case BASEPROPERTY_VALUESTEP_DOUBLE:
5997 			{
5998 				double d = 0;
5999 				if ( Value >>= d )
6000  					setSpinSize( d );
6001 			}
6002 			break;
6003 			case BASEPROPERTY_DECIMALACCURACY:
6004 			{
6005 				sal_Int16 n = sal_Int16();
6006 				if ( Value >>= n )
6007  					setDecimalDigits( n );
6008 			}
6009 			break;
6010 			case BASEPROPERTY_CURRENCYSYMBOL:
6011 			{
6012 				::rtl::OUString aString;
6013 				if ( Value >>= aString )
6014  					((LongCurrencyField*)GetWindow())->SetCurrencySymbol( aString );
6015 			}
6016 			break;
6017 			case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
6018 			{
6019 				sal_Bool b = sal_Bool();
6020 				if ( Value >>= b )
6021  					((LongCurrencyField*)GetWindow())->SetUseThousandSep( b );
6022 			}
6023 			break;
6024 			default:
6025 			{
6026 				VCLXFormattedSpinField::setProperty( PropertyName, Value );
6027 			}
6028 		}
6029 	}
6030 }
6031 
getProperty(const::rtl::OUString & PropertyName)6032 ::com::sun::star::uno::Any VCLXCurrencyField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
6033 {
6034 	::vos::OGuard aGuard( GetMutex() );
6035 
6036 	::com::sun::star::uno::Any aProp;
6037 	FormatterBase* pFormatter = GetFormatter();
6038 	if ( pFormatter )
6039 	{
6040 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
6041 		switch ( nPropType )
6042 		{
6043 			case BASEPROPERTY_VALUE_DOUBLE:
6044 			{
6045 				aProp <<= (double) getValue();
6046 			}
6047 			break;
6048 			case BASEPROPERTY_VALUEMIN_DOUBLE:
6049 			{
6050 				aProp <<= (double) getMin();
6051 			}
6052 			break;
6053 			case BASEPROPERTY_VALUEMAX_DOUBLE:
6054 			{
6055 				aProp <<= (double) getMax();
6056 			}
6057 			break;
6058 			case BASEPROPERTY_VALUESTEP_DOUBLE:
6059 			{
6060 				aProp <<= (double) getSpinSize();
6061 			}
6062 			break;
6063 			case BASEPROPERTY_CURRENCYSYMBOL:
6064 			{
6065 			    aProp <<= ::rtl::OUString( ((LongCurrencyField*)GetWindow())->GetCurrencySymbol() );
6066 			}
6067 			break;
6068 			case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
6069 			{
6070 			    aProp <<= (sal_Bool) ((LongCurrencyField*)GetWindow())->IsUseThousandSep();
6071 			}
6072 			break;
6073 			default:
6074 			{
6075 				aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
6076 			}
6077 		}
6078 	}
6079 	return aProp;
6080 }
6081 
6082 //	----------------------------------------------------
6083 //	class VCLXPatternField
6084 //	----------------------------------------------------
6085 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)6086 void VCLXPatternField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
6087 {
6088     PushPropertyIds( rIds,
6089                      BASEPROPERTY_ALIGN,
6090                      BASEPROPERTY_BACKGROUNDCOLOR,
6091                      BASEPROPERTY_BORDER,
6092                      BASEPROPERTY_BORDERCOLOR,
6093                      BASEPROPERTY_DEFAULTCONTROL,
6094                      BASEPROPERTY_EDITMASK,
6095                      BASEPROPERTY_ENABLED,
6096                      BASEPROPERTY_ENABLEVISIBLE,
6097                      BASEPROPERTY_FONTDESCRIPTOR,
6098                      BASEPROPERTY_HELPTEXT,
6099                      BASEPROPERTY_HELPURL,
6100                      BASEPROPERTY_LITERALMASK,
6101                      BASEPROPERTY_MAXTEXTLEN,
6102                      BASEPROPERTY_PRINTABLE,
6103                      BASEPROPERTY_READONLY,
6104                      BASEPROPERTY_STRICTFORMAT,
6105                      BASEPROPERTY_TABSTOP,
6106                      BASEPROPERTY_TEXT,
6107                      BASEPROPERTY_HIDEINACTIVESELECTION,
6108                      BASEPROPERTY_VERTICALALIGN,
6109                      BASEPROPERTY_WRITING_MODE,
6110                      BASEPROPERTY_CONTEXT_WRITING_MODE,
6111                      BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
6112                      0);
6113     VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
6114 }
6115 
VCLXPatternField()6116 VCLXPatternField::VCLXPatternField()
6117 {
6118 }
6119 
~VCLXPatternField()6120 VCLXPatternField::~VCLXPatternField()
6121 {
6122 }
6123 
6124 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)6125 ::com::sun::star::uno::Any VCLXPatternField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
6126 {
6127 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
6128 										SAL_STATIC_CAST( ::com::sun::star::awt::XPatternField*, this ) );
6129 	return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
6130 }
6131 
6132 // ::com::sun::star::lang::XTypeProvider
6133 IMPL_XTYPEPROVIDER_START( VCLXPatternField )
6134 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPatternField>* ) NULL ),
6135 	VCLXFormattedSpinField::getTypes()
6136 IMPL_XTYPEPROVIDER_END
6137 
6138 void VCLXPatternField::setMasks( const ::rtl::OUString& EditMask, const ::rtl::OUString& LiteralMask ) throw(::com::sun::star::uno::RuntimeException)
6139 {
6140 	::vos::OGuard aGuard( GetMutex() );
6141 
6142 	PatternField* pPatternField = (PatternField*) GetWindow();
6143 	if ( pPatternField )
6144 	{
6145 		pPatternField->SetMask(	ByteString( UniString( EditMask ), RTL_TEXTENCODING_ASCII_US ), LiteralMask );
6146 	}
6147 }
6148 
getMasks(::rtl::OUString & EditMask,::rtl::OUString & LiteralMask)6149 void VCLXPatternField::getMasks( ::rtl::OUString& EditMask, ::rtl::OUString& LiteralMask ) throw(::com::sun::star::uno::RuntimeException)
6150 {
6151 	::vos::OGuard aGuard( GetMutex() );
6152 
6153 	PatternField* pPatternField = (PatternField*) GetWindow();
6154 	if ( pPatternField )
6155 	{
6156 		EditMask = String( pPatternField->GetEditMask(), RTL_TEXTENCODING_ASCII_US );
6157 		LiteralMask = pPatternField->GetLiteralMask();
6158 	}
6159 }
6160 
setString(const::rtl::OUString & Str)6161 void VCLXPatternField::setString( const ::rtl::OUString& Str ) throw(::com::sun::star::uno::RuntimeException)
6162 {
6163 	::vos::OGuard aGuard( GetMutex() );
6164 
6165 	PatternField* pPatternField = (PatternField*) GetWindow();
6166 	if ( pPatternField )
6167 	{
6168 		pPatternField->SetString( Str );
6169 	}
6170 }
6171 
getString()6172 ::rtl::OUString VCLXPatternField::getString() throw(::com::sun::star::uno::RuntimeException)
6173 {
6174 	::vos::OGuard aGuard( GetMutex() );
6175 
6176 	::rtl::OUString aString;
6177 	PatternField* pPatternField = (PatternField*) GetWindow();
6178 	if ( pPatternField )
6179 		aString = pPatternField->GetString();
6180 	return aString;
6181 }
6182 
setStrictFormat(sal_Bool bStrict)6183 void VCLXPatternField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException)
6184 {
6185 	VCLXFormattedSpinField::setStrictFormat( bStrict );
6186 }
6187 
isStrictFormat()6188 sal_Bool VCLXPatternField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException)
6189 {
6190 	return VCLXFormattedSpinField::isStrictFormat();
6191 }
6192 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)6193 void VCLXPatternField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
6194 {
6195 	::vos::OGuard aGuard( GetMutex() );
6196 
6197 	if ( GetWindow() )
6198 	{
6199 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
6200 		switch ( nPropType )
6201 		{
6202 			case BASEPROPERTY_EDITMASK:
6203 			case BASEPROPERTY_LITERALMASK:
6204 			{
6205 				::rtl::OUString aString;
6206 				if ( Value >>= aString )
6207 				{
6208 					::rtl::OUString aEditMask, aLiteralMask;
6209 					getMasks( aEditMask, aLiteralMask );
6210 					if ( nPropType == BASEPROPERTY_EDITMASK )
6211 						aEditMask = aString;
6212 					else
6213 						aLiteralMask = aString;
6214  					setMasks( aEditMask, aLiteralMask );
6215 				}
6216 			}
6217 			break;
6218 			default:
6219 			{
6220 				VCLXFormattedSpinField::setProperty( PropertyName, Value );
6221 			}
6222 		}
6223 	}
6224 }
6225 
getProperty(const::rtl::OUString & PropertyName)6226 ::com::sun::star::uno::Any VCLXPatternField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
6227 {
6228 	::vos::OGuard aGuard( GetMutex() );
6229 
6230 	::com::sun::star::uno::Any aProp;
6231 	if ( GetWindow() )
6232 	{
6233 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
6234 		switch ( nPropType )
6235 		{
6236 			case BASEPROPERTY_EDITMASK:
6237 			case BASEPROPERTY_LITERALMASK:
6238 			{
6239 				::rtl::OUString aEditMask, aLiteralMask;
6240 				getMasks( aEditMask, aLiteralMask );
6241 				if ( nPropType == BASEPROPERTY_EDITMASK )
6242 					aProp <<= aEditMask;
6243 				else
6244 					aProp <<= aLiteralMask;
6245 			}
6246 			break;
6247 			default:
6248 			{
6249 				aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
6250 			}
6251 		}
6252 	}
6253 	return aProp;
6254 }
6255 
6256 //	----------------------------------------------------
6257 //	class VCLXToolBox
6258 //	----------------------------------------------------
VCLXToolBox()6259 VCLXToolBox::VCLXToolBox()
6260 {
6261 }
6262 
~VCLXToolBox()6263 VCLXToolBox::~VCLXToolBox()
6264 {
6265 }
6266 
CreateAccessibleContext()6267 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXToolBox::CreateAccessibleContext()
6268 {
6269     return getAccessibleFactory().createAccessibleContext( this );
6270 }
6271 
6272