lwp build fixes
[LibreOffice.git] / toolkit / source / awt / vclxwindows.cxx
blob002ef31763da8fa6bca230c6640f81f0fc0603ef
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <toolkit/awt/vclxwindows.hxx>
21 #include "toolkit/awt/scrollabledialog.hxx"
22 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
23 #include <com/sun/star/graphic/GraphicProvider.hpp>
24 #include <com/sun/star/graphic/XGraphicProvider.hpp>
25 #include <toolkit/helper/vclunohelper.hxx>
26 #include <toolkit/helper/macros.hxx>
27 #include <toolkit/helper/property.hxx>
28 #include <toolkit/helper/convert.hxx>
29 #include <cppuhelper/typeprovider.hxx>
30 #include <cppuhelper/queryinterface.hxx>
31 #include <com/sun/star/awt/VisualEffect.hpp>
32 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
33 #include <com/sun/star/system/SystemShellExecute.hpp>
34 #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
35 #include <com/sun/star/resource/XStringResourceResolver.hpp>
36 #include <com/sun/star/awt/ImageScaleMode.hpp>
37 #include <com/sun/star/awt/XItemList.hpp>
38 #include <comphelper/namedvaluecollection.hxx>
39 #include <comphelper/processfactory.hxx>
41 #include <vcl/button.hxx>
42 #include <vcl/lstbox.hxx>
43 #include <vcl/combobox.hxx>
44 #include <vcl/field.hxx>
45 #include <vcl/fixedhyper.hxx>
46 #include <vcl/longcurr.hxx>
47 #include <vcl/imgctrl.hxx>
48 #include <vcl/dialog.hxx>
49 #include <vcl/msgbox.hxx>
50 #include <vcl/scrbar.hxx>
51 #include <vcl/svapp.hxx>
52 #include <vcl/tabpage.hxx>
53 #include <vcl/tabctrl.hxx>
54 #include <vcl/settings.hxx>
55 #include <tools/diagnose_ex.h>
57 #include <boost/bind.hpp>
58 #include <boost/function.hpp>
60 #include <vcl/group.hxx>
62 #include "helper/accessibilityclient.hxx"
63 #include "helper/imagealign.hxx"
64 #include "helper/tkresmgr.hxx"
65 #include "vclxwindows_internal.hxx"
67 using ::com::sun::star::uno::Any;
68 using ::com::sun::star::uno::Reference;
69 using ::com::sun::star::uno::makeAny;
70 using ::com::sun::star::uno::RuntimeException;
71 using ::com::sun::star::lang::EventObject;
72 using ::com::sun::star::awt::ItemListEvent;
73 using ::com::sun::star::awt::XItemList;
74 using ::com::sun::star::graphic::XGraphic;
75 using ::com::sun::star::graphic::XGraphicProvider;
77 using namespace ::com::sun::star;
78 using namespace ::com::sun::star::awt::VisualEffect;
79 namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode;
81 static double ImplCalcLongValue( double nValue, sal_uInt16 nDigits )
83 double n = nValue;
84 for ( sal_uInt16 d = 0; d < nDigits; d++ )
85 n *= 10;
86 return n;
89 static double ImplCalcDoubleValue( double nValue, sal_uInt16 nDigits )
91 double n = nValue;
92 for ( sal_uInt16 d = 0; d < nDigits; d++ )
93 n /= 10;
94 return n;
97 namespace toolkit
99 /** sets the "face color" for button like controls (scroll bar, spin button)
101 void setButtonLikeFaceColor( vcl::Window* _pWindow, const ::com::sun::star::uno::Any& _rColorValue )
103 AllSettings aSettings = _pWindow->GetSettings();
104 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
106 if ( !_rColorValue.hasValue() )
108 const StyleSettings& aAppStyle = Application::GetSettings().GetStyleSettings();
109 aStyleSettings.SetFaceColor( aAppStyle.GetFaceColor( ) );
110 aStyleSettings.SetCheckedColor( aAppStyle.GetCheckedColor( ) );
111 aStyleSettings.SetLightBorderColor( aAppStyle.GetLightBorderColor() );
112 aStyleSettings.SetLightColor( aAppStyle.GetLightColor() );
113 aStyleSettings.SetShadowColor( aAppStyle.GetShadowColor() );
114 aStyleSettings.SetDarkShadowColor( aAppStyle.GetDarkShadowColor() );
116 else
118 sal_Int32 nBackgroundColor = 0;
119 _rColorValue >>= nBackgroundColor;
120 aStyleSettings.SetFaceColor( nBackgroundColor );
122 // for the real background (everything except the buttons and the thumb),
123 // use an average between the desired color and "white"
124 Color aWhite( COL_WHITE );
125 Color aBackground( nBackgroundColor );
126 aBackground.SetRed( ( aBackground.GetRed() + aWhite.GetRed() ) / 2 );
127 aBackground.SetGreen( ( aBackground.GetGreen() + aWhite.GetGreen() ) / 2 );
128 aBackground.SetBlue( ( aBackground.GetBlue() + aWhite.GetBlue() ) / 2 );
129 aStyleSettings.SetCheckedColor( aBackground );
131 sal_Int32 nBackgroundLuminance = Color( nBackgroundColor ).GetLuminance();
132 sal_Int32 nWhiteLuminance = Color( COL_WHITE ).GetLuminance();
134 Color aLightShadow( nBackgroundColor );
135 aLightShadow.IncreaseLuminance( (sal_uInt8)( ( nWhiteLuminance - nBackgroundLuminance ) * 2 / 3 ) );
136 aStyleSettings.SetLightBorderColor( aLightShadow );
138 Color aLight( nBackgroundColor );
139 aLight.IncreaseLuminance( (sal_uInt8)( ( nWhiteLuminance - nBackgroundLuminance ) * 1 / 3 ) );
140 aStyleSettings.SetLightColor( aLight );
142 Color aShadow( nBackgroundColor );
143 aShadow.DecreaseLuminance( (sal_uInt8)( nBackgroundLuminance * 1 / 3 ) );
144 aStyleSettings.SetShadowColor( aShadow );
146 Color aDarkShadow( nBackgroundColor );
147 aDarkShadow.DecreaseLuminance( (sal_uInt8)( nBackgroundLuminance * 2 / 3 ) );
148 aStyleSettings.SetDarkShadowColor( aDarkShadow );
151 aSettings.SetStyleSettings( aStyleSettings );
152 _pWindow->SetSettings( aSettings, true );
155 Any getButtonLikeFaceColor( const vcl::Window* _pWindow )
157 sal_Int32 nBackgroundColor = _pWindow->GetSettings().GetStyleSettings().GetFaceColor().GetColor();
158 return makeAny( nBackgroundColor );
161 static void adjustBooleanWindowStyle( const Any& _rValue, vcl::Window* _pWindow, WinBits _nBits, bool _bInverseSemantics )
163 WinBits nStyle = _pWindow->GetStyle();
164 bool bValue( false );
165 OSL_VERIFY( _rValue >>= bValue );
166 if ( bValue != _bInverseSemantics )
167 nStyle |= _nBits;
168 else
169 nStyle &= ~_nBits;
170 _pWindow->SetStyle( nStyle );
173 static void setVisualEffect( const Any& _rValue, vcl::Window* _pWindow )
175 AllSettings aSettings = _pWindow->GetSettings();
176 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
178 sal_Int16 nStyle = LOOK3D;
179 OSL_VERIFY( _rValue >>= nStyle );
180 switch ( nStyle )
182 case FLAT:
183 aStyleSettings.SetOptions( aStyleSettings.GetOptions() | STYLE_OPTION_MONO );
184 break;
185 case LOOK3D:
186 default:
187 aStyleSettings.SetOptions( aStyleSettings.GetOptions() & ~STYLE_OPTION_MONO );
189 aSettings.SetStyleSettings( aStyleSettings );
190 _pWindow->SetSettings( aSettings );
193 static Any getVisualEffect( vcl::Window* _pWindow )
195 Any aEffect;
197 StyleSettings aStyleSettings = _pWindow->GetSettings().GetStyleSettings();
198 if ( (aStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
199 aEffect <<= (sal_Int16)FLAT;
200 else
201 aEffect <<= (sal_Int16)LOOK3D;
202 return aEffect;
207 // class VCLXGraphicControl
210 void VCLXGraphicControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
212 VCLXWindow::ImplGetPropertyIds( rIds );
215 void VCLXGraphicControl::ImplSetNewImage()
217 OSL_PRECOND( GetWindow(), "VCLXGraphicControl::ImplSetNewImage: window is required to be not-NULL!" );
218 Button* pButton = static_cast< Button* >( GetWindow() );
219 pButton->SetModeImage( GetImage() );
222 void VCLXGraphicControl::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, short Flags ) throw(::com::sun::star::uno::RuntimeException, std::exception)
224 SolarMutexGuard aGuard;
226 if ( GetWindow() )
228 Size aOldSize = GetWindow()->GetSizePixel();
229 VCLXWindow::setPosSize( X, Y, Width, Height, Flags );
230 if ( ( aOldSize.Width() != Width ) || ( aOldSize.Height() != Height ) )
231 ImplSetNewImage();
235 void VCLXGraphicControl::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
237 SolarMutexGuard aGuard;
239 Button* pButton = static_cast< Button* >( GetWindow() );
240 if ( !pButton )
241 return;
242 sal_uInt16 nPropType = GetPropertyId( PropertyName );
243 switch ( nPropType )
245 case BASEPROPERTY_GRAPHIC:
247 Reference< XGraphic > xGraphic;
248 OSL_VERIFY( Value >>= xGraphic );
249 maImage = Image( xGraphic );
250 ImplSetNewImage();
252 break;
254 case BASEPROPERTY_IMAGEALIGN:
256 WindowType eType = GetWindow()->GetType();
257 if ( ( eType == WINDOW_PUSHBUTTON )
258 || ( eType == WINDOW_RADIOBUTTON )
259 || ( eType == WINDOW_CHECKBOX )
262 sal_Int16 nAlignment = sal_Int16();
263 if ( Value >>= nAlignment )
264 pButton->SetImageAlign( static_cast< ImageAlign >( nAlignment ) );
267 break;
268 case BASEPROPERTY_IMAGEPOSITION:
270 WindowType eType = GetWindow()->GetType();
271 if ( ( eType == WINDOW_PUSHBUTTON )
272 || ( eType == WINDOW_RADIOBUTTON )
273 || ( eType == WINDOW_CHECKBOX )
276 sal_Int16 nImagePosition = 2;
277 OSL_VERIFY( Value >>= nImagePosition );
278 pButton->SetImageAlign( ::toolkit::translateImagePosition( nImagePosition ) );
281 break;
282 default:
283 VCLXWindow::setProperty( PropertyName, Value );
284 break;
288 ::com::sun::star::uno::Any VCLXGraphicControl::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
290 SolarMutexGuard aGuard;
292 ::com::sun::star::uno::Any aProp;
293 if ( !GetWindow() )
294 return aProp;
296 sal_uInt16 nPropType = GetPropertyId( PropertyName );
297 switch ( nPropType )
299 case BASEPROPERTY_GRAPHIC:
300 aProp <<= maImage.GetXGraphic();
301 break;
302 case BASEPROPERTY_IMAGEALIGN:
304 WindowType eType = GetWindow()->GetType();
305 if ( ( eType == WINDOW_PUSHBUTTON )
306 || ( eType == WINDOW_RADIOBUTTON )
307 || ( eType == WINDOW_CHECKBOX )
310 aProp <<= ::toolkit::getCompatibleImageAlign( static_cast< Button* >( GetWindow() )->GetImageAlign() );
313 break;
314 case BASEPROPERTY_IMAGEPOSITION:
316 WindowType eType = GetWindow()->GetType();
317 if ( ( eType == WINDOW_PUSHBUTTON )
318 || ( eType == WINDOW_RADIOBUTTON )
319 || ( eType == WINDOW_CHECKBOX )
322 aProp <<= ::toolkit::translateImagePosition( static_cast< Button* >( GetWindow() )->GetImageAlign() );
325 break;
326 default:
328 aProp <<= VCLXWindow::getProperty( PropertyName );
330 break;
332 return aProp;
336 // class VCLXButton
339 void VCLXButton::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
341 PushPropertyIds( rIds,
342 BASEPROPERTY_BACKGROUNDCOLOR,
343 BASEPROPERTY_DEFAULTBUTTON,
344 BASEPROPERTY_DEFAULTCONTROL,
345 BASEPROPERTY_ENABLED,
346 BASEPROPERTY_ENABLEVISIBLE,
347 BASEPROPERTY_FONTDESCRIPTOR,
348 BASEPROPERTY_GRAPHIC,
349 BASEPROPERTY_HELPTEXT,
350 BASEPROPERTY_HELPURL,
351 BASEPROPERTY_IMAGEALIGN,
352 BASEPROPERTY_IMAGEPOSITION,
353 BASEPROPERTY_IMAGEURL,
354 BASEPROPERTY_LABEL,
355 BASEPROPERTY_PRINTABLE,
356 BASEPROPERTY_PUSHBUTTONTYPE,
357 BASEPROPERTY_REPEAT,
358 BASEPROPERTY_REPEAT_DELAY,
359 BASEPROPERTY_STATE,
360 BASEPROPERTY_TABSTOP,
361 BASEPROPERTY_TOGGLE,
362 BASEPROPERTY_FOCUSONCLICK,
363 BASEPROPERTY_MULTILINE,
364 BASEPROPERTY_ALIGN,
365 BASEPROPERTY_VERTICALALIGN,
366 BASEPROPERTY_WRITING_MODE,
367 BASEPROPERTY_CONTEXT_WRITING_MODE,
368 BASEPROPERTY_REFERENCE_DEVICE,
370 VCLXGraphicControl::ImplGetPropertyIds( rIds );
373 VCLXButton::VCLXButton()
374 :maActionListeners( *this )
375 ,maItemListeners( *this )
379 VCLXButton::~VCLXButton()
383 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXButton::CreateAccessibleContext()
385 return getAccessibleFactory().createAccessibleContext( this );
388 void VCLXButton::dispose() throw(::com::sun::star::uno::RuntimeException, std::exception)
390 SolarMutexGuard aGuard;
392 ::com::sun::star::lang::EventObject aObj;
393 aObj.Source = (::cppu::OWeakObject*)this;
394 maActionListeners.disposeAndClear( aObj );
395 maItemListeners.disposeAndClear( aObj );
396 VCLXGraphicControl::dispose();
399 void VCLXButton::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )throw(::com::sun::star::uno::RuntimeException, std::exception)
401 SolarMutexGuard aGuard;
402 maActionListeners.addInterface( l );
405 void VCLXButton::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
407 SolarMutexGuard aGuard;
408 maActionListeners.removeInterface( l );
411 void VCLXButton::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l )throw(::com::sun::star::uno::RuntimeException, std::exception)
413 SolarMutexGuard aGuard;
414 maItemListeners.addInterface( l );
417 void VCLXButton::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
419 SolarMutexGuard aGuard;
420 maItemListeners.removeInterface( l );
423 void VCLXButton::setLabel( const OUString& rLabel ) throw(::com::sun::star::uno::RuntimeException, std::exception)
425 SolarMutexGuard aGuard;
427 vcl::Window* pWindow = GetWindow();
428 if ( pWindow )
429 pWindow->SetText( rLabel );
432 void VCLXButton::setActionCommand( const OUString& rCommand ) throw(::com::sun::star::uno::RuntimeException, std::exception)
434 SolarMutexGuard aGuard;
436 maActionCommand = rCommand;
439 ::com::sun::star::awt::Size VCLXButton::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
441 SolarMutexGuard aGuard;
443 Size aSz;
444 PushButton* pButton = static_cast<PushButton*>(GetWindow());
445 if ( pButton )
446 aSz = pButton->CalcMinimumSize();
447 return AWTSize(aSz);
450 ::com::sun::star::awt::Size VCLXButton::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
452 ::com::sun::star::awt::Size aSz = getMinimumSize();
453 aSz.Width += 16;
454 aSz.Height += 10;
455 return aSz;
458 ::com::sun::star::awt::Size VCLXButton::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException, std::exception)
460 SolarMutexGuard aGuard;
462 Size aSz = VCLSize(rNewSize);
463 PushButton* pButton = static_cast<PushButton*>( GetWindow() );
464 if ( pButton )
466 Size aMinSz = pButton->CalcMinimumSize();
467 // no text, thus image
468 if ( pButton->GetText().isEmpty() )
470 if ( aSz.Width() < aMinSz.Width() )
471 aSz.Width() = aMinSz.Width();
472 if ( aSz.Height() < aMinSz.Height() )
473 aSz.Height() = aMinSz.Height();
475 else
477 if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
478 aSz.Height() = aMinSz.Height();
479 else
480 aSz = aMinSz;
483 return AWTSize(aSz);
486 void VCLXButton::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
488 SolarMutexGuard aGuard;
490 Button* pButton = static_cast<Button*>(GetWindow());
491 if ( pButton )
493 sal_uInt16 nPropType = GetPropertyId( PropertyName );
494 switch ( nPropType )
496 case BASEPROPERTY_FOCUSONCLICK:
497 ::toolkit::adjustBooleanWindowStyle( Value, pButton, WB_NOPOINTERFOCUS, true );
498 break;
500 case BASEPROPERTY_TOGGLE:
501 ::toolkit::adjustBooleanWindowStyle( Value, pButton, WB_TOGGLE, false );
502 break;
504 case BASEPROPERTY_DEFAULTBUTTON:
506 WinBits nStyle = pButton->GetStyle() | WB_DEFBUTTON;
507 bool b = bool();
508 if ( ( Value >>= b ) && !b )
509 nStyle &= ~WB_DEFBUTTON;
510 pButton->SetStyle( nStyle );
512 break;
513 case BASEPROPERTY_STATE:
515 if ( GetWindow()->GetType() == WINDOW_PUSHBUTTON )
517 sal_Int16 n = sal_Int16();
518 if ( Value >>= n )
519 static_cast<PushButton*>(pButton)->SetState( (TriState)n );
522 break;
523 default:
525 VCLXGraphicControl::setProperty( PropertyName, Value );
531 ::com::sun::star::uno::Any VCLXButton::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
533 SolarMutexGuard aGuard;
535 ::com::sun::star::uno::Any aProp;
536 Button* pButton = static_cast<Button*>(GetWindow());
537 if ( pButton )
539 sal_uInt16 nPropType = GetPropertyId( PropertyName );
540 switch ( nPropType )
542 case BASEPROPERTY_FOCUSONCLICK:
543 aProp <<= ( ( pButton->GetStyle() & WB_NOPOINTERFOCUS ) == 0 );
544 break;
546 case BASEPROPERTY_TOGGLE:
547 aProp <<= ( ( pButton->GetStyle() & WB_TOGGLE ) != 0 );
548 break;
550 case BASEPROPERTY_DEFAULTBUTTON:
552 aProp <<= ( pButton->GetStyle() & WB_DEFBUTTON ) != 0;
554 break;
555 case BASEPROPERTY_STATE:
557 if ( GetWindow()->GetType() == WINDOW_PUSHBUTTON )
559 aProp <<= (sal_Int16)static_cast<PushButton*>(pButton)->GetState();
562 break;
563 default:
565 aProp <<= VCLXGraphicControl::getProperty( PropertyName );
569 return aProp;
572 void VCLXButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
574 switch ( rVclWindowEvent.GetId() )
576 case VCLEVENT_BUTTON_CLICK:
578 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
579 // since we call listeners below, there is a potential that we will be destroyed
580 // during the listener call. To prevent the resulting crashs, we keep us
581 // alive as long as we're here
583 if ( maActionListeners.getLength() )
585 ::com::sun::star::awt::ActionEvent aEvent;
586 aEvent.Source = (::cppu::OWeakObject*)this;
587 aEvent.ActionCommand = maActionCommand;
589 Callback aCallback = ::boost::bind(
590 &ActionListenerMultiplexer::actionPerformed,
591 &maActionListeners,
592 aEvent
594 ImplExecuteAsyncWithoutSolarLock( aCallback );
597 break;
599 case VCLEVENT_PUSHBUTTON_TOGGLE:
601 PushButton& rButton = dynamic_cast< PushButton& >( *rVclWindowEvent.GetWindow() );
603 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
604 if ( maItemListeners.getLength() )
606 ::com::sun::star::awt::ItemEvent aEvent;
607 aEvent.Source = (::cppu::OWeakObject*)this;
608 aEvent.Selected = ( rButton.GetState() == TRISTATE_TRUE ) ? 1 : 0;
609 maItemListeners.itemStateChanged( aEvent );
612 break;
614 default:
615 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent );
616 break;
621 // class VCLXImageControl
624 void VCLXImageControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
626 PushPropertyIds( rIds,
627 BASEPROPERTY_BACKGROUNDCOLOR,
628 BASEPROPERTY_BORDER,
629 BASEPROPERTY_BORDERCOLOR,
630 BASEPROPERTY_DEFAULTCONTROL,
631 BASEPROPERTY_ENABLED,
632 BASEPROPERTY_ENABLEVISIBLE,
633 BASEPROPERTY_GRAPHIC,
634 BASEPROPERTY_HELPTEXT,
635 BASEPROPERTY_HELPURL,
636 BASEPROPERTY_IMAGEURL,
637 BASEPROPERTY_PRINTABLE,
638 BASEPROPERTY_SCALEIMAGE,
639 BASEPROPERTY_IMAGE_SCALE_MODE,
640 BASEPROPERTY_TABSTOP,
641 BASEPROPERTY_WRITING_MODE,
642 BASEPROPERTY_CONTEXT_WRITING_MODE,
644 VCLXGraphicControl::ImplGetPropertyIds( rIds );
647 VCLXImageControl::VCLXImageControl()
651 VCLXImageControl::~VCLXImageControl()
655 void VCLXImageControl::ImplSetNewImage()
657 OSL_PRECOND( GetWindow(), "VCLXImageControl::ImplSetNewImage: window is required to be not-NULL!" );
658 ImageControl* pControl = static_cast< ImageControl* >( GetWindow() );
659 pControl->SetImage( GetImage() );
662 ::com::sun::star::awt::Size VCLXImageControl::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
664 SolarMutexGuard aGuard;
666 Size aSz = GetImage().GetSizePixel();
667 aSz = ImplCalcWindowSize( aSz );
669 return AWTSize(aSz);
672 ::com::sun::star::awt::Size VCLXImageControl::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
674 return getMinimumSize();
677 ::com::sun::star::awt::Size VCLXImageControl::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException, std::exception)
679 SolarMutexGuard aGuard;
681 ::com::sun::star::awt::Size aSz = rNewSize;
682 ::com::sun::star::awt::Size aMinSz = getMinimumSize();
683 if ( aSz.Width < aMinSz.Width )
684 aSz.Width = aMinSz.Width;
685 if ( aSz.Height < aMinSz.Height )
686 aSz.Height = aMinSz.Height;
687 return aSz;
690 void VCLXImageControl::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
692 SolarMutexGuard aGuard;
694 ImageControl* pImageControl = static_cast<ImageControl*>(GetWindow());
696 sal_uInt16 nPropType = GetPropertyId( PropertyName );
697 switch ( nPropType )
699 case BASEPROPERTY_IMAGE_SCALE_MODE:
701 sal_Int16 nScaleMode( ImageScaleMode::ANISOTROPIC );
702 if ( pImageControl && ( Value >>= nScaleMode ) )
704 pImageControl->SetScaleMode( nScaleMode );
707 break;
709 case BASEPROPERTY_SCALEIMAGE:
711 // this is for compatibility only, nowadays, the ImageScaleMode property should be used
712 bool bScaleImage = false;
713 if ( pImageControl && ( Value >>= bScaleImage ) )
715 pImageControl->SetScaleMode( bScaleImage ? ImageScaleMode::ANISOTROPIC : ImageScaleMode::NONE );
718 break;
720 default:
721 VCLXGraphicControl::setProperty( PropertyName, Value );
722 break;
726 ::com::sun::star::uno::Any VCLXImageControl::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
728 SolarMutexGuard aGuard;
730 ::com::sun::star::uno::Any aProp;
731 ImageControl* pImageControl = static_cast<ImageControl*>(GetWindow());
732 sal_uInt16 nPropType = GetPropertyId( PropertyName );
734 switch ( nPropType )
736 case BASEPROPERTY_IMAGE_SCALE_MODE:
737 aProp <<= ( pImageControl ? pImageControl->GetScaleMode() : ImageScaleMode::ANISOTROPIC );
738 break;
740 case BASEPROPERTY_SCALEIMAGE:
741 aProp <<= ( pImageControl && pImageControl->GetScaleMode() != ImageScaleMode::NONE ) ? sal_True : sal_False;
742 break;
744 default:
745 aProp = VCLXGraphicControl::getProperty( PropertyName );
746 break;
748 return aProp;
752 // class VCLXCheckBox
756 void VCLXCheckBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
758 PushPropertyIds( rIds,
759 BASEPROPERTY_DEFAULTCONTROL,
760 BASEPROPERTY_ENABLED,
761 BASEPROPERTY_ENABLEVISIBLE,
762 BASEPROPERTY_FONTDESCRIPTOR,
763 BASEPROPERTY_GRAPHIC,
764 BASEPROPERTY_HELPTEXT,
765 BASEPROPERTY_HELPURL,
766 BASEPROPERTY_IMAGEPOSITION,
767 BASEPROPERTY_IMAGEURL,
768 BASEPROPERTY_LABEL,
769 BASEPROPERTY_PRINTABLE,
770 BASEPROPERTY_STATE,
771 BASEPROPERTY_TABSTOP,
772 BASEPROPERTY_TRISTATE,
773 BASEPROPERTY_VISUALEFFECT,
774 BASEPROPERTY_MULTILINE,
775 BASEPROPERTY_BACKGROUNDCOLOR,
776 BASEPROPERTY_ALIGN,
777 BASEPROPERTY_VERTICALALIGN,
778 BASEPROPERTY_WRITING_MODE,
779 BASEPROPERTY_CONTEXT_WRITING_MODE,
780 BASEPROPERTY_REFERENCE_DEVICE,
782 VCLXGraphicControl::ImplGetPropertyIds( rIds );
785 VCLXCheckBox::VCLXCheckBox() : maActionListeners( *this ), maItemListeners( *this )
789 // ::com::sun::star::uno::XInterface
790 ::com::sun::star::uno::Any VCLXCheckBox::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
792 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
793 (static_cast< ::com::sun::star::awt::XButton* >(this)),
794 (static_cast< ::com::sun::star::awt::XCheckBox* >(this)) );
795 return (aRet.hasValue() ? aRet : VCLXGraphicControl::queryInterface( rType ));
798 // ::com::sun::star::lang::XTypeProvider
799 IMPL_XTYPEPROVIDER_START( VCLXCheckBox )
800 cppu::UnoType<com::sun::star::awt::XButton>::get(),
801 cppu::UnoType<com::sun::star::awt::XCheckBox>::get(),
802 VCLXGraphicControl::getTypes()
803 IMPL_XTYPEPROVIDER_END
805 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXCheckBox::CreateAccessibleContext()
807 return getAccessibleFactory().createAccessibleContext( this );
810 void VCLXCheckBox::dispose() throw(::com::sun::star::uno::RuntimeException, std::exception)
812 SolarMutexGuard aGuard;
814 ::com::sun::star::lang::EventObject aObj;
815 aObj.Source = (::cppu::OWeakObject*)this;
816 maItemListeners.disposeAndClear( aObj );
817 VCLXGraphicControl::dispose();
820 void VCLXCheckBox::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
822 SolarMutexGuard aGuard;
823 maItemListeners.addInterface( l );
826 void VCLXCheckBox::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
828 SolarMutexGuard aGuard;
829 maItemListeners.removeInterface( l );
832 void VCLXCheckBox::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )throw(::com::sun::star::uno::RuntimeException, std::exception)
834 SolarMutexGuard aGuard;
835 maActionListeners.addInterface( l );
838 void VCLXCheckBox::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
840 SolarMutexGuard aGuard;
841 maActionListeners.removeInterface( l );
844 void VCLXCheckBox::setActionCommand( const OUString& rCommand ) throw(::com::sun::star::uno::RuntimeException, std::exception)
846 SolarMutexGuard aGuard;
847 maActionCommand = rCommand;
850 void VCLXCheckBox::setLabel( const OUString& rLabel ) throw(::com::sun::star::uno::RuntimeException, std::exception)
852 SolarMutexGuard aGuard;
854 vcl::Window* pWindow = GetWindow();
855 if ( pWindow )
856 pWindow->SetText( rLabel );
859 void VCLXCheckBox::setState( short n ) throw(::com::sun::star::uno::RuntimeException, std::exception)
861 SolarMutexGuard aGuard;
863 CheckBox* pCheckBox = static_cast<CheckBox*>(GetWindow());
864 if ( pCheckBox)
866 TriState eState;
867 switch ( n )
869 case 0: eState = TRISTATE_FALSE; break;
870 case 1: eState = TRISTATE_TRUE; break;
871 case 2: eState = TRISTATE_INDET; break;
872 default: eState = TRISTATE_FALSE;
874 pCheckBox->SetState( eState );
876 // #105198# call C++ click listeners (needed for accessibility)
877 // pCheckBox->GetClickHdl().Call( pCheckBox );
879 // #107218# Call same virtual methods and listeners like VCL would do after user interaction
880 SetSynthesizingVCLEvent( true );
881 pCheckBox->Toggle();
882 pCheckBox->Click();
883 SetSynthesizingVCLEvent( false );
887 short VCLXCheckBox::getState() throw(::com::sun::star::uno::RuntimeException, std::exception)
889 SolarMutexGuard aGuard;
891 short nState = -1;
892 CheckBox* pCheckBox = static_cast<CheckBox*>(GetWindow());
893 if ( pCheckBox )
895 switch ( pCheckBox->GetState() )
897 case TRISTATE_FALSE: nState = 0; break;
898 case TRISTATE_TRUE: nState = 1; break;
899 case TRISTATE_INDET: nState = 2; break;
900 default: OSL_FAIL( "VCLXCheckBox::getState(): unknown TriState!" );
904 return nState;
907 void VCLXCheckBox::enableTriState( sal_Bool b ) throw(::com::sun::star::uno::RuntimeException, std::exception)
909 SolarMutexGuard aGuard;
911 CheckBox* pCheckBox = static_cast<CheckBox*>(GetWindow());
912 if ( pCheckBox)
913 pCheckBox->EnableTriState( b );
916 ::com::sun::star::awt::Size VCLXCheckBox::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
918 SolarMutexGuard aGuard;
920 Size aSz;
921 CheckBox* pCheckBox = static_cast<CheckBox*>(GetWindow());
922 if ( pCheckBox )
923 aSz = pCheckBox->CalcMinimumSize();
924 return AWTSize(aSz);
927 ::com::sun::star::awt::Size VCLXCheckBox::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
929 return getMinimumSize();
932 ::com::sun::star::awt::Size VCLXCheckBox::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException, std::exception)
934 SolarMutexGuard aGuard;
936 Size aSz = VCLSize(rNewSize);
937 CheckBox* pCheckBox = static_cast<CheckBox*>(GetWindow());
938 if ( pCheckBox )
940 Size aMinSz = pCheckBox->CalcMinimumSize();
941 if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
942 aSz.Height() = aMinSz.Height();
943 else
944 aSz = aMinSz;
946 return AWTSize(aSz);
949 void VCLXCheckBox::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
951 SolarMutexGuard aGuard;
953 CheckBox* pCheckBox = static_cast<CheckBox*>(GetWindow());
954 if ( pCheckBox )
956 sal_uInt16 nPropType = GetPropertyId( PropertyName );
957 switch ( nPropType )
959 case BASEPROPERTY_VISUALEFFECT:
960 ::toolkit::setVisualEffect( Value, pCheckBox );
961 break;
963 case BASEPROPERTY_TRISTATE:
965 bool b = bool();
966 if ( Value >>= b )
967 pCheckBox->EnableTriState( b );
969 break;
970 case BASEPROPERTY_STATE:
972 sal_Int16 n = sal_Int16();
973 if ( Value >>= n )
974 setState( n );
976 break;
977 default:
979 VCLXGraphicControl::setProperty( PropertyName, Value );
985 ::com::sun::star::uno::Any VCLXCheckBox::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
987 SolarMutexGuard aGuard;
989 ::com::sun::star::uno::Any aProp;
990 CheckBox* pCheckBox = static_cast<CheckBox*>(GetWindow());
991 if ( pCheckBox )
993 sal_uInt16 nPropType = GetPropertyId( PropertyName );
994 switch ( nPropType )
996 case BASEPROPERTY_VISUALEFFECT:
997 aProp = ::toolkit::getVisualEffect( pCheckBox );
998 break;
999 case BASEPROPERTY_TRISTATE:
1000 aProp <<= pCheckBox->IsTriStateEnabled();
1001 break;
1002 case BASEPROPERTY_STATE:
1003 aProp <<= (sal_Int16)pCheckBox->GetState();
1004 break;
1005 default:
1007 aProp <<= VCLXGraphicControl::getProperty( PropertyName );
1011 return aProp;
1014 void VCLXCheckBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1016 switch ( rVclWindowEvent.GetId() )
1018 case VCLEVENT_CHECKBOX_TOGGLE:
1020 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
1021 // since we call listeners below, there is a potential that we will be destroyed
1022 // in during the listener call. To prevent the resulting crashs, we keep us
1023 // alive as long as we're here
1025 CheckBox* pCheckBox = static_cast<CheckBox*>(GetWindow());
1026 if ( pCheckBox )
1028 if ( maItemListeners.getLength() )
1030 ::com::sun::star::awt::ItemEvent aEvent;
1031 aEvent.Source = (::cppu::OWeakObject*)this;
1032 aEvent.Highlighted = sal_False;
1033 aEvent.Selected = pCheckBox->GetState();
1034 maItemListeners.itemStateChanged( aEvent );
1036 if ( !IsSynthesizingVCLEvent() && maActionListeners.getLength() )
1038 ::com::sun::star::awt::ActionEvent aEvent;
1039 aEvent.Source = (::cppu::OWeakObject*)this;
1040 aEvent.ActionCommand = maActionCommand;
1041 maActionListeners.actionPerformed( aEvent );
1045 break;
1047 default:
1048 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent );
1049 break;
1054 // class VCLXRadioButton
1056 void VCLXRadioButton::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1058 PushPropertyIds( rIds,
1059 BASEPROPERTY_DEFAULTCONTROL,
1060 BASEPROPERTY_ENABLED,
1061 BASEPROPERTY_ENABLEVISIBLE,
1062 BASEPROPERTY_FONTDESCRIPTOR,
1063 BASEPROPERTY_GRAPHIC,
1064 BASEPROPERTY_HELPTEXT,
1065 BASEPROPERTY_HELPURL,
1066 BASEPROPERTY_IMAGEPOSITION,
1067 BASEPROPERTY_IMAGEURL,
1068 BASEPROPERTY_LABEL,
1069 BASEPROPERTY_PRINTABLE,
1070 BASEPROPERTY_STATE,
1071 BASEPROPERTY_TABSTOP,
1072 BASEPROPERTY_VISUALEFFECT,
1073 BASEPROPERTY_MULTILINE,
1074 BASEPROPERTY_BACKGROUNDCOLOR,
1075 BASEPROPERTY_ALIGN,
1076 BASEPROPERTY_VERTICALALIGN,
1077 BASEPROPERTY_WRITING_MODE,
1078 BASEPROPERTY_CONTEXT_WRITING_MODE,
1079 BASEPROPERTY_REFERENCE_DEVICE,
1080 BASEPROPERTY_GROUPNAME,
1082 VCLXGraphicControl::ImplGetPropertyIds( rIds );
1086 VCLXRadioButton::VCLXRadioButton() : maItemListeners( *this ), maActionListeners( *this )
1090 // ::com::sun::star::uno::XInterface
1091 ::com::sun::star::uno::Any VCLXRadioButton::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1093 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
1094 (static_cast< ::com::sun::star::awt::XRadioButton* >(this)),
1095 (static_cast< ::com::sun::star::awt::XButton* >(this)) );
1096 return (aRet.hasValue() ? aRet : VCLXGraphicControl::queryInterface( rType ));
1099 // ::com::sun::star::lang::XTypeProvider
1100 IMPL_XTYPEPROVIDER_START( VCLXRadioButton )
1101 cppu::UnoType<com::sun::star::awt::XRadioButton>::get(),
1102 cppu::UnoType<com::sun::star::awt::XButton>::get(),
1103 VCLXGraphicControl::getTypes()
1104 IMPL_XTYPEPROVIDER_END
1106 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXRadioButton::CreateAccessibleContext()
1108 return getAccessibleFactory().createAccessibleContext( this );
1111 void VCLXRadioButton::dispose() throw(::com::sun::star::uno::RuntimeException, std::exception)
1113 SolarMutexGuard aGuard;
1115 ::com::sun::star::lang::EventObject aObj;
1116 aObj.Source = (::cppu::OWeakObject*)this;
1117 maItemListeners.disposeAndClear( aObj );
1118 VCLXGraphicControl::dispose();
1121 void VCLXRadioButton::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
1123 SolarMutexGuard aGuard;
1125 RadioButton* pButton = static_cast<RadioButton*>(GetWindow());
1126 if ( pButton )
1128 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1129 switch ( nPropType )
1131 case BASEPROPERTY_VISUALEFFECT:
1132 ::toolkit::setVisualEffect( Value, pButton );
1133 break;
1135 case BASEPROPERTY_STATE:
1137 sal_Int16 n = sal_Int16();
1138 if ( Value >>= n )
1140 bool b = n ? sal_True : sal_False;
1141 if ( pButton->IsRadioCheckEnabled() )
1142 pButton->Check( b );
1143 else
1144 pButton->SetState( b );
1147 break;
1148 case BASEPROPERTY_AUTOTOGGLE:
1150 bool b = bool();
1151 if ( Value >>= b )
1152 pButton->EnableRadioCheck( b );
1154 break;
1155 default:
1157 VCLXGraphicControl::setProperty( PropertyName, Value );
1163 ::com::sun::star::uno::Any VCLXRadioButton::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1165 SolarMutexGuard aGuard;
1167 ::com::sun::star::uno::Any aProp;
1168 RadioButton* pButton = static_cast<RadioButton*>(GetWindow());
1169 if ( pButton )
1171 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1172 switch ( nPropType )
1174 case BASEPROPERTY_VISUALEFFECT:
1175 aProp = ::toolkit::getVisualEffect( pButton );
1176 break;
1177 case BASEPROPERTY_STATE:
1178 aProp <<= (sal_Int16) ( pButton->IsChecked() ? 1 : 0 );
1179 break;
1180 case BASEPROPERTY_AUTOTOGGLE:
1181 aProp <<= pButton->IsRadioCheckEnabled();
1182 break;
1183 default:
1185 aProp <<= VCLXGraphicControl::getProperty( PropertyName );
1189 return aProp;
1192 void VCLXRadioButton::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1194 SolarMutexGuard aGuard;
1195 maItemListeners.addInterface( l );
1198 void VCLXRadioButton::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1200 SolarMutexGuard aGuard;
1201 maItemListeners.removeInterface( l );
1204 void VCLXRadioButton::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )throw(::com::sun::star::uno::RuntimeException, std::exception)
1206 SolarMutexGuard aGuard;
1207 maActionListeners.addInterface( l );
1210 void VCLXRadioButton::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1212 SolarMutexGuard aGuard;
1213 maActionListeners.removeInterface( l );
1216 void VCLXRadioButton::setLabel( const OUString& rLabel ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1218 SolarMutexGuard aGuard;
1220 vcl::Window* pWindow = GetWindow();
1221 if ( pWindow )
1222 pWindow->SetText( rLabel );
1225 void VCLXRadioButton::setActionCommand( const OUString& rCommand ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1227 SolarMutexGuard aGuard;
1228 maActionCommand = rCommand;
1231 void VCLXRadioButton::setState( sal_Bool b ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1233 SolarMutexGuard aGuard;
1235 RadioButton* pRadioButton = static_cast<RadioButton*>(GetWindow());
1236 if ( pRadioButton)
1238 pRadioButton->Check( b );
1239 // #102717# item listeners are called, but not C++ click listeners in StarOffice code => call click hdl
1240 // But this is needed in old code because Accessibility API uses it.
1241 // pRadioButton->GetClickHdl().Call( pRadioButton );
1243 // #107218# Call same virtual methods and listeners like VCL would do after user interaction
1244 SetSynthesizingVCLEvent( true );
1245 pRadioButton->Click();
1246 SetSynthesizingVCLEvent( false );
1250 sal_Bool VCLXRadioButton::getState() throw(::com::sun::star::uno::RuntimeException, std::exception)
1252 SolarMutexGuard aGuard;
1254 RadioButton* pRadioButton = static_cast<RadioButton*>(GetWindow());
1255 return pRadioButton ? pRadioButton->IsChecked() : sal_False;
1258 ::com::sun::star::awt::Size VCLXRadioButton::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1260 SolarMutexGuard aGuard;
1262 Size aSz;
1263 RadioButton* pRadioButton = static_cast<RadioButton*>(GetWindow());
1264 if ( pRadioButton )
1265 aSz = pRadioButton->CalcMinimumSize();
1266 return AWTSize(aSz);
1269 ::com::sun::star::awt::Size VCLXRadioButton::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1271 return getMinimumSize();
1274 ::com::sun::star::awt::Size VCLXRadioButton::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1276 SolarMutexGuard aGuard;
1278 Size aSz = VCLSize(rNewSize);
1279 RadioButton* pRadioButton = static_cast<RadioButton*>(GetWindow());
1280 if ( pRadioButton )
1282 Size aMinSz = pRadioButton->CalcMinimumSize();
1283 if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
1284 aSz.Height() = aMinSz.Height();
1285 else
1286 aSz = aMinSz;
1288 return AWTSize(aSz);
1291 void VCLXRadioButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1293 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
1294 // since we call listeners below, there is a potential that we will be destroyed
1295 // in during the listener call. To prevent the resulting crashs, we keep us
1296 // alive as long as we're here
1298 switch ( rVclWindowEvent.GetId() )
1300 case VCLEVENT_BUTTON_CLICK:
1301 if ( !IsSynthesizingVCLEvent() && maActionListeners.getLength() )
1303 ::com::sun::star::awt::ActionEvent aEvent;
1304 aEvent.Source = (::cppu::OWeakObject*)this;
1305 aEvent.ActionCommand = maActionCommand;
1306 maActionListeners.actionPerformed( aEvent );
1308 ImplClickedOrToggled( false );
1309 break;
1311 case VCLEVENT_RADIOBUTTON_TOGGLE:
1312 ImplClickedOrToggled( true );
1313 break;
1315 default:
1316 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent );
1317 break;
1321 void VCLXRadioButton::ImplClickedOrToggled( bool bToggled )
1323 // In the formulars, RadioChecked is not enabled, call itemStateChanged only for click
1324 // In the dialog editor, RadioChecked is enabled, call itemStateChanged only for bToggled
1325 RadioButton* pRadioButton = static_cast<RadioButton*>(GetWindow());
1326 if ( pRadioButton && ( pRadioButton->IsRadioCheckEnabled() == bToggled ) && ( bToggled || pRadioButton->IsStateChanged() ) && maItemListeners.getLength() )
1328 ::com::sun::star::awt::ItemEvent aEvent;
1329 aEvent.Source = (::cppu::OWeakObject*)this;
1330 aEvent.Highlighted = sal_False;
1331 aEvent.Selected = pRadioButton->IsChecked() ? 1 : 0;
1332 maItemListeners.itemStateChanged( aEvent );
1337 // class VCLXSpinField
1339 void VCLXSpinField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1341 PushPropertyIds( rIds,
1342 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
1343 0 );
1344 VCLXEdit::ImplGetPropertyIds( rIds );
1347 VCLXSpinField::VCLXSpinField() : maSpinListeners( *this )
1351 // ::com::sun::star::uno::XInterface
1352 ::com::sun::star::uno::Any VCLXSpinField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1354 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
1355 (static_cast< ::com::sun::star::awt::XSpinField* >(this)) );
1356 return (aRet.hasValue() ? aRet : VCLXEdit::queryInterface( rType ));
1359 // ::com::sun::star::lang::XTypeProvider
1360 IMPL_XTYPEPROVIDER_START( VCLXSpinField )
1361 cppu::UnoType<com::sun::star::awt::XSpinField>::get(),
1362 VCLXEdit::getTypes()
1363 IMPL_XTYPEPROVIDER_END
1365 void VCLXSpinField::addSpinListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1367 SolarMutexGuard aGuard;
1368 maSpinListeners.addInterface( l );
1371 void VCLXSpinField::removeSpinListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1373 SolarMutexGuard aGuard;
1374 maSpinListeners.removeInterface( l );
1377 void VCLXSpinField::up() throw(::com::sun::star::uno::RuntimeException, std::exception)
1379 SolarMutexGuard aGuard;
1381 SpinField* pSpinField = static_cast<SpinField*>(GetWindow());
1382 if ( pSpinField )
1383 pSpinField->Up();
1386 void VCLXSpinField::down() throw(::com::sun::star::uno::RuntimeException, std::exception)
1388 SolarMutexGuard aGuard;
1390 SpinField* pSpinField = static_cast<SpinField*>(GetWindow());
1391 if ( pSpinField )
1392 pSpinField->Down();
1395 void VCLXSpinField::first() throw(::com::sun::star::uno::RuntimeException, std::exception)
1397 SolarMutexGuard aGuard;
1399 SpinField* pSpinField = static_cast<SpinField*>(GetWindow());
1400 if ( pSpinField )
1401 pSpinField->First();
1404 void VCLXSpinField::last() throw(::com::sun::star::uno::RuntimeException, std::exception)
1406 SolarMutexGuard aGuard;
1408 SpinField* pSpinField = static_cast<SpinField*>(GetWindow());
1409 if ( pSpinField )
1410 pSpinField->Last();
1413 void VCLXSpinField::enableRepeat( sal_Bool bRepeat ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1415 SolarMutexGuard aGuard;
1417 vcl::Window* pWindow = GetWindow();
1418 if ( pWindow )
1420 WinBits nStyle = pWindow->GetStyle();
1421 if ( bRepeat )
1422 nStyle |= WB_REPEAT;
1423 else
1424 nStyle &= ~WB_REPEAT;
1425 pWindow->SetStyle( nStyle );
1429 void VCLXSpinField::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1431 switch ( rVclWindowEvent.GetId() )
1433 case VCLEVENT_SPINFIELD_UP:
1434 case VCLEVENT_SPINFIELD_DOWN:
1435 case VCLEVENT_SPINFIELD_FIRST:
1436 case VCLEVENT_SPINFIELD_LAST:
1438 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
1439 // since we call listeners below, there is a potential that we will be destroyed
1440 // in during the listener call. To prevent the resulting crashs, we keep us
1441 // alive as long as we're here
1443 if ( maSpinListeners.getLength() )
1445 ::com::sun::star::awt::SpinEvent aEvent;
1446 aEvent.Source = (::cppu::OWeakObject*)this;
1447 switch ( rVclWindowEvent.GetId() )
1449 case VCLEVENT_SPINFIELD_UP: maSpinListeners.up( aEvent );
1450 break;
1451 case VCLEVENT_SPINFIELD_DOWN: maSpinListeners.down( aEvent );
1452 break;
1453 case VCLEVENT_SPINFIELD_FIRST: maSpinListeners.first( aEvent );
1454 break;
1455 case VCLEVENT_SPINFIELD_LAST: maSpinListeners.last( aEvent );
1456 break;
1461 break;
1463 default:
1464 VCLXEdit::ProcessWindowEvent( rVclWindowEvent );
1465 break;
1471 // class VCLXListBox
1473 void VCLXListBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1475 PushPropertyIds( rIds,
1476 BASEPROPERTY_BACKGROUNDCOLOR,
1477 BASEPROPERTY_BORDER,
1478 BASEPROPERTY_BORDERCOLOR,
1479 BASEPROPERTY_DEFAULTCONTROL,
1480 BASEPROPERTY_DROPDOWN,
1481 BASEPROPERTY_ENABLED,
1482 BASEPROPERTY_ENABLEVISIBLE,
1483 BASEPROPERTY_FONTDESCRIPTOR,
1484 BASEPROPERTY_HELPTEXT,
1485 BASEPROPERTY_HELPURL,
1486 BASEPROPERTY_LINECOUNT,
1487 BASEPROPERTY_MULTISELECTION,
1488 BASEPROPERTY_MULTISELECTION_SIMPLEMODE,
1489 BASEPROPERTY_ITEM_SEPARATOR_POS,
1490 BASEPROPERTY_PRINTABLE,
1491 BASEPROPERTY_SELECTEDITEMS,
1492 BASEPROPERTY_STRINGITEMLIST,
1493 BASEPROPERTY_TABSTOP,
1494 BASEPROPERTY_READONLY,
1495 BASEPROPERTY_ALIGN,
1496 BASEPROPERTY_WRITING_MODE,
1497 BASEPROPERTY_CONTEXT_WRITING_MODE,
1498 BASEPROPERTY_REFERENCE_DEVICE,
1499 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
1501 VCLXWindow::ImplGetPropertyIds( rIds );
1505 VCLXListBox::VCLXListBox()
1506 : maActionListeners( *this ),
1507 maItemListeners( *this )
1511 void VCLXListBox::dispose() throw(::com::sun::star::uno::RuntimeException, std::exception)
1513 SolarMutexGuard aGuard;
1515 ::com::sun::star::lang::EventObject aObj;
1516 aObj.Source = (::cppu::OWeakObject*)this;
1517 maItemListeners.disposeAndClear( aObj );
1518 maActionListeners.disposeAndClear( aObj );
1519 VCLXWindow::dispose();
1522 void VCLXListBox::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1524 SolarMutexGuard aGuard;
1525 maItemListeners.addInterface( l );
1528 void VCLXListBox::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1530 SolarMutexGuard aGuard;
1531 maItemListeners.removeInterface( l );
1534 void VCLXListBox::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1536 SolarMutexGuard aGuard;
1537 maActionListeners.addInterface( l );
1540 void VCLXListBox::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1542 SolarMutexGuard aGuard;
1543 maActionListeners.removeInterface( l );
1546 void VCLXListBox::addItem( const OUString& aItem, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1548 SolarMutexGuard aGuard;
1550 ListBox* pBox = static_cast<ListBox*>(GetWindow());
1551 if ( pBox )
1552 pBox->InsertEntry( aItem, nPos );
1555 void VCLXListBox::addItems( const ::com::sun::star::uno::Sequence< OUString>& aItems, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1557 SolarMutexGuard aGuard;
1559 ListBox* pBox = static_cast<ListBox*>(GetWindow());
1560 if ( pBox )
1562 sal_uInt16 nP = nPos;
1563 const OUString* pItems = aItems.getConstArray();
1564 const OUString* pItemsEnd = aItems.getConstArray() + aItems.getLength();
1565 while ( pItems != pItemsEnd )
1567 if ( (sal_uInt16)nP == 0xFFFF )
1569 OSL_FAIL( "VCLXListBox::addItems: too many entries!" );
1570 // skip remaining entries, list cannot hold them, anyway
1571 break;
1574 pBox->InsertEntry( *pItems++, nP++ );
1579 void VCLXListBox::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1581 SolarMutexGuard aGuard;
1583 ListBox* pBox = static_cast<ListBox*>(GetWindow());
1584 if ( pBox )
1586 for ( sal_uInt16 n = nCount; n; )
1587 pBox->RemoveEntry( nPos + (--n) );
1591 sal_Int16 VCLXListBox::getItemCount() throw(::com::sun::star::uno::RuntimeException, std::exception)
1593 SolarMutexGuard aGuard;
1595 ListBox* pBox = static_cast<ListBox*>(GetWindow());
1596 return pBox ? pBox->GetEntryCount() : 0;
1599 OUString VCLXListBox::getItem( sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1601 SolarMutexGuard aGuard;
1603 OUString aItem;
1604 ListBox* pBox = static_cast<ListBox*>(GetWindow());
1605 if ( pBox )
1606 aItem = pBox->GetEntry( nPos );
1607 return aItem;
1610 ::com::sun::star::uno::Sequence< OUString> VCLXListBox::getItems() throw(::com::sun::star::uno::RuntimeException, std::exception)
1612 SolarMutexGuard aGuard;
1614 ::com::sun::star::uno::Sequence< OUString> aSeq;
1615 ListBox* pBox = static_cast<ListBox*>(GetWindow());
1616 if ( pBox )
1618 sal_uInt16 nEntries = pBox->GetEntryCount();
1619 aSeq = ::com::sun::star::uno::Sequence< OUString>( nEntries );
1620 for ( sal_uInt16 n = nEntries; n; )
1622 --n;
1623 aSeq.getArray()[n] = OUString( pBox->GetEntry( n ) );
1626 return aSeq;
1629 sal_Int16 VCLXListBox::getSelectedItemPos() throw(::com::sun::star::uno::RuntimeException, std::exception)
1631 SolarMutexGuard aGuard;
1633 ListBox* pBox = static_cast<ListBox*>(GetWindow());
1634 return pBox ? pBox->GetSelectEntryPos() : 0;
1637 ::com::sun::star::uno::Sequence<sal_Int16> VCLXListBox::getSelectedItemsPos() throw(::com::sun::star::uno::RuntimeException, std::exception)
1639 SolarMutexGuard aGuard;
1641 ::com::sun::star::uno::Sequence<sal_Int16> aSeq;
1642 ListBox* pBox = static_cast<ListBox*>(GetWindow());
1643 if ( pBox )
1645 sal_uInt16 nSelEntries = pBox->GetSelectEntryCount();
1646 aSeq = ::com::sun::star::uno::Sequence<sal_Int16>( nSelEntries );
1647 for ( sal_uInt16 n = 0; n < nSelEntries; n++ )
1648 aSeq.getArray()[n] = pBox->GetSelectEntryPos( n );
1650 return aSeq;
1653 OUString VCLXListBox::getSelectedItem() throw(::com::sun::star::uno::RuntimeException, std::exception)
1655 SolarMutexGuard aGuard;
1657 OUString aItem;
1658 ListBox* pBox = static_cast<ListBox*>(GetWindow());
1659 if ( pBox )
1660 aItem = pBox->GetSelectEntry();
1661 return aItem;
1664 ::com::sun::star::uno::Sequence< OUString> VCLXListBox::getSelectedItems() throw(::com::sun::star::uno::RuntimeException, std::exception)
1666 SolarMutexGuard aGuard;
1668 ::com::sun::star::uno::Sequence< OUString> aSeq;
1669 ListBox* pBox = static_cast<ListBox*>(GetWindow());
1670 if ( pBox )
1672 sal_uInt16 nSelEntries = pBox->GetSelectEntryCount();
1673 aSeq = ::com::sun::star::uno::Sequence< OUString>( nSelEntries );
1674 for ( sal_uInt16 n = 0; n < nSelEntries; n++ )
1675 aSeq.getArray()[n] = OUString( pBox->GetSelectEntry( n ) );
1677 return aSeq;
1680 void VCLXListBox::selectItemPos( sal_Int16 nPos, sal_Bool bSelect ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1682 SolarMutexGuard aGuard;
1684 ListBox* pBox = static_cast<ListBox*>(GetWindow());
1685 if ( pBox && ( pBox->IsEntryPosSelected( nPos ) != bool(bSelect) ) )
1687 pBox->SelectEntryPos( nPos, bSelect );
1689 // VCL doesn't call select handler after API call.
1690 // ImplCallItemListeners();
1692 // #107218# Call same listeners like VCL would do after user interaction
1693 SetSynthesizingVCLEvent( true );
1694 pBox->Select();
1695 SetSynthesizingVCLEvent( false );
1699 void VCLXListBox::selectItemsPos( const ::com::sun::star::uno::Sequence<sal_Int16>& aPositions, sal_Bool bSelect ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1701 SolarMutexGuard aGuard;
1703 ListBox* pBox = static_cast<ListBox*>(GetWindow());
1704 if ( pBox )
1706 bool bChanged = false;
1707 for ( sal_uInt16 n = (sal_uInt16)aPositions.getLength(); n; )
1709 sal_uInt16 nPos = (sal_uInt16) aPositions.getConstArray()[--n];
1710 if ( pBox->IsEntryPosSelected( nPos ) != bool(bSelect) )
1712 pBox->SelectEntryPos( nPos, bSelect );
1713 bChanged = true;
1717 if ( bChanged )
1719 // VCL doesn't call select handler after API call.
1720 // ImplCallItemListeners();
1722 // #107218# Call same listeners like VCL would do after user interaction
1723 SetSynthesizingVCLEvent( true );
1724 pBox->Select();
1725 SetSynthesizingVCLEvent( false );
1730 void VCLXListBox::selectItem( const OUString& rItemText, sal_Bool bSelect ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1732 SolarMutexGuard aGuard;
1734 ListBox* pBox = static_cast<ListBox*>(GetWindow());
1735 if ( pBox )
1737 OUString aItemText( rItemText );
1738 selectItemPos( pBox->GetEntryPos( aItemText ), bSelect );
1743 void VCLXListBox::setDropDownLineCount( sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1745 SolarMutexGuard aGuard;
1747 ListBox* pBox = static_cast<ListBox*>(GetWindow());
1748 if ( pBox )
1749 pBox->SetDropDownLineCount( nLines );
1752 sal_Int16 VCLXListBox::getDropDownLineCount() throw(::com::sun::star::uno::RuntimeException, std::exception)
1754 SolarMutexGuard aGuard;
1756 sal_Int16 nLines = 0;
1757 ListBox* pBox = static_cast<ListBox*>(GetWindow());
1758 if ( pBox )
1759 nLines = pBox->GetDropDownLineCount();
1760 return nLines;
1763 sal_Bool VCLXListBox::isMutipleMode() throw(::com::sun::star::uno::RuntimeException, std::exception)
1765 SolarMutexGuard aGuard;
1767 bool bMulti = false;
1768 ListBox* pBox = static_cast<ListBox*>(GetWindow());
1769 if ( pBox )
1770 bMulti = pBox->IsMultiSelectionEnabled();
1771 return bMulti;
1774 void VCLXListBox::setMultipleMode( sal_Bool bMulti ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1776 SolarMutexGuard aGuard;
1778 ListBox* pBox = static_cast<ListBox*>(GetWindow());
1779 if ( pBox )
1780 pBox->EnableMultiSelection( bMulti );
1783 void VCLXListBox::makeVisible( sal_Int16 nEntry ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1785 SolarMutexGuard aGuard;
1787 ListBox* pBox = static_cast<ListBox*>(GetWindow());
1788 if ( pBox )
1789 pBox->SetTopEntry( nEntry );
1792 void VCLXListBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1794 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
1795 // since we call listeners below, there is a potential that we will be destroyed
1796 // in during the listener call. To prevent the resulting crashs, we keep us
1797 // alive as long as we're here
1799 switch ( rVclWindowEvent.GetId() )
1801 case VCLEVENT_LISTBOX_SELECT:
1803 ListBox* pListBox = static_cast<ListBox*>(GetWindow());
1805 if( pListBox )
1807 bool bDropDown = ( pListBox->GetStyle() & WB_DROPDOWN ) ? sal_True : sal_False;
1808 if ( bDropDown && !IsSynthesizingVCLEvent() && maActionListeners.getLength() )
1810 // Call ActionListener on DropDown event
1811 ::com::sun::star::awt::ActionEvent aEvent;
1812 aEvent.Source = (::cppu::OWeakObject*)this;
1813 aEvent.ActionCommand = pListBox->GetSelectEntry();
1814 maActionListeners.actionPerformed( aEvent );
1817 if ( maItemListeners.getLength() )
1819 ImplCallItemListeners();
1823 break;
1825 case VCLEVENT_LISTBOX_DOUBLECLICK:
1826 if ( GetWindow() && maActionListeners.getLength() )
1828 ::com::sun::star::awt::ActionEvent aEvent;
1829 aEvent.Source = (::cppu::OWeakObject*)this;
1830 aEvent.ActionCommand = static_cast<ListBox*>(GetWindow())->GetSelectEntry();
1831 maActionListeners.actionPerformed( aEvent );
1833 break;
1835 default:
1836 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
1837 break;
1841 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXListBox::CreateAccessibleContext()
1843 SolarMutexGuard aGuard;
1845 return getAccessibleFactory().createAccessibleContext( this );
1848 void VCLXListBox::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
1850 SolarMutexGuard aGuard;
1852 ListBox* pListBox = static_cast<ListBox*>(GetWindow());
1853 if ( pListBox )
1855 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1856 switch ( nPropType )
1858 case BASEPROPERTY_ITEM_SEPARATOR_POS:
1860 sal_Int16 nSeparatorPos(0);
1861 if ( Value >>= nSeparatorPos )
1862 pListBox->SetSeparatorPos( nSeparatorPos );
1864 break;
1865 case BASEPROPERTY_READONLY:
1867 bool b = bool();
1868 if ( Value >>= b )
1869 pListBox->SetReadOnly( b);
1871 break;
1872 case BASEPROPERTY_MULTISELECTION:
1874 bool b = bool();
1875 if ( Value >>= b )
1876 pListBox->EnableMultiSelection( b );
1878 break;
1879 case BASEPROPERTY_MULTISELECTION_SIMPLEMODE:
1880 ::toolkit::adjustBooleanWindowStyle( Value, pListBox, WB_SIMPLEMODE, false );
1881 break;
1882 case BASEPROPERTY_LINECOUNT:
1884 sal_Int16 n = sal_Int16();
1885 if ( Value >>= n )
1886 pListBox->SetDropDownLineCount( n );
1888 break;
1889 case BASEPROPERTY_STRINGITEMLIST:
1891 ::com::sun::star::uno::Sequence< OUString> aItems;
1892 if ( Value >>= aItems )
1894 pListBox->Clear();
1895 addItems( aItems, 0 );
1898 break;
1899 case BASEPROPERTY_SELECTEDITEMS:
1901 ::com::sun::star::uno::Sequence<sal_Int16> aItems;
1902 if ( Value >>= aItems )
1904 for ( sal_uInt16 n = pListBox->GetEntryCount(); n; )
1905 pListBox->SelectEntryPos( --n, false );
1907 if ( aItems.getLength() )
1908 selectItemsPos( aItems, sal_True );
1909 else
1910 pListBox->SetNoSelection();
1912 if ( !pListBox->GetSelectEntryCount() )
1913 pListBox->SetTopEntry( 0 );
1916 break;
1917 default:
1919 VCLXWindow::setProperty( PropertyName, Value );
1925 ::com::sun::star::uno::Any VCLXListBox::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1927 SolarMutexGuard aGuard;
1929 ::com::sun::star::uno::Any aProp;
1930 ListBox* pListBox = static_cast<ListBox*>(GetWindow());
1931 if ( pListBox )
1933 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1934 switch ( nPropType )
1936 case BASEPROPERTY_ITEM_SEPARATOR_POS:
1937 aProp <<= sal_Int16( pListBox->GetSeparatorPos() );
1938 break;
1939 case BASEPROPERTY_READONLY:
1941 aProp <<= pListBox->IsReadOnly();
1943 break;
1944 case BASEPROPERTY_MULTISELECTION:
1946 aProp <<= pListBox->IsMultiSelectionEnabled();
1948 break;
1949 case BASEPROPERTY_MULTISELECTION_SIMPLEMODE:
1951 aProp <<= ( ( pListBox->GetStyle() & WB_SIMPLEMODE ) == 0 );
1953 break;
1954 case BASEPROPERTY_LINECOUNT:
1956 aProp <<= (sal_Int16) pListBox->GetDropDownLineCount();
1958 break;
1959 case BASEPROPERTY_STRINGITEMLIST:
1961 sal_uInt16 nItems = pListBox->GetEntryCount();
1962 ::com::sun::star::uno::Sequence< OUString> aSeq( nItems );
1963 OUString* pStrings = aSeq.getArray();
1964 for ( sal_uInt16 n = 0; n < nItems; n++ )
1965 pStrings[n] = pListBox->GetEntry( n );
1966 aProp <<= aSeq;
1969 break;
1970 default:
1972 aProp <<= VCLXWindow::getProperty( PropertyName );
1976 return aProp;
1979 ::com::sun::star::awt::Size VCLXListBox::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1981 SolarMutexGuard aGuard;
1983 Size aSz;
1984 ListBox* pListBox = static_cast<ListBox*>(GetWindow());
1985 if ( pListBox )
1986 aSz = pListBox->CalcMinimumSize();
1987 return AWTSize(aSz);
1990 ::com::sun::star::awt::Size VCLXListBox::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1992 SolarMutexGuard aGuard;
1994 Size aSz;
1995 ListBox* pListBox = static_cast<ListBox*>(GetWindow());
1996 if ( pListBox )
1998 aSz = pListBox->CalcMinimumSize();
1999 if ( pListBox->GetStyle() & WB_DROPDOWN )
2000 aSz.Height() += 4;
2002 return AWTSize(aSz);
2005 ::com::sun::star::awt::Size VCLXListBox::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2007 SolarMutexGuard aGuard;
2009 Size aSz = VCLSize(rNewSize);
2010 ListBox* pListBox = static_cast<ListBox*>(GetWindow());
2011 if ( pListBox )
2012 aSz = pListBox->CalcAdjustedSize( aSz );
2013 return AWTSize(aSz);
2016 ::com::sun::star::awt::Size VCLXListBox::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2018 SolarMutexGuard aGuard;
2020 Size aSz;
2021 ListBox* pListBox = static_cast<ListBox*>(GetWindow());
2022 if ( pListBox )
2023 aSz = pListBox->CalcBlockSize( nCols, nLines );
2024 return AWTSize(aSz);
2027 void VCLXListBox::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2029 SolarMutexGuard aGuard;
2031 nCols = nLines = 0;
2032 ListBox* pListBox = static_cast<ListBox*>(GetWindow());
2033 if ( pListBox )
2035 sal_uInt16 nC, nL;
2036 pListBox->GetMaxVisColumnsAndLines( nC, nL );
2037 nCols = nC;
2038 nLines = nL;
2042 void VCLXListBox::ImplCallItemListeners()
2044 ListBox* pListBox = static_cast<ListBox*>(GetWindow());
2045 if ( pListBox && maItemListeners.getLength() )
2047 ::com::sun::star::awt::ItemEvent aEvent;
2048 aEvent.Source = (::cppu::OWeakObject*)this;
2049 aEvent.Highlighted = sal_False;
2051 // Set to 0xFFFF on multiple selection, selected entry ID otherwise
2052 aEvent.Selected = (pListBox->GetSelectEntryCount() == 1 ) ? pListBox->GetSelectEntryPos() : 0xFFFF;
2054 maItemListeners.itemStateChanged( aEvent );
2057 namespace
2059 Image lcl_getImageFromURL( const OUString& i_rImageURL )
2061 if ( i_rImageURL.isEmpty() )
2062 return Image();
2066 Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
2067 Reference< XGraphicProvider > xProvider(graphic::GraphicProvider::create(xContext));
2068 ::comphelper::NamedValueCollection aMediaProperties;
2069 aMediaProperties.put( "URL", i_rImageURL );
2070 Reference< XGraphic > xGraphic = xProvider->queryGraphic( aMediaProperties.getPropertyValues() );
2071 return Image( xGraphic );
2073 catch( const uno::Exception& )
2075 DBG_UNHANDLED_EXCEPTION();
2077 return Image();
2080 void SAL_CALL VCLXListBox::listItemInserted( const ItemListEvent& i_rEvent ) throw (RuntimeException, std::exception)
2082 SolarMutexGuard aGuard;
2084 ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() );
2086 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemInserted: no ListBox?!" );
2087 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition <= sal_Int32( pListBox->GetEntryCount() ) ),
2088 "VCLXListBox::listItemInserted: illegal (inconsistent) item position!" );
2089 pListBox->InsertEntry(
2090 i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : OUString(),
2091 i_rEvent.ItemImageURL.IsPresent ? TkResMgr::getImageFromURL( i_rEvent.ItemImageURL.Value ) : Image(),
2092 i_rEvent.ItemPosition );
2095 void SAL_CALL VCLXListBox::listItemRemoved( const ItemListEvent& i_rEvent ) throw (RuntimeException, std::exception)
2097 SolarMutexGuard aGuard;
2099 ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() );
2101 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemRemoved: no ListBox?!" );
2102 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pListBox->GetEntryCount() ) ),
2103 "VCLXListBox::listItemRemoved: illegal (inconsistent) item position!" );
2105 pListBox->RemoveEntry( i_rEvent.ItemPosition );
2108 void SAL_CALL VCLXListBox::listItemModified( const ItemListEvent& i_rEvent ) throw (RuntimeException, std::exception)
2110 SolarMutexGuard aGuard;
2112 ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() );
2114 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" );
2115 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pListBox->GetEntryCount() ) ),
2116 "VCLXListBox::listItemModified: illegal (inconsistent) item position!" );
2118 // VCL's ListBox does not support changing an entry's text or image, so remove and re-insert
2120 const OUString sNewText = i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : OUString( pListBox->GetEntry( i_rEvent.ItemPosition ) );
2121 const Image aNewImage( i_rEvent.ItemImageURL.IsPresent ? TkResMgr::getImageFromURL( i_rEvent.ItemImageURL.Value ) : pListBox->GetEntryImage( i_rEvent.ItemPosition ) );
2123 pListBox->RemoveEntry( i_rEvent.ItemPosition );
2124 pListBox->InsertEntry( sNewText, aNewImage, i_rEvent.ItemPosition );
2127 void SAL_CALL VCLXListBox::allItemsRemoved( const EventObject& i_rEvent ) throw (RuntimeException, std::exception)
2129 SolarMutexGuard aGuard;
2131 ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() );
2132 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" );
2134 pListBox->Clear();
2136 (void)i_rEvent;
2139 void SAL_CALL VCLXListBox::itemListChanged( const EventObject& i_rEvent ) throw (RuntimeException, std::exception)
2141 SolarMutexGuard aGuard;
2143 ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() );
2144 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" );
2146 pListBox->Clear();
2148 uno::Reference< beans::XPropertySet > xPropSet( i_rEvent.Source, uno::UNO_QUERY_THROW );
2149 uno::Reference< beans::XPropertySetInfo > xPSI( xPropSet->getPropertySetInfo(), uno::UNO_QUERY_THROW );
2150 uno::Reference< resource::XStringResourceResolver > xStringResourceResolver;
2151 if ( xPSI->hasPropertyByName("ResourceResolver") )
2153 xStringResourceResolver.set(
2154 xPropSet->getPropertyValue("ResourceResolver"),
2155 uno::UNO_QUERY
2160 Reference< XItemList > xItemList( i_rEvent.Source, uno::UNO_QUERY_THROW );
2161 uno::Sequence< beans::Pair< OUString, OUString > > aItems = xItemList->getAllItems();
2162 for ( sal_Int32 i=0; i<aItems.getLength(); ++i )
2164 OUString aLocalizationKey( aItems[i].First );
2165 if ( xStringResourceResolver.is() && aLocalizationKey.startsWith("&") )
2167 aLocalizationKey = xStringResourceResolver->resolveString(aLocalizationKey.copy( 1 ));
2169 pListBox->InsertEntry( aLocalizationKey, lcl_getImageFromURL( aItems[i].Second ) );
2173 void SAL_CALL VCLXListBox::disposing( const EventObject& i_rEvent ) throw (RuntimeException, std::exception)
2175 // just disambiguate
2176 VCLXWindow::disposing( i_rEvent );
2180 // class VCLXMessageBox
2183 void VCLXMessageBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2185 VCLXTopWindow::ImplGetPropertyIds( rIds );
2188 VCLXMessageBox::VCLXMessageBox()
2192 VCLXMessageBox::~VCLXMessageBox()
2196 // ::com::sun::star::uno::XInterface
2197 ::com::sun::star::uno::Any VCLXMessageBox::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2199 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
2200 (static_cast< ::com::sun::star::awt::XMessageBox* >(this)) );
2201 return (aRet.hasValue() ? aRet : VCLXTopWindow::queryInterface( rType ));
2204 // ::com::sun::star::lang::XTypeProvider
2205 IMPL_XTYPEPROVIDER_START( VCLXMessageBox )
2206 cppu::UnoType<com::sun::star::awt::XMessageBox>::get(),
2207 VCLXTopWindow::getTypes()
2208 IMPL_XTYPEPROVIDER_END
2210 void VCLXMessageBox::setCaptionText( const OUString& rText ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2212 SolarMutexGuard aGuard;
2214 vcl::Window* pWindow = GetWindow();
2215 if ( pWindow )
2216 pWindow->SetText( rText );
2219 OUString VCLXMessageBox::getCaptionText() throw(::com::sun::star::uno::RuntimeException, std::exception)
2221 SolarMutexGuard aGuard;
2223 OUString aText;
2224 vcl::Window* pWindow = GetWindow();
2225 if ( pWindow )
2226 aText = pWindow->GetText();
2227 return aText;
2230 void VCLXMessageBox::setMessageText( const OUString& rText ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2232 SolarMutexGuard aGuard;
2234 MessBox* pBox = static_cast<MessBox*>(GetWindow());
2235 if ( pBox )
2236 pBox->SetMessText( rText );
2239 OUString VCLXMessageBox::getMessageText() throw(::com::sun::star::uno::RuntimeException, std::exception)
2241 SolarMutexGuard aGuard;
2243 OUString aText;
2244 MessBox* pBox = static_cast<MessBox*>(GetWindow());
2245 if ( pBox )
2246 aText = pBox->GetMessText();
2247 return aText;
2250 sal_Int16 VCLXMessageBox::execute() throw(::com::sun::star::uno::RuntimeException, std::exception)
2252 SolarMutexGuard aGuard;
2254 MessBox* pBox = static_cast<MessBox*>(GetWindow());
2255 return pBox ? pBox->Execute() : 0;
2258 ::com::sun::star::awt::Size SAL_CALL VCLXMessageBox::getMinimumSize() throw(::com::sun::star::uno::RuntimeException, std::exception)
2260 SolarMutexGuard aGuard;
2261 return ::com::sun::star::awt::Size( 250, 100 );
2265 // class VCLXDialog
2267 void VCLXDialog::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2269 VCLXTopWindow::ImplGetPropertyIds( rIds );
2272 VCLXDialog::VCLXDialog()
2274 OSL_TRACE("XDialog created");
2277 VCLXDialog::~VCLXDialog()
2279 OSL_TRACE ("%s", __FUNCTION__);
2282 // ::com::sun::star::uno::XInterface
2283 ::com::sun::star::uno::Any VCLXDialog::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2285 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
2286 (static_cast< ::com::sun::star::awt::XDialog2* >(this)),
2287 (static_cast< ::com::sun::star::awt::XDialog* >(this)) );
2288 return (aRet.hasValue() ? aRet : VCLXTopWindow::queryInterface( rType ));
2291 // ::com::sun::star::lang::XTypeProvider
2292 IMPL_XTYPEPROVIDER_START( VCLXDialog )
2293 cppu::UnoType<com::sun::star::awt::XDialog2>::get(),
2294 cppu::UnoType<com::sun::star::awt::XDialog>::get(),
2295 VCLXTopWindow::getTypes()
2296 IMPL_XTYPEPROVIDER_END
2298 void SAL_CALL VCLXDialog::endDialog( ::sal_Int32 i_result ) throw (RuntimeException, std::exception)
2300 SolarMutexGuard aGuard;
2302 Dialog* pDialog = dynamic_cast< Dialog* >( GetWindow() );
2303 if ( pDialog )
2304 pDialog->EndDialog( i_result );
2307 void SAL_CALL VCLXDialog::setHelpId( const OUString& rId ) throw (RuntimeException, std::exception)
2309 SolarMutexGuard aGuard;
2311 vcl::Window* pWindow = GetWindow();
2312 if ( pWindow )
2313 pWindow->SetHelpId( OUStringToOString( rId, RTL_TEXTENCODING_UTF8 ) );
2316 void VCLXDialog::setTitle( const OUString& Title ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2318 SolarMutexGuard aGuard;
2320 vcl::Window* pWindow = GetWindow();
2321 if ( pWindow )
2322 pWindow->SetText( Title );
2325 OUString VCLXDialog::getTitle() throw(::com::sun::star::uno::RuntimeException, std::exception)
2327 SolarMutexGuard aGuard;
2329 OUString aTitle;
2330 vcl::Window* pWindow = GetWindow();
2331 if ( pWindow )
2332 aTitle = pWindow->GetText();
2333 return aTitle;
2336 sal_Int16 VCLXDialog::execute() throw(::com::sun::star::uno::RuntimeException, std::exception)
2338 SolarMutexGuard aGuard;
2340 sal_Int16 nRet = 0;
2341 if ( GetWindow() )
2343 Dialog* pDlg = static_cast<Dialog*>(GetWindow());
2344 vcl::Window* pParent = pDlg->GetWindow( WINDOW_PARENTOVERLAP );
2345 vcl::Window* pOldParent = NULL;
2346 vcl::Window* pSetParent = NULL;
2347 if ( pParent && !pParent->IsReallyVisible() )
2349 pOldParent = pDlg->GetParent();
2350 vcl::Window* pFrame = pDlg->GetWindow( WINDOW_FRAME );
2351 if( pFrame != pDlg )
2353 pDlg->SetParent( pFrame );
2354 pSetParent = pFrame;
2358 nRet = pDlg->Execute();
2360 // set the parent back only in case no new parent was set from outside
2361 // in other words, revert only own changes
2362 if ( pOldParent && pDlg->GetParent() == pSetParent )
2363 pDlg->SetParent( pOldParent );
2365 return nRet;
2368 void VCLXDialog::endExecute() throw(::com::sun::star::uno::RuntimeException, std::exception)
2370 endDialog(0);
2373 void SAL_CALL VCLXDialog::draw( sal_Int32 nX, sal_Int32 nY ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2375 SolarMutexGuard aGuard;
2376 vcl::Window* pWindow = GetWindow();
2378 if ( pWindow )
2380 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
2381 if ( !pDev )
2382 pDev = pWindow->GetParent();
2384 Size aSize = pDev->PixelToLogic( pWindow->GetSizePixel() );
2385 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
2387 pWindow->Draw( pDev, aPos, aSize, WINDOW_DRAW_NOCONTROLS );
2391 ::com::sun::star::awt::DeviceInfo VCLXDialog::getInfo() throw(::com::sun::star::uno::RuntimeException, std::exception)
2393 ::com::sun::star::awt::DeviceInfo aInfo = VCLXDevice::getInfo();
2395 SolarMutexGuard aGuard;
2396 Dialog* pDlg = static_cast<Dialog*>(GetWindow());
2397 if ( pDlg )
2398 pDlg->GetDrawWindowBorder( aInfo.LeftInset, aInfo.TopInset, aInfo.RightInset, aInfo.BottomInset );
2400 return aInfo;
2403 void SAL_CALL VCLXDialog::setProperty(
2404 const OUString& PropertyName,
2405 const ::com::sun::star::uno::Any& Value )
2406 throw(::com::sun::star::uno::RuntimeException, std::exception)
2408 SolarMutexGuard aGuard;
2410 Dialog* pDialog = static_cast<Dialog*>(GetWindow());
2411 if ( pDialog )
2413 bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
2415 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2416 switch ( nPropType )
2418 case BASEPROPERTY_GRAPHIC:
2420 Reference< XGraphic > xGraphic;
2421 if (( Value >>= xGraphic ) && xGraphic.is() )
2423 Image aImage( xGraphic );
2425 Wallpaper aWallpaper( aImage.GetBitmapEx());
2426 aWallpaper.SetStyle( WALLPAPER_SCALE );
2427 pDialog->SetBackground( aWallpaper );
2429 else if ( bVoid || !xGraphic.is() )
2431 Color aColor = pDialog->GetControlBackground().GetColor();
2432 if ( aColor == COL_AUTO )
2433 aColor = pDialog->GetSettings().GetStyleSettings().GetDialogColor();
2435 Wallpaper aWallpaper( aColor );
2436 pDialog->SetBackground( aWallpaper );
2439 break;
2441 default:
2443 VCLXContainer::setProperty( PropertyName, Value );
2451 // class VCLXTabPage
2453 VCLXMultiPage::VCLXMultiPage() : maTabListeners( *this ), mTabId( 1 )
2455 OSL_TRACE("VCLXMultiPage::VCLXMultiPage()" );
2458 void VCLXMultiPage::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2460 PushPropertyIds( rIds,
2461 BASEPROPERTY_BACKGROUNDCOLOR,
2462 BASEPROPERTY_DEFAULTCONTROL,
2463 BASEPROPERTY_ENABLED,
2464 BASEPROPERTY_MULTIPAGEVALUE,
2465 BASEPROPERTY_ENABLEVISIBLE,
2466 BASEPROPERTY_FONTDESCRIPTOR,
2467 BASEPROPERTY_GRAPHIC,
2468 BASEPROPERTY_HELPTEXT,
2469 BASEPROPERTY_HELPURL,
2470 BASEPROPERTY_IMAGEALIGN,
2471 BASEPROPERTY_IMAGEPOSITION,
2472 BASEPROPERTY_IMAGEURL,
2473 BASEPROPERTY_PRINTABLE,
2474 BASEPROPERTY_TABSTOP,
2475 BASEPROPERTY_FOCUSONCLICK,
2477 VCLXContainer::ImplGetPropertyIds( rIds );
2480 VCLXMultiPage::~VCLXMultiPage()
2483 void SAL_CALL VCLXMultiPage::dispose() throw(::com::sun::star::uno::RuntimeException, std::exception)
2485 SolarMutexGuard aGuard;
2487 ::com::sun::star::lang::EventObject aObj;
2488 aObj.Source = (::cppu::OWeakObject*)this;
2489 maTabListeners.disposeAndClear( aObj );
2490 VCLXContainer::dispose();
2492 ::com::sun::star::uno::Any SAL_CALL VCLXMultiPage::queryInterface(const ::com::sun::star::uno::Type & rType )
2493 throw(::com::sun::star::uno::RuntimeException, std::exception)
2495 uno::Any aRet = ::cppu::queryInterface( rType, static_cast< awt::XSimpleTabController*>( this ) );
2497 return ( aRet.hasValue() ? aRet : VCLXContainer::queryInterface( rType ) );
2500 // ::com::sun::star::lang::XTypeProvider
2501 IMPL_XTYPEPROVIDER_START( VCLXMultiPage )
2502 VCLXContainer::getTypes()
2503 IMPL_XTYPEPROVIDER_END
2505 // ::com::sun::star::awt::XView
2506 void SAL_CALL VCLXMultiPage::draw( sal_Int32 nX, sal_Int32 nY )
2507 throw(::com::sun::star::uno::RuntimeException, std::exception)
2509 SolarMutexGuard aGuard;
2510 vcl::Window* pWindow = GetWindow();
2512 if ( pWindow )
2514 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
2515 if ( !pDev )
2516 pDev = pWindow->GetParent();
2518 Size aSize = pDev->PixelToLogic( pWindow->GetSizePixel() );
2519 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
2521 pWindow->Draw( pDev, aPos, aSize, WINDOW_DRAW_NOCONTROLS );
2525 // ::com::sun::star::awt::XDevice,
2526 ::com::sun::star::awt::DeviceInfo SAL_CALL VCLXMultiPage::getInfo()
2527 throw(::com::sun::star::uno::RuntimeException, std::exception)
2529 ::com::sun::star::awt::DeviceInfo aInfo = VCLXDevice::getInfo();
2530 return aInfo;
2533 uno::Any SAL_CALL VCLXMultiPage::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2535 SolarMutexGuard aGuard;
2536 OSL_TRACE(" **** VCLXMultiPage::getProperty( %s )",
2537 OUStringToOString( PropertyName,
2538 RTL_TEXTENCODING_UTF8 ).getStr() );
2539 ::com::sun::star::uno::Any aProp;
2540 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2541 switch ( nPropType )
2544 case BASEPROPERTY_MULTIPAGEVALUE:
2546 aProp <<= getActiveTabID();
2548 break;
2549 default:
2550 aProp <<= VCLXContainer::getProperty( PropertyName );
2552 return aProp;
2555 void SAL_CALL VCLXMultiPage::setProperty(
2556 const OUString& PropertyName,
2557 const ::com::sun::star::uno::Any& Value )
2558 throw(::com::sun::star::uno::RuntimeException, std::exception)
2560 SolarMutexGuard aGuard;
2561 OSL_TRACE(" **** VCLXMultiPage::setProperty( %s )", OUStringToOString( PropertyName, RTL_TEXTENCODING_UTF8 ).getStr() );
2563 TabControl* pTabControl = static_cast<TabControl*>(GetWindow());
2564 if ( pTabControl )
2566 bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
2568 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2569 switch ( nPropType )
2571 case BASEPROPERTY_MULTIPAGEVALUE:
2573 OSL_TRACE("***MULTIPAGE VALUE");
2574 sal_Int32 nId(0);
2575 Value >>= nId;
2576 // when the multipage is created we attempt to set the activepage
2577 // but no pages created
2578 if ( nId && nId <= getWindows().getLength() )
2579 activateTab( nId );
2580 break;
2582 case BASEPROPERTY_GRAPHIC:
2584 Reference< XGraphic > xGraphic;
2585 if (( Value >>= xGraphic ) && xGraphic.is() )
2587 Image aImage( xGraphic );
2589 Wallpaper aWallpaper( aImage.GetBitmapEx());
2590 aWallpaper.SetStyle( WALLPAPER_SCALE );
2591 pTabControl->SetBackground( aWallpaper );
2593 else if ( bVoid || !xGraphic.is() )
2595 Color aColor = pTabControl->GetControlBackground().GetColor();
2596 if ( aColor == COL_AUTO )
2597 aColor = pTabControl->GetSettings().GetStyleSettings().GetDialogColor();
2599 Wallpaper aWallpaper( aColor );
2600 pTabControl->SetBackground( aWallpaper );
2603 break;
2605 default:
2607 VCLXContainer::setProperty( PropertyName, Value );
2613 TabControl *VCLXMultiPage::getTabControl() const throw (uno::RuntimeException)
2615 TabControl *pTabControl = dynamic_cast< TabControl* >( GetWindow() );
2616 if ( pTabControl )
2617 return pTabControl;
2618 throw uno::RuntimeException();
2620 sal_Int32 SAL_CALL VCLXMultiPage::insertTab() throw (uno::RuntimeException, std::exception)
2622 TabControl *pTabControl = getTabControl();
2623 TabPage* pTab = new TabPage( pTabControl );
2624 OUString title ("");
2625 return static_cast< sal_Int32 >( insertTab( pTab, title ) );
2628 sal_uInt16 VCLXMultiPage::insertTab( TabPage* pPage, OUString& sTitle )
2630 TabControl *pTabControl = getTabControl();
2631 sal_uInt16 id = sal::static_int_cast< sal_uInt16 >( mTabId++ );
2632 pTabControl->InsertPage( id, sTitle, TAB_APPEND );
2633 pTabControl->SetTabPage( id, pPage );
2634 return id;
2637 void SAL_CALL VCLXMultiPage::removeTab( sal_Int32 ID ) throw (uno::RuntimeException, lang::IndexOutOfBoundsException, std::exception)
2639 TabControl *pTabControl = getTabControl();
2640 if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == NULL )
2641 throw lang::IndexOutOfBoundsException();
2642 pTabControl->RemovePage( sal::static_int_cast< sal_uInt16 >( ID ) );
2645 void SAL_CALL VCLXMultiPage::activateTab( sal_Int32 ID ) throw (uno::RuntimeException, lang::IndexOutOfBoundsException, std::exception)
2647 TabControl *pTabControl = getTabControl();
2648 OSL_TRACE("Attempting to activate tab %d, active tab is %d, numtabs is %d", ID, getActiveTabID(), getWindows().getLength() );
2649 if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == NULL )
2650 throw lang::IndexOutOfBoundsException();
2651 pTabControl->SelectTabPage( sal::static_int_cast< sal_uInt16 >( ID ) );
2654 sal_Int32 SAL_CALL VCLXMultiPage::getActiveTabID() throw (uno::RuntimeException, std::exception)
2656 return getTabControl()->GetCurPageId( );
2659 void SAL_CALL VCLXMultiPage::addTabListener( const uno::Reference< awt::XTabListener >& xListener ) throw (uno::RuntimeException, std::exception)
2661 SolarMutexGuard aGuard;
2662 maTabListeners.addInterface( xListener );
2665 void SAL_CALL VCLXMultiPage::removeTabListener( const uno::Reference< awt::XTabListener >& xListener ) throw (uno::RuntimeException, std::exception)
2667 SolarMutexGuard aGuard;
2668 maTabListeners.addInterface( xListener );
2671 void SAL_CALL VCLXMultiPage::setTabProps( sal_Int32 ID, const uno::Sequence< beans::NamedValue >& Properties ) throw (uno::RuntimeException, lang::IndexOutOfBoundsException, std::exception)
2673 SolarMutexGuard aGuard;
2674 TabControl *pTabControl = getTabControl();
2675 if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == NULL )
2676 throw lang::IndexOutOfBoundsException();
2678 for (sal_Int32 i = 0; i < Properties.getLength(); ++i)
2680 const OUString &name = Properties[i].Name;
2681 const uno::Any &value = Properties[i].Value;
2683 if (name == "Title")
2685 OUString title = value.get<OUString>();
2686 pTabControl->SetPageText( sal::static_int_cast< sal_uInt16 >( ID ), title );
2691 uno::Sequence< beans::NamedValue > SAL_CALL VCLXMultiPage::getTabProps( sal_Int32 ID )
2692 throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
2694 SolarMutexGuard aGuard;
2695 TabControl *pTabControl = getTabControl();
2696 if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == NULL )
2697 throw lang::IndexOutOfBoundsException();
2699 #define ADD_PROP( seq, i, name, val ) { \
2700 beans::NamedValue value; \
2701 value.Name = OUString( name ); \
2702 value.Value = uno::makeAny( val ); \
2703 seq[i] = value; \
2706 uno::Sequence< beans::NamedValue > props( 2 );
2707 ADD_PROP( props, 0, "Title", OUString( pTabControl->GetPageText( sal::static_int_cast< sal_uInt16 >( ID ) ) ) );
2708 ADD_PROP( props, 1, "Position", pTabControl->GetPagePos( sal::static_int_cast< sal_uInt16 >( ID ) ) );
2709 #undef ADD_PROP
2710 return props;
2712 void VCLXMultiPage::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
2714 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
2715 switch ( rVclWindowEvent.GetId() )
2717 case VCLEVENT_TABPAGE_DEACTIVATE:
2719 sal_uLong nPageID = reinterpret_cast<sal_uLong>( rVclWindowEvent.GetData() );
2720 maTabListeners.deactivated( nPageID );
2721 break;
2724 case VCLEVENT_TABPAGE_ACTIVATE:
2726 sal_uLong nPageID = reinterpret_cast<sal_uLong>( rVclWindowEvent.GetData() );
2727 maTabListeners.activated( nPageID );
2728 break;
2730 default:
2731 VCLXContainer::ProcessWindowEvent( rVclWindowEvent );
2732 break;
2737 // class VCLXTabPage
2739 VCLXTabPage::VCLXTabPage()
2743 void VCLXTabPage::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2745 PushPropertyIds( rIds,
2746 BASEPROPERTY_BACKGROUNDCOLOR,
2747 BASEPROPERTY_DEFAULTCONTROL,
2748 BASEPROPERTY_ENABLED,
2749 BASEPROPERTY_ENABLEVISIBLE,
2750 BASEPROPERTY_FONTDESCRIPTOR,
2751 BASEPROPERTY_GRAPHIC,
2752 BASEPROPERTY_HELPTEXT,
2753 BASEPROPERTY_HELPURL,
2754 BASEPROPERTY_IMAGEALIGN,
2755 BASEPROPERTY_IMAGEPOSITION,
2756 BASEPROPERTY_IMAGEURL,
2757 BASEPROPERTY_PRINTABLE,
2758 BASEPROPERTY_TABSTOP,
2759 BASEPROPERTY_FOCUSONCLICK,
2761 VCLXContainer::ImplGetPropertyIds( rIds );
2764 VCLXTabPage::~VCLXTabPage()
2768 ::com::sun::star::uno::Any SAL_CALL VCLXTabPage::queryInterface(const ::com::sun::star::uno::Type & rType )
2769 throw(::com::sun::star::uno::RuntimeException, std::exception)
2771 return VCLXContainer::queryInterface( rType );
2774 // ::com::sun::star::lang::XTypeProvider
2775 IMPL_XTYPEPROVIDER_START( VCLXTabPage )
2776 VCLXContainer::getTypes()
2777 IMPL_XTYPEPROVIDER_END
2779 // ::com::sun::star::awt::XView
2780 void SAL_CALL VCLXTabPage::draw( sal_Int32 nX, sal_Int32 nY )
2781 throw(::com::sun::star::uno::RuntimeException, std::exception)
2783 SolarMutexGuard aGuard;
2784 vcl::Window* pWindow = GetWindow();
2786 if ( pWindow )
2788 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
2789 if ( !pDev )
2790 pDev = pWindow->GetParent();
2792 Size aSize = pDev->PixelToLogic( pWindow->GetSizePixel() );
2793 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
2795 pWindow->Draw( pDev, aPos, aSize, WINDOW_DRAW_NOCONTROLS );
2799 // ::com::sun::star::awt::XDevice,
2800 ::com::sun::star::awt::DeviceInfo SAL_CALL VCLXTabPage::getInfo()
2801 throw(::com::sun::star::uno::RuntimeException, std::exception)
2803 ::com::sun::star::awt::DeviceInfo aInfo = VCLXDevice::getInfo();
2804 return aInfo;
2807 void SAL_CALL VCLXTabPage::setProperty(
2808 const OUString& PropertyName,
2809 const ::com::sun::star::uno::Any& Value )
2810 throw(::com::sun::star::uno::RuntimeException, std::exception)
2812 SolarMutexGuard aGuard;
2814 TabPage* pTabPage = static_cast<TabPage*>(GetWindow());
2815 if ( pTabPage )
2817 bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
2819 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2820 switch ( nPropType )
2822 case BASEPROPERTY_GRAPHIC:
2824 Reference< XGraphic > xGraphic;
2825 if (( Value >>= xGraphic ) && xGraphic.is() )
2827 Image aImage( xGraphic );
2829 Wallpaper aWallpaper( aImage.GetBitmapEx());
2830 aWallpaper.SetStyle( WALLPAPER_SCALE );
2831 pTabPage->SetBackground( aWallpaper );
2833 else if ( bVoid || !xGraphic.is() )
2835 Color aColor = pTabPage->GetControlBackground().GetColor();
2836 if ( aColor == COL_AUTO )
2837 aColor = pTabPage->GetSettings().GetStyleSettings().GetDialogColor();
2839 Wallpaper aWallpaper( aColor );
2840 pTabPage->SetBackground( aWallpaper );
2843 break;
2844 case BASEPROPERTY_TITLE:
2846 OUString sTitle;
2847 if ( Value >>= sTitle )
2849 pTabPage->SetText(sTitle);
2852 break;
2854 default:
2856 VCLXContainer::setProperty( PropertyName, Value );
2862 TabPage *VCLXTabPage::getTabPage() const throw (uno::RuntimeException)
2864 TabPage *pTabPage = dynamic_cast< TabPage* >( GetWindow() );
2865 if ( pTabPage )
2866 return pTabPage;
2867 throw uno::RuntimeException();
2871 // class VCLXFixedHyperlink
2874 VCLXFixedHyperlink::VCLXFixedHyperlink() :
2876 maActionListeners( *this )
2881 VCLXFixedHyperlink::~VCLXFixedHyperlink()
2885 // ::com::sun::star::uno::XInterface
2886 ::com::sun::star::uno::Any VCLXFixedHyperlink::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2888 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
2889 (static_cast< ::com::sun::star::awt::XFixedHyperlink* >(this)) );
2890 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
2893 void VCLXFixedHyperlink::dispose() throw(::com::sun::star::uno::RuntimeException, std::exception)
2895 SolarMutexGuard aGuard;
2897 ::com::sun::star::lang::EventObject aObj;
2898 aObj.Source = (::cppu::OWeakObject*)this;
2899 maActionListeners.disposeAndClear( aObj );
2900 VCLXWindow::dispose();
2903 // ::com::sun::star::lang::XTypeProvider
2904 IMPL_XTYPEPROVIDER_START( VCLXFixedHyperlink )
2905 cppu::UnoType<com::sun::star::awt::XFixedHyperlink>::get(),
2906 VCLXWindow::getTypes()
2907 IMPL_XTYPEPROVIDER_END
2909 void VCLXFixedHyperlink::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
2911 switch ( rVclWindowEvent.GetId() )
2913 case VCLEVENT_BUTTON_CLICK:
2915 if ( maActionListeners.getLength() )
2917 ::com::sun::star::awt::ActionEvent aEvent;
2918 aEvent.Source = (::cppu::OWeakObject*)this;
2919 maActionListeners.actionPerformed( aEvent );
2921 else
2923 // open the URL
2924 OUString sURL;
2925 FixedHyperlink* pBase = static_cast<FixedHyperlink*>(GetWindow());
2926 if ( pBase )
2927 sURL = pBase->GetURL();
2928 Reference< ::com::sun::star::system::XSystemShellExecute > xSystemShellExecute( ::com::sun::star::system::SystemShellExecute::create(
2929 ::comphelper::getProcessComponentContext() ) );
2930 if ( !sURL.isEmpty() )
2934 // start browser
2935 xSystemShellExecute->execute(
2936 sURL, OUString(), ::com::sun::star::system::SystemShellExecuteFlags::URIS_ONLY );
2938 catch( uno::Exception& )
2944 //fall-through
2945 default:
2946 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
2947 break;
2951 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXFixedHyperlink::CreateAccessibleContext()
2953 return getAccessibleFactory().createAccessibleContext( this );
2956 void VCLXFixedHyperlink::setText( const OUString& Text ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2958 SolarMutexGuard aGuard;
2960 FixedHyperlink* pBase = static_cast<FixedHyperlink*>(GetWindow());
2961 if (pBase)
2962 pBase->SetText(Text);
2965 OUString VCLXFixedHyperlink::getText() throw(::com::sun::star::uno::RuntimeException, std::exception)
2967 SolarMutexGuard aGuard;
2969 OUString aText;
2970 vcl::Window* pWindow = GetWindow();
2971 if ( pWindow )
2972 aText = pWindow->GetText();
2973 return aText;
2976 void VCLXFixedHyperlink::setURL( const OUString& URL ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2978 SolarMutexGuard aGuard;
2980 FixedHyperlink* pBase = static_cast<FixedHyperlink*>(GetWindow());
2981 if ( pBase )
2982 pBase->SetURL( URL );
2985 OUString VCLXFixedHyperlink::getURL( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2987 SolarMutexGuard aGuard;
2989 OUString aText;
2990 FixedHyperlink* pBase = static_cast<FixedHyperlink*>(GetWindow());
2991 if ( pBase )
2992 aText = pBase->GetURL();
2993 return aText;
2996 void VCLXFixedHyperlink::setAlignment( short nAlign ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2998 SolarMutexGuard aGuard;
3000 vcl::Window* pWindow = GetWindow();
3001 if ( pWindow )
3003 WinBits nNewBits = 0;
3004 if ( nAlign == ::com::sun::star::awt::TextAlign::LEFT )
3005 nNewBits = WB_LEFT;
3006 else if ( nAlign == ::com::sun::star::awt::TextAlign::CENTER )
3007 nNewBits = WB_CENTER;
3008 else
3009 nNewBits = WB_RIGHT;
3011 WinBits nStyle = pWindow->GetStyle();
3012 nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT);
3013 pWindow->SetStyle( nStyle | nNewBits );
3017 short VCLXFixedHyperlink::getAlignment() throw(::com::sun::star::uno::RuntimeException, std::exception)
3019 SolarMutexGuard aGuard;
3021 short nAlign = 0;
3022 vcl::Window* pWindow = GetWindow();
3023 if ( pWindow )
3025 WinBits nStyle = pWindow->GetStyle();
3026 if ( nStyle & WB_LEFT )
3027 nAlign = ::com::sun::star::awt::TextAlign::LEFT;
3028 else if ( nStyle & WB_CENTER )
3029 nAlign = ::com::sun::star::awt::TextAlign::CENTER;
3030 else
3031 nAlign = ::com::sun::star::awt::TextAlign::RIGHT;
3033 return nAlign;
3036 void VCLXFixedHyperlink::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )throw(::com::sun::star::uno::RuntimeException, std::exception)
3038 SolarMutexGuard aGuard;
3039 maActionListeners.addInterface( l );
3042 void VCLXFixedHyperlink::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3044 SolarMutexGuard aGuard;
3045 maActionListeners.removeInterface( l );
3048 ::com::sun::star::awt::Size VCLXFixedHyperlink::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3050 SolarMutexGuard aGuard;
3052 Size aSz;
3053 FixedText* pFixedText = static_cast<FixedText*>(GetWindow());
3054 if ( pFixedText )
3055 aSz = pFixedText->CalcMinimumSize();
3056 return AWTSize(aSz);
3059 ::com::sun::star::awt::Size VCLXFixedHyperlink::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3061 return getMinimumSize();
3064 ::com::sun::star::awt::Size VCLXFixedHyperlink::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3066 SolarMutexGuard aGuard;
3068 ::com::sun::star::awt::Size aSz = rNewSize;
3069 ::com::sun::star::awt::Size aMinSz = getMinimumSize();
3070 if ( aSz.Height != aMinSz.Height )
3071 aSz.Height = aMinSz.Height;
3073 return aSz;
3076 void VCLXFixedHyperlink::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
3078 SolarMutexGuard aGuard;
3080 FixedHyperlink* pBase = static_cast<FixedHyperlink*>(GetWindow());
3081 if ( pBase )
3083 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3084 switch ( nPropType )
3086 case BASEPROPERTY_LABEL:
3088 OUString sNewLabel;
3089 if ( Value >>= sNewLabel )
3090 pBase->SetText(sNewLabel);
3091 break;
3094 case BASEPROPERTY_URL:
3096 OUString sNewURL;
3097 if ( Value >>= sNewURL )
3098 pBase->SetURL( sNewURL );
3099 break;
3102 default:
3104 VCLXWindow::setProperty( PropertyName, Value );
3110 ::com::sun::star::uno::Any VCLXFixedHyperlink::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3112 SolarMutexGuard aGuard;
3114 ::com::sun::star::uno::Any aProp;
3115 FixedHyperlink* pBase = static_cast<FixedHyperlink*>(GetWindow());
3116 if ( pBase )
3118 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3119 switch ( nPropType )
3121 case BASEPROPERTY_URL:
3123 aProp = makeAny( OUString( pBase->GetURL() ) );
3124 break;
3127 default:
3129 aProp <<= VCLXWindow::getProperty( PropertyName );
3133 return aProp;
3136 void VCLXFixedHyperlink::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
3138 PushPropertyIds( rIds,
3139 BASEPROPERTY_ALIGN,
3140 BASEPROPERTY_BACKGROUNDCOLOR,
3141 BASEPROPERTY_BORDER,
3142 BASEPROPERTY_BORDERCOLOR,
3143 BASEPROPERTY_DEFAULTCONTROL,
3144 BASEPROPERTY_ENABLED,
3145 BASEPROPERTY_ENABLEVISIBLE,
3146 BASEPROPERTY_FONTDESCRIPTOR,
3147 BASEPROPERTY_HELPTEXT,
3148 BASEPROPERTY_HELPURL,
3149 BASEPROPERTY_LABEL,
3150 BASEPROPERTY_MULTILINE,
3151 BASEPROPERTY_NOLABEL,
3152 BASEPROPERTY_PRINTABLE,
3153 BASEPROPERTY_TABSTOP,
3154 BASEPROPERTY_VERTICALALIGN,
3155 BASEPROPERTY_URL,
3156 BASEPROPERTY_WRITING_MODE,
3157 BASEPROPERTY_CONTEXT_WRITING_MODE,
3159 VCLXWindow::ImplGetPropertyIds( rIds );
3163 // class VCLXFixedText
3165 void VCLXFixedText::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
3167 PushPropertyIds( rIds,
3168 BASEPROPERTY_ALIGN,
3169 BASEPROPERTY_BACKGROUNDCOLOR,
3170 BASEPROPERTY_BORDER,
3171 BASEPROPERTY_BORDERCOLOR,
3172 BASEPROPERTY_DEFAULTCONTROL,
3173 BASEPROPERTY_ENABLED,
3174 BASEPROPERTY_ENABLEVISIBLE,
3175 BASEPROPERTY_FONTDESCRIPTOR,
3176 BASEPROPERTY_HELPTEXT,
3177 BASEPROPERTY_HELPURL,
3178 BASEPROPERTY_LABEL,
3179 BASEPROPERTY_MULTILINE,
3180 BASEPROPERTY_NOLABEL,
3181 BASEPROPERTY_PRINTABLE,
3182 BASEPROPERTY_TABSTOP,
3183 BASEPROPERTY_VERTICALALIGN,
3184 BASEPROPERTY_WRITING_MODE,
3185 BASEPROPERTY_CONTEXT_WRITING_MODE,
3186 BASEPROPERTY_REFERENCE_DEVICE,
3188 VCLXWindow::ImplGetPropertyIds( rIds );
3191 VCLXFixedText::VCLXFixedText()
3195 VCLXFixedText::~VCLXFixedText()
3199 // ::com::sun::star::uno::XInterface
3200 ::com::sun::star::uno::Any VCLXFixedText::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3202 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
3203 (static_cast< ::com::sun::star::awt::XFixedText* >(this)) );
3204 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
3207 // ::com::sun::star::lang::XTypeProvider
3208 IMPL_XTYPEPROVIDER_START( VCLXFixedText )
3209 cppu::UnoType<com::sun::star::awt::XFixedText>::get(),
3210 VCLXWindow::getTypes()
3211 IMPL_XTYPEPROVIDER_END
3213 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXFixedText::CreateAccessibleContext()
3215 return getAccessibleFactory().createAccessibleContext( this );
3218 void VCLXFixedText::setText( const OUString& Text ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3220 SolarMutexGuard aGuard;
3222 vcl::Window* pWindow = GetWindow();
3223 if ( pWindow )
3224 pWindow->SetText( Text );
3227 OUString VCLXFixedText::getText() throw(::com::sun::star::uno::RuntimeException, std::exception)
3229 SolarMutexGuard aGuard;
3231 OUString aText;
3232 vcl::Window* pWindow = GetWindow();
3233 if ( pWindow )
3234 aText = pWindow->GetText();
3235 return aText;
3238 void VCLXFixedText::setAlignment( short nAlign ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3240 SolarMutexGuard aGuard;
3242 vcl::Window* pWindow = GetWindow();
3243 if ( pWindow )
3245 WinBits nNewBits = 0;
3246 if ( nAlign == ::com::sun::star::awt::TextAlign::LEFT )
3247 nNewBits = WB_LEFT;
3248 else if ( nAlign == ::com::sun::star::awt::TextAlign::CENTER )
3249 nNewBits = WB_CENTER;
3250 else
3251 nNewBits = WB_RIGHT;
3253 WinBits nStyle = pWindow->GetStyle();
3254 nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT);
3255 pWindow->SetStyle( nStyle | nNewBits );
3259 short VCLXFixedText::getAlignment() throw(::com::sun::star::uno::RuntimeException, std::exception)
3261 SolarMutexGuard aGuard;
3263 short nAlign = 0;
3264 vcl::Window* pWindow = GetWindow();
3265 if ( pWindow )
3267 WinBits nStyle = pWindow->GetStyle();
3268 if ( nStyle & WB_LEFT )
3269 nAlign = ::com::sun::star::awt::TextAlign::LEFT;
3270 else if ( nStyle & WB_CENTER )
3271 nAlign = ::com::sun::star::awt::TextAlign::CENTER;
3272 else
3273 nAlign = ::com::sun::star::awt::TextAlign::RIGHT;
3275 return nAlign;
3278 ::com::sun::star::awt::Size VCLXFixedText::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3280 SolarMutexGuard aGuard;
3282 Size aSz;
3283 FixedText* pFixedText = static_cast<FixedText*>(GetWindow());
3284 if ( pFixedText )
3285 aSz = pFixedText->CalcMinimumSize();
3286 return AWTSize(aSz);
3289 ::com::sun::star::awt::Size VCLXFixedText::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3291 return getMinimumSize();
3294 ::com::sun::star::awt::Size VCLXFixedText::calcAdjustedSize( const ::com::sun::star::awt::Size& rMaxSize ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3296 SolarMutexGuard aGuard;
3298 Size aAdjustedSize( VCLUnoHelper::ConvertToVCLSize( rMaxSize ) );
3299 FixedText* pFixedText = static_cast<FixedText*>(GetWindow());
3300 if ( pFixedText )
3301 aAdjustedSize = pFixedText->CalcMinimumSize( rMaxSize.Width );
3302 return VCLUnoHelper::ConvertToAWTSize( aAdjustedSize );
3306 // class VCLXScrollBar
3308 void VCLXScrollBar::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
3310 PushPropertyIds( rIds,
3311 BASEPROPERTY_BACKGROUNDCOLOR,
3312 BASEPROPERTY_BLOCKINCREMENT,
3313 BASEPROPERTY_BORDER,
3314 BASEPROPERTY_BORDERCOLOR,
3315 BASEPROPERTY_DEFAULTCONTROL,
3316 BASEPROPERTY_ENABLED,
3317 BASEPROPERTY_ENABLEVISIBLE,
3318 BASEPROPERTY_HELPTEXT,
3319 BASEPROPERTY_HELPURL,
3320 BASEPROPERTY_LINEINCREMENT,
3321 BASEPROPERTY_LIVE_SCROLL,
3322 BASEPROPERTY_ORIENTATION,
3323 BASEPROPERTY_PRINTABLE,
3324 BASEPROPERTY_REPEAT_DELAY,
3325 BASEPROPERTY_SCROLLVALUE,
3326 BASEPROPERTY_SCROLLVALUE_MAX,
3327 BASEPROPERTY_SCROLLVALUE_MIN,
3328 BASEPROPERTY_SYMBOL_COLOR,
3329 BASEPROPERTY_TABSTOP,
3330 BASEPROPERTY_VISIBLESIZE,
3331 BASEPROPERTY_WRITING_MODE,
3332 BASEPROPERTY_CONTEXT_WRITING_MODE,
3334 VCLXWindow::ImplGetPropertyIds( rIds );
3337 VCLXScrollBar::VCLXScrollBar() : maAdjustmentListeners( *this )
3341 // ::com::sun::star::uno::XInterface
3342 ::com::sun::star::uno::Any VCLXScrollBar::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3344 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
3345 (static_cast< ::com::sun::star::awt::XScrollBar* >(this)) );
3346 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
3349 // ::com::sun::star::lang::XTypeProvider
3350 IMPL_XTYPEPROVIDER_START( VCLXScrollBar )
3351 cppu::UnoType<com::sun::star::awt::XScrollBar>::get(),
3352 VCLXWindow::getTypes()
3353 IMPL_XTYPEPROVIDER_END
3355 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXScrollBar::CreateAccessibleContext()
3357 return getAccessibleFactory().createAccessibleContext( this );
3360 // ::com::sun::star::lang::XComponent
3361 void VCLXScrollBar::dispose() throw(::com::sun::star::uno::RuntimeException, std::exception)
3363 SolarMutexGuard aGuard;
3365 ::com::sun::star::lang::EventObject aObj;
3366 aObj.Source = (::cppu::OWeakObject*)this;
3367 maAdjustmentListeners.disposeAndClear( aObj );
3368 VCLXWindow::dispose();
3371 // ::com::sun::star::awt::XScrollbar
3372 void VCLXScrollBar::addAdjustmentListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XAdjustmentListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3374 SolarMutexGuard aGuard;
3375 maAdjustmentListeners.addInterface( l );
3378 void VCLXScrollBar::removeAdjustmentListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XAdjustmentListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3380 SolarMutexGuard aGuard;
3381 maAdjustmentListeners.removeInterface( l );
3384 void VCLXScrollBar::setValue( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3386 SolarMutexGuard aGuard;
3388 ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow());
3389 if ( pScrollBar )
3390 pScrollBar->DoScroll( n );
3393 void VCLXScrollBar::setValues( sal_Int32 nValue, sal_Int32 nVisible, sal_Int32 nMax ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3395 SolarMutexGuard aGuard;
3397 ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow());
3398 if ( pScrollBar )
3400 pScrollBar->SetVisibleSize( nVisible );
3401 pScrollBar->SetRangeMax( nMax );
3402 pScrollBar->DoScroll( nValue );
3406 sal_Int32 VCLXScrollBar::getValue() throw(::com::sun::star::uno::RuntimeException, std::exception)
3408 SolarMutexGuard aGuard;
3410 ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow());
3411 return pScrollBar ? pScrollBar->GetThumbPos() : 0;
3414 void VCLXScrollBar::setMaximum( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3416 SolarMutexGuard aGuard;
3418 ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow());
3419 if ( pScrollBar )
3420 pScrollBar->SetRangeMax( n );
3423 sal_Int32 VCLXScrollBar::getMaximum() throw(::com::sun::star::uno::RuntimeException, std::exception)
3425 SolarMutexGuard aGuard;
3427 ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow());
3428 return pScrollBar ? pScrollBar->GetRangeMax() : 0;
3431 void VCLXScrollBar::setMinimum( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException)
3433 SolarMutexGuard aGuard;
3435 ScrollBar* pScrollBar = static_cast< ScrollBar* >( GetWindow() );
3436 if ( pScrollBar )
3437 pScrollBar->SetRangeMin( n );
3440 sal_Int32 VCLXScrollBar::getMinimum() throw(::com::sun::star::uno::RuntimeException)
3442 SolarMutexGuard aGuard;
3444 ScrollBar* pScrollBar = static_cast< ScrollBar* >( GetWindow() );
3445 return pScrollBar ? pScrollBar->GetRangeMin() : 0;
3448 void VCLXScrollBar::setLineIncrement( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3450 SolarMutexGuard aGuard;
3452 ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow());
3453 if ( pScrollBar )
3454 pScrollBar->SetLineSize( n );
3457 sal_Int32 VCLXScrollBar::getLineIncrement() throw(::com::sun::star::uno::RuntimeException, std::exception)
3459 SolarMutexGuard aGuard;
3461 ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow());
3462 return pScrollBar ? pScrollBar->GetLineSize() : 0;
3465 void VCLXScrollBar::setBlockIncrement( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3467 SolarMutexGuard aGuard;
3469 ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow());
3470 if ( pScrollBar )
3471 pScrollBar->SetPageSize( n );
3474 sal_Int32 VCLXScrollBar::getBlockIncrement() throw(::com::sun::star::uno::RuntimeException, std::exception)
3476 SolarMutexGuard aGuard;
3478 ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow());
3479 return pScrollBar ? pScrollBar->GetPageSize() : 0;
3482 void VCLXScrollBar::setVisibleSize( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3484 SolarMutexGuard aGuard;
3486 ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow());
3487 if ( pScrollBar )
3488 pScrollBar->SetVisibleSize( n );
3491 sal_Int32 VCLXScrollBar::getVisibleSize() throw(::com::sun::star::uno::RuntimeException, std::exception)
3493 SolarMutexGuard aGuard;
3495 ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow());
3496 return pScrollBar ? pScrollBar->GetVisibleSize() : 0;
3499 void VCLXScrollBar::setOrientation( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3501 SolarMutexGuard aGuard;
3503 vcl::Window* pWindow = GetWindow();
3504 if ( pWindow )
3506 WinBits nStyle = pWindow->GetStyle();
3507 nStyle &= ~(WB_HORZ|WB_VERT);
3508 if ( n == ::com::sun::star::awt::ScrollBarOrientation::HORIZONTAL )
3509 nStyle |= WB_HORZ;
3510 else
3511 nStyle |= WB_VERT;
3513 pWindow->SetStyle( nStyle );
3514 pWindow->Resize();
3518 sal_Int32 VCLXScrollBar::getOrientation() throw(::com::sun::star::uno::RuntimeException, std::exception)
3520 SolarMutexGuard aGuard;
3522 sal_Int32 n = 0;
3523 vcl::Window* pWindow = GetWindow();
3524 if ( pWindow )
3526 WinBits nStyle = pWindow->GetStyle();
3527 if ( nStyle & WB_HORZ )
3528 n = ::com::sun::star::awt::ScrollBarOrientation::HORIZONTAL;
3529 else
3530 n = ::com::sun::star::awt::ScrollBarOrientation::VERTICAL;
3532 return n;
3536 // ::com::sun::star::awt::VclWindowPeer
3537 void VCLXScrollBar::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
3539 SolarMutexGuard aGuard;
3541 ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow());
3542 if ( pScrollBar )
3544 bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
3546 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3547 switch ( nPropType )
3549 case BASEPROPERTY_LIVE_SCROLL:
3551 bool bDo = false;
3552 if ( !bVoid )
3554 OSL_VERIFY( Value >>= bDo );
3556 AllSettings aSettings( pScrollBar->GetSettings() );
3557 StyleSettings aStyle( aSettings.GetStyleSettings() );
3558 sal_uLong nDragOptions = aStyle.GetDragFullOptions();
3559 if ( bDo )
3560 nDragOptions |= DRAGFULL_OPTION_SCROLL;
3561 else
3562 nDragOptions &= ~DRAGFULL_OPTION_SCROLL;
3563 aStyle.SetDragFullOptions( nDragOptions );
3564 aSettings.SetStyleSettings( aStyle );
3565 pScrollBar->SetSettings( aSettings );
3567 break;
3569 case BASEPROPERTY_SCROLLVALUE:
3571 if ( !bVoid )
3573 sal_Int32 n = 0;
3574 if ( Value >>= n )
3575 setValue( n );
3578 break;
3579 case BASEPROPERTY_SCROLLVALUE_MAX:
3580 case BASEPROPERTY_SCROLLVALUE_MIN:
3582 if ( !bVoid )
3584 sal_Int32 n = 0;
3585 if ( Value >>= n )
3587 if ( nPropType == BASEPROPERTY_SCROLLVALUE_MAX )
3588 setMaximum( n );
3589 else
3590 setMinimum( n );
3594 break;
3595 case BASEPROPERTY_LINEINCREMENT:
3597 if ( !bVoid )
3599 sal_Int32 n = 0;
3600 if ( Value >>= n )
3601 setLineIncrement( n );
3604 break;
3605 case BASEPROPERTY_BLOCKINCREMENT:
3607 if ( !bVoid )
3609 sal_Int32 n = 0;
3610 if ( Value >>= n )
3611 setBlockIncrement( n );
3614 break;
3615 case BASEPROPERTY_VISIBLESIZE:
3617 if ( !bVoid )
3619 sal_Int32 n = 0;
3620 if ( Value >>= n )
3621 setVisibleSize( n );
3624 break;
3625 case BASEPROPERTY_ORIENTATION:
3627 if ( !bVoid )
3629 sal_Int32 n = 0;
3630 if ( Value >>= n )
3631 setOrientation( n );
3634 break;
3636 case BASEPROPERTY_BACKGROUNDCOLOR:
3638 // the default implementation of the base class doesn't work here, since our
3639 // interpretation for this property is slightly different
3640 ::toolkit::setButtonLikeFaceColor( pScrollBar, Value);
3642 break;
3644 default:
3646 VCLXWindow::setProperty( PropertyName, Value );
3652 ::com::sun::star::uno::Any VCLXScrollBar::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3654 SolarMutexGuard aGuard;
3656 ::com::sun::star::uno::Any aProp;
3657 ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow());
3658 if ( pScrollBar )
3660 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3662 switch ( nPropType )
3664 case BASEPROPERTY_LIVE_SCROLL:
3666 aProp <<= ( 0 != ( pScrollBar->GetSettings().GetStyleSettings().GetDragFullOptions() & DRAGFULL_OPTION_SCROLL ) );
3668 break;
3669 case BASEPROPERTY_SCROLLVALUE:
3671 aProp <<= (sal_Int32) getValue();
3673 break;
3674 case BASEPROPERTY_SCROLLVALUE_MAX:
3676 aProp <<= (sal_Int32) getMaximum();
3678 break;
3679 case BASEPROPERTY_SCROLLVALUE_MIN:
3681 aProp <<= (sal_Int32) getMinimum();
3683 break;
3684 case BASEPROPERTY_LINEINCREMENT:
3686 aProp <<= (sal_Int32) getLineIncrement();
3688 break;
3689 case BASEPROPERTY_BLOCKINCREMENT:
3691 aProp <<= (sal_Int32) getBlockIncrement();
3693 break;
3694 case BASEPROPERTY_VISIBLESIZE:
3696 aProp <<= (sal_Int32) getVisibleSize();
3698 break;
3699 case BASEPROPERTY_ORIENTATION:
3701 aProp <<= (sal_Int32) getOrientation();
3703 break;
3704 case BASEPROPERTY_BACKGROUNDCOLOR:
3706 // the default implementation of the base class doesn't work here, since our
3707 // interpretation for this property is slightly different
3708 aProp = ::toolkit::getButtonLikeFaceColor( pScrollBar );
3710 break;
3712 default:
3714 aProp <<= VCLXWindow::getProperty( PropertyName );
3718 return aProp;
3721 void VCLXScrollBar::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
3723 switch ( rVclWindowEvent.GetId() )
3725 case VCLEVENT_SCROLLBAR_SCROLL:
3727 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
3728 // since we call listeners below, there is a potential that we will be destroyed
3729 // in during the listener call. To prevent the resulting crashs, we keep us
3730 // alive as long as we're here
3732 if ( maAdjustmentListeners.getLength() )
3734 ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow());
3736 if( pScrollBar )
3738 ::com::sun::star::awt::AdjustmentEvent aEvent;
3739 aEvent.Source = (::cppu::OWeakObject*)this;
3740 aEvent.Value = pScrollBar->GetThumbPos();
3742 // set adjustment type
3743 ScrollType aType = pScrollBar->GetType();
3744 if ( aType == SCROLL_LINEUP || aType == SCROLL_LINEDOWN )
3746 aEvent.Type = ::com::sun::star::awt::AdjustmentType_ADJUST_LINE;
3748 else if ( aType == SCROLL_PAGEUP || aType == SCROLL_PAGEDOWN )
3750 aEvent.Type = ::com::sun::star::awt::AdjustmentType_ADJUST_PAGE;
3752 else if ( aType == SCROLL_DRAG )
3754 aEvent.Type = ::com::sun::star::awt::AdjustmentType_ADJUST_ABS;
3757 maAdjustmentListeners.adjustmentValueChanged( aEvent );
3761 break;
3763 default:
3764 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
3765 break;
3769 ::com::sun::star::awt::Size SAL_CALL VCLXScrollBar::implGetMinimumSize( vcl::Window* p ) throw(::com::sun::star::uno::RuntimeException)
3771 long n = p->GetSettings().GetStyleSettings().GetScrollBarSize();
3772 return ::com::sun::star::awt::Size( n, n );
3775 ::com::sun::star::awt::Size SAL_CALL VCLXScrollBar::getMinimumSize() throw(::com::sun::star::uno::RuntimeException, std::exception)
3777 SolarMutexGuard aGuard;
3778 return implGetMinimumSize( GetWindow() );
3783 // class VCLXEdit
3786 void VCLXEdit::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
3788 PushPropertyIds( rIds,
3789 BASEPROPERTY_ALIGN,
3790 BASEPROPERTY_BACKGROUNDCOLOR,
3791 BASEPROPERTY_BORDER,
3792 BASEPROPERTY_BORDERCOLOR,
3793 BASEPROPERTY_DEFAULTCONTROL,
3794 BASEPROPERTY_ECHOCHAR,
3795 BASEPROPERTY_ENABLED,
3796 BASEPROPERTY_ENABLEVISIBLE,
3797 BASEPROPERTY_FONTDESCRIPTOR,
3798 BASEPROPERTY_HARDLINEBREAKS,
3799 BASEPROPERTY_HELPTEXT,
3800 BASEPROPERTY_HELPURL,
3801 BASEPROPERTY_HSCROLL,
3802 BASEPROPERTY_LINE_END_FORMAT,
3803 BASEPROPERTY_MAXTEXTLEN,
3804 BASEPROPERTY_MULTILINE,
3805 BASEPROPERTY_PRINTABLE,
3806 BASEPROPERTY_READONLY,
3807 BASEPROPERTY_TABSTOP,
3808 BASEPROPERTY_TEXT,
3809 BASEPROPERTY_VSCROLL,
3810 BASEPROPERTY_HIDEINACTIVESELECTION,
3811 BASEPROPERTY_PAINTTRANSPARENT,
3812 BASEPROPERTY_AUTOHSCROLL,
3813 BASEPROPERTY_AUTOVSCROLL,
3814 BASEPROPERTY_VERTICALALIGN,
3815 BASEPROPERTY_WRITING_MODE,
3816 BASEPROPERTY_CONTEXT_WRITING_MODE,
3818 VCLXWindow::ImplGetPropertyIds( rIds );
3821 VCLXEdit::VCLXEdit() : maTextListeners( *this )
3825 // ::com::sun::star::uno::XInterface
3826 ::com::sun::star::uno::Any VCLXEdit::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3828 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
3829 (static_cast< ::com::sun::star::awt::XTextComponent* >(this)),
3830 (static_cast< ::com::sun::star::awt::XTextEditField* >(this)),
3831 (static_cast< ::com::sun::star::awt::XTextLayoutConstrains* >(this)) );
3832 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
3835 // ::com::sun::star::lang::XTypeProvider
3836 IMPL_XTYPEPROVIDER_START( VCLXEdit )
3837 cppu::UnoType<com::sun::star::awt::XTextComponent>::get(),
3838 cppu::UnoType<com::sun::star::awt::XTextEditField>::get(),
3839 cppu::UnoType<com::sun::star::awt::XTextLayoutConstrains>::get(),
3840 VCLXWindow::getTypes()
3841 IMPL_XTYPEPROVIDER_END
3843 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXEdit::CreateAccessibleContext()
3845 return getAccessibleFactory().createAccessibleContext( this );
3848 void VCLXEdit::dispose() throw(::com::sun::star::uno::RuntimeException, std::exception)
3850 SolarMutexGuard aGuard;
3852 ::com::sun::star::lang::EventObject aObj;
3853 aObj.Source = (::cppu::OWeakObject*)this;
3854 maTextListeners.disposeAndClear( aObj );
3855 VCLXWindow::dispose();
3858 void VCLXEdit::addTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3860 SolarMutexGuard aGuard;
3861 GetTextListeners().addInterface( l );
3864 void VCLXEdit::removeTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3866 SolarMutexGuard aGuard;
3867 GetTextListeners().removeInterface( l );
3870 void VCLXEdit::setText( const OUString& aText ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3872 SolarMutexGuard aGuard;
3874 Edit* pEdit = static_cast<Edit*>(GetWindow());
3875 if ( pEdit )
3877 pEdit->SetText( aText );
3879 // #107218# Call same listeners like VCL would do after user interaction
3880 SetSynthesizingVCLEvent( true );
3881 pEdit->SetModifyFlag();
3882 pEdit->Modify();
3883 SetSynthesizingVCLEvent( false );
3887 void VCLXEdit::insertText( const ::com::sun::star::awt::Selection& rSel, const OUString& aText ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3889 SolarMutexGuard aGuard;
3891 Edit* pEdit = static_cast<Edit*>(GetWindow());
3892 if ( pEdit )
3894 pEdit->SetSelection( Selection( rSel.Min, rSel.Max ) );
3895 pEdit->ReplaceSelected( aText );
3897 // #107218# Call same listeners like VCL would do after user interaction
3898 SetSynthesizingVCLEvent( true );
3899 pEdit->SetModifyFlag();
3900 pEdit->Modify();
3901 SetSynthesizingVCLEvent( false );
3905 OUString VCLXEdit::getText() throw(::com::sun::star::uno::RuntimeException, std::exception)
3907 SolarMutexGuard aGuard;
3909 OUString aText;
3910 vcl::Window* pWindow = GetWindow();
3911 if ( pWindow )
3912 aText = pWindow->GetText();
3913 return aText;
3916 OUString VCLXEdit::getSelectedText() throw(::com::sun::star::uno::RuntimeException, std::exception)
3918 SolarMutexGuard aGuard;
3920 OUString aText;
3921 Edit* pEdit = static_cast<Edit*>(GetWindow());
3922 if ( pEdit)
3923 aText = pEdit->GetSelected();
3924 return aText;
3928 void VCLXEdit::setSelection( const ::com::sun::star::awt::Selection& aSelection ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3930 SolarMutexGuard aGuard;
3932 Edit* pEdit = static_cast<Edit*>(GetWindow());
3933 if ( pEdit )
3934 pEdit->SetSelection( Selection( aSelection.Min, aSelection.Max ) );
3937 ::com::sun::star::awt::Selection VCLXEdit::getSelection() throw(::com::sun::star::uno::RuntimeException, std::exception)
3939 SolarMutexGuard aGuard;
3941 Selection aSel;
3942 Edit* pEdit = static_cast<Edit*>(GetWindow());
3943 if ( pEdit )
3944 aSel = pEdit->GetSelection();
3945 return ::com::sun::star::awt::Selection( aSel.Min(), aSel.Max() );
3948 sal_Bool VCLXEdit::isEditable() throw(::com::sun::star::uno::RuntimeException, std::exception)
3950 SolarMutexGuard aGuard;
3952 Edit* pEdit = static_cast<Edit*>(GetWindow());
3953 return ( pEdit && !pEdit->IsReadOnly() && pEdit->IsEnabled() ) ? sal_True : sal_False;
3956 void VCLXEdit::setEditable( sal_Bool bEditable ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3958 SolarMutexGuard aGuard;
3960 Edit* pEdit = static_cast<Edit*>(GetWindow());
3961 if ( pEdit )
3962 pEdit->SetReadOnly( !bEditable );
3966 void VCLXEdit::setMaxTextLen( sal_Int16 nLen ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3968 SolarMutexGuard aGuard;
3970 Edit* pEdit = static_cast<Edit*>(GetWindow());
3971 if ( pEdit )
3972 pEdit->SetMaxTextLen( nLen );
3975 sal_Int16 VCLXEdit::getMaxTextLen() throw(::com::sun::star::uno::RuntimeException, std::exception)
3977 SolarMutexGuard aGuard;
3979 Edit* pEdit = static_cast<Edit*>(GetWindow());
3980 return pEdit ? pEdit->GetMaxTextLen() : 0;
3983 void VCLXEdit::setEchoChar( sal_Unicode cEcho ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3985 SolarMutexGuard aGuard;
3987 Edit* pEdit = static_cast<Edit*>(GetWindow());
3988 if ( pEdit )
3989 pEdit->SetEchoChar( cEcho );
3992 void VCLXEdit::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
3994 SolarMutexGuard aGuard;
3996 Edit* pEdit = static_cast<Edit*>(GetWindow());
3997 if ( pEdit )
3999 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4000 switch ( nPropType )
4002 case BASEPROPERTY_HIDEINACTIVESELECTION:
4003 ::toolkit::adjustBooleanWindowStyle( Value, pEdit, WB_NOHIDESELECTION, true );
4004 if ( pEdit->GetSubEdit() )
4005 ::toolkit::adjustBooleanWindowStyle( Value, pEdit->GetSubEdit(), WB_NOHIDESELECTION, true );
4006 break;
4008 case BASEPROPERTY_READONLY:
4010 bool b = bool();
4011 if ( Value >>= b )
4012 pEdit->SetReadOnly( b );
4014 break;
4015 case BASEPROPERTY_ECHOCHAR:
4017 sal_Int16 n = sal_Int16();
4018 if ( Value >>= n )
4019 pEdit->SetEchoChar( n );
4021 break;
4022 case BASEPROPERTY_MAXTEXTLEN:
4024 sal_Int16 n = sal_Int16();
4025 if ( Value >>= n )
4026 pEdit->SetMaxTextLen( n );
4028 break;
4029 default:
4031 VCLXWindow::setProperty( PropertyName, Value );
4037 ::com::sun::star::uno::Any VCLXEdit::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4039 SolarMutexGuard aGuard;
4041 ::com::sun::star::uno::Any aProp;
4042 Edit* pEdit = static_cast<Edit*>(GetWindow());
4043 if ( pEdit )
4045 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4046 switch ( nPropType )
4048 case BASEPROPERTY_HIDEINACTIVESELECTION:
4049 aProp <<= ( ( pEdit->GetStyle() & WB_NOHIDESELECTION ) == 0 );
4050 break;
4051 case BASEPROPERTY_READONLY:
4052 aProp <<= pEdit->IsReadOnly();
4053 break;
4054 case BASEPROPERTY_ECHOCHAR:
4055 aProp <<= (sal_Int16) pEdit->GetEchoChar();
4056 break;
4057 case BASEPROPERTY_MAXTEXTLEN:
4058 aProp <<= (sal_Int16) pEdit->GetMaxTextLen();
4059 break;
4060 default:
4062 aProp = VCLXWindow::getProperty( PropertyName );
4066 return aProp;
4069 ::com::sun::star::awt::Size VCLXEdit::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4071 SolarMutexGuard aGuard;
4073 Size aSz;
4074 Edit* pEdit = static_cast<Edit*>(GetWindow());
4075 if ( pEdit )
4076 aSz = pEdit->CalcMinimumSize();
4077 return AWTSize(aSz);
4080 ::com::sun::star::awt::Size VCLXEdit::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4082 SolarMutexGuard aGuard;
4084 Size aSz;
4085 Edit* pEdit = static_cast<Edit*>(GetWindow());
4086 if ( pEdit )
4088 aSz = pEdit->CalcMinimumSize();
4089 aSz.Height() += 4;
4091 return AWTSize(aSz);
4094 ::com::sun::star::awt::Size VCLXEdit::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4096 SolarMutexGuard aGuard;
4098 ::com::sun::star::awt::Size aSz = rNewSize;
4099 ::com::sun::star::awt::Size aMinSz = getMinimumSize();
4100 if ( aSz.Height != aMinSz.Height )
4101 aSz.Height = aMinSz.Height;
4103 return aSz;
4106 ::com::sun::star::awt::Size VCLXEdit::getMinimumSize( sal_Int16 nCols, sal_Int16 ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4108 SolarMutexGuard aGuard;
4110 Size aSz;
4111 Edit* pEdit = static_cast<Edit*>(GetWindow());
4112 if ( pEdit )
4114 if ( nCols )
4115 aSz = pEdit->CalcSize( nCols );
4116 else
4117 aSz = pEdit->CalcMinimumSize();
4119 return AWTSize(aSz);
4122 void VCLXEdit::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4124 SolarMutexGuard aGuard;
4126 nLines = 1;
4127 nCols = 0;
4128 Edit* pEdit = static_cast<Edit*>(GetWindow());
4129 if ( pEdit )
4130 nCols = pEdit->GetMaxVisChars();
4133 void VCLXEdit::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
4135 switch ( rVclWindowEvent.GetId() )
4137 case VCLEVENT_EDIT_MODIFY:
4139 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
4140 // since we call listeners below, there is a potential that we will be destroyed
4141 // during the listener call. To prevent the resulting crashs, we keep us
4142 // alive as long as we're here
4144 if ( GetTextListeners().getLength() )
4146 ::com::sun::star::awt::TextEvent aEvent;
4147 aEvent.Source = (::cppu::OWeakObject*)this;
4148 GetTextListeners().textChanged( aEvent );
4151 break;
4153 default:
4154 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
4155 break;
4160 // class VCLXComboBox
4163 void VCLXComboBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
4165 PushPropertyIds( rIds,
4166 BASEPROPERTY_AUTOCOMPLETE,
4167 BASEPROPERTY_BACKGROUNDCOLOR,
4168 BASEPROPERTY_BORDER,
4169 BASEPROPERTY_BORDERCOLOR,
4170 BASEPROPERTY_DEFAULTCONTROL,
4171 BASEPROPERTY_DROPDOWN,
4172 BASEPROPERTY_ENABLED,
4173 BASEPROPERTY_ENABLEVISIBLE,
4174 BASEPROPERTY_FONTDESCRIPTOR,
4175 BASEPROPERTY_HELPTEXT,
4176 BASEPROPERTY_HELPURL,
4177 BASEPROPERTY_LINECOUNT,
4178 BASEPROPERTY_MAXTEXTLEN,
4179 BASEPROPERTY_PRINTABLE,
4180 BASEPROPERTY_READONLY,
4181 BASEPROPERTY_STRINGITEMLIST,
4182 BASEPROPERTY_TABSTOP,
4183 BASEPROPERTY_TEXT,
4184 BASEPROPERTY_HIDEINACTIVESELECTION,
4185 BASEPROPERTY_ALIGN,
4186 BASEPROPERTY_WRITING_MODE,
4187 BASEPROPERTY_CONTEXT_WRITING_MODE,
4188 BASEPROPERTY_REFERENCE_DEVICE,
4189 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
4191 // no, don't call VCLXEdit here - it has properties which we do *not* want to have at combo box
4192 // #i92690# / 2008-08-12 / frank.schoenheit@sun.com
4193 // VCLXEdit::ImplGetPropertyIds( rIds );
4194 VCLXWindow::ImplGetPropertyIds( rIds );
4197 VCLXComboBox::VCLXComboBox()
4198 : maActionListeners( *this ), maItemListeners( *this )
4202 VCLXComboBox::~VCLXComboBox()
4204 OSL_TRACE ("%s", __FUNCTION__);
4207 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXComboBox::CreateAccessibleContext()
4209 SolarMutexGuard aGuard;
4211 return getAccessibleFactory().createAccessibleContext( this );
4214 void VCLXComboBox::dispose() throw(::com::sun::star::uno::RuntimeException, std::exception)
4216 SolarMutexGuard aGuard;
4218 ::com::sun::star::lang::EventObject aObj;
4219 aObj.Source = (::cppu::OWeakObject*)this;
4220 maItemListeners.disposeAndClear( aObj );
4221 maActionListeners.disposeAndClear( aObj );
4222 VCLXEdit::dispose();
4226 void VCLXComboBox::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4228 SolarMutexGuard aGuard;
4229 maItemListeners.addInterface( l );
4232 void VCLXComboBox::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4234 SolarMutexGuard aGuard;
4235 maItemListeners.removeInterface( l );
4238 void VCLXComboBox::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4240 SolarMutexGuard aGuard;
4241 maActionListeners.addInterface( l );
4244 void VCLXComboBox::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4246 SolarMutexGuard aGuard;
4247 maActionListeners.removeInterface( l );
4250 void VCLXComboBox::addItem( const OUString& aItem, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4252 SolarMutexGuard aGuard;
4254 ComboBox* pBox = static_cast<ComboBox*>(GetWindow());
4255 if ( pBox )
4256 pBox->InsertEntry( aItem, nPos );
4259 void VCLXComboBox::addItems( const ::com::sun::star::uno::Sequence< OUString>& aItems, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4261 SolarMutexGuard aGuard;
4263 ComboBox* pBox = static_cast<ComboBox*>(GetWindow());
4264 if ( pBox )
4266 sal_uInt16 nP = nPos;
4267 for ( sal_uInt16 n = 0; n < aItems.getLength(); n++ )
4269 pBox->InsertEntry( aItems.getConstArray()[n], nP );
4270 if ( nP == 0xFFFF )
4272 OSL_FAIL( "VCLXComboBox::addItems: too many entries!" );
4273 // skip remaining entries, list cannot hold them, anyway
4274 break;
4280 void VCLXComboBox::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4282 SolarMutexGuard aGuard;
4284 ComboBox* pBox = static_cast<ComboBox*>(GetWindow());
4285 if ( pBox )
4287 for ( sal_uInt16 n = nCount; n; )
4288 pBox->RemoveEntryAt( nPos + (--n) );
4292 sal_Int16 VCLXComboBox::getItemCount() throw(::com::sun::star::uno::RuntimeException, std::exception)
4294 SolarMutexGuard aGuard;
4296 ComboBox* pBox = static_cast<ComboBox*>(GetWindow());
4297 return pBox ? pBox->GetEntryCount() : 0;
4300 OUString VCLXComboBox::getItem( sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4302 SolarMutexGuard aGuard;
4304 OUString aItem;
4305 ComboBox* pBox = static_cast<ComboBox*>(GetWindow());
4306 if ( pBox )
4307 aItem = pBox->GetEntry( nPos );
4308 return aItem;
4311 ::com::sun::star::uno::Sequence< OUString> VCLXComboBox::getItems() throw(::com::sun::star::uno::RuntimeException, std::exception)
4313 SolarMutexGuard aGuard;
4315 ::com::sun::star::uno::Sequence< OUString> aSeq;
4316 ComboBox* pBox = static_cast<ComboBox*>(GetWindow());
4317 if ( pBox )
4319 sal_uInt16 nEntries = pBox->GetEntryCount();
4320 aSeq = ::com::sun::star::uno::Sequence< OUString>( nEntries );
4321 for ( sal_uInt16 n = nEntries; n; )
4323 --n;
4324 aSeq.getArray()[n] = pBox->GetEntry( n );
4327 return aSeq;
4330 void VCLXComboBox::setDropDownLineCount( sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4332 SolarMutexGuard aGuard;
4334 ComboBox* pBox = static_cast<ComboBox*>(GetWindow());
4335 if ( pBox )
4336 pBox->SetDropDownLineCount( nLines );
4339 sal_Int16 VCLXComboBox::getDropDownLineCount() throw(::com::sun::star::uno::RuntimeException, std::exception)
4341 SolarMutexGuard aGuard;
4343 sal_Int16 nLines = 0;
4344 ComboBox* pBox = static_cast<ComboBox*>(GetWindow());
4345 if ( pBox )
4346 nLines = pBox->GetDropDownLineCount();
4347 return nLines;
4350 void VCLXComboBox::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
4352 SolarMutexGuard aGuard;
4354 ComboBox* pComboBox = static_cast<ComboBox*>(GetWindow());
4355 if ( pComboBox )
4357 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4358 switch ( nPropType )
4360 case BASEPROPERTY_LINECOUNT:
4362 sal_Int16 n = sal_Int16();
4363 if ( Value >>= n )
4364 pComboBox->SetDropDownLineCount( n );
4366 break;
4367 case BASEPROPERTY_AUTOCOMPLETE:
4369 sal_Int16 n = sal_Int16();
4370 if ( Value >>= n )
4371 pComboBox->EnableAutocomplete( n != 0 );
4372 else
4374 bool b = bool();
4375 if ( Value >>= b )
4376 pComboBox->EnableAutocomplete( b );
4379 break;
4380 case BASEPROPERTY_STRINGITEMLIST:
4382 ::com::sun::star::uno::Sequence< OUString> aItems;
4383 if ( Value >>= aItems )
4385 pComboBox->Clear();
4386 addItems( aItems, 0 );
4389 break;
4390 default:
4392 VCLXEdit::setProperty( PropertyName, Value );
4394 // #109385# SetBorderStyle is not virtual
4395 if ( nPropType == BASEPROPERTY_BORDER )
4397 sal_uInt16 nBorder = sal_uInt16();
4398 if ( (Value >>= nBorder) && nBorder != 0 )
4399 pComboBox->SetBorderStyle( static_cast<WindowBorderStyle>(nBorder) );
4406 ::com::sun::star::uno::Any VCLXComboBox::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4408 SolarMutexGuard aGuard;
4410 ::com::sun::star::uno::Any aProp;
4411 ComboBox* pComboBox = static_cast<ComboBox*>(GetWindow());
4412 if ( pComboBox )
4414 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4415 switch ( nPropType )
4417 case BASEPROPERTY_LINECOUNT:
4419 aProp <<= (sal_Int16) pComboBox->GetDropDownLineCount();
4421 break;
4422 case BASEPROPERTY_AUTOCOMPLETE:
4424 aProp <<= pComboBox->IsAutocompleteEnabled();
4426 break;
4427 case BASEPROPERTY_STRINGITEMLIST:
4429 sal_uInt16 nItems = pComboBox->GetEntryCount();
4430 ::com::sun::star::uno::Sequence< OUString> aSeq( nItems );
4431 OUString* pStrings = aSeq.getArray();
4432 for ( sal_uInt16 n = 0; n < nItems; n++ )
4433 pStrings[n] = pComboBox->GetEntry( n );
4434 aProp <<= aSeq;
4437 break;
4438 default:
4440 aProp <<= VCLXEdit::getProperty( PropertyName );
4444 return aProp;
4447 void VCLXComboBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
4449 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
4450 // since we call listeners below, there is a potential that we will be destroyed
4451 // during the listener call. To prevent the resulting crashs, we keep us
4452 // alive as long as we're here
4454 switch ( rVclWindowEvent.GetId() )
4456 case VCLEVENT_COMBOBOX_SELECT:
4457 if ( maItemListeners.getLength() )
4459 ComboBox* pComboBox = static_cast<ComboBox*>(GetWindow());
4460 if( pComboBox )
4462 if ( !pComboBox->IsTravelSelect() )
4464 ::com::sun::star::awt::ItemEvent aEvent;
4465 aEvent.Source = (::cppu::OWeakObject*)this;
4466 aEvent.Highlighted = sal_False;
4468 // Set to 0xFFFF on multiple selection, selected entry ID otherwise
4469 aEvent.Selected = pComboBox->GetEntryPos( pComboBox->GetText() );
4471 maItemListeners.itemStateChanged( aEvent );
4475 break;
4477 case VCLEVENT_COMBOBOX_DOUBLECLICK:
4478 if ( maActionListeners.getLength() )
4480 ::com::sun::star::awt::ActionEvent aEvent;
4481 aEvent.Source = (::cppu::OWeakObject*)this;
4482 // aEvent.ActionCommand = ...;
4483 maActionListeners.actionPerformed( aEvent );
4485 break;
4487 default:
4488 VCLXEdit::ProcessWindowEvent( rVclWindowEvent );
4489 break;
4493 ::com::sun::star::awt::Size VCLXComboBox::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4495 SolarMutexGuard aGuard;
4497 Size aSz;
4498 ComboBox* pComboBox = static_cast<ComboBox*>(GetWindow());
4499 if ( pComboBox )
4500 aSz = pComboBox->CalcMinimumSize();
4501 return AWTSize(aSz);
4504 ::com::sun::star::awt::Size VCLXComboBox::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4506 SolarMutexGuard aGuard;
4508 Size aSz;
4509 ComboBox* pComboBox = static_cast<ComboBox*>(GetWindow());
4510 if ( pComboBox )
4512 aSz = pComboBox->CalcMinimumSize();
4513 if ( pComboBox->GetStyle() & WB_DROPDOWN )
4514 aSz.Height() += 4;
4516 return AWTSize(aSz);
4519 ::com::sun::star::awt::Size VCLXComboBox::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4521 SolarMutexGuard aGuard;
4523 Size aSz = VCLSize(rNewSize);
4524 ComboBox* pComboBox = static_cast<ComboBox*>(GetWindow());
4525 if ( pComboBox )
4526 aSz = pComboBox->CalcAdjustedSize( aSz );
4527 return AWTSize(aSz);
4530 ::com::sun::star::awt::Size VCLXComboBox::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4532 SolarMutexGuard aGuard;
4534 Size aSz;
4535 ComboBox* pComboBox = static_cast<ComboBox*>(GetWindow());
4536 if ( pComboBox )
4537 aSz = pComboBox->CalcBlockSize( nCols, nLines );
4538 return AWTSize(aSz);
4541 void VCLXComboBox::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4543 SolarMutexGuard aGuard;
4545 nCols = nLines = 0;
4546 ComboBox* pComboBox = static_cast<ComboBox*>(GetWindow());
4547 if ( pComboBox )
4549 sal_uInt16 nC, nL;
4550 pComboBox->GetMaxVisColumnsAndLines( nC, nL );
4551 nCols = nC;
4552 nLines = nL;
4555 void SAL_CALL VCLXComboBox::listItemInserted( const ItemListEvent& i_rEvent ) throw (RuntimeException, std::exception)
4557 SolarMutexGuard aGuard;
4559 ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() );
4561 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemInserted: no ComboBox?!" );
4562 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition <= sal_Int32( pComboBox->GetEntryCount() ) ),
4563 "VCLXComboBox::listItemInserted: illegal (inconsistent) item position!" );
4564 pComboBox->InsertEntryWithImage(
4565 i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : OUString(),
4566 i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : Image(),
4567 i_rEvent.ItemPosition );
4570 void SAL_CALL VCLXComboBox::listItemRemoved( const ItemListEvent& i_rEvent ) throw (RuntimeException, std::exception)
4572 SolarMutexGuard aGuard;
4574 ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() );
4576 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemRemoved: no ComboBox?!" );
4577 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pComboBox->GetEntryCount() ) ),
4578 "VCLXComboBox::listItemRemoved: illegal (inconsistent) item position!" );
4580 pComboBox->RemoveEntryAt( i_rEvent.ItemPosition );
4583 void SAL_CALL VCLXComboBox::listItemModified( const ItemListEvent& i_rEvent ) throw (RuntimeException, std::exception)
4585 SolarMutexGuard aGuard;
4587 ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() );
4589 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" );
4590 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pComboBox->GetEntryCount() ) ),
4591 "VCLXComboBox::listItemModified: illegal (inconsistent) item position!" );
4593 // VCL's ComboBox does not support changing an entry's text or image, so remove and re-insert
4595 const OUString sNewText = i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : OUString( pComboBox->GetEntry( i_rEvent.ItemPosition ) );
4596 const Image aNewImage( i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : pComboBox->GetEntryImage( i_rEvent.ItemPosition ) );
4598 pComboBox->RemoveEntryAt( i_rEvent.ItemPosition );
4599 pComboBox->InsertEntryWithImage(sNewText, aNewImage, i_rEvent.ItemPosition);
4602 void SAL_CALL VCLXComboBox::allItemsRemoved( const EventObject& i_rEvent ) throw (RuntimeException, std::exception)
4604 SolarMutexGuard aGuard;
4606 ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() );
4607 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" );
4609 pComboBox->Clear();
4611 (void)i_rEvent;
4614 void SAL_CALL VCLXComboBox::itemListChanged( const EventObject& i_rEvent ) throw (RuntimeException, std::exception)
4616 SolarMutexGuard aGuard;
4618 ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() );
4619 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" );
4621 pComboBox->Clear();
4623 uno::Reference< beans::XPropertySet > xPropSet( i_rEvent.Source, uno::UNO_QUERY_THROW );
4624 uno::Reference< beans::XPropertySetInfo > xPSI( xPropSet->getPropertySetInfo(), uno::UNO_QUERY_THROW );
4625 // bool localize = xPSI->hasPropertyByName("ResourceResolver");
4626 uno::Reference< resource::XStringResourceResolver > xStringResourceResolver;
4627 if ( xPSI->hasPropertyByName("ResourceResolver") )
4629 xStringResourceResolver.set(
4630 xPropSet->getPropertyValue("ResourceResolver"),
4631 uno::UNO_QUERY
4636 Reference< XItemList > xItemList( i_rEvent.Source, uno::UNO_QUERY_THROW );
4637 uno::Sequence< beans::Pair< OUString, OUString > > aItems = xItemList->getAllItems();
4638 for ( sal_Int32 i=0; i<aItems.getLength(); ++i )
4640 OUString aLocalizationKey( aItems[i].First );
4641 if ( xStringResourceResolver.is() && !aLocalizationKey.isEmpty() && aLocalizationKey[0] == '&' )
4643 aLocalizationKey = xStringResourceResolver->resolveString(aLocalizationKey.copy( 1 ));
4645 pComboBox->InsertEntryWithImage(aLocalizationKey,
4646 lcl_getImageFromURL(aItems[i].Second));
4649 void SAL_CALL VCLXComboBox::disposing( const EventObject& i_rEvent ) throw (RuntimeException, std::exception)
4651 // just disambiguate
4652 VCLXEdit::disposing( i_rEvent );
4656 // class VCLXFormattedSpinField
4658 void VCLXFormattedSpinField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
4660 // Interestingly in the UnoControl API this is
4661 // - not derived from XEdit ultimately, (correct ?) - so cut this here ...
4662 // VCLXSpinField::ImplGetPropertyIds( rIds );
4663 VCLXWindow::ImplGetPropertyIds( rIds );
4666 VCLXFormattedSpinField::VCLXFormattedSpinField()
4667 : mpFormatter(NULL)
4671 VCLXFormattedSpinField::~VCLXFormattedSpinField()
4675 void VCLXFormattedSpinField::setStrictFormat( bool bStrict )
4677 SolarMutexGuard aGuard;
4679 FormatterBase* pFormatter = GetFormatter();
4680 if ( pFormatter )
4681 pFormatter->SetStrictFormat( bStrict );
4684 bool VCLXFormattedSpinField::isStrictFormat()
4686 FormatterBase* pFormatter = GetFormatter();
4687 return pFormatter ? pFormatter->IsStrictFormat() : sal_False;
4691 void VCLXFormattedSpinField::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
4693 SolarMutexGuard aGuard;
4695 FormatterBase* pFormatter = GetFormatter();
4696 if ( pFormatter )
4698 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4699 switch ( nPropType )
4701 case BASEPROPERTY_SPIN:
4703 bool b = bool();
4704 if ( Value >>= b )
4706 WinBits nStyle = GetWindow()->GetStyle() | WB_SPIN;
4707 if ( !b )
4708 nStyle &= ~WB_SPIN;
4709 GetWindow()->SetStyle( nStyle );
4712 break;
4713 case BASEPROPERTY_STRICTFORMAT:
4715 bool b = bool();
4716 if ( Value >>= b )
4718 pFormatter->SetStrictFormat( b );
4721 break;
4722 default:
4724 VCLXSpinField::setProperty( PropertyName, Value );
4730 ::com::sun::star::uno::Any VCLXFormattedSpinField::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4732 SolarMutexGuard aGuard;
4734 ::com::sun::star::uno::Any aProp;
4735 FormatterBase* pFormatter = GetFormatter();
4736 if ( pFormatter )
4738 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4739 switch ( nPropType )
4741 case BASEPROPERTY_TABSTOP:
4743 aProp <<= ( GetWindow()->GetStyle() & WB_SPIN ) != 0;
4745 break;
4746 case BASEPROPERTY_STRICTFORMAT:
4748 aProp <<= pFormatter->IsStrictFormat();
4750 break;
4751 default:
4753 aProp <<= VCLXSpinField::getProperty( PropertyName );
4757 return aProp;
4762 // class VCLXDateField
4765 void VCLXDateField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
4767 PushPropertyIds( rIds,
4768 BASEPROPERTY_ALIGN,
4769 BASEPROPERTY_BACKGROUNDCOLOR,
4770 BASEPROPERTY_BORDER,
4771 BASEPROPERTY_BORDERCOLOR,
4772 BASEPROPERTY_DATE,
4773 BASEPROPERTY_DATEMAX,
4774 BASEPROPERTY_DATEMIN,
4775 BASEPROPERTY_DATESHOWCENTURY,
4776 BASEPROPERTY_DEFAULTCONTROL,
4777 BASEPROPERTY_DROPDOWN,
4778 BASEPROPERTY_ENABLED,
4779 BASEPROPERTY_ENABLEVISIBLE,
4780 BASEPROPERTY_EXTDATEFORMAT,
4781 BASEPROPERTY_FONTDESCRIPTOR,
4782 BASEPROPERTY_HELPTEXT,
4783 BASEPROPERTY_HELPURL,
4784 BASEPROPERTY_PRINTABLE,
4785 BASEPROPERTY_READONLY,
4786 BASEPROPERTY_REPEAT,
4787 BASEPROPERTY_REPEAT_DELAY,
4788 BASEPROPERTY_SPIN,
4789 BASEPROPERTY_STRICTFORMAT,
4790 BASEPROPERTY_TABSTOP,
4791 BASEPROPERTY_ENFORCE_FORMAT,
4792 BASEPROPERTY_TEXT,
4793 BASEPROPERTY_HIDEINACTIVESELECTION,
4794 BASEPROPERTY_VERTICALALIGN,
4795 BASEPROPERTY_WRITING_MODE,
4796 BASEPROPERTY_CONTEXT_WRITING_MODE,
4797 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
4799 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
4802 VCLXDateField::VCLXDateField()
4806 VCLXDateField::~VCLXDateField()
4810 //change the window type here to match the role
4811 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXDateField::CreateAccessibleContext()
4813 vcl::Window* pWindow = GetWindow();
4814 if ( pWindow )
4816 pWindow->SetType( WINDOW_DATEFIELD );
4818 return getAccessibleFactory().createAccessibleContext( this );
4821 // ::com::sun::star::uno::XInterface
4822 ::com::sun::star::uno::Any VCLXDateField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4824 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
4825 (static_cast< ::com::sun::star::awt::XDateField* >(this)) );
4826 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
4829 // ::com::sun::star::lang::XTypeProvider
4830 IMPL_XTYPEPROVIDER_START( VCLXDateField )
4831 cppu::UnoType<com::sun::star::awt::XDateField>::get(),
4832 VCLXFormattedSpinField::getTypes()
4833 IMPL_XTYPEPROVIDER_END
4835 void VCLXDateField::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
4837 SolarMutexGuard aGuard;
4839 if ( GetWindow() )
4841 bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
4843 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4844 switch ( nPropType )
4846 case BASEPROPERTY_DATE:
4848 if ( bVoid )
4850 static_cast<DateField*>(GetWindow())->EnableEmptyFieldValue( true );
4851 static_cast<DateField*>(GetWindow())->SetEmptyFieldValue();
4853 else
4855 util::Date d;
4856 if ( Value >>= d )
4857 setDate( d );
4860 break;
4861 case BASEPROPERTY_DATEMIN:
4863 util::Date d;
4864 if ( Value >>= d )
4865 setMin( d );
4867 break;
4868 case BASEPROPERTY_DATEMAX:
4870 util::Date d;
4871 if ( Value >>= d )
4872 setMax( d );
4874 break;
4875 case BASEPROPERTY_EXTDATEFORMAT:
4877 sal_Int16 n = sal_Int16();
4878 if ( Value >>= n )
4879 static_cast<DateField*>(GetWindow())->SetExtDateFormat( (ExtDateFieldFormat) n );
4881 break;
4882 case BASEPROPERTY_DATESHOWCENTURY:
4884 bool b = bool();
4885 if ( Value >>= b )
4886 static_cast<DateField*>(GetWindow())->SetShowDateCentury( b );
4888 break;
4889 case BASEPROPERTY_ENFORCE_FORMAT:
4891 bool bEnforce( true );
4892 OSL_VERIFY( Value >>= bEnforce );
4893 static_cast< DateField* >( GetWindow() )->EnforceValidValue( bEnforce );
4895 break;
4896 default:
4898 VCLXFormattedSpinField::setProperty( PropertyName, Value );
4904 ::com::sun::star::uno::Any VCLXDateField::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4906 SolarMutexGuard aGuard;
4908 ::com::sun::star::uno::Any aProp;
4909 FormatterBase* pFormatter = GetFormatter();
4910 if ( pFormatter )
4912 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4913 switch ( nPropType )
4915 case BASEPROPERTY_DATE:
4917 aProp <<= getDate();
4919 break;
4920 case BASEPROPERTY_DATEMIN:
4922 aProp <<= getMin();
4924 break;
4925 case BASEPROPERTY_DATEMAX:
4927 aProp <<= getMax();
4929 break;
4930 case BASEPROPERTY_DATESHOWCENTURY:
4932 aProp <<= static_cast<DateField*>(GetWindow())->IsShowDateCentury();
4934 break;
4935 case BASEPROPERTY_ENFORCE_FORMAT:
4937 aProp <<= static_cast< DateField* >( GetWindow() )->IsEnforceValidValue( );
4939 break;
4940 default:
4942 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
4946 return aProp;
4950 void VCLXDateField::setDate( const util::Date& aDate ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4952 SolarMutexGuard aGuard;
4954 DateField* pDateField = static_cast<DateField*>(GetWindow());
4955 if ( pDateField )
4957 pDateField->SetDate( aDate );
4959 // #107218# Call same listeners like VCL would do after user interaction
4960 SetSynthesizingVCLEvent( true );
4961 pDateField->SetModifyFlag();
4962 pDateField->Modify();
4963 SetSynthesizingVCLEvent( false );
4967 util::Date VCLXDateField::getDate() throw(::com::sun::star::uno::RuntimeException, std::exception)
4969 SolarMutexGuard aGuard;
4971 DateField* pDateField = static_cast<DateField*>(GetWindow());
4972 if ( pDateField )
4973 return pDateField->GetDate().GetUNODate();
4974 else
4975 return util::Date();
4978 void VCLXDateField::setMin( const util::Date& aDate ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4980 SolarMutexGuard aGuard;
4982 DateField* pDateField = static_cast<DateField*>(GetWindow());
4983 if ( pDateField )
4984 pDateField->SetMin( aDate );
4987 util::Date VCLXDateField::getMin() throw(::com::sun::star::uno::RuntimeException, std::exception)
4989 SolarMutexGuard aGuard;
4991 DateField* pDateField = static_cast<DateField*>(GetWindow());
4992 if ( pDateField )
4993 return pDateField->GetMin().GetUNODate();
4994 else
4995 return util::Date();
4998 void VCLXDateField::setMax( const util::Date& aDate ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5000 SolarMutexGuard aGuard;
5002 DateField* pDateField = static_cast<DateField*>(GetWindow());
5003 if ( pDateField )
5004 pDateField->SetMax( aDate );
5007 util::Date VCLXDateField::getMax() throw(::com::sun::star::uno::RuntimeException, std::exception)
5009 SolarMutexGuard aGuard;
5011 DateField* pDateField = static_cast<DateField*>(GetWindow());
5012 if ( pDateField )
5013 return pDateField->GetMax().GetUNODate();
5014 else
5015 return util::Date();
5018 void VCLXDateField::setFirst( const util::Date& aDate ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5020 SolarMutexGuard aGuard;
5022 DateField* pDateField = static_cast<DateField*>(GetWindow());
5023 if ( pDateField )
5024 pDateField->SetFirst( aDate );
5027 util::Date VCLXDateField::getFirst() throw(::com::sun::star::uno::RuntimeException, std::exception)
5029 SolarMutexGuard aGuard;
5031 DateField* pDateField = static_cast<DateField*>(GetWindow());
5032 if ( pDateField )
5033 return pDateField->GetFirst().GetUNODate();
5034 else
5035 return util::Date();
5038 void VCLXDateField::setLast( const util::Date& aDate ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5040 SolarMutexGuard aGuard;
5042 DateField* pDateField = static_cast<DateField*>(GetWindow());
5043 if ( pDateField )
5044 pDateField->SetLast( aDate );
5047 util::Date VCLXDateField::getLast() throw(::com::sun::star::uno::RuntimeException, std::exception)
5049 SolarMutexGuard aGuard;
5051 DateField* pDateField = static_cast<DateField*>(GetWindow());
5052 if ( pDateField )
5053 return pDateField->GetLast().GetUNODate();
5054 else
5055 return util::Date();
5058 void VCLXDateField::setLongFormat( sal_Bool bLong ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5060 SolarMutexGuard aGuard;
5062 DateField* pDateField = static_cast<DateField*>(GetWindow());
5063 if ( pDateField )
5064 pDateField->SetLongFormat( bLong );
5067 sal_Bool VCLXDateField::isLongFormat() throw(::com::sun::star::uno::RuntimeException, std::exception)
5069 SolarMutexGuard aGuard;
5071 DateField* pDateField = static_cast<DateField*>(GetWindow());
5072 return pDateField ? pDateField->IsLongFormat() : sal_False;
5075 void VCLXDateField::setEmpty() throw(::com::sun::star::uno::RuntimeException, std::exception)
5077 SolarMutexGuard aGuard;
5079 DateField* pDateField = static_cast<DateField*>(GetWindow());
5080 if ( pDateField )
5082 pDateField->SetEmptyDate();
5084 // #107218# Call same listeners like VCL would do after user interaction
5085 SetSynthesizingVCLEvent( true );
5086 pDateField->SetModifyFlag();
5087 pDateField->Modify();
5088 SetSynthesizingVCLEvent( false );
5092 sal_Bool VCLXDateField::isEmpty() throw(::com::sun::star::uno::RuntimeException, std::exception)
5094 SolarMutexGuard aGuard;
5096 DateField* pDateField = static_cast<DateField*>(GetWindow());
5097 return pDateField ? pDateField->IsEmptyDate() : sal_False;
5100 void VCLXDateField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5102 VCLXFormattedSpinField::setStrictFormat( bStrict );
5105 sal_Bool VCLXDateField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException, std::exception)
5107 return VCLXFormattedSpinField::isStrictFormat();
5112 // class VCLXTimeField
5115 void VCLXTimeField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
5117 PushPropertyIds( rIds,
5118 BASEPROPERTY_ALIGN,
5119 BASEPROPERTY_BACKGROUNDCOLOR,
5120 BASEPROPERTY_BORDER,
5121 BASEPROPERTY_BORDERCOLOR,
5122 BASEPROPERTY_DEFAULTCONTROL,
5123 BASEPROPERTY_ENABLED,
5124 BASEPROPERTY_ENABLEVISIBLE,
5125 BASEPROPERTY_EXTTIMEFORMAT,
5126 BASEPROPERTY_FONTDESCRIPTOR,
5127 BASEPROPERTY_HELPTEXT,
5128 BASEPROPERTY_HELPURL,
5129 BASEPROPERTY_PRINTABLE,
5130 BASEPROPERTY_READONLY,
5131 BASEPROPERTY_REPEAT,
5132 BASEPROPERTY_REPEAT_DELAY,
5133 BASEPROPERTY_SPIN,
5134 BASEPROPERTY_STRICTFORMAT,
5135 BASEPROPERTY_TABSTOP,
5136 BASEPROPERTY_TIME,
5137 BASEPROPERTY_TIMEMAX,
5138 BASEPROPERTY_TIMEMIN,
5139 BASEPROPERTY_ENFORCE_FORMAT,
5140 BASEPROPERTY_TEXT,
5141 BASEPROPERTY_HIDEINACTIVESELECTION,
5142 BASEPROPERTY_VERTICALALIGN,
5143 BASEPROPERTY_WRITING_MODE,
5144 BASEPROPERTY_CONTEXT_WRITING_MODE,
5145 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
5147 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5150 VCLXTimeField::VCLXTimeField()
5154 VCLXTimeField::~VCLXTimeField()
5158 //change the window type here to match the role
5159 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXTimeField::CreateAccessibleContext()
5161 vcl::Window* pWindow = GetWindow();
5162 if ( pWindow )
5164 pWindow->SetType( WINDOW_TIMEFIELD );
5166 return getAccessibleFactory().createAccessibleContext( this );
5169 // ::com::sun::star::uno::XInterface
5170 ::com::sun::star::uno::Any VCLXTimeField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5172 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
5173 (static_cast< ::com::sun::star::awt::XTimeField* >(this)) );
5174 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
5177 // ::com::sun::star::lang::XTypeProvider
5178 IMPL_XTYPEPROVIDER_START( VCLXTimeField )
5179 cppu::UnoType<com::sun::star::awt::XTimeField>::get(),
5180 VCLXFormattedSpinField::getTypes()
5181 IMPL_XTYPEPROVIDER_END
5183 void VCLXTimeField::setTime( const util::Time& aTime ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5185 SolarMutexGuard aGuard;
5187 TimeField* pTimeField = static_cast<TimeField*>(GetWindow());
5188 if ( pTimeField )
5190 pTimeField->SetTime( aTime );
5192 // #107218# Call same listeners like VCL would do after user interaction
5193 SetSynthesizingVCLEvent( true );
5194 pTimeField->SetModifyFlag();
5195 pTimeField->Modify();
5196 SetSynthesizingVCLEvent( false );
5200 util::Time VCLXTimeField::getTime() throw(::com::sun::star::uno::RuntimeException, std::exception)
5202 SolarMutexGuard aGuard;
5204 TimeField* pTimeField = static_cast<TimeField*>(GetWindow());
5205 if ( pTimeField )
5206 return pTimeField->GetTime().GetUNOTime();
5207 else
5208 return util::Time();
5211 void VCLXTimeField::setMin( const util::Time& aTime ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5213 SolarMutexGuard aGuard;
5215 TimeField* pTimeField = static_cast<TimeField*>(GetWindow());
5216 if ( pTimeField )
5217 pTimeField->SetMin( aTime );
5220 util::Time VCLXTimeField::getMin() throw(::com::sun::star::uno::RuntimeException, std::exception)
5222 SolarMutexGuard aGuard;
5224 TimeField* pTimeField = static_cast<TimeField*>(GetWindow());
5225 if ( pTimeField )
5226 return pTimeField->GetMin().GetUNOTime();
5227 else
5228 return util::Time();
5231 void VCLXTimeField::setMax( const util::Time& aTime ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5233 SolarMutexGuard aGuard;
5235 TimeField* pTimeField = static_cast<TimeField*>(GetWindow());
5236 if ( pTimeField )
5237 pTimeField->SetMax( aTime );
5240 util::Time VCLXTimeField::getMax() throw(::com::sun::star::uno::RuntimeException, std::exception)
5242 SolarMutexGuard aGuard;
5244 TimeField* pTimeField = static_cast<TimeField*>(GetWindow());
5245 if ( pTimeField )
5246 return pTimeField->GetMax().GetUNOTime();
5247 else
5248 return util::Time();
5251 void VCLXTimeField::setFirst( const util::Time& aTime ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5253 SolarMutexGuard aGuard;
5255 TimeField* pTimeField = static_cast<TimeField*>(GetWindow());
5256 if ( pTimeField )
5257 pTimeField->SetFirst( aTime );
5260 util::Time VCLXTimeField::getFirst() throw(::com::sun::star::uno::RuntimeException, std::exception)
5262 SolarMutexGuard aGuard;
5264 TimeField* pTimeField = static_cast<TimeField*>(GetWindow());
5265 if ( pTimeField )
5266 return pTimeField->GetFirst().GetUNOTime();
5267 else
5268 return util::Time();
5271 void VCLXTimeField::setLast( const util::Time& aTime ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5273 SolarMutexGuard aGuard;
5275 TimeField* pTimeField = static_cast<TimeField*>(GetWindow());
5276 if ( pTimeField )
5277 pTimeField->SetLast( aTime );
5280 util::Time VCLXTimeField::getLast() throw(::com::sun::star::uno::RuntimeException, std::exception)
5282 SolarMutexGuard aGuard;
5284 TimeField* pTimeField = static_cast<TimeField*>(GetWindow());
5285 if ( pTimeField )
5286 return pTimeField->GetLast().GetUNOTime();
5287 else
5288 return util::Time();
5291 void VCLXTimeField::setEmpty() throw(::com::sun::star::uno::RuntimeException, std::exception)
5293 SolarMutexGuard aGuard;
5295 TimeField* pTimeField = static_cast<TimeField*>(GetWindow());
5296 if ( pTimeField )
5297 pTimeField->SetEmptyTime();
5300 sal_Bool VCLXTimeField::isEmpty() throw(::com::sun::star::uno::RuntimeException, std::exception)
5302 SolarMutexGuard aGuard;
5304 TimeField* pTimeField = static_cast<TimeField*>(GetWindow());
5305 return pTimeField ? pTimeField->IsEmptyTime() : sal_False;
5308 void VCLXTimeField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5310 VCLXFormattedSpinField::setStrictFormat( bStrict );
5313 sal_Bool VCLXTimeField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException, std::exception)
5315 return VCLXFormattedSpinField::isStrictFormat();
5319 void VCLXTimeField::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
5321 SolarMutexGuard aGuard;
5323 if ( GetWindow() )
5325 bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
5327 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5328 switch ( nPropType )
5330 case BASEPROPERTY_TIME:
5332 if ( bVoid )
5334 static_cast<TimeField*>(GetWindow())->EnableEmptyFieldValue( true );
5335 static_cast<TimeField*>(GetWindow())->SetEmptyFieldValue();
5337 else
5339 util::Time t;
5340 if ( Value >>= t )
5341 setTime( t );
5344 break;
5345 case BASEPROPERTY_TIMEMIN:
5347 util::Time t;
5348 if ( Value >>= t )
5349 setMin( t );
5351 break;
5352 case BASEPROPERTY_TIMEMAX:
5354 util::Time t;
5355 if ( Value >>= t )
5356 setMax( t );
5358 break;
5359 case BASEPROPERTY_EXTTIMEFORMAT:
5361 sal_Int16 n = sal_Int16();
5362 if ( Value >>= n )
5363 static_cast<TimeField*>(GetWindow())->SetExtFormat( (ExtTimeFieldFormat) n );
5365 break;
5366 case BASEPROPERTY_ENFORCE_FORMAT:
5368 bool bEnforce( true );
5369 OSL_VERIFY( Value >>= bEnforce );
5370 static_cast< TimeField* >( GetWindow() )->EnforceValidValue( bEnforce );
5372 break;
5373 default:
5375 VCLXFormattedSpinField::setProperty( PropertyName, Value );
5381 ::com::sun::star::uno::Any VCLXTimeField::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5383 SolarMutexGuard aGuard;
5385 ::com::sun::star::uno::Any aProp;
5386 if ( GetWindow() )
5388 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5389 switch ( nPropType )
5391 case BASEPROPERTY_TIME:
5393 aProp <<= getTime();
5395 break;
5396 case BASEPROPERTY_TIMEMIN:
5398 aProp <<= getMin();
5400 break;
5401 case BASEPROPERTY_TIMEMAX:
5403 aProp <<= getMax();
5405 break;
5406 case BASEPROPERTY_ENFORCE_FORMAT:
5408 aProp <<= static_cast< TimeField* >( GetWindow() )->IsEnforceValidValue( );
5410 break;
5411 default:
5413 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
5417 return aProp;
5421 // class VCLXNumericField
5424 void VCLXNumericField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
5426 PushPropertyIds( rIds,
5427 BASEPROPERTY_ALIGN,
5428 BASEPROPERTY_BACKGROUNDCOLOR,
5429 BASEPROPERTY_BORDER,
5430 BASEPROPERTY_BORDERCOLOR,
5431 BASEPROPERTY_DECIMALACCURACY,
5432 BASEPROPERTY_DEFAULTCONTROL,
5433 BASEPROPERTY_ENABLED,
5434 BASEPROPERTY_ENABLEVISIBLE,
5435 BASEPROPERTY_FONTDESCRIPTOR,
5436 BASEPROPERTY_HELPTEXT,
5437 BASEPROPERTY_HELPURL,
5438 BASEPROPERTY_NUMSHOWTHOUSANDSEP,
5439 BASEPROPERTY_PRINTABLE,
5440 BASEPROPERTY_READONLY,
5441 BASEPROPERTY_REPEAT,
5442 BASEPROPERTY_REPEAT_DELAY,
5443 BASEPROPERTY_SPIN,
5444 BASEPROPERTY_STRICTFORMAT,
5445 BASEPROPERTY_TABSTOP,
5446 BASEPROPERTY_VALUEMAX_DOUBLE,
5447 BASEPROPERTY_VALUEMIN_DOUBLE,
5448 BASEPROPERTY_VALUESTEP_DOUBLE,
5449 BASEPROPERTY_VALUE_DOUBLE,
5450 BASEPROPERTY_ENFORCE_FORMAT,
5451 BASEPROPERTY_HIDEINACTIVESELECTION,
5452 BASEPROPERTY_VERTICALALIGN,
5453 BASEPROPERTY_WRITING_MODE,
5454 BASEPROPERTY_CONTEXT_WRITING_MODE,
5455 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
5457 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5460 VCLXNumericField::VCLXNumericField()
5464 VCLXNumericField::~VCLXNumericField()
5468 // ::com::sun::star::uno::XInterface
5469 ::com::sun::star::uno::Any VCLXNumericField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5471 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
5472 (static_cast< ::com::sun::star::awt::XNumericField* >(this)) );
5473 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
5476 // ::com::sun::star::lang::XTypeProvider
5477 IMPL_XTYPEPROVIDER_START( VCLXNumericField )
5478 cppu::UnoType<com::sun::star::awt::XNumericField>::get(),
5479 VCLXFormattedSpinField::getTypes()
5480 IMPL_XTYPEPROVIDER_END
5482 void VCLXNumericField::setValue( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5484 SolarMutexGuard aGuard;
5486 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5487 if ( pNumericFormatter )
5489 // shift long value using decimal digits
5490 // (e.g., input 105 using 2 digits returns 1,05)
5491 // Thus, to set a value of 1,05, insert 105 and 2 digits
5492 pNumericFormatter->SetValue(
5493 (long)ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() ) );
5495 // #107218# Call same listeners like VCL would do after user interaction
5496 Edit* pEdit = static_cast<Edit*>(GetWindow());
5497 if ( pEdit )
5499 SetSynthesizingVCLEvent( true );
5500 pEdit->SetModifyFlag();
5501 pEdit->Modify();
5502 SetSynthesizingVCLEvent( false );
5507 double VCLXNumericField::getValue() throw(::com::sun::star::uno::RuntimeException, std::exception)
5509 SolarMutexGuard aGuard;
5511 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5512 return pNumericFormatter
5513 ? ImplCalcDoubleValue( (double)pNumericFormatter->GetValue(), pNumericFormatter->GetDecimalDigits() )
5514 : 0;
5517 void VCLXNumericField::setMin( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5519 SolarMutexGuard aGuard;
5521 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5522 if ( pNumericFormatter )
5523 pNumericFormatter->SetMin(
5524 (long)ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() ) );
5527 double VCLXNumericField::getMin() throw(::com::sun::star::uno::RuntimeException, std::exception)
5529 SolarMutexGuard aGuard;
5531 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5532 return pNumericFormatter
5533 ? ImplCalcDoubleValue( (double)pNumericFormatter->GetMin(), pNumericFormatter->GetDecimalDigits() )
5534 : 0;
5537 void VCLXNumericField::setMax( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5539 SolarMutexGuard aGuard;
5541 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5542 if ( pNumericFormatter )
5543 pNumericFormatter->SetMax(
5544 (long)ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() ) );
5547 double VCLXNumericField::getMax() throw(::com::sun::star::uno::RuntimeException, std::exception)
5549 SolarMutexGuard aGuard;
5551 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5552 return pNumericFormatter
5553 ? ImplCalcDoubleValue( (double)pNumericFormatter->GetMax(), pNumericFormatter->GetDecimalDigits() )
5554 : 0;
5557 void VCLXNumericField::setFirst( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5559 SolarMutexGuard aGuard;
5561 NumericField* pNumericField = static_cast<NumericField*>(GetWindow());
5562 if ( pNumericField )
5563 pNumericField->SetFirst(
5564 (long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) );
5567 double VCLXNumericField::getFirst() throw(::com::sun::star::uno::RuntimeException, std::exception)
5569 SolarMutexGuard aGuard;
5571 NumericField* pNumericField = static_cast<NumericField*>(GetWindow());
5572 return pNumericField
5573 ? ImplCalcDoubleValue( (double)pNumericField->GetFirst(), pNumericField->GetDecimalDigits() )
5574 : 0;
5577 void VCLXNumericField::setLast( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5579 SolarMutexGuard aGuard;
5581 NumericField* pNumericField = static_cast<NumericField*>(GetWindow());
5582 if ( pNumericField )
5583 pNumericField->SetLast(
5584 (long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) );
5587 double VCLXNumericField::getLast() throw(::com::sun::star::uno::RuntimeException, std::exception)
5589 SolarMutexGuard aGuard;
5591 NumericField* pNumericField = static_cast<NumericField*>(GetWindow());
5592 return pNumericField
5593 ? ImplCalcDoubleValue( (double)pNumericField->GetLast(), pNumericField->GetDecimalDigits() )
5594 : 0;
5597 void VCLXNumericField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5599 VCLXFormattedSpinField::setStrictFormat( bStrict );
5602 sal_Bool VCLXNumericField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException, std::exception)
5604 return VCLXFormattedSpinField::isStrictFormat();
5608 void VCLXNumericField::setSpinSize( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5610 SolarMutexGuard aGuard;
5612 NumericField* pNumericField = static_cast<NumericField*>(GetWindow());
5613 if ( pNumericField )
5614 pNumericField->SetSpinSize(
5615 (long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) );
5618 double VCLXNumericField::getSpinSize() throw(::com::sun::star::uno::RuntimeException, std::exception)
5620 SolarMutexGuard aGuard;
5622 NumericField* pNumericField = static_cast<NumericField*>(GetWindow());
5623 return pNumericField
5624 ? ImplCalcDoubleValue( (double)pNumericField->GetSpinSize(), pNumericField->GetDecimalDigits() )
5625 : 0;
5628 void VCLXNumericField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5630 SolarMutexGuard aGuard;
5632 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5633 if ( pNumericFormatter )
5635 double n = getValue();
5636 pNumericFormatter->SetDecimalDigits( Value );
5637 setValue( n );
5641 sal_Int16 VCLXNumericField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException, std::exception)
5643 SolarMutexGuard aGuard;
5645 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5646 return pNumericFormatter ? pNumericFormatter->GetDecimalDigits() : 0;
5649 void VCLXNumericField::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
5651 SolarMutexGuard aGuard;
5653 if ( GetWindow() )
5655 bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
5657 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5658 switch ( nPropType )
5660 case BASEPROPERTY_VALUE_DOUBLE:
5662 if ( bVoid )
5664 static_cast<NumericField*>(GetWindow())->EnableEmptyFieldValue( true );
5665 static_cast<NumericField*>(GetWindow())->SetEmptyFieldValue();
5667 else
5669 double d = 0;
5670 if ( Value >>= d )
5671 setValue( d );
5674 break;
5675 case BASEPROPERTY_VALUEMIN_DOUBLE:
5677 double d = 0;
5678 if ( Value >>= d )
5679 setMin( d );
5681 break;
5682 case BASEPROPERTY_VALUEMAX_DOUBLE:
5684 double d = 0;
5685 if ( Value >>= d )
5686 setMax( d );
5688 break;
5689 case BASEPROPERTY_VALUESTEP_DOUBLE:
5691 double d = 0;
5692 if ( Value >>= d )
5693 setSpinSize( d );
5695 break;
5696 case BASEPROPERTY_DECIMALACCURACY:
5698 sal_Int16 n = sal_Int16();
5699 if ( Value >>= n )
5700 setDecimalDigits( n );
5702 break;
5703 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5705 bool b = bool();
5706 if ( Value >>= b )
5707 static_cast<NumericField*>(GetWindow())->SetUseThousandSep( b );
5709 break;
5710 default:
5712 VCLXFormattedSpinField::setProperty( PropertyName, Value );
5718 ::com::sun::star::uno::Any VCLXNumericField::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5720 SolarMutexGuard aGuard;
5722 ::com::sun::star::uno::Any aProp;
5723 FormatterBase* pFormatter = GetFormatter();
5724 if ( pFormatter )
5726 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5727 switch ( nPropType )
5729 case BASEPROPERTY_VALUE_DOUBLE:
5731 aProp <<= (double) getValue();
5733 break;
5734 case BASEPROPERTY_VALUEMIN_DOUBLE:
5736 aProp <<= (double) getMin();
5738 break;
5739 case BASEPROPERTY_VALUEMAX_DOUBLE:
5741 aProp <<= (double) getMax();
5743 break;
5744 case BASEPROPERTY_VALUESTEP_DOUBLE:
5746 aProp <<= (double) getSpinSize();
5748 break;
5749 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5751 aProp <<= static_cast<NumericField*>(GetWindow())->IsUseThousandSep();
5753 break;
5754 default:
5756 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
5760 return aProp;
5764 // ----------------------------------------------------
5765 // class VCLXMetricField
5766 // ----------------------------------------------------
5768 void VCLXMetricField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
5770 PushPropertyIds( rIds,
5771 BASEPROPERTY_ALIGN,
5772 BASEPROPERTY_BACKGROUNDCOLOR,
5773 BASEPROPERTY_BORDER,
5774 BASEPROPERTY_BORDERCOLOR,
5775 BASEPROPERTY_DECIMALACCURACY,
5776 BASEPROPERTY_DEFAULTCONTROL,
5777 BASEPROPERTY_ENABLED,
5778 BASEPROPERTY_ENABLEVISIBLE,
5779 BASEPROPERTY_FONTDESCRIPTOR,
5780 BASEPROPERTY_HELPTEXT,
5781 BASEPROPERTY_HELPURL,
5782 BASEPROPERTY_NUMSHOWTHOUSANDSEP,
5783 BASEPROPERTY_PRINTABLE,
5784 BASEPROPERTY_READONLY,
5785 BASEPROPERTY_REPEAT,
5786 BASEPROPERTY_REPEAT_DELAY,
5787 BASEPROPERTY_SPIN,
5788 BASEPROPERTY_STRICTFORMAT,
5789 BASEPROPERTY_TABSTOP,
5790 BASEPROPERTY_ENFORCE_FORMAT,
5791 BASEPROPERTY_HIDEINACTIVESELECTION,
5792 BASEPROPERTY_UNIT,
5793 BASEPROPERTY_CUSTOMUNITTEXT,
5794 BASEPROPERTY_WRITING_MODE,
5795 BASEPROPERTY_CONTEXT_WRITING_MODE,
5796 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
5798 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5801 VCLXMetricField::VCLXMetricField()
5805 VCLXMetricField::~VCLXMetricField()
5809 MetricFormatter *VCLXMetricField::GetMetricFormatter() throw(::com::sun::star::uno::RuntimeException)
5811 MetricFormatter *pFormatter = static_cast<MetricFormatter *>(GetFormatter());
5812 if (!pFormatter)
5813 throw ::com::sun::star::uno::RuntimeException();
5814 return pFormatter;
5817 MetricField *VCLXMetricField::GetMetricField() throw(::com::sun::star::uno::RuntimeException)
5819 MetricField *pField = static_cast<MetricField *>(GetWindow());
5820 if (!pField)
5821 throw ::com::sun::star::uno::RuntimeException();
5822 return pField;
5825 // ::com::sun::star::uno::XInterface
5826 ::com::sun::star::uno::Any VCLXMetricField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5828 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
5829 (static_cast< ::com::sun::star::awt::XMetricField* >(this)) );
5830 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
5833 // ::com::sun::star::lang::XTypeProvider
5834 IMPL_XTYPEPROVIDER_START( VCLXMetricField )
5835 cppu::UnoType<com::sun::star::awt::XMetricField>::get(),
5836 VCLXFormattedSpinField::getTypes()
5837 IMPL_XTYPEPROVIDER_END
5839 // FIXME: later ...
5840 #define MetricUnitUnoToVcl(a) ((FieldUnit)(a))
5842 #define METRIC_MAP_PAIR(method,parent) \
5843 sal_Int64 VCLXMetricField::get##method( sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException, std::exception) \
5845 SolarMutexGuard aGuard; \
5846 return GetMetric##parent()->Get##method( MetricUnitUnoToVcl( nUnit ) ); \
5848 void VCLXMetricField::set##method( sal_Int64 nValue, sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException, std::exception) \
5850 SolarMutexGuard aGuard; \
5851 GetMetric##parent()->Set##method( nValue, MetricUnitUnoToVcl( nUnit ) ); \
5854 METRIC_MAP_PAIR(Min, Formatter)
5855 METRIC_MAP_PAIR(Max, Formatter)
5856 METRIC_MAP_PAIR(First, Field)
5857 METRIC_MAP_PAIR(Last, Field)
5859 #undef METRIC_MAP_PAIR
5861 ::sal_Int64 VCLXMetricField::getValue( ::sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException, std::exception)
5863 SolarMutexGuard aGuard;
5864 return GetMetricFormatter()->GetValue( MetricUnitUnoToVcl( nUnit ) );
5867 ::sal_Int64 VCLXMetricField::getCorrectedValue( ::sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException, std::exception)
5869 SolarMutexGuard aGuard;
5870 return GetMetricFormatter()->GetCorrectedValue( MetricUnitUnoToVcl( nUnit ) );
5873 // FIXME: acute cut/paste evilness - move this to the parent Edit class ?
5874 void VCLXMetricField::CallListeners()
5876 // #107218# Call same listeners like VCL would do after user interaction
5877 Edit* pEdit = static_cast<Edit*>(GetWindow());
5878 if ( pEdit )
5880 SetSynthesizingVCLEvent( true );
5881 pEdit->SetModifyFlag();
5882 pEdit->Modify();
5883 SetSynthesizingVCLEvent( false );
5887 void VCLXMetricField::setValue( ::sal_Int64 Value, ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException, std::exception)
5889 SolarMutexGuard aGuard;
5890 GetMetricFormatter()->SetValue( Value, MetricUnitUnoToVcl( Unit ) );
5891 CallListeners();
5894 void VCLXMetricField::setUserValue( ::sal_Int64 Value, ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException, std::exception)
5896 SolarMutexGuard aGuard;
5897 GetMetricFormatter()->SetUserValue( Value, MetricUnitUnoToVcl( Unit ) );
5898 CallListeners();
5901 void VCLXMetricField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5903 VCLXFormattedSpinField::setStrictFormat( bStrict );
5906 sal_Bool VCLXMetricField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException, std::exception)
5908 return VCLXFormattedSpinField::isStrictFormat();
5911 void VCLXMetricField::setSpinSize( sal_Int64 Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5913 SolarMutexGuard aGuard;
5914 GetMetricField()->SetSpinSize( Value );
5917 sal_Int64 VCLXMetricField::getSpinSize() throw(::com::sun::star::uno::RuntimeException, std::exception)
5919 SolarMutexGuard aGuard;
5920 return GetMetricField()->GetSpinSize();
5923 void VCLXMetricField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5925 SolarMutexGuard aGuard;
5926 GetMetricFormatter()->SetDecimalDigits( Value );
5929 sal_Int16 VCLXMetricField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException, std::exception)
5931 SolarMutexGuard aGuard;
5933 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5934 return pNumericFormatter ? pNumericFormatter->GetDecimalDigits() : 0;
5937 void VCLXMetricField::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
5939 SolarMutexGuard aGuard;
5941 if ( GetWindow() )
5943 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5944 switch ( nPropType )
5946 case BASEPROPERTY_DECIMALACCURACY:
5948 sal_Int16 n = 0;
5949 if ( Value >>= n )
5950 setDecimalDigits( n );
5951 break;
5953 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5955 bool b = false;
5956 if ( Value >>= b )
5957 static_cast<NumericField*>(GetWindow())->SetUseThousandSep( b );
5959 break;
5960 case BASEPROPERTY_UNIT:
5962 sal_uInt16 nVal = 0;
5963 if ( Value >>= nVal )
5964 static_cast<MetricField*>(GetWindow())->SetUnit( (FieldUnit) nVal );
5965 break;
5967 case BASEPROPERTY_CUSTOMUNITTEXT:
5969 OUString aStr;
5970 if ( Value >>= aStr )
5971 static_cast<MetricField*>(GetWindow())->SetCustomUnitText( aStr );
5972 break;
5974 default:
5976 VCLXFormattedSpinField::setProperty( PropertyName, Value );
5977 break;
5983 ::com::sun::star::uno::Any VCLXMetricField::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5985 SolarMutexGuard aGuard;
5987 ::com::sun::star::uno::Any aProp;
5988 FormatterBase* pFormatter = GetFormatter();
5989 if ( pFormatter )
5991 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5992 switch ( nPropType )
5994 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5995 aProp <<= static_cast<NumericField*>(GetWindow())->IsUseThousandSep();
5996 break;
5997 case BASEPROPERTY_UNIT:
5998 aProp <<= (sal_uInt16) (static_cast<MetricField*>(GetWindow())->GetUnit());
5999 break;
6000 case BASEPROPERTY_CUSTOMUNITTEXT:
6001 aProp <<= OUString( static_cast<MetricField*>(GetWindow())->GetCustomUnitText() );
6002 break;
6003 default:
6005 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
6006 break;
6010 return aProp;
6015 // class VCLXCurrencyField
6018 void VCLXCurrencyField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
6020 PushPropertyIds( rIds,
6021 BASEPROPERTY_ALIGN,
6022 BASEPROPERTY_BACKGROUNDCOLOR,
6023 BASEPROPERTY_BORDER,
6024 BASEPROPERTY_BORDERCOLOR,
6025 BASEPROPERTY_CURRENCYSYMBOL,
6026 BASEPROPERTY_CURSYM_POSITION,
6027 BASEPROPERTY_DECIMALACCURACY,
6028 BASEPROPERTY_DEFAULTCONTROL,
6029 BASEPROPERTY_ENABLED,
6030 BASEPROPERTY_ENABLEVISIBLE,
6031 BASEPROPERTY_FONTDESCRIPTOR,
6032 BASEPROPERTY_HELPTEXT,
6033 BASEPROPERTY_HELPURL,
6034 BASEPROPERTY_NUMSHOWTHOUSANDSEP,
6035 BASEPROPERTY_PRINTABLE,
6036 BASEPROPERTY_READONLY,
6037 BASEPROPERTY_REPEAT,
6038 BASEPROPERTY_REPEAT_DELAY,
6039 BASEPROPERTY_SPIN,
6040 BASEPROPERTY_STRICTFORMAT,
6041 BASEPROPERTY_TABSTOP,
6042 BASEPROPERTY_VALUEMAX_DOUBLE,
6043 BASEPROPERTY_VALUEMIN_DOUBLE,
6044 BASEPROPERTY_VALUESTEP_DOUBLE,
6045 BASEPROPERTY_VALUE_DOUBLE,
6046 BASEPROPERTY_ENFORCE_FORMAT,
6047 BASEPROPERTY_HIDEINACTIVESELECTION,
6048 BASEPROPERTY_VERTICALALIGN,
6049 BASEPROPERTY_WRITING_MODE,
6050 BASEPROPERTY_CONTEXT_WRITING_MODE,
6051 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
6053 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
6056 VCLXCurrencyField::VCLXCurrencyField()
6060 VCLXCurrencyField::~VCLXCurrencyField()
6064 // ::com::sun::star::uno::XInterface
6065 ::com::sun::star::uno::Any VCLXCurrencyField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6067 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
6068 (static_cast< ::com::sun::star::awt::XCurrencyField* >(this)) );
6069 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
6072 // ::com::sun::star::lang::XTypeProvider
6073 IMPL_XTYPEPROVIDER_START( VCLXCurrencyField )
6074 cppu::UnoType<com::sun::star::awt::XCurrencyField>::get(),
6075 VCLXFormattedSpinField::getTypes()
6076 IMPL_XTYPEPROVIDER_END
6078 void VCLXCurrencyField::setValue( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6080 SolarMutexGuard aGuard;
6082 LongCurrencyFormatter* pCurrencyFormatter = static_cast<LongCurrencyFormatter*>(GetFormatter());
6083 if ( pCurrencyFormatter )
6085 // shift long value using decimal digits
6086 // (e.g., input 105 using 2 digits returns 1,05)
6087 // Thus, to set a value of 1,05, insert 105 and 2 digits
6088 pCurrencyFormatter->SetValue(
6089 ImplCalcLongValue( Value, pCurrencyFormatter->GetDecimalDigits() ) );
6091 // #107218# Call same listeners like VCL would do after user interaction
6092 Edit* pEdit = static_cast<Edit*>(GetWindow());
6093 if ( pEdit )
6095 SetSynthesizingVCLEvent( true );
6096 pEdit->SetModifyFlag();
6097 pEdit->Modify();
6098 SetSynthesizingVCLEvent( false );
6103 double VCLXCurrencyField::getValue() throw(::com::sun::star::uno::RuntimeException, std::exception)
6105 SolarMutexGuard aGuard;
6107 LongCurrencyFormatter* pCurrencyFormatter = static_cast<LongCurrencyFormatter*>(GetFormatter());
6108 return pCurrencyFormatter
6109 ? ImplCalcDoubleValue( (double)pCurrencyFormatter->GetValue(), pCurrencyFormatter->GetDecimalDigits() )
6110 : 0;
6113 void VCLXCurrencyField::setMin( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6115 SolarMutexGuard aGuard;
6117 LongCurrencyFormatter* pCurrencyFormatter = static_cast<LongCurrencyFormatter*>(GetFormatter());
6118 if ( pCurrencyFormatter )
6119 pCurrencyFormatter->SetMin(
6120 ImplCalcLongValue( Value, pCurrencyFormatter->GetDecimalDigits() ) );
6123 double VCLXCurrencyField::getMin() throw(::com::sun::star::uno::RuntimeException, std::exception)
6125 SolarMutexGuard aGuard;
6127 LongCurrencyFormatter* pCurrencyFormatter = static_cast<LongCurrencyFormatter*>(GetFormatter());
6128 return pCurrencyFormatter
6129 ? ImplCalcDoubleValue( (double)pCurrencyFormatter->GetMin(), pCurrencyFormatter->GetDecimalDigits() )
6130 : 0;
6133 void VCLXCurrencyField::setMax( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6135 SolarMutexGuard aGuard;
6137 LongCurrencyFormatter* pCurrencyFormatter = static_cast<LongCurrencyFormatter*>(GetFormatter());
6138 if ( pCurrencyFormatter )
6139 pCurrencyFormatter->SetMax(
6140 ImplCalcLongValue( Value, pCurrencyFormatter->GetDecimalDigits() ) );
6143 double VCLXCurrencyField::getMax() throw(::com::sun::star::uno::RuntimeException, std::exception)
6145 SolarMutexGuard aGuard;
6147 LongCurrencyFormatter* pCurrencyFormatter = static_cast<LongCurrencyFormatter*>(GetFormatter());
6148 return pCurrencyFormatter
6149 ? ImplCalcDoubleValue( (double)pCurrencyFormatter->GetMax(), pCurrencyFormatter->GetDecimalDigits() )
6150 : 0;
6153 void VCLXCurrencyField::setFirst( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6155 SolarMutexGuard aGuard;
6157 LongCurrencyField* pCurrencyField = static_cast<LongCurrencyField*>(GetWindow());
6158 if ( pCurrencyField )
6159 pCurrencyField->SetFirst(
6160 ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) );
6163 double VCLXCurrencyField::getFirst() throw(::com::sun::star::uno::RuntimeException, std::exception)
6165 SolarMutexGuard aGuard;
6167 LongCurrencyField* pCurrencyField = static_cast<LongCurrencyField*>(GetWindow());
6168 return pCurrencyField
6169 ? ImplCalcDoubleValue( (double)pCurrencyField->GetFirst(), pCurrencyField->GetDecimalDigits() )
6170 : 0;
6173 void VCLXCurrencyField::setLast( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6175 SolarMutexGuard aGuard;
6177 LongCurrencyField* pCurrencyField = static_cast<LongCurrencyField*>(GetWindow());
6178 if ( pCurrencyField )
6179 pCurrencyField->SetLast(
6180 ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) );
6183 double VCLXCurrencyField::getLast() throw(::com::sun::star::uno::RuntimeException, std::exception)
6185 SolarMutexGuard aGuard;
6187 LongCurrencyField* pCurrencyField = static_cast<LongCurrencyField*>(GetWindow());
6188 return pCurrencyField
6189 ? ImplCalcDoubleValue( (double)pCurrencyField->GetLast(), pCurrencyField->GetDecimalDigits() )
6190 : 0;
6193 void VCLXCurrencyField::setSpinSize( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6195 SolarMutexGuard aGuard;
6197 LongCurrencyField* pCurrencyField = static_cast<LongCurrencyField*>(GetWindow());
6198 if ( pCurrencyField )
6199 pCurrencyField->SetSpinSize(
6200 ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) );
6203 double VCLXCurrencyField::getSpinSize() throw(::com::sun::star::uno::RuntimeException, std::exception)
6205 SolarMutexGuard aGuard;
6207 LongCurrencyField* pCurrencyField = static_cast<LongCurrencyField*>(GetWindow());
6208 return pCurrencyField
6209 ? ImplCalcDoubleValue( (double)pCurrencyField->GetSpinSize(), pCurrencyField->GetDecimalDigits() )
6210 : 0;
6213 void VCLXCurrencyField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6215 VCLXFormattedSpinField::setStrictFormat( bStrict );
6218 sal_Bool VCLXCurrencyField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException, std::exception)
6220 return VCLXFormattedSpinField::isStrictFormat();
6224 void VCLXCurrencyField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6226 SolarMutexGuard aGuard;
6228 LongCurrencyFormatter* pCurrencyFormatter = static_cast<LongCurrencyFormatter*>(GetFormatter());
6229 if ( pCurrencyFormatter )
6231 double n = getValue();
6232 pCurrencyFormatter->SetDecimalDigits( Value );
6233 setValue( n );
6237 sal_Int16 VCLXCurrencyField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException, std::exception)
6239 SolarMutexGuard aGuard;
6241 LongCurrencyFormatter* pCurrencyFormatter = static_cast<LongCurrencyFormatter*>(GetFormatter());
6242 return pCurrencyFormatter ? pCurrencyFormatter->GetDecimalDigits() : 0;
6245 void VCLXCurrencyField::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
6247 SolarMutexGuard aGuard;
6249 if ( GetWindow() )
6251 bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
6253 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6254 switch ( nPropType )
6256 case BASEPROPERTY_VALUE_DOUBLE:
6258 if ( bVoid )
6260 static_cast<LongCurrencyField*>(GetWindow())->EnableEmptyFieldValue( true );
6261 static_cast<LongCurrencyField*>(GetWindow())->SetEmptyFieldValue();
6263 else
6265 double d = 0;
6266 if ( Value >>= d )
6267 setValue( d );
6270 break;
6271 case BASEPROPERTY_VALUEMIN_DOUBLE:
6273 double d = 0;
6274 if ( Value >>= d )
6275 setMin( d );
6277 break;
6278 case BASEPROPERTY_VALUEMAX_DOUBLE:
6280 double d = 0;
6281 if ( Value >>= d )
6282 setMax( d );
6284 break;
6285 case BASEPROPERTY_VALUESTEP_DOUBLE:
6287 double d = 0;
6288 if ( Value >>= d )
6289 setSpinSize( d );
6291 break;
6292 case BASEPROPERTY_DECIMALACCURACY:
6294 sal_Int16 n = sal_Int16();
6295 if ( Value >>= n )
6296 setDecimalDigits( n );
6298 break;
6299 case BASEPROPERTY_CURRENCYSYMBOL:
6301 OUString aString;
6302 if ( Value >>= aString )
6303 static_cast<LongCurrencyField*>(GetWindow())->SetCurrencySymbol( aString );
6305 break;
6306 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
6308 bool b = bool();
6309 if ( Value >>= b )
6310 static_cast<LongCurrencyField*>(GetWindow())->SetUseThousandSep( b );
6312 break;
6313 default:
6315 VCLXFormattedSpinField::setProperty( PropertyName, Value );
6321 ::com::sun::star::uno::Any VCLXCurrencyField::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6323 SolarMutexGuard aGuard;
6325 ::com::sun::star::uno::Any aProp;
6326 FormatterBase* pFormatter = GetFormatter();
6327 if ( pFormatter )
6329 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6330 switch ( nPropType )
6332 case BASEPROPERTY_VALUE_DOUBLE:
6334 aProp <<= (double) getValue();
6336 break;
6337 case BASEPROPERTY_VALUEMIN_DOUBLE:
6339 aProp <<= (double) getMin();
6341 break;
6342 case BASEPROPERTY_VALUEMAX_DOUBLE:
6344 aProp <<= (double) getMax();
6346 break;
6347 case BASEPROPERTY_VALUESTEP_DOUBLE:
6349 aProp <<= (double) getSpinSize();
6351 break;
6352 case BASEPROPERTY_CURRENCYSYMBOL:
6354 aProp <<= OUString( static_cast<LongCurrencyField*>(GetWindow())->GetCurrencySymbol() );
6356 break;
6357 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
6359 aProp <<= static_cast<LongCurrencyField*>(GetWindow())->IsUseThousandSep();
6361 break;
6362 default:
6364 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
6368 return aProp;
6372 // class VCLXPatternField
6375 void VCLXPatternField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
6377 PushPropertyIds( rIds,
6378 BASEPROPERTY_ALIGN,
6379 BASEPROPERTY_BACKGROUNDCOLOR,
6380 BASEPROPERTY_BORDER,
6381 BASEPROPERTY_BORDERCOLOR,
6382 BASEPROPERTY_DEFAULTCONTROL,
6383 BASEPROPERTY_EDITMASK,
6384 BASEPROPERTY_ENABLED,
6385 BASEPROPERTY_ENABLEVISIBLE,
6386 BASEPROPERTY_FONTDESCRIPTOR,
6387 BASEPROPERTY_HELPTEXT,
6388 BASEPROPERTY_HELPURL,
6389 BASEPROPERTY_LITERALMASK,
6390 BASEPROPERTY_MAXTEXTLEN,
6391 BASEPROPERTY_PRINTABLE,
6392 BASEPROPERTY_READONLY,
6393 BASEPROPERTY_STRICTFORMAT,
6394 BASEPROPERTY_TABSTOP,
6395 BASEPROPERTY_TEXT,
6396 BASEPROPERTY_HIDEINACTIVESELECTION,
6397 BASEPROPERTY_VERTICALALIGN,
6398 BASEPROPERTY_WRITING_MODE,
6399 BASEPROPERTY_CONTEXT_WRITING_MODE,
6400 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
6402 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
6405 VCLXPatternField::VCLXPatternField()
6409 VCLXPatternField::~VCLXPatternField()
6413 // ::com::sun::star::uno::XInterface
6414 ::com::sun::star::uno::Any VCLXPatternField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6416 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
6417 (static_cast< ::com::sun::star::awt::XPatternField* >(this)) );
6418 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
6421 // ::com::sun::star::lang::XTypeProvider
6422 IMPL_XTYPEPROVIDER_START( VCLXPatternField )
6423 cppu::UnoType<com::sun::star::awt::XPatternField>::get(),
6424 VCLXFormattedSpinField::getTypes()
6425 IMPL_XTYPEPROVIDER_END
6427 void VCLXPatternField::setMasks( const OUString& EditMask, const OUString& LiteralMask ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6429 SolarMutexGuard aGuard;
6431 PatternField* pPatternField = static_cast<PatternField*>(GetWindow());
6432 if ( pPatternField )
6434 pPatternField->SetMask( OUStringToOString(EditMask, RTL_TEXTENCODING_ASCII_US), LiteralMask );
6438 void VCLXPatternField::getMasks( OUString& EditMask, OUString& LiteralMask ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6440 SolarMutexGuard aGuard;
6442 PatternField* pPatternField = static_cast<PatternField*>(GetWindow());
6443 if ( pPatternField )
6445 EditMask = OStringToOUString(pPatternField->GetEditMask(), RTL_TEXTENCODING_ASCII_US);
6446 LiteralMask = pPatternField->GetLiteralMask();
6450 void VCLXPatternField::setString( const OUString& Str ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6452 SolarMutexGuard aGuard;
6454 PatternField* pPatternField = static_cast<PatternField*>(GetWindow());
6455 if ( pPatternField )
6457 pPatternField->SetString( Str );
6461 OUString VCLXPatternField::getString() throw(::com::sun::star::uno::RuntimeException, std::exception)
6463 SolarMutexGuard aGuard;
6465 OUString aString;
6466 PatternField* pPatternField = static_cast<PatternField*>(GetWindow());
6467 if ( pPatternField )
6468 aString = pPatternField->GetString();
6469 return aString;
6472 void VCLXPatternField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6474 VCLXFormattedSpinField::setStrictFormat( bStrict );
6477 sal_Bool VCLXPatternField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException, std::exception)
6479 return VCLXFormattedSpinField::isStrictFormat();
6482 void VCLXPatternField::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
6484 SolarMutexGuard aGuard;
6486 if ( GetWindow() )
6488 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6489 switch ( nPropType )
6491 case BASEPROPERTY_EDITMASK:
6492 case BASEPROPERTY_LITERALMASK:
6494 OUString aString;
6495 if ( Value >>= aString )
6497 OUString aEditMask, aLiteralMask;
6498 getMasks( aEditMask, aLiteralMask );
6499 if ( nPropType == BASEPROPERTY_EDITMASK )
6500 aEditMask = aString;
6501 else
6502 aLiteralMask = aString;
6503 setMasks( aEditMask, aLiteralMask );
6506 break;
6507 default:
6509 VCLXFormattedSpinField::setProperty( PropertyName, Value );
6515 ::com::sun::star::uno::Any VCLXPatternField::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6517 SolarMutexGuard aGuard;
6519 ::com::sun::star::uno::Any aProp;
6520 if ( GetWindow() )
6522 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6523 switch ( nPropType )
6525 case BASEPROPERTY_EDITMASK:
6526 case BASEPROPERTY_LITERALMASK:
6528 OUString aEditMask, aLiteralMask;
6529 getMasks( aEditMask, aLiteralMask );
6530 if ( nPropType == BASEPROPERTY_EDITMASK )
6531 aProp <<= aEditMask;
6532 else
6533 aProp <<= aLiteralMask;
6535 break;
6536 default:
6538 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
6542 return aProp;
6546 // class VCLXToolBox
6548 VCLXToolBox::VCLXToolBox()
6552 VCLXToolBox::~VCLXToolBox()
6556 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXToolBox::CreateAccessibleContext()
6558 return getAccessibleFactory().createAccessibleContext( this );
6562 // class VCLXFrame
6564 VCLXFrame::VCLXFrame()
6568 void VCLXFrame::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
6570 PushPropertyIds( rIds,
6571 BASEPROPERTY_BACKGROUNDCOLOR,
6572 BASEPROPERTY_DEFAULTCONTROL,
6573 BASEPROPERTY_ENABLED,
6574 BASEPROPERTY_ENABLEVISIBLE,
6575 BASEPROPERTY_FONTDESCRIPTOR,
6576 BASEPROPERTY_GRAPHIC,
6577 BASEPROPERTY_HELPTEXT,
6578 BASEPROPERTY_HELPURL,
6579 BASEPROPERTY_PRINTABLE,
6580 BASEPROPERTY_LABEL,
6582 VCLXContainer::ImplGetPropertyIds( rIds );
6585 VCLXFrame::~VCLXFrame()
6589 ::com::sun::star::uno::Any SAL_CALL VCLXFrame::queryInterface(const ::com::sun::star::uno::Type & rType )
6590 throw(::com::sun::star::uno::RuntimeException, std::exception)
6592 return VCLXContainer::queryInterface( rType );
6595 // ::com::sun::star::lang::XTypeProvider
6596 IMPL_XTYPEPROVIDER_START( VCLXFrame )
6597 VCLXContainer::getTypes()
6598 IMPL_XTYPEPROVIDER_END
6600 // ::com::sun::star::awt::XView
6601 void SAL_CALL VCLXFrame::draw( sal_Int32 nX, sal_Int32 nY )
6602 throw(::com::sun::star::uno::RuntimeException, std::exception)
6604 SolarMutexGuard aGuard;
6605 vcl::Window* pWindow = GetWindow();
6607 if ( pWindow )
6609 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
6610 if ( !pDev )
6611 pDev = pWindow->GetParent();
6613 Size aSize = pDev->PixelToLogic( pWindow->GetSizePixel() );
6614 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
6616 pWindow->Draw( pDev, aPos, aSize, WINDOW_DRAW_NOCONTROLS );
6620 // ::com::sun::star::awt::XDevice,
6621 ::com::sun::star::awt::DeviceInfo SAL_CALL VCLXFrame::getInfo()
6622 throw(::com::sun::star::uno::RuntimeException, std::exception)
6624 ::com::sun::star::awt::DeviceInfo aInfo = VCLXDevice::getInfo();
6625 return aInfo;
6628 void SAL_CALL VCLXFrame::setProperty(
6629 const OUString& PropertyName,
6630 const ::com::sun::star::uno::Any& Value )
6631 throw(::com::sun::star::uno::RuntimeException, std::exception)
6633 SolarMutexGuard aGuard;
6635 VCLXContainer::setProperty( PropertyName, Value );
6638 void VCLXFrame::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
6640 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
6641 VCLXContainer::ProcessWindowEvent( rVclWindowEvent );
6644 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */