1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
)
84 for ( sal_uInt16 d
= 0; d
< nDigits
; d
++ )
89 static double ImplCalcDoubleValue( double nValue
, sal_uInt16 nDigits
)
92 for ( sal_uInt16 d
= 0; d
< nDigits
; d
++ )
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() );
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
)
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
);
183 aStyleSettings
.SetOptions( aStyleSettings
.GetOptions() | StyleSettingsOptions::Mono
);
187 aStyleSettings
.SetOptions( aStyleSettings
.GetOptions() & ~StyleSettingsOptions::Mono
);
189 aSettings
.SetStyleSettings( aStyleSettings
);
190 _pWindow
->SetSettings( aSettings
);
193 static Any
getVisualEffect( vcl::Window
const * _pWindow
)
197 StyleSettings aStyleSettings
= _pWindow
->GetSettings().GetStyleSettings();
198 if ( aStyleSettings
.GetOptions() & StyleSettingsOptions::Mono
)
199 aEffect
<<= sal_Int16(FLAT
);
201 aEffect
<<= sal_Int16(LOOK3D
);
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
;
228 Size aOldSize
= GetWindow()->GetSizePixel();
229 VCLXWindow::setPosSize( X
, Y
, Width
, Height
, Flags
);
230 if ( ( aOldSize
.Width() != Width
) || ( aOldSize
.Height() != Height
) )
235 void VCLXGraphicControl::setProperty( const OUString
& PropertyName
, const css::uno::Any
& Value
)
237 SolarMutexGuard aGuard
;
242 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
245 case BASEPROPERTY_GRAPHIC
:
247 Reference
< XGraphic
> xGraphic
;
248 OSL_VERIFY( Value
>>= xGraphic
);
249 maImage
= Image( xGraphic
);
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
) );
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
) );
283 VCLXWindow::setProperty( PropertyName
, Value
);
288 css::uno::Any
VCLXGraphicControl::getProperty( const OUString
& PropertyName
)
290 SolarMutexGuard aGuard
;
296 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
299 case BASEPROPERTY_GRAPHIC
:
300 aProp
<<= Graphic(maImage
.GetBitmapEx()).GetXGraphic();
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() );
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() );
330 aProp
= VCLXWindow::getProperty( PropertyName
);
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
,
356 BASEPROPERTY_PRINTABLE
,
357 BASEPROPERTY_PUSHBUTTONTYPE
,
359 BASEPROPERTY_REPEAT_DELAY
,
361 BASEPROPERTY_TABSTOP
,
363 BASEPROPERTY_FOCUSONCLICK
,
364 BASEPROPERTY_MULTILINE
,
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();
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
;
446 VclPtr
< PushButton
> pButton
= GetAs
< PushButton
>();
448 aSz
= pButton
->CalcMinimumSize();
449 return vcl::unohelper::ConvertToAWTSize(aSz
);
452 css::awt::Size
VCLXButton::getPreferredSize( )
454 css::awt::Size aSz
= getMinimumSize();
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
>();
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() );
479 if ( ( aSz
.Width() > aMinSz
.Width() ) && ( aSz
.Height() < aMinSz
.Height() ) )
480 aSz
.setHeight( aMinSz
.Height() );
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
>();
496 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
499 case BASEPROPERTY_FOCUSONCLICK
:
500 ::toolkit::adjustBooleanWindowStyle( Value
, pButton
, WB_NOPOINTERFOCUS
, true );
503 case BASEPROPERTY_TOGGLE
:
504 ::toolkit::adjustBooleanWindowStyle( Value
, pButton
, WB_TOGGLE
, false );
507 case BASEPROPERTY_DEFAULTBUTTON
:
509 WinBits nStyle
= pButton
->GetStyle() | WB_DEFBUTTON
;
511 if ( ( Value
>>= b
) && !b
)
512 nStyle
&= ~WB_DEFBUTTON
;
513 pButton
->SetStyle( nStyle
);
516 case BASEPROPERTY_STATE
:
518 if ( GetWindow()->GetType() == WindowType::PUSHBUTTON
)
520 sal_Int16 n
= sal_Int16();
522 static_cast<PushButton
*>(pButton
.get())->SetState( static_cast<TriState
>(n
) );
528 VCLXGraphicControl::setProperty( PropertyName
, Value
);
533 css::uno::Any
VCLXButton::getProperty( const OUString
& PropertyName
)
535 SolarMutexGuard aGuard
;
538 VclPtr
< Button
> pButton
= GetAs
< Button
>();
541 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
544 case BASEPROPERTY_FOCUSONCLICK
:
545 aProp
<<= ( ( pButton
->GetStyle() & WB_NOPOINTERFOCUS
) == 0 );
548 case BASEPROPERTY_TOGGLE
:
549 aProp
<<= ( ( pButton
->GetStyle() & WB_TOGGLE
) != 0 );
552 case BASEPROPERTY_DEFAULTBUTTON
:
554 aProp
<<= ( pButton
->GetStyle() & WB_DEFBUTTON
) != 0;
557 case BASEPROPERTY_STATE
:
559 if ( GetWindow()->GetType() == WindowType::PUSHBUTTON
)
561 aProp
<<= static_cast<sal_Int16
>(static_cast<PushButton
*>(pButton
.get())->GetState());
567 aProp
= VCLXGraphicControl::getProperty( PropertyName
);
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
);
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
);
615 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent
);
623 void VCLXImageControl::ImplGetPropertyIds( std::vector
< sal_uInt16
> &rIds
)
625 PushPropertyIds( rIds
,
626 BASEPROPERTY_BACKGROUNDCOLOR
,
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
;
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
);
698 case BASEPROPERTY_IMAGE_SCALE_MODE
:
700 sal_Int16
nScaleMode( ImageScaleMode::ANISOTROPIC
);
701 if ( pImageControl
&& ( Value
>>= nScaleMode
) )
703 pImageControl
->SetScaleMode( nScaleMode
);
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
);
720 VCLXGraphicControl::setProperty( PropertyName
, Value
);
725 css::uno::Any
VCLXImageControl::getProperty( const OUString
& PropertyName
)
727 SolarMutexGuard aGuard
;
730 VclPtr
< ImageControl
> pImageControl
= GetAs
< ImageControl
>();
731 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
735 case BASEPROPERTY_IMAGE_SCALE_MODE
:
736 aProp
<<= ( pImageControl
? pImageControl
->GetScaleMode() : ImageScaleMode::ANISOTROPIC
);
739 case BASEPROPERTY_SCALEIMAGE
:
740 aProp
<<= ( pImageControl
&& pImageControl
->GetScaleMode() != ImageScaleMode::NONE
);
744 aProp
= VCLXGraphicControl::getProperty( PropertyName
);
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
,
766 BASEPROPERTY_PRINTABLE
,
768 BASEPROPERTY_TABSTOP
,
769 BASEPROPERTY_TRISTATE
,
770 BASEPROPERTY_VISUALEFFECT
,
771 BASEPROPERTY_MULTILINE
,
772 BASEPROPERTY_BACKGROUNDCOLOR
,
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();
838 pWindow
->SetText( rLabel
);
841 void VCLXCheckBox::setState( sal_Int16 n
)
843 SolarMutexGuard aGuard
;
845 VclPtr
< CheckBox
> pCheckBox
= GetAs
< CheckBox
>();
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 );
866 SetSynthesizingVCLEvent( false );
869 sal_Int16
VCLXCheckBox::getState()
871 SolarMutexGuard aGuard
;
873 sal_Int16 nState
= -1;
874 VclPtr
< CheckBox
> pCheckBox
= GetAs
< CheckBox
>();
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!" );
889 void VCLXCheckBox::enableTriState( sal_Bool b
)
891 SolarMutexGuard aGuard
;
893 VclPtr
< CheckBox
> pCheckBox
= GetAs
< CheckBox
>();
895 pCheckBox
->EnableTriState( b
);
898 css::awt::Size
VCLXCheckBox::getMinimumSize()
900 SolarMutexGuard aGuard
;
903 VclPtr
< CheckBox
> pCheckBox
= GetAs
< CheckBox
>();
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
>();
922 Size aMinSz
= pCheckBox
->CalcMinimumSize(rNewSize
.Width
);
923 if ( ( aSz
.Width() > aMinSz
.Width() ) && ( aSz
.Height() < aMinSz
.Height() ) )
924 aSz
.setHeight( aMinSz
.Height() );
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
>();
939 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
942 case BASEPROPERTY_VISUALEFFECT
:
943 ::toolkit::setVisualEffect( Value
, pCheckBox
);
946 case BASEPROPERTY_TRISTATE
:
950 pCheckBox
->EnableTriState( b
);
953 case BASEPROPERTY_STATE
:
955 sal_Int16 n
= sal_Int16();
962 VCLXGraphicControl::setProperty( PropertyName
, Value
);
967 css::uno::Any
VCLXCheckBox::getProperty( const OUString
& PropertyName
)
969 SolarMutexGuard aGuard
;
972 VclPtr
< CheckBox
> pCheckBox
= GetAs
< CheckBox
>();
975 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
978 case BASEPROPERTY_VISUALEFFECT
:
979 aProp
= ::toolkit::getVisualEffect( pCheckBox
);
981 case BASEPROPERTY_TRISTATE
:
982 aProp
<<= pCheckBox
->IsTriStateEnabled();
984 case BASEPROPERTY_STATE
:
985 aProp
<<= static_cast<sal_Int16
>(pCheckBox
->GetState());
989 aProp
= VCLXGraphicControl::getProperty( PropertyName
);
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
>();
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
);
1030 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent
);
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
,
1050 BASEPROPERTY_PRINTABLE
,
1052 BASEPROPERTY_TABSTOP
,
1053 BASEPROPERTY_VISUALEFFECT
,
1054 BASEPROPERTY_MULTILINE
,
1055 BASEPROPERTY_BACKGROUNDCOLOR
,
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
>();
1095 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
1096 switch ( nPropType
)
1098 case BASEPROPERTY_VISUALEFFECT
:
1099 ::toolkit::setVisualEffect( Value
, pButton
);
1102 case BASEPROPERTY_STATE
:
1104 sal_Int16 n
= sal_Int16();
1108 if ( pButton
->IsRadioCheckEnabled() )
1109 pButton
->Check( b
);
1111 pButton
->SetState( b
);
1115 case BASEPROPERTY_AUTOTOGGLE
:
1119 pButton
->EnableRadioCheck( b
);
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
>();
1137 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
1138 switch ( nPropType
)
1140 case BASEPROPERTY_VISUALEFFECT
:
1141 aProp
= ::toolkit::getVisualEffect( pButton
);
1143 case BASEPROPERTY_STATE
:
1144 aProp
<<= static_cast<sal_Int16
>( pButton
->IsChecked() ? 1 : 0 );
1146 case BASEPROPERTY_AUTOTOGGLE
:
1147 aProp
<<= pButton
->IsRadioCheckEnabled();
1151 aProp
= VCLXGraphicControl::getProperty( PropertyName
);
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();
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
>();
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
;
1229 VclPtr
< RadioButton
> pRadioButton
= GetAs
< RadioButton
>();
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
>();
1248 Size aMinSz
= pRadioButton
->CalcMinimumSize(rNewSize
.Width
);
1249 if ( ( aSz
.Width() > aMinSz
.Width() ) && ( aSz
.Height() < aMinSz
.Height() ) )
1250 aSz
.setHeight( aMinSz
.Height() );
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 );
1277 case VclEventId::RadiobuttonToggle
:
1278 ImplClickedOrToggled( true );
1282 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent
);
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
,
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
>();
1337 void VCLXSpinField::down()
1339 SolarMutexGuard aGuard
;
1341 VclPtr
< SpinField
> pSpinField
= GetAs
< SpinField
>();
1346 void VCLXSpinField::first()
1348 SolarMutexGuard aGuard
;
1350 VclPtr
< SpinField
> pSpinField
= GetAs
< SpinField
>();
1352 pSpinField
->First();
1355 void VCLXSpinField::last()
1357 SolarMutexGuard aGuard
;
1359 VclPtr
< SpinField
> pSpinField
= GetAs
< SpinField
>();
1364 void VCLXSpinField::enableRepeat( sal_Bool bRepeat
)
1366 SolarMutexGuard aGuard
;
1368 VclPtr
<vcl::Window
> pWindow
= GetWindow();
1371 WinBits nStyle
= pWindow
->GetStyle();
1373 nStyle
|= WB_REPEAT
;
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
);
1402 case VclEventId::SpinfieldDown
: maSpinListeners
.down( aEvent
);
1404 case VclEventId::SpinfieldFirst
: maSpinListeners
.first( aEvent
);
1406 case VclEventId::SpinfieldLast
: maSpinListeners
.last( aEvent
);
1416 VCLXEdit::ProcessWindowEvent( rVclWindowEvent
);
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
,
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
>();
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
>();
1514 sal_uInt16 nP
= nPos
;
1515 for ( auto const & item
: aItems
)
1519 OSL_FAIL( "VCLXListBox::addItems: too many entries!" );
1520 // skip remaining entries, list cannot hold them, anyway
1524 pBox
->InsertEntry( item
, nP
++ );
1528 void VCLXListBox::removeItems( sal_Int16 nPos
, sal_Int16 nCount
)
1530 SolarMutexGuard aGuard
;
1531 VclPtr
< ListBox
> pBox
= GetAs
< ListBox
>();
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
;
1552 VclPtr
< ListBox
> pBox
= GetAs
< ListBox
>();
1554 aItem
= pBox
->GetEntry( nPos
);
1558 css::uno::Sequence
< OUString
> VCLXListBox::getItems()
1560 SolarMutexGuard aGuard
;
1562 css::uno::Sequence
< OUString
> aSeq
;
1563 VclPtr
< ListBox
> pBox
= GetAs
< ListBox
>();
1566 auto n
= pBox
->GetEntryCount();
1567 aSeq
= css::uno::Sequence
< OUString
>( n
);
1571 aSeq
.getArray()[n
] = pBox
->GetEntry( n
);
1577 sal_Int16
VCLXListBox::getSelectedItemPos()
1579 SolarMutexGuard aGuard
;
1580 VclPtr
< ListBox
> pBox
= GetAs
< ListBox
>();
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");
1590 css::uno::Sequence
<sal_Int16
> VCLXListBox::getSelectedItemsPos()
1592 SolarMutexGuard aGuard
;
1594 css::uno::Sequence
<sal_Int16
> aSeq
;
1595 VclPtr
< ListBox
> pBox
= GetAs
< ListBox
>();
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
);
1606 OUString
VCLXListBox::getSelectedItem()
1608 SolarMutexGuard aGuard
;
1611 VclPtr
< ListBox
> pBox
= GetAs
< ListBox
>();
1613 aItem
= pBox
->GetSelectedEntry();
1617 css::uno::Sequence
< OUString
> VCLXListBox::getSelectedItems()
1619 SolarMutexGuard aGuard
;
1621 css::uno::Sequence
< OUString
> aSeq
;
1622 VclPtr
< ListBox
> pBox
= GetAs
< ListBox
>();
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
);
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 );
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
>();
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
);
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 );
1690 SetSynthesizingVCLEvent( false );
1693 void VCLXListBox::selectItem( const OUString
& rItemText
, sal_Bool bSelect
)
1695 SolarMutexGuard aGuard
;
1697 VclPtr
< ListBox
> pBox
= GetAs
< ListBox
>();
1700 selectItemPos( pBox
->GetEntryPos( rItemText
), bSelect
);
1704 void VCLXListBox::setDropDownLineCount( sal_Int16 nLines
)
1706 SolarMutexGuard aGuard
;
1707 VclPtr
< ListBox
> pBox
= GetAs
< ListBox
>();
1709 pBox
->SetDropDownLineCount( nLines
);
1712 sal_Int16
VCLXListBox::getDropDownLineCount()
1714 SolarMutexGuard aGuard
;
1716 sal_Int16 nLines
= 0;
1717 VclPtr
< ListBox
> pBox
= GetAs
< ListBox
>();
1719 nLines
= pBox
->GetDropDownLineCount();
1723 sal_Bool
VCLXListBox::isMutipleMode()
1725 SolarMutexGuard aGuard
;
1726 bool bMulti
= false;
1727 VclPtr
< ListBox
> pBox
= GetAs
< ListBox
>();
1729 bMulti
= pBox
->IsMultiSelectionEnabled();
1733 void VCLXListBox::setMultipleMode( sal_Bool bMulti
)
1735 SolarMutexGuard aGuard
;
1736 VclPtr
< ListBox
> pBox
= GetAs
< ListBox
>();
1738 pBox
->EnableMultiSelection( bMulti
);
1741 void VCLXListBox::makeVisible( sal_Int16 nEntry
)
1743 SolarMutexGuard aGuard
;
1744 VclPtr
< ListBox
> pBox
= GetAs
< ListBox
>();
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
>();
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();
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
);
1792 VCLXWindow::ProcessWindowEvent( rVclWindowEvent
);
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
>();
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
);
1822 case BASEPROPERTY_READONLY
:
1826 pListBox
->SetReadOnly( b
);
1829 case BASEPROPERTY_MULTISELECTION
:
1833 pListBox
->EnableMultiSelection( b
);
1836 case BASEPROPERTY_MULTISELECTION_SIMPLEMODE
:
1837 ::toolkit::adjustBooleanWindowStyle( Value
, pListBox
, WB_SIMPLEMODE
, false );
1839 case BASEPROPERTY_LINECOUNT
:
1843 pListBox
->SetDropDownLineCount( n
);
1846 case BASEPROPERTY_STRINGITEMLIST
:
1848 css::uno::Sequence
< OUString
> aItems
;
1849 if ( Value
>>= aItems
)
1852 addItems( aItems
, 0 );
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 );
1867 pListBox
->SetNoSelection();
1869 if ( !pListBox
->GetSelectedEntryCount() )
1870 pListBox
->SetTopEntry( 0 );
1874 case BASEPROPERTY_HIGHLIGHT_COLOR
:
1877 bool bVoid
= Value
.getValueTypeClass() == css::uno::TypeClass_VOID
;
1880 nColor
= Application::GetSettings().GetStyleSettings().GetHighlightColor();
1884 if (!(Value
>>= nColor
))
1887 pListBox
->SetHighlightColor(nColor
);
1890 case BASEPROPERTY_HIGHLIGHT_TEXT_COLOR
:
1893 bool bVoid
= Value
.getValueTypeClass() == css::uno::TypeClass_VOID
;
1896 nColor
= Application::GetSettings().GetStyleSettings().GetHighlightTextColor();
1900 if (!(Value
>>= nColor
))
1903 pListBox
->SetHighlightTextColor(nColor
);
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
>();
1920 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
1921 switch ( nPropType
)
1923 case BASEPROPERTY_ITEM_SEPARATOR_POS
:
1924 aProp
<<= sal_Int16( pListBox
->GetSeparatorPos() );
1926 case BASEPROPERTY_READONLY
:
1928 aProp
<<= pListBox
->IsReadOnly();
1931 case BASEPROPERTY_MULTISELECTION
:
1933 aProp
<<= pListBox
->IsMultiSelectionEnabled();
1936 case BASEPROPERTY_MULTISELECTION_SIMPLEMODE
:
1938 aProp
<<= ( ( pListBox
->GetStyle() & WB_SIMPLEMODE
) == 0 );
1941 case BASEPROPERTY_LINECOUNT
:
1943 aProp
<<= static_cast<sal_Int16
>(pListBox
->GetDropDownLineCount());
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
);
1959 aProp
= VCLXWindow::getProperty( PropertyName
);
1966 css::awt::Size
VCLXListBox::getMinimumSize( )
1968 SolarMutexGuard aGuard
;
1970 VclPtr
< ListBox
> pListBox
= GetAs
< ListBox
>();
1972 aSz
= pListBox
->CalcMinimumSize();
1973 return vcl::unohelper::ConvertToAWTSize(aSz
);
1976 css::awt::Size
VCLXListBox::getPreferredSize( )
1978 SolarMutexGuard aGuard
;
1980 VclPtr
< ListBox
> pListBox
= GetAs
< ListBox
>();
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
>();
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
;
2004 VclPtr
< ListBox
> pListBox
= GetAs
< ListBox
>();
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
;
2014 VclPtr
< ListBox
> pListBox
= GetAs
< ListBox
>();
2018 pListBox
->GetMaxVisColumnsAndLines( nC
, 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
);
2041 Image
lcl_getImageFromURL( const OUString
& i_rImageURL
)
2043 if ( i_rImageURL
.isEmpty() )
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");
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?!" );
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?!" );
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
),
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();
2178 pWindow
->SetText( rText
);
2181 OUString
VCLXMessageBox::getCaptionText()
2183 SolarMutexGuard aGuard
;
2186 VclPtr
<vcl::Window
> pWindow
= GetWindow();
2188 aText
= pWindow
->GetText();
2192 void VCLXMessageBox::setMessageText( const OUString
& rText
)
2194 SolarMutexGuard aGuard
;
2195 VclPtr
< MessBox
> pBox
= GetAs
< MessBox
>();
2197 pBox
->SetMessText( rText
);
2200 OUString
VCLXMessageBox::getMessageText()
2202 SolarMutexGuard aGuard
;
2204 VclPtr
< MessBox
> pBox
= GetAs
< MessBox
>();
2206 aText
= pBox
->GetMessText();
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
>();
2244 pDialog
->EndDialog( i_result
);
2247 void SAL_CALL
VCLXDialog::setHelpId( const OUString
& rId
)
2249 SolarMutexGuard aGuard
;
2250 VclPtr
< vcl::Window
> pWindow
= GetWindow();
2252 pWindow
->SetHelpId( rId
);
2255 void VCLXDialog::setTitle( const OUString
& Title
)
2257 SolarMutexGuard aGuard
;
2258 VclPtr
< vcl::Window
> pWindow
= GetWindow();
2260 pWindow
->SetText( Title
);
2263 OUString
VCLXDialog::getTitle()
2265 SolarMutexGuard aGuard
;
2268 VclPtr
< vcl::Window
> pWindow
= GetWindow();
2270 aTitle
= pWindow
->GetText();
2274 sal_Int16
VCLXDialog::execute()
2276 SolarMutexGuard aGuard
;
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
);
2306 void VCLXDialog::endExecute()
2311 void SAL_CALL
VCLXDialog::draw( sal_Int32 nX
, sal_Int32 nY
)
2313 SolarMutexGuard aGuard
;
2314 VclPtr
< vcl::Window
> pWindow
= GetWindow();
2317 OutputDevice
* pDev
= VCLUnoHelper::GetOutputDevice( getGraphics() );
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
>();
2333 pDlg
->GetDrawWindowBorder( aInfo
.LeftInset
, aInfo
.TopInset
, aInfo
.RightInset
, aInfo
.BottomInset
);
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
>();
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
);
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();
2424 void SAL_CALL
VCLXMultiPage::draw( sal_Int32 nX
, sal_Int32 nY
)
2426 SolarMutexGuard aGuard
;
2427 VclPtr
< vcl::Window
> pWindow
= GetWindow();
2431 OutputDevice
* pDev
= VCLUnoHelper::GetOutputDevice( getGraphics() );
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();
2455 aProp
= VCLXContainer::getProperty( PropertyName
);
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
>();
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");
2481 // when the multipage is created we attempt to set the activepage
2482 // but no pages created
2483 if ( nId
&& nId
<= getWindows().getLength() )
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
);
2512 VCLXContainer::setProperty( PropertyName
, Value
);
2517 TabControl
*VCLXMultiPage::getTabControl() const
2519 VclPtr
<TabControl
> pTabControl
= GetAsDynamic
< TabControl
>();
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
);
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();
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
) )) }
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
);
2623 case VclEventId::TabpageActivate
:
2625 sal_uInt16 nPageID
= static_cast<sal_uInt16
>(reinterpret_cast<sal_uIntPtr
>( rVclWindowEvent
.GetData() ));
2626 maTabListeners
.activated( nPageID
);
2630 VCLXContainer::ProcessWindowEvent( rVclWindowEvent
);
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()
2667 void SAL_CALL
VCLXTabPage::draw( sal_Int32 nX
, sal_Int32 nY
)
2669 SolarMutexGuard aGuard
;
2670 VclPtr
< vcl::Window
> pWindow
= GetWindow();
2674 OutputDevice
* pDev
= VCLUnoHelper::GetOutputDevice( getGraphics() );
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
>();
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
);
2719 case BASEPROPERTY_TITLE
:
2722 if ( Value
>>= sTitle
)
2724 pTabPage
->SetText(sTitle
);
2731 VCLXContainer::setProperty( PropertyName
, Value
);
2736 TabPage
*VCLXTabPage::getTabPage() const
2738 VclPtr
< TabPage
> pTabPage
= GetAsDynamic
< TabPage
>();
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
);
2783 VCLXWindow::ProcessWindowEvent( rVclWindowEvent
);
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
>();
2799 pBase
->SetText(Text
);
2802 OUString
VCLXFixedHyperlink::getText()
2804 SolarMutexGuard aGuard
;
2807 VclPtr
< vcl::Window
> pWindow
= GetWindow();
2809 aText
= pWindow
->GetText();
2813 void VCLXFixedHyperlink::setURL( const OUString
& URL
)
2815 SolarMutexGuard aGuard
;
2816 VclPtr
< FixedHyperlink
> pBase
= GetAs
< FixedHyperlink
>();
2818 pBase
->SetURL( URL
);
2821 OUString
VCLXFixedHyperlink::getURL( )
2823 SolarMutexGuard aGuard
;
2826 VclPtr
< FixedHyperlink
> pBase
= GetAs
< FixedHyperlink
>();
2828 aText
= pBase
->GetURL();
2832 void VCLXFixedHyperlink::setAlignment( sal_Int16 nAlign
)
2834 SolarMutexGuard aGuard
;
2836 VclPtr
< vcl::Window
> pWindow
= GetWindow();
2840 WinBits nNewBits
= 0;
2841 if ( nAlign
== css::awt::TextAlign::LEFT
)
2843 else if ( nAlign
== css::awt::TextAlign::CENTER
)
2844 nNewBits
= WB_CENTER
;
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();
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
;
2867 nAlign
= css::awt::TextAlign::RIGHT
;
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
;
2888 VclPtr
< FixedText
> pFixedText
= GetAs
< FixedText
>();
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
>();
2906 Size aMinSz
= pFixedText
->CalcMinimumSize(rNewSize
.Width
);
2907 if ( ( aSz
.Width() > aMinSz
.Width() ) && ( aSz
.Height() < aMinSz
.Height() ) )
2908 aSz
.setHeight( aMinSz
.Height() );
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
>();
2924 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
2925 switch ( nPropType
)
2927 case BASEPROPERTY_LABEL
:
2930 if ( Value
>>= sNewLabel
)
2931 pBase
->SetText(sNewLabel
);
2935 case BASEPROPERTY_URL
:
2938 if ( Value
>>= sNewURL
)
2939 pBase
->SetURL( sNewURL
);
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
>();
2958 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
2959 switch ( nPropType
)
2961 case BASEPROPERTY_URL
:
2963 aProp
<<= pBase
->GetURL();
2969 aProp
= VCLXWindow::getProperty( PropertyName
);
2976 void VCLXFixedHyperlink::ImplGetPropertyIds( std::vector
< sal_uInt16
> &rIds
)
2978 PushPropertyIds( rIds
,
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
,
2990 BASEPROPERTY_MULTILINE
,
2991 BASEPROPERTY_NOLABEL
,
2992 BASEPROPERTY_PRINTABLE
,
2993 BASEPROPERTY_TABSTOP
,
2994 BASEPROPERTY_VERTICALALIGN
,
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
,
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
,
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();
3052 pWindow
->SetText( Text
);
3055 OUString
VCLXFixedText::getText()
3057 SolarMutexGuard aGuard
;
3060 VclPtr
< vcl::Window
> pWindow
= GetWindow();
3062 aText
= pWindow
->GetText();
3066 void VCLXFixedText::setAlignment( sal_Int16 nAlign
)
3068 SolarMutexGuard aGuard
;
3070 VclPtr
< vcl::Window
> pWindow
= GetWindow();
3074 WinBits nNewBits
= 0;
3075 if ( nAlign
== css::awt::TextAlign::LEFT
)
3077 else if ( nAlign
== css::awt::TextAlign::CENTER
)
3078 nNewBits
= WB_CENTER
;
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();
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
;
3101 nAlign
= css::awt::TextAlign::RIGHT
;
3106 css::awt::Size
VCLXFixedText::getMinimumSize( )
3108 SolarMutexGuard aGuard
;
3111 VclPtr
< FixedText
> pFixedText
= GetAs
< FixedText
>();
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
>();
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
>();
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
>();
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
>();
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
>();
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
>();
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
>();
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
>();
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();
3320 WinBits nStyle
= pWindow
->GetStyle();
3321 nStyle
&= ~(WB_HORZ
|WB_VERT
);
3322 if ( n
== css::awt::ScrollBarOrientation::HORIZONTAL
)
3327 pWindow
->SetStyle( nStyle
);
3332 sal_Int32
VCLXScrollBar::getOrientation()
3334 SolarMutexGuard aGuard
;
3337 VclPtr
< vcl::Window
> pWindow
= GetWindow();
3340 WinBits nStyle
= pWindow
->GetStyle();
3341 if ( nStyle
& WB_HORZ
)
3342 n
= css::awt::ScrollBarOrientation::HORIZONTAL
;
3344 n
= css::awt::ScrollBarOrientation::VERTICAL
;
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
>();
3359 bool bVoid
= Value
.getValueTypeClass() == css::uno::TypeClass_VOID
;
3361 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
3362 switch ( nPropType
)
3364 case BASEPROPERTY_LIVE_SCROLL
:
3369 OSL_VERIFY( Value
>>= bDo
);
3371 AllSettings
aSettings( pScrollBar
->GetSettings() );
3372 StyleSettings
aStyle( aSettings
.GetStyleSettings() );
3373 DragFullOptions nDragOptions
= aStyle
.GetDragFullOptions();
3375 nDragOptions
|= DragFullOptions::Scroll
;
3377 nDragOptions
&= ~DragFullOptions::Scroll
;
3378 aStyle
.SetDragFullOptions( nDragOptions
);
3379 aSettings
.SetStyleSettings( aStyle
);
3380 pScrollBar
->SetSettings( aSettings
);
3384 case BASEPROPERTY_SCROLLVALUE
:
3394 case BASEPROPERTY_SCROLLVALUE_MAX
:
3395 case BASEPROPERTY_SCROLLVALUE_MIN
:
3402 if ( nPropType
== BASEPROPERTY_SCROLLVALUE_MAX
)
3410 case BASEPROPERTY_LINEINCREMENT
:
3416 setLineIncrement( n
);
3420 case BASEPROPERTY_BLOCKINCREMENT
:
3426 setBlockIncrement( n
);
3430 case BASEPROPERTY_VISIBLESIZE
:
3436 setVisibleSize( n
);
3440 case BASEPROPERTY_ORIENTATION
:
3446 setOrientation( n
);
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
);
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
>();
3474 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
3476 switch ( nPropType
)
3478 case BASEPROPERTY_LIVE_SCROLL
:
3480 aProp
<<= bool( pScrollBar
->GetSettings().GetStyleSettings().GetDragFullOptions() & DragFullOptions::Scroll
);
3483 case BASEPROPERTY_SCROLLVALUE
:
3485 aProp
<<= getValue();
3488 case BASEPROPERTY_SCROLLVALUE_MAX
:
3490 aProp
<<= getMaximum();
3493 case BASEPROPERTY_SCROLLVALUE_MIN
:
3495 aProp
<<= getMinimum();
3498 case BASEPROPERTY_LINEINCREMENT
:
3500 aProp
<<= getLineIncrement();
3503 case BASEPROPERTY_BLOCKINCREMENT
:
3505 aProp
<<= getBlockIncrement();
3508 case BASEPROPERTY_VISIBLESIZE
:
3510 aProp
<<= getVisibleSize();
3513 case BASEPROPERTY_ORIENTATION
:
3515 aProp
<<= getOrientation();
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
);
3528 aProp
= VCLXWindow::getProperty( PropertyName
);
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
>();
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
);
3578 VCLXWindow::ProcessWindowEvent( rVclWindowEvent
);
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
,
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
,
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
>();
3674 pEdit
->SetText( aText
);
3676 // #107218# Call same listeners like VCL would do after user interaction
3677 SetSynthesizingVCLEvent( true );
3678 pEdit
->SetModifyFlag();
3680 SetSynthesizingVCLEvent( false );
3684 void VCLXEdit::insertText( const css::awt::Selection
& rSel
, const OUString
& aText
)
3686 SolarMutexGuard aGuard
;
3688 VclPtr
< Edit
> pEdit
= GetAs
< Edit
>();
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();
3698 SetSynthesizingVCLEvent( false );
3702 OUString
VCLXEdit::getText()
3704 SolarMutexGuard aGuard
;
3707 VclPtr
< vcl::Window
> pWindow
= GetWindow();
3709 aText
= pWindow
->GetText();
3713 OUString
VCLXEdit::getSelectedText()
3715 SolarMutexGuard aGuard
;
3718 VclPtr
< Edit
> pEdit
= GetAs
< Edit
>();
3720 aText
= pEdit
->GetSelected();
3725 void VCLXEdit::setSelection( const css::awt::Selection
& aSelection
)
3727 SolarMutexGuard aGuard
;
3729 VclPtr
< Edit
> pEdit
= GetAs
< Edit
>();
3731 pEdit
->SetSelection( Selection( aSelection
.Min
, aSelection
.Max
) );
3734 css::awt::Selection
VCLXEdit::getSelection()
3736 SolarMutexGuard aGuard
;
3739 VclPtr
< Edit
> pEdit
= GetAs
< Edit
>();
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
>();
3759 pEdit
->SetReadOnly( !bEditable
);
3763 void VCLXEdit::setMaxTextLen( sal_Int16 nLen
)
3765 SolarMutexGuard aGuard
;
3767 VclPtr
< Edit
> pEdit
= GetAs
< Edit
>();
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
>();
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
>();
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 );
3806 case BASEPROPERTY_READONLY
:
3810 pEdit
->SetReadOnly( b
);
3813 case BASEPROPERTY_ECHOCHAR
:
3815 sal_Int16 n
= sal_Int16();
3817 pEdit
->SetEchoChar( n
);
3820 case BASEPROPERTY_MAXTEXTLEN
:
3822 sal_Int16 n
= sal_Int16();
3824 pEdit
->SetMaxTextLen( n
);
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
>();
3842 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
3843 switch ( nPropType
)
3845 case BASEPROPERTY_HIDEINACTIVESELECTION
:
3846 aProp
<<= ( ( pEdit
->GetStyle() & WB_NOHIDESELECTION
) == 0 );
3848 case BASEPROPERTY_READONLY
:
3849 aProp
<<= pEdit
->IsReadOnly();
3851 case BASEPROPERTY_ECHOCHAR
:
3852 aProp
<<= static_cast<sal_Int16
>(pEdit
->GetEchoChar());
3854 case BASEPROPERTY_MAXTEXTLEN
:
3855 aProp
<<= static_cast<sal_Int16
>(pEdit
->GetMaxTextLen());
3859 aProp
= VCLXWindow::getProperty( PropertyName
);
3866 css::awt::Size
VCLXEdit::getMinimumSize( )
3868 SolarMutexGuard aGuard
;
3871 VclPtr
< Edit
> pEdit
= GetAs
< Edit
>();
3873 aSz
= pEdit
->CalcMinimumSize();
3874 return vcl::unohelper::ConvertToAWTSize(aSz
);
3877 css::awt::Size
VCLXEdit::getPreferredSize( )
3879 SolarMutexGuard aGuard
;
3882 VclPtr
< Edit
> pEdit
= GetAs
< Edit
>();
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
;
3903 css::awt::Size
VCLXEdit::getMinimumSize( sal_Int16 nCols
, sal_Int16
)
3905 SolarMutexGuard aGuard
;
3908 VclPtr
< Edit
> pEdit
= GetAs
< Edit
>();
3912 aSz
= pEdit
->CalcSize( nCols
);
3914 aSz
= pEdit
->CalcMinimumSize();
3916 return vcl::unohelper::ConvertToAWTSize(aSz
);
3919 void VCLXEdit::getColumnsAndLines( sal_Int16
& nCols
, sal_Int16
& nLines
)
3921 SolarMutexGuard aGuard
;
3925 VclPtr
< Edit
> pEdit
= GetAs
< Edit
>();
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
);
3951 VCLXWindow::ProcessWindowEvent( rVclWindowEvent
);
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
,
3981 BASEPROPERTY_HIDEINACTIVESELECTION
,
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
>();
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
>();
4067 sal_uInt16 nP
= nPos
;
4068 for ( const auto& rItem
: aItems
)
4070 pBox
->InsertEntry( rItem
, nP
);
4073 OSL_FAIL( "VCLXComboBox::addItems: too many entries!" );
4074 // skip remaining entries, list cannot hold them, anyway
4080 void VCLXComboBox::removeItems( sal_Int16 nPos
, sal_Int16 nCount
)
4082 SolarMutexGuard aGuard
;
4084 VclPtr
< ComboBox
> pBox
= GetAs
< ComboBox
>();
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
;
4105 VclPtr
< ComboBox
> pBox
= GetAs
< ComboBox
>();
4107 aItem
= pBox
->GetEntry( nPos
);
4111 css::uno::Sequence
< OUString
> VCLXComboBox::getItems()
4113 SolarMutexGuard aGuard
;
4115 css::uno::Sequence
< OUString
> aSeq
;
4116 VclPtr
< ComboBox
> pBox
= GetAs
< ComboBox
>();
4119 auto n
= pBox
->GetEntryCount();
4120 aSeq
= css::uno::Sequence
< OUString
>( n
);
4124 aSeq
.getArray()[n
] = pBox
->GetEntry( n
);
4130 void VCLXComboBox::setDropDownLineCount( sal_Int16 nLines
)
4132 SolarMutexGuard aGuard
;
4134 VclPtr
< ComboBox
> pBox
= GetAs
< ComboBox
>();
4136 pBox
->SetDropDownLineCount( nLines
);
4139 sal_Int16
VCLXComboBox::getDropDownLineCount()
4141 SolarMutexGuard aGuard
;
4143 sal_Int16 nLines
= 0;
4144 VclPtr
< ComboBox
> pBox
= GetAs
< ComboBox
>();
4146 nLines
= pBox
->GetDropDownLineCount();
4150 void VCLXComboBox::setProperty( const OUString
& PropertyName
, const css::uno::Any
& Value
)
4152 SolarMutexGuard aGuard
;
4154 VclPtr
< ComboBox
> pComboBox
= GetAs
< ComboBox
>();
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();
4166 pComboBox
->SetDropDownLineCount( n
);
4169 case BASEPROPERTY_AUTOCOMPLETE
:
4171 sal_Int16 n
= sal_Int16();
4173 pComboBox
->EnableAutocomplete( n
!= 0 );
4178 pComboBox
->EnableAutocomplete( b
);
4182 case BASEPROPERTY_STRINGITEMLIST
:
4184 css::uno::Sequence
< OUString
> aItems
;
4185 if ( Value
>>= aItems
)
4188 addItems( aItems
, 0 );
4192 case BASEPROPERTY_HIGHLIGHT_COLOR
:
4197 nColor
= Application::GetSettings().GetStyleSettings().GetHighlightColor();
4201 if (!(Value
>>= nColor
))
4204 pComboBox
->SetHighlightColor(nColor
);
4207 case BASEPROPERTY_HIGHLIGHT_TEXT_COLOR
:
4212 nColor
= Application::GetSettings().GetStyleSettings().GetHighlightTextColor();
4216 if (!(Value
>>= nColor
))
4219 pComboBox
->SetHighlightTextColor(nColor
);
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
>();
4245 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
4246 switch ( nPropType
)
4248 case BASEPROPERTY_LINECOUNT
:
4250 aProp
<<= static_cast<sal_Int16
>(pComboBox
->GetDropDownLineCount());
4253 case BASEPROPERTY_AUTOCOMPLETE
:
4255 aProp
<<= pComboBox
->IsAutocompleteEnabled();
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
);
4271 aProp
= VCLXEdit::getProperty( PropertyName
);
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
>();
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
);
4308 case VclEventId::ComboboxDoubleClick
:
4309 if ( maActionListeners
.getLength() )
4311 css::awt::ActionEvent aEvent
;
4312 aEvent
.Source
= getXWeak();
4313 // aEvent.ActionCommand = ...;
4314 maActionListeners
.actionPerformed( aEvent
);
4319 VCLXEdit::ProcessWindowEvent( rVclWindowEvent
);
4324 css::awt::Size
VCLXComboBox::getMinimumSize( )
4326 SolarMutexGuard aGuard
;
4329 VclPtr
< ComboBox
> pComboBox
= GetAs
< ComboBox
>();
4331 aSz
= pComboBox
->CalcMinimumSize();
4332 return vcl::unohelper::ConvertToAWTSize(aSz
);
4335 css::awt::Size
VCLXComboBox::getPreferredSize( )
4337 SolarMutexGuard aGuard
;
4340 VclPtr
< ComboBox
> pComboBox
= GetAs
< ComboBox
>();
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
>();
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
;
4366 VclPtr
< ComboBox
> pComboBox
= GetAs
< ComboBox
>();
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
;
4377 VclPtr
< ComboBox
> pComboBox
= GetAs
< ComboBox
>();
4381 pComboBox
->GetMaxVisColumnsAndLines( nC
, 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?!" );
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?!" );
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
),
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();
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();
4527 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
4528 switch ( nPropType
)
4530 case BASEPROPERTY_SPIN
:
4535 WinBits nStyle
= GetWindow()->GetStyle() | WB_SPIN
;
4538 GetWindow()->SetStyle( nStyle
);
4542 case BASEPROPERTY_STRICTFORMAT
:
4547 pFormatter
->SetStrictFormat( b
);
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();
4566 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
4567 switch ( nPropType
)
4569 case BASEPROPERTY_TABSTOP
:
4571 aProp
<<= ( GetWindow()->GetStyle() & WB_SPIN
) != 0;
4574 case BASEPROPERTY_STRICTFORMAT
:
4576 aProp
<<= pFormatter
->IsStrictFormat();
4581 aProp
= VCLXSpinField::getProperty( PropertyName
);
4591 void VCLXDateField::ImplGetPropertyIds( std::vector
< sal_uInt16
> &rIds
)
4593 PushPropertyIds( rIds
,
4595 BASEPROPERTY_BACKGROUNDCOLOR
,
4596 BASEPROPERTY_BORDER
,
4597 BASEPROPERTY_BORDERCOLOR
,
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
,
4615 BASEPROPERTY_STRICTFORMAT
,
4616 BASEPROPERTY_TABSTOP
,
4617 BASEPROPERTY_ENFORCE_FORMAT
,
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
>();
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()) )
4656 bool bVoid
= Value
.getValueTypeClass() == css::uno::TypeClass_VOID
;
4658 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
4659 switch ( nPropType
)
4661 case BASEPROPERTY_DATE
:
4665 GetAs
< DateField
>()->EnableEmptyFieldValue( true );
4666 GetAs
< DateField
>()->SetEmptyFieldValue();
4671 if ((Value
>>= d
) && d
.Year
!= 0)
4676 case BASEPROPERTY_DATEMIN
:
4679 if ((Value
>>= d
) && d
.Year
!= 0)
4683 case BASEPROPERTY_DATEMAX
:
4686 if ((Value
>>= d
) && d
.Year
!= 0)
4690 case BASEPROPERTY_EXTDATEFORMAT
:
4692 sal_Int16 n
= sal_Int16();
4694 GetAs
< DateField
>()->SetExtDateFormat( static_cast<ExtDateFieldFormat
>(n
) );
4697 case BASEPROPERTY_DATESHOWCENTURY
:
4701 GetAs
< DateField
>()->SetShowDateCentury( b
);
4704 case BASEPROPERTY_ENFORCE_FORMAT
:
4706 bool bEnforce( true );
4707 OSL_VERIFY( Value
>>= bEnforce
);
4708 GetAs
< DateField
>()->EnforceValidValue( bEnforce
);
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();
4726 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
4727 switch ( nPropType
)
4729 case BASEPROPERTY_DATE
:
4731 aProp
<<= getDate();
4734 case BASEPROPERTY_DATEMIN
:
4739 case BASEPROPERTY_DATEMAX
:
4744 case BASEPROPERTY_DATESHOWCENTURY
:
4746 aProp
<<= GetAs
< DateField
>()->IsShowDateCentury();
4749 case BASEPROPERTY_ENFORCE_FORMAT
:
4751 aProp
<<= GetAs
< DateField
>()->IsEnforceValidValue( );
4756 aProp
= VCLXFormattedSpinField::getProperty( PropertyName
);
4764 void VCLXDateField::setDate( const util::Date
& aDate
)
4766 SolarMutexGuard aGuard
;
4768 VclPtr
< DateField
> pDateField
= GetAs
< DateField
>();
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
>();
4787 return pDateField
->GetDate().GetUNODate();
4789 return util::Date();
4792 void VCLXDateField::setMin( const util::Date
& aDate
)
4794 SolarMutexGuard aGuard
;
4796 VclPtr
< DateField
> pDateField
= GetAs
< DateField
>();
4798 pDateField
->SetMin( ::Date(aDate
) );
4801 util::Date
VCLXDateField::getMin()
4803 SolarMutexGuard aGuard
;
4805 VclPtr
< DateField
> pDateField
= GetAs
< DateField
>();
4807 return pDateField
->GetMin().GetUNODate();
4809 return util::Date();
4812 void VCLXDateField::setMax( const util::Date
& aDate
)
4814 SolarMutexGuard aGuard
;
4816 VclPtr
< DateField
> pDateField
= GetAs
< DateField
>();
4818 pDateField
->SetMax( ::Date(aDate
) );
4821 util::Date
VCLXDateField::getMax()
4823 SolarMutexGuard aGuard
;
4825 VclPtr
< DateField
> pDateField
= GetAs
< DateField
>();
4827 return pDateField
->GetMax().GetUNODate();
4829 return util::Date();
4832 void VCLXDateField::setFirst( const util::Date
& aDate
)
4834 SolarMutexGuard aGuard
;
4836 VclPtr
< DateField
> pDateField
= GetAs
< DateField
>();
4838 pDateField
->SetFirst( ::Date(aDate
) );
4841 util::Date
VCLXDateField::getFirst()
4843 SolarMutexGuard aGuard
;
4845 VclPtr
< DateField
> pDateField
= GetAs
< DateField
>();
4847 return pDateField
->GetFirst().GetUNODate();
4849 return util::Date();
4852 void VCLXDateField::setLast( const util::Date
& aDate
)
4854 SolarMutexGuard aGuard
;
4856 VclPtr
< DateField
> pDateField
= GetAs
< DateField
>();
4858 pDateField
->SetLast( ::Date(aDate
) );
4861 util::Date
VCLXDateField::getLast()
4863 SolarMutexGuard aGuard
;
4865 VclPtr
< DateField
> pDateField
= GetAs
< DateField
>();
4867 return pDateField
->GetLast().GetUNODate();
4869 return util::Date();
4872 void VCLXDateField::setLongFormat( sal_Bool bLong
)
4874 SolarMutexGuard aGuard
;
4876 VclPtr
< DateField
> pDateField
= GetAs
< DateField
>();
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
>();
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
,
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
,
4946 BASEPROPERTY_STRICTFORMAT
,
4947 BASEPROPERTY_TABSTOP
,
4949 BASEPROPERTY_TIMEMAX
,
4950 BASEPROPERTY_TIMEMIN
,
4951 BASEPROPERTY_ENFORCE_FORMAT
,
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
>();
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
>();
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
>();
5006 return pTimeField
->GetTime().GetUNOTime();
5008 return util::Time();
5011 void VCLXTimeField::setMin( const util::Time
& aTime
)
5013 SolarMutexGuard aGuard
;
5015 VclPtr
< TimeField
> pTimeField
= GetAs
< TimeField
>();
5017 pTimeField
->SetMin( tools::Time(aTime
) );
5020 util::Time
VCLXTimeField::getMin()
5022 SolarMutexGuard aGuard
;
5024 VclPtr
< TimeField
> pTimeField
= GetAs
< TimeField
>();
5026 return pTimeField
->GetMin().GetUNOTime();
5028 return util::Time();
5031 void VCLXTimeField::setMax( const util::Time
& aTime
)
5033 SolarMutexGuard aGuard
;
5035 VclPtr
< TimeField
> pTimeField
= GetAs
< TimeField
>();
5037 pTimeField
->SetMax( tools::Time(aTime
) );
5040 util::Time
VCLXTimeField::getMax()
5042 SolarMutexGuard aGuard
;
5044 VclPtr
< TimeField
> pTimeField
= GetAs
< TimeField
>();
5046 return pTimeField
->GetMax().GetUNOTime();
5048 return util::Time();
5051 void VCLXTimeField::setFirst( const util::Time
& aTime
)
5053 SolarMutexGuard aGuard
;
5055 VclPtr
< TimeField
> pTimeField
= GetAs
< TimeField
>();
5057 pTimeField
->SetFirst( tools::Time(aTime
) );
5060 util::Time
VCLXTimeField::getFirst()
5062 SolarMutexGuard aGuard
;
5064 VclPtr
< TimeField
> pTimeField
= GetAs
< TimeField
>();
5066 return pTimeField
->GetFirst().GetUNOTime();
5068 return util::Time();
5071 void VCLXTimeField::setLast( const util::Time
& aTime
)
5073 SolarMutexGuard aGuard
;
5075 VclPtr
< TimeField
> pTimeField
= GetAs
< TimeField
>();
5077 pTimeField
->SetLast( tools::Time(aTime
) );
5080 util::Time
VCLXTimeField::getLast()
5082 SolarMutexGuard aGuard
;
5084 VclPtr
< TimeField
> pTimeField
= GetAs
< TimeField
>();
5086 return pTimeField
->GetLast().GetUNOTime();
5088 return util::Time();
5091 void VCLXTimeField::setEmpty()
5093 SolarMutexGuard aGuard
;
5095 VclPtr
< TimeField
> pTimeField
= GetAs
< TimeField
>();
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()) )
5126 bool bVoid
= Value
.getValueTypeClass() == css::uno::TypeClass_VOID
;
5128 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
5129 switch ( nPropType
)
5131 case BASEPROPERTY_TIME
:
5135 GetAs
< TimeField
>()->EnableEmptyFieldValue( true );
5136 GetAs
< TimeField
>()->SetEmptyFieldValue();
5146 case BASEPROPERTY_TIMEMIN
:
5153 case BASEPROPERTY_TIMEMAX
:
5160 case BASEPROPERTY_EXTTIMEFORMAT
:
5162 sal_Int16 n
= sal_Int16();
5164 GetAs
< TimeField
>()->SetExtFormat( static_cast<ExtTimeFieldFormat
>(n
) );
5167 case BASEPROPERTY_ENFORCE_FORMAT
:
5169 bool bEnforce( true );
5170 OSL_VERIFY( Value
>>= bEnforce
);
5171 GetAs
< TimeField
>()->EnforceValidValue( bEnforce
);
5176 VCLXFormattedSpinField::setProperty( PropertyName
, Value
);
5181 css::uno::Any
VCLXTimeField::getProperty( const OUString
& PropertyName
)
5183 SolarMutexGuard aGuard
;
5185 css::uno::Any aProp
;
5188 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
5189 switch ( nPropType
)
5191 case BASEPROPERTY_TIME
:
5193 aProp
<<= getTime();
5196 case BASEPROPERTY_TIMEMIN
:
5201 case BASEPROPERTY_TIMEMAX
:
5206 case BASEPROPERTY_ENFORCE_FORMAT
:
5208 aProp
<<= GetAs
< TimeField
>()->IsEnforceValidValue( );
5213 aProp
= VCLXFormattedSpinField::getProperty( PropertyName
);
5223 void VCLXNumericField::ImplGetPropertyIds( std::vector
< sal_uInt16
> &rIds
)
5225 PushPropertyIds( rIds
,
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
,
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
)
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
>();
5287 SetSynthesizingVCLEvent( true );
5288 pEdit
->SetModifyFlag();
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() )
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() )
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() )
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() )
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() )
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() )
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
);
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()) )
5442 bool bVoid
= Value
.getValueTypeClass() == css::uno::TypeClass_VOID
;
5444 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
5445 switch ( nPropType
)
5447 case BASEPROPERTY_VALUE_DOUBLE
:
5451 NumericFormatter
* pNumericFormatter
= static_cast<NumericFormatter
*>(GetFormatter());
5452 if (!pNumericFormatter
)
5454 pNumericFormatter
->EnableEmptyFieldValue( true );
5455 pNumericFormatter
->SetEmptyFieldValue();
5465 case BASEPROPERTY_VALUEMIN_DOUBLE
:
5472 case BASEPROPERTY_VALUEMAX_DOUBLE
:
5479 case BASEPROPERTY_VALUESTEP_DOUBLE
:
5486 case BASEPROPERTY_DECIMALACCURACY
:
5488 sal_Int16 n
= sal_Int16();
5490 setDecimalDigits( n
);
5493 case BASEPROPERTY_NUMSHOWTHOUSANDSEP
:
5498 NumericFormatter
* pNumericFormatter
= static_cast<NumericFormatter
*>(GetFormatter());
5499 if (!pNumericFormatter
)
5501 pNumericFormatter
->SetUseThousandSep( b
);
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();
5520 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
5521 switch ( nPropType
)
5523 case BASEPROPERTY_VALUE_DOUBLE
:
5525 aProp
<<= getValue();
5528 case BASEPROPERTY_VALUEMIN_DOUBLE
:
5533 case BASEPROPERTY_VALUEMAX_DOUBLE
:
5538 case BASEPROPERTY_VALUESTEP_DOUBLE
:
5540 aProp
<<= getSpinSize();
5543 case BASEPROPERTY_NUMSHOWTHOUSANDSEP
:
5545 NumericFormatter
* pNumericFormatter
= static_cast<NumericFormatter
*>(pFormatter
);
5546 aProp
<<= pNumericFormatter
->IsUseThousandSep();
5551 aProp
= VCLXFormattedSpinField::getProperty( PropertyName
);
5559 // ----------------------------------------------------
5560 // ----------------------------------------------------
5562 void VCLXMetricField::ImplGetPropertyIds( std::vector
< sal_uInt16
> &rIds
)
5564 PushPropertyIds( rIds
,
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
,
5582 BASEPROPERTY_STRICTFORMAT
,
5583 BASEPROPERTY_TABSTOP
,
5584 BASEPROPERTY_ENFORCE_FORMAT
,
5585 BASEPROPERTY_HIDEINACTIVESELECTION
,
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());
5607 throw css::uno::RuntimeException();
5611 MetricField
*VCLXMetricField::GetMetricField()
5613 VclPtr
< MetricField
> pField
= GetAs
< MetricField
>();
5615 throw css::uno::RuntimeException();
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
>();
5660 SetSynthesizingVCLEvent( true );
5661 pEdit
->SetModifyFlag();
5663 SetSynthesizingVCLEvent( false );
5667 void VCLXMetricField::setValue( ::sal_Int64 Value
, ::sal_Int16 Unit
)
5669 SolarMutexGuard aGuard
;
5670 GetMetricFormatter()->SetValue( Value
, MetricUnitUnoToVcl( Unit
) );
5674 void VCLXMetricField::setUserValue( ::sal_Int64 Value
, ::sal_Int16 Unit
)
5676 SolarMutexGuard aGuard
;
5677 GetMetricFormatter()->SetUserValue( Value
, MetricUnitUnoToVcl( Unit
) );
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()) )
5724 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
5725 switch ( nPropType
)
5727 case BASEPROPERTY_DECIMALACCURACY
:
5731 setDecimalDigits( n
);
5734 case BASEPROPERTY_NUMSHOWTHOUSANDSEP
:
5739 NumericFormatter
* pNumericFormatter
= static_cast<NumericFormatter
*>(GetFormatter());
5740 if (!pNumericFormatter
)
5742 pNumericFormatter
->SetUseThousandSep( b
);
5746 case BASEPROPERTY_UNIT
:
5748 sal_uInt16 nVal
= 0;
5749 if ( Value
>>= nVal
)
5750 GetAs
< MetricField
>()->SetUnit( static_cast<FieldUnit
>(nVal
) );
5753 case BASEPROPERTY_CUSTOMUNITTEXT
:
5756 if ( Value
>>= aStr
)
5757 GetAs
< MetricField
>()->SetCustomUnitText( aStr
);
5762 VCLXFormattedSpinField::setProperty( PropertyName
, Value
);
5768 css::uno::Any
VCLXMetricField::getProperty( const OUString
& PropertyName
)
5770 SolarMutexGuard aGuard
;
5772 css::uno::Any aProp
;
5773 FormatterBase
* pFormatter
= GetFormatter();
5776 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
5777 switch ( nPropType
)
5779 case BASEPROPERTY_NUMSHOWTHOUSANDSEP
:
5781 NumericFormatter
* pNumericFormatter
= static_cast<NumericFormatter
*>(pFormatter
);
5782 aProp
<<= pNumericFormatter
->IsUseThousandSep();
5785 case BASEPROPERTY_UNIT
:
5786 aProp
<<= static_cast<sal_uInt16
>(GetAs
< MetricField
>()->GetUnit());
5788 case BASEPROPERTY_CUSTOMUNITTEXT
:
5789 aProp
<<= GetAs
< MetricField
>()->GetCustomUnitText();
5793 aProp
= VCLXFormattedSpinField::getProperty( PropertyName
);
5801 void VCLXPatternField::ImplGetPropertyIds( std::vector
< sal_uInt16
> &rIds
)
5803 PushPropertyIds( rIds
,
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
,
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
;
5877 VclPtr
< PatternField
> pPatternField
= GetAs
< PatternField
>();
5878 if ( pPatternField
)
5879 aString
= pPatternField
->GetString();
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()) )
5900 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
5901 switch ( nPropType
)
5903 case BASEPROPERTY_EDITMASK
:
5904 case BASEPROPERTY_LITERALMASK
:
5907 if ( Value
>>= aString
)
5909 OUString aEditMask
, aLiteralMask
;
5910 getMasks( aEditMask
, aLiteralMask
);
5911 if ( nPropType
== BASEPROPERTY_EDITMASK
)
5912 aEditMask
= aString
;
5914 aLiteralMask
= aString
;
5915 setMasks( aEditMask
, aLiteralMask
);
5921 VCLXFormattedSpinField::setProperty( PropertyName
, Value
);
5926 css::uno::Any
VCLXPatternField::getProperty( const OUString
& PropertyName
)
5928 SolarMutexGuard aGuard
;
5930 css::uno::Any aProp
;
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
;
5944 aProp
<<= aLiteralMask
;
5949 aProp
= VCLXFormattedSpinField::getProperty( PropertyName
);
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
,
6005 VCLXContainer::ImplGetPropertyIds( rIds
);
6008 VCLXFrame::~VCLXFrame()
6013 void SAL_CALL
VCLXFrame::draw( sal_Int32 nX
, sal_Int32 nY
)
6015 SolarMutexGuard aGuard
;
6016 VclPtr
< vcl::Window
> pWindow
= GetWindow();
6020 OutputDevice
* pDev
= VCLUnoHelper::GetOutputDevice( getGraphics() );
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()
6051 VCLXProgressBar::~VCLXProgressBar()
6055 void VCLXProgressBar::ImplUpdateValue()
6057 VclPtr
< ProgressBar
> pProgressBar
= GetAs
< ProgressBar
>();
6058 if ( !pProgressBar
)
6065 // check min and max
6066 if (m_nValueMin
< m_nValueMax
)
6068 nValMin
= m_nValueMin
;
6069 nValMax
= m_nValueMax
;
6073 nValMin
= m_nValueMax
;
6074 nValMax
= m_nValueMin
;
6078 if (m_nValue
< nValMin
)
6082 else if (m_nValue
> nValMax
)
6091 // calculate percent
6093 if (nValMin
!= nValMax
)
6095 nPercent
= 100 * (nVal
- nValMin
) / (nValMax
- nValMin
);
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();
6114 pWindow
->SetControlForeground( Color(ColorTransparency
, nColor
) );
6118 void VCLXProgressBar::setBackgroundColor( sal_Int32 nColor
)
6120 SolarMutexGuard aGuard
;
6122 VclPtr
<vcl::Window
> pWindow
= GetWindow();
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
;
6140 void VCLXProgressBar::setRange( sal_Int32 nMin
, sal_Int32 nMax
)
6142 SolarMutexGuard aGuard
;
6146 // take correct min and max
6152 // change min and max
6160 sal_Int32
VCLXProgressBar::getValue()
6162 SolarMutexGuard aGuard
;
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
)
6176 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
6177 switch ( nPropType
)
6179 case BASEPROPERTY_PROGRESSVALUE
:
6181 if ( Value
>>= m_nValue
)
6185 case BASEPROPERTY_PROGRESSVALUE_MIN
:
6187 if ( Value
>>= m_nValueMin
)
6191 case BASEPROPERTY_PROGRESSVALUE_MAX
:
6193 if ( Value
>>= m_nValueMax
)
6197 case BASEPROPERTY_FILLCOLOR
:
6199 VclPtr
<vcl::Window
> pWindow
= GetWindow();
6202 bool bVoid
= Value
.getValueTypeClass() == css::uno::TypeClass_VOID
;
6206 pWindow
->SetControlForeground();
6211 if ( Value
>>= nColor
)
6212 pWindow
->SetControlForeground( nColor
);
6218 VCLXWindow::setProperty( PropertyName
, Value
);
6223 css::uno::Any
VCLXProgressBar::getProperty( const OUString
& PropertyName
)
6225 SolarMutexGuard aGuard
;
6227 css::uno::Any aProp
;
6228 VclPtr
< ProgressBar
> pProgressBar
= GetAs
< ProgressBar
>();
6231 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
6232 switch ( nPropType
)
6234 case BASEPROPERTY_PROGRESSVALUE
:
6239 case BASEPROPERTY_PROGRESSVALUE_MIN
:
6241 aProp
<<= m_nValueMin
;
6244 case BASEPROPERTY_PROGRESSVALUE_MAX
:
6246 aProp
<<= m_nValueMax
;
6250 aProp
= VCLXWindow::getProperty( PropertyName
);
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
>();
6276 pControl
->GetEdit().SetModifyHdl( Link
<Edit
&,void>() );
6281 void lcl_setWinBits( vcl::Window
* _pWindow
, WinBits _nBits
, bool _bSet
)
6283 WinBits nStyle
= _pWindow
->GetStyle();
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
>();
6300 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
6301 switch ( nPropType
)
6303 case BASEPROPERTY_HIDEINACTIVESELECTION
:
6306 OSL_VERIFY( Value
>>= bValue
);
6308 lcl_setWinBits( pControl
, WB_NOHIDESELECTION
, !bValue
);
6309 lcl_setWinBits( &pControl
->GetEdit(), WB_NOHIDESELECTION
, !bValue
);
6314 VCLXWindow::setProperty( PropertyName
, Value
);
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();
6349 pWindow
->SetText( aText
);
6351 // also in Java a textChanged is triggered, not in VCL.
6352 // css::awt::Toolkit should be JAVA-compliant...
6357 void VCLXFileControl::insertText( const css::awt::Selection
& rSel
, const OUString
& aText
)
6359 SolarMutexGuard aGuard
;
6361 VclPtr
< FileControl
> pFileControl
= GetAs
< FileControl
>();
6364 pFileControl
->GetEdit().SetSelection( Selection( rSel
.Min
, rSel
.Max
) );
6365 pFileControl
->GetEdit().ReplaceSelected( aText
);
6369 OUString
VCLXFileControl::getText()
6371 SolarMutexGuard aGuard
;
6374 VclPtr
<vcl::Window
> pWindow
= GetWindow();
6376 aText
= pWindow
->GetText();
6380 OUString
VCLXFileControl::getSelectedText()
6382 SolarMutexGuard aGuard
;
6385 VclPtr
< FileControl
> pFileControl
= GetAs
< FileControl
>();
6387 aText
= pFileControl
->GetEdit().GetSelected();
6392 void VCLXFileControl::setSelection( const css::awt::Selection
& aSelection
)
6394 SolarMutexGuard aGuard
;
6396 VclPtr
< FileControl
> pFileControl
= GetAs
< FileControl
>();
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
>();
6409 aSel
.Min
= pFileControl
->GetEdit().GetSelection().Min();
6410 aSel
.Max
= pFileControl
->GetEdit().GetSelection().Max();
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
>();
6429 pFileControl
->GetEdit().SetReadOnly( !bEditable
);
6432 void VCLXFileControl::setMaxTextLen( sal_Int16 nLen
)
6434 SolarMutexGuard aGuard
;
6436 VclPtr
< FileControl
> pFileControl
= GetAs
< FileControl
>();
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)
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
;
6467 VclPtr
< FileControl
> pControl
= GetAs
< FileControl
>();
6470 Size aTmpSize
= pControl
->GetEdit().CalcMinimumSize();
6471 aTmpSize
.AdjustWidth(pControl
->GetButton().CalcMinimumSize().Width() );
6472 aSz
= vcl::unohelper::ConvertToAWTSize(pControl
->CalcWindowSize(aTmpSize
));
6477 css::awt::Size
VCLXFileControl::getPreferredSize()
6479 css::awt::Size aSz
= getMinimumSize();
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
>();
6492 css::awt::Size aMinSz
= getMinimumSize();
6493 if ( aSz
.Height
!= aMinSz
.Height
)
6494 aSz
.Height
= aMinSz
.Height
;
6499 css::awt::Size
VCLXFileControl::getMinimumSize( sal_Int16 nCols
, sal_Int16
)
6501 SolarMutexGuard aGuard
;
6504 VclPtr
< FileControl
> pControl
= GetAs
< FileControl
>();
6507 aSz
= vcl::unohelper::ConvertToAWTSize(pControl
->GetEdit().CalcSize(nCols
));
6508 aSz
.Width
+= pControl
->GetButton().CalcMinimumSize().Width();
6513 void VCLXFileControl::getColumnsAndLines( sal_Int16
& nCols
, sal_Int16
& nLines
)
6515 SolarMutexGuard aGuard
;
6519 VclPtr
< FileControl
> pControl
= GetAs
< FileControl
>();
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
>();
6557 Formatter
& rFormatter
= pField
->GetFormatter();
6558 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
6561 case BASEPROPERTY_ENFORCE_FORMAT
:
6563 bool bEnable( true );
6564 if ( Value
>>= bEnable
)
6565 rFormatter
.EnableNotANumber( !bEnable
);
6569 case BASEPROPERTY_EFFECTIVE_MIN
:
6570 case BASEPROPERTY_VALUEMIN_DOUBLE
:
6574 case BASEPROPERTY_EFFECTIVE_MAX
:
6575 case BASEPROPERTY_VALUEMAX_DOUBLE
:
6579 case BASEPROPERTY_EFFECTIVE_DEFAULT
:
6580 SetDefaultValue(Value
);
6583 case BASEPROPERTY_TREATASNUMBER
:
6587 SetTreatAsNumber(b
);
6591 case BASEPROPERTY_FORMATSSUPPLIER
:
6592 if (!Value
.hasValue())
6593 setFormatsSupplier(css::uno::Reference
< css::util::XNumberFormatsSupplier
> (nullptr));
6596 css::uno::Reference
< css::util::XNumberFormatsSupplier
> xNFS
;
6597 if ( Value
>>= xNFS
)
6598 setFormatsSupplier(xNFS
);
6601 case BASEPROPERTY_FORMATKEY
:
6602 if (!Value
.hasValue())
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
)
6618 if (rTC
!= css::uno::TypeClass_DOUBLE
)
6620 if (Value
.hasValue())
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
)));
6633 case BASEPROPERTY_VALUESTEP_DOUBLE
:
6637 rFormatter
.SetSpinSize( d
);
6642 rFormatter
.SetSpinSize( n
);
6646 case BASEPROPERTY_DECIMALACCURACY
:
6650 rFormatter
.SetDecimalDigits( static_cast<sal_uInt16
>(n
) );
6653 case BASEPROPERTY_NUMSHOWTHOUSANDSEP
:
6657 rFormatter
.SetThousandsSep( b
);
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());
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
>();
6684 Formatter
& rFormatter
= pField
->GetFormatter();
6685 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
6688 case BASEPROPERTY_EFFECTIVE_MIN
:
6689 case BASEPROPERTY_VALUEMIN_DOUBLE
:
6690 aReturn
= GetMinValue();
6693 case BASEPROPERTY_EFFECTIVE_MAX
:
6694 case BASEPROPERTY_VALUEMAX_DOUBLE
:
6695 aReturn
= GetMaxValue();
6698 case BASEPROPERTY_EFFECTIVE_DEFAULT
:
6699 aReturn
= GetDefaultValue();
6702 case BASEPROPERTY_TREATASNUMBER
:
6703 aReturn
<<= GetTreatAsNumber();
6706 case BASEPROPERTY_EFFECTIVE_VALUE
:
6707 case BASEPROPERTY_VALUE_DOUBLE
:
6708 aReturn
= GetValue();
6711 case BASEPROPERTY_VALUESTEP_DOUBLE
:
6712 aReturn
<<= rFormatter
.GetSpinSize();
6715 case BASEPROPERTY_DECIMALACCURACY
:
6716 aReturn
<<= rFormatter
.GetDecimalDigits();
6719 case BASEPROPERTY_FORMATSSUPPLIER
:
6721 if (!bIsStandardSupplier
)
6723 css::uno::Reference
< css::util::XNumberFormatsSupplier
> xSupplier
= m_xCurrentSupplier
;
6724 aReturn
<<= xSupplier
;
6729 case BASEPROPERTY_FORMATKEY
:
6731 if (!bIsStandardSupplier
)
6732 aReturn
<<= getFormatKey();
6737 aReturn
= VCLXSpinField::getProperty(PropertyName
);
6743 css::uno::Any
SVTXFormattedField::convertEffectiveValue(const css::uno::Any
& rValue
) const
6745 css::uno::Any aReturn
;
6747 VclPtr
<FormattedField
> pField
= GetAs
< FormattedField
>();
6751 Formatter
& rFieldFormatter
= pField
->GetFormatter();
6752 switch (rValue
.getValueTypeClass())
6754 case css::uno::TypeClass_DOUBLE
:
6755 if (rFieldFormatter
.TreatingAsNumber())
6763 SvNumberFormatter
* pFormatter
= rFieldFormatter
.GetFormatter();
6765 pFormatter
= rFieldFormatter
.StandardFormatter();
6766 // should never fail
6771 OUString sConverted
;
6772 pFormatter
->GetOutputString(d
, 0, sConverted
, &pDum
);
6773 aReturn
<<= sConverted
;
6776 case css::uno::TypeClass_STRING
:
6780 if (rFieldFormatter
.TreatingAsNumber())
6782 SvNumberFormatter
* pFormatter
= rFieldFormatter
.GetFormatter();
6784 pFormatter
= rFieldFormatter
.StandardFormatter();
6787 sal_uInt32
nTestFormat(0);
6788 if (!pFormatter
->IsNumberFormat(aStr
, nTestFormat
, dVal
))
6803 void SVTXFormattedField::SetMinValue(const css::uno::Any
& rValue
)
6805 VclPtr
<FormattedField
> pField
= GetAs
< FormattedField
>();
6809 Formatter
& rFormatter
= pField
->GetFormatter();
6810 switch (rValue
.getValueTypeClass())
6813 case css::uno::TypeClass_DOUBLE
:
6817 rFormatter
.SetMinValue(d
);
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();
6832 css::uno::Any
SVTXFormattedField::GetMinValue() const
6834 VclPtr
<FormattedField
> pField
= GetAs
< FormattedField
>();
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();
6846 void SVTXFormattedField::SetMaxValue(const css::uno::Any
& rValue
)
6848 VclPtr
<FormattedField
> pField
= GetAs
< FormattedField
>();
6852 Formatter
& rFormatter
= pField
->GetFormatter();
6853 switch (rValue
.getValueTypeClass())
6855 case css::uno::TypeClass_DOUBLE
:
6859 rFormatter
.SetMaxValue(d
);
6863 if (rValue
.getValueTypeClass() != css::uno::TypeClass_VOID
)
6866 throw css::lang::IllegalArgumentException();
6868 rFormatter
.ClearMaxValue();
6873 css::uno::Any
SVTXFormattedField::GetMaxValue() const
6875 VclPtr
<FormattedField
> pField
= GetAs
< FormattedField
>();
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();
6887 void SVTXFormattedField::SetDefaultValue(const css::uno::Any
& rValue
)
6889 VclPtr
<FormattedField
> pField
= GetAs
< FormattedField
>();
6893 css::uno::Any aConverted
= convertEffectiveValue(rValue
);
6895 Formatter
& rFormatter
= pField
->GetFormatter();
6896 switch (aConverted
.getValueTypeClass())
6898 case css::uno::TypeClass_DOUBLE
:
6902 rFormatter
.SetDefaultValue(d
);
6905 case css::uno::TypeClass_STRING
:
6908 aConverted
>>= aStr
;
6909 rFormatter
.SetDefaultText( aStr
);
6913 rFormatter
.EnableEmptyField(true);
6914 // only void accepted
6919 css::uno::Any
SVTXFormattedField::GetDefaultValue() const
6921 VclPtr
<FormattedField
> pField
= GetAs
< FormattedField
>();
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();
6932 aReturn
<<= rFormatter
.GetDefaultText();
6936 bool SVTXFormattedField::GetTreatAsNumber() const
6938 VclPtr
<FormattedField
> pField
= GetAs
< FormattedField
>();
6940 return pField
->GetFormatter().TreatingAsNumber();
6945 void SVTXFormattedField::SetTreatAsNumber(bool bSet
)
6947 VclPtr
<FormattedField
> pField
= GetAs
< FormattedField
>();
6949 pField
->GetFormatter().TreatAsNumber(bSet
);
6952 css::uno::Any
SVTXFormattedField::GetValue() const
6954 VclPtr
<FormattedField
> pField
= GetAs
< FormattedField
>();
6956 return css::uno::Any();
6958 Formatter
& rFormatter
= pField
->GetFormatter();
6959 css::uno::Any aReturn
;
6960 if (!rFormatter
.TreatingAsNumber())
6962 OUString sText
= rFormatter
.GetTextValue();
6967 if (!pField
->GetText().isEmpty()) // empty is returned as void by default
6968 aReturn
<<= rFormatter
.GetValue();
6974 void SVTXFormattedField::SetValue(const css::uno::Any
& rValue
)
6976 VclPtr
<FormattedField
> pField
= GetAs
< FormattedField
>();
6980 if (!rValue
.hasValue())
6982 pField
->SetText(u
""_ustr
);
6986 Formatter
& rFormatter
= pField
->GetFormatter();
6987 if (rValue
.getValueTypeClass() == css::uno::TypeClass_DOUBLE
)
6991 rFormatter
.SetValue(d
);
6995 DBG_ASSERT(rValue
.getValueTypeClass() == css::uno::TypeClass_STRING
, "SVTXFormattedField::SetValue : invalid argument !");
6999 if (!rFormatter
.TreatingAsNumber())
7000 rFormatter
.SetTextFormatted(sText
);
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())
7017 Formatter
& rFormatter
= pField
->GetFormatter();
7018 pNew
= new SvNumberFormatsSupplierObj(rFormatter
.StandardFormatter());
7019 bIsStandardSupplier
= true;
7024 pNew
= comphelper::getFromUnoTunnel
<SvNumberFormatsSupplierObj
>(xSupplier
);
7025 bIsStandardSupplier
= false;
7029 return; // TODO : how to process ?
7031 m_xCurrentSupplier
= std::move(pNew
);
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;
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
>();
7060 Formatter
& rFormatter
= pField
->GetFormatter();
7061 if (rFormatter
.GetFormatter())
7062 rFormatter
.SetFormatKey(nKey
);
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
>();
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
>();
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
>();
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
>();
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
>();
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
>();
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
>();
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
>();
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
>();
7258 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
7261 case BASEPROPERTY_CURRENCYSYMBOL
:
7265 pField
->setCurrencySymbol( aStr
);
7268 case BASEPROPERTY_CURSYM_POSITION
:
7272 pField
->setPrependCurrSym(b
);
7277 SVTXFormattedField::setProperty(PropertyName
, Value
);
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
>();
7293 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
7296 case BASEPROPERTY_CURRENCYSYMBOL
:
7298 aReturn
<<= pField
->getCurrencySymbol();
7301 case BASEPROPERTY_CURSYM_POSITION
:
7303 aReturn
<<= pField
->getPrependCurrSym();
7307 return SVTXFormattedField::getProperty(PropertyName
);
7310 return SVTXFormattedField::getProperty(PropertyName
);
7313 void SVTXCurrencyField::ImplGetPropertyIds( std::vector
< sal_uInt16
> &rIds
)
7315 PushPropertyIds( rIds
,
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
,
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
>();
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
>();
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
>();
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
>();
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
>();
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
>();
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
>();
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
>();
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
7524 VclPtr
< Edit
> pSubEdit
= GetWindow() ? GetAs
<Edit
>()->GetSubEdit() : nullptr;
7528 switch ( GetPropertyId( PropertyName
) )
7530 case BASEPROPERTY_TEXTLINECOLOR
:
7531 if ( !Value
.hasValue() )
7532 pSubEdit
->SetTextLineColor();
7536 if ( Value
>>= nColor
)
7537 pSubEdit
->SetTextLineColor( nColor
);
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
>();
7578 pEdit
->SetText( aText
);
7580 // #107218# Call same listeners like VCL would do after user interaction
7581 SetSynthesizingVCLEvent( true );
7582 pEdit
->SetModifyFlag();
7584 SetSynthesizingVCLEvent( false );
7588 void VCLXMultiLineEdit::insertText( const css::awt::Selection
& rSel
, const OUString
& aText
)
7590 SolarMutexGuard aGuard
;
7592 VclPtr
< MultiLineEdit
> pEdit
= GetAs
< MultiLineEdit
>();
7595 setSelection( rSel
);
7596 pEdit
->ReplaceSelected( aText
);
7600 OUString
VCLXMultiLineEdit::getText()
7602 SolarMutexGuard aGuard
;
7605 VclPtr
< MultiLineEdit
> pEdit
= GetAs
< MultiLineEdit
>();
7607 aText
= pEdit
->GetText( meLineEndType
);
7611 OUString
VCLXMultiLineEdit::getSelectedText()
7613 SolarMutexGuard aGuard
;
7616 VclPtr
< MultiLineEdit
> pMultiLineEdit
= GetAs
< MultiLineEdit
>();
7617 if ( pMultiLineEdit
)
7618 aText
= pMultiLineEdit
->GetSelected( meLineEndType
);
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();
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
;
7687 VclPtr
< MultiLineEdit
> pEdit
= GetAs
< MultiLineEdit
>();
7689 aText
= pEdit
->GetTextLines( meLineEndType
);
7693 css::awt::Size
VCLXMultiLineEdit::getMinimumSize()
7695 SolarMutexGuard aGuard
;
7698 VclPtr
< MultiLineEdit
> pEdit
= GetAs
< MultiLineEdit
>();
7700 aSz
= vcl::unohelper::ConvertToAWTSize(pEdit
->CalcMinimumSize());
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
>();
7716 aSz
= vcl::unohelper::ConvertToAWTSize(
7717 pEdit
->CalcAdjustedSize(vcl::unohelper::ConvertToVCLSize(rNewSize
)));
7721 css::awt::Size
VCLXMultiLineEdit::getMinimumSize( sal_Int16 nCols
, sal_Int16 nLines
)
7723 SolarMutexGuard aGuard
;
7726 VclPtr
< MultiLineEdit
> pEdit
= GetAs
< MultiLineEdit
>();
7728 aSz
= vcl::unohelper::ConvertToAWTSize(pEdit
->CalcBlockSize(nCols
, nLines
));
7732 void VCLXMultiLineEdit::getColumnsAndLines( sal_Int16
& nCols
, sal_Int16
& nLines
)
7734 SolarMutexGuard aGuard
;
7737 VclPtr
< MultiLineEdit
> pEdit
= GetAs
< MultiLineEdit
>();
7741 pEdit
->GetMaxVisColumnsAndLines( nC
, 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
);
7763 VCLXWindow::ProcessWindowEvent( rVclWindowEvent
);
7769 void VCLXMultiLineEdit::setProperty( const OUString
& PropertyName
, const css::uno::Any
& Value
)
7771 SolarMutexGuard aGuard
;
7773 VclPtr
< MultiLineEdit
> pMultiLineEdit
= GetAs
< MultiLineEdit
>();
7774 if ( !pMultiLineEdit
)
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;
7794 case BASEPROPERTY_READONLY
:
7798 pMultiLineEdit
->SetReadOnly( b
);
7801 case BASEPROPERTY_MAXTEXTLEN
:
7803 sal_Int16 n
= sal_Int16();
7805 pMultiLineEdit
->SetMaxTextLen( n
);
7808 case BASEPROPERTY_HIDEINACTIVESELECTION
:
7813 pMultiLineEdit
->EnableFocusSelectionHide( b
);
7814 lcl_setWinBits( pMultiLineEdit
, WB_NOHIDESELECTION
, !b
);
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
;
7850 case BASEPROPERTY_READONLY
:
7852 aProp
<<= pMultiLineEdit
->IsReadOnly();
7855 case BASEPROPERTY_MAXTEXTLEN
:
7857 aProp
<<= static_cast<sal_Int16
>(pMultiLineEdit
->GetMaxTextLen());
7862 aProp
= VCLXWindow::getProperty( PropertyName
);
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.
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: */