xref: /aoo41x/main/toolkit/source/awt/vclxwindows.cxx (revision 4d7c9de0)
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 			}
4078 			break;
4079 			case BASEPROPERTY_STRINGITEMLIST:
4080 			{
4081                 ::com::sun::star::uno::Sequence< ::rtl::OUString> aItems;
4082 				if ( Value >>= aItems )
4083 				{
4084 					pComboBox->Clear();
4085 					addItems( aItems, 0 );
4086 				}
4087 			}
4088 			break;
4089 			default:
4090 			{
4091 				VCLXEdit::setProperty( PropertyName, Value );
4092 
4093 				// #109385# SetBorderStyle is not virtual
4094 				if ( nPropType == BASEPROPERTY_BORDER )
4095 				{
4096 					sal_uInt16 nBorder = sal_uInt16();
4097 					if ( (Value >>= nBorder) && nBorder != 0 )
4098 						pComboBox->SetBorderStyle( nBorder );
4099 				}
4100 			}
4101 		}
4102 	}
4103 }
4104 
getProperty(const::rtl::OUString & PropertyName)4105 ::com::sun::star::uno::Any VCLXComboBox::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
4106 {
4107 	::vos::OGuard aGuard( GetMutex() );
4108 
4109 	::com::sun::star::uno::Any aProp;
4110 	ComboBox* pComboBox = (ComboBox*)GetWindow();
4111 	if ( pComboBox )
4112 	{
4113 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
4114 		switch ( nPropType )
4115 		{
4116 			case BASEPROPERTY_LINECOUNT:
4117 			{
4118  				aProp <<= (sal_Int16)  pComboBox->GetDropDownLineCount();
4119 			}
4120 			break;
4121 			case BASEPROPERTY_AUTOCOMPLETE:
4122 			{
4123  				aProp <<= (sal_Bool) pComboBox->IsAutocompleteEnabled();
4124 			}
4125 			break;
4126 			case BASEPROPERTY_STRINGITEMLIST:
4127 			{
4128 				sal_uInt16 nItems = pComboBox->GetEntryCount();
4129 				::com::sun::star::uno::Sequence< ::rtl::OUString> aSeq( nItems );
4130 				::rtl::OUString* pStrings = aSeq.getArray();
4131 				for ( sal_uInt16 n = 0; n < nItems; n++ )
4132 					pStrings[n] = pComboBox->GetEntry( n );
4133 				aProp <<= aSeq;
4134 
4135 			}
4136 			break;
4137 			default:
4138 			{
4139 				aProp <<= VCLXEdit::getProperty( PropertyName );
4140 			}
4141 		}
4142 	}
4143 	return aProp;
4144 }
4145 
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)4146 void VCLXComboBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
4147 {
4148     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
4149         // since we call listeners below, there is a potential that we will be destroyed
4150         // during the listener call. To prevent the resulting crashs, we keep us
4151         // alive as long as we're here
4152         // #20178# - 2003-10-01 - fs@openoffice.org
4153 
4154 	switch ( rVclWindowEvent.GetId() )
4155 	{
4156 		case VCLEVENT_COMBOBOX_SELECT:
4157 			if ( maItemListeners.getLength() )
4158 			{
4159 				ComboBox* pComboBox = (ComboBox*)GetWindow();
4160                 if( pComboBox )
4161                 {
4162 				    if ( !pComboBox->IsTravelSelect() )
4163 				    {
4164 					    ::com::sun::star::awt::ItemEvent aEvent;
4165 					    aEvent.Source = (::cppu::OWeakObject*)this;
4166 					    aEvent.Highlighted = sal_False;
4167 
4168 					    // Bei Mehrfachselektion 0xFFFF, sonst die ID
4169 					    aEvent.Selected = pComboBox->GetEntryPos( pComboBox->GetText() );
4170 
4171 					    maItemListeners.itemStateChanged( aEvent );
4172 				    }
4173                 }
4174 			}
4175 			break;
4176 
4177 		case VCLEVENT_COMBOBOX_DOUBLECLICK:
4178 			if ( maActionListeners.getLength() )
4179 			{
4180 				::com::sun::star::awt::ActionEvent aEvent;
4181 				aEvent.Source = (::cppu::OWeakObject*)this;
4182 //				aEvent.ActionCommand = ...;
4183 				maActionListeners.actionPerformed( aEvent );
4184 			}
4185 			break;
4186 
4187 		default:
4188 			VCLXEdit::ProcessWindowEvent( rVclWindowEvent );
4189 			break;
4190 	}
4191 }
4192 
getMinimumSize()4193 ::com::sun::star::awt::Size VCLXComboBox::getMinimumSize(  ) throw(::com::sun::star::uno::RuntimeException)
4194 {
4195 	::vos::OGuard aGuard( GetMutex() );
4196 
4197 	Size aSz;
4198 	ComboBox* pComboBox = (ComboBox*) GetWindow();
4199 	if ( pComboBox )
4200 		aSz = pComboBox->CalcMinimumSize();
4201 	return AWTSize(aSz);
4202 }
4203 
getPreferredSize()4204 ::com::sun::star::awt::Size VCLXComboBox::getPreferredSize(  ) throw(::com::sun::star::uno::RuntimeException)
4205 {
4206 	::vos::OGuard aGuard( GetMutex() );
4207 
4208 	Size aSz;
4209 	ComboBox* pComboBox = (ComboBox*) GetWindow();
4210 	if ( pComboBox )
4211 	{
4212 		aSz = pComboBox->CalcMinimumSize();
4213 		if ( pComboBox->GetStyle() & WB_DROPDOWN )
4214 			aSz.Height() += 4;
4215 	}
4216 	return AWTSize(aSz);
4217 }
4218 
calcAdjustedSize(const::com::sun::star::awt::Size & rNewSize)4219 ::com::sun::star::awt::Size VCLXComboBox::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException)
4220 {
4221 	::vos::OGuard aGuard( GetMutex() );
4222 
4223 	Size aSz = VCLSize(rNewSize);
4224 	ComboBox* pComboBox = (ComboBox*) GetWindow();
4225 	if ( pComboBox )
4226 		aSz = pComboBox->CalcAdjustedSize( aSz );
4227 	return AWTSize(aSz);
4228 }
4229 
getMinimumSize(sal_Int16 nCols,sal_Int16 nLines)4230 ::com::sun::star::awt::Size VCLXComboBox::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException)
4231 {
4232 	::vos::OGuard aGuard( GetMutex() );
4233 
4234 	Size aSz;
4235 	ComboBox* pComboBox = (ComboBox*) GetWindow();
4236 	if ( pComboBox )
4237 		aSz = pComboBox->CalcSize( nCols, nLines );
4238 	return AWTSize(aSz);
4239 }
4240 
getColumnsAndLines(sal_Int16 & nCols,sal_Int16 & nLines)4241 void VCLXComboBox::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException)
4242 {
4243 	::vos::OGuard aGuard( GetMutex() );
4244 
4245 	nCols = nLines = 0;
4246 	ComboBox* pComboBox = (ComboBox*) GetWindow();
4247 	if ( pComboBox )
4248 	{
4249 		sal_uInt16 nC, nL;
4250 		pComboBox->GetMaxVisColumnsAndLines( nC, nL );
4251 		nCols = nC;
4252 		nLines = nL;
4253 	}
4254 }
listItemInserted(const ItemListEvent & i_rEvent)4255 void SAL_CALL VCLXComboBox::listItemInserted( const ItemListEvent& i_rEvent ) throw (RuntimeException)
4256 {
4257 	::vos::OGuard aGuard( GetMutex() );
4258 
4259     ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() );
4260 
4261     ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemInserted: no ComboBox?!" );
4262     ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition <= sal_Int32( pComboBox->GetEntryCount() ) ),
4263         "VCLXComboBox::listItemInserted: illegal (inconsistent) item position!" );
4264     pComboBox->InsertEntry(
4265         i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : ::rtl::OUString(),
4266         i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : Image(),
4267         i_rEvent.ItemPosition );
4268 }
4269 
listItemRemoved(const ItemListEvent & i_rEvent)4270 void SAL_CALL VCLXComboBox::listItemRemoved( const ItemListEvent& i_rEvent ) throw (RuntimeException)
4271 {
4272 	::vos::OGuard aGuard( GetMutex() );
4273 
4274     ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() );
4275 
4276     ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemRemoved: no ComboBox?!" );
4277     ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pComboBox->GetEntryCount() ) ),
4278         "VCLXComboBox::listItemRemoved: illegal (inconsistent) item position!" );
4279 
4280     pComboBox->RemoveEntry( i_rEvent.ItemPosition );
4281 }
4282 
listItemModified(const ItemListEvent & i_rEvent)4283 void SAL_CALL VCLXComboBox::listItemModified( const ItemListEvent& i_rEvent ) throw (RuntimeException)
4284 {
4285 	::vos::OGuard aGuard( GetMutex() );
4286 
4287     ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() );
4288 
4289     ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" );
4290     ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pComboBox->GetEntryCount() ) ),
4291         "VCLXComboBox::listItemModified: illegal (inconsistent) item position!" );
4292 
4293     // VCL's ComboBox does not support changing an entry's text or image, so remove and re-insert
4294 
4295     const ::rtl::OUString sNewText = i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : ::rtl::OUString( pComboBox->GetEntry( i_rEvent.ItemPosition ) );
4296     const Image aNewImage( i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : pComboBox->GetEntryImage( i_rEvent.ItemPosition  ) );
4297 
4298     pComboBox->RemoveEntry( i_rEvent.ItemPosition );
4299     pComboBox->InsertEntry( sNewText, aNewImage, i_rEvent.ItemPosition );
4300 }
4301 
allItemsRemoved(const EventObject & i_rEvent)4302 void SAL_CALL VCLXComboBox::allItemsRemoved( const EventObject& i_rEvent ) throw (RuntimeException)
4303 {
4304 	::vos::OGuard aGuard( GetMutex() );
4305 
4306     ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() );
4307     ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" );
4308 
4309     pComboBox->Clear();
4310 
4311     (void)i_rEvent;
4312 }
4313 
itemListChanged(const EventObject & i_rEvent)4314 void SAL_CALL VCLXComboBox::itemListChanged( const EventObject& i_rEvent ) throw (RuntimeException)
4315 {
4316 	::vos::OGuard aGuard( GetMutex() );
4317 
4318     ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() );
4319     ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" );
4320 
4321     pComboBox->Clear();
4322 
4323     uno::Reference< beans::XPropertySet > xPropSet( i_rEvent.Source, uno::UNO_QUERY_THROW );
4324     uno::Reference< beans::XPropertySetInfo > xPSI( xPropSet->getPropertySetInfo(), uno::UNO_QUERY_THROW );
4325     // bool localize = xPSI->hasPropertyByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" ) ) );
4326     uno::Reference< resource::XStringResourceResolver > xStringResourceResolver;
4327     if ( xPSI->hasPropertyByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" ) ) ) )
4328     {
4329         xStringResourceResolver.set(
4330             xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" ) ) ),
4331             uno::UNO_QUERY
4332         );
4333     }
4334 
4335 
4336     Reference< XItemList > xItemList( i_rEvent.Source, uno::UNO_QUERY_THROW );
4337     uno::Sequence< beans::Pair< ::rtl::OUString, ::rtl::OUString > > aItems = xItemList->getAllItems();
4338     for ( sal_Int32 i=0; i<aItems.getLength(); ++i )
4339     {
4340         ::rtl::OUString aLocalizationKey( aItems[i].First );
4341         if ( xStringResourceResolver.is() && aLocalizationKey.getLength() != 0 && aLocalizationKey[0] == '&' )
4342         {
4343             aLocalizationKey = xStringResourceResolver->resolveString(aLocalizationKey.copy( 1 ));
4344         }
4345         pComboBox->InsertEntry( aLocalizationKey, lcl_getImageFromURL( aItems[i].Second ) );
4346     }
4347 }
disposing(const EventObject & i_rEvent)4348 void SAL_CALL VCLXComboBox::disposing( const EventObject& i_rEvent ) throw (RuntimeException)
4349 {
4350     // just disambiguate
4351     VCLXEdit::disposing( i_rEvent );
4352 }
4353 
4354 //	----------------------------------------------------
4355 //	class VCLXFormattedSpinField
4356 //	----------------------------------------------------
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)4357 void VCLXFormattedSpinField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
4358 {
4359     // Interestingly in the UnoControl API this is
4360     // - not derived from XEdit ultimately, (correct ?) - so cut this here ...
4361 //    VCLXSpinField::ImplGetPropertyIds( rIds );
4362     VCLXWindow::ImplGetPropertyIds( rIds );
4363 }
4364 
VCLXFormattedSpinField()4365 VCLXFormattedSpinField::VCLXFormattedSpinField()
4366 {
4367 }
4368 
~VCLXFormattedSpinField()4369 VCLXFormattedSpinField::~VCLXFormattedSpinField()
4370 {
4371 }
4372 
setStrictFormat(sal_Bool bStrict)4373 void VCLXFormattedSpinField::setStrictFormat( sal_Bool bStrict )
4374 {
4375 	::vos::OGuard aGuard( GetMutex() );
4376 
4377 	FormatterBase* pFormatter = GetFormatter();
4378 	if ( pFormatter )
4379 		pFormatter->SetStrictFormat( bStrict );
4380 }
4381 
isStrictFormat()4382 sal_Bool VCLXFormattedSpinField::isStrictFormat()
4383 {
4384 	FormatterBase* pFormatter = GetFormatter();
4385 	return pFormatter ? pFormatter->IsStrictFormat() : sal_False;
4386 }
4387 
4388 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)4389 void VCLXFormattedSpinField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
4390 {
4391 	::vos::OGuard aGuard( GetMutex() );
4392 
4393 	FormatterBase* pFormatter = GetFormatter();
4394 	if ( pFormatter )
4395 	{
4396 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
4397 		switch ( nPropType )
4398 		{
4399 			case BASEPROPERTY_SPIN:
4400 			{
4401 				sal_Bool b = sal_Bool();
4402 				if ( Value >>= b )
4403 				{
4404 					WinBits nStyle = GetWindow()->GetStyle() | WB_SPIN;
4405 					if ( !b )
4406 						nStyle &= ~WB_SPIN;
4407 					GetWindow()->SetStyle( nStyle );
4408 				}
4409 			}
4410 			break;
4411 			case BASEPROPERTY_STRICTFORMAT:
4412 			{
4413 				sal_Bool b = sal_Bool();
4414 				if ( Value >>= b )
4415 				{
4416 	 				pFormatter->SetStrictFormat( b );
4417 				}
4418 			}
4419 			break;
4420 			default:
4421 			{
4422 				VCLXSpinField::setProperty( PropertyName, Value );
4423 			}
4424 		}
4425 	}
4426 }
4427 
getProperty(const::rtl::OUString & PropertyName)4428 ::com::sun::star::uno::Any VCLXFormattedSpinField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
4429 {
4430 	::vos::OGuard aGuard( GetMutex() );
4431 
4432 	::com::sun::star::uno::Any aProp;
4433 	FormatterBase* pFormatter = GetFormatter();
4434 	if ( pFormatter )
4435 	{
4436 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
4437 		switch ( nPropType )
4438 		{
4439 			case BASEPROPERTY_TABSTOP:
4440 			{
4441                 aProp <<= (sal_Bool) ( ( GetWindow()->GetStyle() & WB_SPIN ) ? sal_True : sal_False );
4442 			}
4443 			break;
4444 			case BASEPROPERTY_STRICTFORMAT:
4445 			{
4446 				aProp <<= (sal_Bool) pFormatter->IsStrictFormat();
4447 			}
4448 			break;
4449 			default:
4450 			{
4451 				aProp <<= VCLXSpinField::getProperty( PropertyName );
4452 			}
4453 		}
4454 	}
4455 	return aProp;
4456 }
4457 
4458 
4459 //	----------------------------------------------------
4460 //	class VCLXDateField
4461 //	----------------------------------------------------
4462 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)4463 void VCLXDateField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
4464 {
4465     PushPropertyIds( rIds,
4466                      BASEPROPERTY_ALIGN,
4467                      BASEPROPERTY_BACKGROUNDCOLOR,
4468                      BASEPROPERTY_BORDER,
4469                      BASEPROPERTY_BORDERCOLOR,
4470                      BASEPROPERTY_DATE,
4471                      BASEPROPERTY_DATEMAX,
4472                      BASEPROPERTY_DATEMIN,
4473                      BASEPROPERTY_DATESHOWCENTURY,
4474                      BASEPROPERTY_DEFAULTCONTROL,
4475                      BASEPROPERTY_DROPDOWN,
4476                      BASEPROPERTY_ENABLED,
4477                      BASEPROPERTY_ENABLEVISIBLE,
4478                      BASEPROPERTY_EXTDATEFORMAT,
4479                      BASEPROPERTY_FONTDESCRIPTOR,
4480                      BASEPROPERTY_HELPTEXT,
4481                      BASEPROPERTY_HELPURL,
4482                      BASEPROPERTY_PRINTABLE,
4483                      BASEPROPERTY_READONLY,
4484                      BASEPROPERTY_REPEAT,
4485                      BASEPROPERTY_REPEAT_DELAY,
4486                      BASEPROPERTY_SPIN,
4487                      BASEPROPERTY_STRICTFORMAT,
4488                      BASEPROPERTY_TABSTOP,
4489                      BASEPROPERTY_ENFORCE_FORMAT,
4490                      BASEPROPERTY_TEXT,
4491                      BASEPROPERTY_HIDEINACTIVESELECTION,
4492                      BASEPROPERTY_VERTICALALIGN,
4493                      BASEPROPERTY_WRITING_MODE,
4494                      BASEPROPERTY_CONTEXT_WRITING_MODE,
4495                      BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
4496                      0);
4497     VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
4498 }
4499 
VCLXDateField()4500 VCLXDateField::VCLXDateField()
4501 {
4502 }
4503 
~VCLXDateField()4504 VCLXDateField::~VCLXDateField()
4505 {
4506 }
4507 
4508 //change the window type here to match the role
CreateAccessibleContext()4509 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXDateField::CreateAccessibleContext()
4510 {
4511 	Window* pWindow = GetWindow();
4512 	if ( pWindow )
4513 	{
4514 		pWindow->SetType( WINDOW_DATEFIELD );
4515 	}
4516 	return getAccessibleFactory().createAccessibleContext( this );
4517 }
4518 
4519 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)4520 ::com::sun::star::uno::Any VCLXDateField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
4521 {
4522 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
4523 										SAL_STATIC_CAST( ::com::sun::star::awt::XDateField*, this ) );
4524 	return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
4525 }
4526 
4527 // ::com::sun::star::lang::XTypeProvider
4528 IMPL_XTYPEPROVIDER_START( VCLXDateField )
4529 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDateField>* ) NULL ),
4530 	VCLXFormattedSpinField::getTypes()
4531 IMPL_XTYPEPROVIDER_END
4532 
4533 void VCLXDateField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
4534 {
4535 	::vos::OGuard aGuard( GetMutex() );
4536 
4537 	if ( GetWindow() )
4538 	{
4539 		sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
4540 
4541 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
4542 		switch ( nPropType )
4543 		{
4544 			case BASEPROPERTY_DATE:
4545 			{
4546 				if ( bVoid )
4547 				{
4548 					((DateField*)GetWindow())->EnableEmptyFieldValue( sal_True );
4549 					((DateField*)GetWindow())->SetEmptyFieldValue();
4550 				}
4551 				else
4552 				{
4553 					sal_Int32 n = 0;
4554 					if ( Value >>= n )
4555  						setDate( n );
4556 				}
4557 			}
4558 			break;
4559 			case BASEPROPERTY_DATEMIN:
4560 			{
4561 				sal_Int32 n = 0;
4562 				if ( Value >>= n )
4563  					setMin( n );
4564 			}
4565 			break;
4566 			case BASEPROPERTY_DATEMAX:
4567 			{
4568 				sal_Int32 n = 0;
4569 				if ( Value >>= n )
4570  					setMax( n );
4571 			}
4572 			break;
4573 			case BASEPROPERTY_EXTDATEFORMAT:
4574 			{
4575 				sal_Int16 n = sal_Int16();
4576 				if ( Value >>= n )
4577 					((DateField*)GetWindow())->SetExtDateFormat( (ExtDateFieldFormat) n );
4578 			}
4579 			break;
4580 			case BASEPROPERTY_DATESHOWCENTURY:
4581 			{
4582 				sal_Bool b = sal_Bool();
4583 				if ( Value >>= b )
4584  					((DateField*)GetWindow())->SetShowDateCentury( b );
4585 			}
4586 			break;
4587             case BASEPROPERTY_ENFORCE_FORMAT:
4588             {
4589 				sal_Bool bEnforce( sal_True );
4590 				OSL_VERIFY( Value >>= bEnforce );
4591                 static_cast< DateField* >( GetWindow() )->EnforceValidValue( bEnforce );
4592             }
4593             break;
4594 			default:
4595 			{
4596 				VCLXFormattedSpinField::setProperty( PropertyName, Value );
4597 			}
4598 		}
4599 	}
4600 }
4601 
getProperty(const::rtl::OUString & PropertyName)4602 ::com::sun::star::uno::Any VCLXDateField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
4603 {
4604 	::vos::OGuard aGuard( GetMutex() );
4605 
4606 	::com::sun::star::uno::Any aProp;
4607 	FormatterBase* pFormatter = GetFormatter();
4608 	if ( pFormatter )
4609 	{
4610 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
4611 		switch ( nPropType )
4612 		{
4613 			case BASEPROPERTY_DATE:
4614 			{
4615 				aProp <<= (sal_Int32) getDate();
4616 			}
4617 			break;
4618 			case BASEPROPERTY_DATEMIN:
4619 			{
4620 				aProp <<= (sal_Int32) getMin();
4621 			}
4622 			break;
4623 			case BASEPROPERTY_DATEMAX:
4624 			{
4625 				aProp <<= (sal_Int32) getMax();
4626 			}
4627 			break;
4628 			case BASEPROPERTY_DATESHOWCENTURY:
4629 			{
4630 			    aProp <<= ((DateField*)GetWindow())->IsShowDateCentury();
4631 			}
4632 			break;
4633             case BASEPROPERTY_ENFORCE_FORMAT:
4634             {
4635                 aProp <<= (sal_Bool)static_cast< DateField* >( GetWindow() )->IsEnforceValidValue( );
4636             }
4637             break;
4638 			default:
4639 			{
4640 				aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
4641 			}
4642 		}
4643 	}
4644 	return aProp;
4645 }
4646 
4647 
setDate(sal_Int32 nDate)4648 void VCLXDateField::setDate( sal_Int32 nDate ) throw(::com::sun::star::uno::RuntimeException)
4649 {
4650 	::vos::OGuard aGuard( GetMutex() );
4651 
4652 	DateField* pDateField = (DateField*) GetWindow();
4653 	if ( pDateField )
4654     {
4655 		pDateField->SetDate( nDate );
4656 
4657         // #107218# Call same listeners like VCL would do after user interaction
4658         SetSynthesizingVCLEvent( sal_True );
4659         pDateField->SetModifyFlag();
4660         pDateField->Modify();
4661         SetSynthesizingVCLEvent( sal_False );
4662     }
4663 }
4664 
getDate()4665 sal_Int32 VCLXDateField::getDate() throw(::com::sun::star::uno::RuntimeException)
4666 {
4667 	::vos::OGuard aGuard( GetMutex() );
4668 
4669 	sal_Int32 nDate = 0;
4670 	DateField* pDateField = (DateField*) GetWindow();
4671 	if ( pDateField )
4672 		nDate = pDateField->GetDate().GetDate();
4673 
4674 	return nDate;
4675 }
4676 
setMin(sal_Int32 nDate)4677 void VCLXDateField::setMin( sal_Int32 nDate ) throw(::com::sun::star::uno::RuntimeException)
4678 {
4679 	::vos::OGuard aGuard( GetMutex() );
4680 
4681 	DateField* pDateField = (DateField*) GetWindow();
4682 	if ( pDateField )
4683 		pDateField->SetMin( nDate );
4684 }
4685 
getMin()4686 sal_Int32 VCLXDateField::getMin() throw(::com::sun::star::uno::RuntimeException)
4687 {
4688 	::vos::OGuard aGuard( GetMutex() );
4689 
4690 	sal_Int32 nDate = 0;
4691 	DateField* pDateField = (DateField*) GetWindow();
4692 	if ( pDateField )
4693 		nDate = pDateField->GetMin().GetDate();
4694 
4695 	return nDate;
4696 }
4697 
setMax(sal_Int32 nDate)4698 void VCLXDateField::setMax( sal_Int32 nDate ) throw(::com::sun::star::uno::RuntimeException)
4699 {
4700 	::vos::OGuard aGuard( GetMutex() );
4701 
4702 	DateField* pDateField = (DateField*) GetWindow();
4703 	if ( pDateField )
4704 		pDateField->SetMax( nDate );
4705 }
4706 
getMax()4707 sal_Int32 VCLXDateField::getMax() throw(::com::sun::star::uno::RuntimeException)
4708 {
4709 	::vos::OGuard aGuard( GetMutex() );
4710 
4711 	sal_Int32 nDate = 0;
4712 	DateField* pDateField = (DateField*) GetWindow();
4713 	if ( pDateField )
4714 		nDate = pDateField->GetMax().GetDate();
4715 
4716 	return nDate;
4717 }
4718 
setFirst(sal_Int32 nDate)4719 void VCLXDateField::setFirst( sal_Int32 nDate ) throw(::com::sun::star::uno::RuntimeException)
4720 {
4721 	::vos::OGuard aGuard( GetMutex() );
4722 
4723 	DateField* pDateField = (DateField*) GetWindow();
4724 	if ( pDateField )
4725 		pDateField->SetFirst( nDate );
4726 }
4727 
getFirst()4728 sal_Int32 VCLXDateField::getFirst() throw(::com::sun::star::uno::RuntimeException)
4729 {
4730 	::vos::OGuard aGuard( GetMutex() );
4731 
4732 	sal_Int32 nDate = 0;
4733 	DateField* pDateField = (DateField*) GetWindow();
4734 	if ( pDateField )
4735 		nDate = pDateField->GetFirst().GetDate();
4736 
4737 	return nDate;
4738 }
4739 
setLast(sal_Int32 nDate)4740 void VCLXDateField::setLast( sal_Int32 nDate ) throw(::com::sun::star::uno::RuntimeException)
4741 {
4742 	::vos::OGuard aGuard( GetMutex() );
4743 
4744 	DateField* pDateField = (DateField*) GetWindow();
4745 	if ( pDateField )
4746 		pDateField->SetLast( nDate );
4747 }
4748 
getLast()4749 sal_Int32 VCLXDateField::getLast() throw(::com::sun::star::uno::RuntimeException)
4750 {
4751 	::vos::OGuard aGuard( GetMutex() );
4752 
4753 	sal_Int32 nDate = 0;
4754 	DateField* pDateField = (DateField*) GetWindow();
4755 	if ( pDateField )
4756 		nDate = pDateField->GetLast().GetDate();
4757 
4758 	return nDate;
4759 }
4760 
setLongFormat(sal_Bool bLong)4761 void VCLXDateField::setLongFormat( sal_Bool bLong ) throw(::com::sun::star::uno::RuntimeException)
4762 {
4763 	::vos::OGuard aGuard( GetMutex() );
4764 
4765 	DateField* pDateField = (DateField*) GetWindow();
4766 	if ( pDateField )
4767 		pDateField->SetLongFormat( bLong );
4768 }
4769 
isLongFormat()4770 sal_Bool VCLXDateField::isLongFormat() throw(::com::sun::star::uno::RuntimeException)
4771 {
4772 	::vos::OGuard aGuard( GetMutex() );
4773 
4774 	DateField* pDateField = (DateField*) GetWindow();
4775 	return pDateField ? pDateField->IsLongFormat() : sal_False;
4776 }
4777 
setEmpty()4778 void VCLXDateField::setEmpty() throw(::com::sun::star::uno::RuntimeException)
4779 {
4780 	::vos::OGuard aGuard( GetMutex() );
4781 
4782 	DateField* pDateField = (DateField*) GetWindow();
4783 	if ( pDateField )
4784     {
4785 		pDateField->SetEmptyDate();
4786 
4787         // #107218# Call same listeners like VCL would do after user interaction
4788         SetSynthesizingVCLEvent( sal_True );
4789         pDateField->SetModifyFlag();
4790         pDateField->Modify();
4791         SetSynthesizingVCLEvent( sal_False );
4792     }
4793 }
4794 
isEmpty()4795 sal_Bool VCLXDateField::isEmpty() throw(::com::sun::star::uno::RuntimeException)
4796 {
4797 	::vos::OGuard aGuard( GetMutex() );
4798 
4799 	DateField* pDateField = (DateField*) GetWindow();
4800 	return pDateField ? pDateField->IsEmptyDate() : sal_False;
4801 }
4802 
setStrictFormat(sal_Bool bStrict)4803 void VCLXDateField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException)
4804 {
4805 	VCLXFormattedSpinField::setStrictFormat( bStrict );
4806 }
4807 
isStrictFormat()4808 sal_Bool VCLXDateField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException)
4809 {
4810 	return VCLXFormattedSpinField::isStrictFormat();
4811 }
4812 
4813 
4814 //	----------------------------------------------------
4815 //	class VCLXTimeField
4816 //	----------------------------------------------------
4817 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)4818 void VCLXTimeField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
4819 {
4820     PushPropertyIds( rIds,
4821                      BASEPROPERTY_ALIGN,
4822                      BASEPROPERTY_BACKGROUNDCOLOR,
4823                      BASEPROPERTY_BORDER,
4824                      BASEPROPERTY_BORDERCOLOR,
4825                      BASEPROPERTY_DEFAULTCONTROL,
4826                      BASEPROPERTY_ENABLED,
4827                      BASEPROPERTY_ENABLEVISIBLE,
4828                      BASEPROPERTY_EXTTIMEFORMAT,
4829                      BASEPROPERTY_FONTDESCRIPTOR,
4830                      BASEPROPERTY_HELPTEXT,
4831                      BASEPROPERTY_HELPURL,
4832                      BASEPROPERTY_PRINTABLE,
4833                      BASEPROPERTY_READONLY,
4834                      BASEPROPERTY_REPEAT,
4835                      BASEPROPERTY_REPEAT_DELAY,
4836                      BASEPROPERTY_SPIN,
4837                      BASEPROPERTY_STRICTFORMAT,
4838                      BASEPROPERTY_TABSTOP,
4839                      BASEPROPERTY_TIME,
4840                      BASEPROPERTY_TIMEMAX,
4841                      BASEPROPERTY_TIMEMIN,
4842                      BASEPROPERTY_ENFORCE_FORMAT,
4843                      BASEPROPERTY_TEXT,
4844                      BASEPROPERTY_HIDEINACTIVESELECTION,
4845                      BASEPROPERTY_VERTICALALIGN,
4846                      BASEPROPERTY_WRITING_MODE,
4847                      BASEPROPERTY_CONTEXT_WRITING_MODE,
4848                      BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
4849                      0);
4850     VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
4851 }
4852 
VCLXTimeField()4853 VCLXTimeField::VCLXTimeField()
4854 {
4855 }
4856 
~VCLXTimeField()4857 VCLXTimeField::~VCLXTimeField()
4858 {
4859 }
4860 //change the window type here to match the role
CreateAccessibleContext()4861 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXTimeField::CreateAccessibleContext()
4862 {
4863 	Window* pWindow = GetWindow();
4864 	if ( pWindow )
4865 	{
4866 		pWindow->SetType( WINDOW_TIMEFIELD );
4867 	}
4868 	return getAccessibleFactory().createAccessibleContext( this );
4869 }
4870 
4871 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)4872 ::com::sun::star::uno::Any VCLXTimeField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
4873 {
4874 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
4875 										SAL_STATIC_CAST( ::com::sun::star::awt::XTimeField*, this ) );
4876 	return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
4877 }
4878 
4879 // ::com::sun::star::lang::XTypeProvider
4880 IMPL_XTYPEPROVIDER_START( VCLXTimeField )
4881 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTimeField>* ) NULL ),
4882 	VCLXFormattedSpinField::getTypes()
4883 IMPL_XTYPEPROVIDER_END
4884 
4885 void VCLXTimeField::setTime( sal_Int32 nTime ) throw(::com::sun::star::uno::RuntimeException)
4886 {
4887 	::vos::OGuard aGuard( GetMutex() );
4888 
4889 	TimeField* pTimeField = (TimeField*) GetWindow();
4890 	if ( pTimeField )
4891     {
4892 		pTimeField->SetTime( nTime );
4893 
4894         // #107218# Call same listeners like VCL would do after user interaction
4895         SetSynthesizingVCLEvent( sal_True );
4896         pTimeField->SetModifyFlag();
4897         pTimeField->Modify();
4898         SetSynthesizingVCLEvent( sal_False );
4899     }
4900 }
4901 
getTime()4902 sal_Int32 VCLXTimeField::getTime() throw(::com::sun::star::uno::RuntimeException)
4903 {
4904 	::vos::OGuard aGuard( GetMutex() );
4905 
4906 	sal_Int32 nTime = 0;
4907 	TimeField* pTimeField = (TimeField*) GetWindow();
4908 	if ( pTimeField )
4909 		nTime = pTimeField->GetTime().GetTime();
4910 
4911 	return nTime;
4912 }
4913 
setMin(sal_Int32 nTime)4914 void VCLXTimeField::setMin( sal_Int32 nTime ) throw(::com::sun::star::uno::RuntimeException)
4915 {
4916 	::vos::OGuard aGuard( GetMutex() );
4917 
4918 	TimeField* pTimeField = (TimeField*) GetWindow();
4919 	if ( pTimeField )
4920 		pTimeField->SetMin( nTime );
4921 }
4922 
getMin()4923 sal_Int32 VCLXTimeField::getMin() throw(::com::sun::star::uno::RuntimeException)
4924 {
4925 	::vos::OGuard aGuard( GetMutex() );
4926 
4927 	sal_Int32 nTime = 0;
4928 	TimeField* pTimeField = (TimeField*) GetWindow();
4929 	if ( pTimeField )
4930 		nTime = pTimeField->GetMin().GetTime();
4931 
4932 	return nTime;
4933 }
4934 
setMax(sal_Int32 nTime)4935 void VCLXTimeField::setMax( sal_Int32 nTime ) throw(::com::sun::star::uno::RuntimeException)
4936 {
4937 	::vos::OGuard aGuard( GetMutex() );
4938 
4939 	TimeField* pTimeField = (TimeField*) GetWindow();
4940 	if ( pTimeField )
4941 		pTimeField->SetMax( nTime );
4942 }
4943 
getMax()4944 sal_Int32 VCLXTimeField::getMax() throw(::com::sun::star::uno::RuntimeException)
4945 {
4946 	::vos::OGuard aGuard( GetMutex() );
4947 
4948 	sal_Int32 nTime = 0;
4949 	TimeField* pTimeField = (TimeField*) GetWindow();
4950 	if ( pTimeField )
4951 		nTime = pTimeField->GetMax().GetTime();
4952 
4953 	return nTime;
4954 }
4955 
setFirst(sal_Int32 nTime)4956 void VCLXTimeField::setFirst( sal_Int32 nTime ) throw(::com::sun::star::uno::RuntimeException)
4957 {
4958 	::vos::OGuard aGuard( GetMutex() );
4959 
4960 	TimeField* pTimeField = (TimeField*) GetWindow();
4961 	if ( pTimeField )
4962 		pTimeField->SetFirst( nTime );
4963 }
4964 
getFirst()4965 sal_Int32 VCLXTimeField::getFirst() throw(::com::sun::star::uno::RuntimeException)
4966 {
4967 	::vos::OGuard aGuard( GetMutex() );
4968 
4969 	sal_Int32 nTime = 0;
4970 	TimeField* pTimeField = (TimeField*) GetWindow();
4971 	if ( pTimeField )
4972 		nTime = pTimeField->GetFirst().GetTime();
4973 
4974 	return nTime;
4975 }
4976 
setLast(sal_Int32 nTime)4977 void VCLXTimeField::setLast( sal_Int32 nTime ) throw(::com::sun::star::uno::RuntimeException)
4978 {
4979 	::vos::OGuard aGuard( GetMutex() );
4980 
4981 	TimeField* pTimeField = (TimeField*) GetWindow();
4982 	if ( pTimeField )
4983 		pTimeField->SetLast( nTime );
4984 }
4985 
getLast()4986 sal_Int32 VCLXTimeField::getLast() throw(::com::sun::star::uno::RuntimeException)
4987 {
4988 	::vos::OGuard aGuard( GetMutex() );
4989 
4990 	sal_Int32 nTime = 0;
4991 	TimeField* pTimeField = (TimeField*) GetWindow();
4992 	if ( pTimeField )
4993 		nTime = pTimeField->GetLast().GetTime();
4994 
4995 	return nTime;
4996 }
4997 
setEmpty()4998 void VCLXTimeField::setEmpty() throw(::com::sun::star::uno::RuntimeException)
4999 {
5000 	::vos::OGuard aGuard( GetMutex() );
5001 
5002 	TimeField* pTimeField = (TimeField*) GetWindow();
5003 	if ( pTimeField )
5004 		pTimeField->SetEmptyTime();
5005 }
5006 
isEmpty()5007 sal_Bool VCLXTimeField::isEmpty() throw(::com::sun::star::uno::RuntimeException)
5008 {
5009 	::vos::OGuard aGuard( GetMutex() );
5010 
5011 	TimeField* pTimeField = (TimeField*) GetWindow();
5012 	return pTimeField ? pTimeField->IsEmptyTime() : sal_False;
5013 }
5014 
setStrictFormat(sal_Bool bStrict)5015 void VCLXTimeField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException)
5016 {
5017 	VCLXFormattedSpinField::setStrictFormat( bStrict );
5018 }
5019 
isStrictFormat()5020 sal_Bool VCLXTimeField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException)
5021 {
5022 	return VCLXFormattedSpinField::isStrictFormat();
5023 }
5024 
5025 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)5026 void VCLXTimeField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
5027 {
5028 	::vos::OGuard aGuard( GetMutex() );
5029 
5030 	if ( GetWindow() )
5031 	{
5032 		sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
5033 
5034 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
5035 		switch ( nPropType )
5036 		{
5037 			case BASEPROPERTY_TIME:
5038 			{
5039 				if ( bVoid )
5040 				{
5041 					((TimeField*)GetWindow())->EnableEmptyFieldValue( sal_True );
5042 					((TimeField*)GetWindow())->SetEmptyFieldValue();
5043 				}
5044 				else
5045 				{
5046 					sal_Int32 n = 0;
5047 					if ( Value >>= n )
5048  						setTime( n );
5049 				}
5050 			}
5051 			break;
5052 			case BASEPROPERTY_TIMEMIN:
5053 			{
5054 				sal_Int32 n = 0;
5055 				if ( Value >>= n )
5056  					setMin( n );
5057 			}
5058 			break;
5059 			case BASEPROPERTY_TIMEMAX:
5060 			{
5061 				sal_Int32 n = 0;
5062 				if ( Value >>= n )
5063  					setMax( n );
5064 			}
5065 			break;
5066 			case BASEPROPERTY_EXTTIMEFORMAT:
5067 			{
5068 				sal_Int16 n = sal_Int16();
5069 				if ( Value >>= n )
5070 					((TimeField*)GetWindow())->SetExtFormat( (ExtTimeFieldFormat) n );
5071 			}
5072 			break;
5073             case BASEPROPERTY_ENFORCE_FORMAT:
5074             {
5075 				sal_Bool bEnforce( sal_True );
5076 				OSL_VERIFY( Value >>= bEnforce );
5077                 static_cast< TimeField* >( GetWindow() )->EnforceValidValue( bEnforce );
5078             }
5079             break;
5080 			default:
5081 			{
5082 				VCLXFormattedSpinField::setProperty( PropertyName, Value );
5083 			}
5084 		}
5085 	}
5086 }
5087 
getProperty(const::rtl::OUString & PropertyName)5088 ::com::sun::star::uno::Any VCLXTimeField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
5089 {
5090 	::vos::OGuard aGuard( GetMutex() );
5091 
5092 	::com::sun::star::uno::Any aProp;
5093 	if ( GetWindow() )
5094 	{
5095 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
5096 		switch ( nPropType )
5097 		{
5098 			case BASEPROPERTY_TIME:
5099 			{
5100 				aProp <<= (sal_Int32) getTime();
5101 			}
5102 			break;
5103 			case BASEPROPERTY_TIMEMIN:
5104 			{
5105 				aProp <<= (sal_Int32) getMin();
5106 			}
5107 			break;
5108 			case BASEPROPERTY_TIMEMAX:
5109 			{
5110 				aProp <<= (sal_Int32) getMax();
5111 			}
5112 			break;
5113             case BASEPROPERTY_ENFORCE_FORMAT:
5114             {
5115                 aProp <<= (sal_Bool)static_cast< TimeField* >( GetWindow() )->IsEnforceValidValue( );
5116             }
5117             break;
5118 			default:
5119 			{
5120 				aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
5121 			}
5122 		}
5123 	}
5124 	return aProp;
5125 }
5126 
5127 //	----------------------------------------------------
5128 //	class VCLXNumericField
5129 //	----------------------------------------------------
5130 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)5131 void VCLXNumericField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
5132 {
5133     PushPropertyIds( rIds,
5134                      BASEPROPERTY_ALIGN,
5135                      BASEPROPERTY_BACKGROUNDCOLOR,
5136                      BASEPROPERTY_BORDER,
5137                      BASEPROPERTY_BORDERCOLOR,
5138                      BASEPROPERTY_DECIMALACCURACY,
5139                      BASEPROPERTY_DEFAULTCONTROL,
5140                      BASEPROPERTY_ENABLED,
5141                      BASEPROPERTY_ENABLEVISIBLE,
5142                      BASEPROPERTY_FONTDESCRIPTOR,
5143                      BASEPROPERTY_HELPTEXT,
5144                      BASEPROPERTY_HELPURL,
5145                      BASEPROPERTY_NUMSHOWTHOUSANDSEP,
5146                      BASEPROPERTY_PRINTABLE,
5147                      BASEPROPERTY_READONLY,
5148                      BASEPROPERTY_REPEAT,
5149                      BASEPROPERTY_REPEAT_DELAY,
5150                      BASEPROPERTY_SPIN,
5151                      BASEPROPERTY_STRICTFORMAT,
5152                      BASEPROPERTY_TABSTOP,
5153                      BASEPROPERTY_VALUEMAX_DOUBLE,
5154                      BASEPROPERTY_VALUEMIN_DOUBLE,
5155                      BASEPROPERTY_VALUESTEP_DOUBLE,
5156                      BASEPROPERTY_VALUE_DOUBLE,
5157                      BASEPROPERTY_ENFORCE_FORMAT,
5158                      BASEPROPERTY_HIDEINACTIVESELECTION,
5159                      BASEPROPERTY_VERTICALALIGN,
5160                      BASEPROPERTY_WRITING_MODE,
5161                      BASEPROPERTY_CONTEXT_WRITING_MODE,
5162                      BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
5163                      0);
5164     VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5165 }
5166 
VCLXNumericField()5167 VCLXNumericField::VCLXNumericField()
5168 {
5169 }
5170 
~VCLXNumericField()5171 VCLXNumericField::~VCLXNumericField()
5172 {
5173 }
5174 
5175 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)5176 ::com::sun::star::uno::Any VCLXNumericField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
5177 {
5178 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
5179 										SAL_STATIC_CAST( ::com::sun::star::awt::XNumericField*, this ) );
5180 	return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
5181 }
5182 
5183 // ::com::sun::star::lang::XTypeProvider
5184 IMPL_XTYPEPROVIDER_START( VCLXNumericField )
5185 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XNumericField>* ) NULL ),
5186 	VCLXFormattedSpinField::getTypes()
5187 IMPL_XTYPEPROVIDER_END
5188 
5189 void VCLXNumericField::setValue( double Value ) throw(::com::sun::star::uno::RuntimeException)
5190 {
5191 	::vos::OGuard aGuard( GetMutex() );
5192 
5193 	NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5194 	if ( pNumericFormatter )
5195 	{
5196 		// z.B. 105, 2 Digits => 1,05
5197 		// ein float 1,05 muss also eine 105 einstellen...
5198 		pNumericFormatter->SetValue(
5199 			(long)ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() ) );
5200 
5201         // #107218# Call same listeners like VCL would do after user interaction
5202 	    Edit* pEdit = (Edit*)GetWindow();
5203 	    if ( pEdit )
5204         {
5205             SetSynthesizingVCLEvent( sal_True );
5206             pEdit->SetModifyFlag();
5207             pEdit->Modify();
5208             SetSynthesizingVCLEvent( sal_False );
5209         }
5210 	}
5211 }
5212 
getValue()5213 double VCLXNumericField::getValue() throw(::com::sun::star::uno::RuntimeException)
5214 {
5215 	::vos::OGuard aGuard( GetMutex() );
5216 
5217 	NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5218 	return pNumericFormatter
5219 		? ImplCalcDoubleValue( (double)pNumericFormatter->GetValue(), pNumericFormatter->GetDecimalDigits() )
5220 		: 0;
5221 }
5222 
setMin(double Value)5223 void VCLXNumericField::setMin( double Value ) throw(::com::sun::star::uno::RuntimeException)
5224 {
5225 	::vos::OGuard aGuard( GetMutex() );
5226 
5227 	NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5228 	if ( pNumericFormatter )
5229 		pNumericFormatter->SetMin(
5230 			(long)ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() ) );
5231 }
5232 
getMin()5233 double VCLXNumericField::getMin() throw(::com::sun::star::uno::RuntimeException)
5234 {
5235 	::vos::OGuard aGuard( GetMutex() );
5236 
5237 	NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5238 	return pNumericFormatter
5239 		? ImplCalcDoubleValue( (double)pNumericFormatter->GetMin(), pNumericFormatter->GetDecimalDigits() )
5240 		: 0;
5241 }
5242 
setMax(double Value)5243 void VCLXNumericField::setMax( double Value ) throw(::com::sun::star::uno::RuntimeException)
5244 {
5245 	::vos::OGuard aGuard( GetMutex() );
5246 
5247 	NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5248 	if ( pNumericFormatter )
5249 		pNumericFormatter->SetMax(
5250 			(long)ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() ) );
5251 }
5252 
getMax()5253 double VCLXNumericField::getMax() throw(::com::sun::star::uno::RuntimeException)
5254 {
5255 	::vos::OGuard aGuard( GetMutex() );
5256 
5257 	NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5258 	return pNumericFormatter
5259 		? ImplCalcDoubleValue( (double)pNumericFormatter->GetMax(), pNumericFormatter->GetDecimalDigits() )
5260 		: 0;
5261 }
5262 
setFirst(double Value)5263 void VCLXNumericField::setFirst( double Value ) throw(::com::sun::star::uno::RuntimeException)
5264 {
5265 	::vos::OGuard aGuard( GetMutex() );
5266 
5267 	NumericField* pNumericField = (NumericField*) GetWindow();
5268 	if ( pNumericField )
5269 		pNumericField->SetFirst(
5270 			(long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) );
5271 }
5272 
getFirst()5273 double VCLXNumericField::getFirst() throw(::com::sun::star::uno::RuntimeException)
5274 {
5275 	::vos::OGuard aGuard( GetMutex() );
5276 
5277 	NumericField* pNumericField = (NumericField*) GetWindow();
5278 	return pNumericField
5279 		? ImplCalcDoubleValue( (double)pNumericField->GetFirst(), pNumericField->GetDecimalDigits() )
5280 		: 0;
5281 }
5282 
setLast(double Value)5283 void VCLXNumericField::setLast( double Value ) throw(::com::sun::star::uno::RuntimeException)
5284 {
5285 	::vos::OGuard aGuard( GetMutex() );
5286 
5287 	NumericField* pNumericField = (NumericField*) GetWindow();
5288 	if ( pNumericField )
5289 		pNumericField->SetLast(
5290 			(long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) );
5291 }
5292 
getLast()5293 double VCLXNumericField::getLast() throw(::com::sun::star::uno::RuntimeException)
5294 {
5295 	::vos::OGuard aGuard( GetMutex() );
5296 
5297 	NumericField* pNumericField = (NumericField*) GetWindow();
5298 	return pNumericField
5299 		? ImplCalcDoubleValue( (double)pNumericField->GetLast(), pNumericField->GetDecimalDigits() )
5300 		: 0;
5301 }
5302 
setStrictFormat(sal_Bool bStrict)5303 void VCLXNumericField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException)
5304 {
5305 	VCLXFormattedSpinField::setStrictFormat( bStrict );
5306 }
5307 
isStrictFormat()5308 sal_Bool VCLXNumericField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException)
5309 {
5310 	return VCLXFormattedSpinField::isStrictFormat();
5311 }
5312 
5313 
setSpinSize(double Value)5314 void VCLXNumericField::setSpinSize( double Value ) throw(::com::sun::star::uno::RuntimeException)
5315 {
5316 	::vos::OGuard aGuard( GetMutex() );
5317 
5318 	NumericField* pNumericField = (NumericField*) GetWindow();
5319 	if ( pNumericField )
5320 		pNumericField->SetSpinSize(
5321 			(long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) );
5322 }
5323 
getSpinSize()5324 double VCLXNumericField::getSpinSize() throw(::com::sun::star::uno::RuntimeException)
5325 {
5326 	::vos::OGuard aGuard( GetMutex() );
5327 
5328 	NumericField* pNumericField = (NumericField*) GetWindow();
5329 	return pNumericField
5330 		? ImplCalcDoubleValue( (double)pNumericField->GetSpinSize(), pNumericField->GetDecimalDigits() )
5331 		: 0;
5332 }
5333 
setDecimalDigits(sal_Int16 Value)5334 void VCLXNumericField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException)
5335 {
5336 	::vos::OGuard aGuard( GetMutex() );
5337 
5338 	NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5339 	if ( pNumericFormatter )
5340 	{
5341 		double n = getValue();
5342 		pNumericFormatter->SetDecimalDigits( Value );
5343 		setValue( n );
5344    	}
5345 }
5346 
getDecimalDigits()5347 sal_Int16 VCLXNumericField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException)
5348 {
5349 	::vos::OGuard aGuard( GetMutex() );
5350 
5351 	NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5352 	return pNumericFormatter ? pNumericFormatter->GetDecimalDigits() : 0;
5353 }
5354 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)5355 void VCLXNumericField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
5356 {
5357 	::vos::OGuard aGuard( GetMutex() );
5358 
5359 	if ( GetWindow() )
5360 	{
5361 		sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
5362 
5363 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
5364 		switch ( nPropType )
5365 		{
5366 			case BASEPROPERTY_VALUE_DOUBLE:
5367 			{
5368 				if ( bVoid )
5369 				{
5370 					((NumericField*)GetWindow())->EnableEmptyFieldValue( sal_True );
5371 					((NumericField*)GetWindow())->SetEmptyFieldValue();
5372 				}
5373 				else
5374 				{
5375 					double d = 0;
5376 					if ( Value >>= d )
5377  						setValue( d );
5378 				}
5379 			}
5380 			break;
5381 			case BASEPROPERTY_VALUEMIN_DOUBLE:
5382 			{
5383 				double d = 0;
5384 				if ( Value >>= d )
5385  					setMin( d );
5386 			}
5387 			break;
5388 			case BASEPROPERTY_VALUEMAX_DOUBLE:
5389 			{
5390 				double d = 0;
5391 				if ( Value >>= d )
5392  					setMax( d );
5393 			}
5394 			break;
5395 			case BASEPROPERTY_VALUESTEP_DOUBLE:
5396 			{
5397 				double d = 0;
5398 				if ( Value >>= d )
5399  					setSpinSize( d );
5400 			}
5401 			break;
5402 			case BASEPROPERTY_DECIMALACCURACY:
5403 			{
5404 				sal_Int16 n = sal_Int16();
5405 				if ( Value >>= n )
5406  					setDecimalDigits( n );
5407 			}
5408 			break;
5409 			case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5410 			{
5411 				sal_Bool b = sal_Bool();
5412 				if ( Value >>= b )
5413  					((NumericField*)GetWindow())->SetUseThousandSep( b );
5414 			}
5415 			break;
5416 			default:
5417 			{
5418 				VCLXFormattedSpinField::setProperty( PropertyName, Value );
5419 			}
5420 		}
5421 	}
5422 }
5423 
getProperty(const::rtl::OUString & PropertyName)5424 ::com::sun::star::uno::Any VCLXNumericField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
5425 {
5426 	::vos::OGuard aGuard( GetMutex() );
5427 
5428 	::com::sun::star::uno::Any aProp;
5429 	FormatterBase* pFormatter = GetFormatter();
5430 	if ( pFormatter )
5431 	{
5432 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
5433 		switch ( nPropType )
5434 		{
5435 			case BASEPROPERTY_VALUE_DOUBLE:
5436 			{
5437 				aProp <<= (double) getValue();
5438 			}
5439 			break;
5440 			case BASEPROPERTY_VALUEMIN_DOUBLE:
5441 			{
5442 				aProp <<= (double) getMin();
5443 			}
5444 			break;
5445 			case BASEPROPERTY_VALUEMAX_DOUBLE:
5446 			{
5447 				aProp <<= (double) getMax();
5448 			}
5449 			break;
5450 			case BASEPROPERTY_VALUESTEP_DOUBLE:
5451 			{
5452 				aProp <<= (double) getSpinSize();
5453 			}
5454 			break;
5455 			case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5456 			{
5457 			    aProp <<= (sal_Bool) ((NumericField*)GetWindow())->IsUseThousandSep();
5458 			}
5459 			break;
5460 			default:
5461 			{
5462 				aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
5463 			}
5464 		}
5465 	}
5466 	return aProp;
5467 }
5468 
5469 
5470 //    ----------------------------------------------------
5471 //    class VCLXMetricField
5472 //    ----------------------------------------------------
5473 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)5474 void VCLXMetricField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
5475 {
5476     PushPropertyIds( rIds,
5477                      BASEPROPERTY_ALIGN,
5478                      BASEPROPERTY_BACKGROUNDCOLOR,
5479                      BASEPROPERTY_BORDER,
5480                      BASEPROPERTY_BORDERCOLOR,
5481                      BASEPROPERTY_DECIMALACCURACY,
5482                      BASEPROPERTY_DEFAULTCONTROL,
5483                      BASEPROPERTY_ENABLED,
5484                      BASEPROPERTY_ENABLEVISIBLE,
5485                      BASEPROPERTY_FONTDESCRIPTOR,
5486                      BASEPROPERTY_HELPTEXT,
5487                      BASEPROPERTY_HELPURL,
5488                      BASEPROPERTY_NUMSHOWTHOUSANDSEP,
5489                      BASEPROPERTY_PRINTABLE,
5490                      BASEPROPERTY_READONLY,
5491                      BASEPROPERTY_REPEAT,
5492                      BASEPROPERTY_REPEAT_DELAY,
5493                      BASEPROPERTY_SPIN,
5494                      BASEPROPERTY_STRICTFORMAT,
5495                      BASEPROPERTY_TABSTOP,
5496                      BASEPROPERTY_ENFORCE_FORMAT,
5497                      BASEPROPERTY_HIDEINACTIVESELECTION,
5498                      BASEPROPERTY_UNIT,
5499                      BASEPROPERTY_CUSTOMUNITTEXT,
5500                      BASEPROPERTY_WRITING_MODE,
5501                      BASEPROPERTY_CONTEXT_WRITING_MODE,
5502                      BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
5503                      0);
5504     VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5505 }
5506 
VCLXMetricField()5507 VCLXMetricField::VCLXMetricField()
5508 {
5509 }
5510 
~VCLXMetricField()5511 VCLXMetricField::~VCLXMetricField()
5512 {
5513 }
5514 
GetMetricFormatter()5515 MetricFormatter *VCLXMetricField::GetMetricFormatter() throw(::com::sun::star::uno::RuntimeException)
5516 {
5517     MetricFormatter *pFormatter = (MetricFormatter *) GetFormatter();
5518     if (!pFormatter)
5519         throw ::com::sun::star::uno::RuntimeException();
5520     return pFormatter;
5521 }
5522 
GetMetricField()5523 MetricField *VCLXMetricField::GetMetricField() throw(::com::sun::star::uno::RuntimeException)
5524 {
5525     MetricField *pField = (MetricField *) GetWindow();
5526     if (!pField)
5527         throw ::com::sun::star::uno::RuntimeException();
5528     return pField;
5529 }
5530 
5531 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)5532 ::com::sun::star::uno::Any VCLXMetricField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
5533 {
5534     ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
5535                                                               SAL_STATIC_CAST( ::com::sun::star::awt::XMetricField*, this ) );
5536     return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
5537 }
5538 
5539 // ::com::sun::star::lang::XTypeProvider
5540 IMPL_XTYPEPROVIDER_START( VCLXMetricField )
5541     getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMetricField>* ) NULL ),
5542     VCLXFormattedSpinField::getTypes()
5543 IMPL_XTYPEPROVIDER_END
5544 
5545 // FIXME: later ...
5546 #define MetricUnitUnoToVcl(a) ((FieldUnit)(a))
5547 
5548 #define METRIC_MAP_PAIR(method,parent) \
5549     sal_Int64 VCLXMetricField::get##method( sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException) \
5550     { \
5551         ::vos::OGuard aGuard( GetMutex() ); \
5552         return GetMetric##parent()->Get##method( MetricUnitUnoToVcl( nUnit ) ); \
5553     } \
5554     void VCLXMetricField::set##method( sal_Int64 nValue, sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException) \
5555     { \
5556         ::vos::OGuard aGuard( GetMutex() ); \
5557         GetMetric##parent()->Set##method( nValue, MetricUnitUnoToVcl( nUnit ) ); \
5558     }
5559 
5560 METRIC_MAP_PAIR(Min, Formatter)
5561 METRIC_MAP_PAIR(Max, Formatter)
5562 METRIC_MAP_PAIR(First, Field)
5563 METRIC_MAP_PAIR(Last,  Field)
5564 
5565 #undef METRIC_MAP_PAIR
5566 
5567 ::sal_Int64 VCLXMetricField::getValue( ::sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException)
5568 {
5569     ::vos::OGuard aGuard( GetMutex() );
5570     return GetMetricFormatter()->GetValue( MetricUnitUnoToVcl( nUnit ) );
5571 }
5572 
getCorrectedValue(::sal_Int16 nUnit)5573 ::sal_Int64 VCLXMetricField::getCorrectedValue( ::sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException)
5574 {
5575     ::vos::OGuard aGuard( GetMutex() );
5576     return GetMetricFormatter()->GetCorrectedValue( MetricUnitUnoToVcl( nUnit ) );
5577 }
5578 
5579 // FIXME: acute cut/paste evilness - move this to the parent Edit class ?
CallListeners()5580 void VCLXMetricField::CallListeners()
5581 {
5582     // #107218# Call same listeners like VCL would do after user interaction
5583     Edit* pEdit = (Edit*)GetWindow();
5584     if ( pEdit )
5585     {
5586         SetSynthesizingVCLEvent( sal_True );
5587         pEdit->SetModifyFlag();
5588         pEdit->Modify();
5589         SetSynthesizingVCLEvent( sal_False );
5590     }
5591 }
5592 
setValue(::sal_Int64 Value,::sal_Int16 Unit)5593 void VCLXMetricField::setValue( ::sal_Int64 Value, ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException)
5594 {
5595     ::vos::OGuard aGuard( GetMutex() );
5596     GetMetricFormatter()->SetValue( Value, MetricUnitUnoToVcl( Unit ) );
5597     CallListeners();
5598 }
5599 
setUserValue(::sal_Int64 Value,::sal_Int16 Unit)5600 void VCLXMetricField::setUserValue( ::sal_Int64 Value, ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException)
5601 {
5602     ::vos::OGuard aGuard( GetMutex() );
5603     GetMetricFormatter()->SetUserValue( Value, MetricUnitUnoToVcl( Unit ) );
5604     CallListeners();
5605 }
5606 
setStrictFormat(sal_Bool bStrict)5607 void VCLXMetricField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException)
5608 {
5609     VCLXFormattedSpinField::setStrictFormat( bStrict );
5610 }
5611 
isStrictFormat()5612 sal_Bool VCLXMetricField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException)
5613 {
5614     return VCLXFormattedSpinField::isStrictFormat();
5615 }
5616 
setSpinSize(sal_Int64 Value)5617 void VCLXMetricField::setSpinSize( sal_Int64 Value ) throw(::com::sun::star::uno::RuntimeException)
5618 {
5619     ::vos::OGuard aGuard( GetMutex() );
5620     GetMetricField()->SetSpinSize( Value );
5621 }
5622 
getSpinSize()5623 sal_Int64 VCLXMetricField::getSpinSize() throw(::com::sun::star::uno::RuntimeException)
5624 {
5625     ::vos::OGuard aGuard( GetMutex() );
5626     return GetMetricField()->GetSpinSize();
5627 }
5628 
setDecimalDigits(sal_Int16 Value)5629 void VCLXMetricField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException)
5630 {
5631     ::vos::OGuard aGuard( GetMutex() );
5632     GetMetricFormatter()->SetDecimalDigits( Value );
5633 }
5634 
getDecimalDigits()5635 sal_Int16 VCLXMetricField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException)
5636 {
5637     ::vos::OGuard aGuard( GetMutex() );
5638 
5639     NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5640     return pNumericFormatter ? pNumericFormatter->GetDecimalDigits() : 0;
5641 }
5642 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)5643 void VCLXMetricField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
5644 {
5645     ::vos::OGuard aGuard( GetMutex() );
5646 
5647     if ( GetWindow() )
5648     {
5649         sal_uInt16 nPropType = GetPropertyId( PropertyName );
5650         switch ( nPropType )
5651         {
5652             case BASEPROPERTY_DECIMALACCURACY:
5653             {
5654                 sal_Int16 n = 0;
5655                 if ( Value >>= n )
5656                      setDecimalDigits( n );
5657                 break;
5658             }
5659             case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5660             {
5661                 sal_Bool b = sal_False;
5662                 if ( Value >>= b )
5663                      ((NumericField*)GetWindow())->SetUseThousandSep( b );
5664             }
5665             break;
5666             case BASEPROPERTY_UNIT:
5667             {
5668                 sal_uInt16 nVal = 0;
5669                 if ( Value >>= nVal )
5670                     ((MetricField*)GetWindow())->SetUnit( (FieldUnit) nVal );
5671                 break;
5672             }
5673             case BASEPROPERTY_CUSTOMUNITTEXT:
5674             {
5675                 rtl::OUString aStr;
5676                 if ( Value >>= aStr )
5677                     ((MetricField*)GetWindow())->SetCustomUnitText( aStr );
5678                 break;
5679             }
5680             default:
5681             {
5682                 VCLXFormattedSpinField::setProperty( PropertyName, Value );
5683                 break;
5684             }
5685         }
5686     }
5687 }
5688 
getProperty(const::rtl::OUString & PropertyName)5689 ::com::sun::star::uno::Any VCLXMetricField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
5690 {
5691     ::vos::OGuard aGuard( GetMutex() );
5692 
5693     ::com::sun::star::uno::Any aProp;
5694     FormatterBase* pFormatter = GetFormatter();
5695     if ( pFormatter )
5696     {
5697         sal_uInt16 nPropType = GetPropertyId( PropertyName );
5698         switch ( nPropType )
5699         {
5700             case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5701                 aProp <<= (sal_Bool) ((NumericField*)GetWindow())->IsUseThousandSep();
5702                 break;
5703             case BASEPROPERTY_UNIT:
5704                 aProp <<= (sal_uInt16) ((MetricField*)GetWindow())->GetUnit();
5705                 break;
5706             case BASEPROPERTY_CUSTOMUNITTEXT:
5707                 aProp <<= rtl::OUString (((MetricField*)GetWindow())->GetCustomUnitText());
5708                 break;
5709             default:
5710             {
5711                 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
5712                 break;
5713             }
5714         }
5715     }
5716     return aProp;
5717 }
5718 
5719 
5720 //	----------------------------------------------------
5721 //	class VCLXCurrencyField
5722 //	----------------------------------------------------
5723 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)5724 void VCLXCurrencyField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
5725 {
5726     PushPropertyIds( rIds,
5727                      BASEPROPERTY_ALIGN,
5728                      BASEPROPERTY_BACKGROUNDCOLOR,
5729                      BASEPROPERTY_BORDER,
5730                      BASEPROPERTY_BORDERCOLOR,
5731                      BASEPROPERTY_CURRENCYSYMBOL,
5732                      BASEPROPERTY_CURSYM_POSITION,
5733                      BASEPROPERTY_DECIMALACCURACY,
5734                      BASEPROPERTY_DEFAULTCONTROL,
5735                      BASEPROPERTY_ENABLED,
5736                      BASEPROPERTY_ENABLEVISIBLE,
5737                      BASEPROPERTY_FONTDESCRIPTOR,
5738                      BASEPROPERTY_HELPTEXT,
5739                      BASEPROPERTY_HELPURL,
5740                      BASEPROPERTY_NUMSHOWTHOUSANDSEP,
5741                      BASEPROPERTY_PRINTABLE,
5742                      BASEPROPERTY_READONLY,
5743                      BASEPROPERTY_REPEAT,
5744                      BASEPROPERTY_REPEAT_DELAY,
5745                      BASEPROPERTY_SPIN,
5746                      BASEPROPERTY_STRICTFORMAT,
5747                      BASEPROPERTY_TABSTOP,
5748                      BASEPROPERTY_VALUEMAX_DOUBLE,
5749                      BASEPROPERTY_VALUEMIN_DOUBLE,
5750                      BASEPROPERTY_VALUESTEP_DOUBLE,
5751                      BASEPROPERTY_VALUE_DOUBLE,
5752                      BASEPROPERTY_ENFORCE_FORMAT,
5753                      BASEPROPERTY_HIDEINACTIVESELECTION,
5754                      BASEPROPERTY_VERTICALALIGN,
5755                      BASEPROPERTY_WRITING_MODE,
5756                      BASEPROPERTY_CONTEXT_WRITING_MODE,
5757                      BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
5758                      0);
5759     VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5760 }
5761 
VCLXCurrencyField()5762 VCLXCurrencyField::VCLXCurrencyField()
5763 {
5764 }
5765 
~VCLXCurrencyField()5766 VCLXCurrencyField::~VCLXCurrencyField()
5767 {
5768 }
5769 
5770 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)5771 ::com::sun::star::uno::Any VCLXCurrencyField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
5772 {
5773 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
5774 										SAL_STATIC_CAST( ::com::sun::star::awt::XCurrencyField*, this ) );
5775 	return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
5776 }
5777 
5778 // ::com::sun::star::lang::XTypeProvider
5779 IMPL_XTYPEPROVIDER_START( VCLXCurrencyField )
5780 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XCurrencyField>* ) NULL ),
5781 	VCLXFormattedSpinField::getTypes()
5782 IMPL_XTYPEPROVIDER_END
5783 
5784 void VCLXCurrencyField::setValue( double Value ) throw(::com::sun::star::uno::RuntimeException)
5785 {
5786 	::vos::OGuard aGuard( GetMutex() );
5787 
5788 	LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter();
5789 	if ( pCurrencyFormatter )
5790 	{
5791 		// z.B. 105, 2 Digits => 1,05
5792 		// ein float 1,05 muss also eine 105 einstellen...
5793 		pCurrencyFormatter->SetValue(
5794 			ImplCalcLongValue( Value, pCurrencyFormatter->GetDecimalDigits() ) );
5795 
5796         // #107218# Call same listeners like VCL would do after user interaction
5797 	    Edit* pEdit = (Edit*)GetWindow();
5798 	    if ( pEdit )
5799         {
5800             SetSynthesizingVCLEvent( sal_True );
5801             pEdit->SetModifyFlag();
5802             pEdit->Modify();
5803             SetSynthesizingVCLEvent( sal_False );
5804         }
5805 	}
5806 }
5807 
getValue()5808 double VCLXCurrencyField::getValue() throw(::com::sun::star::uno::RuntimeException)
5809 {
5810 	::vos::OGuard aGuard( GetMutex() );
5811 
5812 	LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter();
5813 	return pCurrencyFormatter
5814 		? ImplCalcDoubleValue( (double)pCurrencyFormatter->GetValue(), pCurrencyFormatter->GetDecimalDigits() )
5815 		: 0;
5816 }
5817 
setMin(double Value)5818 void VCLXCurrencyField::setMin( double Value ) throw(::com::sun::star::uno::RuntimeException)
5819 {
5820 	::vos::OGuard aGuard( GetMutex() );
5821 
5822 	LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter();
5823 	if ( pCurrencyFormatter )
5824 		pCurrencyFormatter->SetMin(
5825 			ImplCalcLongValue( Value, pCurrencyFormatter->GetDecimalDigits() ) );
5826 }
5827 
getMin()5828 double VCLXCurrencyField::getMin() throw(::com::sun::star::uno::RuntimeException)
5829 {
5830 	::vos::OGuard aGuard( GetMutex() );
5831 
5832 	LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter();
5833 	return pCurrencyFormatter
5834 		? ImplCalcDoubleValue( (double)pCurrencyFormatter->GetMin(), pCurrencyFormatter->GetDecimalDigits() )
5835 		: 0;
5836 }
5837 
setMax(double Value)5838 void VCLXCurrencyField::setMax( double Value ) throw(::com::sun::star::uno::RuntimeException)
5839 {
5840 	::vos::OGuard aGuard( GetMutex() );
5841 
5842 	LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter();
5843 	if ( pCurrencyFormatter )
5844 		pCurrencyFormatter->SetMax(
5845 			ImplCalcLongValue( Value, pCurrencyFormatter->GetDecimalDigits() ) );
5846 }
5847 
getMax()5848 double VCLXCurrencyField::getMax() throw(::com::sun::star::uno::RuntimeException)
5849 {
5850 	::vos::OGuard aGuard( GetMutex() );
5851 
5852 	LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter();
5853 	return pCurrencyFormatter
5854 		? ImplCalcDoubleValue( (double)pCurrencyFormatter->GetMax(), pCurrencyFormatter->GetDecimalDigits() )
5855 		: 0;
5856 }
5857 
setFirst(double Value)5858 void VCLXCurrencyField::setFirst( double Value ) throw(::com::sun::star::uno::RuntimeException)
5859 {
5860 	::vos::OGuard aGuard( GetMutex() );
5861 
5862 	LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow();
5863 	if ( pCurrencyField )
5864 		pCurrencyField->SetFirst(
5865 			ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) );
5866 }
5867 
getFirst()5868 double VCLXCurrencyField::getFirst() throw(::com::sun::star::uno::RuntimeException)
5869 {
5870 	::vos::OGuard aGuard( GetMutex() );
5871 
5872 	LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow();
5873 	return pCurrencyField
5874 		? ImplCalcDoubleValue( (double)pCurrencyField->GetFirst(), pCurrencyField->GetDecimalDigits() )
5875 		: 0;
5876 }
5877 
setLast(double Value)5878 void VCLXCurrencyField::setLast( double Value ) throw(::com::sun::star::uno::RuntimeException)
5879 {
5880 	::vos::OGuard aGuard( GetMutex() );
5881 
5882 	LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow();
5883 	if ( pCurrencyField )
5884 		pCurrencyField->SetLast(
5885 			ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) );
5886 }
5887 
getLast()5888 double VCLXCurrencyField::getLast() throw(::com::sun::star::uno::RuntimeException)
5889 {
5890 	::vos::OGuard aGuard( GetMutex() );
5891 
5892 	LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow();
5893 	return pCurrencyField
5894 		? ImplCalcDoubleValue( (double)pCurrencyField->GetLast(), pCurrencyField->GetDecimalDigits() )
5895 		: 0;
5896 }
5897 
setSpinSize(double Value)5898 void VCLXCurrencyField::setSpinSize( double Value ) throw(::com::sun::star::uno::RuntimeException)
5899 {
5900 	::vos::OGuard aGuard( GetMutex() );
5901 
5902 	LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow();
5903 	if ( pCurrencyField )
5904 		pCurrencyField->SetSpinSize(
5905 			ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) );
5906 }
5907 
getSpinSize()5908 double VCLXCurrencyField::getSpinSize() throw(::com::sun::star::uno::RuntimeException)
5909 {
5910 	::vos::OGuard aGuard( GetMutex() );
5911 
5912 	LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow();
5913 	return pCurrencyField
5914 		? ImplCalcDoubleValue( (double)pCurrencyField->GetSpinSize(), pCurrencyField->GetDecimalDigits() )
5915 		: 0;
5916 }
5917 
setStrictFormat(sal_Bool bStrict)5918 void VCLXCurrencyField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException)
5919 {
5920 	VCLXFormattedSpinField::setStrictFormat( bStrict );
5921 }
5922 
isStrictFormat()5923 sal_Bool VCLXCurrencyField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException)
5924 {
5925 	return VCLXFormattedSpinField::isStrictFormat();
5926 }
5927 
5928 
setDecimalDigits(sal_Int16 Value)5929 void VCLXCurrencyField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException)
5930 {
5931 	::vos::OGuard aGuard( GetMutex() );
5932 
5933 	LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter();
5934 	if ( pCurrencyFormatter )
5935 	{
5936 		double n = getValue();
5937 		pCurrencyFormatter->SetDecimalDigits( Value );
5938 		setValue( n );
5939    	}
5940 }
5941 
getDecimalDigits()5942 sal_Int16 VCLXCurrencyField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException)
5943 {
5944 	::vos::OGuard aGuard( GetMutex() );
5945 
5946 	LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter();
5947 	return pCurrencyFormatter ? pCurrencyFormatter->GetDecimalDigits() : 0;
5948 }
5949 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)5950 void VCLXCurrencyField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
5951 {
5952 	::vos::OGuard aGuard( GetMutex() );
5953 
5954 	if ( GetWindow() )
5955 	{
5956 		sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
5957 
5958 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
5959 		switch ( nPropType )
5960 		{
5961 			case BASEPROPERTY_VALUE_DOUBLE:
5962 			{
5963 				if ( bVoid )
5964 				{
5965 					((LongCurrencyField*)GetWindow())->EnableEmptyFieldValue( sal_True );
5966 					((LongCurrencyField*)GetWindow())->SetEmptyFieldValue();
5967 				}
5968 				else
5969 				{
5970 					double d = 0;
5971 					if ( Value >>= d )
5972  						setValue( d );
5973 				}
5974 			}
5975 			break;
5976 			case BASEPROPERTY_VALUEMIN_DOUBLE:
5977 			{
5978 				double d = 0;
5979 				if ( Value >>= d )
5980  					setMin( d );
5981 			}
5982 			break;
5983 			case BASEPROPERTY_VALUEMAX_DOUBLE:
5984 			{
5985 				double d = 0;
5986 				if ( Value >>= d )
5987  					setMax( d );
5988 			}
5989 			break;
5990 			case BASEPROPERTY_VALUESTEP_DOUBLE:
5991 			{
5992 				double d = 0;
5993 				if ( Value >>= d )
5994  					setSpinSize( d );
5995 			}
5996 			break;
5997 			case BASEPROPERTY_DECIMALACCURACY:
5998 			{
5999 				sal_Int16 n = sal_Int16();
6000 				if ( Value >>= n )
6001  					setDecimalDigits( n );
6002 			}
6003 			break;
6004 			case BASEPROPERTY_CURRENCYSYMBOL:
6005 			{
6006 				::rtl::OUString aString;
6007 				if ( Value >>= aString )
6008  					((LongCurrencyField*)GetWindow())->SetCurrencySymbol( aString );
6009 			}
6010 			break;
6011 			case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
6012 			{
6013 				sal_Bool b = sal_Bool();
6014 				if ( Value >>= b )
6015  					((LongCurrencyField*)GetWindow())->SetUseThousandSep( b );
6016 			}
6017 			break;
6018 			default:
6019 			{
6020 				VCLXFormattedSpinField::setProperty( PropertyName, Value );
6021 			}
6022 		}
6023 	}
6024 }
6025 
getProperty(const::rtl::OUString & PropertyName)6026 ::com::sun::star::uno::Any VCLXCurrencyField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
6027 {
6028 	::vos::OGuard aGuard( GetMutex() );
6029 
6030 	::com::sun::star::uno::Any aProp;
6031 	FormatterBase* pFormatter = GetFormatter();
6032 	if ( pFormatter )
6033 	{
6034 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
6035 		switch ( nPropType )
6036 		{
6037 			case BASEPROPERTY_VALUE_DOUBLE:
6038 			{
6039 				aProp <<= (double) getValue();
6040 			}
6041 			break;
6042 			case BASEPROPERTY_VALUEMIN_DOUBLE:
6043 			{
6044 				aProp <<= (double) getMin();
6045 			}
6046 			break;
6047 			case BASEPROPERTY_VALUEMAX_DOUBLE:
6048 			{
6049 				aProp <<= (double) getMax();
6050 			}
6051 			break;
6052 			case BASEPROPERTY_VALUESTEP_DOUBLE:
6053 			{
6054 				aProp <<= (double) getSpinSize();
6055 			}
6056 			break;
6057 			case BASEPROPERTY_CURRENCYSYMBOL:
6058 			{
6059 			    aProp <<= ::rtl::OUString( ((LongCurrencyField*)GetWindow())->GetCurrencySymbol() );
6060 			}
6061 			break;
6062 			case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
6063 			{
6064 			    aProp <<= (sal_Bool) ((LongCurrencyField*)GetWindow())->IsUseThousandSep();
6065 			}
6066 			break;
6067 			default:
6068 			{
6069 				aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
6070 			}
6071 		}
6072 	}
6073 	return aProp;
6074 }
6075 
6076 //	----------------------------------------------------
6077 //	class VCLXPatternField
6078 //	----------------------------------------------------
6079 
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)6080 void VCLXPatternField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
6081 {
6082     PushPropertyIds( rIds,
6083                      BASEPROPERTY_ALIGN,
6084                      BASEPROPERTY_BACKGROUNDCOLOR,
6085                      BASEPROPERTY_BORDER,
6086                      BASEPROPERTY_BORDERCOLOR,
6087                      BASEPROPERTY_DEFAULTCONTROL,
6088                      BASEPROPERTY_EDITMASK,
6089                      BASEPROPERTY_ENABLED,
6090                      BASEPROPERTY_ENABLEVISIBLE,
6091                      BASEPROPERTY_FONTDESCRIPTOR,
6092                      BASEPROPERTY_HELPTEXT,
6093                      BASEPROPERTY_HELPURL,
6094                      BASEPROPERTY_LITERALMASK,
6095                      BASEPROPERTY_MAXTEXTLEN,
6096                      BASEPROPERTY_PRINTABLE,
6097                      BASEPROPERTY_READONLY,
6098                      BASEPROPERTY_STRICTFORMAT,
6099                      BASEPROPERTY_TABSTOP,
6100                      BASEPROPERTY_TEXT,
6101                      BASEPROPERTY_HIDEINACTIVESELECTION,
6102                      BASEPROPERTY_VERTICALALIGN,
6103                      BASEPROPERTY_WRITING_MODE,
6104                      BASEPROPERTY_CONTEXT_WRITING_MODE,
6105                      BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
6106                      0);
6107     VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
6108 }
6109 
VCLXPatternField()6110 VCLXPatternField::VCLXPatternField()
6111 {
6112 }
6113 
~VCLXPatternField()6114 VCLXPatternField::~VCLXPatternField()
6115 {
6116 }
6117 
6118 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)6119 ::com::sun::star::uno::Any VCLXPatternField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
6120 {
6121 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
6122 										SAL_STATIC_CAST( ::com::sun::star::awt::XPatternField*, this ) );
6123 	return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
6124 }
6125 
6126 // ::com::sun::star::lang::XTypeProvider
6127 IMPL_XTYPEPROVIDER_START( VCLXPatternField )
6128 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPatternField>* ) NULL ),
6129 	VCLXFormattedSpinField::getTypes()
6130 IMPL_XTYPEPROVIDER_END
6131 
6132 void VCLXPatternField::setMasks( const ::rtl::OUString& EditMask, const ::rtl::OUString& LiteralMask ) throw(::com::sun::star::uno::RuntimeException)
6133 {
6134 	::vos::OGuard aGuard( GetMutex() );
6135 
6136 	PatternField* pPatternField = (PatternField*) GetWindow();
6137 	if ( pPatternField )
6138 	{
6139 		pPatternField->SetMask(	ByteString( UniString( EditMask ), RTL_TEXTENCODING_ASCII_US ), LiteralMask );
6140 	}
6141 }
6142 
getMasks(::rtl::OUString & EditMask,::rtl::OUString & LiteralMask)6143 void VCLXPatternField::getMasks( ::rtl::OUString& EditMask, ::rtl::OUString& LiteralMask ) throw(::com::sun::star::uno::RuntimeException)
6144 {
6145 	::vos::OGuard aGuard( GetMutex() );
6146 
6147 	PatternField* pPatternField = (PatternField*) GetWindow();
6148 	if ( pPatternField )
6149 	{
6150 		EditMask = String( pPatternField->GetEditMask(), RTL_TEXTENCODING_ASCII_US );
6151 		LiteralMask = pPatternField->GetLiteralMask();
6152 	}
6153 }
6154 
setString(const::rtl::OUString & Str)6155 void VCLXPatternField::setString( const ::rtl::OUString& Str ) throw(::com::sun::star::uno::RuntimeException)
6156 {
6157 	::vos::OGuard aGuard( GetMutex() );
6158 
6159 	PatternField* pPatternField = (PatternField*) GetWindow();
6160 	if ( pPatternField )
6161 	{
6162 		pPatternField->SetString( Str );
6163 	}
6164 }
6165 
getString()6166 ::rtl::OUString VCLXPatternField::getString() throw(::com::sun::star::uno::RuntimeException)
6167 {
6168 	::vos::OGuard aGuard( GetMutex() );
6169 
6170 	::rtl::OUString aString;
6171 	PatternField* pPatternField = (PatternField*) GetWindow();
6172 	if ( pPatternField )
6173 		aString = pPatternField->GetString();
6174 	return aString;
6175 }
6176 
setStrictFormat(sal_Bool bStrict)6177 void VCLXPatternField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException)
6178 {
6179 	VCLXFormattedSpinField::setStrictFormat( bStrict );
6180 }
6181 
isStrictFormat()6182 sal_Bool VCLXPatternField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException)
6183 {
6184 	return VCLXFormattedSpinField::isStrictFormat();
6185 }
6186 
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)6187 void VCLXPatternField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
6188 {
6189 	::vos::OGuard aGuard( GetMutex() );
6190 
6191 	if ( GetWindow() )
6192 	{
6193 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
6194 		switch ( nPropType )
6195 		{
6196 			case BASEPROPERTY_EDITMASK:
6197 			case BASEPROPERTY_LITERALMASK:
6198 			{
6199 				::rtl::OUString aString;
6200 				if ( Value >>= aString )
6201 				{
6202 					::rtl::OUString aEditMask, aLiteralMask;
6203 					getMasks( aEditMask, aLiteralMask );
6204 					if ( nPropType == BASEPROPERTY_EDITMASK )
6205 						aEditMask = aString;
6206 					else
6207 						aLiteralMask = aString;
6208  					setMasks( aEditMask, aLiteralMask );
6209 				}
6210 			}
6211 			break;
6212 			default:
6213 			{
6214 				VCLXFormattedSpinField::setProperty( PropertyName, Value );
6215 			}
6216 		}
6217 	}
6218 }
6219 
getProperty(const::rtl::OUString & PropertyName)6220 ::com::sun::star::uno::Any VCLXPatternField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
6221 {
6222 	::vos::OGuard aGuard( GetMutex() );
6223 
6224 	::com::sun::star::uno::Any aProp;
6225 	if ( GetWindow() )
6226 	{
6227 		sal_uInt16 nPropType = GetPropertyId( PropertyName );
6228 		switch ( nPropType )
6229 		{
6230 			case BASEPROPERTY_EDITMASK:
6231 			case BASEPROPERTY_LITERALMASK:
6232 			{
6233 				::rtl::OUString aEditMask, aLiteralMask;
6234 				getMasks( aEditMask, aLiteralMask );
6235 				if ( nPropType == BASEPROPERTY_EDITMASK )
6236 					aProp <<= aEditMask;
6237 				else
6238 					aProp <<= aLiteralMask;
6239 			}
6240 			break;
6241 			default:
6242 			{
6243 				aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
6244 			}
6245 		}
6246 	}
6247 	return aProp;
6248 }
6249 
6250 //	----------------------------------------------------
6251 //	class VCLXToolBox
6252 //	----------------------------------------------------
VCLXToolBox()6253 VCLXToolBox::VCLXToolBox()
6254 {
6255 }
6256 
~VCLXToolBox()6257 VCLXToolBox::~VCLXToolBox()
6258 {
6259 }
6260 
CreateAccessibleContext()6261 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXToolBox::CreateAccessibleContext()
6262 {
6263     return getAccessibleFactory().createAccessibleContext( this );
6264 }
6265 
6266