1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <toolkit/awt/vclxwindows.hxx>
21 #include "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
)
84 for ( sal_uInt16 d
= 0; d
< nDigits
; d
++ )
89 static double ImplCalcDoubleValue( double nValue
, sal_uInt16 nDigits
)
92 for ( sal_uInt16 d
= 0; d
< nDigits
; d
++ )
99 /** sets the "face color" for button like controls (scroll bar, spin button)
101 void setButtonLikeFaceColor( vcl::Window
* _pWindow
, const ::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() );
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
)
170 _pWindow
->SetStyle( nStyle
);
173 static void setVisualEffect( const Any
& _rValue
, vcl::Window
* _pWindow
)
175 AllSettings aSettings
= _pWindow
->GetSettings();
176 StyleSettings aStyleSettings
= aSettings
.GetStyleSettings();
178 sal_Int16 nStyle
= LOOK3D
;
179 OSL_VERIFY( _rValue
>>= nStyle
);
183 aStyleSettings
.SetOptions( aStyleSettings
.GetOptions() | STYLE_OPTION_MONO
);
187 aStyleSettings
.SetOptions( aStyleSettings
.GetOptions() & ~STYLE_OPTION_MONO
);
189 aSettings
.SetStyleSettings( aStyleSettings
);
190 _pWindow
->SetSettings( aSettings
);
193 static Any
getVisualEffect( vcl::Window
* _pWindow
)
197 StyleSettings aStyleSettings
= _pWindow
->GetSettings().GetStyleSettings();
198 if ( (aStyleSettings
.GetOptions() & STYLE_OPTION_MONO
) )
199 aEffect
<<= (sal_Int16
)FLAT
;
201 aEffect
<<= (sal_Int16
)LOOK3D
;
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 Button
* pButton
= static_cast< Button
* >( GetWindow() );
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
;
228 Size aOldSize
= GetWindow()->GetSizePixel();
229 VCLXWindow::setPosSize( X
, Y
, Width
, Height
, Flags
);
230 if ( ( aOldSize
.Width() != Width
) || ( aOldSize
.Height() != Height
) )
235 void VCLXGraphicControl::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
237 SolarMutexGuard aGuard
;
239 Button
* pButton
= static_cast< Button
* >( GetWindow() );
242 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
245 case BASEPROPERTY_GRAPHIC
:
247 Reference
< XGraphic
> xGraphic
;
248 OSL_VERIFY( Value
>>= xGraphic
);
249 maImage
= Image( xGraphic
);
254 case BASEPROPERTY_IMAGEALIGN
:
256 WindowType eType
= GetWindow()->GetType();
257 if ( ( eType
== WINDOW_PUSHBUTTON
)
258 || ( eType
== WINDOW_RADIOBUTTON
)
259 || ( eType
== WINDOW_CHECKBOX
)
262 sal_Int16 nAlignment
= sal_Int16();
263 if ( Value
>>= nAlignment
)
264 pButton
->SetImageAlign( static_cast< ImageAlign
>( nAlignment
) );
268 case BASEPROPERTY_IMAGEPOSITION
:
270 WindowType eType
= GetWindow()->GetType();
271 if ( ( eType
== WINDOW_PUSHBUTTON
)
272 || ( eType
== WINDOW_RADIOBUTTON
)
273 || ( eType
== WINDOW_CHECKBOX
)
276 sal_Int16 nImagePosition
= 2;
277 OSL_VERIFY( Value
>>= nImagePosition
);
278 pButton
->SetImageAlign( ::toolkit::translateImagePosition( nImagePosition
) );
283 VCLXWindow::setProperty( PropertyName
, Value
);
288 ::com::sun::star::uno::Any
VCLXGraphicControl::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
290 SolarMutexGuard aGuard
;
292 ::com::sun::star::uno::Any aProp
;
296 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
299 case BASEPROPERTY_GRAPHIC
:
300 aProp
<<= maImage
.GetXGraphic();
302 case BASEPROPERTY_IMAGEALIGN
:
304 WindowType eType
= GetWindow()->GetType();
305 if ( ( eType
== WINDOW_PUSHBUTTON
)
306 || ( eType
== WINDOW_RADIOBUTTON
)
307 || ( eType
== WINDOW_CHECKBOX
)
310 aProp
<<= ::toolkit::getCompatibleImageAlign( static_cast< Button
* >( GetWindow() )->GetImageAlign() );
314 case BASEPROPERTY_IMAGEPOSITION
:
316 WindowType eType
= GetWindow()->GetType();
317 if ( ( eType
== WINDOW_PUSHBUTTON
)
318 || ( eType
== WINDOW_RADIOBUTTON
)
319 || ( eType
== WINDOW_CHECKBOX
)
322 aProp
<<= ::toolkit::translateImagePosition( static_cast< Button
* >( GetWindow() )->GetImageAlign() );
328 aProp
<<= VCLXWindow::getProperty( PropertyName
);
339 void VCLXButton::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
341 PushPropertyIds( rIds
,
342 BASEPROPERTY_BACKGROUNDCOLOR
,
343 BASEPROPERTY_DEFAULTBUTTON
,
344 BASEPROPERTY_DEFAULTCONTROL
,
345 BASEPROPERTY_ENABLED
,
346 BASEPROPERTY_ENABLEVISIBLE
,
347 BASEPROPERTY_FONTDESCRIPTOR
,
348 BASEPROPERTY_GRAPHIC
,
349 BASEPROPERTY_HELPTEXT
,
350 BASEPROPERTY_HELPURL
,
351 BASEPROPERTY_IMAGEALIGN
,
352 BASEPROPERTY_IMAGEPOSITION
,
353 BASEPROPERTY_IMAGEURL
,
355 BASEPROPERTY_PRINTABLE
,
356 BASEPROPERTY_PUSHBUTTONTYPE
,
358 BASEPROPERTY_REPEAT_DELAY
,
360 BASEPROPERTY_TABSTOP
,
362 BASEPROPERTY_FOCUSONCLICK
,
363 BASEPROPERTY_MULTILINE
,
365 BASEPROPERTY_VERTICALALIGN
,
366 BASEPROPERTY_WRITING_MODE
,
367 BASEPROPERTY_CONTEXT_WRITING_MODE
,
368 BASEPROPERTY_REFERENCE_DEVICE
,
370 VCLXGraphicControl::ImplGetPropertyIds( rIds
);
373 VCLXButton::VCLXButton()
374 :maActionListeners( *this )
375 ,maItemListeners( *this )
379 VCLXButton::~VCLXButton()
383 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> VCLXButton::CreateAccessibleContext()
385 return getAccessibleFactory().createAccessibleContext( this );
388 void VCLXButton::dispose() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
390 SolarMutexGuard aGuard
;
392 ::com::sun::star::lang::EventObject aObj
;
393 aObj
.Source
= (::cppu::OWeakObject
*)this;
394 maActionListeners
.disposeAndClear( aObj
);
395 maItemListeners
.disposeAndClear( aObj
);
396 VCLXGraphicControl::dispose();
399 void VCLXButton::addActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
> & l
)throw(::com::sun::star::uno::RuntimeException
, std::exception
)
401 SolarMutexGuard aGuard
;
402 maActionListeners
.addInterface( l
);
405 void VCLXButton::removeActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
> & l
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
407 SolarMutexGuard aGuard
;
408 maActionListeners
.removeInterface( l
);
411 void VCLXButton::addItemListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XItemListener
> & l
)throw(::com::sun::star::uno::RuntimeException
, std::exception
)
413 SolarMutexGuard aGuard
;
414 maItemListeners
.addInterface( l
);
417 void VCLXButton::removeItemListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XItemListener
> & l
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
419 SolarMutexGuard aGuard
;
420 maItemListeners
.removeInterface( l
);
423 void VCLXButton::setLabel( const OUString
& rLabel
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
425 SolarMutexGuard aGuard
;
427 vcl::Window
* pWindow
= GetWindow();
429 pWindow
->SetText( rLabel
);
432 void VCLXButton::setActionCommand( const OUString
& rCommand
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
434 SolarMutexGuard aGuard
;
436 maActionCommand
= rCommand
;
439 ::com::sun::star::awt::Size
VCLXButton::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
441 SolarMutexGuard aGuard
;
444 PushButton
* pButton
= static_cast<PushButton
*>(GetWindow());
446 aSz
= pButton
->CalcMinimumSize();
450 ::com::sun::star::awt::Size
VCLXButton::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
452 ::com::sun::star::awt::Size aSz
= getMinimumSize();
458 ::com::sun::star::awt::Size
VCLXButton::calcAdjustedSize( const ::com::sun::star::awt::Size
& rNewSize
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
460 SolarMutexGuard aGuard
;
462 Size aSz
= VCLSize(rNewSize
);
463 PushButton
* pButton
= static_cast<PushButton
*>( GetWindow() );
466 Size aMinSz
= pButton
->CalcMinimumSize();
467 // no text, thus image
468 if ( pButton
->GetText().isEmpty() )
470 if ( aSz
.Width() < aMinSz
.Width() )
471 aSz
.Width() = aMinSz
.Width();
472 if ( aSz
.Height() < aMinSz
.Height() )
473 aSz
.Height() = aMinSz
.Height();
477 if ( ( aSz
.Width() > aMinSz
.Width() ) && ( aSz
.Height() < aMinSz
.Height() ) )
478 aSz
.Height() = aMinSz
.Height();
486 void VCLXButton::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
488 SolarMutexGuard aGuard
;
490 Button
* pButton
= static_cast<Button
*>(GetWindow());
493 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
496 case BASEPROPERTY_FOCUSONCLICK
:
497 ::toolkit::adjustBooleanWindowStyle( Value
, pButton
, WB_NOPOINTERFOCUS
, true );
500 case BASEPROPERTY_TOGGLE
:
501 ::toolkit::adjustBooleanWindowStyle( Value
, pButton
, WB_TOGGLE
, false );
504 case BASEPROPERTY_DEFAULTBUTTON
:
506 WinBits nStyle
= pButton
->GetStyle() | WB_DEFBUTTON
;
508 if ( ( Value
>>= b
) && !b
)
509 nStyle
&= ~WB_DEFBUTTON
;
510 pButton
->SetStyle( nStyle
);
513 case BASEPROPERTY_STATE
:
515 if ( GetWindow()->GetType() == WINDOW_PUSHBUTTON
)
517 sal_Int16 n
= sal_Int16();
519 static_cast<PushButton
*>(pButton
)->SetState( (TriState
)n
);
525 VCLXGraphicControl::setProperty( PropertyName
, Value
);
531 ::com::sun::star::uno::Any
VCLXButton::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
533 SolarMutexGuard aGuard
;
535 ::com::sun::star::uno::Any aProp
;
536 Button
* pButton
= static_cast<Button
*>(GetWindow());
539 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
542 case BASEPROPERTY_FOCUSONCLICK
:
543 aProp
<<= ( ( pButton
->GetStyle() & WB_NOPOINTERFOCUS
) == 0 );
546 case BASEPROPERTY_TOGGLE
:
547 aProp
<<= ( ( pButton
->GetStyle() & WB_TOGGLE
) != 0 );
550 case BASEPROPERTY_DEFAULTBUTTON
:
552 aProp
<<= ( pButton
->GetStyle() & WB_DEFBUTTON
) != 0;
555 case BASEPROPERTY_STATE
:
557 if ( GetWindow()->GetType() == WINDOW_PUSHBUTTON
)
559 aProp
<<= (sal_Int16
)static_cast<PushButton
*>(pButton
)->GetState();
565 aProp
<<= VCLXGraphicControl::getProperty( PropertyName
);
572 void VCLXButton::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
574 switch ( rVclWindowEvent
.GetId() )
576 case VCLEVENT_BUTTON_CLICK
:
578 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xKeepAlive( this );
579 // since we call listeners below, there is a potential that we will be destroyed
580 // during the listener call. To prevent the resulting crashs, we keep us
581 // alive as long as we're here
583 if ( maActionListeners
.getLength() )
585 ::com::sun::star::awt::ActionEvent aEvent
;
586 aEvent
.Source
= (::cppu::OWeakObject
*)this;
587 aEvent
.ActionCommand
= maActionCommand
;
589 Callback aCallback
= ::boost::bind(
590 &ActionListenerMultiplexer::actionPerformed
,
594 ImplExecuteAsyncWithoutSolarLock( aCallback
);
599 case VCLEVENT_PUSHBUTTON_TOGGLE
:
601 PushButton
& rButton
= dynamic_cast< PushButton
& >( *rVclWindowEvent
.GetWindow() );
603 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xKeepAlive( this );
604 if ( maItemListeners
.getLength() )
606 ::com::sun::star::awt::ItemEvent aEvent
;
607 aEvent
.Source
= (::cppu::OWeakObject
*)this;
608 aEvent
.Selected
= ( rButton
.GetState() == TRISTATE_TRUE
) ? 1 : 0;
609 maItemListeners
.itemStateChanged( aEvent
);
615 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent
);
621 // class VCLXImageControl
624 void VCLXImageControl::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
626 PushPropertyIds( rIds
,
627 BASEPROPERTY_BACKGROUNDCOLOR
,
629 BASEPROPERTY_BORDERCOLOR
,
630 BASEPROPERTY_DEFAULTCONTROL
,
631 BASEPROPERTY_ENABLED
,
632 BASEPROPERTY_ENABLEVISIBLE
,
633 BASEPROPERTY_GRAPHIC
,
634 BASEPROPERTY_HELPTEXT
,
635 BASEPROPERTY_HELPURL
,
636 BASEPROPERTY_IMAGEURL
,
637 BASEPROPERTY_PRINTABLE
,
638 BASEPROPERTY_SCALEIMAGE
,
639 BASEPROPERTY_IMAGE_SCALE_MODE
,
640 BASEPROPERTY_TABSTOP
,
641 BASEPROPERTY_WRITING_MODE
,
642 BASEPROPERTY_CONTEXT_WRITING_MODE
,
644 VCLXGraphicControl::ImplGetPropertyIds( rIds
);
647 VCLXImageControl::VCLXImageControl()
651 VCLXImageControl::~VCLXImageControl()
655 void VCLXImageControl::ImplSetNewImage()
657 OSL_PRECOND( GetWindow(), "VCLXImageControl::ImplSetNewImage: window is required to be not-NULL!" );
658 ImageControl
* pControl
= static_cast< ImageControl
* >( GetWindow() );
659 pControl
->SetImage( GetImage() );
662 ::com::sun::star::awt::Size
VCLXImageControl::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
664 SolarMutexGuard aGuard
;
666 Size aSz
= GetImage().GetSizePixel();
667 aSz
= ImplCalcWindowSize( aSz
);
672 ::com::sun::star::awt::Size
VCLXImageControl::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
674 return getMinimumSize();
677 ::com::sun::star::awt::Size
VCLXImageControl::calcAdjustedSize( const ::com::sun::star::awt::Size
& rNewSize
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
679 SolarMutexGuard aGuard
;
681 ::com::sun::star::awt::Size aSz
= rNewSize
;
682 ::com::sun::star::awt::Size aMinSz
= getMinimumSize();
683 if ( aSz
.Width
< aMinSz
.Width
)
684 aSz
.Width
= aMinSz
.Width
;
685 if ( aSz
.Height
< aMinSz
.Height
)
686 aSz
.Height
= aMinSz
.Height
;
690 void VCLXImageControl::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
692 SolarMutexGuard aGuard
;
694 ImageControl
* pImageControl
= static_cast<ImageControl
*>(GetWindow());
696 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
699 case BASEPROPERTY_IMAGE_SCALE_MODE
:
701 sal_Int16
nScaleMode( ImageScaleMode::ANISOTROPIC
);
702 if ( pImageControl
&& ( Value
>>= nScaleMode
) )
704 pImageControl
->SetScaleMode( nScaleMode
);
709 case BASEPROPERTY_SCALEIMAGE
:
711 // this is for compatibility only, nowadays, the ImageScaleMode property should be used
712 bool bScaleImage
= false;
713 if ( pImageControl
&& ( Value
>>= bScaleImage
) )
715 pImageControl
->SetScaleMode( bScaleImage
? ImageScaleMode::ANISOTROPIC
: ImageScaleMode::NONE
);
721 VCLXGraphicControl::setProperty( PropertyName
, Value
);
726 ::com::sun::star::uno::Any
VCLXImageControl::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
728 SolarMutexGuard aGuard
;
730 ::com::sun::star::uno::Any aProp
;
731 ImageControl
* pImageControl
= static_cast<ImageControl
*>(GetWindow());
732 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
736 case BASEPROPERTY_IMAGE_SCALE_MODE
:
737 aProp
<<= ( pImageControl
? pImageControl
->GetScaleMode() : ImageScaleMode::ANISOTROPIC
);
740 case BASEPROPERTY_SCALEIMAGE
:
741 aProp
<<= ( pImageControl
&& pImageControl
->GetScaleMode() != ImageScaleMode::NONE
) ? sal_True
: sal_False
;
745 aProp
= VCLXGraphicControl::getProperty( PropertyName
);
752 // class VCLXCheckBox
756 void VCLXCheckBox::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
758 PushPropertyIds( rIds
,
759 BASEPROPERTY_DEFAULTCONTROL
,
760 BASEPROPERTY_ENABLED
,
761 BASEPROPERTY_ENABLEVISIBLE
,
762 BASEPROPERTY_FONTDESCRIPTOR
,
763 BASEPROPERTY_GRAPHIC
,
764 BASEPROPERTY_HELPTEXT
,
765 BASEPROPERTY_HELPURL
,
766 BASEPROPERTY_IMAGEPOSITION
,
767 BASEPROPERTY_IMAGEURL
,
769 BASEPROPERTY_PRINTABLE
,
771 BASEPROPERTY_TABSTOP
,
772 BASEPROPERTY_TRISTATE
,
773 BASEPROPERTY_VISUALEFFECT
,
774 BASEPROPERTY_MULTILINE
,
775 BASEPROPERTY_BACKGROUNDCOLOR
,
777 BASEPROPERTY_VERTICALALIGN
,
778 BASEPROPERTY_WRITING_MODE
,
779 BASEPROPERTY_CONTEXT_WRITING_MODE
,
780 BASEPROPERTY_REFERENCE_DEVICE
,
782 VCLXGraphicControl::ImplGetPropertyIds( rIds
);
785 VCLXCheckBox::VCLXCheckBox() : maActionListeners( *this ), maItemListeners( *this )
789 // ::com::sun::star::uno::XInterface
790 ::com::sun::star::uno::Any
VCLXCheckBox::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
792 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
793 (static_cast< ::com::sun::star::awt::XButton
* >(this)),
794 (static_cast< ::com::sun::star::awt::XCheckBox
* >(this)) );
795 return (aRet
.hasValue() ? aRet
: VCLXGraphicControl::queryInterface( rType
));
798 // ::com::sun::star::lang::XTypeProvider
799 IMPL_XTYPEPROVIDER_START( VCLXCheckBox
)
800 cppu::UnoType
<com::sun::star::awt::XButton
>::get(),
801 cppu::UnoType
<com::sun::star::awt::XCheckBox
>::get(),
802 VCLXGraphicControl::getTypes()
803 IMPL_XTYPEPROVIDER_END
805 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> VCLXCheckBox::CreateAccessibleContext()
807 return getAccessibleFactory().createAccessibleContext( this );
810 void VCLXCheckBox::dispose() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
812 SolarMutexGuard aGuard
;
814 ::com::sun::star::lang::EventObject aObj
;
815 aObj
.Source
= (::cppu::OWeakObject
*)this;
816 maItemListeners
.disposeAndClear( aObj
);
817 VCLXGraphicControl::dispose();
820 void VCLXCheckBox::addItemListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XItemListener
> & l
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
822 SolarMutexGuard aGuard
;
823 maItemListeners
.addInterface( l
);
826 void VCLXCheckBox::removeItemListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XItemListener
> & l
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
828 SolarMutexGuard aGuard
;
829 maItemListeners
.removeInterface( l
);
832 void VCLXCheckBox::addActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
> & l
)throw(::com::sun::star::uno::RuntimeException
, std::exception
)
834 SolarMutexGuard aGuard
;
835 maActionListeners
.addInterface( l
);
838 void VCLXCheckBox::removeActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
> & l
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
840 SolarMutexGuard aGuard
;
841 maActionListeners
.removeInterface( l
);
844 void VCLXCheckBox::setActionCommand( const OUString
& rCommand
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
846 SolarMutexGuard aGuard
;
847 maActionCommand
= rCommand
;
850 void VCLXCheckBox::setLabel( const OUString
& rLabel
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
852 SolarMutexGuard aGuard
;
854 vcl::Window
* pWindow
= GetWindow();
856 pWindow
->SetText( rLabel
);
859 void VCLXCheckBox::setState( short n
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
861 SolarMutexGuard aGuard
;
863 CheckBox
* pCheckBox
= static_cast<CheckBox
*>(GetWindow());
869 case 0: eState
= TRISTATE_FALSE
; break;
870 case 1: eState
= TRISTATE_TRUE
; break;
871 case 2: eState
= TRISTATE_INDET
; break;
872 default: eState
= TRISTATE_FALSE
;
874 pCheckBox
->SetState( eState
);
876 // #105198# call C++ click listeners (needed for accessibility)
877 // pCheckBox->GetClickHdl().Call( pCheckBox );
879 // #107218# Call same virtual methods and listeners like VCL would do after user interaction
880 SetSynthesizingVCLEvent( true );
883 SetSynthesizingVCLEvent( false );
887 short VCLXCheckBox::getState() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
889 SolarMutexGuard aGuard
;
892 CheckBox
* pCheckBox
= static_cast<CheckBox
*>(GetWindow());
895 switch ( pCheckBox
->GetState() )
897 case TRISTATE_FALSE
: nState
= 0; break;
898 case TRISTATE_TRUE
: nState
= 1; break;
899 case TRISTATE_INDET
: nState
= 2; break;
900 default: OSL_FAIL( "VCLXCheckBox::getState(): unknown TriState!" );
907 void VCLXCheckBox::enableTriState( sal_Bool b
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
909 SolarMutexGuard aGuard
;
911 CheckBox
* pCheckBox
= static_cast<CheckBox
*>(GetWindow());
913 pCheckBox
->EnableTriState( b
);
916 ::com::sun::star::awt::Size
VCLXCheckBox::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
918 SolarMutexGuard aGuard
;
921 CheckBox
* pCheckBox
= static_cast<CheckBox
*>(GetWindow());
923 aSz
= pCheckBox
->CalcMinimumSize();
927 ::com::sun::star::awt::Size
VCLXCheckBox::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
929 return getMinimumSize();
932 ::com::sun::star::awt::Size
VCLXCheckBox::calcAdjustedSize( const ::com::sun::star::awt::Size
& rNewSize
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
934 SolarMutexGuard aGuard
;
936 Size aSz
= VCLSize(rNewSize
);
937 CheckBox
* pCheckBox
= static_cast<CheckBox
*>(GetWindow());
940 Size aMinSz
= pCheckBox
->CalcMinimumSize();
941 if ( ( aSz
.Width() > aMinSz
.Width() ) && ( aSz
.Height() < aMinSz
.Height() ) )
942 aSz
.Height() = aMinSz
.Height();
949 void VCLXCheckBox::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
951 SolarMutexGuard aGuard
;
953 CheckBox
* pCheckBox
= static_cast<CheckBox
*>(GetWindow());
956 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
959 case BASEPROPERTY_VISUALEFFECT
:
960 ::toolkit::setVisualEffect( Value
, pCheckBox
);
963 case BASEPROPERTY_TRISTATE
:
967 pCheckBox
->EnableTriState( b
);
970 case BASEPROPERTY_STATE
:
972 sal_Int16 n
= sal_Int16();
979 VCLXGraphicControl::setProperty( PropertyName
, Value
);
985 ::com::sun::star::uno::Any
VCLXCheckBox::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
987 SolarMutexGuard aGuard
;
989 ::com::sun::star::uno::Any aProp
;
990 CheckBox
* pCheckBox
= static_cast<CheckBox
*>(GetWindow());
993 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
996 case BASEPROPERTY_VISUALEFFECT
:
997 aProp
= ::toolkit::getVisualEffect( pCheckBox
);
999 case BASEPROPERTY_TRISTATE
:
1000 aProp
<<= pCheckBox
->IsTriStateEnabled();
1002 case BASEPROPERTY_STATE
:
1003 aProp
<<= (sal_Int16
)pCheckBox
->GetState();
1007 aProp
<<= VCLXGraphicControl::getProperty( PropertyName
);
1014 void VCLXCheckBox::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
1016 switch ( rVclWindowEvent
.GetId() )
1018 case VCLEVENT_CHECKBOX_TOGGLE
:
1020 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xKeepAlive( this );
1021 // since we call listeners below, there is a potential that we will be destroyed
1022 // in during the listener call. To prevent the resulting crashs, we keep us
1023 // alive as long as we're here
1025 CheckBox
* pCheckBox
= static_cast<CheckBox
*>(GetWindow());
1028 if ( maItemListeners
.getLength() )
1030 ::com::sun::star::awt::ItemEvent aEvent
;
1031 aEvent
.Source
= (::cppu::OWeakObject
*)this;
1032 aEvent
.Highlighted
= sal_False
;
1033 aEvent
.Selected
= pCheckBox
->GetState();
1034 maItemListeners
.itemStateChanged( aEvent
);
1036 if ( !IsSynthesizingVCLEvent() && maActionListeners
.getLength() )
1038 ::com::sun::star::awt::ActionEvent aEvent
;
1039 aEvent
.Source
= (::cppu::OWeakObject
*)this;
1040 aEvent
.ActionCommand
= maActionCommand
;
1041 maActionListeners
.actionPerformed( aEvent
);
1048 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent
);
1054 // class VCLXRadioButton
1056 void VCLXRadioButton::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
1058 PushPropertyIds( rIds
,
1059 BASEPROPERTY_DEFAULTCONTROL
,
1060 BASEPROPERTY_ENABLED
,
1061 BASEPROPERTY_ENABLEVISIBLE
,
1062 BASEPROPERTY_FONTDESCRIPTOR
,
1063 BASEPROPERTY_GRAPHIC
,
1064 BASEPROPERTY_HELPTEXT
,
1065 BASEPROPERTY_HELPURL
,
1066 BASEPROPERTY_IMAGEPOSITION
,
1067 BASEPROPERTY_IMAGEURL
,
1069 BASEPROPERTY_PRINTABLE
,
1071 BASEPROPERTY_TABSTOP
,
1072 BASEPROPERTY_VISUALEFFECT
,
1073 BASEPROPERTY_MULTILINE
,
1074 BASEPROPERTY_BACKGROUNDCOLOR
,
1076 BASEPROPERTY_VERTICALALIGN
,
1077 BASEPROPERTY_WRITING_MODE
,
1078 BASEPROPERTY_CONTEXT_WRITING_MODE
,
1079 BASEPROPERTY_REFERENCE_DEVICE
,
1080 BASEPROPERTY_GROUPNAME
,
1082 VCLXGraphicControl::ImplGetPropertyIds( rIds
);
1086 VCLXRadioButton::VCLXRadioButton() : maItemListeners( *this ), maActionListeners( *this )
1090 // ::com::sun::star::uno::XInterface
1091 ::com::sun::star::uno::Any
VCLXRadioButton::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1093 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
1094 (static_cast< ::com::sun::star::awt::XRadioButton
* >(this)),
1095 (static_cast< ::com::sun::star::awt::XButton
* >(this)) );
1096 return (aRet
.hasValue() ? aRet
: VCLXGraphicControl::queryInterface( rType
));
1099 // ::com::sun::star::lang::XTypeProvider
1100 IMPL_XTYPEPROVIDER_START( VCLXRadioButton
)
1101 cppu::UnoType
<com::sun::star::awt::XRadioButton
>::get(),
1102 cppu::UnoType
<com::sun::star::awt::XButton
>::get(),
1103 VCLXGraphicControl::getTypes()
1104 IMPL_XTYPEPROVIDER_END
1106 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> VCLXRadioButton::CreateAccessibleContext()
1108 return getAccessibleFactory().createAccessibleContext( this );
1111 void VCLXRadioButton::dispose() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1113 SolarMutexGuard aGuard
;
1115 ::com::sun::star::lang::EventObject aObj
;
1116 aObj
.Source
= (::cppu::OWeakObject
*)this;
1117 maItemListeners
.disposeAndClear( aObj
);
1118 VCLXGraphicControl::dispose();
1121 void VCLXRadioButton::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1123 SolarMutexGuard aGuard
;
1125 RadioButton
* pButton
= static_cast<RadioButton
*>(GetWindow());
1128 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
1129 switch ( nPropType
)
1131 case BASEPROPERTY_VISUALEFFECT
:
1132 ::toolkit::setVisualEffect( Value
, pButton
);
1135 case BASEPROPERTY_STATE
:
1137 sal_Int16 n
= sal_Int16();
1140 bool b
= n
? sal_True
: sal_False
;
1141 if ( pButton
->IsRadioCheckEnabled() )
1142 pButton
->Check( b
);
1144 pButton
->SetState( b
);
1148 case BASEPROPERTY_AUTOTOGGLE
:
1152 pButton
->EnableRadioCheck( b
);
1157 VCLXGraphicControl::setProperty( PropertyName
, Value
);
1163 ::com::sun::star::uno::Any
VCLXRadioButton::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1165 SolarMutexGuard aGuard
;
1167 ::com::sun::star::uno::Any aProp
;
1168 RadioButton
* pButton
= static_cast<RadioButton
*>(GetWindow());
1171 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
1172 switch ( nPropType
)
1174 case BASEPROPERTY_VISUALEFFECT
:
1175 aProp
= ::toolkit::getVisualEffect( pButton
);
1177 case BASEPROPERTY_STATE
:
1178 aProp
<<= (sal_Int16
) ( pButton
->IsChecked() ? 1 : 0 );
1180 case BASEPROPERTY_AUTOTOGGLE
:
1181 aProp
<<= pButton
->IsRadioCheckEnabled();
1185 aProp
<<= VCLXGraphicControl::getProperty( PropertyName
);
1192 void VCLXRadioButton::addItemListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XItemListener
> & l
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1194 SolarMutexGuard aGuard
;
1195 maItemListeners
.addInterface( l
);
1198 void VCLXRadioButton::removeItemListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XItemListener
> & l
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1200 SolarMutexGuard aGuard
;
1201 maItemListeners
.removeInterface( l
);
1204 void VCLXRadioButton::addActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
> & l
)throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1206 SolarMutexGuard aGuard
;
1207 maActionListeners
.addInterface( l
);
1210 void VCLXRadioButton::removeActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
> & l
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1212 SolarMutexGuard aGuard
;
1213 maActionListeners
.removeInterface( l
);
1216 void VCLXRadioButton::setLabel( const OUString
& rLabel
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1218 SolarMutexGuard aGuard
;
1220 vcl::Window
* pWindow
= GetWindow();
1222 pWindow
->SetText( rLabel
);
1225 void VCLXRadioButton::setActionCommand( const OUString
& rCommand
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1227 SolarMutexGuard aGuard
;
1228 maActionCommand
= rCommand
;
1231 void VCLXRadioButton::setState( sal_Bool b
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1233 SolarMutexGuard aGuard
;
1235 RadioButton
* pRadioButton
= static_cast<RadioButton
*>(GetWindow());
1238 pRadioButton
->Check( b
);
1239 // #102717# item listeners are called, but not C++ click listeners in StarOffice code => call click hdl
1240 // But this is needed in old code because Accessibility API uses it.
1241 // pRadioButton->GetClickHdl().Call( pRadioButton );
1243 // #107218# Call same virtual methods and listeners like VCL would do after user interaction
1244 SetSynthesizingVCLEvent( true );
1245 pRadioButton
->Click();
1246 SetSynthesizingVCLEvent( false );
1250 sal_Bool
VCLXRadioButton::getState() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1252 SolarMutexGuard aGuard
;
1254 RadioButton
* pRadioButton
= static_cast<RadioButton
*>(GetWindow());
1255 return pRadioButton
? pRadioButton
->IsChecked() : sal_False
;
1258 ::com::sun::star::awt::Size
VCLXRadioButton::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1260 SolarMutexGuard aGuard
;
1263 RadioButton
* pRadioButton
= static_cast<RadioButton
*>(GetWindow());
1265 aSz
= pRadioButton
->CalcMinimumSize();
1266 return AWTSize(aSz
);
1269 ::com::sun::star::awt::Size
VCLXRadioButton::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1271 return getMinimumSize();
1274 ::com::sun::star::awt::Size
VCLXRadioButton::calcAdjustedSize( const ::com::sun::star::awt::Size
& rNewSize
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1276 SolarMutexGuard aGuard
;
1278 Size aSz
= VCLSize(rNewSize
);
1279 RadioButton
* pRadioButton
= static_cast<RadioButton
*>(GetWindow());
1282 Size aMinSz
= pRadioButton
->CalcMinimumSize();
1283 if ( ( aSz
.Width() > aMinSz
.Width() ) && ( aSz
.Height() < aMinSz
.Height() ) )
1284 aSz
.Height() = aMinSz
.Height();
1288 return AWTSize(aSz
);
1291 void VCLXRadioButton::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
1293 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xKeepAlive( this );
1294 // since we call listeners below, there is a potential that we will be destroyed
1295 // in during the listener call. To prevent the resulting crashs, we keep us
1296 // alive as long as we're here
1298 switch ( rVclWindowEvent
.GetId() )
1300 case VCLEVENT_BUTTON_CLICK
:
1301 if ( !IsSynthesizingVCLEvent() && maActionListeners
.getLength() )
1303 ::com::sun::star::awt::ActionEvent aEvent
;
1304 aEvent
.Source
= (::cppu::OWeakObject
*)this;
1305 aEvent
.ActionCommand
= maActionCommand
;
1306 maActionListeners
.actionPerformed( aEvent
);
1308 ImplClickedOrToggled( false );
1311 case VCLEVENT_RADIOBUTTON_TOGGLE
:
1312 ImplClickedOrToggled( true );
1316 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent
);
1321 void VCLXRadioButton::ImplClickedOrToggled( bool bToggled
)
1323 // In the formulars, RadioChecked is not enabled, call itemStateChanged only for click
1324 // In the dialog editor, RadioChecked is enabled, call itemStateChanged only for bToggled
1325 RadioButton
* pRadioButton
= static_cast<RadioButton
*>(GetWindow());
1326 if ( pRadioButton
&& ( pRadioButton
->IsRadioCheckEnabled() == bToggled
) && ( bToggled
|| pRadioButton
->IsStateChanged() ) && maItemListeners
.getLength() )
1328 ::com::sun::star::awt::ItemEvent aEvent
;
1329 aEvent
.Source
= (::cppu::OWeakObject
*)this;
1330 aEvent
.Highlighted
= sal_False
;
1331 aEvent
.Selected
= pRadioButton
->IsChecked() ? 1 : 0;
1332 maItemListeners
.itemStateChanged( aEvent
);
1337 // class VCLXSpinField
1339 void VCLXSpinField::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
1341 PushPropertyIds( rIds
,
1342 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR
,
1344 VCLXEdit::ImplGetPropertyIds( rIds
);
1347 VCLXSpinField::VCLXSpinField() : maSpinListeners( *this )
1351 // ::com::sun::star::uno::XInterface
1352 ::com::sun::star::uno::Any
VCLXSpinField::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1354 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
1355 (static_cast< ::com::sun::star::awt::XSpinField
* >(this)) );
1356 return (aRet
.hasValue() ? aRet
: VCLXEdit::queryInterface( rType
));
1359 // ::com::sun::star::lang::XTypeProvider
1360 IMPL_XTYPEPROVIDER_START( VCLXSpinField
)
1361 cppu::UnoType
<com::sun::star::awt::XSpinField
>::get(),
1362 VCLXEdit::getTypes()
1363 IMPL_XTYPEPROVIDER_END
1365 void VCLXSpinField::addSpinListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XSpinListener
> & l
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1367 SolarMutexGuard aGuard
;
1368 maSpinListeners
.addInterface( l
);
1371 void VCLXSpinField::removeSpinListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XSpinListener
> & l
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1373 SolarMutexGuard aGuard
;
1374 maSpinListeners
.removeInterface( l
);
1377 void VCLXSpinField::up() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1379 SolarMutexGuard aGuard
;
1381 SpinField
* pSpinField
= static_cast<SpinField
*>(GetWindow());
1386 void VCLXSpinField::down() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1388 SolarMutexGuard aGuard
;
1390 SpinField
* pSpinField
= static_cast<SpinField
*>(GetWindow());
1395 void VCLXSpinField::first() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1397 SolarMutexGuard aGuard
;
1399 SpinField
* pSpinField
= static_cast<SpinField
*>(GetWindow());
1401 pSpinField
->First();
1404 void VCLXSpinField::last() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1406 SolarMutexGuard aGuard
;
1408 SpinField
* pSpinField
= static_cast<SpinField
*>(GetWindow());
1413 void VCLXSpinField::enableRepeat( sal_Bool bRepeat
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1415 SolarMutexGuard aGuard
;
1417 vcl::Window
* pWindow
= GetWindow();
1420 WinBits nStyle
= pWindow
->GetStyle();
1422 nStyle
|= WB_REPEAT
;
1424 nStyle
&= ~WB_REPEAT
;
1425 pWindow
->SetStyle( nStyle
);
1429 void VCLXSpinField::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
1431 switch ( rVclWindowEvent
.GetId() )
1433 case VCLEVENT_SPINFIELD_UP
:
1434 case VCLEVENT_SPINFIELD_DOWN
:
1435 case VCLEVENT_SPINFIELD_FIRST
:
1436 case VCLEVENT_SPINFIELD_LAST
:
1438 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xKeepAlive( this );
1439 // since we call listeners below, there is a potential that we will be destroyed
1440 // in during the listener call. To prevent the resulting crashs, we keep us
1441 // alive as long as we're here
1443 if ( maSpinListeners
.getLength() )
1445 ::com::sun::star::awt::SpinEvent aEvent
;
1446 aEvent
.Source
= (::cppu::OWeakObject
*)this;
1447 switch ( rVclWindowEvent
.GetId() )
1449 case VCLEVENT_SPINFIELD_UP
: maSpinListeners
.up( aEvent
);
1451 case VCLEVENT_SPINFIELD_DOWN
: maSpinListeners
.down( aEvent
);
1453 case VCLEVENT_SPINFIELD_FIRST
: maSpinListeners
.first( aEvent
);
1455 case VCLEVENT_SPINFIELD_LAST
: maSpinListeners
.last( aEvent
);
1464 VCLXEdit::ProcessWindowEvent( rVclWindowEvent
);
1471 // class VCLXListBox
1473 void VCLXListBox::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
1475 PushPropertyIds( rIds
,
1476 BASEPROPERTY_BACKGROUNDCOLOR
,
1477 BASEPROPERTY_BORDER
,
1478 BASEPROPERTY_BORDERCOLOR
,
1479 BASEPROPERTY_DEFAULTCONTROL
,
1480 BASEPROPERTY_DROPDOWN
,
1481 BASEPROPERTY_ENABLED
,
1482 BASEPROPERTY_ENABLEVISIBLE
,
1483 BASEPROPERTY_FONTDESCRIPTOR
,
1484 BASEPROPERTY_HELPTEXT
,
1485 BASEPROPERTY_HELPURL
,
1486 BASEPROPERTY_LINECOUNT
,
1487 BASEPROPERTY_MULTISELECTION
,
1488 BASEPROPERTY_MULTISELECTION_SIMPLEMODE
,
1489 BASEPROPERTY_ITEM_SEPARATOR_POS
,
1490 BASEPROPERTY_PRINTABLE
,
1491 BASEPROPERTY_SELECTEDITEMS
,
1492 BASEPROPERTY_STRINGITEMLIST
,
1493 BASEPROPERTY_TABSTOP
,
1494 BASEPROPERTY_READONLY
,
1496 BASEPROPERTY_WRITING_MODE
,
1497 BASEPROPERTY_CONTEXT_WRITING_MODE
,
1498 BASEPROPERTY_REFERENCE_DEVICE
,
1499 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR
,
1501 VCLXWindow::ImplGetPropertyIds( rIds
);
1505 VCLXListBox::VCLXListBox()
1506 : maActionListeners( *this ),
1507 maItemListeners( *this )
1511 void VCLXListBox::dispose() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1513 SolarMutexGuard aGuard
;
1515 ::com::sun::star::lang::EventObject aObj
;
1516 aObj
.Source
= (::cppu::OWeakObject
*)this;
1517 maItemListeners
.disposeAndClear( aObj
);
1518 maActionListeners
.disposeAndClear( aObj
);
1519 VCLXWindow::dispose();
1522 void VCLXListBox::addItemListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XItemListener
> & l
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1524 SolarMutexGuard aGuard
;
1525 maItemListeners
.addInterface( l
);
1528 void VCLXListBox::removeItemListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XItemListener
> & l
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1530 SolarMutexGuard aGuard
;
1531 maItemListeners
.removeInterface( l
);
1534 void VCLXListBox::addActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
> & l
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1536 SolarMutexGuard aGuard
;
1537 maActionListeners
.addInterface( l
);
1540 void VCLXListBox::removeActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
> & l
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1542 SolarMutexGuard aGuard
;
1543 maActionListeners
.removeInterface( l
);
1546 void VCLXListBox::addItem( const OUString
& aItem
, sal_Int16 nPos
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1548 SolarMutexGuard aGuard
;
1550 ListBox
* pBox
= static_cast<ListBox
*>(GetWindow());
1552 pBox
->InsertEntry( aItem
, nPos
);
1555 void VCLXListBox::addItems( const ::com::sun::star::uno::Sequence
< OUString
>& aItems
, sal_Int16 nPos
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1557 SolarMutexGuard aGuard
;
1559 ListBox
* pBox
= static_cast<ListBox
*>(GetWindow());
1562 sal_uInt16 nP
= nPos
;
1563 const OUString
* pItems
= aItems
.getConstArray();
1564 const OUString
* pItemsEnd
= aItems
.getConstArray() + aItems
.getLength();
1565 while ( pItems
!= pItemsEnd
)
1567 if ( (sal_uInt16
)nP
== 0xFFFF )
1569 OSL_FAIL( "VCLXListBox::addItems: too many entries!" );
1570 // skip remaining entries, list cannot hold them, anyway
1574 pBox
->InsertEntry( *pItems
++, nP
++ );
1579 void VCLXListBox::removeItems( sal_Int16 nPos
, sal_Int16 nCount
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1581 SolarMutexGuard aGuard
;
1583 ListBox
* pBox
= static_cast<ListBox
*>(GetWindow());
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 ListBox
* pBox
= static_cast<ListBox
*>(GetWindow());
1596 return pBox
? pBox
->GetEntryCount() : 0;
1599 OUString
VCLXListBox::getItem( sal_Int16 nPos
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1601 SolarMutexGuard aGuard
;
1604 ListBox
* pBox
= static_cast<ListBox
*>(GetWindow());
1606 aItem
= pBox
->GetEntry( nPos
);
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 ListBox
* pBox
= static_cast<ListBox
*>(GetWindow());
1618 sal_uInt16 nEntries
= pBox
->GetEntryCount();
1619 aSeq
= ::com::sun::star::uno::Sequence
< OUString
>( nEntries
);
1620 for ( sal_uInt16 n
= nEntries
; n
; )
1623 aSeq
.getArray()[n
] = OUString( pBox
->GetEntry( n
) );
1629 sal_Int16
VCLXListBox::getSelectedItemPos() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1631 SolarMutexGuard aGuard
;
1633 ListBox
* pBox
= static_cast<ListBox
*>(GetWindow());
1634 return pBox
? pBox
->GetSelectEntryPos() : 0;
1637 ::com::sun::star::uno::Sequence
<sal_Int16
> VCLXListBox::getSelectedItemsPos() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1639 SolarMutexGuard aGuard
;
1641 ::com::sun::star::uno::Sequence
<sal_Int16
> aSeq
;
1642 ListBox
* pBox
= static_cast<ListBox
*>(GetWindow());
1645 sal_uInt16 nSelEntries
= pBox
->GetSelectEntryCount();
1646 aSeq
= ::com::sun::star::uno::Sequence
<sal_Int16
>( nSelEntries
);
1647 for ( sal_uInt16 n
= 0; n
< nSelEntries
; n
++ )
1648 aSeq
.getArray()[n
] = pBox
->GetSelectEntryPos( n
);
1653 OUString
VCLXListBox::getSelectedItem() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1655 SolarMutexGuard aGuard
;
1658 ListBox
* pBox
= static_cast<ListBox
*>(GetWindow());
1660 aItem
= pBox
->GetSelectEntry();
1664 ::com::sun::star::uno::Sequence
< OUString
> VCLXListBox::getSelectedItems() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1666 SolarMutexGuard aGuard
;
1668 ::com::sun::star::uno::Sequence
< OUString
> aSeq
;
1669 ListBox
* pBox
= static_cast<ListBox
*>(GetWindow());
1672 sal_uInt16 nSelEntries
= pBox
->GetSelectEntryCount();
1673 aSeq
= ::com::sun::star::uno::Sequence
< OUString
>( nSelEntries
);
1674 for ( sal_uInt16 n
= 0; n
< nSelEntries
; n
++ )
1675 aSeq
.getArray()[n
] = OUString( pBox
->GetSelectEntry( n
) );
1680 void VCLXListBox::selectItemPos( sal_Int16 nPos
, sal_Bool bSelect
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1682 SolarMutexGuard aGuard
;
1684 ListBox
* pBox
= static_cast<ListBox
*>(GetWindow());
1685 if ( pBox
&& ( pBox
->IsEntryPosSelected( nPos
) != bool(bSelect
) ) )
1687 pBox
->SelectEntryPos( nPos
, bSelect
);
1689 // VCL doesn't call select handler after API call.
1690 // ImplCallItemListeners();
1692 // #107218# Call same listeners like VCL would do after user interaction
1693 SetSynthesizingVCLEvent( true );
1695 SetSynthesizingVCLEvent( false );
1699 void VCLXListBox::selectItemsPos( const ::com::sun::star::uno::Sequence
<sal_Int16
>& aPositions
, sal_Bool bSelect
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1701 SolarMutexGuard aGuard
;
1703 ListBox
* pBox
= static_cast<ListBox
*>(GetWindow());
1706 bool bChanged
= false;
1707 for ( sal_uInt16 n
= (sal_uInt16
)aPositions
.getLength(); n
; )
1709 sal_uInt16 nPos
= (sal_uInt16
) aPositions
.getConstArray()[--n
];
1710 if ( pBox
->IsEntryPosSelected( nPos
) != bool(bSelect
) )
1712 pBox
->SelectEntryPos( nPos
, bSelect
);
1719 // VCL doesn't call select handler after API call.
1720 // ImplCallItemListeners();
1722 // #107218# Call same listeners like VCL would do after user interaction
1723 SetSynthesizingVCLEvent( true );
1725 SetSynthesizingVCLEvent( false );
1730 void VCLXListBox::selectItem( const OUString
& rItemText
, sal_Bool bSelect
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1732 SolarMutexGuard aGuard
;
1734 ListBox
* pBox
= static_cast<ListBox
*>(GetWindow());
1737 OUString
aItemText( rItemText
);
1738 selectItemPos( pBox
->GetEntryPos( aItemText
), bSelect
);
1743 void VCLXListBox::setDropDownLineCount( sal_Int16 nLines
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1745 SolarMutexGuard aGuard
;
1747 ListBox
* pBox
= static_cast<ListBox
*>(GetWindow());
1749 pBox
->SetDropDownLineCount( nLines
);
1752 sal_Int16
VCLXListBox::getDropDownLineCount() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1754 SolarMutexGuard aGuard
;
1756 sal_Int16 nLines
= 0;
1757 ListBox
* pBox
= static_cast<ListBox
*>(GetWindow());
1759 nLines
= pBox
->GetDropDownLineCount();
1763 sal_Bool
VCLXListBox::isMutipleMode() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1765 SolarMutexGuard aGuard
;
1767 bool bMulti
= false;
1768 ListBox
* pBox
= static_cast<ListBox
*>(GetWindow());
1770 bMulti
= pBox
->IsMultiSelectionEnabled();
1774 void VCLXListBox::setMultipleMode( sal_Bool bMulti
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1776 SolarMutexGuard aGuard
;
1778 ListBox
* pBox
= static_cast<ListBox
*>(GetWindow());
1780 pBox
->EnableMultiSelection( bMulti
);
1783 void VCLXListBox::makeVisible( sal_Int16 nEntry
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1785 SolarMutexGuard aGuard
;
1787 ListBox
* pBox
= static_cast<ListBox
*>(GetWindow());
1789 pBox
->SetTopEntry( nEntry
);
1792 void VCLXListBox::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
1794 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xKeepAlive( this );
1795 // since we call listeners below, there is a potential that we will be destroyed
1796 // in during the listener call. To prevent the resulting crashs, we keep us
1797 // alive as long as we're here
1799 switch ( rVclWindowEvent
.GetId() )
1801 case VCLEVENT_LISTBOX_SELECT
:
1803 ListBox
* pListBox
= static_cast<ListBox
*>(GetWindow());
1807 bool bDropDown
= ( pListBox
->GetStyle() & WB_DROPDOWN
) ? sal_True
: sal_False
;
1808 if ( bDropDown
&& !IsSynthesizingVCLEvent() && maActionListeners
.getLength() )
1810 // Call ActionListener on DropDown event
1811 ::com::sun::star::awt::ActionEvent aEvent
;
1812 aEvent
.Source
= (::cppu::OWeakObject
*)this;
1813 aEvent
.ActionCommand
= pListBox
->GetSelectEntry();
1814 maActionListeners
.actionPerformed( aEvent
);
1817 if ( maItemListeners
.getLength() )
1819 ImplCallItemListeners();
1825 case VCLEVENT_LISTBOX_DOUBLECLICK
:
1826 if ( GetWindow() && maActionListeners
.getLength() )
1828 ::com::sun::star::awt::ActionEvent aEvent
;
1829 aEvent
.Source
= (::cppu::OWeakObject
*)this;
1830 aEvent
.ActionCommand
= static_cast<ListBox
*>(GetWindow())->GetSelectEntry();
1831 maActionListeners
.actionPerformed( aEvent
);
1836 VCLXWindow::ProcessWindowEvent( rVclWindowEvent
);
1841 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> VCLXListBox::CreateAccessibleContext()
1843 SolarMutexGuard aGuard
;
1845 return getAccessibleFactory().createAccessibleContext( this );
1848 void VCLXListBox::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1850 SolarMutexGuard aGuard
;
1852 ListBox
* pListBox
= static_cast<ListBox
*>(GetWindow());
1855 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
1856 switch ( nPropType
)
1858 case BASEPROPERTY_ITEM_SEPARATOR_POS
:
1860 sal_Int16
nSeparatorPos(0);
1861 if ( Value
>>= nSeparatorPos
)
1862 pListBox
->SetSeparatorPos( nSeparatorPos
);
1865 case BASEPROPERTY_READONLY
:
1869 pListBox
->SetReadOnly( b
);
1872 case BASEPROPERTY_MULTISELECTION
:
1876 pListBox
->EnableMultiSelection( b
);
1879 case BASEPROPERTY_MULTISELECTION_SIMPLEMODE
:
1880 ::toolkit::adjustBooleanWindowStyle( Value
, pListBox
, WB_SIMPLEMODE
, false );
1882 case BASEPROPERTY_LINECOUNT
:
1884 sal_Int16 n
= sal_Int16();
1886 pListBox
->SetDropDownLineCount( n
);
1889 case BASEPROPERTY_STRINGITEMLIST
:
1891 ::com::sun::star::uno::Sequence
< OUString
> aItems
;
1892 if ( Value
>>= aItems
)
1895 addItems( aItems
, 0 );
1899 case BASEPROPERTY_SELECTEDITEMS
:
1901 ::com::sun::star::uno::Sequence
<sal_Int16
> aItems
;
1902 if ( Value
>>= aItems
)
1904 for ( sal_uInt16 n
= pListBox
->GetEntryCount(); n
; )
1905 pListBox
->SelectEntryPos( --n
, false );
1907 if ( aItems
.getLength() )
1908 selectItemsPos( aItems
, sal_True
);
1910 pListBox
->SetNoSelection();
1912 if ( !pListBox
->GetSelectEntryCount() )
1913 pListBox
->SetTopEntry( 0 );
1919 VCLXWindow::setProperty( PropertyName
, Value
);
1925 ::com::sun::star::uno::Any
VCLXListBox::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1927 SolarMutexGuard aGuard
;
1929 ::com::sun::star::uno::Any aProp
;
1930 ListBox
* pListBox
= static_cast<ListBox
*>(GetWindow());
1933 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
1934 switch ( nPropType
)
1936 case BASEPROPERTY_ITEM_SEPARATOR_POS
:
1937 aProp
<<= sal_Int16( pListBox
->GetSeparatorPos() );
1939 case BASEPROPERTY_READONLY
:
1941 aProp
<<= pListBox
->IsReadOnly();
1944 case BASEPROPERTY_MULTISELECTION
:
1946 aProp
<<= pListBox
->IsMultiSelectionEnabled();
1949 case BASEPROPERTY_MULTISELECTION_SIMPLEMODE
:
1951 aProp
<<= ( ( pListBox
->GetStyle() & WB_SIMPLEMODE
) == 0 );
1954 case BASEPROPERTY_LINECOUNT
:
1956 aProp
<<= (sal_Int16
) pListBox
->GetDropDownLineCount();
1959 case BASEPROPERTY_STRINGITEMLIST
:
1961 sal_uInt16 nItems
= pListBox
->GetEntryCount();
1962 ::com::sun::star::uno::Sequence
< OUString
> aSeq( nItems
);
1963 OUString
* pStrings
= aSeq
.getArray();
1964 for ( sal_uInt16 n
= 0; n
< nItems
; n
++ )
1965 pStrings
[n
] = pListBox
->GetEntry( n
);
1972 aProp
<<= VCLXWindow::getProperty( PropertyName
);
1979 ::com::sun::star::awt::Size
VCLXListBox::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1981 SolarMutexGuard aGuard
;
1984 ListBox
* pListBox
= static_cast<ListBox
*>(GetWindow());
1986 aSz
= pListBox
->CalcMinimumSize();
1987 return AWTSize(aSz
);
1990 ::com::sun::star::awt::Size
VCLXListBox::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1992 SolarMutexGuard aGuard
;
1995 ListBox
* pListBox
= static_cast<ListBox
*>(GetWindow());
1998 aSz
= pListBox
->CalcMinimumSize();
1999 if ( pListBox
->GetStyle() & WB_DROPDOWN
)
2002 return AWTSize(aSz
);
2005 ::com::sun::star::awt::Size
VCLXListBox::calcAdjustedSize( const ::com::sun::star::awt::Size
& rNewSize
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2007 SolarMutexGuard aGuard
;
2009 Size aSz
= VCLSize(rNewSize
);
2010 ListBox
* pListBox
= static_cast<ListBox
*>(GetWindow());
2012 aSz
= pListBox
->CalcAdjustedSize( aSz
);
2013 return AWTSize(aSz
);
2016 ::com::sun::star::awt::Size
VCLXListBox::getMinimumSize( sal_Int16 nCols
, sal_Int16 nLines
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2018 SolarMutexGuard aGuard
;
2021 ListBox
* pListBox
= static_cast<ListBox
*>(GetWindow());
2023 aSz
= pListBox
->CalcBlockSize( nCols
, nLines
);
2024 return AWTSize(aSz
);
2027 void VCLXListBox::getColumnsAndLines( sal_Int16
& nCols
, sal_Int16
& nLines
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2029 SolarMutexGuard aGuard
;
2032 ListBox
* pListBox
= static_cast<ListBox
*>(GetWindow());
2036 pListBox
->GetMaxVisColumnsAndLines( nC
, nL
);
2042 void VCLXListBox::ImplCallItemListeners()
2044 ListBox
* pListBox
= static_cast<ListBox
*>(GetWindow());
2045 if ( pListBox
&& maItemListeners
.getLength() )
2047 ::com::sun::star::awt::ItemEvent aEvent
;
2048 aEvent
.Source
= (::cppu::OWeakObject
*)this;
2049 aEvent
.Highlighted
= sal_False
;
2051 // Set to 0xFFFF on multiple selection, selected entry ID otherwise
2052 aEvent
.Selected
= (pListBox
->GetSelectEntryCount() == 1 ) ? pListBox
->GetSelectEntryPos() : 0xFFFF;
2054 maItemListeners
.itemStateChanged( aEvent
);
2059 Image
lcl_getImageFromURL( const OUString
& i_rImageURL
)
2061 if ( i_rImageURL
.isEmpty() )
2066 Reference
< uno::XComponentContext
> xContext( ::comphelper::getProcessComponentContext() );
2067 Reference
< XGraphicProvider
> xProvider(graphic::GraphicProvider::create(xContext
));
2068 ::comphelper::NamedValueCollection aMediaProperties
;
2069 aMediaProperties
.put( "URL", i_rImageURL
);
2070 Reference
< XGraphic
> xGraphic
= xProvider
->queryGraphic( aMediaProperties
.getPropertyValues() );
2071 return Image( xGraphic
);
2073 catch( const uno::Exception
& )
2075 DBG_UNHANDLED_EXCEPTION();
2080 void SAL_CALL
VCLXListBox::listItemInserted( const ItemListEvent
& i_rEvent
) throw (RuntimeException
, std::exception
)
2082 SolarMutexGuard aGuard
;
2084 ListBox
* pListBox
= dynamic_cast< ListBox
* >( GetWindow() );
2086 ENSURE_OR_RETURN_VOID( pListBox
, "VCLXListBox::listItemInserted: no ListBox?!" );
2087 ENSURE_OR_RETURN_VOID( ( i_rEvent
.ItemPosition
>= 0 ) && ( i_rEvent
.ItemPosition
<= sal_Int32( pListBox
->GetEntryCount() ) ),
2088 "VCLXListBox::listItemInserted: illegal (inconsistent) item position!" );
2089 pListBox
->InsertEntry(
2090 i_rEvent
.ItemText
.IsPresent
? i_rEvent
.ItemText
.Value
: OUString(),
2091 i_rEvent
.ItemImageURL
.IsPresent
? TkResMgr::getImageFromURL( i_rEvent
.ItemImageURL
.Value
) : Image(),
2092 i_rEvent
.ItemPosition
);
2095 void SAL_CALL
VCLXListBox::listItemRemoved( const ItemListEvent
& i_rEvent
) throw (RuntimeException
, std::exception
)
2097 SolarMutexGuard aGuard
;
2099 ListBox
* pListBox
= dynamic_cast< ListBox
* >( GetWindow() );
2101 ENSURE_OR_RETURN_VOID( pListBox
, "VCLXListBox::listItemRemoved: no ListBox?!" );
2102 ENSURE_OR_RETURN_VOID( ( i_rEvent
.ItemPosition
>= 0 ) && ( i_rEvent
.ItemPosition
< sal_Int32( pListBox
->GetEntryCount() ) ),
2103 "VCLXListBox::listItemRemoved: illegal (inconsistent) item position!" );
2105 pListBox
->RemoveEntry( i_rEvent
.ItemPosition
);
2108 void SAL_CALL
VCLXListBox::listItemModified( const ItemListEvent
& i_rEvent
) throw (RuntimeException
, std::exception
)
2110 SolarMutexGuard aGuard
;
2112 ListBox
* pListBox
= dynamic_cast< ListBox
* >( GetWindow() );
2114 ENSURE_OR_RETURN_VOID( pListBox
, "VCLXListBox::listItemModified: no ListBox?!" );
2115 ENSURE_OR_RETURN_VOID( ( i_rEvent
.ItemPosition
>= 0 ) && ( i_rEvent
.ItemPosition
< sal_Int32( pListBox
->GetEntryCount() ) ),
2116 "VCLXListBox::listItemModified: illegal (inconsistent) item position!" );
2118 // VCL's ListBox does not support changing an entry's text or image, so remove and re-insert
2120 const OUString sNewText
= i_rEvent
.ItemText
.IsPresent
? i_rEvent
.ItemText
.Value
: OUString( pListBox
->GetEntry( i_rEvent
.ItemPosition
) );
2121 const Image
aNewImage( i_rEvent
.ItemImageURL
.IsPresent
? TkResMgr::getImageFromURL( i_rEvent
.ItemImageURL
.Value
) : pListBox
->GetEntryImage( i_rEvent
.ItemPosition
) );
2123 pListBox
->RemoveEntry( i_rEvent
.ItemPosition
);
2124 pListBox
->InsertEntry( sNewText
, aNewImage
, i_rEvent
.ItemPosition
);
2127 void SAL_CALL
VCLXListBox::allItemsRemoved( const EventObject
& i_rEvent
) throw (RuntimeException
, std::exception
)
2129 SolarMutexGuard aGuard
;
2131 ListBox
* pListBox
= dynamic_cast< ListBox
* >( GetWindow() );
2132 ENSURE_OR_RETURN_VOID( pListBox
, "VCLXListBox::listItemModified: no ListBox?!" );
2139 void SAL_CALL
VCLXListBox::itemListChanged( const EventObject
& i_rEvent
) throw (RuntimeException
, std::exception
)
2141 SolarMutexGuard aGuard
;
2143 ListBox
* pListBox
= dynamic_cast< ListBox
* >( GetWindow() );
2144 ENSURE_OR_RETURN_VOID( pListBox
, "VCLXListBox::listItemModified: no ListBox?!" );
2148 uno::Reference
< beans::XPropertySet
> xPropSet( i_rEvent
.Source
, uno::UNO_QUERY_THROW
);
2149 uno::Reference
< beans::XPropertySetInfo
> xPSI( xPropSet
->getPropertySetInfo(), uno::UNO_QUERY_THROW
);
2150 uno::Reference
< resource::XStringResourceResolver
> xStringResourceResolver
;
2151 if ( xPSI
->hasPropertyByName("ResourceResolver") )
2153 xStringResourceResolver
.set(
2154 xPropSet
->getPropertyValue("ResourceResolver"),
2160 Reference
< XItemList
> xItemList( i_rEvent
.Source
, uno::UNO_QUERY_THROW
);
2161 uno::Sequence
< beans::Pair
< OUString
, OUString
> > aItems
= xItemList
->getAllItems();
2162 for ( sal_Int32 i
=0; i
<aItems
.getLength(); ++i
)
2164 OUString
aLocalizationKey( aItems
[i
].First
);
2165 if ( xStringResourceResolver
.is() && aLocalizationKey
.startsWith("&") )
2167 aLocalizationKey
= xStringResourceResolver
->resolveString(aLocalizationKey
.copy( 1 ));
2169 pListBox
->InsertEntry( aLocalizationKey
, lcl_getImageFromURL( aItems
[i
].Second
) );
2173 void SAL_CALL
VCLXListBox::disposing( const EventObject
& i_rEvent
) throw (RuntimeException
, std::exception
)
2175 // just disambiguate
2176 VCLXWindow::disposing( i_rEvent
);
2180 // class VCLXMessageBox
2183 void VCLXMessageBox::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
2185 VCLXTopWindow::ImplGetPropertyIds( rIds
);
2188 VCLXMessageBox::VCLXMessageBox()
2192 VCLXMessageBox::~VCLXMessageBox()
2196 // ::com::sun::star::uno::XInterface
2197 ::com::sun::star::uno::Any
VCLXMessageBox::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2199 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
2200 (static_cast< ::com::sun::star::awt::XMessageBox
* >(this)) );
2201 return (aRet
.hasValue() ? aRet
: VCLXTopWindow::queryInterface( rType
));
2204 // ::com::sun::star::lang::XTypeProvider
2205 IMPL_XTYPEPROVIDER_START( VCLXMessageBox
)
2206 cppu::UnoType
<com::sun::star::awt::XMessageBox
>::get(),
2207 VCLXTopWindow::getTypes()
2208 IMPL_XTYPEPROVIDER_END
2210 void VCLXMessageBox::setCaptionText( const OUString
& rText
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2212 SolarMutexGuard aGuard
;
2214 vcl::Window
* pWindow
= GetWindow();
2216 pWindow
->SetText( rText
);
2219 OUString
VCLXMessageBox::getCaptionText() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2221 SolarMutexGuard aGuard
;
2224 vcl::Window
* pWindow
= GetWindow();
2226 aText
= pWindow
->GetText();
2230 void VCLXMessageBox::setMessageText( const OUString
& rText
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2232 SolarMutexGuard aGuard
;
2234 MessBox
* pBox
= static_cast<MessBox
*>(GetWindow());
2236 pBox
->SetMessText( rText
);
2239 OUString
VCLXMessageBox::getMessageText() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2241 SolarMutexGuard aGuard
;
2244 MessBox
* pBox
= static_cast<MessBox
*>(GetWindow());
2246 aText
= pBox
->GetMessText();
2250 sal_Int16
VCLXMessageBox::execute() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2252 SolarMutexGuard aGuard
;
2254 MessBox
* pBox
= static_cast<MessBox
*>(GetWindow());
2255 return pBox
? pBox
->Execute() : 0;
2258 ::com::sun::star::awt::Size SAL_CALL
VCLXMessageBox::getMinimumSize() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2260 SolarMutexGuard aGuard
;
2261 return ::com::sun::star::awt::Size( 250, 100 );
2267 void VCLXDialog::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
2269 VCLXTopWindow::ImplGetPropertyIds( rIds
);
2272 VCLXDialog::VCLXDialog()
2274 OSL_TRACE("XDialog created");
2277 VCLXDialog::~VCLXDialog()
2279 OSL_TRACE ("%s", __FUNCTION__
);
2282 // ::com::sun::star::uno::XInterface
2283 ::com::sun::star::uno::Any
VCLXDialog::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2285 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
2286 (static_cast< ::com::sun::star::awt::XDialog2
* >(this)),
2287 (static_cast< ::com::sun::star::awt::XDialog
* >(this)) );
2288 return (aRet
.hasValue() ? aRet
: VCLXTopWindow::queryInterface( rType
));
2291 // ::com::sun::star::lang::XTypeProvider
2292 IMPL_XTYPEPROVIDER_START( VCLXDialog
)
2293 cppu::UnoType
<com::sun::star::awt::XDialog2
>::get(),
2294 cppu::UnoType
<com::sun::star::awt::XDialog
>::get(),
2295 VCLXTopWindow::getTypes()
2296 IMPL_XTYPEPROVIDER_END
2298 void SAL_CALL
VCLXDialog::endDialog( ::sal_Int32 i_result
) throw (RuntimeException
, std::exception
)
2300 SolarMutexGuard aGuard
;
2302 Dialog
* pDialog
= dynamic_cast< Dialog
* >( GetWindow() );
2304 pDialog
->EndDialog( i_result
);
2307 void SAL_CALL
VCLXDialog::setHelpId( const OUString
& rId
) throw (RuntimeException
, std::exception
)
2309 SolarMutexGuard aGuard
;
2311 vcl::Window
* pWindow
= GetWindow();
2313 pWindow
->SetHelpId( OUStringToOString( rId
, RTL_TEXTENCODING_UTF8
) );
2316 void VCLXDialog::setTitle( const OUString
& Title
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2318 SolarMutexGuard aGuard
;
2320 vcl::Window
* pWindow
= GetWindow();
2322 pWindow
->SetText( Title
);
2325 OUString
VCLXDialog::getTitle() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2327 SolarMutexGuard aGuard
;
2330 vcl::Window
* pWindow
= GetWindow();
2332 aTitle
= pWindow
->GetText();
2336 sal_Int16
VCLXDialog::execute() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2338 SolarMutexGuard aGuard
;
2343 Dialog
* pDlg
= static_cast<Dialog
*>(GetWindow());
2344 vcl::Window
* pParent
= pDlg
->GetWindow( WINDOW_PARENTOVERLAP
);
2345 vcl::Window
* pOldParent
= NULL
;
2346 vcl::Window
* pSetParent
= NULL
;
2347 if ( pParent
&& !pParent
->IsReallyVisible() )
2349 pOldParent
= pDlg
->GetParent();
2350 vcl::Window
* pFrame
= pDlg
->GetWindow( WINDOW_FRAME
);
2351 if( pFrame
!= pDlg
)
2353 pDlg
->SetParent( pFrame
);
2354 pSetParent
= pFrame
;
2358 nRet
= pDlg
->Execute();
2360 // set the parent back only in case no new parent was set from outside
2361 // in other words, revert only own changes
2362 if ( pOldParent
&& pDlg
->GetParent() == pSetParent
)
2363 pDlg
->SetParent( pOldParent
);
2368 void VCLXDialog::endExecute() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2373 void SAL_CALL
VCLXDialog::draw( sal_Int32 nX
, sal_Int32 nY
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2375 SolarMutexGuard aGuard
;
2376 vcl::Window
* pWindow
= GetWindow();
2380 OutputDevice
* pDev
= VCLUnoHelper::GetOutputDevice( getGraphics() );
2382 pDev
= pWindow
->GetParent();
2384 Size aSize
= pDev
->PixelToLogic( pWindow
->GetSizePixel() );
2385 Point aPos
= pDev
->PixelToLogic( Point( nX
, nY
) );
2387 pWindow
->Draw( pDev
, aPos
, aSize
, WINDOW_DRAW_NOCONTROLS
);
2391 ::com::sun::star::awt::DeviceInfo
VCLXDialog::getInfo() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2393 ::com::sun::star::awt::DeviceInfo aInfo
= VCLXDevice::getInfo();
2395 SolarMutexGuard aGuard
;
2396 Dialog
* pDlg
= static_cast<Dialog
*>(GetWindow());
2398 pDlg
->GetDrawWindowBorder( aInfo
.LeftInset
, aInfo
.TopInset
, aInfo
.RightInset
, aInfo
.BottomInset
);
2403 void SAL_CALL
VCLXDialog::setProperty(
2404 const OUString
& PropertyName
,
2405 const ::com::sun::star::uno::Any
& Value
)
2406 throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2408 SolarMutexGuard aGuard
;
2410 Dialog
* pDialog
= static_cast<Dialog
*>(GetWindow());
2413 bool bVoid
= Value
.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID
;
2415 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
2416 switch ( nPropType
)
2418 case BASEPROPERTY_GRAPHIC
:
2420 Reference
< XGraphic
> xGraphic
;
2421 if (( Value
>>= xGraphic
) && xGraphic
.is() )
2423 Image
aImage( xGraphic
);
2425 Wallpaper
aWallpaper( aImage
.GetBitmapEx());
2426 aWallpaper
.SetStyle( WALLPAPER_SCALE
);
2427 pDialog
->SetBackground( aWallpaper
);
2429 else if ( bVoid
|| !xGraphic
.is() )
2431 Color aColor
= pDialog
->GetControlBackground().GetColor();
2432 if ( aColor
== COL_AUTO
)
2433 aColor
= pDialog
->GetSettings().GetStyleSettings().GetDialogColor();
2435 Wallpaper
aWallpaper( aColor
);
2436 pDialog
->SetBackground( aWallpaper
);
2443 VCLXContainer::setProperty( PropertyName
, Value
);
2451 // class VCLXTabPage
2453 VCLXMultiPage::VCLXMultiPage() : maTabListeners( *this ), mTabId( 1 )
2455 OSL_TRACE("VCLXMultiPage::VCLXMultiPage()" );
2458 void VCLXMultiPage::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
2460 PushPropertyIds( rIds
,
2461 BASEPROPERTY_BACKGROUNDCOLOR
,
2462 BASEPROPERTY_DEFAULTCONTROL
,
2463 BASEPROPERTY_ENABLED
,
2464 BASEPROPERTY_MULTIPAGEVALUE
,
2465 BASEPROPERTY_ENABLEVISIBLE
,
2466 BASEPROPERTY_FONTDESCRIPTOR
,
2467 BASEPROPERTY_GRAPHIC
,
2468 BASEPROPERTY_HELPTEXT
,
2469 BASEPROPERTY_HELPURL
,
2470 BASEPROPERTY_IMAGEALIGN
,
2471 BASEPROPERTY_IMAGEPOSITION
,
2472 BASEPROPERTY_IMAGEURL
,
2473 BASEPROPERTY_PRINTABLE
,
2474 BASEPROPERTY_TABSTOP
,
2475 BASEPROPERTY_FOCUSONCLICK
,
2477 VCLXContainer::ImplGetPropertyIds( rIds
);
2480 VCLXMultiPage::~VCLXMultiPage()
2483 void SAL_CALL
VCLXMultiPage::dispose() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2485 SolarMutexGuard aGuard
;
2487 ::com::sun::star::lang::EventObject aObj
;
2488 aObj
.Source
= (::cppu::OWeakObject
*)this;
2489 maTabListeners
.disposeAndClear( aObj
);
2490 VCLXContainer::dispose();
2492 ::com::sun::star::uno::Any SAL_CALL
VCLXMultiPage::queryInterface(const ::com::sun::star::uno::Type
& rType
)
2493 throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2495 uno::Any aRet
= ::cppu::queryInterface( rType
, static_cast< awt::XSimpleTabController
*>( this ) );
2497 return ( aRet
.hasValue() ? aRet
: VCLXContainer::queryInterface( rType
) );
2500 // ::com::sun::star::lang::XTypeProvider
2501 IMPL_XTYPEPROVIDER_START( VCLXMultiPage
)
2502 VCLXContainer::getTypes()
2503 IMPL_XTYPEPROVIDER_END
2505 // ::com::sun::star::awt::XView
2506 void SAL_CALL
VCLXMultiPage::draw( sal_Int32 nX
, sal_Int32 nY
)
2507 throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2509 SolarMutexGuard aGuard
;
2510 vcl::Window
* pWindow
= GetWindow();
2514 OutputDevice
* pDev
= VCLUnoHelper::GetOutputDevice( getGraphics() );
2516 pDev
= pWindow
->GetParent();
2518 Size aSize
= pDev
->PixelToLogic( pWindow
->GetSizePixel() );
2519 Point aPos
= pDev
->PixelToLogic( Point( nX
, nY
) );
2521 pWindow
->Draw( pDev
, aPos
, aSize
, WINDOW_DRAW_NOCONTROLS
);
2525 // ::com::sun::star::awt::XDevice,
2526 ::com::sun::star::awt::DeviceInfo SAL_CALL
VCLXMultiPage::getInfo()
2527 throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2529 ::com::sun::star::awt::DeviceInfo aInfo
= VCLXDevice::getInfo();
2533 uno::Any SAL_CALL
VCLXMultiPage::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2535 SolarMutexGuard aGuard
;
2536 OSL_TRACE(" **** VCLXMultiPage::getProperty( %s )",
2537 OUStringToOString( PropertyName
,
2538 RTL_TEXTENCODING_UTF8
).getStr() );
2539 ::com::sun::star::uno::Any aProp
;
2540 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
2541 switch ( nPropType
)
2544 case BASEPROPERTY_MULTIPAGEVALUE
:
2546 aProp
<<= getActiveTabID();
2550 aProp
<<= VCLXContainer::getProperty( PropertyName
);
2555 void SAL_CALL
VCLXMultiPage::setProperty(
2556 const OUString
& PropertyName
,
2557 const ::com::sun::star::uno::Any
& Value
)
2558 throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2560 SolarMutexGuard aGuard
;
2561 OSL_TRACE(" **** VCLXMultiPage::setProperty( %s )", OUStringToOString( PropertyName
, RTL_TEXTENCODING_UTF8
).getStr() );
2563 TabControl
* pTabControl
= static_cast<TabControl
*>(GetWindow());
2566 bool bVoid
= Value
.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID
;
2568 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
2569 switch ( nPropType
)
2571 case BASEPROPERTY_MULTIPAGEVALUE
:
2573 OSL_TRACE("***MULTIPAGE VALUE");
2576 // when the multipage is created we attempt to set the activepage
2577 // but no pages created
2578 if ( nId
&& nId
<= getWindows().getLength() )
2582 case BASEPROPERTY_GRAPHIC
:
2584 Reference
< XGraphic
> xGraphic
;
2585 if (( Value
>>= xGraphic
) && xGraphic
.is() )
2587 Image
aImage( xGraphic
);
2589 Wallpaper
aWallpaper( aImage
.GetBitmapEx());
2590 aWallpaper
.SetStyle( WALLPAPER_SCALE
);
2591 pTabControl
->SetBackground( aWallpaper
);
2593 else if ( bVoid
|| !xGraphic
.is() )
2595 Color aColor
= pTabControl
->GetControlBackground().GetColor();
2596 if ( aColor
== COL_AUTO
)
2597 aColor
= pTabControl
->GetSettings().GetStyleSettings().GetDialogColor();
2599 Wallpaper
aWallpaper( aColor
);
2600 pTabControl
->SetBackground( aWallpaper
);
2607 VCLXContainer::setProperty( PropertyName
, Value
);
2613 TabControl
*VCLXMultiPage::getTabControl() const throw (uno::RuntimeException
)
2615 TabControl
*pTabControl
= dynamic_cast< TabControl
* >( GetWindow() );
2618 throw uno::RuntimeException();
2620 sal_Int32 SAL_CALL
VCLXMultiPage::insertTab() throw (uno::RuntimeException
, std::exception
)
2622 TabControl
*pTabControl
= getTabControl();
2623 TabPage
* pTab
= new TabPage( pTabControl
);
2624 OUString
title ("");
2625 return static_cast< sal_Int32
>( insertTab( pTab
, title
) );
2628 sal_uInt16
VCLXMultiPage::insertTab( TabPage
* pPage
, OUString
& sTitle
)
2630 TabControl
*pTabControl
= getTabControl();
2631 sal_uInt16 id
= sal::static_int_cast
< sal_uInt16
>( mTabId
++ );
2632 pTabControl
->InsertPage( id
, sTitle
, TAB_APPEND
);
2633 pTabControl
->SetTabPage( id
, pPage
);
2637 void SAL_CALL
VCLXMultiPage::removeTab( sal_Int32 ID
) throw (uno::RuntimeException
, lang::IndexOutOfBoundsException
, std::exception
)
2639 TabControl
*pTabControl
= getTabControl();
2640 if ( pTabControl
->GetTabPage( sal::static_int_cast
< sal_uInt16
>( ID
) ) == NULL
)
2641 throw lang::IndexOutOfBoundsException();
2642 pTabControl
->RemovePage( sal::static_int_cast
< sal_uInt16
>( ID
) );
2645 void SAL_CALL
VCLXMultiPage::activateTab( sal_Int32 ID
) throw (uno::RuntimeException
, lang::IndexOutOfBoundsException
, std::exception
)
2647 TabControl
*pTabControl
= getTabControl();
2648 OSL_TRACE("Attempting to activate tab %d, active tab is %d, numtabs is %d", ID
, getActiveTabID(), getWindows().getLength() );
2649 if ( pTabControl
->GetTabPage( sal::static_int_cast
< sal_uInt16
>( ID
) ) == NULL
)
2650 throw lang::IndexOutOfBoundsException();
2651 pTabControl
->SelectTabPage( sal::static_int_cast
< sal_uInt16
>( ID
) );
2654 sal_Int32 SAL_CALL
VCLXMultiPage::getActiveTabID() throw (uno::RuntimeException
, std::exception
)
2656 return getTabControl()->GetCurPageId( );
2659 void SAL_CALL
VCLXMultiPage::addTabListener( const uno::Reference
< awt::XTabListener
>& xListener
) throw (uno::RuntimeException
, std::exception
)
2661 SolarMutexGuard aGuard
;
2662 maTabListeners
.addInterface( xListener
);
2665 void SAL_CALL
VCLXMultiPage::removeTabListener( const uno::Reference
< awt::XTabListener
>& xListener
) throw (uno::RuntimeException
, std::exception
)
2667 SolarMutexGuard aGuard
;
2668 maTabListeners
.addInterface( xListener
);
2671 void SAL_CALL
VCLXMultiPage::setTabProps( sal_Int32 ID
, const uno::Sequence
< beans::NamedValue
>& Properties
) throw (uno::RuntimeException
, lang::IndexOutOfBoundsException
, std::exception
)
2673 SolarMutexGuard aGuard
;
2674 TabControl
*pTabControl
= getTabControl();
2675 if ( pTabControl
->GetTabPage( sal::static_int_cast
< sal_uInt16
>( ID
) ) == NULL
)
2676 throw lang::IndexOutOfBoundsException();
2678 for (sal_Int32 i
= 0; i
< Properties
.getLength(); ++i
)
2680 const OUString
&name
= Properties
[i
].Name
;
2681 const uno::Any
&value
= Properties
[i
].Value
;
2683 if (name
== "Title")
2685 OUString title
= value
.get
<OUString
>();
2686 pTabControl
->SetPageText( sal::static_int_cast
< sal_uInt16
>( ID
), title
);
2691 uno::Sequence
< beans::NamedValue
> SAL_CALL
VCLXMultiPage::getTabProps( sal_Int32 ID
)
2692 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
, std::exception
)
2694 SolarMutexGuard aGuard
;
2695 TabControl
*pTabControl
= getTabControl();
2696 if ( pTabControl
->GetTabPage( sal::static_int_cast
< sal_uInt16
>( ID
) ) == NULL
)
2697 throw lang::IndexOutOfBoundsException();
2699 #define ADD_PROP( seq, i, name, val ) { \
2700 beans::NamedValue value; \
2701 value.Name = OUString( name ); \
2702 value.Value = uno::makeAny( val ); \
2706 uno::Sequence
< beans::NamedValue
> props( 2 );
2707 ADD_PROP( props
, 0, "Title", OUString( pTabControl
->GetPageText( sal::static_int_cast
< sal_uInt16
>( ID
) ) ) );
2708 ADD_PROP( props
, 1, "Position", pTabControl
->GetPagePos( sal::static_int_cast
< sal_uInt16
>( ID
) ) );
2712 void VCLXMultiPage::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
2714 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xKeepAlive( this );
2715 switch ( rVclWindowEvent
.GetId() )
2717 case VCLEVENT_TABPAGE_DEACTIVATE
:
2719 sal_uLong nPageID
= reinterpret_cast<sal_uLong
>( rVclWindowEvent
.GetData() );
2720 maTabListeners
.deactivated( nPageID
);
2724 case VCLEVENT_TABPAGE_ACTIVATE
:
2726 sal_uLong nPageID
= reinterpret_cast<sal_uLong
>( rVclWindowEvent
.GetData() );
2727 maTabListeners
.activated( nPageID
);
2731 VCLXContainer::ProcessWindowEvent( rVclWindowEvent
);
2737 // class VCLXTabPage
2739 VCLXTabPage::VCLXTabPage()
2743 void VCLXTabPage::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
2745 PushPropertyIds( rIds
,
2746 BASEPROPERTY_BACKGROUNDCOLOR
,
2747 BASEPROPERTY_DEFAULTCONTROL
,
2748 BASEPROPERTY_ENABLED
,
2749 BASEPROPERTY_ENABLEVISIBLE
,
2750 BASEPROPERTY_FONTDESCRIPTOR
,
2751 BASEPROPERTY_GRAPHIC
,
2752 BASEPROPERTY_HELPTEXT
,
2753 BASEPROPERTY_HELPURL
,
2754 BASEPROPERTY_IMAGEALIGN
,
2755 BASEPROPERTY_IMAGEPOSITION
,
2756 BASEPROPERTY_IMAGEURL
,
2757 BASEPROPERTY_PRINTABLE
,
2758 BASEPROPERTY_TABSTOP
,
2759 BASEPROPERTY_FOCUSONCLICK
,
2761 VCLXContainer::ImplGetPropertyIds( rIds
);
2764 VCLXTabPage::~VCLXTabPage()
2768 ::com::sun::star::uno::Any SAL_CALL
VCLXTabPage::queryInterface(const ::com::sun::star::uno::Type
& rType
)
2769 throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2771 return VCLXContainer::queryInterface( rType
);
2774 // ::com::sun::star::lang::XTypeProvider
2775 IMPL_XTYPEPROVIDER_START( VCLXTabPage
)
2776 VCLXContainer::getTypes()
2777 IMPL_XTYPEPROVIDER_END
2779 // ::com::sun::star::awt::XView
2780 void SAL_CALL
VCLXTabPage::draw( sal_Int32 nX
, sal_Int32 nY
)
2781 throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2783 SolarMutexGuard aGuard
;
2784 vcl::Window
* pWindow
= GetWindow();
2788 OutputDevice
* pDev
= VCLUnoHelper::GetOutputDevice( getGraphics() );
2790 pDev
= pWindow
->GetParent();
2792 Size aSize
= pDev
->PixelToLogic( pWindow
->GetSizePixel() );
2793 Point aPos
= pDev
->PixelToLogic( Point( nX
, nY
) );
2795 pWindow
->Draw( pDev
, aPos
, aSize
, WINDOW_DRAW_NOCONTROLS
);
2799 // ::com::sun::star::awt::XDevice,
2800 ::com::sun::star::awt::DeviceInfo SAL_CALL
VCLXTabPage::getInfo()
2801 throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2803 ::com::sun::star::awt::DeviceInfo aInfo
= VCLXDevice::getInfo();
2807 void SAL_CALL
VCLXTabPage::setProperty(
2808 const OUString
& PropertyName
,
2809 const ::com::sun::star::uno::Any
& Value
)
2810 throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2812 SolarMutexGuard aGuard
;
2814 TabPage
* pTabPage
= static_cast<TabPage
*>(GetWindow());
2817 bool bVoid
= Value
.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID
;
2819 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
2820 switch ( nPropType
)
2822 case BASEPROPERTY_GRAPHIC
:
2824 Reference
< XGraphic
> xGraphic
;
2825 if (( Value
>>= xGraphic
) && xGraphic
.is() )
2827 Image
aImage( xGraphic
);
2829 Wallpaper
aWallpaper( aImage
.GetBitmapEx());
2830 aWallpaper
.SetStyle( WALLPAPER_SCALE
);
2831 pTabPage
->SetBackground( aWallpaper
);
2833 else if ( bVoid
|| !xGraphic
.is() )
2835 Color aColor
= pTabPage
->GetControlBackground().GetColor();
2836 if ( aColor
== COL_AUTO
)
2837 aColor
= pTabPage
->GetSettings().GetStyleSettings().GetDialogColor();
2839 Wallpaper
aWallpaper( aColor
);
2840 pTabPage
->SetBackground( aWallpaper
);
2844 case BASEPROPERTY_TITLE
:
2847 if ( Value
>>= sTitle
)
2849 pTabPage
->SetText(sTitle
);
2856 VCLXContainer::setProperty( PropertyName
, Value
);
2862 TabPage
*VCLXTabPage::getTabPage() const throw (uno::RuntimeException
)
2864 TabPage
*pTabPage
= dynamic_cast< TabPage
* >( GetWindow() );
2867 throw uno::RuntimeException();
2871 // class VCLXFixedHyperlink
2874 VCLXFixedHyperlink::VCLXFixedHyperlink() :
2876 maActionListeners( *this )
2881 VCLXFixedHyperlink::~VCLXFixedHyperlink()
2885 // ::com::sun::star::uno::XInterface
2886 ::com::sun::star::uno::Any
VCLXFixedHyperlink::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2888 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
2889 (static_cast< ::com::sun::star::awt::XFixedHyperlink
* >(this)) );
2890 return (aRet
.hasValue() ? aRet
: VCLXWindow::queryInterface( rType
));
2893 void VCLXFixedHyperlink::dispose() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2895 SolarMutexGuard aGuard
;
2897 ::com::sun::star::lang::EventObject aObj
;
2898 aObj
.Source
= (::cppu::OWeakObject
*)this;
2899 maActionListeners
.disposeAndClear( aObj
);
2900 VCLXWindow::dispose();
2903 // ::com::sun::star::lang::XTypeProvider
2904 IMPL_XTYPEPROVIDER_START( VCLXFixedHyperlink
)
2905 cppu::UnoType
<com::sun::star::awt::XFixedHyperlink
>::get(),
2906 VCLXWindow::getTypes()
2907 IMPL_XTYPEPROVIDER_END
2909 void VCLXFixedHyperlink::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
2911 switch ( rVclWindowEvent
.GetId() )
2913 case VCLEVENT_BUTTON_CLICK
:
2915 if ( maActionListeners
.getLength() )
2917 ::com::sun::star::awt::ActionEvent aEvent
;
2918 aEvent
.Source
= (::cppu::OWeakObject
*)this;
2919 maActionListeners
.actionPerformed( aEvent
);
2925 FixedHyperlink
* pBase
= static_cast<FixedHyperlink
*>(GetWindow());
2927 sURL
= pBase
->GetURL();
2928 Reference
< ::com::sun::star::system::XSystemShellExecute
> xSystemShellExecute( ::com::sun::star::system::SystemShellExecute::create(
2929 ::comphelper::getProcessComponentContext() ) );
2930 if ( !sURL
.isEmpty() )
2935 xSystemShellExecute
->execute(
2936 sURL
, OUString(), ::com::sun::star::system::SystemShellExecuteFlags::URIS_ONLY
);
2938 catch( uno::Exception
& )
2946 VCLXWindow::ProcessWindowEvent( rVclWindowEvent
);
2951 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> VCLXFixedHyperlink::CreateAccessibleContext()
2953 return getAccessibleFactory().createAccessibleContext( this );
2956 void VCLXFixedHyperlink::setText( const OUString
& Text
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2958 SolarMutexGuard aGuard
;
2960 FixedHyperlink
* pBase
= static_cast<FixedHyperlink
*>(GetWindow());
2962 pBase
->SetText(Text
);
2965 OUString
VCLXFixedHyperlink::getText() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2967 SolarMutexGuard aGuard
;
2970 vcl::Window
* pWindow
= GetWindow();
2972 aText
= pWindow
->GetText();
2976 void VCLXFixedHyperlink::setURL( const OUString
& URL
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2978 SolarMutexGuard aGuard
;
2980 FixedHyperlink
* pBase
= static_cast<FixedHyperlink
*>(GetWindow());
2982 pBase
->SetURL( URL
);
2985 OUString
VCLXFixedHyperlink::getURL( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2987 SolarMutexGuard aGuard
;
2990 FixedHyperlink
* pBase
= static_cast<FixedHyperlink
*>(GetWindow());
2992 aText
= pBase
->GetURL();
2996 void VCLXFixedHyperlink::setAlignment( short nAlign
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2998 SolarMutexGuard aGuard
;
3000 vcl::Window
* pWindow
= GetWindow();
3003 WinBits nNewBits
= 0;
3004 if ( nAlign
== ::com::sun::star::awt::TextAlign::LEFT
)
3006 else if ( nAlign
== ::com::sun::star::awt::TextAlign::CENTER
)
3007 nNewBits
= WB_CENTER
;
3009 nNewBits
= WB_RIGHT
;
3011 WinBits nStyle
= pWindow
->GetStyle();
3012 nStyle
&= ~(WB_LEFT
|WB_CENTER
|WB_RIGHT
);
3013 pWindow
->SetStyle( nStyle
| nNewBits
);
3017 short VCLXFixedHyperlink::getAlignment() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3019 SolarMutexGuard aGuard
;
3022 vcl::Window
* pWindow
= GetWindow();
3025 WinBits nStyle
= pWindow
->GetStyle();
3026 if ( nStyle
& WB_LEFT
)
3027 nAlign
= ::com::sun::star::awt::TextAlign::LEFT
;
3028 else if ( nStyle
& WB_CENTER
)
3029 nAlign
= ::com::sun::star::awt::TextAlign::CENTER
;
3031 nAlign
= ::com::sun::star::awt::TextAlign::RIGHT
;
3036 void VCLXFixedHyperlink::addActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
> & l
)throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3038 SolarMutexGuard aGuard
;
3039 maActionListeners
.addInterface( l
);
3042 void VCLXFixedHyperlink::removeActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
> & l
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3044 SolarMutexGuard aGuard
;
3045 maActionListeners
.removeInterface( l
);
3048 ::com::sun::star::awt::Size
VCLXFixedHyperlink::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3050 SolarMutexGuard aGuard
;
3053 FixedText
* pFixedText
= static_cast<FixedText
*>(GetWindow());
3055 aSz
= pFixedText
->CalcMinimumSize();
3056 return AWTSize(aSz
);
3059 ::com::sun::star::awt::Size
VCLXFixedHyperlink::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3061 return getMinimumSize();
3064 ::com::sun::star::awt::Size
VCLXFixedHyperlink::calcAdjustedSize( const ::com::sun::star::awt::Size
& rNewSize
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3066 SolarMutexGuard aGuard
;
3068 ::com::sun::star::awt::Size aSz
= rNewSize
;
3069 ::com::sun::star::awt::Size aMinSz
= getMinimumSize();
3070 if ( aSz
.Height
!= aMinSz
.Height
)
3071 aSz
.Height
= aMinSz
.Height
;
3076 void VCLXFixedHyperlink::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3078 SolarMutexGuard aGuard
;
3080 FixedHyperlink
* pBase
= static_cast<FixedHyperlink
*>(GetWindow());
3083 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
3084 switch ( nPropType
)
3086 case BASEPROPERTY_LABEL
:
3089 if ( Value
>>= sNewLabel
)
3090 pBase
->SetText(sNewLabel
);
3094 case BASEPROPERTY_URL
:
3097 if ( Value
>>= sNewURL
)
3098 pBase
->SetURL( sNewURL
);
3104 VCLXWindow::setProperty( PropertyName
, Value
);
3110 ::com::sun::star::uno::Any
VCLXFixedHyperlink::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3112 SolarMutexGuard aGuard
;
3114 ::com::sun::star::uno::Any aProp
;
3115 FixedHyperlink
* pBase
= static_cast<FixedHyperlink
*>(GetWindow());
3118 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
3119 switch ( nPropType
)
3121 case BASEPROPERTY_URL
:
3123 aProp
= makeAny( OUString( pBase
->GetURL() ) );
3129 aProp
<<= VCLXWindow::getProperty( PropertyName
);
3136 void VCLXFixedHyperlink::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
3138 PushPropertyIds( rIds
,
3140 BASEPROPERTY_BACKGROUNDCOLOR
,
3141 BASEPROPERTY_BORDER
,
3142 BASEPROPERTY_BORDERCOLOR
,
3143 BASEPROPERTY_DEFAULTCONTROL
,
3144 BASEPROPERTY_ENABLED
,
3145 BASEPROPERTY_ENABLEVISIBLE
,
3146 BASEPROPERTY_FONTDESCRIPTOR
,
3147 BASEPROPERTY_HELPTEXT
,
3148 BASEPROPERTY_HELPURL
,
3150 BASEPROPERTY_MULTILINE
,
3151 BASEPROPERTY_NOLABEL
,
3152 BASEPROPERTY_PRINTABLE
,
3153 BASEPROPERTY_TABSTOP
,
3154 BASEPROPERTY_VERTICALALIGN
,
3156 BASEPROPERTY_WRITING_MODE
,
3157 BASEPROPERTY_CONTEXT_WRITING_MODE
,
3159 VCLXWindow::ImplGetPropertyIds( rIds
);
3163 // class VCLXFixedText
3165 void VCLXFixedText::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
3167 PushPropertyIds( rIds
,
3169 BASEPROPERTY_BACKGROUNDCOLOR
,
3170 BASEPROPERTY_BORDER
,
3171 BASEPROPERTY_BORDERCOLOR
,
3172 BASEPROPERTY_DEFAULTCONTROL
,
3173 BASEPROPERTY_ENABLED
,
3174 BASEPROPERTY_ENABLEVISIBLE
,
3175 BASEPROPERTY_FONTDESCRIPTOR
,
3176 BASEPROPERTY_HELPTEXT
,
3177 BASEPROPERTY_HELPURL
,
3179 BASEPROPERTY_MULTILINE
,
3180 BASEPROPERTY_NOLABEL
,
3181 BASEPROPERTY_PRINTABLE
,
3182 BASEPROPERTY_TABSTOP
,
3183 BASEPROPERTY_VERTICALALIGN
,
3184 BASEPROPERTY_WRITING_MODE
,
3185 BASEPROPERTY_CONTEXT_WRITING_MODE
,
3186 BASEPROPERTY_REFERENCE_DEVICE
,
3188 VCLXWindow::ImplGetPropertyIds( rIds
);
3191 VCLXFixedText::VCLXFixedText()
3195 VCLXFixedText::~VCLXFixedText()
3199 // ::com::sun::star::uno::XInterface
3200 ::com::sun::star::uno::Any
VCLXFixedText::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3202 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
3203 (static_cast< ::com::sun::star::awt::XFixedText
* >(this)) );
3204 return (aRet
.hasValue() ? aRet
: VCLXWindow::queryInterface( rType
));
3207 // ::com::sun::star::lang::XTypeProvider
3208 IMPL_XTYPEPROVIDER_START( VCLXFixedText
)
3209 cppu::UnoType
<com::sun::star::awt::XFixedText
>::get(),
3210 VCLXWindow::getTypes()
3211 IMPL_XTYPEPROVIDER_END
3213 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> VCLXFixedText::CreateAccessibleContext()
3215 return getAccessibleFactory().createAccessibleContext( this );
3218 void VCLXFixedText::setText( const OUString
& Text
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3220 SolarMutexGuard aGuard
;
3222 vcl::Window
* pWindow
= GetWindow();
3224 pWindow
->SetText( Text
);
3227 OUString
VCLXFixedText::getText() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3229 SolarMutexGuard aGuard
;
3232 vcl::Window
* pWindow
= GetWindow();
3234 aText
= pWindow
->GetText();
3238 void VCLXFixedText::setAlignment( short nAlign
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3240 SolarMutexGuard aGuard
;
3242 vcl::Window
* pWindow
= GetWindow();
3245 WinBits nNewBits
= 0;
3246 if ( nAlign
== ::com::sun::star::awt::TextAlign::LEFT
)
3248 else if ( nAlign
== ::com::sun::star::awt::TextAlign::CENTER
)
3249 nNewBits
= WB_CENTER
;
3251 nNewBits
= WB_RIGHT
;
3253 WinBits nStyle
= pWindow
->GetStyle();
3254 nStyle
&= ~(WB_LEFT
|WB_CENTER
|WB_RIGHT
);
3255 pWindow
->SetStyle( nStyle
| nNewBits
);
3259 short VCLXFixedText::getAlignment() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3261 SolarMutexGuard aGuard
;
3264 vcl::Window
* pWindow
= GetWindow();
3267 WinBits nStyle
= pWindow
->GetStyle();
3268 if ( nStyle
& WB_LEFT
)
3269 nAlign
= ::com::sun::star::awt::TextAlign::LEFT
;
3270 else if ( nStyle
& WB_CENTER
)
3271 nAlign
= ::com::sun::star::awt::TextAlign::CENTER
;
3273 nAlign
= ::com::sun::star::awt::TextAlign::RIGHT
;
3278 ::com::sun::star::awt::Size
VCLXFixedText::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3280 SolarMutexGuard aGuard
;
3283 FixedText
* pFixedText
= static_cast<FixedText
*>(GetWindow());
3285 aSz
= pFixedText
->CalcMinimumSize();
3286 return AWTSize(aSz
);
3289 ::com::sun::star::awt::Size
VCLXFixedText::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3291 return getMinimumSize();
3294 ::com::sun::star::awt::Size
VCLXFixedText::calcAdjustedSize( const ::com::sun::star::awt::Size
& rMaxSize
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3296 SolarMutexGuard aGuard
;
3298 Size
aAdjustedSize( VCLUnoHelper::ConvertToVCLSize( rMaxSize
) );
3299 FixedText
* pFixedText
= static_cast<FixedText
*>(GetWindow());
3301 aAdjustedSize
= pFixedText
->CalcMinimumSize( rMaxSize
.Width
);
3302 return VCLUnoHelper::ConvertToAWTSize( aAdjustedSize
);
3306 // class VCLXScrollBar
3308 void VCLXScrollBar::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
3310 PushPropertyIds( rIds
,
3311 BASEPROPERTY_BACKGROUNDCOLOR
,
3312 BASEPROPERTY_BLOCKINCREMENT
,
3313 BASEPROPERTY_BORDER
,
3314 BASEPROPERTY_BORDERCOLOR
,
3315 BASEPROPERTY_DEFAULTCONTROL
,
3316 BASEPROPERTY_ENABLED
,
3317 BASEPROPERTY_ENABLEVISIBLE
,
3318 BASEPROPERTY_HELPTEXT
,
3319 BASEPROPERTY_HELPURL
,
3320 BASEPROPERTY_LINEINCREMENT
,
3321 BASEPROPERTY_LIVE_SCROLL
,
3322 BASEPROPERTY_ORIENTATION
,
3323 BASEPROPERTY_PRINTABLE
,
3324 BASEPROPERTY_REPEAT_DELAY
,
3325 BASEPROPERTY_SCROLLVALUE
,
3326 BASEPROPERTY_SCROLLVALUE_MAX
,
3327 BASEPROPERTY_SCROLLVALUE_MIN
,
3328 BASEPROPERTY_SYMBOL_COLOR
,
3329 BASEPROPERTY_TABSTOP
,
3330 BASEPROPERTY_VISIBLESIZE
,
3331 BASEPROPERTY_WRITING_MODE
,
3332 BASEPROPERTY_CONTEXT_WRITING_MODE
,
3334 VCLXWindow::ImplGetPropertyIds( rIds
);
3337 VCLXScrollBar::VCLXScrollBar() : maAdjustmentListeners( *this )
3341 // ::com::sun::star::uno::XInterface
3342 ::com::sun::star::uno::Any
VCLXScrollBar::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3344 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
3345 (static_cast< ::com::sun::star::awt::XScrollBar
* >(this)) );
3346 return (aRet
.hasValue() ? aRet
: VCLXWindow::queryInterface( rType
));
3349 // ::com::sun::star::lang::XTypeProvider
3350 IMPL_XTYPEPROVIDER_START( VCLXScrollBar
)
3351 cppu::UnoType
<com::sun::star::awt::XScrollBar
>::get(),
3352 VCLXWindow::getTypes()
3353 IMPL_XTYPEPROVIDER_END
3355 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> VCLXScrollBar::CreateAccessibleContext()
3357 return getAccessibleFactory().createAccessibleContext( this );
3360 // ::com::sun::star::lang::XComponent
3361 void VCLXScrollBar::dispose() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3363 SolarMutexGuard aGuard
;
3365 ::com::sun::star::lang::EventObject aObj
;
3366 aObj
.Source
= (::cppu::OWeakObject
*)this;
3367 maAdjustmentListeners
.disposeAndClear( aObj
);
3368 VCLXWindow::dispose();
3371 // ::com::sun::star::awt::XScrollbar
3372 void VCLXScrollBar::addAdjustmentListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XAdjustmentListener
> & l
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3374 SolarMutexGuard aGuard
;
3375 maAdjustmentListeners
.addInterface( l
);
3378 void VCLXScrollBar::removeAdjustmentListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XAdjustmentListener
> & l
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3380 SolarMutexGuard aGuard
;
3381 maAdjustmentListeners
.removeInterface( l
);
3384 void VCLXScrollBar::setValue( sal_Int32 n
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3386 SolarMutexGuard aGuard
;
3388 ScrollBar
* pScrollBar
= static_cast<ScrollBar
*>(GetWindow());
3390 pScrollBar
->DoScroll( n
);
3393 void VCLXScrollBar::setValues( sal_Int32 nValue
, sal_Int32 nVisible
, sal_Int32 nMax
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3395 SolarMutexGuard aGuard
;
3397 ScrollBar
* pScrollBar
= static_cast<ScrollBar
*>(GetWindow());
3400 pScrollBar
->SetVisibleSize( nVisible
);
3401 pScrollBar
->SetRangeMax( nMax
);
3402 pScrollBar
->DoScroll( nValue
);
3406 sal_Int32
VCLXScrollBar::getValue() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3408 SolarMutexGuard aGuard
;
3410 ScrollBar
* pScrollBar
= static_cast<ScrollBar
*>(GetWindow());
3411 return pScrollBar
? pScrollBar
->GetThumbPos() : 0;
3414 void VCLXScrollBar::setMaximum( sal_Int32 n
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3416 SolarMutexGuard aGuard
;
3418 ScrollBar
* pScrollBar
= static_cast<ScrollBar
*>(GetWindow());
3420 pScrollBar
->SetRangeMax( n
);
3423 sal_Int32
VCLXScrollBar::getMaximum() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3425 SolarMutexGuard aGuard
;
3427 ScrollBar
* pScrollBar
= static_cast<ScrollBar
*>(GetWindow());
3428 return pScrollBar
? pScrollBar
->GetRangeMax() : 0;
3431 void VCLXScrollBar::setMinimum( sal_Int32 n
) throw(::com::sun::star::uno::RuntimeException
)
3433 SolarMutexGuard aGuard
;
3435 ScrollBar
* pScrollBar
= static_cast< ScrollBar
* >( GetWindow() );
3437 pScrollBar
->SetRangeMin( n
);
3440 sal_Int32
VCLXScrollBar::getMinimum() throw(::com::sun::star::uno::RuntimeException
)
3442 SolarMutexGuard aGuard
;
3444 ScrollBar
* pScrollBar
= static_cast< ScrollBar
* >( GetWindow() );
3445 return pScrollBar
? pScrollBar
->GetRangeMin() : 0;
3448 void VCLXScrollBar::setLineIncrement( sal_Int32 n
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3450 SolarMutexGuard aGuard
;
3452 ScrollBar
* pScrollBar
= static_cast<ScrollBar
*>(GetWindow());
3454 pScrollBar
->SetLineSize( n
);
3457 sal_Int32
VCLXScrollBar::getLineIncrement() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3459 SolarMutexGuard aGuard
;
3461 ScrollBar
* pScrollBar
= static_cast<ScrollBar
*>(GetWindow());
3462 return pScrollBar
? pScrollBar
->GetLineSize() : 0;
3465 void VCLXScrollBar::setBlockIncrement( sal_Int32 n
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3467 SolarMutexGuard aGuard
;
3469 ScrollBar
* pScrollBar
= static_cast<ScrollBar
*>(GetWindow());
3471 pScrollBar
->SetPageSize( n
);
3474 sal_Int32
VCLXScrollBar::getBlockIncrement() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3476 SolarMutexGuard aGuard
;
3478 ScrollBar
* pScrollBar
= static_cast<ScrollBar
*>(GetWindow());
3479 return pScrollBar
? pScrollBar
->GetPageSize() : 0;
3482 void VCLXScrollBar::setVisibleSize( sal_Int32 n
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3484 SolarMutexGuard aGuard
;
3486 ScrollBar
* pScrollBar
= static_cast<ScrollBar
*>(GetWindow());
3488 pScrollBar
->SetVisibleSize( n
);
3491 sal_Int32
VCLXScrollBar::getVisibleSize() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3493 SolarMutexGuard aGuard
;
3495 ScrollBar
* pScrollBar
= static_cast<ScrollBar
*>(GetWindow());
3496 return pScrollBar
? pScrollBar
->GetVisibleSize() : 0;
3499 void VCLXScrollBar::setOrientation( sal_Int32 n
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3501 SolarMutexGuard aGuard
;
3503 vcl::Window
* pWindow
= GetWindow();
3506 WinBits nStyle
= pWindow
->GetStyle();
3507 nStyle
&= ~(WB_HORZ
|WB_VERT
);
3508 if ( n
== ::com::sun::star::awt::ScrollBarOrientation::HORIZONTAL
)
3513 pWindow
->SetStyle( nStyle
);
3518 sal_Int32
VCLXScrollBar::getOrientation() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3520 SolarMutexGuard aGuard
;
3523 vcl::Window
* pWindow
= GetWindow();
3526 WinBits nStyle
= pWindow
->GetStyle();
3527 if ( nStyle
& WB_HORZ
)
3528 n
= ::com::sun::star::awt::ScrollBarOrientation::HORIZONTAL
;
3530 n
= ::com::sun::star::awt::ScrollBarOrientation::VERTICAL
;
3536 // ::com::sun::star::awt::VclWindowPeer
3537 void VCLXScrollBar::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3539 SolarMutexGuard aGuard
;
3541 ScrollBar
* pScrollBar
= static_cast<ScrollBar
*>(GetWindow());
3544 bool bVoid
= Value
.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID
;
3546 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
3547 switch ( nPropType
)
3549 case BASEPROPERTY_LIVE_SCROLL
:
3554 OSL_VERIFY( Value
>>= bDo
);
3556 AllSettings
aSettings( pScrollBar
->GetSettings() );
3557 StyleSettings
aStyle( aSettings
.GetStyleSettings() );
3558 sal_uLong nDragOptions
= aStyle
.GetDragFullOptions();
3560 nDragOptions
|= DRAGFULL_OPTION_SCROLL
;
3562 nDragOptions
&= ~DRAGFULL_OPTION_SCROLL
;
3563 aStyle
.SetDragFullOptions( nDragOptions
);
3564 aSettings
.SetStyleSettings( aStyle
);
3565 pScrollBar
->SetSettings( aSettings
);
3569 case BASEPROPERTY_SCROLLVALUE
:
3579 case BASEPROPERTY_SCROLLVALUE_MAX
:
3580 case BASEPROPERTY_SCROLLVALUE_MIN
:
3587 if ( nPropType
== BASEPROPERTY_SCROLLVALUE_MAX
)
3595 case BASEPROPERTY_LINEINCREMENT
:
3601 setLineIncrement( n
);
3605 case BASEPROPERTY_BLOCKINCREMENT
:
3611 setBlockIncrement( n
);
3615 case BASEPROPERTY_VISIBLESIZE
:
3621 setVisibleSize( n
);
3625 case BASEPROPERTY_ORIENTATION
:
3631 setOrientation( n
);
3636 case BASEPROPERTY_BACKGROUNDCOLOR
:
3638 // the default implementation of the base class doesn't work here, since our
3639 // interpretation for this property is slightly different
3640 ::toolkit::setButtonLikeFaceColor( pScrollBar
, Value
);
3646 VCLXWindow::setProperty( PropertyName
, Value
);
3652 ::com::sun::star::uno::Any
VCLXScrollBar::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3654 SolarMutexGuard aGuard
;
3656 ::com::sun::star::uno::Any aProp
;
3657 ScrollBar
* pScrollBar
= static_cast<ScrollBar
*>(GetWindow());
3660 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
3662 switch ( nPropType
)
3664 case BASEPROPERTY_LIVE_SCROLL
:
3666 aProp
<<= ( 0 != ( pScrollBar
->GetSettings().GetStyleSettings().GetDragFullOptions() & DRAGFULL_OPTION_SCROLL
) );
3669 case BASEPROPERTY_SCROLLVALUE
:
3671 aProp
<<= (sal_Int32
) getValue();
3674 case BASEPROPERTY_SCROLLVALUE_MAX
:
3676 aProp
<<= (sal_Int32
) getMaximum();
3679 case BASEPROPERTY_SCROLLVALUE_MIN
:
3681 aProp
<<= (sal_Int32
) getMinimum();
3684 case BASEPROPERTY_LINEINCREMENT
:
3686 aProp
<<= (sal_Int32
) getLineIncrement();
3689 case BASEPROPERTY_BLOCKINCREMENT
:
3691 aProp
<<= (sal_Int32
) getBlockIncrement();
3694 case BASEPROPERTY_VISIBLESIZE
:
3696 aProp
<<= (sal_Int32
) getVisibleSize();
3699 case BASEPROPERTY_ORIENTATION
:
3701 aProp
<<= (sal_Int32
) getOrientation();
3704 case BASEPROPERTY_BACKGROUNDCOLOR
:
3706 // the default implementation of the base class doesn't work here, since our
3707 // interpretation for this property is slightly different
3708 aProp
= ::toolkit::getButtonLikeFaceColor( pScrollBar
);
3714 aProp
<<= VCLXWindow::getProperty( PropertyName
);
3721 void VCLXScrollBar::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
3723 switch ( rVclWindowEvent
.GetId() )
3725 case VCLEVENT_SCROLLBAR_SCROLL
:
3727 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xKeepAlive( this );
3728 // since we call listeners below, there is a potential that we will be destroyed
3729 // in during the listener call. To prevent the resulting crashs, we keep us
3730 // alive as long as we're here
3732 if ( maAdjustmentListeners
.getLength() )
3734 ScrollBar
* pScrollBar
= static_cast<ScrollBar
*>(GetWindow());
3738 ::com::sun::star::awt::AdjustmentEvent aEvent
;
3739 aEvent
.Source
= (::cppu::OWeakObject
*)this;
3740 aEvent
.Value
= pScrollBar
->GetThumbPos();
3742 // set adjustment type
3743 ScrollType aType
= pScrollBar
->GetType();
3744 if ( aType
== SCROLL_LINEUP
|| aType
== SCROLL_LINEDOWN
)
3746 aEvent
.Type
= ::com::sun::star::awt::AdjustmentType_ADJUST_LINE
;
3748 else if ( aType
== SCROLL_PAGEUP
|| aType
== SCROLL_PAGEDOWN
)
3750 aEvent
.Type
= ::com::sun::star::awt::AdjustmentType_ADJUST_PAGE
;
3752 else if ( aType
== SCROLL_DRAG
)
3754 aEvent
.Type
= ::com::sun::star::awt::AdjustmentType_ADJUST_ABS
;
3757 maAdjustmentListeners
.adjustmentValueChanged( aEvent
);
3764 VCLXWindow::ProcessWindowEvent( rVclWindowEvent
);
3769 ::com::sun::star::awt::Size SAL_CALL
VCLXScrollBar::implGetMinimumSize( vcl::Window
* p
) throw(::com::sun::star::uno::RuntimeException
)
3771 long n
= p
->GetSettings().GetStyleSettings().GetScrollBarSize();
3772 return ::com::sun::star::awt::Size( n
, n
);
3775 ::com::sun::star::awt::Size SAL_CALL
VCLXScrollBar::getMinimumSize() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3777 SolarMutexGuard aGuard
;
3778 return implGetMinimumSize( GetWindow() );
3786 void VCLXEdit::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
3788 PushPropertyIds( rIds
,
3790 BASEPROPERTY_BACKGROUNDCOLOR
,
3791 BASEPROPERTY_BORDER
,
3792 BASEPROPERTY_BORDERCOLOR
,
3793 BASEPROPERTY_DEFAULTCONTROL
,
3794 BASEPROPERTY_ECHOCHAR
,
3795 BASEPROPERTY_ENABLED
,
3796 BASEPROPERTY_ENABLEVISIBLE
,
3797 BASEPROPERTY_FONTDESCRIPTOR
,
3798 BASEPROPERTY_HARDLINEBREAKS
,
3799 BASEPROPERTY_HELPTEXT
,
3800 BASEPROPERTY_HELPURL
,
3801 BASEPROPERTY_HSCROLL
,
3802 BASEPROPERTY_LINE_END_FORMAT
,
3803 BASEPROPERTY_MAXTEXTLEN
,
3804 BASEPROPERTY_MULTILINE
,
3805 BASEPROPERTY_PRINTABLE
,
3806 BASEPROPERTY_READONLY
,
3807 BASEPROPERTY_TABSTOP
,
3809 BASEPROPERTY_VSCROLL
,
3810 BASEPROPERTY_HIDEINACTIVESELECTION
,
3811 BASEPROPERTY_PAINTTRANSPARENT
,
3812 BASEPROPERTY_AUTOHSCROLL
,
3813 BASEPROPERTY_AUTOVSCROLL
,
3814 BASEPROPERTY_VERTICALALIGN
,
3815 BASEPROPERTY_WRITING_MODE
,
3816 BASEPROPERTY_CONTEXT_WRITING_MODE
,
3818 VCLXWindow::ImplGetPropertyIds( rIds
);
3821 VCLXEdit::VCLXEdit() : maTextListeners( *this )
3825 // ::com::sun::star::uno::XInterface
3826 ::com::sun::star::uno::Any
VCLXEdit::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3828 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
3829 (static_cast< ::com::sun::star::awt::XTextComponent
* >(this)),
3830 (static_cast< ::com::sun::star::awt::XTextEditField
* >(this)),
3831 (static_cast< ::com::sun::star::awt::XTextLayoutConstrains
* >(this)) );
3832 return (aRet
.hasValue() ? aRet
: VCLXWindow::queryInterface( rType
));
3835 // ::com::sun::star::lang::XTypeProvider
3836 IMPL_XTYPEPROVIDER_START( VCLXEdit
)
3837 cppu::UnoType
<com::sun::star::awt::XTextComponent
>::get(),
3838 cppu::UnoType
<com::sun::star::awt::XTextEditField
>::get(),
3839 cppu::UnoType
<com::sun::star::awt::XTextLayoutConstrains
>::get(),
3840 VCLXWindow::getTypes()
3841 IMPL_XTYPEPROVIDER_END
3843 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> VCLXEdit::CreateAccessibleContext()
3845 return getAccessibleFactory().createAccessibleContext( this );
3848 void VCLXEdit::dispose() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3850 SolarMutexGuard aGuard
;
3852 ::com::sun::star::lang::EventObject aObj
;
3853 aObj
.Source
= (::cppu::OWeakObject
*)this;
3854 maTextListeners
.disposeAndClear( aObj
);
3855 VCLXWindow::dispose();
3858 void VCLXEdit::addTextListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XTextListener
> & l
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3860 SolarMutexGuard aGuard
;
3861 GetTextListeners().addInterface( l
);
3864 void VCLXEdit::removeTextListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XTextListener
> & l
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3866 SolarMutexGuard aGuard
;
3867 GetTextListeners().removeInterface( l
);
3870 void VCLXEdit::setText( const OUString
& aText
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3872 SolarMutexGuard aGuard
;
3874 Edit
* pEdit
= static_cast<Edit
*>(GetWindow());
3877 pEdit
->SetText( aText
);
3879 // #107218# Call same listeners like VCL would do after user interaction
3880 SetSynthesizingVCLEvent( true );
3881 pEdit
->SetModifyFlag();
3883 SetSynthesizingVCLEvent( false );
3887 void VCLXEdit::insertText( const ::com::sun::star::awt::Selection
& rSel
, const OUString
& aText
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3889 SolarMutexGuard aGuard
;
3891 Edit
* pEdit
= static_cast<Edit
*>(GetWindow());
3894 pEdit
->SetSelection( Selection( rSel
.Min
, rSel
.Max
) );
3895 pEdit
->ReplaceSelected( aText
);
3897 // #107218# Call same listeners like VCL would do after user interaction
3898 SetSynthesizingVCLEvent( true );
3899 pEdit
->SetModifyFlag();
3901 SetSynthesizingVCLEvent( false );
3905 OUString
VCLXEdit::getText() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3907 SolarMutexGuard aGuard
;
3910 vcl::Window
* pWindow
= GetWindow();
3912 aText
= pWindow
->GetText();
3916 OUString
VCLXEdit::getSelectedText() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3918 SolarMutexGuard aGuard
;
3921 Edit
* pEdit
= static_cast<Edit
*>(GetWindow());
3923 aText
= pEdit
->GetSelected();
3928 void VCLXEdit::setSelection( const ::com::sun::star::awt::Selection
& aSelection
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3930 SolarMutexGuard aGuard
;
3932 Edit
* pEdit
= static_cast<Edit
*>(GetWindow());
3934 pEdit
->SetSelection( Selection( aSelection
.Min
, aSelection
.Max
) );
3937 ::com::sun::star::awt::Selection
VCLXEdit::getSelection() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3939 SolarMutexGuard aGuard
;
3942 Edit
* pEdit
= static_cast<Edit
*>(GetWindow());
3944 aSel
= pEdit
->GetSelection();
3945 return ::com::sun::star::awt::Selection( aSel
.Min(), aSel
.Max() );
3948 sal_Bool
VCLXEdit::isEditable() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3950 SolarMutexGuard aGuard
;
3952 Edit
* pEdit
= static_cast<Edit
*>(GetWindow());
3953 return ( pEdit
&& !pEdit
->IsReadOnly() && pEdit
->IsEnabled() ) ? sal_True
: sal_False
;
3956 void VCLXEdit::setEditable( sal_Bool bEditable
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3958 SolarMutexGuard aGuard
;
3960 Edit
* pEdit
= static_cast<Edit
*>(GetWindow());
3962 pEdit
->SetReadOnly( !bEditable
);
3966 void VCLXEdit::setMaxTextLen( sal_Int16 nLen
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3968 SolarMutexGuard aGuard
;
3970 Edit
* pEdit
= static_cast<Edit
*>(GetWindow());
3972 pEdit
->SetMaxTextLen( nLen
);
3975 sal_Int16
VCLXEdit::getMaxTextLen() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3977 SolarMutexGuard aGuard
;
3979 Edit
* pEdit
= static_cast<Edit
*>(GetWindow());
3980 return pEdit
? pEdit
->GetMaxTextLen() : 0;
3983 void VCLXEdit::setEchoChar( sal_Unicode cEcho
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3985 SolarMutexGuard aGuard
;
3987 Edit
* pEdit
= static_cast<Edit
*>(GetWindow());
3989 pEdit
->SetEchoChar( cEcho
);
3992 void VCLXEdit::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
3994 SolarMutexGuard aGuard
;
3996 Edit
* pEdit
= static_cast<Edit
*>(GetWindow());
3999 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
4000 switch ( nPropType
)
4002 case BASEPROPERTY_HIDEINACTIVESELECTION
:
4003 ::toolkit::adjustBooleanWindowStyle( Value
, pEdit
, WB_NOHIDESELECTION
, true );
4004 if ( pEdit
->GetSubEdit() )
4005 ::toolkit::adjustBooleanWindowStyle( Value
, pEdit
->GetSubEdit(), WB_NOHIDESELECTION
, true );
4008 case BASEPROPERTY_READONLY
:
4012 pEdit
->SetReadOnly( b
);
4015 case BASEPROPERTY_ECHOCHAR
:
4017 sal_Int16 n
= sal_Int16();
4019 pEdit
->SetEchoChar( n
);
4022 case BASEPROPERTY_MAXTEXTLEN
:
4024 sal_Int16 n
= sal_Int16();
4026 pEdit
->SetMaxTextLen( n
);
4031 VCLXWindow::setProperty( PropertyName
, Value
);
4037 ::com::sun::star::uno::Any
VCLXEdit::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4039 SolarMutexGuard aGuard
;
4041 ::com::sun::star::uno::Any aProp
;
4042 Edit
* pEdit
= static_cast<Edit
*>(GetWindow());
4045 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
4046 switch ( nPropType
)
4048 case BASEPROPERTY_HIDEINACTIVESELECTION
:
4049 aProp
<<= ( ( pEdit
->GetStyle() & WB_NOHIDESELECTION
) == 0 );
4051 case BASEPROPERTY_READONLY
:
4052 aProp
<<= pEdit
->IsReadOnly();
4054 case BASEPROPERTY_ECHOCHAR
:
4055 aProp
<<= (sal_Int16
) pEdit
->GetEchoChar();
4057 case BASEPROPERTY_MAXTEXTLEN
:
4058 aProp
<<= (sal_Int16
) pEdit
->GetMaxTextLen();
4062 aProp
= VCLXWindow::getProperty( PropertyName
);
4069 ::com::sun::star::awt::Size
VCLXEdit::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4071 SolarMutexGuard aGuard
;
4074 Edit
* pEdit
= static_cast<Edit
*>(GetWindow());
4076 aSz
= pEdit
->CalcMinimumSize();
4077 return AWTSize(aSz
);
4080 ::com::sun::star::awt::Size
VCLXEdit::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4082 SolarMutexGuard aGuard
;
4085 Edit
* pEdit
= static_cast<Edit
*>(GetWindow());
4088 aSz
= pEdit
->CalcMinimumSize();
4091 return AWTSize(aSz
);
4094 ::com::sun::star::awt::Size
VCLXEdit::calcAdjustedSize( const ::com::sun::star::awt::Size
& rNewSize
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4096 SolarMutexGuard aGuard
;
4098 ::com::sun::star::awt::Size aSz
= rNewSize
;
4099 ::com::sun::star::awt::Size aMinSz
= getMinimumSize();
4100 if ( aSz
.Height
!= aMinSz
.Height
)
4101 aSz
.Height
= aMinSz
.Height
;
4106 ::com::sun::star::awt::Size
VCLXEdit::getMinimumSize( sal_Int16 nCols
, sal_Int16
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4108 SolarMutexGuard aGuard
;
4111 Edit
* pEdit
= static_cast<Edit
*>(GetWindow());
4115 aSz
= pEdit
->CalcSize( nCols
);
4117 aSz
= pEdit
->CalcMinimumSize();
4119 return AWTSize(aSz
);
4122 void VCLXEdit::getColumnsAndLines( sal_Int16
& nCols
, sal_Int16
& nLines
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4124 SolarMutexGuard aGuard
;
4128 Edit
* pEdit
= static_cast<Edit
*>(GetWindow());
4130 nCols
= pEdit
->GetMaxVisChars();
4133 void VCLXEdit::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
4135 switch ( rVclWindowEvent
.GetId() )
4137 case VCLEVENT_EDIT_MODIFY
:
4139 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xKeepAlive( this );
4140 // since we call listeners below, there is a potential that we will be destroyed
4141 // during the listener call. To prevent the resulting crashs, we keep us
4142 // alive as long as we're here
4144 if ( GetTextListeners().getLength() )
4146 ::com::sun::star::awt::TextEvent aEvent
;
4147 aEvent
.Source
= (::cppu::OWeakObject
*)this;
4148 GetTextListeners().textChanged( aEvent
);
4154 VCLXWindow::ProcessWindowEvent( rVclWindowEvent
);
4160 // class VCLXComboBox
4163 void VCLXComboBox::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
4165 PushPropertyIds( rIds
,
4166 BASEPROPERTY_AUTOCOMPLETE
,
4167 BASEPROPERTY_BACKGROUNDCOLOR
,
4168 BASEPROPERTY_BORDER
,
4169 BASEPROPERTY_BORDERCOLOR
,
4170 BASEPROPERTY_DEFAULTCONTROL
,
4171 BASEPROPERTY_DROPDOWN
,
4172 BASEPROPERTY_ENABLED
,
4173 BASEPROPERTY_ENABLEVISIBLE
,
4174 BASEPROPERTY_FONTDESCRIPTOR
,
4175 BASEPROPERTY_HELPTEXT
,
4176 BASEPROPERTY_HELPURL
,
4177 BASEPROPERTY_LINECOUNT
,
4178 BASEPROPERTY_MAXTEXTLEN
,
4179 BASEPROPERTY_PRINTABLE
,
4180 BASEPROPERTY_READONLY
,
4181 BASEPROPERTY_STRINGITEMLIST
,
4182 BASEPROPERTY_TABSTOP
,
4184 BASEPROPERTY_HIDEINACTIVESELECTION
,
4186 BASEPROPERTY_WRITING_MODE
,
4187 BASEPROPERTY_CONTEXT_WRITING_MODE
,
4188 BASEPROPERTY_REFERENCE_DEVICE
,
4189 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR
,
4191 // no, don't call VCLXEdit here - it has properties which we do *not* want to have at combo box
4192 // #i92690# / 2008-08-12 / frank.schoenheit@sun.com
4193 // VCLXEdit::ImplGetPropertyIds( rIds );
4194 VCLXWindow::ImplGetPropertyIds( rIds
);
4197 VCLXComboBox::VCLXComboBox()
4198 : maActionListeners( *this ), maItemListeners( *this )
4202 VCLXComboBox::~VCLXComboBox()
4204 OSL_TRACE ("%s", __FUNCTION__
);
4207 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> VCLXComboBox::CreateAccessibleContext()
4209 SolarMutexGuard aGuard
;
4211 return getAccessibleFactory().createAccessibleContext( this );
4214 void VCLXComboBox::dispose() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4216 SolarMutexGuard aGuard
;
4218 ::com::sun::star::lang::EventObject aObj
;
4219 aObj
.Source
= (::cppu::OWeakObject
*)this;
4220 maItemListeners
.disposeAndClear( aObj
);
4221 maActionListeners
.disposeAndClear( aObj
);
4222 VCLXEdit::dispose();
4226 void VCLXComboBox::addItemListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XItemListener
> & l
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4228 SolarMutexGuard aGuard
;
4229 maItemListeners
.addInterface( l
);
4232 void VCLXComboBox::removeItemListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XItemListener
> & l
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4234 SolarMutexGuard aGuard
;
4235 maItemListeners
.removeInterface( l
);
4238 void VCLXComboBox::addActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
> & l
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4240 SolarMutexGuard aGuard
;
4241 maActionListeners
.addInterface( l
);
4244 void VCLXComboBox::removeActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
> & l
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4246 SolarMutexGuard aGuard
;
4247 maActionListeners
.removeInterface( l
);
4250 void VCLXComboBox::addItem( const OUString
& aItem
, sal_Int16 nPos
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4252 SolarMutexGuard aGuard
;
4254 ComboBox
* pBox
= static_cast<ComboBox
*>(GetWindow());
4256 pBox
->InsertEntry( aItem
, nPos
);
4259 void VCLXComboBox::addItems( const ::com::sun::star::uno::Sequence
< OUString
>& aItems
, sal_Int16 nPos
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4261 SolarMutexGuard aGuard
;
4263 ComboBox
* pBox
= static_cast<ComboBox
*>(GetWindow());
4266 sal_uInt16 nP
= nPos
;
4267 for ( sal_uInt16 n
= 0; n
< aItems
.getLength(); n
++ )
4269 pBox
->InsertEntry( aItems
.getConstArray()[n
], nP
);
4272 OSL_FAIL( "VCLXComboBox::addItems: too many entries!" );
4273 // skip remaining entries, list cannot hold them, anyway
4280 void VCLXComboBox::removeItems( sal_Int16 nPos
, sal_Int16 nCount
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4282 SolarMutexGuard aGuard
;
4284 ComboBox
* pBox
= static_cast<ComboBox
*>(GetWindow());
4287 for ( sal_uInt16 n
= nCount
; n
; )
4288 pBox
->RemoveEntryAt( nPos
+ (--n
) );
4292 sal_Int16
VCLXComboBox::getItemCount() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4294 SolarMutexGuard aGuard
;
4296 ComboBox
* pBox
= static_cast<ComboBox
*>(GetWindow());
4297 return pBox
? pBox
->GetEntryCount() : 0;
4300 OUString
VCLXComboBox::getItem( sal_Int16 nPos
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4302 SolarMutexGuard aGuard
;
4305 ComboBox
* pBox
= static_cast<ComboBox
*>(GetWindow());
4307 aItem
= pBox
->GetEntry( nPos
);
4311 ::com::sun::star::uno::Sequence
< OUString
> VCLXComboBox::getItems() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4313 SolarMutexGuard aGuard
;
4315 ::com::sun::star::uno::Sequence
< OUString
> aSeq
;
4316 ComboBox
* pBox
= static_cast<ComboBox
*>(GetWindow());
4319 sal_uInt16 nEntries
= pBox
->GetEntryCount();
4320 aSeq
= ::com::sun::star::uno::Sequence
< OUString
>( nEntries
);
4321 for ( sal_uInt16 n
= nEntries
; n
; )
4324 aSeq
.getArray()[n
] = pBox
->GetEntry( n
);
4330 void VCLXComboBox::setDropDownLineCount( sal_Int16 nLines
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4332 SolarMutexGuard aGuard
;
4334 ComboBox
* pBox
= static_cast<ComboBox
*>(GetWindow());
4336 pBox
->SetDropDownLineCount( nLines
);
4339 sal_Int16
VCLXComboBox::getDropDownLineCount() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4341 SolarMutexGuard aGuard
;
4343 sal_Int16 nLines
= 0;
4344 ComboBox
* pBox
= static_cast<ComboBox
*>(GetWindow());
4346 nLines
= pBox
->GetDropDownLineCount();
4350 void VCLXComboBox::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4352 SolarMutexGuard aGuard
;
4354 ComboBox
* pComboBox
= static_cast<ComboBox
*>(GetWindow());
4357 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
4358 switch ( nPropType
)
4360 case BASEPROPERTY_LINECOUNT
:
4362 sal_Int16 n
= sal_Int16();
4364 pComboBox
->SetDropDownLineCount( n
);
4367 case BASEPROPERTY_AUTOCOMPLETE
:
4369 sal_Int16 n
= sal_Int16();
4371 pComboBox
->EnableAutocomplete( n
!= 0 );
4376 pComboBox
->EnableAutocomplete( b
);
4380 case BASEPROPERTY_STRINGITEMLIST
:
4382 ::com::sun::star::uno::Sequence
< OUString
> aItems
;
4383 if ( Value
>>= aItems
)
4386 addItems( aItems
, 0 );
4392 VCLXEdit::setProperty( PropertyName
, Value
);
4394 // #109385# SetBorderStyle is not virtual
4395 if ( nPropType
== BASEPROPERTY_BORDER
)
4397 sal_uInt16 nBorder
= sal_uInt16();
4398 if ( (Value
>>= nBorder
) && nBorder
!= 0 )
4399 pComboBox
->SetBorderStyle( static_cast<WindowBorderStyle
>(nBorder
) );
4406 ::com::sun::star::uno::Any
VCLXComboBox::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4408 SolarMutexGuard aGuard
;
4410 ::com::sun::star::uno::Any aProp
;
4411 ComboBox
* pComboBox
= static_cast<ComboBox
*>(GetWindow());
4414 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
4415 switch ( nPropType
)
4417 case BASEPROPERTY_LINECOUNT
:
4419 aProp
<<= (sal_Int16
) pComboBox
->GetDropDownLineCount();
4422 case BASEPROPERTY_AUTOCOMPLETE
:
4424 aProp
<<= pComboBox
->IsAutocompleteEnabled();
4427 case BASEPROPERTY_STRINGITEMLIST
:
4429 sal_uInt16 nItems
= pComboBox
->GetEntryCount();
4430 ::com::sun::star::uno::Sequence
< OUString
> aSeq( nItems
);
4431 OUString
* pStrings
= aSeq
.getArray();
4432 for ( sal_uInt16 n
= 0; n
< nItems
; n
++ )
4433 pStrings
[n
] = pComboBox
->GetEntry( n
);
4440 aProp
<<= VCLXEdit::getProperty( PropertyName
);
4447 void VCLXComboBox::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
4449 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xKeepAlive( this );
4450 // since we call listeners below, there is a potential that we will be destroyed
4451 // during the listener call. To prevent the resulting crashs, we keep us
4452 // alive as long as we're here
4454 switch ( rVclWindowEvent
.GetId() )
4456 case VCLEVENT_COMBOBOX_SELECT
:
4457 if ( maItemListeners
.getLength() )
4459 ComboBox
* pComboBox
= static_cast<ComboBox
*>(GetWindow());
4462 if ( !pComboBox
->IsTravelSelect() )
4464 ::com::sun::star::awt::ItemEvent aEvent
;
4465 aEvent
.Source
= (::cppu::OWeakObject
*)this;
4466 aEvent
.Highlighted
= sal_False
;
4468 // Set to 0xFFFF on multiple selection, selected entry ID otherwise
4469 aEvent
.Selected
= pComboBox
->GetEntryPos( pComboBox
->GetText() );
4471 maItemListeners
.itemStateChanged( aEvent
);
4477 case VCLEVENT_COMBOBOX_DOUBLECLICK
:
4478 if ( maActionListeners
.getLength() )
4480 ::com::sun::star::awt::ActionEvent aEvent
;
4481 aEvent
.Source
= (::cppu::OWeakObject
*)this;
4482 // aEvent.ActionCommand = ...;
4483 maActionListeners
.actionPerformed( aEvent
);
4488 VCLXEdit::ProcessWindowEvent( rVclWindowEvent
);
4493 ::com::sun::star::awt::Size
VCLXComboBox::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4495 SolarMutexGuard aGuard
;
4498 ComboBox
* pComboBox
= static_cast<ComboBox
*>(GetWindow());
4500 aSz
= pComboBox
->CalcMinimumSize();
4501 return AWTSize(aSz
);
4504 ::com::sun::star::awt::Size
VCLXComboBox::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4506 SolarMutexGuard aGuard
;
4509 ComboBox
* pComboBox
= static_cast<ComboBox
*>(GetWindow());
4512 aSz
= pComboBox
->CalcMinimumSize();
4513 if ( pComboBox
->GetStyle() & WB_DROPDOWN
)
4516 return AWTSize(aSz
);
4519 ::com::sun::star::awt::Size
VCLXComboBox::calcAdjustedSize( const ::com::sun::star::awt::Size
& rNewSize
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4521 SolarMutexGuard aGuard
;
4523 Size aSz
= VCLSize(rNewSize
);
4524 ComboBox
* pComboBox
= static_cast<ComboBox
*>(GetWindow());
4526 aSz
= pComboBox
->CalcAdjustedSize( aSz
);
4527 return AWTSize(aSz
);
4530 ::com::sun::star::awt::Size
VCLXComboBox::getMinimumSize( sal_Int16 nCols
, sal_Int16 nLines
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4532 SolarMutexGuard aGuard
;
4535 ComboBox
* pComboBox
= static_cast<ComboBox
*>(GetWindow());
4537 aSz
= pComboBox
->CalcBlockSize( nCols
, nLines
);
4538 return AWTSize(aSz
);
4541 void VCLXComboBox::getColumnsAndLines( sal_Int16
& nCols
, sal_Int16
& nLines
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4543 SolarMutexGuard aGuard
;
4546 ComboBox
* pComboBox
= static_cast<ComboBox
*>(GetWindow());
4550 pComboBox
->GetMaxVisColumnsAndLines( nC
, nL
);
4555 void SAL_CALL
VCLXComboBox::listItemInserted( const ItemListEvent
& i_rEvent
) throw (RuntimeException
, std::exception
)
4557 SolarMutexGuard aGuard
;
4559 ComboBox
* pComboBox
= dynamic_cast< ComboBox
* >( GetWindow() );
4561 ENSURE_OR_RETURN_VOID( pComboBox
, "VCLXComboBox::listItemInserted: no ComboBox?!" );
4562 ENSURE_OR_RETURN_VOID( ( i_rEvent
.ItemPosition
>= 0 ) && ( i_rEvent
.ItemPosition
<= sal_Int32( pComboBox
->GetEntryCount() ) ),
4563 "VCLXComboBox::listItemInserted: illegal (inconsistent) item position!" );
4564 pComboBox
->InsertEntryWithImage(
4565 i_rEvent
.ItemText
.IsPresent
? i_rEvent
.ItemText
.Value
: OUString(),
4566 i_rEvent
.ItemImageURL
.IsPresent
? lcl_getImageFromURL( i_rEvent
.ItemImageURL
.Value
) : Image(),
4567 i_rEvent
.ItemPosition
);
4570 void SAL_CALL
VCLXComboBox::listItemRemoved( const ItemListEvent
& i_rEvent
) throw (RuntimeException
, std::exception
)
4572 SolarMutexGuard aGuard
;
4574 ComboBox
* pComboBox
= dynamic_cast< ComboBox
* >( GetWindow() );
4576 ENSURE_OR_RETURN_VOID( pComboBox
, "VCLXComboBox::listItemRemoved: no ComboBox?!" );
4577 ENSURE_OR_RETURN_VOID( ( i_rEvent
.ItemPosition
>= 0 ) && ( i_rEvent
.ItemPosition
< sal_Int32( pComboBox
->GetEntryCount() ) ),
4578 "VCLXComboBox::listItemRemoved: illegal (inconsistent) item position!" );
4580 pComboBox
->RemoveEntryAt( i_rEvent
.ItemPosition
);
4583 void SAL_CALL
VCLXComboBox::listItemModified( const ItemListEvent
& i_rEvent
) throw (RuntimeException
, std::exception
)
4585 SolarMutexGuard aGuard
;
4587 ComboBox
* pComboBox
= dynamic_cast< ComboBox
* >( GetWindow() );
4589 ENSURE_OR_RETURN_VOID( pComboBox
, "VCLXComboBox::listItemModified: no ComboBox?!" );
4590 ENSURE_OR_RETURN_VOID( ( i_rEvent
.ItemPosition
>= 0 ) && ( i_rEvent
.ItemPosition
< sal_Int32( pComboBox
->GetEntryCount() ) ),
4591 "VCLXComboBox::listItemModified: illegal (inconsistent) item position!" );
4593 // VCL's ComboBox does not support changing an entry's text or image, so remove and re-insert
4595 const OUString sNewText
= i_rEvent
.ItemText
.IsPresent
? i_rEvent
.ItemText
.Value
: OUString( pComboBox
->GetEntry( i_rEvent
.ItemPosition
) );
4596 const Image
aNewImage( i_rEvent
.ItemImageURL
.IsPresent
? lcl_getImageFromURL( i_rEvent
.ItemImageURL
.Value
) : pComboBox
->GetEntryImage( i_rEvent
.ItemPosition
) );
4598 pComboBox
->RemoveEntryAt( i_rEvent
.ItemPosition
);
4599 pComboBox
->InsertEntryWithImage(sNewText
, aNewImage
, i_rEvent
.ItemPosition
);
4602 void SAL_CALL
VCLXComboBox::allItemsRemoved( const EventObject
& i_rEvent
) throw (RuntimeException
, std::exception
)
4604 SolarMutexGuard aGuard
;
4606 ComboBox
* pComboBox
= dynamic_cast< ComboBox
* >( GetWindow() );
4607 ENSURE_OR_RETURN_VOID( pComboBox
, "VCLXComboBox::listItemModified: no ComboBox?!" );
4614 void SAL_CALL
VCLXComboBox::itemListChanged( const EventObject
& i_rEvent
) throw (RuntimeException
, std::exception
)
4616 SolarMutexGuard aGuard
;
4618 ComboBox
* pComboBox
= dynamic_cast< ComboBox
* >( GetWindow() );
4619 ENSURE_OR_RETURN_VOID( pComboBox
, "VCLXComboBox::listItemModified: no ComboBox?!" );
4623 uno::Reference
< beans::XPropertySet
> xPropSet( i_rEvent
.Source
, uno::UNO_QUERY_THROW
);
4624 uno::Reference
< beans::XPropertySetInfo
> xPSI( xPropSet
->getPropertySetInfo(), uno::UNO_QUERY_THROW
);
4625 // bool localize = xPSI->hasPropertyByName("ResourceResolver");
4626 uno::Reference
< resource::XStringResourceResolver
> xStringResourceResolver
;
4627 if ( xPSI
->hasPropertyByName("ResourceResolver") )
4629 xStringResourceResolver
.set(
4630 xPropSet
->getPropertyValue("ResourceResolver"),
4636 Reference
< XItemList
> xItemList( i_rEvent
.Source
, uno::UNO_QUERY_THROW
);
4637 uno::Sequence
< beans::Pair
< OUString
, OUString
> > aItems
= xItemList
->getAllItems();
4638 for ( sal_Int32 i
=0; i
<aItems
.getLength(); ++i
)
4640 OUString
aLocalizationKey( aItems
[i
].First
);
4641 if ( xStringResourceResolver
.is() && !aLocalizationKey
.isEmpty() && aLocalizationKey
[0] == '&' )
4643 aLocalizationKey
= xStringResourceResolver
->resolveString(aLocalizationKey
.copy( 1 ));
4645 pComboBox
->InsertEntryWithImage(aLocalizationKey
,
4646 lcl_getImageFromURL(aItems
[i
].Second
));
4649 void SAL_CALL
VCLXComboBox::disposing( const EventObject
& i_rEvent
) throw (RuntimeException
, std::exception
)
4651 // just disambiguate
4652 VCLXEdit::disposing( i_rEvent
);
4656 // class VCLXFormattedSpinField
4658 void VCLXFormattedSpinField::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
4660 // Interestingly in the UnoControl API this is
4661 // - not derived from XEdit ultimately, (correct ?) - so cut this here ...
4662 // VCLXSpinField::ImplGetPropertyIds( rIds );
4663 VCLXWindow::ImplGetPropertyIds( rIds
);
4666 VCLXFormattedSpinField::VCLXFormattedSpinField()
4671 VCLXFormattedSpinField::~VCLXFormattedSpinField()
4675 void VCLXFormattedSpinField::setStrictFormat( bool bStrict
)
4677 SolarMutexGuard aGuard
;
4679 FormatterBase
* pFormatter
= GetFormatter();
4681 pFormatter
->SetStrictFormat( bStrict
);
4684 bool VCLXFormattedSpinField::isStrictFormat()
4686 FormatterBase
* pFormatter
= GetFormatter();
4687 return pFormatter
? pFormatter
->IsStrictFormat() : sal_False
;
4691 void VCLXFormattedSpinField::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4693 SolarMutexGuard aGuard
;
4695 FormatterBase
* pFormatter
= GetFormatter();
4698 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
4699 switch ( nPropType
)
4701 case BASEPROPERTY_SPIN
:
4706 WinBits nStyle
= GetWindow()->GetStyle() | WB_SPIN
;
4709 GetWindow()->SetStyle( nStyle
);
4713 case BASEPROPERTY_STRICTFORMAT
:
4718 pFormatter
->SetStrictFormat( b
);
4724 VCLXSpinField::setProperty( PropertyName
, Value
);
4730 ::com::sun::star::uno::Any
VCLXFormattedSpinField::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4732 SolarMutexGuard aGuard
;
4734 ::com::sun::star::uno::Any aProp
;
4735 FormatterBase
* pFormatter
= GetFormatter();
4738 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
4739 switch ( nPropType
)
4741 case BASEPROPERTY_TABSTOP
:
4743 aProp
<<= ( GetWindow()->GetStyle() & WB_SPIN
) != 0;
4746 case BASEPROPERTY_STRICTFORMAT
:
4748 aProp
<<= pFormatter
->IsStrictFormat();
4753 aProp
<<= VCLXSpinField::getProperty( PropertyName
);
4762 // class VCLXDateField
4765 void VCLXDateField::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
4767 PushPropertyIds( rIds
,
4769 BASEPROPERTY_BACKGROUNDCOLOR
,
4770 BASEPROPERTY_BORDER
,
4771 BASEPROPERTY_BORDERCOLOR
,
4773 BASEPROPERTY_DATEMAX
,
4774 BASEPROPERTY_DATEMIN
,
4775 BASEPROPERTY_DATESHOWCENTURY
,
4776 BASEPROPERTY_DEFAULTCONTROL
,
4777 BASEPROPERTY_DROPDOWN
,
4778 BASEPROPERTY_ENABLED
,
4779 BASEPROPERTY_ENABLEVISIBLE
,
4780 BASEPROPERTY_EXTDATEFORMAT
,
4781 BASEPROPERTY_FONTDESCRIPTOR
,
4782 BASEPROPERTY_HELPTEXT
,
4783 BASEPROPERTY_HELPURL
,
4784 BASEPROPERTY_PRINTABLE
,
4785 BASEPROPERTY_READONLY
,
4786 BASEPROPERTY_REPEAT
,
4787 BASEPROPERTY_REPEAT_DELAY
,
4789 BASEPROPERTY_STRICTFORMAT
,
4790 BASEPROPERTY_TABSTOP
,
4791 BASEPROPERTY_ENFORCE_FORMAT
,
4793 BASEPROPERTY_HIDEINACTIVESELECTION
,
4794 BASEPROPERTY_VERTICALALIGN
,
4795 BASEPROPERTY_WRITING_MODE
,
4796 BASEPROPERTY_CONTEXT_WRITING_MODE
,
4797 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR
,
4799 VCLXFormattedSpinField::ImplGetPropertyIds( rIds
);
4802 VCLXDateField::VCLXDateField()
4806 VCLXDateField::~VCLXDateField()
4810 //change the window type here to match the role
4811 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> VCLXDateField::CreateAccessibleContext()
4813 vcl::Window
* pWindow
= GetWindow();
4816 pWindow
->SetType( WINDOW_DATEFIELD
);
4818 return getAccessibleFactory().createAccessibleContext( this );
4821 // ::com::sun::star::uno::XInterface
4822 ::com::sun::star::uno::Any
VCLXDateField::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4824 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
4825 (static_cast< ::com::sun::star::awt::XDateField
* >(this)) );
4826 return (aRet
.hasValue() ? aRet
: VCLXFormattedSpinField::queryInterface( rType
));
4829 // ::com::sun::star::lang::XTypeProvider
4830 IMPL_XTYPEPROVIDER_START( VCLXDateField
)
4831 cppu::UnoType
<com::sun::star::awt::XDateField
>::get(),
4832 VCLXFormattedSpinField::getTypes()
4833 IMPL_XTYPEPROVIDER_END
4835 void VCLXDateField::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4837 SolarMutexGuard aGuard
;
4841 bool bVoid
= Value
.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID
;
4843 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
4844 switch ( nPropType
)
4846 case BASEPROPERTY_DATE
:
4850 static_cast<DateField
*>(GetWindow())->EnableEmptyFieldValue( true );
4851 static_cast<DateField
*>(GetWindow())->SetEmptyFieldValue();
4861 case BASEPROPERTY_DATEMIN
:
4868 case BASEPROPERTY_DATEMAX
:
4875 case BASEPROPERTY_EXTDATEFORMAT
:
4877 sal_Int16 n
= sal_Int16();
4879 static_cast<DateField
*>(GetWindow())->SetExtDateFormat( (ExtDateFieldFormat
) n
);
4882 case BASEPROPERTY_DATESHOWCENTURY
:
4886 static_cast<DateField
*>(GetWindow())->SetShowDateCentury( b
);
4889 case BASEPROPERTY_ENFORCE_FORMAT
:
4891 bool bEnforce( true );
4892 OSL_VERIFY( Value
>>= bEnforce
);
4893 static_cast< DateField
* >( GetWindow() )->EnforceValidValue( bEnforce
);
4898 VCLXFormattedSpinField::setProperty( PropertyName
, Value
);
4904 ::com::sun::star::uno::Any
VCLXDateField::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4906 SolarMutexGuard aGuard
;
4908 ::com::sun::star::uno::Any aProp
;
4909 FormatterBase
* pFormatter
= GetFormatter();
4912 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
4913 switch ( nPropType
)
4915 case BASEPROPERTY_DATE
:
4917 aProp
<<= getDate();
4920 case BASEPROPERTY_DATEMIN
:
4925 case BASEPROPERTY_DATEMAX
:
4930 case BASEPROPERTY_DATESHOWCENTURY
:
4932 aProp
<<= static_cast<DateField
*>(GetWindow())->IsShowDateCentury();
4935 case BASEPROPERTY_ENFORCE_FORMAT
:
4937 aProp
<<= static_cast< DateField
* >( GetWindow() )->IsEnforceValidValue( );
4942 aProp
<<= VCLXFormattedSpinField::getProperty( PropertyName
);
4950 void VCLXDateField::setDate( const util::Date
& aDate
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4952 SolarMutexGuard aGuard
;
4954 DateField
* pDateField
= static_cast<DateField
*>(GetWindow());
4957 pDateField
->SetDate( aDate
);
4959 // #107218# Call same listeners like VCL would do after user interaction
4960 SetSynthesizingVCLEvent( true );
4961 pDateField
->SetModifyFlag();
4962 pDateField
->Modify();
4963 SetSynthesizingVCLEvent( false );
4967 util::Date
VCLXDateField::getDate() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4969 SolarMutexGuard aGuard
;
4971 DateField
* pDateField
= static_cast<DateField
*>(GetWindow());
4973 return pDateField
->GetDate().GetUNODate();
4975 return util::Date();
4978 void VCLXDateField::setMin( const util::Date
& aDate
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4980 SolarMutexGuard aGuard
;
4982 DateField
* pDateField
= static_cast<DateField
*>(GetWindow());
4984 pDateField
->SetMin( aDate
);
4987 util::Date
VCLXDateField::getMin() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
4989 SolarMutexGuard aGuard
;
4991 DateField
* pDateField
= static_cast<DateField
*>(GetWindow());
4993 return pDateField
->GetMin().GetUNODate();
4995 return util::Date();
4998 void VCLXDateField::setMax( const util::Date
& aDate
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5000 SolarMutexGuard aGuard
;
5002 DateField
* pDateField
= static_cast<DateField
*>(GetWindow());
5004 pDateField
->SetMax( aDate
);
5007 util::Date
VCLXDateField::getMax() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5009 SolarMutexGuard aGuard
;
5011 DateField
* pDateField
= static_cast<DateField
*>(GetWindow());
5013 return pDateField
->GetMax().GetUNODate();
5015 return util::Date();
5018 void VCLXDateField::setFirst( const util::Date
& aDate
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5020 SolarMutexGuard aGuard
;
5022 DateField
* pDateField
= static_cast<DateField
*>(GetWindow());
5024 pDateField
->SetFirst( aDate
);
5027 util::Date
VCLXDateField::getFirst() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5029 SolarMutexGuard aGuard
;
5031 DateField
* pDateField
= static_cast<DateField
*>(GetWindow());
5033 return pDateField
->GetFirst().GetUNODate();
5035 return util::Date();
5038 void VCLXDateField::setLast( const util::Date
& aDate
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5040 SolarMutexGuard aGuard
;
5042 DateField
* pDateField
= static_cast<DateField
*>(GetWindow());
5044 pDateField
->SetLast( aDate
);
5047 util::Date
VCLXDateField::getLast() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5049 SolarMutexGuard aGuard
;
5051 DateField
* pDateField
= static_cast<DateField
*>(GetWindow());
5053 return pDateField
->GetLast().GetUNODate();
5055 return util::Date();
5058 void VCLXDateField::setLongFormat( sal_Bool bLong
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5060 SolarMutexGuard aGuard
;
5062 DateField
* pDateField
= static_cast<DateField
*>(GetWindow());
5064 pDateField
->SetLongFormat( bLong
);
5067 sal_Bool
VCLXDateField::isLongFormat() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5069 SolarMutexGuard aGuard
;
5071 DateField
* pDateField
= static_cast<DateField
*>(GetWindow());
5072 return pDateField
? pDateField
->IsLongFormat() : sal_False
;
5075 void VCLXDateField::setEmpty() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5077 SolarMutexGuard aGuard
;
5079 DateField
* pDateField
= static_cast<DateField
*>(GetWindow());
5082 pDateField
->SetEmptyDate();
5084 // #107218# Call same listeners like VCL would do after user interaction
5085 SetSynthesizingVCLEvent( true );
5086 pDateField
->SetModifyFlag();
5087 pDateField
->Modify();
5088 SetSynthesizingVCLEvent( false );
5092 sal_Bool
VCLXDateField::isEmpty() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5094 SolarMutexGuard aGuard
;
5096 DateField
* pDateField
= static_cast<DateField
*>(GetWindow());
5097 return pDateField
? pDateField
->IsEmptyDate() : sal_False
;
5100 void VCLXDateField::setStrictFormat( sal_Bool bStrict
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5102 VCLXFormattedSpinField::setStrictFormat( bStrict
);
5105 sal_Bool
VCLXDateField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5107 return VCLXFormattedSpinField::isStrictFormat();
5112 // class VCLXTimeField
5115 void VCLXTimeField::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
5117 PushPropertyIds( rIds
,
5119 BASEPROPERTY_BACKGROUNDCOLOR
,
5120 BASEPROPERTY_BORDER
,
5121 BASEPROPERTY_BORDERCOLOR
,
5122 BASEPROPERTY_DEFAULTCONTROL
,
5123 BASEPROPERTY_ENABLED
,
5124 BASEPROPERTY_ENABLEVISIBLE
,
5125 BASEPROPERTY_EXTTIMEFORMAT
,
5126 BASEPROPERTY_FONTDESCRIPTOR
,
5127 BASEPROPERTY_HELPTEXT
,
5128 BASEPROPERTY_HELPURL
,
5129 BASEPROPERTY_PRINTABLE
,
5130 BASEPROPERTY_READONLY
,
5131 BASEPROPERTY_REPEAT
,
5132 BASEPROPERTY_REPEAT_DELAY
,
5134 BASEPROPERTY_STRICTFORMAT
,
5135 BASEPROPERTY_TABSTOP
,
5137 BASEPROPERTY_TIMEMAX
,
5138 BASEPROPERTY_TIMEMIN
,
5139 BASEPROPERTY_ENFORCE_FORMAT
,
5141 BASEPROPERTY_HIDEINACTIVESELECTION
,
5142 BASEPROPERTY_VERTICALALIGN
,
5143 BASEPROPERTY_WRITING_MODE
,
5144 BASEPROPERTY_CONTEXT_WRITING_MODE
,
5145 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR
,
5147 VCLXFormattedSpinField::ImplGetPropertyIds( rIds
);
5150 VCLXTimeField::VCLXTimeField()
5154 VCLXTimeField::~VCLXTimeField()
5158 //change the window type here to match the role
5159 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> VCLXTimeField::CreateAccessibleContext()
5161 vcl::Window
* pWindow
= GetWindow();
5164 pWindow
->SetType( WINDOW_TIMEFIELD
);
5166 return getAccessibleFactory().createAccessibleContext( this );
5169 // ::com::sun::star::uno::XInterface
5170 ::com::sun::star::uno::Any
VCLXTimeField::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5172 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
5173 (static_cast< ::com::sun::star::awt::XTimeField
* >(this)) );
5174 return (aRet
.hasValue() ? aRet
: VCLXFormattedSpinField::queryInterface( rType
));
5177 // ::com::sun::star::lang::XTypeProvider
5178 IMPL_XTYPEPROVIDER_START( VCLXTimeField
)
5179 cppu::UnoType
<com::sun::star::awt::XTimeField
>::get(),
5180 VCLXFormattedSpinField::getTypes()
5181 IMPL_XTYPEPROVIDER_END
5183 void VCLXTimeField::setTime( const util::Time
& aTime
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5185 SolarMutexGuard aGuard
;
5187 TimeField
* pTimeField
= static_cast<TimeField
*>(GetWindow());
5190 pTimeField
->SetTime( aTime
);
5192 // #107218# Call same listeners like VCL would do after user interaction
5193 SetSynthesizingVCLEvent( true );
5194 pTimeField
->SetModifyFlag();
5195 pTimeField
->Modify();
5196 SetSynthesizingVCLEvent( false );
5200 util::Time
VCLXTimeField::getTime() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5202 SolarMutexGuard aGuard
;
5204 TimeField
* pTimeField
= static_cast<TimeField
*>(GetWindow());
5206 return pTimeField
->GetTime().GetUNOTime();
5208 return util::Time();
5211 void VCLXTimeField::setMin( const util::Time
& aTime
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5213 SolarMutexGuard aGuard
;
5215 TimeField
* pTimeField
= static_cast<TimeField
*>(GetWindow());
5217 pTimeField
->SetMin( aTime
);
5220 util::Time
VCLXTimeField::getMin() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5222 SolarMutexGuard aGuard
;
5224 TimeField
* pTimeField
= static_cast<TimeField
*>(GetWindow());
5226 return pTimeField
->GetMin().GetUNOTime();
5228 return util::Time();
5231 void VCLXTimeField::setMax( const util::Time
& aTime
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5233 SolarMutexGuard aGuard
;
5235 TimeField
* pTimeField
= static_cast<TimeField
*>(GetWindow());
5237 pTimeField
->SetMax( aTime
);
5240 util::Time
VCLXTimeField::getMax() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5242 SolarMutexGuard aGuard
;
5244 TimeField
* pTimeField
= static_cast<TimeField
*>(GetWindow());
5246 return pTimeField
->GetMax().GetUNOTime();
5248 return util::Time();
5251 void VCLXTimeField::setFirst( const util::Time
& aTime
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5253 SolarMutexGuard aGuard
;
5255 TimeField
* pTimeField
= static_cast<TimeField
*>(GetWindow());
5257 pTimeField
->SetFirst( aTime
);
5260 util::Time
VCLXTimeField::getFirst() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5262 SolarMutexGuard aGuard
;
5264 TimeField
* pTimeField
= static_cast<TimeField
*>(GetWindow());
5266 return pTimeField
->GetFirst().GetUNOTime();
5268 return util::Time();
5271 void VCLXTimeField::setLast( const util::Time
& aTime
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5273 SolarMutexGuard aGuard
;
5275 TimeField
* pTimeField
= static_cast<TimeField
*>(GetWindow());
5277 pTimeField
->SetLast( aTime
);
5280 util::Time
VCLXTimeField::getLast() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5282 SolarMutexGuard aGuard
;
5284 TimeField
* pTimeField
= static_cast<TimeField
*>(GetWindow());
5286 return pTimeField
->GetLast().GetUNOTime();
5288 return util::Time();
5291 void VCLXTimeField::setEmpty() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5293 SolarMutexGuard aGuard
;
5295 TimeField
* pTimeField
= static_cast<TimeField
*>(GetWindow());
5297 pTimeField
->SetEmptyTime();
5300 sal_Bool
VCLXTimeField::isEmpty() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5302 SolarMutexGuard aGuard
;
5304 TimeField
* pTimeField
= static_cast<TimeField
*>(GetWindow());
5305 return pTimeField
? pTimeField
->IsEmptyTime() : sal_False
;
5308 void VCLXTimeField::setStrictFormat( sal_Bool bStrict
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5310 VCLXFormattedSpinField::setStrictFormat( bStrict
);
5313 sal_Bool
VCLXTimeField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5315 return VCLXFormattedSpinField::isStrictFormat();
5319 void VCLXTimeField::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5321 SolarMutexGuard aGuard
;
5325 bool bVoid
= Value
.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID
;
5327 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
5328 switch ( nPropType
)
5330 case BASEPROPERTY_TIME
:
5334 static_cast<TimeField
*>(GetWindow())->EnableEmptyFieldValue( true );
5335 static_cast<TimeField
*>(GetWindow())->SetEmptyFieldValue();
5345 case BASEPROPERTY_TIMEMIN
:
5352 case BASEPROPERTY_TIMEMAX
:
5359 case BASEPROPERTY_EXTTIMEFORMAT
:
5361 sal_Int16 n
= sal_Int16();
5363 static_cast<TimeField
*>(GetWindow())->SetExtFormat( (ExtTimeFieldFormat
) n
);
5366 case BASEPROPERTY_ENFORCE_FORMAT
:
5368 bool bEnforce( true );
5369 OSL_VERIFY( Value
>>= bEnforce
);
5370 static_cast< TimeField
* >( GetWindow() )->EnforceValidValue( bEnforce
);
5375 VCLXFormattedSpinField::setProperty( PropertyName
, Value
);
5381 ::com::sun::star::uno::Any
VCLXTimeField::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5383 SolarMutexGuard aGuard
;
5385 ::com::sun::star::uno::Any aProp
;
5388 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
5389 switch ( nPropType
)
5391 case BASEPROPERTY_TIME
:
5393 aProp
<<= getTime();
5396 case BASEPROPERTY_TIMEMIN
:
5401 case BASEPROPERTY_TIMEMAX
:
5406 case BASEPROPERTY_ENFORCE_FORMAT
:
5408 aProp
<<= static_cast< TimeField
* >( GetWindow() )->IsEnforceValidValue( );
5413 aProp
<<= VCLXFormattedSpinField::getProperty( PropertyName
);
5421 // class VCLXNumericField
5424 void VCLXNumericField::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
5426 PushPropertyIds( rIds
,
5428 BASEPROPERTY_BACKGROUNDCOLOR
,
5429 BASEPROPERTY_BORDER
,
5430 BASEPROPERTY_BORDERCOLOR
,
5431 BASEPROPERTY_DECIMALACCURACY
,
5432 BASEPROPERTY_DEFAULTCONTROL
,
5433 BASEPROPERTY_ENABLED
,
5434 BASEPROPERTY_ENABLEVISIBLE
,
5435 BASEPROPERTY_FONTDESCRIPTOR
,
5436 BASEPROPERTY_HELPTEXT
,
5437 BASEPROPERTY_HELPURL
,
5438 BASEPROPERTY_NUMSHOWTHOUSANDSEP
,
5439 BASEPROPERTY_PRINTABLE
,
5440 BASEPROPERTY_READONLY
,
5441 BASEPROPERTY_REPEAT
,
5442 BASEPROPERTY_REPEAT_DELAY
,
5444 BASEPROPERTY_STRICTFORMAT
,
5445 BASEPROPERTY_TABSTOP
,
5446 BASEPROPERTY_VALUEMAX_DOUBLE
,
5447 BASEPROPERTY_VALUEMIN_DOUBLE
,
5448 BASEPROPERTY_VALUESTEP_DOUBLE
,
5449 BASEPROPERTY_VALUE_DOUBLE
,
5450 BASEPROPERTY_ENFORCE_FORMAT
,
5451 BASEPROPERTY_HIDEINACTIVESELECTION
,
5452 BASEPROPERTY_VERTICALALIGN
,
5453 BASEPROPERTY_WRITING_MODE
,
5454 BASEPROPERTY_CONTEXT_WRITING_MODE
,
5455 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR
,
5457 VCLXFormattedSpinField::ImplGetPropertyIds( rIds
);
5460 VCLXNumericField::VCLXNumericField()
5464 VCLXNumericField::~VCLXNumericField()
5468 // ::com::sun::star::uno::XInterface
5469 ::com::sun::star::uno::Any
VCLXNumericField::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5471 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
5472 (static_cast< ::com::sun::star::awt::XNumericField
* >(this)) );
5473 return (aRet
.hasValue() ? aRet
: VCLXFormattedSpinField::queryInterface( rType
));
5476 // ::com::sun::star::lang::XTypeProvider
5477 IMPL_XTYPEPROVIDER_START( VCLXNumericField
)
5478 cppu::UnoType
<com::sun::star::awt::XNumericField
>::get(),
5479 VCLXFormattedSpinField::getTypes()
5480 IMPL_XTYPEPROVIDER_END
5482 void VCLXNumericField::setValue( double Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5484 SolarMutexGuard aGuard
;
5486 NumericFormatter
* pNumericFormatter
= static_cast<NumericFormatter
*>(GetFormatter());
5487 if ( pNumericFormatter
)
5489 // shift long value using decimal digits
5490 // (e.g., input 105 using 2 digits returns 1,05)
5491 // Thus, to set a value of 1,05, insert 105 and 2 digits
5492 pNumericFormatter
->SetValue(
5493 (long)ImplCalcLongValue( Value
, pNumericFormatter
->GetDecimalDigits() ) );
5495 // #107218# Call same listeners like VCL would do after user interaction
5496 Edit
* pEdit
= static_cast<Edit
*>(GetWindow());
5499 SetSynthesizingVCLEvent( true );
5500 pEdit
->SetModifyFlag();
5502 SetSynthesizingVCLEvent( false );
5507 double VCLXNumericField::getValue() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5509 SolarMutexGuard aGuard
;
5511 NumericFormatter
* pNumericFormatter
= static_cast<NumericFormatter
*>(GetFormatter());
5512 return pNumericFormatter
5513 ? ImplCalcDoubleValue( (double)pNumericFormatter
->GetValue(), pNumericFormatter
->GetDecimalDigits() )
5517 void VCLXNumericField::setMin( double Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5519 SolarMutexGuard aGuard
;
5521 NumericFormatter
* pNumericFormatter
= static_cast<NumericFormatter
*>(GetFormatter());
5522 if ( pNumericFormatter
)
5523 pNumericFormatter
->SetMin(
5524 (long)ImplCalcLongValue( Value
, pNumericFormatter
->GetDecimalDigits() ) );
5527 double VCLXNumericField::getMin() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5529 SolarMutexGuard aGuard
;
5531 NumericFormatter
* pNumericFormatter
= static_cast<NumericFormatter
*>(GetFormatter());
5532 return pNumericFormatter
5533 ? ImplCalcDoubleValue( (double)pNumericFormatter
->GetMin(), pNumericFormatter
->GetDecimalDigits() )
5537 void VCLXNumericField::setMax( double Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5539 SolarMutexGuard aGuard
;
5541 NumericFormatter
* pNumericFormatter
= static_cast<NumericFormatter
*>(GetFormatter());
5542 if ( pNumericFormatter
)
5543 pNumericFormatter
->SetMax(
5544 (long)ImplCalcLongValue( Value
, pNumericFormatter
->GetDecimalDigits() ) );
5547 double VCLXNumericField::getMax() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5549 SolarMutexGuard aGuard
;
5551 NumericFormatter
* pNumericFormatter
= static_cast<NumericFormatter
*>(GetFormatter());
5552 return pNumericFormatter
5553 ? ImplCalcDoubleValue( (double)pNumericFormatter
->GetMax(), pNumericFormatter
->GetDecimalDigits() )
5557 void VCLXNumericField::setFirst( double Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5559 SolarMutexGuard aGuard
;
5561 NumericField
* pNumericField
= static_cast<NumericField
*>(GetWindow());
5562 if ( pNumericField
)
5563 pNumericField
->SetFirst(
5564 (long)ImplCalcLongValue( Value
, pNumericField
->GetDecimalDigits() ) );
5567 double VCLXNumericField::getFirst() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5569 SolarMutexGuard aGuard
;
5571 NumericField
* pNumericField
= static_cast<NumericField
*>(GetWindow());
5572 return pNumericField
5573 ? ImplCalcDoubleValue( (double)pNumericField
->GetFirst(), pNumericField
->GetDecimalDigits() )
5577 void VCLXNumericField::setLast( double Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5579 SolarMutexGuard aGuard
;
5581 NumericField
* pNumericField
= static_cast<NumericField
*>(GetWindow());
5582 if ( pNumericField
)
5583 pNumericField
->SetLast(
5584 (long)ImplCalcLongValue( Value
, pNumericField
->GetDecimalDigits() ) );
5587 double VCLXNumericField::getLast() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5589 SolarMutexGuard aGuard
;
5591 NumericField
* pNumericField
= static_cast<NumericField
*>(GetWindow());
5592 return pNumericField
5593 ? ImplCalcDoubleValue( (double)pNumericField
->GetLast(), pNumericField
->GetDecimalDigits() )
5597 void VCLXNumericField::setStrictFormat( sal_Bool bStrict
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5599 VCLXFormattedSpinField::setStrictFormat( bStrict
);
5602 sal_Bool
VCLXNumericField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5604 return VCLXFormattedSpinField::isStrictFormat();
5608 void VCLXNumericField::setSpinSize( double Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5610 SolarMutexGuard aGuard
;
5612 NumericField
* pNumericField
= static_cast<NumericField
*>(GetWindow());
5613 if ( pNumericField
)
5614 pNumericField
->SetSpinSize(
5615 (long)ImplCalcLongValue( Value
, pNumericField
->GetDecimalDigits() ) );
5618 double VCLXNumericField::getSpinSize() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5620 SolarMutexGuard aGuard
;
5622 NumericField
* pNumericField
= static_cast<NumericField
*>(GetWindow());
5623 return pNumericField
5624 ? ImplCalcDoubleValue( (double)pNumericField
->GetSpinSize(), pNumericField
->GetDecimalDigits() )
5628 void VCLXNumericField::setDecimalDigits( sal_Int16 Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5630 SolarMutexGuard aGuard
;
5632 NumericFormatter
* pNumericFormatter
= static_cast<NumericFormatter
*>(GetFormatter());
5633 if ( pNumericFormatter
)
5635 double n
= getValue();
5636 pNumericFormatter
->SetDecimalDigits( Value
);
5641 sal_Int16
VCLXNumericField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5643 SolarMutexGuard aGuard
;
5645 NumericFormatter
* pNumericFormatter
= static_cast<NumericFormatter
*>(GetFormatter());
5646 return pNumericFormatter
? pNumericFormatter
->GetDecimalDigits() : 0;
5649 void VCLXNumericField::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5651 SolarMutexGuard aGuard
;
5655 bool bVoid
= Value
.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID
;
5657 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
5658 switch ( nPropType
)
5660 case BASEPROPERTY_VALUE_DOUBLE
:
5664 static_cast<NumericField
*>(GetWindow())->EnableEmptyFieldValue( true );
5665 static_cast<NumericField
*>(GetWindow())->SetEmptyFieldValue();
5675 case BASEPROPERTY_VALUEMIN_DOUBLE
:
5682 case BASEPROPERTY_VALUEMAX_DOUBLE
:
5689 case BASEPROPERTY_VALUESTEP_DOUBLE
:
5696 case BASEPROPERTY_DECIMALACCURACY
:
5698 sal_Int16 n
= sal_Int16();
5700 setDecimalDigits( n
);
5703 case BASEPROPERTY_NUMSHOWTHOUSANDSEP
:
5707 static_cast<NumericField
*>(GetWindow())->SetUseThousandSep( b
);
5712 VCLXFormattedSpinField::setProperty( PropertyName
, Value
);
5718 ::com::sun::star::uno::Any
VCLXNumericField::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5720 SolarMutexGuard aGuard
;
5722 ::com::sun::star::uno::Any aProp
;
5723 FormatterBase
* pFormatter
= GetFormatter();
5726 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
5727 switch ( nPropType
)
5729 case BASEPROPERTY_VALUE_DOUBLE
:
5731 aProp
<<= (double) getValue();
5734 case BASEPROPERTY_VALUEMIN_DOUBLE
:
5736 aProp
<<= (double) getMin();
5739 case BASEPROPERTY_VALUEMAX_DOUBLE
:
5741 aProp
<<= (double) getMax();
5744 case BASEPROPERTY_VALUESTEP_DOUBLE
:
5746 aProp
<<= (double) getSpinSize();
5749 case BASEPROPERTY_NUMSHOWTHOUSANDSEP
:
5751 aProp
<<= static_cast<NumericField
*>(GetWindow())->IsUseThousandSep();
5756 aProp
<<= VCLXFormattedSpinField::getProperty( PropertyName
);
5764 // ----------------------------------------------------
5765 // class VCLXMetricField
5766 // ----------------------------------------------------
5768 void VCLXMetricField::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
5770 PushPropertyIds( rIds
,
5772 BASEPROPERTY_BACKGROUNDCOLOR
,
5773 BASEPROPERTY_BORDER
,
5774 BASEPROPERTY_BORDERCOLOR
,
5775 BASEPROPERTY_DECIMALACCURACY
,
5776 BASEPROPERTY_DEFAULTCONTROL
,
5777 BASEPROPERTY_ENABLED
,
5778 BASEPROPERTY_ENABLEVISIBLE
,
5779 BASEPROPERTY_FONTDESCRIPTOR
,
5780 BASEPROPERTY_HELPTEXT
,
5781 BASEPROPERTY_HELPURL
,
5782 BASEPROPERTY_NUMSHOWTHOUSANDSEP
,
5783 BASEPROPERTY_PRINTABLE
,
5784 BASEPROPERTY_READONLY
,
5785 BASEPROPERTY_REPEAT
,
5786 BASEPROPERTY_REPEAT_DELAY
,
5788 BASEPROPERTY_STRICTFORMAT
,
5789 BASEPROPERTY_TABSTOP
,
5790 BASEPROPERTY_ENFORCE_FORMAT
,
5791 BASEPROPERTY_HIDEINACTIVESELECTION
,
5793 BASEPROPERTY_CUSTOMUNITTEXT
,
5794 BASEPROPERTY_WRITING_MODE
,
5795 BASEPROPERTY_CONTEXT_WRITING_MODE
,
5796 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR
,
5798 VCLXFormattedSpinField::ImplGetPropertyIds( rIds
);
5801 VCLXMetricField::VCLXMetricField()
5805 VCLXMetricField::~VCLXMetricField()
5809 MetricFormatter
*VCLXMetricField::GetMetricFormatter() throw(::com::sun::star::uno::RuntimeException
)
5811 MetricFormatter
*pFormatter
= static_cast<MetricFormatter
*>(GetFormatter());
5813 throw ::com::sun::star::uno::RuntimeException();
5817 MetricField
*VCLXMetricField::GetMetricField() throw(::com::sun::star::uno::RuntimeException
)
5819 MetricField
*pField
= static_cast<MetricField
*>(GetWindow());
5821 throw ::com::sun::star::uno::RuntimeException();
5825 // ::com::sun::star::uno::XInterface
5826 ::com::sun::star::uno::Any
VCLXMetricField::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5828 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
5829 (static_cast< ::com::sun::star::awt::XMetricField
* >(this)) );
5830 return (aRet
.hasValue() ? aRet
: VCLXFormattedSpinField::queryInterface( rType
));
5833 // ::com::sun::star::lang::XTypeProvider
5834 IMPL_XTYPEPROVIDER_START( VCLXMetricField
)
5835 cppu::UnoType
<com::sun::star::awt::XMetricField
>::get(),
5836 VCLXFormattedSpinField::getTypes()
5837 IMPL_XTYPEPROVIDER_END
5840 #define MetricUnitUnoToVcl(a) ((FieldUnit)(a))
5842 #define METRIC_MAP_PAIR(method,parent) \
5843 sal_Int64 VCLXMetricField::get##method( sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException, std::exception) \
5845 SolarMutexGuard aGuard; \
5846 return GetMetric##parent()->Get##method( MetricUnitUnoToVcl( nUnit ) ); \
5848 void VCLXMetricField::set##method( sal_Int64 nValue, sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException, std::exception) \
5850 SolarMutexGuard aGuard; \
5851 GetMetric##parent()->Set##method( nValue, MetricUnitUnoToVcl( nUnit ) ); \
5854 METRIC_MAP_PAIR(Min
, Formatter
)
5855 METRIC_MAP_PAIR(Max
, Formatter
)
5856 METRIC_MAP_PAIR(First
, Field
)
5857 METRIC_MAP_PAIR(Last
, Field
)
5859 #undef METRIC_MAP_PAIR
5861 ::sal_Int64
VCLXMetricField::getValue( ::sal_Int16 nUnit
) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
5863 SolarMutexGuard aGuard
;
5864 return GetMetricFormatter()->GetValue( MetricUnitUnoToVcl( nUnit
) );
5867 ::sal_Int64
VCLXMetricField::getCorrectedValue( ::sal_Int16 nUnit
) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
5869 SolarMutexGuard aGuard
;
5870 return GetMetricFormatter()->GetCorrectedValue( MetricUnitUnoToVcl( nUnit
) );
5873 // FIXME: acute cut/paste evilness - move this to the parent Edit class ?
5874 void VCLXMetricField::CallListeners()
5876 // #107218# Call same listeners like VCL would do after user interaction
5877 Edit
* pEdit
= static_cast<Edit
*>(GetWindow());
5880 SetSynthesizingVCLEvent( true );
5881 pEdit
->SetModifyFlag();
5883 SetSynthesizingVCLEvent( false );
5887 void VCLXMetricField::setValue( ::sal_Int64 Value
, ::sal_Int16 Unit
) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
5889 SolarMutexGuard aGuard
;
5890 GetMetricFormatter()->SetValue( Value
, MetricUnitUnoToVcl( Unit
) );
5894 void VCLXMetricField::setUserValue( ::sal_Int64 Value
, ::sal_Int16 Unit
) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
5896 SolarMutexGuard aGuard
;
5897 GetMetricFormatter()->SetUserValue( Value
, MetricUnitUnoToVcl( Unit
) );
5901 void VCLXMetricField::setStrictFormat( sal_Bool bStrict
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5903 VCLXFormattedSpinField::setStrictFormat( bStrict
);
5906 sal_Bool
VCLXMetricField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5908 return VCLXFormattedSpinField::isStrictFormat();
5911 void VCLXMetricField::setSpinSize( sal_Int64 Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5913 SolarMutexGuard aGuard
;
5914 GetMetricField()->SetSpinSize( Value
);
5917 sal_Int64
VCLXMetricField::getSpinSize() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5919 SolarMutexGuard aGuard
;
5920 return GetMetricField()->GetSpinSize();
5923 void VCLXMetricField::setDecimalDigits( sal_Int16 Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5925 SolarMutexGuard aGuard
;
5926 GetMetricFormatter()->SetDecimalDigits( Value
);
5929 sal_Int16
VCLXMetricField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5931 SolarMutexGuard aGuard
;
5933 NumericFormatter
* pNumericFormatter
= static_cast<NumericFormatter
*>(GetFormatter());
5934 return pNumericFormatter
? pNumericFormatter
->GetDecimalDigits() : 0;
5937 void VCLXMetricField::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5939 SolarMutexGuard aGuard
;
5943 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
5944 switch ( nPropType
)
5946 case BASEPROPERTY_DECIMALACCURACY
:
5950 setDecimalDigits( n
);
5953 case BASEPROPERTY_NUMSHOWTHOUSANDSEP
:
5957 static_cast<NumericField
*>(GetWindow())->SetUseThousandSep( b
);
5960 case BASEPROPERTY_UNIT
:
5962 sal_uInt16 nVal
= 0;
5963 if ( Value
>>= nVal
)
5964 static_cast<MetricField
*>(GetWindow())->SetUnit( (FieldUnit
) nVal
);
5967 case BASEPROPERTY_CUSTOMUNITTEXT
:
5970 if ( Value
>>= aStr
)
5971 static_cast<MetricField
*>(GetWindow())->SetCustomUnitText( aStr
);
5976 VCLXFormattedSpinField::setProperty( PropertyName
, Value
);
5983 ::com::sun::star::uno::Any
VCLXMetricField::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
5985 SolarMutexGuard aGuard
;
5987 ::com::sun::star::uno::Any aProp
;
5988 FormatterBase
* pFormatter
= GetFormatter();
5991 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
5992 switch ( nPropType
)
5994 case BASEPROPERTY_NUMSHOWTHOUSANDSEP
:
5995 aProp
<<= static_cast<NumericField
*>(GetWindow())->IsUseThousandSep();
5997 case BASEPROPERTY_UNIT
:
5998 aProp
<<= (sal_uInt16
) (static_cast<MetricField
*>(GetWindow())->GetUnit());
6000 case BASEPROPERTY_CUSTOMUNITTEXT
:
6001 aProp
<<= OUString( static_cast<MetricField
*>(GetWindow())->GetCustomUnitText() );
6005 aProp
<<= VCLXFormattedSpinField::getProperty( PropertyName
);
6015 // class VCLXCurrencyField
6018 void VCLXCurrencyField::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
6020 PushPropertyIds( rIds
,
6022 BASEPROPERTY_BACKGROUNDCOLOR
,
6023 BASEPROPERTY_BORDER
,
6024 BASEPROPERTY_BORDERCOLOR
,
6025 BASEPROPERTY_CURRENCYSYMBOL
,
6026 BASEPROPERTY_CURSYM_POSITION
,
6027 BASEPROPERTY_DECIMALACCURACY
,
6028 BASEPROPERTY_DEFAULTCONTROL
,
6029 BASEPROPERTY_ENABLED
,
6030 BASEPROPERTY_ENABLEVISIBLE
,
6031 BASEPROPERTY_FONTDESCRIPTOR
,
6032 BASEPROPERTY_HELPTEXT
,
6033 BASEPROPERTY_HELPURL
,
6034 BASEPROPERTY_NUMSHOWTHOUSANDSEP
,
6035 BASEPROPERTY_PRINTABLE
,
6036 BASEPROPERTY_READONLY
,
6037 BASEPROPERTY_REPEAT
,
6038 BASEPROPERTY_REPEAT_DELAY
,
6040 BASEPROPERTY_STRICTFORMAT
,
6041 BASEPROPERTY_TABSTOP
,
6042 BASEPROPERTY_VALUEMAX_DOUBLE
,
6043 BASEPROPERTY_VALUEMIN_DOUBLE
,
6044 BASEPROPERTY_VALUESTEP_DOUBLE
,
6045 BASEPROPERTY_VALUE_DOUBLE
,
6046 BASEPROPERTY_ENFORCE_FORMAT
,
6047 BASEPROPERTY_HIDEINACTIVESELECTION
,
6048 BASEPROPERTY_VERTICALALIGN
,
6049 BASEPROPERTY_WRITING_MODE
,
6050 BASEPROPERTY_CONTEXT_WRITING_MODE
,
6051 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR
,
6053 VCLXFormattedSpinField::ImplGetPropertyIds( rIds
);
6056 VCLXCurrencyField::VCLXCurrencyField()
6060 VCLXCurrencyField::~VCLXCurrencyField()
6064 // ::com::sun::star::uno::XInterface
6065 ::com::sun::star::uno::Any
VCLXCurrencyField::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6067 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
6068 (static_cast< ::com::sun::star::awt::XCurrencyField
* >(this)) );
6069 return (aRet
.hasValue() ? aRet
: VCLXFormattedSpinField::queryInterface( rType
));
6072 // ::com::sun::star::lang::XTypeProvider
6073 IMPL_XTYPEPROVIDER_START( VCLXCurrencyField
)
6074 cppu::UnoType
<com::sun::star::awt::XCurrencyField
>::get(),
6075 VCLXFormattedSpinField::getTypes()
6076 IMPL_XTYPEPROVIDER_END
6078 void VCLXCurrencyField::setValue( double Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6080 SolarMutexGuard aGuard
;
6082 LongCurrencyFormatter
* pCurrencyFormatter
= static_cast<LongCurrencyFormatter
*>(GetFormatter());
6083 if ( pCurrencyFormatter
)
6085 // shift long value using decimal digits
6086 // (e.g., input 105 using 2 digits returns 1,05)
6087 // Thus, to set a value of 1,05, insert 105 and 2 digits
6088 pCurrencyFormatter
->SetValue(
6089 ImplCalcLongValue( Value
, pCurrencyFormatter
->GetDecimalDigits() ) );
6091 // #107218# Call same listeners like VCL would do after user interaction
6092 Edit
* pEdit
= static_cast<Edit
*>(GetWindow());
6095 SetSynthesizingVCLEvent( true );
6096 pEdit
->SetModifyFlag();
6098 SetSynthesizingVCLEvent( false );
6103 double VCLXCurrencyField::getValue() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6105 SolarMutexGuard aGuard
;
6107 LongCurrencyFormatter
* pCurrencyFormatter
= static_cast<LongCurrencyFormatter
*>(GetFormatter());
6108 return pCurrencyFormatter
6109 ? ImplCalcDoubleValue( (double)pCurrencyFormatter
->GetValue(), pCurrencyFormatter
->GetDecimalDigits() )
6113 void VCLXCurrencyField::setMin( double Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6115 SolarMutexGuard aGuard
;
6117 LongCurrencyFormatter
* pCurrencyFormatter
= static_cast<LongCurrencyFormatter
*>(GetFormatter());
6118 if ( pCurrencyFormatter
)
6119 pCurrencyFormatter
->SetMin(
6120 ImplCalcLongValue( Value
, pCurrencyFormatter
->GetDecimalDigits() ) );
6123 double VCLXCurrencyField::getMin() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6125 SolarMutexGuard aGuard
;
6127 LongCurrencyFormatter
* pCurrencyFormatter
= static_cast<LongCurrencyFormatter
*>(GetFormatter());
6128 return pCurrencyFormatter
6129 ? ImplCalcDoubleValue( (double)pCurrencyFormatter
->GetMin(), pCurrencyFormatter
->GetDecimalDigits() )
6133 void VCLXCurrencyField::setMax( double Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6135 SolarMutexGuard aGuard
;
6137 LongCurrencyFormatter
* pCurrencyFormatter
= static_cast<LongCurrencyFormatter
*>(GetFormatter());
6138 if ( pCurrencyFormatter
)
6139 pCurrencyFormatter
->SetMax(
6140 ImplCalcLongValue( Value
, pCurrencyFormatter
->GetDecimalDigits() ) );
6143 double VCLXCurrencyField::getMax() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6145 SolarMutexGuard aGuard
;
6147 LongCurrencyFormatter
* pCurrencyFormatter
= static_cast<LongCurrencyFormatter
*>(GetFormatter());
6148 return pCurrencyFormatter
6149 ? ImplCalcDoubleValue( (double)pCurrencyFormatter
->GetMax(), pCurrencyFormatter
->GetDecimalDigits() )
6153 void VCLXCurrencyField::setFirst( double Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6155 SolarMutexGuard aGuard
;
6157 LongCurrencyField
* pCurrencyField
= static_cast<LongCurrencyField
*>(GetWindow());
6158 if ( pCurrencyField
)
6159 pCurrencyField
->SetFirst(
6160 ImplCalcLongValue( Value
, pCurrencyField
->GetDecimalDigits() ) );
6163 double VCLXCurrencyField::getFirst() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6165 SolarMutexGuard aGuard
;
6167 LongCurrencyField
* pCurrencyField
= static_cast<LongCurrencyField
*>(GetWindow());
6168 return pCurrencyField
6169 ? ImplCalcDoubleValue( (double)pCurrencyField
->GetFirst(), pCurrencyField
->GetDecimalDigits() )
6173 void VCLXCurrencyField::setLast( double Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6175 SolarMutexGuard aGuard
;
6177 LongCurrencyField
* pCurrencyField
= static_cast<LongCurrencyField
*>(GetWindow());
6178 if ( pCurrencyField
)
6179 pCurrencyField
->SetLast(
6180 ImplCalcLongValue( Value
, pCurrencyField
->GetDecimalDigits() ) );
6183 double VCLXCurrencyField::getLast() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6185 SolarMutexGuard aGuard
;
6187 LongCurrencyField
* pCurrencyField
= static_cast<LongCurrencyField
*>(GetWindow());
6188 return pCurrencyField
6189 ? ImplCalcDoubleValue( (double)pCurrencyField
->GetLast(), pCurrencyField
->GetDecimalDigits() )
6193 void VCLXCurrencyField::setSpinSize( double Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6195 SolarMutexGuard aGuard
;
6197 LongCurrencyField
* pCurrencyField
= static_cast<LongCurrencyField
*>(GetWindow());
6198 if ( pCurrencyField
)
6199 pCurrencyField
->SetSpinSize(
6200 ImplCalcLongValue( Value
, pCurrencyField
->GetDecimalDigits() ) );
6203 double VCLXCurrencyField::getSpinSize() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6205 SolarMutexGuard aGuard
;
6207 LongCurrencyField
* pCurrencyField
= static_cast<LongCurrencyField
*>(GetWindow());
6208 return pCurrencyField
6209 ? ImplCalcDoubleValue( (double)pCurrencyField
->GetSpinSize(), pCurrencyField
->GetDecimalDigits() )
6213 void VCLXCurrencyField::setStrictFormat( sal_Bool bStrict
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6215 VCLXFormattedSpinField::setStrictFormat( bStrict
);
6218 sal_Bool
VCLXCurrencyField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6220 return VCLXFormattedSpinField::isStrictFormat();
6224 void VCLXCurrencyField::setDecimalDigits( sal_Int16 Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6226 SolarMutexGuard aGuard
;
6228 LongCurrencyFormatter
* pCurrencyFormatter
= static_cast<LongCurrencyFormatter
*>(GetFormatter());
6229 if ( pCurrencyFormatter
)
6231 double n
= getValue();
6232 pCurrencyFormatter
->SetDecimalDigits( Value
);
6237 sal_Int16
VCLXCurrencyField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6239 SolarMutexGuard aGuard
;
6241 LongCurrencyFormatter
* pCurrencyFormatter
= static_cast<LongCurrencyFormatter
*>(GetFormatter());
6242 return pCurrencyFormatter
? pCurrencyFormatter
->GetDecimalDigits() : 0;
6245 void VCLXCurrencyField::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6247 SolarMutexGuard aGuard
;
6251 bool bVoid
= Value
.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID
;
6253 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
6254 switch ( nPropType
)
6256 case BASEPROPERTY_VALUE_DOUBLE
:
6260 static_cast<LongCurrencyField
*>(GetWindow())->EnableEmptyFieldValue( true );
6261 static_cast<LongCurrencyField
*>(GetWindow())->SetEmptyFieldValue();
6271 case BASEPROPERTY_VALUEMIN_DOUBLE
:
6278 case BASEPROPERTY_VALUEMAX_DOUBLE
:
6285 case BASEPROPERTY_VALUESTEP_DOUBLE
:
6292 case BASEPROPERTY_DECIMALACCURACY
:
6294 sal_Int16 n
= sal_Int16();
6296 setDecimalDigits( n
);
6299 case BASEPROPERTY_CURRENCYSYMBOL
:
6302 if ( Value
>>= aString
)
6303 static_cast<LongCurrencyField
*>(GetWindow())->SetCurrencySymbol( aString
);
6306 case BASEPROPERTY_NUMSHOWTHOUSANDSEP
:
6310 static_cast<LongCurrencyField
*>(GetWindow())->SetUseThousandSep( b
);
6315 VCLXFormattedSpinField::setProperty( PropertyName
, Value
);
6321 ::com::sun::star::uno::Any
VCLXCurrencyField::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6323 SolarMutexGuard aGuard
;
6325 ::com::sun::star::uno::Any aProp
;
6326 FormatterBase
* pFormatter
= GetFormatter();
6329 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
6330 switch ( nPropType
)
6332 case BASEPROPERTY_VALUE_DOUBLE
:
6334 aProp
<<= (double) getValue();
6337 case BASEPROPERTY_VALUEMIN_DOUBLE
:
6339 aProp
<<= (double) getMin();
6342 case BASEPROPERTY_VALUEMAX_DOUBLE
:
6344 aProp
<<= (double) getMax();
6347 case BASEPROPERTY_VALUESTEP_DOUBLE
:
6349 aProp
<<= (double) getSpinSize();
6352 case BASEPROPERTY_CURRENCYSYMBOL
:
6354 aProp
<<= OUString( static_cast<LongCurrencyField
*>(GetWindow())->GetCurrencySymbol() );
6357 case BASEPROPERTY_NUMSHOWTHOUSANDSEP
:
6359 aProp
<<= static_cast<LongCurrencyField
*>(GetWindow())->IsUseThousandSep();
6364 aProp
<<= VCLXFormattedSpinField::getProperty( PropertyName
);
6372 // class VCLXPatternField
6375 void VCLXPatternField::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
6377 PushPropertyIds( rIds
,
6379 BASEPROPERTY_BACKGROUNDCOLOR
,
6380 BASEPROPERTY_BORDER
,
6381 BASEPROPERTY_BORDERCOLOR
,
6382 BASEPROPERTY_DEFAULTCONTROL
,
6383 BASEPROPERTY_EDITMASK
,
6384 BASEPROPERTY_ENABLED
,
6385 BASEPROPERTY_ENABLEVISIBLE
,
6386 BASEPROPERTY_FONTDESCRIPTOR
,
6387 BASEPROPERTY_HELPTEXT
,
6388 BASEPROPERTY_HELPURL
,
6389 BASEPROPERTY_LITERALMASK
,
6390 BASEPROPERTY_MAXTEXTLEN
,
6391 BASEPROPERTY_PRINTABLE
,
6392 BASEPROPERTY_READONLY
,
6393 BASEPROPERTY_STRICTFORMAT
,
6394 BASEPROPERTY_TABSTOP
,
6396 BASEPROPERTY_HIDEINACTIVESELECTION
,
6397 BASEPROPERTY_VERTICALALIGN
,
6398 BASEPROPERTY_WRITING_MODE
,
6399 BASEPROPERTY_CONTEXT_WRITING_MODE
,
6400 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR
,
6402 VCLXFormattedSpinField::ImplGetPropertyIds( rIds
);
6405 VCLXPatternField::VCLXPatternField()
6409 VCLXPatternField::~VCLXPatternField()
6413 // ::com::sun::star::uno::XInterface
6414 ::com::sun::star::uno::Any
VCLXPatternField::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6416 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
6417 (static_cast< ::com::sun::star::awt::XPatternField
* >(this)) );
6418 return (aRet
.hasValue() ? aRet
: VCLXFormattedSpinField::queryInterface( rType
));
6421 // ::com::sun::star::lang::XTypeProvider
6422 IMPL_XTYPEPROVIDER_START( VCLXPatternField
)
6423 cppu::UnoType
<com::sun::star::awt::XPatternField
>::get(),
6424 VCLXFormattedSpinField::getTypes()
6425 IMPL_XTYPEPROVIDER_END
6427 void VCLXPatternField::setMasks( const OUString
& EditMask
, const OUString
& LiteralMask
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6429 SolarMutexGuard aGuard
;
6431 PatternField
* pPatternField
= static_cast<PatternField
*>(GetWindow());
6432 if ( pPatternField
)
6434 pPatternField
->SetMask( OUStringToOString(EditMask
, RTL_TEXTENCODING_ASCII_US
), LiteralMask
);
6438 void VCLXPatternField::getMasks( OUString
& EditMask
, OUString
& LiteralMask
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6440 SolarMutexGuard aGuard
;
6442 PatternField
* pPatternField
= static_cast<PatternField
*>(GetWindow());
6443 if ( pPatternField
)
6445 EditMask
= OStringToOUString(pPatternField
->GetEditMask(), RTL_TEXTENCODING_ASCII_US
);
6446 LiteralMask
= pPatternField
->GetLiteralMask();
6450 void VCLXPatternField::setString( const OUString
& Str
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6452 SolarMutexGuard aGuard
;
6454 PatternField
* pPatternField
= static_cast<PatternField
*>(GetWindow());
6455 if ( pPatternField
)
6457 pPatternField
->SetString( Str
);
6461 OUString
VCLXPatternField::getString() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6463 SolarMutexGuard aGuard
;
6466 PatternField
* pPatternField
= static_cast<PatternField
*>(GetWindow());
6467 if ( pPatternField
)
6468 aString
= pPatternField
->GetString();
6472 void VCLXPatternField::setStrictFormat( sal_Bool bStrict
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6474 VCLXFormattedSpinField::setStrictFormat( bStrict
);
6477 sal_Bool
VCLXPatternField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6479 return VCLXFormattedSpinField::isStrictFormat();
6482 void VCLXPatternField::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6484 SolarMutexGuard aGuard
;
6488 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
6489 switch ( nPropType
)
6491 case BASEPROPERTY_EDITMASK
:
6492 case BASEPROPERTY_LITERALMASK
:
6495 if ( Value
>>= aString
)
6497 OUString aEditMask
, aLiteralMask
;
6498 getMasks( aEditMask
, aLiteralMask
);
6499 if ( nPropType
== BASEPROPERTY_EDITMASK
)
6500 aEditMask
= aString
;
6502 aLiteralMask
= aString
;
6503 setMasks( aEditMask
, aLiteralMask
);
6509 VCLXFormattedSpinField::setProperty( PropertyName
, Value
);
6515 ::com::sun::star::uno::Any
VCLXPatternField::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6517 SolarMutexGuard aGuard
;
6519 ::com::sun::star::uno::Any aProp
;
6522 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
6523 switch ( nPropType
)
6525 case BASEPROPERTY_EDITMASK
:
6526 case BASEPROPERTY_LITERALMASK
:
6528 OUString aEditMask
, aLiteralMask
;
6529 getMasks( aEditMask
, aLiteralMask
);
6530 if ( nPropType
== BASEPROPERTY_EDITMASK
)
6531 aProp
<<= aEditMask
;
6533 aProp
<<= aLiteralMask
;
6538 aProp
<<= VCLXFormattedSpinField::getProperty( PropertyName
);
6546 // class VCLXToolBox
6548 VCLXToolBox::VCLXToolBox()
6552 VCLXToolBox::~VCLXToolBox()
6556 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> VCLXToolBox::CreateAccessibleContext()
6558 return getAccessibleFactory().createAccessibleContext( this );
6564 VCLXFrame::VCLXFrame()
6568 void VCLXFrame::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
6570 PushPropertyIds( rIds
,
6571 BASEPROPERTY_BACKGROUNDCOLOR
,
6572 BASEPROPERTY_DEFAULTCONTROL
,
6573 BASEPROPERTY_ENABLED
,
6574 BASEPROPERTY_ENABLEVISIBLE
,
6575 BASEPROPERTY_FONTDESCRIPTOR
,
6576 BASEPROPERTY_GRAPHIC
,
6577 BASEPROPERTY_HELPTEXT
,
6578 BASEPROPERTY_HELPURL
,
6579 BASEPROPERTY_PRINTABLE
,
6582 VCLXContainer::ImplGetPropertyIds( rIds
);
6585 VCLXFrame::~VCLXFrame()
6589 ::com::sun::star::uno::Any SAL_CALL
VCLXFrame::queryInterface(const ::com::sun::star::uno::Type
& rType
)
6590 throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6592 return VCLXContainer::queryInterface( rType
);
6595 // ::com::sun::star::lang::XTypeProvider
6596 IMPL_XTYPEPROVIDER_START( VCLXFrame
)
6597 VCLXContainer::getTypes()
6598 IMPL_XTYPEPROVIDER_END
6600 // ::com::sun::star::awt::XView
6601 void SAL_CALL
VCLXFrame::draw( sal_Int32 nX
, sal_Int32 nY
)
6602 throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6604 SolarMutexGuard aGuard
;
6605 vcl::Window
* pWindow
= GetWindow();
6609 OutputDevice
* pDev
= VCLUnoHelper::GetOutputDevice( getGraphics() );
6611 pDev
= pWindow
->GetParent();
6613 Size aSize
= pDev
->PixelToLogic( pWindow
->GetSizePixel() );
6614 Point aPos
= pDev
->PixelToLogic( Point( nX
, nY
) );
6616 pWindow
->Draw( pDev
, aPos
, aSize
, WINDOW_DRAW_NOCONTROLS
);
6620 // ::com::sun::star::awt::XDevice,
6621 ::com::sun::star::awt::DeviceInfo SAL_CALL
VCLXFrame::getInfo()
6622 throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6624 ::com::sun::star::awt::DeviceInfo aInfo
= VCLXDevice::getInfo();
6628 void SAL_CALL
VCLXFrame::setProperty(
6629 const OUString
& PropertyName
,
6630 const ::com::sun::star::uno::Any
& Value
)
6631 throw(::com::sun::star::uno::RuntimeException
, std::exception
)
6633 SolarMutexGuard aGuard
;
6635 VCLXContainer::setProperty( PropertyName
, Value
);
6638 void VCLXFrame::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
6640 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xKeepAlive( this );
6641 VCLXContainer::ProcessWindowEvent( rVclWindowEvent
);
6644 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */