tdf#154285 Check upper bound of arguments in SbRtl_Minute function
[LibreOffice.git] / toolkit / source / awt / vclxwindows.cxx
blobfb58403e9ef5a73bf49a00d9afd566b99f381c79
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 <com/sun/star/awt/LineEndFormat.hpp>
22 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
23 #include <com/sun/star/graphic/GraphicProvider.hpp>
24 #include <com/sun/star/graphic/XGraphicProvider.hpp>
25 #include <toolkit/helper/vclunohelper.hxx>
26 #include <helper/property.hxx>
27 #include <com/sun/star/awt/VisualEffect.hpp>
28 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
29 #include <com/sun/star/resource/XStringResourceResolver.hpp>
30 #include <com/sun/star/awt/ImageScaleMode.hpp>
31 #include <com/sun/star/awt/XItemList.hpp>
32 #include <com/sun/star/awt/TextAlign.hpp>
33 #include <comphelper/namedvaluecollection.hxx>
34 #include <comphelper/processfactory.hxx>
35 #include <sal/log.hxx>
37 #include <awt/vclxwindows.hxx>
38 #include <controls/filectrl.hxx>
39 #include <controls/svmedit.hxx>
40 #include <vcl/accessiblefactory.hxx>
41 #include <vcl/toolkit/button.hxx>
42 #include <vcl/toolkit/fmtfield.hxx>
43 #include <vcl/graph.hxx>
44 #include <vcl/headbar.hxx>
45 #include <vcl/toolbox.hxx>
46 #include <vcl/toolkit/lstbox.hxx>
47 #include <vcl/toolkit/combobox.hxx>
48 #include <vcl/toolkit/field.hxx>
49 #include <vcl/toolkit/fixedhyper.hxx>
50 #include <vcl/toolkit/imgctrl.hxx>
51 #include <vcl/toolkit/dialog.hxx>
52 #include <vcl/toolkit/prgsbar.hxx>
53 #include <vcl/toolkit/scrbar.hxx>
54 #include <vcl/svapp.hxx>
55 #include <vcl/tabpage.hxx>
56 #include <vcl/tabctrl.hxx>
57 #include <vcl/unohelp.hxx>
58 #include <vcl/settings.hxx>
59 #include <comphelper/diagnose_ex.hxx>
60 #include <tools/debug.hxx>
62 #include <helper/imagealign.hxx>
63 #include <helper/msgbox.hxx>
64 #include <helper/tkresmgr.hxx>
65 #include "vclxwindows_internal.hxx"
66 #include <svl/numformat.hxx>
68 using ::com::sun::star::uno::Any;
69 using ::com::sun::star::uno::Reference;
70 using ::com::sun::star::uno::RuntimeException;
71 using ::com::sun::star::lang::EventObject;
72 using ::com::sun::star::awt::ItemListEvent;
73 using ::com::sun::star::awt::XItemList;
74 using ::com::sun::star::graphic::XGraphic;
75 using ::com::sun::star::graphic::XGraphicProvider;
77 using namespace ::com::sun::star;
78 using namespace ::com::sun::star::awt::VisualEffect;
79 namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode;
81 static double ImplCalcLongValue( double nValue, sal_uInt16 nDigits )
83 double n = nValue;
84 for ( sal_uInt16 d = 0; d < nDigits; d++ )
85 n *= 10;
86 return n;
89 static double ImplCalcDoubleValue( double nValue, sal_uInt16 nDigits )
91 double n = nValue;
92 for ( sal_uInt16 d = 0; d < nDigits; d++ )
93 n /= 10;
94 return n;
97 namespace toolkit
99 /** sets the "face color" for button like controls (scroll bar, spin button)
101 void setButtonLikeFaceColor( vcl::Window* _pWindow, const css::uno::Any& _rColorValue )
103 AllSettings aSettings = _pWindow->GetSettings();
104 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
106 if ( !_rColorValue.hasValue() )
108 const StyleSettings& aAppStyle = Application::GetSettings().GetStyleSettings();
109 aStyleSettings.SetFaceColor( aAppStyle.GetFaceColor( ) );
110 aStyleSettings.SetCheckedColor( aAppStyle.GetCheckedColor( ) );
111 aStyleSettings.SetLightBorderColor( aAppStyle.GetLightBorderColor() );
112 aStyleSettings.SetLightColor( aAppStyle.GetLightColor() );
113 aStyleSettings.SetShadowColor( aAppStyle.GetShadowColor() );
114 aStyleSettings.SetDarkShadowColor( aAppStyle.GetDarkShadowColor() );
116 else
118 Color nBackgroundColor;
119 _rColorValue >>= nBackgroundColor;
120 aStyleSettings.SetFaceColor( nBackgroundColor );
122 // for the real background (everything except the buttons and the thumb),
123 // use an average between the desired color and "white"
124 Color aWhite( COL_WHITE );
125 Color aCheckedBackground( nBackgroundColor );
126 aCheckedBackground.SetRed( ( aCheckedBackground.GetRed() + aWhite.GetRed() ) / 2 );
127 aCheckedBackground.SetGreen( ( aCheckedBackground.GetGreen() + aWhite.GetGreen() ) / 2 );
128 aCheckedBackground.SetBlue( ( aCheckedBackground.GetBlue() + aWhite.GetBlue() ) / 2 );
129 aStyleSettings.SetCheckedColor( aCheckedBackground );
131 sal_Int32 nBackgroundLuminance = nBackgroundColor.GetLuminance();
132 sal_Int32 nWhiteLuminance = COL_WHITE.GetLuminance();
134 Color aLightShadow( nBackgroundColor );
135 aLightShadow.IncreaseLuminance( static_cast<sal_uInt8>( ( nWhiteLuminance - nBackgroundLuminance ) * 2 / 3 ) );
136 aStyleSettings.SetLightBorderColor( aLightShadow );
138 Color aLight( nBackgroundColor );
139 aLight.IncreaseLuminance( static_cast<sal_uInt8>( ( nWhiteLuminance - nBackgroundLuminance ) * 1 / 3 ) );
140 aStyleSettings.SetLightColor( aLight );
142 Color aShadow( nBackgroundColor );
143 aShadow.DecreaseLuminance( static_cast<sal_uInt8>( nBackgroundLuminance * 1 / 3 ) );
144 aStyleSettings.SetShadowColor( aShadow );
146 Color aDarkShadow( nBackgroundColor );
147 aDarkShadow.DecreaseLuminance( static_cast<sal_uInt8>( nBackgroundLuminance * 2 / 3 ) );
148 aStyleSettings.SetDarkShadowColor( aDarkShadow );
151 aSettings.SetStyleSettings( aStyleSettings );
152 _pWindow->SetSettings( aSettings, true );
155 Any getButtonLikeFaceColor( const vcl::Window* _pWindow )
157 Color nBackgroundColor = _pWindow->GetSettings().GetStyleSettings().GetFaceColor();
158 return Any( sal_Int32(nBackgroundColor) );
161 static void adjustBooleanWindowStyle( const Any& _rValue, vcl::Window* _pWindow, WinBits _nBits, bool _bInverseSemantics )
163 WinBits nStyle = _pWindow->GetStyle();
164 bool bValue( false );
165 OSL_VERIFY( _rValue >>= bValue );
166 if ( bValue != _bInverseSemantics )
167 nStyle |= _nBits;
168 else
169 nStyle &= ~_nBits;
170 _pWindow->SetStyle( nStyle );
173 static void setVisualEffect( const Any& _rValue, vcl::Window* _pWindow )
175 AllSettings aSettings = _pWindow->GetSettings();
176 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
178 sal_Int16 nStyle = LOOK3D;
179 OSL_VERIFY( _rValue >>= nStyle );
180 switch ( nStyle )
182 case FLAT:
183 aStyleSettings.SetOptions( aStyleSettings.GetOptions() | StyleSettingsOptions::Mono );
184 break;
185 case LOOK3D:
186 default:
187 aStyleSettings.SetOptions( aStyleSettings.GetOptions() & ~StyleSettingsOptions::Mono );
189 aSettings.SetStyleSettings( aStyleSettings );
190 _pWindow->SetSettings( aSettings );
193 static Any getVisualEffect( vcl::Window const * _pWindow )
195 Any aEffect;
197 StyleSettings aStyleSettings = _pWindow->GetSettings().GetStyleSettings();
198 if ( aStyleSettings.GetOptions() & StyleSettingsOptions::Mono )
199 aEffect <<= sal_Int16(FLAT);
200 else
201 aEffect <<= sal_Int16(LOOK3D);
202 return aEffect;
209 void VCLXGraphicControl::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
211 PushPropertyIds(rIds, BASEPROPERTY_REFERER, 0);
212 VCLXWindow::ImplGetPropertyIds( rIds );
215 void VCLXGraphicControl::ImplSetNewImage()
217 OSL_PRECOND( GetWindow(), "VCLXGraphicControl::ImplSetNewImage: window is required to be not-NULL!" );
218 VclPtr< Button > pButton = GetAsDynamic< Button >();
219 pButton->SetModeImage( GetImage() );
222 void VCLXGraphicControl::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags )
224 SolarMutexGuard aGuard;
226 if ( GetWindow() )
228 Size aOldSize = GetWindow()->GetSizePixel();
229 VCLXWindow::setPosSize( X, Y, Width, Height, Flags );
230 if ( ( aOldSize.Width() != Width ) || ( aOldSize.Height() != Height ) )
231 ImplSetNewImage();
235 void VCLXGraphicControl::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
237 SolarMutexGuard aGuard;
239 if ( !GetWindow() )
240 return;
242 sal_uInt16 nPropType = GetPropertyId( PropertyName );
243 switch ( nPropType )
245 case BASEPROPERTY_GRAPHIC:
247 Reference< XGraphic > xGraphic;
248 OSL_VERIFY( Value >>= xGraphic );
249 maImage = Image( xGraphic );
250 ImplSetNewImage();
252 break;
254 case BASEPROPERTY_IMAGEALIGN:
256 WindowType eType = GetWindow()->GetType();
257 if ( ( eType == WindowType::PUSHBUTTON )
258 || ( eType == WindowType::RADIOBUTTON )
259 || ( eType == WindowType::CHECKBOX )
262 sal_Int16 nAlignment = sal_Int16();
263 if ( Value >>= nAlignment )
264 GetAs< Button >()->SetImageAlign( static_cast< ImageAlign >( nAlignment ) );
267 break;
268 case BASEPROPERTY_IMAGEPOSITION:
270 WindowType eType = GetWindow()->GetType();
271 if ( ( eType == WindowType::PUSHBUTTON )
272 || ( eType == WindowType::RADIOBUTTON )
273 || ( eType == WindowType::CHECKBOX )
276 sal_Int16 nImagePosition = 2;
277 OSL_VERIFY( Value >>= nImagePosition );
278 GetAs<Button>()->SetImageAlign( ::toolkit::translateImagePosition( nImagePosition ) );
281 break;
282 default:
283 VCLXWindow::setProperty( PropertyName, Value );
284 break;
288 css::uno::Any VCLXGraphicControl::getProperty( const OUString& PropertyName )
290 SolarMutexGuard aGuard;
292 css::uno::Any aProp;
293 if ( !GetWindow() )
294 return aProp;
296 sal_uInt16 nPropType = GetPropertyId( PropertyName );
297 switch ( nPropType )
299 case BASEPROPERTY_GRAPHIC:
300 aProp <<= Graphic(maImage.GetBitmapEx()).GetXGraphic();
301 break;
302 case BASEPROPERTY_IMAGEALIGN:
304 WindowType eType = GetWindow()->GetType();
305 if ( ( eType == WindowType::PUSHBUTTON )
306 || ( eType == WindowType::RADIOBUTTON )
307 || ( eType == WindowType::CHECKBOX )
310 aProp <<= ::toolkit::getCompatibleImageAlign(
311 GetAs<Button>()->GetImageAlign() );
314 break;
315 case BASEPROPERTY_IMAGEPOSITION:
317 WindowType eType = GetWindow()->GetType();
318 if ( ( eType == WindowType::PUSHBUTTON )
319 || ( eType == WindowType::RADIOBUTTON )
320 || ( eType == WindowType::CHECKBOX )
323 aProp <<= ::toolkit::translateImagePosition(
324 GetAs< Button >()->GetImageAlign() );
327 break;
328 default:
330 aProp = VCLXWindow::getProperty( PropertyName );
332 break;
334 return aProp;
340 void VCLXButton::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
342 PushPropertyIds( rIds,
343 BASEPROPERTY_BACKGROUNDCOLOR,
344 BASEPROPERTY_DEFAULTBUTTON,
345 BASEPROPERTY_DEFAULTCONTROL,
346 BASEPROPERTY_ENABLED,
347 BASEPROPERTY_ENABLEVISIBLE,
348 BASEPROPERTY_FONTDESCRIPTOR,
349 BASEPROPERTY_GRAPHIC,
350 BASEPROPERTY_HELPTEXT,
351 BASEPROPERTY_HELPURL,
352 BASEPROPERTY_IMAGEALIGN,
353 BASEPROPERTY_IMAGEPOSITION,
354 BASEPROPERTY_IMAGEURL,
355 BASEPROPERTY_LABEL,
356 BASEPROPERTY_PRINTABLE,
357 BASEPROPERTY_PUSHBUTTONTYPE,
358 BASEPROPERTY_REPEAT,
359 BASEPROPERTY_REPEAT_DELAY,
360 BASEPROPERTY_STATE,
361 BASEPROPERTY_TABSTOP,
362 BASEPROPERTY_TOGGLE,
363 BASEPROPERTY_FOCUSONCLICK,
364 BASEPROPERTY_MULTILINE,
365 BASEPROPERTY_ALIGN,
366 BASEPROPERTY_VERTICALALIGN,
367 BASEPROPERTY_WRITING_MODE,
368 BASEPROPERTY_CONTEXT_WRITING_MODE,
369 BASEPROPERTY_REFERENCE_DEVICE,
371 VCLXGraphicControl::ImplGetPropertyIds( rIds );
374 VCLXButton::VCLXButton()
375 :maActionListeners( *this )
376 ,maItemListeners( *this )
380 VCLXButton::~VCLXButton()
384 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXButton::CreateAccessibleContext()
386 VclPtr<PushButton> pButton = GetAs<PushButton>();
387 return AccessibleFactory::createAccessibleContext(pButton);
390 void VCLXButton::dispose()
392 SolarMutexGuard aGuard;
394 css::lang::EventObject aObj;
395 aObj.Source = getXWeak();
396 maActionListeners.disposeAndClear( aObj );
397 maItemListeners.disposeAndClear( aObj );
398 VCLXGraphicControl::dispose();
401 void VCLXButton::addActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
403 SolarMutexGuard aGuard;
404 maActionListeners.addInterface( l );
407 void VCLXButton::removeActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
409 SolarMutexGuard aGuard;
410 maActionListeners.removeInterface( l );
413 void VCLXButton::addItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
415 SolarMutexGuard aGuard;
416 maItemListeners.addInterface( l );
419 void VCLXButton::removeItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
421 SolarMutexGuard aGuard;
422 maItemListeners.removeInterface( l );
425 void VCLXButton::setLabel( const OUString& rLabel )
427 SolarMutexGuard aGuard;
429 VclPtr<vcl::Window> pWindow = GetWindow();
430 if ( pWindow )
431 pWindow->SetText( rLabel );
434 void VCLXButton::setActionCommand( const OUString& rCommand )
436 SolarMutexGuard aGuard;
438 maActionCommand = rCommand;
441 css::awt::Size VCLXButton::getMinimumSize( )
443 SolarMutexGuard aGuard;
445 Size aSz;
446 VclPtr< PushButton > pButton = GetAs< PushButton >();
447 if ( pButton )
448 aSz = pButton->CalcMinimumSize();
449 return vcl::unohelper::ConvertToAWTSize(aSz);
452 css::awt::Size VCLXButton::getPreferredSize( )
454 css::awt::Size aSz = getMinimumSize();
455 aSz.Width += 16;
456 aSz.Height += 10;
457 return aSz;
460 css::awt::Size VCLXButton::calcAdjustedSize( const css::awt::Size& rNewSize )
462 SolarMutexGuard aGuard;
464 Size aSz = vcl::unohelper::ConvertToVCLSize(rNewSize);
465 VclPtr< PushButton > pButton = GetAs< PushButton >();
466 if ( pButton )
468 Size aMinSz = pButton->CalcMinimumSize();
469 // no text, thus image
470 if ( pButton->GetText().isEmpty() )
472 if ( aSz.Width() < aMinSz.Width() )
473 aSz.setWidth( aMinSz.Width() );
474 if ( aSz.Height() < aMinSz.Height() )
475 aSz.setHeight( aMinSz.Height() );
477 else
479 if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
480 aSz.setHeight( aMinSz.Height() );
481 else
482 aSz = aMinSz;
485 return vcl::unohelper::ConvertToAWTSize(aSz);
488 void VCLXButton::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
490 SolarMutexGuard aGuard;
492 VclPtr< Button > pButton = GetAs< Button >();
493 if ( !pButton )
494 return;
496 sal_uInt16 nPropType = GetPropertyId( PropertyName );
497 switch ( nPropType )
499 case BASEPROPERTY_FOCUSONCLICK:
500 ::toolkit::adjustBooleanWindowStyle( Value, pButton, WB_NOPOINTERFOCUS, true );
501 break;
503 case BASEPROPERTY_TOGGLE:
504 ::toolkit::adjustBooleanWindowStyle( Value, pButton, WB_TOGGLE, false );
505 break;
507 case BASEPROPERTY_DEFAULTBUTTON:
509 WinBits nStyle = pButton->GetStyle() | WB_DEFBUTTON;
510 bool b = bool();
511 if ( ( Value >>= b ) && !b )
512 nStyle &= ~WB_DEFBUTTON;
513 pButton->SetStyle( nStyle );
515 break;
516 case BASEPROPERTY_STATE:
518 if ( GetWindow()->GetType() == WindowType::PUSHBUTTON )
520 sal_Int16 n = sal_Int16();
521 if ( Value >>= n )
522 static_cast<PushButton*>(pButton.get())->SetState( static_cast<TriState>(n) );
525 break;
526 default:
528 VCLXGraphicControl::setProperty( PropertyName, Value );
533 css::uno::Any VCLXButton::getProperty( const OUString& PropertyName )
535 SolarMutexGuard aGuard;
537 css::uno::Any aProp;
538 VclPtr< Button > pButton = GetAs< Button >();
539 if ( pButton )
541 sal_uInt16 nPropType = GetPropertyId( PropertyName );
542 switch ( nPropType )
544 case BASEPROPERTY_FOCUSONCLICK:
545 aProp <<= ( ( pButton->GetStyle() & WB_NOPOINTERFOCUS ) == 0 );
546 break;
548 case BASEPROPERTY_TOGGLE:
549 aProp <<= ( ( pButton->GetStyle() & WB_TOGGLE ) != 0 );
550 break;
552 case BASEPROPERTY_DEFAULTBUTTON:
554 aProp <<= ( pButton->GetStyle() & WB_DEFBUTTON ) != 0;
556 break;
557 case BASEPROPERTY_STATE:
559 if ( GetWindow()->GetType() == WindowType::PUSHBUTTON )
561 aProp <<= static_cast<sal_Int16>(static_cast<PushButton*>(pButton.get())->GetState());
564 break;
565 default:
567 aProp = VCLXGraphicControl::getProperty( PropertyName );
571 return aProp;
574 void VCLXButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
576 switch ( rVclWindowEvent.GetId() )
578 case VclEventId::ButtonClick:
580 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
581 // since we call listeners below, there is a potential that we will be destroyed
582 // during the listener call. To prevent the resulting crashes, we keep us
583 // alive as long as we're here
585 if ( maActionListeners.getLength() )
587 css::awt::ActionEvent aEvent;
588 aEvent.Source = getXWeak();
589 aEvent.ActionCommand = maActionCommand;
591 Callback aCallback = [ this, aEvent=std::move(aEvent) ]()
592 { this->maActionListeners.actionPerformed( aEvent ); };
594 ImplExecuteAsyncWithoutSolarLock( aCallback );
597 break;
599 case VclEventId::PushbuttonToggle:
601 PushButton& rButton = dynamic_cast< PushButton& >( *rVclWindowEvent.GetWindow() );
603 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
604 if ( maItemListeners.getLength() )
606 css::awt::ItemEvent aEvent;
607 aEvent.Source = getXWeak();
608 aEvent.Selected = ( rButton.GetState() == TRISTATE_TRUE ) ? 1 : 0;
609 maItemListeners.itemStateChanged( aEvent );
612 break;
614 default:
615 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent );
616 break;
623 void VCLXImageControl::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
625 PushPropertyIds( rIds,
626 BASEPROPERTY_BACKGROUNDCOLOR,
627 BASEPROPERTY_BORDER,
628 BASEPROPERTY_BORDERCOLOR,
629 BASEPROPERTY_DEFAULTCONTROL,
630 BASEPROPERTY_ENABLED,
631 BASEPROPERTY_ENABLEVISIBLE,
632 BASEPROPERTY_GRAPHIC,
633 BASEPROPERTY_HELPTEXT,
634 BASEPROPERTY_HELPURL,
635 BASEPROPERTY_IMAGEURL,
636 BASEPROPERTY_PRINTABLE,
637 BASEPROPERTY_SCALEIMAGE,
638 BASEPROPERTY_IMAGE_SCALE_MODE,
639 BASEPROPERTY_TABSTOP,
640 BASEPROPERTY_WRITING_MODE,
641 BASEPROPERTY_CONTEXT_WRITING_MODE,
643 VCLXGraphicControl::ImplGetPropertyIds( rIds );
646 VCLXImageControl::VCLXImageControl()
650 VCLXImageControl::~VCLXImageControl()
654 void VCLXImageControl::ImplSetNewImage()
656 OSL_PRECOND( GetWindow(), "VCLXImageControl::ImplSetNewImage: window is required to be not-NULL!" );
657 VclPtr<ImageControl> pControl = GetAs< ImageControl >();
658 pControl->SetImage( GetImage() );
661 css::awt::Size VCLXImageControl::getMinimumSize( )
663 SolarMutexGuard aGuard;
665 Size aSz = GetImage().GetSizePixel();
666 aSz = ImplCalcWindowSize( aSz );
668 return vcl::unohelper::ConvertToAWTSize(aSz);
671 css::awt::Size VCLXImageControl::getPreferredSize( )
673 return getMinimumSize();
676 css::awt::Size VCLXImageControl::calcAdjustedSize( const css::awt::Size& rNewSize )
678 SolarMutexGuard aGuard;
680 css::awt::Size aSz = rNewSize;
681 css::awt::Size aMinSz = getMinimumSize();
682 if ( aSz.Width < aMinSz.Width )
683 aSz.Width = aMinSz.Width;
684 if ( aSz.Height < aMinSz.Height )
685 aSz.Height = aMinSz.Height;
686 return aSz;
689 void VCLXImageControl::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
691 SolarMutexGuard aGuard;
693 VclPtr< ImageControl > pImageControl = GetAs< ImageControl >();
695 sal_uInt16 nPropType = GetPropertyId( PropertyName );
696 switch ( nPropType )
698 case BASEPROPERTY_IMAGE_SCALE_MODE:
700 sal_Int16 nScaleMode( ImageScaleMode::ANISOTROPIC );
701 if ( pImageControl && ( Value >>= nScaleMode ) )
703 pImageControl->SetScaleMode( nScaleMode );
706 break;
708 case BASEPROPERTY_SCALEIMAGE:
710 // this is for compatibility only, nowadays, the ImageScaleMode property should be used
711 bool bScaleImage = false;
712 if ( pImageControl && ( Value >>= bScaleImage ) )
714 pImageControl->SetScaleMode( bScaleImage ? ImageScaleMode::ANISOTROPIC : ImageScaleMode::NONE );
717 break;
719 default:
720 VCLXGraphicControl::setProperty( PropertyName, Value );
721 break;
725 css::uno::Any VCLXImageControl::getProperty( const OUString& PropertyName )
727 SolarMutexGuard aGuard;
729 css::uno::Any aProp;
730 VclPtr< ImageControl > pImageControl = GetAs< ImageControl >();
731 sal_uInt16 nPropType = GetPropertyId( PropertyName );
733 switch ( nPropType )
735 case BASEPROPERTY_IMAGE_SCALE_MODE:
736 aProp <<= ( pImageControl ? pImageControl->GetScaleMode() : ImageScaleMode::ANISOTROPIC );
737 break;
739 case BASEPROPERTY_SCALEIMAGE:
740 aProp <<= ( pImageControl && pImageControl->GetScaleMode() != ImageScaleMode::NONE );
741 break;
743 default:
744 aProp = VCLXGraphicControl::getProperty( PropertyName );
745 break;
747 return aProp;
753 void VCLXCheckBox::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
755 PushPropertyIds( rIds,
756 BASEPROPERTY_DEFAULTCONTROL,
757 BASEPROPERTY_ENABLED,
758 BASEPROPERTY_ENABLEVISIBLE,
759 BASEPROPERTY_FONTDESCRIPTOR,
760 BASEPROPERTY_GRAPHIC,
761 BASEPROPERTY_HELPTEXT,
762 BASEPROPERTY_HELPURL,
763 BASEPROPERTY_IMAGEPOSITION,
764 BASEPROPERTY_IMAGEURL,
765 BASEPROPERTY_LABEL,
766 BASEPROPERTY_PRINTABLE,
767 BASEPROPERTY_STATE,
768 BASEPROPERTY_TABSTOP,
769 BASEPROPERTY_TRISTATE,
770 BASEPROPERTY_VISUALEFFECT,
771 BASEPROPERTY_MULTILINE,
772 BASEPROPERTY_BACKGROUNDCOLOR,
773 BASEPROPERTY_ALIGN,
774 BASEPROPERTY_VERTICALALIGN,
775 BASEPROPERTY_WRITING_MODE,
776 BASEPROPERTY_CONTEXT_WRITING_MODE,
777 BASEPROPERTY_REFERENCE_DEVICE,
779 VCLXGraphicControl::ImplGetPropertyIds( rIds );
782 VCLXCheckBox::VCLXCheckBox() : maActionListeners( *this ), maItemListeners( *this )
786 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXCheckBox::CreateAccessibleContext()
788 VclPtr<CheckBox> pCheckBox = GetAs<CheckBox>();
789 return AccessibleFactory::createAccessibleContext(pCheckBox);
792 void VCLXCheckBox::dispose()
794 SolarMutexGuard aGuard;
796 css::lang::EventObject aObj;
797 aObj.Source = getXWeak();
798 maItemListeners.disposeAndClear( aObj );
799 VCLXGraphicControl::dispose();
802 void VCLXCheckBox::addItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
804 SolarMutexGuard aGuard;
805 maItemListeners.addInterface( l );
808 void VCLXCheckBox::removeItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
810 SolarMutexGuard aGuard;
811 maItemListeners.removeInterface( l );
814 void VCLXCheckBox::addActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
816 SolarMutexGuard aGuard;
817 maActionListeners.addInterface( l );
820 void VCLXCheckBox::removeActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
822 SolarMutexGuard aGuard;
823 maActionListeners.removeInterface( l );
826 void VCLXCheckBox::setActionCommand( const OUString& rCommand )
828 SolarMutexGuard aGuard;
829 maActionCommand = rCommand;
832 void VCLXCheckBox::setLabel( const OUString& rLabel )
834 SolarMutexGuard aGuard;
836 VclPtr<vcl::Window> pWindow = GetWindow();
837 if ( pWindow )
838 pWindow->SetText( rLabel );
841 void VCLXCheckBox::setState( sal_Int16 n )
843 SolarMutexGuard aGuard;
845 VclPtr< CheckBox> pCheckBox = GetAs< CheckBox >();
846 if ( !pCheckBox)
847 return;
849 TriState eState;
850 switch ( n )
852 case 0: eState = TRISTATE_FALSE; break;
853 case 1: eState = TRISTATE_TRUE; break;
854 case 2: eState = TRISTATE_INDET; break;
855 default: eState = TRISTATE_FALSE;
857 pCheckBox->SetState( eState );
859 // #105198# call C++ click listeners (needed for accessibility)
860 // pCheckBox->GetClickHdl().Call( pCheckBox );
862 // #107218# Call same virtual methods and listeners like VCL would do after user interaction
863 SetSynthesizingVCLEvent( true );
864 pCheckBox->Toggle();
865 pCheckBox->Click();
866 SetSynthesizingVCLEvent( false );
869 sal_Int16 VCLXCheckBox::getState()
871 SolarMutexGuard aGuard;
873 sal_Int16 nState = -1;
874 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
875 if ( pCheckBox )
877 switch ( pCheckBox->GetState() )
879 case TRISTATE_FALSE: nState = 0; break;
880 case TRISTATE_TRUE: nState = 1; break;
881 case TRISTATE_INDET: nState = 2; break;
882 default: OSL_FAIL( "VCLXCheckBox::getState(): unknown TriState!" );
886 return nState;
889 void VCLXCheckBox::enableTriState( sal_Bool b )
891 SolarMutexGuard aGuard;
893 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
894 if ( pCheckBox)
895 pCheckBox->EnableTriState( b );
898 css::awt::Size VCLXCheckBox::getMinimumSize()
900 SolarMutexGuard aGuard;
902 Size aSz;
903 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
904 if ( pCheckBox )
905 aSz = pCheckBox->CalcMinimumSize();
906 return vcl::unohelper::ConvertToAWTSize(aSz);
909 css::awt::Size VCLXCheckBox::getPreferredSize()
911 return getMinimumSize();
914 css::awt::Size VCLXCheckBox::calcAdjustedSize( const css::awt::Size& rNewSize )
916 SolarMutexGuard aGuard;
918 Size aSz = vcl::unohelper::ConvertToVCLSize(rNewSize);
919 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
920 if ( pCheckBox )
922 Size aMinSz = pCheckBox->CalcMinimumSize(rNewSize.Width);
923 if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
924 aSz.setHeight( aMinSz.Height() );
925 else
926 aSz = aMinSz;
928 return vcl::unohelper::ConvertToAWTSize(aSz);
931 void VCLXCheckBox::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
933 SolarMutexGuard aGuard;
935 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
936 if ( !pCheckBox )
937 return;
939 sal_uInt16 nPropType = GetPropertyId( PropertyName );
940 switch ( nPropType )
942 case BASEPROPERTY_VISUALEFFECT:
943 ::toolkit::setVisualEffect( Value, pCheckBox );
944 break;
946 case BASEPROPERTY_TRISTATE:
948 bool b = bool();
949 if ( Value >>= b )
950 pCheckBox->EnableTriState( b );
952 break;
953 case BASEPROPERTY_STATE:
955 sal_Int16 n = sal_Int16();
956 if ( Value >>= n )
957 setState( n );
959 break;
960 default:
962 VCLXGraphicControl::setProperty( PropertyName, Value );
967 css::uno::Any VCLXCheckBox::getProperty( const OUString& PropertyName )
969 SolarMutexGuard aGuard;
971 css::uno::Any aProp;
972 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
973 if ( pCheckBox )
975 sal_uInt16 nPropType = GetPropertyId( PropertyName );
976 switch ( nPropType )
978 case BASEPROPERTY_VISUALEFFECT:
979 aProp = ::toolkit::getVisualEffect( pCheckBox );
980 break;
981 case BASEPROPERTY_TRISTATE:
982 aProp <<= pCheckBox->IsTriStateEnabled();
983 break;
984 case BASEPROPERTY_STATE:
985 aProp <<= static_cast<sal_Int16>(pCheckBox->GetState());
986 break;
987 default:
989 aProp = VCLXGraphicControl::getProperty( PropertyName );
993 return aProp;
996 void VCLXCheckBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
998 switch ( rVclWindowEvent.GetId() )
1000 case VclEventId::CheckboxToggle:
1002 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
1003 // since we call listeners below, there is a potential that we will be destroyed
1004 // in during the listener call. To prevent the resulting crashes, we keep us
1005 // alive as long as we're here
1007 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
1008 if ( pCheckBox )
1010 if ( maItemListeners.getLength() )
1012 css::awt::ItemEvent aEvent;
1013 aEvent.Source = getXWeak();
1014 aEvent.Highlighted = 0;
1015 aEvent.Selected = pCheckBox->GetState();
1016 maItemListeners.itemStateChanged( aEvent );
1018 if ( !IsSynthesizingVCLEvent() && maActionListeners.getLength() )
1020 css::awt::ActionEvent aEvent;
1021 aEvent.Source = getXWeak();
1022 aEvent.ActionCommand = maActionCommand;
1023 maActionListeners.actionPerformed( aEvent );
1027 break;
1029 default:
1030 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent );
1031 break;
1037 void VCLXRadioButton::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
1039 PushPropertyIds( rIds,
1040 BASEPROPERTY_DEFAULTCONTROL,
1041 BASEPROPERTY_ENABLED,
1042 BASEPROPERTY_ENABLEVISIBLE,
1043 BASEPROPERTY_FONTDESCRIPTOR,
1044 BASEPROPERTY_GRAPHIC,
1045 BASEPROPERTY_HELPTEXT,
1046 BASEPROPERTY_HELPURL,
1047 BASEPROPERTY_IMAGEPOSITION,
1048 BASEPROPERTY_IMAGEURL,
1049 BASEPROPERTY_LABEL,
1050 BASEPROPERTY_PRINTABLE,
1051 BASEPROPERTY_STATE,
1052 BASEPROPERTY_TABSTOP,
1053 BASEPROPERTY_VISUALEFFECT,
1054 BASEPROPERTY_MULTILINE,
1055 BASEPROPERTY_BACKGROUNDCOLOR,
1056 BASEPROPERTY_ALIGN,
1057 BASEPROPERTY_VERTICALALIGN,
1058 BASEPROPERTY_WRITING_MODE,
1059 BASEPROPERTY_CONTEXT_WRITING_MODE,
1060 BASEPROPERTY_REFERENCE_DEVICE,
1061 BASEPROPERTY_GROUPNAME,
1063 VCLXGraphicControl::ImplGetPropertyIds( rIds );
1067 VCLXRadioButton::VCLXRadioButton() : maItemListeners( *this ), maActionListeners( *this )
1071 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXRadioButton::CreateAccessibleContext()
1073 VclPtr<RadioButton> pRadioButton = GetAs<RadioButton>();
1074 return AccessibleFactory::createAccessibleContext(pRadioButton);
1077 void VCLXRadioButton::dispose()
1079 SolarMutexGuard aGuard;
1081 css::lang::EventObject aObj;
1082 aObj.Source = getXWeak();
1083 maItemListeners.disposeAndClear( aObj );
1084 VCLXGraphicControl::dispose();
1087 void VCLXRadioButton::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
1089 SolarMutexGuard aGuard;
1091 VclPtr< RadioButton > pButton = GetAs< RadioButton >();
1092 if ( !pButton )
1093 return;
1095 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1096 switch ( nPropType )
1098 case BASEPROPERTY_VISUALEFFECT:
1099 ::toolkit::setVisualEffect( Value, pButton );
1100 break;
1102 case BASEPROPERTY_STATE:
1104 sal_Int16 n = sal_Int16();
1105 if ( Value >>= n )
1107 bool b = n != 0;
1108 if ( pButton->IsRadioCheckEnabled() )
1109 pButton->Check( b );
1110 else
1111 pButton->SetState( b );
1114 break;
1115 case BASEPROPERTY_AUTOTOGGLE:
1117 bool b = bool();
1118 if ( Value >>= b )
1119 pButton->EnableRadioCheck( b );
1121 break;
1122 default:
1124 VCLXGraphicControl::setProperty( PropertyName, Value );
1129 css::uno::Any VCLXRadioButton::getProperty( const OUString& PropertyName )
1131 SolarMutexGuard aGuard;
1133 css::uno::Any aProp;
1134 VclPtr< RadioButton > pButton = GetAs< RadioButton >();
1135 if ( pButton )
1137 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1138 switch ( nPropType )
1140 case BASEPROPERTY_VISUALEFFECT:
1141 aProp = ::toolkit::getVisualEffect( pButton );
1142 break;
1143 case BASEPROPERTY_STATE:
1144 aProp <<= static_cast<sal_Int16>( pButton->IsChecked() ? 1 : 0 );
1145 break;
1146 case BASEPROPERTY_AUTOTOGGLE:
1147 aProp <<= pButton->IsRadioCheckEnabled();
1148 break;
1149 default:
1151 aProp = VCLXGraphicControl::getProperty( PropertyName );
1155 return aProp;
1158 void VCLXRadioButton::addItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
1160 SolarMutexGuard aGuard;
1161 maItemListeners.addInterface( l );
1164 void VCLXRadioButton::removeItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
1166 SolarMutexGuard aGuard;
1167 maItemListeners.removeInterface( l );
1170 void VCLXRadioButton::addActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
1172 SolarMutexGuard aGuard;
1173 maActionListeners.addInterface( l );
1176 void VCLXRadioButton::removeActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
1178 SolarMutexGuard aGuard;
1179 maActionListeners.removeInterface( l );
1182 void VCLXRadioButton::setLabel( const OUString& rLabel )
1184 SolarMutexGuard aGuard;
1186 VclPtr<vcl::Window> pWindow = GetWindow();
1187 if ( pWindow )
1188 pWindow->SetText( rLabel );
1191 void VCLXRadioButton::setActionCommand( const OUString& rCommand )
1193 SolarMutexGuard aGuard;
1194 maActionCommand = rCommand;
1197 void VCLXRadioButton::setState( sal_Bool b )
1199 SolarMutexGuard aGuard;
1201 VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >();
1202 if ( pRadioButton)
1204 pRadioButton->Check( b );
1205 // #102717# item listeners are called, but not C++ click listeners in StarOffice code => call click hdl
1206 // But this is needed in old code because Accessibility API uses it.
1207 // pRadioButton->GetClickHdl().Call( pRadioButton );
1209 // #107218# Call same virtual methods and listeners like VCL would do after user interaction
1210 SetSynthesizingVCLEvent( true );
1211 pRadioButton->Click();
1212 SetSynthesizingVCLEvent( false );
1216 sal_Bool VCLXRadioButton::getState()
1218 SolarMutexGuard aGuard;
1220 VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >();
1221 return pRadioButton && pRadioButton->IsChecked();
1224 css::awt::Size VCLXRadioButton::getMinimumSize( )
1226 SolarMutexGuard aGuard;
1228 Size aSz;
1229 VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >();
1230 if ( pRadioButton )
1231 aSz = pRadioButton->CalcMinimumSize();
1232 return vcl::unohelper::ConvertToAWTSize(aSz);
1235 css::awt::Size VCLXRadioButton::getPreferredSize( )
1237 return getMinimumSize();
1240 css::awt::Size VCLXRadioButton::calcAdjustedSize( const css::awt::Size& rNewSize )
1242 SolarMutexGuard aGuard;
1244 Size aSz = vcl::unohelper::ConvertToVCLSize(rNewSize);
1245 VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >();
1246 if ( pRadioButton )
1248 Size aMinSz = pRadioButton->CalcMinimumSize(rNewSize.Width);
1249 if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
1250 aSz.setHeight( aMinSz.Height() );
1251 else
1252 aSz = aMinSz;
1254 return vcl::unohelper::ConvertToAWTSize(aSz);
1257 void VCLXRadioButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1259 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
1260 // since we call listeners below, there is a potential that we will be destroyed
1261 // in during the listener call. To prevent the resulting crashes, we keep us
1262 // alive as long as we're here
1264 switch ( rVclWindowEvent.GetId() )
1266 case VclEventId::ButtonClick:
1267 if ( !IsSynthesizingVCLEvent() && maActionListeners.getLength() )
1269 css::awt::ActionEvent aEvent;
1270 aEvent.Source = getXWeak();
1271 aEvent.ActionCommand = maActionCommand;
1272 maActionListeners.actionPerformed( aEvent );
1274 ImplClickedOrToggled( false );
1275 break;
1277 case VclEventId::RadiobuttonToggle:
1278 ImplClickedOrToggled( true );
1279 break;
1281 default:
1282 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent );
1283 break;
1287 void VCLXRadioButton::ImplClickedOrToggled( bool bToggled )
1289 // In the forms, RadioChecked is not enabled, call itemStateChanged only for click
1290 // In the dialog editor, RadioChecked is enabled, call itemStateChanged only for bToggled
1291 VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >();
1292 if ( pRadioButton && ( pRadioButton->IsRadioCheckEnabled() == bToggled ) && ( bToggled || pRadioButton->IsStateChanged() ) && maItemListeners.getLength() )
1294 css::awt::ItemEvent aEvent;
1295 aEvent.Source = getXWeak();
1296 aEvent.Highlighted = 0;
1297 aEvent.Selected = pRadioButton->IsChecked() ? 1 : 0;
1298 maItemListeners.itemStateChanged( aEvent );
1304 void VCLXSpinField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
1306 PushPropertyIds( rIds,
1307 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
1308 0 );
1309 VCLXEdit::ImplGetPropertyIds( rIds );
1312 VCLXSpinField::VCLXSpinField() : maSpinListeners( *this )
1316 void VCLXSpinField::addSpinListener( const css::uno::Reference< css::awt::XSpinListener > & l )
1318 SolarMutexGuard aGuard;
1319 maSpinListeners.addInterface( l );
1322 void VCLXSpinField::removeSpinListener( const css::uno::Reference< css::awt::XSpinListener > & l )
1324 SolarMutexGuard aGuard;
1325 maSpinListeners.removeInterface( l );
1328 void VCLXSpinField::up()
1330 SolarMutexGuard aGuard;
1332 VclPtr< SpinField > pSpinField = GetAs< SpinField >();
1333 if ( pSpinField )
1334 pSpinField->Up();
1337 void VCLXSpinField::down()
1339 SolarMutexGuard aGuard;
1341 VclPtr< SpinField > pSpinField = GetAs< SpinField >();
1342 if ( pSpinField )
1343 pSpinField->Down();
1346 void VCLXSpinField::first()
1348 SolarMutexGuard aGuard;
1350 VclPtr< SpinField > pSpinField = GetAs< SpinField >();
1351 if ( pSpinField )
1352 pSpinField->First();
1355 void VCLXSpinField::last()
1357 SolarMutexGuard aGuard;
1359 VclPtr< SpinField > pSpinField = GetAs< SpinField >();
1360 if ( pSpinField )
1361 pSpinField->Last();
1364 void VCLXSpinField::enableRepeat( sal_Bool bRepeat )
1366 SolarMutexGuard aGuard;
1368 VclPtr<vcl::Window> pWindow = GetWindow();
1369 if ( pWindow )
1371 WinBits nStyle = pWindow->GetStyle();
1372 if ( bRepeat )
1373 nStyle |= WB_REPEAT;
1374 else
1375 nStyle &= ~WB_REPEAT;
1376 pWindow->SetStyle( nStyle );
1380 void VCLXSpinField::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1382 switch ( rVclWindowEvent.GetId() )
1384 case VclEventId::SpinfieldUp:
1385 case VclEventId::SpinfieldDown:
1386 case VclEventId::SpinfieldFirst:
1387 case VclEventId::SpinfieldLast:
1389 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
1390 // since we call listeners below, there is a potential that we will be destroyed
1391 // in during the listener call. To prevent the resulting crashes, we keep us
1392 // alive as long as we're here
1394 if ( maSpinListeners.getLength() )
1396 css::awt::SpinEvent aEvent;
1397 aEvent.Source = getXWeak();
1398 switch ( rVclWindowEvent.GetId() )
1400 case VclEventId::SpinfieldUp: maSpinListeners.up( aEvent );
1401 break;
1402 case VclEventId::SpinfieldDown: maSpinListeners.down( aEvent );
1403 break;
1404 case VclEventId::SpinfieldFirst: maSpinListeners.first( aEvent );
1405 break;
1406 case VclEventId::SpinfieldLast: maSpinListeners.last( aEvent );
1407 break;
1408 default: break;
1413 break;
1415 default:
1416 VCLXEdit::ProcessWindowEvent( rVclWindowEvent );
1417 break;
1423 void VCLXListBox::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
1425 PushPropertyIds( rIds,
1426 BASEPROPERTY_BACKGROUNDCOLOR,
1427 BASEPROPERTY_BORDER,
1428 BASEPROPERTY_BORDERCOLOR,
1429 BASEPROPERTY_DEFAULTCONTROL,
1430 BASEPROPERTY_DROPDOWN,
1431 BASEPROPERTY_ENABLED,
1432 BASEPROPERTY_ENABLEVISIBLE,
1433 BASEPROPERTY_FONTDESCRIPTOR,
1434 BASEPROPERTY_HELPTEXT,
1435 BASEPROPERTY_HELPURL,
1436 BASEPROPERTY_LINECOUNT,
1437 BASEPROPERTY_MULTISELECTION,
1438 BASEPROPERTY_MULTISELECTION_SIMPLEMODE,
1439 BASEPROPERTY_ITEM_SEPARATOR_POS,
1440 BASEPROPERTY_PRINTABLE,
1441 BASEPROPERTY_SELECTEDITEMS,
1442 BASEPROPERTY_STRINGITEMLIST,
1443 BASEPROPERTY_TYPEDITEMLIST,
1444 BASEPROPERTY_TABSTOP,
1445 BASEPROPERTY_READONLY,
1446 BASEPROPERTY_ALIGN,
1447 BASEPROPERTY_WRITING_MODE,
1448 BASEPROPERTY_CONTEXT_WRITING_MODE,
1449 BASEPROPERTY_REFERENCE_DEVICE,
1450 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
1451 BASEPROPERTY_HIGHLIGHT_COLOR,
1452 BASEPROPERTY_HIGHLIGHT_TEXT_COLOR,
1454 VCLXWindow::ImplGetPropertyIds( rIds );
1458 VCLXListBox::VCLXListBox()
1459 : maActionListeners( *this ),
1460 maItemListeners( *this )
1464 void VCLXListBox::dispose()
1466 SolarMutexGuard aGuard;
1468 css::lang::EventObject aObj;
1469 aObj.Source = getXWeak();
1470 maItemListeners.disposeAndClear( aObj );
1471 maActionListeners.disposeAndClear( aObj );
1472 VCLXWindow::dispose();
1475 void VCLXListBox::addItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
1477 SolarMutexGuard aGuard;
1478 maItemListeners.addInterface( l );
1481 void VCLXListBox::removeItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
1483 SolarMutexGuard aGuard;
1484 maItemListeners.removeInterface( l );
1487 void VCLXListBox::addActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
1489 SolarMutexGuard aGuard;
1490 maActionListeners.addInterface( l );
1493 void VCLXListBox::removeActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
1495 SolarMutexGuard aGuard;
1496 maActionListeners.removeInterface( l );
1499 void VCLXListBox::addItem( const OUString& aItem, sal_Int16 nPos )
1501 SolarMutexGuard aGuard;
1502 VclPtr< ListBox > pBox = GetAs< ListBox >();
1503 if ( pBox )
1504 pBox->InsertEntry( aItem, nPos );
1507 void VCLXListBox::addItems( const css::uno::Sequence< OUString>& aItems, sal_Int16 nPos )
1509 SolarMutexGuard aGuard;
1510 VclPtr< ListBox > pBox = GetAs< ListBox >();
1511 if ( !pBox )
1512 return;
1514 sal_uInt16 nP = nPos;
1515 for ( auto const & item : aItems )
1517 if ( nP == 0xFFFF )
1519 OSL_FAIL( "VCLXListBox::addItems: too many entries!" );
1520 // skip remaining entries, list cannot hold them, anyway
1521 break;
1524 pBox->InsertEntry( item, nP++ );
1528 void VCLXListBox::removeItems( sal_Int16 nPos, sal_Int16 nCount )
1530 SolarMutexGuard aGuard;
1531 VclPtr< ListBox > pBox = GetAs< ListBox >();
1532 if ( pBox )
1534 for ( sal_Int16 n = nCount; n; )
1535 pBox->RemoveEntry( nPos + (--n) );
1539 sal_Int16 VCLXListBox::getItemCount()
1541 SolarMutexGuard aGuard;
1543 VclPtr< ListBox > pBox = GetAs< ListBox >();
1544 return pBox ? pBox->GetEntryCount() : 0;
1547 OUString VCLXListBox::getItem( sal_Int16 nPos )
1549 SolarMutexGuard aGuard;
1551 OUString aItem;
1552 VclPtr< ListBox > pBox = GetAs< ListBox >();
1553 if ( pBox )
1554 aItem = pBox->GetEntry( nPos );
1555 return aItem;
1558 css::uno::Sequence< OUString> VCLXListBox::getItems()
1560 SolarMutexGuard aGuard;
1562 css::uno::Sequence< OUString> aSeq;
1563 VclPtr< ListBox > pBox = GetAs< ListBox >();
1564 if ( pBox )
1566 auto n = pBox->GetEntryCount();
1567 aSeq = css::uno::Sequence< OUString>( n );
1568 while (n)
1570 --n;
1571 aSeq.getArray()[n] = pBox->GetEntry( n );
1574 return aSeq;
1577 sal_Int16 VCLXListBox::getSelectedItemPos()
1579 SolarMutexGuard aGuard;
1580 VclPtr< ListBox > pBox = GetAs< ListBox >();
1581 if (!pBox)
1582 return -1; // nothing selected
1583 sal_Int32 nPos = pBox->GetSelectedEntryPos();
1584 if (nPos == LISTBOX_ENTRY_NOTFOUND)
1585 return -1; // nothing selected
1586 assert(nPos <= SAL_MAX_INT16 && "nPos is out of the range we can represent");
1587 return nPos;
1590 css::uno::Sequence<sal_Int16> VCLXListBox::getSelectedItemsPos()
1592 SolarMutexGuard aGuard;
1594 css::uno::Sequence<sal_Int16> aSeq;
1595 VclPtr< ListBox > pBox = GetAs< ListBox >();
1596 if ( pBox )
1598 const sal_Int32 nSelEntries = pBox->GetSelectedEntryCount();
1599 aSeq = css::uno::Sequence<sal_Int16>( nSelEntries );
1600 for ( sal_Int32 n = 0; n < nSelEntries; ++n )
1601 aSeq.getArray()[n] = pBox->GetSelectedEntryPos( n );
1603 return aSeq;
1606 OUString VCLXListBox::getSelectedItem()
1608 SolarMutexGuard aGuard;
1610 OUString aItem;
1611 VclPtr< ListBox > pBox = GetAs< ListBox >();
1612 if ( pBox )
1613 aItem = pBox->GetSelectedEntry();
1614 return aItem;
1617 css::uno::Sequence< OUString> VCLXListBox::getSelectedItems()
1619 SolarMutexGuard aGuard;
1621 css::uno::Sequence< OUString> aSeq;
1622 VclPtr< ListBox > pBox = GetAs< ListBox >();
1623 if ( pBox )
1625 const sal_Int32 nSelEntries = pBox->GetSelectedEntryCount();
1626 aSeq = css::uno::Sequence< OUString>( nSelEntries );
1627 for ( sal_Int32 n = 0; n < nSelEntries; ++n )
1628 aSeq.getArray()[n] = pBox->GetSelectedEntry( n );
1630 return aSeq;
1633 void VCLXListBox::selectItemPos( sal_Int16 nPos, sal_Bool bSelect )
1635 SolarMutexGuard aGuard;
1637 VclPtr< ListBox > pBox = GetAs< ListBox >();
1638 if ( pBox && ( pBox->IsEntryPosSelected( nPos ) != bool(bSelect) ) )
1640 pBox->SelectEntryPos( nPos, bSelect );
1642 // VCL doesn't call select handler after API call.
1643 // ImplCallItemListeners();
1645 // #107218# Call same listeners like VCL would do after user interaction
1646 SetSynthesizingVCLEvent( true );
1647 pBox->Select();
1648 SetSynthesizingVCLEvent( false );
1652 void VCLXListBox::selectItemsPos( const css::uno::Sequence<sal_Int16>& aPositions, sal_Bool bSelect )
1654 SolarMutexGuard aGuard;
1656 VclPtr< ListBox > pBox = GetAs< ListBox >();
1657 if ( !pBox )
1658 return;
1660 std::vector<sal_Int32> aPositionVec;
1661 aPositionVec.reserve(aPositions.getLength());
1663 bool bChanged = false;
1664 for ( auto n = aPositions.getLength(); n; )
1666 const auto nPos = aPositions.getConstArray()[--n];
1667 if ( pBox->IsEntryPosSelected( nPos ) != bool(bSelect) )
1669 aPositionVec.push_back(nPos);
1670 bChanged = true;
1674 if ( !bChanged )
1675 return;
1677 bool bOrigUpdateMode = pBox->IsUpdateMode();
1678 pBox->SetUpdateMode(false);
1680 pBox->SelectEntriesPos(aPositionVec, bSelect);
1682 pBox->SetUpdateMode(bOrigUpdateMode);
1684 // VCL doesn't call select handler after API call.
1685 // ImplCallItemListeners();
1687 // #107218# Call same listeners like VCL would do after user interaction
1688 SetSynthesizingVCLEvent( true );
1689 pBox->Select();
1690 SetSynthesizingVCLEvent( false );
1693 void VCLXListBox::selectItem( const OUString& rItemText, sal_Bool bSelect )
1695 SolarMutexGuard aGuard;
1697 VclPtr< ListBox > pBox = GetAs< ListBox >();
1698 if ( pBox )
1700 selectItemPos( pBox->GetEntryPos( rItemText ), bSelect );
1704 void VCLXListBox::setDropDownLineCount( sal_Int16 nLines )
1706 SolarMutexGuard aGuard;
1707 VclPtr< ListBox > pBox = GetAs< ListBox >();
1708 if ( pBox )
1709 pBox->SetDropDownLineCount( nLines );
1712 sal_Int16 VCLXListBox::getDropDownLineCount()
1714 SolarMutexGuard aGuard;
1716 sal_Int16 nLines = 0;
1717 VclPtr< ListBox > pBox = GetAs< ListBox >();
1718 if ( pBox )
1719 nLines = pBox->GetDropDownLineCount();
1720 return nLines;
1723 sal_Bool VCLXListBox::isMutipleMode()
1725 SolarMutexGuard aGuard;
1726 bool bMulti = false;
1727 VclPtr< ListBox > pBox = GetAs< ListBox >();
1728 if ( pBox )
1729 bMulti = pBox->IsMultiSelectionEnabled();
1730 return bMulti;
1733 void VCLXListBox::setMultipleMode( sal_Bool bMulti )
1735 SolarMutexGuard aGuard;
1736 VclPtr< ListBox > pBox = GetAs< ListBox >();
1737 if ( pBox )
1738 pBox->EnableMultiSelection( bMulti );
1741 void VCLXListBox::makeVisible( sal_Int16 nEntry )
1743 SolarMutexGuard aGuard;
1744 VclPtr< ListBox > pBox = GetAs< ListBox >();
1745 if ( pBox )
1746 pBox->SetTopEntry( nEntry );
1749 void VCLXListBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1751 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
1752 // since we call listeners below, there is a potential that we will be destroyed
1753 // in during the listener call. To prevent the resulting crashes, we keep us
1754 // alive as long as we're here
1756 switch ( rVclWindowEvent.GetId() )
1758 case VclEventId::ListboxSelect:
1760 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1761 if( pListBox )
1763 bool bDropDown = ( pListBox->GetStyle() & WB_DROPDOWN ) != 0;
1764 if ( bDropDown && !IsSynthesizingVCLEvent() && maActionListeners.getLength() )
1766 // Call ActionListener on DropDown event
1767 css::awt::ActionEvent aEvent;
1768 aEvent.Source = getXWeak();
1769 aEvent.ActionCommand = pListBox->GetSelectedEntry();
1770 maActionListeners.actionPerformed( aEvent );
1773 if ( maItemListeners.getLength() )
1775 ImplCallItemListeners();
1779 break;
1781 case VclEventId::ListboxDoubleClick:
1782 if ( GetWindow() && maActionListeners.getLength() )
1784 css::awt::ActionEvent aEvent;
1785 aEvent.Source = getXWeak();
1786 aEvent.ActionCommand = GetAs<ListBox>()->GetSelectedEntry();
1787 maActionListeners.actionPerformed( aEvent );
1789 break;
1791 default:
1792 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
1793 break;
1797 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXListBox::CreateAccessibleContext()
1799 SolarMutexGuard aGuard;
1801 VclPtr<ListBox> pListBox = GetAs<ListBox>();
1802 return AccessibleFactory::createAccessibleContext(pListBox);
1805 void VCLXListBox::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
1807 SolarMutexGuard aGuard;
1808 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1809 if ( !pListBox )
1810 return;
1812 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1813 switch ( nPropType )
1815 case BASEPROPERTY_ITEM_SEPARATOR_POS:
1817 sal_Int16 nSeparatorPos(0);
1818 if ( Value >>= nSeparatorPos )
1819 pListBox->SetSeparatorPos( nSeparatorPos );
1821 break;
1822 case BASEPROPERTY_READONLY:
1824 bool b = false;
1825 if ( Value >>= b )
1826 pListBox->SetReadOnly( b);
1828 break;
1829 case BASEPROPERTY_MULTISELECTION:
1831 bool b = false;
1832 if ( Value >>= b )
1833 pListBox->EnableMultiSelection( b );
1835 break;
1836 case BASEPROPERTY_MULTISELECTION_SIMPLEMODE:
1837 ::toolkit::adjustBooleanWindowStyle( Value, pListBox, WB_SIMPLEMODE, false );
1838 break;
1839 case BASEPROPERTY_LINECOUNT:
1841 sal_Int16 n = 0;
1842 if ( Value >>= n )
1843 pListBox->SetDropDownLineCount( n );
1845 break;
1846 case BASEPROPERTY_STRINGITEMLIST:
1848 css::uno::Sequence< OUString> aItems;
1849 if ( Value >>= aItems )
1851 pListBox->Clear();
1852 addItems( aItems, 0 );
1855 break;
1856 case BASEPROPERTY_SELECTEDITEMS:
1858 css::uno::Sequence<sal_Int16> aItems;
1859 if ( Value >>= aItems )
1861 for ( auto n = pListBox->GetEntryCount(); n; )
1862 pListBox->SelectEntryPos( --n, false );
1864 if ( aItems.hasElements() )
1865 selectItemsPos( aItems, true );
1866 else
1867 pListBox->SetNoSelection();
1869 if ( !pListBox->GetSelectedEntryCount() )
1870 pListBox->SetTopEntry( 0 );
1873 break;
1874 case BASEPROPERTY_HIGHLIGHT_COLOR:
1876 Color nColor = 0;
1877 bool bVoid = Value.getValueTypeClass() == css::uno::TypeClass_VOID;
1878 if (bVoid)
1880 nColor = Application::GetSettings().GetStyleSettings().GetHighlightColor();
1882 else
1884 if (!(Value >>= nColor))
1885 break;
1887 pListBox->SetHighlightColor(nColor);
1889 break;
1890 case BASEPROPERTY_HIGHLIGHT_TEXT_COLOR:
1892 Color nColor = 0;
1893 bool bVoid = Value.getValueTypeClass() == css::uno::TypeClass_VOID;
1894 if (bVoid)
1896 nColor = Application::GetSettings().GetStyleSettings().GetHighlightTextColor();
1898 else
1900 if (!(Value >>= nColor))
1901 break;
1903 pListBox->SetHighlightTextColor(nColor);
1905 break;
1906 default:
1908 VCLXWindow::setProperty( PropertyName, Value );
1913 css::uno::Any VCLXListBox::getProperty( const OUString& PropertyName )
1915 SolarMutexGuard aGuard;
1916 css::uno::Any aProp;
1917 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1918 if ( pListBox )
1920 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1921 switch ( nPropType )
1923 case BASEPROPERTY_ITEM_SEPARATOR_POS:
1924 aProp <<= sal_Int16( pListBox->GetSeparatorPos() );
1925 break;
1926 case BASEPROPERTY_READONLY:
1928 aProp <<= pListBox->IsReadOnly();
1930 break;
1931 case BASEPROPERTY_MULTISELECTION:
1933 aProp <<= pListBox->IsMultiSelectionEnabled();
1935 break;
1936 case BASEPROPERTY_MULTISELECTION_SIMPLEMODE:
1938 aProp <<= ( ( pListBox->GetStyle() & WB_SIMPLEMODE ) == 0 );
1940 break;
1941 case BASEPROPERTY_LINECOUNT:
1943 aProp <<= static_cast<sal_Int16>(pListBox->GetDropDownLineCount());
1945 break;
1946 case BASEPROPERTY_STRINGITEMLIST:
1948 const sal_Int32 nItems = pListBox->GetEntryCount();
1949 css::uno::Sequence< OUString> aSeq( nItems );
1950 OUString* pStrings = aSeq.getArray();
1951 for ( sal_Int32 n = 0; n < nItems; ++n )
1952 pStrings[n] = pListBox->GetEntry( n );
1953 aProp <<= aSeq;
1956 break;
1957 default:
1959 aProp = VCLXWindow::getProperty( PropertyName );
1963 return aProp;
1966 css::awt::Size VCLXListBox::getMinimumSize( )
1968 SolarMutexGuard aGuard;
1969 Size aSz;
1970 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1971 if ( pListBox )
1972 aSz = pListBox->CalcMinimumSize();
1973 return vcl::unohelper::ConvertToAWTSize(aSz);
1976 css::awt::Size VCLXListBox::getPreferredSize( )
1978 SolarMutexGuard aGuard;
1979 Size aSz;
1980 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1981 if ( pListBox )
1983 aSz = pListBox->CalcMinimumSize();
1984 if ( pListBox->GetStyle() & WB_DROPDOWN )
1985 aSz.AdjustHeight(4 );
1987 return vcl::unohelper::ConvertToAWTSize(aSz);
1990 css::awt::Size VCLXListBox::calcAdjustedSize( const css::awt::Size& rNewSize )
1992 SolarMutexGuard aGuard;
1993 Size aSz = vcl::unohelper::ConvertToVCLSize(rNewSize);
1994 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1995 if ( pListBox )
1996 aSz = pListBox->CalcAdjustedSize( aSz );
1997 return vcl::unohelper::ConvertToAWTSize(aSz);
2000 css::awt::Size VCLXListBox::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines )
2002 SolarMutexGuard aGuard;
2003 Size aSz;
2004 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2005 if ( pListBox )
2006 aSz = pListBox->CalcBlockSize( nCols, nLines );
2007 return vcl::unohelper::ConvertToAWTSize(aSz);
2010 void VCLXListBox::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines )
2012 SolarMutexGuard aGuard;
2013 nCols = nLines = 0;
2014 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2015 if ( pListBox )
2017 sal_uInt16 nC, nL;
2018 pListBox->GetMaxVisColumnsAndLines( nC, nL );
2019 nCols = nC;
2020 nLines = nL;
2024 void VCLXListBox::ImplCallItemListeners()
2026 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2027 if ( pListBox && maItemListeners.getLength() )
2029 css::awt::ItemEvent aEvent;
2030 aEvent.Source = getXWeak();
2031 aEvent.Highlighted = 0;
2033 // Set to 0xFFFF on multiple selection, selected entry ID otherwise
2034 aEvent.Selected = (pListBox->GetSelectedEntryCount() == 1 ) ? pListBox->GetSelectedEntryPos() : 0xFFFF;
2036 maItemListeners.itemStateChanged( aEvent );
2039 namespace
2041 Image lcl_getImageFromURL( const OUString& i_rImageURL )
2043 if ( i_rImageURL.isEmpty() )
2044 return Image();
2048 const Reference< uno::XComponentContext >& xContext( ::comphelper::getProcessComponentContext() );
2049 Reference< XGraphicProvider > xProvider(graphic::GraphicProvider::create(xContext));
2050 ::comphelper::NamedValueCollection aMediaProperties;
2051 aMediaProperties.put( u"URL"_ustr, i_rImageURL );
2052 Reference< XGraphic > xGraphic = xProvider->queryGraphic( aMediaProperties.getPropertyValues() );
2053 return Image( xGraphic );
2055 catch( const uno::Exception& )
2057 DBG_UNHANDLED_EXCEPTION("toolkit");
2059 return Image();
2062 void SAL_CALL VCLXListBox::listItemInserted( const ItemListEvent& i_rEvent )
2064 SolarMutexGuard aGuard;
2065 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2067 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemInserted: no ListBox?!" );
2068 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition <= pListBox->GetEntryCount() ),
2069 "VCLXListBox::listItemInserted: illegal (inconsistent) item position!" );
2070 pListBox->InsertEntry(
2071 i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : OUString(),
2072 i_rEvent.ItemImageURL.IsPresent ? TkResMgr::getImageFromURL( i_rEvent.ItemImageURL.Value ) : Image(),
2073 i_rEvent.ItemPosition );
2076 void SAL_CALL VCLXListBox::listItemRemoved( const ItemListEvent& i_rEvent )
2078 SolarMutexGuard aGuard;
2079 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2081 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemRemoved: no ListBox?!" );
2082 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < pListBox->GetEntryCount() ),
2083 "VCLXListBox::listItemRemoved: illegal (inconsistent) item position!" );
2085 pListBox->RemoveEntry( i_rEvent.ItemPosition );
2088 void SAL_CALL VCLXListBox::listItemModified( const ItemListEvent& i_rEvent )
2090 SolarMutexGuard aGuard;
2091 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2093 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" );
2094 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < pListBox->GetEntryCount() ),
2095 "VCLXListBox::listItemModified: illegal (inconsistent) item position!" );
2097 // VCL's ListBox does not support changing an entry's text or image, so remove and re-insert
2099 const OUString sNewText = i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : pListBox->GetEntry( i_rEvent.ItemPosition );
2100 const Image aNewImage( i_rEvent.ItemImageURL.IsPresent ? TkResMgr::getImageFromURL( i_rEvent.ItemImageURL.Value ) : pListBox->GetEntryImage( i_rEvent.ItemPosition ) );
2102 pListBox->RemoveEntry( i_rEvent.ItemPosition );
2103 pListBox->InsertEntry( sNewText, aNewImage, i_rEvent.ItemPosition );
2106 void SAL_CALL VCLXListBox::allItemsRemoved( const EventObject& )
2108 SolarMutexGuard aGuard;
2110 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2111 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" );
2113 pListBox->Clear();
2116 void SAL_CALL VCLXListBox::itemListChanged( const EventObject& i_rEvent )
2118 SolarMutexGuard aGuard;
2120 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2121 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" );
2123 pListBox->Clear();
2125 uno::Reference< beans::XPropertySet > xPropSet( i_rEvent.Source, uno::UNO_QUERY_THROW );
2126 uno::Reference< beans::XPropertySetInfo > xPSI( xPropSet->getPropertySetInfo(), uno::UNO_SET_THROW );
2127 uno::Reference< resource::XStringResourceResolver > xStringResourceResolver;
2128 if ( xPSI->hasPropertyByName(u"ResourceResolver"_ustr) )
2130 xStringResourceResolver.set(
2131 xPropSet->getPropertyValue(u"ResourceResolver"_ustr),
2132 uno::UNO_QUERY
2137 Reference< XItemList > xItemList( i_rEvent.Source, uno::UNO_QUERY_THROW );
2138 const uno::Sequence< beans::Pair< OUString, OUString > > aItems = xItemList->getAllItems();
2139 for ( const auto& rItem : aItems )
2141 OUString aLocalizationKey( rItem.First );
2142 if ( xStringResourceResolver.is() && aLocalizationKey.startsWith("&") )
2144 aLocalizationKey = xStringResourceResolver->resolveString(aLocalizationKey.copy( 1 ));
2146 pListBox->InsertEntry( aLocalizationKey, lcl_getImageFromURL( rItem.Second ) );
2150 void SAL_CALL VCLXListBox::disposing( const EventObject& i_rEvent )
2152 // just disambiguate
2153 VCLXWindow::disposing( i_rEvent );
2159 void VCLXMessageBox::GetPropertyIds( std::vector< sal_uInt16 > &rIds )
2161 VCLXTopWindow::ImplGetPropertyIds( rIds );
2164 VCLXMessageBox::VCLXMessageBox()
2168 VCLXMessageBox::~VCLXMessageBox()
2172 void VCLXMessageBox::setCaptionText( const OUString& rText )
2174 SolarMutexGuard aGuard;
2176 VclPtr<vcl::Window> pWindow = GetWindow();
2177 if ( pWindow )
2178 pWindow->SetText( rText );
2181 OUString VCLXMessageBox::getCaptionText()
2183 SolarMutexGuard aGuard;
2185 OUString aText;
2186 VclPtr<vcl::Window> pWindow = GetWindow();
2187 if ( pWindow )
2188 aText = pWindow->GetText();
2189 return aText;
2192 void VCLXMessageBox::setMessageText( const OUString& rText )
2194 SolarMutexGuard aGuard;
2195 VclPtr< MessBox > pBox = GetAs< MessBox >();
2196 if ( pBox )
2197 pBox->SetMessText( rText );
2200 OUString VCLXMessageBox::getMessageText()
2202 SolarMutexGuard aGuard;
2203 OUString aText;
2204 VclPtr< MessBox > pBox = GetAs< MessBox >();
2205 if ( pBox )
2206 aText = pBox->GetMessText();
2207 return aText;
2210 sal_Int16 VCLXMessageBox::execute()
2212 SolarMutexGuard aGuard;
2213 VclPtr< MessBox > pBox = GetAs< MessBox >();
2214 return pBox ? pBox->Execute() : 0;
2217 css::awt::Size SAL_CALL VCLXMessageBox::getMinimumSize()
2219 return css::awt::Size( 250, 100 );
2224 void VCLXDialog::GetPropertyIds( std::vector< sal_uInt16 > &rIds )
2226 VCLXTopWindow::ImplGetPropertyIds( rIds );
2229 VCLXDialog::VCLXDialog()
2231 SAL_INFO("toolkit", "XDialog created");
2234 VCLXDialog::~VCLXDialog()
2236 SAL_INFO("toolkit", __FUNCTION__);
2239 void SAL_CALL VCLXDialog::endDialog( ::sal_Int32 i_result )
2241 SolarMutexGuard aGuard;
2242 VclPtr<Dialog> pDialog = GetAsDynamic< Dialog >();
2243 if ( pDialog )
2244 pDialog->EndDialog( i_result );
2247 void SAL_CALL VCLXDialog::setHelpId( const OUString& rId )
2249 SolarMutexGuard aGuard;
2250 VclPtr< vcl::Window > pWindow = GetWindow();
2251 if ( pWindow )
2252 pWindow->SetHelpId( rId );
2255 void VCLXDialog::setTitle( const OUString& Title )
2257 SolarMutexGuard aGuard;
2258 VclPtr< vcl::Window > pWindow = GetWindow();
2259 if ( pWindow )
2260 pWindow->SetText( Title );
2263 OUString VCLXDialog::getTitle()
2265 SolarMutexGuard aGuard;
2267 OUString aTitle;
2268 VclPtr< vcl::Window > pWindow = GetWindow();
2269 if ( pWindow )
2270 aTitle = pWindow->GetText();
2271 return aTitle;
2274 sal_Int16 VCLXDialog::execute()
2276 SolarMutexGuard aGuard;
2278 sal_Int16 nRet = 0;
2279 if ( GetWindow() )
2281 VclPtr< Dialog > pDlg = GetAs< Dialog >();
2282 vcl::Window* pParent = pDlg->GetWindow( GetWindowType::ParentOverlap );
2283 vcl::Window* pOldParent = nullptr;
2284 vcl::Window* pSetParent = nullptr;
2285 if ( pParent && !pParent->IsReallyVisible() )
2287 pOldParent = pDlg->GetParent();
2288 vcl::Window* pFrame = pDlg->GetWindow( GetWindowType::Frame );
2289 if( pFrame != pDlg )
2291 pDlg->SetParent( pFrame );
2292 pSetParent = pFrame;
2296 nRet = pDlg->Execute();
2298 // set the parent back only in case no new parent was set from outside
2299 // in other words, revert only own changes
2300 if ( pOldParent && pDlg->GetParent() == pSetParent )
2301 pDlg->SetParent( pOldParent );
2303 return nRet;
2306 void VCLXDialog::endExecute()
2308 endDialog(0);
2311 void SAL_CALL VCLXDialog::draw( sal_Int32 nX, sal_Int32 nY )
2313 SolarMutexGuard aGuard;
2314 VclPtr< vcl::Window > pWindow = GetWindow();
2315 if ( pWindow )
2317 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
2318 if ( !pDev )
2319 pDev = pWindow->GetParent()->GetOutDev();
2321 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
2322 pWindow->Draw( pDev, aPos, SystemTextColorFlags::NoControls );
2326 css::awt::DeviceInfo VCLXDialog::getInfo()
2328 css::awt::DeviceInfo aInfo = VCLXDevice::getInfo();
2330 SolarMutexGuard aGuard;
2331 VclPtr< Dialog > pDlg = GetAs< Dialog >();
2332 if ( pDlg )
2333 pDlg->GetDrawWindowBorder( aInfo.LeftInset, aInfo.TopInset, aInfo.RightInset, aInfo.BottomInset );
2335 return aInfo;
2338 void SAL_CALL VCLXDialog::setProperty(
2339 const OUString& PropertyName,
2340 const css::uno::Any& Value )
2342 SolarMutexGuard aGuard;
2343 VclPtr< Dialog > pDialog = GetAs< Dialog >();
2344 if ( !pDialog )
2345 return;
2347 bool bVoid = Value.getValueTypeClass() == css::uno::TypeClass_VOID;
2349 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2350 switch ( nPropType )
2352 case BASEPROPERTY_GRAPHIC:
2354 Reference< XGraphic > xGraphic;
2355 if (( Value >>= xGraphic ) && xGraphic.is() )
2357 Graphic aImage(xGraphic);
2359 Wallpaper aWallpaper(aImage.GetBitmapEx());
2360 aWallpaper.SetStyle( WallpaperStyle::Scale );
2361 pDialog->SetBackground( aWallpaper );
2363 else if ( bVoid || !xGraphic.is() )
2365 Color aColor = pDialog->GetControlBackground();
2366 if ( aColor == COL_AUTO )
2367 aColor = pDialog->GetSettings().GetStyleSettings().GetDialogColor();
2369 Wallpaper aWallpaper( aColor );
2370 pDialog->SetBackground( aWallpaper );
2373 break;
2375 default:
2377 VCLXContainer::setProperty( PropertyName, Value );
2384 VCLXMultiPage::VCLXMultiPage() : maTabListeners( *this ), mTabId( 1 )
2386 SAL_INFO("toolkit", "VCLXMultiPage::VCLXMultiPage()" );
2389 void VCLXMultiPage::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
2391 PushPropertyIds( rIds,
2392 BASEPROPERTY_BACKGROUNDCOLOR,
2393 BASEPROPERTY_DEFAULTCONTROL,
2394 BASEPROPERTY_ENABLED,
2395 BASEPROPERTY_MULTIPAGEVALUE,
2396 BASEPROPERTY_ENABLEVISIBLE,
2397 BASEPROPERTY_FONTDESCRIPTOR,
2398 BASEPROPERTY_GRAPHIC,
2399 BASEPROPERTY_HELPTEXT,
2400 BASEPROPERTY_HELPURL,
2401 BASEPROPERTY_IMAGEALIGN,
2402 BASEPROPERTY_IMAGEPOSITION,
2403 BASEPROPERTY_IMAGEURL,
2404 BASEPROPERTY_PRINTABLE,
2405 BASEPROPERTY_TABSTOP,
2406 BASEPROPERTY_FOCUSONCLICK,
2408 VCLXContainer::ImplGetPropertyIds( rIds );
2411 VCLXMultiPage::~VCLXMultiPage()
2414 void SAL_CALL VCLXMultiPage::dispose()
2416 SolarMutexGuard aGuard;
2418 css::lang::EventObject aObj;
2419 aObj.Source = getXWeak();
2420 maTabListeners.disposeAndClear( aObj );
2421 VCLXContainer::dispose();
2423 // css::awt::XView
2424 void SAL_CALL VCLXMultiPage::draw( sal_Int32 nX, sal_Int32 nY )
2426 SolarMutexGuard aGuard;
2427 VclPtr< vcl::Window > pWindow = GetWindow();
2429 if ( pWindow )
2431 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
2432 if ( !pDev )
2433 pDev = pWindow->GetParent()->GetOutDev();
2435 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
2436 pWindow->Draw( pDev, aPos, SystemTextColorFlags::NoControls );
2440 uno::Any SAL_CALL VCLXMultiPage::getProperty( const OUString& PropertyName )
2442 SAL_INFO("toolkit", " **** VCLXMultiPage::getProperty " << PropertyName );
2443 SolarMutexGuard aGuard;
2444 css::uno::Any aProp;
2445 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2446 switch ( nPropType )
2449 case BASEPROPERTY_MULTIPAGEVALUE:
2451 aProp <<= getActiveTabID();
2453 break;
2454 default:
2455 aProp = VCLXContainer::getProperty( PropertyName );
2457 return aProp;
2460 void SAL_CALL VCLXMultiPage::setProperty(
2461 const OUString& PropertyName,
2462 const css::uno::Any& Value )
2464 SAL_INFO("toolkit", " **** VCLXMultiPage::setProperty " << PropertyName );
2465 SolarMutexGuard aGuard;
2467 VclPtr< TabControl > pTabControl = GetAs< TabControl >();
2468 if ( !pTabControl )
2469 return;
2471 bool bVoid = Value.getValueTypeClass() == css::uno::TypeClass_VOID;
2473 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2474 switch ( nPropType )
2476 case BASEPROPERTY_MULTIPAGEVALUE:
2478 SAL_INFO("toolkit", "***MULTIPAGE VALUE");
2479 sal_Int32 nId(0);
2480 Value >>= nId;
2481 // when the multipage is created we attempt to set the activepage
2482 // but no pages created
2483 if ( nId && nId <= getWindows().getLength() )
2484 activateTab( nId );
2485 break;
2487 case BASEPROPERTY_GRAPHIC:
2489 Reference< XGraphic > xGraphic;
2490 if (( Value >>= xGraphic ) && xGraphic.is() )
2492 Graphic aImage(xGraphic);
2494 Wallpaper aWallpaper(aImage.GetBitmapEx());
2495 aWallpaper.SetStyle( WallpaperStyle::Scale );
2496 pTabControl->SetBackground( aWallpaper );
2498 else if ( bVoid || !xGraphic.is() )
2500 Color aColor = pTabControl->GetControlBackground();
2501 if ( aColor == COL_AUTO )
2502 aColor = pTabControl->GetSettings().GetStyleSettings().GetDialogColor();
2504 Wallpaper aWallpaper( aColor );
2505 pTabControl->SetBackground( aWallpaper );
2508 break;
2510 default:
2512 VCLXContainer::setProperty( PropertyName, Value );
2517 TabControl *VCLXMultiPage::getTabControl() const
2519 VclPtr<TabControl> pTabControl = GetAsDynamic< TabControl >();
2520 if ( pTabControl )
2521 return pTabControl;
2522 throw uno::RuntimeException();
2524 sal_Int32 SAL_CALL VCLXMultiPage::insertTab()
2526 TabControl *pTabControl = getTabControl();
2527 VclPtrInstance<TabPage> pTab( pTabControl );
2528 return static_cast< sal_Int32 >( insertTab( pTab, OUString() ) );
2531 sal_uInt16 VCLXMultiPage::insertTab( TabPage* pPage, OUString const & sTitle )
2533 TabControl *pTabControl = getTabControl();
2534 sal_uInt16 id = sal::static_int_cast< sal_uInt16 >( mTabId++ );
2535 pTabControl->InsertPage( id, sTitle );
2536 pTabControl->SetTabPage( id, pPage );
2537 return id;
2540 void SAL_CALL VCLXMultiPage::removeTab( sal_Int32 ID )
2542 TabControl *pTabControl = getTabControl();
2543 if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == nullptr )
2544 throw lang::IndexOutOfBoundsException();
2545 pTabControl->RemovePage( sal::static_int_cast< sal_uInt16 >( ID ) );
2548 void SAL_CALL VCLXMultiPage::activateTab( sal_Int32 ID )
2550 TabControl *pTabControl = getTabControl();
2551 SAL_INFO(
2552 "toolkit",
2553 "Attempting to activate tab " << ID << ", active tab is "
2554 << getActiveTabID() << ", numtabs is " << getWindows().getLength());
2555 if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == nullptr )
2556 throw lang::IndexOutOfBoundsException();
2557 pTabControl->SelectTabPage( sal::static_int_cast< sal_uInt16 >( ID ) );
2560 sal_Int32 SAL_CALL VCLXMultiPage::getActiveTabID()
2562 return getTabControl()->GetCurPageId( );
2565 void SAL_CALL VCLXMultiPage::addTabListener( const uno::Reference< awt::XTabListener >& xListener )
2567 SolarMutexGuard aGuard;
2568 maTabListeners.addInterface( xListener );
2571 void SAL_CALL VCLXMultiPage::removeTabListener( const uno::Reference< awt::XTabListener >& xListener )
2573 SolarMutexGuard aGuard;
2574 maTabListeners.removeInterface( xListener );
2577 void SAL_CALL VCLXMultiPage::setTabProps( sal_Int32 ID, const uno::Sequence< beans::NamedValue >& Properties )
2579 SolarMutexGuard aGuard;
2580 TabControl *pTabControl = getTabControl();
2581 if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == nullptr )
2582 throw lang::IndexOutOfBoundsException();
2584 for (const auto& rProp : Properties)
2586 const OUString &name = rProp.Name;
2587 const uno::Any &value = rProp.Value;
2589 if (name == "Title")
2591 OUString title = value.get<OUString>();
2592 pTabControl->SetPageText( sal::static_int_cast< sal_uInt16 >( ID ), title );
2597 uno::Sequence< beans::NamedValue > SAL_CALL VCLXMultiPage::getTabProps( sal_Int32 ID )
2599 SolarMutexGuard aGuard;
2600 TabControl *pTabControl = getTabControl();
2601 if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == nullptr )
2602 throw lang::IndexOutOfBoundsException();
2604 uno::Sequence< beans::NamedValue > props
2606 { u"Title"_ustr, css::uno::Any(pTabControl->GetPageText( sal::static_int_cast< sal_uInt16 >( ID ) )) },
2607 { u"Position"_ustr, css::uno::Any(pTabControl->GetPagePos( sal::static_int_cast< sal_uInt16 >( ID ) )) }
2609 return props;
2611 void VCLXMultiPage::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
2613 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
2614 switch ( rVclWindowEvent.GetId() )
2616 case VclEventId::TabpageDeactivate:
2618 sal_uInt16 nPageID = static_cast<sal_uInt16>(reinterpret_cast<sal_uIntPtr>( rVclWindowEvent.GetData() ));
2619 maTabListeners.deactivated( nPageID );
2620 break;
2623 case VclEventId::TabpageActivate:
2625 sal_uInt16 nPageID = static_cast<sal_uInt16>(reinterpret_cast<sal_uIntPtr>( rVclWindowEvent.GetData() ));
2626 maTabListeners.activated( nPageID );
2627 break;
2629 default:
2630 VCLXContainer::ProcessWindowEvent( rVclWindowEvent );
2631 break;
2637 VCLXTabPage::VCLXTabPage()
2641 void VCLXTabPage::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
2643 PushPropertyIds( rIds,
2644 BASEPROPERTY_BACKGROUNDCOLOR,
2645 BASEPROPERTY_DEFAULTCONTROL,
2646 BASEPROPERTY_ENABLED,
2647 BASEPROPERTY_ENABLEVISIBLE,
2648 BASEPROPERTY_FONTDESCRIPTOR,
2649 BASEPROPERTY_GRAPHIC,
2650 BASEPROPERTY_HELPTEXT,
2651 BASEPROPERTY_HELPURL,
2652 BASEPROPERTY_IMAGEALIGN,
2653 BASEPROPERTY_IMAGEPOSITION,
2654 BASEPROPERTY_IMAGEURL,
2655 BASEPROPERTY_PRINTABLE,
2656 BASEPROPERTY_TABSTOP,
2657 BASEPROPERTY_FOCUSONCLICK,
2659 VCLXContainer::ImplGetPropertyIds( rIds );
2662 VCLXTabPage::~VCLXTabPage()
2666 // css::awt::XView
2667 void SAL_CALL VCLXTabPage::draw( sal_Int32 nX, sal_Int32 nY )
2669 SolarMutexGuard aGuard;
2670 VclPtr< vcl::Window > pWindow = GetWindow();
2672 if ( pWindow )
2674 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
2675 if ( !pDev )
2676 pDev = pWindow->GetParent()->GetOutDev();
2678 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
2679 pWindow->Draw( pDev, aPos, SystemTextColorFlags::NoControls );
2683 void SAL_CALL VCLXTabPage::setProperty(
2684 const OUString& PropertyName,
2685 const css::uno::Any& Value )
2687 SolarMutexGuard aGuard;
2688 VclPtr< TabPage > pTabPage = GetAs< TabPage >();
2689 if ( !pTabPage )
2690 return;
2692 bool bVoid = Value.getValueTypeClass() == css::uno::TypeClass_VOID;
2694 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2695 switch ( nPropType )
2697 case BASEPROPERTY_GRAPHIC:
2699 Reference< XGraphic > xGraphic;
2700 if (( Value >>= xGraphic ) && xGraphic.is() )
2702 Graphic aImage(xGraphic);
2704 Wallpaper aWallpaper(aImage.GetBitmapEx());
2705 aWallpaper.SetStyle( WallpaperStyle::Scale );
2706 pTabPage->SetBackground( aWallpaper );
2708 else if ( bVoid || !xGraphic.is() )
2710 Color aColor = pTabPage->GetControlBackground();
2711 if ( aColor == COL_AUTO )
2712 aColor = pTabPage->GetSettings().GetStyleSettings().GetDialogColor();
2714 Wallpaper aWallpaper( aColor );
2715 pTabPage->SetBackground( aWallpaper );
2718 break;
2719 case BASEPROPERTY_TITLE:
2721 OUString sTitle;
2722 if ( Value >>= sTitle )
2724 pTabPage->SetText(sTitle);
2727 break;
2729 default:
2731 VCLXContainer::setProperty( PropertyName, Value );
2736 TabPage *VCLXTabPage::getTabPage() const
2738 VclPtr< TabPage > pTabPage = GetAsDynamic< TabPage >();
2739 if ( pTabPage )
2740 return pTabPage;
2741 throw uno::RuntimeException();
2747 VCLXFixedHyperlink::VCLXFixedHyperlink() :
2749 maActionListeners( *this )
2754 VCLXFixedHyperlink::~VCLXFixedHyperlink()
2758 void VCLXFixedHyperlink::dispose()
2760 SolarMutexGuard aGuard;
2762 css::lang::EventObject aObj;
2763 aObj.Source = getXWeak();
2764 maActionListeners.disposeAndClear( aObj );
2765 VCLXWindow::dispose();
2768 void VCLXFixedHyperlink::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
2770 switch ( rVclWindowEvent.GetId() )
2772 case VclEventId::ButtonClick:
2774 if ( maActionListeners.getLength() )
2776 css::awt::ActionEvent aEvent;
2777 aEvent.Source = getXWeak();
2778 maActionListeners.actionPerformed( aEvent );
2780 [[fallthrough]];
2782 default:
2783 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
2784 break;
2788 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXFixedHyperlink::CreateAccessibleContext()
2790 VclPtr<FixedHyperlink> pFixedHyperlink = GetAs<FixedHyperlink>();
2791 return AccessibleFactory::createAccessibleContext(pFixedHyperlink);
2794 void VCLXFixedHyperlink::setText( const OUString& Text )
2796 SolarMutexGuard aGuard;
2797 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
2798 if (pBase)
2799 pBase->SetText(Text);
2802 OUString VCLXFixedHyperlink::getText()
2804 SolarMutexGuard aGuard;
2806 OUString aText;
2807 VclPtr< vcl::Window > pWindow = GetWindow();
2808 if ( pWindow )
2809 aText = pWindow->GetText();
2810 return aText;
2813 void VCLXFixedHyperlink::setURL( const OUString& URL )
2815 SolarMutexGuard aGuard;
2816 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
2817 if ( pBase )
2818 pBase->SetURL( URL );
2821 OUString VCLXFixedHyperlink::getURL( )
2823 SolarMutexGuard aGuard;
2825 OUString aText;
2826 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
2827 if ( pBase )
2828 aText = pBase->GetURL();
2829 return aText;
2832 void VCLXFixedHyperlink::setAlignment( sal_Int16 nAlign )
2834 SolarMutexGuard aGuard;
2836 VclPtr< vcl::Window > pWindow = GetWindow();
2837 if ( !pWindow )
2838 return;
2840 WinBits nNewBits = 0;
2841 if ( nAlign == css::awt::TextAlign::LEFT )
2842 nNewBits = WB_LEFT;
2843 else if ( nAlign == css::awt::TextAlign::CENTER )
2844 nNewBits = WB_CENTER;
2845 else
2846 nNewBits = WB_RIGHT;
2848 WinBits nStyle = pWindow->GetStyle();
2849 nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT);
2850 pWindow->SetStyle( nStyle | nNewBits );
2853 sal_Int16 VCLXFixedHyperlink::getAlignment()
2855 SolarMutexGuard aGuard;
2857 sal_Int16 nAlign = 0;
2858 VclPtr< vcl::Window > pWindow = GetWindow();
2859 if ( pWindow )
2861 WinBits nStyle = pWindow->GetStyle();
2862 if ( nStyle & WB_LEFT )
2863 nAlign = css::awt::TextAlign::LEFT;
2864 else if ( nStyle & WB_CENTER )
2865 nAlign = css::awt::TextAlign::CENTER;
2866 else
2867 nAlign = css::awt::TextAlign::RIGHT;
2869 return nAlign;
2872 void VCLXFixedHyperlink::addActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
2874 SolarMutexGuard aGuard;
2875 maActionListeners.addInterface( l );
2878 void VCLXFixedHyperlink::removeActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
2880 SolarMutexGuard aGuard;
2881 maActionListeners.removeInterface( l );
2884 css::awt::Size VCLXFixedHyperlink::getMinimumSize( )
2886 SolarMutexGuard aGuard;
2887 Size aSz;
2888 VclPtr< FixedText > pFixedText = GetAs< FixedText >();
2889 if ( pFixedText )
2890 aSz = pFixedText->CalcMinimumSize();
2891 return vcl::unohelper::ConvertToAWTSize(aSz);
2894 css::awt::Size VCLXFixedHyperlink::getPreferredSize( )
2896 return getMinimumSize();
2899 css::awt::Size VCLXFixedHyperlink::calcAdjustedSize( const css::awt::Size& rNewSize )
2901 SolarMutexGuard aGuard;
2902 Size aSz( vcl::unohelper::ConvertToVCLSize( rNewSize ));
2903 VclPtr< FixedText > pFixedText = GetAs< FixedText >();
2904 if (pFixedText)
2906 Size aMinSz = pFixedText->CalcMinimumSize(rNewSize.Width);
2907 if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
2908 aSz.setHeight( aMinSz.Height() );
2909 else
2910 aSz = aMinSz;
2913 return vcl::unohelper::ConvertToAWTSize(aSz);
2916 void VCLXFixedHyperlink::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
2918 SolarMutexGuard aGuard;
2920 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
2921 if ( !pBase )
2922 return;
2924 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2925 switch ( nPropType )
2927 case BASEPROPERTY_LABEL:
2929 OUString sNewLabel;
2930 if ( Value >>= sNewLabel )
2931 pBase->SetText(sNewLabel);
2932 break;
2935 case BASEPROPERTY_URL:
2937 OUString sNewURL;
2938 if ( Value >>= sNewURL )
2939 pBase->SetURL( sNewURL );
2940 break;
2943 default:
2945 VCLXWindow::setProperty( PropertyName, Value );
2950 css::uno::Any VCLXFixedHyperlink::getProperty( const OUString& PropertyName )
2952 SolarMutexGuard aGuard;
2954 css::uno::Any aProp;
2955 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
2956 if ( pBase )
2958 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2959 switch ( nPropType )
2961 case BASEPROPERTY_URL:
2963 aProp <<= pBase->GetURL();
2964 break;
2967 default:
2969 aProp = VCLXWindow::getProperty( PropertyName );
2973 return aProp;
2976 void VCLXFixedHyperlink::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
2978 PushPropertyIds( rIds,
2979 BASEPROPERTY_ALIGN,
2980 BASEPROPERTY_BACKGROUNDCOLOR,
2981 BASEPROPERTY_BORDER,
2982 BASEPROPERTY_BORDERCOLOR,
2983 BASEPROPERTY_DEFAULTCONTROL,
2984 BASEPROPERTY_ENABLED,
2985 BASEPROPERTY_ENABLEVISIBLE,
2986 BASEPROPERTY_FONTDESCRIPTOR,
2987 BASEPROPERTY_HELPTEXT,
2988 BASEPROPERTY_HELPURL,
2989 BASEPROPERTY_LABEL,
2990 BASEPROPERTY_MULTILINE,
2991 BASEPROPERTY_NOLABEL,
2992 BASEPROPERTY_PRINTABLE,
2993 BASEPROPERTY_TABSTOP,
2994 BASEPROPERTY_VERTICALALIGN,
2995 BASEPROPERTY_URL,
2996 BASEPROPERTY_WRITING_MODE,
2997 BASEPROPERTY_CONTEXT_WRITING_MODE,
2999 VCLXWindow::ImplGetPropertyIds( rIds );
3004 void VCLXFixedText::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
3006 PushPropertyIds( rIds,
3007 BASEPROPERTY_ALIGN,
3008 BASEPROPERTY_BACKGROUNDCOLOR,
3009 BASEPROPERTY_BORDER,
3010 BASEPROPERTY_BORDERCOLOR,
3011 BASEPROPERTY_DEFAULTCONTROL,
3012 BASEPROPERTY_ENABLED,
3013 BASEPROPERTY_ENABLEVISIBLE,
3014 BASEPROPERTY_FONTDESCRIPTOR,
3015 BASEPROPERTY_HELPTEXT,
3016 BASEPROPERTY_HELPURL,
3017 BASEPROPERTY_LABEL,
3018 BASEPROPERTY_MULTILINE,
3019 BASEPROPERTY_NOLABEL,
3020 BASEPROPERTY_PRINTABLE,
3021 BASEPROPERTY_TABSTOP,
3022 BASEPROPERTY_VERTICALALIGN,
3023 BASEPROPERTY_WRITING_MODE,
3024 BASEPROPERTY_CONTEXT_WRITING_MODE,
3025 BASEPROPERTY_REFERENCE_DEVICE,
3026 BASEPROPERTY_HIGHLIGHT_COLOR,
3027 BASEPROPERTY_HIGHLIGHT_TEXT_COLOR,
3029 VCLXWindow::ImplGetPropertyIds( rIds );
3032 VCLXFixedText::VCLXFixedText()
3036 VCLXFixedText::~VCLXFixedText()
3040 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXFixedText::CreateAccessibleContext()
3042 VclPtr<FixedText> pFixedText = GetAs<FixedText>();
3043 return AccessibleFactory::createAccessibleContext(pFixedText);
3046 void VCLXFixedText::setText( const OUString& Text )
3048 SolarMutexGuard aGuard;
3050 VclPtr< vcl::Window > pWindow = GetWindow();
3051 if ( pWindow )
3052 pWindow->SetText( Text );
3055 OUString VCLXFixedText::getText()
3057 SolarMutexGuard aGuard;
3059 OUString aText;
3060 VclPtr< vcl::Window > pWindow = GetWindow();
3061 if ( pWindow )
3062 aText = pWindow->GetText();
3063 return aText;
3066 void VCLXFixedText::setAlignment( sal_Int16 nAlign )
3068 SolarMutexGuard aGuard;
3070 VclPtr< vcl::Window > pWindow = GetWindow();
3071 if ( !pWindow )
3072 return;
3074 WinBits nNewBits = 0;
3075 if ( nAlign == css::awt::TextAlign::LEFT )
3076 nNewBits = WB_LEFT;
3077 else if ( nAlign == css::awt::TextAlign::CENTER )
3078 nNewBits = WB_CENTER;
3079 else
3080 nNewBits = WB_RIGHT;
3082 WinBits nStyle = pWindow->GetStyle();
3083 nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT);
3084 pWindow->SetStyle( nStyle | nNewBits );
3087 sal_Int16 VCLXFixedText::getAlignment()
3089 SolarMutexGuard aGuard;
3091 sal_Int16 nAlign = 0;
3092 VclPtr< vcl::Window > pWindow = GetWindow();
3093 if ( pWindow )
3095 WinBits nStyle = pWindow->GetStyle();
3096 if ( nStyle & WB_LEFT )
3097 nAlign = css::awt::TextAlign::LEFT;
3098 else if ( nStyle & WB_CENTER )
3099 nAlign = css::awt::TextAlign::CENTER;
3100 else
3101 nAlign = css::awt::TextAlign::RIGHT;
3103 return nAlign;
3106 css::awt::Size VCLXFixedText::getMinimumSize( )
3108 SolarMutexGuard aGuard;
3110 Size aSz;
3111 VclPtr< FixedText > pFixedText = GetAs< FixedText >();
3112 if ( pFixedText )
3113 aSz = pFixedText->CalcMinimumSize();
3114 return vcl::unohelper::ConvertToAWTSize(aSz);
3117 css::awt::Size VCLXFixedText::getPreferredSize( )
3119 return getMinimumSize();
3122 css::awt::Size VCLXFixedText::calcAdjustedSize( const css::awt::Size& rMaxSize )
3124 SolarMutexGuard aGuard;
3126 Size aAdjustedSize( vcl::unohelper::ConvertToVCLSize( rMaxSize ) );
3127 VclPtr< FixedText > pFixedText = GetAs< FixedText >();
3128 if ( pFixedText )
3129 aAdjustedSize = pFixedText->CalcMinimumSize( rMaxSize.Width );
3130 return vcl::unohelper::ConvertToAWTSize( aAdjustedSize );
3135 void VCLXScrollBar::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
3137 PushPropertyIds( rIds,
3138 BASEPROPERTY_BACKGROUNDCOLOR,
3139 BASEPROPERTY_BLOCKINCREMENT,
3140 BASEPROPERTY_BORDER,
3141 BASEPROPERTY_BORDERCOLOR,
3142 BASEPROPERTY_DEFAULTCONTROL,
3143 BASEPROPERTY_ENABLED,
3144 BASEPROPERTY_ENABLEVISIBLE,
3145 BASEPROPERTY_HELPTEXT,
3146 BASEPROPERTY_HELPURL,
3147 BASEPROPERTY_LINEINCREMENT,
3148 BASEPROPERTY_LIVE_SCROLL,
3149 BASEPROPERTY_ORIENTATION,
3150 BASEPROPERTY_PRINTABLE,
3151 BASEPROPERTY_REPEAT_DELAY,
3152 BASEPROPERTY_SCROLLVALUE,
3153 BASEPROPERTY_SCROLLVALUE_MAX,
3154 BASEPROPERTY_SCROLLVALUE_MIN,
3155 BASEPROPERTY_SYMBOL_COLOR,
3156 BASEPROPERTY_TABSTOP,
3157 BASEPROPERTY_VISIBLESIZE,
3158 BASEPROPERTY_WRITING_MODE,
3159 BASEPROPERTY_CONTEXT_WRITING_MODE,
3161 VCLXWindow::ImplGetPropertyIds( rIds );
3164 VCLXScrollBar::VCLXScrollBar() : maAdjustmentListeners( *this )
3168 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXScrollBar::CreateAccessibleContext()
3170 VclPtr<ScrollBar> pScrollBar = GetAs<ScrollBar>();
3171 return AccessibleFactory::createAccessibleContext(pScrollBar);
3174 // css::lang::XComponent
3175 void VCLXScrollBar::dispose()
3177 SolarMutexGuard aGuard;
3179 css::lang::EventObject aObj;
3180 aObj.Source = getXWeak();
3181 maAdjustmentListeners.disposeAndClear( aObj );
3182 VCLXWindow::dispose();
3185 // css::awt::XScrollbar
3186 void VCLXScrollBar::addAdjustmentListener( const css::uno::Reference< css::awt::XAdjustmentListener > & l )
3188 SolarMutexGuard aGuard;
3189 maAdjustmentListeners.addInterface( l );
3192 void VCLXScrollBar::removeAdjustmentListener( const css::uno::Reference< css::awt::XAdjustmentListener > & l )
3194 SolarMutexGuard aGuard;
3195 maAdjustmentListeners.removeInterface( l );
3198 void VCLXScrollBar::setValue( sal_Int32 n )
3200 SolarMutexGuard aGuard;
3202 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3203 if ( pScrollBar )
3204 pScrollBar->DoScroll( n );
3207 void VCLXScrollBar::setValues( sal_Int32 nValue, sal_Int32 nVisible, sal_Int32 nMax )
3209 SolarMutexGuard aGuard;
3211 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3212 if ( pScrollBar )
3214 pScrollBar->SetVisibleSize( nVisible );
3215 pScrollBar->SetRangeMax( nMax );
3216 pScrollBar->DoScroll( nValue );
3220 sal_Int32 VCLXScrollBar::getValue()
3222 SolarMutexGuard aGuard;
3224 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3225 return pScrollBar ? pScrollBar->GetThumbPos() : 0;
3228 void VCLXScrollBar::setMaximum( sal_Int32 n )
3230 SolarMutexGuard aGuard;
3232 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3233 if ( pScrollBar )
3234 pScrollBar->SetRangeMax( n );
3237 sal_Int32 VCLXScrollBar::getMaximum()
3239 SolarMutexGuard aGuard;
3241 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3242 return pScrollBar ? pScrollBar->GetRangeMax() : 0;
3245 void VCLXScrollBar::setMinimum( sal_Int32 n )
3247 SolarMutexGuard aGuard;
3249 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3250 if ( pScrollBar )
3251 pScrollBar->SetRangeMin( n );
3254 sal_Int32 VCLXScrollBar::getMinimum() const
3256 SolarMutexGuard aGuard;
3258 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3259 return pScrollBar ? pScrollBar->GetRangeMin() : 0;
3262 void VCLXScrollBar::setLineIncrement( sal_Int32 n )
3264 SolarMutexGuard aGuard;
3266 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3267 if ( pScrollBar )
3268 pScrollBar->SetLineSize( n );
3271 sal_Int32 VCLXScrollBar::getLineIncrement()
3273 SolarMutexGuard aGuard;
3275 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3276 return pScrollBar ? pScrollBar->GetLineSize() : 0;
3279 void VCLXScrollBar::setBlockIncrement( sal_Int32 n )
3281 SolarMutexGuard aGuard;
3283 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3284 if ( pScrollBar )
3285 pScrollBar->SetPageSize( n );
3288 sal_Int32 VCLXScrollBar::getBlockIncrement()
3290 SolarMutexGuard aGuard;
3292 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3293 return pScrollBar ? pScrollBar->GetPageSize() : 0;
3296 void VCLXScrollBar::setVisibleSize( sal_Int32 n )
3298 SolarMutexGuard aGuard;
3300 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3301 if ( pScrollBar )
3302 pScrollBar->SetVisibleSize( n );
3305 sal_Int32 VCLXScrollBar::getVisibleSize()
3307 SolarMutexGuard aGuard;
3309 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3310 return pScrollBar ? pScrollBar->GetVisibleSize() : 0;
3313 void VCLXScrollBar::setOrientation( sal_Int32 n )
3315 SolarMutexGuard aGuard;
3317 VclPtr< vcl::Window > pWindow = GetWindow();
3318 if ( pWindow )
3320 WinBits nStyle = pWindow->GetStyle();
3321 nStyle &= ~(WB_HORZ|WB_VERT);
3322 if ( n == css::awt::ScrollBarOrientation::HORIZONTAL )
3323 nStyle |= WB_HORZ;
3324 else
3325 nStyle |= WB_VERT;
3327 pWindow->SetStyle( nStyle );
3328 pWindow->Resize();
3332 sal_Int32 VCLXScrollBar::getOrientation()
3334 SolarMutexGuard aGuard;
3336 sal_Int32 n = 0;
3337 VclPtr< vcl::Window > pWindow = GetWindow();
3338 if ( pWindow )
3340 WinBits nStyle = pWindow->GetStyle();
3341 if ( nStyle & WB_HORZ )
3342 n = css::awt::ScrollBarOrientation::HORIZONTAL;
3343 else
3344 n = css::awt::ScrollBarOrientation::VERTICAL;
3346 return n;
3350 // css::awt::VclWindowPeer
3351 void VCLXScrollBar::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
3353 SolarMutexGuard aGuard;
3355 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3356 if ( !pScrollBar )
3357 return;
3359 bool bVoid = Value.getValueTypeClass() == css::uno::TypeClass_VOID;
3361 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3362 switch ( nPropType )
3364 case BASEPROPERTY_LIVE_SCROLL:
3366 bool bDo = false;
3367 if ( !bVoid )
3369 OSL_VERIFY( Value >>= bDo );
3371 AllSettings aSettings( pScrollBar->GetSettings() );
3372 StyleSettings aStyle( aSettings.GetStyleSettings() );
3373 DragFullOptions nDragOptions = aStyle.GetDragFullOptions();
3374 if ( bDo )
3375 nDragOptions |= DragFullOptions::Scroll;
3376 else
3377 nDragOptions &= ~DragFullOptions::Scroll;
3378 aStyle.SetDragFullOptions( nDragOptions );
3379 aSettings.SetStyleSettings( aStyle );
3380 pScrollBar->SetSettings( aSettings );
3382 break;
3384 case BASEPROPERTY_SCROLLVALUE:
3386 if ( !bVoid )
3388 sal_Int32 n = 0;
3389 if ( Value >>= n )
3390 setValue( n );
3393 break;
3394 case BASEPROPERTY_SCROLLVALUE_MAX:
3395 case BASEPROPERTY_SCROLLVALUE_MIN:
3397 if ( !bVoid )
3399 sal_Int32 n = 0;
3400 if ( Value >>= n )
3402 if ( nPropType == BASEPROPERTY_SCROLLVALUE_MAX )
3403 setMaximum( n );
3404 else
3405 setMinimum( n );
3409 break;
3410 case BASEPROPERTY_LINEINCREMENT:
3412 if ( !bVoid )
3414 sal_Int32 n = 0;
3415 if ( Value >>= n )
3416 setLineIncrement( n );
3419 break;
3420 case BASEPROPERTY_BLOCKINCREMENT:
3422 if ( !bVoid )
3424 sal_Int32 n = 0;
3425 if ( Value >>= n )
3426 setBlockIncrement( n );
3429 break;
3430 case BASEPROPERTY_VISIBLESIZE:
3432 if ( !bVoid )
3434 sal_Int32 n = 0;
3435 if ( Value >>= n )
3436 setVisibleSize( n );
3439 break;
3440 case BASEPROPERTY_ORIENTATION:
3442 if ( !bVoid )
3444 sal_Int32 n = 0;
3445 if ( Value >>= n )
3446 setOrientation( n );
3449 break;
3451 case BASEPROPERTY_BACKGROUNDCOLOR:
3453 // the default implementation of the base class doesn't work here, since our
3454 // interpretation for this property is slightly different
3455 ::toolkit::setButtonLikeFaceColor( pScrollBar, Value);
3457 break;
3459 default:
3461 VCLXWindow::setProperty( PropertyName, Value );
3466 css::uno::Any VCLXScrollBar::getProperty( const OUString& PropertyName )
3468 SolarMutexGuard aGuard;
3470 css::uno::Any aProp;
3471 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3472 if ( pScrollBar )
3474 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3476 switch ( nPropType )
3478 case BASEPROPERTY_LIVE_SCROLL:
3480 aProp <<= bool( pScrollBar->GetSettings().GetStyleSettings().GetDragFullOptions() & DragFullOptions::Scroll );
3482 break;
3483 case BASEPROPERTY_SCROLLVALUE:
3485 aProp <<= getValue();
3487 break;
3488 case BASEPROPERTY_SCROLLVALUE_MAX:
3490 aProp <<= getMaximum();
3492 break;
3493 case BASEPROPERTY_SCROLLVALUE_MIN:
3495 aProp <<= getMinimum();
3497 break;
3498 case BASEPROPERTY_LINEINCREMENT:
3500 aProp <<= getLineIncrement();
3502 break;
3503 case BASEPROPERTY_BLOCKINCREMENT:
3505 aProp <<= getBlockIncrement();
3507 break;
3508 case BASEPROPERTY_VISIBLESIZE:
3510 aProp <<= getVisibleSize();
3512 break;
3513 case BASEPROPERTY_ORIENTATION:
3515 aProp <<= getOrientation();
3517 break;
3518 case BASEPROPERTY_BACKGROUNDCOLOR:
3520 // the default implementation of the base class doesn't work here, since our
3521 // interpretation for this property is slightly different
3522 aProp = ::toolkit::getButtonLikeFaceColor( pScrollBar );
3524 break;
3526 default:
3528 aProp = VCLXWindow::getProperty( PropertyName );
3532 return aProp;
3535 void VCLXScrollBar::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
3537 switch ( rVclWindowEvent.GetId() )
3539 case VclEventId::ScrollbarScroll:
3541 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
3542 // since we call listeners below, there is a potential that we will be destroyed
3543 // in during the listener call. To prevent the resulting crashes, we keep us
3544 // alive as long as we're here
3546 if ( maAdjustmentListeners.getLength() )
3548 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3550 if( pScrollBar )
3552 css::awt::AdjustmentEvent aEvent;
3553 aEvent.Source = getXWeak();
3554 aEvent.Value = pScrollBar->GetThumbPos();
3556 // set adjustment type
3557 ScrollType aType = pScrollBar->GetType();
3558 if ( aType == ScrollType::LineUp || aType == ScrollType::LineDown )
3560 aEvent.Type = css::awt::AdjustmentType_ADJUST_LINE;
3562 else if ( aType == ScrollType::PageUp || aType == ScrollType::PageDown )
3564 aEvent.Type = css::awt::AdjustmentType_ADJUST_PAGE;
3566 else if ( aType == ScrollType::Drag )
3568 aEvent.Type = css::awt::AdjustmentType_ADJUST_ABS;
3571 maAdjustmentListeners.adjustmentValueChanged( aEvent );
3575 break;
3577 default:
3578 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
3579 break;
3583 css::awt::Size VCLXScrollBar::implGetMinimumSize( vcl::Window const * p )
3585 tools::Long n = p->GetSettings().GetStyleSettings().GetScrollBarSize();
3586 return css::awt::Size( n, n );
3589 css::awt::Size SAL_CALL VCLXScrollBar::getMinimumSize()
3591 SolarMutexGuard aGuard;
3592 return implGetMinimumSize( GetWindow() );
3598 void VCLXEdit::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
3600 PushPropertyIds( rIds,
3601 BASEPROPERTY_ALIGN,
3602 BASEPROPERTY_BACKGROUNDCOLOR,
3603 BASEPROPERTY_BORDER,
3604 BASEPROPERTY_BORDERCOLOR,
3605 BASEPROPERTY_DEFAULTCONTROL,
3606 BASEPROPERTY_ECHOCHAR,
3607 BASEPROPERTY_ENABLED,
3608 BASEPROPERTY_ENABLEVISIBLE,
3609 BASEPROPERTY_FONTDESCRIPTOR,
3610 BASEPROPERTY_HARDLINEBREAKS,
3611 BASEPROPERTY_HELPTEXT,
3612 BASEPROPERTY_HELPURL,
3613 BASEPROPERTY_HSCROLL,
3614 BASEPROPERTY_LINE_END_FORMAT,
3615 BASEPROPERTY_MAXTEXTLEN,
3616 BASEPROPERTY_MULTILINE,
3617 BASEPROPERTY_PRINTABLE,
3618 BASEPROPERTY_READONLY,
3619 BASEPROPERTY_TABSTOP,
3620 BASEPROPERTY_TEXT,
3621 BASEPROPERTY_VSCROLL,
3622 BASEPROPERTY_HIDEINACTIVESELECTION,
3623 BASEPROPERTY_PAINTTRANSPARENT,
3624 BASEPROPERTY_AUTOHSCROLL,
3625 BASEPROPERTY_AUTOVSCROLL,
3626 BASEPROPERTY_VERTICALALIGN,
3627 BASEPROPERTY_WRITING_MODE,
3628 BASEPROPERTY_CONTEXT_WRITING_MODE,
3629 BASEPROPERTY_HIGHLIGHT_COLOR,
3630 BASEPROPERTY_HIGHLIGHT_TEXT_COLOR,
3632 VCLXWindow::ImplGetPropertyIds( rIds );
3635 VCLXEdit::VCLXEdit() : maTextListeners( *this )
3639 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXEdit::CreateAccessibleContext()
3641 VclPtr<Edit> pEdit = GetAs<Edit>();
3642 return AccessibleFactory::createAccessibleContext(pEdit);
3645 void VCLXEdit::dispose()
3647 SolarMutexGuard aGuard;
3649 css::lang::EventObject aObj;
3650 aObj.Source = getXWeak();
3651 maTextListeners.disposeAndClear( aObj );
3652 VCLXWindow::dispose();
3655 void VCLXEdit::addTextListener( const css::uno::Reference< css::awt::XTextListener > & l )
3657 SolarMutexGuard aGuard;
3658 GetTextListeners().addInterface( l );
3661 void VCLXEdit::removeTextListener( const css::uno::Reference< css::awt::XTextListener > & l )
3663 SolarMutexGuard aGuard;
3664 GetTextListeners().removeInterface( l );
3667 void VCLXEdit::setText( const OUString& aText )
3669 SolarMutexGuard aGuard;
3671 VclPtr< Edit > pEdit = GetAs< Edit >();
3672 if ( pEdit )
3674 pEdit->SetText( aText );
3676 // #107218# Call same listeners like VCL would do after user interaction
3677 SetSynthesizingVCLEvent( true );
3678 pEdit->SetModifyFlag();
3679 pEdit->Modify();
3680 SetSynthesizingVCLEvent( false );
3684 void VCLXEdit::insertText( const css::awt::Selection& rSel, const OUString& aText )
3686 SolarMutexGuard aGuard;
3688 VclPtr< Edit > pEdit = GetAs< Edit >();
3689 if ( pEdit )
3691 pEdit->SetSelection( Selection( rSel.Min, rSel.Max ) );
3692 pEdit->ReplaceSelected( aText );
3694 // #107218# Call same listeners like VCL would do after user interaction
3695 SetSynthesizingVCLEvent( true );
3696 pEdit->SetModifyFlag();
3697 pEdit->Modify();
3698 SetSynthesizingVCLEvent( false );
3702 OUString VCLXEdit::getText()
3704 SolarMutexGuard aGuard;
3706 OUString aText;
3707 VclPtr< vcl::Window > pWindow = GetWindow();
3708 if ( pWindow )
3709 aText = pWindow->GetText();
3710 return aText;
3713 OUString VCLXEdit::getSelectedText()
3715 SolarMutexGuard aGuard;
3717 OUString aText;
3718 VclPtr< Edit > pEdit = GetAs< Edit >();
3719 if ( pEdit)
3720 aText = pEdit->GetSelected();
3721 return aText;
3725 void VCLXEdit::setSelection( const css::awt::Selection& aSelection )
3727 SolarMutexGuard aGuard;
3729 VclPtr< Edit > pEdit = GetAs< Edit >();
3730 if ( pEdit )
3731 pEdit->SetSelection( Selection( aSelection.Min, aSelection.Max ) );
3734 css::awt::Selection VCLXEdit::getSelection()
3736 SolarMutexGuard aGuard;
3738 Selection aSel;
3739 VclPtr< Edit > pEdit = GetAs< Edit >();
3740 if ( pEdit )
3741 aSel = pEdit->GetSelection();
3742 return css::awt::Selection( aSel.Min(), aSel.Max() );
3745 sal_Bool VCLXEdit::isEditable()
3747 SolarMutexGuard aGuard;
3749 VclPtr< Edit > pEdit = GetAs< Edit >();
3750 return pEdit && !pEdit->IsReadOnly() && pEdit->IsEnabled();
3753 void VCLXEdit::setEditable( sal_Bool bEditable )
3755 SolarMutexGuard aGuard;
3757 VclPtr< Edit > pEdit = GetAs< Edit >();
3758 if ( pEdit )
3759 pEdit->SetReadOnly( !bEditable );
3763 void VCLXEdit::setMaxTextLen( sal_Int16 nLen )
3765 SolarMutexGuard aGuard;
3767 VclPtr< Edit > pEdit = GetAs< Edit >();
3768 if ( pEdit )
3769 pEdit->SetMaxTextLen( nLen );
3772 sal_Int16 VCLXEdit::getMaxTextLen()
3774 SolarMutexGuard aGuard;
3776 VclPtr< Edit > pEdit = GetAs< Edit >();
3777 return pEdit ? pEdit->GetMaxTextLen() : 0;
3780 void VCLXEdit::setEchoChar( sal_Unicode cEcho )
3782 SolarMutexGuard aGuard;
3784 VclPtr< Edit > pEdit = GetAs< Edit >();
3785 if ( pEdit )
3786 pEdit->SetEchoChar( cEcho );
3789 void VCLXEdit::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
3791 SolarMutexGuard aGuard;
3793 VclPtr< Edit > pEdit = GetAs< Edit >();
3794 if ( !pEdit )
3795 return;
3797 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3798 switch ( nPropType )
3800 case BASEPROPERTY_HIDEINACTIVESELECTION:
3801 ::toolkit::adjustBooleanWindowStyle( Value, pEdit, WB_NOHIDESELECTION, true );
3802 if ( pEdit->GetSubEdit() )
3803 ::toolkit::adjustBooleanWindowStyle( Value, pEdit->GetSubEdit(), WB_NOHIDESELECTION, true );
3804 break;
3806 case BASEPROPERTY_READONLY:
3808 bool b = bool();
3809 if ( Value >>= b )
3810 pEdit->SetReadOnly( b );
3812 break;
3813 case BASEPROPERTY_ECHOCHAR:
3815 sal_Int16 n = sal_Int16();
3816 if ( Value >>= n )
3817 pEdit->SetEchoChar( n );
3819 break;
3820 case BASEPROPERTY_MAXTEXTLEN:
3822 sal_Int16 n = sal_Int16();
3823 if ( Value >>= n )
3824 pEdit->SetMaxTextLen( n );
3826 break;
3827 default:
3829 VCLXWindow::setProperty( PropertyName, Value );
3834 css::uno::Any VCLXEdit::getProperty( const OUString& PropertyName )
3836 SolarMutexGuard aGuard;
3838 css::uno::Any aProp;
3839 VclPtr< Edit > pEdit = GetAs< Edit >();
3840 if ( pEdit )
3842 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3843 switch ( nPropType )
3845 case BASEPROPERTY_HIDEINACTIVESELECTION:
3846 aProp <<= ( ( pEdit->GetStyle() & WB_NOHIDESELECTION ) == 0 );
3847 break;
3848 case BASEPROPERTY_READONLY:
3849 aProp <<= pEdit->IsReadOnly();
3850 break;
3851 case BASEPROPERTY_ECHOCHAR:
3852 aProp <<= static_cast<sal_Int16>(pEdit->GetEchoChar());
3853 break;
3854 case BASEPROPERTY_MAXTEXTLEN:
3855 aProp <<= static_cast<sal_Int16>(pEdit->GetMaxTextLen());
3856 break;
3857 default:
3859 aProp = VCLXWindow::getProperty( PropertyName );
3863 return aProp;
3866 css::awt::Size VCLXEdit::getMinimumSize( )
3868 SolarMutexGuard aGuard;
3870 Size aSz;
3871 VclPtr< Edit > pEdit = GetAs< Edit >();
3872 if ( pEdit )
3873 aSz = pEdit->CalcMinimumSize();
3874 return vcl::unohelper::ConvertToAWTSize(aSz);
3877 css::awt::Size VCLXEdit::getPreferredSize( )
3879 SolarMutexGuard aGuard;
3881 Size aSz;
3882 VclPtr< Edit > pEdit = GetAs< Edit >();
3883 if ( pEdit )
3885 aSz = pEdit->CalcMinimumSize();
3886 aSz.AdjustHeight(4 );
3888 return vcl::unohelper::ConvertToAWTSize(aSz);
3891 css::awt::Size VCLXEdit::calcAdjustedSize( const css::awt::Size& rNewSize )
3893 SolarMutexGuard aGuard;
3895 css::awt::Size aSz = rNewSize;
3896 css::awt::Size aMinSz = getMinimumSize();
3897 if ( aSz.Height != aMinSz.Height )
3898 aSz.Height = aMinSz.Height;
3900 return aSz;
3903 css::awt::Size VCLXEdit::getMinimumSize( sal_Int16 nCols, sal_Int16 )
3905 SolarMutexGuard aGuard;
3907 Size aSz;
3908 VclPtr< Edit > pEdit = GetAs< Edit >();
3909 if ( pEdit )
3911 if ( nCols )
3912 aSz = pEdit->CalcSize( nCols );
3913 else
3914 aSz = pEdit->CalcMinimumSize();
3916 return vcl::unohelper::ConvertToAWTSize(aSz);
3919 void VCLXEdit::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines )
3921 SolarMutexGuard aGuard;
3923 nLines = 1;
3924 nCols = 0;
3925 VclPtr< Edit > pEdit = GetAs< Edit >();
3926 if ( pEdit )
3927 nCols = pEdit->GetMaxVisChars();
3930 void VCLXEdit::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
3932 switch ( rVclWindowEvent.GetId() )
3934 case VclEventId::EditModify:
3936 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
3937 // since we call listeners below, there is a potential that we will be destroyed
3938 // during the listener call. To prevent the resulting crashes, we keep us
3939 // alive as long as we're here
3941 if ( GetTextListeners().getLength() )
3943 css::awt::TextEvent aEvent;
3944 aEvent.Source = getXWeak();
3945 GetTextListeners().textChanged( aEvent );
3948 break;
3950 default:
3951 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
3952 break;
3959 void VCLXComboBox::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
3961 PushPropertyIds( rIds,
3962 BASEPROPERTY_AUTOCOMPLETE,
3963 BASEPROPERTY_BACKGROUNDCOLOR,
3964 BASEPROPERTY_BORDER,
3965 BASEPROPERTY_BORDERCOLOR,
3966 BASEPROPERTY_DEFAULTCONTROL,
3967 BASEPROPERTY_DROPDOWN,
3968 BASEPROPERTY_ENABLED,
3969 BASEPROPERTY_ENABLEVISIBLE,
3970 BASEPROPERTY_FONTDESCRIPTOR,
3971 BASEPROPERTY_HELPTEXT,
3972 BASEPROPERTY_HELPURL,
3973 BASEPROPERTY_LINECOUNT,
3974 BASEPROPERTY_MAXTEXTLEN,
3975 BASEPROPERTY_PRINTABLE,
3976 BASEPROPERTY_READONLY,
3977 BASEPROPERTY_STRINGITEMLIST,
3978 BASEPROPERTY_TYPEDITEMLIST,
3979 BASEPROPERTY_TABSTOP,
3980 BASEPROPERTY_TEXT,
3981 BASEPROPERTY_HIDEINACTIVESELECTION,
3982 BASEPROPERTY_ALIGN,
3983 BASEPROPERTY_WRITING_MODE,
3984 BASEPROPERTY_CONTEXT_WRITING_MODE,
3985 BASEPROPERTY_REFERENCE_DEVICE,
3986 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
3987 BASEPROPERTY_HIGHLIGHT_COLOR,
3988 BASEPROPERTY_HIGHLIGHT_TEXT_COLOR,
3990 // no, don't call VCLXEdit here - it has properties which we do *not* want to have at combo box
3991 // #i92690# / 2008-08-12 / frank.schoenheit@sun.com
3992 // VCLXEdit::ImplGetPropertyIds( rIds );
3993 VCLXWindow::ImplGetPropertyIds( rIds );
3996 VCLXComboBox::VCLXComboBox()
3997 : maActionListeners( *this ), maItemListeners( *this )
4001 VCLXComboBox::~VCLXComboBox()
4003 SAL_INFO("toolkit", __FUNCTION__);
4006 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXComboBox::CreateAccessibleContext()
4008 SolarMutexGuard aGuard;
4010 VclPtr<ComboBox> pComboBox = GetAs<ComboBox>();
4011 return AccessibleFactory::createAccessibleContext(pComboBox);
4014 void VCLXComboBox::dispose()
4016 SolarMutexGuard aGuard;
4018 css::lang::EventObject aObj;
4019 aObj.Source = getXWeak();
4020 maItemListeners.disposeAndClear( aObj );
4021 maActionListeners.disposeAndClear( aObj );
4022 VCLXEdit::dispose();
4026 void VCLXComboBox::addItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
4028 SolarMutexGuard aGuard;
4029 maItemListeners.addInterface( l );
4032 void VCLXComboBox::removeItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
4034 SolarMutexGuard aGuard;
4035 maItemListeners.removeInterface( l );
4038 void VCLXComboBox::addActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
4040 SolarMutexGuard aGuard;
4041 maActionListeners.addInterface( l );
4044 void VCLXComboBox::removeActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
4046 SolarMutexGuard aGuard;
4047 maActionListeners.removeInterface( l );
4050 void VCLXComboBox::addItem( const OUString& aItem, sal_Int16 nPos )
4052 SolarMutexGuard aGuard;
4054 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4055 if ( pBox )
4056 pBox->InsertEntry( aItem, nPos );
4059 void VCLXComboBox::addItems( const css::uno::Sequence< OUString>& aItems, sal_Int16 nPos )
4061 SolarMutexGuard aGuard;
4063 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4064 if ( !pBox )
4065 return;
4067 sal_uInt16 nP = nPos;
4068 for ( const auto& rItem : aItems )
4070 pBox->InsertEntry( rItem, nP );
4071 if ( nP == 0xFFFF )
4073 OSL_FAIL( "VCLXComboBox::addItems: too many entries!" );
4074 // skip remaining entries, list cannot hold them, anyway
4075 break;
4080 void VCLXComboBox::removeItems( sal_Int16 nPos, sal_Int16 nCount )
4082 SolarMutexGuard aGuard;
4084 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4085 if ( pBox )
4087 for ( sal_uInt16 n = nCount; n; )
4088 pBox->RemoveEntryAt( nPos + (--n) );
4092 sal_Int16 VCLXComboBox::getItemCount()
4094 SolarMutexGuard aGuard;
4096 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4097 return pBox ? pBox->GetEntryCount() : 0;
4100 OUString VCLXComboBox::getItem( sal_Int16 nPos )
4102 SolarMutexGuard aGuard;
4104 OUString aItem;
4105 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4106 if ( pBox )
4107 aItem = pBox->GetEntry( nPos );
4108 return aItem;
4111 css::uno::Sequence< OUString> VCLXComboBox::getItems()
4113 SolarMutexGuard aGuard;
4115 css::uno::Sequence< OUString> aSeq;
4116 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4117 if ( pBox )
4119 auto n = pBox->GetEntryCount();
4120 aSeq = css::uno::Sequence< OUString>( n );
4121 while ( n )
4123 --n;
4124 aSeq.getArray()[n] = pBox->GetEntry( n );
4127 return aSeq;
4130 void VCLXComboBox::setDropDownLineCount( sal_Int16 nLines )
4132 SolarMutexGuard aGuard;
4134 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4135 if ( pBox )
4136 pBox->SetDropDownLineCount( nLines );
4139 sal_Int16 VCLXComboBox::getDropDownLineCount()
4141 SolarMutexGuard aGuard;
4143 sal_Int16 nLines = 0;
4144 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4145 if ( pBox )
4146 nLines = pBox->GetDropDownLineCount();
4147 return nLines;
4150 void VCLXComboBox::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
4152 SolarMutexGuard aGuard;
4154 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4155 if ( !pComboBox )
4156 return;
4158 bool bVoid = Value.getValueTypeClass() == css::uno::TypeClass_VOID;
4159 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4160 switch ( nPropType )
4162 case BASEPROPERTY_LINECOUNT:
4164 sal_Int16 n = sal_Int16();
4165 if ( Value >>= n )
4166 pComboBox->SetDropDownLineCount( n );
4168 break;
4169 case BASEPROPERTY_AUTOCOMPLETE:
4171 sal_Int16 n = sal_Int16();
4172 if ( Value >>= n )
4173 pComboBox->EnableAutocomplete( n != 0 );
4174 else
4176 bool b = bool();
4177 if ( Value >>= b )
4178 pComboBox->EnableAutocomplete( b );
4181 break;
4182 case BASEPROPERTY_STRINGITEMLIST:
4184 css::uno::Sequence< OUString> aItems;
4185 if ( Value >>= aItems )
4187 pComboBox->Clear();
4188 addItems( aItems, 0 );
4191 break;
4192 case BASEPROPERTY_HIGHLIGHT_COLOR:
4194 Color nColor = 0;
4195 if (bVoid)
4197 nColor = Application::GetSettings().GetStyleSettings().GetHighlightColor();
4199 else
4201 if (!(Value >>= nColor))
4202 break;
4204 pComboBox->SetHighlightColor(nColor);
4206 break;
4207 case BASEPROPERTY_HIGHLIGHT_TEXT_COLOR:
4209 Color nColor = 0;
4210 if (bVoid)
4212 nColor = Application::GetSettings().GetStyleSettings().GetHighlightTextColor();
4214 else
4216 if (!(Value >>= nColor))
4217 break;
4219 pComboBox->SetHighlightTextColor(nColor);
4221 break;
4222 default:
4224 VCLXEdit::setProperty( PropertyName, Value );
4226 // #109385# SetBorderStyle is not virtual
4227 if ( nPropType == BASEPROPERTY_BORDER )
4229 sal_uInt16 nBorder = sal_uInt16();
4230 if ( (Value >>= nBorder) && nBorder != 0 )
4231 pComboBox->SetBorderStyle( static_cast<WindowBorderStyle>(nBorder) );
4237 css::uno::Any VCLXComboBox::getProperty( const OUString& PropertyName )
4239 SolarMutexGuard aGuard;
4241 css::uno::Any aProp;
4242 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4243 if ( pComboBox )
4245 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4246 switch ( nPropType )
4248 case BASEPROPERTY_LINECOUNT:
4250 aProp <<= static_cast<sal_Int16>(pComboBox->GetDropDownLineCount());
4252 break;
4253 case BASEPROPERTY_AUTOCOMPLETE:
4255 aProp <<= pComboBox->IsAutocompleteEnabled();
4257 break;
4258 case BASEPROPERTY_STRINGITEMLIST:
4260 const sal_Int32 nItems = pComboBox->GetEntryCount();
4261 css::uno::Sequence< OUString> aSeq( nItems );
4262 OUString* pStrings = aSeq.getArray();
4263 for ( sal_Int32 n = 0; n < nItems; ++n )
4264 pStrings[n] = pComboBox->GetEntry( n );
4265 aProp <<= aSeq;
4268 break;
4269 default:
4271 aProp = VCLXEdit::getProperty( PropertyName );
4275 return aProp;
4278 void VCLXComboBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
4280 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
4281 // since we call listeners below, there is a potential that we will be destroyed
4282 // during the listener call. To prevent the resulting crashes, we keep us
4283 // alive as long as we're here
4285 switch ( rVclWindowEvent.GetId() )
4287 case VclEventId::ComboboxSelect:
4288 if ( maItemListeners.getLength() )
4290 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4291 if( pComboBox )
4293 if ( !pComboBox->IsTravelSelect() )
4295 css::awt::ItemEvent aEvent;
4296 aEvent.Source = getXWeak();
4297 aEvent.Highlighted = 0;
4299 // Set to 0xFFFF on multiple selection, selected entry ID otherwise
4300 aEvent.Selected = pComboBox->GetEntryPos( pComboBox->GetText() );
4302 maItemListeners.itemStateChanged( aEvent );
4306 break;
4308 case VclEventId::ComboboxDoubleClick:
4309 if ( maActionListeners.getLength() )
4311 css::awt::ActionEvent aEvent;
4312 aEvent.Source = getXWeak();
4313 // aEvent.ActionCommand = ...;
4314 maActionListeners.actionPerformed( aEvent );
4316 break;
4318 default:
4319 VCLXEdit::ProcessWindowEvent( rVclWindowEvent );
4320 break;
4324 css::awt::Size VCLXComboBox::getMinimumSize( )
4326 SolarMutexGuard aGuard;
4328 Size aSz;
4329 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4330 if ( pComboBox )
4331 aSz = pComboBox->CalcMinimumSize();
4332 return vcl::unohelper::ConvertToAWTSize(aSz);
4335 css::awt::Size VCLXComboBox::getPreferredSize( )
4337 SolarMutexGuard aGuard;
4339 Size aSz;
4340 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4341 if ( pComboBox )
4343 aSz = pComboBox->CalcMinimumSize();
4344 if ( pComboBox->GetStyle() & WB_DROPDOWN )
4345 aSz.AdjustHeight(4 );
4347 return vcl::unohelper::ConvertToAWTSize(aSz);
4350 css::awt::Size VCLXComboBox::calcAdjustedSize( const css::awt::Size& rNewSize )
4352 SolarMutexGuard aGuard;
4354 Size aSz = vcl::unohelper::ConvertToVCLSize(rNewSize);
4355 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4356 if ( pComboBox )
4357 aSz = pComboBox->CalcAdjustedSize( aSz );
4358 return vcl::unohelper::ConvertToAWTSize(aSz);
4361 css::awt::Size VCLXComboBox::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines )
4363 SolarMutexGuard aGuard;
4365 Size aSz;
4366 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4367 if ( pComboBox )
4368 aSz = pComboBox->CalcBlockSize( nCols, nLines );
4369 return vcl::unohelper::ConvertToAWTSize(aSz);
4372 void VCLXComboBox::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines )
4374 SolarMutexGuard aGuard;
4376 nCols = nLines = 0;
4377 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4378 if ( pComboBox )
4380 sal_uInt16 nC, nL;
4381 pComboBox->GetMaxVisColumnsAndLines( nC, nL );
4382 nCols = nC;
4383 nLines = nL;
4386 void SAL_CALL VCLXComboBox::listItemInserted( const ItemListEvent& i_rEvent )
4388 SolarMutexGuard aGuard;
4390 VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >();
4392 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemInserted: no ComboBox?!" );
4393 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition <= pComboBox->GetEntryCount() ),
4394 "VCLXComboBox::listItemInserted: illegal (inconsistent) item position!" );
4395 pComboBox->InsertEntryWithImage(
4396 i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : OUString(),
4397 i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : Image(),
4398 i_rEvent.ItemPosition );
4401 void SAL_CALL VCLXComboBox::listItemRemoved( const ItemListEvent& i_rEvent )
4403 SolarMutexGuard aGuard;
4405 VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >();
4407 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemRemoved: no ComboBox?!" );
4408 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < pComboBox->GetEntryCount() ),
4409 "VCLXComboBox::listItemRemoved: illegal (inconsistent) item position!" );
4411 pComboBox->RemoveEntryAt( i_rEvent.ItemPosition );
4414 void SAL_CALL VCLXComboBox::listItemModified( const ItemListEvent& i_rEvent )
4416 SolarMutexGuard aGuard;
4418 VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >();
4420 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" );
4421 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < pComboBox->GetEntryCount() ),
4422 "VCLXComboBox::listItemModified: illegal (inconsistent) item position!" );
4424 // VCL's ComboBox does not support changing an entry's text or image, so remove and re-insert
4426 const OUString sNewText = i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : pComboBox->GetEntry( i_rEvent.ItemPosition );
4427 const Image aNewImage( i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : pComboBox->GetEntryImage( i_rEvent.ItemPosition ) );
4429 pComboBox->RemoveEntryAt( i_rEvent.ItemPosition );
4430 pComboBox->InsertEntryWithImage(sNewText, aNewImage, i_rEvent.ItemPosition);
4433 void SAL_CALL VCLXComboBox::allItemsRemoved( const EventObject& )
4435 SolarMutexGuard aGuard;
4437 VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >();
4438 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" );
4440 pComboBox->Clear();
4443 void SAL_CALL VCLXComboBox::itemListChanged( const EventObject& i_rEvent )
4445 SolarMutexGuard aGuard;
4447 VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >();
4448 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" );
4450 pComboBox->Clear();
4452 uno::Reference< beans::XPropertySet > xPropSet( i_rEvent.Source, uno::UNO_QUERY_THROW );
4453 uno::Reference< beans::XPropertySetInfo > xPSI( xPropSet->getPropertySetInfo(), uno::UNO_SET_THROW );
4454 // bool localize = xPSI->hasPropertyByName("ResourceResolver");
4455 uno::Reference< resource::XStringResourceResolver > xStringResourceResolver;
4456 if ( xPSI->hasPropertyByName(u"ResourceResolver"_ustr) )
4458 xStringResourceResolver.set(
4459 xPropSet->getPropertyValue(u"ResourceResolver"_ustr),
4460 uno::UNO_QUERY
4465 Reference< XItemList > xItemList( i_rEvent.Source, uno::UNO_QUERY_THROW );
4466 const uno::Sequence< beans::Pair< OUString, OUString > > aItems = xItemList->getAllItems();
4467 for ( const auto& rItem : aItems )
4469 OUString aLocalizationKey( rItem.First );
4470 if ( xStringResourceResolver.is() && !aLocalizationKey.isEmpty() && aLocalizationKey[0] == '&' )
4472 aLocalizationKey = xStringResourceResolver->resolveString(aLocalizationKey.copy( 1 ));
4474 pComboBox->InsertEntryWithImage(aLocalizationKey,
4475 lcl_getImageFromURL(rItem.Second));
4478 void SAL_CALL VCLXComboBox::disposing( const EventObject& i_rEvent )
4480 // just disambiguate
4481 VCLXEdit::disposing( i_rEvent );
4486 void VCLXFormattedSpinField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
4488 // Interestingly in the UnoControl API this is
4489 // - not derived from XEdit ultimately, (correct ?) - so cut this here ...
4490 // VCLXSpinField::ImplGetPropertyIds( rIds );
4491 VCLXWindow::ImplGetPropertyIds( rIds );
4494 VCLXFormattedSpinField::VCLXFormattedSpinField()
4495 : mpFormatter(nullptr)
4499 VCLXFormattedSpinField::~VCLXFormattedSpinField()
4503 void VCLXFormattedSpinField::setStrictFormat( bool bStrict )
4505 SolarMutexGuard aGuard;
4507 FormatterBase* pFormatter = GetFormatter();
4508 if ( pFormatter )
4509 pFormatter->SetStrictFormat( bStrict );
4512 bool VCLXFormattedSpinField::isStrictFormat() const
4514 FormatterBase* pFormatter = GetFormatter();
4515 return pFormatter && pFormatter->IsStrictFormat();
4519 void VCLXFormattedSpinField::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
4521 SolarMutexGuard aGuard;
4523 FormatterBase* pFormatter = GetFormatter();
4524 if ( !pFormatter )
4525 return;
4527 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4528 switch ( nPropType )
4530 case BASEPROPERTY_SPIN:
4532 bool b = bool();
4533 if ( Value >>= b )
4535 WinBits nStyle = GetWindow()->GetStyle() | WB_SPIN;
4536 if ( !b )
4537 nStyle &= ~WB_SPIN;
4538 GetWindow()->SetStyle( nStyle );
4541 break;
4542 case BASEPROPERTY_STRICTFORMAT:
4544 bool b = bool();
4545 if ( Value >>= b )
4547 pFormatter->SetStrictFormat( b );
4550 break;
4551 default:
4553 VCLXSpinField::setProperty( PropertyName, Value );
4558 css::uno::Any VCLXFormattedSpinField::getProperty( const OUString& PropertyName )
4560 SolarMutexGuard aGuard;
4562 css::uno::Any aProp;
4563 FormatterBase* pFormatter = GetFormatter();
4564 if ( pFormatter )
4566 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4567 switch ( nPropType )
4569 case BASEPROPERTY_TABSTOP:
4571 aProp <<= ( GetWindow()->GetStyle() & WB_SPIN ) != 0;
4573 break;
4574 case BASEPROPERTY_STRICTFORMAT:
4576 aProp <<= pFormatter->IsStrictFormat();
4578 break;
4579 default:
4581 aProp = VCLXSpinField::getProperty( PropertyName );
4585 return aProp;
4591 void VCLXDateField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
4593 PushPropertyIds( rIds,
4594 BASEPROPERTY_ALIGN,
4595 BASEPROPERTY_BACKGROUNDCOLOR,
4596 BASEPROPERTY_BORDER,
4597 BASEPROPERTY_BORDERCOLOR,
4598 BASEPROPERTY_DATE,
4599 BASEPROPERTY_DATEMAX,
4600 BASEPROPERTY_DATEMIN,
4601 BASEPROPERTY_DATESHOWCENTURY,
4602 BASEPROPERTY_DEFAULTCONTROL,
4603 BASEPROPERTY_DROPDOWN,
4604 BASEPROPERTY_ENABLED,
4605 BASEPROPERTY_ENABLEVISIBLE,
4606 BASEPROPERTY_EXTDATEFORMAT,
4607 BASEPROPERTY_FONTDESCRIPTOR,
4608 BASEPROPERTY_HELPTEXT,
4609 BASEPROPERTY_HELPURL,
4610 BASEPROPERTY_PRINTABLE,
4611 BASEPROPERTY_READONLY,
4612 BASEPROPERTY_REPEAT,
4613 BASEPROPERTY_REPEAT_DELAY,
4614 BASEPROPERTY_SPIN,
4615 BASEPROPERTY_STRICTFORMAT,
4616 BASEPROPERTY_TABSTOP,
4617 BASEPROPERTY_ENFORCE_FORMAT,
4618 BASEPROPERTY_TEXT,
4619 BASEPROPERTY_HIDEINACTIVESELECTION,
4620 BASEPROPERTY_VERTICALALIGN,
4621 BASEPROPERTY_WRITING_MODE,
4622 BASEPROPERTY_CONTEXT_WRITING_MODE,
4623 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
4624 BASEPROPERTY_HIGHLIGHT_COLOR,
4625 BASEPROPERTY_HIGHLIGHT_TEXT_COLOR,
4627 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
4630 VCLXDateField::VCLXDateField()
4634 VCLXDateField::~VCLXDateField()
4638 //change the window type here to match the role
4639 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXDateField::CreateAccessibleContext()
4641 VclPtr<Edit> pEdit = GetAs<Edit>();
4642 if (pEdit)
4644 pEdit->SetType( WindowType::DATEFIELD );
4646 return AccessibleFactory::createAccessibleContext(pEdit);
4649 void VCLXDateField::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
4651 SolarMutexGuard aGuard;
4653 if ( !(GetWindow()) )
4654 return;
4656 bool bVoid = Value.getValueTypeClass() == css::uno::TypeClass_VOID;
4658 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4659 switch ( nPropType )
4661 case BASEPROPERTY_DATE:
4663 if ( bVoid )
4665 GetAs< DateField >()->EnableEmptyFieldValue( true );
4666 GetAs< DateField >()->SetEmptyFieldValue();
4668 else
4670 util::Date d;
4671 if ((Value >>= d) && d.Year != 0)
4672 setDate( d );
4675 break;
4676 case BASEPROPERTY_DATEMIN:
4678 util::Date d;
4679 if ((Value >>= d) && d.Year != 0)
4680 setMin( d );
4682 break;
4683 case BASEPROPERTY_DATEMAX:
4685 util::Date d;
4686 if ((Value >>= d) && d.Year != 0)
4687 setMax( d );
4689 break;
4690 case BASEPROPERTY_EXTDATEFORMAT:
4692 sal_Int16 n = sal_Int16();
4693 if ( Value >>= n )
4694 GetAs< DateField >()->SetExtDateFormat( static_cast<ExtDateFieldFormat>(n) );
4696 break;
4697 case BASEPROPERTY_DATESHOWCENTURY:
4699 bool b = bool();
4700 if ( Value >>= b )
4701 GetAs< DateField >()->SetShowDateCentury( b );
4703 break;
4704 case BASEPROPERTY_ENFORCE_FORMAT:
4706 bool bEnforce( true );
4707 OSL_VERIFY( Value >>= bEnforce );
4708 GetAs< DateField >()->EnforceValidValue( bEnforce );
4710 break;
4711 default:
4713 VCLXFormattedSpinField::setProperty( PropertyName, Value );
4718 css::uno::Any VCLXDateField::getProperty( const OUString& PropertyName )
4720 SolarMutexGuard aGuard;
4722 css::uno::Any aProp;
4723 FormatterBase* pFormatter = GetFormatter();
4724 if ( pFormatter )
4726 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4727 switch ( nPropType )
4729 case BASEPROPERTY_DATE:
4731 aProp <<= getDate();
4733 break;
4734 case BASEPROPERTY_DATEMIN:
4736 aProp <<= getMin();
4738 break;
4739 case BASEPROPERTY_DATEMAX:
4741 aProp <<= getMax();
4743 break;
4744 case BASEPROPERTY_DATESHOWCENTURY:
4746 aProp <<= GetAs< DateField >()->IsShowDateCentury();
4748 break;
4749 case BASEPROPERTY_ENFORCE_FORMAT:
4751 aProp <<= GetAs< DateField >()->IsEnforceValidValue( );
4753 break;
4754 default:
4756 aProp = VCLXFormattedSpinField::getProperty( PropertyName );
4760 return aProp;
4764 void VCLXDateField::setDate( const util::Date& aDate )
4766 SolarMutexGuard aGuard;
4768 VclPtr< DateField > pDateField = GetAs< DateField >();
4769 if ( pDateField )
4771 pDateField->SetDate( ::Date(aDate) );
4773 // #107218# Call same listeners like VCL would do after user interaction
4774 SetSynthesizingVCLEvent( true );
4775 pDateField->SetModifyFlag();
4776 pDateField->Modify();
4777 SetSynthesizingVCLEvent( false );
4781 util::Date VCLXDateField::getDate()
4783 SolarMutexGuard aGuard;
4785 VclPtr< DateField > pDateField = GetAs< DateField >();
4786 if ( pDateField )
4787 return pDateField->GetDate().GetUNODate();
4788 else
4789 return util::Date();
4792 void VCLXDateField::setMin( const util::Date& aDate )
4794 SolarMutexGuard aGuard;
4796 VclPtr< DateField > pDateField = GetAs< DateField >();
4797 if ( pDateField )
4798 pDateField->SetMin( ::Date(aDate) );
4801 util::Date VCLXDateField::getMin()
4803 SolarMutexGuard aGuard;
4805 VclPtr< DateField > pDateField = GetAs< DateField >();
4806 if ( pDateField )
4807 return pDateField->GetMin().GetUNODate();
4808 else
4809 return util::Date();
4812 void VCLXDateField::setMax( const util::Date& aDate )
4814 SolarMutexGuard aGuard;
4816 VclPtr< DateField > pDateField = GetAs< DateField >();
4817 if ( pDateField )
4818 pDateField->SetMax( ::Date(aDate) );
4821 util::Date VCLXDateField::getMax()
4823 SolarMutexGuard aGuard;
4825 VclPtr< DateField > pDateField = GetAs< DateField >();
4826 if ( pDateField )
4827 return pDateField->GetMax().GetUNODate();
4828 else
4829 return util::Date();
4832 void VCLXDateField::setFirst( const util::Date& aDate )
4834 SolarMutexGuard aGuard;
4836 VclPtr< DateField > pDateField = GetAs< DateField >();
4837 if ( pDateField )
4838 pDateField->SetFirst( ::Date(aDate) );
4841 util::Date VCLXDateField::getFirst()
4843 SolarMutexGuard aGuard;
4845 VclPtr< DateField > pDateField = GetAs< DateField >();
4846 if ( pDateField )
4847 return pDateField->GetFirst().GetUNODate();
4848 else
4849 return util::Date();
4852 void VCLXDateField::setLast( const util::Date& aDate )
4854 SolarMutexGuard aGuard;
4856 VclPtr< DateField > pDateField = GetAs< DateField >();
4857 if ( pDateField )
4858 pDateField->SetLast( ::Date(aDate) );
4861 util::Date VCLXDateField::getLast()
4863 SolarMutexGuard aGuard;
4865 VclPtr< DateField > pDateField = GetAs< DateField >();
4866 if ( pDateField )
4867 return pDateField->GetLast().GetUNODate();
4868 else
4869 return util::Date();
4872 void VCLXDateField::setLongFormat( sal_Bool bLong )
4874 SolarMutexGuard aGuard;
4876 VclPtr< DateField > pDateField = GetAs< DateField >();
4877 if ( pDateField )
4878 pDateField->SetLongFormat( bLong );
4881 sal_Bool VCLXDateField::isLongFormat()
4883 SolarMutexGuard aGuard;
4885 VclPtr< DateField > pDateField = GetAs< DateField >();
4886 return pDateField && pDateField->IsLongFormat();
4889 void VCLXDateField::setEmpty()
4891 SolarMutexGuard aGuard;
4893 VclPtr< DateField > pDateField = GetAs< DateField >();
4894 if ( pDateField )
4896 pDateField->SetEmptyDate();
4898 // #107218# Call same listeners like VCL would do after user interaction
4899 SetSynthesizingVCLEvent( true );
4900 pDateField->SetModifyFlag();
4901 pDateField->Modify();
4902 SetSynthesizingVCLEvent( false );
4906 sal_Bool VCLXDateField::isEmpty()
4908 SolarMutexGuard aGuard;
4910 VclPtr< DateField > pDateField = GetAs< DateField >();
4911 return pDateField && pDateField->IsEmptyDate();
4914 void VCLXDateField::setStrictFormat( sal_Bool bStrict )
4916 VCLXFormattedSpinField::setStrictFormat( bStrict );
4919 sal_Bool VCLXDateField::isStrictFormat()
4921 return VCLXFormattedSpinField::isStrictFormat();
4927 void VCLXTimeField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
4929 PushPropertyIds( rIds,
4930 BASEPROPERTY_ALIGN,
4931 BASEPROPERTY_BACKGROUNDCOLOR,
4932 BASEPROPERTY_BORDER,
4933 BASEPROPERTY_BORDERCOLOR,
4934 BASEPROPERTY_DEFAULTCONTROL,
4935 BASEPROPERTY_ENABLED,
4936 BASEPROPERTY_ENABLEVISIBLE,
4937 BASEPROPERTY_EXTTIMEFORMAT,
4938 BASEPROPERTY_FONTDESCRIPTOR,
4939 BASEPROPERTY_HELPTEXT,
4940 BASEPROPERTY_HELPURL,
4941 BASEPROPERTY_PRINTABLE,
4942 BASEPROPERTY_READONLY,
4943 BASEPROPERTY_REPEAT,
4944 BASEPROPERTY_REPEAT_DELAY,
4945 BASEPROPERTY_SPIN,
4946 BASEPROPERTY_STRICTFORMAT,
4947 BASEPROPERTY_TABSTOP,
4948 BASEPROPERTY_TIME,
4949 BASEPROPERTY_TIMEMAX,
4950 BASEPROPERTY_TIMEMIN,
4951 BASEPROPERTY_ENFORCE_FORMAT,
4952 BASEPROPERTY_TEXT,
4953 BASEPROPERTY_HIDEINACTIVESELECTION,
4954 BASEPROPERTY_VERTICALALIGN,
4955 BASEPROPERTY_WRITING_MODE,
4956 BASEPROPERTY_CONTEXT_WRITING_MODE,
4957 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
4958 BASEPROPERTY_HIGHLIGHT_COLOR,
4959 BASEPROPERTY_HIGHLIGHT_TEXT_COLOR,
4961 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
4964 VCLXTimeField::VCLXTimeField()
4968 VCLXTimeField::~VCLXTimeField()
4972 //change the window type here to match the role
4973 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXTimeField::CreateAccessibleContext()
4975 VclPtr<Edit> pEdit = GetAs<Edit>();
4976 if (pEdit)
4978 pEdit->SetType( WindowType::TIMEFIELD );
4980 return AccessibleFactory::createAccessibleContext(pEdit);
4983 void VCLXTimeField::setTime( const util::Time& aTime )
4985 SolarMutexGuard aGuard;
4987 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
4988 if ( pTimeField )
4990 pTimeField->SetTime( tools::Time(aTime) );
4992 // #107218# Call same listeners like VCL would do after user interaction
4993 SetSynthesizingVCLEvent( true );
4994 pTimeField->SetModifyFlag();
4995 pTimeField->Modify();
4996 SetSynthesizingVCLEvent( false );
5000 util::Time VCLXTimeField::getTime()
5002 SolarMutexGuard aGuard;
5004 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5005 if ( pTimeField )
5006 return pTimeField->GetTime().GetUNOTime();
5007 else
5008 return util::Time();
5011 void VCLXTimeField::setMin( const util::Time& aTime )
5013 SolarMutexGuard aGuard;
5015 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5016 if ( pTimeField )
5017 pTimeField->SetMin( tools::Time(aTime) );
5020 util::Time VCLXTimeField::getMin()
5022 SolarMutexGuard aGuard;
5024 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5025 if ( pTimeField )
5026 return pTimeField->GetMin().GetUNOTime();
5027 else
5028 return util::Time();
5031 void VCLXTimeField::setMax( const util::Time& aTime )
5033 SolarMutexGuard aGuard;
5035 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5036 if ( pTimeField )
5037 pTimeField->SetMax( tools::Time(aTime) );
5040 util::Time VCLXTimeField::getMax()
5042 SolarMutexGuard aGuard;
5044 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5045 if ( pTimeField )
5046 return pTimeField->GetMax().GetUNOTime();
5047 else
5048 return util::Time();
5051 void VCLXTimeField::setFirst( const util::Time& aTime )
5053 SolarMutexGuard aGuard;
5055 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5056 if ( pTimeField )
5057 pTimeField->SetFirst( tools::Time(aTime) );
5060 util::Time VCLXTimeField::getFirst()
5062 SolarMutexGuard aGuard;
5064 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5065 if ( pTimeField )
5066 return pTimeField->GetFirst().GetUNOTime();
5067 else
5068 return util::Time();
5071 void VCLXTimeField::setLast( const util::Time& aTime )
5073 SolarMutexGuard aGuard;
5075 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5076 if ( pTimeField )
5077 pTimeField->SetLast( tools::Time(aTime) );
5080 util::Time VCLXTimeField::getLast()
5082 SolarMutexGuard aGuard;
5084 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5085 if ( pTimeField )
5086 return pTimeField->GetLast().GetUNOTime();
5087 else
5088 return util::Time();
5091 void VCLXTimeField::setEmpty()
5093 SolarMutexGuard aGuard;
5095 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5096 if ( pTimeField )
5097 pTimeField->SetEmptyTime();
5100 sal_Bool VCLXTimeField::isEmpty()
5102 SolarMutexGuard aGuard;
5104 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5105 return pTimeField && pTimeField->IsEmptyTime();
5108 void VCLXTimeField::setStrictFormat( sal_Bool bStrict )
5110 VCLXFormattedSpinField::setStrictFormat( bStrict );
5113 sal_Bool VCLXTimeField::isStrictFormat()
5115 return VCLXFormattedSpinField::isStrictFormat();
5119 void VCLXTimeField::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
5121 SolarMutexGuard aGuard;
5123 if ( !(GetWindow()) )
5124 return;
5126 bool bVoid = Value.getValueTypeClass() == css::uno::TypeClass_VOID;
5128 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5129 switch ( nPropType )
5131 case BASEPROPERTY_TIME:
5133 if ( bVoid )
5135 GetAs< TimeField >()->EnableEmptyFieldValue( true );
5136 GetAs< TimeField >()->SetEmptyFieldValue();
5138 else
5140 util::Time t;
5141 if ( Value >>= t )
5142 setTime( t );
5145 break;
5146 case BASEPROPERTY_TIMEMIN:
5148 util::Time t;
5149 if ( Value >>= t )
5150 setMin( t );
5152 break;
5153 case BASEPROPERTY_TIMEMAX:
5155 util::Time t;
5156 if ( Value >>= t )
5157 setMax( t );
5159 break;
5160 case BASEPROPERTY_EXTTIMEFORMAT:
5162 sal_Int16 n = sal_Int16();
5163 if ( Value >>= n )
5164 GetAs< TimeField >()->SetExtFormat( static_cast<ExtTimeFieldFormat>(n) );
5166 break;
5167 case BASEPROPERTY_ENFORCE_FORMAT:
5169 bool bEnforce( true );
5170 OSL_VERIFY( Value >>= bEnforce );
5171 GetAs< TimeField >()->EnforceValidValue( bEnforce );
5173 break;
5174 default:
5176 VCLXFormattedSpinField::setProperty( PropertyName, Value );
5181 css::uno::Any VCLXTimeField::getProperty( const OUString& PropertyName )
5183 SolarMutexGuard aGuard;
5185 css::uno::Any aProp;
5186 if ( GetWindow() )
5188 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5189 switch ( nPropType )
5191 case BASEPROPERTY_TIME:
5193 aProp <<= getTime();
5195 break;
5196 case BASEPROPERTY_TIMEMIN:
5198 aProp <<= getMin();
5200 break;
5201 case BASEPROPERTY_TIMEMAX:
5203 aProp <<= getMax();
5205 break;
5206 case BASEPROPERTY_ENFORCE_FORMAT:
5208 aProp <<= GetAs< TimeField >()->IsEnforceValidValue( );
5210 break;
5211 default:
5213 aProp = VCLXFormattedSpinField::getProperty( PropertyName );
5217 return aProp;
5223 void VCLXNumericField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
5225 PushPropertyIds( rIds,
5226 BASEPROPERTY_ALIGN,
5227 BASEPROPERTY_BACKGROUNDCOLOR,
5228 BASEPROPERTY_BORDER,
5229 BASEPROPERTY_BORDERCOLOR,
5230 BASEPROPERTY_DECIMALACCURACY,
5231 BASEPROPERTY_DEFAULTCONTROL,
5232 BASEPROPERTY_ENABLED,
5233 BASEPROPERTY_ENABLEVISIBLE,
5234 BASEPROPERTY_FONTDESCRIPTOR,
5235 BASEPROPERTY_HELPTEXT,
5236 BASEPROPERTY_HELPURL,
5237 BASEPROPERTY_NUMSHOWTHOUSANDSEP,
5238 BASEPROPERTY_PRINTABLE,
5239 BASEPROPERTY_READONLY,
5240 BASEPROPERTY_REPEAT,
5241 BASEPROPERTY_REPEAT_DELAY,
5242 BASEPROPERTY_SPIN,
5243 BASEPROPERTY_STRICTFORMAT,
5244 BASEPROPERTY_TABSTOP,
5245 BASEPROPERTY_VALUEMAX_DOUBLE,
5246 BASEPROPERTY_VALUEMIN_DOUBLE,
5247 BASEPROPERTY_VALUESTEP_DOUBLE,
5248 BASEPROPERTY_VALUE_DOUBLE,
5249 BASEPROPERTY_ENFORCE_FORMAT,
5250 BASEPROPERTY_HIDEINACTIVESELECTION,
5251 BASEPROPERTY_VERTICALALIGN,
5252 BASEPROPERTY_WRITING_MODE,
5253 BASEPROPERTY_CONTEXT_WRITING_MODE,
5254 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
5255 BASEPROPERTY_HIGHLIGHT_COLOR,
5256 BASEPROPERTY_HIGHLIGHT_TEXT_COLOR,
5258 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5261 VCLXNumericField::VCLXNumericField()
5265 VCLXNumericField::~VCLXNumericField()
5269 void VCLXNumericField::setValue( double Value )
5271 SolarMutexGuard aGuard;
5273 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5274 if ( !pNumericFormatter )
5275 return;
5277 // shift long value using decimal digits
5278 // (e.g., input 105 using 2 digits returns 1,05)
5279 // Thus, to set a value of 1,05, insert 105 and 2 digits
5280 pNumericFormatter->SetValue(
5281 static_cast<tools::Long>(ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() )) );
5283 // #107218# Call same listeners like VCL would do after user interaction
5284 VclPtr< Edit > pEdit = GetAs< Edit >();
5285 if ( pEdit )
5287 SetSynthesizingVCLEvent( true );
5288 pEdit->SetModifyFlag();
5289 pEdit->Modify();
5290 SetSynthesizingVCLEvent( false );
5294 double VCLXNumericField::getValue()
5296 SolarMutexGuard aGuard;
5298 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5299 return pNumericFormatter
5300 ? ImplCalcDoubleValue( static_cast<double>(pNumericFormatter->GetValue()), pNumericFormatter->GetDecimalDigits() )
5301 : 0;
5304 void VCLXNumericField::setMin( double Value )
5306 SolarMutexGuard aGuard;
5308 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5309 if ( pNumericFormatter )
5310 pNumericFormatter->SetMin(
5311 static_cast<tools::Long>(ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() )) );
5314 double VCLXNumericField::getMin()
5316 SolarMutexGuard aGuard;
5318 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5319 return pNumericFormatter
5320 ? ImplCalcDoubleValue( static_cast<double>(pNumericFormatter->GetMin()), pNumericFormatter->GetDecimalDigits() )
5321 : 0;
5324 void VCLXNumericField::setMax( double Value )
5326 SolarMutexGuard aGuard;
5328 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5329 if ( pNumericFormatter )
5330 pNumericFormatter->SetMax(
5331 static_cast<tools::Long>(ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() )) );
5334 double VCLXNumericField::getMax()
5336 SolarMutexGuard aGuard;
5338 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5339 return pNumericFormatter
5340 ? ImplCalcDoubleValue( static_cast<double>(pNumericFormatter->GetMax()), pNumericFormatter->GetDecimalDigits() )
5341 : 0;
5344 void VCLXNumericField::setFirst( double Value )
5346 SolarMutexGuard aGuard;
5348 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5349 if ( pNumericFormatter )
5350 pNumericFormatter->SetFirst(
5351 static_cast<tools::Long>(ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() )) );
5354 double VCLXNumericField::getFirst()
5356 SolarMutexGuard aGuard;
5358 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5359 return pNumericFormatter
5360 ? ImplCalcDoubleValue( static_cast<double>(pNumericFormatter->GetFirst()), pNumericFormatter->GetDecimalDigits() )
5361 : 0;
5364 void VCLXNumericField::setLast( double Value )
5366 SolarMutexGuard aGuard;
5368 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5369 if ( pNumericFormatter )
5370 pNumericFormatter->SetLast(
5371 static_cast<tools::Long>(ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() )) );
5374 double VCLXNumericField::getLast()
5376 SolarMutexGuard aGuard;
5378 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5379 return pNumericFormatter
5380 ? ImplCalcDoubleValue( static_cast<double>(pNumericFormatter->GetLast()), pNumericFormatter->GetDecimalDigits() )
5381 : 0;
5384 void VCLXNumericField::setStrictFormat( sal_Bool bStrict )
5386 VCLXFormattedSpinField::setStrictFormat( bStrict );
5389 sal_Bool VCLXNumericField::isStrictFormat()
5391 return VCLXFormattedSpinField::isStrictFormat();
5394 void VCLXNumericField::setSpinSize( double Value )
5396 SolarMutexGuard aGuard;
5398 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5399 if ( pNumericFormatter )
5400 pNumericFormatter->SetSpinSize(
5401 static_cast<tools::Long>(ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() )) );
5404 double VCLXNumericField::getSpinSize()
5406 SolarMutexGuard aGuard;
5408 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5409 return pNumericFormatter
5410 ? ImplCalcDoubleValue( static_cast<double>(pNumericFormatter->GetSpinSize()), pNumericFormatter->GetDecimalDigits() )
5411 : 0;
5414 void VCLXNumericField::setDecimalDigits( sal_Int16 Value )
5416 SolarMutexGuard aGuard;
5418 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5419 if ( pNumericFormatter )
5421 double n = getValue();
5422 pNumericFormatter->SetDecimalDigits( Value );
5423 setValue( n );
5427 sal_Int16 VCLXNumericField::getDecimalDigits()
5429 SolarMutexGuard aGuard;
5431 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5432 return pNumericFormatter ? pNumericFormatter->GetDecimalDigits() : 0;
5435 void VCLXNumericField::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
5437 SolarMutexGuard aGuard;
5439 if ( !(GetWindow()) )
5440 return;
5442 bool bVoid = Value.getValueTypeClass() == css::uno::TypeClass_VOID;
5444 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5445 switch ( nPropType )
5447 case BASEPROPERTY_VALUE_DOUBLE:
5449 if ( bVoid )
5451 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5452 if (!pNumericFormatter)
5453 return;
5454 pNumericFormatter->EnableEmptyFieldValue( true );
5455 pNumericFormatter->SetEmptyFieldValue();
5457 else
5459 double d = 0;
5460 if ( Value >>= d )
5461 setValue( d );
5464 break;
5465 case BASEPROPERTY_VALUEMIN_DOUBLE:
5467 double d = 0;
5468 if ( Value >>= d )
5469 setMin( d );
5471 break;
5472 case BASEPROPERTY_VALUEMAX_DOUBLE:
5474 double d = 0;
5475 if ( Value >>= d )
5476 setMax( d );
5478 break;
5479 case BASEPROPERTY_VALUESTEP_DOUBLE:
5481 double d = 0;
5482 if ( Value >>= d )
5483 setSpinSize( d );
5485 break;
5486 case BASEPROPERTY_DECIMALACCURACY:
5488 sal_Int16 n = sal_Int16();
5489 if ( Value >>= n )
5490 setDecimalDigits( n );
5492 break;
5493 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5495 bool b = bool();
5496 if ( Value >>= b )
5498 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5499 if (!pNumericFormatter)
5500 return;
5501 pNumericFormatter->SetUseThousandSep( b );
5504 break;
5505 default:
5507 VCLXFormattedSpinField::setProperty( PropertyName, Value );
5512 css::uno::Any VCLXNumericField::getProperty( const OUString& PropertyName )
5514 SolarMutexGuard aGuard;
5516 css::uno::Any aProp;
5517 FormatterBase* pFormatter = GetFormatter();
5518 if ( pFormatter )
5520 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5521 switch ( nPropType )
5523 case BASEPROPERTY_VALUE_DOUBLE:
5525 aProp <<= getValue();
5527 break;
5528 case BASEPROPERTY_VALUEMIN_DOUBLE:
5530 aProp <<= getMin();
5532 break;
5533 case BASEPROPERTY_VALUEMAX_DOUBLE:
5535 aProp <<= getMax();
5537 break;
5538 case BASEPROPERTY_VALUESTEP_DOUBLE:
5540 aProp <<= getSpinSize();
5542 break;
5543 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5545 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(pFormatter);
5546 aProp <<= pNumericFormatter->IsUseThousandSep();
5548 break;
5549 default:
5551 aProp = VCLXFormattedSpinField::getProperty( PropertyName );
5555 return aProp;
5559 // ----------------------------------------------------
5560 // ----------------------------------------------------
5562 void VCLXMetricField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
5564 PushPropertyIds( rIds,
5565 BASEPROPERTY_ALIGN,
5566 BASEPROPERTY_BACKGROUNDCOLOR,
5567 BASEPROPERTY_BORDER,
5568 BASEPROPERTY_BORDERCOLOR,
5569 BASEPROPERTY_DECIMALACCURACY,
5570 BASEPROPERTY_DEFAULTCONTROL,
5571 BASEPROPERTY_ENABLED,
5572 BASEPROPERTY_ENABLEVISIBLE,
5573 BASEPROPERTY_FONTDESCRIPTOR,
5574 BASEPROPERTY_HELPTEXT,
5575 BASEPROPERTY_HELPURL,
5576 BASEPROPERTY_NUMSHOWTHOUSANDSEP,
5577 BASEPROPERTY_PRINTABLE,
5578 BASEPROPERTY_READONLY,
5579 BASEPROPERTY_REPEAT,
5580 BASEPROPERTY_REPEAT_DELAY,
5581 BASEPROPERTY_SPIN,
5582 BASEPROPERTY_STRICTFORMAT,
5583 BASEPROPERTY_TABSTOP,
5584 BASEPROPERTY_ENFORCE_FORMAT,
5585 BASEPROPERTY_HIDEINACTIVESELECTION,
5586 BASEPROPERTY_UNIT,
5587 BASEPROPERTY_CUSTOMUNITTEXT,
5588 BASEPROPERTY_WRITING_MODE,
5589 BASEPROPERTY_CONTEXT_WRITING_MODE,
5590 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
5592 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5595 VCLXMetricField::VCLXMetricField()
5599 VCLXMetricField::~VCLXMetricField()
5603 MetricFormatter *VCLXMetricField::GetMetricFormatter()
5605 MetricFormatter *pFormatter = static_cast<MetricFormatter *>(GetFormatter());
5606 if (!pFormatter)
5607 throw css::uno::RuntimeException();
5608 return pFormatter;
5611 MetricField *VCLXMetricField::GetMetricField()
5613 VclPtr< MetricField > pField = GetAs< MetricField >();
5614 if (!pField)
5615 throw css::uno::RuntimeException();
5616 return pField;
5619 // FIXME: later ...
5620 #define MetricUnitUnoToVcl(a) (static_cast<FieldUnit>(a))
5622 #define METRIC_MAP_PAIR(method,parent) \
5623 sal_Int64 VCLXMetricField::get##method( sal_Int16 nUnit ) \
5625 SolarMutexGuard aGuard; \
5626 return GetMetric##parent()->Get##method( MetricUnitUnoToVcl( nUnit ) ); \
5628 void VCLXMetricField::set##method( sal_Int64 nValue, sal_Int16 nUnit ) \
5630 SolarMutexGuard aGuard; \
5631 GetMetric##parent()->Set##method( nValue, MetricUnitUnoToVcl( nUnit ) ); \
5634 METRIC_MAP_PAIR(Min, Formatter)
5635 METRIC_MAP_PAIR(Max, Formatter)
5636 METRIC_MAP_PAIR(First, Field)
5637 METRIC_MAP_PAIR(Last, Field)
5639 #undef METRIC_MAP_PAIR
5641 ::sal_Int64 VCLXMetricField::getValue( ::sal_Int16 nUnit )
5643 SolarMutexGuard aGuard;
5644 return GetMetricFormatter()->GetValue( MetricUnitUnoToVcl( nUnit ) );
5647 ::sal_Int64 VCLXMetricField::getCorrectedValue( ::sal_Int16 nUnit )
5649 SolarMutexGuard aGuard;
5650 return GetMetricFormatter()->GetCorrectedValue( MetricUnitUnoToVcl( nUnit ) );
5653 // FIXME: acute cut/paste evilness - move this to the parent Edit class ?
5654 void VCLXMetricField::CallListeners()
5656 // #107218# Call same listeners like VCL would do after user interaction
5657 VclPtr< Edit > pEdit = GetAs< Edit >();
5658 if ( pEdit )
5660 SetSynthesizingVCLEvent( true );
5661 pEdit->SetModifyFlag();
5662 pEdit->Modify();
5663 SetSynthesizingVCLEvent( false );
5667 void VCLXMetricField::setValue( ::sal_Int64 Value, ::sal_Int16 Unit )
5669 SolarMutexGuard aGuard;
5670 GetMetricFormatter()->SetValue( Value, MetricUnitUnoToVcl( Unit ) );
5671 CallListeners();
5674 void VCLXMetricField::setUserValue( ::sal_Int64 Value, ::sal_Int16 Unit )
5676 SolarMutexGuard aGuard;
5677 GetMetricFormatter()->SetUserValue( Value, MetricUnitUnoToVcl( Unit ) );
5678 CallListeners();
5681 void VCLXMetricField::setStrictFormat( sal_Bool bStrict )
5683 VCLXFormattedSpinField::setStrictFormat( bStrict );
5686 sal_Bool VCLXMetricField::isStrictFormat()
5688 return VCLXFormattedSpinField::isStrictFormat();
5691 void VCLXMetricField::setSpinSize( sal_Int64 Value )
5693 SolarMutexGuard aGuard;
5694 GetMetricField()->SetSpinSize( Value );
5697 sal_Int64 VCLXMetricField::getSpinSize()
5699 SolarMutexGuard aGuard;
5700 return GetMetricField()->GetSpinSize();
5703 void VCLXMetricField::setDecimalDigits( sal_Int16 Value )
5705 SolarMutexGuard aGuard;
5706 GetMetricFormatter()->SetDecimalDigits( Value );
5709 sal_Int16 VCLXMetricField::getDecimalDigits()
5711 SolarMutexGuard aGuard;
5713 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5714 return pNumericFormatter ? pNumericFormatter->GetDecimalDigits() : 0;
5717 void VCLXMetricField::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
5719 SolarMutexGuard aGuard;
5721 if ( !(GetWindow()) )
5722 return;
5724 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5725 switch ( nPropType )
5727 case BASEPROPERTY_DECIMALACCURACY:
5729 sal_Int16 n = 0;
5730 if ( Value >>= n )
5731 setDecimalDigits( n );
5732 break;
5734 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5736 bool b = false;
5737 if ( Value >>= b )
5739 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5740 if (!pNumericFormatter)
5741 return;
5742 pNumericFormatter->SetUseThousandSep( b );
5745 break;
5746 case BASEPROPERTY_UNIT:
5748 sal_uInt16 nVal = 0;
5749 if ( Value >>= nVal )
5750 GetAs< MetricField >()->SetUnit( static_cast<FieldUnit>(nVal) );
5751 break;
5753 case BASEPROPERTY_CUSTOMUNITTEXT:
5755 OUString aStr;
5756 if ( Value >>= aStr )
5757 GetAs< MetricField >()->SetCustomUnitText( aStr );
5758 break;
5760 default:
5762 VCLXFormattedSpinField::setProperty( PropertyName, Value );
5763 break;
5768 css::uno::Any VCLXMetricField::getProperty( const OUString& PropertyName )
5770 SolarMutexGuard aGuard;
5772 css::uno::Any aProp;
5773 FormatterBase* pFormatter = GetFormatter();
5774 if ( pFormatter )
5776 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5777 switch ( nPropType )
5779 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5781 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(pFormatter);
5782 aProp <<= pNumericFormatter->IsUseThousandSep();
5783 break;
5785 case BASEPROPERTY_UNIT:
5786 aProp <<= static_cast<sal_uInt16>(GetAs< MetricField >()->GetUnit());
5787 break;
5788 case BASEPROPERTY_CUSTOMUNITTEXT:
5789 aProp <<= GetAs< MetricField >()->GetCustomUnitText();
5790 break;
5791 default:
5793 aProp = VCLXFormattedSpinField::getProperty( PropertyName );
5794 break;
5798 return aProp;
5801 void VCLXPatternField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
5803 PushPropertyIds( rIds,
5804 BASEPROPERTY_ALIGN,
5805 BASEPROPERTY_BACKGROUNDCOLOR,
5806 BASEPROPERTY_BORDER,
5807 BASEPROPERTY_BORDERCOLOR,
5808 BASEPROPERTY_DEFAULTCONTROL,
5809 BASEPROPERTY_EDITMASK,
5810 BASEPROPERTY_ENABLED,
5811 BASEPROPERTY_ENABLEVISIBLE,
5812 BASEPROPERTY_FONTDESCRIPTOR,
5813 BASEPROPERTY_HELPTEXT,
5814 BASEPROPERTY_HELPURL,
5815 BASEPROPERTY_LITERALMASK,
5816 BASEPROPERTY_MAXTEXTLEN,
5817 BASEPROPERTY_PRINTABLE,
5818 BASEPROPERTY_READONLY,
5819 BASEPROPERTY_STRICTFORMAT,
5820 BASEPROPERTY_TABSTOP,
5821 BASEPROPERTY_TEXT,
5822 BASEPROPERTY_HIDEINACTIVESELECTION,
5823 BASEPROPERTY_VERTICALALIGN,
5824 BASEPROPERTY_WRITING_MODE,
5825 BASEPROPERTY_CONTEXT_WRITING_MODE,
5826 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
5827 BASEPROPERTY_HIGHLIGHT_COLOR,
5828 BASEPROPERTY_HIGHLIGHT_TEXT_COLOR,
5830 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5833 VCLXPatternField::VCLXPatternField()
5837 VCLXPatternField::~VCLXPatternField()
5841 void VCLXPatternField::setMasks( const OUString& EditMask, const OUString& LiteralMask )
5843 SolarMutexGuard aGuard;
5845 VclPtr< PatternField > pPatternField = GetAs< PatternField >();
5846 if ( pPatternField )
5848 pPatternField->SetMask( OUStringToOString(EditMask, RTL_TEXTENCODING_ASCII_US), LiteralMask );
5852 void VCLXPatternField::getMasks( OUString& EditMask, OUString& LiteralMask )
5854 SolarMutexGuard aGuard;
5856 VclPtr< PatternField > pPatternField = GetAs< PatternField >();
5857 if ( pPatternField )
5859 EditMask = OStringToOUString(pPatternField->GetEditMask(), RTL_TEXTENCODING_ASCII_US);
5860 LiteralMask = pPatternField->GetLiteralMask();
5864 void VCLXPatternField::setString( const OUString& Str )
5866 SolarMutexGuard aGuard;
5867 VclPtr< PatternField > pPatternField = GetAs< PatternField >();
5868 if ( pPatternField )
5869 pPatternField->SetString( Str );
5872 OUString VCLXPatternField::getString()
5874 SolarMutexGuard aGuard;
5876 OUString aString;
5877 VclPtr< PatternField > pPatternField = GetAs< PatternField >();
5878 if ( pPatternField )
5879 aString = pPatternField->GetString();
5880 return aString;
5883 void VCLXPatternField::setStrictFormat( sal_Bool bStrict )
5885 VCLXFormattedSpinField::setStrictFormat( bStrict );
5888 sal_Bool VCLXPatternField::isStrictFormat()
5890 return VCLXFormattedSpinField::isStrictFormat();
5893 void VCLXPatternField::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
5895 SolarMutexGuard aGuard;
5897 if ( !(GetWindow()) )
5898 return;
5900 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5901 switch ( nPropType )
5903 case BASEPROPERTY_EDITMASK:
5904 case BASEPROPERTY_LITERALMASK:
5906 OUString aString;
5907 if ( Value >>= aString )
5909 OUString aEditMask, aLiteralMask;
5910 getMasks( aEditMask, aLiteralMask );
5911 if ( nPropType == BASEPROPERTY_EDITMASK )
5912 aEditMask = aString;
5913 else
5914 aLiteralMask = aString;
5915 setMasks( aEditMask, aLiteralMask );
5918 break;
5919 default:
5921 VCLXFormattedSpinField::setProperty( PropertyName, Value );
5926 css::uno::Any VCLXPatternField::getProperty( const OUString& PropertyName )
5928 SolarMutexGuard aGuard;
5930 css::uno::Any aProp;
5931 if ( GetWindow() )
5933 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5934 switch ( nPropType )
5936 case BASEPROPERTY_EDITMASK:
5937 case BASEPROPERTY_LITERALMASK:
5939 OUString aEditMask, aLiteralMask;
5940 getMasks( aEditMask, aLiteralMask );
5941 if ( nPropType == BASEPROPERTY_EDITMASK )
5942 aProp <<= aEditMask;
5943 else
5944 aProp <<= aLiteralMask;
5946 break;
5947 default:
5949 aProp = VCLXFormattedSpinField::getProperty( PropertyName );
5953 return aProp;
5958 VCLXToolBox::VCLXToolBox()
5962 VCLXToolBox::~VCLXToolBox()
5966 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXToolBox::CreateAccessibleContext()
5968 VclPtr<ToolBox> pToolBox = GetAs<ToolBox>();
5969 return AccessibleFactory::createAccessibleContext(pToolBox);
5972 VCLXHeaderBar::VCLXHeaderBar()
5976 VCLXHeaderBar::~VCLXHeaderBar()
5980 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXHeaderBar::CreateAccessibleContext()
5982 VclPtr<HeaderBar> pHeaderBar = GetAs<HeaderBar>();
5983 return AccessibleFactory::createAccessibleContext(pHeaderBar);
5987 VCLXFrame::VCLXFrame()
5991 void VCLXFrame::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
5993 PushPropertyIds( rIds,
5994 BASEPROPERTY_BACKGROUNDCOLOR,
5995 BASEPROPERTY_DEFAULTCONTROL,
5996 BASEPROPERTY_ENABLED,
5997 BASEPROPERTY_ENABLEVISIBLE,
5998 BASEPROPERTY_FONTDESCRIPTOR,
5999 BASEPROPERTY_GRAPHIC,
6000 BASEPROPERTY_HELPTEXT,
6001 BASEPROPERTY_HELPURL,
6002 BASEPROPERTY_PRINTABLE,
6003 BASEPROPERTY_LABEL,
6005 VCLXContainer::ImplGetPropertyIds( rIds );
6008 VCLXFrame::~VCLXFrame()
6012 // css::awt::XView
6013 void SAL_CALL VCLXFrame::draw( sal_Int32 nX, sal_Int32 nY )
6015 SolarMutexGuard aGuard;
6016 VclPtr< vcl::Window > pWindow = GetWindow();
6018 if ( pWindow )
6020 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
6021 if ( !pDev )
6022 pDev = pWindow->GetParent()->GetOutDev();
6024 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
6025 pWindow->Draw( pDev, aPos, SystemTextColorFlags::NoControls );
6029 void SAL_CALL VCLXFrame::setProperty(
6030 const OUString& PropertyName,
6031 const css::uno::Any& Value )
6033 SolarMutexGuard aGuard;
6035 VCLXContainer::setProperty( PropertyName, Value );
6038 void VCLXFrame::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
6040 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
6041 VCLXContainer::ProcessWindowEvent( rVclWindowEvent );
6044 VCLXProgressBar::VCLXProgressBar()
6045 :m_nValue(0)
6046 ,m_nValueMin(0)
6047 ,m_nValueMax(100)
6051 VCLXProgressBar::~VCLXProgressBar()
6055 void VCLXProgressBar::ImplUpdateValue()
6057 VclPtr< ProgressBar > pProgressBar = GetAs< ProgressBar >();
6058 if ( !pProgressBar )
6059 return;
6061 sal_Int32 nVal;
6062 sal_Int32 nValMin;
6063 sal_Int32 nValMax;
6065 // check min and max
6066 if (m_nValueMin < m_nValueMax)
6068 nValMin = m_nValueMin;
6069 nValMax = m_nValueMax;
6071 else
6073 nValMin = m_nValueMax;
6074 nValMax = m_nValueMin;
6077 // check value
6078 if (m_nValue < nValMin)
6080 nVal = nValMin;
6082 else if (m_nValue > nValMax)
6084 nVal = nValMax;
6086 else
6088 nVal = m_nValue;
6091 // calculate percent
6092 sal_Int32 nPercent;
6093 if (nValMin != nValMax)
6095 nPercent = 100 * (nVal - nValMin) / (nValMax - nValMin);
6097 else
6099 nPercent = 0;
6102 // set progressbar value
6103 pProgressBar->SetValue( static_cast<sal_uInt16>(nPercent) );
6106 // css::awt::XProgressBar
6107 void VCLXProgressBar::setForegroundColor( sal_Int32 nColor )
6109 SolarMutexGuard aGuard;
6111 VclPtr<vcl::Window> pWindow = GetWindow();
6112 if ( pWindow )
6114 pWindow->SetControlForeground( Color(ColorTransparency, nColor) );
6118 void VCLXProgressBar::setBackgroundColor( sal_Int32 nColor )
6120 SolarMutexGuard aGuard;
6122 VclPtr<vcl::Window> pWindow = GetWindow();
6123 if ( pWindow )
6125 Color aColor( ColorTransparency, nColor );
6126 pWindow->SetBackground( aColor );
6127 pWindow->SetControlBackground( aColor );
6128 pWindow->Invalidate();
6132 void VCLXProgressBar::setValue( sal_Int32 nValue )
6134 SolarMutexGuard aGuard;
6136 m_nValue = nValue;
6137 ImplUpdateValue();
6140 void VCLXProgressBar::setRange( sal_Int32 nMin, sal_Int32 nMax )
6142 SolarMutexGuard aGuard;
6144 if ( nMin < nMax )
6146 // take correct min and max
6147 m_nValueMin = nMin;
6148 m_nValueMax = nMax;
6150 else
6152 // change min and max
6153 m_nValueMin = nMax;
6154 m_nValueMax = nMin;
6157 ImplUpdateValue();
6160 sal_Int32 VCLXProgressBar::getValue()
6162 SolarMutexGuard aGuard;
6164 return m_nValue;
6167 // css::awt::VclWindowPeer
6168 void VCLXProgressBar::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
6170 SolarMutexGuard aGuard;
6172 VclPtr< ProgressBar > pProgressBar = GetAs< ProgressBar >();
6173 if ( !pProgressBar )
6174 return;
6176 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6177 switch ( nPropType )
6179 case BASEPROPERTY_PROGRESSVALUE:
6181 if ( Value >>= m_nValue )
6182 ImplUpdateValue();
6184 break;
6185 case BASEPROPERTY_PROGRESSVALUE_MIN:
6187 if ( Value >>= m_nValueMin )
6188 ImplUpdateValue();
6190 break;
6191 case BASEPROPERTY_PROGRESSVALUE_MAX:
6193 if ( Value >>= m_nValueMax )
6194 ImplUpdateValue();
6196 break;
6197 case BASEPROPERTY_FILLCOLOR:
6199 VclPtr<vcl::Window> pWindow = GetWindow();
6200 if ( pWindow )
6202 bool bVoid = Value.getValueTypeClass() == css::uno::TypeClass_VOID;
6204 if ( bVoid )
6206 pWindow->SetControlForeground();
6208 else
6210 Color nColor;
6211 if ( Value >>= nColor )
6212 pWindow->SetControlForeground( nColor );
6216 break;
6217 default:
6218 VCLXWindow::setProperty( PropertyName, Value );
6219 break;
6223 css::uno::Any VCLXProgressBar::getProperty( const OUString& PropertyName )
6225 SolarMutexGuard aGuard;
6227 css::uno::Any aProp;
6228 VclPtr< ProgressBar > pProgressBar = GetAs< ProgressBar >();
6229 if ( pProgressBar )
6231 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6232 switch ( nPropType )
6234 case BASEPROPERTY_PROGRESSVALUE:
6236 aProp <<= m_nValue;
6238 break;
6239 case BASEPROPERTY_PROGRESSVALUE_MIN:
6241 aProp <<= m_nValueMin;
6243 break;
6244 case BASEPROPERTY_PROGRESSVALUE_MAX:
6246 aProp <<= m_nValueMax;
6248 break;
6249 default:
6250 aProp = VCLXWindow::getProperty( PropertyName );
6251 break;
6254 return aProp;
6257 void VCLXProgressBar::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
6259 PushPropertyIds( rIds,
6260 BASEPROPERTY_PROGRESSVALUE,
6261 BASEPROPERTY_PROGRESSVALUE_MIN,
6262 BASEPROPERTY_PROGRESSVALUE_MAX,
6263 BASEPROPERTY_FILLCOLOR,
6265 VCLXWindow::ImplGetPropertyIds( rIds, true );
6268 VCLXFileControl::VCLXFileControl() : maTextListeners( *this )
6272 VCLXFileControl::~VCLXFileControl()
6274 VclPtr< FileControl > pControl = GetAs< FileControl >();
6275 if ( pControl )
6276 pControl->GetEdit().SetModifyHdl( Link<Edit&,void>() );
6279 namespace
6281 void lcl_setWinBits( vcl::Window* _pWindow, WinBits _nBits, bool _bSet )
6283 WinBits nStyle = _pWindow->GetStyle();
6284 if ( _bSet )
6285 nStyle |= _nBits;
6286 else
6287 nStyle &= ~_nBits;
6288 _pWindow->SetStyle( nStyle );
6292 void SAL_CALL VCLXFileControl::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
6294 SolarMutexGuard aGuard;
6296 VclPtr< FileControl > pControl = GetAs< FileControl >();
6297 if ( !pControl )
6298 return;
6300 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6301 switch ( nPropType )
6303 case BASEPROPERTY_HIDEINACTIVESELECTION:
6305 bool bValue(false);
6306 OSL_VERIFY( Value >>= bValue );
6308 lcl_setWinBits( pControl, WB_NOHIDESELECTION, !bValue );
6309 lcl_setWinBits( &pControl->GetEdit(), WB_NOHIDESELECTION, !bValue );
6311 break;
6313 default:
6314 VCLXWindow::setProperty( PropertyName, Value );
6315 break;
6319 void VCLXFileControl::SetWindow( const VclPtr< vcl::Window > &pWindow )
6321 VclPtr< FileControl > pPrevFileControl = GetAsDynamic< FileControl >();
6322 if ( pPrevFileControl )
6323 pPrevFileControl->SetEditModifyHdl( Link<Edit&,void>() );
6325 FileControl* pNewFileControl = dynamic_cast<FileControl*>( pWindow.get() );
6326 if ( pNewFileControl )
6327 pNewFileControl->SetEditModifyHdl( LINK( this, VCLXFileControl, ModifyHdl ) );
6329 VCLXWindow::SetWindow( pWindow );
6332 void VCLXFileControl::addTextListener( const css::uno::Reference< css::awt::XTextListener > & l )
6334 maTextListeners.addInterface( l );
6337 void VCLXFileControl::removeTextListener( const css::uno::Reference< css::awt::XTextListener > & l )
6339 maTextListeners.removeInterface( l );
6342 void VCLXFileControl::setText( const OUString& aText )
6344 SolarMutexGuard aGuard;
6346 VclPtr<vcl::Window> pWindow = GetWindow();
6347 if ( pWindow )
6349 pWindow->SetText( aText );
6351 // also in Java a textChanged is triggered, not in VCL.
6352 // css::awt::Toolkit should be JAVA-compliant...
6353 ModifyHdl();
6357 void VCLXFileControl::insertText( const css::awt::Selection& rSel, const OUString& aText )
6359 SolarMutexGuard aGuard;
6361 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
6362 if ( pFileControl )
6364 pFileControl->GetEdit().SetSelection( Selection( rSel.Min, rSel.Max ) );
6365 pFileControl->GetEdit().ReplaceSelected( aText );
6369 OUString VCLXFileControl::getText()
6371 SolarMutexGuard aGuard;
6373 OUString aText;
6374 VclPtr<vcl::Window> pWindow = GetWindow();
6375 if ( pWindow )
6376 aText = pWindow->GetText();
6377 return aText;
6380 OUString VCLXFileControl::getSelectedText()
6382 SolarMutexGuard aGuard;
6384 OUString aText;
6385 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
6386 if ( pFileControl)
6387 aText = pFileControl->GetEdit().GetSelected();
6388 return aText;
6392 void VCLXFileControl::setSelection( const css::awt::Selection& aSelection )
6394 SolarMutexGuard aGuard;
6396 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
6397 if ( pFileControl )
6398 pFileControl->GetEdit().SetSelection( Selection( aSelection.Min, aSelection.Max ) );
6401 css::awt::Selection VCLXFileControl::getSelection()
6403 SolarMutexGuard aGuard;
6405 css::awt::Selection aSel;
6406 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
6407 if ( pFileControl )
6409 aSel.Min = pFileControl->GetEdit().GetSelection().Min();
6410 aSel.Max = pFileControl->GetEdit().GetSelection().Max();
6412 return aSel;
6415 sal_Bool VCLXFileControl::isEditable()
6417 SolarMutexGuard aGuard;
6419 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
6420 return pFileControl && !pFileControl->GetEdit().IsReadOnly() && pFileControl->GetEdit().IsEnabled();
6423 void VCLXFileControl::setEditable( sal_Bool bEditable )
6425 SolarMutexGuard aGuard;
6427 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
6428 if ( pFileControl )
6429 pFileControl->GetEdit().SetReadOnly( !bEditable );
6432 void VCLXFileControl::setMaxTextLen( sal_Int16 nLen )
6434 SolarMutexGuard aGuard;
6436 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
6437 if ( pFileControl )
6438 pFileControl->GetEdit().SetMaxTextLen( nLen );
6441 sal_Int16 VCLXFileControl::getMaxTextLen()
6443 SolarMutexGuard aGuard;
6445 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
6446 return pFileControl ? pFileControl->GetEdit().GetMaxTextLen() : 0;
6450 IMPL_LINK_NOARG(VCLXFileControl, ModifyHdl, Edit&, void)
6452 ModifyHdl();
6455 void VCLXFileControl::ModifyHdl()
6457 css::awt::TextEvent aEvent;
6458 aEvent.Source = getXWeak();
6459 maTextListeners.textChanged( aEvent );
6462 css::awt::Size VCLXFileControl::getMinimumSize()
6464 SolarMutexGuard aGuard;
6466 css::awt::Size aSz;
6467 VclPtr< FileControl > pControl = GetAs< FileControl >();
6468 if ( pControl )
6470 Size aTmpSize = pControl->GetEdit().CalcMinimumSize();
6471 aTmpSize.AdjustWidth(pControl->GetButton().CalcMinimumSize().Width() );
6472 aSz = vcl::unohelper::ConvertToAWTSize(pControl->CalcWindowSize(aTmpSize));
6474 return aSz;
6477 css::awt::Size VCLXFileControl::getPreferredSize()
6479 css::awt::Size aSz = getMinimumSize();
6480 aSz.Height += 4;
6481 return aSz;
6484 css::awt::Size VCLXFileControl::calcAdjustedSize( const css::awt::Size& rNewSize )
6486 SolarMutexGuard aGuard;
6488 css::awt::Size aSz =rNewSize;
6489 VclPtr< FileControl > pControl = GetAs< FileControl >();
6490 if ( pControl )
6492 css::awt::Size aMinSz = getMinimumSize();
6493 if ( aSz.Height != aMinSz.Height )
6494 aSz.Height = aMinSz.Height;
6496 return aSz;
6499 css::awt::Size VCLXFileControl::getMinimumSize( sal_Int16 nCols, sal_Int16 )
6501 SolarMutexGuard aGuard;
6503 css::awt::Size aSz;
6504 VclPtr< FileControl > pControl = GetAs< FileControl >();
6505 if ( pControl )
6507 aSz = vcl::unohelper::ConvertToAWTSize(pControl->GetEdit().CalcSize(nCols));
6508 aSz.Width += pControl->GetButton().CalcMinimumSize().Width();
6510 return aSz;
6513 void VCLXFileControl::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines )
6515 SolarMutexGuard aGuard;
6517 nCols = 0;
6518 nLines = 1;
6519 VclPtr< FileControl > pControl = GetAs< FileControl >();
6520 if ( pControl )
6521 nCols = pControl->GetEdit().GetMaxVisChars();
6524 void VCLXFileControl::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
6526 PushPropertyIds( rIds,
6527 // FIXME: elide duplication ?
6528 BASEPROPERTY_HIDEINACTIVESELECTION,
6530 VCLXWindow::ImplGetPropertyIds( rIds, true );
6533 SVTXFormattedField::SVTXFormattedField()
6534 :bIsStandardSupplier(true)
6535 ,nKeyToSetDelayed(-1)
6539 SVTXFormattedField::~SVTXFormattedField()
6543 void SVTXFormattedField::SetWindow( const VclPtr< vcl::Window > &_pWindow )
6545 VCLXSpinField::SetWindow(_pWindow);
6546 if (GetAs< FormattedField >())
6547 GetAs< FormattedField >()->GetFormatter().SetAutoColor(true);
6550 void SVTXFormattedField::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
6552 SolarMutexGuard aGuard;
6554 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6555 if ( pField )
6557 Formatter& rFormatter = pField->GetFormatter();
6558 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6559 switch (nPropType)
6561 case BASEPROPERTY_ENFORCE_FORMAT:
6563 bool bEnable( true );
6564 if ( Value >>= bEnable )
6565 rFormatter.EnableNotANumber( !bEnable );
6567 break;
6569 case BASEPROPERTY_EFFECTIVE_MIN:
6570 case BASEPROPERTY_VALUEMIN_DOUBLE:
6571 SetMinValue(Value);
6572 break;
6574 case BASEPROPERTY_EFFECTIVE_MAX:
6575 case BASEPROPERTY_VALUEMAX_DOUBLE:
6576 SetMaxValue(Value);
6577 break;
6579 case BASEPROPERTY_EFFECTIVE_DEFAULT:
6580 SetDefaultValue(Value);
6581 break;
6583 case BASEPROPERTY_TREATASNUMBER:
6585 bool b;
6586 if ( Value >>= b )
6587 SetTreatAsNumber(b);
6589 break;
6591 case BASEPROPERTY_FORMATSSUPPLIER:
6592 if (!Value.hasValue())
6593 setFormatsSupplier(css::uno::Reference< css::util::XNumberFormatsSupplier > (nullptr));
6594 else
6596 css::uno::Reference< css::util::XNumberFormatsSupplier > xNFS;
6597 if ( Value >>= xNFS )
6598 setFormatsSupplier(xNFS);
6600 break;
6601 case BASEPROPERTY_FORMATKEY:
6602 if (!Value.hasValue())
6603 setFormatKey(0);
6604 else
6606 sal_Int32 n = 0;
6607 if ( Value >>= n )
6608 setFormatKey(n);
6610 break;
6612 case BASEPROPERTY_EFFECTIVE_VALUE:
6613 case BASEPROPERTY_VALUE_DOUBLE:
6615 const css::uno::TypeClass rTC = Value.getValueTypeClass();
6616 if (rTC != css::uno::TypeClass_STRING)
6617 // no string
6618 if (rTC != css::uno::TypeClass_DOUBLE)
6619 // no double
6620 if (Value.hasValue())
6621 { // but a value
6622 // try if it is something convertible
6623 sal_Int32 nValue = 0;
6624 if (!(Value >>= nValue))
6625 throw css::lang::IllegalArgumentException();
6626 SetValue(css::uno::Any(static_cast<double>(nValue)));
6627 break;
6630 SetValue(Value);
6632 break;
6633 case BASEPROPERTY_VALUESTEP_DOUBLE:
6635 double d = 0.0;
6636 if ( Value >>= d )
6637 rFormatter.SetSpinSize( d );
6638 else
6640 sal_Int32 n = 0;
6641 if ( Value >>= n )
6642 rFormatter.SetSpinSize( n );
6645 break;
6646 case BASEPROPERTY_DECIMALACCURACY:
6648 sal_Int32 n = 0;
6649 if ( Value >>= n )
6650 rFormatter.SetDecimalDigits( static_cast<sal_uInt16>(n) );
6652 break;
6653 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
6655 bool b;
6656 if ( Value >>= b )
6657 rFormatter.SetThousandsSep( b );
6659 break;
6661 default:
6662 VCLXSpinField::setProperty( PropertyName, Value );
6665 if (BASEPROPERTY_TEXTCOLOR == nPropType)
6666 { // after setting a new text color, think again about the AutoColor flag of the control
6667 // 17.05.2001 - 86859 - frank.schoenheit@germany.sun.com
6668 rFormatter.SetAutoColor(!Value.hasValue());
6671 else
6672 VCLXSpinField::setProperty( PropertyName, Value );
6675 css::uno::Any SVTXFormattedField::getProperty( const OUString& PropertyName )
6677 SolarMutexGuard aGuard;
6679 css::uno::Any aReturn;
6681 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6682 if ( pField )
6684 Formatter& rFormatter = pField->GetFormatter();
6685 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6686 switch (nPropType)
6688 case BASEPROPERTY_EFFECTIVE_MIN:
6689 case BASEPROPERTY_VALUEMIN_DOUBLE:
6690 aReturn = GetMinValue();
6691 break;
6693 case BASEPROPERTY_EFFECTIVE_MAX:
6694 case BASEPROPERTY_VALUEMAX_DOUBLE:
6695 aReturn = GetMaxValue();
6696 break;
6698 case BASEPROPERTY_EFFECTIVE_DEFAULT:
6699 aReturn = GetDefaultValue();
6700 break;
6702 case BASEPROPERTY_TREATASNUMBER:
6703 aReturn <<= GetTreatAsNumber();
6704 break;
6706 case BASEPROPERTY_EFFECTIVE_VALUE:
6707 case BASEPROPERTY_VALUE_DOUBLE:
6708 aReturn = GetValue();
6709 break;
6711 case BASEPROPERTY_VALUESTEP_DOUBLE:
6712 aReturn <<= rFormatter.GetSpinSize();
6713 break;
6715 case BASEPROPERTY_DECIMALACCURACY:
6716 aReturn <<= rFormatter.GetDecimalDigits();
6717 break;
6719 case BASEPROPERTY_FORMATSSUPPLIER:
6721 if (!bIsStandardSupplier)
6722 { // otherwise void
6723 css::uno::Reference< css::util::XNumberFormatsSupplier > xSupplier = m_xCurrentSupplier;
6724 aReturn <<= xSupplier;
6727 break;
6729 case BASEPROPERTY_FORMATKEY:
6731 if (!bIsStandardSupplier)
6732 aReturn <<= getFormatKey();
6734 break;
6736 default:
6737 aReturn = VCLXSpinField::getProperty(PropertyName);
6740 return aReturn;
6743 css::uno::Any SVTXFormattedField::convertEffectiveValue(const css::uno::Any& rValue) const
6745 css::uno::Any aReturn;
6747 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6748 if (!pField)
6749 return aReturn;
6751 Formatter& rFieldFormatter = pField->GetFormatter();
6752 switch (rValue.getValueTypeClass())
6754 case css::uno::TypeClass_DOUBLE:
6755 if (rFieldFormatter.TreatingAsNumber())
6757 double d = 0.0;
6758 rValue >>= d;
6759 aReturn <<= d;
6761 else
6763 SvNumberFormatter* pFormatter = rFieldFormatter.GetFormatter();
6764 if (!pFormatter)
6765 pFormatter = rFieldFormatter.StandardFormatter();
6766 // should never fail
6768 const Color* pDum;
6769 double d = 0.0;
6770 rValue >>= d;
6771 OUString sConverted;
6772 pFormatter->GetOutputString(d, 0, sConverted, &pDum);
6773 aReturn <<= sConverted;
6775 break;
6776 case css::uno::TypeClass_STRING:
6778 OUString aStr;
6779 rValue >>= aStr;
6780 if (rFieldFormatter.TreatingAsNumber())
6782 SvNumberFormatter* pFormatter = rFieldFormatter.GetFormatter();
6783 if (!pFormatter)
6784 pFormatter = rFieldFormatter.StandardFormatter();
6786 double dVal;
6787 sal_uInt32 nTestFormat(0);
6788 if (!pFormatter->IsNumberFormat(aStr, nTestFormat, dVal))
6789 aReturn.clear();
6790 aReturn <<= dVal;
6792 else
6793 aReturn <<= aStr;
6795 break;
6796 default:
6797 aReturn.clear();
6798 break;
6800 return aReturn;
6803 void SVTXFormattedField::SetMinValue(const css::uno::Any& rValue)
6805 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6806 if (!pField)
6807 return;
6809 Formatter& rFormatter = pField->GetFormatter();
6810 switch (rValue.getValueTypeClass())
6813 case css::uno::TypeClass_DOUBLE:
6815 double d = 0.0;
6816 rValue >>= d;
6817 rFormatter.SetMinValue(d);
6818 break;
6820 default:
6821 DBG_ASSERT(rValue.getValueTypeClass() == css::uno::TypeClass_VOID, "SVTXFormattedField::SetMinValue : invalid argument (an exception will be thrown) !");
6822 if ( rValue.getValueTypeClass() != css::uno::TypeClass_VOID )
6825 throw css::lang::IllegalArgumentException();
6827 rFormatter.ClearMinValue();
6828 break;
6832 css::uno::Any SVTXFormattedField::GetMinValue() const
6834 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6835 if (!pField)
6836 return css::uno::Any();
6837 Formatter& rFormatter = pField->GetFormatter();
6838 if (!rFormatter.HasMinValue())
6839 return css::uno::Any();
6841 css::uno::Any aReturn;
6842 aReturn <<= rFormatter.GetMinValue();
6843 return aReturn;
6846 void SVTXFormattedField::SetMaxValue(const css::uno::Any& rValue)
6848 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6849 if (!pField)
6850 return;
6852 Formatter& rFormatter = pField->GetFormatter();
6853 switch (rValue.getValueTypeClass())
6855 case css::uno::TypeClass_DOUBLE:
6857 double d = 0.0;
6858 rValue >>= d;
6859 rFormatter.SetMaxValue(d);
6860 break;
6862 default:
6863 if (rValue.getValueTypeClass() != css::uno::TypeClass_VOID)
6866 throw css::lang::IllegalArgumentException();
6868 rFormatter.ClearMaxValue();
6869 break;
6873 css::uno::Any SVTXFormattedField::GetMaxValue() const
6875 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6876 if (!pField)
6877 return css::uno::Any();
6878 Formatter& rFormatter = pField->GetFormatter();
6879 if (!rFormatter.HasMaxValue())
6880 return css::uno::Any();
6882 css::uno::Any aReturn;
6883 aReturn <<= rFormatter.GetMaxValue();
6884 return aReturn;
6887 void SVTXFormattedField::SetDefaultValue(const css::uno::Any& rValue)
6889 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6890 if (!pField)
6891 return;
6893 css::uno::Any aConverted = convertEffectiveValue(rValue);
6895 Formatter& rFormatter = pField->GetFormatter();
6896 switch (aConverted.getValueTypeClass())
6898 case css::uno::TypeClass_DOUBLE:
6900 double d = 0.0;
6901 aConverted >>= d;
6902 rFormatter.SetDefaultValue(d);
6904 break;
6905 case css::uno::TypeClass_STRING:
6907 OUString aStr;
6908 aConverted >>= aStr;
6909 rFormatter.SetDefaultText( aStr );
6911 break;
6912 default:
6913 rFormatter.EnableEmptyField(true);
6914 // only void accepted
6915 break;
6919 css::uno::Any SVTXFormattedField::GetDefaultValue() const
6921 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6922 if (!pField)
6923 return css::uno::Any();
6924 Formatter& rFormatter = pField->GetFormatter();
6925 if (rFormatter.IsEmptyFieldEnabled())
6926 return css::uno::Any();
6928 css::uno::Any aReturn;
6929 if (rFormatter.TreatingAsNumber())
6930 aReturn <<= rFormatter.GetDefaultValue();
6931 else
6932 aReturn <<= rFormatter.GetDefaultText();
6933 return aReturn;
6936 bool SVTXFormattedField::GetTreatAsNumber() const
6938 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6939 if (pField)
6940 return pField->GetFormatter().TreatingAsNumber();
6942 return true;
6945 void SVTXFormattedField::SetTreatAsNumber(bool bSet)
6947 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6948 if (pField)
6949 pField->GetFormatter().TreatAsNumber(bSet);
6952 css::uno::Any SVTXFormattedField::GetValue() const
6954 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6955 if (!pField)
6956 return css::uno::Any();
6958 Formatter& rFormatter = pField->GetFormatter();
6959 css::uno::Any aReturn;
6960 if (!rFormatter.TreatingAsNumber())
6962 OUString sText = rFormatter.GetTextValue();
6963 aReturn <<= sText;
6965 else
6967 if (!pField->GetText().isEmpty()) // empty is returned as void by default
6968 aReturn <<= rFormatter.GetValue();
6971 return aReturn;
6974 void SVTXFormattedField::SetValue(const css::uno::Any& rValue)
6976 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6977 if (!pField)
6978 return;
6980 if (!rValue.hasValue())
6982 pField->SetText(u""_ustr);
6984 else
6986 Formatter& rFormatter = pField->GetFormatter();
6987 if (rValue.getValueTypeClass() == css::uno::TypeClass_DOUBLE )
6989 double d = 0.0;
6990 rValue >>= d;
6991 rFormatter.SetValue(d);
6993 else
6995 DBG_ASSERT(rValue.getValueTypeClass() == css::uno::TypeClass_STRING, "SVTXFormattedField::SetValue : invalid argument !");
6997 OUString sText;
6998 rValue >>= sText;
6999 if (!rFormatter.TreatingAsNumber())
7000 rFormatter.SetTextFormatted(sText);
7001 else
7002 rFormatter.SetTextValue(sText);
7005 // NotifyTextListeners();
7008 void SVTXFormattedField::setFormatsSupplier(const css::uno::Reference< css::util::XNumberFormatsSupplier > & xSupplier)
7010 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7012 rtl::Reference<SvNumberFormatsSupplierObj> pNew;
7013 if (!xSupplier.is())
7015 if (pField)
7017 Formatter& rFormatter = pField->GetFormatter();
7018 pNew = new SvNumberFormatsSupplierObj(rFormatter.StandardFormatter());
7019 bIsStandardSupplier = true;
7022 else
7024 pNew = comphelper::getFromUnoTunnel<SvNumberFormatsSupplierObj>(xSupplier);
7025 bIsStandardSupplier = false;
7028 if (!pNew)
7029 return; // TODO : how to process ?
7031 m_xCurrentSupplier = std::move(pNew);
7032 if (!pField)
7033 return;
7035 // save the actual value
7036 css::uno::Any aCurrent = GetValue();
7037 Formatter& rFormatter = pField->GetFormatter();
7038 rFormatter.SetFormatter(m_xCurrentSupplier->GetNumberFormatter(), false);
7039 if (nKeyToSetDelayed != -1)
7041 rFormatter.SetFormatKey(nKeyToSetDelayed);
7042 nKeyToSetDelayed = -1;
7044 SetValue(aCurrent);
7045 NotifyTextListeners();
7048 sal_Int32 SVTXFormattedField::getFormatKey() const
7050 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7051 return pField ? pField->GetFormatter().GetFormatKey() : 0;
7054 void SVTXFormattedField::setFormatKey(sal_Int32 nKey)
7056 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7057 if (!pField)
7058 return;
7060 Formatter& rFormatter = pField->GetFormatter();
7061 if (rFormatter.GetFormatter())
7062 rFormatter.SetFormatKey(nKey);
7063 else
7065 // probably I am in a block, in which first the key and next the formatter will be set,
7066 // initially this happens quite certain, as the properties are set in alphabetic sequence,
7067 // and the FormatsSupplier is processed before the FormatKey
7068 nKeyToSetDelayed = nKey;
7070 NotifyTextListeners();
7073 void SVTXFormattedField::NotifyTextListeners()
7075 if ( GetTextListeners().getLength() )
7077 css::awt::TextEvent aEvent;
7078 aEvent.Source = getXWeak();
7079 GetTextListeners().textChanged( aEvent );
7083 void SVTXFormattedField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
7085 PushPropertyIds( rIds,
7086 // FIXME: elide duplication ?
7087 BASEPROPERTY_EFFECTIVE_MIN,
7088 BASEPROPERTY_VALUEMIN_DOUBLE,
7089 BASEPROPERTY_EFFECTIVE_MAX,
7090 BASEPROPERTY_VALUEMAX_DOUBLE,
7091 BASEPROPERTY_EFFECTIVE_DEFAULT,
7092 BASEPROPERTY_TREATASNUMBER,
7093 BASEPROPERTY_EFFECTIVE_VALUE,
7094 BASEPROPERTY_VALUE_DOUBLE,
7095 BASEPROPERTY_VALUESTEP_DOUBLE,
7096 BASEPROPERTY_DECIMALACCURACY,
7097 BASEPROPERTY_FORMATSSUPPLIER,
7098 BASEPROPERTY_NUMSHOWTHOUSANDSEP,
7099 BASEPROPERTY_FORMATKEY,
7100 BASEPROPERTY_TREATASNUMBER,
7101 BASEPROPERTY_ENFORCE_FORMAT,
7103 VCLXWindow::ImplGetPropertyIds( rIds, true );
7104 VCLXSpinField::ImplGetPropertyIds( rIds );
7107 SVTXCurrencyField::SVTXCurrencyField()
7111 SVTXCurrencyField::~SVTXCurrencyField()
7115 void SVTXCurrencyField::setValue( double Value )
7117 SolarMutexGuard aGuard;
7119 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7120 if ( pField )
7121 pField->GetFormatter().SetValue( Value );
7124 double SVTXCurrencyField::getValue()
7126 SolarMutexGuard aGuard;
7128 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7129 return pField ? pField->GetFormatter().GetValue() : 0;
7132 void SVTXCurrencyField::setMin( double Value )
7134 SolarMutexGuard aGuard;
7136 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7137 if ( pField )
7138 pField->GetFormatter().SetMinValue( Value );
7141 double SVTXCurrencyField::getMin()
7143 SolarMutexGuard aGuard;
7145 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7146 return pField ? pField->GetFormatter().GetMinValue() : 0;
7149 void SVTXCurrencyField::setMax( double Value )
7151 SolarMutexGuard aGuard;
7153 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7154 if ( pField )
7155 pField->GetFormatter().SetMaxValue( Value );
7158 double SVTXCurrencyField::getMax()
7160 SolarMutexGuard aGuard;
7162 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7163 return pField ? pField->GetFormatter().GetMaxValue() : 0;
7166 void SVTXCurrencyField::setFirst( double Value )
7168 SolarMutexGuard aGuard;
7170 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7171 if ( pField )
7172 pField->GetFormatter().SetSpinFirst( Value );
7175 double SVTXCurrencyField::getFirst()
7177 SolarMutexGuard aGuard;
7179 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7180 return pField ? pField->GetFormatter().GetSpinFirst() : 0;
7183 void SVTXCurrencyField::setLast( double Value )
7185 SolarMutexGuard aGuard;
7187 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7188 if ( pField )
7189 pField->GetFormatter().SetSpinLast( Value );
7192 double SVTXCurrencyField::getLast()
7194 SolarMutexGuard aGuard;
7196 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7197 return pField ? pField->GetFormatter().GetSpinLast() : 0;
7200 void SVTXCurrencyField::setSpinSize( double Value )
7202 SolarMutexGuard aGuard;
7204 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7205 if ( pField )
7206 pField->GetFormatter().SetSpinSize( Value );
7209 double SVTXCurrencyField::getSpinSize()
7211 SolarMutexGuard aGuard;
7213 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7214 return pField ? pField->GetFormatter().GetSpinSize() : 0;
7217 void SVTXCurrencyField::setDecimalDigits( sal_Int16 Value )
7219 SolarMutexGuard aGuard;
7221 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7222 if ( pField )
7223 pField->GetFormatter().SetDecimalDigits( Value );
7226 sal_Int16 SVTXCurrencyField::getDecimalDigits()
7228 SolarMutexGuard aGuard;
7230 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7231 return pField ? pField->GetFormatter().GetDecimalDigits() : 0;
7234 void SVTXCurrencyField::setStrictFormat( sal_Bool bStrict )
7236 SolarMutexGuard aGuard;
7238 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7239 if ( pField )
7240 pField->GetFormatter().SetStrictFormat( bStrict );
7243 sal_Bool SVTXCurrencyField::isStrictFormat()
7245 SolarMutexGuard aGuard;
7247 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7248 return pField && pField->GetFormatter().IsStrictFormat();
7251 void SVTXCurrencyField::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
7253 SolarMutexGuard aGuard;
7255 VclPtr< DoubleCurrencyField > pField = GetAs< DoubleCurrencyField >();
7256 if ( pField )
7258 sal_uInt16 nPropType = GetPropertyId( PropertyName );
7259 switch (nPropType)
7261 case BASEPROPERTY_CURRENCYSYMBOL:
7263 OUString aStr;
7264 Value >>= aStr;
7265 pField->setCurrencySymbol( aStr );
7267 break;
7268 case BASEPROPERTY_CURSYM_POSITION:
7270 bool b = false;
7271 Value >>= b;
7272 pField->setPrependCurrSym(b);
7274 break;
7276 default:
7277 SVTXFormattedField::setProperty(PropertyName, Value);
7280 else
7281 SVTXFormattedField::setProperty(PropertyName, Value);
7284 css::uno::Any SVTXCurrencyField::getProperty( const OUString& PropertyName )
7286 SolarMutexGuard aGuard;
7288 css::uno::Any aReturn;
7290 VclPtr< DoubleCurrencyField > pField = GetAs< DoubleCurrencyField >();
7291 if ( pField )
7293 sal_uInt16 nPropType = GetPropertyId( PropertyName );
7294 switch (nPropType)
7296 case BASEPROPERTY_CURRENCYSYMBOL:
7298 aReturn <<= pField->getCurrencySymbol();
7300 break;
7301 case BASEPROPERTY_CURSYM_POSITION:
7303 aReturn <<= pField->getPrependCurrSym();
7305 break;
7306 default:
7307 return SVTXFormattedField::getProperty(PropertyName);
7310 return SVTXFormattedField::getProperty(PropertyName);
7313 void SVTXCurrencyField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
7315 PushPropertyIds( rIds,
7316 BASEPROPERTY_ALIGN,
7317 BASEPROPERTY_BACKGROUNDCOLOR,
7318 BASEPROPERTY_BORDER,
7319 BASEPROPERTY_BORDERCOLOR,
7320 BASEPROPERTY_CURRENCYSYMBOL,
7321 BASEPROPERTY_CURSYM_POSITION,
7322 BASEPROPERTY_DECIMALACCURACY,
7323 BASEPROPERTY_DEFAULTCONTROL,
7324 BASEPROPERTY_ENABLED,
7325 BASEPROPERTY_ENABLEVISIBLE,
7326 BASEPROPERTY_FONTDESCRIPTOR,
7327 BASEPROPERTY_HELPTEXT,
7328 BASEPROPERTY_HELPURL,
7329 BASEPROPERTY_NUMSHOWTHOUSANDSEP,
7330 BASEPROPERTY_PRINTABLE,
7331 BASEPROPERTY_READONLY,
7332 BASEPROPERTY_REPEAT,
7333 BASEPROPERTY_REPEAT_DELAY,
7334 BASEPROPERTY_SPIN,
7335 BASEPROPERTY_STRICTFORMAT,
7336 BASEPROPERTY_TABSTOP,
7337 BASEPROPERTY_VALUEMAX_DOUBLE,
7338 BASEPROPERTY_VALUEMIN_DOUBLE,
7339 BASEPROPERTY_VALUESTEP_DOUBLE,
7340 BASEPROPERTY_VALUE_DOUBLE,
7341 BASEPROPERTY_ENFORCE_FORMAT,
7342 BASEPROPERTY_HIDEINACTIVESELECTION,
7343 BASEPROPERTY_VERTICALALIGN,
7344 BASEPROPERTY_WRITING_MODE,
7345 BASEPROPERTY_CONTEXT_WRITING_MODE,
7346 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
7347 BASEPROPERTY_HIGHLIGHT_COLOR,
7348 BASEPROPERTY_HIGHLIGHT_TEXT_COLOR,
7350 VCLXWindow::ImplGetPropertyIds( rIds );
7353 SVTXNumericField::SVTXNumericField()
7357 SVTXNumericField::~SVTXNumericField()
7362 css::uno::Reference<accessibility::XAccessibleContext> SVTXNumericField::CreateAccessibleContext()
7364 VclPtr<FormattedField> pFormattedField = GetAs<FormattedField>();
7365 return AccessibleFactory::createAccessibleContext(pFormattedField);
7369 void SVTXNumericField::setValue( double Value )
7371 SolarMutexGuard aGuard;
7373 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7374 if ( pField )
7375 pField->GetFormatter().SetValue( Value );
7378 double SVTXNumericField::getValue()
7380 SolarMutexGuard aGuard;
7382 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7383 return pField ? pField->GetFormatter().GetValue() : 0;
7386 void SVTXNumericField::setMin( double Value )
7388 SolarMutexGuard aGuard;
7390 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7391 if ( pField )
7392 pField->GetFormatter().SetMinValue( Value );
7395 double SVTXNumericField::getMin()
7397 SolarMutexGuard aGuard;
7399 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7400 return pField ? pField->GetFormatter().GetMinValue() : 0;
7403 void SVTXNumericField::setMax( double Value )
7405 SolarMutexGuard aGuard;
7407 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7408 if ( pField )
7409 pField->GetFormatter().SetMaxValue( Value );
7412 double SVTXNumericField::getMax()
7414 SolarMutexGuard aGuard;
7416 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7417 return pField ? pField->GetFormatter().GetMaxValue() : 0;
7420 void SVTXNumericField::setFirst( double Value )
7422 SolarMutexGuard aGuard;
7424 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7425 if ( pField )
7426 pField->GetFormatter().SetSpinFirst( Value );
7429 double SVTXNumericField::getFirst()
7431 SolarMutexGuard aGuard;
7433 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7434 return pField ? pField->GetFormatter().GetSpinFirst() : 0;
7437 void SVTXNumericField::setLast( double Value )
7439 SolarMutexGuard aGuard;
7441 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7442 if ( pField )
7443 pField->GetFormatter().SetSpinLast( Value );
7446 double SVTXNumericField::getLast()
7448 SolarMutexGuard aGuard;
7450 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7451 return pField ? pField->GetFormatter().GetSpinLast() : 0;
7454 void SVTXNumericField::setSpinSize( double Value )
7456 SolarMutexGuard aGuard;
7458 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7459 if ( pField )
7460 pField->GetFormatter().SetSpinSize( Value );
7463 double SVTXNumericField::getSpinSize()
7465 SolarMutexGuard aGuard;
7467 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7468 return pField ? pField->GetFormatter().GetSpinSize() : 0;
7471 void SVTXNumericField::setDecimalDigits( sal_Int16 Value )
7473 SolarMutexGuard aGuard;
7475 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7476 if ( pField )
7477 pField->GetFormatter().SetDecimalDigits( Value );
7480 sal_Int16 SVTXNumericField::getDecimalDigits()
7482 SolarMutexGuard aGuard;
7484 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7485 return pField ? pField->GetFormatter().GetDecimalDigits() : 0;
7488 void SVTXNumericField::setStrictFormat( sal_Bool bStrict )
7490 SolarMutexGuard aGuard;
7492 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7493 if ( pField )
7494 pField->GetFormatter().SetStrictFormat( bStrict );
7497 sal_Bool SVTXNumericField::isStrictFormat()
7499 SolarMutexGuard aGuard;
7501 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7502 return pField && pField->GetFormatter().IsStrictFormat();
7505 void SVTXNumericField::GetPropertyIds( std::vector< sal_uInt16 > &rIds )
7507 SVTXFormattedField::ImplGetPropertyIds( rIds );
7510 SVTXDateField::SVTXDateField()
7514 SVTXDateField::~SVTXDateField()
7518 void SAL_CALL SVTXDateField::setProperty( const OUString& PropertyName, const css::uno::Any& Value )
7520 VCLXDateField::setProperty( PropertyName, Value );
7522 // some properties need to be forwarded to the sub edit, too
7523 SolarMutexGuard g;
7524 VclPtr< Edit > pSubEdit = GetWindow() ? GetAs<Edit>()->GetSubEdit() : nullptr;
7525 if ( !pSubEdit )
7526 return;
7528 switch ( GetPropertyId( PropertyName ) )
7530 case BASEPROPERTY_TEXTLINECOLOR:
7531 if ( !Value.hasValue() )
7532 pSubEdit->SetTextLineColor();
7533 else
7535 Color nColor;
7536 if ( Value >>= nColor )
7537 pSubEdit->SetTextLineColor( nColor );
7539 break;
7543 void SVTXDateField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
7545 PushPropertyIds( rIds,
7546 BASEPROPERTY_TEXTLINECOLOR,
7548 VCLXDateField::ImplGetPropertyIds( rIds );
7551 VCLXMultiLineEdit::VCLXMultiLineEdit()
7552 :maTextListeners( *this )
7553 ,meLineEndType( LINEEND_LF ) // default behavior before introducing this property: LF (unix-like)
7557 VCLXMultiLineEdit::~VCLXMultiLineEdit()
7561 void VCLXMultiLineEdit::addTextListener( const css::uno::Reference< css::awt::XTextListener > & l )
7563 maTextListeners.addInterface( l );
7566 void VCLXMultiLineEdit::removeTextListener( const css::uno::Reference< css::awt::XTextListener > & l )
7568 maTextListeners.removeInterface( l );
7571 void VCLXMultiLineEdit::setText( const OUString& aText )
7573 SolarMutexGuard aGuard;
7575 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
7576 if ( pEdit )
7578 pEdit->SetText( aText );
7580 // #107218# Call same listeners like VCL would do after user interaction
7581 SetSynthesizingVCLEvent( true );
7582 pEdit->SetModifyFlag();
7583 pEdit->Modify();
7584 SetSynthesizingVCLEvent( false );
7588 void VCLXMultiLineEdit::insertText( const css::awt::Selection& rSel, const OUString& aText )
7590 SolarMutexGuard aGuard;
7592 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
7593 if ( pEdit )
7595 setSelection( rSel );
7596 pEdit->ReplaceSelected( aText );
7600 OUString VCLXMultiLineEdit::getText()
7602 SolarMutexGuard aGuard;
7604 OUString aText;
7605 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
7606 if ( pEdit )
7607 aText = pEdit->GetText( meLineEndType );
7608 return aText;
7611 OUString VCLXMultiLineEdit::getSelectedText()
7613 SolarMutexGuard aGuard;
7615 OUString aText;
7616 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
7617 if ( pMultiLineEdit)
7618 aText = pMultiLineEdit->GetSelected( meLineEndType );
7619 return aText;
7623 void VCLXMultiLineEdit::setSelection( const css::awt::Selection& aSelection )
7625 SolarMutexGuard aGuard;
7627 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
7628 if ( pMultiLineEdit )
7630 pMultiLineEdit->SetSelection( Selection( aSelection.Min, aSelection.Max ) );
7634 css::awt::Selection VCLXMultiLineEdit::getSelection()
7636 SolarMutexGuard aGuard;
7638 css::awt::Selection aSel;
7639 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
7640 if ( pMultiLineEdit )
7642 aSel.Min = pMultiLineEdit->GetSelection().Min();
7643 aSel.Max = pMultiLineEdit->GetSelection().Max();
7645 return aSel;
7648 sal_Bool VCLXMultiLineEdit::isEditable()
7650 SolarMutexGuard aGuard;
7652 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
7653 return pMultiLineEdit && !pMultiLineEdit->IsReadOnly() && pMultiLineEdit->IsEnabled();
7656 void VCLXMultiLineEdit::setEditable( sal_Bool bEditable )
7658 SolarMutexGuard aGuard;
7660 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
7661 if ( pMultiLineEdit )
7662 pMultiLineEdit->SetReadOnly( !bEditable );
7665 void VCLXMultiLineEdit::setMaxTextLen( sal_Int16 nLen )
7667 SolarMutexGuard aGuard;
7669 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
7670 if ( pMultiLineEdit )
7671 pMultiLineEdit->SetMaxTextLen( nLen );
7674 sal_Int16 VCLXMultiLineEdit::getMaxTextLen()
7676 SolarMutexGuard aGuard;
7678 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
7679 return pMultiLineEdit ? static_cast<sal_Int16>(pMultiLineEdit->GetMaxTextLen()) : sal_Int16(0);
7682 OUString VCLXMultiLineEdit::getTextLines()
7684 SolarMutexGuard aGuard;
7686 OUString aText;
7687 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
7688 if ( pEdit )
7689 aText = pEdit->GetTextLines( meLineEndType );
7690 return aText;
7693 css::awt::Size VCLXMultiLineEdit::getMinimumSize()
7695 SolarMutexGuard aGuard;
7697 css::awt::Size aSz;
7698 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
7699 if ( pEdit )
7700 aSz = vcl::unohelper::ConvertToAWTSize(pEdit->CalcMinimumSize());
7701 return aSz;
7704 css::awt::Size VCLXMultiLineEdit::getPreferredSize()
7706 return getMinimumSize();
7709 css::awt::Size VCLXMultiLineEdit::calcAdjustedSize( const css::awt::Size& rNewSize )
7711 SolarMutexGuard aGuard;
7713 css::awt::Size aSz = rNewSize;
7714 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
7715 if ( pEdit )
7716 aSz = vcl::unohelper::ConvertToAWTSize(
7717 pEdit->CalcAdjustedSize(vcl::unohelper::ConvertToVCLSize(rNewSize)));
7718 return aSz;
7721 css::awt::Size VCLXMultiLineEdit::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines )
7723 SolarMutexGuard aGuard;
7725 css::awt::Size aSz;
7726 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
7727 if ( pEdit )
7728 aSz = vcl::unohelper::ConvertToAWTSize(pEdit->CalcBlockSize(nCols, nLines));
7729 return aSz;
7732 void VCLXMultiLineEdit::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines )
7734 SolarMutexGuard aGuard;
7736 nCols = nLines = 0;
7737 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
7738 if ( pEdit )
7740 sal_uInt16 nC, nL;
7741 pEdit->GetMaxVisColumnsAndLines( nC, nL );
7742 nCols = nC;
7743 nLines = nL;
7747 void VCLXMultiLineEdit::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
7749 switch ( rVclWindowEvent.GetId() )
7751 case VclEventId::EditModify:
7753 if ( maTextListeners.getLength() )
7755 css::awt::TextEvent aEvent;
7756 aEvent.Source = getXWeak();
7757 maTextListeners.textChanged( aEvent );
7760 break;
7761 default:
7763 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
7765 break;
7769 void VCLXMultiLineEdit::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
7771 SolarMutexGuard aGuard;
7773 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
7774 if ( !pMultiLineEdit )
7775 return;
7777 sal_uInt16 nPropType = GetPropertyId( PropertyName );
7778 switch ( nPropType )
7780 case BASEPROPERTY_LINE_END_FORMAT:
7782 sal_Int16 nLineEndType = css::awt::LineEndFormat::LINE_FEED;
7783 OSL_VERIFY( Value >>= nLineEndType );
7784 switch ( nLineEndType )
7786 case css::awt::LineEndFormat::CARRIAGE_RETURN: meLineEndType = LINEEND_CR; break;
7787 case css::awt::LineEndFormat::LINE_FEED: meLineEndType = LINEEND_LF; break;
7788 case css::awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED: meLineEndType = LINEEND_CRLF; break;
7789 default: OSL_FAIL( "VCLXMultiLineEdit::setProperty: invalid line end value!" ); break;
7792 break;
7794 case BASEPROPERTY_READONLY:
7796 bool b;
7797 if ( Value >>= b )
7798 pMultiLineEdit->SetReadOnly( b );
7800 break;
7801 case BASEPROPERTY_MAXTEXTLEN:
7803 sal_Int16 n = sal_Int16();
7804 if ( Value >>= n )
7805 pMultiLineEdit->SetMaxTextLen( n );
7807 break;
7808 case BASEPROPERTY_HIDEINACTIVESELECTION:
7810 bool b;
7811 if ( Value >>= b )
7813 pMultiLineEdit->EnableFocusSelectionHide( b );
7814 lcl_setWinBits( pMultiLineEdit, WB_NOHIDESELECTION, !b );
7817 break;
7818 default:
7820 VCLXWindow::setProperty( PropertyName, Value );
7825 css::uno::Any VCLXMultiLineEdit::getProperty( const OUString& PropertyName )
7827 SolarMutexGuard aGuard;
7829 css::uno::Any aProp;
7830 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
7831 if ( pMultiLineEdit )
7833 sal_uInt16 nPropType = GetPropertyId( PropertyName );
7834 switch ( nPropType )
7836 case BASEPROPERTY_LINE_END_FORMAT:
7838 sal_Int16 nLineEndType = css::awt::LineEndFormat::LINE_FEED;
7839 switch ( meLineEndType )
7841 case LINEEND_CR: nLineEndType = css::awt::LineEndFormat::CARRIAGE_RETURN; break;
7842 case LINEEND_LF: nLineEndType = css::awt::LineEndFormat::LINE_FEED; break;
7843 case LINEEND_CRLF: nLineEndType = css::awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED; break;
7844 default: OSL_FAIL( "VCLXMultiLineEdit::getProperty: invalid line end value!" ); break;
7846 aProp <<= nLineEndType;
7848 break;
7850 case BASEPROPERTY_READONLY:
7852 aProp <<= pMultiLineEdit->IsReadOnly();
7854 break;
7855 case BASEPROPERTY_MAXTEXTLEN:
7857 aProp <<= static_cast<sal_Int16>(pMultiLineEdit->GetMaxTextLen());
7859 break;
7860 default:
7862 aProp = VCLXWindow::getProperty( PropertyName );
7866 return aProp;
7869 void SAL_CALL VCLXMultiLineEdit::setFocus( )
7871 SolarMutexGuard aGuard;
7873 // don't grab the focus if we already have it. Reason is that the only thing which the edit
7874 // does is forwarding the focus to its text window. This text window then does a "select all".
7875 // So if the text window already has the focus, and we give the focus to the multi line
7876 // edit, then all which happens is that everything is selected.
7877 // #i27072#
7878 if ( GetWindow() && !GetWindow()->HasChildPathFocus() )
7879 GetWindow()->GrabFocus();
7882 void VCLXMultiLineEdit::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
7884 PushPropertyIds( rIds,
7885 // FIXME: elide duplication ?
7886 BASEPROPERTY_LINE_END_FORMAT,
7887 BASEPROPERTY_READONLY,
7888 BASEPROPERTY_MAXTEXTLEN,
7889 BASEPROPERTY_HIDEINACTIVESELECTION,
7891 VCLXWindow::ImplGetPropertyIds( rIds, true );
7894 css::uno::Reference<css::accessibility::XAccessibleContext> VCLXMultiLineEdit::CreateAccessibleContext()
7896 VclPtr<MultiLineEdit> pMultiLineEdit = GetAs<MultiLineEdit>();
7897 return AccessibleFactory::createAccessibleContext(pMultiLineEdit);
7900 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */