bump product version to 5.0.4.1
[LibreOffice.git] / toolkit / source / awt / vclxwindows.cxx
blob2476e1f1151c8ff41932c25a45de582f4ef76242
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <toolkit/awt/vclxwindows.hxx>
21 #include "toolkit/awt/scrollabledialog.hxx"
22 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
23 #include <com/sun/star/graphic/GraphicProvider.hpp>
24 #include <com/sun/star/graphic/XGraphicProvider.hpp>
25 #include <toolkit/helper/vclunohelper.hxx>
26 #include <toolkit/helper/macros.hxx>
27 #include <toolkit/helper/property.hxx>
28 #include <toolkit/helper/convert.hxx>
29 #include <cppuhelper/typeprovider.hxx>
30 #include <cppuhelper/queryinterface.hxx>
31 #include <com/sun/star/awt/VisualEffect.hpp>
32 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
33 #include <com/sun/star/system/SystemShellExecute.hpp>
34 #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
35 #include <com/sun/star/resource/XStringResourceResolver.hpp>
36 #include <com/sun/star/awt/ImageScaleMode.hpp>
37 #include <com/sun/star/awt/XItemList.hpp>
38 #include <comphelper/namedvaluecollection.hxx>
39 #include <comphelper/processfactory.hxx>
41 #include <vcl/button.hxx>
42 #include <vcl/lstbox.hxx>
43 #include <vcl/combobox.hxx>
44 #include <vcl/field.hxx>
45 #include <vcl/fixedhyper.hxx>
46 #include <vcl/longcurr.hxx>
47 #include <vcl/imgctrl.hxx>
48 #include <vcl/dialog.hxx>
49 #include <vcl/msgbox.hxx>
50 #include <vcl/scrbar.hxx>
51 #include <vcl/svapp.hxx>
52 #include <vcl/tabpage.hxx>
53 #include <vcl/tabctrl.hxx>
54 #include <vcl/settings.hxx>
55 #include <tools/diagnose_ex.h>
57 #include <boost/bind.hpp>
58 #include <boost/function.hpp>
60 #include <vcl/group.hxx>
62 #include "helper/accessibilityclient.hxx"
63 #include "helper/imagealign.hxx"
64 #include "helper/tkresmgr.hxx"
65 #include "vclxwindows_internal.hxx"
67 using ::com::sun::star::uno::Any;
68 using ::com::sun::star::uno::Reference;
69 using ::com::sun::star::uno::makeAny;
70 using ::com::sun::star::uno::RuntimeException;
71 using ::com::sun::star::lang::EventObject;
72 using ::com::sun::star::awt::ItemListEvent;
73 using ::com::sun::star::awt::XItemList;
74 using ::com::sun::star::graphic::XGraphic;
75 using ::com::sun::star::graphic::XGraphicProvider;
77 using namespace ::com::sun::star;
78 using namespace ::com::sun::star::awt::VisualEffect;
79 namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode;
81 static double ImplCalcLongValue( double nValue, sal_uInt16 nDigits )
83 double n = nValue;
84 for ( sal_uInt16 d = 0; d < nDigits; d++ )
85 n *= 10;
86 return n;
89 static double ImplCalcDoubleValue( double nValue, sal_uInt16 nDigits )
91 double n = nValue;
92 for ( sal_uInt16 d = 0; d < nDigits; d++ )
93 n /= 10;
94 return n;
97 namespace toolkit
99 /** sets the "face color" for button like controls (scroll bar, spin button)
101 void setButtonLikeFaceColor( vcl::Window* _pWindow, const ::com::sun::star::uno::Any& _rColorValue )
103 AllSettings aSettings = _pWindow->GetSettings();
104 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
106 if ( !_rColorValue.hasValue() )
108 const StyleSettings& aAppStyle = Application::GetSettings().GetStyleSettings();
109 aStyleSettings.SetFaceColor( aAppStyle.GetFaceColor( ) );
110 aStyleSettings.SetCheckedColor( aAppStyle.GetCheckedColor( ) );
111 aStyleSettings.SetLightBorderColor( aAppStyle.GetLightBorderColor() );
112 aStyleSettings.SetLightColor( aAppStyle.GetLightColor() );
113 aStyleSettings.SetShadowColor( aAppStyle.GetShadowColor() );
114 aStyleSettings.SetDarkShadowColor( aAppStyle.GetDarkShadowColor() );
116 else
118 sal_Int32 nBackgroundColor = 0;
119 _rColorValue >>= nBackgroundColor;
120 aStyleSettings.SetFaceColor( nBackgroundColor );
122 // for the real background (everything except the buttons and the thumb),
123 // use an average between the desired color and "white"
124 Color aWhite( COL_WHITE );
125 Color aBackground( nBackgroundColor );
126 aBackground.SetRed( ( aBackground.GetRed() + aWhite.GetRed() ) / 2 );
127 aBackground.SetGreen( ( aBackground.GetGreen() + aWhite.GetGreen() ) / 2 );
128 aBackground.SetBlue( ( aBackground.GetBlue() + aWhite.GetBlue() ) / 2 );
129 aStyleSettings.SetCheckedColor( aBackground );
131 sal_Int32 nBackgroundLuminance = Color( nBackgroundColor ).GetLuminance();
132 sal_Int32 nWhiteLuminance = Color( COL_WHITE ).GetLuminance();
134 Color aLightShadow( nBackgroundColor );
135 aLightShadow.IncreaseLuminance( (sal_uInt8)( ( nWhiteLuminance - nBackgroundLuminance ) * 2 / 3 ) );
136 aStyleSettings.SetLightBorderColor( aLightShadow );
138 Color aLight( nBackgroundColor );
139 aLight.IncreaseLuminance( (sal_uInt8)( ( nWhiteLuminance - nBackgroundLuminance ) * 1 / 3 ) );
140 aStyleSettings.SetLightColor( aLight );
142 Color aShadow( nBackgroundColor );
143 aShadow.DecreaseLuminance( (sal_uInt8)( nBackgroundLuminance * 1 / 3 ) );
144 aStyleSettings.SetShadowColor( aShadow );
146 Color aDarkShadow( nBackgroundColor );
147 aDarkShadow.DecreaseLuminance( (sal_uInt8)( nBackgroundLuminance * 2 / 3 ) );
148 aStyleSettings.SetDarkShadowColor( aDarkShadow );
151 aSettings.SetStyleSettings( aStyleSettings );
152 _pWindow->SetSettings( aSettings, true );
155 Any getButtonLikeFaceColor( const vcl::Window* _pWindow )
157 sal_Int32 nBackgroundColor = _pWindow->GetSettings().GetStyleSettings().GetFaceColor().GetColor();
158 return makeAny( nBackgroundColor );
161 static void adjustBooleanWindowStyle( const Any& _rValue, vcl::Window* _pWindow, WinBits _nBits, bool _bInverseSemantics )
163 WinBits nStyle = _pWindow->GetStyle();
164 bool bValue( false );
165 OSL_VERIFY( _rValue >>= bValue );
166 if ( bValue != _bInverseSemantics )
167 nStyle |= _nBits;
168 else
169 nStyle &= ~_nBits;
170 _pWindow->SetStyle( nStyle );
173 static void setVisualEffect( const Any& _rValue, vcl::Window* _pWindow )
175 AllSettings aSettings = _pWindow->GetSettings();
176 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
178 sal_Int16 nStyle = LOOK3D;
179 OSL_VERIFY( _rValue >>= nStyle );
180 switch ( nStyle )
182 case FLAT:
183 aStyleSettings.SetOptions( aStyleSettings.GetOptions() | StyleSettingsOptions::Mono );
184 break;
185 case LOOK3D:
186 default:
187 aStyleSettings.SetOptions( aStyleSettings.GetOptions() & ~StyleSettingsOptions::Mono );
189 aSettings.SetStyleSettings( aStyleSettings );
190 _pWindow->SetSettings( aSettings );
193 static Any getVisualEffect( vcl::Window* _pWindow )
195 Any aEffect;
197 StyleSettings aStyleSettings = _pWindow->GetSettings().GetStyleSettings();
198 if ( (aStyleSettings.GetOptions() & StyleSettingsOptions::Mono) )
199 aEffect <<= (sal_Int16)FLAT;
200 else
201 aEffect <<= (sal_Int16)LOOK3D;
202 return aEffect;
207 // class VCLXGraphicControl
210 void VCLXGraphicControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
212 VCLXWindow::ImplGetPropertyIds( rIds );
215 void VCLXGraphicControl::ImplSetNewImage()
217 OSL_PRECOND( GetWindow(), "VCLXGraphicControl::ImplSetNewImage: window is required to be not-NULL!" );
218 VclPtr< Button > pButton = GetAsDynamic< Button >();
219 pButton->SetModeImage( GetImage() );
222 void VCLXGraphicControl::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, short Flags ) throw(::com::sun::star::uno::RuntimeException, std::exception)
224 SolarMutexGuard aGuard;
226 if ( GetWindow() )
228 Size aOldSize = GetWindow()->GetSizePixel();
229 VCLXWindow::setPosSize( X, Y, Width, Height, Flags );
230 if ( ( aOldSize.Width() != Width ) || ( aOldSize.Height() != Height ) )
231 ImplSetNewImage();
235 void VCLXGraphicControl::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
237 SolarMutexGuard aGuard;
239 VclPtr< Button > pButton = GetAs< Button >();
240 if ( !pButton )
241 return;
243 sal_uInt16 nPropType = GetPropertyId( PropertyName );
244 switch ( nPropType )
246 case BASEPROPERTY_GRAPHIC:
248 Reference< XGraphic > xGraphic;
249 OSL_VERIFY( Value >>= xGraphic );
250 maImage = Image( xGraphic );
251 ImplSetNewImage();
253 break;
255 case BASEPROPERTY_IMAGEALIGN:
257 WindowType eType = GetWindow()->GetType();
258 if ( ( eType == WINDOW_PUSHBUTTON )
259 || ( eType == WINDOW_RADIOBUTTON )
260 || ( eType == WINDOW_CHECKBOX )
263 sal_Int16 nAlignment = sal_Int16();
264 if ( Value >>= nAlignment )
265 GetAs< Button >()->SetImageAlign( static_cast< ImageAlign >( nAlignment ) );
268 break;
269 case BASEPROPERTY_IMAGEPOSITION:
271 WindowType eType = GetWindow()->GetType();
272 if ( ( eType == WINDOW_PUSHBUTTON )
273 || ( eType == WINDOW_RADIOBUTTON )
274 || ( eType == WINDOW_CHECKBOX )
277 sal_Int16 nImagePosition = 2;
278 OSL_VERIFY( Value >>= nImagePosition );
279 GetAs<Button>()->SetImageAlign( ::toolkit::translateImagePosition( nImagePosition ) );
282 break;
283 default:
284 VCLXWindow::setProperty( PropertyName, Value );
285 break;
289 ::com::sun::star::uno::Any VCLXGraphicControl::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
291 SolarMutexGuard aGuard;
293 ::com::sun::star::uno::Any aProp;
294 if ( !GetWindow() )
295 return aProp;
297 sal_uInt16 nPropType = GetPropertyId( PropertyName );
298 switch ( nPropType )
300 case BASEPROPERTY_GRAPHIC:
301 aProp <<= maImage.GetXGraphic();
302 break;
303 case BASEPROPERTY_IMAGEALIGN:
305 WindowType eType = GetWindow()->GetType();
306 if ( ( eType == WINDOW_PUSHBUTTON )
307 || ( eType == WINDOW_RADIOBUTTON )
308 || ( eType == WINDOW_CHECKBOX )
311 aProp <<= ::toolkit::getCompatibleImageAlign(
312 GetAs<Button>()->GetImageAlign() );
315 break;
316 case BASEPROPERTY_IMAGEPOSITION:
318 WindowType eType = GetWindow()->GetType();
319 if ( ( eType == WINDOW_PUSHBUTTON )
320 || ( eType == WINDOW_RADIOBUTTON )
321 || ( eType == WINDOW_CHECKBOX )
324 aProp <<= ::toolkit::translateImagePosition(
325 GetAs< Button >()->GetImageAlign() );
328 break;
329 default:
331 aProp <<= VCLXWindow::getProperty( PropertyName );
333 break;
335 return aProp;
339 // class VCLXButton
342 void VCLXButton::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
344 PushPropertyIds( rIds,
345 BASEPROPERTY_BACKGROUNDCOLOR,
346 BASEPROPERTY_DEFAULTBUTTON,
347 BASEPROPERTY_DEFAULTCONTROL,
348 BASEPROPERTY_ENABLED,
349 BASEPROPERTY_ENABLEVISIBLE,
350 BASEPROPERTY_FONTDESCRIPTOR,
351 BASEPROPERTY_GRAPHIC,
352 BASEPROPERTY_HELPTEXT,
353 BASEPROPERTY_HELPURL,
354 BASEPROPERTY_IMAGEALIGN,
355 BASEPROPERTY_IMAGEPOSITION,
356 BASEPROPERTY_IMAGEURL,
357 BASEPROPERTY_LABEL,
358 BASEPROPERTY_PRINTABLE,
359 BASEPROPERTY_PUSHBUTTONTYPE,
360 BASEPROPERTY_REPEAT,
361 BASEPROPERTY_REPEAT_DELAY,
362 BASEPROPERTY_STATE,
363 BASEPROPERTY_TABSTOP,
364 BASEPROPERTY_TOGGLE,
365 BASEPROPERTY_FOCUSONCLICK,
366 BASEPROPERTY_MULTILINE,
367 BASEPROPERTY_ALIGN,
368 BASEPROPERTY_VERTICALALIGN,
369 BASEPROPERTY_WRITING_MODE,
370 BASEPROPERTY_CONTEXT_WRITING_MODE,
371 BASEPROPERTY_REFERENCE_DEVICE,
373 VCLXGraphicControl::ImplGetPropertyIds( rIds );
376 VCLXButton::VCLXButton()
377 :maActionListeners( *this )
378 ,maItemListeners( *this )
382 VCLXButton::~VCLXButton()
386 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXButton::CreateAccessibleContext()
388 return getAccessibleFactory().createAccessibleContext( this );
391 void VCLXButton::dispose() throw(::com::sun::star::uno::RuntimeException, std::exception)
393 SolarMutexGuard aGuard;
395 ::com::sun::star::lang::EventObject aObj;
396 aObj.Source = (::cppu::OWeakObject*)this;
397 maActionListeners.disposeAndClear( aObj );
398 maItemListeners.disposeAndClear( aObj );
399 VCLXGraphicControl::dispose();
402 void VCLXButton::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )throw(::com::sun::star::uno::RuntimeException, std::exception)
404 SolarMutexGuard aGuard;
405 maActionListeners.addInterface( l );
408 void VCLXButton::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
410 SolarMutexGuard aGuard;
411 maActionListeners.removeInterface( l );
414 void VCLXButton::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l )throw(::com::sun::star::uno::RuntimeException, std::exception)
416 SolarMutexGuard aGuard;
417 maItemListeners.addInterface( l );
420 void VCLXButton::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
422 SolarMutexGuard aGuard;
423 maItemListeners.removeInterface( l );
426 void VCLXButton::setLabel( const OUString& rLabel ) throw(::com::sun::star::uno::RuntimeException, std::exception)
428 SolarMutexGuard aGuard;
430 vcl::Window* pWindow = GetWindow();
431 if ( pWindow )
432 pWindow->SetText( rLabel );
435 void VCLXButton::setActionCommand( const OUString& rCommand ) throw(::com::sun::star::uno::RuntimeException, std::exception)
437 SolarMutexGuard aGuard;
439 maActionCommand = rCommand;
442 ::com::sun::star::awt::Size VCLXButton::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
444 SolarMutexGuard aGuard;
446 Size aSz;
447 VclPtr< PushButton > pButton = GetAs< PushButton >();
448 if ( pButton )
449 aSz = pButton->CalcMinimumSize();
450 return AWTSize(aSz);
453 ::com::sun::star::awt::Size VCLXButton::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
455 ::com::sun::star::awt::Size aSz = getMinimumSize();
456 aSz.Width += 16;
457 aSz.Height += 10;
458 return aSz;
461 ::com::sun::star::awt::Size VCLXButton::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException, std::exception)
463 SolarMutexGuard aGuard;
465 Size aSz = VCLSize(rNewSize);
466 VclPtr< PushButton > pButton = GetAs< PushButton >();
467 if ( pButton )
469 Size aMinSz = pButton->CalcMinimumSize();
470 // no text, thus image
471 if ( pButton->GetText().isEmpty() )
473 if ( aSz.Width() < aMinSz.Width() )
474 aSz.Width() = aMinSz.Width();
475 if ( aSz.Height() < aMinSz.Height() )
476 aSz.Height() = aMinSz.Height();
478 else
480 if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
481 aSz.Height() = aMinSz.Height();
482 else
483 aSz = aMinSz;
486 return AWTSize(aSz);
489 void VCLXButton::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
491 SolarMutexGuard aGuard;
493 VclPtr< Button > pButton = GetAs< Button >();
494 if ( pButton )
496 sal_uInt16 nPropType = GetPropertyId( PropertyName );
497 switch ( nPropType )
499 case BASEPROPERTY_FOCUSONCLICK:
500 ::toolkit::adjustBooleanWindowStyle( Value, pButton, WB_NOPOINTERFOCUS, true );
501 break;
503 case BASEPROPERTY_TOGGLE:
504 ::toolkit::adjustBooleanWindowStyle( Value, pButton, WB_TOGGLE, false );
505 break;
507 case BASEPROPERTY_DEFAULTBUTTON:
509 WinBits nStyle = pButton->GetStyle() | WB_DEFBUTTON;
510 bool b = bool();
511 if ( ( Value >>= b ) && !b )
512 nStyle &= ~WB_DEFBUTTON;
513 pButton->SetStyle( nStyle );
515 break;
516 case BASEPROPERTY_STATE:
518 if ( GetWindow()->GetType() == WINDOW_PUSHBUTTON )
520 sal_Int16 n = sal_Int16();
521 if ( Value >>= n )
522 static_cast<PushButton*>(pButton.get())->SetState( (TriState)n );
525 break;
526 default:
528 VCLXGraphicControl::setProperty( PropertyName, Value );
534 ::com::sun::star::uno::Any VCLXButton::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
536 SolarMutexGuard aGuard;
538 ::com::sun::star::uno::Any aProp;
539 VclPtr< Button > pButton = GetAs< Button >();
540 if ( pButton )
542 sal_uInt16 nPropType = GetPropertyId( PropertyName );
543 switch ( nPropType )
545 case BASEPROPERTY_FOCUSONCLICK:
546 aProp <<= ( ( pButton->GetStyle() & WB_NOPOINTERFOCUS ) == 0 );
547 break;
549 case BASEPROPERTY_TOGGLE:
550 aProp <<= ( ( pButton->GetStyle() & WB_TOGGLE ) != 0 );
551 break;
553 case BASEPROPERTY_DEFAULTBUTTON:
555 aProp <<= ( pButton->GetStyle() & WB_DEFBUTTON ) != 0;
557 break;
558 case BASEPROPERTY_STATE:
560 if ( GetWindow()->GetType() == WINDOW_PUSHBUTTON )
562 aProp <<= (sal_Int16)static_cast<PushButton*>(pButton.get())->GetState();
565 break;
566 default:
568 aProp <<= VCLXGraphicControl::getProperty( PropertyName );
572 return aProp;
575 void VCLXButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
577 switch ( rVclWindowEvent.GetId() )
579 case VCLEVENT_BUTTON_CLICK:
581 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
582 // since we call listeners below, there is a potential that we will be destroyed
583 // during the listener call. To prevent the resulting crashs, we keep us
584 // alive as long as we're here
586 if ( maActionListeners.getLength() )
588 ::com::sun::star::awt::ActionEvent aEvent;
589 aEvent.Source = (::cppu::OWeakObject*)this;
590 aEvent.ActionCommand = maActionCommand;
592 Callback aCallback = ::boost::bind(
593 &ActionListenerMultiplexer::actionPerformed,
594 &maActionListeners,
595 aEvent
597 ImplExecuteAsyncWithoutSolarLock( aCallback );
600 break;
602 case VCLEVENT_PUSHBUTTON_TOGGLE:
604 PushButton& rButton = dynamic_cast< PushButton& >( *rVclWindowEvent.GetWindow() );
606 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
607 if ( maItemListeners.getLength() )
609 ::com::sun::star::awt::ItemEvent aEvent;
610 aEvent.Source = (::cppu::OWeakObject*)this;
611 aEvent.Selected = ( rButton.GetState() == TRISTATE_TRUE ) ? 1 : 0;
612 maItemListeners.itemStateChanged( aEvent );
615 break;
617 default:
618 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent );
619 break;
624 // class VCLXImageControl
627 void VCLXImageControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
629 PushPropertyIds( rIds,
630 BASEPROPERTY_BACKGROUNDCOLOR,
631 BASEPROPERTY_BORDER,
632 BASEPROPERTY_BORDERCOLOR,
633 BASEPROPERTY_DEFAULTCONTROL,
634 BASEPROPERTY_ENABLED,
635 BASEPROPERTY_ENABLEVISIBLE,
636 BASEPROPERTY_GRAPHIC,
637 BASEPROPERTY_HELPTEXT,
638 BASEPROPERTY_HELPURL,
639 BASEPROPERTY_IMAGEURL,
640 BASEPROPERTY_PRINTABLE,
641 BASEPROPERTY_SCALEIMAGE,
642 BASEPROPERTY_IMAGE_SCALE_MODE,
643 BASEPROPERTY_TABSTOP,
644 BASEPROPERTY_WRITING_MODE,
645 BASEPROPERTY_CONTEXT_WRITING_MODE,
647 VCLXGraphicControl::ImplGetPropertyIds( rIds );
650 VCLXImageControl::VCLXImageControl()
654 VCLXImageControl::~VCLXImageControl()
658 void VCLXImageControl::ImplSetNewImage()
660 OSL_PRECOND( GetWindow(), "VCLXImageControl::ImplSetNewImage: window is required to be not-NULL!" );
661 VclPtr<ImageControl> pControl = GetAs< ImageControl >();
662 pControl->SetImage( GetImage() );
665 ::com::sun::star::awt::Size VCLXImageControl::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
667 SolarMutexGuard aGuard;
669 Size aSz = GetImage().GetSizePixel();
670 aSz = ImplCalcWindowSize( aSz );
672 return AWTSize(aSz);
675 ::com::sun::star::awt::Size VCLXImageControl::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
677 return getMinimumSize();
680 ::com::sun::star::awt::Size VCLXImageControl::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException, std::exception)
682 SolarMutexGuard aGuard;
684 ::com::sun::star::awt::Size aSz = rNewSize;
685 ::com::sun::star::awt::Size aMinSz = getMinimumSize();
686 if ( aSz.Width < aMinSz.Width )
687 aSz.Width = aMinSz.Width;
688 if ( aSz.Height < aMinSz.Height )
689 aSz.Height = aMinSz.Height;
690 return aSz;
693 void VCLXImageControl::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
695 SolarMutexGuard aGuard;
697 VclPtr< ImageControl > pImageControl = GetAs< ImageControl >();
699 sal_uInt16 nPropType = GetPropertyId( PropertyName );
700 switch ( nPropType )
702 case BASEPROPERTY_IMAGE_SCALE_MODE:
704 sal_Int16 nScaleMode( ImageScaleMode::ANISOTROPIC );
705 if ( pImageControl && ( Value >>= nScaleMode ) )
707 pImageControl->SetScaleMode( nScaleMode );
710 break;
712 case BASEPROPERTY_SCALEIMAGE:
714 // this is for compatibility only, nowadays, the ImageScaleMode property should be used
715 bool bScaleImage = false;
716 if ( pImageControl && ( Value >>= bScaleImage ) )
718 pImageControl->SetScaleMode( bScaleImage ? ImageScaleMode::ANISOTROPIC : ImageScaleMode::NONE );
721 break;
723 default:
724 VCLXGraphicControl::setProperty( PropertyName, Value );
725 break;
729 ::com::sun::star::uno::Any VCLXImageControl::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
731 SolarMutexGuard aGuard;
733 ::com::sun::star::uno::Any aProp;
734 VclPtr< ImageControl > pImageControl = GetAs< ImageControl >();
735 sal_uInt16 nPropType = GetPropertyId( PropertyName );
737 switch ( nPropType )
739 case BASEPROPERTY_IMAGE_SCALE_MODE:
740 aProp <<= ( pImageControl ? pImageControl->GetScaleMode() : ImageScaleMode::ANISOTROPIC );
741 break;
743 case BASEPROPERTY_SCALEIMAGE:
744 aProp <<= ( pImageControl && pImageControl->GetScaleMode() != ImageScaleMode::NONE ) ? sal_True : sal_False;
745 break;
747 default:
748 aProp = VCLXGraphicControl::getProperty( PropertyName );
749 break;
751 return aProp;
755 // class VCLXCheckBox
759 void VCLXCheckBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
761 PushPropertyIds( rIds,
762 BASEPROPERTY_DEFAULTCONTROL,
763 BASEPROPERTY_ENABLED,
764 BASEPROPERTY_ENABLEVISIBLE,
765 BASEPROPERTY_FONTDESCRIPTOR,
766 BASEPROPERTY_GRAPHIC,
767 BASEPROPERTY_HELPTEXT,
768 BASEPROPERTY_HELPURL,
769 BASEPROPERTY_IMAGEPOSITION,
770 BASEPROPERTY_IMAGEURL,
771 BASEPROPERTY_LABEL,
772 BASEPROPERTY_PRINTABLE,
773 BASEPROPERTY_STATE,
774 BASEPROPERTY_TABSTOP,
775 BASEPROPERTY_TRISTATE,
776 BASEPROPERTY_VISUALEFFECT,
777 BASEPROPERTY_MULTILINE,
778 BASEPROPERTY_BACKGROUNDCOLOR,
779 BASEPROPERTY_ALIGN,
780 BASEPROPERTY_VERTICALALIGN,
781 BASEPROPERTY_WRITING_MODE,
782 BASEPROPERTY_CONTEXT_WRITING_MODE,
783 BASEPROPERTY_REFERENCE_DEVICE,
785 VCLXGraphicControl::ImplGetPropertyIds( rIds );
788 VCLXCheckBox::VCLXCheckBox() : maActionListeners( *this ), maItemListeners( *this )
792 // ::com::sun::star::uno::XInterface
793 ::com::sun::star::uno::Any VCLXCheckBox::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
795 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
796 (static_cast< ::com::sun::star::awt::XButton* >(this)),
797 (static_cast< ::com::sun::star::awt::XCheckBox* >(this)) );
798 return (aRet.hasValue() ? aRet : VCLXGraphicControl::queryInterface( rType ));
801 // ::com::sun::star::lang::XTypeProvider
802 IMPL_XTYPEPROVIDER_START( VCLXCheckBox )
803 cppu::UnoType<com::sun::star::awt::XButton>::get(),
804 cppu::UnoType<com::sun::star::awt::XCheckBox>::get(),
805 VCLXGraphicControl::getTypes()
806 IMPL_XTYPEPROVIDER_END
808 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXCheckBox::CreateAccessibleContext()
810 return getAccessibleFactory().createAccessibleContext( this );
813 void VCLXCheckBox::dispose() throw(::com::sun::star::uno::RuntimeException, std::exception)
815 SolarMutexGuard aGuard;
817 ::com::sun::star::lang::EventObject aObj;
818 aObj.Source = (::cppu::OWeakObject*)this;
819 maItemListeners.disposeAndClear( aObj );
820 VCLXGraphicControl::dispose();
823 void VCLXCheckBox::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
825 SolarMutexGuard aGuard;
826 maItemListeners.addInterface( l );
829 void VCLXCheckBox::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
831 SolarMutexGuard aGuard;
832 maItemListeners.removeInterface( l );
835 void VCLXCheckBox::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )throw(::com::sun::star::uno::RuntimeException, std::exception)
837 SolarMutexGuard aGuard;
838 maActionListeners.addInterface( l );
841 void VCLXCheckBox::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
843 SolarMutexGuard aGuard;
844 maActionListeners.removeInterface( l );
847 void VCLXCheckBox::setActionCommand( const OUString& rCommand ) throw(::com::sun::star::uno::RuntimeException, std::exception)
849 SolarMutexGuard aGuard;
850 maActionCommand = rCommand;
853 void VCLXCheckBox::setLabel( const OUString& rLabel ) throw(::com::sun::star::uno::RuntimeException, std::exception)
855 SolarMutexGuard aGuard;
857 vcl::Window* pWindow = GetWindow();
858 if ( pWindow )
859 pWindow->SetText( rLabel );
862 void VCLXCheckBox::setState( short n ) throw(::com::sun::star::uno::RuntimeException, std::exception)
864 SolarMutexGuard aGuard;
866 VclPtr< CheckBox> pCheckBox = GetAs< CheckBox >();
867 if ( pCheckBox)
869 TriState eState;
870 switch ( n )
872 case 0: eState = TRISTATE_FALSE; break;
873 case 1: eState = TRISTATE_TRUE; break;
874 case 2: eState = TRISTATE_INDET; break;
875 default: eState = TRISTATE_FALSE;
877 pCheckBox->SetState( eState );
879 // #105198# call C++ click listeners (needed for accessibility)
880 // pCheckBox->GetClickHdl().Call( pCheckBox );
882 // #107218# Call same virtual methods and listeners like VCL would do after user interaction
883 SetSynthesizingVCLEvent( true );
884 pCheckBox->Toggle();
885 pCheckBox->Click();
886 SetSynthesizingVCLEvent( false );
890 short VCLXCheckBox::getState() throw(::com::sun::star::uno::RuntimeException, std::exception)
892 SolarMutexGuard aGuard;
894 short nState = -1;
895 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
896 if ( pCheckBox )
898 switch ( pCheckBox->GetState() )
900 case TRISTATE_FALSE: nState = 0; break;
901 case TRISTATE_TRUE: nState = 1; break;
902 case TRISTATE_INDET: nState = 2; break;
903 default: OSL_FAIL( "VCLXCheckBox::getState(): unknown TriState!" );
907 return nState;
910 void VCLXCheckBox::enableTriState( sal_Bool b ) throw(::com::sun::star::uno::RuntimeException, std::exception)
912 SolarMutexGuard aGuard;
914 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
915 if ( pCheckBox)
916 pCheckBox->EnableTriState( b );
919 ::com::sun::star::awt::Size VCLXCheckBox::getMinimumSize() throw(::com::sun::star::uno::RuntimeException, std::exception)
921 SolarMutexGuard aGuard;
923 Size aSz;
924 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
925 if ( pCheckBox )
926 aSz = pCheckBox->CalcMinimumSize();
927 return AWTSize(aSz);
930 ::com::sun::star::awt::Size VCLXCheckBox::getPreferredSize() throw(::com::sun::star::uno::RuntimeException, std::exception)
932 return getMinimumSize();
935 ::com::sun::star::awt::Size VCLXCheckBox::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException, std::exception)
937 SolarMutexGuard aGuard;
939 Size aSz = VCLSize(rNewSize);
940 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
941 if ( pCheckBox )
943 Size aMinSz = pCheckBox->CalcMinimumSize();
944 if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
945 aSz.Height() = aMinSz.Height();
946 else
947 aSz = aMinSz;
949 return AWTSize(aSz);
952 void VCLXCheckBox::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
954 SolarMutexGuard aGuard;
956 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
957 if ( pCheckBox )
959 sal_uInt16 nPropType = GetPropertyId( PropertyName );
960 switch ( nPropType )
962 case BASEPROPERTY_VISUALEFFECT:
963 ::toolkit::setVisualEffect( Value, pCheckBox );
964 break;
966 case BASEPROPERTY_TRISTATE:
968 bool b = bool();
969 if ( Value >>= b )
970 pCheckBox->EnableTriState( b );
972 break;
973 case BASEPROPERTY_STATE:
975 sal_Int16 n = sal_Int16();
976 if ( Value >>= n )
977 setState( n );
979 break;
980 default:
982 VCLXGraphicControl::setProperty( PropertyName, Value );
988 ::com::sun::star::uno::Any VCLXCheckBox::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
990 SolarMutexGuard aGuard;
992 ::com::sun::star::uno::Any aProp;
993 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
994 if ( pCheckBox )
996 sal_uInt16 nPropType = GetPropertyId( PropertyName );
997 switch ( nPropType )
999 case BASEPROPERTY_VISUALEFFECT:
1000 aProp = ::toolkit::getVisualEffect( pCheckBox );
1001 break;
1002 case BASEPROPERTY_TRISTATE:
1003 aProp <<= pCheckBox->IsTriStateEnabled();
1004 break;
1005 case BASEPROPERTY_STATE:
1006 aProp <<= (sal_Int16)pCheckBox->GetState();
1007 break;
1008 default:
1010 aProp <<= VCLXGraphicControl::getProperty( PropertyName );
1014 return aProp;
1017 void VCLXCheckBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1019 switch ( rVclWindowEvent.GetId() )
1021 case VCLEVENT_CHECKBOX_TOGGLE:
1023 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
1024 // since we call listeners below, there is a potential that we will be destroyed
1025 // in during the listener call. To prevent the resulting crashs, we keep us
1026 // alive as long as we're here
1028 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
1029 if ( pCheckBox )
1031 if ( maItemListeners.getLength() )
1033 ::com::sun::star::awt::ItemEvent aEvent;
1034 aEvent.Source = (::cppu::OWeakObject*)this;
1035 aEvent.Highlighted = 0;
1036 aEvent.Selected = pCheckBox->GetState();
1037 maItemListeners.itemStateChanged( aEvent );
1039 if ( !IsSynthesizingVCLEvent() && maActionListeners.getLength() )
1041 ::com::sun::star::awt::ActionEvent aEvent;
1042 aEvent.Source = (::cppu::OWeakObject*)this;
1043 aEvent.ActionCommand = maActionCommand;
1044 maActionListeners.actionPerformed( aEvent );
1048 break;
1050 default:
1051 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent );
1052 break;
1057 // class VCLXRadioButton
1059 void VCLXRadioButton::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1061 PushPropertyIds( rIds,
1062 BASEPROPERTY_DEFAULTCONTROL,
1063 BASEPROPERTY_ENABLED,
1064 BASEPROPERTY_ENABLEVISIBLE,
1065 BASEPROPERTY_FONTDESCRIPTOR,
1066 BASEPROPERTY_GRAPHIC,
1067 BASEPROPERTY_HELPTEXT,
1068 BASEPROPERTY_HELPURL,
1069 BASEPROPERTY_IMAGEPOSITION,
1070 BASEPROPERTY_IMAGEURL,
1071 BASEPROPERTY_LABEL,
1072 BASEPROPERTY_PRINTABLE,
1073 BASEPROPERTY_STATE,
1074 BASEPROPERTY_TABSTOP,
1075 BASEPROPERTY_VISUALEFFECT,
1076 BASEPROPERTY_MULTILINE,
1077 BASEPROPERTY_BACKGROUNDCOLOR,
1078 BASEPROPERTY_ALIGN,
1079 BASEPROPERTY_VERTICALALIGN,
1080 BASEPROPERTY_WRITING_MODE,
1081 BASEPROPERTY_CONTEXT_WRITING_MODE,
1082 BASEPROPERTY_REFERENCE_DEVICE,
1083 BASEPROPERTY_GROUPNAME,
1085 VCLXGraphicControl::ImplGetPropertyIds( rIds );
1089 VCLXRadioButton::VCLXRadioButton() : maItemListeners( *this ), maActionListeners( *this )
1093 // ::com::sun::star::uno::XInterface
1094 ::com::sun::star::uno::Any VCLXRadioButton::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1096 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
1097 (static_cast< ::com::sun::star::awt::XRadioButton* >(this)),
1098 (static_cast< ::com::sun::star::awt::XButton* >(this)) );
1099 return (aRet.hasValue() ? aRet : VCLXGraphicControl::queryInterface( rType ));
1102 // ::com::sun::star::lang::XTypeProvider
1103 IMPL_XTYPEPROVIDER_START( VCLXRadioButton )
1104 cppu::UnoType<com::sun::star::awt::XRadioButton>::get(),
1105 cppu::UnoType<com::sun::star::awt::XButton>::get(),
1106 VCLXGraphicControl::getTypes()
1107 IMPL_XTYPEPROVIDER_END
1109 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXRadioButton::CreateAccessibleContext()
1111 return getAccessibleFactory().createAccessibleContext( this );
1114 void VCLXRadioButton::dispose() throw(::com::sun::star::uno::RuntimeException, std::exception)
1116 SolarMutexGuard aGuard;
1118 ::com::sun::star::lang::EventObject aObj;
1119 aObj.Source = (::cppu::OWeakObject*)this;
1120 maItemListeners.disposeAndClear( aObj );
1121 VCLXGraphicControl::dispose();
1124 void VCLXRadioButton::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
1126 SolarMutexGuard aGuard;
1128 VclPtr< RadioButton > pButton = GetAs< RadioButton >();
1129 if ( pButton )
1131 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1132 switch ( nPropType )
1134 case BASEPROPERTY_VISUALEFFECT:
1135 ::toolkit::setVisualEffect( Value, pButton );
1136 break;
1138 case BASEPROPERTY_STATE:
1140 sal_Int16 n = sal_Int16();
1141 if ( Value >>= n )
1143 bool b = n != 0;
1144 if ( pButton->IsRadioCheckEnabled() )
1145 pButton->Check( b );
1146 else
1147 pButton->SetState( b );
1150 break;
1151 case BASEPROPERTY_AUTOTOGGLE:
1153 bool b = bool();
1154 if ( Value >>= b )
1155 pButton->EnableRadioCheck( b );
1157 break;
1158 default:
1160 VCLXGraphicControl::setProperty( PropertyName, Value );
1166 ::com::sun::star::uno::Any VCLXRadioButton::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1168 SolarMutexGuard aGuard;
1170 ::com::sun::star::uno::Any aProp;
1171 VclPtr< RadioButton > pButton = GetAs< RadioButton >();
1172 if ( pButton )
1174 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1175 switch ( nPropType )
1177 case BASEPROPERTY_VISUALEFFECT:
1178 aProp = ::toolkit::getVisualEffect( pButton );
1179 break;
1180 case BASEPROPERTY_STATE:
1181 aProp <<= (sal_Int16) ( pButton->IsChecked() ? 1 : 0 );
1182 break;
1183 case BASEPROPERTY_AUTOTOGGLE:
1184 aProp <<= pButton->IsRadioCheckEnabled();
1185 break;
1186 default:
1188 aProp <<= VCLXGraphicControl::getProperty( PropertyName );
1192 return aProp;
1195 void VCLXRadioButton::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1197 SolarMutexGuard aGuard;
1198 maItemListeners.addInterface( l );
1201 void VCLXRadioButton::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1203 SolarMutexGuard aGuard;
1204 maItemListeners.removeInterface( l );
1207 void VCLXRadioButton::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )throw(::com::sun::star::uno::RuntimeException, std::exception)
1209 SolarMutexGuard aGuard;
1210 maActionListeners.addInterface( l );
1213 void VCLXRadioButton::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1215 SolarMutexGuard aGuard;
1216 maActionListeners.removeInterface( l );
1219 void VCLXRadioButton::setLabel( const OUString& rLabel ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1221 SolarMutexGuard aGuard;
1223 vcl::Window* pWindow = GetWindow();
1224 if ( pWindow )
1225 pWindow->SetText( rLabel );
1228 void VCLXRadioButton::setActionCommand( const OUString& rCommand ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1230 SolarMutexGuard aGuard;
1231 maActionCommand = rCommand;
1234 void VCLXRadioButton::setState( sal_Bool b ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1236 SolarMutexGuard aGuard;
1238 VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >();
1239 if ( pRadioButton)
1241 pRadioButton->Check( b );
1242 // #102717# item listeners are called, but not C++ click listeners in StarOffice code => call click hdl
1243 // But this is needed in old code because Accessibility API uses it.
1244 // pRadioButton->GetClickHdl().Call( pRadioButton );
1246 // #107218# Call same virtual methods and listeners like VCL would do after user interaction
1247 SetSynthesizingVCLEvent( true );
1248 pRadioButton->Click();
1249 SetSynthesizingVCLEvent( false );
1253 sal_Bool VCLXRadioButton::getState() throw(::com::sun::star::uno::RuntimeException, std::exception)
1255 SolarMutexGuard aGuard;
1257 VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >();
1258 return pRadioButton ? pRadioButton->IsChecked() : sal_False;
1261 ::com::sun::star::awt::Size VCLXRadioButton::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1263 SolarMutexGuard aGuard;
1265 Size aSz;
1266 VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >();
1267 if ( pRadioButton )
1268 aSz = pRadioButton->CalcMinimumSize();
1269 return AWTSize(aSz);
1272 ::com::sun::star::awt::Size VCLXRadioButton::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1274 return getMinimumSize();
1277 ::com::sun::star::awt::Size VCLXRadioButton::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1279 SolarMutexGuard aGuard;
1281 Size aSz = VCLSize(rNewSize);
1282 VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >();
1283 if ( pRadioButton )
1285 Size aMinSz = pRadioButton->CalcMinimumSize();
1286 if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
1287 aSz.Height() = aMinSz.Height();
1288 else
1289 aSz = aMinSz;
1291 return AWTSize(aSz);
1294 void VCLXRadioButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1296 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
1297 // since we call listeners below, there is a potential that we will be destroyed
1298 // in during the listener call. To prevent the resulting crashs, we keep us
1299 // alive as long as we're here
1301 switch ( rVclWindowEvent.GetId() )
1303 case VCLEVENT_BUTTON_CLICK:
1304 if ( !IsSynthesizingVCLEvent() && maActionListeners.getLength() )
1306 ::com::sun::star::awt::ActionEvent aEvent;
1307 aEvent.Source = (::cppu::OWeakObject*)this;
1308 aEvent.ActionCommand = maActionCommand;
1309 maActionListeners.actionPerformed( aEvent );
1311 ImplClickedOrToggled( false );
1312 break;
1314 case VCLEVENT_RADIOBUTTON_TOGGLE:
1315 ImplClickedOrToggled( true );
1316 break;
1318 default:
1319 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent );
1320 break;
1324 void VCLXRadioButton::ImplClickedOrToggled( bool bToggled )
1326 // In the formulars, RadioChecked is not enabled, call itemStateChanged only for click
1327 // In the dialog editor, RadioChecked is enabled, call itemStateChanged only for bToggled
1328 VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >();
1329 if ( pRadioButton && ( pRadioButton->IsRadioCheckEnabled() == bToggled ) && ( bToggled || pRadioButton->IsStateChanged() ) && maItemListeners.getLength() )
1331 ::com::sun::star::awt::ItemEvent aEvent;
1332 aEvent.Source = (::cppu::OWeakObject*)this;
1333 aEvent.Highlighted = 0;
1334 aEvent.Selected = pRadioButton->IsChecked() ? 1 : 0;
1335 maItemListeners.itemStateChanged( aEvent );
1340 // class VCLXSpinField
1342 void VCLXSpinField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1344 PushPropertyIds( rIds,
1345 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
1346 0 );
1347 VCLXEdit::ImplGetPropertyIds( rIds );
1350 VCLXSpinField::VCLXSpinField() : maSpinListeners( *this )
1354 // ::com::sun::star::uno::XInterface
1355 ::com::sun::star::uno::Any VCLXSpinField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1357 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
1358 (static_cast< ::com::sun::star::awt::XSpinField* >(this)) );
1359 return (aRet.hasValue() ? aRet : VCLXEdit::queryInterface( rType ));
1362 // ::com::sun::star::lang::XTypeProvider
1363 IMPL_XTYPEPROVIDER_START( VCLXSpinField )
1364 cppu::UnoType<com::sun::star::awt::XSpinField>::get(),
1365 VCLXEdit::getTypes()
1366 IMPL_XTYPEPROVIDER_END
1368 void VCLXSpinField::addSpinListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1370 SolarMutexGuard aGuard;
1371 maSpinListeners.addInterface( l );
1374 void VCLXSpinField::removeSpinListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1376 SolarMutexGuard aGuard;
1377 maSpinListeners.removeInterface( l );
1380 void VCLXSpinField::up() throw(::com::sun::star::uno::RuntimeException, std::exception)
1382 SolarMutexGuard aGuard;
1384 VclPtr< SpinField > pSpinField = GetAs< SpinField >();
1385 if ( pSpinField )
1386 pSpinField->Up();
1389 void VCLXSpinField::down() throw(::com::sun::star::uno::RuntimeException, std::exception)
1391 SolarMutexGuard aGuard;
1393 VclPtr< SpinField > pSpinField = GetAs< SpinField >();
1394 if ( pSpinField )
1395 pSpinField->Down();
1398 void VCLXSpinField::first() throw(::com::sun::star::uno::RuntimeException, std::exception)
1400 SolarMutexGuard aGuard;
1402 VclPtr< SpinField > pSpinField = GetAs< SpinField >();
1403 if ( pSpinField )
1404 pSpinField->First();
1407 void VCLXSpinField::last() throw(::com::sun::star::uno::RuntimeException, std::exception)
1409 SolarMutexGuard aGuard;
1411 VclPtr< SpinField > pSpinField = GetAs< SpinField >();
1412 if ( pSpinField )
1413 pSpinField->Last();
1416 void VCLXSpinField::enableRepeat( sal_Bool bRepeat ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1418 SolarMutexGuard aGuard;
1420 vcl::Window* pWindow = GetWindow();
1421 if ( pWindow )
1423 WinBits nStyle = pWindow->GetStyle();
1424 if ( bRepeat )
1425 nStyle |= WB_REPEAT;
1426 else
1427 nStyle &= ~WB_REPEAT;
1428 pWindow->SetStyle( nStyle );
1432 void VCLXSpinField::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1434 switch ( rVclWindowEvent.GetId() )
1436 case VCLEVENT_SPINFIELD_UP:
1437 case VCLEVENT_SPINFIELD_DOWN:
1438 case VCLEVENT_SPINFIELD_FIRST:
1439 case VCLEVENT_SPINFIELD_LAST:
1441 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
1442 // since we call listeners below, there is a potential that we will be destroyed
1443 // in during the listener call. To prevent the resulting crashs, we keep us
1444 // alive as long as we're here
1446 if ( maSpinListeners.getLength() )
1448 ::com::sun::star::awt::SpinEvent aEvent;
1449 aEvent.Source = (::cppu::OWeakObject*)this;
1450 switch ( rVclWindowEvent.GetId() )
1452 case VCLEVENT_SPINFIELD_UP: maSpinListeners.up( aEvent );
1453 break;
1454 case VCLEVENT_SPINFIELD_DOWN: maSpinListeners.down( aEvent );
1455 break;
1456 case VCLEVENT_SPINFIELD_FIRST: maSpinListeners.first( aEvent );
1457 break;
1458 case VCLEVENT_SPINFIELD_LAST: maSpinListeners.last( aEvent );
1459 break;
1464 break;
1466 default:
1467 VCLXEdit::ProcessWindowEvent( rVclWindowEvent );
1468 break;
1474 // class VCLXListBox
1476 void VCLXListBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1478 PushPropertyIds( rIds,
1479 BASEPROPERTY_BACKGROUNDCOLOR,
1480 BASEPROPERTY_BORDER,
1481 BASEPROPERTY_BORDERCOLOR,
1482 BASEPROPERTY_DEFAULTCONTROL,
1483 BASEPROPERTY_DROPDOWN,
1484 BASEPROPERTY_ENABLED,
1485 BASEPROPERTY_ENABLEVISIBLE,
1486 BASEPROPERTY_FONTDESCRIPTOR,
1487 BASEPROPERTY_HELPTEXT,
1488 BASEPROPERTY_HELPURL,
1489 BASEPROPERTY_LINECOUNT,
1490 BASEPROPERTY_MULTISELECTION,
1491 BASEPROPERTY_MULTISELECTION_SIMPLEMODE,
1492 BASEPROPERTY_ITEM_SEPARATOR_POS,
1493 BASEPROPERTY_PRINTABLE,
1494 BASEPROPERTY_SELECTEDITEMS,
1495 BASEPROPERTY_STRINGITEMLIST,
1496 BASEPROPERTY_TABSTOP,
1497 BASEPROPERTY_READONLY,
1498 BASEPROPERTY_ALIGN,
1499 BASEPROPERTY_WRITING_MODE,
1500 BASEPROPERTY_CONTEXT_WRITING_MODE,
1501 BASEPROPERTY_REFERENCE_DEVICE,
1502 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
1504 VCLXWindow::ImplGetPropertyIds( rIds );
1508 VCLXListBox::VCLXListBox()
1509 : maActionListeners( *this ),
1510 maItemListeners( *this )
1514 void VCLXListBox::dispose() throw(::com::sun::star::uno::RuntimeException, std::exception)
1516 SolarMutexGuard aGuard;
1518 ::com::sun::star::lang::EventObject aObj;
1519 aObj.Source = (::cppu::OWeakObject*)this;
1520 maItemListeners.disposeAndClear( aObj );
1521 maActionListeners.disposeAndClear( aObj );
1522 VCLXWindow::dispose();
1525 void VCLXListBox::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1527 SolarMutexGuard aGuard;
1528 maItemListeners.addInterface( l );
1531 void VCLXListBox::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1533 SolarMutexGuard aGuard;
1534 maItemListeners.removeInterface( l );
1537 void VCLXListBox::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1539 SolarMutexGuard aGuard;
1540 maActionListeners.addInterface( l );
1543 void VCLXListBox::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1545 SolarMutexGuard aGuard;
1546 maActionListeners.removeInterface( l );
1549 void VCLXListBox::addItem( const OUString& aItem, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1551 SolarMutexGuard aGuard;
1552 VclPtr< ListBox > pBox = GetAs< ListBox >();
1553 if ( pBox )
1554 pBox->InsertEntry( aItem, nPos );
1557 void VCLXListBox::addItems( const ::com::sun::star::uno::Sequence< OUString>& aItems, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1559 SolarMutexGuard aGuard;
1560 VclPtr< ListBox > pBox = GetAs< ListBox >();
1561 if ( pBox )
1563 sal_uInt16 nP = nPos;
1564 const OUString* pItems = aItems.getConstArray();
1565 const OUString* pItemsEnd = aItems.getConstArray() + aItems.getLength();
1566 while ( pItems != pItemsEnd )
1568 if ( (sal_uInt16)nP == 0xFFFF )
1570 OSL_FAIL( "VCLXListBox::addItems: too many entries!" );
1571 // skip remaining entries, list cannot hold them, anyway
1572 break;
1575 pBox->InsertEntry( *pItems++, nP++ );
1580 void VCLXListBox::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1582 SolarMutexGuard aGuard;
1583 VclPtr< ListBox > pBox = GetAs< ListBox >();
1584 if ( pBox )
1586 for ( sal_uInt16 n = nCount; n; )
1587 pBox->RemoveEntry( nPos + (--n) );
1591 sal_Int16 VCLXListBox::getItemCount() throw(::com::sun::star::uno::RuntimeException, std::exception)
1593 SolarMutexGuard aGuard;
1595 VclPtr< ListBox > pBox = GetAs< ListBox >();
1596 return pBox ? pBox->GetEntryCount() : 0;
1599 OUString VCLXListBox::getItem( sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1601 SolarMutexGuard aGuard;
1603 OUString aItem;
1604 VclPtr< ListBox > pBox = GetAs< ListBox >();
1605 if ( pBox )
1606 aItem = pBox->GetEntry( nPos );
1607 return aItem;
1610 ::com::sun::star::uno::Sequence< OUString> VCLXListBox::getItems() throw(::com::sun::star::uno::RuntimeException, std::exception)
1612 SolarMutexGuard aGuard;
1614 ::com::sun::star::uno::Sequence< OUString> aSeq;
1615 VclPtr< ListBox > pBox = GetAs< ListBox >();
1616 if ( pBox )
1618 sal_uInt16 nEntries = pBox->GetEntryCount();
1619 aSeq = ::com::sun::star::uno::Sequence< OUString>( nEntries );
1620 for ( sal_uInt16 n = nEntries; n; )
1622 --n;
1623 aSeq.getArray()[n] = OUString( pBox->GetEntry( n ) );
1626 return aSeq;
1629 sal_Int16 VCLXListBox::getSelectedItemPos() throw(::com::sun::star::uno::RuntimeException, std::exception)
1631 SolarMutexGuard aGuard;
1632 VclPtr< ListBox > pBox = GetAs< ListBox >();
1633 return pBox ? pBox->GetSelectEntryPos() : 0;
1636 ::com::sun::star::uno::Sequence<sal_Int16> VCLXListBox::getSelectedItemsPos() throw(::com::sun::star::uno::RuntimeException, std::exception)
1638 SolarMutexGuard aGuard;
1640 ::com::sun::star::uno::Sequence<sal_Int16> aSeq;
1641 VclPtr< ListBox > pBox = GetAs< ListBox >();
1642 if ( pBox )
1644 sal_uInt16 nSelEntries = pBox->GetSelectEntryCount();
1645 aSeq = ::com::sun::star::uno::Sequence<sal_Int16>( nSelEntries );
1646 for ( sal_uInt16 n = 0; n < nSelEntries; n++ )
1647 aSeq.getArray()[n] = pBox->GetSelectEntryPos( n );
1649 return aSeq;
1652 OUString VCLXListBox::getSelectedItem() throw(::com::sun::star::uno::RuntimeException, std::exception)
1654 SolarMutexGuard aGuard;
1656 OUString aItem;
1657 VclPtr< ListBox > pBox = GetAs< ListBox >();
1658 if ( pBox )
1659 aItem = pBox->GetSelectEntry();
1660 return aItem;
1663 ::com::sun::star::uno::Sequence< OUString> VCLXListBox::getSelectedItems() throw(::com::sun::star::uno::RuntimeException, std::exception)
1665 SolarMutexGuard aGuard;
1667 ::com::sun::star::uno::Sequence< OUString> aSeq;
1668 VclPtr< ListBox > pBox = GetAs< ListBox >();
1669 if ( pBox )
1671 sal_uInt16 nSelEntries = pBox->GetSelectEntryCount();
1672 aSeq = ::com::sun::star::uno::Sequence< OUString>( nSelEntries );
1673 for ( sal_uInt16 n = 0; n < nSelEntries; n++ )
1674 aSeq.getArray()[n] = OUString( pBox->GetSelectEntry( n ) );
1676 return aSeq;
1679 void VCLXListBox::selectItemPos( sal_Int16 nPos, sal_Bool bSelect ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1681 SolarMutexGuard aGuard;
1683 VclPtr< ListBox > pBox = GetAs< ListBox >();
1684 if ( pBox && ( pBox->IsEntryPosSelected( nPos ) != bool(bSelect) ) )
1686 pBox->SelectEntryPos( nPos, bSelect );
1688 // VCL doesn't call select handler after API call.
1689 // ImplCallItemListeners();
1691 // #107218# Call same listeners like VCL would do after user interaction
1692 SetSynthesizingVCLEvent( true );
1693 pBox->Select();
1694 SetSynthesizingVCLEvent( false );
1698 void VCLXListBox::selectItemsPos( const ::com::sun::star::uno::Sequence<sal_Int16>& aPositions, sal_Bool bSelect ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1700 SolarMutexGuard aGuard;
1702 VclPtr< ListBox > pBox = GetAs< ListBox >();
1703 if ( pBox )
1705 bool bChanged = false;
1706 for ( sal_uInt16 n = (sal_uInt16)aPositions.getLength(); n; )
1708 sal_uInt16 nPos = (sal_uInt16) aPositions.getConstArray()[--n];
1709 if ( pBox->IsEntryPosSelected( nPos ) != bool(bSelect) )
1711 pBox->SelectEntryPos( nPos, bSelect );
1712 bChanged = true;
1716 if ( bChanged )
1718 // VCL doesn't call select handler after API call.
1719 // ImplCallItemListeners();
1721 // #107218# Call same listeners like VCL would do after user interaction
1722 SetSynthesizingVCLEvent( true );
1723 pBox->Select();
1724 SetSynthesizingVCLEvent( false );
1729 void VCLXListBox::selectItem( const OUString& rItemText, sal_Bool bSelect ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1731 SolarMutexGuard aGuard;
1733 VclPtr< ListBox > pBox = GetAs< ListBox >();
1734 if ( pBox )
1736 OUString aItemText( rItemText );
1737 selectItemPos( pBox->GetEntryPos( aItemText ), bSelect );
1741 void VCLXListBox::setDropDownLineCount( sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1743 SolarMutexGuard aGuard;
1744 VclPtr< ListBox > pBox = GetAs< ListBox >();
1745 if ( pBox )
1746 pBox->SetDropDownLineCount( nLines );
1749 sal_Int16 VCLXListBox::getDropDownLineCount() throw(::com::sun::star::uno::RuntimeException, std::exception)
1751 SolarMutexGuard aGuard;
1753 sal_Int16 nLines = 0;
1754 VclPtr< ListBox > pBox = GetAs< ListBox >();
1755 if ( pBox )
1756 nLines = pBox->GetDropDownLineCount();
1757 return nLines;
1760 sal_Bool VCLXListBox::isMutipleMode() throw(::com::sun::star::uno::RuntimeException, std::exception)
1762 SolarMutexGuard aGuard;
1763 bool bMulti = false;
1764 VclPtr< ListBox > pBox = GetAs< ListBox >();
1765 if ( pBox )
1766 bMulti = pBox->IsMultiSelectionEnabled();
1767 return bMulti;
1770 void VCLXListBox::setMultipleMode( sal_Bool bMulti ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1772 SolarMutexGuard aGuard;
1773 VclPtr< ListBox > pBox = GetAs< ListBox >();
1774 if ( pBox )
1775 pBox->EnableMultiSelection( bMulti );
1778 void VCLXListBox::makeVisible( sal_Int16 nEntry ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1780 SolarMutexGuard aGuard;
1781 VclPtr< ListBox > pBox = GetAs< ListBox >();
1782 if ( pBox )
1783 pBox->SetTopEntry( nEntry );
1786 void VCLXListBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1788 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
1789 // since we call listeners below, there is a potential that we will be destroyed
1790 // in during the listener call. To prevent the resulting crashs, we keep us
1791 // alive as long as we're here
1793 switch ( rVclWindowEvent.GetId() )
1795 case VCLEVENT_LISTBOX_SELECT:
1797 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1798 if( pListBox )
1800 bool bDropDown = ( pListBox->GetStyle() & WB_DROPDOWN ) != 0;
1801 if ( bDropDown && !IsSynthesizingVCLEvent() && maActionListeners.getLength() )
1803 // Call ActionListener on DropDown event
1804 ::com::sun::star::awt::ActionEvent aEvent;
1805 aEvent.Source = (::cppu::OWeakObject*)this;
1806 aEvent.ActionCommand = pListBox->GetSelectEntry();
1807 maActionListeners.actionPerformed( aEvent );
1810 if ( maItemListeners.getLength() )
1812 ImplCallItemListeners();
1816 break;
1818 case VCLEVENT_LISTBOX_DOUBLECLICK:
1819 if ( GetWindow() && maActionListeners.getLength() )
1821 ::com::sun::star::awt::ActionEvent aEvent;
1822 aEvent.Source = (::cppu::OWeakObject*)this;
1823 aEvent.ActionCommand = GetAs<ListBox>()->GetSelectEntry();
1824 maActionListeners.actionPerformed( aEvent );
1826 break;
1828 default:
1829 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
1830 break;
1834 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXListBox::CreateAccessibleContext()
1836 SolarMutexGuard aGuard;
1838 return getAccessibleFactory().createAccessibleContext( this );
1841 void VCLXListBox::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
1843 SolarMutexGuard aGuard;
1844 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1845 if ( pListBox )
1847 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1848 switch ( nPropType )
1850 case BASEPROPERTY_ITEM_SEPARATOR_POS:
1852 sal_Int16 nSeparatorPos(0);
1853 if ( Value >>= nSeparatorPos )
1854 pListBox->SetSeparatorPos( nSeparatorPos );
1856 break;
1857 case BASEPROPERTY_READONLY:
1859 bool b = bool();
1860 if ( Value >>= b )
1861 pListBox->SetReadOnly( b);
1863 break;
1864 case BASEPROPERTY_MULTISELECTION:
1866 bool b = bool();
1867 if ( Value >>= b )
1868 pListBox->EnableMultiSelection( b );
1870 break;
1871 case BASEPROPERTY_MULTISELECTION_SIMPLEMODE:
1872 ::toolkit::adjustBooleanWindowStyle( Value, pListBox, WB_SIMPLEMODE, false );
1873 break;
1874 case BASEPROPERTY_LINECOUNT:
1876 sal_Int16 n = sal_Int16();
1877 if ( Value >>= n )
1878 pListBox->SetDropDownLineCount( n );
1880 break;
1881 case BASEPROPERTY_STRINGITEMLIST:
1883 ::com::sun::star::uno::Sequence< OUString> aItems;
1884 if ( Value >>= aItems )
1886 pListBox->Clear();
1887 addItems( aItems, 0 );
1890 break;
1891 case BASEPROPERTY_SELECTEDITEMS:
1893 ::com::sun::star::uno::Sequence<sal_Int16> aItems;
1894 if ( Value >>= aItems )
1896 for ( sal_uInt16 n = pListBox->GetEntryCount(); n; )
1897 pListBox->SelectEntryPos( --n, false );
1899 if ( aItems.getLength() )
1900 selectItemsPos( aItems, sal_True );
1901 else
1902 pListBox->SetNoSelection();
1904 if ( !pListBox->GetSelectEntryCount() )
1905 pListBox->SetTopEntry( 0 );
1908 break;
1909 default:
1911 VCLXWindow::setProperty( PropertyName, Value );
1917 ::com::sun::star::uno::Any VCLXListBox::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1919 SolarMutexGuard aGuard;
1920 ::com::sun::star::uno::Any aProp;
1921 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1922 if ( pListBox )
1924 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1925 switch ( nPropType )
1927 case BASEPROPERTY_ITEM_SEPARATOR_POS:
1928 aProp <<= sal_Int16( pListBox->GetSeparatorPos() );
1929 break;
1930 case BASEPROPERTY_READONLY:
1932 aProp <<= pListBox->IsReadOnly();
1934 break;
1935 case BASEPROPERTY_MULTISELECTION:
1937 aProp <<= pListBox->IsMultiSelectionEnabled();
1939 break;
1940 case BASEPROPERTY_MULTISELECTION_SIMPLEMODE:
1942 aProp <<= ( ( pListBox->GetStyle() & WB_SIMPLEMODE ) == 0 );
1944 break;
1945 case BASEPROPERTY_LINECOUNT:
1947 aProp <<= (sal_Int16) pListBox->GetDropDownLineCount();
1949 break;
1950 case BASEPROPERTY_STRINGITEMLIST:
1952 sal_uInt16 nItems = pListBox->GetEntryCount();
1953 ::com::sun::star::uno::Sequence< OUString> aSeq( nItems );
1954 OUString* pStrings = aSeq.getArray();
1955 for ( sal_uInt16 n = 0; n < nItems; n++ )
1956 pStrings[n] = pListBox->GetEntry( n );
1957 aProp <<= aSeq;
1960 break;
1961 default:
1963 aProp <<= VCLXWindow::getProperty( PropertyName );
1967 return aProp;
1970 ::com::sun::star::awt::Size VCLXListBox::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1972 SolarMutexGuard aGuard;
1973 Size aSz;
1974 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1975 if ( pListBox )
1976 aSz = pListBox->CalcMinimumSize();
1977 return AWTSize(aSz);
1980 ::com::sun::star::awt::Size VCLXListBox::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1982 SolarMutexGuard aGuard;
1983 Size aSz;
1984 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1985 if ( pListBox )
1987 aSz = pListBox->CalcMinimumSize();
1988 if ( pListBox->GetStyle() & WB_DROPDOWN )
1989 aSz.Height() += 4;
1991 return AWTSize(aSz);
1994 ::com::sun::star::awt::Size VCLXListBox::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1996 SolarMutexGuard aGuard;
1997 Size aSz = VCLSize(rNewSize);
1998 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1999 if ( pListBox )
2000 aSz = pListBox->CalcAdjustedSize( aSz );
2001 return AWTSize(aSz);
2004 ::com::sun::star::awt::Size VCLXListBox::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2006 SolarMutexGuard aGuard;
2007 Size aSz;
2008 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2009 if ( pListBox )
2010 aSz = pListBox->CalcBlockSize( nCols, nLines );
2011 return AWTSize(aSz);
2014 void VCLXListBox::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2016 SolarMutexGuard aGuard;
2017 nCols = nLines = 0;
2018 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2019 if ( pListBox )
2021 sal_uInt16 nC, nL;
2022 pListBox->GetMaxVisColumnsAndLines( nC, nL );
2023 nCols = nC;
2024 nLines = nL;
2028 void VCLXListBox::ImplCallItemListeners()
2030 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2031 if ( pListBox && maItemListeners.getLength() )
2033 ::com::sun::star::awt::ItemEvent aEvent;
2034 aEvent.Source = (::cppu::OWeakObject*)this;
2035 aEvent.Highlighted = 0;
2037 // Set to 0xFFFF on multiple selection, selected entry ID otherwise
2038 aEvent.Selected = (pListBox->GetSelectEntryCount() == 1 ) ? pListBox->GetSelectEntryPos() : 0xFFFF;
2040 maItemListeners.itemStateChanged( aEvent );
2043 namespace
2045 Image lcl_getImageFromURL( const OUString& i_rImageURL )
2047 if ( i_rImageURL.isEmpty() )
2048 return Image();
2052 Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
2053 Reference< XGraphicProvider > xProvider(graphic::GraphicProvider::create(xContext));
2054 ::comphelper::NamedValueCollection aMediaProperties;
2055 aMediaProperties.put( "URL", i_rImageURL );
2056 Reference< XGraphic > xGraphic = xProvider->queryGraphic( aMediaProperties.getPropertyValues() );
2057 return Image( xGraphic );
2059 catch( const uno::Exception& )
2061 DBG_UNHANDLED_EXCEPTION();
2063 return Image();
2066 void SAL_CALL VCLXListBox::listItemInserted( const ItemListEvent& i_rEvent ) throw (RuntimeException, std::exception)
2068 SolarMutexGuard aGuard;
2069 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2071 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemInserted: no ListBox?!" );
2072 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition <= sal_Int32( pListBox->GetEntryCount() ) ),
2073 "VCLXListBox::listItemInserted: illegal (inconsistent) item position!" );
2074 pListBox->InsertEntry(
2075 i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : OUString(),
2076 i_rEvent.ItemImageURL.IsPresent ? TkResMgr::getImageFromURL( i_rEvent.ItemImageURL.Value ) : Image(),
2077 i_rEvent.ItemPosition );
2080 void SAL_CALL VCLXListBox::listItemRemoved( const ItemListEvent& i_rEvent ) throw (RuntimeException, std::exception)
2082 SolarMutexGuard aGuard;
2083 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2085 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemRemoved: no ListBox?!" );
2086 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pListBox->GetEntryCount() ) ),
2087 "VCLXListBox::listItemRemoved: illegal (inconsistent) item position!" );
2089 pListBox->RemoveEntry( i_rEvent.ItemPosition );
2092 void SAL_CALL VCLXListBox::listItemModified( const ItemListEvent& i_rEvent ) throw (RuntimeException, std::exception)
2094 SolarMutexGuard aGuard;
2095 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2097 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" );
2098 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pListBox->GetEntryCount() ) ),
2099 "VCLXListBox::listItemModified: illegal (inconsistent) item position!" );
2101 // VCL's ListBox does not support changing an entry's text or image, so remove and re-insert
2103 const OUString sNewText = i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : OUString( pListBox->GetEntry( i_rEvent.ItemPosition ) );
2104 const Image aNewImage( i_rEvent.ItemImageURL.IsPresent ? TkResMgr::getImageFromURL( i_rEvent.ItemImageURL.Value ) : pListBox->GetEntryImage( i_rEvent.ItemPosition ) );
2106 pListBox->RemoveEntry( i_rEvent.ItemPosition );
2107 pListBox->InsertEntry( sNewText, aNewImage, i_rEvent.ItemPosition );
2110 void SAL_CALL VCLXListBox::allItemsRemoved( const EventObject& i_rEvent ) throw (RuntimeException, std::exception)
2112 SolarMutexGuard aGuard;
2114 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2115 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" );
2117 pListBox->Clear();
2119 (void)i_rEvent;
2122 void SAL_CALL VCLXListBox::itemListChanged( const EventObject& i_rEvent ) throw (RuntimeException, std::exception)
2124 SolarMutexGuard aGuard;
2126 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2127 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" );
2129 pListBox->Clear();
2131 uno::Reference< beans::XPropertySet > xPropSet( i_rEvent.Source, uno::UNO_QUERY_THROW );
2132 uno::Reference< beans::XPropertySetInfo > xPSI( xPropSet->getPropertySetInfo(), uno::UNO_QUERY_THROW );
2133 uno::Reference< resource::XStringResourceResolver > xStringResourceResolver;
2134 if ( xPSI->hasPropertyByName("ResourceResolver") )
2136 xStringResourceResolver.set(
2137 xPropSet->getPropertyValue("ResourceResolver"),
2138 uno::UNO_QUERY
2143 Reference< XItemList > xItemList( i_rEvent.Source, uno::UNO_QUERY_THROW );
2144 uno::Sequence< beans::Pair< OUString, OUString > > aItems = xItemList->getAllItems();
2145 for ( sal_Int32 i=0; i<aItems.getLength(); ++i )
2147 OUString aLocalizationKey( aItems[i].First );
2148 if ( xStringResourceResolver.is() && aLocalizationKey.startsWith("&") )
2150 aLocalizationKey = xStringResourceResolver->resolveString(aLocalizationKey.copy( 1 ));
2152 pListBox->InsertEntry( aLocalizationKey, lcl_getImageFromURL( aItems[i].Second ) );
2156 void SAL_CALL VCLXListBox::disposing( const EventObject& i_rEvent ) throw (RuntimeException, std::exception)
2158 // just disambiguate
2159 VCLXWindow::disposing( i_rEvent );
2163 // class VCLXMessageBox
2166 void VCLXMessageBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2168 VCLXTopWindow::ImplGetPropertyIds( rIds );
2171 VCLXMessageBox::VCLXMessageBox()
2175 VCLXMessageBox::~VCLXMessageBox()
2179 // ::com::sun::star::uno::XInterface
2180 ::com::sun::star::uno::Any VCLXMessageBox::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2182 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
2183 (static_cast< ::com::sun::star::awt::XMessageBox* >(this)) );
2184 return (aRet.hasValue() ? aRet : VCLXTopWindow::queryInterface( rType ));
2187 // ::com::sun::star::lang::XTypeProvider
2188 IMPL_XTYPEPROVIDER_START( VCLXMessageBox )
2189 cppu::UnoType<com::sun::star::awt::XMessageBox>::get(),
2190 VCLXTopWindow::getTypes()
2191 IMPL_XTYPEPROVIDER_END
2193 void VCLXMessageBox::setCaptionText( const OUString& rText ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2195 SolarMutexGuard aGuard;
2197 vcl::Window* pWindow = GetWindow();
2198 if ( pWindow )
2199 pWindow->SetText( rText );
2202 OUString VCLXMessageBox::getCaptionText() throw(::com::sun::star::uno::RuntimeException, std::exception)
2204 SolarMutexGuard aGuard;
2206 OUString aText;
2207 vcl::Window* pWindow = GetWindow();
2208 if ( pWindow )
2209 aText = pWindow->GetText();
2210 return aText;
2213 void VCLXMessageBox::setMessageText( const OUString& rText ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2215 SolarMutexGuard aGuard;
2216 VclPtr< MessBox > pBox = GetAs< MessBox >();
2217 if ( pBox )
2218 pBox->SetMessText( rText );
2221 OUString VCLXMessageBox::getMessageText() throw(::com::sun::star::uno::RuntimeException, std::exception)
2223 SolarMutexGuard aGuard;
2224 OUString aText;
2225 VclPtr< MessBox > pBox = GetAs< MessBox >();
2226 if ( pBox )
2227 aText = pBox->GetMessText();
2228 return aText;
2231 sal_Int16 VCLXMessageBox::execute() throw(::com::sun::star::uno::RuntimeException, std::exception)
2233 SolarMutexGuard aGuard;
2234 VclPtr< MessBox > pBox = GetAs< MessBox >();
2235 return pBox ? pBox->Execute() : 0;
2238 ::com::sun::star::awt::Size SAL_CALL VCLXMessageBox::getMinimumSize() throw(::com::sun::star::uno::RuntimeException, std::exception)
2240 SolarMutexGuard aGuard;
2241 return ::com::sun::star::awt::Size( 250, 100 );
2245 // class VCLXDialog
2247 void VCLXDialog::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2249 VCLXTopWindow::ImplGetPropertyIds( rIds );
2252 VCLXDialog::VCLXDialog()
2254 OSL_TRACE("XDialog created");
2257 VCLXDialog::~VCLXDialog()
2259 OSL_TRACE ("%s", __FUNCTION__);
2262 // ::com::sun::star::uno::XInterface
2263 ::com::sun::star::uno::Any VCLXDialog::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2265 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
2266 (static_cast< ::com::sun::star::awt::XDialog2* >(this)),
2267 (static_cast< ::com::sun::star::awt::XDialog* >(this)) );
2268 return (aRet.hasValue() ? aRet : VCLXTopWindow::queryInterface( rType ));
2271 // ::com::sun::star::lang::XTypeProvider
2272 IMPL_XTYPEPROVIDER_START( VCLXDialog )
2273 cppu::UnoType<com::sun::star::awt::XDialog2>::get(),
2274 cppu::UnoType<com::sun::star::awt::XDialog>::get(),
2275 VCLXTopWindow::getTypes()
2276 IMPL_XTYPEPROVIDER_END
2278 void SAL_CALL VCLXDialog::endDialog( ::sal_Int32 i_result ) throw (RuntimeException, std::exception)
2280 SolarMutexGuard aGuard;
2281 VclPtr<Dialog> pDialog = GetAsDynamic< Dialog >();
2282 if ( pDialog )
2283 pDialog->EndDialog( i_result );
2286 void SAL_CALL VCLXDialog::setHelpId( const OUString& rId ) throw (RuntimeException, std::exception)
2288 SolarMutexGuard aGuard;
2289 VclPtr< vcl::Window > pWindow = GetWindow();
2290 if ( pWindow )
2291 pWindow->SetHelpId( OUStringToOString( rId, RTL_TEXTENCODING_UTF8 ) );
2294 void VCLXDialog::setTitle( const OUString& Title ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2296 SolarMutexGuard aGuard;
2297 VclPtr< vcl::Window > pWindow = GetWindow();
2298 if ( pWindow )
2299 pWindow->SetText( Title );
2302 OUString VCLXDialog::getTitle() throw(::com::sun::star::uno::RuntimeException, std::exception)
2304 SolarMutexGuard aGuard;
2306 OUString aTitle;
2307 VclPtr< vcl::Window > pWindow = GetWindow();
2308 if ( pWindow )
2309 aTitle = pWindow->GetText();
2310 return aTitle;
2313 sal_Int16 VCLXDialog::execute() throw(::com::sun::star::uno::RuntimeException, std::exception)
2315 SolarMutexGuard aGuard;
2317 sal_Int16 nRet = 0;
2318 if ( GetWindow() )
2320 VclPtr< Dialog > pDlg = GetAs< Dialog >();
2321 vcl::Window* pParent = pDlg->GetWindow( GetWindowType::ParentOverlap );
2322 vcl::Window* pOldParent = NULL;
2323 vcl::Window* pSetParent = NULL;
2324 if ( pParent && !pParent->IsReallyVisible() )
2326 pOldParent = pDlg->GetParent();
2327 vcl::Window* pFrame = pDlg->GetWindow( GetWindowType::Frame );
2328 if( pFrame != pDlg )
2330 pDlg->SetParent( pFrame );
2331 pSetParent = pFrame;
2335 nRet = pDlg->Execute();
2337 // set the parent back only in case no new parent was set from outside
2338 // in other words, revert only own changes
2339 if ( pOldParent && pDlg->GetParent() == pSetParent )
2340 pDlg->SetParent( pOldParent );
2342 return nRet;
2345 void VCLXDialog::endExecute() throw(::com::sun::star::uno::RuntimeException, std::exception)
2347 endDialog(0);
2350 void SAL_CALL VCLXDialog::draw( sal_Int32 nX, sal_Int32 nY ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2352 SolarMutexGuard aGuard;
2353 VclPtr< vcl::Window > pWindow = GetWindow();
2354 if ( pWindow )
2356 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
2357 if ( !pDev )
2358 pDev = pWindow->GetParent();
2360 Size aSize = pDev->PixelToLogic( pWindow->GetSizePixel() );
2361 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
2363 pWindow->Draw( pDev, aPos, aSize, WINDOW_DRAW_NOCONTROLS );
2367 ::com::sun::star::awt::DeviceInfo VCLXDialog::getInfo() throw(::com::sun::star::uno::RuntimeException, std::exception)
2369 ::com::sun::star::awt::DeviceInfo aInfo = VCLXDevice::getInfo();
2371 SolarMutexGuard aGuard;
2372 VclPtr< Dialog > pDlg = GetAs< Dialog >();
2373 if ( pDlg )
2374 pDlg->GetDrawWindowBorder( aInfo.LeftInset, aInfo.TopInset, aInfo.RightInset, aInfo.BottomInset );
2376 return aInfo;
2379 void SAL_CALL VCLXDialog::setProperty(
2380 const OUString& PropertyName,
2381 const ::com::sun::star::uno::Any& Value )
2382 throw(::com::sun::star::uno::RuntimeException, std::exception)
2384 SolarMutexGuard aGuard;
2385 VclPtr< Dialog > pDialog = GetAs< Dialog >();
2386 if ( pDialog )
2388 bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
2390 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2391 switch ( nPropType )
2393 case BASEPROPERTY_GRAPHIC:
2395 Reference< XGraphic > xGraphic;
2396 if (( Value >>= xGraphic ) && xGraphic.is() )
2398 Image aImage( xGraphic );
2400 Wallpaper aWallpaper( aImage.GetBitmapEx());
2401 aWallpaper.SetStyle( WALLPAPER_SCALE );
2402 pDialog->SetBackground( aWallpaper );
2404 else if ( bVoid || !xGraphic.is() )
2406 Color aColor = pDialog->GetControlBackground().GetColor();
2407 if ( aColor == COL_AUTO )
2408 aColor = pDialog->GetSettings().GetStyleSettings().GetDialogColor();
2410 Wallpaper aWallpaper( aColor );
2411 pDialog->SetBackground( aWallpaper );
2414 break;
2416 default:
2418 VCLXContainer::setProperty( PropertyName, Value );
2426 // class VCLXTabPage
2428 VCLXMultiPage::VCLXMultiPage() : maTabListeners( *this ), mTabId( 1 )
2430 OSL_TRACE("VCLXMultiPage::VCLXMultiPage()" );
2433 void VCLXMultiPage::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2435 PushPropertyIds( rIds,
2436 BASEPROPERTY_BACKGROUNDCOLOR,
2437 BASEPROPERTY_DEFAULTCONTROL,
2438 BASEPROPERTY_ENABLED,
2439 BASEPROPERTY_MULTIPAGEVALUE,
2440 BASEPROPERTY_ENABLEVISIBLE,
2441 BASEPROPERTY_FONTDESCRIPTOR,
2442 BASEPROPERTY_GRAPHIC,
2443 BASEPROPERTY_HELPTEXT,
2444 BASEPROPERTY_HELPURL,
2445 BASEPROPERTY_IMAGEALIGN,
2446 BASEPROPERTY_IMAGEPOSITION,
2447 BASEPROPERTY_IMAGEURL,
2448 BASEPROPERTY_PRINTABLE,
2449 BASEPROPERTY_TABSTOP,
2450 BASEPROPERTY_FOCUSONCLICK,
2452 VCLXContainer::ImplGetPropertyIds( rIds );
2455 VCLXMultiPage::~VCLXMultiPage()
2458 void SAL_CALL VCLXMultiPage::dispose() throw(::com::sun::star::uno::RuntimeException, std::exception)
2460 SolarMutexGuard aGuard;
2462 ::com::sun::star::lang::EventObject aObj;
2463 aObj.Source = (::cppu::OWeakObject*)this;
2464 maTabListeners.disposeAndClear( aObj );
2465 VCLXContainer::dispose();
2467 ::com::sun::star::uno::Any SAL_CALL VCLXMultiPage::queryInterface(const ::com::sun::star::uno::Type & rType )
2468 throw(::com::sun::star::uno::RuntimeException, std::exception)
2470 uno::Any aRet = ::cppu::queryInterface( rType, static_cast< awt::XSimpleTabController*>( this ) );
2472 return ( aRet.hasValue() ? aRet : VCLXContainer::queryInterface( rType ) );
2475 // ::com::sun::star::lang::XTypeProvider
2476 IMPL_XTYPEPROVIDER_START( VCLXMultiPage )
2477 VCLXContainer::getTypes()
2478 IMPL_XTYPEPROVIDER_END
2480 // ::com::sun::star::awt::XView
2481 void SAL_CALL VCLXMultiPage::draw( sal_Int32 nX, sal_Int32 nY )
2482 throw(::com::sun::star::uno::RuntimeException, std::exception)
2484 SolarMutexGuard aGuard;
2485 VclPtr< vcl::Window > pWindow = GetWindow();
2487 if ( pWindow )
2489 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
2490 if ( !pDev )
2491 pDev = pWindow->GetParent();
2493 Size aSize = pDev->PixelToLogic( pWindow->GetSizePixel() );
2494 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
2496 pWindow->Draw( pDev, aPos, aSize, WINDOW_DRAW_NOCONTROLS );
2500 // ::com::sun::star::awt::XDevice,
2501 ::com::sun::star::awt::DeviceInfo SAL_CALL VCLXMultiPage::getInfo()
2502 throw(::com::sun::star::uno::RuntimeException, std::exception)
2504 ::com::sun::star::awt::DeviceInfo aInfo = VCLXDevice::getInfo();
2505 return aInfo;
2508 uno::Any SAL_CALL VCLXMultiPage::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2510 SolarMutexGuard aGuard;
2511 OSL_TRACE(" **** VCLXMultiPage::getProperty( %s )",
2512 OUStringToOString( PropertyName,
2513 RTL_TEXTENCODING_UTF8 ).getStr() );
2514 ::com::sun::star::uno::Any aProp;
2515 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2516 switch ( nPropType )
2519 case BASEPROPERTY_MULTIPAGEVALUE:
2521 aProp <<= getActiveTabID();
2523 break;
2524 default:
2525 aProp <<= VCLXContainer::getProperty( PropertyName );
2527 return aProp;
2530 void SAL_CALL VCLXMultiPage::setProperty(
2531 const OUString& PropertyName,
2532 const ::com::sun::star::uno::Any& Value )
2533 throw(::com::sun::star::uno::RuntimeException, std::exception)
2535 SolarMutexGuard aGuard;
2536 OSL_TRACE(" **** VCLXMultiPage::setProperty( %s )", OUStringToOString( PropertyName, RTL_TEXTENCODING_UTF8 ).getStr() );
2538 VclPtr< TabControl > pTabControl = GetAs< TabControl >();
2539 if ( pTabControl )
2541 bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
2543 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2544 switch ( nPropType )
2546 case BASEPROPERTY_MULTIPAGEVALUE:
2548 OSL_TRACE("***MULTIPAGE VALUE");
2549 sal_Int32 nId(0);
2550 Value >>= nId;
2551 // when the multipage is created we attempt to set the activepage
2552 // but no pages created
2553 if ( nId && nId <= getWindows().getLength() )
2554 activateTab( nId );
2555 break;
2557 case BASEPROPERTY_GRAPHIC:
2559 Reference< XGraphic > xGraphic;
2560 if (( Value >>= xGraphic ) && xGraphic.is() )
2562 Image aImage( xGraphic );
2564 Wallpaper aWallpaper( aImage.GetBitmapEx());
2565 aWallpaper.SetStyle( WALLPAPER_SCALE );
2566 pTabControl->SetBackground( aWallpaper );
2568 else if ( bVoid || !xGraphic.is() )
2570 Color aColor = pTabControl->GetControlBackground().GetColor();
2571 if ( aColor == COL_AUTO )
2572 aColor = pTabControl->GetSettings().GetStyleSettings().GetDialogColor();
2574 Wallpaper aWallpaper( aColor );
2575 pTabControl->SetBackground( aWallpaper );
2578 break;
2580 default:
2582 VCLXContainer::setProperty( PropertyName, Value );
2588 TabControl *VCLXMultiPage::getTabControl() const throw (uno::RuntimeException)
2590 VclPtr<TabControl> pTabControl = GetAsDynamic< TabControl >();
2591 if ( pTabControl )
2592 return pTabControl;
2593 throw uno::RuntimeException();
2595 sal_Int32 SAL_CALL VCLXMultiPage::insertTab() throw (uno::RuntimeException, std::exception)
2597 TabControl *pTabControl = getTabControl();
2598 VclPtrInstance<TabPage> pTab( pTabControl );
2599 OUString title ("");
2600 return static_cast< sal_Int32 >( insertTab( pTab, title ) );
2603 sal_uInt16 VCLXMultiPage::insertTab( TabPage* pPage, OUString& sTitle )
2605 TabControl *pTabControl = getTabControl();
2606 sal_uInt16 id = sal::static_int_cast< sal_uInt16 >( mTabId++ );
2607 pTabControl->InsertPage( id, sTitle, TAB_APPEND );
2608 pTabControl->SetTabPage( id, pPage );
2609 return id;
2612 void SAL_CALL VCLXMultiPage::removeTab( sal_Int32 ID ) throw (uno::RuntimeException, lang::IndexOutOfBoundsException, std::exception)
2614 TabControl *pTabControl = getTabControl();
2615 if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == NULL )
2616 throw lang::IndexOutOfBoundsException();
2617 pTabControl->RemovePage( sal::static_int_cast< sal_uInt16 >( ID ) );
2620 void SAL_CALL VCLXMultiPage::activateTab( sal_Int32 ID ) throw (uno::RuntimeException, lang::IndexOutOfBoundsException, std::exception)
2622 TabControl *pTabControl = getTabControl();
2623 SAL_INFO(
2624 "toolkit",
2625 "Attempting to activate tab " << ID << ", active tab is "
2626 << getActiveTabID() << ", numtabs is " << getWindows().getLength());
2627 if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == NULL )
2628 throw lang::IndexOutOfBoundsException();
2629 pTabControl->SelectTabPage( sal::static_int_cast< sal_uInt16 >( ID ) );
2632 sal_Int32 SAL_CALL VCLXMultiPage::getActiveTabID() throw (uno::RuntimeException, std::exception)
2634 return getTabControl()->GetCurPageId( );
2637 void SAL_CALL VCLXMultiPage::addTabListener( const uno::Reference< awt::XTabListener >& xListener ) throw (uno::RuntimeException, std::exception)
2639 SolarMutexGuard aGuard;
2640 maTabListeners.addInterface( xListener );
2643 void SAL_CALL VCLXMultiPage::removeTabListener( const uno::Reference< awt::XTabListener >& xListener ) throw (uno::RuntimeException, std::exception)
2645 SolarMutexGuard aGuard;
2646 maTabListeners.addInterface( xListener );
2649 void SAL_CALL VCLXMultiPage::setTabProps( sal_Int32 ID, const uno::Sequence< beans::NamedValue >& Properties ) throw (uno::RuntimeException, lang::IndexOutOfBoundsException, std::exception)
2651 SolarMutexGuard aGuard;
2652 TabControl *pTabControl = getTabControl();
2653 if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == NULL )
2654 throw lang::IndexOutOfBoundsException();
2656 for (sal_Int32 i = 0; i < Properties.getLength(); ++i)
2658 const OUString &name = Properties[i].Name;
2659 const uno::Any &value = Properties[i].Value;
2661 if (name == "Title")
2663 OUString title = value.get<OUString>();
2664 pTabControl->SetPageText( sal::static_int_cast< sal_uInt16 >( ID ), title );
2669 uno::Sequence< beans::NamedValue > SAL_CALL VCLXMultiPage::getTabProps( sal_Int32 ID )
2670 throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
2672 SolarMutexGuard aGuard;
2673 TabControl *pTabControl = getTabControl();
2674 if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == NULL )
2675 throw lang::IndexOutOfBoundsException();
2677 #define ADD_PROP( seq, i, name, val ) { \
2678 beans::NamedValue value; \
2679 value.Name = name; \
2680 value.Value = uno::makeAny( val ); \
2681 seq[i] = value; \
2684 uno::Sequence< beans::NamedValue > props( 2 );
2685 ADD_PROP( props, 0, "Title", OUString( pTabControl->GetPageText( sal::static_int_cast< sal_uInt16 >( ID ) ) ) );
2686 ADD_PROP( props, 1, "Position", pTabControl->GetPagePos( sal::static_int_cast< sal_uInt16 >( ID ) ) );
2687 #undef ADD_PROP
2688 return props;
2690 void VCLXMultiPage::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
2692 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
2693 switch ( rVclWindowEvent.GetId() )
2695 case VCLEVENT_TABPAGE_DEACTIVATE:
2697 sal_uLong nPageID = reinterpret_cast<sal_uLong>( rVclWindowEvent.GetData() );
2698 maTabListeners.deactivated( nPageID );
2699 break;
2702 case VCLEVENT_TABPAGE_ACTIVATE:
2704 sal_uLong nPageID = reinterpret_cast<sal_uLong>( rVclWindowEvent.GetData() );
2705 maTabListeners.activated( nPageID );
2706 break;
2708 default:
2709 VCLXContainer::ProcessWindowEvent( rVclWindowEvent );
2710 break;
2715 // class VCLXTabPage
2717 VCLXTabPage::VCLXTabPage()
2721 void VCLXTabPage::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2723 PushPropertyIds( rIds,
2724 BASEPROPERTY_BACKGROUNDCOLOR,
2725 BASEPROPERTY_DEFAULTCONTROL,
2726 BASEPROPERTY_ENABLED,
2727 BASEPROPERTY_ENABLEVISIBLE,
2728 BASEPROPERTY_FONTDESCRIPTOR,
2729 BASEPROPERTY_GRAPHIC,
2730 BASEPROPERTY_HELPTEXT,
2731 BASEPROPERTY_HELPURL,
2732 BASEPROPERTY_IMAGEALIGN,
2733 BASEPROPERTY_IMAGEPOSITION,
2734 BASEPROPERTY_IMAGEURL,
2735 BASEPROPERTY_PRINTABLE,
2736 BASEPROPERTY_TABSTOP,
2737 BASEPROPERTY_FOCUSONCLICK,
2739 VCLXContainer::ImplGetPropertyIds( rIds );
2742 VCLXTabPage::~VCLXTabPage()
2746 ::com::sun::star::uno::Any SAL_CALL VCLXTabPage::queryInterface(const ::com::sun::star::uno::Type & rType )
2747 throw(::com::sun::star::uno::RuntimeException, std::exception)
2749 return VCLXContainer::queryInterface( rType );
2752 // ::com::sun::star::lang::XTypeProvider
2753 IMPL_XTYPEPROVIDER_START( VCLXTabPage )
2754 VCLXContainer::getTypes()
2755 IMPL_XTYPEPROVIDER_END
2757 // ::com::sun::star::awt::XView
2758 void SAL_CALL VCLXTabPage::draw( sal_Int32 nX, sal_Int32 nY )
2759 throw(::com::sun::star::uno::RuntimeException, std::exception)
2761 SolarMutexGuard aGuard;
2762 VclPtr< vcl::Window > pWindow = GetWindow();
2764 if ( pWindow )
2766 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
2767 if ( !pDev )
2768 pDev = pWindow->GetParent();
2770 Size aSize = pDev->PixelToLogic( pWindow->GetSizePixel() );
2771 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
2773 pWindow->Draw( pDev, aPos, aSize, WINDOW_DRAW_NOCONTROLS );
2777 // ::com::sun::star::awt::XDevice,
2778 ::com::sun::star::awt::DeviceInfo SAL_CALL VCLXTabPage::getInfo()
2779 throw(::com::sun::star::uno::RuntimeException, std::exception)
2781 ::com::sun::star::awt::DeviceInfo aInfo = VCLXDevice::getInfo();
2782 return aInfo;
2785 void SAL_CALL VCLXTabPage::setProperty(
2786 const OUString& PropertyName,
2787 const ::com::sun::star::uno::Any& Value )
2788 throw(::com::sun::star::uno::RuntimeException, std::exception)
2790 SolarMutexGuard aGuard;
2791 VclPtr< TabPage > pTabPage = GetAs< TabPage >();
2792 if ( pTabPage )
2794 bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
2796 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2797 switch ( nPropType )
2799 case BASEPROPERTY_GRAPHIC:
2801 Reference< XGraphic > xGraphic;
2802 if (( Value >>= xGraphic ) && xGraphic.is() )
2804 Image aImage( xGraphic );
2806 Wallpaper aWallpaper( aImage.GetBitmapEx());
2807 aWallpaper.SetStyle( WALLPAPER_SCALE );
2808 pTabPage->SetBackground( aWallpaper );
2810 else if ( bVoid || !xGraphic.is() )
2812 Color aColor = pTabPage->GetControlBackground().GetColor();
2813 if ( aColor == COL_AUTO )
2814 aColor = pTabPage->GetSettings().GetStyleSettings().GetDialogColor();
2816 Wallpaper aWallpaper( aColor );
2817 pTabPage->SetBackground( aWallpaper );
2820 break;
2821 case BASEPROPERTY_TITLE:
2823 OUString sTitle;
2824 if ( Value >>= sTitle )
2826 pTabPage->SetText(sTitle);
2829 break;
2831 default:
2833 VCLXContainer::setProperty( PropertyName, Value );
2839 TabPage *VCLXTabPage::getTabPage() const throw (uno::RuntimeException)
2841 VclPtr< TabPage > pTabPage = GetAsDynamic< TabPage >();
2842 if ( pTabPage )
2843 return pTabPage;
2844 throw uno::RuntimeException();
2848 // class VCLXFixedHyperlink
2851 VCLXFixedHyperlink::VCLXFixedHyperlink() :
2853 maActionListeners( *this )
2858 VCLXFixedHyperlink::~VCLXFixedHyperlink()
2862 // ::com::sun::star::uno::XInterface
2863 ::com::sun::star::uno::Any VCLXFixedHyperlink::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2865 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
2866 (static_cast< ::com::sun::star::awt::XFixedHyperlink* >(this)) );
2867 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
2870 void VCLXFixedHyperlink::dispose() throw(::com::sun::star::uno::RuntimeException, std::exception)
2872 SolarMutexGuard aGuard;
2874 ::com::sun::star::lang::EventObject aObj;
2875 aObj.Source = (::cppu::OWeakObject*)this;
2876 maActionListeners.disposeAndClear( aObj );
2877 VCLXWindow::dispose();
2880 // ::com::sun::star::lang::XTypeProvider
2881 IMPL_XTYPEPROVIDER_START( VCLXFixedHyperlink )
2882 cppu::UnoType<com::sun::star::awt::XFixedHyperlink>::get(),
2883 VCLXWindow::getTypes()
2884 IMPL_XTYPEPROVIDER_END
2886 void VCLXFixedHyperlink::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
2888 switch ( rVclWindowEvent.GetId() )
2890 case VCLEVENT_BUTTON_CLICK:
2892 if ( maActionListeners.getLength() )
2894 ::com::sun::star::awt::ActionEvent aEvent;
2895 aEvent.Source = (::cppu::OWeakObject*)this;
2896 maActionListeners.actionPerformed( aEvent );
2898 else
2900 // open the URL
2901 OUString sURL;
2902 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
2903 if ( pBase )
2904 sURL = pBase->GetURL();
2905 Reference< ::com::sun::star::system::XSystemShellExecute > xSystemShellExecute( ::com::sun::star::system::SystemShellExecute::create(
2906 ::comphelper::getProcessComponentContext() ) );
2907 if ( !sURL.isEmpty() )
2911 // start browser
2912 xSystemShellExecute->execute(
2913 sURL, OUString(), ::com::sun::star::system::SystemShellExecuteFlags::URIS_ONLY );
2915 catch( uno::Exception& )
2921 //fall-through
2922 default:
2923 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
2924 break;
2928 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXFixedHyperlink::CreateAccessibleContext()
2930 return getAccessibleFactory().createAccessibleContext( this );
2933 void VCLXFixedHyperlink::setText( const OUString& Text ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2935 SolarMutexGuard aGuard;
2936 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
2937 if (pBase)
2938 pBase->SetText(Text);
2941 OUString VCLXFixedHyperlink::getText() throw(::com::sun::star::uno::RuntimeException, std::exception)
2943 SolarMutexGuard aGuard;
2945 OUString aText;
2946 VclPtr< vcl::Window > pWindow = GetWindow();
2947 if ( pWindow )
2948 aText = pWindow->GetText();
2949 return aText;
2952 void VCLXFixedHyperlink::setURL( const OUString& URL ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2954 SolarMutexGuard aGuard;
2955 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
2956 if ( pBase )
2957 pBase->SetURL( URL );
2960 OUString VCLXFixedHyperlink::getURL( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2962 SolarMutexGuard aGuard;
2964 OUString aText;
2965 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
2966 if ( pBase )
2967 aText = pBase->GetURL();
2968 return aText;
2971 void VCLXFixedHyperlink::setAlignment( short nAlign ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2973 SolarMutexGuard aGuard;
2975 VclPtr< vcl::Window > pWindow = GetWindow();
2976 if ( pWindow )
2978 WinBits nNewBits = 0;
2979 if ( nAlign == ::com::sun::star::awt::TextAlign::LEFT )
2980 nNewBits = WB_LEFT;
2981 else if ( nAlign == ::com::sun::star::awt::TextAlign::CENTER )
2982 nNewBits = WB_CENTER;
2983 else
2984 nNewBits = WB_RIGHT;
2986 WinBits nStyle = pWindow->GetStyle();
2987 nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT);
2988 pWindow->SetStyle( nStyle | nNewBits );
2992 short VCLXFixedHyperlink::getAlignment() throw(::com::sun::star::uno::RuntimeException, std::exception)
2994 SolarMutexGuard aGuard;
2996 short nAlign = 0;
2997 VclPtr< vcl::Window > pWindow = GetWindow();
2998 if ( pWindow )
3000 WinBits nStyle = pWindow->GetStyle();
3001 if ( nStyle & WB_LEFT )
3002 nAlign = ::com::sun::star::awt::TextAlign::LEFT;
3003 else if ( nStyle & WB_CENTER )
3004 nAlign = ::com::sun::star::awt::TextAlign::CENTER;
3005 else
3006 nAlign = ::com::sun::star::awt::TextAlign::RIGHT;
3008 return nAlign;
3011 void VCLXFixedHyperlink::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )throw(::com::sun::star::uno::RuntimeException, std::exception)
3013 SolarMutexGuard aGuard;
3014 maActionListeners.addInterface( l );
3017 void VCLXFixedHyperlink::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3019 SolarMutexGuard aGuard;
3020 maActionListeners.removeInterface( l );
3023 ::com::sun::star::awt::Size VCLXFixedHyperlink::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3025 SolarMutexGuard aGuard;
3026 Size aSz;
3027 VclPtr< FixedText > pFixedText = GetAs< FixedText >();
3028 if ( pFixedText )
3029 aSz = pFixedText->CalcMinimumSize();
3030 return AWTSize(aSz);
3033 ::com::sun::star::awt::Size VCLXFixedHyperlink::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3035 return getMinimumSize();
3038 ::com::sun::star::awt::Size VCLXFixedHyperlink::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3040 SolarMutexGuard aGuard;
3042 ::com::sun::star::awt::Size aSz = rNewSize;
3043 ::com::sun::star::awt::Size aMinSz = getMinimumSize();
3044 if ( aSz.Height != aMinSz.Height )
3045 aSz.Height = aMinSz.Height;
3047 return aSz;
3050 void VCLXFixedHyperlink::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
3052 SolarMutexGuard aGuard;
3054 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
3055 if ( pBase )
3057 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3058 switch ( nPropType )
3060 case BASEPROPERTY_LABEL:
3062 OUString sNewLabel;
3063 if ( Value >>= sNewLabel )
3064 pBase->SetText(sNewLabel);
3065 break;
3068 case BASEPROPERTY_URL:
3070 OUString sNewURL;
3071 if ( Value >>= sNewURL )
3072 pBase->SetURL( sNewURL );
3073 break;
3076 default:
3078 VCLXWindow::setProperty( PropertyName, Value );
3084 ::com::sun::star::uno::Any VCLXFixedHyperlink::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3086 SolarMutexGuard aGuard;
3088 ::com::sun::star::uno::Any aProp;
3089 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
3090 if ( pBase )
3092 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3093 switch ( nPropType )
3095 case BASEPROPERTY_URL:
3097 aProp = makeAny( OUString( pBase->GetURL() ) );
3098 break;
3101 default:
3103 aProp <<= VCLXWindow::getProperty( PropertyName );
3107 return aProp;
3110 void VCLXFixedHyperlink::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
3112 PushPropertyIds( rIds,
3113 BASEPROPERTY_ALIGN,
3114 BASEPROPERTY_BACKGROUNDCOLOR,
3115 BASEPROPERTY_BORDER,
3116 BASEPROPERTY_BORDERCOLOR,
3117 BASEPROPERTY_DEFAULTCONTROL,
3118 BASEPROPERTY_ENABLED,
3119 BASEPROPERTY_ENABLEVISIBLE,
3120 BASEPROPERTY_FONTDESCRIPTOR,
3121 BASEPROPERTY_HELPTEXT,
3122 BASEPROPERTY_HELPURL,
3123 BASEPROPERTY_LABEL,
3124 BASEPROPERTY_MULTILINE,
3125 BASEPROPERTY_NOLABEL,
3126 BASEPROPERTY_PRINTABLE,
3127 BASEPROPERTY_TABSTOP,
3128 BASEPROPERTY_VERTICALALIGN,
3129 BASEPROPERTY_URL,
3130 BASEPROPERTY_WRITING_MODE,
3131 BASEPROPERTY_CONTEXT_WRITING_MODE,
3133 VCLXWindow::ImplGetPropertyIds( rIds );
3137 // class VCLXFixedText
3139 void VCLXFixedText::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
3141 PushPropertyIds( rIds,
3142 BASEPROPERTY_ALIGN,
3143 BASEPROPERTY_BACKGROUNDCOLOR,
3144 BASEPROPERTY_BORDER,
3145 BASEPROPERTY_BORDERCOLOR,
3146 BASEPROPERTY_DEFAULTCONTROL,
3147 BASEPROPERTY_ENABLED,
3148 BASEPROPERTY_ENABLEVISIBLE,
3149 BASEPROPERTY_FONTDESCRIPTOR,
3150 BASEPROPERTY_HELPTEXT,
3151 BASEPROPERTY_HELPURL,
3152 BASEPROPERTY_LABEL,
3153 BASEPROPERTY_MULTILINE,
3154 BASEPROPERTY_NOLABEL,
3155 BASEPROPERTY_PRINTABLE,
3156 BASEPROPERTY_TABSTOP,
3157 BASEPROPERTY_VERTICALALIGN,
3158 BASEPROPERTY_WRITING_MODE,
3159 BASEPROPERTY_CONTEXT_WRITING_MODE,
3160 BASEPROPERTY_REFERENCE_DEVICE,
3162 VCLXWindow::ImplGetPropertyIds( rIds );
3165 VCLXFixedText::VCLXFixedText()
3169 VCLXFixedText::~VCLXFixedText()
3173 // ::com::sun::star::uno::XInterface
3174 ::com::sun::star::uno::Any VCLXFixedText::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3176 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
3177 (static_cast< ::com::sun::star::awt::XFixedText* >(this)) );
3178 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
3181 // ::com::sun::star::lang::XTypeProvider
3182 IMPL_XTYPEPROVIDER_START( VCLXFixedText )
3183 cppu::UnoType<com::sun::star::awt::XFixedText>::get(),
3184 VCLXWindow::getTypes()
3185 IMPL_XTYPEPROVIDER_END
3187 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXFixedText::CreateAccessibleContext()
3189 return getAccessibleFactory().createAccessibleContext( this );
3192 void VCLXFixedText::setText( const OUString& Text ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3194 SolarMutexGuard aGuard;
3196 VclPtr< vcl::Window > pWindow = GetWindow();
3197 if ( pWindow )
3198 pWindow->SetText( Text );
3201 OUString VCLXFixedText::getText() throw(::com::sun::star::uno::RuntimeException, std::exception)
3203 SolarMutexGuard aGuard;
3205 OUString aText;
3206 VclPtr< vcl::Window > pWindow = GetWindow();
3207 if ( pWindow )
3208 aText = pWindow->GetText();
3209 return aText;
3212 void VCLXFixedText::setAlignment( short nAlign ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3214 SolarMutexGuard aGuard;
3216 VclPtr< vcl::Window > pWindow = GetWindow();
3217 if ( pWindow )
3219 WinBits nNewBits = 0;
3220 if ( nAlign == ::com::sun::star::awt::TextAlign::LEFT )
3221 nNewBits = WB_LEFT;
3222 else if ( nAlign == ::com::sun::star::awt::TextAlign::CENTER )
3223 nNewBits = WB_CENTER;
3224 else
3225 nNewBits = WB_RIGHT;
3227 WinBits nStyle = pWindow->GetStyle();
3228 nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT);
3229 pWindow->SetStyle( nStyle | nNewBits );
3233 short VCLXFixedText::getAlignment() throw(::com::sun::star::uno::RuntimeException, std::exception)
3235 SolarMutexGuard aGuard;
3237 short nAlign = 0;
3238 VclPtr< vcl::Window > pWindow = GetWindow();
3239 if ( pWindow )
3241 WinBits nStyle = pWindow->GetStyle();
3242 if ( nStyle & WB_LEFT )
3243 nAlign = ::com::sun::star::awt::TextAlign::LEFT;
3244 else if ( nStyle & WB_CENTER )
3245 nAlign = ::com::sun::star::awt::TextAlign::CENTER;
3246 else
3247 nAlign = ::com::sun::star::awt::TextAlign::RIGHT;
3249 return nAlign;
3252 ::com::sun::star::awt::Size VCLXFixedText::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3254 SolarMutexGuard aGuard;
3256 Size aSz;
3257 VclPtr< FixedText > pFixedText = GetAs< FixedText >();
3258 if ( pFixedText )
3259 aSz = pFixedText->CalcMinimumSize();
3260 return AWTSize(aSz);
3263 ::com::sun::star::awt::Size VCLXFixedText::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3265 return getMinimumSize();
3268 ::com::sun::star::awt::Size VCLXFixedText::calcAdjustedSize( const ::com::sun::star::awt::Size& rMaxSize ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3270 SolarMutexGuard aGuard;
3272 Size aAdjustedSize( VCLUnoHelper::ConvertToVCLSize( rMaxSize ) );
3273 VclPtr< FixedText > pFixedText = GetAs< FixedText >();
3274 if ( pFixedText )
3275 aAdjustedSize = pFixedText->CalcMinimumSize( rMaxSize.Width );
3276 return VCLUnoHelper::ConvertToAWTSize( aAdjustedSize );
3280 // class VCLXScrollBar
3282 void VCLXScrollBar::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
3284 PushPropertyIds( rIds,
3285 BASEPROPERTY_BACKGROUNDCOLOR,
3286 BASEPROPERTY_BLOCKINCREMENT,
3287 BASEPROPERTY_BORDER,
3288 BASEPROPERTY_BORDERCOLOR,
3289 BASEPROPERTY_DEFAULTCONTROL,
3290 BASEPROPERTY_ENABLED,
3291 BASEPROPERTY_ENABLEVISIBLE,
3292 BASEPROPERTY_HELPTEXT,
3293 BASEPROPERTY_HELPURL,
3294 BASEPROPERTY_LINEINCREMENT,
3295 BASEPROPERTY_LIVE_SCROLL,
3296 BASEPROPERTY_ORIENTATION,
3297 BASEPROPERTY_PRINTABLE,
3298 BASEPROPERTY_REPEAT_DELAY,
3299 BASEPROPERTY_SCROLLVALUE,
3300 BASEPROPERTY_SCROLLVALUE_MAX,
3301 BASEPROPERTY_SCROLLVALUE_MIN,
3302 BASEPROPERTY_SYMBOL_COLOR,
3303 BASEPROPERTY_TABSTOP,
3304 BASEPROPERTY_VISIBLESIZE,
3305 BASEPROPERTY_WRITING_MODE,
3306 BASEPROPERTY_CONTEXT_WRITING_MODE,
3308 VCLXWindow::ImplGetPropertyIds( rIds );
3311 VCLXScrollBar::VCLXScrollBar() : maAdjustmentListeners( *this )
3315 // ::com::sun::star::uno::XInterface
3316 ::com::sun::star::uno::Any VCLXScrollBar::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3318 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
3319 (static_cast< ::com::sun::star::awt::XScrollBar* >(this)) );
3320 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
3323 // ::com::sun::star::lang::XTypeProvider
3324 IMPL_XTYPEPROVIDER_START( VCLXScrollBar )
3325 cppu::UnoType<com::sun::star::awt::XScrollBar>::get(),
3326 VCLXWindow::getTypes()
3327 IMPL_XTYPEPROVIDER_END
3329 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXScrollBar::CreateAccessibleContext()
3331 return getAccessibleFactory().createAccessibleContext( this );
3334 // ::com::sun::star::lang::XComponent
3335 void VCLXScrollBar::dispose() throw(::com::sun::star::uno::RuntimeException, std::exception)
3337 SolarMutexGuard aGuard;
3339 ::com::sun::star::lang::EventObject aObj;
3340 aObj.Source = (::cppu::OWeakObject*)this;
3341 maAdjustmentListeners.disposeAndClear( aObj );
3342 VCLXWindow::dispose();
3345 // ::com::sun::star::awt::XScrollbar
3346 void VCLXScrollBar::addAdjustmentListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XAdjustmentListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3348 SolarMutexGuard aGuard;
3349 maAdjustmentListeners.addInterface( l );
3352 void VCLXScrollBar::removeAdjustmentListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XAdjustmentListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3354 SolarMutexGuard aGuard;
3355 maAdjustmentListeners.removeInterface( l );
3358 void VCLXScrollBar::setValue( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3360 SolarMutexGuard aGuard;
3362 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3363 if ( pScrollBar )
3364 pScrollBar->DoScroll( n );
3367 void VCLXScrollBar::setValues( sal_Int32 nValue, sal_Int32 nVisible, sal_Int32 nMax ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3369 SolarMutexGuard aGuard;
3371 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3372 if ( pScrollBar )
3374 pScrollBar->SetVisibleSize( nVisible );
3375 pScrollBar->SetRangeMax( nMax );
3376 pScrollBar->DoScroll( nValue );
3380 sal_Int32 VCLXScrollBar::getValue() throw(::com::sun::star::uno::RuntimeException, std::exception)
3382 SolarMutexGuard aGuard;
3384 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3385 return pScrollBar ? pScrollBar->GetThumbPos() : 0;
3388 void VCLXScrollBar::setMaximum( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3390 SolarMutexGuard aGuard;
3392 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3393 if ( pScrollBar )
3394 pScrollBar->SetRangeMax( n );
3397 sal_Int32 VCLXScrollBar::getMaximum() throw(::com::sun::star::uno::RuntimeException, std::exception)
3399 SolarMutexGuard aGuard;
3401 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3402 return pScrollBar ? pScrollBar->GetRangeMax() : 0;
3405 void VCLXScrollBar::setMinimum( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException)
3407 SolarMutexGuard aGuard;
3409 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3410 if ( pScrollBar )
3411 pScrollBar->SetRangeMin( n );
3414 sal_Int32 VCLXScrollBar::getMinimum() throw(::com::sun::star::uno::RuntimeException)
3416 SolarMutexGuard aGuard;
3418 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3419 return pScrollBar ? pScrollBar->GetRangeMin() : 0;
3422 void VCLXScrollBar::setLineIncrement( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3424 SolarMutexGuard aGuard;
3426 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3427 if ( pScrollBar )
3428 pScrollBar->SetLineSize( n );
3431 sal_Int32 VCLXScrollBar::getLineIncrement() throw(::com::sun::star::uno::RuntimeException, std::exception)
3433 SolarMutexGuard aGuard;
3435 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3436 return pScrollBar ? pScrollBar->GetLineSize() : 0;
3439 void VCLXScrollBar::setBlockIncrement( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3441 SolarMutexGuard aGuard;
3443 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3444 if ( pScrollBar )
3445 pScrollBar->SetPageSize( n );
3448 sal_Int32 VCLXScrollBar::getBlockIncrement() throw(::com::sun::star::uno::RuntimeException, std::exception)
3450 SolarMutexGuard aGuard;
3452 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3453 return pScrollBar ? pScrollBar->GetPageSize() : 0;
3456 void VCLXScrollBar::setVisibleSize( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3458 SolarMutexGuard aGuard;
3460 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3461 if ( pScrollBar )
3462 pScrollBar->SetVisibleSize( n );
3465 sal_Int32 VCLXScrollBar::getVisibleSize() throw(::com::sun::star::uno::RuntimeException, std::exception)
3467 SolarMutexGuard aGuard;
3469 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3470 return pScrollBar ? pScrollBar->GetVisibleSize() : 0;
3473 void VCLXScrollBar::setOrientation( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3475 SolarMutexGuard aGuard;
3477 VclPtr< vcl::Window > pWindow = GetWindow();
3478 if ( pWindow )
3480 WinBits nStyle = pWindow->GetStyle();
3481 nStyle &= ~(WB_HORZ|WB_VERT);
3482 if ( n == ::com::sun::star::awt::ScrollBarOrientation::HORIZONTAL )
3483 nStyle |= WB_HORZ;
3484 else
3485 nStyle |= WB_VERT;
3487 pWindow->SetStyle( nStyle );
3488 pWindow->Resize();
3492 sal_Int32 VCLXScrollBar::getOrientation() throw(::com::sun::star::uno::RuntimeException, std::exception)
3494 SolarMutexGuard aGuard;
3496 sal_Int32 n = 0;
3497 VclPtr< vcl::Window > pWindow = GetWindow();
3498 if ( pWindow )
3500 WinBits nStyle = pWindow->GetStyle();
3501 if ( nStyle & WB_HORZ )
3502 n = ::com::sun::star::awt::ScrollBarOrientation::HORIZONTAL;
3503 else
3504 n = ::com::sun::star::awt::ScrollBarOrientation::VERTICAL;
3506 return n;
3510 // ::com::sun::star::awt::VclWindowPeer
3511 void VCLXScrollBar::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
3513 SolarMutexGuard aGuard;
3515 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3516 if ( pScrollBar )
3518 bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
3520 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3521 switch ( nPropType )
3523 case BASEPROPERTY_LIVE_SCROLL:
3525 bool bDo = false;
3526 if ( !bVoid )
3528 OSL_VERIFY( Value >>= bDo );
3530 AllSettings aSettings( pScrollBar->GetSettings() );
3531 StyleSettings aStyle( aSettings.GetStyleSettings() );
3532 DragFullOptions nDragOptions = aStyle.GetDragFullOptions();
3533 if ( bDo )
3534 nDragOptions |= DragFullOptions::Scroll;
3535 else
3536 nDragOptions &= ~DragFullOptions::Scroll;
3537 aStyle.SetDragFullOptions( nDragOptions );
3538 aSettings.SetStyleSettings( aStyle );
3539 pScrollBar->SetSettings( aSettings );
3541 break;
3543 case BASEPROPERTY_SCROLLVALUE:
3545 if ( !bVoid )
3547 sal_Int32 n = 0;
3548 if ( Value >>= n )
3549 setValue( n );
3552 break;
3553 case BASEPROPERTY_SCROLLVALUE_MAX:
3554 case BASEPROPERTY_SCROLLVALUE_MIN:
3556 if ( !bVoid )
3558 sal_Int32 n = 0;
3559 if ( Value >>= n )
3561 if ( nPropType == BASEPROPERTY_SCROLLVALUE_MAX )
3562 setMaximum( n );
3563 else
3564 setMinimum( n );
3568 break;
3569 case BASEPROPERTY_LINEINCREMENT:
3571 if ( !bVoid )
3573 sal_Int32 n = 0;
3574 if ( Value >>= n )
3575 setLineIncrement( n );
3578 break;
3579 case BASEPROPERTY_BLOCKINCREMENT:
3581 if ( !bVoid )
3583 sal_Int32 n = 0;
3584 if ( Value >>= n )
3585 setBlockIncrement( n );
3588 break;
3589 case BASEPROPERTY_VISIBLESIZE:
3591 if ( !bVoid )
3593 sal_Int32 n = 0;
3594 if ( Value >>= n )
3595 setVisibleSize( n );
3598 break;
3599 case BASEPROPERTY_ORIENTATION:
3601 if ( !bVoid )
3603 sal_Int32 n = 0;
3604 if ( Value >>= n )
3605 setOrientation( n );
3608 break;
3610 case BASEPROPERTY_BACKGROUNDCOLOR:
3612 // the default implementation of the base class doesn't work here, since our
3613 // interpretation for this property is slightly different
3614 ::toolkit::setButtonLikeFaceColor( pScrollBar, Value);
3616 break;
3618 default:
3620 VCLXWindow::setProperty( PropertyName, Value );
3626 ::com::sun::star::uno::Any VCLXScrollBar::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3628 SolarMutexGuard aGuard;
3630 ::com::sun::star::uno::Any aProp;
3631 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3632 if ( pScrollBar )
3634 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3636 switch ( nPropType )
3638 case BASEPROPERTY_LIVE_SCROLL:
3640 aProp <<= bool( pScrollBar->GetSettings().GetStyleSettings().GetDragFullOptions() & DragFullOptions::Scroll );
3642 break;
3643 case BASEPROPERTY_SCROLLVALUE:
3645 aProp <<= (sal_Int32) getValue();
3647 break;
3648 case BASEPROPERTY_SCROLLVALUE_MAX:
3650 aProp <<= (sal_Int32) getMaximum();
3652 break;
3653 case BASEPROPERTY_SCROLLVALUE_MIN:
3655 aProp <<= (sal_Int32) getMinimum();
3657 break;
3658 case BASEPROPERTY_LINEINCREMENT:
3660 aProp <<= (sal_Int32) getLineIncrement();
3662 break;
3663 case BASEPROPERTY_BLOCKINCREMENT:
3665 aProp <<= (sal_Int32) getBlockIncrement();
3667 break;
3668 case BASEPROPERTY_VISIBLESIZE:
3670 aProp <<= (sal_Int32) getVisibleSize();
3672 break;
3673 case BASEPROPERTY_ORIENTATION:
3675 aProp <<= (sal_Int32) getOrientation();
3677 break;
3678 case BASEPROPERTY_BACKGROUNDCOLOR:
3680 // the default implementation of the base class doesn't work here, since our
3681 // interpretation for this property is slightly different
3682 aProp = ::toolkit::getButtonLikeFaceColor( pScrollBar );
3684 break;
3686 default:
3688 aProp <<= VCLXWindow::getProperty( PropertyName );
3692 return aProp;
3695 void VCLXScrollBar::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
3697 switch ( rVclWindowEvent.GetId() )
3699 case VCLEVENT_SCROLLBAR_SCROLL:
3701 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
3702 // since we call listeners below, there is a potential that we will be destroyed
3703 // in during the listener call. To prevent the resulting crashs, we keep us
3704 // alive as long as we're here
3706 if ( maAdjustmentListeners.getLength() )
3708 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3710 if( pScrollBar )
3712 ::com::sun::star::awt::AdjustmentEvent aEvent;
3713 aEvent.Source = (::cppu::OWeakObject*)this;
3714 aEvent.Value = pScrollBar->GetThumbPos();
3716 // set adjustment type
3717 ScrollType aType = pScrollBar->GetType();
3718 if ( aType == SCROLL_LINEUP || aType == SCROLL_LINEDOWN )
3720 aEvent.Type = ::com::sun::star::awt::AdjustmentType_ADJUST_LINE;
3722 else if ( aType == SCROLL_PAGEUP || aType == SCROLL_PAGEDOWN )
3724 aEvent.Type = ::com::sun::star::awt::AdjustmentType_ADJUST_PAGE;
3726 else if ( aType == SCROLL_DRAG )
3728 aEvent.Type = ::com::sun::star::awt::AdjustmentType_ADJUST_ABS;
3731 maAdjustmentListeners.adjustmentValueChanged( aEvent );
3735 break;
3737 default:
3738 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
3739 break;
3743 ::com::sun::star::awt::Size SAL_CALL VCLXScrollBar::implGetMinimumSize( vcl::Window* p ) throw(::com::sun::star::uno::RuntimeException)
3745 long n = p->GetSettings().GetStyleSettings().GetScrollBarSize();
3746 return ::com::sun::star::awt::Size( n, n );
3749 ::com::sun::star::awt::Size SAL_CALL VCLXScrollBar::getMinimumSize() throw(::com::sun::star::uno::RuntimeException, std::exception)
3751 SolarMutexGuard aGuard;
3752 return implGetMinimumSize( GetWindow() );
3757 // class VCLXEdit
3760 void VCLXEdit::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
3762 PushPropertyIds( rIds,
3763 BASEPROPERTY_ALIGN,
3764 BASEPROPERTY_BACKGROUNDCOLOR,
3765 BASEPROPERTY_BORDER,
3766 BASEPROPERTY_BORDERCOLOR,
3767 BASEPROPERTY_DEFAULTCONTROL,
3768 BASEPROPERTY_ECHOCHAR,
3769 BASEPROPERTY_ENABLED,
3770 BASEPROPERTY_ENABLEVISIBLE,
3771 BASEPROPERTY_FONTDESCRIPTOR,
3772 BASEPROPERTY_HARDLINEBREAKS,
3773 BASEPROPERTY_HELPTEXT,
3774 BASEPROPERTY_HELPURL,
3775 BASEPROPERTY_HSCROLL,
3776 BASEPROPERTY_LINE_END_FORMAT,
3777 BASEPROPERTY_MAXTEXTLEN,
3778 BASEPROPERTY_MULTILINE,
3779 BASEPROPERTY_PRINTABLE,
3780 BASEPROPERTY_READONLY,
3781 BASEPROPERTY_TABSTOP,
3782 BASEPROPERTY_TEXT,
3783 BASEPROPERTY_VSCROLL,
3784 BASEPROPERTY_HIDEINACTIVESELECTION,
3785 BASEPROPERTY_PAINTTRANSPARENT,
3786 BASEPROPERTY_AUTOHSCROLL,
3787 BASEPROPERTY_AUTOVSCROLL,
3788 BASEPROPERTY_VERTICALALIGN,
3789 BASEPROPERTY_WRITING_MODE,
3790 BASEPROPERTY_CONTEXT_WRITING_MODE,
3792 VCLXWindow::ImplGetPropertyIds( rIds );
3795 VCLXEdit::VCLXEdit() : maTextListeners( *this )
3799 // ::com::sun::star::uno::XInterface
3800 ::com::sun::star::uno::Any VCLXEdit::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3802 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
3803 (static_cast< ::com::sun::star::awt::XTextComponent* >(this)),
3804 (static_cast< ::com::sun::star::awt::XTextEditField* >(this)),
3805 (static_cast< ::com::sun::star::awt::XTextLayoutConstrains* >(this)) );
3806 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
3809 // ::com::sun::star::lang::XTypeProvider
3810 IMPL_XTYPEPROVIDER_START( VCLXEdit )
3811 cppu::UnoType<com::sun::star::awt::XTextComponent>::get(),
3812 cppu::UnoType<com::sun::star::awt::XTextEditField>::get(),
3813 cppu::UnoType<com::sun::star::awt::XTextLayoutConstrains>::get(),
3814 VCLXWindow::getTypes()
3815 IMPL_XTYPEPROVIDER_END
3817 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXEdit::CreateAccessibleContext()
3819 return getAccessibleFactory().createAccessibleContext( this );
3822 void VCLXEdit::dispose() throw(::com::sun::star::uno::RuntimeException, std::exception)
3824 SolarMutexGuard aGuard;
3826 ::com::sun::star::lang::EventObject aObj;
3827 aObj.Source = (::cppu::OWeakObject*)this;
3828 maTextListeners.disposeAndClear( aObj );
3829 VCLXWindow::dispose();
3832 void VCLXEdit::addTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3834 SolarMutexGuard aGuard;
3835 GetTextListeners().addInterface( l );
3838 void VCLXEdit::removeTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3840 SolarMutexGuard aGuard;
3841 GetTextListeners().removeInterface( l );
3844 void VCLXEdit::setText( const OUString& aText ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3846 SolarMutexGuard aGuard;
3848 VclPtr< Edit > pEdit = GetAs< Edit >();
3849 if ( pEdit )
3851 pEdit->SetText( aText );
3853 // #107218# Call same listeners like VCL would do after user interaction
3854 SetSynthesizingVCLEvent( true );
3855 pEdit->SetModifyFlag();
3856 pEdit->Modify();
3857 SetSynthesizingVCLEvent( false );
3861 void VCLXEdit::insertText( const ::com::sun::star::awt::Selection& rSel, const OUString& aText ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3863 SolarMutexGuard aGuard;
3865 VclPtr< Edit > pEdit = GetAs< Edit >();
3866 if ( pEdit )
3868 pEdit->SetSelection( Selection( rSel.Min, rSel.Max ) );
3869 pEdit->ReplaceSelected( aText );
3871 // #107218# Call same listeners like VCL would do after user interaction
3872 SetSynthesizingVCLEvent( true );
3873 pEdit->SetModifyFlag();
3874 pEdit->Modify();
3875 SetSynthesizingVCLEvent( false );
3879 OUString VCLXEdit::getText() throw(::com::sun::star::uno::RuntimeException, std::exception)
3881 SolarMutexGuard aGuard;
3883 OUString aText;
3884 VclPtr< vcl::Window > pWindow = GetWindow();
3885 if ( pWindow )
3886 aText = pWindow->GetText();
3887 return aText;
3890 OUString VCLXEdit::getSelectedText() throw(::com::sun::star::uno::RuntimeException, std::exception)
3892 SolarMutexGuard aGuard;
3894 OUString aText;
3895 VclPtr< Edit > pEdit = GetAs< Edit >();
3896 if ( pEdit)
3897 aText = pEdit->GetSelected();
3898 return aText;
3902 void VCLXEdit::setSelection( const ::com::sun::star::awt::Selection& aSelection ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3904 SolarMutexGuard aGuard;
3906 VclPtr< Edit > pEdit = GetAs< Edit >();
3907 if ( pEdit )
3908 pEdit->SetSelection( Selection( aSelection.Min, aSelection.Max ) );
3911 ::com::sun::star::awt::Selection VCLXEdit::getSelection() throw(::com::sun::star::uno::RuntimeException, std::exception)
3913 SolarMutexGuard aGuard;
3915 Selection aSel;
3916 VclPtr< Edit > pEdit = GetAs< Edit >();
3917 if ( pEdit )
3918 aSel = pEdit->GetSelection();
3919 return ::com::sun::star::awt::Selection( aSel.Min(), aSel.Max() );
3922 sal_Bool VCLXEdit::isEditable() throw(::com::sun::star::uno::RuntimeException, std::exception)
3924 SolarMutexGuard aGuard;
3926 VclPtr< Edit > pEdit = GetAs< Edit >();
3927 return ( pEdit && !pEdit->IsReadOnly() && pEdit->IsEnabled() ) ? sal_True : sal_False;
3930 void VCLXEdit::setEditable( sal_Bool bEditable ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3932 SolarMutexGuard aGuard;
3934 VclPtr< Edit > pEdit = GetAs< Edit >();
3935 if ( pEdit )
3936 pEdit->SetReadOnly( !bEditable );
3940 void VCLXEdit::setMaxTextLen( sal_Int16 nLen ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3942 SolarMutexGuard aGuard;
3944 VclPtr< Edit > pEdit = GetAs< Edit >();
3945 if ( pEdit )
3946 pEdit->SetMaxTextLen( nLen );
3949 sal_Int16 VCLXEdit::getMaxTextLen() throw(::com::sun::star::uno::RuntimeException, std::exception)
3951 SolarMutexGuard aGuard;
3953 VclPtr< Edit > pEdit = GetAs< Edit >();
3954 return pEdit ? pEdit->GetMaxTextLen() : 0;
3957 void VCLXEdit::setEchoChar( sal_Unicode cEcho ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3959 SolarMutexGuard aGuard;
3961 VclPtr< Edit > pEdit = GetAs< Edit >();
3962 if ( pEdit )
3963 pEdit->SetEchoChar( cEcho );
3966 void VCLXEdit::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
3968 SolarMutexGuard aGuard;
3970 VclPtr< Edit > pEdit = GetAs< Edit >();
3971 if ( pEdit )
3973 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3974 switch ( nPropType )
3976 case BASEPROPERTY_HIDEINACTIVESELECTION:
3977 ::toolkit::adjustBooleanWindowStyle( Value, pEdit, WB_NOHIDESELECTION, true );
3978 if ( pEdit->GetSubEdit() )
3979 ::toolkit::adjustBooleanWindowStyle( Value, pEdit->GetSubEdit(), WB_NOHIDESELECTION, true );
3980 break;
3982 case BASEPROPERTY_READONLY:
3984 bool b = bool();
3985 if ( Value >>= b )
3986 pEdit->SetReadOnly( b );
3988 break;
3989 case BASEPROPERTY_ECHOCHAR:
3991 sal_Int16 n = sal_Int16();
3992 if ( Value >>= n )
3993 pEdit->SetEchoChar( n );
3995 break;
3996 case BASEPROPERTY_MAXTEXTLEN:
3998 sal_Int16 n = sal_Int16();
3999 if ( Value >>= n )
4000 pEdit->SetMaxTextLen( n );
4002 break;
4003 default:
4005 VCLXWindow::setProperty( PropertyName, Value );
4011 ::com::sun::star::uno::Any VCLXEdit::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4013 SolarMutexGuard aGuard;
4015 ::com::sun::star::uno::Any aProp;
4016 VclPtr< Edit > pEdit = GetAs< Edit >();
4017 if ( pEdit )
4019 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4020 switch ( nPropType )
4022 case BASEPROPERTY_HIDEINACTIVESELECTION:
4023 aProp <<= ( ( pEdit->GetStyle() & WB_NOHIDESELECTION ) == 0 );
4024 break;
4025 case BASEPROPERTY_READONLY:
4026 aProp <<= pEdit->IsReadOnly();
4027 break;
4028 case BASEPROPERTY_ECHOCHAR:
4029 aProp <<= (sal_Int16) pEdit->GetEchoChar();
4030 break;
4031 case BASEPROPERTY_MAXTEXTLEN:
4032 aProp <<= (sal_Int16) pEdit->GetMaxTextLen();
4033 break;
4034 default:
4036 aProp = VCLXWindow::getProperty( PropertyName );
4040 return aProp;
4043 ::com::sun::star::awt::Size VCLXEdit::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4045 SolarMutexGuard aGuard;
4047 Size aSz;
4048 VclPtr< Edit > pEdit = GetAs< Edit >();
4049 if ( pEdit )
4050 aSz = pEdit->CalcMinimumSize();
4051 return AWTSize(aSz);
4054 ::com::sun::star::awt::Size VCLXEdit::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4056 SolarMutexGuard aGuard;
4058 Size aSz;
4059 VclPtr< Edit > pEdit = GetAs< Edit >();
4060 if ( pEdit )
4062 aSz = pEdit->CalcMinimumSize();
4063 aSz.Height() += 4;
4065 return AWTSize(aSz);
4068 ::com::sun::star::awt::Size VCLXEdit::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4070 SolarMutexGuard aGuard;
4072 ::com::sun::star::awt::Size aSz = rNewSize;
4073 ::com::sun::star::awt::Size aMinSz = getMinimumSize();
4074 if ( aSz.Height != aMinSz.Height )
4075 aSz.Height = aMinSz.Height;
4077 return aSz;
4080 ::com::sun::star::awt::Size VCLXEdit::getMinimumSize( sal_Int16 nCols, sal_Int16 ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4082 SolarMutexGuard aGuard;
4084 Size aSz;
4085 VclPtr< Edit > pEdit = GetAs< Edit >();
4086 if ( pEdit )
4088 if ( nCols )
4089 aSz = pEdit->CalcSize( nCols );
4090 else
4091 aSz = pEdit->CalcMinimumSize();
4093 return AWTSize(aSz);
4096 void VCLXEdit::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4098 SolarMutexGuard aGuard;
4100 nLines = 1;
4101 nCols = 0;
4102 VclPtr< Edit > pEdit = GetAs< Edit >();
4103 if ( pEdit )
4104 nCols = pEdit->GetMaxVisChars();
4107 void VCLXEdit::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
4109 switch ( rVclWindowEvent.GetId() )
4111 case VCLEVENT_EDIT_MODIFY:
4113 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
4114 // since we call listeners below, there is a potential that we will be destroyed
4115 // during the listener call. To prevent the resulting crashs, we keep us
4116 // alive as long as we're here
4118 if ( GetTextListeners().getLength() )
4120 ::com::sun::star::awt::TextEvent aEvent;
4121 aEvent.Source = (::cppu::OWeakObject*)this;
4122 GetTextListeners().textChanged( aEvent );
4125 break;
4127 default:
4128 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
4129 break;
4134 // class VCLXComboBox
4137 void VCLXComboBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
4139 PushPropertyIds( rIds,
4140 BASEPROPERTY_AUTOCOMPLETE,
4141 BASEPROPERTY_BACKGROUNDCOLOR,
4142 BASEPROPERTY_BORDER,
4143 BASEPROPERTY_BORDERCOLOR,
4144 BASEPROPERTY_DEFAULTCONTROL,
4145 BASEPROPERTY_DROPDOWN,
4146 BASEPROPERTY_ENABLED,
4147 BASEPROPERTY_ENABLEVISIBLE,
4148 BASEPROPERTY_FONTDESCRIPTOR,
4149 BASEPROPERTY_HELPTEXT,
4150 BASEPROPERTY_HELPURL,
4151 BASEPROPERTY_LINECOUNT,
4152 BASEPROPERTY_MAXTEXTLEN,
4153 BASEPROPERTY_PRINTABLE,
4154 BASEPROPERTY_READONLY,
4155 BASEPROPERTY_STRINGITEMLIST,
4156 BASEPROPERTY_TABSTOP,
4157 BASEPROPERTY_TEXT,
4158 BASEPROPERTY_HIDEINACTIVESELECTION,
4159 BASEPROPERTY_ALIGN,
4160 BASEPROPERTY_WRITING_MODE,
4161 BASEPROPERTY_CONTEXT_WRITING_MODE,
4162 BASEPROPERTY_REFERENCE_DEVICE,
4163 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
4165 // no, don't call VCLXEdit here - it has properties which we do *not* want to have at combo box
4166 // #i92690# / 2008-08-12 / frank.schoenheit@sun.com
4167 // VCLXEdit::ImplGetPropertyIds( rIds );
4168 VCLXWindow::ImplGetPropertyIds( rIds );
4171 VCLXComboBox::VCLXComboBox()
4172 : maActionListeners( *this ), maItemListeners( *this )
4176 VCLXComboBox::~VCLXComboBox()
4178 OSL_TRACE ("%s", __FUNCTION__);
4181 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXComboBox::CreateAccessibleContext()
4183 SolarMutexGuard aGuard;
4185 return getAccessibleFactory().createAccessibleContext( this );
4188 void VCLXComboBox::dispose() throw(::com::sun::star::uno::RuntimeException, std::exception)
4190 SolarMutexGuard aGuard;
4192 ::com::sun::star::lang::EventObject aObj;
4193 aObj.Source = (::cppu::OWeakObject*)this;
4194 maItemListeners.disposeAndClear( aObj );
4195 maActionListeners.disposeAndClear( aObj );
4196 VCLXEdit::dispose();
4200 void VCLXComboBox::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4202 SolarMutexGuard aGuard;
4203 maItemListeners.addInterface( l );
4206 void VCLXComboBox::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4208 SolarMutexGuard aGuard;
4209 maItemListeners.removeInterface( l );
4212 void VCLXComboBox::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4214 SolarMutexGuard aGuard;
4215 maActionListeners.addInterface( l );
4218 void VCLXComboBox::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4220 SolarMutexGuard aGuard;
4221 maActionListeners.removeInterface( l );
4224 void VCLXComboBox::addItem( const OUString& aItem, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4226 SolarMutexGuard aGuard;
4228 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4229 if ( pBox )
4230 pBox->InsertEntry( aItem, nPos );
4233 void VCLXComboBox::addItems( const ::com::sun::star::uno::Sequence< OUString>& aItems, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4235 SolarMutexGuard aGuard;
4237 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4238 if ( pBox )
4240 sal_uInt16 nP = nPos;
4241 for ( sal_uInt16 n = 0; n < aItems.getLength(); n++ )
4243 pBox->InsertEntry( aItems.getConstArray()[n], nP );
4244 if ( nP == 0xFFFF )
4246 OSL_FAIL( "VCLXComboBox::addItems: too many entries!" );
4247 // skip remaining entries, list cannot hold them, anyway
4248 break;
4254 void VCLXComboBox::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4256 SolarMutexGuard aGuard;
4258 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4259 if ( pBox )
4261 for ( sal_uInt16 n = nCount; n; )
4262 pBox->RemoveEntryAt( nPos + (--n) );
4266 sal_Int16 VCLXComboBox::getItemCount() throw(::com::sun::star::uno::RuntimeException, std::exception)
4268 SolarMutexGuard aGuard;
4270 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4271 return pBox ? pBox->GetEntryCount() : 0;
4274 OUString VCLXComboBox::getItem( sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4276 SolarMutexGuard aGuard;
4278 OUString aItem;
4279 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4280 if ( pBox )
4281 aItem = pBox->GetEntry( nPos );
4282 return aItem;
4285 ::com::sun::star::uno::Sequence< OUString> VCLXComboBox::getItems() throw(::com::sun::star::uno::RuntimeException, std::exception)
4287 SolarMutexGuard aGuard;
4289 ::com::sun::star::uno::Sequence< OUString> aSeq;
4290 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4291 if ( pBox )
4293 sal_uInt16 nEntries = pBox->GetEntryCount();
4294 aSeq = ::com::sun::star::uno::Sequence< OUString>( nEntries );
4295 for ( sal_uInt16 n = nEntries; n; )
4297 --n;
4298 aSeq.getArray()[n] = pBox->GetEntry( n );
4301 return aSeq;
4304 void VCLXComboBox::setDropDownLineCount( sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4306 SolarMutexGuard aGuard;
4308 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4309 if ( pBox )
4310 pBox->SetDropDownLineCount( nLines );
4313 sal_Int16 VCLXComboBox::getDropDownLineCount() throw(::com::sun::star::uno::RuntimeException, std::exception)
4315 SolarMutexGuard aGuard;
4317 sal_Int16 nLines = 0;
4318 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4319 if ( pBox )
4320 nLines = pBox->GetDropDownLineCount();
4321 return nLines;
4324 void VCLXComboBox::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
4326 SolarMutexGuard aGuard;
4328 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4329 if ( pComboBox )
4331 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4332 switch ( nPropType )
4334 case BASEPROPERTY_LINECOUNT:
4336 sal_Int16 n = sal_Int16();
4337 if ( Value >>= n )
4338 pComboBox->SetDropDownLineCount( n );
4340 break;
4341 case BASEPROPERTY_AUTOCOMPLETE:
4343 sal_Int16 n = sal_Int16();
4344 if ( Value >>= n )
4345 pComboBox->EnableAutocomplete( n != 0, true );
4346 else
4348 bool b = bool();
4349 if ( Value >>= b )
4350 pComboBox->EnableAutocomplete( b, true );
4353 break;
4354 case BASEPROPERTY_STRINGITEMLIST:
4356 ::com::sun::star::uno::Sequence< OUString> aItems;
4357 if ( Value >>= aItems )
4359 pComboBox->Clear();
4360 addItems( aItems, 0 );
4363 break;
4364 default:
4366 VCLXEdit::setProperty( PropertyName, Value );
4368 // #109385# SetBorderStyle is not virtual
4369 if ( nPropType == BASEPROPERTY_BORDER )
4371 sal_uInt16 nBorder = sal_uInt16();
4372 if ( (Value >>= nBorder) && nBorder != 0 )
4373 pComboBox->SetBorderStyle( static_cast<WindowBorderStyle>(nBorder) );
4380 ::com::sun::star::uno::Any VCLXComboBox::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4382 SolarMutexGuard aGuard;
4384 ::com::sun::star::uno::Any aProp;
4385 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4386 if ( pComboBox )
4388 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4389 switch ( nPropType )
4391 case BASEPROPERTY_LINECOUNT:
4393 aProp <<= (sal_Int16) pComboBox->GetDropDownLineCount();
4395 break;
4396 case BASEPROPERTY_AUTOCOMPLETE:
4398 aProp <<= pComboBox->IsAutocompleteEnabled();
4400 break;
4401 case BASEPROPERTY_STRINGITEMLIST:
4403 sal_uInt16 nItems = pComboBox->GetEntryCount();
4404 ::com::sun::star::uno::Sequence< OUString> aSeq( nItems );
4405 OUString* pStrings = aSeq.getArray();
4406 for ( sal_uInt16 n = 0; n < nItems; n++ )
4407 pStrings[n] = pComboBox->GetEntry( n );
4408 aProp <<= aSeq;
4411 break;
4412 default:
4414 aProp <<= VCLXEdit::getProperty( PropertyName );
4418 return aProp;
4421 void VCLXComboBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
4423 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
4424 // since we call listeners below, there is a potential that we will be destroyed
4425 // during the listener call. To prevent the resulting crashs, we keep us
4426 // alive as long as we're here
4428 switch ( rVclWindowEvent.GetId() )
4430 case VCLEVENT_COMBOBOX_SELECT:
4431 if ( maItemListeners.getLength() )
4433 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4434 if( pComboBox )
4436 if ( !pComboBox->IsTravelSelect() )
4438 ::com::sun::star::awt::ItemEvent aEvent;
4439 aEvent.Source = (::cppu::OWeakObject*)this;
4440 aEvent.Highlighted = 0;
4442 // Set to 0xFFFF on multiple selection, selected entry ID otherwise
4443 aEvent.Selected = pComboBox->GetEntryPos( pComboBox->GetText() );
4445 maItemListeners.itemStateChanged( aEvent );
4449 break;
4451 case VCLEVENT_COMBOBOX_DOUBLECLICK:
4452 if ( maActionListeners.getLength() )
4454 ::com::sun::star::awt::ActionEvent aEvent;
4455 aEvent.Source = (::cppu::OWeakObject*)this;
4456 // aEvent.ActionCommand = ...;
4457 maActionListeners.actionPerformed( aEvent );
4459 break;
4461 default:
4462 VCLXEdit::ProcessWindowEvent( rVclWindowEvent );
4463 break;
4467 ::com::sun::star::awt::Size VCLXComboBox::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4469 SolarMutexGuard aGuard;
4471 Size aSz;
4472 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4473 if ( pComboBox )
4474 aSz = pComboBox->CalcMinimumSize();
4475 return AWTSize(aSz);
4478 ::com::sun::star::awt::Size VCLXComboBox::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4480 SolarMutexGuard aGuard;
4482 Size aSz;
4483 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4484 if ( pComboBox )
4486 aSz = pComboBox->CalcMinimumSize();
4487 if ( pComboBox->GetStyle() & WB_DROPDOWN )
4488 aSz.Height() += 4;
4490 return AWTSize(aSz);
4493 ::com::sun::star::awt::Size VCLXComboBox::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4495 SolarMutexGuard aGuard;
4497 Size aSz = VCLSize(rNewSize);
4498 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4499 if ( pComboBox )
4500 aSz = pComboBox->CalcAdjustedSize( aSz );
4501 return AWTSize(aSz);
4504 ::com::sun::star::awt::Size VCLXComboBox::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4506 SolarMutexGuard aGuard;
4508 Size aSz;
4509 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4510 if ( pComboBox )
4511 aSz = pComboBox->CalcBlockSize( nCols, nLines );
4512 return AWTSize(aSz);
4515 void VCLXComboBox::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4517 SolarMutexGuard aGuard;
4519 nCols = nLines = 0;
4520 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4521 if ( pComboBox )
4523 sal_uInt16 nC, nL;
4524 pComboBox->GetMaxVisColumnsAndLines( nC, nL );
4525 nCols = nC;
4526 nLines = nL;
4529 void SAL_CALL VCLXComboBox::listItemInserted( const ItemListEvent& i_rEvent ) throw (RuntimeException, std::exception)
4531 SolarMutexGuard aGuard;
4533 VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >();
4535 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemInserted: no ComboBox?!" );
4536 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition <= sal_Int32( pComboBox->GetEntryCount() ) ),
4537 "VCLXComboBox::listItemInserted: illegal (inconsistent) item position!" );
4538 pComboBox->InsertEntryWithImage(
4539 i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : OUString(),
4540 i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : Image(),
4541 i_rEvent.ItemPosition );
4544 void SAL_CALL VCLXComboBox::listItemRemoved( const ItemListEvent& i_rEvent ) throw (RuntimeException, std::exception)
4546 SolarMutexGuard aGuard;
4548 VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >();
4550 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemRemoved: no ComboBox?!" );
4551 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pComboBox->GetEntryCount() ) ),
4552 "VCLXComboBox::listItemRemoved: illegal (inconsistent) item position!" );
4554 pComboBox->RemoveEntryAt( i_rEvent.ItemPosition );
4557 void SAL_CALL VCLXComboBox::listItemModified( const ItemListEvent& i_rEvent ) throw (RuntimeException, std::exception)
4559 SolarMutexGuard aGuard;
4561 VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >();
4563 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" );
4564 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pComboBox->GetEntryCount() ) ),
4565 "VCLXComboBox::listItemModified: illegal (inconsistent) item position!" );
4567 // VCL's ComboBox does not support changing an entry's text or image, so remove and re-insert
4569 const OUString sNewText = i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : OUString( pComboBox->GetEntry( i_rEvent.ItemPosition ) );
4570 const Image aNewImage( i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : pComboBox->GetEntryImage( i_rEvent.ItemPosition ) );
4572 pComboBox->RemoveEntryAt( i_rEvent.ItemPosition );
4573 pComboBox->InsertEntryWithImage(sNewText, aNewImage, i_rEvent.ItemPosition);
4576 void SAL_CALL VCLXComboBox::allItemsRemoved( const EventObject& i_rEvent ) throw (RuntimeException, std::exception)
4578 SolarMutexGuard aGuard;
4580 VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >();
4581 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" );
4583 pComboBox->Clear();
4585 (void)i_rEvent;
4588 void SAL_CALL VCLXComboBox::itemListChanged( const EventObject& i_rEvent ) throw (RuntimeException, std::exception)
4590 SolarMutexGuard aGuard;
4592 VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >();
4593 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" );
4595 pComboBox->Clear();
4597 uno::Reference< beans::XPropertySet > xPropSet( i_rEvent.Source, uno::UNO_QUERY_THROW );
4598 uno::Reference< beans::XPropertySetInfo > xPSI( xPropSet->getPropertySetInfo(), uno::UNO_QUERY_THROW );
4599 // bool localize = xPSI->hasPropertyByName("ResourceResolver");
4600 uno::Reference< resource::XStringResourceResolver > xStringResourceResolver;
4601 if ( xPSI->hasPropertyByName("ResourceResolver") )
4603 xStringResourceResolver.set(
4604 xPropSet->getPropertyValue("ResourceResolver"),
4605 uno::UNO_QUERY
4610 Reference< XItemList > xItemList( i_rEvent.Source, uno::UNO_QUERY_THROW );
4611 uno::Sequence< beans::Pair< OUString, OUString > > aItems = xItemList->getAllItems();
4612 for ( sal_Int32 i=0; i<aItems.getLength(); ++i )
4614 OUString aLocalizationKey( aItems[i].First );
4615 if ( xStringResourceResolver.is() && !aLocalizationKey.isEmpty() && aLocalizationKey[0] == '&' )
4617 aLocalizationKey = xStringResourceResolver->resolveString(aLocalizationKey.copy( 1 ));
4619 pComboBox->InsertEntryWithImage(aLocalizationKey,
4620 lcl_getImageFromURL(aItems[i].Second));
4623 void SAL_CALL VCLXComboBox::disposing( const EventObject& i_rEvent ) throw (RuntimeException, std::exception)
4625 // just disambiguate
4626 VCLXEdit::disposing( i_rEvent );
4630 // class VCLXFormattedSpinField
4632 void VCLXFormattedSpinField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
4634 // Interestingly in the UnoControl API this is
4635 // - not derived from XEdit ultimately, (correct ?) - so cut this here ...
4636 // VCLXSpinField::ImplGetPropertyIds( rIds );
4637 VCLXWindow::ImplGetPropertyIds( rIds );
4640 VCLXFormattedSpinField::VCLXFormattedSpinField()
4641 : mpFormatter(NULL)
4645 VCLXFormattedSpinField::~VCLXFormattedSpinField()
4649 void VCLXFormattedSpinField::setStrictFormat( bool bStrict )
4651 SolarMutexGuard aGuard;
4653 FormatterBase* pFormatter = GetFormatter();
4654 if ( pFormatter )
4655 pFormatter->SetStrictFormat( bStrict );
4658 bool VCLXFormattedSpinField::isStrictFormat()
4660 FormatterBase* pFormatter = GetFormatter();
4661 return pFormatter && pFormatter->IsStrictFormat();
4665 void VCLXFormattedSpinField::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
4667 SolarMutexGuard aGuard;
4669 FormatterBase* pFormatter = GetFormatter();
4670 if ( pFormatter )
4672 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4673 switch ( nPropType )
4675 case BASEPROPERTY_SPIN:
4677 bool b = bool();
4678 if ( Value >>= b )
4680 WinBits nStyle = GetWindow()->GetStyle() | WB_SPIN;
4681 if ( !b )
4682 nStyle &= ~WB_SPIN;
4683 GetWindow()->SetStyle( nStyle );
4686 break;
4687 case BASEPROPERTY_STRICTFORMAT:
4689 bool b = bool();
4690 if ( Value >>= b )
4692 pFormatter->SetStrictFormat( b );
4695 break;
4696 default:
4698 VCLXSpinField::setProperty( PropertyName, Value );
4704 ::com::sun::star::uno::Any VCLXFormattedSpinField::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4706 SolarMutexGuard aGuard;
4708 ::com::sun::star::uno::Any aProp;
4709 FormatterBase* pFormatter = GetFormatter();
4710 if ( pFormatter )
4712 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4713 switch ( nPropType )
4715 case BASEPROPERTY_TABSTOP:
4717 aProp <<= ( GetWindow()->GetStyle() & WB_SPIN ) != 0;
4719 break;
4720 case BASEPROPERTY_STRICTFORMAT:
4722 aProp <<= pFormatter->IsStrictFormat();
4724 break;
4725 default:
4727 aProp <<= VCLXSpinField::getProperty( PropertyName );
4731 return aProp;
4736 // class VCLXDateField
4739 void VCLXDateField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
4741 PushPropertyIds( rIds,
4742 BASEPROPERTY_ALIGN,
4743 BASEPROPERTY_BACKGROUNDCOLOR,
4744 BASEPROPERTY_BORDER,
4745 BASEPROPERTY_BORDERCOLOR,
4746 BASEPROPERTY_DATE,
4747 BASEPROPERTY_DATEMAX,
4748 BASEPROPERTY_DATEMIN,
4749 BASEPROPERTY_DATESHOWCENTURY,
4750 BASEPROPERTY_DEFAULTCONTROL,
4751 BASEPROPERTY_DROPDOWN,
4752 BASEPROPERTY_ENABLED,
4753 BASEPROPERTY_ENABLEVISIBLE,
4754 BASEPROPERTY_EXTDATEFORMAT,
4755 BASEPROPERTY_FONTDESCRIPTOR,
4756 BASEPROPERTY_HELPTEXT,
4757 BASEPROPERTY_HELPURL,
4758 BASEPROPERTY_PRINTABLE,
4759 BASEPROPERTY_READONLY,
4760 BASEPROPERTY_REPEAT,
4761 BASEPROPERTY_REPEAT_DELAY,
4762 BASEPROPERTY_SPIN,
4763 BASEPROPERTY_STRICTFORMAT,
4764 BASEPROPERTY_TABSTOP,
4765 BASEPROPERTY_ENFORCE_FORMAT,
4766 BASEPROPERTY_TEXT,
4767 BASEPROPERTY_HIDEINACTIVESELECTION,
4768 BASEPROPERTY_VERTICALALIGN,
4769 BASEPROPERTY_WRITING_MODE,
4770 BASEPROPERTY_CONTEXT_WRITING_MODE,
4771 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
4773 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
4776 VCLXDateField::VCLXDateField()
4780 VCLXDateField::~VCLXDateField()
4784 //change the window type here to match the role
4785 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXDateField::CreateAccessibleContext()
4787 VclPtr< vcl::Window > pWindow = GetWindow();
4788 if ( pWindow )
4790 pWindow->SetType( WINDOW_DATEFIELD );
4792 return getAccessibleFactory().createAccessibleContext( this );
4795 // ::com::sun::star::uno::XInterface
4796 ::com::sun::star::uno::Any VCLXDateField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4798 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
4799 (static_cast< ::com::sun::star::awt::XDateField* >(this)) );
4800 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
4803 // ::com::sun::star::lang::XTypeProvider
4804 IMPL_XTYPEPROVIDER_START( VCLXDateField )
4805 cppu::UnoType<com::sun::star::awt::XDateField>::get(),
4806 VCLXFormattedSpinField::getTypes()
4807 IMPL_XTYPEPROVIDER_END
4809 void VCLXDateField::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
4811 SolarMutexGuard aGuard;
4813 if ( GetWindow() )
4815 bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
4817 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4818 switch ( nPropType )
4820 case BASEPROPERTY_DATE:
4822 if ( bVoid )
4824 GetAs< DateField >()->EnableEmptyFieldValue( true );
4825 GetAs< DateField >()->SetEmptyFieldValue();
4827 else
4829 util::Date d;
4830 if ( Value >>= d )
4831 setDate( d );
4834 break;
4835 case BASEPROPERTY_DATEMIN:
4837 util::Date d;
4838 if ( Value >>= d )
4839 setMin( d );
4841 break;
4842 case BASEPROPERTY_DATEMAX:
4844 util::Date d;
4845 if ( Value >>= d )
4846 setMax( d );
4848 break;
4849 case BASEPROPERTY_EXTDATEFORMAT:
4851 sal_Int16 n = sal_Int16();
4852 if ( Value >>= n )
4853 GetAs< DateField >()->SetExtDateFormat( (ExtDateFieldFormat) n );
4855 break;
4856 case BASEPROPERTY_DATESHOWCENTURY:
4858 bool b = bool();
4859 if ( Value >>= b )
4860 GetAs< DateField >()->SetShowDateCentury( b );
4862 break;
4863 case BASEPROPERTY_ENFORCE_FORMAT:
4865 bool bEnforce( true );
4866 OSL_VERIFY( Value >>= bEnforce );
4867 GetAs< DateField >()->EnforceValidValue( bEnforce );
4869 break;
4870 default:
4872 VCLXFormattedSpinField::setProperty( PropertyName, Value );
4878 ::com::sun::star::uno::Any VCLXDateField::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4880 SolarMutexGuard aGuard;
4882 ::com::sun::star::uno::Any aProp;
4883 FormatterBase* pFormatter = GetFormatter();
4884 if ( pFormatter )
4886 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4887 switch ( nPropType )
4889 case BASEPROPERTY_DATE:
4891 aProp <<= getDate();
4893 break;
4894 case BASEPROPERTY_DATEMIN:
4896 aProp <<= getMin();
4898 break;
4899 case BASEPROPERTY_DATEMAX:
4901 aProp <<= getMax();
4903 break;
4904 case BASEPROPERTY_DATESHOWCENTURY:
4906 aProp <<= GetAs< DateField >()->IsShowDateCentury();
4908 break;
4909 case BASEPROPERTY_ENFORCE_FORMAT:
4911 aProp <<= GetAs< DateField >()->IsEnforceValidValue( );
4913 break;
4914 default:
4916 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
4920 return aProp;
4924 void VCLXDateField::setDate( const util::Date& aDate ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4926 SolarMutexGuard aGuard;
4928 VclPtr< DateField > pDateField = GetAs< DateField >();
4929 if ( pDateField )
4931 pDateField->SetDate( aDate );
4933 // #107218# Call same listeners like VCL would do after user interaction
4934 SetSynthesizingVCLEvent( true );
4935 pDateField->SetModifyFlag();
4936 pDateField->Modify();
4937 SetSynthesizingVCLEvent( false );
4941 util::Date VCLXDateField::getDate() throw(::com::sun::star::uno::RuntimeException, std::exception)
4943 SolarMutexGuard aGuard;
4945 VclPtr< DateField > pDateField = GetAs< DateField >();
4946 if ( pDateField )
4947 return pDateField->GetDate().GetUNODate();
4948 else
4949 return util::Date();
4952 void VCLXDateField::setMin( const util::Date& aDate ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4954 SolarMutexGuard aGuard;
4956 VclPtr< DateField > pDateField = GetAs< DateField >();
4957 if ( pDateField )
4958 pDateField->SetMin( aDate );
4961 util::Date VCLXDateField::getMin() throw(::com::sun::star::uno::RuntimeException, std::exception)
4963 SolarMutexGuard aGuard;
4965 VclPtr< DateField > pDateField = GetAs< DateField >();
4966 if ( pDateField )
4967 return pDateField->GetMin().GetUNODate();
4968 else
4969 return util::Date();
4972 void VCLXDateField::setMax( const util::Date& aDate ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4974 SolarMutexGuard aGuard;
4976 VclPtr< DateField > pDateField = GetAs< DateField >();
4977 if ( pDateField )
4978 pDateField->SetMax( aDate );
4981 util::Date VCLXDateField::getMax() throw(::com::sun::star::uno::RuntimeException, std::exception)
4983 SolarMutexGuard aGuard;
4985 VclPtr< DateField > pDateField = GetAs< DateField >();
4986 if ( pDateField )
4987 return pDateField->GetMax().GetUNODate();
4988 else
4989 return util::Date();
4992 void VCLXDateField::setFirst( const util::Date& aDate ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4994 SolarMutexGuard aGuard;
4996 VclPtr< DateField > pDateField = GetAs< DateField >();
4997 if ( pDateField )
4998 pDateField->SetFirst( aDate );
5001 util::Date VCLXDateField::getFirst() throw(::com::sun::star::uno::RuntimeException, std::exception)
5003 SolarMutexGuard aGuard;
5005 VclPtr< DateField > pDateField = GetAs< DateField >();
5006 if ( pDateField )
5007 return pDateField->GetFirst().GetUNODate();
5008 else
5009 return util::Date();
5012 void VCLXDateField::setLast( const util::Date& aDate ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5014 SolarMutexGuard aGuard;
5016 VclPtr< DateField > pDateField = GetAs< DateField >();
5017 if ( pDateField )
5018 pDateField->SetLast( aDate );
5021 util::Date VCLXDateField::getLast() throw(::com::sun::star::uno::RuntimeException, std::exception)
5023 SolarMutexGuard aGuard;
5025 VclPtr< DateField > pDateField = GetAs< DateField >();
5026 if ( pDateField )
5027 return pDateField->GetLast().GetUNODate();
5028 else
5029 return util::Date();
5032 void VCLXDateField::setLongFormat( sal_Bool bLong ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5034 SolarMutexGuard aGuard;
5036 VclPtr< DateField > pDateField = GetAs< DateField >();
5037 if ( pDateField )
5038 pDateField->SetLongFormat( bLong );
5041 sal_Bool VCLXDateField::isLongFormat() throw(::com::sun::star::uno::RuntimeException, std::exception)
5043 SolarMutexGuard aGuard;
5045 VclPtr< DateField > pDateField = GetAs< DateField >();
5046 return pDateField ? pDateField->IsLongFormat() : sal_False;
5049 void VCLXDateField::setEmpty() throw(::com::sun::star::uno::RuntimeException, std::exception)
5051 SolarMutexGuard aGuard;
5053 VclPtr< DateField > pDateField = GetAs< DateField >();
5054 if ( pDateField )
5056 pDateField->SetEmptyDate();
5058 // #107218# Call same listeners like VCL would do after user interaction
5059 SetSynthesizingVCLEvent( true );
5060 pDateField->SetModifyFlag();
5061 pDateField->Modify();
5062 SetSynthesizingVCLEvent( false );
5066 sal_Bool VCLXDateField::isEmpty() throw(::com::sun::star::uno::RuntimeException, std::exception)
5068 SolarMutexGuard aGuard;
5070 VclPtr< DateField > pDateField = GetAs< DateField >();
5071 return pDateField ? pDateField->IsEmptyDate() : sal_False;
5074 void VCLXDateField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5076 VCLXFormattedSpinField::setStrictFormat( bStrict );
5079 sal_Bool VCLXDateField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException, std::exception)
5081 return VCLXFormattedSpinField::isStrictFormat();
5086 // class VCLXTimeField
5089 void VCLXTimeField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
5091 PushPropertyIds( rIds,
5092 BASEPROPERTY_ALIGN,
5093 BASEPROPERTY_BACKGROUNDCOLOR,
5094 BASEPROPERTY_BORDER,
5095 BASEPROPERTY_BORDERCOLOR,
5096 BASEPROPERTY_DEFAULTCONTROL,
5097 BASEPROPERTY_ENABLED,
5098 BASEPROPERTY_ENABLEVISIBLE,
5099 BASEPROPERTY_EXTTIMEFORMAT,
5100 BASEPROPERTY_FONTDESCRIPTOR,
5101 BASEPROPERTY_HELPTEXT,
5102 BASEPROPERTY_HELPURL,
5103 BASEPROPERTY_PRINTABLE,
5104 BASEPROPERTY_READONLY,
5105 BASEPROPERTY_REPEAT,
5106 BASEPROPERTY_REPEAT_DELAY,
5107 BASEPROPERTY_SPIN,
5108 BASEPROPERTY_STRICTFORMAT,
5109 BASEPROPERTY_TABSTOP,
5110 BASEPROPERTY_TIME,
5111 BASEPROPERTY_TIMEMAX,
5112 BASEPROPERTY_TIMEMIN,
5113 BASEPROPERTY_ENFORCE_FORMAT,
5114 BASEPROPERTY_TEXT,
5115 BASEPROPERTY_HIDEINACTIVESELECTION,
5116 BASEPROPERTY_VERTICALALIGN,
5117 BASEPROPERTY_WRITING_MODE,
5118 BASEPROPERTY_CONTEXT_WRITING_MODE,
5119 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
5121 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5124 VCLXTimeField::VCLXTimeField()
5128 VCLXTimeField::~VCLXTimeField()
5132 //change the window type here to match the role
5133 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXTimeField::CreateAccessibleContext()
5135 VclPtr< vcl::Window > pWindow = GetWindow();
5136 if ( pWindow )
5138 pWindow->SetType( WINDOW_TIMEFIELD );
5140 return getAccessibleFactory().createAccessibleContext( this );
5143 // ::com::sun::star::uno::XInterface
5144 ::com::sun::star::uno::Any VCLXTimeField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5146 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
5147 (static_cast< ::com::sun::star::awt::XTimeField* >(this)) );
5148 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
5151 // ::com::sun::star::lang::XTypeProvider
5152 IMPL_XTYPEPROVIDER_START( VCLXTimeField )
5153 cppu::UnoType<com::sun::star::awt::XTimeField>::get(),
5154 VCLXFormattedSpinField::getTypes()
5155 IMPL_XTYPEPROVIDER_END
5157 void VCLXTimeField::setTime( const util::Time& aTime ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5159 SolarMutexGuard aGuard;
5161 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5162 if ( pTimeField )
5164 pTimeField->SetTime( aTime );
5166 // #107218# Call same listeners like VCL would do after user interaction
5167 SetSynthesizingVCLEvent( true );
5168 pTimeField->SetModifyFlag();
5169 pTimeField->Modify();
5170 SetSynthesizingVCLEvent( false );
5174 util::Time VCLXTimeField::getTime() throw(::com::sun::star::uno::RuntimeException, std::exception)
5176 SolarMutexGuard aGuard;
5178 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5179 if ( pTimeField )
5180 return pTimeField->GetTime().GetUNOTime();
5181 else
5182 return util::Time();
5185 void VCLXTimeField::setMin( const util::Time& aTime ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5187 SolarMutexGuard aGuard;
5189 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5190 if ( pTimeField )
5191 pTimeField->SetMin( aTime );
5194 util::Time VCLXTimeField::getMin() throw(::com::sun::star::uno::RuntimeException, std::exception)
5196 SolarMutexGuard aGuard;
5198 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5199 if ( pTimeField )
5200 return pTimeField->GetMin().GetUNOTime();
5201 else
5202 return util::Time();
5205 void VCLXTimeField::setMax( const util::Time& aTime ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5207 SolarMutexGuard aGuard;
5209 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5210 if ( pTimeField )
5211 pTimeField->SetMax( aTime );
5214 util::Time VCLXTimeField::getMax() throw(::com::sun::star::uno::RuntimeException, std::exception)
5216 SolarMutexGuard aGuard;
5218 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5219 if ( pTimeField )
5220 return pTimeField->GetMax().GetUNOTime();
5221 else
5222 return util::Time();
5225 void VCLXTimeField::setFirst( const util::Time& aTime ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5227 SolarMutexGuard aGuard;
5229 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5230 if ( pTimeField )
5231 pTimeField->SetFirst( aTime );
5234 util::Time VCLXTimeField::getFirst() throw(::com::sun::star::uno::RuntimeException, std::exception)
5236 SolarMutexGuard aGuard;
5238 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5239 if ( pTimeField )
5240 return pTimeField->GetFirst().GetUNOTime();
5241 else
5242 return util::Time();
5245 void VCLXTimeField::setLast( const util::Time& aTime ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5247 SolarMutexGuard aGuard;
5249 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5250 if ( pTimeField )
5251 pTimeField->SetLast( aTime );
5254 util::Time VCLXTimeField::getLast() throw(::com::sun::star::uno::RuntimeException, std::exception)
5256 SolarMutexGuard aGuard;
5258 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5259 if ( pTimeField )
5260 return pTimeField->GetLast().GetUNOTime();
5261 else
5262 return util::Time();
5265 void VCLXTimeField::setEmpty() throw(::com::sun::star::uno::RuntimeException, std::exception)
5267 SolarMutexGuard aGuard;
5269 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5270 if ( pTimeField )
5271 pTimeField->SetEmptyTime();
5274 sal_Bool VCLXTimeField::isEmpty() throw(::com::sun::star::uno::RuntimeException, std::exception)
5276 SolarMutexGuard aGuard;
5278 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5279 return pTimeField ? pTimeField->IsEmptyTime() : sal_False;
5282 void VCLXTimeField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5284 VCLXFormattedSpinField::setStrictFormat( bStrict );
5287 sal_Bool VCLXTimeField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException, std::exception)
5289 return VCLXFormattedSpinField::isStrictFormat();
5293 void VCLXTimeField::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
5295 SolarMutexGuard aGuard;
5297 if ( GetWindow() )
5299 bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
5301 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5302 switch ( nPropType )
5304 case BASEPROPERTY_TIME:
5306 if ( bVoid )
5308 GetAs< TimeField >()->EnableEmptyFieldValue( true );
5309 GetAs< TimeField >()->SetEmptyFieldValue();
5311 else
5313 util::Time t;
5314 if ( Value >>= t )
5315 setTime( t );
5318 break;
5319 case BASEPROPERTY_TIMEMIN:
5321 util::Time t;
5322 if ( Value >>= t )
5323 setMin( t );
5325 break;
5326 case BASEPROPERTY_TIMEMAX:
5328 util::Time t;
5329 if ( Value >>= t )
5330 setMax( t );
5332 break;
5333 case BASEPROPERTY_EXTTIMEFORMAT:
5335 sal_Int16 n = sal_Int16();
5336 if ( Value >>= n )
5337 GetAs< TimeField >()->SetExtFormat( (ExtTimeFieldFormat) n );
5339 break;
5340 case BASEPROPERTY_ENFORCE_FORMAT:
5342 bool bEnforce( true );
5343 OSL_VERIFY( Value >>= bEnforce );
5344 GetAs< TimeField >()->EnforceValidValue( bEnforce );
5346 break;
5347 default:
5349 VCLXFormattedSpinField::setProperty( PropertyName, Value );
5355 ::com::sun::star::uno::Any VCLXTimeField::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5357 SolarMutexGuard aGuard;
5359 ::com::sun::star::uno::Any aProp;
5360 if ( GetWindow() )
5362 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5363 switch ( nPropType )
5365 case BASEPROPERTY_TIME:
5367 aProp <<= getTime();
5369 break;
5370 case BASEPROPERTY_TIMEMIN:
5372 aProp <<= getMin();
5374 break;
5375 case BASEPROPERTY_TIMEMAX:
5377 aProp <<= getMax();
5379 break;
5380 case BASEPROPERTY_ENFORCE_FORMAT:
5382 aProp <<= GetAs< TimeField >()->IsEnforceValidValue( );
5384 break;
5385 default:
5387 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
5391 return aProp;
5395 // class VCLXNumericField
5398 void VCLXNumericField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
5400 PushPropertyIds( rIds,
5401 BASEPROPERTY_ALIGN,
5402 BASEPROPERTY_BACKGROUNDCOLOR,
5403 BASEPROPERTY_BORDER,
5404 BASEPROPERTY_BORDERCOLOR,
5405 BASEPROPERTY_DECIMALACCURACY,
5406 BASEPROPERTY_DEFAULTCONTROL,
5407 BASEPROPERTY_ENABLED,
5408 BASEPROPERTY_ENABLEVISIBLE,
5409 BASEPROPERTY_FONTDESCRIPTOR,
5410 BASEPROPERTY_HELPTEXT,
5411 BASEPROPERTY_HELPURL,
5412 BASEPROPERTY_NUMSHOWTHOUSANDSEP,
5413 BASEPROPERTY_PRINTABLE,
5414 BASEPROPERTY_READONLY,
5415 BASEPROPERTY_REPEAT,
5416 BASEPROPERTY_REPEAT_DELAY,
5417 BASEPROPERTY_SPIN,
5418 BASEPROPERTY_STRICTFORMAT,
5419 BASEPROPERTY_TABSTOP,
5420 BASEPROPERTY_VALUEMAX_DOUBLE,
5421 BASEPROPERTY_VALUEMIN_DOUBLE,
5422 BASEPROPERTY_VALUESTEP_DOUBLE,
5423 BASEPROPERTY_VALUE_DOUBLE,
5424 BASEPROPERTY_ENFORCE_FORMAT,
5425 BASEPROPERTY_HIDEINACTIVESELECTION,
5426 BASEPROPERTY_VERTICALALIGN,
5427 BASEPROPERTY_WRITING_MODE,
5428 BASEPROPERTY_CONTEXT_WRITING_MODE,
5429 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
5431 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5434 VCLXNumericField::VCLXNumericField()
5438 VCLXNumericField::~VCLXNumericField()
5442 // ::com::sun::star::uno::XInterface
5443 ::com::sun::star::uno::Any VCLXNumericField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5445 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
5446 (static_cast< ::com::sun::star::awt::XNumericField* >(this)) );
5447 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
5450 // ::com::sun::star::lang::XTypeProvider
5451 IMPL_XTYPEPROVIDER_START( VCLXNumericField )
5452 cppu::UnoType<com::sun::star::awt::XNumericField>::get(),
5453 VCLXFormattedSpinField::getTypes()
5454 IMPL_XTYPEPROVIDER_END
5456 void VCLXNumericField::setValue( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5458 SolarMutexGuard aGuard;
5460 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5461 if ( pNumericFormatter )
5463 // shift long value using decimal digits
5464 // (e.g., input 105 using 2 digits returns 1,05)
5465 // Thus, to set a value of 1,05, insert 105 and 2 digits
5466 pNumericFormatter->SetValue(
5467 (long)ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() ) );
5469 // #107218# Call same listeners like VCL would do after user interaction
5470 VclPtr< Edit > pEdit = GetAs< Edit >();
5471 if ( pEdit )
5473 SetSynthesizingVCLEvent( true );
5474 pEdit->SetModifyFlag();
5475 pEdit->Modify();
5476 SetSynthesizingVCLEvent( false );
5481 double VCLXNumericField::getValue() throw(::com::sun::star::uno::RuntimeException, std::exception)
5483 SolarMutexGuard aGuard;
5485 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5486 return pNumericFormatter
5487 ? ImplCalcDoubleValue( (double)pNumericFormatter->GetValue(), pNumericFormatter->GetDecimalDigits() )
5488 : 0;
5491 void VCLXNumericField::setMin( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5493 SolarMutexGuard aGuard;
5495 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5496 if ( pNumericFormatter )
5497 pNumericFormatter->SetMin(
5498 (long)ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() ) );
5501 double VCLXNumericField::getMin() throw(::com::sun::star::uno::RuntimeException, std::exception)
5503 SolarMutexGuard aGuard;
5505 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5506 return pNumericFormatter
5507 ? ImplCalcDoubleValue( (double)pNumericFormatter->GetMin(), pNumericFormatter->GetDecimalDigits() )
5508 : 0;
5511 void VCLXNumericField::setMax( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5513 SolarMutexGuard aGuard;
5515 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5516 if ( pNumericFormatter )
5517 pNumericFormatter->SetMax(
5518 (long)ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() ) );
5521 double VCLXNumericField::getMax() throw(::com::sun::star::uno::RuntimeException, std::exception)
5523 SolarMutexGuard aGuard;
5525 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5526 return pNumericFormatter
5527 ? ImplCalcDoubleValue( (double)pNumericFormatter->GetMax(), pNumericFormatter->GetDecimalDigits() )
5528 : 0;
5531 void VCLXNumericField::setFirst( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5533 SolarMutexGuard aGuard;
5535 VclPtr< NumericField > pNumericField = GetAs< NumericField >();
5536 if ( pNumericField )
5537 pNumericField->SetFirst(
5538 (long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) );
5541 double VCLXNumericField::getFirst() throw(::com::sun::star::uno::RuntimeException, std::exception)
5543 SolarMutexGuard aGuard;
5545 VclPtr< NumericField > pNumericField = GetAs< NumericField >();
5546 return pNumericField
5547 ? ImplCalcDoubleValue( (double)pNumericField->GetFirst(), pNumericField->GetDecimalDigits() )
5548 : 0;
5551 void VCLXNumericField::setLast( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5553 SolarMutexGuard aGuard;
5555 VclPtr< NumericField > pNumericField = GetAs< NumericField >();
5556 if ( pNumericField )
5557 pNumericField->SetLast(
5558 (long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) );
5561 double VCLXNumericField::getLast() throw(::com::sun::star::uno::RuntimeException, std::exception)
5563 SolarMutexGuard aGuard;
5565 VclPtr< NumericField > pNumericField = GetAs< NumericField >();
5566 return pNumericField
5567 ? ImplCalcDoubleValue( (double)pNumericField->GetLast(), pNumericField->GetDecimalDigits() )
5568 : 0;
5571 void VCLXNumericField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5573 VCLXFormattedSpinField::setStrictFormat( bStrict );
5576 sal_Bool VCLXNumericField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException, std::exception)
5578 return VCLXFormattedSpinField::isStrictFormat();
5582 void VCLXNumericField::setSpinSize( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5584 SolarMutexGuard aGuard;
5586 VclPtr< NumericField > pNumericField = GetAs< NumericField >();
5587 if ( pNumericField )
5588 pNumericField->SetSpinSize(
5589 (long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) );
5592 double VCLXNumericField::getSpinSize() throw(::com::sun::star::uno::RuntimeException, std::exception)
5594 SolarMutexGuard aGuard;
5596 VclPtr< NumericField > pNumericField = GetAs< NumericField >();
5597 return pNumericField
5598 ? ImplCalcDoubleValue( (double)pNumericField->GetSpinSize(), pNumericField->GetDecimalDigits() )
5599 : 0;
5602 void VCLXNumericField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5604 SolarMutexGuard aGuard;
5606 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5607 if ( pNumericFormatter )
5609 double n = getValue();
5610 pNumericFormatter->SetDecimalDigits( Value );
5611 setValue( n );
5615 sal_Int16 VCLXNumericField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException, std::exception)
5617 SolarMutexGuard aGuard;
5619 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5620 return pNumericFormatter ? pNumericFormatter->GetDecimalDigits() : 0;
5623 void VCLXNumericField::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
5625 SolarMutexGuard aGuard;
5627 if ( GetWindow() )
5629 bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
5631 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5632 switch ( nPropType )
5634 case BASEPROPERTY_VALUE_DOUBLE:
5636 if ( bVoid )
5638 GetAs< NumericField >()->EnableEmptyFieldValue( true );
5639 GetAs< NumericField >()->SetEmptyFieldValue();
5641 else
5643 double d = 0;
5644 if ( Value >>= d )
5645 setValue( d );
5648 break;
5649 case BASEPROPERTY_VALUEMIN_DOUBLE:
5651 double d = 0;
5652 if ( Value >>= d )
5653 setMin( d );
5655 break;
5656 case BASEPROPERTY_VALUEMAX_DOUBLE:
5658 double d = 0;
5659 if ( Value >>= d )
5660 setMax( d );
5662 break;
5663 case BASEPROPERTY_VALUESTEP_DOUBLE:
5665 double d = 0;
5666 if ( Value >>= d )
5667 setSpinSize( d );
5669 break;
5670 case BASEPROPERTY_DECIMALACCURACY:
5672 sal_Int16 n = sal_Int16();
5673 if ( Value >>= n )
5674 setDecimalDigits( n );
5676 break;
5677 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5679 bool b = bool();
5680 if ( Value >>= b )
5681 GetAs< NumericField >()->SetUseThousandSep( b );
5683 break;
5684 default:
5686 VCLXFormattedSpinField::setProperty( PropertyName, Value );
5692 ::com::sun::star::uno::Any VCLXNumericField::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5694 SolarMutexGuard aGuard;
5696 ::com::sun::star::uno::Any aProp;
5697 FormatterBase* pFormatter = GetFormatter();
5698 if ( pFormatter )
5700 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5701 switch ( nPropType )
5703 case BASEPROPERTY_VALUE_DOUBLE:
5705 aProp <<= (double) getValue();
5707 break;
5708 case BASEPROPERTY_VALUEMIN_DOUBLE:
5710 aProp <<= (double) getMin();
5712 break;
5713 case BASEPROPERTY_VALUEMAX_DOUBLE:
5715 aProp <<= (double) getMax();
5717 break;
5718 case BASEPROPERTY_VALUESTEP_DOUBLE:
5720 aProp <<= (double) getSpinSize();
5722 break;
5723 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5725 aProp <<= GetAs< NumericField >()->IsUseThousandSep();
5727 break;
5728 default:
5730 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
5734 return aProp;
5738 // ----------------------------------------------------
5739 // class VCLXMetricField
5740 // ----------------------------------------------------
5742 void VCLXMetricField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
5744 PushPropertyIds( rIds,
5745 BASEPROPERTY_ALIGN,
5746 BASEPROPERTY_BACKGROUNDCOLOR,
5747 BASEPROPERTY_BORDER,
5748 BASEPROPERTY_BORDERCOLOR,
5749 BASEPROPERTY_DECIMALACCURACY,
5750 BASEPROPERTY_DEFAULTCONTROL,
5751 BASEPROPERTY_ENABLED,
5752 BASEPROPERTY_ENABLEVISIBLE,
5753 BASEPROPERTY_FONTDESCRIPTOR,
5754 BASEPROPERTY_HELPTEXT,
5755 BASEPROPERTY_HELPURL,
5756 BASEPROPERTY_NUMSHOWTHOUSANDSEP,
5757 BASEPROPERTY_PRINTABLE,
5758 BASEPROPERTY_READONLY,
5759 BASEPROPERTY_REPEAT,
5760 BASEPROPERTY_REPEAT_DELAY,
5761 BASEPROPERTY_SPIN,
5762 BASEPROPERTY_STRICTFORMAT,
5763 BASEPROPERTY_TABSTOP,
5764 BASEPROPERTY_ENFORCE_FORMAT,
5765 BASEPROPERTY_HIDEINACTIVESELECTION,
5766 BASEPROPERTY_UNIT,
5767 BASEPROPERTY_CUSTOMUNITTEXT,
5768 BASEPROPERTY_WRITING_MODE,
5769 BASEPROPERTY_CONTEXT_WRITING_MODE,
5770 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
5772 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5775 VCLXMetricField::VCLXMetricField()
5779 VCLXMetricField::~VCLXMetricField()
5783 MetricFormatter *VCLXMetricField::GetMetricFormatter() throw(::com::sun::star::uno::RuntimeException)
5785 MetricFormatter *pFormatter = static_cast<MetricFormatter *>(GetFormatter());
5786 if (!pFormatter)
5787 throw ::com::sun::star::uno::RuntimeException();
5788 return pFormatter;
5791 MetricField *VCLXMetricField::GetMetricField() throw(::com::sun::star::uno::RuntimeException)
5793 VclPtr< MetricField > pField = GetAs< MetricField >();
5794 if (!pField)
5795 throw ::com::sun::star::uno::RuntimeException();
5796 return pField;
5799 // ::com::sun::star::uno::XInterface
5800 ::com::sun::star::uno::Any VCLXMetricField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5802 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
5803 (static_cast< ::com::sun::star::awt::XMetricField* >(this)) );
5804 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
5807 // ::com::sun::star::lang::XTypeProvider
5808 IMPL_XTYPEPROVIDER_START( VCLXMetricField )
5809 cppu::UnoType<com::sun::star::awt::XMetricField>::get(),
5810 VCLXFormattedSpinField::getTypes()
5811 IMPL_XTYPEPROVIDER_END
5813 // FIXME: later ...
5814 #define MetricUnitUnoToVcl(a) ((FieldUnit)(a))
5816 #define METRIC_MAP_PAIR(method,parent) \
5817 sal_Int64 VCLXMetricField::get##method( sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException, std::exception) \
5819 SolarMutexGuard aGuard; \
5820 return GetMetric##parent()->Get##method( MetricUnitUnoToVcl( nUnit ) ); \
5822 void VCLXMetricField::set##method( sal_Int64 nValue, sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException, std::exception) \
5824 SolarMutexGuard aGuard; \
5825 GetMetric##parent()->Set##method( nValue, MetricUnitUnoToVcl( nUnit ) ); \
5828 METRIC_MAP_PAIR(Min, Formatter)
5829 METRIC_MAP_PAIR(Max, Formatter)
5830 METRIC_MAP_PAIR(First, Field)
5831 METRIC_MAP_PAIR(Last, Field)
5833 #undef METRIC_MAP_PAIR
5835 ::sal_Int64 VCLXMetricField::getValue( ::sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException, std::exception)
5837 SolarMutexGuard aGuard;
5838 return GetMetricFormatter()->GetValue( MetricUnitUnoToVcl( nUnit ) );
5841 ::sal_Int64 VCLXMetricField::getCorrectedValue( ::sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException, std::exception)
5843 SolarMutexGuard aGuard;
5844 return GetMetricFormatter()->GetCorrectedValue( MetricUnitUnoToVcl( nUnit ) );
5847 // FIXME: acute cut/paste evilness - move this to the parent Edit class ?
5848 void VCLXMetricField::CallListeners()
5850 // #107218# Call same listeners like VCL would do after user interaction
5851 VclPtr< Edit > pEdit = GetAs< Edit >();
5852 if ( pEdit )
5854 SetSynthesizingVCLEvent( true );
5855 pEdit->SetModifyFlag();
5856 pEdit->Modify();
5857 SetSynthesizingVCLEvent( false );
5861 void VCLXMetricField::setValue( ::sal_Int64 Value, ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException, std::exception)
5863 SolarMutexGuard aGuard;
5864 GetMetricFormatter()->SetValue( Value, MetricUnitUnoToVcl( Unit ) );
5865 CallListeners();
5868 void VCLXMetricField::setUserValue( ::sal_Int64 Value, ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException, std::exception)
5870 SolarMutexGuard aGuard;
5871 GetMetricFormatter()->SetUserValue( Value, MetricUnitUnoToVcl( Unit ) );
5872 CallListeners();
5875 void VCLXMetricField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5877 VCLXFormattedSpinField::setStrictFormat( bStrict );
5880 sal_Bool VCLXMetricField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException, std::exception)
5882 return VCLXFormattedSpinField::isStrictFormat();
5885 void VCLXMetricField::setSpinSize( sal_Int64 Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5887 SolarMutexGuard aGuard;
5888 GetMetricField()->SetSpinSize( Value );
5891 sal_Int64 VCLXMetricField::getSpinSize() throw(::com::sun::star::uno::RuntimeException, std::exception)
5893 SolarMutexGuard aGuard;
5894 return GetMetricField()->GetSpinSize();
5897 void VCLXMetricField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5899 SolarMutexGuard aGuard;
5900 GetMetricFormatter()->SetDecimalDigits( Value );
5903 sal_Int16 VCLXMetricField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException, std::exception)
5905 SolarMutexGuard aGuard;
5907 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5908 return pNumericFormatter ? pNumericFormatter->GetDecimalDigits() : 0;
5911 void VCLXMetricField::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
5913 SolarMutexGuard aGuard;
5915 if ( GetWindow() )
5917 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5918 switch ( nPropType )
5920 case BASEPROPERTY_DECIMALACCURACY:
5922 sal_Int16 n = 0;
5923 if ( Value >>= n )
5924 setDecimalDigits( n );
5925 break;
5927 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5929 bool b = false;
5930 if ( Value >>= b )
5931 GetAs< NumericField >()->SetUseThousandSep( b );
5933 break;
5934 case BASEPROPERTY_UNIT:
5936 sal_uInt16 nVal = 0;
5937 if ( Value >>= nVal )
5938 GetAs< MetricField >()->SetUnit( (FieldUnit) nVal );
5939 break;
5941 case BASEPROPERTY_CUSTOMUNITTEXT:
5943 OUString aStr;
5944 if ( Value >>= aStr )
5945 GetAs< MetricField >()->SetCustomUnitText( aStr );
5946 break;
5948 default:
5950 VCLXFormattedSpinField::setProperty( PropertyName, Value );
5951 break;
5957 ::com::sun::star::uno::Any VCLXMetricField::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5959 SolarMutexGuard aGuard;
5961 ::com::sun::star::uno::Any aProp;
5962 FormatterBase* pFormatter = GetFormatter();
5963 if ( pFormatter )
5965 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5966 switch ( nPropType )
5968 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5969 aProp <<= GetAs< NumericField >()->IsUseThousandSep();
5970 break;
5971 case BASEPROPERTY_UNIT:
5972 aProp <<= (sal_uInt16) (GetAs< MetricField >()->GetUnit());
5973 break;
5974 case BASEPROPERTY_CUSTOMUNITTEXT:
5975 aProp <<= OUString( GetAs< MetricField >()->GetCustomUnitText() );
5976 break;
5977 default:
5979 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
5980 break;
5984 return aProp;
5989 // class VCLXCurrencyField
5992 void VCLXCurrencyField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
5994 PushPropertyIds( rIds,
5995 BASEPROPERTY_ALIGN,
5996 BASEPROPERTY_BACKGROUNDCOLOR,
5997 BASEPROPERTY_BORDER,
5998 BASEPROPERTY_BORDERCOLOR,
5999 BASEPROPERTY_CURRENCYSYMBOL,
6000 BASEPROPERTY_CURSYM_POSITION,
6001 BASEPROPERTY_DECIMALACCURACY,
6002 BASEPROPERTY_DEFAULTCONTROL,
6003 BASEPROPERTY_ENABLED,
6004 BASEPROPERTY_ENABLEVISIBLE,
6005 BASEPROPERTY_FONTDESCRIPTOR,
6006 BASEPROPERTY_HELPTEXT,
6007 BASEPROPERTY_HELPURL,
6008 BASEPROPERTY_NUMSHOWTHOUSANDSEP,
6009 BASEPROPERTY_PRINTABLE,
6010 BASEPROPERTY_READONLY,
6011 BASEPROPERTY_REPEAT,
6012 BASEPROPERTY_REPEAT_DELAY,
6013 BASEPROPERTY_SPIN,
6014 BASEPROPERTY_STRICTFORMAT,
6015 BASEPROPERTY_TABSTOP,
6016 BASEPROPERTY_VALUEMAX_DOUBLE,
6017 BASEPROPERTY_VALUEMIN_DOUBLE,
6018 BASEPROPERTY_VALUESTEP_DOUBLE,
6019 BASEPROPERTY_VALUE_DOUBLE,
6020 BASEPROPERTY_ENFORCE_FORMAT,
6021 BASEPROPERTY_HIDEINACTIVESELECTION,
6022 BASEPROPERTY_VERTICALALIGN,
6023 BASEPROPERTY_WRITING_MODE,
6024 BASEPROPERTY_CONTEXT_WRITING_MODE,
6025 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
6027 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
6030 VCLXCurrencyField::VCLXCurrencyField()
6034 VCLXCurrencyField::~VCLXCurrencyField()
6038 // ::com::sun::star::uno::XInterface
6039 ::com::sun::star::uno::Any VCLXCurrencyField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6041 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
6042 (static_cast< ::com::sun::star::awt::XCurrencyField* >(this)) );
6043 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
6046 // ::com::sun::star::lang::XTypeProvider
6047 IMPL_XTYPEPROVIDER_START( VCLXCurrencyField )
6048 cppu::UnoType<com::sun::star::awt::XCurrencyField>::get(),
6049 VCLXFormattedSpinField::getTypes()
6050 IMPL_XTYPEPROVIDER_END
6052 void VCLXCurrencyField::setValue( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6054 SolarMutexGuard aGuard;
6056 LongCurrencyFormatter* pCurrencyFormatter = static_cast<LongCurrencyFormatter*>(GetFormatter());
6057 if ( pCurrencyFormatter )
6059 // shift long value using decimal digits
6060 // (e.g., input 105 using 2 digits returns 1,05)
6061 // Thus, to set a value of 1,05, insert 105 and 2 digits
6062 pCurrencyFormatter->SetValue(
6063 ImplCalcLongValue( Value, pCurrencyFormatter->GetDecimalDigits() ) );
6065 // #107218# Call same listeners like VCL would do after user interaction
6066 VclPtr< Edit > pEdit = GetAs< Edit >();
6067 if ( pEdit )
6069 SetSynthesizingVCLEvent( true );
6070 pEdit->SetModifyFlag();
6071 pEdit->Modify();
6072 SetSynthesizingVCLEvent( false );
6077 double VCLXCurrencyField::getValue() throw(::com::sun::star::uno::RuntimeException, std::exception)
6079 SolarMutexGuard aGuard;
6081 LongCurrencyFormatter* pCurrencyFormatter = static_cast<LongCurrencyFormatter*>(GetFormatter());
6082 return pCurrencyFormatter
6083 ? ImplCalcDoubleValue( (double)pCurrencyFormatter->GetValue(), pCurrencyFormatter->GetDecimalDigits() )
6084 : 0;
6087 void VCLXCurrencyField::setMin( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6089 SolarMutexGuard aGuard;
6091 LongCurrencyFormatter* pCurrencyFormatter = static_cast<LongCurrencyFormatter*>(GetFormatter());
6092 if ( pCurrencyFormatter )
6093 pCurrencyFormatter->SetMin(
6094 ImplCalcLongValue( Value, pCurrencyFormatter->GetDecimalDigits() ) );
6097 double VCLXCurrencyField::getMin() throw(::com::sun::star::uno::RuntimeException, std::exception)
6099 SolarMutexGuard aGuard;
6101 LongCurrencyFormatter* pCurrencyFormatter = static_cast<LongCurrencyFormatter*>(GetFormatter());
6102 return pCurrencyFormatter
6103 ? ImplCalcDoubleValue( (double)pCurrencyFormatter->GetMin(), pCurrencyFormatter->GetDecimalDigits() )
6104 : 0;
6107 void VCLXCurrencyField::setMax( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6109 SolarMutexGuard aGuard;
6111 LongCurrencyFormatter* pCurrencyFormatter = static_cast<LongCurrencyFormatter*>(GetFormatter());
6112 if ( pCurrencyFormatter )
6113 pCurrencyFormatter->SetMax(
6114 ImplCalcLongValue( Value, pCurrencyFormatter->GetDecimalDigits() ) );
6117 double VCLXCurrencyField::getMax() throw(::com::sun::star::uno::RuntimeException, std::exception)
6119 SolarMutexGuard aGuard;
6121 LongCurrencyFormatter* pCurrencyFormatter = static_cast<LongCurrencyFormatter*>(GetFormatter());
6122 return pCurrencyFormatter
6123 ? ImplCalcDoubleValue( (double)pCurrencyFormatter->GetMax(), pCurrencyFormatter->GetDecimalDigits() )
6124 : 0;
6127 void VCLXCurrencyField::setFirst( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6129 SolarMutexGuard aGuard;
6131 VclPtr< LongCurrencyField > pCurrencyField = GetAs< LongCurrencyField >();
6132 if ( pCurrencyField )
6133 pCurrencyField->SetFirst(
6134 ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) );
6137 double VCLXCurrencyField::getFirst() throw(::com::sun::star::uno::RuntimeException, std::exception)
6139 SolarMutexGuard aGuard;
6141 VclPtr< LongCurrencyField > pCurrencyField = GetAs< LongCurrencyField >();
6142 return pCurrencyField
6143 ? ImplCalcDoubleValue( (double)pCurrencyField->GetFirst(), pCurrencyField->GetDecimalDigits() )
6144 : 0;
6147 void VCLXCurrencyField::setLast( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6149 SolarMutexGuard aGuard;
6151 VclPtr< LongCurrencyField > pCurrencyField = GetAs< LongCurrencyField >();
6152 if ( pCurrencyField )
6153 pCurrencyField->SetLast(
6154 ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) );
6157 double VCLXCurrencyField::getLast() throw(::com::sun::star::uno::RuntimeException, std::exception)
6159 SolarMutexGuard aGuard;
6161 VclPtr< LongCurrencyField > pCurrencyField = GetAs< LongCurrencyField >();
6162 return pCurrencyField
6163 ? ImplCalcDoubleValue( (double)pCurrencyField->GetLast(), pCurrencyField->GetDecimalDigits() )
6164 : 0;
6167 void VCLXCurrencyField::setSpinSize( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6169 SolarMutexGuard aGuard;
6171 VclPtr< LongCurrencyField > pCurrencyField = GetAs< LongCurrencyField >();
6172 if ( pCurrencyField )
6173 pCurrencyField->SetSpinSize(
6174 ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) );
6177 double VCLXCurrencyField::getSpinSize() throw(::com::sun::star::uno::RuntimeException, std::exception)
6179 SolarMutexGuard aGuard;
6181 VclPtr< LongCurrencyField > pCurrencyField = GetAs< LongCurrencyField >();
6182 return pCurrencyField
6183 ? ImplCalcDoubleValue( (double)pCurrencyField->GetSpinSize(), pCurrencyField->GetDecimalDigits() )
6184 : 0;
6187 void VCLXCurrencyField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6189 VCLXFormattedSpinField::setStrictFormat( bStrict );
6192 sal_Bool VCLXCurrencyField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException, std::exception)
6194 return VCLXFormattedSpinField::isStrictFormat();
6198 void VCLXCurrencyField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6200 SolarMutexGuard aGuard;
6202 LongCurrencyFormatter* pCurrencyFormatter = static_cast<LongCurrencyFormatter*>(GetFormatter());
6203 if ( pCurrencyFormatter )
6205 double n = getValue();
6206 pCurrencyFormatter->SetDecimalDigits( Value );
6207 setValue( n );
6211 sal_Int16 VCLXCurrencyField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException, std::exception)
6213 SolarMutexGuard aGuard;
6215 LongCurrencyFormatter* pCurrencyFormatter = static_cast<LongCurrencyFormatter*>(GetFormatter());
6216 return pCurrencyFormatter ? pCurrencyFormatter->GetDecimalDigits() : 0;
6219 void VCLXCurrencyField::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
6221 SolarMutexGuard aGuard;
6223 if ( GetWindow() )
6225 bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
6227 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6228 switch ( nPropType )
6230 case BASEPROPERTY_VALUE_DOUBLE:
6232 if ( bVoid )
6234 GetAs< LongCurrencyField >()->EnableEmptyFieldValue( true );
6235 GetAs< LongCurrencyField >()->SetEmptyFieldValue();
6237 else
6239 double d = 0;
6240 if ( Value >>= d )
6241 setValue( d );
6244 break;
6245 case BASEPROPERTY_VALUEMIN_DOUBLE:
6247 double d = 0;
6248 if ( Value >>= d )
6249 setMin( d );
6251 break;
6252 case BASEPROPERTY_VALUEMAX_DOUBLE:
6254 double d = 0;
6255 if ( Value >>= d )
6256 setMax( d );
6258 break;
6259 case BASEPROPERTY_VALUESTEP_DOUBLE:
6261 double d = 0;
6262 if ( Value >>= d )
6263 setSpinSize( d );
6265 break;
6266 case BASEPROPERTY_DECIMALACCURACY:
6268 sal_Int16 n = sal_Int16();
6269 if ( Value >>= n )
6270 setDecimalDigits( n );
6272 break;
6273 case BASEPROPERTY_CURRENCYSYMBOL:
6275 OUString aString;
6276 if ( Value >>= aString )
6277 GetAs< LongCurrencyField >()->SetCurrencySymbol( aString );
6279 break;
6280 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
6282 bool b = bool();
6283 if ( Value >>= b )
6284 GetAs< LongCurrencyField >()->SetUseThousandSep( b );
6286 break;
6287 default:
6289 VCLXFormattedSpinField::setProperty( PropertyName, Value );
6295 ::com::sun::star::uno::Any VCLXCurrencyField::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6297 SolarMutexGuard aGuard;
6299 ::com::sun::star::uno::Any aProp;
6300 FormatterBase* pFormatter = GetFormatter();
6301 if ( pFormatter )
6303 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6304 switch ( nPropType )
6306 case BASEPROPERTY_VALUE_DOUBLE:
6308 aProp <<= (double) getValue();
6310 break;
6311 case BASEPROPERTY_VALUEMIN_DOUBLE:
6313 aProp <<= (double) getMin();
6315 break;
6316 case BASEPROPERTY_VALUEMAX_DOUBLE:
6318 aProp <<= (double) getMax();
6320 break;
6321 case BASEPROPERTY_VALUESTEP_DOUBLE:
6323 aProp <<= (double) getSpinSize();
6325 break;
6326 case BASEPROPERTY_CURRENCYSYMBOL:
6328 aProp <<= OUString( GetAs< LongCurrencyField >()->GetCurrencySymbol() );
6330 break;
6331 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
6333 aProp <<= GetAs< LongCurrencyField >()->IsUseThousandSep();
6335 break;
6336 default:
6338 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
6342 return aProp;
6346 // class VCLXPatternField
6349 void VCLXPatternField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
6351 PushPropertyIds( rIds,
6352 BASEPROPERTY_ALIGN,
6353 BASEPROPERTY_BACKGROUNDCOLOR,
6354 BASEPROPERTY_BORDER,
6355 BASEPROPERTY_BORDERCOLOR,
6356 BASEPROPERTY_DEFAULTCONTROL,
6357 BASEPROPERTY_EDITMASK,
6358 BASEPROPERTY_ENABLED,
6359 BASEPROPERTY_ENABLEVISIBLE,
6360 BASEPROPERTY_FONTDESCRIPTOR,
6361 BASEPROPERTY_HELPTEXT,
6362 BASEPROPERTY_HELPURL,
6363 BASEPROPERTY_LITERALMASK,
6364 BASEPROPERTY_MAXTEXTLEN,
6365 BASEPROPERTY_PRINTABLE,
6366 BASEPROPERTY_READONLY,
6367 BASEPROPERTY_STRICTFORMAT,
6368 BASEPROPERTY_TABSTOP,
6369 BASEPROPERTY_TEXT,
6370 BASEPROPERTY_HIDEINACTIVESELECTION,
6371 BASEPROPERTY_VERTICALALIGN,
6372 BASEPROPERTY_WRITING_MODE,
6373 BASEPROPERTY_CONTEXT_WRITING_MODE,
6374 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
6376 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
6379 VCLXPatternField::VCLXPatternField()
6383 VCLXPatternField::~VCLXPatternField()
6387 // ::com::sun::star::uno::XInterface
6388 ::com::sun::star::uno::Any VCLXPatternField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6390 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
6391 (static_cast< ::com::sun::star::awt::XPatternField* >(this)) );
6392 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
6395 // ::com::sun::star::lang::XTypeProvider
6396 IMPL_XTYPEPROVIDER_START( VCLXPatternField )
6397 cppu::UnoType<com::sun::star::awt::XPatternField>::get(),
6398 VCLXFormattedSpinField::getTypes()
6399 IMPL_XTYPEPROVIDER_END
6401 void VCLXPatternField::setMasks( const OUString& EditMask, const OUString& LiteralMask ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6403 SolarMutexGuard aGuard;
6405 VclPtr< PatternField > pPatternField = GetAs< PatternField >();
6406 if ( pPatternField )
6408 pPatternField->SetMask( OUStringToOString(EditMask, RTL_TEXTENCODING_ASCII_US), LiteralMask );
6412 void VCLXPatternField::getMasks( OUString& EditMask, OUString& LiteralMask ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6414 SolarMutexGuard aGuard;
6416 VclPtr< PatternField > pPatternField = GetAs< PatternField >();
6417 if ( pPatternField )
6419 EditMask = OStringToOUString(pPatternField->GetEditMask(), RTL_TEXTENCODING_ASCII_US);
6420 LiteralMask = pPatternField->GetLiteralMask();
6424 void VCLXPatternField::setString( const OUString& Str ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6426 SolarMutexGuard aGuard;
6427 VclPtr< PatternField > pPatternField = GetAs< PatternField >();
6428 if ( pPatternField )
6429 pPatternField->SetString( Str );
6432 OUString VCLXPatternField::getString() throw(::com::sun::star::uno::RuntimeException, std::exception)
6434 SolarMutexGuard aGuard;
6436 OUString aString;
6437 VclPtr< PatternField > pPatternField = GetAs< PatternField >();
6438 if ( pPatternField )
6439 aString = pPatternField->GetString();
6440 return aString;
6443 void VCLXPatternField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6445 VCLXFormattedSpinField::setStrictFormat( bStrict );
6448 sal_Bool VCLXPatternField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException, std::exception)
6450 return VCLXFormattedSpinField::isStrictFormat();
6453 void VCLXPatternField::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
6455 SolarMutexGuard aGuard;
6457 if ( GetWindow() )
6459 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6460 switch ( nPropType )
6462 case BASEPROPERTY_EDITMASK:
6463 case BASEPROPERTY_LITERALMASK:
6465 OUString aString;
6466 if ( Value >>= aString )
6468 OUString aEditMask, aLiteralMask;
6469 getMasks( aEditMask, aLiteralMask );
6470 if ( nPropType == BASEPROPERTY_EDITMASK )
6471 aEditMask = aString;
6472 else
6473 aLiteralMask = aString;
6474 setMasks( aEditMask, aLiteralMask );
6477 break;
6478 default:
6480 VCLXFormattedSpinField::setProperty( PropertyName, Value );
6486 ::com::sun::star::uno::Any VCLXPatternField::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
6488 SolarMutexGuard aGuard;
6490 ::com::sun::star::uno::Any aProp;
6491 if ( GetWindow() )
6493 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6494 switch ( nPropType )
6496 case BASEPROPERTY_EDITMASK:
6497 case BASEPROPERTY_LITERALMASK:
6499 OUString aEditMask, aLiteralMask;
6500 getMasks( aEditMask, aLiteralMask );
6501 if ( nPropType == BASEPROPERTY_EDITMASK )
6502 aProp <<= aEditMask;
6503 else
6504 aProp <<= aLiteralMask;
6506 break;
6507 default:
6509 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
6513 return aProp;
6517 // class VCLXToolBox
6519 VCLXToolBox::VCLXToolBox()
6523 VCLXToolBox::~VCLXToolBox()
6527 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXToolBox::CreateAccessibleContext()
6529 return getAccessibleFactory().createAccessibleContext( this );
6533 // class VCLXFrame
6535 VCLXFrame::VCLXFrame()
6539 void VCLXFrame::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
6541 PushPropertyIds( rIds,
6542 BASEPROPERTY_BACKGROUNDCOLOR,
6543 BASEPROPERTY_DEFAULTCONTROL,
6544 BASEPROPERTY_ENABLED,
6545 BASEPROPERTY_ENABLEVISIBLE,
6546 BASEPROPERTY_FONTDESCRIPTOR,
6547 BASEPROPERTY_GRAPHIC,
6548 BASEPROPERTY_HELPTEXT,
6549 BASEPROPERTY_HELPURL,
6550 BASEPROPERTY_PRINTABLE,
6551 BASEPROPERTY_LABEL,
6553 VCLXContainer::ImplGetPropertyIds( rIds );
6556 VCLXFrame::~VCLXFrame()
6560 ::com::sun::star::uno::Any SAL_CALL VCLXFrame::queryInterface(const ::com::sun::star::uno::Type & rType )
6561 throw(::com::sun::star::uno::RuntimeException, std::exception)
6563 return VCLXContainer::queryInterface( rType );
6566 // ::com::sun::star::lang::XTypeProvider
6567 IMPL_XTYPEPROVIDER_START( VCLXFrame )
6568 VCLXContainer::getTypes()
6569 IMPL_XTYPEPROVIDER_END
6571 // ::com::sun::star::awt::XView
6572 void SAL_CALL VCLXFrame::draw( sal_Int32 nX, sal_Int32 nY )
6573 throw(::com::sun::star::uno::RuntimeException, std::exception)
6575 SolarMutexGuard aGuard;
6576 VclPtr< vcl::Window > pWindow = GetWindow();
6578 if ( pWindow )
6580 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
6581 if ( !pDev )
6582 pDev = pWindow->GetParent();
6584 Size aSize = pDev->PixelToLogic( pWindow->GetSizePixel() );
6585 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
6587 pWindow->Draw( pDev, aPos, aSize, WINDOW_DRAW_NOCONTROLS );
6591 // ::com::sun::star::awt::XDevice,
6592 ::com::sun::star::awt::DeviceInfo SAL_CALL VCLXFrame::getInfo()
6593 throw(::com::sun::star::uno::RuntimeException, std::exception)
6595 ::com::sun::star::awt::DeviceInfo aInfo = VCLXDevice::getInfo();
6596 return aInfo;
6599 void SAL_CALL VCLXFrame::setProperty(
6600 const OUString& PropertyName,
6601 const ::com::sun::star::uno::Any& Value )
6602 throw(::com::sun::star::uno::RuntimeException, std::exception)
6604 SolarMutexGuard aGuard;
6606 VCLXContainer::setProperty( PropertyName, Value );
6609 void VCLXFrame::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
6611 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
6612 VCLXContainer::ProcessWindowEvent( rVclWindowEvent );
6615 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */