Bump version to 24.04.3.4
[LibreOffice.git] / toolkit / source / awt / vclxwindows.cxx
blobd6ba5e48a6e88590049db7802c985e76663b92a7
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/helper/accessiblefactory.hxx>
22 #include <com/sun/star/awt/LineEndFormat.hpp>
23 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
24 #include <com/sun/star/graphic/GraphicProvider.hpp>
25 #include <com/sun/star/graphic/XGraphicProvider.hpp>
26 #include <toolkit/helper/vclunohelper.hxx>
27 #include <helper/property.hxx>
28 #include <toolkit/helper/convert.hxx>
29 #include <com/sun/star/awt/VisualEffect.hpp>
30 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
31 #include <com/sun/star/resource/XStringResourceResolver.hpp>
32 #include <com/sun/star/awt/ImageScaleMode.hpp>
33 #include <com/sun/star/awt/XItemList.hpp>
34 #include <com/sun/star/awt/TextAlign.hpp>
35 #include <comphelper/namedvaluecollection.hxx>
36 #include <comphelper/processfactory.hxx>
37 #include <sal/log.hxx>
39 #include <awt/vclxwindows.hxx>
40 #include <controls/filectrl.hxx>
41 #include <controls/svmedit.hxx>
42 #include <vcl/toolkit/button.hxx>
43 #include <vcl/toolkit/fmtfield.hxx>
44 #include <vcl/graph.hxx>
45 #include <vcl/toolkit/lstbox.hxx>
46 #include <vcl/toolkit/combobox.hxx>
47 #include <vcl/toolkit/field.hxx>
48 #include <vcl/toolkit/fixedhyper.hxx>
49 #include <vcl/toolkit/imgctrl.hxx>
50 #include <vcl/toolkit/dialog.hxx>
51 #include <vcl/toolkit/prgsbar.hxx>
52 #include <vcl/toolkit/scrbar.hxx>
53 #include <vcl/svapp.hxx>
54 #include <vcl/tabpage.hxx>
55 #include <vcl/tabctrl.hxx>
56 #include <vcl/settings.hxx>
57 #include <comphelper/diagnose_ex.hxx>
58 #include <tools/debug.hxx>
60 #include <helper/imagealign.hxx>
61 #include <helper/msgbox.hxx>
62 #include <helper/tkresmgr.hxx>
63 #include "vclxwindows_internal.hxx"
64 #include <svl/numformat.hxx>
66 using ::com::sun::star::uno::Any;
67 using ::com::sun::star::uno::Reference;
68 using ::com::sun::star::uno::RuntimeException;
69 using ::com::sun::star::lang::EventObject;
70 using ::com::sun::star::awt::ItemListEvent;
71 using ::com::sun::star::awt::XItemList;
72 using ::com::sun::star::graphic::XGraphic;
73 using ::com::sun::star::graphic::XGraphicProvider;
75 using namespace ::com::sun::star;
76 using namespace ::com::sun::star::awt::VisualEffect;
77 namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode;
79 static double ImplCalcLongValue( double nValue, sal_uInt16 nDigits )
81 double n = nValue;
82 for ( sal_uInt16 d = 0; d < nDigits; d++ )
83 n *= 10;
84 return n;
87 static double ImplCalcDoubleValue( double nValue, sal_uInt16 nDigits )
89 double n = nValue;
90 for ( sal_uInt16 d = 0; d < nDigits; d++ )
91 n /= 10;
92 return n;
95 namespace toolkit
97 /** sets the "face color" for button like controls (scroll bar, spin button)
99 void setButtonLikeFaceColor( vcl::Window* _pWindow, const css::uno::Any& _rColorValue )
101 AllSettings aSettings = _pWindow->GetSettings();
102 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
104 if ( !_rColorValue.hasValue() )
106 const StyleSettings& aAppStyle = Application::GetSettings().GetStyleSettings();
107 aStyleSettings.SetFaceColor( aAppStyle.GetFaceColor( ) );
108 aStyleSettings.SetCheckedColor( aAppStyle.GetCheckedColor( ) );
109 aStyleSettings.SetLightBorderColor( aAppStyle.GetLightBorderColor() );
110 aStyleSettings.SetLightColor( aAppStyle.GetLightColor() );
111 aStyleSettings.SetShadowColor( aAppStyle.GetShadowColor() );
112 aStyleSettings.SetDarkShadowColor( aAppStyle.GetDarkShadowColor() );
114 else
116 Color nBackgroundColor;
117 _rColorValue >>= nBackgroundColor;
118 aStyleSettings.SetFaceColor( nBackgroundColor );
120 // for the real background (everything except the buttons and the thumb),
121 // use an average between the desired color and "white"
122 Color aWhite( COL_WHITE );
123 Color aCheckedBackground( nBackgroundColor );
124 aCheckedBackground.SetRed( ( aCheckedBackground.GetRed() + aWhite.GetRed() ) / 2 );
125 aCheckedBackground.SetGreen( ( aCheckedBackground.GetGreen() + aWhite.GetGreen() ) / 2 );
126 aCheckedBackground.SetBlue( ( aCheckedBackground.GetBlue() + aWhite.GetBlue() ) / 2 );
127 aStyleSettings.SetCheckedColor( aCheckedBackground );
129 sal_Int32 nBackgroundLuminance = nBackgroundColor.GetLuminance();
130 sal_Int32 nWhiteLuminance = COL_WHITE.GetLuminance();
132 Color aLightShadow( nBackgroundColor );
133 aLightShadow.IncreaseLuminance( static_cast<sal_uInt8>( ( nWhiteLuminance - nBackgroundLuminance ) * 2 / 3 ) );
134 aStyleSettings.SetLightBorderColor( aLightShadow );
136 Color aLight( nBackgroundColor );
137 aLight.IncreaseLuminance( static_cast<sal_uInt8>( ( nWhiteLuminance - nBackgroundLuminance ) * 1 / 3 ) );
138 aStyleSettings.SetLightColor( aLight );
140 Color aShadow( nBackgroundColor );
141 aShadow.DecreaseLuminance( static_cast<sal_uInt8>( nBackgroundLuminance * 1 / 3 ) );
142 aStyleSettings.SetShadowColor( aShadow );
144 Color aDarkShadow( nBackgroundColor );
145 aDarkShadow.DecreaseLuminance( static_cast<sal_uInt8>( nBackgroundLuminance * 2 / 3 ) );
146 aStyleSettings.SetDarkShadowColor( aDarkShadow );
149 aSettings.SetStyleSettings( aStyleSettings );
150 _pWindow->SetSettings( aSettings, true );
153 Any getButtonLikeFaceColor( const vcl::Window* _pWindow )
155 Color nBackgroundColor = _pWindow->GetSettings().GetStyleSettings().GetFaceColor();
156 return Any( sal_Int32(nBackgroundColor) );
159 static void adjustBooleanWindowStyle( const Any& _rValue, vcl::Window* _pWindow, WinBits _nBits, bool _bInverseSemantics )
161 WinBits nStyle = _pWindow->GetStyle();
162 bool bValue( false );
163 OSL_VERIFY( _rValue >>= bValue );
164 if ( bValue != _bInverseSemantics )
165 nStyle |= _nBits;
166 else
167 nStyle &= ~_nBits;
168 _pWindow->SetStyle( nStyle );
171 static void setVisualEffect( const Any& _rValue, vcl::Window* _pWindow )
173 AllSettings aSettings = _pWindow->GetSettings();
174 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
176 sal_Int16 nStyle = LOOK3D;
177 OSL_VERIFY( _rValue >>= nStyle );
178 switch ( nStyle )
180 case FLAT:
181 aStyleSettings.SetOptions( aStyleSettings.GetOptions() | StyleSettingsOptions::Mono );
182 break;
183 case LOOK3D:
184 default:
185 aStyleSettings.SetOptions( aStyleSettings.GetOptions() & ~StyleSettingsOptions::Mono );
187 aSettings.SetStyleSettings( aStyleSettings );
188 _pWindow->SetSettings( aSettings );
191 static Any getVisualEffect( vcl::Window const * _pWindow )
193 Any aEffect;
195 StyleSettings aStyleSettings = _pWindow->GetSettings().GetStyleSettings();
196 if ( aStyleSettings.GetOptions() & StyleSettingsOptions::Mono )
197 aEffect <<= sal_Int16(FLAT);
198 else
199 aEffect <<= sal_Int16(LOOK3D);
200 return aEffect;
207 void VCLXGraphicControl::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
209 VCLXWindow::ImplGetPropertyIds( rIds );
212 void VCLXGraphicControl::ImplSetNewImage()
214 OSL_PRECOND( GetWindow(), "VCLXGraphicControl::ImplSetNewImage: window is required to be not-NULL!" );
215 VclPtr< Button > pButton = GetAsDynamic< Button >();
216 pButton->SetModeImage( GetImage() );
219 void VCLXGraphicControl::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags )
221 SolarMutexGuard aGuard;
223 if ( GetWindow() )
225 Size aOldSize = GetWindow()->GetSizePixel();
226 VCLXWindow::setPosSize( X, Y, Width, Height, Flags );
227 if ( ( aOldSize.Width() != Width ) || ( aOldSize.Height() != Height ) )
228 ImplSetNewImage();
232 void VCLXGraphicControl::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
234 SolarMutexGuard aGuard;
236 if ( !GetWindow() )
237 return;
239 sal_uInt16 nPropType = GetPropertyId( PropertyName );
240 switch ( nPropType )
242 case BASEPROPERTY_GRAPHIC:
244 Reference< XGraphic > xGraphic;
245 OSL_VERIFY( Value >>= xGraphic );
246 maImage = Image( xGraphic );
247 ImplSetNewImage();
249 break;
251 case BASEPROPERTY_IMAGEALIGN:
253 WindowType eType = GetWindow()->GetType();
254 if ( ( eType == WindowType::PUSHBUTTON )
255 || ( eType == WindowType::RADIOBUTTON )
256 || ( eType == WindowType::CHECKBOX )
259 sal_Int16 nAlignment = sal_Int16();
260 if ( Value >>= nAlignment )
261 GetAs< Button >()->SetImageAlign( static_cast< ImageAlign >( nAlignment ) );
264 break;
265 case BASEPROPERTY_IMAGEPOSITION:
267 WindowType eType = GetWindow()->GetType();
268 if ( ( eType == WindowType::PUSHBUTTON )
269 || ( eType == WindowType::RADIOBUTTON )
270 || ( eType == WindowType::CHECKBOX )
273 sal_Int16 nImagePosition = 2;
274 OSL_VERIFY( Value >>= nImagePosition );
275 GetAs<Button>()->SetImageAlign( ::toolkit::translateImagePosition( nImagePosition ) );
278 break;
279 default:
280 VCLXWindow::setProperty( PropertyName, Value );
281 break;
285 css::uno::Any VCLXGraphicControl::getProperty( const OUString& PropertyName )
287 SolarMutexGuard aGuard;
289 css::uno::Any aProp;
290 if ( !GetWindow() )
291 return aProp;
293 sal_uInt16 nPropType = GetPropertyId( PropertyName );
294 switch ( nPropType )
296 case BASEPROPERTY_GRAPHIC:
297 aProp <<= Graphic(maImage.GetBitmapEx()).GetXGraphic();
298 break;
299 case BASEPROPERTY_IMAGEALIGN:
301 WindowType eType = GetWindow()->GetType();
302 if ( ( eType == WindowType::PUSHBUTTON )
303 || ( eType == WindowType::RADIOBUTTON )
304 || ( eType == WindowType::CHECKBOX )
307 aProp <<= ::toolkit::getCompatibleImageAlign(
308 GetAs<Button>()->GetImageAlign() );
311 break;
312 case BASEPROPERTY_IMAGEPOSITION:
314 WindowType eType = GetWindow()->GetType();
315 if ( ( eType == WindowType::PUSHBUTTON )
316 || ( eType == WindowType::RADIOBUTTON )
317 || ( eType == WindowType::CHECKBOX )
320 aProp <<= ::toolkit::translateImagePosition(
321 GetAs< Button >()->GetImageAlign() );
324 break;
325 default:
327 aProp = VCLXWindow::getProperty( PropertyName );
329 break;
331 return aProp;
337 void VCLXButton::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
339 PushPropertyIds( rIds,
340 BASEPROPERTY_BACKGROUNDCOLOR,
341 BASEPROPERTY_DEFAULTBUTTON,
342 BASEPROPERTY_DEFAULTCONTROL,
343 BASEPROPERTY_ENABLED,
344 BASEPROPERTY_ENABLEVISIBLE,
345 BASEPROPERTY_FONTDESCRIPTOR,
346 BASEPROPERTY_GRAPHIC,
347 BASEPROPERTY_HELPTEXT,
348 BASEPROPERTY_HELPURL,
349 BASEPROPERTY_IMAGEALIGN,
350 BASEPROPERTY_IMAGEPOSITION,
351 BASEPROPERTY_IMAGEURL,
352 BASEPROPERTY_LABEL,
353 BASEPROPERTY_PRINTABLE,
354 BASEPROPERTY_PUSHBUTTONTYPE,
355 BASEPROPERTY_REPEAT,
356 BASEPROPERTY_REPEAT_DELAY,
357 BASEPROPERTY_STATE,
358 BASEPROPERTY_TABSTOP,
359 BASEPROPERTY_TOGGLE,
360 BASEPROPERTY_FOCUSONCLICK,
361 BASEPROPERTY_MULTILINE,
362 BASEPROPERTY_ALIGN,
363 BASEPROPERTY_VERTICALALIGN,
364 BASEPROPERTY_WRITING_MODE,
365 BASEPROPERTY_CONTEXT_WRITING_MODE,
366 BASEPROPERTY_REFERENCE_DEVICE,
368 VCLXGraphicControl::ImplGetPropertyIds( rIds );
371 VCLXButton::VCLXButton()
372 :maActionListeners( *this )
373 ,maItemListeners( *this )
377 VCLXButton::~VCLXButton()
381 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXButton::CreateAccessibleContext()
383 return getAccessibleFactory().createAccessibleContext( this );
386 void VCLXButton::dispose()
388 SolarMutexGuard aGuard;
390 css::lang::EventObject aObj;
391 aObj.Source = getXWeak();
392 maActionListeners.disposeAndClear( aObj );
393 maItemListeners.disposeAndClear( aObj );
394 VCLXGraphicControl::dispose();
397 void VCLXButton::addActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
399 SolarMutexGuard aGuard;
400 maActionListeners.addInterface( l );
403 void VCLXButton::removeActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
405 SolarMutexGuard aGuard;
406 maActionListeners.removeInterface( l );
409 void VCLXButton::addItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
411 SolarMutexGuard aGuard;
412 maItemListeners.addInterface( l );
415 void VCLXButton::removeItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
417 SolarMutexGuard aGuard;
418 maItemListeners.removeInterface( l );
421 void VCLXButton::setLabel( const OUString& rLabel )
423 SolarMutexGuard aGuard;
425 VclPtr<vcl::Window> pWindow = GetWindow();
426 if ( pWindow )
427 pWindow->SetText( rLabel );
430 void VCLXButton::setActionCommand( const OUString& rCommand )
432 SolarMutexGuard aGuard;
434 maActionCommand = rCommand;
437 css::awt::Size VCLXButton::getMinimumSize( )
439 SolarMutexGuard aGuard;
441 Size aSz;
442 VclPtr< PushButton > pButton = GetAs< PushButton >();
443 if ( pButton )
444 aSz = pButton->CalcMinimumSize();
445 return AWTSize(aSz);
448 css::awt::Size VCLXButton::getPreferredSize( )
450 css::awt::Size aSz = getMinimumSize();
451 aSz.Width += 16;
452 aSz.Height += 10;
453 return aSz;
456 css::awt::Size VCLXButton::calcAdjustedSize( const css::awt::Size& rNewSize )
458 SolarMutexGuard aGuard;
460 Size aSz = VCLSize(rNewSize);
461 VclPtr< PushButton > pButton = GetAs< PushButton >();
462 if ( pButton )
464 Size aMinSz = pButton->CalcMinimumSize();
465 // no text, thus image
466 if ( pButton->GetText().isEmpty() )
468 if ( aSz.Width() < aMinSz.Width() )
469 aSz.setWidth( aMinSz.Width() );
470 if ( aSz.Height() < aMinSz.Height() )
471 aSz.setHeight( aMinSz.Height() );
473 else
475 if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
476 aSz.setHeight( aMinSz.Height() );
477 else
478 aSz = aMinSz;
481 return AWTSize(aSz);
484 void VCLXButton::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
486 SolarMutexGuard aGuard;
488 VclPtr< Button > pButton = GetAs< Button >();
489 if ( !pButton )
490 return;
492 sal_uInt16 nPropType = GetPropertyId( PropertyName );
493 switch ( nPropType )
495 case BASEPROPERTY_FOCUSONCLICK:
496 ::toolkit::adjustBooleanWindowStyle( Value, pButton, WB_NOPOINTERFOCUS, true );
497 break;
499 case BASEPROPERTY_TOGGLE:
500 ::toolkit::adjustBooleanWindowStyle( Value, pButton, WB_TOGGLE, false );
501 break;
503 case BASEPROPERTY_DEFAULTBUTTON:
505 WinBits nStyle = pButton->GetStyle() | WB_DEFBUTTON;
506 bool b = bool();
507 if ( ( Value >>= b ) && !b )
508 nStyle &= ~WB_DEFBUTTON;
509 pButton->SetStyle( nStyle );
511 break;
512 case BASEPROPERTY_STATE:
514 if ( GetWindow()->GetType() == WindowType::PUSHBUTTON )
516 sal_Int16 n = sal_Int16();
517 if ( Value >>= n )
518 static_cast<PushButton*>(pButton.get())->SetState( static_cast<TriState>(n) );
521 break;
522 default:
524 VCLXGraphicControl::setProperty( PropertyName, Value );
529 css::uno::Any VCLXButton::getProperty( const OUString& PropertyName )
531 SolarMutexGuard aGuard;
533 css::uno::Any aProp;
534 VclPtr< Button > pButton = GetAs< Button >();
535 if ( pButton )
537 sal_uInt16 nPropType = GetPropertyId( PropertyName );
538 switch ( nPropType )
540 case BASEPROPERTY_FOCUSONCLICK:
541 aProp <<= ( ( pButton->GetStyle() & WB_NOPOINTERFOCUS ) == 0 );
542 break;
544 case BASEPROPERTY_TOGGLE:
545 aProp <<= ( ( pButton->GetStyle() & WB_TOGGLE ) != 0 );
546 break;
548 case BASEPROPERTY_DEFAULTBUTTON:
550 aProp <<= ( pButton->GetStyle() & WB_DEFBUTTON ) != 0;
552 break;
553 case BASEPROPERTY_STATE:
555 if ( GetWindow()->GetType() == WindowType::PUSHBUTTON )
557 aProp <<= static_cast<sal_Int16>(static_cast<PushButton*>(pButton.get())->GetState());
560 break;
561 default:
563 aProp = VCLXGraphicControl::getProperty( PropertyName );
567 return aProp;
570 void VCLXButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
572 switch ( rVclWindowEvent.GetId() )
574 case VclEventId::ButtonClick:
576 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
577 // since we call listeners below, there is a potential that we will be destroyed
578 // during the listener call. To prevent the resulting crashes, we keep us
579 // alive as long as we're here
581 if ( maActionListeners.getLength() )
583 css::awt::ActionEvent aEvent;
584 aEvent.Source = getXWeak();
585 aEvent.ActionCommand = maActionCommand;
587 Callback aCallback = [ this, aEvent ]()
588 { this->maActionListeners.actionPerformed( aEvent ); };
590 ImplExecuteAsyncWithoutSolarLock( aCallback );
593 break;
595 case VclEventId::PushbuttonToggle:
597 PushButton& rButton = dynamic_cast< PushButton& >( *rVclWindowEvent.GetWindow() );
599 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
600 if ( maItemListeners.getLength() )
602 css::awt::ItemEvent aEvent;
603 aEvent.Source = getXWeak();
604 aEvent.Selected = ( rButton.GetState() == TRISTATE_TRUE ) ? 1 : 0;
605 maItemListeners.itemStateChanged( aEvent );
608 break;
610 default:
611 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent );
612 break;
619 void VCLXImageControl::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
621 PushPropertyIds( rIds,
622 BASEPROPERTY_BACKGROUNDCOLOR,
623 BASEPROPERTY_BORDER,
624 BASEPROPERTY_BORDERCOLOR,
625 BASEPROPERTY_DEFAULTCONTROL,
626 BASEPROPERTY_ENABLED,
627 BASEPROPERTY_ENABLEVISIBLE,
628 BASEPROPERTY_GRAPHIC,
629 BASEPROPERTY_HELPTEXT,
630 BASEPROPERTY_HELPURL,
631 BASEPROPERTY_IMAGEURL,
632 BASEPROPERTY_PRINTABLE,
633 BASEPROPERTY_SCALEIMAGE,
634 BASEPROPERTY_IMAGE_SCALE_MODE,
635 BASEPROPERTY_TABSTOP,
636 BASEPROPERTY_WRITING_MODE,
637 BASEPROPERTY_CONTEXT_WRITING_MODE,
639 VCLXGraphicControl::ImplGetPropertyIds( rIds );
642 VCLXImageControl::VCLXImageControl()
646 VCLXImageControl::~VCLXImageControl()
650 void VCLXImageControl::ImplSetNewImage()
652 OSL_PRECOND( GetWindow(), "VCLXImageControl::ImplSetNewImage: window is required to be not-NULL!" );
653 VclPtr<ImageControl> pControl = GetAs< ImageControl >();
654 pControl->SetImage( GetImage() );
657 css::awt::Size VCLXImageControl::getMinimumSize( )
659 SolarMutexGuard aGuard;
661 Size aSz = GetImage().GetSizePixel();
662 aSz = ImplCalcWindowSize( aSz );
664 return AWTSize(aSz);
667 css::awt::Size VCLXImageControl::getPreferredSize( )
669 return getMinimumSize();
672 css::awt::Size VCLXImageControl::calcAdjustedSize( const css::awt::Size& rNewSize )
674 SolarMutexGuard aGuard;
676 css::awt::Size aSz = rNewSize;
677 css::awt::Size aMinSz = getMinimumSize();
678 if ( aSz.Width < aMinSz.Width )
679 aSz.Width = aMinSz.Width;
680 if ( aSz.Height < aMinSz.Height )
681 aSz.Height = aMinSz.Height;
682 return aSz;
685 void VCLXImageControl::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
687 SolarMutexGuard aGuard;
689 VclPtr< ImageControl > pImageControl = GetAs< ImageControl >();
691 sal_uInt16 nPropType = GetPropertyId( PropertyName );
692 switch ( nPropType )
694 case BASEPROPERTY_IMAGE_SCALE_MODE:
696 sal_Int16 nScaleMode( ImageScaleMode::ANISOTROPIC );
697 if ( pImageControl && ( Value >>= nScaleMode ) )
699 pImageControl->SetScaleMode( nScaleMode );
702 break;
704 case BASEPROPERTY_SCALEIMAGE:
706 // this is for compatibility only, nowadays, the ImageScaleMode property should be used
707 bool bScaleImage = false;
708 if ( pImageControl && ( Value >>= bScaleImage ) )
710 pImageControl->SetScaleMode( bScaleImage ? ImageScaleMode::ANISOTROPIC : ImageScaleMode::NONE );
713 break;
715 default:
716 VCLXGraphicControl::setProperty( PropertyName, Value );
717 break;
721 css::uno::Any VCLXImageControl::getProperty( const OUString& PropertyName )
723 SolarMutexGuard aGuard;
725 css::uno::Any aProp;
726 VclPtr< ImageControl > pImageControl = GetAs< ImageControl >();
727 sal_uInt16 nPropType = GetPropertyId( PropertyName );
729 switch ( nPropType )
731 case BASEPROPERTY_IMAGE_SCALE_MODE:
732 aProp <<= ( pImageControl ? pImageControl->GetScaleMode() : ImageScaleMode::ANISOTROPIC );
733 break;
735 case BASEPROPERTY_SCALEIMAGE:
736 aProp <<= ( pImageControl && pImageControl->GetScaleMode() != ImageScaleMode::NONE );
737 break;
739 default:
740 aProp = VCLXGraphicControl::getProperty( PropertyName );
741 break;
743 return aProp;
749 void VCLXCheckBox::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
751 PushPropertyIds( rIds,
752 BASEPROPERTY_DEFAULTCONTROL,
753 BASEPROPERTY_ENABLED,
754 BASEPROPERTY_ENABLEVISIBLE,
755 BASEPROPERTY_FONTDESCRIPTOR,
756 BASEPROPERTY_GRAPHIC,
757 BASEPROPERTY_HELPTEXT,
758 BASEPROPERTY_HELPURL,
759 BASEPROPERTY_IMAGEPOSITION,
760 BASEPROPERTY_IMAGEURL,
761 BASEPROPERTY_LABEL,
762 BASEPROPERTY_PRINTABLE,
763 BASEPROPERTY_STATE,
764 BASEPROPERTY_TABSTOP,
765 BASEPROPERTY_TRISTATE,
766 BASEPROPERTY_VISUALEFFECT,
767 BASEPROPERTY_MULTILINE,
768 BASEPROPERTY_BACKGROUNDCOLOR,
769 BASEPROPERTY_ALIGN,
770 BASEPROPERTY_VERTICALALIGN,
771 BASEPROPERTY_WRITING_MODE,
772 BASEPROPERTY_CONTEXT_WRITING_MODE,
773 BASEPROPERTY_REFERENCE_DEVICE,
775 VCLXGraphicControl::ImplGetPropertyIds( rIds );
778 VCLXCheckBox::VCLXCheckBox() : maActionListeners( *this ), maItemListeners( *this )
782 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXCheckBox::CreateAccessibleContext()
784 return getAccessibleFactory().createAccessibleContext( this );
787 void VCLXCheckBox::dispose()
789 SolarMutexGuard aGuard;
791 css::lang::EventObject aObj;
792 aObj.Source = getXWeak();
793 maItemListeners.disposeAndClear( aObj );
794 VCLXGraphicControl::dispose();
797 void VCLXCheckBox::addItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
799 SolarMutexGuard aGuard;
800 maItemListeners.addInterface( l );
803 void VCLXCheckBox::removeItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
805 SolarMutexGuard aGuard;
806 maItemListeners.removeInterface( l );
809 void VCLXCheckBox::addActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
811 SolarMutexGuard aGuard;
812 maActionListeners.addInterface( l );
815 void VCLXCheckBox::removeActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
817 SolarMutexGuard aGuard;
818 maActionListeners.removeInterface( l );
821 void VCLXCheckBox::setActionCommand( const OUString& rCommand )
823 SolarMutexGuard aGuard;
824 maActionCommand = rCommand;
827 void VCLXCheckBox::setLabel( const OUString& rLabel )
829 SolarMutexGuard aGuard;
831 VclPtr<vcl::Window> pWindow = GetWindow();
832 if ( pWindow )
833 pWindow->SetText( rLabel );
836 void VCLXCheckBox::setState( sal_Int16 n )
838 SolarMutexGuard aGuard;
840 VclPtr< CheckBox> pCheckBox = GetAs< CheckBox >();
841 if ( !pCheckBox)
842 return;
844 TriState eState;
845 switch ( n )
847 case 0: eState = TRISTATE_FALSE; break;
848 case 1: eState = TRISTATE_TRUE; break;
849 case 2: eState = TRISTATE_INDET; break;
850 default: eState = TRISTATE_FALSE;
852 pCheckBox->SetState( eState );
854 // #105198# call C++ click listeners (needed for accessibility)
855 // pCheckBox->GetClickHdl().Call( pCheckBox );
857 // #107218# Call same virtual methods and listeners like VCL would do after user interaction
858 SetSynthesizingVCLEvent( true );
859 pCheckBox->Toggle();
860 pCheckBox->Click();
861 SetSynthesizingVCLEvent( false );
864 sal_Int16 VCLXCheckBox::getState()
866 SolarMutexGuard aGuard;
868 sal_Int16 nState = -1;
869 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
870 if ( pCheckBox )
872 switch ( pCheckBox->GetState() )
874 case TRISTATE_FALSE: nState = 0; break;
875 case TRISTATE_TRUE: nState = 1; break;
876 case TRISTATE_INDET: nState = 2; break;
877 default: OSL_FAIL( "VCLXCheckBox::getState(): unknown TriState!" );
881 return nState;
884 void VCLXCheckBox::enableTriState( sal_Bool b )
886 SolarMutexGuard aGuard;
888 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
889 if ( pCheckBox)
890 pCheckBox->EnableTriState( b );
893 css::awt::Size VCLXCheckBox::getMinimumSize()
895 SolarMutexGuard aGuard;
897 Size aSz;
898 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
899 if ( pCheckBox )
900 aSz = pCheckBox->CalcMinimumSize();
901 return AWTSize(aSz);
904 css::awt::Size VCLXCheckBox::getPreferredSize()
906 return getMinimumSize();
909 css::awt::Size VCLXCheckBox::calcAdjustedSize( const css::awt::Size& rNewSize )
911 SolarMutexGuard aGuard;
913 Size aSz = VCLSize(rNewSize);
914 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
915 if ( pCheckBox )
917 Size aMinSz = pCheckBox->CalcMinimumSize(rNewSize.Width);
918 if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
919 aSz.setHeight( aMinSz.Height() );
920 else
921 aSz = aMinSz;
923 return AWTSize(aSz);
926 void VCLXCheckBox::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
928 SolarMutexGuard aGuard;
930 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
931 if ( !pCheckBox )
932 return;
934 sal_uInt16 nPropType = GetPropertyId( PropertyName );
935 switch ( nPropType )
937 case BASEPROPERTY_VISUALEFFECT:
938 ::toolkit::setVisualEffect( Value, pCheckBox );
939 break;
941 case BASEPROPERTY_TRISTATE:
943 bool b = bool();
944 if ( Value >>= b )
945 pCheckBox->EnableTriState( b );
947 break;
948 case BASEPROPERTY_STATE:
950 sal_Int16 n = sal_Int16();
951 if ( Value >>= n )
952 setState( n );
954 break;
955 default:
957 VCLXGraphicControl::setProperty( PropertyName, Value );
962 css::uno::Any VCLXCheckBox::getProperty( const OUString& PropertyName )
964 SolarMutexGuard aGuard;
966 css::uno::Any aProp;
967 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
968 if ( pCheckBox )
970 sal_uInt16 nPropType = GetPropertyId( PropertyName );
971 switch ( nPropType )
973 case BASEPROPERTY_VISUALEFFECT:
974 aProp = ::toolkit::getVisualEffect( pCheckBox );
975 break;
976 case BASEPROPERTY_TRISTATE:
977 aProp <<= pCheckBox->IsTriStateEnabled();
978 break;
979 case BASEPROPERTY_STATE:
980 aProp <<= static_cast<sal_Int16>(pCheckBox->GetState());
981 break;
982 default:
984 aProp = VCLXGraphicControl::getProperty( PropertyName );
988 return aProp;
991 void VCLXCheckBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
993 switch ( rVclWindowEvent.GetId() )
995 case VclEventId::CheckboxToggle:
997 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
998 // since we call listeners below, there is a potential that we will be destroyed
999 // in during the listener call. To prevent the resulting crashes, we keep us
1000 // alive as long as we're here
1002 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
1003 if ( pCheckBox )
1005 if ( maItemListeners.getLength() )
1007 css::awt::ItemEvent aEvent;
1008 aEvent.Source = getXWeak();
1009 aEvent.Highlighted = 0;
1010 aEvent.Selected = pCheckBox->GetState();
1011 maItemListeners.itemStateChanged( aEvent );
1013 if ( !IsSynthesizingVCLEvent() && maActionListeners.getLength() )
1015 css::awt::ActionEvent aEvent;
1016 aEvent.Source = getXWeak();
1017 aEvent.ActionCommand = maActionCommand;
1018 maActionListeners.actionPerformed( aEvent );
1022 break;
1024 default:
1025 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent );
1026 break;
1032 void VCLXRadioButton::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
1034 PushPropertyIds( rIds,
1035 BASEPROPERTY_DEFAULTCONTROL,
1036 BASEPROPERTY_ENABLED,
1037 BASEPROPERTY_ENABLEVISIBLE,
1038 BASEPROPERTY_FONTDESCRIPTOR,
1039 BASEPROPERTY_GRAPHIC,
1040 BASEPROPERTY_HELPTEXT,
1041 BASEPROPERTY_HELPURL,
1042 BASEPROPERTY_IMAGEPOSITION,
1043 BASEPROPERTY_IMAGEURL,
1044 BASEPROPERTY_LABEL,
1045 BASEPROPERTY_PRINTABLE,
1046 BASEPROPERTY_STATE,
1047 BASEPROPERTY_TABSTOP,
1048 BASEPROPERTY_VISUALEFFECT,
1049 BASEPROPERTY_MULTILINE,
1050 BASEPROPERTY_BACKGROUNDCOLOR,
1051 BASEPROPERTY_ALIGN,
1052 BASEPROPERTY_VERTICALALIGN,
1053 BASEPROPERTY_WRITING_MODE,
1054 BASEPROPERTY_CONTEXT_WRITING_MODE,
1055 BASEPROPERTY_REFERENCE_DEVICE,
1056 BASEPROPERTY_GROUPNAME,
1058 VCLXGraphicControl::ImplGetPropertyIds( rIds );
1062 VCLXRadioButton::VCLXRadioButton() : maItemListeners( *this ), maActionListeners( *this )
1066 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXRadioButton::CreateAccessibleContext()
1068 return getAccessibleFactory().createAccessibleContext( this );
1071 void VCLXRadioButton::dispose()
1073 SolarMutexGuard aGuard;
1075 css::lang::EventObject aObj;
1076 aObj.Source = getXWeak();
1077 maItemListeners.disposeAndClear( aObj );
1078 VCLXGraphicControl::dispose();
1081 void VCLXRadioButton::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
1083 SolarMutexGuard aGuard;
1085 VclPtr< RadioButton > pButton = GetAs< RadioButton >();
1086 if ( !pButton )
1087 return;
1089 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1090 switch ( nPropType )
1092 case BASEPROPERTY_VISUALEFFECT:
1093 ::toolkit::setVisualEffect( Value, pButton );
1094 break;
1096 case BASEPROPERTY_STATE:
1098 sal_Int16 n = sal_Int16();
1099 if ( Value >>= n )
1101 bool b = n != 0;
1102 if ( pButton->IsRadioCheckEnabled() )
1103 pButton->Check( b );
1104 else
1105 pButton->SetState( b );
1108 break;
1109 case BASEPROPERTY_AUTOTOGGLE:
1111 bool b = bool();
1112 if ( Value >>= b )
1113 pButton->EnableRadioCheck( b );
1115 break;
1116 default:
1118 VCLXGraphicControl::setProperty( PropertyName, Value );
1123 css::uno::Any VCLXRadioButton::getProperty( const OUString& PropertyName )
1125 SolarMutexGuard aGuard;
1127 css::uno::Any aProp;
1128 VclPtr< RadioButton > pButton = GetAs< RadioButton >();
1129 if ( pButton )
1131 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1132 switch ( nPropType )
1134 case BASEPROPERTY_VISUALEFFECT:
1135 aProp = ::toolkit::getVisualEffect( pButton );
1136 break;
1137 case BASEPROPERTY_STATE:
1138 aProp <<= static_cast<sal_Int16>( pButton->IsChecked() ? 1 : 0 );
1139 break;
1140 case BASEPROPERTY_AUTOTOGGLE:
1141 aProp <<= pButton->IsRadioCheckEnabled();
1142 break;
1143 default:
1145 aProp = VCLXGraphicControl::getProperty( PropertyName );
1149 return aProp;
1152 void VCLXRadioButton::addItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
1154 SolarMutexGuard aGuard;
1155 maItemListeners.addInterface( l );
1158 void VCLXRadioButton::removeItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
1160 SolarMutexGuard aGuard;
1161 maItemListeners.removeInterface( l );
1164 void VCLXRadioButton::addActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
1166 SolarMutexGuard aGuard;
1167 maActionListeners.addInterface( l );
1170 void VCLXRadioButton::removeActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
1172 SolarMutexGuard aGuard;
1173 maActionListeners.removeInterface( l );
1176 void VCLXRadioButton::setLabel( const OUString& rLabel )
1178 SolarMutexGuard aGuard;
1180 VclPtr<vcl::Window> pWindow = GetWindow();
1181 if ( pWindow )
1182 pWindow->SetText( rLabel );
1185 void VCLXRadioButton::setActionCommand( const OUString& rCommand )
1187 SolarMutexGuard aGuard;
1188 maActionCommand = rCommand;
1191 void VCLXRadioButton::setState( sal_Bool b )
1193 SolarMutexGuard aGuard;
1195 VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >();
1196 if ( pRadioButton)
1198 pRadioButton->Check( b );
1199 // #102717# item listeners are called, but not C++ click listeners in StarOffice code => call click hdl
1200 // But this is needed in old code because Accessibility API uses it.
1201 // pRadioButton->GetClickHdl().Call( pRadioButton );
1203 // #107218# Call same virtual methods and listeners like VCL would do after user interaction
1204 SetSynthesizingVCLEvent( true );
1205 pRadioButton->Click();
1206 SetSynthesizingVCLEvent( false );
1210 sal_Bool VCLXRadioButton::getState()
1212 SolarMutexGuard aGuard;
1214 VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >();
1215 return pRadioButton && pRadioButton->IsChecked();
1218 css::awt::Size VCLXRadioButton::getMinimumSize( )
1220 SolarMutexGuard aGuard;
1222 Size aSz;
1223 VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >();
1224 if ( pRadioButton )
1225 aSz = pRadioButton->CalcMinimumSize();
1226 return AWTSize(aSz);
1229 css::awt::Size VCLXRadioButton::getPreferredSize( )
1231 return getMinimumSize();
1234 css::awt::Size VCLXRadioButton::calcAdjustedSize( const css::awt::Size& rNewSize )
1236 SolarMutexGuard aGuard;
1238 Size aSz = VCLSize(rNewSize);
1239 VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >();
1240 if ( pRadioButton )
1242 Size aMinSz = pRadioButton->CalcMinimumSize(rNewSize.Width);
1243 if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
1244 aSz.setHeight( aMinSz.Height() );
1245 else
1246 aSz = aMinSz;
1248 return AWTSize(aSz);
1251 void VCLXRadioButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1253 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
1254 // since we call listeners below, there is a potential that we will be destroyed
1255 // in during the listener call. To prevent the resulting crashes, we keep us
1256 // alive as long as we're here
1258 switch ( rVclWindowEvent.GetId() )
1260 case VclEventId::ButtonClick:
1261 if ( !IsSynthesizingVCLEvent() && maActionListeners.getLength() )
1263 css::awt::ActionEvent aEvent;
1264 aEvent.Source = getXWeak();
1265 aEvent.ActionCommand = maActionCommand;
1266 maActionListeners.actionPerformed( aEvent );
1268 ImplClickedOrToggled( false );
1269 break;
1271 case VclEventId::RadiobuttonToggle:
1272 ImplClickedOrToggled( true );
1273 break;
1275 default:
1276 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent );
1277 break;
1281 void VCLXRadioButton::ImplClickedOrToggled( bool bToggled )
1283 // In the forms, RadioChecked is not enabled, call itemStateChanged only for click
1284 // In the dialog editor, RadioChecked is enabled, call itemStateChanged only for bToggled
1285 VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >();
1286 if ( pRadioButton && ( pRadioButton->IsRadioCheckEnabled() == bToggled ) && ( bToggled || pRadioButton->IsStateChanged() ) && maItemListeners.getLength() )
1288 css::awt::ItemEvent aEvent;
1289 aEvent.Source = getXWeak();
1290 aEvent.Highlighted = 0;
1291 aEvent.Selected = pRadioButton->IsChecked() ? 1 : 0;
1292 maItemListeners.itemStateChanged( aEvent );
1298 void VCLXSpinField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
1300 PushPropertyIds( rIds,
1301 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
1302 0 );
1303 VCLXEdit::ImplGetPropertyIds( rIds );
1306 VCLXSpinField::VCLXSpinField() : maSpinListeners( *this )
1310 void VCLXSpinField::addSpinListener( const css::uno::Reference< css::awt::XSpinListener > & l )
1312 SolarMutexGuard aGuard;
1313 maSpinListeners.addInterface( l );
1316 void VCLXSpinField::removeSpinListener( const css::uno::Reference< css::awt::XSpinListener > & l )
1318 SolarMutexGuard aGuard;
1319 maSpinListeners.removeInterface( l );
1322 void VCLXSpinField::up()
1324 SolarMutexGuard aGuard;
1326 VclPtr< SpinField > pSpinField = GetAs< SpinField >();
1327 if ( pSpinField )
1328 pSpinField->Up();
1331 void VCLXSpinField::down()
1333 SolarMutexGuard aGuard;
1335 VclPtr< SpinField > pSpinField = GetAs< SpinField >();
1336 if ( pSpinField )
1337 pSpinField->Down();
1340 void VCLXSpinField::first()
1342 SolarMutexGuard aGuard;
1344 VclPtr< SpinField > pSpinField = GetAs< SpinField >();
1345 if ( pSpinField )
1346 pSpinField->First();
1349 void VCLXSpinField::last()
1351 SolarMutexGuard aGuard;
1353 VclPtr< SpinField > pSpinField = GetAs< SpinField >();
1354 if ( pSpinField )
1355 pSpinField->Last();
1358 void VCLXSpinField::enableRepeat( sal_Bool bRepeat )
1360 SolarMutexGuard aGuard;
1362 VclPtr<vcl::Window> pWindow = GetWindow();
1363 if ( pWindow )
1365 WinBits nStyle = pWindow->GetStyle();
1366 if ( bRepeat )
1367 nStyle |= WB_REPEAT;
1368 else
1369 nStyle &= ~WB_REPEAT;
1370 pWindow->SetStyle( nStyle );
1374 void VCLXSpinField::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1376 switch ( rVclWindowEvent.GetId() )
1378 case VclEventId::SpinfieldUp:
1379 case VclEventId::SpinfieldDown:
1380 case VclEventId::SpinfieldFirst:
1381 case VclEventId::SpinfieldLast:
1383 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
1384 // since we call listeners below, there is a potential that we will be destroyed
1385 // in during the listener call. To prevent the resulting crashes, we keep us
1386 // alive as long as we're here
1388 if ( maSpinListeners.getLength() )
1390 css::awt::SpinEvent aEvent;
1391 aEvent.Source = getXWeak();
1392 switch ( rVclWindowEvent.GetId() )
1394 case VclEventId::SpinfieldUp: maSpinListeners.up( aEvent );
1395 break;
1396 case VclEventId::SpinfieldDown: maSpinListeners.down( aEvent );
1397 break;
1398 case VclEventId::SpinfieldFirst: maSpinListeners.first( aEvent );
1399 break;
1400 case VclEventId::SpinfieldLast: maSpinListeners.last( aEvent );
1401 break;
1402 default: break;
1407 break;
1409 default:
1410 VCLXEdit::ProcessWindowEvent( rVclWindowEvent );
1411 break;
1417 void VCLXListBox::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
1419 PushPropertyIds( rIds,
1420 BASEPROPERTY_BACKGROUNDCOLOR,
1421 BASEPROPERTY_BORDER,
1422 BASEPROPERTY_BORDERCOLOR,
1423 BASEPROPERTY_DEFAULTCONTROL,
1424 BASEPROPERTY_DROPDOWN,
1425 BASEPROPERTY_ENABLED,
1426 BASEPROPERTY_ENABLEVISIBLE,
1427 BASEPROPERTY_FONTDESCRIPTOR,
1428 BASEPROPERTY_HELPTEXT,
1429 BASEPROPERTY_HELPURL,
1430 BASEPROPERTY_LINECOUNT,
1431 BASEPROPERTY_MULTISELECTION,
1432 BASEPROPERTY_MULTISELECTION_SIMPLEMODE,
1433 BASEPROPERTY_ITEM_SEPARATOR_POS,
1434 BASEPROPERTY_PRINTABLE,
1435 BASEPROPERTY_SELECTEDITEMS,
1436 BASEPROPERTY_STRINGITEMLIST,
1437 BASEPROPERTY_TYPEDITEMLIST,
1438 BASEPROPERTY_TABSTOP,
1439 BASEPROPERTY_READONLY,
1440 BASEPROPERTY_ALIGN,
1441 BASEPROPERTY_WRITING_MODE,
1442 BASEPROPERTY_CONTEXT_WRITING_MODE,
1443 BASEPROPERTY_REFERENCE_DEVICE,
1444 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
1445 BASEPROPERTY_HIGHLIGHT_COLOR,
1446 BASEPROPERTY_HIGHLIGHT_TEXT_COLOR,
1448 VCLXWindow::ImplGetPropertyIds( rIds );
1452 VCLXListBox::VCLXListBox()
1453 : maActionListeners( *this ),
1454 maItemListeners( *this )
1458 void VCLXListBox::dispose()
1460 SolarMutexGuard aGuard;
1462 css::lang::EventObject aObj;
1463 aObj.Source = getXWeak();
1464 maItemListeners.disposeAndClear( aObj );
1465 maActionListeners.disposeAndClear( aObj );
1466 VCLXWindow::dispose();
1469 void VCLXListBox::addItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
1471 SolarMutexGuard aGuard;
1472 maItemListeners.addInterface( l );
1475 void VCLXListBox::removeItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
1477 SolarMutexGuard aGuard;
1478 maItemListeners.removeInterface( l );
1481 void VCLXListBox::addActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
1483 SolarMutexGuard aGuard;
1484 maActionListeners.addInterface( l );
1487 void VCLXListBox::removeActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
1489 SolarMutexGuard aGuard;
1490 maActionListeners.removeInterface( l );
1493 void VCLXListBox::addItem( const OUString& aItem, sal_Int16 nPos )
1495 SolarMutexGuard aGuard;
1496 VclPtr< ListBox > pBox = GetAs< ListBox >();
1497 if ( pBox )
1498 pBox->InsertEntry( aItem, nPos );
1501 void VCLXListBox::addItems( const css::uno::Sequence< OUString>& aItems, sal_Int16 nPos )
1503 SolarMutexGuard aGuard;
1504 VclPtr< ListBox > pBox = GetAs< ListBox >();
1505 if ( !pBox )
1506 return;
1508 sal_uInt16 nP = nPos;
1509 for ( auto const & item : aItems )
1511 if ( nP == 0xFFFF )
1513 OSL_FAIL( "VCLXListBox::addItems: too many entries!" );
1514 // skip remaining entries, list cannot hold them, anyway
1515 break;
1518 pBox->InsertEntry( item, nP++ );
1522 void VCLXListBox::removeItems( sal_Int16 nPos, sal_Int16 nCount )
1524 SolarMutexGuard aGuard;
1525 VclPtr< ListBox > pBox = GetAs< ListBox >();
1526 if ( pBox )
1528 for ( sal_Int16 n = nCount; n; )
1529 pBox->RemoveEntry( nPos + (--n) );
1533 sal_Int16 VCLXListBox::getItemCount()
1535 SolarMutexGuard aGuard;
1537 VclPtr< ListBox > pBox = GetAs< ListBox >();
1538 return pBox ? pBox->GetEntryCount() : 0;
1541 OUString VCLXListBox::getItem( sal_Int16 nPos )
1543 SolarMutexGuard aGuard;
1545 OUString aItem;
1546 VclPtr< ListBox > pBox = GetAs< ListBox >();
1547 if ( pBox )
1548 aItem = pBox->GetEntry( nPos );
1549 return aItem;
1552 css::uno::Sequence< OUString> VCLXListBox::getItems()
1554 SolarMutexGuard aGuard;
1556 css::uno::Sequence< OUString> aSeq;
1557 VclPtr< ListBox > pBox = GetAs< ListBox >();
1558 if ( pBox )
1560 auto n = pBox->GetEntryCount();
1561 aSeq = css::uno::Sequence< OUString>( n );
1562 while (n)
1564 --n;
1565 aSeq.getArray()[n] = pBox->GetEntry( n );
1568 return aSeq;
1571 sal_Int16 VCLXListBox::getSelectedItemPos()
1573 SolarMutexGuard aGuard;
1574 VclPtr< ListBox > pBox = GetAs< ListBox >();
1575 return pBox ? pBox->GetSelectedEntryPos() : 0;
1578 css::uno::Sequence<sal_Int16> VCLXListBox::getSelectedItemsPos()
1580 SolarMutexGuard aGuard;
1582 css::uno::Sequence<sal_Int16> aSeq;
1583 VclPtr< ListBox > pBox = GetAs< ListBox >();
1584 if ( pBox )
1586 const sal_Int32 nSelEntries = pBox->GetSelectedEntryCount();
1587 aSeq = css::uno::Sequence<sal_Int16>( nSelEntries );
1588 for ( sal_Int32 n = 0; n < nSelEntries; ++n )
1589 aSeq.getArray()[n] = pBox->GetSelectedEntryPos( n );
1591 return aSeq;
1594 OUString VCLXListBox::getSelectedItem()
1596 SolarMutexGuard aGuard;
1598 OUString aItem;
1599 VclPtr< ListBox > pBox = GetAs< ListBox >();
1600 if ( pBox )
1601 aItem = pBox->GetSelectedEntry();
1602 return aItem;
1605 css::uno::Sequence< OUString> VCLXListBox::getSelectedItems()
1607 SolarMutexGuard aGuard;
1609 css::uno::Sequence< OUString> aSeq;
1610 VclPtr< ListBox > pBox = GetAs< ListBox >();
1611 if ( pBox )
1613 const sal_Int32 nSelEntries = pBox->GetSelectedEntryCount();
1614 aSeq = css::uno::Sequence< OUString>( nSelEntries );
1615 for ( sal_Int32 n = 0; n < nSelEntries; ++n )
1616 aSeq.getArray()[n] = pBox->GetSelectedEntry( n );
1618 return aSeq;
1621 void VCLXListBox::selectItemPos( sal_Int16 nPos, sal_Bool bSelect )
1623 SolarMutexGuard aGuard;
1625 VclPtr< ListBox > pBox = GetAs< ListBox >();
1626 if ( pBox && ( pBox->IsEntryPosSelected( nPos ) != bool(bSelect) ) )
1628 pBox->SelectEntryPos( nPos, bSelect );
1630 // VCL doesn't call select handler after API call.
1631 // ImplCallItemListeners();
1633 // #107218# Call same listeners like VCL would do after user interaction
1634 SetSynthesizingVCLEvent( true );
1635 pBox->Select();
1636 SetSynthesizingVCLEvent( false );
1640 void VCLXListBox::selectItemsPos( const css::uno::Sequence<sal_Int16>& aPositions, sal_Bool bSelect )
1642 SolarMutexGuard aGuard;
1644 VclPtr< ListBox > pBox = GetAs< ListBox >();
1645 if ( !pBox )
1646 return;
1648 std::vector<sal_Int32> aPositionVec;
1649 aPositionVec.reserve(aPositions.getLength());
1651 bool bChanged = false;
1652 for ( auto n = aPositions.getLength(); n; )
1654 const auto nPos = aPositions.getConstArray()[--n];
1655 if ( pBox->IsEntryPosSelected( nPos ) != bool(bSelect) )
1657 aPositionVec.push_back(nPos);
1658 bChanged = true;
1662 if ( !bChanged )
1663 return;
1665 bool bOrigUpdateMode = pBox->IsUpdateMode();
1666 pBox->SetUpdateMode(false);
1668 pBox->SelectEntriesPos(aPositionVec, bSelect);
1670 pBox->SetUpdateMode(bOrigUpdateMode);
1672 // VCL doesn't call select handler after API call.
1673 // ImplCallItemListeners();
1675 // #107218# Call same listeners like VCL would do after user interaction
1676 SetSynthesizingVCLEvent( true );
1677 pBox->Select();
1678 SetSynthesizingVCLEvent( false );
1681 void VCLXListBox::selectItem( const OUString& rItemText, sal_Bool bSelect )
1683 SolarMutexGuard aGuard;
1685 VclPtr< ListBox > pBox = GetAs< ListBox >();
1686 if ( pBox )
1688 selectItemPos( pBox->GetEntryPos( rItemText ), bSelect );
1692 void VCLXListBox::setDropDownLineCount( sal_Int16 nLines )
1694 SolarMutexGuard aGuard;
1695 VclPtr< ListBox > pBox = GetAs< ListBox >();
1696 if ( pBox )
1697 pBox->SetDropDownLineCount( nLines );
1700 sal_Int16 VCLXListBox::getDropDownLineCount()
1702 SolarMutexGuard aGuard;
1704 sal_Int16 nLines = 0;
1705 VclPtr< ListBox > pBox = GetAs< ListBox >();
1706 if ( pBox )
1707 nLines = pBox->GetDropDownLineCount();
1708 return nLines;
1711 sal_Bool VCLXListBox::isMutipleMode()
1713 SolarMutexGuard aGuard;
1714 bool bMulti = false;
1715 VclPtr< ListBox > pBox = GetAs< ListBox >();
1716 if ( pBox )
1717 bMulti = pBox->IsMultiSelectionEnabled();
1718 return bMulti;
1721 void VCLXListBox::setMultipleMode( sal_Bool bMulti )
1723 SolarMutexGuard aGuard;
1724 VclPtr< ListBox > pBox = GetAs< ListBox >();
1725 if ( pBox )
1726 pBox->EnableMultiSelection( bMulti );
1729 void VCLXListBox::makeVisible( sal_Int16 nEntry )
1731 SolarMutexGuard aGuard;
1732 VclPtr< ListBox > pBox = GetAs< ListBox >();
1733 if ( pBox )
1734 pBox->SetTopEntry( nEntry );
1737 void VCLXListBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1739 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
1740 // since we call listeners below, there is a potential that we will be destroyed
1741 // in during the listener call. To prevent the resulting crashes, we keep us
1742 // alive as long as we're here
1744 switch ( rVclWindowEvent.GetId() )
1746 case VclEventId::ListboxSelect:
1748 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1749 if( pListBox )
1751 bool bDropDown = ( pListBox->GetStyle() & WB_DROPDOWN ) != 0;
1752 if ( bDropDown && !IsSynthesizingVCLEvent() && maActionListeners.getLength() )
1754 // Call ActionListener on DropDown event
1755 css::awt::ActionEvent aEvent;
1756 aEvent.Source = getXWeak();
1757 aEvent.ActionCommand = pListBox->GetSelectedEntry();
1758 maActionListeners.actionPerformed( aEvent );
1761 if ( maItemListeners.getLength() )
1763 ImplCallItemListeners();
1767 break;
1769 case VclEventId::ListboxDoubleClick:
1770 if ( GetWindow() && maActionListeners.getLength() )
1772 css::awt::ActionEvent aEvent;
1773 aEvent.Source = getXWeak();
1774 aEvent.ActionCommand = GetAs<ListBox>()->GetSelectedEntry();
1775 maActionListeners.actionPerformed( aEvent );
1777 break;
1779 default:
1780 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
1781 break;
1785 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXListBox::CreateAccessibleContext()
1787 SolarMutexGuard aGuard;
1789 return getAccessibleFactory().createAccessibleContext( this );
1792 void VCLXListBox::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
1794 SolarMutexGuard aGuard;
1795 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1796 if ( !pListBox )
1797 return;
1799 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1800 switch ( nPropType )
1802 case BASEPROPERTY_ITEM_SEPARATOR_POS:
1804 sal_Int16 nSeparatorPos(0);
1805 if ( Value >>= nSeparatorPos )
1806 pListBox->SetSeparatorPos( nSeparatorPos );
1808 break;
1809 case BASEPROPERTY_READONLY:
1811 bool b = false;
1812 if ( Value >>= b )
1813 pListBox->SetReadOnly( b);
1815 break;
1816 case BASEPROPERTY_MULTISELECTION:
1818 bool b = false;
1819 if ( Value >>= b )
1820 pListBox->EnableMultiSelection( b );
1822 break;
1823 case BASEPROPERTY_MULTISELECTION_SIMPLEMODE:
1824 ::toolkit::adjustBooleanWindowStyle( Value, pListBox, WB_SIMPLEMODE, false );
1825 break;
1826 case BASEPROPERTY_LINECOUNT:
1828 sal_Int16 n = 0;
1829 if ( Value >>= n )
1830 pListBox->SetDropDownLineCount( n );
1832 break;
1833 case BASEPROPERTY_STRINGITEMLIST:
1835 css::uno::Sequence< OUString> aItems;
1836 if ( Value >>= aItems )
1838 pListBox->Clear();
1839 addItems( aItems, 0 );
1842 break;
1843 case BASEPROPERTY_SELECTEDITEMS:
1845 css::uno::Sequence<sal_Int16> aItems;
1846 if ( Value >>= aItems )
1848 for ( auto n = pListBox->GetEntryCount(); n; )
1849 pListBox->SelectEntryPos( --n, false );
1851 if ( aItems.hasElements() )
1852 selectItemsPos( aItems, true );
1853 else
1854 pListBox->SetNoSelection();
1856 if ( !pListBox->GetSelectedEntryCount() )
1857 pListBox->SetTopEntry( 0 );
1860 break;
1861 case BASEPROPERTY_HIGHLIGHT_COLOR:
1863 Color nColor = 0;
1864 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
1865 if (bVoid)
1867 nColor = Application::GetSettings().GetStyleSettings().GetHighlightColor();
1869 else
1871 if (!(Value >>= nColor))
1872 break;
1874 pListBox->SetHighlightColor(nColor);
1876 break;
1877 case BASEPROPERTY_HIGHLIGHT_TEXT_COLOR:
1879 Color nColor = 0;
1880 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
1881 if (bVoid)
1883 nColor = Application::GetSettings().GetStyleSettings().GetHighlightTextColor();
1885 else
1887 if (!(Value >>= nColor))
1888 break;
1890 pListBox->SetHighlightTextColor(nColor);
1892 break;
1893 default:
1895 VCLXWindow::setProperty( PropertyName, Value );
1900 css::uno::Any VCLXListBox::getProperty( const OUString& PropertyName )
1902 SolarMutexGuard aGuard;
1903 css::uno::Any aProp;
1904 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1905 if ( pListBox )
1907 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1908 switch ( nPropType )
1910 case BASEPROPERTY_ITEM_SEPARATOR_POS:
1911 aProp <<= sal_Int16( pListBox->GetSeparatorPos() );
1912 break;
1913 case BASEPROPERTY_READONLY:
1915 aProp <<= pListBox->IsReadOnly();
1917 break;
1918 case BASEPROPERTY_MULTISELECTION:
1920 aProp <<= pListBox->IsMultiSelectionEnabled();
1922 break;
1923 case BASEPROPERTY_MULTISELECTION_SIMPLEMODE:
1925 aProp <<= ( ( pListBox->GetStyle() & WB_SIMPLEMODE ) == 0 );
1927 break;
1928 case BASEPROPERTY_LINECOUNT:
1930 aProp <<= static_cast<sal_Int16>(pListBox->GetDropDownLineCount());
1932 break;
1933 case BASEPROPERTY_STRINGITEMLIST:
1935 const sal_Int32 nItems = pListBox->GetEntryCount();
1936 css::uno::Sequence< OUString> aSeq( nItems );
1937 OUString* pStrings = aSeq.getArray();
1938 for ( sal_Int32 n = 0; n < nItems; ++n )
1939 pStrings[n] = pListBox->GetEntry( n );
1940 aProp <<= aSeq;
1943 break;
1944 default:
1946 aProp = VCLXWindow::getProperty( PropertyName );
1950 return aProp;
1953 css::awt::Size VCLXListBox::getMinimumSize( )
1955 SolarMutexGuard aGuard;
1956 Size aSz;
1957 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1958 if ( pListBox )
1959 aSz = pListBox->CalcMinimumSize();
1960 return AWTSize(aSz);
1963 css::awt::Size VCLXListBox::getPreferredSize( )
1965 SolarMutexGuard aGuard;
1966 Size aSz;
1967 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1968 if ( pListBox )
1970 aSz = pListBox->CalcMinimumSize();
1971 if ( pListBox->GetStyle() & WB_DROPDOWN )
1972 aSz.AdjustHeight(4 );
1974 return AWTSize(aSz);
1977 css::awt::Size VCLXListBox::calcAdjustedSize( const css::awt::Size& rNewSize )
1979 SolarMutexGuard aGuard;
1980 Size aSz = VCLSize(rNewSize);
1981 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1982 if ( pListBox )
1983 aSz = pListBox->CalcAdjustedSize( aSz );
1984 return AWTSize(aSz);
1987 css::awt::Size VCLXListBox::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines )
1989 SolarMutexGuard aGuard;
1990 Size aSz;
1991 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1992 if ( pListBox )
1993 aSz = pListBox->CalcBlockSize( nCols, nLines );
1994 return AWTSize(aSz);
1997 void VCLXListBox::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines )
1999 SolarMutexGuard aGuard;
2000 nCols = nLines = 0;
2001 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2002 if ( pListBox )
2004 sal_uInt16 nC, nL;
2005 pListBox->GetMaxVisColumnsAndLines( nC, nL );
2006 nCols = nC;
2007 nLines = nL;
2011 void VCLXListBox::ImplCallItemListeners()
2013 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2014 if ( pListBox && maItemListeners.getLength() )
2016 css::awt::ItemEvent aEvent;
2017 aEvent.Source = getXWeak();
2018 aEvent.Highlighted = 0;
2020 // Set to 0xFFFF on multiple selection, selected entry ID otherwise
2021 aEvent.Selected = (pListBox->GetSelectedEntryCount() == 1 ) ? pListBox->GetSelectedEntryPos() : 0xFFFF;
2023 maItemListeners.itemStateChanged( aEvent );
2026 namespace
2028 Image lcl_getImageFromURL( const OUString& i_rImageURL )
2030 if ( i_rImageURL.isEmpty() )
2031 return Image();
2035 Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
2036 Reference< XGraphicProvider > xProvider(graphic::GraphicProvider::create(xContext));
2037 ::comphelper::NamedValueCollection aMediaProperties;
2038 aMediaProperties.put( "URL", i_rImageURL );
2039 Reference< XGraphic > xGraphic = xProvider->queryGraphic( aMediaProperties.getPropertyValues() );
2040 return Image( xGraphic );
2042 catch( const uno::Exception& )
2044 DBG_UNHANDLED_EXCEPTION("toolkit");
2046 return Image();
2049 void SAL_CALL VCLXListBox::listItemInserted( const ItemListEvent& i_rEvent )
2051 SolarMutexGuard aGuard;
2052 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2054 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemInserted: no ListBox?!" );
2055 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition <= pListBox->GetEntryCount() ),
2056 "VCLXListBox::listItemInserted: illegal (inconsistent) item position!" );
2057 pListBox->InsertEntry(
2058 i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : OUString(),
2059 i_rEvent.ItemImageURL.IsPresent ? TkResMgr::getImageFromURL( i_rEvent.ItemImageURL.Value ) : Image(),
2060 i_rEvent.ItemPosition );
2063 void SAL_CALL VCLXListBox::listItemRemoved( const ItemListEvent& i_rEvent )
2065 SolarMutexGuard aGuard;
2066 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2068 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemRemoved: no ListBox?!" );
2069 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < pListBox->GetEntryCount() ),
2070 "VCLXListBox::listItemRemoved: illegal (inconsistent) item position!" );
2072 pListBox->RemoveEntry( i_rEvent.ItemPosition );
2075 void SAL_CALL VCLXListBox::listItemModified( const ItemListEvent& i_rEvent )
2077 SolarMutexGuard aGuard;
2078 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2080 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" );
2081 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < pListBox->GetEntryCount() ),
2082 "VCLXListBox::listItemModified: illegal (inconsistent) item position!" );
2084 // VCL's ListBox does not support changing an entry's text or image, so remove and re-insert
2086 const OUString sNewText = i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : pListBox->GetEntry( i_rEvent.ItemPosition );
2087 const Image aNewImage( i_rEvent.ItemImageURL.IsPresent ? TkResMgr::getImageFromURL( i_rEvent.ItemImageURL.Value ) : pListBox->GetEntryImage( i_rEvent.ItemPosition ) );
2089 pListBox->RemoveEntry( i_rEvent.ItemPosition );
2090 pListBox->InsertEntry( sNewText, aNewImage, i_rEvent.ItemPosition );
2093 void SAL_CALL VCLXListBox::allItemsRemoved( const EventObject& )
2095 SolarMutexGuard aGuard;
2097 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2098 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" );
2100 pListBox->Clear();
2103 void SAL_CALL VCLXListBox::itemListChanged( const EventObject& i_rEvent )
2105 SolarMutexGuard aGuard;
2107 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2108 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" );
2110 pListBox->Clear();
2112 uno::Reference< beans::XPropertySet > xPropSet( i_rEvent.Source, uno::UNO_QUERY_THROW );
2113 uno::Reference< beans::XPropertySetInfo > xPSI( xPropSet->getPropertySetInfo(), uno::UNO_SET_THROW );
2114 uno::Reference< resource::XStringResourceResolver > xStringResourceResolver;
2115 if ( xPSI->hasPropertyByName("ResourceResolver") )
2117 xStringResourceResolver.set(
2118 xPropSet->getPropertyValue("ResourceResolver"),
2119 uno::UNO_QUERY
2124 Reference< XItemList > xItemList( i_rEvent.Source, uno::UNO_QUERY_THROW );
2125 const uno::Sequence< beans::Pair< OUString, OUString > > aItems = xItemList->getAllItems();
2126 for ( const auto& rItem : aItems )
2128 OUString aLocalizationKey( rItem.First );
2129 if ( xStringResourceResolver.is() && aLocalizationKey.startsWith("&") )
2131 aLocalizationKey = xStringResourceResolver->resolveString(aLocalizationKey.copy( 1 ));
2133 pListBox->InsertEntry( aLocalizationKey, lcl_getImageFromURL( rItem.Second ) );
2137 void SAL_CALL VCLXListBox::disposing( const EventObject& i_rEvent )
2139 // just disambiguate
2140 VCLXWindow::disposing( i_rEvent );
2146 void VCLXMessageBox::GetPropertyIds( std::vector< sal_uInt16 > &rIds )
2148 VCLXTopWindow::ImplGetPropertyIds( rIds );
2151 VCLXMessageBox::VCLXMessageBox()
2155 VCLXMessageBox::~VCLXMessageBox()
2159 void VCLXMessageBox::setCaptionText( const OUString& rText )
2161 SolarMutexGuard aGuard;
2163 VclPtr<vcl::Window> pWindow = GetWindow();
2164 if ( pWindow )
2165 pWindow->SetText( rText );
2168 OUString VCLXMessageBox::getCaptionText()
2170 SolarMutexGuard aGuard;
2172 OUString aText;
2173 VclPtr<vcl::Window> pWindow = GetWindow();
2174 if ( pWindow )
2175 aText = pWindow->GetText();
2176 return aText;
2179 void VCLXMessageBox::setMessageText( const OUString& rText )
2181 SolarMutexGuard aGuard;
2182 VclPtr< MessBox > pBox = GetAs< MessBox >();
2183 if ( pBox )
2184 pBox->SetMessText( rText );
2187 OUString VCLXMessageBox::getMessageText()
2189 SolarMutexGuard aGuard;
2190 OUString aText;
2191 VclPtr< MessBox > pBox = GetAs< MessBox >();
2192 if ( pBox )
2193 aText = pBox->GetMessText();
2194 return aText;
2197 sal_Int16 VCLXMessageBox::execute()
2199 SolarMutexGuard aGuard;
2200 VclPtr< MessBox > pBox = GetAs< MessBox >();
2201 return pBox ? pBox->Execute() : 0;
2204 css::awt::Size SAL_CALL VCLXMessageBox::getMinimumSize()
2206 return css::awt::Size( 250, 100 );
2211 void VCLXDialog::GetPropertyIds( std::vector< sal_uInt16 > &rIds )
2213 VCLXTopWindow::ImplGetPropertyIds( rIds );
2216 VCLXDialog::VCLXDialog()
2218 SAL_INFO("toolkit", "XDialog created");
2221 VCLXDialog::~VCLXDialog()
2223 SAL_INFO("toolkit", __FUNCTION__);
2226 void SAL_CALL VCLXDialog::endDialog( ::sal_Int32 i_result )
2228 SolarMutexGuard aGuard;
2229 VclPtr<Dialog> pDialog = GetAsDynamic< Dialog >();
2230 if ( pDialog )
2231 pDialog->EndDialog( i_result );
2234 void SAL_CALL VCLXDialog::setHelpId( const OUString& rId )
2236 SolarMutexGuard aGuard;
2237 VclPtr< vcl::Window > pWindow = GetWindow();
2238 if ( pWindow )
2239 pWindow->SetHelpId( rId );
2242 void VCLXDialog::setTitle( const OUString& Title )
2244 SolarMutexGuard aGuard;
2245 VclPtr< vcl::Window > pWindow = GetWindow();
2246 if ( pWindow )
2247 pWindow->SetText( Title );
2250 OUString VCLXDialog::getTitle()
2252 SolarMutexGuard aGuard;
2254 OUString aTitle;
2255 VclPtr< vcl::Window > pWindow = GetWindow();
2256 if ( pWindow )
2257 aTitle = pWindow->GetText();
2258 return aTitle;
2261 sal_Int16 VCLXDialog::execute()
2263 SolarMutexGuard aGuard;
2265 sal_Int16 nRet = 0;
2266 if ( GetWindow() )
2268 VclPtr< Dialog > pDlg = GetAs< Dialog >();
2269 vcl::Window* pParent = pDlg->GetWindow( GetWindowType::ParentOverlap );
2270 vcl::Window* pOldParent = nullptr;
2271 vcl::Window* pSetParent = nullptr;
2272 if ( pParent && !pParent->IsReallyVisible() )
2274 pOldParent = pDlg->GetParent();
2275 vcl::Window* pFrame = pDlg->GetWindow( GetWindowType::Frame );
2276 if( pFrame != pDlg )
2278 pDlg->SetParent( pFrame );
2279 pSetParent = pFrame;
2283 nRet = pDlg->Execute();
2285 // set the parent back only in case no new parent was set from outside
2286 // in other words, revert only own changes
2287 if ( pOldParent && pDlg->GetParent() == pSetParent )
2288 pDlg->SetParent( pOldParent );
2290 return nRet;
2293 void VCLXDialog::endExecute()
2295 endDialog(0);
2298 void SAL_CALL VCLXDialog::draw( sal_Int32 nX, sal_Int32 nY )
2300 SolarMutexGuard aGuard;
2301 VclPtr< vcl::Window > pWindow = GetWindow();
2302 if ( pWindow )
2304 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
2305 if ( !pDev )
2306 pDev = pWindow->GetParent()->GetOutDev();
2308 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
2309 pWindow->Draw( pDev, aPos, SystemTextColorFlags::NoControls );
2313 css::awt::DeviceInfo VCLXDialog::getInfo()
2315 css::awt::DeviceInfo aInfo = VCLXDevice::getInfo();
2317 SolarMutexGuard aGuard;
2318 VclPtr< Dialog > pDlg = GetAs< Dialog >();
2319 if ( pDlg )
2320 pDlg->GetDrawWindowBorder( aInfo.LeftInset, aInfo.TopInset, aInfo.RightInset, aInfo.BottomInset );
2322 return aInfo;
2325 void SAL_CALL VCLXDialog::setProperty(
2326 const OUString& PropertyName,
2327 const css::uno::Any& Value )
2329 SolarMutexGuard aGuard;
2330 VclPtr< Dialog > pDialog = GetAs< Dialog >();
2331 if ( !pDialog )
2332 return;
2334 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
2336 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2337 switch ( nPropType )
2339 case BASEPROPERTY_GRAPHIC:
2341 Reference< XGraphic > xGraphic;
2342 if (( Value >>= xGraphic ) && xGraphic.is() )
2344 Graphic aImage(xGraphic);
2346 Wallpaper aWallpaper(aImage.GetBitmapEx());
2347 aWallpaper.SetStyle( WallpaperStyle::Scale );
2348 pDialog->SetBackground( aWallpaper );
2350 else if ( bVoid || !xGraphic.is() )
2352 Color aColor = pDialog->GetControlBackground();
2353 if ( aColor == COL_AUTO )
2354 aColor = pDialog->GetSettings().GetStyleSettings().GetDialogColor();
2356 Wallpaper aWallpaper( aColor );
2357 pDialog->SetBackground( aWallpaper );
2360 break;
2362 default:
2364 VCLXContainer::setProperty( PropertyName, Value );
2371 VCLXMultiPage::VCLXMultiPage() : maTabListeners( *this ), mTabId( 1 )
2373 SAL_INFO("toolkit", "VCLXMultiPage::VCLXMultiPage()" );
2376 void VCLXMultiPage::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
2378 PushPropertyIds( rIds,
2379 BASEPROPERTY_BACKGROUNDCOLOR,
2380 BASEPROPERTY_DEFAULTCONTROL,
2381 BASEPROPERTY_ENABLED,
2382 BASEPROPERTY_MULTIPAGEVALUE,
2383 BASEPROPERTY_ENABLEVISIBLE,
2384 BASEPROPERTY_FONTDESCRIPTOR,
2385 BASEPROPERTY_GRAPHIC,
2386 BASEPROPERTY_HELPTEXT,
2387 BASEPROPERTY_HELPURL,
2388 BASEPROPERTY_IMAGEALIGN,
2389 BASEPROPERTY_IMAGEPOSITION,
2390 BASEPROPERTY_IMAGEURL,
2391 BASEPROPERTY_PRINTABLE,
2392 BASEPROPERTY_TABSTOP,
2393 BASEPROPERTY_FOCUSONCLICK,
2395 VCLXContainer::ImplGetPropertyIds( rIds );
2398 VCLXMultiPage::~VCLXMultiPage()
2401 void SAL_CALL VCLXMultiPage::dispose()
2403 SolarMutexGuard aGuard;
2405 css::lang::EventObject aObj;
2406 aObj.Source = getXWeak();
2407 maTabListeners.disposeAndClear( aObj );
2408 VCLXContainer::dispose();
2410 // css::awt::XView
2411 void SAL_CALL VCLXMultiPage::draw( sal_Int32 nX, sal_Int32 nY )
2413 SolarMutexGuard aGuard;
2414 VclPtr< vcl::Window > pWindow = GetWindow();
2416 if ( pWindow )
2418 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
2419 if ( !pDev )
2420 pDev = pWindow->GetParent()->GetOutDev();
2422 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
2423 pWindow->Draw( pDev, aPos, SystemTextColorFlags::NoControls );
2427 uno::Any SAL_CALL VCLXMultiPage::getProperty( const OUString& PropertyName )
2429 SAL_INFO("toolkit", " **** VCLXMultiPage::getProperty " << PropertyName );
2430 SolarMutexGuard aGuard;
2431 css::uno::Any aProp;
2432 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2433 switch ( nPropType )
2436 case BASEPROPERTY_MULTIPAGEVALUE:
2438 aProp <<= getActiveTabID();
2440 break;
2441 default:
2442 aProp = VCLXContainer::getProperty( PropertyName );
2444 return aProp;
2447 void SAL_CALL VCLXMultiPage::setProperty(
2448 const OUString& PropertyName,
2449 const css::uno::Any& Value )
2451 SAL_INFO("toolkit", " **** VCLXMultiPage::setProperty " << PropertyName );
2452 SolarMutexGuard aGuard;
2454 VclPtr< TabControl > pTabControl = GetAs< TabControl >();
2455 if ( !pTabControl )
2456 return;
2458 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
2460 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2461 switch ( nPropType )
2463 case BASEPROPERTY_MULTIPAGEVALUE:
2465 SAL_INFO("toolkit", "***MULTIPAGE VALUE");
2466 sal_Int32 nId(0);
2467 Value >>= nId;
2468 // when the multipage is created we attempt to set the activepage
2469 // but no pages created
2470 if ( nId && nId <= getWindows().getLength() )
2471 activateTab( nId );
2472 break;
2474 case BASEPROPERTY_GRAPHIC:
2476 Reference< XGraphic > xGraphic;
2477 if (( Value >>= xGraphic ) && xGraphic.is() )
2479 Graphic aImage(xGraphic);
2481 Wallpaper aWallpaper(aImage.GetBitmapEx());
2482 aWallpaper.SetStyle( WallpaperStyle::Scale );
2483 pTabControl->SetBackground( aWallpaper );
2485 else if ( bVoid || !xGraphic.is() )
2487 Color aColor = pTabControl->GetControlBackground();
2488 if ( aColor == COL_AUTO )
2489 aColor = pTabControl->GetSettings().GetStyleSettings().GetDialogColor();
2491 Wallpaper aWallpaper( aColor );
2492 pTabControl->SetBackground( aWallpaper );
2495 break;
2497 default:
2499 VCLXContainer::setProperty( PropertyName, Value );
2504 TabControl *VCLXMultiPage::getTabControl() const
2506 VclPtr<TabControl> pTabControl = GetAsDynamic< TabControl >();
2507 if ( pTabControl )
2508 return pTabControl;
2509 throw uno::RuntimeException();
2511 sal_Int32 SAL_CALL VCLXMultiPage::insertTab()
2513 TabControl *pTabControl = getTabControl();
2514 VclPtrInstance<TabPage> pTab( pTabControl );
2515 return static_cast< sal_Int32 >( insertTab( pTab, OUString() ) );
2518 sal_uInt16 VCLXMultiPage::insertTab( TabPage* pPage, OUString const & sTitle )
2520 TabControl *pTabControl = getTabControl();
2521 sal_uInt16 id = sal::static_int_cast< sal_uInt16 >( mTabId++ );
2522 pTabControl->InsertPage( id, sTitle );
2523 pTabControl->SetTabPage( id, pPage );
2524 return id;
2527 void SAL_CALL VCLXMultiPage::removeTab( sal_Int32 ID )
2529 TabControl *pTabControl = getTabControl();
2530 if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == nullptr )
2531 throw lang::IndexOutOfBoundsException();
2532 pTabControl->RemovePage( sal::static_int_cast< sal_uInt16 >( ID ) );
2535 void SAL_CALL VCLXMultiPage::activateTab( sal_Int32 ID )
2537 TabControl *pTabControl = getTabControl();
2538 SAL_INFO(
2539 "toolkit",
2540 "Attempting to activate tab " << ID << ", active tab is "
2541 << getActiveTabID() << ", numtabs is " << getWindows().getLength());
2542 if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == nullptr )
2543 throw lang::IndexOutOfBoundsException();
2544 pTabControl->SelectTabPage( sal::static_int_cast< sal_uInt16 >( ID ) );
2547 sal_Int32 SAL_CALL VCLXMultiPage::getActiveTabID()
2549 return getTabControl()->GetCurPageId( );
2552 void SAL_CALL VCLXMultiPage::addTabListener( const uno::Reference< awt::XTabListener >& xListener )
2554 SolarMutexGuard aGuard;
2555 maTabListeners.addInterface( xListener );
2558 void SAL_CALL VCLXMultiPage::removeTabListener( const uno::Reference< awt::XTabListener >& xListener )
2560 SolarMutexGuard aGuard;
2561 maTabListeners.addInterface( xListener );
2564 void SAL_CALL VCLXMultiPage::setTabProps( sal_Int32 ID, const uno::Sequence< beans::NamedValue >& Properties )
2566 SolarMutexGuard aGuard;
2567 TabControl *pTabControl = getTabControl();
2568 if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == nullptr )
2569 throw lang::IndexOutOfBoundsException();
2571 for (const auto& rProp : Properties)
2573 const OUString &name = rProp.Name;
2574 const uno::Any &value = rProp.Value;
2576 if (name == "Title")
2578 OUString title = value.get<OUString>();
2579 pTabControl->SetPageText( sal::static_int_cast< sal_uInt16 >( ID ), title );
2584 uno::Sequence< beans::NamedValue > SAL_CALL VCLXMultiPage::getTabProps( sal_Int32 ID )
2586 SolarMutexGuard aGuard;
2587 TabControl *pTabControl = getTabControl();
2588 if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == nullptr )
2589 throw lang::IndexOutOfBoundsException();
2591 uno::Sequence< beans::NamedValue > props
2593 { "Title", css::uno::Any(pTabControl->GetPageText( sal::static_int_cast< sal_uInt16 >( ID ) )) },
2594 { "Position", css::uno::Any(pTabControl->GetPagePos( sal::static_int_cast< sal_uInt16 >( ID ) )) }
2596 return props;
2598 void VCLXMultiPage::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
2600 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
2601 switch ( rVclWindowEvent.GetId() )
2603 case VclEventId::TabpageDeactivate:
2605 sal_uLong nPageID = reinterpret_cast<sal_uLong>( rVclWindowEvent.GetData() );
2606 maTabListeners.deactivated( nPageID );
2607 break;
2610 case VclEventId::TabpageActivate:
2612 sal_uLong nPageID = reinterpret_cast<sal_uLong>( rVclWindowEvent.GetData() );
2613 maTabListeners.activated( nPageID );
2614 break;
2616 default:
2617 VCLXContainer::ProcessWindowEvent( rVclWindowEvent );
2618 break;
2624 VCLXTabPage::VCLXTabPage()
2628 void VCLXTabPage::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
2630 PushPropertyIds( rIds,
2631 BASEPROPERTY_BACKGROUNDCOLOR,
2632 BASEPROPERTY_DEFAULTCONTROL,
2633 BASEPROPERTY_ENABLED,
2634 BASEPROPERTY_ENABLEVISIBLE,
2635 BASEPROPERTY_FONTDESCRIPTOR,
2636 BASEPROPERTY_GRAPHIC,
2637 BASEPROPERTY_HELPTEXT,
2638 BASEPROPERTY_HELPURL,
2639 BASEPROPERTY_IMAGEALIGN,
2640 BASEPROPERTY_IMAGEPOSITION,
2641 BASEPROPERTY_IMAGEURL,
2642 BASEPROPERTY_PRINTABLE,
2643 BASEPROPERTY_TABSTOP,
2644 BASEPROPERTY_FOCUSONCLICK,
2646 VCLXContainer::ImplGetPropertyIds( rIds );
2649 VCLXTabPage::~VCLXTabPage()
2653 // css::awt::XView
2654 void SAL_CALL VCLXTabPage::draw( sal_Int32 nX, sal_Int32 nY )
2656 SolarMutexGuard aGuard;
2657 VclPtr< vcl::Window > pWindow = GetWindow();
2659 if ( pWindow )
2661 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
2662 if ( !pDev )
2663 pDev = pWindow->GetParent()->GetOutDev();
2665 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
2666 pWindow->Draw( pDev, aPos, SystemTextColorFlags::NoControls );
2670 void SAL_CALL VCLXTabPage::setProperty(
2671 const OUString& PropertyName,
2672 const css::uno::Any& Value )
2674 SolarMutexGuard aGuard;
2675 VclPtr< TabPage > pTabPage = GetAs< TabPage >();
2676 if ( !pTabPage )
2677 return;
2679 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
2681 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2682 switch ( nPropType )
2684 case BASEPROPERTY_GRAPHIC:
2686 Reference< XGraphic > xGraphic;
2687 if (( Value >>= xGraphic ) && xGraphic.is() )
2689 Graphic aImage(xGraphic);
2691 Wallpaper aWallpaper(aImage.GetBitmapEx());
2692 aWallpaper.SetStyle( WallpaperStyle::Scale );
2693 pTabPage->SetBackground( aWallpaper );
2695 else if ( bVoid || !xGraphic.is() )
2697 Color aColor = pTabPage->GetControlBackground();
2698 if ( aColor == COL_AUTO )
2699 aColor = pTabPage->GetSettings().GetStyleSettings().GetDialogColor();
2701 Wallpaper aWallpaper( aColor );
2702 pTabPage->SetBackground( aWallpaper );
2705 break;
2706 case BASEPROPERTY_TITLE:
2708 OUString sTitle;
2709 if ( Value >>= sTitle )
2711 pTabPage->SetText(sTitle);
2714 break;
2716 default:
2718 VCLXContainer::setProperty( PropertyName, Value );
2723 TabPage *VCLXTabPage::getTabPage() const
2725 VclPtr< TabPage > pTabPage = GetAsDynamic< TabPage >();
2726 if ( pTabPage )
2727 return pTabPage;
2728 throw uno::RuntimeException();
2734 VCLXFixedHyperlink::VCLXFixedHyperlink() :
2736 maActionListeners( *this )
2741 VCLXFixedHyperlink::~VCLXFixedHyperlink()
2745 void VCLXFixedHyperlink::dispose()
2747 SolarMutexGuard aGuard;
2749 css::lang::EventObject aObj;
2750 aObj.Source = getXWeak();
2751 maActionListeners.disposeAndClear( aObj );
2752 VCLXWindow::dispose();
2755 void VCLXFixedHyperlink::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
2757 switch ( rVclWindowEvent.GetId() )
2759 case VclEventId::ButtonClick:
2761 if ( maActionListeners.getLength() )
2763 css::awt::ActionEvent aEvent;
2764 aEvent.Source = getXWeak();
2765 maActionListeners.actionPerformed( aEvent );
2767 [[fallthrough]];
2769 default:
2770 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
2771 break;
2775 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXFixedHyperlink::CreateAccessibleContext()
2777 return getAccessibleFactory().createAccessibleContext( this );
2780 void VCLXFixedHyperlink::setText( const OUString& Text )
2782 SolarMutexGuard aGuard;
2783 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
2784 if (pBase)
2785 pBase->SetText(Text);
2788 OUString VCLXFixedHyperlink::getText()
2790 SolarMutexGuard aGuard;
2792 OUString aText;
2793 VclPtr< vcl::Window > pWindow = GetWindow();
2794 if ( pWindow )
2795 aText = pWindow->GetText();
2796 return aText;
2799 void VCLXFixedHyperlink::setURL( const OUString& URL )
2801 SolarMutexGuard aGuard;
2802 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
2803 if ( pBase )
2804 pBase->SetURL( URL );
2807 OUString VCLXFixedHyperlink::getURL( )
2809 SolarMutexGuard aGuard;
2811 OUString aText;
2812 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
2813 if ( pBase )
2814 aText = pBase->GetURL();
2815 return aText;
2818 void VCLXFixedHyperlink::setAlignment( sal_Int16 nAlign )
2820 SolarMutexGuard aGuard;
2822 VclPtr< vcl::Window > pWindow = GetWindow();
2823 if ( !pWindow )
2824 return;
2826 WinBits nNewBits = 0;
2827 if ( nAlign == css::awt::TextAlign::LEFT )
2828 nNewBits = WB_LEFT;
2829 else if ( nAlign == css::awt::TextAlign::CENTER )
2830 nNewBits = WB_CENTER;
2831 else
2832 nNewBits = WB_RIGHT;
2834 WinBits nStyle = pWindow->GetStyle();
2835 nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT);
2836 pWindow->SetStyle( nStyle | nNewBits );
2839 sal_Int16 VCLXFixedHyperlink::getAlignment()
2841 SolarMutexGuard aGuard;
2843 sal_Int16 nAlign = 0;
2844 VclPtr< vcl::Window > pWindow = GetWindow();
2845 if ( pWindow )
2847 WinBits nStyle = pWindow->GetStyle();
2848 if ( nStyle & WB_LEFT )
2849 nAlign = css::awt::TextAlign::LEFT;
2850 else if ( nStyle & WB_CENTER )
2851 nAlign = css::awt::TextAlign::CENTER;
2852 else
2853 nAlign = css::awt::TextAlign::RIGHT;
2855 return nAlign;
2858 void VCLXFixedHyperlink::addActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
2860 SolarMutexGuard aGuard;
2861 maActionListeners.addInterface( l );
2864 void VCLXFixedHyperlink::removeActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
2866 SolarMutexGuard aGuard;
2867 maActionListeners.removeInterface( l );
2870 css::awt::Size VCLXFixedHyperlink::getMinimumSize( )
2872 SolarMutexGuard aGuard;
2873 Size aSz;
2874 VclPtr< FixedText > pFixedText = GetAs< FixedText >();
2875 if ( pFixedText )
2876 aSz = pFixedText->CalcMinimumSize();
2877 return AWTSize(aSz);
2880 css::awt::Size VCLXFixedHyperlink::getPreferredSize( )
2882 return getMinimumSize();
2885 css::awt::Size VCLXFixedHyperlink::calcAdjustedSize( const css::awt::Size& rNewSize )
2887 SolarMutexGuard aGuard;
2888 Size aSz( VCLUnoHelper::ConvertToVCLSize( rNewSize ));
2889 VclPtr< FixedText > pFixedText = GetAs< FixedText >();
2890 if (pFixedText)
2892 Size aMinSz = pFixedText->CalcMinimumSize(rNewSize.Width);
2893 if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
2894 aSz.setHeight( aMinSz.Height() );
2895 else
2896 aSz = aMinSz;
2899 return VCLUnoHelper::ConvertToAWTSize(aSz);
2902 void VCLXFixedHyperlink::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
2904 SolarMutexGuard aGuard;
2906 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
2907 if ( !pBase )
2908 return;
2910 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2911 switch ( nPropType )
2913 case BASEPROPERTY_LABEL:
2915 OUString sNewLabel;
2916 if ( Value >>= sNewLabel )
2917 pBase->SetText(sNewLabel);
2918 break;
2921 case BASEPROPERTY_URL:
2923 OUString sNewURL;
2924 if ( Value >>= sNewURL )
2925 pBase->SetURL( sNewURL );
2926 break;
2929 default:
2931 VCLXWindow::setProperty( PropertyName, Value );
2936 css::uno::Any VCLXFixedHyperlink::getProperty( const OUString& PropertyName )
2938 SolarMutexGuard aGuard;
2940 css::uno::Any aProp;
2941 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
2942 if ( pBase )
2944 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2945 switch ( nPropType )
2947 case BASEPROPERTY_URL:
2949 aProp <<= pBase->GetURL();
2950 break;
2953 default:
2955 aProp = VCLXWindow::getProperty( PropertyName );
2959 return aProp;
2962 void VCLXFixedHyperlink::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
2964 PushPropertyIds( rIds,
2965 BASEPROPERTY_ALIGN,
2966 BASEPROPERTY_BACKGROUNDCOLOR,
2967 BASEPROPERTY_BORDER,
2968 BASEPROPERTY_BORDERCOLOR,
2969 BASEPROPERTY_DEFAULTCONTROL,
2970 BASEPROPERTY_ENABLED,
2971 BASEPROPERTY_ENABLEVISIBLE,
2972 BASEPROPERTY_FONTDESCRIPTOR,
2973 BASEPROPERTY_HELPTEXT,
2974 BASEPROPERTY_HELPURL,
2975 BASEPROPERTY_LABEL,
2976 BASEPROPERTY_MULTILINE,
2977 BASEPROPERTY_NOLABEL,
2978 BASEPROPERTY_PRINTABLE,
2979 BASEPROPERTY_TABSTOP,
2980 BASEPROPERTY_VERTICALALIGN,
2981 BASEPROPERTY_URL,
2982 BASEPROPERTY_WRITING_MODE,
2983 BASEPROPERTY_CONTEXT_WRITING_MODE,
2985 VCLXWindow::ImplGetPropertyIds( rIds );
2990 void VCLXFixedText::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
2992 PushPropertyIds( rIds,
2993 BASEPROPERTY_ALIGN,
2994 BASEPROPERTY_BACKGROUNDCOLOR,
2995 BASEPROPERTY_BORDER,
2996 BASEPROPERTY_BORDERCOLOR,
2997 BASEPROPERTY_DEFAULTCONTROL,
2998 BASEPROPERTY_ENABLED,
2999 BASEPROPERTY_ENABLEVISIBLE,
3000 BASEPROPERTY_FONTDESCRIPTOR,
3001 BASEPROPERTY_HELPTEXT,
3002 BASEPROPERTY_HELPURL,
3003 BASEPROPERTY_LABEL,
3004 BASEPROPERTY_MULTILINE,
3005 BASEPROPERTY_NOLABEL,
3006 BASEPROPERTY_PRINTABLE,
3007 BASEPROPERTY_TABSTOP,
3008 BASEPROPERTY_VERTICALALIGN,
3009 BASEPROPERTY_WRITING_MODE,
3010 BASEPROPERTY_CONTEXT_WRITING_MODE,
3011 BASEPROPERTY_REFERENCE_DEVICE,
3012 BASEPROPERTY_HIGHLIGHT_COLOR,
3013 BASEPROPERTY_HIGHLIGHT_TEXT_COLOR,
3015 VCLXWindow::ImplGetPropertyIds( rIds );
3018 VCLXFixedText::VCLXFixedText()
3022 VCLXFixedText::~VCLXFixedText()
3026 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXFixedText::CreateAccessibleContext()
3028 return getAccessibleFactory().createAccessibleContext( this );
3031 void VCLXFixedText::setText( const OUString& Text )
3033 SolarMutexGuard aGuard;
3035 VclPtr< vcl::Window > pWindow = GetWindow();
3036 if ( pWindow )
3037 pWindow->SetText( Text );
3040 OUString VCLXFixedText::getText()
3042 SolarMutexGuard aGuard;
3044 OUString aText;
3045 VclPtr< vcl::Window > pWindow = GetWindow();
3046 if ( pWindow )
3047 aText = pWindow->GetText();
3048 return aText;
3051 void VCLXFixedText::setAlignment( sal_Int16 nAlign )
3053 SolarMutexGuard aGuard;
3055 VclPtr< vcl::Window > pWindow = GetWindow();
3056 if ( !pWindow )
3057 return;
3059 WinBits nNewBits = 0;
3060 if ( nAlign == css::awt::TextAlign::LEFT )
3061 nNewBits = WB_LEFT;
3062 else if ( nAlign == css::awt::TextAlign::CENTER )
3063 nNewBits = WB_CENTER;
3064 else
3065 nNewBits = WB_RIGHT;
3067 WinBits nStyle = pWindow->GetStyle();
3068 nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT);
3069 pWindow->SetStyle( nStyle | nNewBits );
3072 sal_Int16 VCLXFixedText::getAlignment()
3074 SolarMutexGuard aGuard;
3076 sal_Int16 nAlign = 0;
3077 VclPtr< vcl::Window > pWindow = GetWindow();
3078 if ( pWindow )
3080 WinBits nStyle = pWindow->GetStyle();
3081 if ( nStyle & WB_LEFT )
3082 nAlign = css::awt::TextAlign::LEFT;
3083 else if ( nStyle & WB_CENTER )
3084 nAlign = css::awt::TextAlign::CENTER;
3085 else
3086 nAlign = css::awt::TextAlign::RIGHT;
3088 return nAlign;
3091 css::awt::Size VCLXFixedText::getMinimumSize( )
3093 SolarMutexGuard aGuard;
3095 Size aSz;
3096 VclPtr< FixedText > pFixedText = GetAs< FixedText >();
3097 if ( pFixedText )
3098 aSz = pFixedText->CalcMinimumSize();
3099 return AWTSize(aSz);
3102 css::awt::Size VCLXFixedText::getPreferredSize( )
3104 return getMinimumSize();
3107 css::awt::Size VCLXFixedText::calcAdjustedSize( const css::awt::Size& rMaxSize )
3109 SolarMutexGuard aGuard;
3111 Size aAdjustedSize( VCLUnoHelper::ConvertToVCLSize( rMaxSize ) );
3112 VclPtr< FixedText > pFixedText = GetAs< FixedText >();
3113 if ( pFixedText )
3114 aAdjustedSize = pFixedText->CalcMinimumSize( rMaxSize.Width );
3115 return VCLUnoHelper::ConvertToAWTSize( aAdjustedSize );
3120 void VCLXScrollBar::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
3122 PushPropertyIds( rIds,
3123 BASEPROPERTY_BACKGROUNDCOLOR,
3124 BASEPROPERTY_BLOCKINCREMENT,
3125 BASEPROPERTY_BORDER,
3126 BASEPROPERTY_BORDERCOLOR,
3127 BASEPROPERTY_DEFAULTCONTROL,
3128 BASEPROPERTY_ENABLED,
3129 BASEPROPERTY_ENABLEVISIBLE,
3130 BASEPROPERTY_HELPTEXT,
3131 BASEPROPERTY_HELPURL,
3132 BASEPROPERTY_LINEINCREMENT,
3133 BASEPROPERTY_LIVE_SCROLL,
3134 BASEPROPERTY_ORIENTATION,
3135 BASEPROPERTY_PRINTABLE,
3136 BASEPROPERTY_REPEAT_DELAY,
3137 BASEPROPERTY_SCROLLVALUE,
3138 BASEPROPERTY_SCROLLVALUE_MAX,
3139 BASEPROPERTY_SCROLLVALUE_MIN,
3140 BASEPROPERTY_SYMBOL_COLOR,
3141 BASEPROPERTY_TABSTOP,
3142 BASEPROPERTY_VISIBLESIZE,
3143 BASEPROPERTY_WRITING_MODE,
3144 BASEPROPERTY_CONTEXT_WRITING_MODE,
3146 VCLXWindow::ImplGetPropertyIds( rIds );
3149 VCLXScrollBar::VCLXScrollBar() : maAdjustmentListeners( *this )
3153 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXScrollBar::CreateAccessibleContext()
3155 return getAccessibleFactory().createAccessibleContext( this );
3158 // css::lang::XComponent
3159 void VCLXScrollBar::dispose()
3161 SolarMutexGuard aGuard;
3163 css::lang::EventObject aObj;
3164 aObj.Source = getXWeak();
3165 maAdjustmentListeners.disposeAndClear( aObj );
3166 VCLXWindow::dispose();
3169 // css::awt::XScrollbar
3170 void VCLXScrollBar::addAdjustmentListener( const css::uno::Reference< css::awt::XAdjustmentListener > & l )
3172 SolarMutexGuard aGuard;
3173 maAdjustmentListeners.addInterface( l );
3176 void VCLXScrollBar::removeAdjustmentListener( const css::uno::Reference< css::awt::XAdjustmentListener > & l )
3178 SolarMutexGuard aGuard;
3179 maAdjustmentListeners.removeInterface( l );
3182 void VCLXScrollBar::setValue( sal_Int32 n )
3184 SolarMutexGuard aGuard;
3186 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3187 if ( pScrollBar )
3188 pScrollBar->DoScroll( n );
3191 void VCLXScrollBar::setValues( sal_Int32 nValue, sal_Int32 nVisible, sal_Int32 nMax )
3193 SolarMutexGuard aGuard;
3195 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3196 if ( pScrollBar )
3198 pScrollBar->SetVisibleSize( nVisible );
3199 pScrollBar->SetRangeMax( nMax );
3200 pScrollBar->DoScroll( nValue );
3204 sal_Int32 VCLXScrollBar::getValue()
3206 SolarMutexGuard aGuard;
3208 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3209 return pScrollBar ? pScrollBar->GetThumbPos() : 0;
3212 void VCLXScrollBar::setMaximum( sal_Int32 n )
3214 SolarMutexGuard aGuard;
3216 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3217 if ( pScrollBar )
3218 pScrollBar->SetRangeMax( n );
3221 sal_Int32 VCLXScrollBar::getMaximum()
3223 SolarMutexGuard aGuard;
3225 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3226 return pScrollBar ? pScrollBar->GetRangeMax() : 0;
3229 void VCLXScrollBar::setMinimum( sal_Int32 n )
3231 SolarMutexGuard aGuard;
3233 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3234 if ( pScrollBar )
3235 pScrollBar->SetRangeMin( n );
3238 sal_Int32 VCLXScrollBar::getMinimum() const
3240 SolarMutexGuard aGuard;
3242 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3243 return pScrollBar ? pScrollBar->GetRangeMin() : 0;
3246 void VCLXScrollBar::setLineIncrement( sal_Int32 n )
3248 SolarMutexGuard aGuard;
3250 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3251 if ( pScrollBar )
3252 pScrollBar->SetLineSize( n );
3255 sal_Int32 VCLXScrollBar::getLineIncrement()
3257 SolarMutexGuard aGuard;
3259 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3260 return pScrollBar ? pScrollBar->GetLineSize() : 0;
3263 void VCLXScrollBar::setBlockIncrement( sal_Int32 n )
3265 SolarMutexGuard aGuard;
3267 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3268 if ( pScrollBar )
3269 pScrollBar->SetPageSize( n );
3272 sal_Int32 VCLXScrollBar::getBlockIncrement()
3274 SolarMutexGuard aGuard;
3276 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3277 return pScrollBar ? pScrollBar->GetPageSize() : 0;
3280 void VCLXScrollBar::setVisibleSize( sal_Int32 n )
3282 SolarMutexGuard aGuard;
3284 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3285 if ( pScrollBar )
3286 pScrollBar->SetVisibleSize( n );
3289 sal_Int32 VCLXScrollBar::getVisibleSize()
3291 SolarMutexGuard aGuard;
3293 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3294 return pScrollBar ? pScrollBar->GetVisibleSize() : 0;
3297 void VCLXScrollBar::setOrientation( sal_Int32 n )
3299 SolarMutexGuard aGuard;
3301 VclPtr< vcl::Window > pWindow = GetWindow();
3302 if ( pWindow )
3304 WinBits nStyle = pWindow->GetStyle();
3305 nStyle &= ~(WB_HORZ|WB_VERT);
3306 if ( n == css::awt::ScrollBarOrientation::HORIZONTAL )
3307 nStyle |= WB_HORZ;
3308 else
3309 nStyle |= WB_VERT;
3311 pWindow->SetStyle( nStyle );
3312 pWindow->Resize();
3316 sal_Int32 VCLXScrollBar::getOrientation()
3318 SolarMutexGuard aGuard;
3320 sal_Int32 n = 0;
3321 VclPtr< vcl::Window > pWindow = GetWindow();
3322 if ( pWindow )
3324 WinBits nStyle = pWindow->GetStyle();
3325 if ( nStyle & WB_HORZ )
3326 n = css::awt::ScrollBarOrientation::HORIZONTAL;
3327 else
3328 n = css::awt::ScrollBarOrientation::VERTICAL;
3330 return n;
3334 // css::awt::VclWindowPeer
3335 void VCLXScrollBar::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
3337 SolarMutexGuard aGuard;
3339 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3340 if ( !pScrollBar )
3341 return;
3343 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
3345 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3346 switch ( nPropType )
3348 case BASEPROPERTY_LIVE_SCROLL:
3350 bool bDo = false;
3351 if ( !bVoid )
3353 OSL_VERIFY( Value >>= bDo );
3355 AllSettings aSettings( pScrollBar->GetSettings() );
3356 StyleSettings aStyle( aSettings.GetStyleSettings() );
3357 DragFullOptions nDragOptions = aStyle.GetDragFullOptions();
3358 if ( bDo )
3359 nDragOptions |= DragFullOptions::Scroll;
3360 else
3361 nDragOptions &= ~DragFullOptions::Scroll;
3362 aStyle.SetDragFullOptions( nDragOptions );
3363 aSettings.SetStyleSettings( aStyle );
3364 pScrollBar->SetSettings( aSettings );
3366 break;
3368 case BASEPROPERTY_SCROLLVALUE:
3370 if ( !bVoid )
3372 sal_Int32 n = 0;
3373 if ( Value >>= n )
3374 setValue( n );
3377 break;
3378 case BASEPROPERTY_SCROLLVALUE_MAX:
3379 case BASEPROPERTY_SCROLLVALUE_MIN:
3381 if ( !bVoid )
3383 sal_Int32 n = 0;
3384 if ( Value >>= n )
3386 if ( nPropType == BASEPROPERTY_SCROLLVALUE_MAX )
3387 setMaximum( n );
3388 else
3389 setMinimum( n );
3393 break;
3394 case BASEPROPERTY_LINEINCREMENT:
3396 if ( !bVoid )
3398 sal_Int32 n = 0;
3399 if ( Value >>= n )
3400 setLineIncrement( n );
3403 break;
3404 case BASEPROPERTY_BLOCKINCREMENT:
3406 if ( !bVoid )
3408 sal_Int32 n = 0;
3409 if ( Value >>= n )
3410 setBlockIncrement( n );
3413 break;
3414 case BASEPROPERTY_VISIBLESIZE:
3416 if ( !bVoid )
3418 sal_Int32 n = 0;
3419 if ( Value >>= n )
3420 setVisibleSize( n );
3423 break;
3424 case BASEPROPERTY_ORIENTATION:
3426 if ( !bVoid )
3428 sal_Int32 n = 0;
3429 if ( Value >>= n )
3430 setOrientation( n );
3433 break;
3435 case BASEPROPERTY_BACKGROUNDCOLOR:
3437 // the default implementation of the base class doesn't work here, since our
3438 // interpretation for this property is slightly different
3439 ::toolkit::setButtonLikeFaceColor( pScrollBar, Value);
3441 break;
3443 default:
3445 VCLXWindow::setProperty( PropertyName, Value );
3450 css::uno::Any VCLXScrollBar::getProperty( const OUString& PropertyName )
3452 SolarMutexGuard aGuard;
3454 css::uno::Any aProp;
3455 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3456 if ( pScrollBar )
3458 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3460 switch ( nPropType )
3462 case BASEPROPERTY_LIVE_SCROLL:
3464 aProp <<= bool( pScrollBar->GetSettings().GetStyleSettings().GetDragFullOptions() & DragFullOptions::Scroll );
3466 break;
3467 case BASEPROPERTY_SCROLLVALUE:
3469 aProp <<= getValue();
3471 break;
3472 case BASEPROPERTY_SCROLLVALUE_MAX:
3474 aProp <<= getMaximum();
3476 break;
3477 case BASEPROPERTY_SCROLLVALUE_MIN:
3479 aProp <<= getMinimum();
3481 break;
3482 case BASEPROPERTY_LINEINCREMENT:
3484 aProp <<= getLineIncrement();
3486 break;
3487 case BASEPROPERTY_BLOCKINCREMENT:
3489 aProp <<= getBlockIncrement();
3491 break;
3492 case BASEPROPERTY_VISIBLESIZE:
3494 aProp <<= getVisibleSize();
3496 break;
3497 case BASEPROPERTY_ORIENTATION:
3499 aProp <<= getOrientation();
3501 break;
3502 case BASEPROPERTY_BACKGROUNDCOLOR:
3504 // the default implementation of the base class doesn't work here, since our
3505 // interpretation for this property is slightly different
3506 aProp = ::toolkit::getButtonLikeFaceColor( pScrollBar );
3508 break;
3510 default:
3512 aProp = VCLXWindow::getProperty( PropertyName );
3516 return aProp;
3519 void VCLXScrollBar::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
3521 switch ( rVclWindowEvent.GetId() )
3523 case VclEventId::ScrollbarScroll:
3525 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
3526 // since we call listeners below, there is a potential that we will be destroyed
3527 // in during the listener call. To prevent the resulting crashes, we keep us
3528 // alive as long as we're here
3530 if ( maAdjustmentListeners.getLength() )
3532 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3534 if( pScrollBar )
3536 css::awt::AdjustmentEvent aEvent;
3537 aEvent.Source = getXWeak();
3538 aEvent.Value = pScrollBar->GetThumbPos();
3540 // set adjustment type
3541 ScrollType aType = pScrollBar->GetType();
3542 if ( aType == ScrollType::LineUp || aType == ScrollType::LineDown )
3544 aEvent.Type = css::awt::AdjustmentType_ADJUST_LINE;
3546 else if ( aType == ScrollType::PageUp || aType == ScrollType::PageDown )
3548 aEvent.Type = css::awt::AdjustmentType_ADJUST_PAGE;
3550 else if ( aType == ScrollType::Drag )
3552 aEvent.Type = css::awt::AdjustmentType_ADJUST_ABS;
3555 maAdjustmentListeners.adjustmentValueChanged( aEvent );
3559 break;
3561 default:
3562 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
3563 break;
3567 css::awt::Size VCLXScrollBar::implGetMinimumSize( vcl::Window const * p )
3569 tools::Long n = p->GetSettings().GetStyleSettings().GetScrollBarSize();
3570 return css::awt::Size( n, n );
3573 css::awt::Size SAL_CALL VCLXScrollBar::getMinimumSize()
3575 SolarMutexGuard aGuard;
3576 return implGetMinimumSize( GetWindow() );
3582 void VCLXEdit::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
3584 PushPropertyIds( rIds,
3585 BASEPROPERTY_ALIGN,
3586 BASEPROPERTY_BACKGROUNDCOLOR,
3587 BASEPROPERTY_BORDER,
3588 BASEPROPERTY_BORDERCOLOR,
3589 BASEPROPERTY_DEFAULTCONTROL,
3590 BASEPROPERTY_ECHOCHAR,
3591 BASEPROPERTY_ENABLED,
3592 BASEPROPERTY_ENABLEVISIBLE,
3593 BASEPROPERTY_FONTDESCRIPTOR,
3594 BASEPROPERTY_HARDLINEBREAKS,
3595 BASEPROPERTY_HELPTEXT,
3596 BASEPROPERTY_HELPURL,
3597 BASEPROPERTY_HSCROLL,
3598 BASEPROPERTY_LINE_END_FORMAT,
3599 BASEPROPERTY_MAXTEXTLEN,
3600 BASEPROPERTY_MULTILINE,
3601 BASEPROPERTY_PRINTABLE,
3602 BASEPROPERTY_READONLY,
3603 BASEPROPERTY_TABSTOP,
3604 BASEPROPERTY_TEXT,
3605 BASEPROPERTY_VSCROLL,
3606 BASEPROPERTY_HIDEINACTIVESELECTION,
3607 BASEPROPERTY_PAINTTRANSPARENT,
3608 BASEPROPERTY_AUTOHSCROLL,
3609 BASEPROPERTY_AUTOVSCROLL,
3610 BASEPROPERTY_VERTICALALIGN,
3611 BASEPROPERTY_WRITING_MODE,
3612 BASEPROPERTY_CONTEXT_WRITING_MODE,
3613 BASEPROPERTY_HIGHLIGHT_COLOR,
3614 BASEPROPERTY_HIGHLIGHT_TEXT_COLOR,
3616 VCLXWindow::ImplGetPropertyIds( rIds );
3619 VCLXEdit::VCLXEdit() : maTextListeners( *this )
3623 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXEdit::CreateAccessibleContext()
3625 return getAccessibleFactory().createAccessibleContext( this );
3628 void VCLXEdit::dispose()
3630 SolarMutexGuard aGuard;
3632 css::lang::EventObject aObj;
3633 aObj.Source = getXWeak();
3634 maTextListeners.disposeAndClear( aObj );
3635 VCLXWindow::dispose();
3638 void VCLXEdit::addTextListener( const css::uno::Reference< css::awt::XTextListener > & l )
3640 SolarMutexGuard aGuard;
3641 GetTextListeners().addInterface( l );
3644 void VCLXEdit::removeTextListener( const css::uno::Reference< css::awt::XTextListener > & l )
3646 SolarMutexGuard aGuard;
3647 GetTextListeners().removeInterface( l );
3650 void VCLXEdit::setText( const OUString& aText )
3652 SolarMutexGuard aGuard;
3654 VclPtr< Edit > pEdit = GetAs< Edit >();
3655 if ( pEdit )
3657 pEdit->SetText( aText );
3659 // #107218# Call same listeners like VCL would do after user interaction
3660 SetSynthesizingVCLEvent( true );
3661 pEdit->SetModifyFlag();
3662 pEdit->Modify();
3663 SetSynthesizingVCLEvent( false );
3667 void VCLXEdit::insertText( const css::awt::Selection& rSel, const OUString& aText )
3669 SolarMutexGuard aGuard;
3671 VclPtr< Edit > pEdit = GetAs< Edit >();
3672 if ( pEdit )
3674 pEdit->SetSelection( Selection( rSel.Min, rSel.Max ) );
3675 pEdit->ReplaceSelected( aText );
3677 // #107218# Call same listeners like VCL would do after user interaction
3678 SetSynthesizingVCLEvent( true );
3679 pEdit->SetModifyFlag();
3680 pEdit->Modify();
3681 SetSynthesizingVCLEvent( false );
3685 OUString VCLXEdit::getText()
3687 SolarMutexGuard aGuard;
3689 OUString aText;
3690 VclPtr< vcl::Window > pWindow = GetWindow();
3691 if ( pWindow )
3692 aText = pWindow->GetText();
3693 return aText;
3696 OUString VCLXEdit::getSelectedText()
3698 SolarMutexGuard aGuard;
3700 OUString aText;
3701 VclPtr< Edit > pEdit = GetAs< Edit >();
3702 if ( pEdit)
3703 aText = pEdit->GetSelected();
3704 return aText;
3708 void VCLXEdit::setSelection( const css::awt::Selection& aSelection )
3710 SolarMutexGuard aGuard;
3712 VclPtr< Edit > pEdit = GetAs< Edit >();
3713 if ( pEdit )
3714 pEdit->SetSelection( Selection( aSelection.Min, aSelection.Max ) );
3717 css::awt::Selection VCLXEdit::getSelection()
3719 SolarMutexGuard aGuard;
3721 Selection aSel;
3722 VclPtr< Edit > pEdit = GetAs< Edit >();
3723 if ( pEdit )
3724 aSel = pEdit->GetSelection();
3725 return css::awt::Selection( aSel.Min(), aSel.Max() );
3728 sal_Bool VCLXEdit::isEditable()
3730 SolarMutexGuard aGuard;
3732 VclPtr< Edit > pEdit = GetAs< Edit >();
3733 return pEdit && !pEdit->IsReadOnly() && pEdit->IsEnabled();
3736 void VCLXEdit::setEditable( sal_Bool bEditable )
3738 SolarMutexGuard aGuard;
3740 VclPtr< Edit > pEdit = GetAs< Edit >();
3741 if ( pEdit )
3742 pEdit->SetReadOnly( !bEditable );
3746 void VCLXEdit::setMaxTextLen( sal_Int16 nLen )
3748 SolarMutexGuard aGuard;
3750 VclPtr< Edit > pEdit = GetAs< Edit >();
3751 if ( pEdit )
3752 pEdit->SetMaxTextLen( nLen );
3755 sal_Int16 VCLXEdit::getMaxTextLen()
3757 SolarMutexGuard aGuard;
3759 VclPtr< Edit > pEdit = GetAs< Edit >();
3760 return pEdit ? pEdit->GetMaxTextLen() : 0;
3763 void VCLXEdit::setEchoChar( sal_Unicode cEcho )
3765 SolarMutexGuard aGuard;
3767 VclPtr< Edit > pEdit = GetAs< Edit >();
3768 if ( pEdit )
3769 pEdit->SetEchoChar( cEcho );
3772 void VCLXEdit::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
3774 SolarMutexGuard aGuard;
3776 VclPtr< Edit > pEdit = GetAs< Edit >();
3777 if ( !pEdit )
3778 return;
3780 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3781 switch ( nPropType )
3783 case BASEPROPERTY_HIDEINACTIVESELECTION:
3784 ::toolkit::adjustBooleanWindowStyle( Value, pEdit, WB_NOHIDESELECTION, true );
3785 if ( pEdit->GetSubEdit() )
3786 ::toolkit::adjustBooleanWindowStyle( Value, pEdit->GetSubEdit(), WB_NOHIDESELECTION, true );
3787 break;
3789 case BASEPROPERTY_READONLY:
3791 bool b = bool();
3792 if ( Value >>= b )
3793 pEdit->SetReadOnly( b );
3795 break;
3796 case BASEPROPERTY_ECHOCHAR:
3798 sal_Int16 n = sal_Int16();
3799 if ( Value >>= n )
3800 pEdit->SetEchoChar( n );
3802 break;
3803 case BASEPROPERTY_MAXTEXTLEN:
3805 sal_Int16 n = sal_Int16();
3806 if ( Value >>= n )
3807 pEdit->SetMaxTextLen( n );
3809 break;
3810 default:
3812 VCLXWindow::setProperty( PropertyName, Value );
3817 css::uno::Any VCLXEdit::getProperty( const OUString& PropertyName )
3819 SolarMutexGuard aGuard;
3821 css::uno::Any aProp;
3822 VclPtr< Edit > pEdit = GetAs< Edit >();
3823 if ( pEdit )
3825 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3826 switch ( nPropType )
3828 case BASEPROPERTY_HIDEINACTIVESELECTION:
3829 aProp <<= ( ( pEdit->GetStyle() & WB_NOHIDESELECTION ) == 0 );
3830 break;
3831 case BASEPROPERTY_READONLY:
3832 aProp <<= pEdit->IsReadOnly();
3833 break;
3834 case BASEPROPERTY_ECHOCHAR:
3835 aProp <<= static_cast<sal_Int16>(pEdit->GetEchoChar());
3836 break;
3837 case BASEPROPERTY_MAXTEXTLEN:
3838 aProp <<= static_cast<sal_Int16>(pEdit->GetMaxTextLen());
3839 break;
3840 default:
3842 aProp = VCLXWindow::getProperty( PropertyName );
3846 return aProp;
3849 css::awt::Size VCLXEdit::getMinimumSize( )
3851 SolarMutexGuard aGuard;
3853 Size aSz;
3854 VclPtr< Edit > pEdit = GetAs< Edit >();
3855 if ( pEdit )
3856 aSz = pEdit->CalcMinimumSize();
3857 return AWTSize(aSz);
3860 css::awt::Size VCLXEdit::getPreferredSize( )
3862 SolarMutexGuard aGuard;
3864 Size aSz;
3865 VclPtr< Edit > pEdit = GetAs< Edit >();
3866 if ( pEdit )
3868 aSz = pEdit->CalcMinimumSize();
3869 aSz.AdjustHeight(4 );
3871 return AWTSize(aSz);
3874 css::awt::Size VCLXEdit::calcAdjustedSize( const css::awt::Size& rNewSize )
3876 SolarMutexGuard aGuard;
3878 css::awt::Size aSz = rNewSize;
3879 css::awt::Size aMinSz = getMinimumSize();
3880 if ( aSz.Height != aMinSz.Height )
3881 aSz.Height = aMinSz.Height;
3883 return aSz;
3886 css::awt::Size VCLXEdit::getMinimumSize( sal_Int16 nCols, sal_Int16 )
3888 SolarMutexGuard aGuard;
3890 Size aSz;
3891 VclPtr< Edit > pEdit = GetAs< Edit >();
3892 if ( pEdit )
3894 if ( nCols )
3895 aSz = pEdit->CalcSize( nCols );
3896 else
3897 aSz = pEdit->CalcMinimumSize();
3899 return AWTSize(aSz);
3902 void VCLXEdit::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines )
3904 SolarMutexGuard aGuard;
3906 nLines = 1;
3907 nCols = 0;
3908 VclPtr< Edit > pEdit = GetAs< Edit >();
3909 if ( pEdit )
3910 nCols = pEdit->GetMaxVisChars();
3913 void VCLXEdit::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
3915 switch ( rVclWindowEvent.GetId() )
3917 case VclEventId::EditModify:
3919 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
3920 // since we call listeners below, there is a potential that we will be destroyed
3921 // during the listener call. To prevent the resulting crashes, we keep us
3922 // alive as long as we're here
3924 if ( GetTextListeners().getLength() )
3926 css::awt::TextEvent aEvent;
3927 aEvent.Source = getXWeak();
3928 GetTextListeners().textChanged( aEvent );
3931 break;
3933 default:
3934 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
3935 break;
3942 void VCLXComboBox::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
3944 PushPropertyIds( rIds,
3945 BASEPROPERTY_AUTOCOMPLETE,
3946 BASEPROPERTY_BACKGROUNDCOLOR,
3947 BASEPROPERTY_BORDER,
3948 BASEPROPERTY_BORDERCOLOR,
3949 BASEPROPERTY_DEFAULTCONTROL,
3950 BASEPROPERTY_DROPDOWN,
3951 BASEPROPERTY_ENABLED,
3952 BASEPROPERTY_ENABLEVISIBLE,
3953 BASEPROPERTY_FONTDESCRIPTOR,
3954 BASEPROPERTY_HELPTEXT,
3955 BASEPROPERTY_HELPURL,
3956 BASEPROPERTY_LINECOUNT,
3957 BASEPROPERTY_MAXTEXTLEN,
3958 BASEPROPERTY_PRINTABLE,
3959 BASEPROPERTY_READONLY,
3960 BASEPROPERTY_STRINGITEMLIST,
3961 BASEPROPERTY_TYPEDITEMLIST,
3962 BASEPROPERTY_TABSTOP,
3963 BASEPROPERTY_TEXT,
3964 BASEPROPERTY_HIDEINACTIVESELECTION,
3965 BASEPROPERTY_ALIGN,
3966 BASEPROPERTY_WRITING_MODE,
3967 BASEPROPERTY_CONTEXT_WRITING_MODE,
3968 BASEPROPERTY_REFERENCE_DEVICE,
3969 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
3970 BASEPROPERTY_HIGHLIGHT_COLOR,
3971 BASEPROPERTY_HIGHLIGHT_TEXT_COLOR,
3973 // no, don't call VCLXEdit here - it has properties which we do *not* want to have at combo box
3974 // #i92690# / 2008-08-12 / frank.schoenheit@sun.com
3975 // VCLXEdit::ImplGetPropertyIds( rIds );
3976 VCLXWindow::ImplGetPropertyIds( rIds );
3979 VCLXComboBox::VCLXComboBox()
3980 : maActionListeners( *this ), maItemListeners( *this )
3984 VCLXComboBox::~VCLXComboBox()
3986 SAL_INFO("toolkit", __FUNCTION__);
3989 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXComboBox::CreateAccessibleContext()
3991 SolarMutexGuard aGuard;
3993 return getAccessibleFactory().createAccessibleContext( this );
3996 void VCLXComboBox::dispose()
3998 SolarMutexGuard aGuard;
4000 css::lang::EventObject aObj;
4001 aObj.Source = getXWeak();
4002 maItemListeners.disposeAndClear( aObj );
4003 maActionListeners.disposeAndClear( aObj );
4004 VCLXEdit::dispose();
4008 void VCLXComboBox::addItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
4010 SolarMutexGuard aGuard;
4011 maItemListeners.addInterface( l );
4014 void VCLXComboBox::removeItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
4016 SolarMutexGuard aGuard;
4017 maItemListeners.removeInterface( l );
4020 void VCLXComboBox::addActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
4022 SolarMutexGuard aGuard;
4023 maActionListeners.addInterface( l );
4026 void VCLXComboBox::removeActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
4028 SolarMutexGuard aGuard;
4029 maActionListeners.removeInterface( l );
4032 void VCLXComboBox::addItem( const OUString& aItem, sal_Int16 nPos )
4034 SolarMutexGuard aGuard;
4036 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4037 if ( pBox )
4038 pBox->InsertEntry( aItem, nPos );
4041 void VCLXComboBox::addItems( const css::uno::Sequence< OUString>& aItems, sal_Int16 nPos )
4043 SolarMutexGuard aGuard;
4045 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4046 if ( !pBox )
4047 return;
4049 sal_uInt16 nP = nPos;
4050 for ( const auto& rItem : aItems )
4052 pBox->InsertEntry( rItem, nP );
4053 if ( nP == 0xFFFF )
4055 OSL_FAIL( "VCLXComboBox::addItems: too many entries!" );
4056 // skip remaining entries, list cannot hold them, anyway
4057 break;
4062 void VCLXComboBox::removeItems( sal_Int16 nPos, sal_Int16 nCount )
4064 SolarMutexGuard aGuard;
4066 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4067 if ( pBox )
4069 for ( sal_uInt16 n = nCount; n; )
4070 pBox->RemoveEntryAt( nPos + (--n) );
4074 sal_Int16 VCLXComboBox::getItemCount()
4076 SolarMutexGuard aGuard;
4078 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4079 return pBox ? pBox->GetEntryCount() : 0;
4082 OUString VCLXComboBox::getItem( sal_Int16 nPos )
4084 SolarMutexGuard aGuard;
4086 OUString aItem;
4087 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4088 if ( pBox )
4089 aItem = pBox->GetEntry( nPos );
4090 return aItem;
4093 css::uno::Sequence< OUString> VCLXComboBox::getItems()
4095 SolarMutexGuard aGuard;
4097 css::uno::Sequence< OUString> aSeq;
4098 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4099 if ( pBox )
4101 auto n = pBox->GetEntryCount();
4102 aSeq = css::uno::Sequence< OUString>( n );
4103 while ( n )
4105 --n;
4106 aSeq.getArray()[n] = pBox->GetEntry( n );
4109 return aSeq;
4112 void VCLXComboBox::setDropDownLineCount( sal_Int16 nLines )
4114 SolarMutexGuard aGuard;
4116 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4117 if ( pBox )
4118 pBox->SetDropDownLineCount( nLines );
4121 sal_Int16 VCLXComboBox::getDropDownLineCount()
4123 SolarMutexGuard aGuard;
4125 sal_Int16 nLines = 0;
4126 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4127 if ( pBox )
4128 nLines = pBox->GetDropDownLineCount();
4129 return nLines;
4132 void VCLXComboBox::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
4134 SolarMutexGuard aGuard;
4136 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4137 if ( !pComboBox )
4138 return;
4140 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
4141 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4142 switch ( nPropType )
4144 case BASEPROPERTY_LINECOUNT:
4146 sal_Int16 n = sal_Int16();
4147 if ( Value >>= n )
4148 pComboBox->SetDropDownLineCount( n );
4150 break;
4151 case BASEPROPERTY_AUTOCOMPLETE:
4153 sal_Int16 n = sal_Int16();
4154 if ( Value >>= n )
4155 pComboBox->EnableAutocomplete( n != 0 );
4156 else
4158 bool b = bool();
4159 if ( Value >>= b )
4160 pComboBox->EnableAutocomplete( b );
4163 break;
4164 case BASEPROPERTY_STRINGITEMLIST:
4166 css::uno::Sequence< OUString> aItems;
4167 if ( Value >>= aItems )
4169 pComboBox->Clear();
4170 addItems( aItems, 0 );
4173 break;
4174 case BASEPROPERTY_HIGHLIGHT_COLOR:
4176 Color nColor = 0;
4177 if (bVoid)
4179 nColor = Application::GetSettings().GetStyleSettings().GetHighlightColor();
4181 else
4183 if (!(Value >>= nColor))
4184 break;
4186 pComboBox->SetHighlightColor(nColor);
4188 break;
4189 case BASEPROPERTY_HIGHLIGHT_TEXT_COLOR:
4191 Color nColor = 0;
4192 if (bVoid)
4194 nColor = Application::GetSettings().GetStyleSettings().GetHighlightTextColor();
4196 else
4198 if (!(Value >>= nColor))
4199 break;
4201 pComboBox->SetHighlightTextColor(nColor);
4203 break;
4204 default:
4206 VCLXEdit::setProperty( PropertyName, Value );
4208 // #109385# SetBorderStyle is not virtual
4209 if ( nPropType == BASEPROPERTY_BORDER )
4211 sal_uInt16 nBorder = sal_uInt16();
4212 if ( (Value >>= nBorder) && nBorder != 0 )
4213 pComboBox->SetBorderStyle( static_cast<WindowBorderStyle>(nBorder) );
4219 css::uno::Any VCLXComboBox::getProperty( const OUString& PropertyName )
4221 SolarMutexGuard aGuard;
4223 css::uno::Any aProp;
4224 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4225 if ( pComboBox )
4227 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4228 switch ( nPropType )
4230 case BASEPROPERTY_LINECOUNT:
4232 aProp <<= static_cast<sal_Int16>(pComboBox->GetDropDownLineCount());
4234 break;
4235 case BASEPROPERTY_AUTOCOMPLETE:
4237 aProp <<= pComboBox->IsAutocompleteEnabled();
4239 break;
4240 case BASEPROPERTY_STRINGITEMLIST:
4242 const sal_Int32 nItems = pComboBox->GetEntryCount();
4243 css::uno::Sequence< OUString> aSeq( nItems );
4244 OUString* pStrings = aSeq.getArray();
4245 for ( sal_Int32 n = 0; n < nItems; ++n )
4246 pStrings[n] = pComboBox->GetEntry( n );
4247 aProp <<= aSeq;
4250 break;
4251 default:
4253 aProp = VCLXEdit::getProperty( PropertyName );
4257 return aProp;
4260 void VCLXComboBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
4262 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
4263 // since we call listeners below, there is a potential that we will be destroyed
4264 // during the listener call. To prevent the resulting crashes, we keep us
4265 // alive as long as we're here
4267 switch ( rVclWindowEvent.GetId() )
4269 case VclEventId::ComboboxSelect:
4270 if ( maItemListeners.getLength() )
4272 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4273 if( pComboBox )
4275 if ( !pComboBox->IsTravelSelect() )
4277 css::awt::ItemEvent aEvent;
4278 aEvent.Source = getXWeak();
4279 aEvent.Highlighted = 0;
4281 // Set to 0xFFFF on multiple selection, selected entry ID otherwise
4282 aEvent.Selected = pComboBox->GetEntryPos( pComboBox->GetText() );
4284 maItemListeners.itemStateChanged( aEvent );
4288 break;
4290 case VclEventId::ComboboxDoubleClick:
4291 if ( maActionListeners.getLength() )
4293 css::awt::ActionEvent aEvent;
4294 aEvent.Source = getXWeak();
4295 // aEvent.ActionCommand = ...;
4296 maActionListeners.actionPerformed( aEvent );
4298 break;
4300 default:
4301 VCLXEdit::ProcessWindowEvent( rVclWindowEvent );
4302 break;
4306 css::awt::Size VCLXComboBox::getMinimumSize( )
4308 SolarMutexGuard aGuard;
4310 Size aSz;
4311 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4312 if ( pComboBox )
4313 aSz = pComboBox->CalcMinimumSize();
4314 return AWTSize(aSz);
4317 css::awt::Size VCLXComboBox::getPreferredSize( )
4319 SolarMutexGuard aGuard;
4321 Size aSz;
4322 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4323 if ( pComboBox )
4325 aSz = pComboBox->CalcMinimumSize();
4326 if ( pComboBox->GetStyle() & WB_DROPDOWN )
4327 aSz.AdjustHeight(4 );
4329 return AWTSize(aSz);
4332 css::awt::Size VCLXComboBox::calcAdjustedSize( const css::awt::Size& rNewSize )
4334 SolarMutexGuard aGuard;
4336 Size aSz = VCLSize(rNewSize);
4337 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4338 if ( pComboBox )
4339 aSz = pComboBox->CalcAdjustedSize( aSz );
4340 return AWTSize(aSz);
4343 css::awt::Size VCLXComboBox::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines )
4345 SolarMutexGuard aGuard;
4347 Size aSz;
4348 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4349 if ( pComboBox )
4350 aSz = pComboBox->CalcBlockSize( nCols, nLines );
4351 return AWTSize(aSz);
4354 void VCLXComboBox::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines )
4356 SolarMutexGuard aGuard;
4358 nCols = nLines = 0;
4359 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4360 if ( pComboBox )
4362 sal_uInt16 nC, nL;
4363 pComboBox->GetMaxVisColumnsAndLines( nC, nL );
4364 nCols = nC;
4365 nLines = nL;
4368 void SAL_CALL VCLXComboBox::listItemInserted( const ItemListEvent& i_rEvent )
4370 SolarMutexGuard aGuard;
4372 VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >();
4374 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemInserted: no ComboBox?!" );
4375 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition <= pComboBox->GetEntryCount() ),
4376 "VCLXComboBox::listItemInserted: illegal (inconsistent) item position!" );
4377 pComboBox->InsertEntryWithImage(
4378 i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : OUString(),
4379 i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : Image(),
4380 i_rEvent.ItemPosition );
4383 void SAL_CALL VCLXComboBox::listItemRemoved( const ItemListEvent& i_rEvent )
4385 SolarMutexGuard aGuard;
4387 VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >();
4389 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemRemoved: no ComboBox?!" );
4390 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < pComboBox->GetEntryCount() ),
4391 "VCLXComboBox::listItemRemoved: illegal (inconsistent) item position!" );
4393 pComboBox->RemoveEntryAt( i_rEvent.ItemPosition );
4396 void SAL_CALL VCLXComboBox::listItemModified( const ItemListEvent& i_rEvent )
4398 SolarMutexGuard aGuard;
4400 VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >();
4402 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" );
4403 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < pComboBox->GetEntryCount() ),
4404 "VCLXComboBox::listItemModified: illegal (inconsistent) item position!" );
4406 // VCL's ComboBox does not support changing an entry's text or image, so remove and re-insert
4408 const OUString sNewText = i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : pComboBox->GetEntry( i_rEvent.ItemPosition );
4409 const Image aNewImage( i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : pComboBox->GetEntryImage( i_rEvent.ItemPosition ) );
4411 pComboBox->RemoveEntryAt( i_rEvent.ItemPosition );
4412 pComboBox->InsertEntryWithImage(sNewText, aNewImage, i_rEvent.ItemPosition);
4415 void SAL_CALL VCLXComboBox::allItemsRemoved( const EventObject& )
4417 SolarMutexGuard aGuard;
4419 VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >();
4420 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" );
4422 pComboBox->Clear();
4425 void SAL_CALL VCLXComboBox::itemListChanged( const EventObject& i_rEvent )
4427 SolarMutexGuard aGuard;
4429 VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >();
4430 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" );
4432 pComboBox->Clear();
4434 uno::Reference< beans::XPropertySet > xPropSet( i_rEvent.Source, uno::UNO_QUERY_THROW );
4435 uno::Reference< beans::XPropertySetInfo > xPSI( xPropSet->getPropertySetInfo(), uno::UNO_SET_THROW );
4436 // bool localize = xPSI->hasPropertyByName("ResourceResolver");
4437 uno::Reference< resource::XStringResourceResolver > xStringResourceResolver;
4438 if ( xPSI->hasPropertyByName("ResourceResolver") )
4440 xStringResourceResolver.set(
4441 xPropSet->getPropertyValue("ResourceResolver"),
4442 uno::UNO_QUERY
4447 Reference< XItemList > xItemList( i_rEvent.Source, uno::UNO_QUERY_THROW );
4448 const uno::Sequence< beans::Pair< OUString, OUString > > aItems = xItemList->getAllItems();
4449 for ( const auto& rItem : aItems )
4451 OUString aLocalizationKey( rItem.First );
4452 if ( xStringResourceResolver.is() && !aLocalizationKey.isEmpty() && aLocalizationKey[0] == '&' )
4454 aLocalizationKey = xStringResourceResolver->resolveString(aLocalizationKey.copy( 1 ));
4456 pComboBox->InsertEntryWithImage(aLocalizationKey,
4457 lcl_getImageFromURL(rItem.Second));
4460 void SAL_CALL VCLXComboBox::disposing( const EventObject& i_rEvent )
4462 // just disambiguate
4463 VCLXEdit::disposing( i_rEvent );
4468 void VCLXFormattedSpinField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
4470 // Interestingly in the UnoControl API this is
4471 // - not derived from XEdit ultimately, (correct ?) - so cut this here ...
4472 // VCLXSpinField::ImplGetPropertyIds( rIds );
4473 VCLXWindow::ImplGetPropertyIds( rIds );
4476 VCLXFormattedSpinField::VCLXFormattedSpinField()
4477 : mpFormatter(nullptr)
4481 VCLXFormattedSpinField::~VCLXFormattedSpinField()
4485 void VCLXFormattedSpinField::setStrictFormat( bool bStrict )
4487 SolarMutexGuard aGuard;
4489 FormatterBase* pFormatter = GetFormatter();
4490 if ( pFormatter )
4491 pFormatter->SetStrictFormat( bStrict );
4494 bool VCLXFormattedSpinField::isStrictFormat() const
4496 FormatterBase* pFormatter = GetFormatter();
4497 return pFormatter && pFormatter->IsStrictFormat();
4501 void VCLXFormattedSpinField::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
4503 SolarMutexGuard aGuard;
4505 FormatterBase* pFormatter = GetFormatter();
4506 if ( !pFormatter )
4507 return;
4509 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4510 switch ( nPropType )
4512 case BASEPROPERTY_SPIN:
4514 bool b = bool();
4515 if ( Value >>= b )
4517 WinBits nStyle = GetWindow()->GetStyle() | WB_SPIN;
4518 if ( !b )
4519 nStyle &= ~WB_SPIN;
4520 GetWindow()->SetStyle( nStyle );
4523 break;
4524 case BASEPROPERTY_STRICTFORMAT:
4526 bool b = bool();
4527 if ( Value >>= b )
4529 pFormatter->SetStrictFormat( b );
4532 break;
4533 default:
4535 VCLXSpinField::setProperty( PropertyName, Value );
4540 css::uno::Any VCLXFormattedSpinField::getProperty( const OUString& PropertyName )
4542 SolarMutexGuard aGuard;
4544 css::uno::Any aProp;
4545 FormatterBase* pFormatter = GetFormatter();
4546 if ( pFormatter )
4548 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4549 switch ( nPropType )
4551 case BASEPROPERTY_TABSTOP:
4553 aProp <<= ( GetWindow()->GetStyle() & WB_SPIN ) != 0;
4555 break;
4556 case BASEPROPERTY_STRICTFORMAT:
4558 aProp <<= pFormatter->IsStrictFormat();
4560 break;
4561 default:
4563 aProp = VCLXSpinField::getProperty( PropertyName );
4567 return aProp;
4573 void VCLXDateField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
4575 PushPropertyIds( rIds,
4576 BASEPROPERTY_ALIGN,
4577 BASEPROPERTY_BACKGROUNDCOLOR,
4578 BASEPROPERTY_BORDER,
4579 BASEPROPERTY_BORDERCOLOR,
4580 BASEPROPERTY_DATE,
4581 BASEPROPERTY_DATEMAX,
4582 BASEPROPERTY_DATEMIN,
4583 BASEPROPERTY_DATESHOWCENTURY,
4584 BASEPROPERTY_DEFAULTCONTROL,
4585 BASEPROPERTY_DROPDOWN,
4586 BASEPROPERTY_ENABLED,
4587 BASEPROPERTY_ENABLEVISIBLE,
4588 BASEPROPERTY_EXTDATEFORMAT,
4589 BASEPROPERTY_FONTDESCRIPTOR,
4590 BASEPROPERTY_HELPTEXT,
4591 BASEPROPERTY_HELPURL,
4592 BASEPROPERTY_PRINTABLE,
4593 BASEPROPERTY_READONLY,
4594 BASEPROPERTY_REPEAT,
4595 BASEPROPERTY_REPEAT_DELAY,
4596 BASEPROPERTY_SPIN,
4597 BASEPROPERTY_STRICTFORMAT,
4598 BASEPROPERTY_TABSTOP,
4599 BASEPROPERTY_ENFORCE_FORMAT,
4600 BASEPROPERTY_TEXT,
4601 BASEPROPERTY_HIDEINACTIVESELECTION,
4602 BASEPROPERTY_VERTICALALIGN,
4603 BASEPROPERTY_WRITING_MODE,
4604 BASEPROPERTY_CONTEXT_WRITING_MODE,
4605 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
4606 BASEPROPERTY_HIGHLIGHT_COLOR,
4607 BASEPROPERTY_HIGHLIGHT_TEXT_COLOR,
4609 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
4612 VCLXDateField::VCLXDateField()
4616 VCLXDateField::~VCLXDateField()
4620 //change the window type here to match the role
4621 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXDateField::CreateAccessibleContext()
4623 VclPtr< vcl::Window > pWindow = GetWindow();
4624 if ( pWindow )
4626 pWindow->SetType( WindowType::DATEFIELD );
4628 return getAccessibleFactory().createAccessibleContext( this );
4631 void VCLXDateField::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
4633 SolarMutexGuard aGuard;
4635 if ( !(GetWindow()) )
4636 return;
4638 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
4640 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4641 switch ( nPropType )
4643 case BASEPROPERTY_DATE:
4645 if ( bVoid )
4647 GetAs< DateField >()->EnableEmptyFieldValue( true );
4648 GetAs< DateField >()->SetEmptyFieldValue();
4650 else
4652 util::Date d;
4653 if ((Value >>= d) && d.Year != 0)
4654 setDate( d );
4657 break;
4658 case BASEPROPERTY_DATEMIN:
4660 util::Date d;
4661 if ((Value >>= d) && d.Year != 0)
4662 setMin( d );
4664 break;
4665 case BASEPROPERTY_DATEMAX:
4667 util::Date d;
4668 if ((Value >>= d) && d.Year != 0)
4669 setMax( d );
4671 break;
4672 case BASEPROPERTY_EXTDATEFORMAT:
4674 sal_Int16 n = sal_Int16();
4675 if ( Value >>= n )
4676 GetAs< DateField >()->SetExtDateFormat( static_cast<ExtDateFieldFormat>(n) );
4678 break;
4679 case BASEPROPERTY_DATESHOWCENTURY:
4681 bool b = bool();
4682 if ( Value >>= b )
4683 GetAs< DateField >()->SetShowDateCentury( b );
4685 break;
4686 case BASEPROPERTY_ENFORCE_FORMAT:
4688 bool bEnforce( true );
4689 OSL_VERIFY( Value >>= bEnforce );
4690 GetAs< DateField >()->EnforceValidValue( bEnforce );
4692 break;
4693 default:
4695 VCLXFormattedSpinField::setProperty( PropertyName, Value );
4700 css::uno::Any VCLXDateField::getProperty( const OUString& PropertyName )
4702 SolarMutexGuard aGuard;
4704 css::uno::Any aProp;
4705 FormatterBase* pFormatter = GetFormatter();
4706 if ( pFormatter )
4708 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4709 switch ( nPropType )
4711 case BASEPROPERTY_DATE:
4713 aProp <<= getDate();
4715 break;
4716 case BASEPROPERTY_DATEMIN:
4718 aProp <<= getMin();
4720 break;
4721 case BASEPROPERTY_DATEMAX:
4723 aProp <<= getMax();
4725 break;
4726 case BASEPROPERTY_DATESHOWCENTURY:
4728 aProp <<= GetAs< DateField >()->IsShowDateCentury();
4730 break;
4731 case BASEPROPERTY_ENFORCE_FORMAT:
4733 aProp <<= GetAs< DateField >()->IsEnforceValidValue( );
4735 break;
4736 default:
4738 aProp = VCLXFormattedSpinField::getProperty( PropertyName );
4742 return aProp;
4746 void VCLXDateField::setDate( const util::Date& aDate )
4748 SolarMutexGuard aGuard;
4750 VclPtr< DateField > pDateField = GetAs< DateField >();
4751 if ( pDateField )
4753 pDateField->SetDate( aDate );
4755 // #107218# Call same listeners like VCL would do after user interaction
4756 SetSynthesizingVCLEvent( true );
4757 pDateField->SetModifyFlag();
4758 pDateField->Modify();
4759 SetSynthesizingVCLEvent( false );
4763 util::Date VCLXDateField::getDate()
4765 SolarMutexGuard aGuard;
4767 VclPtr< DateField > pDateField = GetAs< DateField >();
4768 if ( pDateField )
4769 return pDateField->GetDate().GetUNODate();
4770 else
4771 return util::Date();
4774 void VCLXDateField::setMin( const util::Date& aDate )
4776 SolarMutexGuard aGuard;
4778 VclPtr< DateField > pDateField = GetAs< DateField >();
4779 if ( pDateField )
4780 pDateField->SetMin( aDate );
4783 util::Date VCLXDateField::getMin()
4785 SolarMutexGuard aGuard;
4787 VclPtr< DateField > pDateField = GetAs< DateField >();
4788 if ( pDateField )
4789 return pDateField->GetMin().GetUNODate();
4790 else
4791 return util::Date();
4794 void VCLXDateField::setMax( const util::Date& aDate )
4796 SolarMutexGuard aGuard;
4798 VclPtr< DateField > pDateField = GetAs< DateField >();
4799 if ( pDateField )
4800 pDateField->SetMax( aDate );
4803 util::Date VCLXDateField::getMax()
4805 SolarMutexGuard aGuard;
4807 VclPtr< DateField > pDateField = GetAs< DateField >();
4808 if ( pDateField )
4809 return pDateField->GetMax().GetUNODate();
4810 else
4811 return util::Date();
4814 void VCLXDateField::setFirst( const util::Date& aDate )
4816 SolarMutexGuard aGuard;
4818 VclPtr< DateField > pDateField = GetAs< DateField >();
4819 if ( pDateField )
4820 pDateField->SetFirst( aDate );
4823 util::Date VCLXDateField::getFirst()
4825 SolarMutexGuard aGuard;
4827 VclPtr< DateField > pDateField = GetAs< DateField >();
4828 if ( pDateField )
4829 return pDateField->GetFirst().GetUNODate();
4830 else
4831 return util::Date();
4834 void VCLXDateField::setLast( const util::Date& aDate )
4836 SolarMutexGuard aGuard;
4838 VclPtr< DateField > pDateField = GetAs< DateField >();
4839 if ( pDateField )
4840 pDateField->SetLast( aDate );
4843 util::Date VCLXDateField::getLast()
4845 SolarMutexGuard aGuard;
4847 VclPtr< DateField > pDateField = GetAs< DateField >();
4848 if ( pDateField )
4849 return pDateField->GetLast().GetUNODate();
4850 else
4851 return util::Date();
4854 void VCLXDateField::setLongFormat( sal_Bool bLong )
4856 SolarMutexGuard aGuard;
4858 VclPtr< DateField > pDateField = GetAs< DateField >();
4859 if ( pDateField )
4860 pDateField->SetLongFormat( bLong );
4863 sal_Bool VCLXDateField::isLongFormat()
4865 SolarMutexGuard aGuard;
4867 VclPtr< DateField > pDateField = GetAs< DateField >();
4868 return pDateField && pDateField->IsLongFormat();
4871 void VCLXDateField::setEmpty()
4873 SolarMutexGuard aGuard;
4875 VclPtr< DateField > pDateField = GetAs< DateField >();
4876 if ( pDateField )
4878 pDateField->SetEmptyDate();
4880 // #107218# Call same listeners like VCL would do after user interaction
4881 SetSynthesizingVCLEvent( true );
4882 pDateField->SetModifyFlag();
4883 pDateField->Modify();
4884 SetSynthesizingVCLEvent( false );
4888 sal_Bool VCLXDateField::isEmpty()
4890 SolarMutexGuard aGuard;
4892 VclPtr< DateField > pDateField = GetAs< DateField >();
4893 return pDateField && pDateField->IsEmptyDate();
4896 void VCLXDateField::setStrictFormat( sal_Bool bStrict )
4898 VCLXFormattedSpinField::setStrictFormat( bStrict );
4901 sal_Bool VCLXDateField::isStrictFormat()
4903 return VCLXFormattedSpinField::isStrictFormat();
4909 void VCLXTimeField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
4911 PushPropertyIds( rIds,
4912 BASEPROPERTY_ALIGN,
4913 BASEPROPERTY_BACKGROUNDCOLOR,
4914 BASEPROPERTY_BORDER,
4915 BASEPROPERTY_BORDERCOLOR,
4916 BASEPROPERTY_DEFAULTCONTROL,
4917 BASEPROPERTY_ENABLED,
4918 BASEPROPERTY_ENABLEVISIBLE,
4919 BASEPROPERTY_EXTTIMEFORMAT,
4920 BASEPROPERTY_FONTDESCRIPTOR,
4921 BASEPROPERTY_HELPTEXT,
4922 BASEPROPERTY_HELPURL,
4923 BASEPROPERTY_PRINTABLE,
4924 BASEPROPERTY_READONLY,
4925 BASEPROPERTY_REPEAT,
4926 BASEPROPERTY_REPEAT_DELAY,
4927 BASEPROPERTY_SPIN,
4928 BASEPROPERTY_STRICTFORMAT,
4929 BASEPROPERTY_TABSTOP,
4930 BASEPROPERTY_TIME,
4931 BASEPROPERTY_TIMEMAX,
4932 BASEPROPERTY_TIMEMIN,
4933 BASEPROPERTY_ENFORCE_FORMAT,
4934 BASEPROPERTY_TEXT,
4935 BASEPROPERTY_HIDEINACTIVESELECTION,
4936 BASEPROPERTY_VERTICALALIGN,
4937 BASEPROPERTY_WRITING_MODE,
4938 BASEPROPERTY_CONTEXT_WRITING_MODE,
4939 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
4940 BASEPROPERTY_HIGHLIGHT_COLOR,
4941 BASEPROPERTY_HIGHLIGHT_TEXT_COLOR,
4943 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
4946 VCLXTimeField::VCLXTimeField()
4950 VCLXTimeField::~VCLXTimeField()
4954 //change the window type here to match the role
4955 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXTimeField::CreateAccessibleContext()
4957 VclPtr< vcl::Window > pWindow = GetWindow();
4958 if ( pWindow )
4960 pWindow->SetType( WindowType::TIMEFIELD );
4962 return getAccessibleFactory().createAccessibleContext( this );
4965 void VCLXTimeField::setTime( const util::Time& aTime )
4967 SolarMutexGuard aGuard;
4969 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
4970 if ( pTimeField )
4972 pTimeField->SetTime( aTime );
4974 // #107218# Call same listeners like VCL would do after user interaction
4975 SetSynthesizingVCLEvent( true );
4976 pTimeField->SetModifyFlag();
4977 pTimeField->Modify();
4978 SetSynthesizingVCLEvent( false );
4982 util::Time VCLXTimeField::getTime()
4984 SolarMutexGuard aGuard;
4986 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
4987 if ( pTimeField )
4988 return pTimeField->GetTime().GetUNOTime();
4989 else
4990 return util::Time();
4993 void VCLXTimeField::setMin( const util::Time& aTime )
4995 SolarMutexGuard aGuard;
4997 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
4998 if ( pTimeField )
4999 pTimeField->SetMin( aTime );
5002 util::Time VCLXTimeField::getMin()
5004 SolarMutexGuard aGuard;
5006 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5007 if ( pTimeField )
5008 return pTimeField->GetMin().GetUNOTime();
5009 else
5010 return util::Time();
5013 void VCLXTimeField::setMax( const util::Time& aTime )
5015 SolarMutexGuard aGuard;
5017 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5018 if ( pTimeField )
5019 pTimeField->SetMax( aTime );
5022 util::Time VCLXTimeField::getMax()
5024 SolarMutexGuard aGuard;
5026 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5027 if ( pTimeField )
5028 return pTimeField->GetMax().GetUNOTime();
5029 else
5030 return util::Time();
5033 void VCLXTimeField::setFirst( const util::Time& aTime )
5035 SolarMutexGuard aGuard;
5037 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5038 if ( pTimeField )
5039 pTimeField->SetFirst( aTime );
5042 util::Time VCLXTimeField::getFirst()
5044 SolarMutexGuard aGuard;
5046 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5047 if ( pTimeField )
5048 return pTimeField->GetFirst().GetUNOTime();
5049 else
5050 return util::Time();
5053 void VCLXTimeField::setLast( const util::Time& aTime )
5055 SolarMutexGuard aGuard;
5057 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5058 if ( pTimeField )
5059 pTimeField->SetLast( aTime );
5062 util::Time VCLXTimeField::getLast()
5064 SolarMutexGuard aGuard;
5066 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5067 if ( pTimeField )
5068 return pTimeField->GetLast().GetUNOTime();
5069 else
5070 return util::Time();
5073 void VCLXTimeField::setEmpty()
5075 SolarMutexGuard aGuard;
5077 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5078 if ( pTimeField )
5079 pTimeField->SetEmptyTime();
5082 sal_Bool VCLXTimeField::isEmpty()
5084 SolarMutexGuard aGuard;
5086 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5087 return pTimeField && pTimeField->IsEmptyTime();
5090 void VCLXTimeField::setStrictFormat( sal_Bool bStrict )
5092 VCLXFormattedSpinField::setStrictFormat( bStrict );
5095 sal_Bool VCLXTimeField::isStrictFormat()
5097 return VCLXFormattedSpinField::isStrictFormat();
5101 void VCLXTimeField::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
5103 SolarMutexGuard aGuard;
5105 if ( !(GetWindow()) )
5106 return;
5108 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
5110 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5111 switch ( nPropType )
5113 case BASEPROPERTY_TIME:
5115 if ( bVoid )
5117 GetAs< TimeField >()->EnableEmptyFieldValue( true );
5118 GetAs< TimeField >()->SetEmptyFieldValue();
5120 else
5122 util::Time t;
5123 if ( Value >>= t )
5124 setTime( t );
5127 break;
5128 case BASEPROPERTY_TIMEMIN:
5130 util::Time t;
5131 if ( Value >>= t )
5132 setMin( t );
5134 break;
5135 case BASEPROPERTY_TIMEMAX:
5137 util::Time t;
5138 if ( Value >>= t )
5139 setMax( t );
5141 break;
5142 case BASEPROPERTY_EXTTIMEFORMAT:
5144 sal_Int16 n = sal_Int16();
5145 if ( Value >>= n )
5146 GetAs< TimeField >()->SetExtFormat( static_cast<ExtTimeFieldFormat>(n) );
5148 break;
5149 case BASEPROPERTY_ENFORCE_FORMAT:
5151 bool bEnforce( true );
5152 OSL_VERIFY( Value >>= bEnforce );
5153 GetAs< TimeField >()->EnforceValidValue( bEnforce );
5155 break;
5156 default:
5158 VCLXFormattedSpinField::setProperty( PropertyName, Value );
5163 css::uno::Any VCLXTimeField::getProperty( const OUString& PropertyName )
5165 SolarMutexGuard aGuard;
5167 css::uno::Any aProp;
5168 if ( GetWindow() )
5170 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5171 switch ( nPropType )
5173 case BASEPROPERTY_TIME:
5175 aProp <<= getTime();
5177 break;
5178 case BASEPROPERTY_TIMEMIN:
5180 aProp <<= getMin();
5182 break;
5183 case BASEPROPERTY_TIMEMAX:
5185 aProp <<= getMax();
5187 break;
5188 case BASEPROPERTY_ENFORCE_FORMAT:
5190 aProp <<= GetAs< TimeField >()->IsEnforceValidValue( );
5192 break;
5193 default:
5195 aProp = VCLXFormattedSpinField::getProperty( PropertyName );
5199 return aProp;
5205 void VCLXNumericField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
5207 PushPropertyIds( rIds,
5208 BASEPROPERTY_ALIGN,
5209 BASEPROPERTY_BACKGROUNDCOLOR,
5210 BASEPROPERTY_BORDER,
5211 BASEPROPERTY_BORDERCOLOR,
5212 BASEPROPERTY_DECIMALACCURACY,
5213 BASEPROPERTY_DEFAULTCONTROL,
5214 BASEPROPERTY_ENABLED,
5215 BASEPROPERTY_ENABLEVISIBLE,
5216 BASEPROPERTY_FONTDESCRIPTOR,
5217 BASEPROPERTY_HELPTEXT,
5218 BASEPROPERTY_HELPURL,
5219 BASEPROPERTY_NUMSHOWTHOUSANDSEP,
5220 BASEPROPERTY_PRINTABLE,
5221 BASEPROPERTY_READONLY,
5222 BASEPROPERTY_REPEAT,
5223 BASEPROPERTY_REPEAT_DELAY,
5224 BASEPROPERTY_SPIN,
5225 BASEPROPERTY_STRICTFORMAT,
5226 BASEPROPERTY_TABSTOP,
5227 BASEPROPERTY_VALUEMAX_DOUBLE,
5228 BASEPROPERTY_VALUEMIN_DOUBLE,
5229 BASEPROPERTY_VALUESTEP_DOUBLE,
5230 BASEPROPERTY_VALUE_DOUBLE,
5231 BASEPROPERTY_ENFORCE_FORMAT,
5232 BASEPROPERTY_HIDEINACTIVESELECTION,
5233 BASEPROPERTY_VERTICALALIGN,
5234 BASEPROPERTY_WRITING_MODE,
5235 BASEPROPERTY_CONTEXT_WRITING_MODE,
5236 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
5237 BASEPROPERTY_HIGHLIGHT_COLOR,
5238 BASEPROPERTY_HIGHLIGHT_TEXT_COLOR,
5240 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5243 VCLXNumericField::VCLXNumericField()
5247 VCLXNumericField::~VCLXNumericField()
5251 void VCLXNumericField::setValue( double Value )
5253 SolarMutexGuard aGuard;
5255 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5256 if ( !pNumericFormatter )
5257 return;
5259 // shift long value using decimal digits
5260 // (e.g., input 105 using 2 digits returns 1,05)
5261 // Thus, to set a value of 1,05, insert 105 and 2 digits
5262 pNumericFormatter->SetValue(
5263 static_cast<tools::Long>(ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() )) );
5265 // #107218# Call same listeners like VCL would do after user interaction
5266 VclPtr< Edit > pEdit = GetAs< Edit >();
5267 if ( pEdit )
5269 SetSynthesizingVCLEvent( true );
5270 pEdit->SetModifyFlag();
5271 pEdit->Modify();
5272 SetSynthesizingVCLEvent( false );
5276 double VCLXNumericField::getValue()
5278 SolarMutexGuard aGuard;
5280 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5281 return pNumericFormatter
5282 ? ImplCalcDoubleValue( static_cast<double>(pNumericFormatter->GetValue()), pNumericFormatter->GetDecimalDigits() )
5283 : 0;
5286 void VCLXNumericField::setMin( double Value )
5288 SolarMutexGuard aGuard;
5290 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5291 if ( pNumericFormatter )
5292 pNumericFormatter->SetMin(
5293 static_cast<tools::Long>(ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() )) );
5296 double VCLXNumericField::getMin()
5298 SolarMutexGuard aGuard;
5300 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5301 return pNumericFormatter
5302 ? ImplCalcDoubleValue( static_cast<double>(pNumericFormatter->GetMin()), pNumericFormatter->GetDecimalDigits() )
5303 : 0;
5306 void VCLXNumericField::setMax( double Value )
5308 SolarMutexGuard aGuard;
5310 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5311 if ( pNumericFormatter )
5312 pNumericFormatter->SetMax(
5313 static_cast<tools::Long>(ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() )) );
5316 double VCLXNumericField::getMax()
5318 SolarMutexGuard aGuard;
5320 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5321 return pNumericFormatter
5322 ? ImplCalcDoubleValue( static_cast<double>(pNumericFormatter->GetMax()), pNumericFormatter->GetDecimalDigits() )
5323 : 0;
5326 void VCLXNumericField::setFirst( double Value )
5328 SolarMutexGuard aGuard;
5330 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5331 if ( pNumericFormatter )
5332 pNumericFormatter->SetFirst(
5333 static_cast<tools::Long>(ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() )) );
5336 double VCLXNumericField::getFirst()
5338 SolarMutexGuard aGuard;
5340 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5341 return pNumericFormatter
5342 ? ImplCalcDoubleValue( static_cast<double>(pNumericFormatter->GetFirst()), pNumericFormatter->GetDecimalDigits() )
5343 : 0;
5346 void VCLXNumericField::setLast( double Value )
5348 SolarMutexGuard aGuard;
5350 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5351 if ( pNumericFormatter )
5352 pNumericFormatter->SetLast(
5353 static_cast<tools::Long>(ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() )) );
5356 double VCLXNumericField::getLast()
5358 SolarMutexGuard aGuard;
5360 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5361 return pNumericFormatter
5362 ? ImplCalcDoubleValue( static_cast<double>(pNumericFormatter->GetLast()), pNumericFormatter->GetDecimalDigits() )
5363 : 0;
5366 void VCLXNumericField::setStrictFormat( sal_Bool bStrict )
5368 VCLXFormattedSpinField::setStrictFormat( bStrict );
5371 sal_Bool VCLXNumericField::isStrictFormat()
5373 return VCLXFormattedSpinField::isStrictFormat();
5376 void VCLXNumericField::setSpinSize( double Value )
5378 SolarMutexGuard aGuard;
5380 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5381 if ( pNumericFormatter )
5382 pNumericFormatter->SetSpinSize(
5383 static_cast<tools::Long>(ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() )) );
5386 double VCLXNumericField::getSpinSize()
5388 SolarMutexGuard aGuard;
5390 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5391 return pNumericFormatter
5392 ? ImplCalcDoubleValue( static_cast<double>(pNumericFormatter->GetSpinSize()), pNumericFormatter->GetDecimalDigits() )
5393 : 0;
5396 void VCLXNumericField::setDecimalDigits( sal_Int16 Value )
5398 SolarMutexGuard aGuard;
5400 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5401 if ( pNumericFormatter )
5403 double n = getValue();
5404 pNumericFormatter->SetDecimalDigits( Value );
5405 setValue( n );
5409 sal_Int16 VCLXNumericField::getDecimalDigits()
5411 SolarMutexGuard aGuard;
5413 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5414 return pNumericFormatter ? pNumericFormatter->GetDecimalDigits() : 0;
5417 void VCLXNumericField::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
5419 SolarMutexGuard aGuard;
5421 if ( !(GetWindow()) )
5422 return;
5424 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
5426 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5427 switch ( nPropType )
5429 case BASEPROPERTY_VALUE_DOUBLE:
5431 if ( bVoid )
5433 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5434 if (!pNumericFormatter)
5435 return;
5436 pNumericFormatter->EnableEmptyFieldValue( true );
5437 pNumericFormatter->SetEmptyFieldValue();
5439 else
5441 double d = 0;
5442 if ( Value >>= d )
5443 setValue( d );
5446 break;
5447 case BASEPROPERTY_VALUEMIN_DOUBLE:
5449 double d = 0;
5450 if ( Value >>= d )
5451 setMin( d );
5453 break;
5454 case BASEPROPERTY_VALUEMAX_DOUBLE:
5456 double d = 0;
5457 if ( Value >>= d )
5458 setMax( d );
5460 break;
5461 case BASEPROPERTY_VALUESTEP_DOUBLE:
5463 double d = 0;
5464 if ( Value >>= d )
5465 setSpinSize( d );
5467 break;
5468 case BASEPROPERTY_DECIMALACCURACY:
5470 sal_Int16 n = sal_Int16();
5471 if ( Value >>= n )
5472 setDecimalDigits( n );
5474 break;
5475 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5477 bool b = bool();
5478 if ( Value >>= b )
5480 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5481 if (!pNumericFormatter)
5482 return;
5483 pNumericFormatter->SetUseThousandSep( b );
5486 break;
5487 default:
5489 VCLXFormattedSpinField::setProperty( PropertyName, Value );
5494 css::uno::Any VCLXNumericField::getProperty( const OUString& PropertyName )
5496 SolarMutexGuard aGuard;
5498 css::uno::Any aProp;
5499 FormatterBase* pFormatter = GetFormatter();
5500 if ( pFormatter )
5502 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5503 switch ( nPropType )
5505 case BASEPROPERTY_VALUE_DOUBLE:
5507 aProp <<= getValue();
5509 break;
5510 case BASEPROPERTY_VALUEMIN_DOUBLE:
5512 aProp <<= getMin();
5514 break;
5515 case BASEPROPERTY_VALUEMAX_DOUBLE:
5517 aProp <<= getMax();
5519 break;
5520 case BASEPROPERTY_VALUESTEP_DOUBLE:
5522 aProp <<= getSpinSize();
5524 break;
5525 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5527 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(pFormatter);
5528 aProp <<= pNumericFormatter->IsUseThousandSep();
5530 break;
5531 default:
5533 aProp = VCLXFormattedSpinField::getProperty( PropertyName );
5537 return aProp;
5541 // ----------------------------------------------------
5542 // ----------------------------------------------------
5544 void VCLXMetricField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
5546 PushPropertyIds( rIds,
5547 BASEPROPERTY_ALIGN,
5548 BASEPROPERTY_BACKGROUNDCOLOR,
5549 BASEPROPERTY_BORDER,
5550 BASEPROPERTY_BORDERCOLOR,
5551 BASEPROPERTY_DECIMALACCURACY,
5552 BASEPROPERTY_DEFAULTCONTROL,
5553 BASEPROPERTY_ENABLED,
5554 BASEPROPERTY_ENABLEVISIBLE,
5555 BASEPROPERTY_FONTDESCRIPTOR,
5556 BASEPROPERTY_HELPTEXT,
5557 BASEPROPERTY_HELPURL,
5558 BASEPROPERTY_NUMSHOWTHOUSANDSEP,
5559 BASEPROPERTY_PRINTABLE,
5560 BASEPROPERTY_READONLY,
5561 BASEPROPERTY_REPEAT,
5562 BASEPROPERTY_REPEAT_DELAY,
5563 BASEPROPERTY_SPIN,
5564 BASEPROPERTY_STRICTFORMAT,
5565 BASEPROPERTY_TABSTOP,
5566 BASEPROPERTY_ENFORCE_FORMAT,
5567 BASEPROPERTY_HIDEINACTIVESELECTION,
5568 BASEPROPERTY_UNIT,
5569 BASEPROPERTY_CUSTOMUNITTEXT,
5570 BASEPROPERTY_WRITING_MODE,
5571 BASEPROPERTY_CONTEXT_WRITING_MODE,
5572 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
5574 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5577 VCLXMetricField::VCLXMetricField()
5581 VCLXMetricField::~VCLXMetricField()
5585 MetricFormatter *VCLXMetricField::GetMetricFormatter()
5587 MetricFormatter *pFormatter = static_cast<MetricFormatter *>(GetFormatter());
5588 if (!pFormatter)
5589 throw css::uno::RuntimeException();
5590 return pFormatter;
5593 MetricField *VCLXMetricField::GetMetricField()
5595 VclPtr< MetricField > pField = GetAs< MetricField >();
5596 if (!pField)
5597 throw css::uno::RuntimeException();
5598 return pField;
5601 // FIXME: later ...
5602 #define MetricUnitUnoToVcl(a) (static_cast<FieldUnit>(a))
5604 #define METRIC_MAP_PAIR(method,parent) \
5605 sal_Int64 VCLXMetricField::get##method( sal_Int16 nUnit ) \
5607 SolarMutexGuard aGuard; \
5608 return GetMetric##parent()->Get##method( MetricUnitUnoToVcl( nUnit ) ); \
5610 void VCLXMetricField::set##method( sal_Int64 nValue, sal_Int16 nUnit ) \
5612 SolarMutexGuard aGuard; \
5613 GetMetric##parent()->Set##method( nValue, MetricUnitUnoToVcl( nUnit ) ); \
5616 METRIC_MAP_PAIR(Min, Formatter)
5617 METRIC_MAP_PAIR(Max, Formatter)
5618 METRIC_MAP_PAIR(First, Field)
5619 METRIC_MAP_PAIR(Last, Field)
5621 #undef METRIC_MAP_PAIR
5623 ::sal_Int64 VCLXMetricField::getValue( ::sal_Int16 nUnit )
5625 SolarMutexGuard aGuard;
5626 return GetMetricFormatter()->GetValue( MetricUnitUnoToVcl( nUnit ) );
5629 ::sal_Int64 VCLXMetricField::getCorrectedValue( ::sal_Int16 nUnit )
5631 SolarMutexGuard aGuard;
5632 return GetMetricFormatter()->GetCorrectedValue( MetricUnitUnoToVcl( nUnit ) );
5635 // FIXME: acute cut/paste evilness - move this to the parent Edit class ?
5636 void VCLXMetricField::CallListeners()
5638 // #107218# Call same listeners like VCL would do after user interaction
5639 VclPtr< Edit > pEdit = GetAs< Edit >();
5640 if ( pEdit )
5642 SetSynthesizingVCLEvent( true );
5643 pEdit->SetModifyFlag();
5644 pEdit->Modify();
5645 SetSynthesizingVCLEvent( false );
5649 void VCLXMetricField::setValue( ::sal_Int64 Value, ::sal_Int16 Unit )
5651 SolarMutexGuard aGuard;
5652 GetMetricFormatter()->SetValue( Value, MetricUnitUnoToVcl( Unit ) );
5653 CallListeners();
5656 void VCLXMetricField::setUserValue( ::sal_Int64 Value, ::sal_Int16 Unit )
5658 SolarMutexGuard aGuard;
5659 GetMetricFormatter()->SetUserValue( Value, MetricUnitUnoToVcl( Unit ) );
5660 CallListeners();
5663 void VCLXMetricField::setStrictFormat( sal_Bool bStrict )
5665 VCLXFormattedSpinField::setStrictFormat( bStrict );
5668 sal_Bool VCLXMetricField::isStrictFormat()
5670 return VCLXFormattedSpinField::isStrictFormat();
5673 void VCLXMetricField::setSpinSize( sal_Int64 Value )
5675 SolarMutexGuard aGuard;
5676 GetMetricField()->SetSpinSize( Value );
5679 sal_Int64 VCLXMetricField::getSpinSize()
5681 SolarMutexGuard aGuard;
5682 return GetMetricField()->GetSpinSize();
5685 void VCLXMetricField::setDecimalDigits( sal_Int16 Value )
5687 SolarMutexGuard aGuard;
5688 GetMetricFormatter()->SetDecimalDigits( Value );
5691 sal_Int16 VCLXMetricField::getDecimalDigits()
5693 SolarMutexGuard aGuard;
5695 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5696 return pNumericFormatter ? pNumericFormatter->GetDecimalDigits() : 0;
5699 void VCLXMetricField::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
5701 SolarMutexGuard aGuard;
5703 if ( !(GetWindow()) )
5704 return;
5706 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5707 switch ( nPropType )
5709 case BASEPROPERTY_DECIMALACCURACY:
5711 sal_Int16 n = 0;
5712 if ( Value >>= n )
5713 setDecimalDigits( n );
5714 break;
5716 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5718 bool b = false;
5719 if ( Value >>= b )
5721 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5722 if (!pNumericFormatter)
5723 return;
5724 pNumericFormatter->SetUseThousandSep( b );
5727 break;
5728 case BASEPROPERTY_UNIT:
5730 sal_uInt16 nVal = 0;
5731 if ( Value >>= nVal )
5732 GetAs< MetricField >()->SetUnit( static_cast<FieldUnit>(nVal) );
5733 break;
5735 case BASEPROPERTY_CUSTOMUNITTEXT:
5737 OUString aStr;
5738 if ( Value >>= aStr )
5739 GetAs< MetricField >()->SetCustomUnitText( aStr );
5740 break;
5742 default:
5744 VCLXFormattedSpinField::setProperty( PropertyName, Value );
5745 break;
5750 css::uno::Any VCLXMetricField::getProperty( const OUString& PropertyName )
5752 SolarMutexGuard aGuard;
5754 css::uno::Any aProp;
5755 FormatterBase* pFormatter = GetFormatter();
5756 if ( pFormatter )
5758 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5759 switch ( nPropType )
5761 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5763 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(pFormatter);
5764 aProp <<= pNumericFormatter->IsUseThousandSep();
5765 break;
5767 case BASEPROPERTY_UNIT:
5768 aProp <<= static_cast<sal_uInt16>(GetAs< MetricField >()->GetUnit());
5769 break;
5770 case BASEPROPERTY_CUSTOMUNITTEXT:
5771 aProp <<= GetAs< MetricField >()->GetCustomUnitText();
5772 break;
5773 default:
5775 aProp = VCLXFormattedSpinField::getProperty( PropertyName );
5776 break;
5780 return aProp;
5783 void VCLXPatternField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
5785 PushPropertyIds( rIds,
5786 BASEPROPERTY_ALIGN,
5787 BASEPROPERTY_BACKGROUNDCOLOR,
5788 BASEPROPERTY_BORDER,
5789 BASEPROPERTY_BORDERCOLOR,
5790 BASEPROPERTY_DEFAULTCONTROL,
5791 BASEPROPERTY_EDITMASK,
5792 BASEPROPERTY_ENABLED,
5793 BASEPROPERTY_ENABLEVISIBLE,
5794 BASEPROPERTY_FONTDESCRIPTOR,
5795 BASEPROPERTY_HELPTEXT,
5796 BASEPROPERTY_HELPURL,
5797 BASEPROPERTY_LITERALMASK,
5798 BASEPROPERTY_MAXTEXTLEN,
5799 BASEPROPERTY_PRINTABLE,
5800 BASEPROPERTY_READONLY,
5801 BASEPROPERTY_STRICTFORMAT,
5802 BASEPROPERTY_TABSTOP,
5803 BASEPROPERTY_TEXT,
5804 BASEPROPERTY_HIDEINACTIVESELECTION,
5805 BASEPROPERTY_VERTICALALIGN,
5806 BASEPROPERTY_WRITING_MODE,
5807 BASEPROPERTY_CONTEXT_WRITING_MODE,
5808 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
5809 BASEPROPERTY_HIGHLIGHT_COLOR,
5810 BASEPROPERTY_HIGHLIGHT_TEXT_COLOR,
5812 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5815 VCLXPatternField::VCLXPatternField()
5819 VCLXPatternField::~VCLXPatternField()
5823 void VCLXPatternField::setMasks( const OUString& EditMask, const OUString& LiteralMask )
5825 SolarMutexGuard aGuard;
5827 VclPtr< PatternField > pPatternField = GetAs< PatternField >();
5828 if ( pPatternField )
5830 pPatternField->SetMask( OUStringToOString(EditMask, RTL_TEXTENCODING_ASCII_US), LiteralMask );
5834 void VCLXPatternField::getMasks( OUString& EditMask, OUString& LiteralMask )
5836 SolarMutexGuard aGuard;
5838 VclPtr< PatternField > pPatternField = GetAs< PatternField >();
5839 if ( pPatternField )
5841 EditMask = OStringToOUString(pPatternField->GetEditMask(), RTL_TEXTENCODING_ASCII_US);
5842 LiteralMask = pPatternField->GetLiteralMask();
5846 void VCLXPatternField::setString( const OUString& Str )
5848 SolarMutexGuard aGuard;
5849 VclPtr< PatternField > pPatternField = GetAs< PatternField >();
5850 if ( pPatternField )
5851 pPatternField->SetString( Str );
5854 OUString VCLXPatternField::getString()
5856 SolarMutexGuard aGuard;
5858 OUString aString;
5859 VclPtr< PatternField > pPatternField = GetAs< PatternField >();
5860 if ( pPatternField )
5861 aString = pPatternField->GetString();
5862 return aString;
5865 void VCLXPatternField::setStrictFormat( sal_Bool bStrict )
5867 VCLXFormattedSpinField::setStrictFormat( bStrict );
5870 sal_Bool VCLXPatternField::isStrictFormat()
5872 return VCLXFormattedSpinField::isStrictFormat();
5875 void VCLXPatternField::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
5877 SolarMutexGuard aGuard;
5879 if ( !(GetWindow()) )
5880 return;
5882 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5883 switch ( nPropType )
5885 case BASEPROPERTY_EDITMASK:
5886 case BASEPROPERTY_LITERALMASK:
5888 OUString aString;
5889 if ( Value >>= aString )
5891 OUString aEditMask, aLiteralMask;
5892 getMasks( aEditMask, aLiteralMask );
5893 if ( nPropType == BASEPROPERTY_EDITMASK )
5894 aEditMask = aString;
5895 else
5896 aLiteralMask = aString;
5897 setMasks( aEditMask, aLiteralMask );
5900 break;
5901 default:
5903 VCLXFormattedSpinField::setProperty( PropertyName, Value );
5908 css::uno::Any VCLXPatternField::getProperty( const OUString& PropertyName )
5910 SolarMutexGuard aGuard;
5912 css::uno::Any aProp;
5913 if ( GetWindow() )
5915 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5916 switch ( nPropType )
5918 case BASEPROPERTY_EDITMASK:
5919 case BASEPROPERTY_LITERALMASK:
5921 OUString aEditMask, aLiteralMask;
5922 getMasks( aEditMask, aLiteralMask );
5923 if ( nPropType == BASEPROPERTY_EDITMASK )
5924 aProp <<= aEditMask;
5925 else
5926 aProp <<= aLiteralMask;
5928 break;
5929 default:
5931 aProp = VCLXFormattedSpinField::getProperty( PropertyName );
5935 return aProp;
5940 VCLXToolBox::VCLXToolBox()
5944 VCLXToolBox::~VCLXToolBox()
5948 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXToolBox::CreateAccessibleContext()
5950 return getAccessibleFactory().createAccessibleContext( this );
5953 VCLXHeaderBar::VCLXHeaderBar()
5957 VCLXHeaderBar::~VCLXHeaderBar()
5961 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXHeaderBar::CreateAccessibleContext()
5963 return getAccessibleFactory().createAccessibleContext( this );
5967 VCLXFrame::VCLXFrame()
5971 void VCLXFrame::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
5973 PushPropertyIds( rIds,
5974 BASEPROPERTY_BACKGROUNDCOLOR,
5975 BASEPROPERTY_DEFAULTCONTROL,
5976 BASEPROPERTY_ENABLED,
5977 BASEPROPERTY_ENABLEVISIBLE,
5978 BASEPROPERTY_FONTDESCRIPTOR,
5979 BASEPROPERTY_GRAPHIC,
5980 BASEPROPERTY_HELPTEXT,
5981 BASEPROPERTY_HELPURL,
5982 BASEPROPERTY_PRINTABLE,
5983 BASEPROPERTY_LABEL,
5985 VCLXContainer::ImplGetPropertyIds( rIds );
5988 VCLXFrame::~VCLXFrame()
5992 // css::awt::XView
5993 void SAL_CALL VCLXFrame::draw( sal_Int32 nX, sal_Int32 nY )
5995 SolarMutexGuard aGuard;
5996 VclPtr< vcl::Window > pWindow = GetWindow();
5998 if ( pWindow )
6000 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
6001 if ( !pDev )
6002 pDev = pWindow->GetParent()->GetOutDev();
6004 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
6005 pWindow->Draw( pDev, aPos, SystemTextColorFlags::NoControls );
6009 void SAL_CALL VCLXFrame::setProperty(
6010 const OUString& PropertyName,
6011 const css::uno::Any& Value )
6013 SolarMutexGuard aGuard;
6015 VCLXContainer::setProperty( PropertyName, Value );
6018 void VCLXFrame::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
6020 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
6021 VCLXContainer::ProcessWindowEvent( rVclWindowEvent );
6024 VCLXProgressBar::VCLXProgressBar()
6025 :m_nValue(0)
6026 ,m_nValueMin(0)
6027 ,m_nValueMax(100)
6031 VCLXProgressBar::~VCLXProgressBar()
6035 void VCLXProgressBar::ImplUpdateValue()
6037 VclPtr< ProgressBar > pProgressBar = GetAs< ProgressBar >();
6038 if ( !pProgressBar )
6039 return;
6041 sal_Int32 nVal;
6042 sal_Int32 nValMin;
6043 sal_Int32 nValMax;
6045 // check min and max
6046 if (m_nValueMin < m_nValueMax)
6048 nValMin = m_nValueMin;
6049 nValMax = m_nValueMax;
6051 else
6053 nValMin = m_nValueMax;
6054 nValMax = m_nValueMin;
6057 // check value
6058 if (m_nValue < nValMin)
6060 nVal = nValMin;
6062 else if (m_nValue > nValMax)
6064 nVal = nValMax;
6066 else
6068 nVal = m_nValue;
6071 // calculate percent
6072 sal_Int32 nPercent;
6073 if (nValMin != nValMax)
6075 nPercent = 100 * (nVal - nValMin) / (nValMax - nValMin);
6077 else
6079 nPercent = 0;
6082 // set progressbar value
6083 pProgressBar->SetValue( static_cast<sal_uInt16>(nPercent) );
6086 // css::awt::XProgressBar
6087 void VCLXProgressBar::setForegroundColor( sal_Int32 nColor )
6089 SolarMutexGuard aGuard;
6091 VclPtr<vcl::Window> pWindow = GetWindow();
6092 if ( pWindow )
6094 pWindow->SetControlForeground( Color(ColorTransparency, nColor) );
6098 void VCLXProgressBar::setBackgroundColor( sal_Int32 nColor )
6100 SolarMutexGuard aGuard;
6102 VclPtr<vcl::Window> pWindow = GetWindow();
6103 if ( pWindow )
6105 Color aColor( ColorTransparency, nColor );
6106 pWindow->SetBackground( aColor );
6107 pWindow->SetControlBackground( aColor );
6108 pWindow->Invalidate();
6112 void VCLXProgressBar::setValue( sal_Int32 nValue )
6114 SolarMutexGuard aGuard;
6116 m_nValue = nValue;
6117 ImplUpdateValue();
6120 void VCLXProgressBar::setRange( sal_Int32 nMin, sal_Int32 nMax )
6122 SolarMutexGuard aGuard;
6124 if ( nMin < nMax )
6126 // take correct min and max
6127 m_nValueMin = nMin;
6128 m_nValueMax = nMax;
6130 else
6132 // change min and max
6133 m_nValueMin = nMax;
6134 m_nValueMax = nMin;
6137 ImplUpdateValue();
6140 sal_Int32 VCLXProgressBar::getValue()
6142 SolarMutexGuard aGuard;
6144 return m_nValue;
6147 // css::awt::VclWindowPeer
6148 void VCLXProgressBar::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
6150 SolarMutexGuard aGuard;
6152 VclPtr< ProgressBar > pProgressBar = GetAs< ProgressBar >();
6153 if ( !pProgressBar )
6154 return;
6156 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6157 switch ( nPropType )
6159 case BASEPROPERTY_PROGRESSVALUE:
6161 if ( Value >>= m_nValue )
6162 ImplUpdateValue();
6164 break;
6165 case BASEPROPERTY_PROGRESSVALUE_MIN:
6167 if ( Value >>= m_nValueMin )
6168 ImplUpdateValue();
6170 break;
6171 case BASEPROPERTY_PROGRESSVALUE_MAX:
6173 if ( Value >>= m_nValueMax )
6174 ImplUpdateValue();
6176 break;
6177 case BASEPROPERTY_FILLCOLOR:
6179 VclPtr<vcl::Window> pWindow = GetWindow();
6180 if ( pWindow )
6182 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
6184 if ( bVoid )
6186 pWindow->SetControlForeground();
6188 else
6190 Color nColor;
6191 if ( Value >>= nColor )
6192 pWindow->SetControlForeground( nColor );
6196 break;
6197 default:
6198 VCLXWindow::setProperty( PropertyName, Value );
6199 break;
6203 css::uno::Any VCLXProgressBar::getProperty( const OUString& PropertyName )
6205 SolarMutexGuard aGuard;
6207 css::uno::Any aProp;
6208 VclPtr< ProgressBar > pProgressBar = GetAs< ProgressBar >();
6209 if ( pProgressBar )
6211 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6212 switch ( nPropType )
6214 case BASEPROPERTY_PROGRESSVALUE:
6216 aProp <<= m_nValue;
6218 break;
6219 case BASEPROPERTY_PROGRESSVALUE_MIN:
6221 aProp <<= m_nValueMin;
6223 break;
6224 case BASEPROPERTY_PROGRESSVALUE_MAX:
6226 aProp <<= m_nValueMax;
6228 break;
6229 default:
6230 aProp = VCLXWindow::getProperty( PropertyName );
6231 break;
6234 return aProp;
6237 void VCLXProgressBar::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
6239 PushPropertyIds( rIds,
6240 BASEPROPERTY_PROGRESSVALUE,
6241 BASEPROPERTY_PROGRESSVALUE_MIN,
6242 BASEPROPERTY_PROGRESSVALUE_MAX,
6243 BASEPROPERTY_FILLCOLOR,
6245 VCLXWindow::ImplGetPropertyIds( rIds, true );
6248 VCLXFileControl::VCLXFileControl() : maTextListeners( *this )
6252 VCLXFileControl::~VCLXFileControl()
6254 VclPtr< FileControl > pControl = GetAs< FileControl >();
6255 if ( pControl )
6256 pControl->GetEdit().SetModifyHdl( Link<Edit&,void>() );
6259 namespace
6261 void lcl_setWinBits( vcl::Window* _pWindow, WinBits _nBits, bool _bSet )
6263 WinBits nStyle = _pWindow->GetStyle();
6264 if ( _bSet )
6265 nStyle |= _nBits;
6266 else
6267 nStyle &= ~_nBits;
6268 _pWindow->SetStyle( nStyle );
6272 void SAL_CALL VCLXFileControl::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
6274 SolarMutexGuard aGuard;
6276 VclPtr< FileControl > pControl = GetAs< FileControl >();
6277 if ( !pControl )
6278 return;
6280 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6281 switch ( nPropType )
6283 case BASEPROPERTY_HIDEINACTIVESELECTION:
6285 bool bValue(false);
6286 OSL_VERIFY( Value >>= bValue );
6288 lcl_setWinBits( pControl, WB_NOHIDESELECTION, !bValue );
6289 lcl_setWinBits( &pControl->GetEdit(), WB_NOHIDESELECTION, !bValue );
6291 break;
6293 default:
6294 VCLXWindow::setProperty( PropertyName, Value );
6295 break;
6299 void VCLXFileControl::SetWindow( const VclPtr< vcl::Window > &pWindow )
6301 VclPtr< FileControl > pPrevFileControl = GetAsDynamic< FileControl >();
6302 if ( pPrevFileControl )
6303 pPrevFileControl->SetEditModifyHdl( Link<Edit&,void>() );
6305 FileControl* pNewFileControl = dynamic_cast<FileControl*>( pWindow.get() );
6306 if ( pNewFileControl )
6307 pNewFileControl->SetEditModifyHdl( LINK( this, VCLXFileControl, ModifyHdl ) );
6309 VCLXWindow::SetWindow( pWindow );
6312 void VCLXFileControl::addTextListener( const css::uno::Reference< css::awt::XTextListener > & l )
6314 maTextListeners.addInterface( l );
6317 void VCLXFileControl::removeTextListener( const css::uno::Reference< css::awt::XTextListener > & l )
6319 maTextListeners.removeInterface( l );
6322 void VCLXFileControl::setText( const OUString& aText )
6324 SolarMutexGuard aGuard;
6326 VclPtr<vcl::Window> pWindow = GetWindow();
6327 if ( pWindow )
6329 pWindow->SetText( aText );
6331 // also in Java a textChanged is triggered, not in VCL.
6332 // css::awt::Toolkit should be JAVA-compliant...
6333 ModifyHdl();
6337 void VCLXFileControl::insertText( const css::awt::Selection& rSel, const OUString& aText )
6339 SolarMutexGuard aGuard;
6341 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
6342 if ( pFileControl )
6344 pFileControl->GetEdit().SetSelection( Selection( rSel.Min, rSel.Max ) );
6345 pFileControl->GetEdit().ReplaceSelected( aText );
6349 OUString VCLXFileControl::getText()
6351 SolarMutexGuard aGuard;
6353 OUString aText;
6354 VclPtr<vcl::Window> pWindow = GetWindow();
6355 if ( pWindow )
6356 aText = pWindow->GetText();
6357 return aText;
6360 OUString VCLXFileControl::getSelectedText()
6362 SolarMutexGuard aGuard;
6364 OUString aText;
6365 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
6366 if ( pFileControl)
6367 aText = pFileControl->GetEdit().GetSelected();
6368 return aText;
6372 void VCLXFileControl::setSelection( const css::awt::Selection& aSelection )
6374 SolarMutexGuard aGuard;
6376 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
6377 if ( pFileControl )
6378 pFileControl->GetEdit().SetSelection( Selection( aSelection.Min, aSelection.Max ) );
6381 css::awt::Selection VCLXFileControl::getSelection()
6383 SolarMutexGuard aGuard;
6385 css::awt::Selection aSel;
6386 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
6387 if ( pFileControl )
6389 aSel.Min = pFileControl->GetEdit().GetSelection().Min();
6390 aSel.Max = pFileControl->GetEdit().GetSelection().Max();
6392 return aSel;
6395 sal_Bool VCLXFileControl::isEditable()
6397 SolarMutexGuard aGuard;
6399 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
6400 return pFileControl && !pFileControl->GetEdit().IsReadOnly() && pFileControl->GetEdit().IsEnabled();
6403 void VCLXFileControl::setEditable( sal_Bool bEditable )
6405 SolarMutexGuard aGuard;
6407 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
6408 if ( pFileControl )
6409 pFileControl->GetEdit().SetReadOnly( !bEditable );
6412 void VCLXFileControl::setMaxTextLen( sal_Int16 nLen )
6414 SolarMutexGuard aGuard;
6416 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
6417 if ( pFileControl )
6418 pFileControl->GetEdit().SetMaxTextLen( nLen );
6421 sal_Int16 VCLXFileControl::getMaxTextLen()
6423 SolarMutexGuard aGuard;
6425 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
6426 return pFileControl ? pFileControl->GetEdit().GetMaxTextLen() : 0;
6430 IMPL_LINK_NOARG(VCLXFileControl, ModifyHdl, Edit&, void)
6432 ModifyHdl();
6435 void VCLXFileControl::ModifyHdl()
6437 css::awt::TextEvent aEvent;
6438 aEvent.Source = getXWeak();
6439 maTextListeners.textChanged( aEvent );
6442 css::awt::Size VCLXFileControl::getMinimumSize()
6444 SolarMutexGuard aGuard;
6446 css::awt::Size aSz;
6447 VclPtr< FileControl > pControl = GetAs< FileControl >();
6448 if ( pControl )
6450 Size aTmpSize = pControl->GetEdit().CalcMinimumSize();
6451 aTmpSize.AdjustWidth(pControl->GetButton().CalcMinimumSize().Width() );
6452 aSz = AWTSize(pControl->CalcWindowSize( aTmpSize ));
6454 return aSz;
6457 css::awt::Size VCLXFileControl::getPreferredSize()
6459 css::awt::Size aSz = getMinimumSize();
6460 aSz.Height += 4;
6461 return aSz;
6464 css::awt::Size VCLXFileControl::calcAdjustedSize( const css::awt::Size& rNewSize )
6466 SolarMutexGuard aGuard;
6468 css::awt::Size aSz =rNewSize;
6469 VclPtr< FileControl > pControl = GetAs< FileControl >();
6470 if ( pControl )
6472 css::awt::Size aMinSz = getMinimumSize();
6473 if ( aSz.Height != aMinSz.Height )
6474 aSz.Height = aMinSz.Height;
6476 return aSz;
6479 css::awt::Size VCLXFileControl::getMinimumSize( sal_Int16 nCols, sal_Int16 )
6481 SolarMutexGuard aGuard;
6483 css::awt::Size aSz;
6484 VclPtr< FileControl > pControl = GetAs< FileControl >();
6485 if ( pControl )
6487 aSz = AWTSize(pControl->GetEdit().CalcSize( nCols ));
6488 aSz.Width += pControl->GetButton().CalcMinimumSize().Width();
6490 return aSz;
6493 void VCLXFileControl::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines )
6495 SolarMutexGuard aGuard;
6497 nCols = 0;
6498 nLines = 1;
6499 VclPtr< FileControl > pControl = GetAs< FileControl >();
6500 if ( pControl )
6501 nCols = pControl->GetEdit().GetMaxVisChars();
6504 void VCLXFileControl::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
6506 PushPropertyIds( rIds,
6507 // FIXME: elide duplication ?
6508 BASEPROPERTY_HIDEINACTIVESELECTION,
6510 VCLXWindow::ImplGetPropertyIds( rIds, true );
6513 SVTXFormattedField::SVTXFormattedField()
6514 :bIsStandardSupplier(true)
6515 ,nKeyToSetDelayed(-1)
6519 SVTXFormattedField::~SVTXFormattedField()
6523 void SVTXFormattedField::SetWindow( const VclPtr< vcl::Window > &_pWindow )
6525 VCLXSpinField::SetWindow(_pWindow);
6526 if (GetAs< FormattedField >())
6527 GetAs< FormattedField >()->GetFormatter().SetAutoColor(true);
6530 void SVTXFormattedField::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
6532 SolarMutexGuard aGuard;
6534 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6535 if ( pField )
6537 Formatter& rFormatter = pField->GetFormatter();
6538 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6539 switch (nPropType)
6541 case BASEPROPERTY_ENFORCE_FORMAT:
6543 bool bEnable( true );
6544 if ( Value >>= bEnable )
6545 rFormatter.EnableNotANumber( !bEnable );
6547 break;
6549 case BASEPROPERTY_EFFECTIVE_MIN:
6550 case BASEPROPERTY_VALUEMIN_DOUBLE:
6551 SetMinValue(Value);
6552 break;
6554 case BASEPROPERTY_EFFECTIVE_MAX:
6555 case BASEPROPERTY_VALUEMAX_DOUBLE:
6556 SetMaxValue(Value);
6557 break;
6559 case BASEPROPERTY_EFFECTIVE_DEFAULT:
6560 SetDefaultValue(Value);
6561 break;
6563 case BASEPROPERTY_TREATASNUMBER:
6565 bool b;
6566 if ( Value >>= b )
6567 SetTreatAsNumber(b);
6569 break;
6571 case BASEPROPERTY_FORMATSSUPPLIER:
6572 if (!Value.hasValue())
6573 setFormatsSupplier(css::uno::Reference< css::util::XNumberFormatsSupplier > (nullptr));
6574 else
6576 css::uno::Reference< css::util::XNumberFormatsSupplier > xNFS;
6577 if ( Value >>= xNFS )
6578 setFormatsSupplier(xNFS);
6580 break;
6581 case BASEPROPERTY_FORMATKEY:
6582 if (!Value.hasValue())
6583 setFormatKey(0);
6584 else
6586 sal_Int32 n = 0;
6587 if ( Value >>= n )
6588 setFormatKey(n);
6590 break;
6592 case BASEPROPERTY_EFFECTIVE_VALUE:
6593 case BASEPROPERTY_VALUE_DOUBLE:
6595 const css::uno::TypeClass rTC = Value.getValueType().getTypeClass();
6596 if (rTC != css::uno::TypeClass_STRING)
6597 // no string
6598 if (rTC != css::uno::TypeClass_DOUBLE)
6599 // no double
6600 if (Value.hasValue())
6601 { // but a value
6602 // try if it is something convertible
6603 sal_Int32 nValue = 0;
6604 if (!(Value >>= nValue))
6605 throw css::lang::IllegalArgumentException();
6606 SetValue(css::uno::Any(static_cast<double>(nValue)));
6607 break;
6610 SetValue(Value);
6612 break;
6613 case BASEPROPERTY_VALUESTEP_DOUBLE:
6615 double d = 0.0;
6616 if ( Value >>= d )
6617 rFormatter.SetSpinSize( d );
6618 else
6620 sal_Int32 n = 0;
6621 if ( Value >>= n )
6622 rFormatter.SetSpinSize( n );
6625 break;
6626 case BASEPROPERTY_DECIMALACCURACY:
6628 sal_Int32 n = 0;
6629 if ( Value >>= n )
6630 rFormatter.SetDecimalDigits( static_cast<sal_uInt16>(n) );
6632 break;
6633 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
6635 bool b;
6636 if ( Value >>= b )
6637 rFormatter.SetThousandsSep( b );
6639 break;
6641 default:
6642 VCLXSpinField::setProperty( PropertyName, Value );
6645 if (BASEPROPERTY_TEXTCOLOR == nPropType)
6646 { // after setting a new text color, think again about the AutoColor flag of the control
6647 // 17.05.2001 - 86859 - frank.schoenheit@germany.sun.com
6648 rFormatter.SetAutoColor(!Value.hasValue());
6651 else
6652 VCLXSpinField::setProperty( PropertyName, Value );
6655 css::uno::Any SVTXFormattedField::getProperty( const OUString& PropertyName )
6657 SolarMutexGuard aGuard;
6659 css::uno::Any aReturn;
6661 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6662 if ( pField )
6664 Formatter& rFormatter = pField->GetFormatter();
6665 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6666 switch (nPropType)
6668 case BASEPROPERTY_EFFECTIVE_MIN:
6669 case BASEPROPERTY_VALUEMIN_DOUBLE:
6670 aReturn = GetMinValue();
6671 break;
6673 case BASEPROPERTY_EFFECTIVE_MAX:
6674 case BASEPROPERTY_VALUEMAX_DOUBLE:
6675 aReturn = GetMaxValue();
6676 break;
6678 case BASEPROPERTY_EFFECTIVE_DEFAULT:
6679 aReturn = GetDefaultValue();
6680 break;
6682 case BASEPROPERTY_TREATASNUMBER:
6683 aReturn <<= GetTreatAsNumber();
6684 break;
6686 case BASEPROPERTY_EFFECTIVE_VALUE:
6687 case BASEPROPERTY_VALUE_DOUBLE:
6688 aReturn = GetValue();
6689 break;
6691 case BASEPROPERTY_VALUESTEP_DOUBLE:
6692 aReturn <<= rFormatter.GetSpinSize();
6693 break;
6695 case BASEPROPERTY_DECIMALACCURACY:
6696 aReturn <<= rFormatter.GetDecimalDigits();
6697 break;
6699 case BASEPROPERTY_FORMATSSUPPLIER:
6701 if (!bIsStandardSupplier)
6702 { // ansonsten void
6703 css::uno::Reference< css::util::XNumberFormatsSupplier > xSupplier = m_xCurrentSupplier;
6704 aReturn <<= xSupplier;
6707 break;
6709 case BASEPROPERTY_FORMATKEY:
6711 if (!bIsStandardSupplier)
6712 aReturn <<= getFormatKey();
6714 break;
6716 default:
6717 aReturn = VCLXSpinField::getProperty(PropertyName);
6720 return aReturn;
6723 css::uno::Any SVTXFormattedField::convertEffectiveValue(const css::uno::Any& rValue) const
6725 css::uno::Any aReturn;
6727 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6728 if (!pField)
6729 return aReturn;
6731 Formatter& rFieldFormatter = pField->GetFormatter();
6732 switch (rValue.getValueType().getTypeClass())
6734 case css::uno::TypeClass_DOUBLE:
6735 if (rFieldFormatter.TreatingAsNumber())
6737 double d = 0.0;
6738 rValue >>= d;
6739 aReturn <<= d;
6741 else
6743 SvNumberFormatter* pFormatter = rFieldFormatter.GetFormatter();
6744 if (!pFormatter)
6745 pFormatter = rFieldFormatter.StandardFormatter();
6746 // should never fail
6748 const Color* pDum;
6749 double d = 0.0;
6750 rValue >>= d;
6751 OUString sConverted;
6752 pFormatter->GetOutputString(d, 0, sConverted, &pDum);
6753 aReturn <<= sConverted;
6755 break;
6756 case css::uno::TypeClass_STRING:
6758 OUString aStr;
6759 rValue >>= aStr;
6760 if (rFieldFormatter.TreatingAsNumber())
6762 SvNumberFormatter* pFormatter = rFieldFormatter.GetFormatter();
6763 if (!pFormatter)
6764 pFormatter = rFieldFormatter.StandardFormatter();
6766 double dVal;
6767 sal_uInt32 nTestFormat(0);
6768 if (!pFormatter->IsNumberFormat(aStr, nTestFormat, dVal))
6769 aReturn.clear();
6770 aReturn <<= dVal;
6772 else
6773 aReturn <<= aStr;
6775 break;
6776 default:
6777 aReturn.clear();
6778 break;
6780 return aReturn;
6783 void SVTXFormattedField::SetMinValue(const css::uno::Any& rValue)
6785 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6786 if (!pField)
6787 return;
6789 Formatter& rFormatter = pField->GetFormatter();
6790 switch (rValue.getValueType().getTypeClass())
6793 case css::uno::TypeClass_DOUBLE:
6795 double d = 0.0;
6796 rValue >>= d;
6797 rFormatter.SetMinValue(d);
6798 break;
6800 default:
6801 DBG_ASSERT(rValue.getValueType().getTypeClass() == css::uno::TypeClass_VOID, "SVTXFormattedField::SetMinValue : invalid argument (an exception will be thrown) !");
6802 if ( rValue.getValueType().getTypeClass() != css::uno::TypeClass_VOID )
6805 throw css::lang::IllegalArgumentException();
6807 rFormatter.ClearMinValue();
6808 break;
6812 css::uno::Any SVTXFormattedField::GetMinValue() const
6814 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6815 if (!pField)
6816 return css::uno::Any();
6817 Formatter& rFormatter = pField->GetFormatter();
6818 if (!rFormatter.HasMinValue())
6819 return css::uno::Any();
6821 css::uno::Any aReturn;
6822 aReturn <<= rFormatter.GetMinValue();
6823 return aReturn;
6826 void SVTXFormattedField::SetMaxValue(const css::uno::Any& rValue)
6828 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6829 if (!pField)
6830 return;
6832 Formatter& rFormatter = pField->GetFormatter();
6833 switch (rValue.getValueType().getTypeClass())
6835 case css::uno::TypeClass_DOUBLE:
6837 double d = 0.0;
6838 rValue >>= d;
6839 rFormatter.SetMaxValue(d);
6840 break;
6842 default:
6843 if (rValue.getValueType().getTypeClass() != css::uno::TypeClass_VOID)
6846 throw css::lang::IllegalArgumentException();
6848 rFormatter.ClearMaxValue();
6849 break;
6853 css::uno::Any SVTXFormattedField::GetMaxValue() const
6855 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6856 if (!pField)
6857 return css::uno::Any();
6858 Formatter& rFormatter = pField->GetFormatter();
6859 if (!rFormatter.HasMaxValue())
6860 return css::uno::Any();
6862 css::uno::Any aReturn;
6863 aReturn <<= rFormatter.GetMaxValue();
6864 return aReturn;
6867 void SVTXFormattedField::SetDefaultValue(const css::uno::Any& rValue)
6869 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6870 if (!pField)
6871 return;
6873 css::uno::Any aConverted = convertEffectiveValue(rValue);
6875 Formatter& rFormatter = pField->GetFormatter();
6876 switch (aConverted.getValueType().getTypeClass())
6878 case css::uno::TypeClass_DOUBLE:
6880 double d = 0.0;
6881 aConverted >>= d;
6882 rFormatter.SetDefaultValue(d);
6884 break;
6885 case css::uno::TypeClass_STRING:
6887 OUString aStr;
6888 aConverted >>= aStr;
6889 rFormatter.SetDefaultText( aStr );
6891 break;
6892 default:
6893 rFormatter.EnableEmptyField(true);
6894 // only void accepted
6895 break;
6899 css::uno::Any SVTXFormattedField::GetDefaultValue() const
6901 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6902 if (!pField)
6903 return css::uno::Any();
6904 Formatter& rFormatter = pField->GetFormatter();
6905 if (rFormatter.IsEmptyFieldEnabled())
6906 return css::uno::Any();
6908 css::uno::Any aReturn;
6909 if (rFormatter.TreatingAsNumber())
6910 aReturn <<= rFormatter.GetDefaultValue();
6911 else
6912 aReturn <<= rFormatter.GetDefaultText();
6913 return aReturn;
6916 bool SVTXFormattedField::GetTreatAsNumber() const
6918 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6919 if (pField)
6920 return pField->GetFormatter().TreatingAsNumber();
6922 return true;
6925 void SVTXFormattedField::SetTreatAsNumber(bool bSet)
6927 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6928 if (pField)
6929 pField->GetFormatter().TreatAsNumber(bSet);
6932 css::uno::Any SVTXFormattedField::GetValue() const
6934 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6935 if (!pField)
6936 return css::uno::Any();
6938 Formatter& rFormatter = pField->GetFormatter();
6939 css::uno::Any aReturn;
6940 if (!rFormatter.TreatingAsNumber())
6942 OUString sText = rFormatter.GetTextValue();
6943 aReturn <<= sText;
6945 else
6947 if (!pField->GetText().isEmpty()) // empty is returned as void by default
6948 aReturn <<= rFormatter.GetValue();
6951 return aReturn;
6954 void SVTXFormattedField::SetValue(const css::uno::Any& rValue)
6956 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6957 if (!pField)
6958 return;
6960 if (!rValue.hasValue())
6962 pField->SetText("");
6964 else
6966 Formatter& rFormatter = pField->GetFormatter();
6967 if (rValue.getValueType().getTypeClass() == css::uno::TypeClass_DOUBLE )
6969 double d = 0.0;
6970 rValue >>= d;
6971 rFormatter.SetValue(d);
6973 else
6975 DBG_ASSERT(rValue.getValueType().getTypeClass() == css::uno::TypeClass_STRING, "SVTXFormattedField::SetValue : invalid argument !");
6977 OUString sText;
6978 rValue >>= sText;
6979 if (!rFormatter.TreatingAsNumber())
6980 rFormatter.SetTextFormatted(sText);
6981 else
6982 rFormatter.SetTextValue(sText);
6985 // NotifyTextListeners();
6988 void SVTXFormattedField::setFormatsSupplier(const css::uno::Reference< css::util::XNumberFormatsSupplier > & xSupplier)
6990 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6992 rtl::Reference<SvNumberFormatsSupplierObj> pNew;
6993 if (!xSupplier.is())
6995 if (pField)
6997 Formatter& rFormatter = pField->GetFormatter();
6998 pNew = new SvNumberFormatsSupplierObj(rFormatter.StandardFormatter());
6999 bIsStandardSupplier = true;
7002 else
7004 pNew = comphelper::getFromUnoTunnel<SvNumberFormatsSupplierObj>(xSupplier);
7005 bIsStandardSupplier = false;
7008 if (!pNew)
7009 return; // TODO : how to process ?
7011 m_xCurrentSupplier = pNew;
7012 if (!pField)
7013 return;
7015 // save the actual value
7016 css::uno::Any aCurrent = GetValue();
7017 Formatter& rFormatter = pField->GetFormatter();
7018 rFormatter.SetFormatter(m_xCurrentSupplier->GetNumberFormatter(), false);
7019 if (nKeyToSetDelayed != -1)
7021 rFormatter.SetFormatKey(nKeyToSetDelayed);
7022 nKeyToSetDelayed = -1;
7024 SetValue(aCurrent);
7025 NotifyTextListeners();
7028 sal_Int32 SVTXFormattedField::getFormatKey() const
7030 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7031 return pField ? pField->GetFormatter().GetFormatKey() : 0;
7034 void SVTXFormattedField::setFormatKey(sal_Int32 nKey)
7036 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7037 if (!pField)
7038 return;
7040 Formatter& rFormatter = pField->GetFormatter();
7041 if (rFormatter.GetFormatter())
7042 rFormatter.SetFormatKey(nKey);
7043 else
7045 // probably I am in a block, in which first the key and next the formatter will be set,
7046 // initially this happens quite certain, as the properties are set in alphabetic sequence,
7047 // and the FormatsSupplier is processed before the FormatKey
7048 nKeyToSetDelayed = nKey;
7050 NotifyTextListeners();
7053 void SVTXFormattedField::NotifyTextListeners()
7055 if ( GetTextListeners().getLength() )
7057 css::awt::TextEvent aEvent;
7058 aEvent.Source = getXWeak();
7059 GetTextListeners().textChanged( aEvent );
7063 void SVTXFormattedField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
7065 PushPropertyIds( rIds,
7066 // FIXME: elide duplication ?
7067 BASEPROPERTY_EFFECTIVE_MIN,
7068 BASEPROPERTY_VALUEMIN_DOUBLE,
7069 BASEPROPERTY_EFFECTIVE_MAX,
7070 BASEPROPERTY_VALUEMAX_DOUBLE,
7071 BASEPROPERTY_EFFECTIVE_DEFAULT,
7072 BASEPROPERTY_TREATASNUMBER,
7073 BASEPROPERTY_EFFECTIVE_VALUE,
7074 BASEPROPERTY_VALUE_DOUBLE,
7075 BASEPROPERTY_VALUESTEP_DOUBLE,
7076 BASEPROPERTY_DECIMALACCURACY,
7077 BASEPROPERTY_FORMATSSUPPLIER,
7078 BASEPROPERTY_NUMSHOWTHOUSANDSEP,
7079 BASEPROPERTY_FORMATKEY,
7080 BASEPROPERTY_TREATASNUMBER,
7081 BASEPROPERTY_ENFORCE_FORMAT,
7083 VCLXWindow::ImplGetPropertyIds( rIds, true );
7084 VCLXSpinField::ImplGetPropertyIds( rIds );
7087 SVTXCurrencyField::SVTXCurrencyField()
7091 SVTXCurrencyField::~SVTXCurrencyField()
7095 void SVTXCurrencyField::setValue( double Value )
7097 SolarMutexGuard aGuard;
7099 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7100 if ( pField )
7101 pField->GetFormatter().SetValue( Value );
7104 double SVTXCurrencyField::getValue()
7106 SolarMutexGuard aGuard;
7108 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7109 return pField ? pField->GetFormatter().GetValue() : 0;
7112 void SVTXCurrencyField::setMin( double Value )
7114 SolarMutexGuard aGuard;
7116 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7117 if ( pField )
7118 pField->GetFormatter().SetMinValue( Value );
7121 double SVTXCurrencyField::getMin()
7123 SolarMutexGuard aGuard;
7125 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7126 return pField ? pField->GetFormatter().GetMinValue() : 0;
7129 void SVTXCurrencyField::setMax( double Value )
7131 SolarMutexGuard aGuard;
7133 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7134 if ( pField )
7135 pField->GetFormatter().SetMaxValue( Value );
7138 double SVTXCurrencyField::getMax()
7140 SolarMutexGuard aGuard;
7142 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7143 return pField ? pField->GetFormatter().GetMaxValue() : 0;
7146 void SVTXCurrencyField::setFirst( double Value )
7148 SolarMutexGuard aGuard;
7150 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7151 if ( pField )
7152 pField->GetFormatter().SetSpinFirst( Value );
7155 double SVTXCurrencyField::getFirst()
7157 SolarMutexGuard aGuard;
7159 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7160 return pField ? pField->GetFormatter().GetSpinFirst() : 0;
7163 void SVTXCurrencyField::setLast( double Value )
7165 SolarMutexGuard aGuard;
7167 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7168 if ( pField )
7169 pField->GetFormatter().SetSpinLast( Value );
7172 double SVTXCurrencyField::getLast()
7174 SolarMutexGuard aGuard;
7176 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7177 return pField ? pField->GetFormatter().GetSpinLast() : 0;
7180 void SVTXCurrencyField::setSpinSize( double Value )
7182 SolarMutexGuard aGuard;
7184 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7185 if ( pField )
7186 pField->GetFormatter().SetSpinSize( Value );
7189 double SVTXCurrencyField::getSpinSize()
7191 SolarMutexGuard aGuard;
7193 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7194 return pField ? pField->GetFormatter().GetSpinSize() : 0;
7197 void SVTXCurrencyField::setDecimalDigits( sal_Int16 Value )
7199 SolarMutexGuard aGuard;
7201 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7202 if ( pField )
7203 pField->GetFormatter().SetDecimalDigits( Value );
7206 sal_Int16 SVTXCurrencyField::getDecimalDigits()
7208 SolarMutexGuard aGuard;
7210 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7211 return pField ? pField->GetFormatter().GetDecimalDigits() : 0;
7214 void SVTXCurrencyField::setStrictFormat( sal_Bool bStrict )
7216 SolarMutexGuard aGuard;
7218 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7219 if ( pField )
7220 pField->GetFormatter().SetStrictFormat( bStrict );
7223 sal_Bool SVTXCurrencyField::isStrictFormat()
7225 SolarMutexGuard aGuard;
7227 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7228 return pField && pField->GetFormatter().IsStrictFormat();
7231 void SVTXCurrencyField::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
7233 SolarMutexGuard aGuard;
7235 VclPtr< DoubleCurrencyField > pField = GetAs< DoubleCurrencyField >();
7236 if ( pField )
7238 sal_uInt16 nPropType = GetPropertyId( PropertyName );
7239 switch (nPropType)
7241 case BASEPROPERTY_CURRENCYSYMBOL:
7243 OUString aStr;
7244 Value >>= aStr;
7245 pField->setCurrencySymbol( aStr );
7247 break;
7248 case BASEPROPERTY_CURSYM_POSITION:
7250 bool b = false;
7251 Value >>= b;
7252 pField->setPrependCurrSym(b);
7254 break;
7256 default:
7257 SVTXFormattedField::setProperty(PropertyName, Value);
7260 else
7261 SVTXFormattedField::setProperty(PropertyName, Value);
7264 css::uno::Any SVTXCurrencyField::getProperty( const OUString& PropertyName )
7266 SolarMutexGuard aGuard;
7268 css::uno::Any aReturn;
7270 VclPtr< DoubleCurrencyField > pField = GetAs< DoubleCurrencyField >();
7271 if ( pField )
7273 sal_uInt16 nPropType = GetPropertyId( PropertyName );
7274 switch (nPropType)
7276 case BASEPROPERTY_CURRENCYSYMBOL:
7278 aReturn <<= pField->getCurrencySymbol();
7280 break;
7281 case BASEPROPERTY_CURSYM_POSITION:
7283 aReturn <<= pField->getPrependCurrSym();
7285 break;
7286 default:
7287 return SVTXFormattedField::getProperty(PropertyName);
7290 return SVTXFormattedField::getProperty(PropertyName);
7293 void SVTXCurrencyField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
7295 PushPropertyIds( rIds,
7296 BASEPROPERTY_ALIGN,
7297 BASEPROPERTY_BACKGROUNDCOLOR,
7298 BASEPROPERTY_BORDER,
7299 BASEPROPERTY_BORDERCOLOR,
7300 BASEPROPERTY_CURRENCYSYMBOL,
7301 BASEPROPERTY_CURSYM_POSITION,
7302 BASEPROPERTY_DECIMALACCURACY,
7303 BASEPROPERTY_DEFAULTCONTROL,
7304 BASEPROPERTY_ENABLED,
7305 BASEPROPERTY_ENABLEVISIBLE,
7306 BASEPROPERTY_FONTDESCRIPTOR,
7307 BASEPROPERTY_HELPTEXT,
7308 BASEPROPERTY_HELPURL,
7309 BASEPROPERTY_NUMSHOWTHOUSANDSEP,
7310 BASEPROPERTY_PRINTABLE,
7311 BASEPROPERTY_READONLY,
7312 BASEPROPERTY_REPEAT,
7313 BASEPROPERTY_REPEAT_DELAY,
7314 BASEPROPERTY_SPIN,
7315 BASEPROPERTY_STRICTFORMAT,
7316 BASEPROPERTY_TABSTOP,
7317 BASEPROPERTY_VALUEMAX_DOUBLE,
7318 BASEPROPERTY_VALUEMIN_DOUBLE,
7319 BASEPROPERTY_VALUESTEP_DOUBLE,
7320 BASEPROPERTY_VALUE_DOUBLE,
7321 BASEPROPERTY_ENFORCE_FORMAT,
7322 BASEPROPERTY_HIDEINACTIVESELECTION,
7323 BASEPROPERTY_VERTICALALIGN,
7324 BASEPROPERTY_WRITING_MODE,
7325 BASEPROPERTY_CONTEXT_WRITING_MODE,
7326 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
7327 BASEPROPERTY_HIGHLIGHT_COLOR,
7328 BASEPROPERTY_HIGHLIGHT_TEXT_COLOR,
7330 VCLXWindow::ImplGetPropertyIds( rIds );
7333 SVTXNumericField::SVTXNumericField()
7337 SVTXNumericField::~SVTXNumericField()
7342 css::uno::Reference<accessibility::XAccessibleContext> SVTXNumericField::CreateAccessibleContext()
7344 return getAccessibleFactory().createAccessibleContext(this);
7348 void SVTXNumericField::setValue( double Value )
7350 SolarMutexGuard aGuard;
7352 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7353 if ( pField )
7354 pField->GetFormatter().SetValue( Value );
7357 double SVTXNumericField::getValue()
7359 SolarMutexGuard aGuard;
7361 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7362 return pField ? pField->GetFormatter().GetValue() : 0;
7365 void SVTXNumericField::setMin( double Value )
7367 SolarMutexGuard aGuard;
7369 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7370 if ( pField )
7371 pField->GetFormatter().SetMinValue( Value );
7374 double SVTXNumericField::getMin()
7376 SolarMutexGuard aGuard;
7378 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7379 return pField ? pField->GetFormatter().GetMinValue() : 0;
7382 void SVTXNumericField::setMax( double Value )
7384 SolarMutexGuard aGuard;
7386 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7387 if ( pField )
7388 pField->GetFormatter().SetMaxValue( Value );
7391 double SVTXNumericField::getMax()
7393 SolarMutexGuard aGuard;
7395 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7396 return pField ? pField->GetFormatter().GetMaxValue() : 0;
7399 void SVTXNumericField::setFirst( double Value )
7401 SolarMutexGuard aGuard;
7403 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7404 if ( pField )
7405 pField->GetFormatter().SetSpinFirst( Value );
7408 double SVTXNumericField::getFirst()
7410 SolarMutexGuard aGuard;
7412 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7413 return pField ? pField->GetFormatter().GetSpinFirst() : 0;
7416 void SVTXNumericField::setLast( double Value )
7418 SolarMutexGuard aGuard;
7420 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7421 if ( pField )
7422 pField->GetFormatter().SetSpinLast( Value );
7425 double SVTXNumericField::getLast()
7427 SolarMutexGuard aGuard;
7429 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7430 return pField ? pField->GetFormatter().GetSpinLast() : 0;
7433 void SVTXNumericField::setSpinSize( double Value )
7435 SolarMutexGuard aGuard;
7437 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7438 if ( pField )
7439 pField->GetFormatter().SetSpinSize( Value );
7442 double SVTXNumericField::getSpinSize()
7444 SolarMutexGuard aGuard;
7446 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7447 return pField ? pField->GetFormatter().GetSpinSize() : 0;
7450 void SVTXNumericField::setDecimalDigits( sal_Int16 Value )
7452 SolarMutexGuard aGuard;
7454 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7455 if ( pField )
7456 pField->GetFormatter().SetDecimalDigits( Value );
7459 sal_Int16 SVTXNumericField::getDecimalDigits()
7461 SolarMutexGuard aGuard;
7463 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7464 return pField ? pField->GetFormatter().GetDecimalDigits() : 0;
7467 void SVTXNumericField::setStrictFormat( sal_Bool bStrict )
7469 SolarMutexGuard aGuard;
7471 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7472 if ( pField )
7473 pField->GetFormatter().SetStrictFormat( bStrict );
7476 sal_Bool SVTXNumericField::isStrictFormat()
7478 SolarMutexGuard aGuard;
7480 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7481 return pField && pField->GetFormatter().IsStrictFormat();
7484 void SVTXNumericField::GetPropertyIds( std::vector< sal_uInt16 > &rIds )
7486 SVTXFormattedField::ImplGetPropertyIds( rIds );
7489 SVTXDateField::SVTXDateField()
7493 SVTXDateField::~SVTXDateField()
7497 void SAL_CALL SVTXDateField::setProperty( const OUString& PropertyName, const css::uno::Any& Value )
7499 VCLXDateField::setProperty( PropertyName, Value );
7501 // some properties need to be forwarded to the sub edit, too
7502 SolarMutexGuard g;
7503 VclPtr< Edit > pSubEdit = GetWindow() ? GetAs<Edit>()->GetSubEdit() : nullptr;
7504 if ( !pSubEdit )
7505 return;
7507 switch ( GetPropertyId( PropertyName ) )
7509 case BASEPROPERTY_TEXTLINECOLOR:
7510 if ( !Value.hasValue() )
7511 pSubEdit->SetTextLineColor();
7512 else
7514 Color nColor;
7515 if ( Value >>= nColor )
7516 pSubEdit->SetTextLineColor( nColor );
7518 break;
7522 void SVTXDateField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
7524 PushPropertyIds( rIds,
7525 BASEPROPERTY_TEXTLINECOLOR,
7527 VCLXDateField::ImplGetPropertyIds( rIds );
7530 VCLXMultiLineEdit::VCLXMultiLineEdit()
7531 :maTextListeners( *this )
7532 ,meLineEndType( LINEEND_LF ) // default behavior before introducing this property: LF (unix-like)
7536 VCLXMultiLineEdit::~VCLXMultiLineEdit()
7540 void VCLXMultiLineEdit::addTextListener( const css::uno::Reference< css::awt::XTextListener > & l )
7542 maTextListeners.addInterface( l );
7545 void VCLXMultiLineEdit::removeTextListener( const css::uno::Reference< css::awt::XTextListener > & l )
7547 maTextListeners.removeInterface( l );
7550 void VCLXMultiLineEdit::setText( const OUString& aText )
7552 SolarMutexGuard aGuard;
7554 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
7555 if ( pEdit )
7557 pEdit->SetText( aText );
7559 // #107218# Call same listeners like VCL would do after user interaction
7560 SetSynthesizingVCLEvent( true );
7561 pEdit->SetModifyFlag();
7562 pEdit->Modify();
7563 SetSynthesizingVCLEvent( false );
7567 void VCLXMultiLineEdit::insertText( const css::awt::Selection& rSel, const OUString& aText )
7569 SolarMutexGuard aGuard;
7571 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
7572 if ( pEdit )
7574 setSelection( rSel );
7575 pEdit->ReplaceSelected( aText );
7579 OUString VCLXMultiLineEdit::getText()
7581 SolarMutexGuard aGuard;
7583 OUString aText;
7584 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
7585 if ( pEdit )
7586 aText = pEdit->GetText( meLineEndType );
7587 return aText;
7590 OUString VCLXMultiLineEdit::getSelectedText()
7592 SolarMutexGuard aGuard;
7594 OUString aText;
7595 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
7596 if ( pMultiLineEdit)
7597 aText = pMultiLineEdit->GetSelected( meLineEndType );
7598 return aText;
7602 void VCLXMultiLineEdit::setSelection( const css::awt::Selection& aSelection )
7604 SolarMutexGuard aGuard;
7606 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
7607 if ( pMultiLineEdit )
7609 pMultiLineEdit->SetSelection( Selection( aSelection.Min, aSelection.Max ) );
7613 css::awt::Selection VCLXMultiLineEdit::getSelection()
7615 SolarMutexGuard aGuard;
7617 css::awt::Selection aSel;
7618 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
7619 if ( pMultiLineEdit )
7621 aSel.Min = pMultiLineEdit->GetSelection().Min();
7622 aSel.Max = pMultiLineEdit->GetSelection().Max();
7624 return aSel;
7627 sal_Bool VCLXMultiLineEdit::isEditable()
7629 SolarMutexGuard aGuard;
7631 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
7632 return pMultiLineEdit && !pMultiLineEdit->IsReadOnly() && pMultiLineEdit->IsEnabled();
7635 void VCLXMultiLineEdit::setEditable( sal_Bool bEditable )
7637 SolarMutexGuard aGuard;
7639 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
7640 if ( pMultiLineEdit )
7641 pMultiLineEdit->SetReadOnly( !bEditable );
7644 void VCLXMultiLineEdit::setMaxTextLen( sal_Int16 nLen )
7646 SolarMutexGuard aGuard;
7648 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
7649 if ( pMultiLineEdit )
7650 pMultiLineEdit->SetMaxTextLen( nLen );
7653 sal_Int16 VCLXMultiLineEdit::getMaxTextLen()
7655 SolarMutexGuard aGuard;
7657 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
7658 return pMultiLineEdit ? static_cast<sal_Int16>(pMultiLineEdit->GetMaxTextLen()) : sal_Int16(0);
7661 OUString VCLXMultiLineEdit::getTextLines()
7663 SolarMutexGuard aGuard;
7665 OUString aText;
7666 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
7667 if ( pEdit )
7668 aText = pEdit->GetTextLines( meLineEndType );
7669 return aText;
7672 css::awt::Size VCLXMultiLineEdit::getMinimumSize()
7674 SolarMutexGuard aGuard;
7676 css::awt::Size aSz;
7677 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
7678 if ( pEdit )
7679 aSz = AWTSize(pEdit->CalcMinimumSize());
7680 return aSz;
7683 css::awt::Size VCLXMultiLineEdit::getPreferredSize()
7685 return getMinimumSize();
7688 css::awt::Size VCLXMultiLineEdit::calcAdjustedSize( const css::awt::Size& rNewSize )
7690 SolarMutexGuard aGuard;
7692 css::awt::Size aSz = rNewSize;
7693 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
7694 if ( pEdit )
7695 aSz = AWTSize(pEdit->CalcAdjustedSize( VCLSize(rNewSize )));
7696 return aSz;
7699 css::awt::Size VCLXMultiLineEdit::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines )
7701 SolarMutexGuard aGuard;
7703 css::awt::Size aSz;
7704 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
7705 if ( pEdit )
7706 aSz = AWTSize(pEdit->CalcBlockSize( nCols, nLines ));
7707 return aSz;
7710 void VCLXMultiLineEdit::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines )
7712 SolarMutexGuard aGuard;
7714 nCols = nLines = 0;
7715 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
7716 if ( pEdit )
7718 sal_uInt16 nC, nL;
7719 pEdit->GetMaxVisColumnsAndLines( nC, nL );
7720 nCols = nC;
7721 nLines = nL;
7725 void VCLXMultiLineEdit::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
7727 switch ( rVclWindowEvent.GetId() )
7729 case VclEventId::EditModify:
7731 if ( maTextListeners.getLength() )
7733 css::awt::TextEvent aEvent;
7734 aEvent.Source = getXWeak();
7735 maTextListeners.textChanged( aEvent );
7738 break;
7739 default:
7741 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
7743 break;
7747 void VCLXMultiLineEdit::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
7749 SolarMutexGuard aGuard;
7751 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
7752 if ( !pMultiLineEdit )
7753 return;
7755 sal_uInt16 nPropType = GetPropertyId( PropertyName );
7756 switch ( nPropType )
7758 case BASEPROPERTY_LINE_END_FORMAT:
7760 sal_Int16 nLineEndType = css::awt::LineEndFormat::LINE_FEED;
7761 OSL_VERIFY( Value >>= nLineEndType );
7762 switch ( nLineEndType )
7764 case css::awt::LineEndFormat::CARRIAGE_RETURN: meLineEndType = LINEEND_CR; break;
7765 case css::awt::LineEndFormat::LINE_FEED: meLineEndType = LINEEND_LF; break;
7766 case css::awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED: meLineEndType = LINEEND_CRLF; break;
7767 default: OSL_FAIL( "VCLXMultiLineEdit::setProperty: invalid line end value!" ); break;
7770 break;
7772 case BASEPROPERTY_READONLY:
7774 bool b;
7775 if ( Value >>= b )
7776 pMultiLineEdit->SetReadOnly( b );
7778 break;
7779 case BASEPROPERTY_MAXTEXTLEN:
7781 sal_Int16 n = sal_Int16();
7782 if ( Value >>= n )
7783 pMultiLineEdit->SetMaxTextLen( n );
7785 break;
7786 case BASEPROPERTY_HIDEINACTIVESELECTION:
7788 bool b;
7789 if ( Value >>= b )
7791 pMultiLineEdit->EnableFocusSelectionHide( b );
7792 lcl_setWinBits( pMultiLineEdit, WB_NOHIDESELECTION, !b );
7795 break;
7796 default:
7798 VCLXWindow::setProperty( PropertyName, Value );
7803 css::uno::Any VCLXMultiLineEdit::getProperty( const OUString& PropertyName )
7805 SolarMutexGuard aGuard;
7807 css::uno::Any aProp;
7808 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
7809 if ( pMultiLineEdit )
7811 sal_uInt16 nPropType = GetPropertyId( PropertyName );
7812 switch ( nPropType )
7814 case BASEPROPERTY_LINE_END_FORMAT:
7816 sal_Int16 nLineEndType = css::awt::LineEndFormat::LINE_FEED;
7817 switch ( meLineEndType )
7819 case LINEEND_CR: nLineEndType = css::awt::LineEndFormat::CARRIAGE_RETURN; break;
7820 case LINEEND_LF: nLineEndType = css::awt::LineEndFormat::LINE_FEED; break;
7821 case LINEEND_CRLF: nLineEndType = css::awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED; break;
7822 default: OSL_FAIL( "VCLXMultiLineEdit::getProperty: invalid line end value!" ); break;
7824 aProp <<= nLineEndType;
7826 break;
7828 case BASEPROPERTY_READONLY:
7830 aProp <<= pMultiLineEdit->IsReadOnly();
7832 break;
7833 case BASEPROPERTY_MAXTEXTLEN:
7835 aProp <<= static_cast<sal_Int16>(pMultiLineEdit->GetMaxTextLen());
7837 break;
7838 default:
7840 aProp = VCLXWindow::getProperty( PropertyName );
7844 return aProp;
7847 void SAL_CALL VCLXMultiLineEdit::setFocus( )
7849 SolarMutexGuard aGuard;
7851 // don't grab the focus if we already have it. Reason is that the only thing which the edit
7852 // does is forwarding the focus to its text window. This text window then does a "select all".
7853 // So if the text window already has the focus, and we give the focus to the multi line
7854 // edit, then all which happens is that everything is selected.
7855 // #i27072#
7856 if ( GetWindow() && !GetWindow()->HasChildPathFocus() )
7857 GetWindow()->GrabFocus();
7860 void VCLXMultiLineEdit::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
7862 PushPropertyIds( rIds,
7863 // FIXME: elide duplication ?
7864 BASEPROPERTY_LINE_END_FORMAT,
7865 BASEPROPERTY_READONLY,
7866 BASEPROPERTY_MAXTEXTLEN,
7867 BASEPROPERTY_HIDEINACTIVESELECTION,
7869 VCLXWindow::ImplGetPropertyIds( rIds, true );
7872 css::uno::Reference<css::accessibility::XAccessibleContext> VCLXMultiLineEdit::CreateAccessibleContext()
7874 return getAccessibleFactory().createAccessibleContext(this);
7877 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */