Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / toolkit / source / awt / vclxwindows.cxx
blobb246d20c9723fc21389948fea9be95458bf351ed
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <toolkit/awt/vclxwindows.hxx>
21 #include "toolkit/awt/scrollabledialog.hxx"
22 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
23 #include <com/sun/star/graphic/GraphicProvider.hpp>
24 #include <com/sun/star/graphic/XGraphicProvider.hpp>
25 #include <toolkit/helper/vclunohelper.hxx>
26 #include <toolkit/helper/macros.hxx>
27 #include <toolkit/helper/property.hxx>
28 #include <toolkit/helper/convert.hxx>
29 #include <cppuhelper/typeprovider.hxx>
30 #include <cppuhelper/queryinterface.hxx>
31 #include <com/sun/star/awt/VisualEffect.hpp>
32 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
33 #include <com/sun/star/system/SystemShellExecute.hpp>
34 #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
35 #include <com/sun/star/resource/XStringResourceResolver.hpp>
36 #include <com/sun/star/awt/ImageScaleMode.hpp>
37 #include <com/sun/star/awt/XItemList.hpp>
38 #include <comphelper/namedvaluecollection.hxx>
39 #include <comphelper/processfactory.hxx>
41 #include <vcl/button.hxx>
42 #include <vcl/lstbox.hxx>
43 #include <vcl/combobox.hxx>
44 #include <vcl/field.hxx>
45 #include <vcl/fixedhyper.hxx>
46 #include <vcl/longcurr.hxx>
47 #include <vcl/imgctrl.hxx>
48 #include <vcl/dialog.hxx>
49 #include <vcl/msgbox.hxx>
50 #include <vcl/scrbar.hxx>
51 #include <vcl/svapp.hxx>
52 #include <vcl/tabpage.hxx>
53 #include <vcl/tabctrl.hxx>
54 #include <vcl/settings.hxx>
55 #include <tools/diagnose_ex.h>
57 #include <vcl/group.hxx>
59 #include "helper/accessibilityclient.hxx"
60 #include "helper/imagealign.hxx"
61 #include "helper/tkresmgr.hxx"
62 #include "vclxwindows_internal.hxx"
64 using ::com::sun::star::uno::Any;
65 using ::com::sun::star::uno::Reference;
66 using ::com::sun::star::uno::makeAny;
67 using ::com::sun::star::uno::RuntimeException;
68 using ::com::sun::star::lang::EventObject;
69 using ::com::sun::star::awt::ItemListEvent;
70 using ::com::sun::star::awt::XItemList;
71 using ::com::sun::star::graphic::XGraphic;
72 using ::com::sun::star::graphic::XGraphicProvider;
74 using namespace ::com::sun::star;
75 using namespace ::com::sun::star::awt::VisualEffect;
76 namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode;
78 static double ImplCalcLongValue( double nValue, sal_uInt16 nDigits )
80 double n = nValue;
81 for ( sal_uInt16 d = 0; d < nDigits; d++ )
82 n *= 10;
83 return n;
86 static double ImplCalcDoubleValue( double nValue, sal_uInt16 nDigits )
88 double n = nValue;
89 for ( sal_uInt16 d = 0; d < nDigits; d++ )
90 n /= 10;
91 return n;
94 namespace toolkit
96 /** sets the "face color" for button like controls (scroll bar, spin button)
98 void setButtonLikeFaceColor( vcl::Window* _pWindow, const css::uno::Any& _rColorValue )
100 AllSettings aSettings = _pWindow->GetSettings();
101 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
103 if ( !_rColorValue.hasValue() )
105 const StyleSettings& aAppStyle = Application::GetSettings().GetStyleSettings();
106 aStyleSettings.SetFaceColor( aAppStyle.GetFaceColor( ) );
107 aStyleSettings.SetCheckedColor( aAppStyle.GetCheckedColor( ) );
108 aStyleSettings.SetLightBorderColor( aAppStyle.GetLightBorderColor() );
109 aStyleSettings.SetLightColor( aAppStyle.GetLightColor() );
110 aStyleSettings.SetShadowColor( aAppStyle.GetShadowColor() );
111 aStyleSettings.SetDarkShadowColor( aAppStyle.GetDarkShadowColor() );
113 else
115 sal_Int32 nBackgroundColor = 0;
116 _rColorValue >>= nBackgroundColor;
117 aStyleSettings.SetFaceColor( nBackgroundColor );
119 // for the real background (everything except the buttons and the thumb),
120 // use an average between the desired color and "white"
121 Color aWhite( COL_WHITE );
122 Color aBackground( nBackgroundColor );
123 aBackground.SetRed( ( aBackground.GetRed() + aWhite.GetRed() ) / 2 );
124 aBackground.SetGreen( ( aBackground.GetGreen() + aWhite.GetGreen() ) / 2 );
125 aBackground.SetBlue( ( aBackground.GetBlue() + aWhite.GetBlue() ) / 2 );
126 aStyleSettings.SetCheckedColor( aBackground );
128 sal_Int32 nBackgroundLuminance = Color( nBackgroundColor ).GetLuminance();
129 sal_Int32 nWhiteLuminance = Color( COL_WHITE ).GetLuminance();
131 Color aLightShadow( nBackgroundColor );
132 aLightShadow.IncreaseLuminance( (sal_uInt8)( ( nWhiteLuminance - nBackgroundLuminance ) * 2 / 3 ) );
133 aStyleSettings.SetLightBorderColor( aLightShadow );
135 Color aLight( nBackgroundColor );
136 aLight.IncreaseLuminance( (sal_uInt8)( ( nWhiteLuminance - nBackgroundLuminance ) * 1 / 3 ) );
137 aStyleSettings.SetLightColor( aLight );
139 Color aShadow( nBackgroundColor );
140 aShadow.DecreaseLuminance( (sal_uInt8)( nBackgroundLuminance * 1 / 3 ) );
141 aStyleSettings.SetShadowColor( aShadow );
143 Color aDarkShadow( nBackgroundColor );
144 aDarkShadow.DecreaseLuminance( (sal_uInt8)( nBackgroundLuminance * 2 / 3 ) );
145 aStyleSettings.SetDarkShadowColor( aDarkShadow );
148 aSettings.SetStyleSettings( aStyleSettings );
149 _pWindow->SetSettings( aSettings, true );
152 Any getButtonLikeFaceColor( const vcl::Window* _pWindow )
154 sal_Int32 nBackgroundColor = _pWindow->GetSettings().GetStyleSettings().GetFaceColor().GetColor();
155 return makeAny( nBackgroundColor );
158 static void adjustBooleanWindowStyle( const Any& _rValue, vcl::Window* _pWindow, WinBits _nBits, bool _bInverseSemantics )
160 WinBits nStyle = _pWindow->GetStyle();
161 bool bValue( false );
162 OSL_VERIFY( _rValue >>= bValue );
163 if ( bValue != _bInverseSemantics )
164 nStyle |= _nBits;
165 else
166 nStyle &= ~_nBits;
167 _pWindow->SetStyle( nStyle );
170 static void setVisualEffect( const Any& _rValue, vcl::Window* _pWindow )
172 AllSettings aSettings = _pWindow->GetSettings();
173 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
175 sal_Int16 nStyle = LOOK3D;
176 OSL_VERIFY( _rValue >>= nStyle );
177 switch ( nStyle )
179 case FLAT:
180 aStyleSettings.SetOptions( aStyleSettings.GetOptions() | StyleSettingsOptions::Mono );
181 break;
182 case LOOK3D:
183 default:
184 aStyleSettings.SetOptions( aStyleSettings.GetOptions() & ~StyleSettingsOptions::Mono );
186 aSettings.SetStyleSettings( aStyleSettings );
187 _pWindow->SetSettings( aSettings );
190 static Any getVisualEffect( vcl::Window* _pWindow )
192 Any aEffect;
194 StyleSettings aStyleSettings = _pWindow->GetSettings().GetStyleSettings();
195 if ( (aStyleSettings.GetOptions() & StyleSettingsOptions::Mono) )
196 aEffect <<= (sal_Int16)FLAT;
197 else
198 aEffect <<= (sal_Int16)LOOK3D;
199 return aEffect;
204 // class VCLXGraphicControl
207 void VCLXGraphicControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
209 VCLXWindow::ImplGetPropertyIds( rIds );
212 void VCLXGraphicControl::ImplSetNewImage()
214 OSL_PRECOND( GetWindow(), "VCLXGraphicControl::ImplSetNewImage: window is required to be not-NULL!" );
215 VclPtr< Button > pButton = GetAsDynamic< Button >();
216 pButton->SetModeImage( GetImage() );
219 void VCLXGraphicControl::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, short Flags ) throw(css::uno::RuntimeException, std::exception)
221 SolarMutexGuard aGuard;
223 if ( GetWindow() )
225 Size aOldSize = GetWindow()->GetSizePixel();
226 VCLXWindow::setPosSize( X, Y, Width, Height, Flags );
227 if ( ( aOldSize.Width() != Width ) || ( aOldSize.Height() != Height ) )
228 ImplSetNewImage();
232 void VCLXGraphicControl::setProperty( const OUString& PropertyName, const css::uno::Any& Value) throw(css::uno::RuntimeException, std::exception)
234 SolarMutexGuard aGuard;
236 if ( !GetWindow() )
237 return;
239 sal_uInt16 nPropType = GetPropertyId( PropertyName );
240 switch ( nPropType )
242 case BASEPROPERTY_GRAPHIC:
244 Reference< XGraphic > xGraphic;
245 OSL_VERIFY( Value >>= xGraphic );
246 maImage = Image( xGraphic );
247 ImplSetNewImage();
249 break;
251 case BASEPROPERTY_IMAGEALIGN:
253 WindowType eType = GetWindow()->GetType();
254 if ( ( eType == WINDOW_PUSHBUTTON )
255 || ( eType == WINDOW_RADIOBUTTON )
256 || ( eType == WINDOW_CHECKBOX )
259 sal_Int16 nAlignment = sal_Int16();
260 if ( Value >>= nAlignment )
261 GetAs< Button >()->SetImageAlign( static_cast< ImageAlign >( nAlignment ) );
264 break;
265 case BASEPROPERTY_IMAGEPOSITION:
267 WindowType eType = GetWindow()->GetType();
268 if ( ( eType == WINDOW_PUSHBUTTON )
269 || ( eType == WINDOW_RADIOBUTTON )
270 || ( eType == WINDOW_CHECKBOX )
273 sal_Int16 nImagePosition = 2;
274 OSL_VERIFY( Value >>= nImagePosition );
275 GetAs<Button>()->SetImageAlign( ::toolkit::translateImagePosition( nImagePosition ) );
278 break;
279 default:
280 VCLXWindow::setProperty( PropertyName, Value );
281 break;
285 css::uno::Any VCLXGraphicControl::getProperty( const OUString& PropertyName ) throw(css::uno::RuntimeException, std::exception)
287 SolarMutexGuard aGuard;
289 css::uno::Any aProp;
290 if ( !GetWindow() )
291 return aProp;
293 sal_uInt16 nPropType = GetPropertyId( PropertyName );
294 switch ( nPropType )
296 case BASEPROPERTY_GRAPHIC:
297 aProp <<= maImage.GetXGraphic();
298 break;
299 case BASEPROPERTY_IMAGEALIGN:
301 WindowType eType = GetWindow()->GetType();
302 if ( ( eType == WINDOW_PUSHBUTTON )
303 || ( eType == WINDOW_RADIOBUTTON )
304 || ( eType == WINDOW_CHECKBOX )
307 aProp <<= ::toolkit::getCompatibleImageAlign(
308 GetAs<Button>()->GetImageAlign() );
311 break;
312 case BASEPROPERTY_IMAGEPOSITION:
314 WindowType eType = GetWindow()->GetType();
315 if ( ( eType == WINDOW_PUSHBUTTON )
316 || ( eType == WINDOW_RADIOBUTTON )
317 || ( eType == WINDOW_CHECKBOX )
320 aProp <<= ::toolkit::translateImagePosition(
321 GetAs< Button >()->GetImageAlign() );
324 break;
325 default:
327 aProp <<= VCLXWindow::getProperty( PropertyName );
329 break;
331 return aProp;
335 // class VCLXButton
338 void VCLXButton::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
340 PushPropertyIds( rIds,
341 BASEPROPERTY_BACKGROUNDCOLOR,
342 BASEPROPERTY_DEFAULTBUTTON,
343 BASEPROPERTY_DEFAULTCONTROL,
344 BASEPROPERTY_ENABLED,
345 BASEPROPERTY_ENABLEVISIBLE,
346 BASEPROPERTY_FONTDESCRIPTOR,
347 BASEPROPERTY_GRAPHIC,
348 BASEPROPERTY_HELPTEXT,
349 BASEPROPERTY_HELPURL,
350 BASEPROPERTY_IMAGEALIGN,
351 BASEPROPERTY_IMAGEPOSITION,
352 BASEPROPERTY_IMAGEURL,
353 BASEPROPERTY_LABEL,
354 BASEPROPERTY_PRINTABLE,
355 BASEPROPERTY_PUSHBUTTONTYPE,
356 BASEPROPERTY_REPEAT,
357 BASEPROPERTY_REPEAT_DELAY,
358 BASEPROPERTY_STATE,
359 BASEPROPERTY_TABSTOP,
360 BASEPROPERTY_TOGGLE,
361 BASEPROPERTY_FOCUSONCLICK,
362 BASEPROPERTY_MULTILINE,
363 BASEPROPERTY_ALIGN,
364 BASEPROPERTY_VERTICALALIGN,
365 BASEPROPERTY_WRITING_MODE,
366 BASEPROPERTY_CONTEXT_WRITING_MODE,
367 BASEPROPERTY_REFERENCE_DEVICE,
369 VCLXGraphicControl::ImplGetPropertyIds( rIds );
372 VCLXButton::VCLXButton()
373 :maActionListeners( *this )
374 ,maItemListeners( *this )
378 VCLXButton::~VCLXButton()
382 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXButton::CreateAccessibleContext()
384 return getAccessibleFactory().createAccessibleContext( this );
387 void VCLXButton::dispose() throw(css::uno::RuntimeException, std::exception)
389 SolarMutexGuard aGuard;
391 css::lang::EventObject aObj;
392 aObj.Source = static_cast<cppu::OWeakObject*>(this);
393 maActionListeners.disposeAndClear( aObj );
394 maItemListeners.disposeAndClear( aObj );
395 VCLXGraphicControl::dispose();
398 void VCLXButton::addActionListener( const css::uno::Reference< css::awt::XActionListener > & l )throw(css::uno::RuntimeException, std::exception)
400 SolarMutexGuard aGuard;
401 maActionListeners.addInterface( l );
404 void VCLXButton::removeActionListener( const css::uno::Reference< css::awt::XActionListener > & l ) throw(css::uno::RuntimeException, std::exception)
406 SolarMutexGuard aGuard;
407 maActionListeners.removeInterface( l );
410 void VCLXButton::addItemListener( const css::uno::Reference< css::awt::XItemListener > & l )throw(css::uno::RuntimeException, std::exception)
412 SolarMutexGuard aGuard;
413 maItemListeners.addInterface( l );
416 void VCLXButton::removeItemListener( const css::uno::Reference< css::awt::XItemListener > & l ) throw(css::uno::RuntimeException, std::exception)
418 SolarMutexGuard aGuard;
419 maItemListeners.removeInterface( l );
422 void VCLXButton::setLabel( const OUString& rLabel ) throw(css::uno::RuntimeException, std::exception)
424 SolarMutexGuard aGuard;
426 vcl::Window* pWindow = GetWindow();
427 if ( pWindow )
428 pWindow->SetText( rLabel );
431 void VCLXButton::setActionCommand( const OUString& rCommand ) throw(css::uno::RuntimeException, std::exception)
433 SolarMutexGuard aGuard;
435 maActionCommand = rCommand;
438 css::awt::Size VCLXButton::getMinimumSize( ) throw(css::uno::RuntimeException, std::exception)
440 SolarMutexGuard aGuard;
442 Size aSz;
443 VclPtr< PushButton > pButton = GetAs< PushButton >();
444 if ( pButton )
445 aSz = pButton->CalcMinimumSize();
446 return AWTSize(aSz);
449 css::awt::Size VCLXButton::getPreferredSize( ) throw(css::uno::RuntimeException, std::exception)
451 css::awt::Size aSz = getMinimumSize();
452 aSz.Width += 16;
453 aSz.Height += 10;
454 return aSz;
457 css::awt::Size VCLXButton::calcAdjustedSize( const css::awt::Size& rNewSize ) throw(css::uno::RuntimeException, std::exception)
459 SolarMutexGuard aGuard;
461 Size aSz = VCLSize(rNewSize);
462 VclPtr< PushButton > pButton = GetAs< PushButton >();
463 if ( pButton )
465 Size aMinSz = pButton->CalcMinimumSize();
466 // no text, thus image
467 if ( pButton->GetText().isEmpty() )
469 if ( aSz.Width() < aMinSz.Width() )
470 aSz.Width() = aMinSz.Width();
471 if ( aSz.Height() < aMinSz.Height() )
472 aSz.Height() = aMinSz.Height();
474 else
476 if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
477 aSz.Height() = aMinSz.Height();
478 else
479 aSz = aMinSz;
482 return AWTSize(aSz);
485 void VCLXButton::setProperty( const OUString& PropertyName, const css::uno::Any& Value) throw(css::uno::RuntimeException, std::exception)
487 SolarMutexGuard aGuard;
489 VclPtr< Button > pButton = GetAs< Button >();
490 if ( pButton )
492 sal_uInt16 nPropType = GetPropertyId( PropertyName );
493 switch ( nPropType )
495 case BASEPROPERTY_FOCUSONCLICK:
496 ::toolkit::adjustBooleanWindowStyle( Value, pButton, WB_NOPOINTERFOCUS, true );
497 break;
499 case BASEPROPERTY_TOGGLE:
500 ::toolkit::adjustBooleanWindowStyle( Value, pButton, WB_TOGGLE, false );
501 break;
503 case BASEPROPERTY_DEFAULTBUTTON:
505 WinBits nStyle = pButton->GetStyle() | WB_DEFBUTTON;
506 bool b = bool();
507 if ( ( Value >>= b ) && !b )
508 nStyle &= ~WB_DEFBUTTON;
509 pButton->SetStyle( nStyle );
511 break;
512 case BASEPROPERTY_STATE:
514 if ( GetWindow()->GetType() == WINDOW_PUSHBUTTON )
516 sal_Int16 n = sal_Int16();
517 if ( Value >>= n )
518 static_cast<PushButton*>(pButton.get())->SetState( (TriState)n );
521 break;
522 default:
524 VCLXGraphicControl::setProperty( PropertyName, Value );
530 css::uno::Any VCLXButton::getProperty( const OUString& PropertyName ) throw(css::uno::RuntimeException, std::exception)
532 SolarMutexGuard aGuard;
534 css::uno::Any aProp;
535 VclPtr< Button > pButton = GetAs< Button >();
536 if ( pButton )
538 sal_uInt16 nPropType = GetPropertyId( PropertyName );
539 switch ( nPropType )
541 case BASEPROPERTY_FOCUSONCLICK:
542 aProp <<= ( ( pButton->GetStyle() & WB_NOPOINTERFOCUS ) == 0 );
543 break;
545 case BASEPROPERTY_TOGGLE:
546 aProp <<= ( ( pButton->GetStyle() & WB_TOGGLE ) != 0 );
547 break;
549 case BASEPROPERTY_DEFAULTBUTTON:
551 aProp <<= ( pButton->GetStyle() & WB_DEFBUTTON ) != 0;
553 break;
554 case BASEPROPERTY_STATE:
556 if ( GetWindow()->GetType() == WINDOW_PUSHBUTTON )
558 aProp <<= (sal_Int16)static_cast<PushButton*>(pButton.get())->GetState();
561 break;
562 default:
564 aProp <<= VCLXGraphicControl::getProperty( PropertyName );
568 return aProp;
571 void VCLXButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
573 switch ( rVclWindowEvent.GetId() )
575 case VCLEVENT_BUTTON_CLICK:
577 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
578 // since we call listeners below, there is a potential that we will be destroyed
579 // during the listener call. To prevent the resulting crashs, we keep us
580 // alive as long as we're here
582 if ( maActionListeners.getLength() )
584 css::awt::ActionEvent aEvent;
585 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
586 aEvent.ActionCommand = maActionCommand;
588 Callback aCallback = [ this, aEvent ]()
589 { this->maActionListeners.actionPerformed( aEvent ); };
591 ImplExecuteAsyncWithoutSolarLock( aCallback );
594 break;
596 case VCLEVENT_PUSHBUTTON_TOGGLE:
598 PushButton& rButton = dynamic_cast< PushButton& >( *rVclWindowEvent.GetWindow() );
600 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
601 if ( maItemListeners.getLength() )
603 css::awt::ItemEvent aEvent;
604 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
605 aEvent.Selected = ( rButton.GetState() == TRISTATE_TRUE ) ? 1 : 0;
606 maItemListeners.itemStateChanged( aEvent );
609 break;
611 default:
612 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent );
613 break;
618 // class VCLXImageControl
621 void VCLXImageControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
623 PushPropertyIds( rIds,
624 BASEPROPERTY_BACKGROUNDCOLOR,
625 BASEPROPERTY_BORDER,
626 BASEPROPERTY_BORDERCOLOR,
627 BASEPROPERTY_DEFAULTCONTROL,
628 BASEPROPERTY_ENABLED,
629 BASEPROPERTY_ENABLEVISIBLE,
630 BASEPROPERTY_GRAPHIC,
631 BASEPROPERTY_HELPTEXT,
632 BASEPROPERTY_HELPURL,
633 BASEPROPERTY_IMAGEURL,
634 BASEPROPERTY_PRINTABLE,
635 BASEPROPERTY_SCALEIMAGE,
636 BASEPROPERTY_IMAGE_SCALE_MODE,
637 BASEPROPERTY_TABSTOP,
638 BASEPROPERTY_WRITING_MODE,
639 BASEPROPERTY_CONTEXT_WRITING_MODE,
641 VCLXGraphicControl::ImplGetPropertyIds( rIds );
644 VCLXImageControl::VCLXImageControl()
648 VCLXImageControl::~VCLXImageControl()
652 void VCLXImageControl::ImplSetNewImage()
654 OSL_PRECOND( GetWindow(), "VCLXImageControl::ImplSetNewImage: window is required to be not-NULL!" );
655 VclPtr<ImageControl> pControl = GetAs< ImageControl >();
656 pControl->SetImage( GetImage() );
659 css::awt::Size VCLXImageControl::getMinimumSize( ) throw(css::uno::RuntimeException, std::exception)
661 SolarMutexGuard aGuard;
663 Size aSz = GetImage().GetSizePixel();
664 aSz = ImplCalcWindowSize( aSz );
666 return AWTSize(aSz);
669 css::awt::Size VCLXImageControl::getPreferredSize( ) throw(css::uno::RuntimeException, std::exception)
671 return getMinimumSize();
674 css::awt::Size VCLXImageControl::calcAdjustedSize( const css::awt::Size& rNewSize ) throw(css::uno::RuntimeException, std::exception)
676 SolarMutexGuard aGuard;
678 css::awt::Size aSz = rNewSize;
679 css::awt::Size aMinSz = getMinimumSize();
680 if ( aSz.Width < aMinSz.Width )
681 aSz.Width = aMinSz.Width;
682 if ( aSz.Height < aMinSz.Height )
683 aSz.Height = aMinSz.Height;
684 return aSz;
687 void VCLXImageControl::setProperty( const OUString& PropertyName, const css::uno::Any& Value) throw(css::uno::RuntimeException, std::exception)
689 SolarMutexGuard aGuard;
691 VclPtr< ImageControl > pImageControl = GetAs< ImageControl >();
693 sal_uInt16 nPropType = GetPropertyId( PropertyName );
694 switch ( nPropType )
696 case BASEPROPERTY_IMAGE_SCALE_MODE:
698 sal_Int16 nScaleMode( ImageScaleMode::ANISOTROPIC );
699 if ( pImageControl && ( Value >>= nScaleMode ) )
701 pImageControl->SetScaleMode( nScaleMode );
704 break;
706 case BASEPROPERTY_SCALEIMAGE:
708 // this is for compatibility only, nowadays, the ImageScaleMode property should be used
709 bool bScaleImage = false;
710 if ( pImageControl && ( Value >>= bScaleImage ) )
712 pImageControl->SetScaleMode( bScaleImage ? ImageScaleMode::ANISOTROPIC : ImageScaleMode::NONE );
715 break;
717 default:
718 VCLXGraphicControl::setProperty( PropertyName, Value );
719 break;
723 css::uno::Any VCLXImageControl::getProperty( const OUString& PropertyName ) throw(css::uno::RuntimeException, std::exception)
725 SolarMutexGuard aGuard;
727 css::uno::Any aProp;
728 VclPtr< ImageControl > pImageControl = GetAs< ImageControl >();
729 sal_uInt16 nPropType = GetPropertyId( PropertyName );
731 switch ( nPropType )
733 case BASEPROPERTY_IMAGE_SCALE_MODE:
734 aProp <<= ( pImageControl ? pImageControl->GetScaleMode() : ImageScaleMode::ANISOTROPIC );
735 break;
737 case BASEPROPERTY_SCALEIMAGE:
738 aProp <<= ( pImageControl && pImageControl->GetScaleMode() != ImageScaleMode::NONE );
739 break;
741 default:
742 aProp = VCLXGraphicControl::getProperty( PropertyName );
743 break;
745 return aProp;
749 // class VCLXCheckBox
752 void VCLXCheckBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
754 PushPropertyIds( rIds,
755 BASEPROPERTY_DEFAULTCONTROL,
756 BASEPROPERTY_ENABLED,
757 BASEPROPERTY_ENABLEVISIBLE,
758 BASEPROPERTY_FONTDESCRIPTOR,
759 BASEPROPERTY_GRAPHIC,
760 BASEPROPERTY_HELPTEXT,
761 BASEPROPERTY_HELPURL,
762 BASEPROPERTY_IMAGEPOSITION,
763 BASEPROPERTY_IMAGEURL,
764 BASEPROPERTY_LABEL,
765 BASEPROPERTY_PRINTABLE,
766 BASEPROPERTY_STATE,
767 BASEPROPERTY_TABSTOP,
768 BASEPROPERTY_TRISTATE,
769 BASEPROPERTY_VISUALEFFECT,
770 BASEPROPERTY_MULTILINE,
771 BASEPROPERTY_BACKGROUNDCOLOR,
772 BASEPROPERTY_ALIGN,
773 BASEPROPERTY_VERTICALALIGN,
774 BASEPROPERTY_WRITING_MODE,
775 BASEPROPERTY_CONTEXT_WRITING_MODE,
776 BASEPROPERTY_REFERENCE_DEVICE,
778 VCLXGraphicControl::ImplGetPropertyIds( rIds );
781 VCLXCheckBox::VCLXCheckBox() : maActionListeners( *this ), maItemListeners( *this )
785 // css::uno::XInterface
786 css::uno::Any VCLXCheckBox::queryInterface( const css::uno::Type & rType ) throw(css::uno::RuntimeException, std::exception)
788 css::uno::Any aRet = ::cppu::queryInterface( rType,
789 (static_cast< css::awt::XButton* >(this)),
790 (static_cast< css::awt::XCheckBox* >(this)) );
791 return (aRet.hasValue() ? aRet : VCLXGraphicControl::queryInterface( rType ));
794 // css::lang::XTypeProvider
795 IMPL_XTYPEPROVIDER_START( VCLXCheckBox )
796 cppu::UnoType<css::awt::XButton>::get(),
797 cppu::UnoType<css::awt::XCheckBox>::get(),
798 VCLXGraphicControl::getTypes()
799 IMPL_XTYPEPROVIDER_END
801 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXCheckBox::CreateAccessibleContext()
803 return getAccessibleFactory().createAccessibleContext( this );
806 void VCLXCheckBox::dispose() throw(css::uno::RuntimeException, std::exception)
808 SolarMutexGuard aGuard;
810 css::lang::EventObject aObj;
811 aObj.Source = static_cast<cppu::OWeakObject*>(this);
812 maItemListeners.disposeAndClear( aObj );
813 VCLXGraphicControl::dispose();
816 void VCLXCheckBox::addItemListener( const css::uno::Reference< css::awt::XItemListener > & l ) throw(css::uno::RuntimeException, std::exception)
818 SolarMutexGuard aGuard;
819 maItemListeners.addInterface( l );
822 void VCLXCheckBox::removeItemListener( const css::uno::Reference< css::awt::XItemListener > & l ) throw(css::uno::RuntimeException, std::exception)
824 SolarMutexGuard aGuard;
825 maItemListeners.removeInterface( l );
828 void VCLXCheckBox::addActionListener( const css::uno::Reference< css::awt::XActionListener > & l )throw(css::uno::RuntimeException, std::exception)
830 SolarMutexGuard aGuard;
831 maActionListeners.addInterface( l );
834 void VCLXCheckBox::removeActionListener( const css::uno::Reference< css::awt::XActionListener > & l ) throw(css::uno::RuntimeException, std::exception)
836 SolarMutexGuard aGuard;
837 maActionListeners.removeInterface( l );
840 void VCLXCheckBox::setActionCommand( const OUString& rCommand ) throw(css::uno::RuntimeException, std::exception)
842 SolarMutexGuard aGuard;
843 maActionCommand = rCommand;
846 void VCLXCheckBox::setLabel( const OUString& rLabel ) throw(css::uno::RuntimeException, std::exception)
848 SolarMutexGuard aGuard;
850 vcl::Window* pWindow = GetWindow();
851 if ( pWindow )
852 pWindow->SetText( rLabel );
855 void VCLXCheckBox::setState( short n ) throw(css::uno::RuntimeException, std::exception)
857 SolarMutexGuard aGuard;
859 VclPtr< CheckBox> pCheckBox = GetAs< CheckBox >();
860 if ( pCheckBox)
862 TriState eState;
863 switch ( n )
865 case 0: eState = TRISTATE_FALSE; break;
866 case 1: eState = TRISTATE_TRUE; break;
867 case 2: eState = TRISTATE_INDET; break;
868 default: eState = TRISTATE_FALSE;
870 pCheckBox->SetState( eState );
872 // #105198# call C++ click listeners (needed for accessibility)
873 // pCheckBox->GetClickHdl().Call( pCheckBox );
875 // #107218# Call same virtual methods and listeners like VCL would do after user interaction
876 SetSynthesizingVCLEvent( true );
877 pCheckBox->Toggle();
878 pCheckBox->Click();
879 SetSynthesizingVCLEvent( false );
883 short VCLXCheckBox::getState() throw(css::uno::RuntimeException, std::exception)
885 SolarMutexGuard aGuard;
887 short nState = -1;
888 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
889 if ( pCheckBox )
891 switch ( pCheckBox->GetState() )
893 case TRISTATE_FALSE: nState = 0; break;
894 case TRISTATE_TRUE: nState = 1; break;
895 case TRISTATE_INDET: nState = 2; break;
896 default: OSL_FAIL( "VCLXCheckBox::getState(): unknown TriState!" );
900 return nState;
903 void VCLXCheckBox::enableTriState( sal_Bool b ) throw(css::uno::RuntimeException, std::exception)
905 SolarMutexGuard aGuard;
907 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
908 if ( pCheckBox)
909 pCheckBox->EnableTriState( b );
912 css::awt::Size VCLXCheckBox::getMinimumSize() throw(css::uno::RuntimeException, std::exception)
914 SolarMutexGuard aGuard;
916 Size aSz;
917 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
918 if ( pCheckBox )
919 aSz = pCheckBox->CalcMinimumSize();
920 return AWTSize(aSz);
923 css::awt::Size VCLXCheckBox::getPreferredSize() throw(css::uno::RuntimeException, std::exception)
925 return getMinimumSize();
928 css::awt::Size VCLXCheckBox::calcAdjustedSize( const css::awt::Size& rNewSize ) throw(css::uno::RuntimeException, std::exception)
930 SolarMutexGuard aGuard;
932 Size aSz = VCLSize(rNewSize);
933 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
934 if ( pCheckBox )
936 Size aMinSz = pCheckBox->CalcMinimumSize();
937 if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
938 aSz.Height() = aMinSz.Height();
939 else
940 aSz = aMinSz;
942 return AWTSize(aSz);
945 void VCLXCheckBox::setProperty( const OUString& PropertyName, const css::uno::Any& Value) throw(css::uno::RuntimeException, std::exception)
947 SolarMutexGuard aGuard;
949 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
950 if ( pCheckBox )
952 sal_uInt16 nPropType = GetPropertyId( PropertyName );
953 switch ( nPropType )
955 case BASEPROPERTY_VISUALEFFECT:
956 ::toolkit::setVisualEffect( Value, pCheckBox );
957 break;
959 case BASEPROPERTY_TRISTATE:
961 bool b = bool();
962 if ( Value >>= b )
963 pCheckBox->EnableTriState( b );
965 break;
966 case BASEPROPERTY_STATE:
968 sal_Int16 n = sal_Int16();
969 if ( Value >>= n )
970 setState( n );
972 break;
973 default:
975 VCLXGraphicControl::setProperty( PropertyName, Value );
981 css::uno::Any VCLXCheckBox::getProperty( const OUString& PropertyName ) throw(css::uno::RuntimeException, std::exception)
983 SolarMutexGuard aGuard;
985 css::uno::Any aProp;
986 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
987 if ( pCheckBox )
989 sal_uInt16 nPropType = GetPropertyId( PropertyName );
990 switch ( nPropType )
992 case BASEPROPERTY_VISUALEFFECT:
993 aProp = ::toolkit::getVisualEffect( pCheckBox );
994 break;
995 case BASEPROPERTY_TRISTATE:
996 aProp <<= pCheckBox->IsTriStateEnabled();
997 break;
998 case BASEPROPERTY_STATE:
999 aProp <<= (sal_Int16)pCheckBox->GetState();
1000 break;
1001 default:
1003 aProp <<= VCLXGraphicControl::getProperty( PropertyName );
1007 return aProp;
1010 void VCLXCheckBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1012 switch ( rVclWindowEvent.GetId() )
1014 case VCLEVENT_CHECKBOX_TOGGLE:
1016 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
1017 // since we call listeners below, there is a potential that we will be destroyed
1018 // in during the listener call. To prevent the resulting crashs, we keep us
1019 // alive as long as we're here
1021 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
1022 if ( pCheckBox )
1024 if ( maItemListeners.getLength() )
1026 css::awt::ItemEvent aEvent;
1027 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
1028 aEvent.Highlighted = 0;
1029 aEvent.Selected = pCheckBox->GetState();
1030 maItemListeners.itemStateChanged( aEvent );
1032 if ( !IsSynthesizingVCLEvent() && maActionListeners.getLength() )
1034 css::awt::ActionEvent aEvent;
1035 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
1036 aEvent.ActionCommand = maActionCommand;
1037 maActionListeners.actionPerformed( aEvent );
1041 break;
1043 default:
1044 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent );
1045 break;
1050 // class VCLXRadioButton
1052 void VCLXRadioButton::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1054 PushPropertyIds( rIds,
1055 BASEPROPERTY_DEFAULTCONTROL,
1056 BASEPROPERTY_ENABLED,
1057 BASEPROPERTY_ENABLEVISIBLE,
1058 BASEPROPERTY_FONTDESCRIPTOR,
1059 BASEPROPERTY_GRAPHIC,
1060 BASEPROPERTY_HELPTEXT,
1061 BASEPROPERTY_HELPURL,
1062 BASEPROPERTY_IMAGEPOSITION,
1063 BASEPROPERTY_IMAGEURL,
1064 BASEPROPERTY_LABEL,
1065 BASEPROPERTY_PRINTABLE,
1066 BASEPROPERTY_STATE,
1067 BASEPROPERTY_TABSTOP,
1068 BASEPROPERTY_VISUALEFFECT,
1069 BASEPROPERTY_MULTILINE,
1070 BASEPROPERTY_BACKGROUNDCOLOR,
1071 BASEPROPERTY_ALIGN,
1072 BASEPROPERTY_VERTICALALIGN,
1073 BASEPROPERTY_WRITING_MODE,
1074 BASEPROPERTY_CONTEXT_WRITING_MODE,
1075 BASEPROPERTY_REFERENCE_DEVICE,
1076 BASEPROPERTY_GROUPNAME,
1078 VCLXGraphicControl::ImplGetPropertyIds( rIds );
1082 VCLXRadioButton::VCLXRadioButton() : maItemListeners( *this ), maActionListeners( *this )
1086 // css::uno::XInterface
1087 css::uno::Any VCLXRadioButton::queryInterface( const css::uno::Type & rType ) throw(css::uno::RuntimeException, std::exception)
1089 css::uno::Any aRet = ::cppu::queryInterface( rType,
1090 (static_cast< css::awt::XRadioButton* >(this)),
1091 (static_cast< css::awt::XButton* >(this)) );
1092 return (aRet.hasValue() ? aRet : VCLXGraphicControl::queryInterface( rType ));
1095 // css::lang::XTypeProvider
1096 IMPL_XTYPEPROVIDER_START( VCLXRadioButton )
1097 cppu::UnoType<css::awt::XRadioButton>::get(),
1098 cppu::UnoType<css::awt::XButton>::get(),
1099 VCLXGraphicControl::getTypes()
1100 IMPL_XTYPEPROVIDER_END
1102 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXRadioButton::CreateAccessibleContext()
1104 return getAccessibleFactory().createAccessibleContext( this );
1107 void VCLXRadioButton::dispose() throw(css::uno::RuntimeException, std::exception)
1109 SolarMutexGuard aGuard;
1111 css::lang::EventObject aObj;
1112 aObj.Source = static_cast<cppu::OWeakObject*>(this);
1113 maItemListeners.disposeAndClear( aObj );
1114 VCLXGraphicControl::dispose();
1117 void VCLXRadioButton::setProperty( const OUString& PropertyName, const css::uno::Any& Value) throw(css::uno::RuntimeException, std::exception)
1119 SolarMutexGuard aGuard;
1121 VclPtr< RadioButton > pButton = GetAs< RadioButton >();
1122 if ( pButton )
1124 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1125 switch ( nPropType )
1127 case BASEPROPERTY_VISUALEFFECT:
1128 ::toolkit::setVisualEffect( Value, pButton );
1129 break;
1131 case BASEPROPERTY_STATE:
1133 sal_Int16 n = sal_Int16();
1134 if ( Value >>= n )
1136 bool b = n != 0;
1137 if ( pButton->IsRadioCheckEnabled() )
1138 pButton->Check( b );
1139 else
1140 pButton->SetState( b );
1143 break;
1144 case BASEPROPERTY_AUTOTOGGLE:
1146 bool b = bool();
1147 if ( Value >>= b )
1148 pButton->EnableRadioCheck( b );
1150 break;
1151 default:
1153 VCLXGraphicControl::setProperty( PropertyName, Value );
1159 css::uno::Any VCLXRadioButton::getProperty( const OUString& PropertyName ) throw(css::uno::RuntimeException, std::exception)
1161 SolarMutexGuard aGuard;
1163 css::uno::Any aProp;
1164 VclPtr< RadioButton > pButton = GetAs< RadioButton >();
1165 if ( pButton )
1167 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1168 switch ( nPropType )
1170 case BASEPROPERTY_VISUALEFFECT:
1171 aProp = ::toolkit::getVisualEffect( pButton );
1172 break;
1173 case BASEPROPERTY_STATE:
1174 aProp <<= (sal_Int16) ( pButton->IsChecked() ? 1 : 0 );
1175 break;
1176 case BASEPROPERTY_AUTOTOGGLE:
1177 aProp <<= pButton->IsRadioCheckEnabled();
1178 break;
1179 default:
1181 aProp <<= VCLXGraphicControl::getProperty( PropertyName );
1185 return aProp;
1188 void VCLXRadioButton::addItemListener( const css::uno::Reference< css::awt::XItemListener > & l ) throw(css::uno::RuntimeException, std::exception)
1190 SolarMutexGuard aGuard;
1191 maItemListeners.addInterface( l );
1194 void VCLXRadioButton::removeItemListener( const css::uno::Reference< css::awt::XItemListener > & l ) throw(css::uno::RuntimeException, std::exception)
1196 SolarMutexGuard aGuard;
1197 maItemListeners.removeInterface( l );
1200 void VCLXRadioButton::addActionListener( const css::uno::Reference< css::awt::XActionListener > & l )throw(css::uno::RuntimeException, std::exception)
1202 SolarMutexGuard aGuard;
1203 maActionListeners.addInterface( l );
1206 void VCLXRadioButton::removeActionListener( const css::uno::Reference< css::awt::XActionListener > & l ) throw(css::uno::RuntimeException, std::exception)
1208 SolarMutexGuard aGuard;
1209 maActionListeners.removeInterface( l );
1212 void VCLXRadioButton::setLabel( const OUString& rLabel ) throw(css::uno::RuntimeException, std::exception)
1214 SolarMutexGuard aGuard;
1216 vcl::Window* pWindow = GetWindow();
1217 if ( pWindow )
1218 pWindow->SetText( rLabel );
1221 void VCLXRadioButton::setActionCommand( const OUString& rCommand ) throw(css::uno::RuntimeException, std::exception)
1223 SolarMutexGuard aGuard;
1224 maActionCommand = rCommand;
1227 void VCLXRadioButton::setState( sal_Bool b ) throw(css::uno::RuntimeException, std::exception)
1229 SolarMutexGuard aGuard;
1231 VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >();
1232 if ( pRadioButton)
1234 pRadioButton->Check( b );
1235 // #102717# item listeners are called, but not C++ click listeners in StarOffice code => call click hdl
1236 // But this is needed in old code because Accessibility API uses it.
1237 // pRadioButton->GetClickHdl().Call( pRadioButton );
1239 // #107218# Call same virtual methods and listeners like VCL would do after user interaction
1240 SetSynthesizingVCLEvent( true );
1241 pRadioButton->Click();
1242 SetSynthesizingVCLEvent( false );
1246 sal_Bool VCLXRadioButton::getState() throw(css::uno::RuntimeException, std::exception)
1248 SolarMutexGuard aGuard;
1250 VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >();
1251 return pRadioButton && pRadioButton->IsChecked();
1254 css::awt::Size VCLXRadioButton::getMinimumSize( ) throw(css::uno::RuntimeException, std::exception)
1256 SolarMutexGuard aGuard;
1258 Size aSz;
1259 VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >();
1260 if ( pRadioButton )
1261 aSz = pRadioButton->CalcMinimumSize();
1262 return AWTSize(aSz);
1265 css::awt::Size VCLXRadioButton::getPreferredSize( ) throw(css::uno::RuntimeException, std::exception)
1267 return getMinimumSize();
1270 css::awt::Size VCLXRadioButton::calcAdjustedSize( const css::awt::Size& rNewSize ) throw(css::uno::RuntimeException, std::exception)
1272 SolarMutexGuard aGuard;
1274 Size aSz = VCLSize(rNewSize);
1275 VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >();
1276 if ( pRadioButton )
1278 Size aMinSz = pRadioButton->CalcMinimumSize();
1279 if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
1280 aSz.Height() = aMinSz.Height();
1281 else
1282 aSz = aMinSz;
1284 return AWTSize(aSz);
1287 void VCLXRadioButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1289 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
1290 // since we call listeners below, there is a potential that we will be destroyed
1291 // in during the listener call. To prevent the resulting crashs, we keep us
1292 // alive as long as we're here
1294 switch ( rVclWindowEvent.GetId() )
1296 case VCLEVENT_BUTTON_CLICK:
1297 if ( !IsSynthesizingVCLEvent() && maActionListeners.getLength() )
1299 css::awt::ActionEvent aEvent;
1300 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
1301 aEvent.ActionCommand = maActionCommand;
1302 maActionListeners.actionPerformed( aEvent );
1304 ImplClickedOrToggled( false );
1305 break;
1307 case VCLEVENT_RADIOBUTTON_TOGGLE:
1308 ImplClickedOrToggled( true );
1309 break;
1311 default:
1312 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent );
1313 break;
1317 void VCLXRadioButton::ImplClickedOrToggled( bool bToggled )
1319 // In the formulars, RadioChecked is not enabled, call itemStateChanged only for click
1320 // In the dialog editor, RadioChecked is enabled, call itemStateChanged only for bToggled
1321 VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >();
1322 if ( pRadioButton && ( pRadioButton->IsRadioCheckEnabled() == bToggled ) && ( bToggled || pRadioButton->IsStateChanged() ) && maItemListeners.getLength() )
1324 css::awt::ItemEvent aEvent;
1325 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
1326 aEvent.Highlighted = 0;
1327 aEvent.Selected = pRadioButton->IsChecked() ? 1 : 0;
1328 maItemListeners.itemStateChanged( aEvent );
1333 // class VCLXSpinField
1335 void VCLXSpinField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1337 PushPropertyIds( rIds,
1338 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
1339 0 );
1340 VCLXEdit::ImplGetPropertyIds( rIds );
1343 VCLXSpinField::VCLXSpinField() : maSpinListeners( *this )
1347 // css::uno::XInterface
1348 css::uno::Any VCLXSpinField::queryInterface( const css::uno::Type & rType ) throw(css::uno::RuntimeException, std::exception)
1350 css::uno::Any aRet = ::cppu::queryInterface( rType,
1351 (static_cast< css::awt::XSpinField* >(this)) );
1352 return (aRet.hasValue() ? aRet : VCLXEdit::queryInterface( rType ));
1355 // css::lang::XTypeProvider
1356 IMPL_XTYPEPROVIDER_START( VCLXSpinField )
1357 cppu::UnoType<css::awt::XSpinField>::get(),
1358 VCLXEdit::getTypes()
1359 IMPL_XTYPEPROVIDER_END
1361 void VCLXSpinField::addSpinListener( const css::uno::Reference< css::awt::XSpinListener > & l ) throw(css::uno::RuntimeException, std::exception)
1363 SolarMutexGuard aGuard;
1364 maSpinListeners.addInterface( l );
1367 void VCLXSpinField::removeSpinListener( const css::uno::Reference< css::awt::XSpinListener > & l ) throw(css::uno::RuntimeException, std::exception)
1369 SolarMutexGuard aGuard;
1370 maSpinListeners.removeInterface( l );
1373 void VCLXSpinField::up() throw(css::uno::RuntimeException, std::exception)
1375 SolarMutexGuard aGuard;
1377 VclPtr< SpinField > pSpinField = GetAs< SpinField >();
1378 if ( pSpinField )
1379 pSpinField->Up();
1382 void VCLXSpinField::down() throw(css::uno::RuntimeException, std::exception)
1384 SolarMutexGuard aGuard;
1386 VclPtr< SpinField > pSpinField = GetAs< SpinField >();
1387 if ( pSpinField )
1388 pSpinField->Down();
1391 void VCLXSpinField::first() throw(css::uno::RuntimeException, std::exception)
1393 SolarMutexGuard aGuard;
1395 VclPtr< SpinField > pSpinField = GetAs< SpinField >();
1396 if ( pSpinField )
1397 pSpinField->First();
1400 void VCLXSpinField::last() throw(css::uno::RuntimeException, std::exception)
1402 SolarMutexGuard aGuard;
1404 VclPtr< SpinField > pSpinField = GetAs< SpinField >();
1405 if ( pSpinField )
1406 pSpinField->Last();
1409 void VCLXSpinField::enableRepeat( sal_Bool bRepeat ) throw(css::uno::RuntimeException, std::exception)
1411 SolarMutexGuard aGuard;
1413 vcl::Window* pWindow = GetWindow();
1414 if ( pWindow )
1416 WinBits nStyle = pWindow->GetStyle();
1417 if ( bRepeat )
1418 nStyle |= WB_REPEAT;
1419 else
1420 nStyle &= ~WB_REPEAT;
1421 pWindow->SetStyle( nStyle );
1425 void VCLXSpinField::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1427 switch ( rVclWindowEvent.GetId() )
1429 case VCLEVENT_SPINFIELD_UP:
1430 case VCLEVENT_SPINFIELD_DOWN:
1431 case VCLEVENT_SPINFIELD_FIRST:
1432 case VCLEVENT_SPINFIELD_LAST:
1434 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
1435 // since we call listeners below, there is a potential that we will be destroyed
1436 // in during the listener call. To prevent the resulting crashs, we keep us
1437 // alive as long as we're here
1439 if ( maSpinListeners.getLength() )
1441 css::awt::SpinEvent aEvent;
1442 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
1443 switch ( rVclWindowEvent.GetId() )
1445 case VCLEVENT_SPINFIELD_UP: maSpinListeners.up( aEvent );
1446 break;
1447 case VCLEVENT_SPINFIELD_DOWN: maSpinListeners.down( aEvent );
1448 break;
1449 case VCLEVENT_SPINFIELD_FIRST: maSpinListeners.first( aEvent );
1450 break;
1451 case VCLEVENT_SPINFIELD_LAST: maSpinListeners.last( aEvent );
1452 break;
1457 break;
1459 default:
1460 VCLXEdit::ProcessWindowEvent( rVclWindowEvent );
1461 break;
1466 // class VCLXListBox
1468 void VCLXListBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1470 PushPropertyIds( rIds,
1471 BASEPROPERTY_BACKGROUNDCOLOR,
1472 BASEPROPERTY_BORDER,
1473 BASEPROPERTY_BORDERCOLOR,
1474 BASEPROPERTY_DEFAULTCONTROL,
1475 BASEPROPERTY_DROPDOWN,
1476 BASEPROPERTY_ENABLED,
1477 BASEPROPERTY_ENABLEVISIBLE,
1478 BASEPROPERTY_FONTDESCRIPTOR,
1479 BASEPROPERTY_HELPTEXT,
1480 BASEPROPERTY_HELPURL,
1481 BASEPROPERTY_LINECOUNT,
1482 BASEPROPERTY_MULTISELECTION,
1483 BASEPROPERTY_MULTISELECTION_SIMPLEMODE,
1484 BASEPROPERTY_ITEM_SEPARATOR_POS,
1485 BASEPROPERTY_PRINTABLE,
1486 BASEPROPERTY_SELECTEDITEMS,
1487 BASEPROPERTY_STRINGITEMLIST,
1488 BASEPROPERTY_TABSTOP,
1489 BASEPROPERTY_READONLY,
1490 BASEPROPERTY_ALIGN,
1491 BASEPROPERTY_WRITING_MODE,
1492 BASEPROPERTY_CONTEXT_WRITING_MODE,
1493 BASEPROPERTY_REFERENCE_DEVICE,
1494 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
1496 VCLXWindow::ImplGetPropertyIds( rIds );
1500 VCLXListBox::VCLXListBox()
1501 : maActionListeners( *this ),
1502 maItemListeners( *this )
1506 void VCLXListBox::dispose() throw(css::uno::RuntimeException, std::exception)
1508 SolarMutexGuard aGuard;
1510 css::lang::EventObject aObj;
1511 aObj.Source = static_cast<cppu::OWeakObject*>(this);
1512 maItemListeners.disposeAndClear( aObj );
1513 maActionListeners.disposeAndClear( aObj );
1514 VCLXWindow::dispose();
1517 void VCLXListBox::addItemListener( const css::uno::Reference< css::awt::XItemListener > & l ) throw(css::uno::RuntimeException, std::exception)
1519 SolarMutexGuard aGuard;
1520 maItemListeners.addInterface( l );
1523 void VCLXListBox::removeItemListener( const css::uno::Reference< css::awt::XItemListener > & l ) throw(css::uno::RuntimeException, std::exception)
1525 SolarMutexGuard aGuard;
1526 maItemListeners.removeInterface( l );
1529 void VCLXListBox::addActionListener( const css::uno::Reference< css::awt::XActionListener > & l ) throw(css::uno::RuntimeException, std::exception)
1531 SolarMutexGuard aGuard;
1532 maActionListeners.addInterface( l );
1535 void VCLXListBox::removeActionListener( const css::uno::Reference< css::awt::XActionListener > & l ) throw(css::uno::RuntimeException, std::exception)
1537 SolarMutexGuard aGuard;
1538 maActionListeners.removeInterface( l );
1541 void VCLXListBox::addItem( const OUString& aItem, sal_Int16 nPos ) throw(css::uno::RuntimeException, std::exception)
1543 SolarMutexGuard aGuard;
1544 VclPtr< ListBox > pBox = GetAs< ListBox >();
1545 if ( pBox )
1546 pBox->InsertEntry( aItem, nPos );
1549 void VCLXListBox::addItems( const css::uno::Sequence< OUString>& aItems, sal_Int16 nPos ) throw(css::uno::RuntimeException, std::exception)
1551 SolarMutexGuard aGuard;
1552 VclPtr< ListBox > pBox = GetAs< ListBox >();
1553 if ( pBox )
1555 sal_uInt16 nP = nPos;
1556 const OUString* pItems = aItems.getConstArray();
1557 const OUString* pItemsEnd = aItems.getConstArray() + aItems.getLength();
1558 while ( pItems != pItemsEnd )
1560 if ( (sal_uInt16)nP == 0xFFFF )
1562 OSL_FAIL( "VCLXListBox::addItems: too many entries!" );
1563 // skip remaining entries, list cannot hold them, anyway
1564 break;
1567 pBox->InsertEntry( *pItems++, nP++ );
1572 void VCLXListBox::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(css::uno::RuntimeException, std::exception)
1574 SolarMutexGuard aGuard;
1575 VclPtr< ListBox > pBox = GetAs< ListBox >();
1576 if ( pBox )
1578 for ( sal_Int16 n = nCount; n; )
1579 pBox->RemoveEntry( nPos + (--n) );
1583 sal_Int16 VCLXListBox::getItemCount() throw(css::uno::RuntimeException, std::exception)
1585 SolarMutexGuard aGuard;
1587 VclPtr< ListBox > pBox = GetAs< ListBox >();
1588 return pBox ? pBox->GetEntryCount() : 0;
1591 OUString VCLXListBox::getItem( sal_Int16 nPos ) throw(css::uno::RuntimeException, std::exception)
1593 SolarMutexGuard aGuard;
1595 OUString aItem;
1596 VclPtr< ListBox > pBox = GetAs< ListBox >();
1597 if ( pBox )
1598 aItem = pBox->GetEntry( nPos );
1599 return aItem;
1602 css::uno::Sequence< OUString> VCLXListBox::getItems() throw(css::uno::RuntimeException, std::exception)
1604 SolarMutexGuard aGuard;
1606 css::uno::Sequence< OUString> aSeq;
1607 VclPtr< ListBox > pBox = GetAs< ListBox >();
1608 if ( pBox )
1610 auto n = pBox->GetEntryCount();
1611 aSeq = css::uno::Sequence< OUString>( n );
1612 while (n)
1614 --n;
1615 aSeq.getArray()[n] = pBox->GetEntry( n );
1618 return aSeq;
1621 sal_Int16 VCLXListBox::getSelectedItemPos() throw(css::uno::RuntimeException, std::exception)
1623 SolarMutexGuard aGuard;
1624 VclPtr< ListBox > pBox = GetAs< ListBox >();
1625 return pBox ? pBox->GetSelectEntryPos() : 0;
1628 css::uno::Sequence<sal_Int16> VCLXListBox::getSelectedItemsPos() throw(css::uno::RuntimeException, std::exception)
1630 SolarMutexGuard aGuard;
1632 css::uno::Sequence<sal_Int16> aSeq;
1633 VclPtr< ListBox > pBox = GetAs< ListBox >();
1634 if ( pBox )
1636 const sal_Int32 nSelEntries = pBox->GetSelectEntryCount();
1637 aSeq = css::uno::Sequence<sal_Int16>( nSelEntries );
1638 for ( sal_Int32 n = 0; n < nSelEntries; ++n )
1639 aSeq.getArray()[n] = pBox->GetSelectEntryPos( n );
1641 return aSeq;
1644 OUString VCLXListBox::getSelectedItem() throw(css::uno::RuntimeException, std::exception)
1646 SolarMutexGuard aGuard;
1648 OUString aItem;
1649 VclPtr< ListBox > pBox = GetAs< ListBox >();
1650 if ( pBox )
1651 aItem = pBox->GetSelectEntry();
1652 return aItem;
1655 css::uno::Sequence< OUString> VCLXListBox::getSelectedItems() throw(css::uno::RuntimeException, std::exception)
1657 SolarMutexGuard aGuard;
1659 css::uno::Sequence< OUString> aSeq;
1660 VclPtr< ListBox > pBox = GetAs< ListBox >();
1661 if ( pBox )
1663 const sal_Int32 nSelEntries = pBox->GetSelectEntryCount();
1664 aSeq = css::uno::Sequence< OUString>( nSelEntries );
1665 for ( sal_Int32 n = 0; n < nSelEntries; ++n )
1666 aSeq.getArray()[n] = pBox->GetSelectEntry( n );
1668 return aSeq;
1671 void VCLXListBox::selectItemPos( sal_Int16 nPos, sal_Bool bSelect ) throw(css::uno::RuntimeException, std::exception)
1673 SolarMutexGuard aGuard;
1675 VclPtr< ListBox > pBox = GetAs< ListBox >();
1676 if ( pBox && ( pBox->IsEntryPosSelected( nPos ) != bool(bSelect) ) )
1678 pBox->SelectEntryPos( nPos, bSelect );
1680 // VCL doesn't call select handler after API call.
1681 // ImplCallItemListeners();
1683 // #107218# Call same listeners like VCL would do after user interaction
1684 SetSynthesizingVCLEvent( true );
1685 pBox->Select();
1686 SetSynthesizingVCLEvent( false );
1690 void VCLXListBox::selectItemsPos( const css::uno::Sequence<sal_Int16>& aPositions, sal_Bool bSelect ) throw(css::uno::RuntimeException, std::exception)
1692 SolarMutexGuard aGuard;
1694 VclPtr< ListBox > pBox = GetAs< ListBox >();
1695 if ( pBox )
1697 bool bChanged = false;
1698 for ( auto n = aPositions.getLength(); n; )
1700 const auto nPos = aPositions.getConstArray()[--n];
1701 if ( pBox->IsEntryPosSelected( nPos ) != bool(bSelect) )
1703 pBox->SelectEntryPos( nPos, bSelect );
1704 bChanged = true;
1708 if ( bChanged )
1710 // VCL doesn't call select handler after API call.
1711 // ImplCallItemListeners();
1713 // #107218# Call same listeners like VCL would do after user interaction
1714 SetSynthesizingVCLEvent( true );
1715 pBox->Select();
1716 SetSynthesizingVCLEvent( false );
1721 void VCLXListBox::selectItem( const OUString& rItemText, sal_Bool bSelect ) throw(css::uno::RuntimeException, std::exception)
1723 SolarMutexGuard aGuard;
1725 VclPtr< ListBox > pBox = GetAs< ListBox >();
1726 if ( pBox )
1728 selectItemPos( pBox->GetEntryPos( rItemText ), bSelect );
1732 void VCLXListBox::setDropDownLineCount( sal_Int16 nLines ) throw(css::uno::RuntimeException, std::exception)
1734 SolarMutexGuard aGuard;
1735 VclPtr< ListBox > pBox = GetAs< ListBox >();
1736 if ( pBox )
1737 pBox->SetDropDownLineCount( nLines );
1740 sal_Int16 VCLXListBox::getDropDownLineCount() throw(css::uno::RuntimeException, std::exception)
1742 SolarMutexGuard aGuard;
1744 sal_Int16 nLines = 0;
1745 VclPtr< ListBox > pBox = GetAs< ListBox >();
1746 if ( pBox )
1747 nLines = pBox->GetDropDownLineCount();
1748 return nLines;
1751 sal_Bool VCLXListBox::isMutipleMode() throw(css::uno::RuntimeException, std::exception)
1753 SolarMutexGuard aGuard;
1754 bool bMulti = false;
1755 VclPtr< ListBox > pBox = GetAs< ListBox >();
1756 if ( pBox )
1757 bMulti = pBox->IsMultiSelectionEnabled();
1758 return bMulti;
1761 void VCLXListBox::setMultipleMode( sal_Bool bMulti ) throw(css::uno::RuntimeException, std::exception)
1763 SolarMutexGuard aGuard;
1764 VclPtr< ListBox > pBox = GetAs< ListBox >();
1765 if ( pBox )
1766 pBox->EnableMultiSelection( bMulti );
1769 void VCLXListBox::makeVisible( sal_Int16 nEntry ) throw(css::uno::RuntimeException, std::exception)
1771 SolarMutexGuard aGuard;
1772 VclPtr< ListBox > pBox = GetAs< ListBox >();
1773 if ( pBox )
1774 pBox->SetTopEntry( nEntry );
1777 void VCLXListBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1779 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
1780 // since we call listeners below, there is a potential that we will be destroyed
1781 // in during the listener call. To prevent the resulting crashs, we keep us
1782 // alive as long as we're here
1784 switch ( rVclWindowEvent.GetId() )
1786 case VCLEVENT_LISTBOX_SELECT:
1788 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1789 if( pListBox )
1791 bool bDropDown = ( pListBox->GetStyle() & WB_DROPDOWN ) != 0;
1792 if ( bDropDown && !IsSynthesizingVCLEvent() && maActionListeners.getLength() )
1794 // Call ActionListener on DropDown event
1795 css::awt::ActionEvent aEvent;
1796 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
1797 aEvent.ActionCommand = pListBox->GetSelectEntry();
1798 maActionListeners.actionPerformed( aEvent );
1801 if ( maItemListeners.getLength() )
1803 ImplCallItemListeners();
1807 break;
1809 case VCLEVENT_LISTBOX_DOUBLECLICK:
1810 if ( GetWindow() && maActionListeners.getLength() )
1812 css::awt::ActionEvent aEvent;
1813 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
1814 aEvent.ActionCommand = GetAs<ListBox>()->GetSelectEntry();
1815 maActionListeners.actionPerformed( aEvent );
1817 break;
1819 default:
1820 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
1821 break;
1825 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXListBox::CreateAccessibleContext()
1827 SolarMutexGuard aGuard;
1829 return getAccessibleFactory().createAccessibleContext( this );
1832 void VCLXListBox::setProperty( const OUString& PropertyName, const css::uno::Any& Value) throw(css::uno::RuntimeException, std::exception)
1834 SolarMutexGuard aGuard;
1835 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1836 if ( pListBox )
1838 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1839 switch ( nPropType )
1841 case BASEPROPERTY_ITEM_SEPARATOR_POS:
1843 sal_Int16 nSeparatorPos(0);
1844 if ( Value >>= nSeparatorPos )
1845 pListBox->SetSeparatorPos( nSeparatorPos );
1847 break;
1848 case BASEPROPERTY_READONLY:
1850 bool b = bool();
1851 if ( Value >>= b )
1852 pListBox->SetReadOnly( b);
1854 break;
1855 case BASEPROPERTY_MULTISELECTION:
1857 bool b = bool();
1858 if ( Value >>= b )
1859 pListBox->EnableMultiSelection( b );
1861 break;
1862 case BASEPROPERTY_MULTISELECTION_SIMPLEMODE:
1863 ::toolkit::adjustBooleanWindowStyle( Value, pListBox, WB_SIMPLEMODE, false );
1864 break;
1865 case BASEPROPERTY_LINECOUNT:
1867 sal_Int16 n = sal_Int16();
1868 if ( Value >>= n )
1869 pListBox->SetDropDownLineCount( n );
1871 break;
1872 case BASEPROPERTY_STRINGITEMLIST:
1874 css::uno::Sequence< OUString> aItems;
1875 if ( Value >>= aItems )
1877 pListBox->Clear();
1878 addItems( aItems, 0 );
1881 break;
1882 case BASEPROPERTY_SELECTEDITEMS:
1884 css::uno::Sequence<sal_Int16> aItems;
1885 if ( Value >>= aItems )
1887 for ( auto n = pListBox->GetEntryCount(); n; )
1888 pListBox->SelectEntryPos( --n, false );
1890 if ( aItems.getLength() )
1891 selectItemsPos( aItems, true );
1892 else
1893 pListBox->SetNoSelection();
1895 if ( !pListBox->GetSelectEntryCount() )
1896 pListBox->SetTopEntry( 0 );
1899 break;
1900 default:
1902 VCLXWindow::setProperty( PropertyName, Value );
1908 css::uno::Any VCLXListBox::getProperty( const OUString& PropertyName ) throw(css::uno::RuntimeException, std::exception)
1910 SolarMutexGuard aGuard;
1911 css::uno::Any aProp;
1912 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1913 if ( pListBox )
1915 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1916 switch ( nPropType )
1918 case BASEPROPERTY_ITEM_SEPARATOR_POS:
1919 aProp <<= sal_Int16( pListBox->GetSeparatorPos() );
1920 break;
1921 case BASEPROPERTY_READONLY:
1923 aProp <<= pListBox->IsReadOnly();
1925 break;
1926 case BASEPROPERTY_MULTISELECTION:
1928 aProp <<= pListBox->IsMultiSelectionEnabled();
1930 break;
1931 case BASEPROPERTY_MULTISELECTION_SIMPLEMODE:
1933 aProp <<= ( ( pListBox->GetStyle() & WB_SIMPLEMODE ) == 0 );
1935 break;
1936 case BASEPROPERTY_LINECOUNT:
1938 aProp <<= (sal_Int16) pListBox->GetDropDownLineCount();
1940 break;
1941 case BASEPROPERTY_STRINGITEMLIST:
1943 const sal_Int32 nItems = pListBox->GetEntryCount();
1944 css::uno::Sequence< OUString> aSeq( nItems );
1945 OUString* pStrings = aSeq.getArray();
1946 for ( sal_Int32 n = 0; n < nItems; ++n )
1947 pStrings[n] = pListBox->GetEntry( n );
1948 aProp <<= aSeq;
1951 break;
1952 default:
1954 aProp <<= VCLXWindow::getProperty( PropertyName );
1958 return aProp;
1961 css::awt::Size VCLXListBox::getMinimumSize( ) throw(css::uno::RuntimeException, std::exception)
1963 SolarMutexGuard aGuard;
1964 Size aSz;
1965 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1966 if ( pListBox )
1967 aSz = pListBox->CalcMinimumSize();
1968 return AWTSize(aSz);
1971 css::awt::Size VCLXListBox::getPreferredSize( ) throw(css::uno::RuntimeException, std::exception)
1973 SolarMutexGuard aGuard;
1974 Size aSz;
1975 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1976 if ( pListBox )
1978 aSz = pListBox->CalcMinimumSize();
1979 if ( pListBox->GetStyle() & WB_DROPDOWN )
1980 aSz.Height() += 4;
1982 return AWTSize(aSz);
1985 css::awt::Size VCLXListBox::calcAdjustedSize( const css::awt::Size& rNewSize ) throw(css::uno::RuntimeException, std::exception)
1987 SolarMutexGuard aGuard;
1988 Size aSz = VCLSize(rNewSize);
1989 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1990 if ( pListBox )
1991 aSz = pListBox->CalcAdjustedSize( aSz );
1992 return AWTSize(aSz);
1995 css::awt::Size VCLXListBox::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(css::uno::RuntimeException, std::exception)
1997 SolarMutexGuard aGuard;
1998 Size aSz;
1999 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2000 if ( pListBox )
2001 aSz = pListBox->CalcBlockSize( nCols, nLines );
2002 return AWTSize(aSz);
2005 void VCLXListBox::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(css::uno::RuntimeException, std::exception)
2007 SolarMutexGuard aGuard;
2008 nCols = nLines = 0;
2009 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2010 if ( pListBox )
2012 sal_uInt16 nC, nL;
2013 pListBox->GetMaxVisColumnsAndLines( nC, nL );
2014 nCols = nC;
2015 nLines = nL;
2019 void VCLXListBox::ImplCallItemListeners()
2021 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2022 if ( pListBox && maItemListeners.getLength() )
2024 css::awt::ItemEvent aEvent;
2025 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
2026 aEvent.Highlighted = 0;
2028 // Set to 0xFFFF on multiple selection, selected entry ID otherwise
2029 aEvent.Selected = (pListBox->GetSelectEntryCount() == 1 ) ? pListBox->GetSelectEntryPos() : 0xFFFF;
2031 maItemListeners.itemStateChanged( aEvent );
2034 namespace
2036 Image lcl_getImageFromURL( const OUString& i_rImageURL )
2038 if ( i_rImageURL.isEmpty() )
2039 return Image();
2043 Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
2044 Reference< XGraphicProvider > xProvider(graphic::GraphicProvider::create(xContext));
2045 ::comphelper::NamedValueCollection aMediaProperties;
2046 aMediaProperties.put( "URL", i_rImageURL );
2047 Reference< XGraphic > xGraphic = xProvider->queryGraphic( aMediaProperties.getPropertyValues() );
2048 return Image( xGraphic );
2050 catch( const uno::Exception& )
2052 DBG_UNHANDLED_EXCEPTION();
2054 return Image();
2057 void SAL_CALL VCLXListBox::listItemInserted( const ItemListEvent& i_rEvent ) throw (RuntimeException, std::exception)
2059 SolarMutexGuard aGuard;
2060 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2062 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemInserted: no ListBox?!" );
2063 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition <= sal_Int32( pListBox->GetEntryCount() ) ),
2064 "VCLXListBox::listItemInserted: illegal (inconsistent) item position!" );
2065 pListBox->InsertEntry(
2066 i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : OUString(),
2067 i_rEvent.ItemImageURL.IsPresent ? TkResMgr::getImageFromURL( i_rEvent.ItemImageURL.Value ) : Image(),
2068 i_rEvent.ItemPosition );
2071 void SAL_CALL VCLXListBox::listItemRemoved( const ItemListEvent& i_rEvent ) throw (RuntimeException, std::exception)
2073 SolarMutexGuard aGuard;
2074 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2076 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemRemoved: no ListBox?!" );
2077 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pListBox->GetEntryCount() ) ),
2078 "VCLXListBox::listItemRemoved: illegal (inconsistent) item position!" );
2080 pListBox->RemoveEntry( i_rEvent.ItemPosition );
2083 void SAL_CALL VCLXListBox::listItemModified( const ItemListEvent& i_rEvent ) throw (RuntimeException, std::exception)
2085 SolarMutexGuard aGuard;
2086 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2088 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" );
2089 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pListBox->GetEntryCount() ) ),
2090 "VCLXListBox::listItemModified: illegal (inconsistent) item position!" );
2092 // VCL's ListBox does not support changing an entry's text or image, so remove and re-insert
2094 const OUString sNewText = i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : OUString( pListBox->GetEntry( i_rEvent.ItemPosition ) );
2095 const Image aNewImage( i_rEvent.ItemImageURL.IsPresent ? TkResMgr::getImageFromURL( i_rEvent.ItemImageURL.Value ) : pListBox->GetEntryImage( i_rEvent.ItemPosition ) );
2097 pListBox->RemoveEntry( i_rEvent.ItemPosition );
2098 pListBox->InsertEntry( sNewText, aNewImage, i_rEvent.ItemPosition );
2101 void SAL_CALL VCLXListBox::allItemsRemoved( const EventObject& i_rEvent ) throw (RuntimeException, std::exception)
2103 SolarMutexGuard aGuard;
2105 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2106 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" );
2108 pListBox->Clear();
2110 (void)i_rEvent;
2113 void SAL_CALL VCLXListBox::itemListChanged( const EventObject& i_rEvent ) throw (RuntimeException, std::exception)
2115 SolarMutexGuard aGuard;
2117 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2118 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" );
2120 pListBox->Clear();
2122 uno::Reference< beans::XPropertySet > xPropSet( i_rEvent.Source, uno::UNO_QUERY_THROW );
2123 uno::Reference< beans::XPropertySetInfo > xPSI( xPropSet->getPropertySetInfo(), uno::UNO_QUERY_THROW );
2124 uno::Reference< resource::XStringResourceResolver > xStringResourceResolver;
2125 if ( xPSI->hasPropertyByName("ResourceResolver") )
2127 xStringResourceResolver.set(
2128 xPropSet->getPropertyValue("ResourceResolver"),
2129 uno::UNO_QUERY
2134 Reference< XItemList > xItemList( i_rEvent.Source, uno::UNO_QUERY_THROW );
2135 uno::Sequence< beans::Pair< OUString, OUString > > aItems = xItemList->getAllItems();
2136 for ( sal_Int32 i=0; i<aItems.getLength(); ++i )
2138 OUString aLocalizationKey( aItems[i].First );
2139 if ( xStringResourceResolver.is() && aLocalizationKey.startsWith("&") )
2141 aLocalizationKey = xStringResourceResolver->resolveString(aLocalizationKey.copy( 1 ));
2143 pListBox->InsertEntry( aLocalizationKey, lcl_getImageFromURL( aItems[i].Second ) );
2147 void SAL_CALL VCLXListBox::disposing( const EventObject& i_rEvent ) throw (RuntimeException, std::exception)
2149 // just disambiguate
2150 VCLXWindow::disposing( i_rEvent );
2154 // class VCLXMessageBox
2157 void VCLXMessageBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2159 VCLXTopWindow::ImplGetPropertyIds( rIds );
2162 VCLXMessageBox::VCLXMessageBox()
2166 VCLXMessageBox::~VCLXMessageBox()
2170 // css::uno::XInterface
2171 css::uno::Any VCLXMessageBox::queryInterface( const css::uno::Type & rType ) throw(css::uno::RuntimeException, std::exception)
2173 css::uno::Any aRet = ::cppu::queryInterface( rType,
2174 (static_cast< css::awt::XMessageBox* >(this)) );
2175 return (aRet.hasValue() ? aRet : VCLXTopWindow::queryInterface( rType ));
2178 // css::lang::XTypeProvider
2179 IMPL_XTYPEPROVIDER_START( VCLXMessageBox )
2180 cppu::UnoType<css::awt::XMessageBox>::get(),
2181 VCLXTopWindow::getTypes()
2182 IMPL_XTYPEPROVIDER_END
2184 void VCLXMessageBox::setCaptionText( const OUString& rText ) throw(css::uno::RuntimeException, std::exception)
2186 SolarMutexGuard aGuard;
2188 vcl::Window* pWindow = GetWindow();
2189 if ( pWindow )
2190 pWindow->SetText( rText );
2193 OUString VCLXMessageBox::getCaptionText() throw(css::uno::RuntimeException, std::exception)
2195 SolarMutexGuard aGuard;
2197 OUString aText;
2198 vcl::Window* pWindow = GetWindow();
2199 if ( pWindow )
2200 aText = pWindow->GetText();
2201 return aText;
2204 void VCLXMessageBox::setMessageText( const OUString& rText ) throw(css::uno::RuntimeException, std::exception)
2206 SolarMutexGuard aGuard;
2207 VclPtr< MessBox > pBox = GetAs< MessBox >();
2208 if ( pBox )
2209 pBox->SetMessText( rText );
2212 OUString VCLXMessageBox::getMessageText() throw(css::uno::RuntimeException, std::exception)
2214 SolarMutexGuard aGuard;
2215 OUString aText;
2216 VclPtr< MessBox > pBox = GetAs< MessBox >();
2217 if ( pBox )
2218 aText = pBox->GetMessText();
2219 return aText;
2222 sal_Int16 VCLXMessageBox::execute() throw(css::uno::RuntimeException, std::exception)
2224 SolarMutexGuard aGuard;
2225 VclPtr< MessBox > pBox = GetAs< MessBox >();
2226 return pBox ? pBox->Execute() : 0;
2229 css::awt::Size SAL_CALL VCLXMessageBox::getMinimumSize() throw(css::uno::RuntimeException, std::exception)
2231 SolarMutexGuard aGuard;
2232 return css::awt::Size( 250, 100 );
2236 // class VCLXDialog
2238 void VCLXDialog::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2240 VCLXTopWindow::ImplGetPropertyIds( rIds );
2243 VCLXDialog::VCLXDialog()
2245 OSL_TRACE("XDialog created");
2248 VCLXDialog::~VCLXDialog()
2250 OSL_TRACE ("%s", __FUNCTION__);
2253 // css::uno::XInterface
2254 css::uno::Any VCLXDialog::queryInterface( const css::uno::Type & rType ) throw(css::uno::RuntimeException, std::exception)
2256 css::uno::Any aRet = ::cppu::queryInterface( rType,
2257 (static_cast< css::awt::XDialog2* >(this)),
2258 (static_cast< css::awt::XDialog* >(this)) );
2259 return (aRet.hasValue() ? aRet : VCLXTopWindow::queryInterface( rType ));
2262 // css::lang::XTypeProvider
2263 IMPL_XTYPEPROVIDER_START( VCLXDialog )
2264 cppu::UnoType<css::awt::XDialog2>::get(),
2265 cppu::UnoType<css::awt::XDialog>::get(),
2266 VCLXTopWindow::getTypes()
2267 IMPL_XTYPEPROVIDER_END
2269 void SAL_CALL VCLXDialog::endDialog( ::sal_Int32 i_result ) throw (RuntimeException, std::exception)
2271 SolarMutexGuard aGuard;
2272 VclPtr<Dialog> pDialog = GetAsDynamic< Dialog >();
2273 if ( pDialog )
2274 pDialog->EndDialog( i_result );
2277 void SAL_CALL VCLXDialog::setHelpId( const OUString& rId ) throw (RuntimeException, std::exception)
2279 SolarMutexGuard aGuard;
2280 VclPtr< vcl::Window > pWindow = GetWindow();
2281 if ( pWindow )
2282 pWindow->SetHelpId( OUStringToOString( rId, RTL_TEXTENCODING_UTF8 ) );
2285 void VCLXDialog::setTitle( const OUString& Title ) throw(css::uno::RuntimeException, std::exception)
2287 SolarMutexGuard aGuard;
2288 VclPtr< vcl::Window > pWindow = GetWindow();
2289 if ( pWindow )
2290 pWindow->SetText( Title );
2293 OUString VCLXDialog::getTitle() throw(css::uno::RuntimeException, std::exception)
2295 SolarMutexGuard aGuard;
2297 OUString aTitle;
2298 VclPtr< vcl::Window > pWindow = GetWindow();
2299 if ( pWindow )
2300 aTitle = pWindow->GetText();
2301 return aTitle;
2304 sal_Int16 VCLXDialog::execute() throw(css::uno::RuntimeException, std::exception)
2306 SolarMutexGuard aGuard;
2308 sal_Int16 nRet = 0;
2309 if ( GetWindow() )
2311 VclPtr< Dialog > pDlg = GetAs< Dialog >();
2312 vcl::Window* pParent = pDlg->GetWindow( GetWindowType::ParentOverlap );
2313 vcl::Window* pOldParent = nullptr;
2314 vcl::Window* pSetParent = nullptr;
2315 if ( pParent && !pParent->IsReallyVisible() )
2317 pOldParent = pDlg->GetParent();
2318 vcl::Window* pFrame = pDlg->GetWindow( GetWindowType::Frame );
2319 if( pFrame != pDlg )
2321 pDlg->SetParent( pFrame );
2322 pSetParent = pFrame;
2326 nRet = pDlg->Execute();
2328 // set the parent back only in case no new parent was set from outside
2329 // in other words, revert only own changes
2330 if ( pOldParent && pDlg->GetParent() == pSetParent )
2331 pDlg->SetParent( pOldParent );
2333 return nRet;
2336 void VCLXDialog::endExecute() throw(css::uno::RuntimeException, std::exception)
2338 endDialog(0);
2341 void SAL_CALL VCLXDialog::draw( sal_Int32 nX, sal_Int32 nY ) throw(css::uno::RuntimeException, std::exception)
2343 SolarMutexGuard aGuard;
2344 VclPtr< vcl::Window > pWindow = GetWindow();
2345 if ( pWindow )
2347 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
2348 if ( !pDev )
2349 pDev = pWindow->GetParent();
2351 Size aSize = pDev->PixelToLogic( pWindow->GetSizePixel() );
2352 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
2354 pWindow->Draw( pDev, aPos, aSize, DrawFlags::NoControls );
2358 css::awt::DeviceInfo VCLXDialog::getInfo() throw(css::uno::RuntimeException, std::exception)
2360 css::awt::DeviceInfo aInfo = VCLXDevice::getInfo();
2362 SolarMutexGuard aGuard;
2363 VclPtr< Dialog > pDlg = GetAs< Dialog >();
2364 if ( pDlg )
2365 pDlg->GetDrawWindowBorder( aInfo.LeftInset, aInfo.TopInset, aInfo.RightInset, aInfo.BottomInset );
2367 return aInfo;
2370 void SAL_CALL VCLXDialog::setProperty(
2371 const OUString& PropertyName,
2372 const css::uno::Any& Value )
2373 throw(css::uno::RuntimeException, std::exception)
2375 SolarMutexGuard aGuard;
2376 VclPtr< Dialog > pDialog = GetAs< Dialog >();
2377 if ( pDialog )
2379 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
2381 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2382 switch ( nPropType )
2384 case BASEPROPERTY_GRAPHIC:
2386 Reference< XGraphic > xGraphic;
2387 if (( Value >>= xGraphic ) && xGraphic.is() )
2389 Image aImage( xGraphic );
2391 Wallpaper aWallpaper( aImage.GetBitmapEx());
2392 aWallpaper.SetStyle( WallpaperStyle::Scale );
2393 pDialog->SetBackground( aWallpaper );
2395 else if ( bVoid || !xGraphic.is() )
2397 Color aColor = pDialog->GetControlBackground().GetColor();
2398 if ( aColor == COL_AUTO )
2399 aColor = pDialog->GetSettings().GetStyleSettings().GetDialogColor();
2401 Wallpaper aWallpaper( aColor );
2402 pDialog->SetBackground( aWallpaper );
2405 break;
2407 default:
2409 VCLXContainer::setProperty( PropertyName, Value );
2416 // class VCLXTabPage
2418 VCLXMultiPage::VCLXMultiPage() : maTabListeners( *this ), mTabId( 1 )
2420 OSL_TRACE("VCLXMultiPage::VCLXMultiPage()" );
2423 void VCLXMultiPage::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2425 PushPropertyIds( rIds,
2426 BASEPROPERTY_BACKGROUNDCOLOR,
2427 BASEPROPERTY_DEFAULTCONTROL,
2428 BASEPROPERTY_ENABLED,
2429 BASEPROPERTY_MULTIPAGEVALUE,
2430 BASEPROPERTY_ENABLEVISIBLE,
2431 BASEPROPERTY_FONTDESCRIPTOR,
2432 BASEPROPERTY_GRAPHIC,
2433 BASEPROPERTY_HELPTEXT,
2434 BASEPROPERTY_HELPURL,
2435 BASEPROPERTY_IMAGEALIGN,
2436 BASEPROPERTY_IMAGEPOSITION,
2437 BASEPROPERTY_IMAGEURL,
2438 BASEPROPERTY_PRINTABLE,
2439 BASEPROPERTY_TABSTOP,
2440 BASEPROPERTY_FOCUSONCLICK,
2442 VCLXContainer::ImplGetPropertyIds( rIds );
2445 VCLXMultiPage::~VCLXMultiPage()
2448 void SAL_CALL VCLXMultiPage::dispose() throw(css::uno::RuntimeException, std::exception)
2450 SolarMutexGuard aGuard;
2452 css::lang::EventObject aObj;
2453 aObj.Source = static_cast<cppu::OWeakObject*>(this);
2454 maTabListeners.disposeAndClear( aObj );
2455 VCLXContainer::dispose();
2457 css::uno::Any SAL_CALL VCLXMultiPage::queryInterface(const css::uno::Type & rType )
2458 throw(css::uno::RuntimeException, std::exception)
2460 uno::Any aRet = ::cppu::queryInterface( rType, static_cast< awt::XSimpleTabController*>( this ) );
2462 return ( aRet.hasValue() ? aRet : VCLXContainer::queryInterface( rType ) );
2465 // css::lang::XTypeProvider
2466 IMPL_XTYPEPROVIDER_START( VCLXMultiPage )
2467 VCLXContainer::getTypes()
2468 IMPL_XTYPEPROVIDER_END
2470 // css::awt::XView
2471 void SAL_CALL VCLXMultiPage::draw( sal_Int32 nX, sal_Int32 nY )
2472 throw(css::uno::RuntimeException, std::exception)
2474 SolarMutexGuard aGuard;
2475 VclPtr< vcl::Window > pWindow = GetWindow();
2477 if ( pWindow )
2479 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
2480 if ( !pDev )
2481 pDev = pWindow->GetParent();
2483 Size aSize = pDev->PixelToLogic( pWindow->GetSizePixel() );
2484 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
2486 pWindow->Draw( pDev, aPos, aSize, DrawFlags::NoControls );
2490 // css::awt::XDevice,
2491 css::awt::DeviceInfo SAL_CALL VCLXMultiPage::getInfo()
2492 throw(css::uno::RuntimeException, std::exception)
2494 css::awt::DeviceInfo aInfo = VCLXDevice::getInfo();
2495 return aInfo;
2498 uno::Any SAL_CALL VCLXMultiPage::getProperty( const OUString& PropertyName ) throw(css::uno::RuntimeException, std::exception)
2500 SolarMutexGuard aGuard;
2501 OSL_TRACE(" **** VCLXMultiPage::getProperty( %s )",
2502 OUStringToOString( PropertyName,
2503 RTL_TEXTENCODING_UTF8 ).getStr() );
2504 css::uno::Any aProp;
2505 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2506 switch ( nPropType )
2509 case BASEPROPERTY_MULTIPAGEVALUE:
2511 aProp <<= getActiveTabID();
2513 break;
2514 default:
2515 aProp <<= VCLXContainer::getProperty( PropertyName );
2517 return aProp;
2520 void SAL_CALL VCLXMultiPage::setProperty(
2521 const OUString& PropertyName,
2522 const css::uno::Any& Value )
2523 throw(css::uno::RuntimeException, std::exception)
2525 SolarMutexGuard aGuard;
2526 OSL_TRACE(" **** VCLXMultiPage::setProperty( %s )", OUStringToOString( PropertyName, RTL_TEXTENCODING_UTF8 ).getStr() );
2528 VclPtr< TabControl > pTabControl = GetAs< TabControl >();
2529 if ( pTabControl )
2531 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
2533 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2534 switch ( nPropType )
2536 case BASEPROPERTY_MULTIPAGEVALUE:
2538 OSL_TRACE("***MULTIPAGE VALUE");
2539 sal_Int32 nId(0);
2540 Value >>= nId;
2541 // when the multipage is created we attempt to set the activepage
2542 // but no pages created
2543 if ( nId && nId <= getWindows().getLength() )
2544 activateTab( nId );
2545 break;
2547 case BASEPROPERTY_GRAPHIC:
2549 Reference< XGraphic > xGraphic;
2550 if (( Value >>= xGraphic ) && xGraphic.is() )
2552 Image aImage( xGraphic );
2554 Wallpaper aWallpaper( aImage.GetBitmapEx());
2555 aWallpaper.SetStyle( WallpaperStyle::Scale );
2556 pTabControl->SetBackground( aWallpaper );
2558 else if ( bVoid || !xGraphic.is() )
2560 Color aColor = pTabControl->GetControlBackground().GetColor();
2561 if ( aColor == COL_AUTO )
2562 aColor = pTabControl->GetSettings().GetStyleSettings().GetDialogColor();
2564 Wallpaper aWallpaper( aColor );
2565 pTabControl->SetBackground( aWallpaper );
2568 break;
2570 default:
2572 VCLXContainer::setProperty( PropertyName, Value );
2578 TabControl *VCLXMultiPage::getTabControl() const throw (uno::RuntimeException)
2580 VclPtr<TabControl> pTabControl = GetAsDynamic< TabControl >();
2581 if ( pTabControl )
2582 return pTabControl;
2583 throw uno::RuntimeException();
2585 sal_Int32 SAL_CALL VCLXMultiPage::insertTab() throw (uno::RuntimeException, std::exception)
2587 TabControl *pTabControl = getTabControl();
2588 VclPtrInstance<TabPage> pTab( pTabControl );
2589 OUString title ("");
2590 return static_cast< sal_Int32 >( insertTab( pTab, title ) );
2593 sal_uInt16 VCLXMultiPage::insertTab( TabPage* pPage, OUString& sTitle )
2595 TabControl *pTabControl = getTabControl();
2596 sal_uInt16 id = sal::static_int_cast< sal_uInt16 >( mTabId++ );
2597 pTabControl->InsertPage( id, sTitle );
2598 pTabControl->SetTabPage( id, pPage );
2599 return id;
2602 void SAL_CALL VCLXMultiPage::removeTab( sal_Int32 ID ) throw (uno::RuntimeException, lang::IndexOutOfBoundsException, std::exception)
2604 TabControl *pTabControl = getTabControl();
2605 if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == nullptr )
2606 throw lang::IndexOutOfBoundsException();
2607 pTabControl->RemovePage( sal::static_int_cast< sal_uInt16 >( ID ) );
2610 void SAL_CALL VCLXMultiPage::activateTab( sal_Int32 ID ) throw (uno::RuntimeException, lang::IndexOutOfBoundsException, std::exception)
2612 TabControl *pTabControl = getTabControl();
2613 SAL_INFO(
2614 "toolkit",
2615 "Attempting to activate tab " << ID << ", active tab is "
2616 << getActiveTabID() << ", numtabs is " << getWindows().getLength());
2617 if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == nullptr )
2618 throw lang::IndexOutOfBoundsException();
2619 pTabControl->SelectTabPage( sal::static_int_cast< sal_uInt16 >( ID ) );
2622 sal_Int32 SAL_CALL VCLXMultiPage::getActiveTabID() throw (uno::RuntimeException, std::exception)
2624 return getTabControl()->GetCurPageId( );
2627 void SAL_CALL VCLXMultiPage::addTabListener( const uno::Reference< awt::XTabListener >& xListener ) throw (uno::RuntimeException, std::exception)
2629 SolarMutexGuard aGuard;
2630 maTabListeners.addInterface( xListener );
2633 void SAL_CALL VCLXMultiPage::removeTabListener( const uno::Reference< awt::XTabListener >& xListener ) throw (uno::RuntimeException, std::exception)
2635 SolarMutexGuard aGuard;
2636 maTabListeners.addInterface( xListener );
2639 void SAL_CALL VCLXMultiPage::setTabProps( sal_Int32 ID, const uno::Sequence< beans::NamedValue >& Properties ) throw (uno::RuntimeException, lang::IndexOutOfBoundsException, std::exception)
2641 SolarMutexGuard aGuard;
2642 TabControl *pTabControl = getTabControl();
2643 if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == nullptr )
2644 throw lang::IndexOutOfBoundsException();
2646 for (sal_Int32 i = 0; i < Properties.getLength(); ++i)
2648 const OUString &name = Properties[i].Name;
2649 const uno::Any &value = Properties[i].Value;
2651 if (name == "Title")
2653 OUString title = value.get<OUString>();
2654 pTabControl->SetPageText( sal::static_int_cast< sal_uInt16 >( ID ), title );
2659 uno::Sequence< beans::NamedValue > SAL_CALL VCLXMultiPage::getTabProps( sal_Int32 ID )
2660 throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
2662 SolarMutexGuard aGuard;
2663 TabControl *pTabControl = getTabControl();
2664 if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == nullptr )
2665 throw lang::IndexOutOfBoundsException();
2667 uno::Sequence< beans::NamedValue > props
2669 { "Title", css::uno::makeAny(pTabControl->GetPageText( sal::static_int_cast< sal_uInt16 >( ID ) )) },
2670 { "Position", css::uno::makeAny(pTabControl->GetPagePos( sal::static_int_cast< sal_uInt16 >( ID ) )) }
2672 return props;
2674 void VCLXMultiPage::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
2676 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
2677 switch ( rVclWindowEvent.GetId() )
2679 case VCLEVENT_TABPAGE_DEACTIVATE:
2681 sal_uLong nPageID = reinterpret_cast<sal_uLong>( rVclWindowEvent.GetData() );
2682 maTabListeners.deactivated( nPageID );
2683 break;
2686 case VCLEVENT_TABPAGE_ACTIVATE:
2688 sal_uLong nPageID = reinterpret_cast<sal_uLong>( rVclWindowEvent.GetData() );
2689 maTabListeners.activated( nPageID );
2690 break;
2692 default:
2693 VCLXContainer::ProcessWindowEvent( rVclWindowEvent );
2694 break;
2699 // class VCLXTabPage
2701 VCLXTabPage::VCLXTabPage()
2705 void VCLXTabPage::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2707 PushPropertyIds( rIds,
2708 BASEPROPERTY_BACKGROUNDCOLOR,
2709 BASEPROPERTY_DEFAULTCONTROL,
2710 BASEPROPERTY_ENABLED,
2711 BASEPROPERTY_ENABLEVISIBLE,
2712 BASEPROPERTY_FONTDESCRIPTOR,
2713 BASEPROPERTY_GRAPHIC,
2714 BASEPROPERTY_HELPTEXT,
2715 BASEPROPERTY_HELPURL,
2716 BASEPROPERTY_IMAGEALIGN,
2717 BASEPROPERTY_IMAGEPOSITION,
2718 BASEPROPERTY_IMAGEURL,
2719 BASEPROPERTY_PRINTABLE,
2720 BASEPROPERTY_TABSTOP,
2721 BASEPROPERTY_FOCUSONCLICK,
2723 VCLXContainer::ImplGetPropertyIds( rIds );
2726 VCLXTabPage::~VCLXTabPage()
2730 css::uno::Any SAL_CALL VCLXTabPage::queryInterface(const css::uno::Type & rType )
2731 throw(css::uno::RuntimeException, std::exception)
2733 return VCLXContainer::queryInterface( rType );
2736 // css::lang::XTypeProvider
2737 IMPL_XTYPEPROVIDER_START( VCLXTabPage )
2738 VCLXContainer::getTypes()
2739 IMPL_XTYPEPROVIDER_END
2741 // css::awt::XView
2742 void SAL_CALL VCLXTabPage::draw( sal_Int32 nX, sal_Int32 nY )
2743 throw(css::uno::RuntimeException, std::exception)
2745 SolarMutexGuard aGuard;
2746 VclPtr< vcl::Window > pWindow = GetWindow();
2748 if ( pWindow )
2750 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
2751 if ( !pDev )
2752 pDev = pWindow->GetParent();
2754 Size aSize = pDev->PixelToLogic( pWindow->GetSizePixel() );
2755 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
2757 pWindow->Draw( pDev, aPos, aSize, DrawFlags::NoControls );
2761 // css::awt::XDevice,
2762 css::awt::DeviceInfo SAL_CALL VCLXTabPage::getInfo()
2763 throw(css::uno::RuntimeException, std::exception)
2765 css::awt::DeviceInfo aInfo = VCLXDevice::getInfo();
2766 return aInfo;
2769 void SAL_CALL VCLXTabPage::setProperty(
2770 const OUString& PropertyName,
2771 const css::uno::Any& Value )
2772 throw(css::uno::RuntimeException, std::exception)
2774 SolarMutexGuard aGuard;
2775 VclPtr< TabPage > pTabPage = GetAs< TabPage >();
2776 if ( pTabPage )
2778 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
2780 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2781 switch ( nPropType )
2783 case BASEPROPERTY_GRAPHIC:
2785 Reference< XGraphic > xGraphic;
2786 if (( Value >>= xGraphic ) && xGraphic.is() )
2788 Image aImage( xGraphic );
2790 Wallpaper aWallpaper( aImage.GetBitmapEx());
2791 aWallpaper.SetStyle( WallpaperStyle::Scale );
2792 pTabPage->SetBackground( aWallpaper );
2794 else if ( bVoid || !xGraphic.is() )
2796 Color aColor = pTabPage->GetControlBackground().GetColor();
2797 if ( aColor == COL_AUTO )
2798 aColor = pTabPage->GetSettings().GetStyleSettings().GetDialogColor();
2800 Wallpaper aWallpaper( aColor );
2801 pTabPage->SetBackground( aWallpaper );
2804 break;
2805 case BASEPROPERTY_TITLE:
2807 OUString sTitle;
2808 if ( Value >>= sTitle )
2810 pTabPage->SetText(sTitle);
2813 break;
2815 default:
2817 VCLXContainer::setProperty( PropertyName, Value );
2823 TabPage *VCLXTabPage::getTabPage() const throw (uno::RuntimeException)
2825 VclPtr< TabPage > pTabPage = GetAsDynamic< TabPage >();
2826 if ( pTabPage )
2827 return pTabPage;
2828 throw uno::RuntimeException();
2832 // class VCLXFixedHyperlink
2835 VCLXFixedHyperlink::VCLXFixedHyperlink() :
2837 maActionListeners( *this )
2842 VCLXFixedHyperlink::~VCLXFixedHyperlink()
2846 // css::uno::XInterface
2847 css::uno::Any VCLXFixedHyperlink::queryInterface( const css::uno::Type & rType ) throw(css::uno::RuntimeException, std::exception)
2849 css::uno::Any aRet = ::cppu::queryInterface( rType,
2850 (static_cast< css::awt::XFixedHyperlink* >(this)) );
2851 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
2854 void VCLXFixedHyperlink::dispose() throw(css::uno::RuntimeException, std::exception)
2856 SolarMutexGuard aGuard;
2858 css::lang::EventObject aObj;
2859 aObj.Source = static_cast<cppu::OWeakObject*>(this);
2860 maActionListeners.disposeAndClear( aObj );
2861 VCLXWindow::dispose();
2864 // css::lang::XTypeProvider
2865 IMPL_XTYPEPROVIDER_START( VCLXFixedHyperlink )
2866 cppu::UnoType<css::awt::XFixedHyperlink>::get(),
2867 VCLXWindow::getTypes()
2868 IMPL_XTYPEPROVIDER_END
2870 void VCLXFixedHyperlink::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
2872 switch ( rVclWindowEvent.GetId() )
2874 case VCLEVENT_BUTTON_CLICK:
2876 if ( maActionListeners.getLength() )
2878 css::awt::ActionEvent aEvent;
2879 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
2880 maActionListeners.actionPerformed( aEvent );
2882 else
2884 // open the URL
2885 OUString sURL;
2886 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
2887 if ( pBase )
2888 sURL = pBase->GetURL();
2889 Reference< css::system::XSystemShellExecute > xSystemShellExecute( css::system::SystemShellExecute::create(
2890 ::comphelper::getProcessComponentContext() ) );
2891 if ( !sURL.isEmpty() )
2895 // start browser
2896 xSystemShellExecute->execute(
2897 sURL, OUString(), css::system::SystemShellExecuteFlags::URIS_ONLY );
2899 catch( uno::Exception& )
2904 SAL_FALLTHROUGH;
2906 default:
2907 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
2908 break;
2912 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXFixedHyperlink::CreateAccessibleContext()
2914 return getAccessibleFactory().createAccessibleContext( this );
2917 void VCLXFixedHyperlink::setText( const OUString& Text ) throw(css::uno::RuntimeException, std::exception)
2919 SolarMutexGuard aGuard;
2920 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
2921 if (pBase)
2922 pBase->SetText(Text);
2925 OUString VCLXFixedHyperlink::getText() throw(css::uno::RuntimeException, std::exception)
2927 SolarMutexGuard aGuard;
2929 OUString aText;
2930 VclPtr< vcl::Window > pWindow = GetWindow();
2931 if ( pWindow )
2932 aText = pWindow->GetText();
2933 return aText;
2936 void VCLXFixedHyperlink::setURL( const OUString& URL ) throw(css::uno::RuntimeException, std::exception)
2938 SolarMutexGuard aGuard;
2939 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
2940 if ( pBase )
2941 pBase->SetURL( URL );
2944 OUString VCLXFixedHyperlink::getURL( ) throw(css::uno::RuntimeException, std::exception)
2946 SolarMutexGuard aGuard;
2948 OUString aText;
2949 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
2950 if ( pBase )
2951 aText = pBase->GetURL();
2952 return aText;
2955 void VCLXFixedHyperlink::setAlignment( short nAlign ) throw(css::uno::RuntimeException, std::exception)
2957 SolarMutexGuard aGuard;
2959 VclPtr< vcl::Window > pWindow = GetWindow();
2960 if ( pWindow )
2962 WinBits nNewBits = 0;
2963 if ( nAlign == css::awt::TextAlign::LEFT )
2964 nNewBits = WB_LEFT;
2965 else if ( nAlign == css::awt::TextAlign::CENTER )
2966 nNewBits = WB_CENTER;
2967 else
2968 nNewBits = WB_RIGHT;
2970 WinBits nStyle = pWindow->GetStyle();
2971 nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT);
2972 pWindow->SetStyle( nStyle | nNewBits );
2976 short VCLXFixedHyperlink::getAlignment() throw(css::uno::RuntimeException, std::exception)
2978 SolarMutexGuard aGuard;
2980 short nAlign = 0;
2981 VclPtr< vcl::Window > pWindow = GetWindow();
2982 if ( pWindow )
2984 WinBits nStyle = pWindow->GetStyle();
2985 if ( nStyle & WB_LEFT )
2986 nAlign = css::awt::TextAlign::LEFT;
2987 else if ( nStyle & WB_CENTER )
2988 nAlign = css::awt::TextAlign::CENTER;
2989 else
2990 nAlign = css::awt::TextAlign::RIGHT;
2992 return nAlign;
2995 void VCLXFixedHyperlink::addActionListener( const css::uno::Reference< css::awt::XActionListener > & l )throw(css::uno::RuntimeException, std::exception)
2997 SolarMutexGuard aGuard;
2998 maActionListeners.addInterface( l );
3001 void VCLXFixedHyperlink::removeActionListener( const css::uno::Reference< css::awt::XActionListener > & l ) throw(css::uno::RuntimeException, std::exception)
3003 SolarMutexGuard aGuard;
3004 maActionListeners.removeInterface( l );
3007 css::awt::Size VCLXFixedHyperlink::getMinimumSize( ) throw(css::uno::RuntimeException, std::exception)
3009 SolarMutexGuard aGuard;
3010 Size aSz;
3011 VclPtr< FixedText > pFixedText = GetAs< FixedText >();
3012 if ( pFixedText )
3013 aSz = pFixedText->CalcMinimumSize();
3014 return AWTSize(aSz);
3017 css::awt::Size VCLXFixedHyperlink::getPreferredSize( ) throw(css::uno::RuntimeException, std::exception)
3019 return getMinimumSize();
3022 css::awt::Size VCLXFixedHyperlink::calcAdjustedSize( const css::awt::Size& rNewSize ) throw(css::uno::RuntimeException, std::exception)
3024 SolarMutexGuard aGuard;
3026 css::awt::Size aSz = rNewSize;
3027 css::awt::Size aMinSz = getMinimumSize();
3028 if ( aSz.Height != aMinSz.Height )
3029 aSz.Height = aMinSz.Height;
3031 return aSz;
3034 void VCLXFixedHyperlink::setProperty( const OUString& PropertyName, const css::uno::Any& Value) throw(css::uno::RuntimeException, std::exception)
3036 SolarMutexGuard aGuard;
3038 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
3039 if ( pBase )
3041 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3042 switch ( nPropType )
3044 case BASEPROPERTY_LABEL:
3046 OUString sNewLabel;
3047 if ( Value >>= sNewLabel )
3048 pBase->SetText(sNewLabel);
3049 break;
3052 case BASEPROPERTY_URL:
3054 OUString sNewURL;
3055 if ( Value >>= sNewURL )
3056 pBase->SetURL( sNewURL );
3057 break;
3060 default:
3062 VCLXWindow::setProperty( PropertyName, Value );
3068 css::uno::Any VCLXFixedHyperlink::getProperty( const OUString& PropertyName ) throw(css::uno::RuntimeException, std::exception)
3070 SolarMutexGuard aGuard;
3072 css::uno::Any aProp;
3073 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
3074 if ( pBase )
3076 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3077 switch ( nPropType )
3079 case BASEPROPERTY_URL:
3081 aProp = makeAny( OUString( pBase->GetURL() ) );
3082 break;
3085 default:
3087 aProp <<= VCLXWindow::getProperty( PropertyName );
3091 return aProp;
3094 void VCLXFixedHyperlink::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
3096 PushPropertyIds( rIds,
3097 BASEPROPERTY_ALIGN,
3098 BASEPROPERTY_BACKGROUNDCOLOR,
3099 BASEPROPERTY_BORDER,
3100 BASEPROPERTY_BORDERCOLOR,
3101 BASEPROPERTY_DEFAULTCONTROL,
3102 BASEPROPERTY_ENABLED,
3103 BASEPROPERTY_ENABLEVISIBLE,
3104 BASEPROPERTY_FONTDESCRIPTOR,
3105 BASEPROPERTY_HELPTEXT,
3106 BASEPROPERTY_HELPURL,
3107 BASEPROPERTY_LABEL,
3108 BASEPROPERTY_MULTILINE,
3109 BASEPROPERTY_NOLABEL,
3110 BASEPROPERTY_PRINTABLE,
3111 BASEPROPERTY_TABSTOP,
3112 BASEPROPERTY_VERTICALALIGN,
3113 BASEPROPERTY_URL,
3114 BASEPROPERTY_WRITING_MODE,
3115 BASEPROPERTY_CONTEXT_WRITING_MODE,
3117 VCLXWindow::ImplGetPropertyIds( rIds );
3121 // class VCLXFixedText
3123 void VCLXFixedText::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
3125 PushPropertyIds( rIds,
3126 BASEPROPERTY_ALIGN,
3127 BASEPROPERTY_BACKGROUNDCOLOR,
3128 BASEPROPERTY_BORDER,
3129 BASEPROPERTY_BORDERCOLOR,
3130 BASEPROPERTY_DEFAULTCONTROL,
3131 BASEPROPERTY_ENABLED,
3132 BASEPROPERTY_ENABLEVISIBLE,
3133 BASEPROPERTY_FONTDESCRIPTOR,
3134 BASEPROPERTY_HELPTEXT,
3135 BASEPROPERTY_HELPURL,
3136 BASEPROPERTY_LABEL,
3137 BASEPROPERTY_MULTILINE,
3138 BASEPROPERTY_NOLABEL,
3139 BASEPROPERTY_PRINTABLE,
3140 BASEPROPERTY_TABSTOP,
3141 BASEPROPERTY_VERTICALALIGN,
3142 BASEPROPERTY_WRITING_MODE,
3143 BASEPROPERTY_CONTEXT_WRITING_MODE,
3144 BASEPROPERTY_REFERENCE_DEVICE,
3146 VCLXWindow::ImplGetPropertyIds( rIds );
3149 VCLXFixedText::VCLXFixedText()
3153 VCLXFixedText::~VCLXFixedText()
3157 // css::uno::XInterface
3158 css::uno::Any VCLXFixedText::queryInterface( const css::uno::Type & rType ) throw(css::uno::RuntimeException, std::exception)
3160 css::uno::Any aRet = ::cppu::queryInterface( rType,
3161 (static_cast< css::awt::XFixedText* >(this)) );
3162 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
3165 // css::lang::XTypeProvider
3166 IMPL_XTYPEPROVIDER_START( VCLXFixedText )
3167 cppu::UnoType<css::awt::XFixedText>::get(),
3168 VCLXWindow::getTypes()
3169 IMPL_XTYPEPROVIDER_END
3171 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXFixedText::CreateAccessibleContext()
3173 return getAccessibleFactory().createAccessibleContext( this );
3176 void VCLXFixedText::setText( const OUString& Text ) throw(css::uno::RuntimeException, std::exception)
3178 SolarMutexGuard aGuard;
3180 VclPtr< vcl::Window > pWindow = GetWindow();
3181 if ( pWindow )
3182 pWindow->SetText( Text );
3185 OUString VCLXFixedText::getText() throw(css::uno::RuntimeException, std::exception)
3187 SolarMutexGuard aGuard;
3189 OUString aText;
3190 VclPtr< vcl::Window > pWindow = GetWindow();
3191 if ( pWindow )
3192 aText = pWindow->GetText();
3193 return aText;
3196 void VCLXFixedText::setAlignment( short nAlign ) throw(css::uno::RuntimeException, std::exception)
3198 SolarMutexGuard aGuard;
3200 VclPtr< vcl::Window > pWindow = GetWindow();
3201 if ( pWindow )
3203 WinBits nNewBits = 0;
3204 if ( nAlign == css::awt::TextAlign::LEFT )
3205 nNewBits = WB_LEFT;
3206 else if ( nAlign == css::awt::TextAlign::CENTER )
3207 nNewBits = WB_CENTER;
3208 else
3209 nNewBits = WB_RIGHT;
3211 WinBits nStyle = pWindow->GetStyle();
3212 nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT);
3213 pWindow->SetStyle( nStyle | nNewBits );
3217 short VCLXFixedText::getAlignment() throw(css::uno::RuntimeException, std::exception)
3219 SolarMutexGuard aGuard;
3221 short nAlign = 0;
3222 VclPtr< vcl::Window > pWindow = GetWindow();
3223 if ( pWindow )
3225 WinBits nStyle = pWindow->GetStyle();
3226 if ( nStyle & WB_LEFT )
3227 nAlign = css::awt::TextAlign::LEFT;
3228 else if ( nStyle & WB_CENTER )
3229 nAlign = css::awt::TextAlign::CENTER;
3230 else
3231 nAlign = css::awt::TextAlign::RIGHT;
3233 return nAlign;
3236 css::awt::Size VCLXFixedText::getMinimumSize( ) throw(css::uno::RuntimeException, std::exception)
3238 SolarMutexGuard aGuard;
3240 Size aSz;
3241 VclPtr< FixedText > pFixedText = GetAs< FixedText >();
3242 if ( pFixedText )
3243 aSz = pFixedText->CalcMinimumSize();
3244 return AWTSize(aSz);
3247 css::awt::Size VCLXFixedText::getPreferredSize( ) throw(css::uno::RuntimeException, std::exception)
3249 return getMinimumSize();
3252 css::awt::Size VCLXFixedText::calcAdjustedSize( const css::awt::Size& rMaxSize ) throw(css::uno::RuntimeException, std::exception)
3254 SolarMutexGuard aGuard;
3256 Size aAdjustedSize( VCLUnoHelper::ConvertToVCLSize( rMaxSize ) );
3257 VclPtr< FixedText > pFixedText = GetAs< FixedText >();
3258 if ( pFixedText )
3259 aAdjustedSize = pFixedText->CalcMinimumSize( rMaxSize.Width );
3260 return VCLUnoHelper::ConvertToAWTSize( aAdjustedSize );
3264 // class VCLXScrollBar
3266 void VCLXScrollBar::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
3268 PushPropertyIds( rIds,
3269 BASEPROPERTY_BACKGROUNDCOLOR,
3270 BASEPROPERTY_BLOCKINCREMENT,
3271 BASEPROPERTY_BORDER,
3272 BASEPROPERTY_BORDERCOLOR,
3273 BASEPROPERTY_DEFAULTCONTROL,
3274 BASEPROPERTY_ENABLED,
3275 BASEPROPERTY_ENABLEVISIBLE,
3276 BASEPROPERTY_HELPTEXT,
3277 BASEPROPERTY_HELPURL,
3278 BASEPROPERTY_LINEINCREMENT,
3279 BASEPROPERTY_LIVE_SCROLL,
3280 BASEPROPERTY_ORIENTATION,
3281 BASEPROPERTY_PRINTABLE,
3282 BASEPROPERTY_REPEAT_DELAY,
3283 BASEPROPERTY_SCROLLVALUE,
3284 BASEPROPERTY_SCROLLVALUE_MAX,
3285 BASEPROPERTY_SCROLLVALUE_MIN,
3286 BASEPROPERTY_SYMBOL_COLOR,
3287 BASEPROPERTY_TABSTOP,
3288 BASEPROPERTY_VISIBLESIZE,
3289 BASEPROPERTY_WRITING_MODE,
3290 BASEPROPERTY_CONTEXT_WRITING_MODE,
3292 VCLXWindow::ImplGetPropertyIds( rIds );
3295 VCLXScrollBar::VCLXScrollBar() : maAdjustmentListeners( *this )
3299 // css::uno::XInterface
3300 css::uno::Any VCLXScrollBar::queryInterface( const css::uno::Type & rType ) throw(css::uno::RuntimeException, std::exception)
3302 css::uno::Any aRet = ::cppu::queryInterface( rType,
3303 (static_cast< css::awt::XScrollBar* >(this)) );
3304 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
3307 // css::lang::XTypeProvider
3308 IMPL_XTYPEPROVIDER_START( VCLXScrollBar )
3309 cppu::UnoType<css::awt::XScrollBar>::get(),
3310 VCLXWindow::getTypes()
3311 IMPL_XTYPEPROVIDER_END
3313 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXScrollBar::CreateAccessibleContext()
3315 return getAccessibleFactory().createAccessibleContext( this );
3318 // css::lang::XComponent
3319 void VCLXScrollBar::dispose() throw(css::uno::RuntimeException, std::exception)
3321 SolarMutexGuard aGuard;
3323 css::lang::EventObject aObj;
3324 aObj.Source = static_cast<cppu::OWeakObject*>(this);
3325 maAdjustmentListeners.disposeAndClear( aObj );
3326 VCLXWindow::dispose();
3329 // css::awt::XScrollbar
3330 void VCLXScrollBar::addAdjustmentListener( const css::uno::Reference< css::awt::XAdjustmentListener > & l ) throw(css::uno::RuntimeException, std::exception)
3332 SolarMutexGuard aGuard;
3333 maAdjustmentListeners.addInterface( l );
3336 void VCLXScrollBar::removeAdjustmentListener( const css::uno::Reference< css::awt::XAdjustmentListener > & l ) throw(css::uno::RuntimeException, std::exception)
3338 SolarMutexGuard aGuard;
3339 maAdjustmentListeners.removeInterface( l );
3342 void VCLXScrollBar::setValue( sal_Int32 n ) throw(css::uno::RuntimeException, std::exception)
3344 SolarMutexGuard aGuard;
3346 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3347 if ( pScrollBar )
3348 pScrollBar->DoScroll( n );
3351 void VCLXScrollBar::setValues( sal_Int32 nValue, sal_Int32 nVisible, sal_Int32 nMax ) throw(css::uno::RuntimeException, std::exception)
3353 SolarMutexGuard aGuard;
3355 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3356 if ( pScrollBar )
3358 pScrollBar->SetVisibleSize( nVisible );
3359 pScrollBar->SetRangeMax( nMax );
3360 pScrollBar->DoScroll( nValue );
3364 sal_Int32 VCLXScrollBar::getValue() throw(css::uno::RuntimeException, std::exception)
3366 SolarMutexGuard aGuard;
3368 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3369 return pScrollBar ? pScrollBar->GetThumbPos() : 0;
3372 void VCLXScrollBar::setMaximum( sal_Int32 n ) throw(css::uno::RuntimeException, std::exception)
3374 SolarMutexGuard aGuard;
3376 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3377 if ( pScrollBar )
3378 pScrollBar->SetRangeMax( n );
3381 sal_Int32 VCLXScrollBar::getMaximum() throw(css::uno::RuntimeException, std::exception)
3383 SolarMutexGuard aGuard;
3385 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3386 return pScrollBar ? pScrollBar->GetRangeMax() : 0;
3389 void VCLXScrollBar::setMinimum( sal_Int32 n ) throw(css::uno::RuntimeException)
3391 SolarMutexGuard aGuard;
3393 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3394 if ( pScrollBar )
3395 pScrollBar->SetRangeMin( n );
3398 sal_Int32 VCLXScrollBar::getMinimum() throw(css::uno::RuntimeException)
3400 SolarMutexGuard aGuard;
3402 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3403 return pScrollBar ? pScrollBar->GetRangeMin() : 0;
3406 void VCLXScrollBar::setLineIncrement( sal_Int32 n ) throw(css::uno::RuntimeException, std::exception)
3408 SolarMutexGuard aGuard;
3410 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3411 if ( pScrollBar )
3412 pScrollBar->SetLineSize( n );
3415 sal_Int32 VCLXScrollBar::getLineIncrement() throw(css::uno::RuntimeException, std::exception)
3417 SolarMutexGuard aGuard;
3419 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3420 return pScrollBar ? pScrollBar->GetLineSize() : 0;
3423 void VCLXScrollBar::setBlockIncrement( sal_Int32 n ) throw(css::uno::RuntimeException, std::exception)
3425 SolarMutexGuard aGuard;
3427 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3428 if ( pScrollBar )
3429 pScrollBar->SetPageSize( n );
3432 sal_Int32 VCLXScrollBar::getBlockIncrement() throw(css::uno::RuntimeException, std::exception)
3434 SolarMutexGuard aGuard;
3436 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3437 return pScrollBar ? pScrollBar->GetPageSize() : 0;
3440 void VCLXScrollBar::setVisibleSize( sal_Int32 n ) throw(css::uno::RuntimeException, std::exception)
3442 SolarMutexGuard aGuard;
3444 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3445 if ( pScrollBar )
3446 pScrollBar->SetVisibleSize( n );
3449 sal_Int32 VCLXScrollBar::getVisibleSize() throw(css::uno::RuntimeException, std::exception)
3451 SolarMutexGuard aGuard;
3453 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3454 return pScrollBar ? pScrollBar->GetVisibleSize() : 0;
3457 void VCLXScrollBar::setOrientation( sal_Int32 n ) throw(css::uno::RuntimeException, std::exception)
3459 SolarMutexGuard aGuard;
3461 VclPtr< vcl::Window > pWindow = GetWindow();
3462 if ( pWindow )
3464 WinBits nStyle = pWindow->GetStyle();
3465 nStyle &= ~(WB_HORZ|WB_VERT);
3466 if ( n == css::awt::ScrollBarOrientation::HORIZONTAL )
3467 nStyle |= WB_HORZ;
3468 else
3469 nStyle |= WB_VERT;
3471 pWindow->SetStyle( nStyle );
3472 pWindow->Resize();
3476 sal_Int32 VCLXScrollBar::getOrientation() throw(css::uno::RuntimeException, std::exception)
3478 SolarMutexGuard aGuard;
3480 sal_Int32 n = 0;
3481 VclPtr< vcl::Window > pWindow = GetWindow();
3482 if ( pWindow )
3484 WinBits nStyle = pWindow->GetStyle();
3485 if ( nStyle & WB_HORZ )
3486 n = css::awt::ScrollBarOrientation::HORIZONTAL;
3487 else
3488 n = css::awt::ScrollBarOrientation::VERTICAL;
3490 return n;
3494 // css::awt::VclWindowPeer
3495 void VCLXScrollBar::setProperty( const OUString& PropertyName, const css::uno::Any& Value) throw(css::uno::RuntimeException, std::exception)
3497 SolarMutexGuard aGuard;
3499 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3500 if ( pScrollBar )
3502 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
3504 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3505 switch ( nPropType )
3507 case BASEPROPERTY_LIVE_SCROLL:
3509 bool bDo = false;
3510 if ( !bVoid )
3512 OSL_VERIFY( Value >>= bDo );
3514 AllSettings aSettings( pScrollBar->GetSettings() );
3515 StyleSettings aStyle( aSettings.GetStyleSettings() );
3516 DragFullOptions nDragOptions = aStyle.GetDragFullOptions();
3517 if ( bDo )
3518 nDragOptions |= DragFullOptions::Scroll;
3519 else
3520 nDragOptions &= ~DragFullOptions::Scroll;
3521 aStyle.SetDragFullOptions( nDragOptions );
3522 aSettings.SetStyleSettings( aStyle );
3523 pScrollBar->SetSettings( aSettings );
3525 break;
3527 case BASEPROPERTY_SCROLLVALUE:
3529 if ( !bVoid )
3531 sal_Int32 n = 0;
3532 if ( Value >>= n )
3533 setValue( n );
3536 break;
3537 case BASEPROPERTY_SCROLLVALUE_MAX:
3538 case BASEPROPERTY_SCROLLVALUE_MIN:
3540 if ( !bVoid )
3542 sal_Int32 n = 0;
3543 if ( Value >>= n )
3545 if ( nPropType == BASEPROPERTY_SCROLLVALUE_MAX )
3546 setMaximum( n );
3547 else
3548 setMinimum( n );
3552 break;
3553 case BASEPROPERTY_LINEINCREMENT:
3555 if ( !bVoid )
3557 sal_Int32 n = 0;
3558 if ( Value >>= n )
3559 setLineIncrement( n );
3562 break;
3563 case BASEPROPERTY_BLOCKINCREMENT:
3565 if ( !bVoid )
3567 sal_Int32 n = 0;
3568 if ( Value >>= n )
3569 setBlockIncrement( n );
3572 break;
3573 case BASEPROPERTY_VISIBLESIZE:
3575 if ( !bVoid )
3577 sal_Int32 n = 0;
3578 if ( Value >>= n )
3579 setVisibleSize( n );
3582 break;
3583 case BASEPROPERTY_ORIENTATION:
3585 if ( !bVoid )
3587 sal_Int32 n = 0;
3588 if ( Value >>= n )
3589 setOrientation( n );
3592 break;
3594 case BASEPROPERTY_BACKGROUNDCOLOR:
3596 // the default implementation of the base class doesn't work here, since our
3597 // interpretation for this property is slightly different
3598 ::toolkit::setButtonLikeFaceColor( pScrollBar, Value);
3600 break;
3602 default:
3604 VCLXWindow::setProperty( PropertyName, Value );
3610 css::uno::Any VCLXScrollBar::getProperty( const OUString& PropertyName ) throw(css::uno::RuntimeException, std::exception)
3612 SolarMutexGuard aGuard;
3614 css::uno::Any aProp;
3615 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3616 if ( pScrollBar )
3618 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3620 switch ( nPropType )
3622 case BASEPROPERTY_LIVE_SCROLL:
3624 aProp <<= bool( pScrollBar->GetSettings().GetStyleSettings().GetDragFullOptions() & DragFullOptions::Scroll );
3626 break;
3627 case BASEPROPERTY_SCROLLVALUE:
3629 aProp <<= (sal_Int32) getValue();
3631 break;
3632 case BASEPROPERTY_SCROLLVALUE_MAX:
3634 aProp <<= (sal_Int32) getMaximum();
3636 break;
3637 case BASEPROPERTY_SCROLLVALUE_MIN:
3639 aProp <<= (sal_Int32) getMinimum();
3641 break;
3642 case BASEPROPERTY_LINEINCREMENT:
3644 aProp <<= (sal_Int32) getLineIncrement();
3646 break;
3647 case BASEPROPERTY_BLOCKINCREMENT:
3649 aProp <<= (sal_Int32) getBlockIncrement();
3651 break;
3652 case BASEPROPERTY_VISIBLESIZE:
3654 aProp <<= (sal_Int32) getVisibleSize();
3656 break;
3657 case BASEPROPERTY_ORIENTATION:
3659 aProp <<= (sal_Int32) getOrientation();
3661 break;
3662 case BASEPROPERTY_BACKGROUNDCOLOR:
3664 // the default implementation of the base class doesn't work here, since our
3665 // interpretation for this property is slightly different
3666 aProp = ::toolkit::getButtonLikeFaceColor( pScrollBar );
3668 break;
3670 default:
3672 aProp <<= VCLXWindow::getProperty( PropertyName );
3676 return aProp;
3679 void VCLXScrollBar::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
3681 switch ( rVclWindowEvent.GetId() )
3683 case VCLEVENT_SCROLLBAR_SCROLL:
3685 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
3686 // since we call listeners below, there is a potential that we will be destroyed
3687 // in during the listener call. To prevent the resulting crashs, we keep us
3688 // alive as long as we're here
3690 if ( maAdjustmentListeners.getLength() )
3692 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3694 if( pScrollBar )
3696 css::awt::AdjustmentEvent aEvent;
3697 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
3698 aEvent.Value = pScrollBar->GetThumbPos();
3700 // set adjustment type
3701 ScrollType aType = pScrollBar->GetType();
3702 if ( aType == SCROLL_LINEUP || aType == SCROLL_LINEDOWN )
3704 aEvent.Type = css::awt::AdjustmentType_ADJUST_LINE;
3706 else if ( aType == SCROLL_PAGEUP || aType == SCROLL_PAGEDOWN )
3708 aEvent.Type = css::awt::AdjustmentType_ADJUST_PAGE;
3710 else if ( aType == SCROLL_DRAG )
3712 aEvent.Type = css::awt::AdjustmentType_ADJUST_ABS;
3715 maAdjustmentListeners.adjustmentValueChanged( aEvent );
3719 break;
3721 default:
3722 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
3723 break;
3727 css::awt::Size SAL_CALL VCLXScrollBar::implGetMinimumSize( vcl::Window* p ) throw(css::uno::RuntimeException)
3729 long n = p->GetSettings().GetStyleSettings().GetScrollBarSize();
3730 return css::awt::Size( n, n );
3733 css::awt::Size SAL_CALL VCLXScrollBar::getMinimumSize() throw(css::uno::RuntimeException, std::exception)
3735 SolarMutexGuard aGuard;
3736 return implGetMinimumSize( GetWindow() );
3740 // class VCLXEdit
3743 void VCLXEdit::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
3745 PushPropertyIds( rIds,
3746 BASEPROPERTY_ALIGN,
3747 BASEPROPERTY_BACKGROUNDCOLOR,
3748 BASEPROPERTY_BORDER,
3749 BASEPROPERTY_BORDERCOLOR,
3750 BASEPROPERTY_DEFAULTCONTROL,
3751 BASEPROPERTY_ECHOCHAR,
3752 BASEPROPERTY_ENABLED,
3753 BASEPROPERTY_ENABLEVISIBLE,
3754 BASEPROPERTY_FONTDESCRIPTOR,
3755 BASEPROPERTY_HARDLINEBREAKS,
3756 BASEPROPERTY_HELPTEXT,
3757 BASEPROPERTY_HELPURL,
3758 BASEPROPERTY_HSCROLL,
3759 BASEPROPERTY_LINE_END_FORMAT,
3760 BASEPROPERTY_MAXTEXTLEN,
3761 BASEPROPERTY_MULTILINE,
3762 BASEPROPERTY_PRINTABLE,
3763 BASEPROPERTY_READONLY,
3764 BASEPROPERTY_TABSTOP,
3765 BASEPROPERTY_TEXT,
3766 BASEPROPERTY_VSCROLL,
3767 BASEPROPERTY_HIDEINACTIVESELECTION,
3768 BASEPROPERTY_PAINTTRANSPARENT,
3769 BASEPROPERTY_AUTOHSCROLL,
3770 BASEPROPERTY_AUTOVSCROLL,
3771 BASEPROPERTY_VERTICALALIGN,
3772 BASEPROPERTY_WRITING_MODE,
3773 BASEPROPERTY_CONTEXT_WRITING_MODE,
3775 VCLXWindow::ImplGetPropertyIds( rIds );
3778 VCLXEdit::VCLXEdit() : maTextListeners( *this )
3782 // css::uno::XInterface
3783 css::uno::Any VCLXEdit::queryInterface( const css::uno::Type & rType ) throw(css::uno::RuntimeException, std::exception)
3785 css::uno::Any aRet = ::cppu::queryInterface( rType,
3786 (static_cast< css::awt::XTextComponent* >(this)),
3787 (static_cast< css::awt::XTextEditField* >(this)),
3788 (static_cast< css::awt::XTextLayoutConstrains* >(this)) );
3789 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
3792 // css::lang::XTypeProvider
3793 IMPL_XTYPEPROVIDER_START( VCLXEdit )
3794 cppu::UnoType<css::awt::XTextComponent>::get(),
3795 cppu::UnoType<css::awt::XTextEditField>::get(),
3796 cppu::UnoType<css::awt::XTextLayoutConstrains>::get(),
3797 VCLXWindow::getTypes()
3798 IMPL_XTYPEPROVIDER_END
3800 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXEdit::CreateAccessibleContext()
3802 return getAccessibleFactory().createAccessibleContext( this );
3805 void VCLXEdit::dispose() throw(css::uno::RuntimeException, std::exception)
3807 SolarMutexGuard aGuard;
3809 css::lang::EventObject aObj;
3810 aObj.Source = static_cast<cppu::OWeakObject*>(this);
3811 maTextListeners.disposeAndClear( aObj );
3812 VCLXWindow::dispose();
3815 void VCLXEdit::addTextListener( const css::uno::Reference< css::awt::XTextListener > & l ) throw(css::uno::RuntimeException, std::exception)
3817 SolarMutexGuard aGuard;
3818 GetTextListeners().addInterface( l );
3821 void VCLXEdit::removeTextListener( const css::uno::Reference< css::awt::XTextListener > & l ) throw(css::uno::RuntimeException, std::exception)
3823 SolarMutexGuard aGuard;
3824 GetTextListeners().removeInterface( l );
3827 void VCLXEdit::setText( const OUString& aText ) throw(css::uno::RuntimeException, std::exception)
3829 SolarMutexGuard aGuard;
3831 VclPtr< Edit > pEdit = GetAs< Edit >();
3832 if ( pEdit )
3834 pEdit->SetText( aText );
3836 // #107218# Call same listeners like VCL would do after user interaction
3837 SetSynthesizingVCLEvent( true );
3838 pEdit->SetModifyFlag();
3839 pEdit->Modify();
3840 SetSynthesizingVCLEvent( false );
3844 void VCLXEdit::insertText( const css::awt::Selection& rSel, const OUString& aText ) throw(css::uno::RuntimeException, std::exception)
3846 SolarMutexGuard aGuard;
3848 VclPtr< Edit > pEdit = GetAs< Edit >();
3849 if ( pEdit )
3851 pEdit->SetSelection( Selection( rSel.Min, rSel.Max ) );
3852 pEdit->ReplaceSelected( aText );
3854 // #107218# Call same listeners like VCL would do after user interaction
3855 SetSynthesizingVCLEvent( true );
3856 pEdit->SetModifyFlag();
3857 pEdit->Modify();
3858 SetSynthesizingVCLEvent( false );
3862 OUString VCLXEdit::getText() throw(css::uno::RuntimeException, std::exception)
3864 SolarMutexGuard aGuard;
3866 OUString aText;
3867 VclPtr< vcl::Window > pWindow = GetWindow();
3868 if ( pWindow )
3869 aText = pWindow->GetText();
3870 return aText;
3873 OUString VCLXEdit::getSelectedText() throw(css::uno::RuntimeException, std::exception)
3875 SolarMutexGuard aGuard;
3877 OUString aText;
3878 VclPtr< Edit > pEdit = GetAs< Edit >();
3879 if ( pEdit)
3880 aText = pEdit->GetSelected();
3881 return aText;
3885 void VCLXEdit::setSelection( const css::awt::Selection& aSelection ) throw(css::uno::RuntimeException, std::exception)
3887 SolarMutexGuard aGuard;
3889 VclPtr< Edit > pEdit = GetAs< Edit >();
3890 if ( pEdit )
3891 pEdit->SetSelection( Selection( aSelection.Min, aSelection.Max ) );
3894 css::awt::Selection VCLXEdit::getSelection() throw(css::uno::RuntimeException, std::exception)
3896 SolarMutexGuard aGuard;
3898 Selection aSel;
3899 VclPtr< Edit > pEdit = GetAs< Edit >();
3900 if ( pEdit )
3901 aSel = pEdit->GetSelection();
3902 return css::awt::Selection( aSel.Min(), aSel.Max() );
3905 sal_Bool VCLXEdit::isEditable() throw(css::uno::RuntimeException, std::exception)
3907 SolarMutexGuard aGuard;
3909 VclPtr< Edit > pEdit = GetAs< Edit >();
3910 return pEdit && !pEdit->IsReadOnly() && pEdit->IsEnabled();
3913 void VCLXEdit::setEditable( sal_Bool bEditable ) throw(css::uno::RuntimeException, std::exception)
3915 SolarMutexGuard aGuard;
3917 VclPtr< Edit > pEdit = GetAs< Edit >();
3918 if ( pEdit )
3919 pEdit->SetReadOnly( !bEditable );
3923 void VCLXEdit::setMaxTextLen( sal_Int16 nLen ) throw(css::uno::RuntimeException, std::exception)
3925 SolarMutexGuard aGuard;
3927 VclPtr< Edit > pEdit = GetAs< Edit >();
3928 if ( pEdit )
3929 pEdit->SetMaxTextLen( nLen );
3932 sal_Int16 VCLXEdit::getMaxTextLen() throw(css::uno::RuntimeException, std::exception)
3934 SolarMutexGuard aGuard;
3936 VclPtr< Edit > pEdit = GetAs< Edit >();
3937 return pEdit ? pEdit->GetMaxTextLen() : 0;
3940 void VCLXEdit::setEchoChar( sal_Unicode cEcho ) throw(css::uno::RuntimeException, std::exception)
3942 SolarMutexGuard aGuard;
3944 VclPtr< Edit > pEdit = GetAs< Edit >();
3945 if ( pEdit )
3946 pEdit->SetEchoChar( cEcho );
3949 void VCLXEdit::setProperty( const OUString& PropertyName, const css::uno::Any& Value) throw(css::uno::RuntimeException, std::exception)
3951 SolarMutexGuard aGuard;
3953 VclPtr< Edit > pEdit = GetAs< Edit >();
3954 if ( pEdit )
3956 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3957 switch ( nPropType )
3959 case BASEPROPERTY_HIDEINACTIVESELECTION:
3960 ::toolkit::adjustBooleanWindowStyle( Value, pEdit, WB_NOHIDESELECTION, true );
3961 if ( pEdit->GetSubEdit() )
3962 ::toolkit::adjustBooleanWindowStyle( Value, pEdit->GetSubEdit(), WB_NOHIDESELECTION, true );
3963 break;
3965 case BASEPROPERTY_READONLY:
3967 bool b = bool();
3968 if ( Value >>= b )
3969 pEdit->SetReadOnly( b );
3971 break;
3972 case BASEPROPERTY_ECHOCHAR:
3974 sal_Int16 n = sal_Int16();
3975 if ( Value >>= n )
3976 pEdit->SetEchoChar( n );
3978 break;
3979 case BASEPROPERTY_MAXTEXTLEN:
3981 sal_Int16 n = sal_Int16();
3982 if ( Value >>= n )
3983 pEdit->SetMaxTextLen( n );
3985 break;
3986 default:
3988 VCLXWindow::setProperty( PropertyName, Value );
3994 css::uno::Any VCLXEdit::getProperty( const OUString& PropertyName ) throw(css::uno::RuntimeException, std::exception)
3996 SolarMutexGuard aGuard;
3998 css::uno::Any aProp;
3999 VclPtr< Edit > pEdit = GetAs< Edit >();
4000 if ( pEdit )
4002 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4003 switch ( nPropType )
4005 case BASEPROPERTY_HIDEINACTIVESELECTION:
4006 aProp <<= ( ( pEdit->GetStyle() & WB_NOHIDESELECTION ) == 0 );
4007 break;
4008 case BASEPROPERTY_READONLY:
4009 aProp <<= pEdit->IsReadOnly();
4010 break;
4011 case BASEPROPERTY_ECHOCHAR:
4012 aProp <<= (sal_Int16) pEdit->GetEchoChar();
4013 break;
4014 case BASEPROPERTY_MAXTEXTLEN:
4015 aProp <<= (sal_Int16) pEdit->GetMaxTextLen();
4016 break;
4017 default:
4019 aProp = VCLXWindow::getProperty( PropertyName );
4023 return aProp;
4026 css::awt::Size VCLXEdit::getMinimumSize( ) throw(css::uno::RuntimeException, std::exception)
4028 SolarMutexGuard aGuard;
4030 Size aSz;
4031 VclPtr< Edit > pEdit = GetAs< Edit >();
4032 if ( pEdit )
4033 aSz = pEdit->CalcMinimumSize();
4034 return AWTSize(aSz);
4037 css::awt::Size VCLXEdit::getPreferredSize( ) throw(css::uno::RuntimeException, std::exception)
4039 SolarMutexGuard aGuard;
4041 Size aSz;
4042 VclPtr< Edit > pEdit = GetAs< Edit >();
4043 if ( pEdit )
4045 aSz = pEdit->CalcMinimumSize();
4046 aSz.Height() += 4;
4048 return AWTSize(aSz);
4051 css::awt::Size VCLXEdit::calcAdjustedSize( const css::awt::Size& rNewSize ) throw(css::uno::RuntimeException, std::exception)
4053 SolarMutexGuard aGuard;
4055 css::awt::Size aSz = rNewSize;
4056 css::awt::Size aMinSz = getMinimumSize();
4057 if ( aSz.Height != aMinSz.Height )
4058 aSz.Height = aMinSz.Height;
4060 return aSz;
4063 css::awt::Size VCLXEdit::getMinimumSize( sal_Int16 nCols, sal_Int16 ) throw(css::uno::RuntimeException, std::exception)
4065 SolarMutexGuard aGuard;
4067 Size aSz;
4068 VclPtr< Edit > pEdit = GetAs< Edit >();
4069 if ( pEdit )
4071 if ( nCols )
4072 aSz = pEdit->CalcSize( nCols );
4073 else
4074 aSz = pEdit->CalcMinimumSize();
4076 return AWTSize(aSz);
4079 void VCLXEdit::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(css::uno::RuntimeException, std::exception)
4081 SolarMutexGuard aGuard;
4083 nLines = 1;
4084 nCols = 0;
4085 VclPtr< Edit > pEdit = GetAs< Edit >();
4086 if ( pEdit )
4087 nCols = pEdit->GetMaxVisChars();
4090 void VCLXEdit::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
4092 switch ( rVclWindowEvent.GetId() )
4094 case VCLEVENT_EDIT_MODIFY:
4096 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
4097 // since we call listeners below, there is a potential that we will be destroyed
4098 // during the listener call. To prevent the resulting crashs, we keep us
4099 // alive as long as we're here
4101 if ( GetTextListeners().getLength() )
4103 css::awt::TextEvent aEvent;
4104 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
4105 GetTextListeners().textChanged( aEvent );
4108 break;
4110 default:
4111 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
4112 break;
4117 // class VCLXComboBox
4120 void VCLXComboBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
4122 PushPropertyIds( rIds,
4123 BASEPROPERTY_AUTOCOMPLETE,
4124 BASEPROPERTY_BACKGROUNDCOLOR,
4125 BASEPROPERTY_BORDER,
4126 BASEPROPERTY_BORDERCOLOR,
4127 BASEPROPERTY_DEFAULTCONTROL,
4128 BASEPROPERTY_DROPDOWN,
4129 BASEPROPERTY_ENABLED,
4130 BASEPROPERTY_ENABLEVISIBLE,
4131 BASEPROPERTY_FONTDESCRIPTOR,
4132 BASEPROPERTY_HELPTEXT,
4133 BASEPROPERTY_HELPURL,
4134 BASEPROPERTY_LINECOUNT,
4135 BASEPROPERTY_MAXTEXTLEN,
4136 BASEPROPERTY_PRINTABLE,
4137 BASEPROPERTY_READONLY,
4138 BASEPROPERTY_STRINGITEMLIST,
4139 BASEPROPERTY_TABSTOP,
4140 BASEPROPERTY_TEXT,
4141 BASEPROPERTY_HIDEINACTIVESELECTION,
4142 BASEPROPERTY_ALIGN,
4143 BASEPROPERTY_WRITING_MODE,
4144 BASEPROPERTY_CONTEXT_WRITING_MODE,
4145 BASEPROPERTY_REFERENCE_DEVICE,
4146 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
4148 // no, don't call VCLXEdit here - it has properties which we do *not* want to have at combo box
4149 // #i92690# / 2008-08-12 / frank.schoenheit@sun.com
4150 // VCLXEdit::ImplGetPropertyIds( rIds );
4151 VCLXWindow::ImplGetPropertyIds( rIds );
4154 VCLXComboBox::VCLXComboBox()
4155 : maActionListeners( *this ), maItemListeners( *this )
4159 VCLXComboBox::~VCLXComboBox()
4161 OSL_TRACE ("%s", __FUNCTION__);
4164 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXComboBox::CreateAccessibleContext()
4166 SolarMutexGuard aGuard;
4168 return getAccessibleFactory().createAccessibleContext( this );
4171 void VCLXComboBox::dispose() throw(css::uno::RuntimeException, std::exception)
4173 SolarMutexGuard aGuard;
4175 css::lang::EventObject aObj;
4176 aObj.Source = static_cast<cppu::OWeakObject*>(this);
4177 maItemListeners.disposeAndClear( aObj );
4178 maActionListeners.disposeAndClear( aObj );
4179 VCLXEdit::dispose();
4183 void VCLXComboBox::addItemListener( const css::uno::Reference< css::awt::XItemListener > & l ) throw(css::uno::RuntimeException, std::exception)
4185 SolarMutexGuard aGuard;
4186 maItemListeners.addInterface( l );
4189 void VCLXComboBox::removeItemListener( const css::uno::Reference< css::awt::XItemListener > & l ) throw(css::uno::RuntimeException, std::exception)
4191 SolarMutexGuard aGuard;
4192 maItemListeners.removeInterface( l );
4195 void VCLXComboBox::addActionListener( const css::uno::Reference< css::awt::XActionListener > & l ) throw(css::uno::RuntimeException, std::exception)
4197 SolarMutexGuard aGuard;
4198 maActionListeners.addInterface( l );
4201 void VCLXComboBox::removeActionListener( const css::uno::Reference< css::awt::XActionListener > & l ) throw(css::uno::RuntimeException, std::exception)
4203 SolarMutexGuard aGuard;
4204 maActionListeners.removeInterface( l );
4207 void VCLXComboBox::addItem( const OUString& aItem, sal_Int16 nPos ) throw(css::uno::RuntimeException, std::exception)
4209 SolarMutexGuard aGuard;
4211 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4212 if ( pBox )
4213 pBox->InsertEntry( aItem, nPos );
4216 void VCLXComboBox::addItems( const css::uno::Sequence< OUString>& aItems, sal_Int16 nPos ) throw(css::uno::RuntimeException, std::exception)
4218 SolarMutexGuard aGuard;
4220 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4221 if ( pBox )
4223 sal_uInt16 nP = nPos;
4224 for ( sal_Int32 n = 0; n < aItems.getLength(); n++ )
4226 pBox->InsertEntry( aItems.getConstArray()[n], nP );
4227 if ( nP == 0xFFFF )
4229 OSL_FAIL( "VCLXComboBox::addItems: too many entries!" );
4230 // skip remaining entries, list cannot hold them, anyway
4231 break;
4237 void VCLXComboBox::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(css::uno::RuntimeException, std::exception)
4239 SolarMutexGuard aGuard;
4241 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4242 if ( pBox )
4244 for ( sal_uInt16 n = nCount; n; )
4245 pBox->RemoveEntryAt( nPos + (--n) );
4249 sal_Int16 VCLXComboBox::getItemCount() throw(css::uno::RuntimeException, std::exception)
4251 SolarMutexGuard aGuard;
4253 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4254 return pBox ? pBox->GetEntryCount() : 0;
4257 OUString VCLXComboBox::getItem( sal_Int16 nPos ) throw(css::uno::RuntimeException, std::exception)
4259 SolarMutexGuard aGuard;
4261 OUString aItem;
4262 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4263 if ( pBox )
4264 aItem = pBox->GetEntry( nPos );
4265 return aItem;
4268 css::uno::Sequence< OUString> VCLXComboBox::getItems() throw(css::uno::RuntimeException, std::exception)
4270 SolarMutexGuard aGuard;
4272 css::uno::Sequence< OUString> aSeq;
4273 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4274 if ( pBox )
4276 auto n = pBox->GetEntryCount();
4277 aSeq = css::uno::Sequence< OUString>( n );
4278 while ( n )
4280 --n;
4281 aSeq.getArray()[n] = pBox->GetEntry( n );
4284 return aSeq;
4287 void VCLXComboBox::setDropDownLineCount( sal_Int16 nLines ) throw(css::uno::RuntimeException, std::exception)
4289 SolarMutexGuard aGuard;
4291 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4292 if ( pBox )
4293 pBox->SetDropDownLineCount( nLines );
4296 sal_Int16 VCLXComboBox::getDropDownLineCount() throw(css::uno::RuntimeException, std::exception)
4298 SolarMutexGuard aGuard;
4300 sal_Int16 nLines = 0;
4301 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4302 if ( pBox )
4303 nLines = pBox->GetDropDownLineCount();
4304 return nLines;
4307 void VCLXComboBox::setProperty( const OUString& PropertyName, const css::uno::Any& Value) throw(css::uno::RuntimeException, std::exception)
4309 SolarMutexGuard aGuard;
4311 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4312 if ( pComboBox )
4314 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4315 switch ( nPropType )
4317 case BASEPROPERTY_LINECOUNT:
4319 sal_Int16 n = sal_Int16();
4320 if ( Value >>= n )
4321 pComboBox->SetDropDownLineCount( n );
4323 break;
4324 case BASEPROPERTY_AUTOCOMPLETE:
4326 sal_Int16 n = sal_Int16();
4327 if ( Value >>= n )
4328 pComboBox->EnableAutocomplete( n != 0 );
4329 else
4331 bool b = bool();
4332 if ( Value >>= b )
4333 pComboBox->EnableAutocomplete( b );
4336 break;
4337 case BASEPROPERTY_STRINGITEMLIST:
4339 css::uno::Sequence< OUString> aItems;
4340 if ( Value >>= aItems )
4342 pComboBox->Clear();
4343 addItems( aItems, 0 );
4346 break;
4347 default:
4349 VCLXEdit::setProperty( PropertyName, Value );
4351 // #109385# SetBorderStyle is not virtual
4352 if ( nPropType == BASEPROPERTY_BORDER )
4354 sal_uInt16 nBorder = sal_uInt16();
4355 if ( (Value >>= nBorder) && nBorder != 0 )
4356 pComboBox->SetBorderStyle( static_cast<WindowBorderStyle>(nBorder) );
4363 css::uno::Any VCLXComboBox::getProperty( const OUString& PropertyName ) throw(css::uno::RuntimeException, std::exception)
4365 SolarMutexGuard aGuard;
4367 css::uno::Any aProp;
4368 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4369 if ( pComboBox )
4371 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4372 switch ( nPropType )
4374 case BASEPROPERTY_LINECOUNT:
4376 aProp <<= (sal_Int16) pComboBox->GetDropDownLineCount();
4378 break;
4379 case BASEPROPERTY_AUTOCOMPLETE:
4381 aProp <<= pComboBox->IsAutocompleteEnabled();
4383 break;
4384 case BASEPROPERTY_STRINGITEMLIST:
4386 const sal_Int32 nItems = pComboBox->GetEntryCount();
4387 css::uno::Sequence< OUString> aSeq( nItems );
4388 OUString* pStrings = aSeq.getArray();
4389 for ( sal_Int32 n = 0; n < nItems; ++n )
4390 pStrings[n] = pComboBox->GetEntry( n );
4391 aProp <<= aSeq;
4394 break;
4395 default:
4397 aProp <<= VCLXEdit::getProperty( PropertyName );
4401 return aProp;
4404 void VCLXComboBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
4406 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
4407 // since we call listeners below, there is a potential that we will be destroyed
4408 // during the listener call. To prevent the resulting crashs, we keep us
4409 // alive as long as we're here
4411 switch ( rVclWindowEvent.GetId() )
4413 case VCLEVENT_COMBOBOX_SELECT:
4414 if ( maItemListeners.getLength() )
4416 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4417 if( pComboBox )
4419 if ( !pComboBox->IsTravelSelect() )
4421 css::awt::ItemEvent aEvent;
4422 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
4423 aEvent.Highlighted = 0;
4425 // Set to 0xFFFF on multiple selection, selected entry ID otherwise
4426 aEvent.Selected = pComboBox->GetEntryPos( pComboBox->GetText() );
4428 maItemListeners.itemStateChanged( aEvent );
4432 break;
4434 case VCLEVENT_COMBOBOX_DOUBLECLICK:
4435 if ( maActionListeners.getLength() )
4437 css::awt::ActionEvent aEvent;
4438 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
4439 // aEvent.ActionCommand = ...;
4440 maActionListeners.actionPerformed( aEvent );
4442 break;
4444 default:
4445 VCLXEdit::ProcessWindowEvent( rVclWindowEvent );
4446 break;
4450 css::awt::Size VCLXComboBox::getMinimumSize( ) throw(css::uno::RuntimeException, std::exception)
4452 SolarMutexGuard aGuard;
4454 Size aSz;
4455 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4456 if ( pComboBox )
4457 aSz = pComboBox->CalcMinimumSize();
4458 return AWTSize(aSz);
4461 css::awt::Size VCLXComboBox::getPreferredSize( ) throw(css::uno::RuntimeException, std::exception)
4463 SolarMutexGuard aGuard;
4465 Size aSz;
4466 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4467 if ( pComboBox )
4469 aSz = pComboBox->CalcMinimumSize();
4470 if ( pComboBox->GetStyle() & WB_DROPDOWN )
4471 aSz.Height() += 4;
4473 return AWTSize(aSz);
4476 css::awt::Size VCLXComboBox::calcAdjustedSize( const css::awt::Size& rNewSize ) throw(css::uno::RuntimeException, std::exception)
4478 SolarMutexGuard aGuard;
4480 Size aSz = VCLSize(rNewSize);
4481 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4482 if ( pComboBox )
4483 aSz = pComboBox->CalcAdjustedSize( aSz );
4484 return AWTSize(aSz);
4487 css::awt::Size VCLXComboBox::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(css::uno::RuntimeException, std::exception)
4489 SolarMutexGuard aGuard;
4491 Size aSz;
4492 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4493 if ( pComboBox )
4494 aSz = pComboBox->CalcBlockSize( nCols, nLines );
4495 return AWTSize(aSz);
4498 void VCLXComboBox::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(css::uno::RuntimeException, std::exception)
4500 SolarMutexGuard aGuard;
4502 nCols = nLines = 0;
4503 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4504 if ( pComboBox )
4506 sal_uInt16 nC, nL;
4507 pComboBox->GetMaxVisColumnsAndLines( nC, nL );
4508 nCols = nC;
4509 nLines = nL;
4512 void SAL_CALL VCLXComboBox::listItemInserted( const ItemListEvent& i_rEvent ) throw (RuntimeException, std::exception)
4514 SolarMutexGuard aGuard;
4516 VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >();
4518 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemInserted: no ComboBox?!" );
4519 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition <= sal_Int32( pComboBox->GetEntryCount() ) ),
4520 "VCLXComboBox::listItemInserted: illegal (inconsistent) item position!" );
4521 pComboBox->InsertEntryWithImage(
4522 i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : OUString(),
4523 i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : Image(),
4524 i_rEvent.ItemPosition );
4527 void SAL_CALL VCLXComboBox::listItemRemoved( const ItemListEvent& i_rEvent ) throw (RuntimeException, std::exception)
4529 SolarMutexGuard aGuard;
4531 VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >();
4533 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemRemoved: no ComboBox?!" );
4534 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pComboBox->GetEntryCount() ) ),
4535 "VCLXComboBox::listItemRemoved: illegal (inconsistent) item position!" );
4537 pComboBox->RemoveEntryAt( i_rEvent.ItemPosition );
4540 void SAL_CALL VCLXComboBox::listItemModified( const ItemListEvent& i_rEvent ) throw (RuntimeException, std::exception)
4542 SolarMutexGuard aGuard;
4544 VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >();
4546 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" );
4547 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pComboBox->GetEntryCount() ) ),
4548 "VCLXComboBox::listItemModified: illegal (inconsistent) item position!" );
4550 // VCL's ComboBox does not support changing an entry's text or image, so remove and re-insert
4552 const OUString sNewText = i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : OUString( pComboBox->GetEntry( i_rEvent.ItemPosition ) );
4553 const Image aNewImage( i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : pComboBox->GetEntryImage( i_rEvent.ItemPosition ) );
4555 pComboBox->RemoveEntryAt( i_rEvent.ItemPosition );
4556 pComboBox->InsertEntryWithImage(sNewText, aNewImage, i_rEvent.ItemPosition);
4559 void SAL_CALL VCLXComboBox::allItemsRemoved( const EventObject& i_rEvent ) throw (RuntimeException, std::exception)
4561 SolarMutexGuard aGuard;
4563 VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >();
4564 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" );
4566 pComboBox->Clear();
4568 (void)i_rEvent;
4571 void SAL_CALL VCLXComboBox::itemListChanged( const EventObject& i_rEvent ) throw (RuntimeException, std::exception)
4573 SolarMutexGuard aGuard;
4575 VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >();
4576 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" );
4578 pComboBox->Clear();
4580 uno::Reference< beans::XPropertySet > xPropSet( i_rEvent.Source, uno::UNO_QUERY_THROW );
4581 uno::Reference< beans::XPropertySetInfo > xPSI( xPropSet->getPropertySetInfo(), uno::UNO_QUERY_THROW );
4582 // bool localize = xPSI->hasPropertyByName("ResourceResolver");
4583 uno::Reference< resource::XStringResourceResolver > xStringResourceResolver;
4584 if ( xPSI->hasPropertyByName("ResourceResolver") )
4586 xStringResourceResolver.set(
4587 xPropSet->getPropertyValue("ResourceResolver"),
4588 uno::UNO_QUERY
4593 Reference< XItemList > xItemList( i_rEvent.Source, uno::UNO_QUERY_THROW );
4594 uno::Sequence< beans::Pair< OUString, OUString > > aItems = xItemList->getAllItems();
4595 for ( sal_Int32 i=0; i<aItems.getLength(); ++i )
4597 OUString aLocalizationKey( aItems[i].First );
4598 if ( xStringResourceResolver.is() && !aLocalizationKey.isEmpty() && aLocalizationKey[0] == '&' )
4600 aLocalizationKey = xStringResourceResolver->resolveString(aLocalizationKey.copy( 1 ));
4602 pComboBox->InsertEntryWithImage(aLocalizationKey,
4603 lcl_getImageFromURL(aItems[i].Second));
4606 void SAL_CALL VCLXComboBox::disposing( const EventObject& i_rEvent ) throw (RuntimeException, std::exception)
4608 // just disambiguate
4609 VCLXEdit::disposing( i_rEvent );
4613 // class VCLXFormattedSpinField
4615 void VCLXFormattedSpinField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
4617 // Interestingly in the UnoControl API this is
4618 // - not derived from XEdit ultimately, (correct ?) - so cut this here ...
4619 // VCLXSpinField::ImplGetPropertyIds( rIds );
4620 VCLXWindow::ImplGetPropertyIds( rIds );
4623 VCLXFormattedSpinField::VCLXFormattedSpinField()
4624 : mpFormatter(nullptr)
4628 VCLXFormattedSpinField::~VCLXFormattedSpinField()
4632 void VCLXFormattedSpinField::setStrictFormat( bool bStrict )
4634 SolarMutexGuard aGuard;
4636 FormatterBase* pFormatter = GetFormatter();
4637 if ( pFormatter )
4638 pFormatter->SetStrictFormat( bStrict );
4641 bool VCLXFormattedSpinField::isStrictFormat()
4643 FormatterBase* pFormatter = GetFormatter();
4644 return pFormatter && pFormatter->IsStrictFormat();
4648 void VCLXFormattedSpinField::setProperty( const OUString& PropertyName, const css::uno::Any& Value) throw(css::uno::RuntimeException, std::exception)
4650 SolarMutexGuard aGuard;
4652 FormatterBase* pFormatter = GetFormatter();
4653 if ( pFormatter )
4655 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4656 switch ( nPropType )
4658 case BASEPROPERTY_SPIN:
4660 bool b = bool();
4661 if ( Value >>= b )
4663 WinBits nStyle = GetWindow()->GetStyle() | WB_SPIN;
4664 if ( !b )
4665 nStyle &= ~WB_SPIN;
4666 GetWindow()->SetStyle( nStyle );
4669 break;
4670 case BASEPROPERTY_STRICTFORMAT:
4672 bool b = bool();
4673 if ( Value >>= b )
4675 pFormatter->SetStrictFormat( b );
4678 break;
4679 default:
4681 VCLXSpinField::setProperty( PropertyName, Value );
4687 css::uno::Any VCLXFormattedSpinField::getProperty( const OUString& PropertyName ) throw(css::uno::RuntimeException, std::exception)
4689 SolarMutexGuard aGuard;
4691 css::uno::Any aProp;
4692 FormatterBase* pFormatter = GetFormatter();
4693 if ( pFormatter )
4695 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4696 switch ( nPropType )
4698 case BASEPROPERTY_TABSTOP:
4700 aProp <<= ( GetWindow()->GetStyle() & WB_SPIN ) != 0;
4702 break;
4703 case BASEPROPERTY_STRICTFORMAT:
4705 aProp <<= pFormatter->IsStrictFormat();
4707 break;
4708 default:
4710 aProp <<= VCLXSpinField::getProperty( PropertyName );
4714 return aProp;
4718 // class VCLXDateField
4721 void VCLXDateField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
4723 PushPropertyIds( rIds,
4724 BASEPROPERTY_ALIGN,
4725 BASEPROPERTY_BACKGROUNDCOLOR,
4726 BASEPROPERTY_BORDER,
4727 BASEPROPERTY_BORDERCOLOR,
4728 BASEPROPERTY_DATE,
4729 BASEPROPERTY_DATEMAX,
4730 BASEPROPERTY_DATEMIN,
4731 BASEPROPERTY_DATESHOWCENTURY,
4732 BASEPROPERTY_DEFAULTCONTROL,
4733 BASEPROPERTY_DROPDOWN,
4734 BASEPROPERTY_ENABLED,
4735 BASEPROPERTY_ENABLEVISIBLE,
4736 BASEPROPERTY_EXTDATEFORMAT,
4737 BASEPROPERTY_FONTDESCRIPTOR,
4738 BASEPROPERTY_HELPTEXT,
4739 BASEPROPERTY_HELPURL,
4740 BASEPROPERTY_PRINTABLE,
4741 BASEPROPERTY_READONLY,
4742 BASEPROPERTY_REPEAT,
4743 BASEPROPERTY_REPEAT_DELAY,
4744 BASEPROPERTY_SPIN,
4745 BASEPROPERTY_STRICTFORMAT,
4746 BASEPROPERTY_TABSTOP,
4747 BASEPROPERTY_ENFORCE_FORMAT,
4748 BASEPROPERTY_TEXT,
4749 BASEPROPERTY_HIDEINACTIVESELECTION,
4750 BASEPROPERTY_VERTICALALIGN,
4751 BASEPROPERTY_WRITING_MODE,
4752 BASEPROPERTY_CONTEXT_WRITING_MODE,
4753 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
4755 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
4758 VCLXDateField::VCLXDateField()
4762 VCLXDateField::~VCLXDateField()
4766 //change the window type here to match the role
4767 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXDateField::CreateAccessibleContext()
4769 VclPtr< vcl::Window > pWindow = GetWindow();
4770 if ( pWindow )
4772 pWindow->SetType( WINDOW_DATEFIELD );
4774 return getAccessibleFactory().createAccessibleContext( this );
4777 // css::uno::XInterface
4778 css::uno::Any VCLXDateField::queryInterface( const css::uno::Type & rType ) throw(css::uno::RuntimeException, std::exception)
4780 css::uno::Any aRet = ::cppu::queryInterface( rType,
4781 (static_cast< css::awt::XDateField* >(this)) );
4782 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
4785 // css::lang::XTypeProvider
4786 IMPL_XTYPEPROVIDER_START( VCLXDateField )
4787 cppu::UnoType<css::awt::XDateField>::get(),
4788 VCLXFormattedSpinField::getTypes()
4789 IMPL_XTYPEPROVIDER_END
4791 void VCLXDateField::setProperty( const OUString& PropertyName, const css::uno::Any& Value) throw(css::uno::RuntimeException, std::exception)
4793 SolarMutexGuard aGuard;
4795 if ( GetWindow() )
4797 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
4799 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4800 switch ( nPropType )
4802 case BASEPROPERTY_DATE:
4804 if ( bVoid )
4806 GetAs< DateField >()->EnableEmptyFieldValue( true );
4807 GetAs< DateField >()->SetEmptyFieldValue();
4809 else
4811 util::Date d;
4812 if ( Value >>= d )
4813 setDate( d );
4816 break;
4817 case BASEPROPERTY_DATEMIN:
4819 util::Date d;
4820 if ( Value >>= d )
4821 setMin( d );
4823 break;
4824 case BASEPROPERTY_DATEMAX:
4826 util::Date d;
4827 if ( Value >>= d )
4828 setMax( d );
4830 break;
4831 case BASEPROPERTY_EXTDATEFORMAT:
4833 sal_Int16 n = sal_Int16();
4834 if ( Value >>= n )
4835 GetAs< DateField >()->SetExtDateFormat( (ExtDateFieldFormat) n );
4837 break;
4838 case BASEPROPERTY_DATESHOWCENTURY:
4840 bool b = bool();
4841 if ( Value >>= b )
4842 GetAs< DateField >()->SetShowDateCentury( b );
4844 break;
4845 case BASEPROPERTY_ENFORCE_FORMAT:
4847 bool bEnforce( true );
4848 OSL_VERIFY( Value >>= bEnforce );
4849 GetAs< DateField >()->EnforceValidValue( bEnforce );
4851 break;
4852 default:
4854 VCLXFormattedSpinField::setProperty( PropertyName, Value );
4860 css::uno::Any VCLXDateField::getProperty( const OUString& PropertyName ) throw(css::uno::RuntimeException, std::exception)
4862 SolarMutexGuard aGuard;
4864 css::uno::Any aProp;
4865 FormatterBase* pFormatter = GetFormatter();
4866 if ( pFormatter )
4868 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4869 switch ( nPropType )
4871 case BASEPROPERTY_DATE:
4873 aProp <<= getDate();
4875 break;
4876 case BASEPROPERTY_DATEMIN:
4878 aProp <<= getMin();
4880 break;
4881 case BASEPROPERTY_DATEMAX:
4883 aProp <<= getMax();
4885 break;
4886 case BASEPROPERTY_DATESHOWCENTURY:
4888 aProp <<= GetAs< DateField >()->IsShowDateCentury();
4890 break;
4891 case BASEPROPERTY_ENFORCE_FORMAT:
4893 aProp <<= GetAs< DateField >()->IsEnforceValidValue( );
4895 break;
4896 default:
4898 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
4902 return aProp;
4906 void VCLXDateField::setDate( const util::Date& aDate ) throw(css::uno::RuntimeException, std::exception)
4908 SolarMutexGuard aGuard;
4910 VclPtr< DateField > pDateField = GetAs< DateField >();
4911 if ( pDateField )
4913 pDateField->SetDate( aDate );
4915 // #107218# Call same listeners like VCL would do after user interaction
4916 SetSynthesizingVCLEvent( true );
4917 pDateField->SetModifyFlag();
4918 pDateField->Modify();
4919 SetSynthesizingVCLEvent( false );
4923 util::Date VCLXDateField::getDate() throw(css::uno::RuntimeException, std::exception)
4925 SolarMutexGuard aGuard;
4927 VclPtr< DateField > pDateField = GetAs< DateField >();
4928 if ( pDateField )
4929 return pDateField->GetDate().GetUNODate();
4930 else
4931 return util::Date();
4934 void VCLXDateField::setMin( const util::Date& aDate ) throw(css::uno::RuntimeException, std::exception)
4936 SolarMutexGuard aGuard;
4938 VclPtr< DateField > pDateField = GetAs< DateField >();
4939 if ( pDateField )
4940 pDateField->SetMin( aDate );
4943 util::Date VCLXDateField::getMin() throw(css::uno::RuntimeException, std::exception)
4945 SolarMutexGuard aGuard;
4947 VclPtr< DateField > pDateField = GetAs< DateField >();
4948 if ( pDateField )
4949 return pDateField->GetMin().GetUNODate();
4950 else
4951 return util::Date();
4954 void VCLXDateField::setMax( const util::Date& aDate ) throw(css::uno::RuntimeException, std::exception)
4956 SolarMutexGuard aGuard;
4958 VclPtr< DateField > pDateField = GetAs< DateField >();
4959 if ( pDateField )
4960 pDateField->SetMax( aDate );
4963 util::Date VCLXDateField::getMax() throw(css::uno::RuntimeException, std::exception)
4965 SolarMutexGuard aGuard;
4967 VclPtr< DateField > pDateField = GetAs< DateField >();
4968 if ( pDateField )
4969 return pDateField->GetMax().GetUNODate();
4970 else
4971 return util::Date();
4974 void VCLXDateField::setFirst( const util::Date& aDate ) throw(css::uno::RuntimeException, std::exception)
4976 SolarMutexGuard aGuard;
4978 VclPtr< DateField > pDateField = GetAs< DateField >();
4979 if ( pDateField )
4980 pDateField->SetFirst( aDate );
4983 util::Date VCLXDateField::getFirst() throw(css::uno::RuntimeException, std::exception)
4985 SolarMutexGuard aGuard;
4987 VclPtr< DateField > pDateField = GetAs< DateField >();
4988 if ( pDateField )
4989 return pDateField->GetFirst().GetUNODate();
4990 else
4991 return util::Date();
4994 void VCLXDateField::setLast( const util::Date& aDate ) throw(css::uno::RuntimeException, std::exception)
4996 SolarMutexGuard aGuard;
4998 VclPtr< DateField > pDateField = GetAs< DateField >();
4999 if ( pDateField )
5000 pDateField->SetLast( aDate );
5003 util::Date VCLXDateField::getLast() throw(css::uno::RuntimeException, std::exception)
5005 SolarMutexGuard aGuard;
5007 VclPtr< DateField > pDateField = GetAs< DateField >();
5008 if ( pDateField )
5009 return pDateField->GetLast().GetUNODate();
5010 else
5011 return util::Date();
5014 void VCLXDateField::setLongFormat( sal_Bool bLong ) throw(css::uno::RuntimeException, std::exception)
5016 SolarMutexGuard aGuard;
5018 VclPtr< DateField > pDateField = GetAs< DateField >();
5019 if ( pDateField )
5020 pDateField->SetLongFormat( bLong );
5023 sal_Bool VCLXDateField::isLongFormat() throw(css::uno::RuntimeException, std::exception)
5025 SolarMutexGuard aGuard;
5027 VclPtr< DateField > pDateField = GetAs< DateField >();
5028 return pDateField && pDateField->IsLongFormat();
5031 void VCLXDateField::setEmpty() throw(css::uno::RuntimeException, std::exception)
5033 SolarMutexGuard aGuard;
5035 VclPtr< DateField > pDateField = GetAs< DateField >();
5036 if ( pDateField )
5038 pDateField->SetEmptyDate();
5040 // #107218# Call same listeners like VCL would do after user interaction
5041 SetSynthesizingVCLEvent( true );
5042 pDateField->SetModifyFlag();
5043 pDateField->Modify();
5044 SetSynthesizingVCLEvent( false );
5048 sal_Bool VCLXDateField::isEmpty() throw(css::uno::RuntimeException, std::exception)
5050 SolarMutexGuard aGuard;
5052 VclPtr< DateField > pDateField = GetAs< DateField >();
5053 return pDateField && pDateField->IsEmptyDate();
5056 void VCLXDateField::setStrictFormat( sal_Bool bStrict ) throw(css::uno::RuntimeException, std::exception)
5058 VCLXFormattedSpinField::setStrictFormat( bStrict );
5061 sal_Bool VCLXDateField::isStrictFormat() throw(css::uno::RuntimeException, std::exception)
5063 return VCLXFormattedSpinField::isStrictFormat();
5067 // class VCLXTimeField
5070 void VCLXTimeField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
5072 PushPropertyIds( rIds,
5073 BASEPROPERTY_ALIGN,
5074 BASEPROPERTY_BACKGROUNDCOLOR,
5075 BASEPROPERTY_BORDER,
5076 BASEPROPERTY_BORDERCOLOR,
5077 BASEPROPERTY_DEFAULTCONTROL,
5078 BASEPROPERTY_ENABLED,
5079 BASEPROPERTY_ENABLEVISIBLE,
5080 BASEPROPERTY_EXTTIMEFORMAT,
5081 BASEPROPERTY_FONTDESCRIPTOR,
5082 BASEPROPERTY_HELPTEXT,
5083 BASEPROPERTY_HELPURL,
5084 BASEPROPERTY_PRINTABLE,
5085 BASEPROPERTY_READONLY,
5086 BASEPROPERTY_REPEAT,
5087 BASEPROPERTY_REPEAT_DELAY,
5088 BASEPROPERTY_SPIN,
5089 BASEPROPERTY_STRICTFORMAT,
5090 BASEPROPERTY_TABSTOP,
5091 BASEPROPERTY_TIME,
5092 BASEPROPERTY_TIMEMAX,
5093 BASEPROPERTY_TIMEMIN,
5094 BASEPROPERTY_ENFORCE_FORMAT,
5095 BASEPROPERTY_TEXT,
5096 BASEPROPERTY_HIDEINACTIVESELECTION,
5097 BASEPROPERTY_VERTICALALIGN,
5098 BASEPROPERTY_WRITING_MODE,
5099 BASEPROPERTY_CONTEXT_WRITING_MODE,
5100 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
5102 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5105 VCLXTimeField::VCLXTimeField()
5109 VCLXTimeField::~VCLXTimeField()
5113 //change the window type here to match the role
5114 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXTimeField::CreateAccessibleContext()
5116 VclPtr< vcl::Window > pWindow = GetWindow();
5117 if ( pWindow )
5119 pWindow->SetType( WINDOW_TIMEFIELD );
5121 return getAccessibleFactory().createAccessibleContext( this );
5124 // css::uno::XInterface
5125 css::uno::Any VCLXTimeField::queryInterface( const css::uno::Type & rType ) throw(css::uno::RuntimeException, std::exception)
5127 css::uno::Any aRet = ::cppu::queryInterface( rType,
5128 (static_cast< css::awt::XTimeField* >(this)) );
5129 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
5132 // css::lang::XTypeProvider
5133 IMPL_XTYPEPROVIDER_START( VCLXTimeField )
5134 cppu::UnoType<css::awt::XTimeField>::get(),
5135 VCLXFormattedSpinField::getTypes()
5136 IMPL_XTYPEPROVIDER_END
5138 void VCLXTimeField::setTime( const util::Time& aTime ) throw(css::uno::RuntimeException, std::exception)
5140 SolarMutexGuard aGuard;
5142 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5143 if ( pTimeField )
5145 pTimeField->SetTime( aTime );
5147 // #107218# Call same listeners like VCL would do after user interaction
5148 SetSynthesizingVCLEvent( true );
5149 pTimeField->SetModifyFlag();
5150 pTimeField->Modify();
5151 SetSynthesizingVCLEvent( false );
5155 util::Time VCLXTimeField::getTime() throw(css::uno::RuntimeException, std::exception)
5157 SolarMutexGuard aGuard;
5159 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5160 if ( pTimeField )
5161 return pTimeField->GetTime().GetUNOTime();
5162 else
5163 return util::Time();
5166 void VCLXTimeField::setMin( const util::Time& aTime ) throw(css::uno::RuntimeException, std::exception)
5168 SolarMutexGuard aGuard;
5170 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5171 if ( pTimeField )
5172 pTimeField->SetMin( aTime );
5175 util::Time VCLXTimeField::getMin() throw(css::uno::RuntimeException, std::exception)
5177 SolarMutexGuard aGuard;
5179 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5180 if ( pTimeField )
5181 return pTimeField->GetMin().GetUNOTime();
5182 else
5183 return util::Time();
5186 void VCLXTimeField::setMax( const util::Time& aTime ) throw(css::uno::RuntimeException, std::exception)
5188 SolarMutexGuard aGuard;
5190 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5191 if ( pTimeField )
5192 pTimeField->SetMax( aTime );
5195 util::Time VCLXTimeField::getMax() throw(css::uno::RuntimeException, std::exception)
5197 SolarMutexGuard aGuard;
5199 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5200 if ( pTimeField )
5201 return pTimeField->GetMax().GetUNOTime();
5202 else
5203 return util::Time();
5206 void VCLXTimeField::setFirst( const util::Time& aTime ) throw(css::uno::RuntimeException, std::exception)
5208 SolarMutexGuard aGuard;
5210 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5211 if ( pTimeField )
5212 pTimeField->SetFirst( aTime );
5215 util::Time VCLXTimeField::getFirst() throw(css::uno::RuntimeException, std::exception)
5217 SolarMutexGuard aGuard;
5219 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5220 if ( pTimeField )
5221 return pTimeField->GetFirst().GetUNOTime();
5222 else
5223 return util::Time();
5226 void VCLXTimeField::setLast( const util::Time& aTime ) throw(css::uno::RuntimeException, std::exception)
5228 SolarMutexGuard aGuard;
5230 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5231 if ( pTimeField )
5232 pTimeField->SetLast( aTime );
5235 util::Time VCLXTimeField::getLast() throw(css::uno::RuntimeException, std::exception)
5237 SolarMutexGuard aGuard;
5239 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5240 if ( pTimeField )
5241 return pTimeField->GetLast().GetUNOTime();
5242 else
5243 return util::Time();
5246 void VCLXTimeField::setEmpty() throw(css::uno::RuntimeException, std::exception)
5248 SolarMutexGuard aGuard;
5250 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5251 if ( pTimeField )
5252 pTimeField->SetEmptyTime();
5255 sal_Bool VCLXTimeField::isEmpty() throw(css::uno::RuntimeException, std::exception)
5257 SolarMutexGuard aGuard;
5259 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5260 return pTimeField && pTimeField->IsEmptyTime();
5263 void VCLXTimeField::setStrictFormat( sal_Bool bStrict ) throw(css::uno::RuntimeException, std::exception)
5265 VCLXFormattedSpinField::setStrictFormat( bStrict );
5268 sal_Bool VCLXTimeField::isStrictFormat() throw(css::uno::RuntimeException, std::exception)
5270 return VCLXFormattedSpinField::isStrictFormat();
5274 void VCLXTimeField::setProperty( const OUString& PropertyName, const css::uno::Any& Value) throw(css::uno::RuntimeException, std::exception)
5276 SolarMutexGuard aGuard;
5278 if ( GetWindow() )
5280 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
5282 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5283 switch ( nPropType )
5285 case BASEPROPERTY_TIME:
5287 if ( bVoid )
5289 GetAs< TimeField >()->EnableEmptyFieldValue( true );
5290 GetAs< TimeField >()->SetEmptyFieldValue();
5292 else
5294 util::Time t;
5295 if ( Value >>= t )
5296 setTime( t );
5299 break;
5300 case BASEPROPERTY_TIMEMIN:
5302 util::Time t;
5303 if ( Value >>= t )
5304 setMin( t );
5306 break;
5307 case BASEPROPERTY_TIMEMAX:
5309 util::Time t;
5310 if ( Value >>= t )
5311 setMax( t );
5313 break;
5314 case BASEPROPERTY_EXTTIMEFORMAT:
5316 sal_Int16 n = sal_Int16();
5317 if ( Value >>= n )
5318 GetAs< TimeField >()->SetExtFormat( (ExtTimeFieldFormat) n );
5320 break;
5321 case BASEPROPERTY_ENFORCE_FORMAT:
5323 bool bEnforce( true );
5324 OSL_VERIFY( Value >>= bEnforce );
5325 GetAs< TimeField >()->EnforceValidValue( bEnforce );
5327 break;
5328 default:
5330 VCLXFormattedSpinField::setProperty( PropertyName, Value );
5336 css::uno::Any VCLXTimeField::getProperty( const OUString& PropertyName ) throw(css::uno::RuntimeException, std::exception)
5338 SolarMutexGuard aGuard;
5340 css::uno::Any aProp;
5341 if ( GetWindow() )
5343 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5344 switch ( nPropType )
5346 case BASEPROPERTY_TIME:
5348 aProp <<= getTime();
5350 break;
5351 case BASEPROPERTY_TIMEMIN:
5353 aProp <<= getMin();
5355 break;
5356 case BASEPROPERTY_TIMEMAX:
5358 aProp <<= getMax();
5360 break;
5361 case BASEPROPERTY_ENFORCE_FORMAT:
5363 aProp <<= GetAs< TimeField >()->IsEnforceValidValue( );
5365 break;
5366 default:
5368 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
5372 return aProp;
5376 // class VCLXNumericField
5379 void VCLXNumericField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
5381 PushPropertyIds( rIds,
5382 BASEPROPERTY_ALIGN,
5383 BASEPROPERTY_BACKGROUNDCOLOR,
5384 BASEPROPERTY_BORDER,
5385 BASEPROPERTY_BORDERCOLOR,
5386 BASEPROPERTY_DECIMALACCURACY,
5387 BASEPROPERTY_DEFAULTCONTROL,
5388 BASEPROPERTY_ENABLED,
5389 BASEPROPERTY_ENABLEVISIBLE,
5390 BASEPROPERTY_FONTDESCRIPTOR,
5391 BASEPROPERTY_HELPTEXT,
5392 BASEPROPERTY_HELPURL,
5393 BASEPROPERTY_NUMSHOWTHOUSANDSEP,
5394 BASEPROPERTY_PRINTABLE,
5395 BASEPROPERTY_READONLY,
5396 BASEPROPERTY_REPEAT,
5397 BASEPROPERTY_REPEAT_DELAY,
5398 BASEPROPERTY_SPIN,
5399 BASEPROPERTY_STRICTFORMAT,
5400 BASEPROPERTY_TABSTOP,
5401 BASEPROPERTY_VALUEMAX_DOUBLE,
5402 BASEPROPERTY_VALUEMIN_DOUBLE,
5403 BASEPROPERTY_VALUESTEP_DOUBLE,
5404 BASEPROPERTY_VALUE_DOUBLE,
5405 BASEPROPERTY_ENFORCE_FORMAT,
5406 BASEPROPERTY_HIDEINACTIVESELECTION,
5407 BASEPROPERTY_VERTICALALIGN,
5408 BASEPROPERTY_WRITING_MODE,
5409 BASEPROPERTY_CONTEXT_WRITING_MODE,
5410 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
5412 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5415 VCLXNumericField::VCLXNumericField()
5419 VCLXNumericField::~VCLXNumericField()
5423 // css::uno::XInterface
5424 css::uno::Any VCLXNumericField::queryInterface( const css::uno::Type & rType ) throw(css::uno::RuntimeException, std::exception)
5426 css::uno::Any aRet = ::cppu::queryInterface( rType,
5427 (static_cast< css::awt::XNumericField* >(this)) );
5428 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
5431 // css::lang::XTypeProvider
5432 IMPL_XTYPEPROVIDER_START( VCLXNumericField )
5433 cppu::UnoType<css::awt::XNumericField>::get(),
5434 VCLXFormattedSpinField::getTypes()
5435 IMPL_XTYPEPROVIDER_END
5437 void VCLXNumericField::setValue( double Value ) throw(css::uno::RuntimeException, std::exception)
5439 SolarMutexGuard aGuard;
5441 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5442 if ( pNumericFormatter )
5444 // shift long value using decimal digits
5445 // (e.g., input 105 using 2 digits returns 1,05)
5446 // Thus, to set a value of 1,05, insert 105 and 2 digits
5447 pNumericFormatter->SetValue(
5448 (long)ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() ) );
5450 // #107218# Call same listeners like VCL would do after user interaction
5451 VclPtr< Edit > pEdit = GetAs< Edit >();
5452 if ( pEdit )
5454 SetSynthesizingVCLEvent( true );
5455 pEdit->SetModifyFlag();
5456 pEdit->Modify();
5457 SetSynthesizingVCLEvent( false );
5462 double VCLXNumericField::getValue() throw(css::uno::RuntimeException, std::exception)
5464 SolarMutexGuard aGuard;
5466 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5467 return pNumericFormatter
5468 ? ImplCalcDoubleValue( (double)pNumericFormatter->GetValue(), pNumericFormatter->GetDecimalDigits() )
5469 : 0;
5472 void VCLXNumericField::setMin( double Value ) throw(css::uno::RuntimeException, std::exception)
5474 SolarMutexGuard aGuard;
5476 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5477 if ( pNumericFormatter )
5478 pNumericFormatter->SetMin(
5479 (long)ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() ) );
5482 double VCLXNumericField::getMin() throw(css::uno::RuntimeException, std::exception)
5484 SolarMutexGuard aGuard;
5486 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5487 return pNumericFormatter
5488 ? ImplCalcDoubleValue( (double)pNumericFormatter->GetMin(), pNumericFormatter->GetDecimalDigits() )
5489 : 0;
5492 void VCLXNumericField::setMax( double Value ) throw(css::uno::RuntimeException, std::exception)
5494 SolarMutexGuard aGuard;
5496 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5497 if ( pNumericFormatter )
5498 pNumericFormatter->SetMax(
5499 (long)ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() ) );
5502 double VCLXNumericField::getMax() throw(css::uno::RuntimeException, std::exception)
5504 SolarMutexGuard aGuard;
5506 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5507 return pNumericFormatter
5508 ? ImplCalcDoubleValue( (double)pNumericFormatter->GetMax(), pNumericFormatter->GetDecimalDigits() )
5509 : 0;
5512 void VCLXNumericField::setFirst( double Value ) throw(css::uno::RuntimeException, std::exception)
5514 SolarMutexGuard aGuard;
5516 VclPtr< NumericField > pNumericField = GetAs< NumericField >();
5517 if ( pNumericField )
5518 pNumericField->SetFirst(
5519 (long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) );
5522 double VCLXNumericField::getFirst() throw(css::uno::RuntimeException, std::exception)
5524 SolarMutexGuard aGuard;
5526 VclPtr< NumericField > pNumericField = GetAs< NumericField >();
5527 return pNumericField
5528 ? ImplCalcDoubleValue( (double)pNumericField->GetFirst(), pNumericField->GetDecimalDigits() )
5529 : 0;
5532 void VCLXNumericField::setLast( double Value ) throw(css::uno::RuntimeException, std::exception)
5534 SolarMutexGuard aGuard;
5536 VclPtr< NumericField > pNumericField = GetAs< NumericField >();
5537 if ( pNumericField )
5538 pNumericField->SetLast(
5539 (long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) );
5542 double VCLXNumericField::getLast() throw(css::uno::RuntimeException, std::exception)
5544 SolarMutexGuard aGuard;
5546 VclPtr< NumericField > pNumericField = GetAs< NumericField >();
5547 return pNumericField
5548 ? ImplCalcDoubleValue( (double)pNumericField->GetLast(), pNumericField->GetDecimalDigits() )
5549 : 0;
5552 void VCLXNumericField::setStrictFormat( sal_Bool bStrict ) throw(css::uno::RuntimeException, std::exception)
5554 VCLXFormattedSpinField::setStrictFormat( bStrict );
5557 sal_Bool VCLXNumericField::isStrictFormat() throw(css::uno::RuntimeException, std::exception)
5559 return VCLXFormattedSpinField::isStrictFormat();
5563 void VCLXNumericField::setSpinSize( double Value ) throw(css::uno::RuntimeException, std::exception)
5565 SolarMutexGuard aGuard;
5567 VclPtr< NumericField > pNumericField = GetAs< NumericField >();
5568 if ( pNumericField )
5569 pNumericField->SetSpinSize(
5570 (long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) );
5573 double VCLXNumericField::getSpinSize() throw(css::uno::RuntimeException, std::exception)
5575 SolarMutexGuard aGuard;
5577 VclPtr< NumericField > pNumericField = GetAs< NumericField >();
5578 return pNumericField
5579 ? ImplCalcDoubleValue( (double)pNumericField->GetSpinSize(), pNumericField->GetDecimalDigits() )
5580 : 0;
5583 void VCLXNumericField::setDecimalDigits( sal_Int16 Value ) throw(css::uno::RuntimeException, std::exception)
5585 SolarMutexGuard aGuard;
5587 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5588 if ( pNumericFormatter )
5590 double n = getValue();
5591 pNumericFormatter->SetDecimalDigits( Value );
5592 setValue( n );
5596 sal_Int16 VCLXNumericField::getDecimalDigits() throw(css::uno::RuntimeException, std::exception)
5598 SolarMutexGuard aGuard;
5600 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5601 return pNumericFormatter ? pNumericFormatter->GetDecimalDigits() : 0;
5604 void VCLXNumericField::setProperty( const OUString& PropertyName, const css::uno::Any& Value) throw(css::uno::RuntimeException, std::exception)
5606 SolarMutexGuard aGuard;
5608 if ( GetWindow() )
5610 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
5612 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5613 switch ( nPropType )
5615 case BASEPROPERTY_VALUE_DOUBLE:
5617 if ( bVoid )
5619 GetAs< NumericField >()->EnableEmptyFieldValue( true );
5620 GetAs< NumericField >()->SetEmptyFieldValue();
5622 else
5624 double d = 0;
5625 if ( Value >>= d )
5626 setValue( d );
5629 break;
5630 case BASEPROPERTY_VALUEMIN_DOUBLE:
5632 double d = 0;
5633 if ( Value >>= d )
5634 setMin( d );
5636 break;
5637 case BASEPROPERTY_VALUEMAX_DOUBLE:
5639 double d = 0;
5640 if ( Value >>= d )
5641 setMax( d );
5643 break;
5644 case BASEPROPERTY_VALUESTEP_DOUBLE:
5646 double d = 0;
5647 if ( Value >>= d )
5648 setSpinSize( d );
5650 break;
5651 case BASEPROPERTY_DECIMALACCURACY:
5653 sal_Int16 n = sal_Int16();
5654 if ( Value >>= n )
5655 setDecimalDigits( n );
5657 break;
5658 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5660 bool b = bool();
5661 if ( Value >>= b )
5662 GetAs< NumericField >()->SetUseThousandSep( b );
5664 break;
5665 default:
5667 VCLXFormattedSpinField::setProperty( PropertyName, Value );
5673 css::uno::Any VCLXNumericField::getProperty( const OUString& PropertyName ) throw(css::uno::RuntimeException, std::exception)
5675 SolarMutexGuard aGuard;
5677 css::uno::Any aProp;
5678 FormatterBase* pFormatter = GetFormatter();
5679 if ( pFormatter )
5681 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5682 switch ( nPropType )
5684 case BASEPROPERTY_VALUE_DOUBLE:
5686 aProp <<= (double) getValue();
5688 break;
5689 case BASEPROPERTY_VALUEMIN_DOUBLE:
5691 aProp <<= (double) getMin();
5693 break;
5694 case BASEPROPERTY_VALUEMAX_DOUBLE:
5696 aProp <<= (double) getMax();
5698 break;
5699 case BASEPROPERTY_VALUESTEP_DOUBLE:
5701 aProp <<= (double) getSpinSize();
5703 break;
5704 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5706 aProp <<= GetAs< NumericField >()->IsUseThousandSep();
5708 break;
5709 default:
5711 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
5715 return aProp;
5719 // ----------------------------------------------------
5720 // class VCLXMetricField
5721 // ----------------------------------------------------
5723 void VCLXMetricField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
5725 PushPropertyIds( rIds,
5726 BASEPROPERTY_ALIGN,
5727 BASEPROPERTY_BACKGROUNDCOLOR,
5728 BASEPROPERTY_BORDER,
5729 BASEPROPERTY_BORDERCOLOR,
5730 BASEPROPERTY_DECIMALACCURACY,
5731 BASEPROPERTY_DEFAULTCONTROL,
5732 BASEPROPERTY_ENABLED,
5733 BASEPROPERTY_ENABLEVISIBLE,
5734 BASEPROPERTY_FONTDESCRIPTOR,
5735 BASEPROPERTY_HELPTEXT,
5736 BASEPROPERTY_HELPURL,
5737 BASEPROPERTY_NUMSHOWTHOUSANDSEP,
5738 BASEPROPERTY_PRINTABLE,
5739 BASEPROPERTY_READONLY,
5740 BASEPROPERTY_REPEAT,
5741 BASEPROPERTY_REPEAT_DELAY,
5742 BASEPROPERTY_SPIN,
5743 BASEPROPERTY_STRICTFORMAT,
5744 BASEPROPERTY_TABSTOP,
5745 BASEPROPERTY_ENFORCE_FORMAT,
5746 BASEPROPERTY_HIDEINACTIVESELECTION,
5747 BASEPROPERTY_UNIT,
5748 BASEPROPERTY_CUSTOMUNITTEXT,
5749 BASEPROPERTY_WRITING_MODE,
5750 BASEPROPERTY_CONTEXT_WRITING_MODE,
5751 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
5753 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5756 VCLXMetricField::VCLXMetricField()
5760 VCLXMetricField::~VCLXMetricField()
5764 MetricFormatter *VCLXMetricField::GetMetricFormatter() throw(css::uno::RuntimeException)
5766 MetricFormatter *pFormatter = static_cast<MetricFormatter *>(GetFormatter());
5767 if (!pFormatter)
5768 throw css::uno::RuntimeException();
5769 return pFormatter;
5772 MetricField *VCLXMetricField::GetMetricField() throw(css::uno::RuntimeException)
5774 VclPtr< MetricField > pField = GetAs< MetricField >();
5775 if (!pField)
5776 throw css::uno::RuntimeException();
5777 return pField;
5780 // css::uno::XInterface
5781 css::uno::Any VCLXMetricField::queryInterface( const css::uno::Type & rType ) throw(css::uno::RuntimeException, std::exception)
5783 css::uno::Any aRet = ::cppu::queryInterface( rType,
5784 (static_cast< css::awt::XMetricField* >(this)) );
5785 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
5788 // css::lang::XTypeProvider
5789 IMPL_XTYPEPROVIDER_START( VCLXMetricField )
5790 cppu::UnoType<css::awt::XMetricField>::get(),
5791 VCLXFormattedSpinField::getTypes()
5792 IMPL_XTYPEPROVIDER_END
5794 // FIXME: later ...
5795 #define MetricUnitUnoToVcl(a) ((FieldUnit)(a))
5797 #define METRIC_MAP_PAIR(method,parent) \
5798 sal_Int64 VCLXMetricField::get##method( sal_Int16 nUnit ) throw (css::uno::RuntimeException, std::exception) \
5800 SolarMutexGuard aGuard; \
5801 return GetMetric##parent()->Get##method( MetricUnitUnoToVcl( nUnit ) ); \
5803 void VCLXMetricField::set##method( sal_Int64 nValue, sal_Int16 nUnit ) throw (css::uno::RuntimeException, std::exception) \
5805 SolarMutexGuard aGuard; \
5806 GetMetric##parent()->Set##method( nValue, MetricUnitUnoToVcl( nUnit ) ); \
5809 METRIC_MAP_PAIR(Min, Formatter)
5810 METRIC_MAP_PAIR(Max, Formatter)
5811 METRIC_MAP_PAIR(First, Field)
5812 METRIC_MAP_PAIR(Last, Field)
5814 #undef METRIC_MAP_PAIR
5816 ::sal_Int64 VCLXMetricField::getValue( ::sal_Int16 nUnit ) throw (css::uno::RuntimeException, std::exception)
5818 SolarMutexGuard aGuard;
5819 return GetMetricFormatter()->GetValue( MetricUnitUnoToVcl( nUnit ) );
5822 ::sal_Int64 VCLXMetricField::getCorrectedValue( ::sal_Int16 nUnit ) throw (css::uno::RuntimeException, std::exception)
5824 SolarMutexGuard aGuard;
5825 return GetMetricFormatter()->GetCorrectedValue( MetricUnitUnoToVcl( nUnit ) );
5828 // FIXME: acute cut/paste evilness - move this to the parent Edit class ?
5829 void VCLXMetricField::CallListeners()
5831 // #107218# Call same listeners like VCL would do after user interaction
5832 VclPtr< Edit > pEdit = GetAs< Edit >();
5833 if ( pEdit )
5835 SetSynthesizingVCLEvent( true );
5836 pEdit->SetModifyFlag();
5837 pEdit->Modify();
5838 SetSynthesizingVCLEvent( false );
5842 void VCLXMetricField::setValue( ::sal_Int64 Value, ::sal_Int16 Unit ) throw (css::uno::RuntimeException, std::exception)
5844 SolarMutexGuard aGuard;
5845 GetMetricFormatter()->SetValue( Value, MetricUnitUnoToVcl( Unit ) );
5846 CallListeners();
5849 void VCLXMetricField::setUserValue( ::sal_Int64 Value, ::sal_Int16 Unit ) throw (css::uno::RuntimeException, std::exception)
5851 SolarMutexGuard aGuard;
5852 GetMetricFormatter()->SetUserValue( Value, MetricUnitUnoToVcl( Unit ) );
5853 CallListeners();
5856 void VCLXMetricField::setStrictFormat( sal_Bool bStrict ) throw(css::uno::RuntimeException, std::exception)
5858 VCLXFormattedSpinField::setStrictFormat( bStrict );
5861 sal_Bool VCLXMetricField::isStrictFormat() throw(css::uno::RuntimeException, std::exception)
5863 return VCLXFormattedSpinField::isStrictFormat();
5866 void VCLXMetricField::setSpinSize( sal_Int64 Value ) throw(css::uno::RuntimeException, std::exception)
5868 SolarMutexGuard aGuard;
5869 GetMetricField()->SetSpinSize( Value );
5872 sal_Int64 VCLXMetricField::getSpinSize() throw(css::uno::RuntimeException, std::exception)
5874 SolarMutexGuard aGuard;
5875 return GetMetricField()->GetSpinSize();
5878 void VCLXMetricField::setDecimalDigits( sal_Int16 Value ) throw(css::uno::RuntimeException, std::exception)
5880 SolarMutexGuard aGuard;
5881 GetMetricFormatter()->SetDecimalDigits( Value );
5884 sal_Int16 VCLXMetricField::getDecimalDigits() throw(css::uno::RuntimeException, std::exception)
5886 SolarMutexGuard aGuard;
5888 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5889 return pNumericFormatter ? pNumericFormatter->GetDecimalDigits() : 0;
5892 void VCLXMetricField::setProperty( const OUString& PropertyName, const css::uno::Any& Value) throw(css::uno::RuntimeException, std::exception)
5894 SolarMutexGuard aGuard;
5896 if ( GetWindow() )
5898 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5899 switch ( nPropType )
5901 case BASEPROPERTY_DECIMALACCURACY:
5903 sal_Int16 n = 0;
5904 if ( Value >>= n )
5905 setDecimalDigits( n );
5906 break;
5908 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5910 bool b = false;
5911 if ( Value >>= b )
5912 GetAs< NumericField >()->SetUseThousandSep( b );
5914 break;
5915 case BASEPROPERTY_UNIT:
5917 sal_uInt16 nVal = 0;
5918 if ( Value >>= nVal )
5919 GetAs< MetricField >()->SetUnit( (FieldUnit) nVal );
5920 break;
5922 case BASEPROPERTY_CUSTOMUNITTEXT:
5924 OUString aStr;
5925 if ( Value >>= aStr )
5926 GetAs< MetricField >()->SetCustomUnitText( aStr );
5927 break;
5929 default:
5931 VCLXFormattedSpinField::setProperty( PropertyName, Value );
5932 break;
5938 css::uno::Any VCLXMetricField::getProperty( const OUString& PropertyName ) throw(css::uno::RuntimeException, std::exception)
5940 SolarMutexGuard aGuard;
5942 css::uno::Any aProp;
5943 FormatterBase* pFormatter = GetFormatter();
5944 if ( pFormatter )
5946 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5947 switch ( nPropType )
5949 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5950 aProp <<= GetAs< NumericField >()->IsUseThousandSep();
5951 break;
5952 case BASEPROPERTY_UNIT:
5953 aProp <<= (sal_uInt16) (GetAs< MetricField >()->GetUnit());
5954 break;
5955 case BASEPROPERTY_CUSTOMUNITTEXT:
5956 aProp <<= OUString( GetAs< MetricField >()->GetCustomUnitText() );
5957 break;
5958 default:
5960 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
5961 break;
5965 return aProp;
5969 // class VCLXCurrencyField
5972 void VCLXCurrencyField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
5974 PushPropertyIds( rIds,
5975 BASEPROPERTY_ALIGN,
5976 BASEPROPERTY_BACKGROUNDCOLOR,
5977 BASEPROPERTY_BORDER,
5978 BASEPROPERTY_BORDERCOLOR,
5979 BASEPROPERTY_CURRENCYSYMBOL,
5980 BASEPROPERTY_CURSYM_POSITION,
5981 BASEPROPERTY_DECIMALACCURACY,
5982 BASEPROPERTY_DEFAULTCONTROL,
5983 BASEPROPERTY_ENABLED,
5984 BASEPROPERTY_ENABLEVISIBLE,
5985 BASEPROPERTY_FONTDESCRIPTOR,
5986 BASEPROPERTY_HELPTEXT,
5987 BASEPROPERTY_HELPURL,
5988 BASEPROPERTY_NUMSHOWTHOUSANDSEP,
5989 BASEPROPERTY_PRINTABLE,
5990 BASEPROPERTY_READONLY,
5991 BASEPROPERTY_REPEAT,
5992 BASEPROPERTY_REPEAT_DELAY,
5993 BASEPROPERTY_SPIN,
5994 BASEPROPERTY_STRICTFORMAT,
5995 BASEPROPERTY_TABSTOP,
5996 BASEPROPERTY_VALUEMAX_DOUBLE,
5997 BASEPROPERTY_VALUEMIN_DOUBLE,
5998 BASEPROPERTY_VALUESTEP_DOUBLE,
5999 BASEPROPERTY_VALUE_DOUBLE,
6000 BASEPROPERTY_ENFORCE_FORMAT,
6001 BASEPROPERTY_HIDEINACTIVESELECTION,
6002 BASEPROPERTY_VERTICALALIGN,
6003 BASEPROPERTY_WRITING_MODE,
6004 BASEPROPERTY_CONTEXT_WRITING_MODE,
6005 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
6007 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
6010 VCLXCurrencyField::VCLXCurrencyField()
6014 VCLXCurrencyField::~VCLXCurrencyField()
6018 // css::uno::XInterface
6019 css::uno::Any VCLXCurrencyField::queryInterface( const css::uno::Type & rType ) throw(css::uno::RuntimeException, std::exception)
6021 css::uno::Any aRet = ::cppu::queryInterface( rType,
6022 (static_cast< css::awt::XCurrencyField* >(this)) );
6023 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
6026 // css::lang::XTypeProvider
6027 IMPL_XTYPEPROVIDER_START( VCLXCurrencyField )
6028 cppu::UnoType<css::awt::XCurrencyField>::get(),
6029 VCLXFormattedSpinField::getTypes()
6030 IMPL_XTYPEPROVIDER_END
6032 void VCLXCurrencyField::setValue( double Value ) throw(css::uno::RuntimeException, std::exception)
6034 SolarMutexGuard aGuard;
6036 LongCurrencyFormatter* pCurrencyFormatter = static_cast<LongCurrencyFormatter*>(GetFormatter());
6037 if ( pCurrencyFormatter )
6039 // shift long value using decimal digits
6040 // (e.g., input 105 using 2 digits returns 1,05)
6041 // Thus, to set a value of 1,05, insert 105 and 2 digits
6042 pCurrencyFormatter->SetValue(
6043 ImplCalcLongValue( Value, pCurrencyFormatter->GetDecimalDigits() ) );
6045 // #107218# Call same listeners like VCL would do after user interaction
6046 VclPtr< Edit > pEdit = GetAs< Edit >();
6047 if ( pEdit )
6049 SetSynthesizingVCLEvent( true );
6050 pEdit->SetModifyFlag();
6051 pEdit->Modify();
6052 SetSynthesizingVCLEvent( false );
6057 double VCLXCurrencyField::getValue() throw(css::uno::RuntimeException, std::exception)
6059 SolarMutexGuard aGuard;
6061 LongCurrencyFormatter* pCurrencyFormatter = static_cast<LongCurrencyFormatter*>(GetFormatter());
6062 return pCurrencyFormatter
6063 ? ImplCalcDoubleValue( (double)pCurrencyFormatter->GetValue(), pCurrencyFormatter->GetDecimalDigits() )
6064 : 0;
6067 void VCLXCurrencyField::setMin( double Value ) throw(css::uno::RuntimeException, std::exception)
6069 SolarMutexGuard aGuard;
6071 LongCurrencyFormatter* pCurrencyFormatter = static_cast<LongCurrencyFormatter*>(GetFormatter());
6072 if ( pCurrencyFormatter )
6073 pCurrencyFormatter->SetMin(
6074 ImplCalcLongValue( Value, pCurrencyFormatter->GetDecimalDigits() ) );
6077 double VCLXCurrencyField::getMin() throw(css::uno::RuntimeException, std::exception)
6079 SolarMutexGuard aGuard;
6081 LongCurrencyFormatter* pCurrencyFormatter = static_cast<LongCurrencyFormatter*>(GetFormatter());
6082 return pCurrencyFormatter
6083 ? ImplCalcDoubleValue( (double)pCurrencyFormatter->GetMin(), pCurrencyFormatter->GetDecimalDigits() )
6084 : 0;
6087 void VCLXCurrencyField::setMax( double Value ) throw(css::uno::RuntimeException, std::exception)
6089 SolarMutexGuard aGuard;
6091 LongCurrencyFormatter* pCurrencyFormatter = static_cast<LongCurrencyFormatter*>(GetFormatter());
6092 if ( pCurrencyFormatter )
6093 pCurrencyFormatter->SetMax(
6094 ImplCalcLongValue( Value, pCurrencyFormatter->GetDecimalDigits() ) );
6097 double VCLXCurrencyField::getMax() throw(css::uno::RuntimeException, std::exception)
6099 SolarMutexGuard aGuard;
6101 LongCurrencyFormatter* pCurrencyFormatter = static_cast<LongCurrencyFormatter*>(GetFormatter());
6102 return pCurrencyFormatter
6103 ? ImplCalcDoubleValue( (double)pCurrencyFormatter->GetMax(), pCurrencyFormatter->GetDecimalDigits() )
6104 : 0;
6107 void VCLXCurrencyField::setFirst( double Value ) throw(css::uno::RuntimeException, std::exception)
6109 SolarMutexGuard aGuard;
6111 VclPtr< LongCurrencyField > pCurrencyField = GetAs< LongCurrencyField >();
6112 if ( pCurrencyField )
6113 pCurrencyField->SetFirst(
6114 ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) );
6117 double VCLXCurrencyField::getFirst() throw(css::uno::RuntimeException, std::exception)
6119 SolarMutexGuard aGuard;
6121 VclPtr< LongCurrencyField > pCurrencyField = GetAs< LongCurrencyField >();
6122 return pCurrencyField
6123 ? ImplCalcDoubleValue( (double)pCurrencyField->GetFirst(), pCurrencyField->GetDecimalDigits() )
6124 : 0;
6127 void VCLXCurrencyField::setLast( double Value ) throw(css::uno::RuntimeException, std::exception)
6129 SolarMutexGuard aGuard;
6131 VclPtr< LongCurrencyField > pCurrencyField = GetAs< LongCurrencyField >();
6132 if ( pCurrencyField )
6133 pCurrencyField->SetLast(
6134 ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) );
6137 double VCLXCurrencyField::getLast() throw(css::uno::RuntimeException, std::exception)
6139 SolarMutexGuard aGuard;
6141 VclPtr< LongCurrencyField > pCurrencyField = GetAs< LongCurrencyField >();
6142 return pCurrencyField
6143 ? ImplCalcDoubleValue( (double)pCurrencyField->GetLast(), pCurrencyField->GetDecimalDigits() )
6144 : 0;
6147 void VCLXCurrencyField::setSpinSize( double Value ) throw(css::uno::RuntimeException, std::exception)
6149 SolarMutexGuard aGuard;
6151 VclPtr< LongCurrencyField > pCurrencyField = GetAs< LongCurrencyField >();
6152 if ( pCurrencyField )
6153 pCurrencyField->SetSpinSize(
6154 ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) );
6157 double VCLXCurrencyField::getSpinSize() throw(css::uno::RuntimeException, std::exception)
6159 SolarMutexGuard aGuard;
6161 VclPtr< LongCurrencyField > pCurrencyField = GetAs< LongCurrencyField >();
6162 return pCurrencyField
6163 ? ImplCalcDoubleValue( (double)pCurrencyField->GetSpinSize(), pCurrencyField->GetDecimalDigits() )
6164 : 0;
6167 void VCLXCurrencyField::setStrictFormat( sal_Bool bStrict ) throw(css::uno::RuntimeException, std::exception)
6169 VCLXFormattedSpinField::setStrictFormat( bStrict );
6172 sal_Bool VCLXCurrencyField::isStrictFormat() throw(css::uno::RuntimeException, std::exception)
6174 return VCLXFormattedSpinField::isStrictFormat();
6178 void VCLXCurrencyField::setDecimalDigits( sal_Int16 Value ) throw(css::uno::RuntimeException, std::exception)
6180 SolarMutexGuard aGuard;
6182 LongCurrencyFormatter* pCurrencyFormatter = static_cast<LongCurrencyFormatter*>(GetFormatter());
6183 if ( pCurrencyFormatter )
6185 double n = getValue();
6186 pCurrencyFormatter->SetDecimalDigits( Value );
6187 setValue( n );
6191 sal_Int16 VCLXCurrencyField::getDecimalDigits() throw(css::uno::RuntimeException, std::exception)
6193 SolarMutexGuard aGuard;
6195 LongCurrencyFormatter* pCurrencyFormatter = static_cast<LongCurrencyFormatter*>(GetFormatter());
6196 return pCurrencyFormatter ? pCurrencyFormatter->GetDecimalDigits() : 0;
6199 void VCLXCurrencyField::setProperty( const OUString& PropertyName, const css::uno::Any& Value) throw(css::uno::RuntimeException, std::exception)
6201 SolarMutexGuard aGuard;
6203 if ( GetWindow() )
6205 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
6207 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6208 switch ( nPropType )
6210 case BASEPROPERTY_VALUE_DOUBLE:
6212 if ( bVoid )
6214 GetAs< LongCurrencyField >()->EnableEmptyFieldValue( true );
6215 GetAs< LongCurrencyField >()->SetEmptyFieldValue();
6217 else
6219 double d = 0;
6220 if ( Value >>= d )
6221 setValue( d );
6224 break;
6225 case BASEPROPERTY_VALUEMIN_DOUBLE:
6227 double d = 0;
6228 if ( Value >>= d )
6229 setMin( d );
6231 break;
6232 case BASEPROPERTY_VALUEMAX_DOUBLE:
6234 double d = 0;
6235 if ( Value >>= d )
6236 setMax( d );
6238 break;
6239 case BASEPROPERTY_VALUESTEP_DOUBLE:
6241 double d = 0;
6242 if ( Value >>= d )
6243 setSpinSize( d );
6245 break;
6246 case BASEPROPERTY_DECIMALACCURACY:
6248 sal_Int16 n = sal_Int16();
6249 if ( Value >>= n )
6250 setDecimalDigits( n );
6252 break;
6253 case BASEPROPERTY_CURRENCYSYMBOL:
6255 OUString aString;
6256 if ( Value >>= aString )
6257 GetAs< LongCurrencyField >()->SetCurrencySymbol( aString );
6259 break;
6260 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
6262 bool b = bool();
6263 if ( Value >>= b )
6264 GetAs< LongCurrencyField >()->SetUseThousandSep( b );
6266 break;
6267 default:
6269 VCLXFormattedSpinField::setProperty( PropertyName, Value );
6275 css::uno::Any VCLXCurrencyField::getProperty( const OUString& PropertyName ) throw(css::uno::RuntimeException, std::exception)
6277 SolarMutexGuard aGuard;
6279 css::uno::Any aProp;
6280 FormatterBase* pFormatter = GetFormatter();
6281 if ( pFormatter )
6283 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6284 switch ( nPropType )
6286 case BASEPROPERTY_VALUE_DOUBLE:
6288 aProp <<= (double) getValue();
6290 break;
6291 case BASEPROPERTY_VALUEMIN_DOUBLE:
6293 aProp <<= (double) getMin();
6295 break;
6296 case BASEPROPERTY_VALUEMAX_DOUBLE:
6298 aProp <<= (double) getMax();
6300 break;
6301 case BASEPROPERTY_VALUESTEP_DOUBLE:
6303 aProp <<= (double) getSpinSize();
6305 break;
6306 case BASEPROPERTY_CURRENCYSYMBOL:
6308 aProp <<= OUString( GetAs< LongCurrencyField >()->GetCurrencySymbol() );
6310 break;
6311 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
6313 aProp <<= GetAs< LongCurrencyField >()->IsUseThousandSep();
6315 break;
6316 default:
6318 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
6322 return aProp;
6326 // class VCLXPatternField
6329 void VCLXPatternField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
6331 PushPropertyIds( rIds,
6332 BASEPROPERTY_ALIGN,
6333 BASEPROPERTY_BACKGROUNDCOLOR,
6334 BASEPROPERTY_BORDER,
6335 BASEPROPERTY_BORDERCOLOR,
6336 BASEPROPERTY_DEFAULTCONTROL,
6337 BASEPROPERTY_EDITMASK,
6338 BASEPROPERTY_ENABLED,
6339 BASEPROPERTY_ENABLEVISIBLE,
6340 BASEPROPERTY_FONTDESCRIPTOR,
6341 BASEPROPERTY_HELPTEXT,
6342 BASEPROPERTY_HELPURL,
6343 BASEPROPERTY_LITERALMASK,
6344 BASEPROPERTY_MAXTEXTLEN,
6345 BASEPROPERTY_PRINTABLE,
6346 BASEPROPERTY_READONLY,
6347 BASEPROPERTY_STRICTFORMAT,
6348 BASEPROPERTY_TABSTOP,
6349 BASEPROPERTY_TEXT,
6350 BASEPROPERTY_HIDEINACTIVESELECTION,
6351 BASEPROPERTY_VERTICALALIGN,
6352 BASEPROPERTY_WRITING_MODE,
6353 BASEPROPERTY_CONTEXT_WRITING_MODE,
6354 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
6356 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
6359 VCLXPatternField::VCLXPatternField()
6363 VCLXPatternField::~VCLXPatternField()
6367 // css::uno::XInterface
6368 css::uno::Any VCLXPatternField::queryInterface( const css::uno::Type & rType ) throw(css::uno::RuntimeException, std::exception)
6370 css::uno::Any aRet = ::cppu::queryInterface( rType,
6371 (static_cast< css::awt::XPatternField* >(this)) );
6372 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
6375 // css::lang::XTypeProvider
6376 IMPL_XTYPEPROVIDER_START( VCLXPatternField )
6377 cppu::UnoType<css::awt::XPatternField>::get(),
6378 VCLXFormattedSpinField::getTypes()
6379 IMPL_XTYPEPROVIDER_END
6381 void VCLXPatternField::setMasks( const OUString& EditMask, const OUString& LiteralMask ) throw(css::uno::RuntimeException, std::exception)
6383 SolarMutexGuard aGuard;
6385 VclPtr< PatternField > pPatternField = GetAs< PatternField >();
6386 if ( pPatternField )
6388 pPatternField->SetMask( OUStringToOString(EditMask, RTL_TEXTENCODING_ASCII_US), LiteralMask );
6392 void VCLXPatternField::getMasks( OUString& EditMask, OUString& LiteralMask ) throw(css::uno::RuntimeException, std::exception)
6394 SolarMutexGuard aGuard;
6396 VclPtr< PatternField > pPatternField = GetAs< PatternField >();
6397 if ( pPatternField )
6399 EditMask = OStringToOUString(pPatternField->GetEditMask(), RTL_TEXTENCODING_ASCII_US);
6400 LiteralMask = pPatternField->GetLiteralMask();
6404 void VCLXPatternField::setString( const OUString& Str ) throw(css::uno::RuntimeException, std::exception)
6406 SolarMutexGuard aGuard;
6407 VclPtr< PatternField > pPatternField = GetAs< PatternField >();
6408 if ( pPatternField )
6409 pPatternField->SetString( Str );
6412 OUString VCLXPatternField::getString() throw(css::uno::RuntimeException, std::exception)
6414 SolarMutexGuard aGuard;
6416 OUString aString;
6417 VclPtr< PatternField > pPatternField = GetAs< PatternField >();
6418 if ( pPatternField )
6419 aString = pPatternField->GetString();
6420 return aString;
6423 void VCLXPatternField::setStrictFormat( sal_Bool bStrict ) throw(css::uno::RuntimeException, std::exception)
6425 VCLXFormattedSpinField::setStrictFormat( bStrict );
6428 sal_Bool VCLXPatternField::isStrictFormat() throw(css::uno::RuntimeException, std::exception)
6430 return VCLXFormattedSpinField::isStrictFormat();
6433 void VCLXPatternField::setProperty( const OUString& PropertyName, const css::uno::Any& Value) throw(css::uno::RuntimeException, std::exception)
6435 SolarMutexGuard aGuard;
6437 if ( GetWindow() )
6439 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6440 switch ( nPropType )
6442 case BASEPROPERTY_EDITMASK:
6443 case BASEPROPERTY_LITERALMASK:
6445 OUString aString;
6446 if ( Value >>= aString )
6448 OUString aEditMask, aLiteralMask;
6449 getMasks( aEditMask, aLiteralMask );
6450 if ( nPropType == BASEPROPERTY_EDITMASK )
6451 aEditMask = aString;
6452 else
6453 aLiteralMask = aString;
6454 setMasks( aEditMask, aLiteralMask );
6457 break;
6458 default:
6460 VCLXFormattedSpinField::setProperty( PropertyName, Value );
6466 css::uno::Any VCLXPatternField::getProperty( const OUString& PropertyName ) throw(css::uno::RuntimeException, std::exception)
6468 SolarMutexGuard aGuard;
6470 css::uno::Any aProp;
6471 if ( GetWindow() )
6473 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6474 switch ( nPropType )
6476 case BASEPROPERTY_EDITMASK:
6477 case BASEPROPERTY_LITERALMASK:
6479 OUString aEditMask, aLiteralMask;
6480 getMasks( aEditMask, aLiteralMask );
6481 if ( nPropType == BASEPROPERTY_EDITMASK )
6482 aProp <<= aEditMask;
6483 else
6484 aProp <<= aLiteralMask;
6486 break;
6487 default:
6489 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
6493 return aProp;
6497 // class VCLXToolBox
6499 VCLXToolBox::VCLXToolBox()
6503 VCLXToolBox::~VCLXToolBox()
6507 css::uno::Reference< css::accessibility::XAccessibleContext > VCLXToolBox::CreateAccessibleContext()
6509 return getAccessibleFactory().createAccessibleContext( this );
6513 // class VCLXFrame
6515 VCLXFrame::VCLXFrame()
6519 void VCLXFrame::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
6521 PushPropertyIds( rIds,
6522 BASEPROPERTY_BACKGROUNDCOLOR,
6523 BASEPROPERTY_DEFAULTCONTROL,
6524 BASEPROPERTY_ENABLED,
6525 BASEPROPERTY_ENABLEVISIBLE,
6526 BASEPROPERTY_FONTDESCRIPTOR,
6527 BASEPROPERTY_GRAPHIC,
6528 BASEPROPERTY_HELPTEXT,
6529 BASEPROPERTY_HELPURL,
6530 BASEPROPERTY_PRINTABLE,
6531 BASEPROPERTY_LABEL,
6533 VCLXContainer::ImplGetPropertyIds( rIds );
6536 VCLXFrame::~VCLXFrame()
6540 css::uno::Any SAL_CALL VCLXFrame::queryInterface(const css::uno::Type & rType )
6541 throw(css::uno::RuntimeException, std::exception)
6543 return VCLXContainer::queryInterface( rType );
6546 // css::lang::XTypeProvider
6547 IMPL_XTYPEPROVIDER_START( VCLXFrame )
6548 VCLXContainer::getTypes()
6549 IMPL_XTYPEPROVIDER_END
6551 // css::awt::XView
6552 void SAL_CALL VCLXFrame::draw( sal_Int32 nX, sal_Int32 nY )
6553 throw(css::uno::RuntimeException, std::exception)
6555 SolarMutexGuard aGuard;
6556 VclPtr< vcl::Window > pWindow = GetWindow();
6558 if ( pWindow )
6560 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
6561 if ( !pDev )
6562 pDev = pWindow->GetParent();
6564 Size aSize = pDev->PixelToLogic( pWindow->GetSizePixel() );
6565 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
6567 pWindow->Draw( pDev, aPos, aSize, DrawFlags::NoControls );
6571 // css::awt::XDevice,
6572 css::awt::DeviceInfo SAL_CALL VCLXFrame::getInfo()
6573 throw(css::uno::RuntimeException, std::exception)
6575 css::awt::DeviceInfo aInfo = VCLXDevice::getInfo();
6576 return aInfo;
6579 void SAL_CALL VCLXFrame::setProperty(
6580 const OUString& PropertyName,
6581 const css::uno::Any& Value )
6582 throw(css::uno::RuntimeException, std::exception)
6584 SolarMutexGuard aGuard;
6586 VCLXContainer::setProperty( PropertyName, Value );
6589 void VCLXFrame::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
6591 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
6592 VCLXContainer::ProcessWindowEvent( rVclWindowEvent );
6595 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */