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 <toolkit/helper/imagealign.hxx>
30 #include <toolkit/helper/accessibilityclient.hxx>
31 #include <toolkit/helper/tkresmgr.hxx>
32 #include <cppuhelper/typeprovider.hxx>
33 #include <com/sun/star/awt/VisualEffect.hpp>
34 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
35 #include <com/sun/star/system/SystemShellExecute.hpp>
36 #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
37 #include <com/sun/star/resource/XStringResourceResolver.hpp>
38 #include <com/sun/star/awt/ImageScaleMode.hpp>
39 #include <com/sun/star/awt/XItemList.hpp>
40 #include <comphelper/componentcontext.hxx>
41 #include <comphelper/namedvaluecollection.hxx>
42 #include <comphelper/processfactory.hxx>
44 #include <vcl/button.hxx>
45 #include <vcl/lstbox.hxx>
46 #include <vcl/combobox.hxx>
47 #include <vcl/field.hxx>
48 #include <vcl/fixedhyper.hxx>
49 #include <vcl/longcurr.hxx>
50 #include <vcl/imgctrl.hxx>
51 #include <vcl/dialog.hxx>
52 #include <vcl/msgbox.hxx>
53 #include <vcl/scrbar.hxx>
54 #include <vcl/svapp.hxx>
55 #include <vcl/tabpage.hxx>
56 #include <vcl/tabctrl.hxx>
57 #include <tools/diagnose_ex.h>
59 #include <boost/bind.hpp>
60 #include <boost/function.hpp>
62 #include <vcl/group.hxx>
63 using ::com::sun::star::uno::Any
;
64 using ::com::sun::star::uno::Reference
;
65 using ::com::sun::star::uno::makeAny
;
66 using ::com::sun::star::uno::RuntimeException
;
67 using ::com::sun::star::lang::EventObject
;
68 using ::com::sun::star::awt::ItemListEvent
;
69 using ::com::sun::star::awt::XItemList
;
70 using ::com::sun::star::graphic::XGraphic
;
71 using ::com::sun::star::graphic::XGraphicProvider
;
73 using namespace ::com::sun::star
;
74 using namespace ::com::sun::star::awt::VisualEffect
;
75 namespace ImageScaleMode
= ::com::sun::star::awt::ImageScaleMode
;
77 static double ImplCalcLongValue( double nValue
, sal_uInt16 nDigits
)
80 for ( sal_uInt16 d
= 0; d
< nDigits
; d
++ )
85 static double ImplCalcDoubleValue( double nValue
, sal_uInt16 nDigits
)
88 for ( sal_uInt16 d
= 0; d
< nDigits
; d
++ )
95 /** sets the "face color" for button like controls (scroll bar, spin button)
97 void setButtonLikeFaceColor( Window
* _pWindow
, const ::com::sun::star::uno::Any
& _rColorValue
)
99 AllSettings aSettings
= _pWindow
->GetSettings();
100 StyleSettings aStyleSettings
= aSettings
.GetStyleSettings();
102 if ( !_rColorValue
.hasValue() )
104 const StyleSettings
& aAppStyle
= Application::GetSettings().GetStyleSettings();
105 aStyleSettings
.SetFaceColor( aAppStyle
.GetFaceColor( ) );
106 aStyleSettings
.SetCheckedColor( aAppStyle
.GetCheckedColor( ) );
107 aStyleSettings
.SetLightBorderColor( aAppStyle
.GetLightBorderColor() );
108 aStyleSettings
.SetLightColor( aAppStyle
.GetLightColor() );
109 aStyleSettings
.SetShadowColor( aAppStyle
.GetShadowColor() );
110 aStyleSettings
.SetDarkShadowColor( aAppStyle
.GetDarkShadowColor() );
114 sal_Int32 nBackgroundColor
= 0;
115 _rColorValue
>>= nBackgroundColor
;
116 aStyleSettings
.SetFaceColor( nBackgroundColor
);
118 // for the real background (everything except the buttons and the thumb),
119 // use an average between the desired color and "white"
120 Color
aWhite( COL_WHITE
);
121 Color
aBackground( nBackgroundColor
);
122 aBackground
.SetRed( ( aBackground
.GetRed() + aWhite
.GetRed() ) / 2 );
123 aBackground
.SetGreen( ( aBackground
.GetGreen() + aWhite
.GetGreen() ) / 2 );
124 aBackground
.SetBlue( ( aBackground
.GetBlue() + aWhite
.GetBlue() ) / 2 );
125 aStyleSettings
.SetCheckedColor( aBackground
);
127 sal_Int32 nBackgroundLuminance
= Color( nBackgroundColor
).GetLuminance();
128 sal_Int32 nWhiteLuminance
= Color( COL_WHITE
).GetLuminance();
130 Color
aLightShadow( nBackgroundColor
);
131 aLightShadow
.IncreaseLuminance( (sal_uInt8
)( ( nWhiteLuminance
- nBackgroundLuminance
) * 2 / 3 ) );
132 aStyleSettings
.SetLightBorderColor( aLightShadow
);
134 Color
aLight( nBackgroundColor
);
135 aLight
.IncreaseLuminance( (sal_uInt8
)( ( nWhiteLuminance
- nBackgroundLuminance
) * 1 / 3 ) );
136 aStyleSettings
.SetLightColor( aLight
);
138 Color
aShadow( nBackgroundColor
);
139 aShadow
.DecreaseLuminance( (sal_uInt8
)( nBackgroundLuminance
* 1 / 3 ) );
140 aStyleSettings
.SetShadowColor( aShadow
);
142 Color
aDarkShadow( nBackgroundColor
);
143 aDarkShadow
.DecreaseLuminance( (sal_uInt8
)( nBackgroundLuminance
* 2 / 3 ) );
144 aStyleSettings
.SetDarkShadowColor( aDarkShadow
);
147 aSettings
.SetStyleSettings( aStyleSettings
);
148 _pWindow
->SetSettings( aSettings
, sal_True
);
151 Any
getButtonLikeFaceColor( const Window
* _pWindow
)
153 sal_Int32 nBackgroundColor
= _pWindow
->GetSettings().GetStyleSettings().GetFaceColor().GetColor();
154 return makeAny( nBackgroundColor
);
157 static void adjustBooleanWindowStyle( const Any
& _rValue
, Window
* _pWindow
, WinBits _nBits
, sal_Bool _bInverseSemantics
)
159 WinBits nStyle
= _pWindow
->GetStyle();
160 sal_Bool
bValue( sal_False
);
161 OSL_VERIFY( _rValue
>>= bValue
);
162 if ( bValue
!= _bInverseSemantics
)
166 _pWindow
->SetStyle( nStyle
);
169 static void setVisualEffect( const Any
& _rValue
, Window
* _pWindow
)
171 AllSettings aSettings
= _pWindow
->GetSettings();
172 StyleSettings aStyleSettings
= aSettings
.GetStyleSettings();
174 sal_Int16 nStyle
= LOOK3D
;
175 OSL_VERIFY( _rValue
>>= nStyle
);
179 aStyleSettings
.SetOptions( aStyleSettings
.GetOptions() & ~STYLE_OPTION_MONO
);
183 aStyleSettings
.SetOptions( aStyleSettings
.GetOptions() | STYLE_OPTION_MONO
);
185 aSettings
.SetStyleSettings( aStyleSettings
);
186 _pWindow
->SetSettings( aSettings
);
189 static Any
getVisualEffect( Window
* _pWindow
)
193 StyleSettings aStyleSettings
= _pWindow
->GetSettings().GetStyleSettings();
194 if ( (aStyleSettings
.GetOptions() & STYLE_OPTION_MONO
) )
195 aEffect
<<= (sal_Int16
)FLAT
;
197 aEffect
<<= (sal_Int16
)LOOK3D
;
202 // ----------------------------------------------------
203 // class VCLXGraphicControl
204 // ----------------------------------------------------
206 void VCLXGraphicControl::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
208 VCLXWindow::ImplGetPropertyIds( rIds
);
211 void VCLXGraphicControl::ImplSetNewImage()
213 OSL_PRECOND( GetWindow(), "VCLXGraphicControl::ImplSetNewImage: window is required to be not-NULL!" );
214 Button
* pButton
= static_cast< Button
* >( GetWindow() );
215 pButton
->SetModeImage( GetImage() );
218 void VCLXGraphicControl::setPosSize( sal_Int32 X
, sal_Int32 Y
, sal_Int32 Width
, sal_Int32 Height
, short Flags
) throw(::com::sun::star::uno::RuntimeException
)
220 SolarMutexGuard aGuard
;
224 Size aOldSize
= GetWindow()->GetSizePixel();
225 VCLXWindow::setPosSize( X
, Y
, Width
, Height
, Flags
);
226 if ( ( aOldSize
.Width() != Width
) || ( aOldSize
.Height() != Height
) )
231 void VCLXGraphicControl::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
)
233 SolarMutexGuard aGuard
;
235 Button
* pButton
= static_cast< Button
* >( GetWindow() );
238 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
241 case BASEPROPERTY_GRAPHIC
:
243 Reference
< XGraphic
> xGraphic
;
244 OSL_VERIFY( Value
>>= xGraphic
);
245 maImage
= Image( xGraphic
);
250 case BASEPROPERTY_IMAGEALIGN
:
252 WindowType eType
= GetWindow()->GetType();
253 if ( ( eType
== WINDOW_PUSHBUTTON
)
254 || ( eType
== WINDOW_RADIOBUTTON
)
255 || ( eType
== WINDOW_CHECKBOX
)
258 sal_Int16 nAlignment
= sal_Int16();
259 if ( Value
>>= nAlignment
)
260 pButton
->SetImageAlign( static_cast< ImageAlign
>( nAlignment
) );
264 case BASEPROPERTY_IMAGEPOSITION
:
266 WindowType eType
= GetWindow()->GetType();
267 if ( ( eType
== WINDOW_PUSHBUTTON
)
268 || ( eType
== WINDOW_RADIOBUTTON
)
269 || ( eType
== WINDOW_CHECKBOX
)
272 sal_Int16 nImagePosition
= 2;
273 OSL_VERIFY( Value
>>= nImagePosition
);
274 pButton
->SetImageAlign( ::toolkit::translateImagePosition( nImagePosition
) );
279 VCLXWindow::setProperty( PropertyName
, Value
);
284 ::com::sun::star::uno::Any
VCLXGraphicControl::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
)
286 SolarMutexGuard aGuard
;
288 ::com::sun::star::uno::Any aProp
;
292 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
295 case BASEPROPERTY_GRAPHIC
:
296 aProp
<<= maImage
.GetXGraphic();
298 case BASEPROPERTY_IMAGEALIGN
:
300 WindowType eType
= GetWindow()->GetType();
301 if ( ( eType
== WINDOW_PUSHBUTTON
)
302 || ( eType
== WINDOW_RADIOBUTTON
)
303 || ( eType
== WINDOW_CHECKBOX
)
306 aProp
<<= ::toolkit::getCompatibleImageAlign( static_cast< Button
* >( GetWindow() )->GetImageAlign() );
310 case BASEPROPERTY_IMAGEPOSITION
:
312 WindowType eType
= GetWindow()->GetType();
313 if ( ( eType
== WINDOW_PUSHBUTTON
)
314 || ( eType
== WINDOW_RADIOBUTTON
)
315 || ( eType
== WINDOW_CHECKBOX
)
318 aProp
<<= ::toolkit::translateImagePosition( static_cast< Button
* >( GetWindow() )->GetImageAlign() );
324 aProp
<<= VCLXWindow::getProperty( PropertyName
);
331 //--------------------------------------------------------------------
333 // ----------------------------------------------------
335 void VCLXButton::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
337 PushPropertyIds( rIds
,
338 BASEPROPERTY_BACKGROUNDCOLOR
,
339 BASEPROPERTY_DEFAULTBUTTON
,
340 BASEPROPERTY_DEFAULTCONTROL
,
341 BASEPROPERTY_ENABLED
,
342 BASEPROPERTY_ENABLEVISIBLE
,
343 BASEPROPERTY_FONTDESCRIPTOR
,
344 BASEPROPERTY_GRAPHIC
,
345 BASEPROPERTY_HELPTEXT
,
346 BASEPROPERTY_HELPURL
,
347 BASEPROPERTY_IMAGEALIGN
,
348 BASEPROPERTY_IMAGEPOSITION
,
349 BASEPROPERTY_IMAGEURL
,
351 BASEPROPERTY_PRINTABLE
,
352 BASEPROPERTY_PUSHBUTTONTYPE
,
354 BASEPROPERTY_REPEAT_DELAY
,
356 BASEPROPERTY_TABSTOP
,
358 BASEPROPERTY_FOCUSONCLICK
,
359 BASEPROPERTY_MULTILINE
,
361 BASEPROPERTY_VERTICALALIGN
,
362 BASEPROPERTY_WRITING_MODE
,
363 BASEPROPERTY_CONTEXT_WRITING_MODE
,
364 BASEPROPERTY_REFERENCE_DEVICE
,
366 VCLXGraphicControl::ImplGetPropertyIds( rIds
);
369 VCLXButton::VCLXButton()
370 :maActionListeners( *this )
371 ,maItemListeners( *this )
375 VCLXButton::~VCLXButton()
379 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> VCLXButton::CreateAccessibleContext()
381 return getAccessibleFactory().createAccessibleContext( this );
384 void VCLXButton::dispose() throw(::com::sun::star::uno::RuntimeException
)
386 SolarMutexGuard aGuard
;
388 ::com::sun::star::lang::EventObject aObj
;
389 aObj
.Source
= (::cppu::OWeakObject
*)this;
390 maActionListeners
.disposeAndClear( aObj
);
391 maItemListeners
.disposeAndClear( aObj
);
392 VCLXGraphicControl::dispose();
395 void VCLXButton::addActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
> & l
)throw(::com::sun::star::uno::RuntimeException
)
397 SolarMutexGuard aGuard
;
398 maActionListeners
.addInterface( l
);
401 void VCLXButton::removeActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
> & l
) throw(::com::sun::star::uno::RuntimeException
)
403 SolarMutexGuard aGuard
;
404 maActionListeners
.removeInterface( l
);
407 void VCLXButton::addItemListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XItemListener
> & l
)throw(::com::sun::star::uno::RuntimeException
)
409 SolarMutexGuard aGuard
;
410 maItemListeners
.addInterface( l
);
413 void VCLXButton::removeItemListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XItemListener
> & l
) throw(::com::sun::star::uno::RuntimeException
)
415 SolarMutexGuard aGuard
;
416 maItemListeners
.removeInterface( l
);
419 void VCLXButton::setLabel( const OUString
& rLabel
) throw(::com::sun::star::uno::RuntimeException
)
421 SolarMutexGuard aGuard
;
423 Window
* pWindow
= GetWindow();
425 pWindow
->SetText( rLabel
);
428 void VCLXButton::setActionCommand( const OUString
& rCommand
) throw(::com::sun::star::uno::RuntimeException
)
430 SolarMutexGuard aGuard
;
432 maActionCommand
= rCommand
;
435 ::com::sun::star::awt::Size
VCLXButton::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException
)
437 SolarMutexGuard aGuard
;
440 PushButton
* pButton
= (PushButton
*) GetWindow();
442 aSz
= pButton
->CalcMinimumSize();
446 ::com::sun::star::awt::Size
VCLXButton::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException
)
448 ::com::sun::star::awt::Size aSz
= getMinimumSize();
454 ::com::sun::star::awt::Size
VCLXButton::calcAdjustedSize( const ::com::sun::star::awt::Size
& rNewSize
) throw(::com::sun::star::uno::RuntimeException
)
456 SolarMutexGuard aGuard
;
458 Size aSz
= VCLSize(rNewSize
);
459 PushButton
* pButton
= (PushButton
*) GetWindow();
462 Size aMinSz
= pButton
->CalcMinimumSize();
463 // no text, thus image
464 if ( pButton
->GetText().isEmpty() )
466 if ( aSz
.Width() < aMinSz
.Width() )
467 aSz
.Width() = aMinSz
.Width();
468 if ( aSz
.Height() < aMinSz
.Height() )
469 aSz
.Height() = aMinSz
.Height();
473 if ( ( aSz
.Width() > aMinSz
.Width() ) && ( aSz
.Height() < aMinSz
.Height() ) )
474 aSz
.Height() = aMinSz
.Height();
482 void VCLXButton::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
)
484 SolarMutexGuard aGuard
;
486 Button
* pButton
= (Button
*)GetWindow();
489 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
492 case BASEPROPERTY_FOCUSONCLICK
:
493 ::toolkit::adjustBooleanWindowStyle( Value
, pButton
, WB_NOPOINTERFOCUS
, sal_True
);
496 case BASEPROPERTY_TOGGLE
:
497 ::toolkit::adjustBooleanWindowStyle( Value
, pButton
, WB_TOGGLE
, sal_False
);
500 case BASEPROPERTY_DEFAULTBUTTON
:
502 WinBits nStyle
= pButton
->GetStyle() | WB_DEFBUTTON
;
503 sal_Bool b
= sal_Bool();
504 if ( ( Value
>>= b
) && !b
)
505 nStyle
&= ~WB_DEFBUTTON
;
506 pButton
->SetStyle( nStyle
);
509 case BASEPROPERTY_STATE
:
511 if ( GetWindow()->GetType() == WINDOW_PUSHBUTTON
)
513 sal_Int16 n
= sal_Int16();
515 ((PushButton
*)pButton
)->SetState( (TriState
)n
);
521 VCLXGraphicControl::setProperty( PropertyName
, Value
);
527 ::com::sun::star::uno::Any
VCLXButton::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
)
529 SolarMutexGuard aGuard
;
531 ::com::sun::star::uno::Any aProp
;
532 Button
* pButton
= (Button
*)GetWindow();
535 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
538 case BASEPROPERTY_FOCUSONCLICK
:
539 aProp
<<= (sal_Bool
)( ( pButton
->GetStyle() & WB_NOPOINTERFOCUS
) == 0 );
542 case BASEPROPERTY_TOGGLE
:
543 aProp
<<= (sal_Bool
)( ( pButton
->GetStyle() & WB_TOGGLE
) != 0 );
546 case BASEPROPERTY_DEFAULTBUTTON
:
548 aProp
<<= (sal_Bool
) ( ( pButton
->GetStyle() & WB_DEFBUTTON
) ? sal_True
: sal_False
);
551 case BASEPROPERTY_STATE
:
553 if ( GetWindow()->GetType() == WINDOW_PUSHBUTTON
)
555 aProp
<<= (sal_Int16
)((PushButton
*)pButton
)->GetState();
561 aProp
<<= VCLXGraphicControl::getProperty( PropertyName
);
568 void VCLXButton::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
570 switch ( rVclWindowEvent
.GetId() )
572 case VCLEVENT_BUTTON_CLICK
:
574 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xKeepAlive( this );
575 // since we call listeners below, there is a potential that we will be destroyed
576 // during the listener call. To prevent the resulting crashs, we keep us
577 // alive as long as we're here
579 if ( maActionListeners
.getLength() )
581 ::com::sun::star::awt::ActionEvent aEvent
;
582 aEvent
.Source
= (::cppu::OWeakObject
*)this;
583 aEvent
.ActionCommand
= maActionCommand
;
585 Callback aCallback
= ::boost::bind(
586 &ActionListenerMultiplexer::actionPerformed
,
590 ImplExecuteAsyncWithoutSolarLock( aCallback
);
595 case VCLEVENT_PUSHBUTTON_TOGGLE
:
597 PushButton
& rButton
= dynamic_cast< PushButton
& >( *rVclWindowEvent
.GetWindow() );
599 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xKeepAlive( this );
600 if ( maItemListeners
.getLength() )
602 ::com::sun::star::awt::ItemEvent aEvent
;
603 aEvent
.Source
= (::cppu::OWeakObject
*)this;
604 aEvent
.Selected
= ( rButton
.GetState() == STATE_CHECK
) ? 1 : 0;
605 maItemListeners
.itemStateChanged( aEvent
);
611 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent
);
616 // ----------------------------------------------------
617 // class VCLXImageControl
618 // ----------------------------------------------------
620 void VCLXImageControl::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
622 PushPropertyIds( rIds
,
623 BASEPROPERTY_BACKGROUNDCOLOR
,
625 BASEPROPERTY_BORDERCOLOR
,
626 BASEPROPERTY_DEFAULTCONTROL
,
627 BASEPROPERTY_ENABLED
,
628 BASEPROPERTY_ENABLEVISIBLE
,
629 BASEPROPERTY_GRAPHIC
,
630 BASEPROPERTY_HELPTEXT
,
631 BASEPROPERTY_HELPURL
,
632 BASEPROPERTY_IMAGEURL
,
633 BASEPROPERTY_PRINTABLE
,
634 BASEPROPERTY_SCALEIMAGE
,
635 BASEPROPERTY_IMAGE_SCALE_MODE
,
636 BASEPROPERTY_TABSTOP
,
637 BASEPROPERTY_WRITING_MODE
,
638 BASEPROPERTY_CONTEXT_WRITING_MODE
,
640 VCLXGraphicControl::ImplGetPropertyIds( rIds
);
643 VCLXImageControl::VCLXImageControl()
647 VCLXImageControl::~VCLXImageControl()
651 void VCLXImageControl::ImplSetNewImage()
653 OSL_PRECOND( GetWindow(), "VCLXImageControl::ImplSetNewImage: window is required to be not-NULL!" );
654 ImageControl
* pControl
= static_cast< ImageControl
* >( GetWindow() );
655 pControl
->SetImage( GetImage() );
658 ::com::sun::star::awt::Size
VCLXImageControl::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException
)
660 SolarMutexGuard aGuard
;
662 Size aSz
= GetImage().GetSizePixel();
663 aSz
= ImplCalcWindowSize( aSz
);
668 ::com::sun::star::awt::Size
VCLXImageControl::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException
)
670 return getMinimumSize();
673 ::com::sun::star::awt::Size
VCLXImageControl::calcAdjustedSize( const ::com::sun::star::awt::Size
& rNewSize
) throw(::com::sun::star::uno::RuntimeException
)
675 SolarMutexGuard aGuard
;
677 ::com::sun::star::awt::Size aSz
= rNewSize
;
678 ::com::sun::star::awt::Size aMinSz
= getMinimumSize();
679 if ( aSz
.Width
< aMinSz
.Width
)
680 aSz
.Width
= aMinSz
.Width
;
681 if ( aSz
.Height
< aMinSz
.Height
)
682 aSz
.Height
= aMinSz
.Height
;
686 void VCLXImageControl::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
)
688 SolarMutexGuard aGuard
;
690 ImageControl
* pImageControl
= (ImageControl
*)GetWindow();
692 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
695 case BASEPROPERTY_IMAGE_SCALE_MODE
:
697 sal_Int16
nScaleMode( ImageScaleMode::Anisotropic
);
698 if ( pImageControl
&& ( Value
>>= nScaleMode
) )
700 pImageControl
->SetScaleMode( nScaleMode
);
705 case BASEPROPERTY_SCALEIMAGE
:
707 // this is for compatibility only, nowadays, the ImageScaleMode property should be used
708 sal_Bool bScaleImage
= sal_False
;
709 if ( pImageControl
&& ( Value
>>= bScaleImage
) )
711 pImageControl
->SetScaleMode( bScaleImage
? ImageScaleMode::Anisotropic
: ImageScaleMode::None
);
717 VCLXGraphicControl::setProperty( PropertyName
, Value
);
722 ::com::sun::star::uno::Any
VCLXImageControl::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
)
724 SolarMutexGuard aGuard
;
726 ::com::sun::star::uno::Any aProp
;
727 ImageControl
* pImageControl
= (ImageControl
*)GetWindow();
728 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
732 case BASEPROPERTY_IMAGE_SCALE_MODE
:
733 aProp
<<= ( pImageControl
? pImageControl
->GetScaleMode() : ImageScaleMode::Anisotropic
);
736 case BASEPROPERTY_SCALEIMAGE
:
737 aProp
<<= ( pImageControl
&& pImageControl
->GetScaleMode() != ImageScaleMode::None
) ? sal_True
: sal_False
;
741 aProp
= VCLXGraphicControl::getProperty( PropertyName
);
747 // ----------------------------------------------------
748 // class VCLXCheckBox
749 // ----------------------------------------------------
752 void VCLXCheckBox::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
754 PushPropertyIds( rIds
,
755 BASEPROPERTY_DEFAULTCONTROL
,
756 BASEPROPERTY_ENABLED
,
757 BASEPROPERTY_ENABLEVISIBLE
,
758 BASEPROPERTY_FONTDESCRIPTOR
,
759 BASEPROPERTY_GRAPHIC
,
760 BASEPROPERTY_HELPTEXT
,
761 BASEPROPERTY_HELPURL
,
762 BASEPROPERTY_IMAGEPOSITION
,
763 BASEPROPERTY_IMAGEURL
,
765 BASEPROPERTY_PRINTABLE
,
767 BASEPROPERTY_TABSTOP
,
768 BASEPROPERTY_TRISTATE
,
769 BASEPROPERTY_VISUALEFFECT
,
770 BASEPROPERTY_MULTILINE
,
771 BASEPROPERTY_BACKGROUNDCOLOR
,
773 BASEPROPERTY_VERTICALALIGN
,
774 BASEPROPERTY_WRITING_MODE
,
775 BASEPROPERTY_CONTEXT_WRITING_MODE
,
776 BASEPROPERTY_REFERENCE_DEVICE
,
778 VCLXGraphicControl::ImplGetPropertyIds( rIds
);
781 VCLXCheckBox::VCLXCheckBox() : maActionListeners( *this ), maItemListeners( *this )
785 // ::com::sun::star::uno::XInterface
786 ::com::sun::star::uno::Any
VCLXCheckBox::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
)
788 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
789 (static_cast< ::com::sun::star::awt::XButton
* >(this)),
790 (static_cast< ::com::sun::star::awt::XCheckBox
* >(this)) );
791 return (aRet
.hasValue() ? aRet
: VCLXGraphicControl::queryInterface( rType
));
794 // ::com::sun::star::lang::XTypeProvider
795 IMPL_XTYPEPROVIDER_START( VCLXCheckBox
)
796 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XButton
>* ) NULL
),
797 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XCheckBox
>* ) NULL
),
798 VCLXGraphicControl::getTypes()
799 IMPL_XTYPEPROVIDER_END
801 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> VCLXCheckBox::CreateAccessibleContext()
803 return getAccessibleFactory().createAccessibleContext( this );
806 void VCLXCheckBox::dispose() throw(::com::sun::star::uno::RuntimeException
)
808 SolarMutexGuard aGuard
;
810 ::com::sun::star::lang::EventObject aObj
;
811 aObj
.Source
= (::cppu::OWeakObject
*)this;
812 maItemListeners
.disposeAndClear( aObj
);
813 VCLXGraphicControl::dispose();
816 void VCLXCheckBox::addItemListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XItemListener
> & l
) throw(::com::sun::star::uno::RuntimeException
)
818 SolarMutexGuard aGuard
;
819 maItemListeners
.addInterface( l
);
822 void VCLXCheckBox::removeItemListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XItemListener
> & l
) throw(::com::sun::star::uno::RuntimeException
)
824 SolarMutexGuard aGuard
;
825 maItemListeners
.removeInterface( l
);
828 void VCLXCheckBox::addActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
> & l
)throw(::com::sun::star::uno::RuntimeException
)
830 SolarMutexGuard aGuard
;
831 maActionListeners
.addInterface( l
);
834 void VCLXCheckBox::removeActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
> & l
) throw(::com::sun::star::uno::RuntimeException
)
836 SolarMutexGuard aGuard
;
837 maActionListeners
.removeInterface( l
);
840 void VCLXCheckBox::setActionCommand( const OUString
& rCommand
) throw(::com::sun::star::uno::RuntimeException
)
842 SolarMutexGuard aGuard
;
843 maActionCommand
= rCommand
;
846 void VCLXCheckBox::setLabel( const OUString
& rLabel
) throw(::com::sun::star::uno::RuntimeException
)
848 SolarMutexGuard aGuard
;
850 Window
* pWindow
= GetWindow();
852 pWindow
->SetText( rLabel
);
855 void VCLXCheckBox::setState( short n
) throw(::com::sun::star::uno::RuntimeException
)
857 SolarMutexGuard aGuard
;
859 CheckBox
* pCheckBox
= (CheckBox
*)GetWindow();
865 case 0: eState
= STATE_NOCHECK
; break;
866 case 1: eState
= STATE_CHECK
; break;
867 case 2: eState
= STATE_DONTKNOW
; break;
868 default: eState
= STATE_NOCHECK
;
870 pCheckBox
->SetState( eState
);
872 // #105198# call C++ click listeners (needed for accessibility)
873 // pCheckBox->GetClickHdl().Call( pCheckBox );
875 // #107218# Call same virtual methods and listeners like VCL would do after user interaction
876 SetSynthesizingVCLEvent( sal_True
);
879 SetSynthesizingVCLEvent( sal_False
);
883 short VCLXCheckBox::getState() throw(::com::sun::star::uno::RuntimeException
)
885 SolarMutexGuard aGuard
;
888 CheckBox
* pCheckBox
= (CheckBox
*)GetWindow();
891 switch ( pCheckBox
->GetState() )
893 case STATE_NOCHECK
: nState
= 0; break;
894 case STATE_CHECK
: nState
= 1; break;
895 case STATE_DONTKNOW
: nState
= 2; break;
896 default: OSL_FAIL( "VCLXCheckBox::getState(): unknown TriState!" );
903 void VCLXCheckBox::enableTriState( sal_Bool b
) throw(::com::sun::star::uno::RuntimeException
)
905 SolarMutexGuard aGuard
;
907 CheckBox
* pCheckBox
= (CheckBox
*)GetWindow();
909 pCheckBox
->EnableTriState( b
);
912 ::com::sun::star::awt::Size
VCLXCheckBox::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException
)
914 SolarMutexGuard aGuard
;
917 CheckBox
* pCheckBox
= (CheckBox
*) GetWindow();
919 aSz
= pCheckBox
->CalcMinimumSize();
923 ::com::sun::star::awt::Size
VCLXCheckBox::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException
)
925 return getMinimumSize();
928 ::com::sun::star::awt::Size
VCLXCheckBox::calcAdjustedSize( const ::com::sun::star::awt::Size
& rNewSize
) throw(::com::sun::star::uno::RuntimeException
)
930 SolarMutexGuard aGuard
;
932 Size aSz
= VCLSize(rNewSize
);
933 CheckBox
* pCheckBox
= (CheckBox
*) GetWindow();
936 Size aMinSz
= pCheckBox
->CalcMinimumSize();
937 if ( ( aSz
.Width() > aMinSz
.Width() ) && ( aSz
.Height() < aMinSz
.Height() ) )
938 aSz
.Height() = aMinSz
.Height();
945 void VCLXCheckBox::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
)
947 SolarMutexGuard aGuard
;
949 CheckBox
* pCheckBox
= (CheckBox
*)GetWindow();
952 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
955 case BASEPROPERTY_VISUALEFFECT
:
956 ::toolkit::setVisualEffect( Value
, pCheckBox
);
959 case BASEPROPERTY_TRISTATE
:
961 sal_Bool b
= sal_Bool();
963 pCheckBox
->EnableTriState( b
);
966 case BASEPROPERTY_STATE
:
968 sal_Int16 n
= sal_Int16();
975 VCLXGraphicControl::setProperty( PropertyName
, Value
);
981 ::com::sun::star::uno::Any
VCLXCheckBox::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
)
983 SolarMutexGuard aGuard
;
985 ::com::sun::star::uno::Any aProp
;
986 CheckBox
* pCheckBox
= (CheckBox
*)GetWindow();
989 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
992 case BASEPROPERTY_VISUALEFFECT
:
993 aProp
= ::toolkit::getVisualEffect( pCheckBox
);
995 case BASEPROPERTY_TRISTATE
:
996 aProp
<<= (sal_Bool
)pCheckBox
->IsTriStateEnabled();
998 case BASEPROPERTY_STATE
:
999 aProp
<<= (sal_Int16
)pCheckBox
->GetState();
1003 aProp
<<= VCLXGraphicControl::getProperty( PropertyName
);
1010 void VCLXCheckBox::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
1012 switch ( rVclWindowEvent
.GetId() )
1014 case VCLEVENT_CHECKBOX_TOGGLE
:
1016 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xKeepAlive( this );
1017 // since we call listeners below, there is a potential that we will be destroyed
1018 // in during the listener call. To prevent the resulting crashs, we keep us
1019 // alive as long as we're here
1021 CheckBox
* pCheckBox
= (CheckBox
*)GetWindow();
1024 if ( maItemListeners
.getLength() )
1026 ::com::sun::star::awt::ItemEvent aEvent
;
1027 aEvent
.Source
= (::cppu::OWeakObject
*)this;
1028 aEvent
.Highlighted
= sal_False
;
1029 aEvent
.Selected
= pCheckBox
->GetState();
1030 maItemListeners
.itemStateChanged( aEvent
);
1032 if ( !IsSynthesizingVCLEvent() && maActionListeners
.getLength() )
1034 ::com::sun::star::awt::ActionEvent aEvent
;
1035 aEvent
.Source
= (::cppu::OWeakObject
*)this;
1036 aEvent
.ActionCommand
= maActionCommand
;
1037 maActionListeners
.actionPerformed( aEvent
);
1044 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent
);
1049 // ----------------------------------------------------
1050 // class VCLXRadioButton
1051 // ----------------------------------------------------
1052 void VCLXRadioButton::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
1054 PushPropertyIds( rIds
,
1055 BASEPROPERTY_DEFAULTCONTROL
,
1056 BASEPROPERTY_ENABLED
,
1057 BASEPROPERTY_ENABLEVISIBLE
,
1058 BASEPROPERTY_FONTDESCRIPTOR
,
1059 BASEPROPERTY_GRAPHIC
,
1060 BASEPROPERTY_HELPTEXT
,
1061 BASEPROPERTY_HELPURL
,
1062 BASEPROPERTY_IMAGEPOSITION
,
1063 BASEPROPERTY_IMAGEURL
,
1065 BASEPROPERTY_PRINTABLE
,
1067 BASEPROPERTY_TABSTOP
,
1068 BASEPROPERTY_VISUALEFFECT
,
1069 BASEPROPERTY_MULTILINE
,
1070 BASEPROPERTY_BACKGROUNDCOLOR
,
1072 BASEPROPERTY_VERTICALALIGN
,
1073 BASEPROPERTY_WRITING_MODE
,
1074 BASEPROPERTY_CONTEXT_WRITING_MODE
,
1075 BASEPROPERTY_REFERENCE_DEVICE
,
1076 BASEPROPERTY_GROUPNAME
,
1078 VCLXGraphicControl::ImplGetPropertyIds( rIds
);
1082 VCLXRadioButton::VCLXRadioButton() : maItemListeners( *this ), maActionListeners( *this )
1086 // ::com::sun::star::uno::XInterface
1087 ::com::sun::star::uno::Any
VCLXRadioButton::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
)
1089 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
1090 (static_cast< ::com::sun::star::awt::XRadioButton
* >(this)),
1091 (static_cast< ::com::sun::star::awt::XButton
* >(this)) );
1092 return (aRet
.hasValue() ? aRet
: VCLXGraphicControl::queryInterface( rType
));
1095 // ::com::sun::star::lang::XTypeProvider
1096 IMPL_XTYPEPROVIDER_START( VCLXRadioButton
)
1097 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XRadioButton
>* ) NULL
),
1098 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XButton
>* ) NULL
),
1099 VCLXGraphicControl::getTypes()
1100 IMPL_XTYPEPROVIDER_END
1102 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> VCLXRadioButton::CreateAccessibleContext()
1104 return getAccessibleFactory().createAccessibleContext( this );
1107 void VCLXRadioButton::dispose() throw(::com::sun::star::uno::RuntimeException
)
1109 SolarMutexGuard aGuard
;
1111 ::com::sun::star::lang::EventObject aObj
;
1112 aObj
.Source
= (::cppu::OWeakObject
*)this;
1113 maItemListeners
.disposeAndClear( aObj
);
1114 VCLXGraphicControl::dispose();
1117 void VCLXRadioButton::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
)
1119 SolarMutexGuard aGuard
;
1121 RadioButton
* pButton
= (RadioButton
*)GetWindow();
1124 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
1125 switch ( nPropType
)
1127 case BASEPROPERTY_VISUALEFFECT
:
1128 ::toolkit::setVisualEffect( Value
, pButton
);
1131 case BASEPROPERTY_STATE
:
1133 sal_Int16 n
= sal_Int16();
1136 sal_Bool b
= n
? sal_True
: sal_False
;
1137 if ( pButton
->IsRadioCheckEnabled() )
1138 pButton
->Check( b
);
1140 pButton
->SetState( b
);
1144 case BASEPROPERTY_AUTOTOGGLE
:
1146 sal_Bool b
= sal_Bool();
1148 pButton
->EnableRadioCheck( b
);
1153 VCLXGraphicControl::setProperty( PropertyName
, Value
);
1159 ::com::sun::star::uno::Any
VCLXRadioButton::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
)
1161 SolarMutexGuard aGuard
;
1163 ::com::sun::star::uno::Any aProp
;
1164 RadioButton
* pButton
= (RadioButton
*)GetWindow();
1167 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
1168 switch ( nPropType
)
1170 case BASEPROPERTY_VISUALEFFECT
:
1171 aProp
= ::toolkit::getVisualEffect( pButton
);
1173 case BASEPROPERTY_STATE
:
1174 aProp
<<= (sal_Int16
) ( pButton
->IsChecked() ? 1 : 0 );
1176 case BASEPROPERTY_AUTOTOGGLE
:
1177 aProp
<<= (sal_Bool
) pButton
->IsRadioCheckEnabled();
1181 aProp
<<= VCLXGraphicControl::getProperty( PropertyName
);
1188 void VCLXRadioButton::addItemListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XItemListener
> & l
) throw(::com::sun::star::uno::RuntimeException
)
1190 SolarMutexGuard aGuard
;
1191 maItemListeners
.addInterface( l
);
1194 void VCLXRadioButton::removeItemListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XItemListener
> & l
) throw(::com::sun::star::uno::RuntimeException
)
1196 SolarMutexGuard aGuard
;
1197 maItemListeners
.removeInterface( l
);
1200 void VCLXRadioButton::addActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
> & l
)throw(::com::sun::star::uno::RuntimeException
)
1202 SolarMutexGuard aGuard
;
1203 maActionListeners
.addInterface( l
);
1206 void VCLXRadioButton::removeActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
> & l
) throw(::com::sun::star::uno::RuntimeException
)
1208 SolarMutexGuard aGuard
;
1209 maActionListeners
.removeInterface( l
);
1212 void VCLXRadioButton::setLabel( const OUString
& rLabel
) throw(::com::sun::star::uno::RuntimeException
)
1214 SolarMutexGuard aGuard
;
1216 Window
* pWindow
= GetWindow();
1218 pWindow
->SetText( rLabel
);
1221 void VCLXRadioButton::setActionCommand( const OUString
& rCommand
) throw(::com::sun::star::uno::RuntimeException
)
1223 SolarMutexGuard aGuard
;
1224 maActionCommand
= rCommand
;
1227 void VCLXRadioButton::setState( sal_Bool b
) throw(::com::sun::star::uno::RuntimeException
)
1229 SolarMutexGuard aGuard
;
1231 RadioButton
* pRadioButton
= (RadioButton
*)GetWindow();
1234 pRadioButton
->Check( b
);
1235 // #102717# item listeners are called, but not C++ click listeners in StarOffice code => call click hdl
1236 // But this is needed in old code because Accessibility API uses it.
1237 // pRadioButton->GetClickHdl().Call( pRadioButton );
1239 // #107218# Call same virtual methods and listeners like VCL would do after user interaction
1240 SetSynthesizingVCLEvent( sal_True
);
1241 pRadioButton
->Click();
1242 SetSynthesizingVCLEvent( sal_False
);
1246 sal_Bool
VCLXRadioButton::getState() throw(::com::sun::star::uno::RuntimeException
)
1248 SolarMutexGuard aGuard
;
1250 RadioButton
* pRadioButton
= (RadioButton
*)GetWindow();
1251 return pRadioButton
? pRadioButton
->IsChecked() : sal_False
;
1254 ::com::sun::star::awt::Size
VCLXRadioButton::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException
)
1256 SolarMutexGuard aGuard
;
1259 RadioButton
* pRadioButton
= (RadioButton
*) GetWindow();
1261 aSz
= pRadioButton
->CalcMinimumSize();
1262 return AWTSize(aSz
);
1265 ::com::sun::star::awt::Size
VCLXRadioButton::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException
)
1267 return getMinimumSize();
1270 ::com::sun::star::awt::Size
VCLXRadioButton::calcAdjustedSize( const ::com::sun::star::awt::Size
& rNewSize
) throw(::com::sun::star::uno::RuntimeException
)
1272 SolarMutexGuard aGuard
;
1274 Size aSz
= VCLSize(rNewSize
);
1275 RadioButton
* pRadioButton
= (RadioButton
*) GetWindow();
1278 Size aMinSz
= pRadioButton
->CalcMinimumSize();
1279 if ( ( aSz
.Width() > aMinSz
.Width() ) && ( aSz
.Height() < aMinSz
.Height() ) )
1280 aSz
.Height() = aMinSz
.Height();
1284 return AWTSize(aSz
);
1287 void VCLXRadioButton::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
1289 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xKeepAlive( this );
1290 // since we call listeners below, there is a potential that we will be destroyed
1291 // in during the listener call. To prevent the resulting crashs, we keep us
1292 // alive as long as we're here
1294 switch ( rVclWindowEvent
.GetId() )
1296 case VCLEVENT_BUTTON_CLICK
:
1297 if ( !IsSynthesizingVCLEvent() && maActionListeners
.getLength() )
1299 ::com::sun::star::awt::ActionEvent aEvent
;
1300 aEvent
.Source
= (::cppu::OWeakObject
*)this;
1301 aEvent
.ActionCommand
= maActionCommand
;
1302 maActionListeners
.actionPerformed( aEvent
);
1304 ImplClickedOrToggled( sal_False
);
1307 case VCLEVENT_RADIOBUTTON_TOGGLE
:
1308 ImplClickedOrToggled( sal_True
);
1312 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent
);
1317 void VCLXRadioButton::ImplClickedOrToggled( sal_Bool bToggled
)
1319 // In the formulars, RadioChecked is not enabled, call itemStateChanged only for click
1320 // In the dialog editor, RadioChecked is enabled, call itemStateChanged only for bToggled
1321 RadioButton
* pRadioButton
= (RadioButton
*)GetWindow();
1322 if ( pRadioButton
&& ( pRadioButton
->IsRadioCheckEnabled() == bToggled
) && ( bToggled
|| pRadioButton
->IsStateChanged() ) && maItemListeners
.getLength() )
1324 ::com::sun::star::awt::ItemEvent aEvent
;
1325 aEvent
.Source
= (::cppu::OWeakObject
*)this;
1326 aEvent
.Highlighted
= sal_False
;
1327 aEvent
.Selected
= pRadioButton
->IsChecked();
1328 maItemListeners
.itemStateChanged( aEvent
);
1332 // ----------------------------------------------------
1333 // class VCLXSpinField
1334 // ----------------------------------------------------
1335 void VCLXSpinField::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
1337 PushPropertyIds( rIds
,
1338 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR
,
1340 VCLXEdit::ImplGetPropertyIds( rIds
);
1343 VCLXSpinField::VCLXSpinField() : maSpinListeners( *this )
1347 // ::com::sun::star::uno::XInterface
1348 ::com::sun::star::uno::Any
VCLXSpinField::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
)
1350 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
1351 (static_cast< ::com::sun::star::awt::XSpinField
* >(this)) );
1352 return (aRet
.hasValue() ? aRet
: VCLXEdit::queryInterface( rType
));
1355 // ::com::sun::star::lang::XTypeProvider
1356 IMPL_XTYPEPROVIDER_START( VCLXSpinField
)
1357 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XSpinField
>* ) NULL
),
1358 VCLXEdit::getTypes()
1359 IMPL_XTYPEPROVIDER_END
1361 void VCLXSpinField::addSpinListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XSpinListener
> & l
) throw(::com::sun::star::uno::RuntimeException
)
1363 SolarMutexGuard aGuard
;
1364 maSpinListeners
.addInterface( l
);
1367 void VCLXSpinField::removeSpinListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XSpinListener
> & l
) throw(::com::sun::star::uno::RuntimeException
)
1369 SolarMutexGuard aGuard
;
1370 maSpinListeners
.removeInterface( l
);
1373 void VCLXSpinField::up() throw(::com::sun::star::uno::RuntimeException
)
1375 SolarMutexGuard aGuard
;
1377 SpinField
* pSpinField
= (SpinField
*) GetWindow();
1382 void VCLXSpinField::down() throw(::com::sun::star::uno::RuntimeException
)
1384 SolarMutexGuard aGuard
;
1386 SpinField
* pSpinField
= (SpinField
*) GetWindow();
1391 void VCLXSpinField::first() throw(::com::sun::star::uno::RuntimeException
)
1393 SolarMutexGuard aGuard
;
1395 SpinField
* pSpinField
= (SpinField
*) GetWindow();
1397 pSpinField
->First();
1400 void VCLXSpinField::last() throw(::com::sun::star::uno::RuntimeException
)
1402 SolarMutexGuard aGuard
;
1404 SpinField
* pSpinField
= (SpinField
*) GetWindow();
1409 void VCLXSpinField::enableRepeat( sal_Bool bRepeat
) throw(::com::sun::star::uno::RuntimeException
)
1411 SolarMutexGuard aGuard
;
1413 Window
* pWindow
= GetWindow();
1416 WinBits nStyle
= pWindow
->GetStyle();
1418 nStyle
|= WB_REPEAT
;
1420 nStyle
&= ~WB_REPEAT
;
1421 pWindow
->SetStyle( nStyle
);
1425 void VCLXSpinField::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
1427 switch ( rVclWindowEvent
.GetId() )
1429 case VCLEVENT_SPINFIELD_UP
:
1430 case VCLEVENT_SPINFIELD_DOWN
:
1431 case VCLEVENT_SPINFIELD_FIRST
:
1432 case VCLEVENT_SPINFIELD_LAST
:
1434 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xKeepAlive( this );
1435 // since we call listeners below, there is a potential that we will be destroyed
1436 // in during the listener call. To prevent the resulting crashs, we keep us
1437 // alive as long as we're here
1439 if ( maSpinListeners
.getLength() )
1441 ::com::sun::star::awt::SpinEvent aEvent
;
1442 aEvent
.Source
= (::cppu::OWeakObject
*)this;
1443 switch ( rVclWindowEvent
.GetId() )
1445 case VCLEVENT_SPINFIELD_UP
: maSpinListeners
.up( aEvent
);
1447 case VCLEVENT_SPINFIELD_DOWN
: maSpinListeners
.down( aEvent
);
1449 case VCLEVENT_SPINFIELD_FIRST
: maSpinListeners
.first( aEvent
);
1451 case VCLEVENT_SPINFIELD_LAST
: maSpinListeners
.last( aEvent
);
1460 VCLXEdit::ProcessWindowEvent( rVclWindowEvent
);
1466 // ----------------------------------------------------
1467 // class VCLXListBox
1468 // ----------------------------------------------------
1469 void VCLXListBox::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
1471 PushPropertyIds( rIds
,
1472 BASEPROPERTY_BACKGROUNDCOLOR
,
1473 BASEPROPERTY_BORDER
,
1474 BASEPROPERTY_BORDERCOLOR
,
1475 BASEPROPERTY_DEFAULTCONTROL
,
1476 BASEPROPERTY_DROPDOWN
,
1477 BASEPROPERTY_ENABLED
,
1478 BASEPROPERTY_ENABLEVISIBLE
,
1479 BASEPROPERTY_FONTDESCRIPTOR
,
1480 BASEPROPERTY_HELPTEXT
,
1481 BASEPROPERTY_HELPURL
,
1482 BASEPROPERTY_LINECOUNT
,
1483 BASEPROPERTY_MULTISELECTION
,
1484 BASEPROPERTY_MULTISELECTION_SIMPLEMODE
,
1485 BASEPROPERTY_ITEM_SEPARATOR_POS
,
1486 BASEPROPERTY_PRINTABLE
,
1487 BASEPROPERTY_SELECTEDITEMS
,
1488 BASEPROPERTY_STRINGITEMLIST
,
1489 BASEPROPERTY_TABSTOP
,
1490 BASEPROPERTY_READONLY
,
1492 BASEPROPERTY_WRITING_MODE
,
1493 BASEPROPERTY_CONTEXT_WRITING_MODE
,
1494 BASEPROPERTY_REFERENCE_DEVICE
,
1495 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR
,
1497 VCLXWindow::ImplGetPropertyIds( rIds
);
1501 VCLXListBox::VCLXListBox()
1502 : maActionListeners( *this ),
1503 maItemListeners( *this )
1507 void VCLXListBox::dispose() throw(::com::sun::star::uno::RuntimeException
)
1509 SolarMutexGuard aGuard
;
1511 ::com::sun::star::lang::EventObject aObj
;
1512 aObj
.Source
= (::cppu::OWeakObject
*)this;
1513 maItemListeners
.disposeAndClear( aObj
);
1514 maActionListeners
.disposeAndClear( aObj
);
1515 VCLXWindow::dispose();
1518 void VCLXListBox::addItemListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XItemListener
> & l
) throw(::com::sun::star::uno::RuntimeException
)
1520 SolarMutexGuard aGuard
;
1521 maItemListeners
.addInterface( l
);
1524 void VCLXListBox::removeItemListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XItemListener
> & l
) throw(::com::sun::star::uno::RuntimeException
)
1526 SolarMutexGuard aGuard
;
1527 maItemListeners
.removeInterface( l
);
1530 void VCLXListBox::addActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
> & l
) throw(::com::sun::star::uno::RuntimeException
)
1532 SolarMutexGuard aGuard
;
1533 maActionListeners
.addInterface( l
);
1536 void VCLXListBox::removeActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
> & l
) throw(::com::sun::star::uno::RuntimeException
)
1538 SolarMutexGuard aGuard
;
1539 maActionListeners
.removeInterface( l
);
1542 void VCLXListBox::addItem( const OUString
& aItem
, sal_Int16 nPos
) throw(::com::sun::star::uno::RuntimeException
)
1544 SolarMutexGuard aGuard
;
1546 ListBox
* pBox
= (ListBox
*) GetWindow();
1548 pBox
->InsertEntry( aItem
, nPos
);
1551 void VCLXListBox::addItems( const ::com::sun::star::uno::Sequence
< OUString
>& aItems
, sal_Int16 nPos
) throw(::com::sun::star::uno::RuntimeException
)
1553 SolarMutexGuard aGuard
;
1555 ListBox
* pBox
= (ListBox
*) GetWindow();
1558 sal_uInt16 nP
= nPos
;
1559 const OUString
* pItems
= aItems
.getConstArray();
1560 const OUString
* pItemsEnd
= aItems
.getConstArray() + aItems
.getLength();
1561 while ( pItems
!= pItemsEnd
)
1563 if ( (sal_uInt16
)nP
== 0xFFFF )
1565 OSL_FAIL( "VCLXListBox::addItems: too many entries!" );
1566 // skip remaining entries, list cannot hold them, anyway
1570 pBox
->InsertEntry( *pItems
++, nP
++ );
1575 void VCLXListBox::removeItems( sal_Int16 nPos
, sal_Int16 nCount
) throw(::com::sun::star::uno::RuntimeException
)
1577 SolarMutexGuard aGuard
;
1579 ListBox
* pBox
= (ListBox
*) GetWindow();
1582 for ( sal_uInt16 n
= nCount
; n
; )
1583 pBox
->RemoveEntry( nPos
+ (--n
) );
1587 sal_Int16
VCLXListBox::getItemCount() throw(::com::sun::star::uno::RuntimeException
)
1589 SolarMutexGuard aGuard
;
1591 ListBox
* pBox
= (ListBox
*) GetWindow();
1592 return pBox
? pBox
->GetEntryCount() : 0;
1595 OUString
VCLXListBox::getItem( sal_Int16 nPos
) throw(::com::sun::star::uno::RuntimeException
)
1597 SolarMutexGuard aGuard
;
1600 ListBox
* pBox
= (ListBox
*) GetWindow();
1602 aItem
= pBox
->GetEntry( nPos
);
1606 ::com::sun::star::uno::Sequence
< OUString
> VCLXListBox::getItems() throw(::com::sun::star::uno::RuntimeException
)
1608 SolarMutexGuard aGuard
;
1610 ::com::sun::star::uno::Sequence
< OUString
> aSeq
;
1611 ListBox
* pBox
= (ListBox
*) GetWindow();
1614 sal_uInt16 nEntries
= pBox
->GetEntryCount();
1615 aSeq
= ::com::sun::star::uno::Sequence
< OUString
>( nEntries
);
1616 for ( sal_uInt16 n
= nEntries
; n
; )
1619 aSeq
.getArray()[n
] = OUString( pBox
->GetEntry( n
) );
1625 sal_Int16
VCLXListBox::getSelectedItemPos() throw(::com::sun::star::uno::RuntimeException
)
1627 SolarMutexGuard aGuard
;
1629 ListBox
* pBox
= (ListBox
*) GetWindow();
1630 return pBox
? pBox
->GetSelectEntryPos() : 0;
1633 ::com::sun::star::uno::Sequence
<sal_Int16
> VCLXListBox::getSelectedItemsPos() throw(::com::sun::star::uno::RuntimeException
)
1635 SolarMutexGuard aGuard
;
1637 ::com::sun::star::uno::Sequence
<sal_Int16
> aSeq
;
1638 ListBox
* pBox
= (ListBox
*) GetWindow();
1641 sal_uInt16 nSelEntries
= pBox
->GetSelectEntryCount();
1642 aSeq
= ::com::sun::star::uno::Sequence
<sal_Int16
>( nSelEntries
);
1643 for ( sal_uInt16 n
= 0; n
< nSelEntries
; n
++ )
1644 aSeq
.getArray()[n
] = pBox
->GetSelectEntryPos( n
);
1649 OUString
VCLXListBox::getSelectedItem() throw(::com::sun::star::uno::RuntimeException
)
1651 SolarMutexGuard aGuard
;
1654 ListBox
* pBox
= (ListBox
*) GetWindow();
1656 aItem
= pBox
->GetSelectEntry();
1660 ::com::sun::star::uno::Sequence
< OUString
> VCLXListBox::getSelectedItems() throw(::com::sun::star::uno::RuntimeException
)
1662 SolarMutexGuard aGuard
;
1664 ::com::sun::star::uno::Sequence
< OUString
> aSeq
;
1665 ListBox
* pBox
= (ListBox
*) GetWindow();
1668 sal_uInt16 nSelEntries
= pBox
->GetSelectEntryCount();
1669 aSeq
= ::com::sun::star::uno::Sequence
< OUString
>( nSelEntries
);
1670 for ( sal_uInt16 n
= 0; n
< nSelEntries
; n
++ )
1671 aSeq
.getArray()[n
] = OUString( pBox
->GetSelectEntry( n
) );
1676 void VCLXListBox::selectItemPos( sal_Int16 nPos
, sal_Bool bSelect
) throw(::com::sun::star::uno::RuntimeException
)
1678 SolarMutexGuard aGuard
;
1680 ListBox
* pBox
= (ListBox
*) GetWindow();
1681 if ( pBox
&& ( pBox
->IsEntryPosSelected( nPos
) != bSelect
) )
1683 pBox
->SelectEntryPos( nPos
, bSelect
);
1685 // VCL doesn't call select handler after API call.
1686 // ImplCallItemListeners();
1688 // #107218# Call same listeners like VCL would do after user interaction
1689 SetSynthesizingVCLEvent( sal_True
);
1691 SetSynthesizingVCLEvent( sal_False
);
1695 void VCLXListBox::selectItemsPos( const ::com::sun::star::uno::Sequence
<sal_Int16
>& aPositions
, sal_Bool bSelect
) throw(::com::sun::star::uno::RuntimeException
)
1697 SolarMutexGuard aGuard
;
1699 ListBox
* pBox
= (ListBox
*) GetWindow();
1702 sal_Bool bChanged
= sal_False
;
1703 for ( sal_uInt16 n
= (sal_uInt16
)aPositions
.getLength(); n
; )
1705 sal_uInt16 nPos
= (sal_uInt16
) aPositions
.getConstArray()[--n
];
1706 if ( pBox
->IsEntryPosSelected( nPos
) != bSelect
)
1708 pBox
->SelectEntryPos( nPos
, bSelect
);
1709 bChanged
= sal_True
;
1715 // VCL doesn't call select handler after API call.
1716 // ImplCallItemListeners();
1718 // #107218# Call same listeners like VCL would do after user interaction
1719 SetSynthesizingVCLEvent( sal_True
);
1721 SetSynthesizingVCLEvent( sal_False
);
1726 void VCLXListBox::selectItem( const OUString
& rItemText
, sal_Bool bSelect
) throw(::com::sun::star::uno::RuntimeException
)
1728 SolarMutexGuard aGuard
;
1730 ListBox
* pBox
= (ListBox
*) GetWindow();
1733 String
aItemText( rItemText
);
1734 selectItemPos( pBox
->GetEntryPos( aItemText
), bSelect
);
1739 void VCLXListBox::setDropDownLineCount( sal_Int16 nLines
) throw(::com::sun::star::uno::RuntimeException
)
1741 SolarMutexGuard aGuard
;
1743 ListBox
* pBox
= (ListBox
*) GetWindow();
1745 pBox
->SetDropDownLineCount( nLines
);
1748 sal_Int16
VCLXListBox::getDropDownLineCount() throw(::com::sun::star::uno::RuntimeException
)
1750 SolarMutexGuard aGuard
;
1752 sal_Int16 nLines
= 0;
1753 ListBox
* pBox
= (ListBox
*) GetWindow();
1755 nLines
= pBox
->GetDropDownLineCount();
1759 sal_Bool
VCLXListBox::isMutipleMode() throw(::com::sun::star::uno::RuntimeException
)
1761 SolarMutexGuard aGuard
;
1763 sal_Bool bMulti
= sal_False
;
1764 ListBox
* pBox
= (ListBox
*) GetWindow();
1766 bMulti
= pBox
->IsMultiSelectionEnabled();
1770 void VCLXListBox::setMultipleMode( sal_Bool bMulti
) throw(::com::sun::star::uno::RuntimeException
)
1772 SolarMutexGuard aGuard
;
1774 ListBox
* pBox
= (ListBox
*) GetWindow();
1776 pBox
->EnableMultiSelection( bMulti
);
1779 void VCLXListBox::makeVisible( sal_Int16 nEntry
) throw(::com::sun::star::uno::RuntimeException
)
1781 SolarMutexGuard aGuard
;
1783 ListBox
* pBox
= (ListBox
*) GetWindow();
1785 pBox
->SetTopEntry( nEntry
);
1788 void VCLXListBox::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
1790 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xKeepAlive( this );
1791 // since we call listeners below, there is a potential that we will be destroyed
1792 // in during the listener call. To prevent the resulting crashs, we keep us
1793 // alive as long as we're here
1795 switch ( rVclWindowEvent
.GetId() )
1797 case VCLEVENT_LISTBOX_SELECT
:
1799 ListBox
* pListBox
= (ListBox
*)GetWindow();
1803 sal_Bool bDropDown
= ( pListBox
->GetStyle() & WB_DROPDOWN
) ? sal_True
: sal_False
;
1804 if ( bDropDown
&& !IsSynthesizingVCLEvent() && maActionListeners
.getLength() )
1806 // Call ActionListener on DropDown event
1807 ::com::sun::star::awt::ActionEvent aEvent
;
1808 aEvent
.Source
= (::cppu::OWeakObject
*)this;
1809 aEvent
.ActionCommand
= pListBox
->GetSelectEntry();
1810 maActionListeners
.actionPerformed( aEvent
);
1813 if ( maItemListeners
.getLength() )
1815 ImplCallItemListeners();
1821 case VCLEVENT_LISTBOX_DOUBLECLICK
:
1822 if ( GetWindow() && maActionListeners
.getLength() )
1824 ::com::sun::star::awt::ActionEvent aEvent
;
1825 aEvent
.Source
= (::cppu::OWeakObject
*)this;
1826 aEvent
.ActionCommand
= ((ListBox
*)GetWindow())->GetSelectEntry();
1827 maActionListeners
.actionPerformed( aEvent
);
1832 VCLXWindow::ProcessWindowEvent( rVclWindowEvent
);
1837 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> VCLXListBox::CreateAccessibleContext()
1839 SolarMutexGuard aGuard
;
1841 return getAccessibleFactory().createAccessibleContext( this );
1844 void VCLXListBox::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
)
1846 SolarMutexGuard aGuard
;
1848 ListBox
* pListBox
= (ListBox
*)GetWindow();
1851 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
1852 switch ( nPropType
)
1854 case BASEPROPERTY_ITEM_SEPARATOR_POS
:
1856 sal_Int16
nSeparatorPos(0);
1857 if ( Value
>>= nSeparatorPos
)
1858 pListBox
->SetSeparatorPos( nSeparatorPos
);
1861 case BASEPROPERTY_READONLY
:
1863 sal_Bool b
= sal_Bool();
1865 pListBox
->SetReadOnly( b
);
1868 case BASEPROPERTY_MULTISELECTION
:
1870 sal_Bool b
= sal_Bool();
1872 pListBox
->EnableMultiSelection( b
);
1875 case BASEPROPERTY_MULTISELECTION_SIMPLEMODE
:
1876 ::toolkit::adjustBooleanWindowStyle( Value
, pListBox
, WB_SIMPLEMODE
, sal_False
);
1878 case BASEPROPERTY_LINECOUNT
:
1880 sal_Int16 n
= sal_Int16();
1882 pListBox
->SetDropDownLineCount( n
);
1885 case BASEPROPERTY_STRINGITEMLIST
:
1887 ::com::sun::star::uno::Sequence
< OUString
> aItems
;
1888 if ( Value
>>= aItems
)
1891 addItems( aItems
, 0 );
1895 case BASEPROPERTY_SELECTEDITEMS
:
1897 ::com::sun::star::uno::Sequence
<sal_Int16
> aItems
;
1898 if ( Value
>>= aItems
)
1900 for ( sal_uInt16 n
= pListBox
->GetEntryCount(); n
; )
1901 pListBox
->SelectEntryPos( --n
, sal_False
);
1903 if ( aItems
.getLength() )
1904 selectItemsPos( aItems
, sal_True
);
1906 pListBox
->SetNoSelection();
1908 if ( !pListBox
->GetSelectEntryCount() )
1909 pListBox
->SetTopEntry( 0 );
1915 VCLXWindow::setProperty( PropertyName
, Value
);
1921 ::com::sun::star::uno::Any
VCLXListBox::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
)
1923 SolarMutexGuard aGuard
;
1925 ::com::sun::star::uno::Any aProp
;
1926 ListBox
* pListBox
= (ListBox
*)GetWindow();
1929 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
1930 switch ( nPropType
)
1932 case BASEPROPERTY_ITEM_SEPARATOR_POS
:
1933 aProp
<<= sal_Int16( pListBox
->GetSeparatorPos() );
1935 case BASEPROPERTY_READONLY
:
1937 aProp
<<= (sal_Bool
) pListBox
->IsReadOnly();
1940 case BASEPROPERTY_MULTISELECTION
:
1942 aProp
<<= (sal_Bool
) pListBox
->IsMultiSelectionEnabled();
1945 case BASEPROPERTY_MULTISELECTION_SIMPLEMODE
:
1947 aProp
<<= (sal_Bool
)( ( pListBox
->GetStyle() & WB_SIMPLEMODE
) == 0 );
1950 case BASEPROPERTY_LINECOUNT
:
1952 aProp
<<= (sal_Int16
) pListBox
->GetDropDownLineCount();
1955 case BASEPROPERTY_STRINGITEMLIST
:
1957 sal_uInt16 nItems
= pListBox
->GetEntryCount();
1958 ::com::sun::star::uno::Sequence
< OUString
> aSeq( nItems
);
1959 OUString
* pStrings
= aSeq
.getArray();
1960 for ( sal_uInt16 n
= 0; n
< nItems
; n
++ )
1961 pStrings
[n
] = pListBox
->GetEntry( n
);
1968 aProp
<<= VCLXWindow::getProperty( PropertyName
);
1975 ::com::sun::star::awt::Size
VCLXListBox::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException
)
1977 SolarMutexGuard aGuard
;
1980 ListBox
* pListBox
= (ListBox
*) GetWindow();
1982 aSz
= pListBox
->CalcMinimumSize();
1983 return AWTSize(aSz
);
1986 ::com::sun::star::awt::Size
VCLXListBox::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException
)
1988 SolarMutexGuard aGuard
;
1991 ListBox
* pListBox
= (ListBox
*) GetWindow();
1994 aSz
= pListBox
->CalcMinimumSize();
1995 if ( pListBox
->GetStyle() & WB_DROPDOWN
)
1998 return AWTSize(aSz
);
2001 ::com::sun::star::awt::Size
VCLXListBox::calcAdjustedSize( const ::com::sun::star::awt::Size
& rNewSize
) throw(::com::sun::star::uno::RuntimeException
)
2003 SolarMutexGuard aGuard
;
2005 Size aSz
= VCLSize(rNewSize
);
2006 ListBox
* pListBox
= (ListBox
*) GetWindow();
2008 aSz
= pListBox
->CalcAdjustedSize( aSz
);
2009 return AWTSize(aSz
);
2012 ::com::sun::star::awt::Size
VCLXListBox::getMinimumSize( sal_Int16 nCols
, sal_Int16 nLines
) throw(::com::sun::star::uno::RuntimeException
)
2014 SolarMutexGuard aGuard
;
2017 ListBox
* pListBox
= (ListBox
*) GetWindow();
2019 aSz
= pListBox
->CalcSize( nCols
, nLines
);
2020 return AWTSize(aSz
);
2023 void VCLXListBox::getColumnsAndLines( sal_Int16
& nCols
, sal_Int16
& nLines
) throw(::com::sun::star::uno::RuntimeException
)
2025 SolarMutexGuard aGuard
;
2028 ListBox
* pListBox
= (ListBox
*) GetWindow();
2032 pListBox
->GetMaxVisColumnsAndLines( nC
, nL
);
2038 void VCLXListBox::ImplCallItemListeners()
2040 ListBox
* pListBox
= (ListBox
*) GetWindow();
2041 if ( pListBox
&& maItemListeners
.getLength() )
2043 ::com::sun::star::awt::ItemEvent aEvent
;
2044 aEvent
.Source
= (::cppu::OWeakObject
*)this;
2045 aEvent
.Highlighted
= sal_False
;
2047 // Set to 0xFFFF on multiple selection, selected entry ID otherwise
2048 aEvent
.Selected
= (pListBox
->GetSelectEntryCount() == 1 ) ? pListBox
->GetSelectEntryPos() : 0xFFFF;
2050 maItemListeners
.itemStateChanged( aEvent
);
2055 Image
lcl_getImageFromURL( const OUString
& i_rImageURL
)
2057 if ( i_rImageURL
.isEmpty() )
2062 Reference
< uno::XComponentContext
> xContext( ::comphelper::getProcessComponentContext() );
2063 Reference
< XGraphicProvider
> xProvider(graphic::GraphicProvider::create(xContext
));
2064 ::comphelper::NamedValueCollection aMediaProperties
;
2065 aMediaProperties
.put( "URL", i_rImageURL
);
2066 Reference
< XGraphic
> xGraphic
= xProvider
->queryGraphic( aMediaProperties
.getPropertyValues() );
2067 return Image( xGraphic
);
2069 catch( const uno::Exception
& )
2071 DBG_UNHANDLED_EXCEPTION();
2076 void SAL_CALL
VCLXListBox::listItemInserted( const ItemListEvent
& i_rEvent
) throw (RuntimeException
)
2078 SolarMutexGuard aGuard
;
2080 ListBox
* pListBox
= dynamic_cast< ListBox
* >( GetWindow() );
2082 ENSURE_OR_RETURN_VOID( pListBox
, "VCLXListBox::listItemInserted: no ListBox?!" );
2083 ENSURE_OR_RETURN_VOID( ( i_rEvent
.ItemPosition
>= 0 ) && ( i_rEvent
.ItemPosition
<= sal_Int32( pListBox
->GetEntryCount() ) ),
2084 "VCLXListBox::listItemInserted: illegal (inconsistent) item position!" );
2085 pListBox
->InsertEntry(
2086 i_rEvent
.ItemText
.IsPresent
? i_rEvent
.ItemText
.Value
: OUString(),
2087 i_rEvent
.ItemImageURL
.IsPresent
? TkResMgr::getImageFromURL( i_rEvent
.ItemImageURL
.Value
) : Image(),
2088 i_rEvent
.ItemPosition
);
2091 void SAL_CALL
VCLXListBox::listItemRemoved( const ItemListEvent
& i_rEvent
) throw (RuntimeException
)
2093 SolarMutexGuard aGuard
;
2095 ListBox
* pListBox
= dynamic_cast< ListBox
* >( GetWindow() );
2097 ENSURE_OR_RETURN_VOID( pListBox
, "VCLXListBox::listItemRemoved: no ListBox?!" );
2098 ENSURE_OR_RETURN_VOID( ( i_rEvent
.ItemPosition
>= 0 ) && ( i_rEvent
.ItemPosition
< sal_Int32( pListBox
->GetEntryCount() ) ),
2099 "VCLXListBox::listItemRemoved: illegal (inconsistent) item position!" );
2101 pListBox
->RemoveEntry( i_rEvent
.ItemPosition
);
2104 void SAL_CALL
VCLXListBox::listItemModified( const ItemListEvent
& i_rEvent
) throw (RuntimeException
)
2106 SolarMutexGuard aGuard
;
2108 ListBox
* pListBox
= dynamic_cast< ListBox
* >( GetWindow() );
2110 ENSURE_OR_RETURN_VOID( pListBox
, "VCLXListBox::listItemModified: no ListBox?!" );
2111 ENSURE_OR_RETURN_VOID( ( i_rEvent
.ItemPosition
>= 0 ) && ( i_rEvent
.ItemPosition
< sal_Int32( pListBox
->GetEntryCount() ) ),
2112 "VCLXListBox::listItemModified: illegal (inconsistent) item position!" );
2114 // VCL's ListBox does not support changing an entry's text or image, so remove and re-insert
2116 const OUString sNewText
= i_rEvent
.ItemText
.IsPresent
? i_rEvent
.ItemText
.Value
: OUString( pListBox
->GetEntry( i_rEvent
.ItemPosition
) );
2117 const Image
aNewImage( i_rEvent
.ItemImageURL
.IsPresent
? TkResMgr::getImageFromURL( i_rEvent
.ItemImageURL
.Value
) : pListBox
->GetEntryImage( i_rEvent
.ItemPosition
) );
2119 pListBox
->RemoveEntry( i_rEvent
.ItemPosition
);
2120 pListBox
->InsertEntry( sNewText
, aNewImage
, i_rEvent
.ItemPosition
);
2123 void SAL_CALL
VCLXListBox::allItemsRemoved( const EventObject
& i_rEvent
) throw (RuntimeException
)
2125 SolarMutexGuard aGuard
;
2127 ListBox
* pListBox
= dynamic_cast< ListBox
* >( GetWindow() );
2128 ENSURE_OR_RETURN_VOID( pListBox
, "VCLXListBox::listItemModified: no ListBox?!" );
2135 void SAL_CALL
VCLXListBox::itemListChanged( const EventObject
& i_rEvent
) throw (RuntimeException
)
2137 SolarMutexGuard aGuard
;
2139 ListBox
* pListBox
= dynamic_cast< ListBox
* >( GetWindow() );
2140 ENSURE_OR_RETURN_VOID( pListBox
, "VCLXListBox::listItemModified: no ListBox?!" );
2144 uno::Reference
< beans::XPropertySet
> xPropSet( i_rEvent
.Source
, uno::UNO_QUERY_THROW
);
2145 uno::Reference
< beans::XPropertySetInfo
> xPSI( xPropSet
->getPropertySetInfo(), uno::UNO_QUERY_THROW
);
2146 uno::Reference
< resource::XStringResourceResolver
> xStringResourceResolver
;
2147 if ( xPSI
->hasPropertyByName( OUString( "ResourceResolver" ) ) )
2149 xStringResourceResolver
.set(
2150 xPropSet
->getPropertyValue( OUString( "ResourceResolver" ) ),
2156 Reference
< XItemList
> xItemList( i_rEvent
.Source
, uno::UNO_QUERY_THROW
);
2157 uno::Sequence
< beans::Pair
< OUString
, OUString
> > aItems
= xItemList
->getAllItems();
2158 for ( sal_Int32 i
=0; i
<aItems
.getLength(); ++i
)
2160 OUString
aLocalizationKey( aItems
[i
].First
);
2161 if ( xStringResourceResolver
.is() && !aLocalizationKey
.isEmpty() && aLocalizationKey
[0] == '&' )
2163 aLocalizationKey
= xStringResourceResolver
->resolveString(aLocalizationKey
.copy( 1 ));
2165 pListBox
->InsertEntry( aLocalizationKey
, lcl_getImageFromURL( aItems
[i
].Second
) );
2169 void SAL_CALL
VCLXListBox::disposing( const EventObject
& i_rEvent
) throw (RuntimeException
)
2171 // just disambiguate
2172 VCLXWindow::disposing( i_rEvent
);
2175 // ----------------------------------------------------
2176 // class VCLXMessageBox
2177 // ----------------------------------------------------
2179 void VCLXMessageBox::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
2181 VCLXTopWindow::ImplGetPropertyIds( rIds
);
2184 VCLXMessageBox::VCLXMessageBox()
2188 VCLXMessageBox::~VCLXMessageBox()
2192 // ::com::sun::star::uno::XInterface
2193 ::com::sun::star::uno::Any
VCLXMessageBox::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
)
2195 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
2196 (static_cast< ::com::sun::star::awt::XMessageBox
* >(this)) );
2197 return (aRet
.hasValue() ? aRet
: VCLXTopWindow::queryInterface( rType
));
2200 // ::com::sun::star::lang::XTypeProvider
2201 IMPL_XTYPEPROVIDER_START( VCLXMessageBox
)
2202 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XMessageBox
>* ) NULL
),
2203 VCLXTopWindow::getTypes()
2204 IMPL_XTYPEPROVIDER_END
2206 void VCLXMessageBox::setCaptionText( const OUString
& rText
) throw(::com::sun::star::uno::RuntimeException
)
2208 SolarMutexGuard aGuard
;
2210 Window
* pWindow
= GetWindow();
2212 pWindow
->SetText( rText
);
2215 OUString
VCLXMessageBox::getCaptionText() throw(::com::sun::star::uno::RuntimeException
)
2217 SolarMutexGuard aGuard
;
2220 Window
* pWindow
= GetWindow();
2222 aText
= pWindow
->GetText();
2226 void VCLXMessageBox::setMessageText( const OUString
& rText
) throw(::com::sun::star::uno::RuntimeException
)
2228 SolarMutexGuard aGuard
;
2230 MessBox
* pBox
= (MessBox
*)GetWindow();
2232 pBox
->SetMessText( rText
);
2235 OUString
VCLXMessageBox::getMessageText() throw(::com::sun::star::uno::RuntimeException
)
2237 SolarMutexGuard aGuard
;
2240 MessBox
* pBox
= (MessBox
*)GetWindow();
2242 aText
= pBox
->GetMessText();
2246 sal_Int16
VCLXMessageBox::execute() throw(::com::sun::star::uno::RuntimeException
)
2248 SolarMutexGuard aGuard
;
2250 MessBox
* pBox
= (MessBox
*)GetWindow();
2251 return pBox
? pBox
->Execute() : 0;
2254 ::com::sun::star::awt::Size SAL_CALL
VCLXMessageBox::getMinimumSize() throw(::com::sun::star::uno::RuntimeException
)
2256 SolarMutexGuard aGuard
;
2257 return ::com::sun::star::awt::Size( 250, 100 );
2260 // ----------------------------------------------------
2262 // ----------------------------------------------------
2263 void VCLXDialog::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
2265 VCLXTopWindow::ImplGetPropertyIds( rIds
);
2268 VCLXDialog::VCLXDialog()
2270 OSL_TRACE("XDialog created");
2273 VCLXDialog::~VCLXDialog()
2276 OSL_TRACE ("%s", __FUNCTION__
);
2280 // ::com::sun::star::uno::XInterface
2281 ::com::sun::star::uno::Any
VCLXDialog::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
)
2283 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
2284 (static_cast< ::com::sun::star::awt::XDialog2
* >(this)),
2285 (static_cast< ::com::sun::star::awt::XDialog
* >(this)) );
2286 return (aRet
.hasValue() ? aRet
: VCLXTopWindow::queryInterface( rType
));
2289 // ::com::sun::star::lang::XTypeProvider
2290 IMPL_XTYPEPROVIDER_START( VCLXDialog
)
2291 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XDialog2
>* ) NULL
),
2292 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XDialog
>* ) NULL
),
2293 VCLXTopWindow::getTypes()
2294 IMPL_XTYPEPROVIDER_END
2296 void SAL_CALL
VCLXDialog::endDialog( ::sal_Int32 i_result
) throw (RuntimeException
)
2298 SolarMutexGuard aGuard
;
2300 Dialog
* pDialog
= dynamic_cast< Dialog
* >( GetWindow() );
2302 pDialog
->EndDialog( i_result
);
2305 void SAL_CALL
VCLXDialog::setHelpId( const OUString
& rId
) throw (RuntimeException
)
2307 SolarMutexGuard aGuard
;
2309 Window
* pWindow
= GetWindow();
2311 pWindow
->SetHelpId( OUStringToOString( rId
, RTL_TEXTENCODING_UTF8
) );
2314 void VCLXDialog::setTitle( const OUString
& Title
) throw(::com::sun::star::uno::RuntimeException
)
2316 SolarMutexGuard aGuard
;
2318 Window
* pWindow
= GetWindow();
2320 pWindow
->SetText( Title
);
2323 OUString
VCLXDialog::getTitle() throw(::com::sun::star::uno::RuntimeException
)
2325 SolarMutexGuard aGuard
;
2328 Window
* pWindow
= GetWindow();
2330 aTitle
= pWindow
->GetText();
2334 sal_Int16
VCLXDialog::execute() throw(::com::sun::star::uno::RuntimeException
)
2336 SolarMutexGuard aGuard
;
2341 Dialog
* pDlg
= (Dialog
*) GetWindow();
2342 Window
* pParent
= pDlg
->GetWindow( WINDOW_PARENTOVERLAP
);
2343 Window
* pOldParent
= NULL
;
2344 Window
* pSetParent
= NULL
;
2345 if ( pParent
&& !pParent
->IsReallyVisible() )
2347 pOldParent
= pDlg
->GetParent();
2348 Window
* pFrame
= pDlg
->GetWindow( WINDOW_FRAME
);
2349 if( pFrame
!= pDlg
)
2351 pDlg
->SetParent( pFrame
);
2352 pSetParent
= pFrame
;
2356 nRet
= pDlg
->Execute();
2358 // set the parent back only in case no new parent was set from outside
2359 // in other words, revert only own changes
2360 if ( pOldParent
&& pDlg
->GetParent() == pSetParent
)
2361 pDlg
->SetParent( pOldParent
);
2366 void VCLXDialog::endExecute() throw(::com::sun::star::uno::RuntimeException
)
2371 void SAL_CALL
VCLXDialog::draw( sal_Int32 nX
, sal_Int32 nY
) throw(::com::sun::star::uno::RuntimeException
)
2373 SolarMutexGuard aGuard
;
2374 Window
* pWindow
= GetWindow();
2378 OutputDevice
* pDev
= VCLUnoHelper::GetOutputDevice( getGraphics() );
2380 pDev
= pWindow
->GetParent();
2382 Size aSize
= pDev
->PixelToLogic( pWindow
->GetSizePixel() );
2383 Point aPos
= pDev
->PixelToLogic( Point( nX
, nY
) );
2385 pWindow
->Draw( pDev
, aPos
, aSize
, WINDOW_DRAW_NOCONTROLS
);
2389 ::com::sun::star::awt::DeviceInfo
VCLXDialog::getInfo() throw(::com::sun::star::uno::RuntimeException
)
2391 ::com::sun::star::awt::DeviceInfo aInfo
= VCLXDevice::getInfo();
2393 SolarMutexGuard aGuard
;
2394 Dialog
* pDlg
= (Dialog
*) GetWindow();
2396 pDlg
->GetDrawWindowBorder( aInfo
.LeftInset
, aInfo
.TopInset
, aInfo
.RightInset
, aInfo
.BottomInset
);
2401 void SAL_CALL
VCLXDialog::setProperty(
2402 const OUString
& PropertyName
,
2403 const ::com::sun::star::uno::Any
& Value
)
2404 throw(::com::sun::star::uno::RuntimeException
)
2406 SolarMutexGuard aGuard
;
2408 Dialog
* pDialog
= (Dialog
*)GetWindow();
2411 sal_Bool bVoid
= Value
.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID
;
2413 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
2414 switch ( nPropType
)
2416 case BASEPROPERTY_GRAPHIC
:
2418 Reference
< XGraphic
> xGraphic
;
2419 if (( Value
>>= xGraphic
) && xGraphic
.is() )
2421 Image
aImage( xGraphic
);
2423 Wallpaper
aWallpaper( aImage
.GetBitmapEx());
2424 aWallpaper
.SetStyle( WALLPAPER_SCALE
);
2425 pDialog
->SetBackground( aWallpaper
);
2427 else if ( bVoid
|| !xGraphic
.is() )
2429 Color aColor
= pDialog
->GetControlBackground().GetColor();
2430 if ( aColor
== COL_AUTO
)
2431 aColor
= pDialog
->GetSettings().GetStyleSettings().GetDialogColor();
2433 Wallpaper
aWallpaper( aColor
);
2434 pDialog
->SetBackground( aWallpaper
);
2441 VCLXContainer::setProperty( PropertyName
, Value
);
2448 // ----------------------------------------------------
2449 // class VCLXTabPage
2450 // ----------------------------------------------------
2451 VCLXMultiPage::VCLXMultiPage() : maTabListeners( *this ), mTabId( 1 )
2453 OSL_TRACE("VCLXMultiPage::VCLXMultiPage()" );
2456 void VCLXMultiPage::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
2458 PushPropertyIds( rIds
,
2459 BASEPROPERTY_BACKGROUNDCOLOR
,
2460 BASEPROPERTY_DEFAULTCONTROL
,
2461 BASEPROPERTY_ENABLED
,
2462 BASEPROPERTY_MULTIPAGEVALUE
,
2463 BASEPROPERTY_ENABLEVISIBLE
,
2464 BASEPROPERTY_FONTDESCRIPTOR
,
2465 BASEPROPERTY_GRAPHIC
,
2466 BASEPROPERTY_HELPTEXT
,
2467 BASEPROPERTY_HELPURL
,
2468 BASEPROPERTY_IMAGEALIGN
,
2469 BASEPROPERTY_IMAGEPOSITION
,
2470 BASEPROPERTY_IMAGEURL
,
2471 BASEPROPERTY_PRINTABLE
,
2472 BASEPROPERTY_TABSTOP
,
2473 BASEPROPERTY_FOCUSONCLICK
,
2475 VCLXContainer::ImplGetPropertyIds( rIds
);
2478 VCLXMultiPage::~VCLXMultiPage()
2481 void SAL_CALL
VCLXMultiPage::dispose() throw(::com::sun::star::uno::RuntimeException
)
2483 SolarMutexGuard aGuard
;
2485 ::com::sun::star::lang::EventObject aObj
;
2486 aObj
.Source
= (::cppu::OWeakObject
*)this;
2487 maTabListeners
.disposeAndClear( aObj
);
2488 VCLXContainer::dispose();
2490 ::com::sun::star::uno::Any SAL_CALL
VCLXMultiPage::queryInterface(const ::com::sun::star::uno::Type
& rType
)
2491 throw(::com::sun::star::uno::RuntimeException
)
2493 uno::Any aRet
= ::cppu::queryInterface( rType
, static_cast< awt::XSimpleTabController
*>( this ) );
2495 return ( aRet
.hasValue() ? aRet
: VCLXContainer::queryInterface( rType
) );
2498 // ::com::sun::star::lang::XTypeProvider
2499 IMPL_XTYPEPROVIDER_START( VCLXMultiPage
)
2500 VCLXContainer::getTypes()
2501 IMPL_XTYPEPROVIDER_END
2503 // ::com::sun::star::awt::XView
2504 void SAL_CALL
VCLXMultiPage::draw( sal_Int32 nX
, sal_Int32 nY
)
2505 throw(::com::sun::star::uno::RuntimeException
)
2507 SolarMutexGuard aGuard
;
2508 Window
* pWindow
= GetWindow();
2512 OutputDevice
* pDev
= VCLUnoHelper::GetOutputDevice( getGraphics() );
2514 pDev
= pWindow
->GetParent();
2516 Size aSize
= pDev
->PixelToLogic( pWindow
->GetSizePixel() );
2517 Point aPos
= pDev
->PixelToLogic( Point( nX
, nY
) );
2519 pWindow
->Draw( pDev
, aPos
, aSize
, WINDOW_DRAW_NOCONTROLS
);
2523 // ::com::sun::star::awt::XDevice,
2524 ::com::sun::star::awt::DeviceInfo SAL_CALL
VCLXMultiPage::getInfo()
2525 throw(::com::sun::star::uno::RuntimeException
)
2527 ::com::sun::star::awt::DeviceInfo aInfo
= VCLXDevice::getInfo();
2531 uno::Any SAL_CALL
VCLXMultiPage::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
)
2533 SolarMutexGuard aGuard
;
2534 OSL_TRACE(" **** VCLXMultiPage::getProperty( %s )",
2535 OUStringToOString( PropertyName
,
2536 RTL_TEXTENCODING_UTF8
).getStr() );
2537 ::com::sun::star::uno::Any aProp
;
2538 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
2539 switch ( nPropType
)
2542 case BASEPROPERTY_MULTIPAGEVALUE
:
2544 aProp
<<= getActiveTabID();
2548 aProp
<<= VCLXContainer::getProperty( PropertyName
);
2553 void SAL_CALL
VCLXMultiPage::setProperty(
2554 const OUString
& PropertyName
,
2555 const ::com::sun::star::uno::Any
& Value
)
2556 throw(::com::sun::star::uno::RuntimeException
)
2558 SolarMutexGuard aGuard
;
2559 OSL_TRACE(" **** VCLXMultiPage::setProperty( %s )", OUStringToOString( PropertyName
, RTL_TEXTENCODING_UTF8
).getStr() );
2561 TabControl
* pTabControl
= (TabControl
*)GetWindow();
2564 sal_Bool bVoid
= Value
.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID
;
2566 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
2567 switch ( nPropType
)
2569 case BASEPROPERTY_MULTIPAGEVALUE
:
2571 OSL_TRACE("***MULTIPAGE VALUE");
2574 // when the multipage is created we attempt to set the activepage
2575 // but no pages created
2576 if ( nId
&& nId
<= getWindows().getLength() )
2579 case BASEPROPERTY_GRAPHIC
:
2581 Reference
< XGraphic
> xGraphic
;
2582 if (( Value
>>= xGraphic
) && xGraphic
.is() )
2584 Image
aImage( xGraphic
);
2586 Wallpaper
aWallpaper( aImage
.GetBitmapEx());
2587 aWallpaper
.SetStyle( WALLPAPER_SCALE
);
2588 pTabControl
->SetBackground( aWallpaper
);
2590 else if ( bVoid
|| !xGraphic
.is() )
2592 Color aColor
= pTabControl
->GetControlBackground().GetColor();
2593 if ( aColor
== COL_AUTO
)
2594 aColor
= pTabControl
->GetSettings().GetStyleSettings().GetDialogColor();
2596 Wallpaper
aWallpaper( aColor
);
2597 pTabControl
->SetBackground( aWallpaper
);
2604 VCLXContainer::setProperty( PropertyName
, Value
);
2610 TabControl
*VCLXMultiPage::getTabControl() const throw (uno::RuntimeException
)
2612 TabControl
*pTabControl
= dynamic_cast< TabControl
* >( GetWindow() );
2615 throw uno::RuntimeException();
2617 sal_Int32 SAL_CALL
VCLXMultiPage::insertTab() throw (uno::RuntimeException
)
2619 TabControl
*pTabControl
= getTabControl();
2620 TabPage
* pTab
= new TabPage( pTabControl
);
2621 OUString
title ("");
2622 return static_cast< sal_Int32
>( insertTab( pTab
, title
) );
2625 sal_uInt16
VCLXMultiPage::insertTab( TabPage
* pPage
, OUString
& sTitle
)
2627 TabControl
*pTabControl
= getTabControl();
2628 sal_uInt16 id
= sal::static_int_cast
< sal_uInt16
>( mTabId
++ );
2629 pTabControl
->InsertPage( id
, sTitle
, TAB_APPEND
);
2630 pTabControl
->SetTabPage( id
, pPage
);
2634 void SAL_CALL
VCLXMultiPage::removeTab( sal_Int32 ID
) throw (uno::RuntimeException
, lang::IndexOutOfBoundsException
)
2636 TabControl
*pTabControl
= getTabControl();
2637 if ( pTabControl
->GetTabPage( sal::static_int_cast
< sal_uInt16
>( ID
) ) == NULL
)
2638 throw lang::IndexOutOfBoundsException();
2639 pTabControl
->RemovePage( sal::static_int_cast
< sal_uInt16
>( ID
) );
2642 void SAL_CALL
VCLXMultiPage::activateTab( sal_Int32 ID
) throw (uno::RuntimeException
, lang::IndexOutOfBoundsException
)
2644 TabControl
*pTabControl
= getTabControl();
2645 OSL_TRACE("Attempting to activate tab %d, active tab is %d, numtabs is %d", ID
, getActiveTabID(), getWindows().getLength() );
2646 if ( pTabControl
->GetTabPage( sal::static_int_cast
< sal_uInt16
>( ID
) ) == NULL
)
2647 throw lang::IndexOutOfBoundsException();
2648 pTabControl
->SelectTabPage( sal::static_int_cast
< sal_uInt16
>( ID
) );
2651 sal_Int32 SAL_CALL
VCLXMultiPage::getActiveTabID() throw (uno::RuntimeException
)
2653 return getTabControl()->GetCurPageId( );
2656 void SAL_CALL
VCLXMultiPage::addTabListener( const uno::Reference
< awt::XTabListener
>& xListener
) throw (uno::RuntimeException
)
2658 SolarMutexGuard aGuard
;
2659 maTabListeners
.addInterface( xListener
);
2662 void SAL_CALL
VCLXMultiPage::removeTabListener( const uno::Reference
< awt::XTabListener
>& xListener
) throw (uno::RuntimeException
)
2664 SolarMutexGuard aGuard
;
2665 maTabListeners
.addInterface( xListener
);
2668 void SAL_CALL
VCLXMultiPage::setTabProps( sal_Int32 ID
, const uno::Sequence
< beans::NamedValue
>& Properties
) throw (uno::RuntimeException
, lang::IndexOutOfBoundsException
)
2670 SolarMutexGuard aGuard
;
2671 TabControl
*pTabControl
= getTabControl();
2672 if ( pTabControl
->GetTabPage( sal::static_int_cast
< sal_uInt16
>( ID
) ) == NULL
)
2673 throw lang::IndexOutOfBoundsException();
2675 for (sal_Int32 i
= 0; i
< Properties
.getLength(); ++i
)
2677 const OUString
&name
= Properties
[i
].Name
;
2678 const uno::Any
&value
= Properties
[i
].Value
;
2680 if (name
== "Title")
2682 OUString title
= value
.get
<OUString
>();
2683 pTabControl
->SetPageText( sal::static_int_cast
< sal_uInt16
>( ID
), title
);
2688 uno::Sequence
< beans::NamedValue
> SAL_CALL
VCLXMultiPage::getTabProps( sal_Int32 ID
)
2689 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
2691 SolarMutexGuard aGuard
;
2692 TabControl
*pTabControl
= getTabControl();
2693 if ( pTabControl
->GetTabPage( sal::static_int_cast
< sal_uInt16
>( ID
) ) == NULL
)
2694 throw lang::IndexOutOfBoundsException();
2696 #define ADD_PROP( seq, i, name, val ) { \
2697 beans::NamedValue value; \
2698 value.Name = OUString( name ); \
2699 value.Value = uno::makeAny( val ); \
2703 uno::Sequence
< beans::NamedValue
> props( 2 );
2704 ADD_PROP( props
, 0, "Title", OUString( pTabControl
->GetPageText( sal::static_int_cast
< sal_uInt16
>( ID
) ) ) );
2705 ADD_PROP( props
, 1, "Position", pTabControl
->GetPagePos( sal::static_int_cast
< sal_uInt16
>( ID
) ) );
2709 void VCLXMultiPage::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
2711 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xKeepAlive( this );
2712 switch ( rVclWindowEvent
.GetId() )
2714 case VCLEVENT_TABPAGE_DEACTIVATE
:
2716 sal_uLong nPageID
= (sal_uLong
)( rVclWindowEvent
.GetData() );
2717 maTabListeners
.deactivated( nPageID
);
2721 case VCLEVENT_TABPAGE_ACTIVATE
:
2723 sal_uLong nPageID
= (sal_uLong
)( rVclWindowEvent
.GetData() );
2724 maTabListeners
.activated( nPageID
);
2728 VCLXContainer::ProcessWindowEvent( rVclWindowEvent
);
2733 // ----------------------------------------------------
2734 // class VCLXTabPage
2735 // ----------------------------------------------------
2736 VCLXTabPage::VCLXTabPage()
2740 void VCLXTabPage::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
2742 PushPropertyIds( rIds
,
2743 BASEPROPERTY_BACKGROUNDCOLOR
,
2744 BASEPROPERTY_DEFAULTCONTROL
,
2745 BASEPROPERTY_ENABLED
,
2746 BASEPROPERTY_ENABLEVISIBLE
,
2747 BASEPROPERTY_FONTDESCRIPTOR
,
2748 BASEPROPERTY_GRAPHIC
,
2749 BASEPROPERTY_HELPTEXT
,
2750 BASEPROPERTY_HELPURL
,
2751 BASEPROPERTY_IMAGEALIGN
,
2752 BASEPROPERTY_IMAGEPOSITION
,
2753 BASEPROPERTY_IMAGEURL
,
2754 BASEPROPERTY_PRINTABLE
,
2755 BASEPROPERTY_TABSTOP
,
2756 BASEPROPERTY_FOCUSONCLICK
,
2758 VCLXContainer::ImplGetPropertyIds( rIds
);
2761 VCLXTabPage::~VCLXTabPage()
2765 ::com::sun::star::uno::Any SAL_CALL
VCLXTabPage::queryInterface(const ::com::sun::star::uno::Type
& rType
)
2766 throw(::com::sun::star::uno::RuntimeException
)
2768 return VCLXContainer::queryInterface( rType
);
2771 // ::com::sun::star::lang::XTypeProvider
2772 IMPL_XTYPEPROVIDER_START( VCLXTabPage
)
2773 VCLXContainer::getTypes()
2774 IMPL_XTYPEPROVIDER_END
2776 // ::com::sun::star::awt::XView
2777 void SAL_CALL
VCLXTabPage::draw( sal_Int32 nX
, sal_Int32 nY
)
2778 throw(::com::sun::star::uno::RuntimeException
)
2780 SolarMutexGuard aGuard
;
2781 Window
* pWindow
= GetWindow();
2785 OutputDevice
* pDev
= VCLUnoHelper::GetOutputDevice( getGraphics() );
2787 pDev
= pWindow
->GetParent();
2789 Size aSize
= pDev
->PixelToLogic( pWindow
->GetSizePixel() );
2790 Point aPos
= pDev
->PixelToLogic( Point( nX
, nY
) );
2792 pWindow
->Draw( pDev
, aPos
, aSize
, WINDOW_DRAW_NOCONTROLS
);
2796 // ::com::sun::star::awt::XDevice,
2797 ::com::sun::star::awt::DeviceInfo SAL_CALL
VCLXTabPage::getInfo()
2798 throw(::com::sun::star::uno::RuntimeException
)
2800 ::com::sun::star::awt::DeviceInfo aInfo
= VCLXDevice::getInfo();
2804 void SAL_CALL
VCLXTabPage::setProperty(
2805 const OUString
& PropertyName
,
2806 const ::com::sun::star::uno::Any
& Value
)
2807 throw(::com::sun::star::uno::RuntimeException
)
2809 SolarMutexGuard aGuard
;
2811 TabPage
* pTabPage
= (TabPage
*)GetWindow();
2814 sal_Bool bVoid
= Value
.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID
;
2816 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
2817 switch ( nPropType
)
2819 case BASEPROPERTY_GRAPHIC
:
2821 Reference
< XGraphic
> xGraphic
;
2822 if (( Value
>>= xGraphic
) && xGraphic
.is() )
2824 Image
aImage( xGraphic
);
2826 Wallpaper
aWallpaper( aImage
.GetBitmapEx());
2827 aWallpaper
.SetStyle( WALLPAPER_SCALE
);
2828 pTabPage
->SetBackground( aWallpaper
);
2830 else if ( bVoid
|| !xGraphic
.is() )
2832 Color aColor
= pTabPage
->GetControlBackground().GetColor();
2833 if ( aColor
== COL_AUTO
)
2834 aColor
= pTabPage
->GetSettings().GetStyleSettings().GetDialogColor();
2836 Wallpaper
aWallpaper( aColor
);
2837 pTabPage
->SetBackground( aWallpaper
);
2841 case BASEPROPERTY_TITLE
:
2844 if ( Value
>>= sTitle
)
2846 pTabPage
->SetText(sTitle
);
2853 VCLXContainer::setProperty( PropertyName
, Value
);
2859 TabPage
*VCLXTabPage::getTabPage() const throw (uno::RuntimeException
)
2861 TabPage
*pTabPage
= dynamic_cast< TabPage
* >( GetWindow() );
2864 throw uno::RuntimeException();
2867 // ----------------------------------------------------
2868 // class VCLXFixedHyperlink
2869 // ----------------------------------------------------
2871 VCLXFixedHyperlink::VCLXFixedHyperlink() :
2873 maActionListeners( *this )
2878 VCLXFixedHyperlink::~VCLXFixedHyperlink()
2882 // ::com::sun::star::uno::XInterface
2883 ::com::sun::star::uno::Any
VCLXFixedHyperlink::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
)
2885 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
2886 (static_cast< ::com::sun::star::awt::XFixedHyperlink
* >(this)) );
2887 return (aRet
.hasValue() ? aRet
: VCLXWindow::queryInterface( rType
));
2890 void VCLXFixedHyperlink::dispose() throw(::com::sun::star::uno::RuntimeException
)
2892 SolarMutexGuard aGuard
;
2894 ::com::sun::star::lang::EventObject aObj
;
2895 aObj
.Source
= (::cppu::OWeakObject
*)this;
2896 maActionListeners
.disposeAndClear( aObj
);
2897 VCLXWindow::dispose();
2900 // ::com::sun::star::lang::XTypeProvider
2901 IMPL_XTYPEPROVIDER_START( VCLXFixedHyperlink
)
2902 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XFixedHyperlink
>* ) NULL
),
2903 VCLXWindow::getTypes()
2904 IMPL_XTYPEPROVIDER_END
2906 void VCLXFixedHyperlink::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
2908 switch ( rVclWindowEvent
.GetId() )
2910 case VCLEVENT_BUTTON_CLICK
:
2912 if ( maActionListeners
.getLength() )
2914 ::com::sun::star::awt::ActionEvent aEvent
;
2915 aEvent
.Source
= (::cppu::OWeakObject
*)this;
2916 maActionListeners
.actionPerformed( aEvent
);
2922 FixedHyperlink
* pBase
= (FixedHyperlink
*)GetWindow();
2924 sURL
= pBase
->GetURL();
2925 Reference
< ::com::sun::star::system::XSystemShellExecute
> xSystemShellExecute( ::com::sun::star::system::SystemShellExecute::create(
2926 ::comphelper::getProcessComponentContext() ) );
2927 if ( !sURL
.isEmpty() )
2932 xSystemShellExecute
->execute(
2933 sURL
, OUString(), ::com::sun::star::system::SystemShellExecuteFlags::URIS_ONLY
);
2935 catch( uno::Exception
& )
2943 VCLXWindow::ProcessWindowEvent( rVclWindowEvent
);
2948 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> VCLXFixedHyperlink::CreateAccessibleContext()
2950 return getAccessibleFactory().createAccessibleContext( this );
2953 void VCLXFixedHyperlink::setText( const OUString
& Text
) throw(::com::sun::star::uno::RuntimeException
)
2955 SolarMutexGuard aGuard
;
2957 FixedHyperlink
* pBase
= (FixedHyperlink
*)GetWindow();
2959 pBase
->SetText(Text
);
2962 OUString
VCLXFixedHyperlink::getText() throw(::com::sun::star::uno::RuntimeException
)
2964 SolarMutexGuard aGuard
;
2967 Window
* pWindow
= GetWindow();
2969 aText
= pWindow
->GetText();
2973 void VCLXFixedHyperlink::setURL( const OUString
& URL
) throw(::com::sun::star::uno::RuntimeException
)
2975 SolarMutexGuard aGuard
;
2977 FixedHyperlink
* pBase
= (FixedHyperlink
*)GetWindow();
2979 pBase
->SetURL( URL
);
2982 OUString
VCLXFixedHyperlink::getURL( ) throw(::com::sun::star::uno::RuntimeException
)
2984 SolarMutexGuard aGuard
;
2987 FixedHyperlink
* pBase
= (FixedHyperlink
*)GetWindow();
2989 aText
= pBase
->GetURL();
2993 void VCLXFixedHyperlink::setAlignment( short nAlign
) throw(::com::sun::star::uno::RuntimeException
)
2995 SolarMutexGuard aGuard
;
2997 Window
* pWindow
= GetWindow();
3000 WinBits nNewBits
= 0;
3001 if ( nAlign
== ::com::sun::star::awt::TextAlign::LEFT
)
3003 else if ( nAlign
== ::com::sun::star::awt::TextAlign::CENTER
)
3004 nNewBits
= WB_CENTER
;
3006 nNewBits
= WB_RIGHT
;
3008 WinBits nStyle
= pWindow
->GetStyle();
3009 nStyle
&= ~(WB_LEFT
|WB_CENTER
|WB_RIGHT
);
3010 pWindow
->SetStyle( nStyle
| nNewBits
);
3014 short VCLXFixedHyperlink::getAlignment() throw(::com::sun::star::uno::RuntimeException
)
3016 SolarMutexGuard aGuard
;
3019 Window
* pWindow
= GetWindow();
3022 WinBits nStyle
= pWindow
->GetStyle();
3023 if ( nStyle
& WB_LEFT
)
3024 nAlign
= ::com::sun::star::awt::TextAlign::LEFT
;
3025 else if ( nStyle
& WB_CENTER
)
3026 nAlign
= ::com::sun::star::awt::TextAlign::CENTER
;
3028 nAlign
= ::com::sun::star::awt::TextAlign::RIGHT
;
3033 void VCLXFixedHyperlink::addActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
> & l
)throw(::com::sun::star::uno::RuntimeException
)
3035 SolarMutexGuard aGuard
;
3036 maActionListeners
.addInterface( l
);
3039 void VCLXFixedHyperlink::removeActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
> & l
) throw(::com::sun::star::uno::RuntimeException
)
3041 SolarMutexGuard aGuard
;
3042 maActionListeners
.removeInterface( l
);
3045 ::com::sun::star::awt::Size
VCLXFixedHyperlink::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException
)
3047 SolarMutexGuard aGuard
;
3050 FixedText
* pFixedText
= (FixedText
*)GetWindow();
3052 aSz
= pFixedText
->CalcMinimumSize();
3053 return AWTSize(aSz
);
3056 ::com::sun::star::awt::Size
VCLXFixedHyperlink::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException
)
3058 return getMinimumSize();
3061 ::com::sun::star::awt::Size
VCLXFixedHyperlink::calcAdjustedSize( const ::com::sun::star::awt::Size
& rNewSize
) throw(::com::sun::star::uno::RuntimeException
)
3063 SolarMutexGuard aGuard
;
3065 ::com::sun::star::awt::Size aSz
= rNewSize
;
3066 ::com::sun::star::awt::Size aMinSz
= getMinimumSize();
3067 if ( aSz
.Height
!= aMinSz
.Height
)
3068 aSz
.Height
= aMinSz
.Height
;
3073 void VCLXFixedHyperlink::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
)
3075 SolarMutexGuard aGuard
;
3077 FixedHyperlink
* pBase
= (FixedHyperlink
*)GetWindow();
3080 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
3081 switch ( nPropType
)
3083 case BASEPROPERTY_LABEL
:
3086 if ( Value
>>= sNewLabel
)
3087 pBase
->SetText(sNewLabel
);
3091 case BASEPROPERTY_URL
:
3094 if ( Value
>>= sNewURL
)
3095 pBase
->SetURL( sNewURL
);
3101 VCLXWindow::setProperty( PropertyName
, Value
);
3107 ::com::sun::star::uno::Any
VCLXFixedHyperlink::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
)
3109 SolarMutexGuard aGuard
;
3111 ::com::sun::star::uno::Any aProp
;
3112 FixedHyperlink
* pBase
= (FixedHyperlink
*)GetWindow();
3115 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
3116 switch ( nPropType
)
3118 case BASEPROPERTY_URL
:
3120 aProp
= makeAny( OUString( pBase
->GetURL() ) );
3126 aProp
<<= VCLXWindow::getProperty( PropertyName
);
3133 void VCLXFixedHyperlink::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
3135 PushPropertyIds( rIds
,
3137 BASEPROPERTY_BACKGROUNDCOLOR
,
3138 BASEPROPERTY_BORDER
,
3139 BASEPROPERTY_BORDERCOLOR
,
3140 BASEPROPERTY_DEFAULTCONTROL
,
3141 BASEPROPERTY_ENABLED
,
3142 BASEPROPERTY_ENABLEVISIBLE
,
3143 BASEPROPERTY_FONTDESCRIPTOR
,
3144 BASEPROPERTY_HELPTEXT
,
3145 BASEPROPERTY_HELPURL
,
3147 BASEPROPERTY_MULTILINE
,
3148 BASEPROPERTY_NOLABEL
,
3149 BASEPROPERTY_PRINTABLE
,
3150 BASEPROPERTY_TABSTOP
,
3151 BASEPROPERTY_VERTICALALIGN
,
3153 BASEPROPERTY_WRITING_MODE
,
3154 BASEPROPERTY_CONTEXT_WRITING_MODE
,
3156 VCLXWindow::ImplGetPropertyIds( rIds
);
3159 // ----------------------------------------------------
3160 // class VCLXFixedText
3161 // ----------------------------------------------------
3162 void VCLXFixedText::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
3164 PushPropertyIds( rIds
,
3166 BASEPROPERTY_BACKGROUNDCOLOR
,
3167 BASEPROPERTY_BORDER
,
3168 BASEPROPERTY_BORDERCOLOR
,
3169 BASEPROPERTY_DEFAULTCONTROL
,
3170 BASEPROPERTY_ENABLED
,
3171 BASEPROPERTY_ENABLEVISIBLE
,
3172 BASEPROPERTY_FONTDESCRIPTOR
,
3173 BASEPROPERTY_HELPTEXT
,
3174 BASEPROPERTY_HELPURL
,
3176 BASEPROPERTY_MULTILINE
,
3177 BASEPROPERTY_NOLABEL
,
3178 BASEPROPERTY_PRINTABLE
,
3179 BASEPROPERTY_TABSTOP
,
3180 BASEPROPERTY_VERTICALALIGN
,
3181 BASEPROPERTY_WRITING_MODE
,
3182 BASEPROPERTY_CONTEXT_WRITING_MODE
,
3183 BASEPROPERTY_REFERENCE_DEVICE
,
3185 VCLXWindow::ImplGetPropertyIds( rIds
);
3188 VCLXFixedText::VCLXFixedText()
3192 VCLXFixedText::~VCLXFixedText()
3196 // ::com::sun::star::uno::XInterface
3197 ::com::sun::star::uno::Any
VCLXFixedText::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
)
3199 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
3200 (static_cast< ::com::sun::star::awt::XFixedText
* >(this)) );
3201 return (aRet
.hasValue() ? aRet
: VCLXWindow::queryInterface( rType
));
3204 // ::com::sun::star::lang::XTypeProvider
3205 IMPL_XTYPEPROVIDER_START( VCLXFixedText
)
3206 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XFixedText
>* ) NULL
),
3207 VCLXWindow::getTypes()
3208 IMPL_XTYPEPROVIDER_END
3210 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> VCLXFixedText::CreateAccessibleContext()
3212 return getAccessibleFactory().createAccessibleContext( this );
3215 void VCLXFixedText::setText( const OUString
& Text
) throw(::com::sun::star::uno::RuntimeException
)
3217 SolarMutexGuard aGuard
;
3219 Window
* pWindow
= GetWindow();
3221 pWindow
->SetText( Text
);
3224 OUString
VCLXFixedText::getText() throw(::com::sun::star::uno::RuntimeException
)
3226 SolarMutexGuard aGuard
;
3229 Window
* pWindow
= GetWindow();
3231 aText
= pWindow
->GetText();
3235 void VCLXFixedText::setAlignment( short nAlign
) throw(::com::sun::star::uno::RuntimeException
)
3237 SolarMutexGuard aGuard
;
3239 Window
* pWindow
= GetWindow();
3242 WinBits nNewBits
= 0;
3243 if ( nAlign
== ::com::sun::star::awt::TextAlign::LEFT
)
3245 else if ( nAlign
== ::com::sun::star::awt::TextAlign::CENTER
)
3246 nNewBits
= WB_CENTER
;
3248 nNewBits
= WB_RIGHT
;
3250 WinBits nStyle
= pWindow
->GetStyle();
3251 nStyle
&= ~(WB_LEFT
|WB_CENTER
|WB_RIGHT
);
3252 pWindow
->SetStyle( nStyle
| nNewBits
);
3256 short VCLXFixedText::getAlignment() throw(::com::sun::star::uno::RuntimeException
)
3258 SolarMutexGuard aGuard
;
3261 Window
* pWindow
= GetWindow();
3264 WinBits nStyle
= pWindow
->GetStyle();
3265 if ( nStyle
& WB_LEFT
)
3266 nAlign
= ::com::sun::star::awt::TextAlign::LEFT
;
3267 else if ( nStyle
& WB_CENTER
)
3268 nAlign
= ::com::sun::star::awt::TextAlign::CENTER
;
3270 nAlign
= ::com::sun::star::awt::TextAlign::RIGHT
;
3275 ::com::sun::star::awt::Size
VCLXFixedText::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException
)
3277 SolarMutexGuard aGuard
;
3280 FixedText
* pFixedText
= (FixedText
*)GetWindow();
3282 aSz
= pFixedText
->CalcMinimumSize();
3283 return AWTSize(aSz
);
3286 ::com::sun::star::awt::Size
VCLXFixedText::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException
)
3288 return getMinimumSize();
3291 ::com::sun::star::awt::Size
VCLXFixedText::calcAdjustedSize( const ::com::sun::star::awt::Size
& rMaxSize
) throw(::com::sun::star::uno::RuntimeException
)
3293 SolarMutexGuard aGuard
;
3295 Size
aAdjustedSize( VCLUnoHelper::ConvertToVCLSize( rMaxSize
) );
3296 FixedText
* pFixedText
= (FixedText
*)GetWindow();
3298 aAdjustedSize
= pFixedText
->CalcMinimumSize( rMaxSize
.Width
);
3299 return VCLUnoHelper::ConvertToAWTSize( aAdjustedSize
);
3302 // ----------------------------------------------------
3303 // class VCLXScrollBar
3304 // ----------------------------------------------------
3305 void VCLXScrollBar::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
3307 PushPropertyIds( rIds
,
3308 BASEPROPERTY_BACKGROUNDCOLOR
,
3309 BASEPROPERTY_BLOCKINCREMENT
,
3310 BASEPROPERTY_BORDER
,
3311 BASEPROPERTY_BORDERCOLOR
,
3312 BASEPROPERTY_DEFAULTCONTROL
,
3313 BASEPROPERTY_ENABLED
,
3314 BASEPROPERTY_ENABLEVISIBLE
,
3315 BASEPROPERTY_HELPTEXT
,
3316 BASEPROPERTY_HELPURL
,
3317 BASEPROPERTY_LINEINCREMENT
,
3318 BASEPROPERTY_LIVE_SCROLL
,
3319 BASEPROPERTY_ORIENTATION
,
3320 BASEPROPERTY_PRINTABLE
,
3321 BASEPROPERTY_REPEAT_DELAY
,
3322 BASEPROPERTY_SCROLLVALUE
,
3323 BASEPROPERTY_SCROLLVALUE_MAX
,
3324 BASEPROPERTY_SCROLLVALUE_MIN
,
3325 BASEPROPERTY_SYMBOL_COLOR
,
3326 BASEPROPERTY_TABSTOP
,
3327 BASEPROPERTY_VISIBLESIZE
,
3328 BASEPROPERTY_WRITING_MODE
,
3329 BASEPROPERTY_CONTEXT_WRITING_MODE
,
3331 VCLXWindow::ImplGetPropertyIds( rIds
);
3334 VCLXScrollBar::VCLXScrollBar() : maAdjustmentListeners( *this )
3338 // ::com::sun::star::uno::XInterface
3339 ::com::sun::star::uno::Any
VCLXScrollBar::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
)
3341 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
3342 (static_cast< ::com::sun::star::awt::XScrollBar
* >(this)) );
3343 return (aRet
.hasValue() ? aRet
: VCLXWindow::queryInterface( rType
));
3346 // ::com::sun::star::lang::XTypeProvider
3347 IMPL_XTYPEPROVIDER_START( VCLXScrollBar
)
3348 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XScrollBar
>* ) NULL
),
3349 VCLXWindow::getTypes()
3350 IMPL_XTYPEPROVIDER_END
3352 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> VCLXScrollBar::CreateAccessibleContext()
3354 return getAccessibleFactory().createAccessibleContext( this );
3357 // ::com::sun::star::lang::XComponent
3358 void VCLXScrollBar::dispose() throw(::com::sun::star::uno::RuntimeException
)
3360 SolarMutexGuard aGuard
;
3362 ::com::sun::star::lang::EventObject aObj
;
3363 aObj
.Source
= (::cppu::OWeakObject
*)this;
3364 maAdjustmentListeners
.disposeAndClear( aObj
);
3365 VCLXWindow::dispose();
3368 // ::com::sun::star::awt::XScrollbar
3369 void VCLXScrollBar::addAdjustmentListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XAdjustmentListener
> & l
) throw(::com::sun::star::uno::RuntimeException
)
3371 SolarMutexGuard aGuard
;
3372 maAdjustmentListeners
.addInterface( l
);
3375 void VCLXScrollBar::removeAdjustmentListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XAdjustmentListener
> & l
) throw(::com::sun::star::uno::RuntimeException
)
3377 SolarMutexGuard aGuard
;
3378 maAdjustmentListeners
.removeInterface( l
);
3381 void VCLXScrollBar::setValue( sal_Int32 n
) throw(::com::sun::star::uno::RuntimeException
)
3383 SolarMutexGuard aGuard
;
3385 ScrollBar
* pScrollBar
= (ScrollBar
*) GetWindow();
3387 pScrollBar
->DoScroll( n
);
3390 void VCLXScrollBar::setValues( sal_Int32 nValue
, sal_Int32 nVisible
, sal_Int32 nMax
) throw(::com::sun::star::uno::RuntimeException
)
3392 SolarMutexGuard aGuard
;
3394 ScrollBar
* pScrollBar
= (ScrollBar
*) GetWindow();
3397 pScrollBar
->SetVisibleSize( nVisible
);
3398 pScrollBar
->SetRangeMax( nMax
);
3399 pScrollBar
->DoScroll( nValue
);
3403 sal_Int32
VCLXScrollBar::getValue() throw(::com::sun::star::uno::RuntimeException
)
3405 SolarMutexGuard aGuard
;
3407 ScrollBar
* pScrollBar
= (ScrollBar
*) GetWindow();
3408 return pScrollBar
? pScrollBar
->GetThumbPos() : 0;
3411 void VCLXScrollBar::setMaximum( sal_Int32 n
) throw(::com::sun::star::uno::RuntimeException
)
3413 SolarMutexGuard aGuard
;
3415 ScrollBar
* pScrollBar
= (ScrollBar
*) GetWindow();
3417 pScrollBar
->SetRangeMax( n
);
3420 sal_Int32
VCLXScrollBar::getMaximum() throw(::com::sun::star::uno::RuntimeException
)
3422 SolarMutexGuard aGuard
;
3424 ScrollBar
* pScrollBar
= (ScrollBar
*) GetWindow();
3425 return pScrollBar
? pScrollBar
->GetRangeMax() : 0;
3428 void VCLXScrollBar::setMinimum( sal_Int32 n
) throw(::com::sun::star::uno::RuntimeException
)
3430 SolarMutexGuard aGuard
;
3432 ScrollBar
* pScrollBar
= static_cast< ScrollBar
* >( GetWindow() );
3434 pScrollBar
->SetRangeMin( n
);
3437 sal_Int32
VCLXScrollBar::getMinimum() throw(::com::sun::star::uno::RuntimeException
)
3439 SolarMutexGuard aGuard
;
3441 ScrollBar
* pScrollBar
= static_cast< ScrollBar
* >( GetWindow() );
3442 return pScrollBar
? pScrollBar
->GetRangeMin() : 0;
3445 void VCLXScrollBar::setLineIncrement( sal_Int32 n
) throw(::com::sun::star::uno::RuntimeException
)
3447 SolarMutexGuard aGuard
;
3449 ScrollBar
* pScrollBar
= (ScrollBar
*) GetWindow();
3451 pScrollBar
->SetLineSize( n
);
3454 sal_Int32
VCLXScrollBar::getLineIncrement() throw(::com::sun::star::uno::RuntimeException
)
3456 SolarMutexGuard aGuard
;
3458 ScrollBar
* pScrollBar
= (ScrollBar
*) GetWindow();
3459 return pScrollBar
? pScrollBar
->GetLineSize() : 0;
3462 void VCLXScrollBar::setBlockIncrement( sal_Int32 n
) throw(::com::sun::star::uno::RuntimeException
)
3464 SolarMutexGuard aGuard
;
3466 ScrollBar
* pScrollBar
= (ScrollBar
*) GetWindow();
3468 pScrollBar
->SetPageSize( n
);
3471 sal_Int32
VCLXScrollBar::getBlockIncrement() throw(::com::sun::star::uno::RuntimeException
)
3473 SolarMutexGuard aGuard
;
3475 ScrollBar
* pScrollBar
= (ScrollBar
*) GetWindow();
3476 return pScrollBar
? pScrollBar
->GetPageSize() : 0;
3479 void VCLXScrollBar::setVisibleSize( sal_Int32 n
) throw(::com::sun::star::uno::RuntimeException
)
3481 SolarMutexGuard aGuard
;
3483 ScrollBar
* pScrollBar
= (ScrollBar
*) GetWindow();
3485 pScrollBar
->SetVisibleSize( n
);
3488 sal_Int32
VCLXScrollBar::getVisibleSize() throw(::com::sun::star::uno::RuntimeException
)
3490 SolarMutexGuard aGuard
;
3492 ScrollBar
* pScrollBar
= (ScrollBar
*) GetWindow();
3493 return pScrollBar
? pScrollBar
->GetVisibleSize() : 0;
3496 void VCLXScrollBar::setOrientation( sal_Int32 n
) throw(::com::sun::star::uno::RuntimeException
)
3498 SolarMutexGuard aGuard
;
3500 Window
* pWindow
= GetWindow();
3503 WinBits nStyle
= pWindow
->GetStyle();
3504 nStyle
&= ~(WB_HORZ
|WB_VERT
);
3505 if ( n
== ::com::sun::star::awt::ScrollBarOrientation::HORIZONTAL
)
3510 pWindow
->SetStyle( nStyle
);
3515 sal_Int32
VCLXScrollBar::getOrientation() throw(::com::sun::star::uno::RuntimeException
)
3517 SolarMutexGuard aGuard
;
3520 Window
* pWindow
= GetWindow();
3523 WinBits nStyle
= pWindow
->GetStyle();
3524 if ( nStyle
& WB_HORZ
)
3525 n
= ::com::sun::star::awt::ScrollBarOrientation::HORIZONTAL
;
3527 n
= ::com::sun::star::awt::ScrollBarOrientation::VERTICAL
;
3533 // ::com::sun::star::awt::VclWindowPeer
3534 void VCLXScrollBar::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
)
3536 SolarMutexGuard aGuard
;
3538 ScrollBar
* pScrollBar
= (ScrollBar
*)GetWindow();
3541 sal_Bool bVoid
= Value
.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID
;
3543 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
3544 switch ( nPropType
)
3546 case BASEPROPERTY_LIVE_SCROLL
:
3548 sal_Bool bDo
= sal_False
;
3551 OSL_VERIFY( Value
>>= bDo
);
3553 AllSettings
aSettings( pScrollBar
->GetSettings() );
3554 StyleSettings
aStyle( aSettings
.GetStyleSettings() );
3555 sal_uLong nDragOptions
= aStyle
.GetDragFullOptions();
3557 nDragOptions
|= DRAGFULL_OPTION_SCROLL
;
3559 nDragOptions
&= ~DRAGFULL_OPTION_SCROLL
;
3560 aStyle
.SetDragFullOptions( nDragOptions
);
3561 aSettings
.SetStyleSettings( aStyle
);
3562 pScrollBar
->SetSettings( aSettings
);
3566 case BASEPROPERTY_SCROLLVALUE
:
3576 case BASEPROPERTY_SCROLLVALUE_MAX
:
3577 case BASEPROPERTY_SCROLLVALUE_MIN
:
3584 if ( nPropType
== BASEPROPERTY_SCROLLVALUE_MAX
)
3592 case BASEPROPERTY_LINEINCREMENT
:
3598 setLineIncrement( n
);
3602 case BASEPROPERTY_BLOCKINCREMENT
:
3608 setBlockIncrement( n
);
3612 case BASEPROPERTY_VISIBLESIZE
:
3618 setVisibleSize( n
);
3622 case BASEPROPERTY_ORIENTATION
:
3628 setOrientation( n
);
3633 case BASEPROPERTY_BACKGROUNDCOLOR
:
3635 // the default implementation of the base class doesn't work here, since our
3636 // interpretation for this property is slightly different
3637 ::toolkit::setButtonLikeFaceColor( pScrollBar
, Value
);
3643 VCLXWindow::setProperty( PropertyName
, Value
);
3649 ::com::sun::star::uno::Any
VCLXScrollBar::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
)
3651 SolarMutexGuard aGuard
;
3653 ::com::sun::star::uno::Any aProp
;
3654 ScrollBar
* pScrollBar
= (ScrollBar
*)GetWindow();
3657 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
3659 switch ( nPropType
)
3661 case BASEPROPERTY_LIVE_SCROLL
:
3663 aProp
<<= (sal_Bool
)( 0 != ( pScrollBar
->GetSettings().GetStyleSettings().GetDragFullOptions() & DRAGFULL_OPTION_SCROLL
) );
3666 case BASEPROPERTY_SCROLLVALUE
:
3668 aProp
<<= (sal_Int32
) getValue();
3671 case BASEPROPERTY_SCROLLVALUE_MAX
:
3673 aProp
<<= (sal_Int32
) getMaximum();
3676 case BASEPROPERTY_SCROLLVALUE_MIN
:
3678 aProp
<<= (sal_Int32
) getMinimum();
3681 case BASEPROPERTY_LINEINCREMENT
:
3683 aProp
<<= (sal_Int32
) getLineIncrement();
3686 case BASEPROPERTY_BLOCKINCREMENT
:
3688 aProp
<<= (sal_Int32
) getBlockIncrement();
3691 case BASEPROPERTY_VISIBLESIZE
:
3693 aProp
<<= (sal_Int32
) getVisibleSize();
3696 case BASEPROPERTY_ORIENTATION
:
3698 aProp
<<= (sal_Int32
) getOrientation();
3701 case BASEPROPERTY_BACKGROUNDCOLOR
:
3703 // the default implementation of the base class doesn't work here, since our
3704 // interpretation for this property is slightly different
3705 aProp
= ::toolkit::getButtonLikeFaceColor( pScrollBar
);
3711 aProp
<<= VCLXWindow::getProperty( PropertyName
);
3718 void VCLXScrollBar::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
3720 switch ( rVclWindowEvent
.GetId() )
3722 case VCLEVENT_SCROLLBAR_SCROLL
:
3724 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xKeepAlive( this );
3725 // since we call listeners below, there is a potential that we will be destroyed
3726 // in during the listener call. To prevent the resulting crashs, we keep us
3727 // alive as long as we're here
3729 if ( maAdjustmentListeners
.getLength() )
3731 ScrollBar
* pScrollBar
= (ScrollBar
*)GetWindow();
3735 ::com::sun::star::awt::AdjustmentEvent aEvent
;
3736 aEvent
.Source
= (::cppu::OWeakObject
*)this;
3737 aEvent
.Value
= pScrollBar
->GetThumbPos();
3739 // set adjustment type
3740 ScrollType aType
= pScrollBar
->GetType();
3741 if ( aType
== SCROLL_LINEUP
|| aType
== SCROLL_LINEDOWN
)
3743 aEvent
.Type
= ::com::sun::star::awt::AdjustmentType_ADJUST_LINE
;
3745 else if ( aType
== SCROLL_PAGEUP
|| aType
== SCROLL_PAGEDOWN
)
3747 aEvent
.Type
= ::com::sun::star::awt::AdjustmentType_ADJUST_PAGE
;
3749 else if ( aType
== SCROLL_DRAG
)
3751 aEvent
.Type
= ::com::sun::star::awt::AdjustmentType_ADJUST_ABS
;
3754 maAdjustmentListeners
.adjustmentValueChanged( aEvent
);
3761 VCLXWindow::ProcessWindowEvent( rVclWindowEvent
);
3766 ::com::sun::star::awt::Size SAL_CALL
VCLXScrollBar::implGetMinimumSize( Window
* p
) throw(::com::sun::star::uno::RuntimeException
)
3768 long n
= p
->GetSettings().GetStyleSettings().GetScrollBarSize();
3769 return ::com::sun::star::awt::Size( n
, n
);
3772 ::com::sun::star::awt::Size SAL_CALL
VCLXScrollBar::getMinimumSize() throw(::com::sun::star::uno::RuntimeException
)
3774 SolarMutexGuard aGuard
;
3775 return implGetMinimumSize( GetWindow() );
3779 // ----------------------------------------------------
3781 // ----------------------------------------------------
3783 void VCLXEdit::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
3785 PushPropertyIds( rIds
,
3787 BASEPROPERTY_BACKGROUNDCOLOR
,
3788 BASEPROPERTY_BORDER
,
3789 BASEPROPERTY_BORDERCOLOR
,
3790 BASEPROPERTY_DEFAULTCONTROL
,
3791 BASEPROPERTY_ECHOCHAR
,
3792 BASEPROPERTY_ENABLED
,
3793 BASEPROPERTY_ENABLEVISIBLE
,
3794 BASEPROPERTY_FONTDESCRIPTOR
,
3795 BASEPROPERTY_HARDLINEBREAKS
,
3796 BASEPROPERTY_HELPTEXT
,
3797 BASEPROPERTY_HELPURL
,
3798 BASEPROPERTY_HSCROLL
,
3799 BASEPROPERTY_LINE_END_FORMAT
,
3800 BASEPROPERTY_MAXTEXTLEN
,
3801 BASEPROPERTY_MULTILINE
,
3802 BASEPROPERTY_PRINTABLE
,
3803 BASEPROPERTY_READONLY
,
3804 BASEPROPERTY_TABSTOP
,
3806 BASEPROPERTY_VSCROLL
,
3807 BASEPROPERTY_HIDEINACTIVESELECTION
,
3808 BASEPROPERTY_PAINTTRANSPARENT
,
3809 BASEPROPERTY_AUTOHSCROLL
,
3810 BASEPROPERTY_AUTOVSCROLL
,
3811 BASEPROPERTY_VERTICALALIGN
,
3812 BASEPROPERTY_WRITING_MODE
,
3813 BASEPROPERTY_CONTEXT_WRITING_MODE
,
3815 VCLXWindow::ImplGetPropertyIds( rIds
);
3818 VCLXEdit::VCLXEdit() : maTextListeners( *this )
3822 // ::com::sun::star::uno::XInterface
3823 ::com::sun::star::uno::Any
VCLXEdit::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
)
3825 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
3826 (static_cast< ::com::sun::star::awt::XTextComponent
* >(this)),
3827 (static_cast< ::com::sun::star::awt::XTextEditField
* >(this)),
3828 (static_cast< ::com::sun::star::awt::XTextLayoutConstrains
* >(this)) );
3829 return (aRet
.hasValue() ? aRet
: VCLXWindow::queryInterface( rType
));
3832 // ::com::sun::star::lang::XTypeProvider
3833 IMPL_XTYPEPROVIDER_START( VCLXEdit
)
3834 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XTextComponent
>* ) NULL
),
3835 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XTextEditField
>* ) NULL
),
3836 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XTextLayoutConstrains
>* ) NULL
),
3837 VCLXWindow::getTypes()
3838 IMPL_XTYPEPROVIDER_END
3840 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> VCLXEdit::CreateAccessibleContext()
3842 return getAccessibleFactory().createAccessibleContext( this );
3845 void VCLXEdit::dispose() throw(::com::sun::star::uno::RuntimeException
)
3847 SolarMutexGuard aGuard
;
3849 ::com::sun::star::lang::EventObject aObj
;
3850 aObj
.Source
= (::cppu::OWeakObject
*)this;
3851 maTextListeners
.disposeAndClear( aObj
);
3852 VCLXWindow::dispose();
3855 void VCLXEdit::addTextListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XTextListener
> & l
) throw(::com::sun::star::uno::RuntimeException
)
3857 SolarMutexGuard aGuard
;
3858 GetTextListeners().addInterface( l
);
3861 void VCLXEdit::removeTextListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XTextListener
> & l
) throw(::com::sun::star::uno::RuntimeException
)
3863 SolarMutexGuard aGuard
;
3864 GetTextListeners().removeInterface( l
);
3867 void VCLXEdit::setText( const OUString
& aText
) throw(::com::sun::star::uno::RuntimeException
)
3869 SolarMutexGuard aGuard
;
3871 Edit
* pEdit
= (Edit
*)GetWindow();
3874 pEdit
->SetText( aText
);
3876 // #107218# Call same listeners like VCL would do after user interaction
3877 SetSynthesizingVCLEvent( sal_True
);
3878 pEdit
->SetModifyFlag();
3880 SetSynthesizingVCLEvent( sal_False
);
3884 void VCLXEdit::insertText( const ::com::sun::star::awt::Selection
& rSel
, const OUString
& aText
) throw(::com::sun::star::uno::RuntimeException
)
3886 SolarMutexGuard aGuard
;
3888 Edit
* pEdit
= (Edit
*)GetWindow();
3891 pEdit
->SetSelection( Selection( rSel
.Min
, rSel
.Max
) );
3892 pEdit
->ReplaceSelected( aText
);
3894 // #107218# Call same listeners like VCL would do after user interaction
3895 SetSynthesizingVCLEvent( sal_True
);
3896 pEdit
->SetModifyFlag();
3898 SetSynthesizingVCLEvent( sal_False
);
3902 OUString
VCLXEdit::getText() throw(::com::sun::star::uno::RuntimeException
)
3904 SolarMutexGuard aGuard
;
3907 Window
* pWindow
= GetWindow();
3909 aText
= pWindow
->GetText();
3913 OUString
VCLXEdit::getSelectedText() throw(::com::sun::star::uno::RuntimeException
)
3915 SolarMutexGuard aGuard
;
3918 Edit
* pEdit
= (Edit
*) GetWindow();
3920 aText
= pEdit
->GetSelected();
3925 void VCLXEdit::setSelection( const ::com::sun::star::awt::Selection
& aSelection
) throw(::com::sun::star::uno::RuntimeException
)
3927 SolarMutexGuard aGuard
;
3929 Edit
* pEdit
= (Edit
*) GetWindow();
3931 pEdit
->SetSelection( Selection( aSelection
.Min
, aSelection
.Max
) );
3934 ::com::sun::star::awt::Selection
VCLXEdit::getSelection() throw(::com::sun::star::uno::RuntimeException
)
3936 SolarMutexGuard aGuard
;
3939 Edit
* pEdit
= (Edit
*) GetWindow();
3941 aSel
= pEdit
->GetSelection();
3942 return ::com::sun::star::awt::Selection( aSel
.Min(), aSel
.Max() );
3945 sal_Bool
VCLXEdit::isEditable() throw(::com::sun::star::uno::RuntimeException
)
3947 SolarMutexGuard aGuard
;
3949 Edit
* pEdit
= (Edit
*) GetWindow();
3950 return ( pEdit
&& !pEdit
->IsReadOnly() && pEdit
->IsEnabled() ) ? sal_True
: sal_False
;
3953 void VCLXEdit::setEditable( sal_Bool bEditable
) throw(::com::sun::star::uno::RuntimeException
)
3955 SolarMutexGuard aGuard
;
3957 Edit
* pEdit
= (Edit
*) GetWindow();
3959 pEdit
->SetReadOnly( !bEditable
);
3963 void VCLXEdit::setMaxTextLen( sal_Int16 nLen
) throw(::com::sun::star::uno::RuntimeException
)
3965 SolarMutexGuard aGuard
;
3967 Edit
* pEdit
= (Edit
*) GetWindow();
3969 pEdit
->SetMaxTextLen( nLen
);
3972 sal_Int16
VCLXEdit::getMaxTextLen() throw(::com::sun::star::uno::RuntimeException
)
3974 SolarMutexGuard aGuard
;
3976 Edit
* pEdit
= (Edit
*) GetWindow();
3977 return pEdit
? pEdit
->GetMaxTextLen() : 0;
3980 void VCLXEdit::setEchoChar( sal_Unicode cEcho
) throw(::com::sun::star::uno::RuntimeException
)
3982 SolarMutexGuard aGuard
;
3984 Edit
* pEdit
= (Edit
*) GetWindow();
3986 pEdit
->SetEchoChar( cEcho
);
3989 void VCLXEdit::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
)
3991 SolarMutexGuard aGuard
;
3993 Edit
* pEdit
= (Edit
*)GetWindow();
3996 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
3997 switch ( nPropType
)
3999 case BASEPROPERTY_HIDEINACTIVESELECTION
:
4000 ::toolkit::adjustBooleanWindowStyle( Value
, pEdit
, WB_NOHIDESELECTION
, sal_True
);
4001 if ( pEdit
->GetSubEdit() )
4002 ::toolkit::adjustBooleanWindowStyle( Value
, pEdit
->GetSubEdit(), WB_NOHIDESELECTION
, sal_True
);
4005 case BASEPROPERTY_READONLY
:
4007 sal_Bool b
= sal_Bool();
4009 pEdit
->SetReadOnly( b
);
4012 case BASEPROPERTY_ECHOCHAR
:
4014 sal_Int16 n
= sal_Int16();
4016 pEdit
->SetEchoChar( n
);
4019 case BASEPROPERTY_MAXTEXTLEN
:
4021 sal_Int16 n
= sal_Int16();
4023 pEdit
->SetMaxTextLen( n
);
4028 VCLXWindow::setProperty( PropertyName
, Value
);
4034 ::com::sun::star::uno::Any
VCLXEdit::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
)
4036 SolarMutexGuard aGuard
;
4038 ::com::sun::star::uno::Any aProp
;
4039 Edit
* pEdit
= (Edit
*)GetWindow();
4042 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
4043 switch ( nPropType
)
4045 case BASEPROPERTY_HIDEINACTIVESELECTION
:
4046 aProp
<<= (sal_Bool
)( ( pEdit
->GetStyle() & WB_NOHIDESELECTION
) == 0 );
4048 case BASEPROPERTY_READONLY
:
4049 aProp
<<= (sal_Bool
) pEdit
->IsReadOnly();
4051 case BASEPROPERTY_ECHOCHAR
:
4052 aProp
<<= (sal_Int16
) pEdit
->GetEchoChar();
4054 case BASEPROPERTY_MAXTEXTLEN
:
4055 aProp
<<= (sal_Int16
) pEdit
->GetMaxTextLen();
4059 aProp
= VCLXWindow::getProperty( PropertyName
);
4066 ::com::sun::star::awt::Size
VCLXEdit::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException
)
4068 SolarMutexGuard aGuard
;
4071 Edit
* pEdit
= (Edit
*) GetWindow();
4073 aSz
= pEdit
->CalcMinimumSize();
4074 return AWTSize(aSz
);
4077 ::com::sun::star::awt::Size
VCLXEdit::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException
)
4079 SolarMutexGuard aGuard
;
4082 Edit
* pEdit
= (Edit
*) GetWindow();
4085 aSz
= pEdit
->CalcMinimumSize();
4088 return AWTSize(aSz
);
4091 ::com::sun::star::awt::Size
VCLXEdit::calcAdjustedSize( const ::com::sun::star::awt::Size
& rNewSize
) throw(::com::sun::star::uno::RuntimeException
)
4093 SolarMutexGuard aGuard
;
4095 ::com::sun::star::awt::Size aSz
= rNewSize
;
4096 ::com::sun::star::awt::Size aMinSz
= getMinimumSize();
4097 if ( aSz
.Height
!= aMinSz
.Height
)
4098 aSz
.Height
= aMinSz
.Height
;
4103 ::com::sun::star::awt::Size
VCLXEdit::getMinimumSize( sal_Int16 nCols
, sal_Int16
) throw(::com::sun::star::uno::RuntimeException
)
4105 SolarMutexGuard aGuard
;
4108 Edit
* pEdit
= (Edit
*) GetWindow();
4112 aSz
= pEdit
->CalcSize( nCols
);
4114 aSz
= pEdit
->CalcMinimumSize();
4116 return AWTSize(aSz
);
4119 void VCLXEdit::getColumnsAndLines( sal_Int16
& nCols
, sal_Int16
& nLines
) throw(::com::sun::star::uno::RuntimeException
)
4121 SolarMutexGuard aGuard
;
4125 Edit
* pEdit
= (Edit
*) GetWindow();
4127 nCols
= pEdit
->GetMaxVisChars();
4130 void VCLXEdit::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
4132 switch ( rVclWindowEvent
.GetId() )
4134 case VCLEVENT_EDIT_MODIFY
:
4136 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xKeepAlive( this );
4137 // since we call listeners below, there is a potential that we will be destroyed
4138 // during the listener call. To prevent the resulting crashs, we keep us
4139 // alive as long as we're here
4141 if ( GetTextListeners().getLength() )
4143 ::com::sun::star::awt::TextEvent aEvent
;
4144 aEvent
.Source
= (::cppu::OWeakObject
*)this;
4145 GetTextListeners().textChanged( aEvent
);
4151 VCLXWindow::ProcessWindowEvent( rVclWindowEvent
);
4156 // ----------------------------------------------------
4157 // class VCLXComboBox
4158 // ----------------------------------------------------
4160 void VCLXComboBox::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
4162 PushPropertyIds( rIds
,
4163 BASEPROPERTY_AUTOCOMPLETE
,
4164 BASEPROPERTY_BACKGROUNDCOLOR
,
4165 BASEPROPERTY_BORDER
,
4166 BASEPROPERTY_BORDERCOLOR
,
4167 BASEPROPERTY_DEFAULTCONTROL
,
4168 BASEPROPERTY_DROPDOWN
,
4169 BASEPROPERTY_ENABLED
,
4170 BASEPROPERTY_ENABLEVISIBLE
,
4171 BASEPROPERTY_FONTDESCRIPTOR
,
4172 BASEPROPERTY_HELPTEXT
,
4173 BASEPROPERTY_HELPURL
,
4174 BASEPROPERTY_LINECOUNT
,
4175 BASEPROPERTY_MAXTEXTLEN
,
4176 BASEPROPERTY_PRINTABLE
,
4177 BASEPROPERTY_READONLY
,
4178 BASEPROPERTY_STRINGITEMLIST
,
4179 BASEPROPERTY_TABSTOP
,
4181 BASEPROPERTY_HIDEINACTIVESELECTION
,
4183 BASEPROPERTY_WRITING_MODE
,
4184 BASEPROPERTY_CONTEXT_WRITING_MODE
,
4185 BASEPROPERTY_REFERENCE_DEVICE
,
4186 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR
,
4188 // no, don't call VCLXEdit here - it has properties which we do *not* want to have at at combo box
4189 // #i92690# / 2008-08-12 / frank.schoenheit@sun.com
4190 // VCLXEdit::ImplGetPropertyIds( rIds );
4191 VCLXWindow::ImplGetPropertyIds( rIds
);
4194 VCLXComboBox::VCLXComboBox()
4195 : maActionListeners( *this ), maItemListeners( *this )
4199 VCLXComboBox::~VCLXComboBox()
4202 OSL_TRACE ("%s", __FUNCTION__
);
4206 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> VCLXComboBox::CreateAccessibleContext()
4208 SolarMutexGuard aGuard
;
4210 return getAccessibleFactory().createAccessibleContext( this );
4213 void VCLXComboBox::dispose() throw(::com::sun::star::uno::RuntimeException
)
4215 SolarMutexGuard aGuard
;
4217 ::com::sun::star::lang::EventObject aObj
;
4218 aObj
.Source
= (::cppu::OWeakObject
*)this;
4219 maItemListeners
.disposeAndClear( aObj
);
4220 maActionListeners
.disposeAndClear( aObj
);
4221 VCLXEdit::dispose();
4225 void VCLXComboBox::addItemListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XItemListener
> & l
) throw(::com::sun::star::uno::RuntimeException
)
4227 SolarMutexGuard aGuard
;
4228 maItemListeners
.addInterface( l
);
4231 void VCLXComboBox::removeItemListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XItemListener
> & l
) throw(::com::sun::star::uno::RuntimeException
)
4233 SolarMutexGuard aGuard
;
4234 maItemListeners
.removeInterface( l
);
4237 void VCLXComboBox::addActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
> & l
) throw(::com::sun::star::uno::RuntimeException
)
4239 SolarMutexGuard aGuard
;
4240 maActionListeners
.addInterface( l
);
4243 void VCLXComboBox::removeActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
> & l
) throw(::com::sun::star::uno::RuntimeException
)
4245 SolarMutexGuard aGuard
;
4246 maActionListeners
.removeInterface( l
);
4249 void VCLXComboBox::addItem( const OUString
& aItem
, sal_Int16 nPos
) throw(::com::sun::star::uno::RuntimeException
)
4251 SolarMutexGuard aGuard
;
4253 ComboBox
* pBox
= (ComboBox
*) GetWindow();
4255 pBox
->InsertEntry( aItem
, nPos
);
4258 void VCLXComboBox::addItems( const ::com::sun::star::uno::Sequence
< OUString
>& aItems
, sal_Int16 nPos
) throw(::com::sun::star::uno::RuntimeException
)
4260 SolarMutexGuard aGuard
;
4262 ComboBox
* pBox
= (ComboBox
*) GetWindow();
4265 sal_uInt16 nP
= nPos
;
4266 for ( sal_uInt16 n
= 0; n
< aItems
.getLength(); n
++ )
4268 pBox
->InsertEntry( aItems
.getConstArray()[n
], nP
);
4271 OSL_FAIL( "VCLXComboBox::addItems: too many entries!" );
4272 // skip remaining entries, list cannot hold them, anyway
4279 void VCLXComboBox::removeItems( sal_Int16 nPos
, sal_Int16 nCount
) throw(::com::sun::star::uno::RuntimeException
)
4281 SolarMutexGuard aGuard
;
4283 ComboBox
* pBox
= (ComboBox
*) GetWindow();
4286 for ( sal_uInt16 n
= nCount
; n
; )
4287 pBox
->RemoveEntry( nPos
+ (--n
) );
4291 sal_Int16
VCLXComboBox::getItemCount() throw(::com::sun::star::uno::RuntimeException
)
4293 SolarMutexGuard aGuard
;
4295 ComboBox
* pBox
= (ComboBox
*) GetWindow();
4296 return pBox
? pBox
->GetEntryCount() : 0;
4299 OUString
VCLXComboBox::getItem( sal_Int16 nPos
) throw(::com::sun::star::uno::RuntimeException
)
4301 SolarMutexGuard aGuard
;
4304 ComboBox
* pBox
= (ComboBox
*) GetWindow();
4306 aItem
= pBox
->GetEntry( nPos
);
4310 ::com::sun::star::uno::Sequence
< OUString
> VCLXComboBox::getItems() throw(::com::sun::star::uno::RuntimeException
)
4312 SolarMutexGuard aGuard
;
4314 ::com::sun::star::uno::Sequence
< OUString
> aSeq
;
4315 ComboBox
* pBox
= (ComboBox
*) GetWindow();
4318 sal_uInt16 nEntries
= pBox
->GetEntryCount();
4319 aSeq
= ::com::sun::star::uno::Sequence
< OUString
>( nEntries
);
4320 for ( sal_uInt16 n
= nEntries
; n
; )
4323 aSeq
.getArray()[n
] = pBox
->GetEntry( n
);
4329 void VCLXComboBox::setDropDownLineCount( sal_Int16 nLines
) throw(::com::sun::star::uno::RuntimeException
)
4331 SolarMutexGuard aGuard
;
4333 ComboBox
* pBox
= (ComboBox
*) GetWindow();
4335 pBox
->SetDropDownLineCount( nLines
);
4338 sal_Int16
VCLXComboBox::getDropDownLineCount() throw(::com::sun::star::uno::RuntimeException
)
4340 SolarMutexGuard aGuard
;
4342 sal_Int16 nLines
= 0;
4343 ComboBox
* pBox
= (ComboBox
*) GetWindow();
4345 nLines
= pBox
->GetDropDownLineCount();
4349 void VCLXComboBox::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
)
4351 SolarMutexGuard aGuard
;
4353 ComboBox
* pComboBox
= (ComboBox
*)GetWindow();
4356 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
4357 switch ( nPropType
)
4359 case BASEPROPERTY_LINECOUNT
:
4361 sal_Int16 n
= sal_Int16();
4363 pComboBox
->SetDropDownLineCount( n
);
4366 case BASEPROPERTY_AUTOCOMPLETE
:
4368 sal_Int16 n
= sal_Int16();
4370 pComboBox
->EnableAutocomplete( n
!= 0 );
4373 case BASEPROPERTY_STRINGITEMLIST
:
4375 ::com::sun::star::uno::Sequence
< OUString
> aItems
;
4376 if ( Value
>>= aItems
)
4379 addItems( aItems
, 0 );
4385 VCLXEdit::setProperty( PropertyName
, Value
);
4387 // #109385# SetBorderStyle is not virtual
4388 if ( nPropType
== BASEPROPERTY_BORDER
)
4390 sal_uInt16 nBorder
= sal_uInt16();
4391 if ( (Value
>>= nBorder
) && nBorder
!= 0 )
4392 pComboBox
->SetBorderStyle( nBorder
);
4399 ::com::sun::star::uno::Any
VCLXComboBox::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
)
4401 SolarMutexGuard aGuard
;
4403 ::com::sun::star::uno::Any aProp
;
4404 ComboBox
* pComboBox
= (ComboBox
*)GetWindow();
4407 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
4408 switch ( nPropType
)
4410 case BASEPROPERTY_LINECOUNT
:
4412 aProp
<<= (sal_Int16
) pComboBox
->GetDropDownLineCount();
4415 case BASEPROPERTY_AUTOCOMPLETE
:
4417 aProp
<<= (sal_Bool
) pComboBox
->IsAutocompleteEnabled();
4420 case BASEPROPERTY_STRINGITEMLIST
:
4422 sal_uInt16 nItems
= pComboBox
->GetEntryCount();
4423 ::com::sun::star::uno::Sequence
< OUString
> aSeq( nItems
);
4424 OUString
* pStrings
= aSeq
.getArray();
4425 for ( sal_uInt16 n
= 0; n
< nItems
; n
++ )
4426 pStrings
[n
] = pComboBox
->GetEntry( n
);
4433 aProp
<<= VCLXEdit::getProperty( PropertyName
);
4440 void VCLXComboBox::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
4442 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xKeepAlive( this );
4443 // since we call listeners below, there is a potential that we will be destroyed
4444 // during the listener call. To prevent the resulting crashs, we keep us
4445 // alive as long as we're here
4447 switch ( rVclWindowEvent
.GetId() )
4449 case VCLEVENT_COMBOBOX_SELECT
:
4450 if ( maItemListeners
.getLength() )
4452 ComboBox
* pComboBox
= (ComboBox
*)GetWindow();
4455 if ( !pComboBox
->IsTravelSelect() )
4457 ::com::sun::star::awt::ItemEvent aEvent
;
4458 aEvent
.Source
= (::cppu::OWeakObject
*)this;
4459 aEvent
.Highlighted
= sal_False
;
4461 // Set to 0xFFFF on multiple selection, selected entry ID otherwise
4462 aEvent
.Selected
= pComboBox
->GetEntryPos( pComboBox
->GetText() );
4464 maItemListeners
.itemStateChanged( aEvent
);
4470 case VCLEVENT_COMBOBOX_DOUBLECLICK
:
4471 if ( maActionListeners
.getLength() )
4473 ::com::sun::star::awt::ActionEvent aEvent
;
4474 aEvent
.Source
= (::cppu::OWeakObject
*)this;
4475 // aEvent.ActionCommand = ...;
4476 maActionListeners
.actionPerformed( aEvent
);
4481 VCLXEdit::ProcessWindowEvent( rVclWindowEvent
);
4486 ::com::sun::star::awt::Size
VCLXComboBox::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException
)
4488 SolarMutexGuard aGuard
;
4491 ComboBox
* pComboBox
= (ComboBox
*) GetWindow();
4493 aSz
= pComboBox
->CalcMinimumSize();
4494 return AWTSize(aSz
);
4497 ::com::sun::star::awt::Size
VCLXComboBox::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException
)
4499 SolarMutexGuard aGuard
;
4502 ComboBox
* pComboBox
= (ComboBox
*) GetWindow();
4505 aSz
= pComboBox
->CalcMinimumSize();
4506 if ( pComboBox
->GetStyle() & WB_DROPDOWN
)
4509 return AWTSize(aSz
);
4512 ::com::sun::star::awt::Size
VCLXComboBox::calcAdjustedSize( const ::com::sun::star::awt::Size
& rNewSize
) throw(::com::sun::star::uno::RuntimeException
)
4514 SolarMutexGuard aGuard
;
4516 Size aSz
= VCLSize(rNewSize
);
4517 ComboBox
* pComboBox
= (ComboBox
*) GetWindow();
4519 aSz
= pComboBox
->CalcAdjustedSize( aSz
);
4520 return AWTSize(aSz
);
4523 ::com::sun::star::awt::Size
VCLXComboBox::getMinimumSize( sal_Int16 nCols
, sal_Int16 nLines
) throw(::com::sun::star::uno::RuntimeException
)
4525 SolarMutexGuard aGuard
;
4528 ComboBox
* pComboBox
= (ComboBox
*) GetWindow();
4530 aSz
= pComboBox
->CalcSize( nCols
, nLines
);
4531 return AWTSize(aSz
);
4534 void VCLXComboBox::getColumnsAndLines( sal_Int16
& nCols
, sal_Int16
& nLines
) throw(::com::sun::star::uno::RuntimeException
)
4536 SolarMutexGuard aGuard
;
4539 ComboBox
* pComboBox
= (ComboBox
*) GetWindow();
4543 pComboBox
->GetMaxVisColumnsAndLines( nC
, nL
);
4548 void SAL_CALL
VCLXComboBox::listItemInserted( const ItemListEvent
& i_rEvent
) throw (RuntimeException
)
4550 SolarMutexGuard aGuard
;
4552 ComboBox
* pComboBox
= dynamic_cast< ComboBox
* >( GetWindow() );
4554 ENSURE_OR_RETURN_VOID( pComboBox
, "VCLXComboBox::listItemInserted: no ComboBox?!" );
4555 ENSURE_OR_RETURN_VOID( ( i_rEvent
.ItemPosition
>= 0 ) && ( i_rEvent
.ItemPosition
<= sal_Int32( pComboBox
->GetEntryCount() ) ),
4556 "VCLXComboBox::listItemInserted: illegal (inconsistent) item position!" );
4557 pComboBox
->InsertEntry(
4558 i_rEvent
.ItemText
.IsPresent
? i_rEvent
.ItemText
.Value
: OUString(),
4559 i_rEvent
.ItemImageURL
.IsPresent
? lcl_getImageFromURL( i_rEvent
.ItemImageURL
.Value
) : Image(),
4560 i_rEvent
.ItemPosition
);
4563 void SAL_CALL
VCLXComboBox::listItemRemoved( const ItemListEvent
& i_rEvent
) throw (RuntimeException
)
4565 SolarMutexGuard aGuard
;
4567 ComboBox
* pComboBox
= dynamic_cast< ComboBox
* >( GetWindow() );
4569 ENSURE_OR_RETURN_VOID( pComboBox
, "VCLXComboBox::listItemRemoved: no ComboBox?!" );
4570 ENSURE_OR_RETURN_VOID( ( i_rEvent
.ItemPosition
>= 0 ) && ( i_rEvent
.ItemPosition
< sal_Int32( pComboBox
->GetEntryCount() ) ),
4571 "VCLXComboBox::listItemRemoved: illegal (inconsistent) item position!" );
4573 pComboBox
->RemoveEntry( i_rEvent
.ItemPosition
);
4576 void SAL_CALL
VCLXComboBox::listItemModified( const ItemListEvent
& i_rEvent
) throw (RuntimeException
)
4578 SolarMutexGuard aGuard
;
4580 ComboBox
* pComboBox
= dynamic_cast< ComboBox
* >( GetWindow() );
4582 ENSURE_OR_RETURN_VOID( pComboBox
, "VCLXComboBox::listItemModified: no ComboBox?!" );
4583 ENSURE_OR_RETURN_VOID( ( i_rEvent
.ItemPosition
>= 0 ) && ( i_rEvent
.ItemPosition
< sal_Int32( pComboBox
->GetEntryCount() ) ),
4584 "VCLXComboBox::listItemModified: illegal (inconsistent) item position!" );
4586 // VCL's ComboBox does not support changing an entry's text or image, so remove and re-insert
4588 const OUString sNewText
= i_rEvent
.ItemText
.IsPresent
? i_rEvent
.ItemText
.Value
: OUString( pComboBox
->GetEntry( i_rEvent
.ItemPosition
) );
4589 const Image
aNewImage( i_rEvent
.ItemImageURL
.IsPresent
? lcl_getImageFromURL( i_rEvent
.ItemImageURL
.Value
) : pComboBox
->GetEntryImage( i_rEvent
.ItemPosition
) );
4591 pComboBox
->RemoveEntry( i_rEvent
.ItemPosition
);
4592 pComboBox
->InsertEntry( sNewText
, aNewImage
, i_rEvent
.ItemPosition
);
4595 void SAL_CALL
VCLXComboBox::allItemsRemoved( const EventObject
& i_rEvent
) throw (RuntimeException
)
4597 SolarMutexGuard aGuard
;
4599 ComboBox
* pComboBox
= dynamic_cast< ComboBox
* >( GetWindow() );
4600 ENSURE_OR_RETURN_VOID( pComboBox
, "VCLXComboBox::listItemModified: no ComboBox?!" );
4607 void SAL_CALL
VCLXComboBox::itemListChanged( const EventObject
& i_rEvent
) throw (RuntimeException
)
4609 SolarMutexGuard aGuard
;
4611 ComboBox
* pComboBox
= dynamic_cast< ComboBox
* >( GetWindow() );
4612 ENSURE_OR_RETURN_VOID( pComboBox
, "VCLXComboBox::listItemModified: no ComboBox?!" );
4616 uno::Reference
< beans::XPropertySet
> xPropSet( i_rEvent
.Source
, uno::UNO_QUERY_THROW
);
4617 uno::Reference
< beans::XPropertySetInfo
> xPSI( xPropSet
->getPropertySetInfo(), uno::UNO_QUERY_THROW
);
4618 // bool localize = xPSI->hasPropertyByName( OUString( "ResourceResolver" ) );
4619 uno::Reference
< resource::XStringResourceResolver
> xStringResourceResolver
;
4620 if ( xPSI
->hasPropertyByName( OUString( "ResourceResolver" ) ) )
4622 xStringResourceResolver
.set(
4623 xPropSet
->getPropertyValue( OUString( "ResourceResolver" ) ),
4629 Reference
< XItemList
> xItemList( i_rEvent
.Source
, uno::UNO_QUERY_THROW
);
4630 uno::Sequence
< beans::Pair
< OUString
, OUString
> > aItems
= xItemList
->getAllItems();
4631 for ( sal_Int32 i
=0; i
<aItems
.getLength(); ++i
)
4633 OUString
aLocalizationKey( aItems
[i
].First
);
4634 if ( xStringResourceResolver
.is() && !aLocalizationKey
.isEmpty() && aLocalizationKey
[0] == '&' )
4636 aLocalizationKey
= xStringResourceResolver
->resolveString(aLocalizationKey
.copy( 1 ));
4638 pComboBox
->InsertEntry( aLocalizationKey
, lcl_getImageFromURL( aItems
[i
].Second
) );
4641 void SAL_CALL
VCLXComboBox::disposing( const EventObject
& i_rEvent
) throw (RuntimeException
)
4643 // just disambiguate
4644 VCLXEdit::disposing( i_rEvent
);
4647 // ----------------------------------------------------
4648 // class VCLXFormattedSpinField
4649 // ----------------------------------------------------
4650 void VCLXFormattedSpinField::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
4652 // Interestingly in the UnoControl API this is
4653 // - not derived from XEdit ultimately, (correct ?) - so cut this here ...
4654 // VCLXSpinField::ImplGetPropertyIds( rIds );
4655 VCLXWindow::ImplGetPropertyIds( rIds
);
4658 VCLXFormattedSpinField::VCLXFormattedSpinField()
4662 VCLXFormattedSpinField::~VCLXFormattedSpinField()
4666 void VCLXFormattedSpinField::setStrictFormat( sal_Bool bStrict
)
4668 SolarMutexGuard aGuard
;
4670 FormatterBase
* pFormatter
= GetFormatter();
4672 pFormatter
->SetStrictFormat( bStrict
);
4675 sal_Bool
VCLXFormattedSpinField::isStrictFormat()
4677 FormatterBase
* pFormatter
= GetFormatter();
4678 return pFormatter
? pFormatter
->IsStrictFormat() : sal_False
;
4682 void VCLXFormattedSpinField::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
)
4684 SolarMutexGuard aGuard
;
4686 FormatterBase
* pFormatter
= GetFormatter();
4689 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
4690 switch ( nPropType
)
4692 case BASEPROPERTY_SPIN
:
4694 sal_Bool b
= sal_Bool();
4697 WinBits nStyle
= GetWindow()->GetStyle() | WB_SPIN
;
4700 GetWindow()->SetStyle( nStyle
);
4704 case BASEPROPERTY_STRICTFORMAT
:
4706 sal_Bool b
= sal_Bool();
4709 pFormatter
->SetStrictFormat( b
);
4715 VCLXSpinField::setProperty( PropertyName
, Value
);
4721 ::com::sun::star::uno::Any
VCLXFormattedSpinField::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
)
4723 SolarMutexGuard aGuard
;
4725 ::com::sun::star::uno::Any aProp
;
4726 FormatterBase
* pFormatter
= GetFormatter();
4729 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
4730 switch ( nPropType
)
4732 case BASEPROPERTY_TABSTOP
:
4734 aProp
<<= (sal_Bool
) ( ( GetWindow()->GetStyle() & WB_SPIN
) ? sal_True
: sal_False
);
4737 case BASEPROPERTY_STRICTFORMAT
:
4739 aProp
<<= (sal_Bool
) pFormatter
->IsStrictFormat();
4744 aProp
<<= VCLXSpinField::getProperty( PropertyName
);
4752 // ----------------------------------------------------
4753 // class VCLXDateField
4754 // ----------------------------------------------------
4756 void VCLXDateField::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
4758 PushPropertyIds( rIds
,
4760 BASEPROPERTY_BACKGROUNDCOLOR
,
4761 BASEPROPERTY_BORDER
,
4762 BASEPROPERTY_BORDERCOLOR
,
4764 BASEPROPERTY_DATEMAX
,
4765 BASEPROPERTY_DATEMIN
,
4766 BASEPROPERTY_DATESHOWCENTURY
,
4767 BASEPROPERTY_DEFAULTCONTROL
,
4768 BASEPROPERTY_DROPDOWN
,
4769 BASEPROPERTY_ENABLED
,
4770 BASEPROPERTY_ENABLEVISIBLE
,
4771 BASEPROPERTY_EXTDATEFORMAT
,
4772 BASEPROPERTY_FONTDESCRIPTOR
,
4773 BASEPROPERTY_HELPTEXT
,
4774 BASEPROPERTY_HELPURL
,
4775 BASEPROPERTY_PRINTABLE
,
4776 BASEPROPERTY_READONLY
,
4777 BASEPROPERTY_REPEAT
,
4778 BASEPROPERTY_REPEAT_DELAY
,
4780 BASEPROPERTY_STRICTFORMAT
,
4781 BASEPROPERTY_TABSTOP
,
4782 BASEPROPERTY_ENFORCE_FORMAT
,
4784 BASEPROPERTY_HIDEINACTIVESELECTION
,
4785 BASEPROPERTY_VERTICALALIGN
,
4786 BASEPROPERTY_WRITING_MODE
,
4787 BASEPROPERTY_CONTEXT_WRITING_MODE
,
4788 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR
,
4790 VCLXFormattedSpinField::ImplGetPropertyIds( rIds
);
4793 VCLXDateField::VCLXDateField()
4797 VCLXDateField::~VCLXDateField()
4801 // ::com::sun::star::uno::XInterface
4802 ::com::sun::star::uno::Any
VCLXDateField::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
)
4804 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
4805 (static_cast< ::com::sun::star::awt::XDateField
* >(this)) );
4806 return (aRet
.hasValue() ? aRet
: VCLXFormattedSpinField::queryInterface( rType
));
4809 // ::com::sun::star::lang::XTypeProvider
4810 IMPL_XTYPEPROVIDER_START( VCLXDateField
)
4811 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XDateField
>* ) NULL
),
4812 VCLXFormattedSpinField::getTypes()
4813 IMPL_XTYPEPROVIDER_END
4815 void VCLXDateField::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
)
4817 SolarMutexGuard aGuard
;
4821 sal_Bool bVoid
= Value
.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID
;
4823 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
4824 switch ( nPropType
)
4826 case BASEPROPERTY_DATE
:
4830 ((DateField
*)GetWindow())->EnableEmptyFieldValue( sal_True
);
4831 ((DateField
*)GetWindow())->SetEmptyFieldValue();
4841 case BASEPROPERTY_DATEMIN
:
4848 case BASEPROPERTY_DATEMAX
:
4855 case BASEPROPERTY_EXTDATEFORMAT
:
4857 sal_Int16 n
= sal_Int16();
4859 ((DateField
*)GetWindow())->SetExtDateFormat( (ExtDateFieldFormat
) n
);
4862 case BASEPROPERTY_DATESHOWCENTURY
:
4864 sal_Bool b
= sal_Bool();
4866 ((DateField
*)GetWindow())->SetShowDateCentury( b
);
4869 case BASEPROPERTY_ENFORCE_FORMAT
:
4871 sal_Bool
bEnforce( sal_True
);
4872 OSL_VERIFY( Value
>>= bEnforce
);
4873 static_cast< DateField
* >( GetWindow() )->EnforceValidValue( bEnforce
);
4878 VCLXFormattedSpinField::setProperty( PropertyName
, Value
);
4884 ::com::sun::star::uno::Any
VCLXDateField::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
)
4886 SolarMutexGuard aGuard
;
4888 ::com::sun::star::uno::Any aProp
;
4889 FormatterBase
* pFormatter
= GetFormatter();
4892 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
4893 switch ( nPropType
)
4895 case BASEPROPERTY_DATE
:
4897 aProp
<<= getDate();
4900 case BASEPROPERTY_DATEMIN
:
4905 case BASEPROPERTY_DATEMAX
:
4910 case BASEPROPERTY_DATESHOWCENTURY
:
4912 aProp
<<= ((DateField
*)GetWindow())->IsShowDateCentury();
4915 case BASEPROPERTY_ENFORCE_FORMAT
:
4917 aProp
<<= (sal_Bool
)static_cast< DateField
* >( GetWindow() )->IsEnforceValidValue( );
4922 aProp
<<= VCLXFormattedSpinField::getProperty( PropertyName
);
4930 void VCLXDateField::setDate( const util::Date
& aDate
) throw(::com::sun::star::uno::RuntimeException
)
4932 SolarMutexGuard aGuard
;
4934 DateField
* pDateField
= (DateField
*) GetWindow();
4937 pDateField
->SetDate( aDate
);
4939 // #107218# Call same listeners like VCL would do after user interaction
4940 SetSynthesizingVCLEvent( sal_True
);
4941 pDateField
->SetModifyFlag();
4942 pDateField
->Modify();
4943 SetSynthesizingVCLEvent( sal_False
);
4947 util::Date
VCLXDateField::getDate() throw(::com::sun::star::uno::RuntimeException
)
4949 SolarMutexGuard aGuard
;
4951 DateField
* pDateField
= (DateField
*) GetWindow();
4953 return pDateField
->GetDate().GetUNODate();
4955 return util::Date();
4958 void VCLXDateField::setMin( const util::Date
& aDate
) throw(::com::sun::star::uno::RuntimeException
)
4960 SolarMutexGuard aGuard
;
4962 DateField
* pDateField
= (DateField
*) GetWindow();
4964 pDateField
->SetMin( aDate
);
4967 util::Date
VCLXDateField::getMin() throw(::com::sun::star::uno::RuntimeException
)
4969 SolarMutexGuard aGuard
;
4971 DateField
* pDateField
= (DateField
*) GetWindow();
4973 return pDateField
->GetMin().GetUNODate();
4975 return util::Date();
4978 void VCLXDateField::setMax( const util::Date
& aDate
) throw(::com::sun::star::uno::RuntimeException
)
4980 SolarMutexGuard aGuard
;
4982 DateField
* pDateField
= (DateField
*) GetWindow();
4984 pDateField
->SetMax( aDate
);
4987 util::Date
VCLXDateField::getMax() throw(::com::sun::star::uno::RuntimeException
)
4989 SolarMutexGuard aGuard
;
4991 DateField
* pDateField
= (DateField
*) GetWindow();
4993 return pDateField
->GetMax().GetUNODate();
4995 return util::Date();
4998 void VCLXDateField::setFirst( const util::Date
& aDate
) throw(::com::sun::star::uno::RuntimeException
)
5000 SolarMutexGuard aGuard
;
5002 DateField
* pDateField
= (DateField
*) GetWindow();
5004 pDateField
->SetFirst( aDate
);
5007 util::Date
VCLXDateField::getFirst() throw(::com::sun::star::uno::RuntimeException
)
5009 SolarMutexGuard aGuard
;
5011 DateField
* pDateField
= (DateField
*) GetWindow();
5013 return pDateField
->GetFirst().GetUNODate();
5015 return util::Date();
5018 void VCLXDateField::setLast( const util::Date
& aDate
) throw(::com::sun::star::uno::RuntimeException
)
5020 SolarMutexGuard aGuard
;
5022 DateField
* pDateField
= (DateField
*) GetWindow();
5024 pDateField
->SetLast( aDate
);
5027 util::Date
VCLXDateField::getLast() throw(::com::sun::star::uno::RuntimeException
)
5029 SolarMutexGuard aGuard
;
5031 DateField
* pDateField
= (DateField
*) GetWindow();
5033 return pDateField
->GetLast().GetUNODate();
5035 return util::Date();
5038 void VCLXDateField::setLongFormat( sal_Bool bLong
) throw(::com::sun::star::uno::RuntimeException
)
5040 SolarMutexGuard aGuard
;
5042 DateField
* pDateField
= (DateField
*) GetWindow();
5044 pDateField
->SetLongFormat( bLong
);
5047 sal_Bool
VCLXDateField::isLongFormat() throw(::com::sun::star::uno::RuntimeException
)
5049 SolarMutexGuard aGuard
;
5051 DateField
* pDateField
= (DateField
*) GetWindow();
5052 return pDateField
? pDateField
->IsLongFormat() : sal_False
;
5055 void VCLXDateField::setEmpty() throw(::com::sun::star::uno::RuntimeException
)
5057 SolarMutexGuard aGuard
;
5059 DateField
* pDateField
= (DateField
*) GetWindow();
5062 pDateField
->SetEmptyDate();
5064 // #107218# Call same listeners like VCL would do after user interaction
5065 SetSynthesizingVCLEvent( sal_True
);
5066 pDateField
->SetModifyFlag();
5067 pDateField
->Modify();
5068 SetSynthesizingVCLEvent( sal_False
);
5072 sal_Bool
VCLXDateField::isEmpty() throw(::com::sun::star::uno::RuntimeException
)
5074 SolarMutexGuard aGuard
;
5076 DateField
* pDateField
= (DateField
*) GetWindow();
5077 return pDateField
? pDateField
->IsEmptyDate() : sal_False
;
5080 void VCLXDateField::setStrictFormat( sal_Bool bStrict
) throw(::com::sun::star::uno::RuntimeException
)
5082 VCLXFormattedSpinField::setStrictFormat( bStrict
);
5085 sal_Bool
VCLXDateField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException
)
5087 return VCLXFormattedSpinField::isStrictFormat();
5091 // ----------------------------------------------------
5092 // class VCLXTimeField
5093 // ----------------------------------------------------
5095 void VCLXTimeField::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
5097 PushPropertyIds( rIds
,
5099 BASEPROPERTY_BACKGROUNDCOLOR
,
5100 BASEPROPERTY_BORDER
,
5101 BASEPROPERTY_BORDERCOLOR
,
5102 BASEPROPERTY_DEFAULTCONTROL
,
5103 BASEPROPERTY_ENABLED
,
5104 BASEPROPERTY_ENABLEVISIBLE
,
5105 BASEPROPERTY_EXTTIMEFORMAT
,
5106 BASEPROPERTY_FONTDESCRIPTOR
,
5107 BASEPROPERTY_HELPTEXT
,
5108 BASEPROPERTY_HELPURL
,
5109 BASEPROPERTY_PRINTABLE
,
5110 BASEPROPERTY_READONLY
,
5111 BASEPROPERTY_REPEAT
,
5112 BASEPROPERTY_REPEAT_DELAY
,
5114 BASEPROPERTY_STRICTFORMAT
,
5115 BASEPROPERTY_TABSTOP
,
5117 BASEPROPERTY_TIMEMAX
,
5118 BASEPROPERTY_TIMEMIN
,
5119 BASEPROPERTY_ENFORCE_FORMAT
,
5121 BASEPROPERTY_HIDEINACTIVESELECTION
,
5122 BASEPROPERTY_VERTICALALIGN
,
5123 BASEPROPERTY_WRITING_MODE
,
5124 BASEPROPERTY_CONTEXT_WRITING_MODE
,
5125 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR
,
5127 VCLXFormattedSpinField::ImplGetPropertyIds( rIds
);
5130 VCLXTimeField::VCLXTimeField()
5134 VCLXTimeField::~VCLXTimeField()
5138 // ::com::sun::star::uno::XInterface
5139 ::com::sun::star::uno::Any
VCLXTimeField::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
)
5141 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
5142 (static_cast< ::com::sun::star::awt::XTimeField
* >(this)) );
5143 return (aRet
.hasValue() ? aRet
: VCLXFormattedSpinField::queryInterface( rType
));
5146 // ::com::sun::star::lang::XTypeProvider
5147 IMPL_XTYPEPROVIDER_START( VCLXTimeField
)
5148 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XTimeField
>* ) NULL
),
5149 VCLXFormattedSpinField::getTypes()
5150 IMPL_XTYPEPROVIDER_END
5152 void VCLXTimeField::setTime( const util::Time
& aTime
) throw(::com::sun::star::uno::RuntimeException
)
5154 SolarMutexGuard aGuard
;
5156 TimeField
* pTimeField
= (TimeField
*) GetWindow();
5159 pTimeField
->SetTime( aTime
);
5161 // #107218# Call same listeners like VCL would do after user interaction
5162 SetSynthesizingVCLEvent( sal_True
);
5163 pTimeField
->SetModifyFlag();
5164 pTimeField
->Modify();
5165 SetSynthesizingVCLEvent( sal_False
);
5169 util::Time
VCLXTimeField::getTime() throw(::com::sun::star::uno::RuntimeException
)
5171 SolarMutexGuard aGuard
;
5173 TimeField
* pTimeField
= (TimeField
*) GetWindow();
5175 return pTimeField
->GetTime().GetUNOTime();
5177 return util::Time();
5180 void VCLXTimeField::setMin( const util::Time
& aTime
) throw(::com::sun::star::uno::RuntimeException
)
5182 SolarMutexGuard aGuard
;
5184 TimeField
* pTimeField
= (TimeField
*) GetWindow();
5186 pTimeField
->SetMin( aTime
);
5189 util::Time
VCLXTimeField::getMin() throw(::com::sun::star::uno::RuntimeException
)
5191 SolarMutexGuard aGuard
;
5193 TimeField
* pTimeField
= (TimeField
*) GetWindow();
5195 return pTimeField
->GetMin().GetUNOTime();
5197 return util::Time();
5200 void VCLXTimeField::setMax( const util::Time
& aTime
) throw(::com::sun::star::uno::RuntimeException
)
5202 SolarMutexGuard aGuard
;
5204 TimeField
* pTimeField
= (TimeField
*) GetWindow();
5206 pTimeField
->SetMax( aTime
);
5209 util::Time
VCLXTimeField::getMax() throw(::com::sun::star::uno::RuntimeException
)
5211 SolarMutexGuard aGuard
;
5213 TimeField
* pTimeField
= (TimeField
*) GetWindow();
5215 return pTimeField
->GetMax().GetUNOTime();
5217 return util::Time();
5220 void VCLXTimeField::setFirst( const util::Time
& aTime
) throw(::com::sun::star::uno::RuntimeException
)
5222 SolarMutexGuard aGuard
;
5224 TimeField
* pTimeField
= (TimeField
*) GetWindow();
5226 pTimeField
->SetFirst( aTime
);
5229 util::Time
VCLXTimeField::getFirst() throw(::com::sun::star::uno::RuntimeException
)
5231 SolarMutexGuard aGuard
;
5233 TimeField
* pTimeField
= (TimeField
*) GetWindow();
5235 return pTimeField
->GetFirst().GetUNOTime();
5237 return util::Time();
5240 void VCLXTimeField::setLast( const util::Time
& aTime
) throw(::com::sun::star::uno::RuntimeException
)
5242 SolarMutexGuard aGuard
;
5244 TimeField
* pTimeField
= (TimeField
*) GetWindow();
5246 pTimeField
->SetLast( aTime
);
5249 util::Time
VCLXTimeField::getLast() throw(::com::sun::star::uno::RuntimeException
)
5251 SolarMutexGuard aGuard
;
5253 TimeField
* pTimeField
= (TimeField
*) GetWindow();
5255 return pTimeField
->GetLast().GetUNOTime();
5257 return util::Time();
5260 void VCLXTimeField::setEmpty() throw(::com::sun::star::uno::RuntimeException
)
5262 SolarMutexGuard aGuard
;
5264 TimeField
* pTimeField
= (TimeField
*) GetWindow();
5266 pTimeField
->SetEmptyTime();
5269 sal_Bool
VCLXTimeField::isEmpty() throw(::com::sun::star::uno::RuntimeException
)
5271 SolarMutexGuard aGuard
;
5273 TimeField
* pTimeField
= (TimeField
*) GetWindow();
5274 return pTimeField
? pTimeField
->IsEmptyTime() : sal_False
;
5277 void VCLXTimeField::setStrictFormat( sal_Bool bStrict
) throw(::com::sun::star::uno::RuntimeException
)
5279 VCLXFormattedSpinField::setStrictFormat( bStrict
);
5282 sal_Bool
VCLXTimeField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException
)
5284 return VCLXFormattedSpinField::isStrictFormat();
5288 void VCLXTimeField::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
)
5290 SolarMutexGuard aGuard
;
5294 sal_Bool bVoid
= Value
.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID
;
5296 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
5297 switch ( nPropType
)
5299 case BASEPROPERTY_TIME
:
5303 ((TimeField
*)GetWindow())->EnableEmptyFieldValue( sal_True
);
5304 ((TimeField
*)GetWindow())->SetEmptyFieldValue();
5314 case BASEPROPERTY_TIMEMIN
:
5321 case BASEPROPERTY_TIMEMAX
:
5328 case BASEPROPERTY_EXTTIMEFORMAT
:
5330 sal_Int16 n
= sal_Int16();
5332 ((TimeField
*)GetWindow())->SetExtFormat( (ExtTimeFieldFormat
) n
);
5335 case BASEPROPERTY_ENFORCE_FORMAT
:
5337 sal_Bool
bEnforce( sal_True
);
5338 OSL_VERIFY( Value
>>= bEnforce
);
5339 static_cast< TimeField
* >( GetWindow() )->EnforceValidValue( bEnforce
);
5344 VCLXFormattedSpinField::setProperty( PropertyName
, Value
);
5350 ::com::sun::star::uno::Any
VCLXTimeField::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
)
5352 SolarMutexGuard aGuard
;
5354 ::com::sun::star::uno::Any aProp
;
5357 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
5358 switch ( nPropType
)
5360 case BASEPROPERTY_TIME
:
5362 aProp
<<= getTime();
5365 case BASEPROPERTY_TIMEMIN
:
5370 case BASEPROPERTY_TIMEMAX
:
5375 case BASEPROPERTY_ENFORCE_FORMAT
:
5377 aProp
<<= (sal_Bool
)static_cast< TimeField
* >( GetWindow() )->IsEnforceValidValue( );
5382 aProp
<<= VCLXFormattedSpinField::getProperty( PropertyName
);
5389 // ----------------------------------------------------
5390 // class VCLXNumericField
5391 // ----------------------------------------------------
5393 void VCLXNumericField::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
5395 PushPropertyIds( rIds
,
5397 BASEPROPERTY_BACKGROUNDCOLOR
,
5398 BASEPROPERTY_BORDER
,
5399 BASEPROPERTY_BORDERCOLOR
,
5400 BASEPROPERTY_DECIMALACCURACY
,
5401 BASEPROPERTY_DEFAULTCONTROL
,
5402 BASEPROPERTY_ENABLED
,
5403 BASEPROPERTY_ENABLEVISIBLE
,
5404 BASEPROPERTY_FONTDESCRIPTOR
,
5405 BASEPROPERTY_HELPTEXT
,
5406 BASEPROPERTY_HELPURL
,
5407 BASEPROPERTY_NUMSHOWTHOUSANDSEP
,
5408 BASEPROPERTY_PRINTABLE
,
5409 BASEPROPERTY_READONLY
,
5410 BASEPROPERTY_REPEAT
,
5411 BASEPROPERTY_REPEAT_DELAY
,
5413 BASEPROPERTY_STRICTFORMAT
,
5414 BASEPROPERTY_TABSTOP
,
5415 BASEPROPERTY_VALUEMAX_DOUBLE
,
5416 BASEPROPERTY_VALUEMIN_DOUBLE
,
5417 BASEPROPERTY_VALUESTEP_DOUBLE
,
5418 BASEPROPERTY_VALUE_DOUBLE
,
5419 BASEPROPERTY_ENFORCE_FORMAT
,
5420 BASEPROPERTY_HIDEINACTIVESELECTION
,
5421 BASEPROPERTY_VERTICALALIGN
,
5422 BASEPROPERTY_WRITING_MODE
,
5423 BASEPROPERTY_CONTEXT_WRITING_MODE
,
5424 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR
,
5426 VCLXFormattedSpinField::ImplGetPropertyIds( rIds
);
5429 VCLXNumericField::VCLXNumericField()
5433 VCLXNumericField::~VCLXNumericField()
5437 // ::com::sun::star::uno::XInterface
5438 ::com::sun::star::uno::Any
VCLXNumericField::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
)
5440 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
5441 (static_cast< ::com::sun::star::awt::XNumericField
* >(this)) );
5442 return (aRet
.hasValue() ? aRet
: VCLXFormattedSpinField::queryInterface( rType
));
5445 // ::com::sun::star::lang::XTypeProvider
5446 IMPL_XTYPEPROVIDER_START( VCLXNumericField
)
5447 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XNumericField
>* ) NULL
),
5448 VCLXFormattedSpinField::getTypes()
5449 IMPL_XTYPEPROVIDER_END
5451 void VCLXNumericField::setValue( double Value
) throw(::com::sun::star::uno::RuntimeException
)
5453 SolarMutexGuard aGuard
;
5455 NumericFormatter
* pNumericFormatter
= (NumericFormatter
*) GetFormatter();
5456 if ( pNumericFormatter
)
5458 // shift long value using decimal digits
5459 // (e.g., input 105 using 2 digits returns 1,05)
5460 // Thus, to set a value of 1,05, insert 105 and 2 digits
5461 pNumericFormatter
->SetValue(
5462 (long)ImplCalcLongValue( Value
, pNumericFormatter
->GetDecimalDigits() ) );
5464 // #107218# Call same listeners like VCL would do after user interaction
5465 Edit
* pEdit
= (Edit
*)GetWindow();
5468 SetSynthesizingVCLEvent( sal_True
);
5469 pEdit
->SetModifyFlag();
5471 SetSynthesizingVCLEvent( sal_False
);
5476 double VCLXNumericField::getValue() throw(::com::sun::star::uno::RuntimeException
)
5478 SolarMutexGuard aGuard
;
5480 NumericFormatter
* pNumericFormatter
= (NumericFormatter
*) GetFormatter();
5481 return pNumericFormatter
5482 ? ImplCalcDoubleValue( (double)pNumericFormatter
->GetValue(), pNumericFormatter
->GetDecimalDigits() )
5486 void VCLXNumericField::setMin( double Value
) throw(::com::sun::star::uno::RuntimeException
)
5488 SolarMutexGuard aGuard
;
5490 NumericFormatter
* pNumericFormatter
= (NumericFormatter
*) GetFormatter();
5491 if ( pNumericFormatter
)
5492 pNumericFormatter
->SetMin(
5493 (long)ImplCalcLongValue( Value
, pNumericFormatter
->GetDecimalDigits() ) );
5496 double VCLXNumericField::getMin() throw(::com::sun::star::uno::RuntimeException
)
5498 SolarMutexGuard aGuard
;
5500 NumericFormatter
* pNumericFormatter
= (NumericFormatter
*) GetFormatter();
5501 return pNumericFormatter
5502 ? ImplCalcDoubleValue( (double)pNumericFormatter
->GetMin(), pNumericFormatter
->GetDecimalDigits() )
5506 void VCLXNumericField::setMax( double Value
) throw(::com::sun::star::uno::RuntimeException
)
5508 SolarMutexGuard aGuard
;
5510 NumericFormatter
* pNumericFormatter
= (NumericFormatter
*) GetFormatter();
5511 if ( pNumericFormatter
)
5512 pNumericFormatter
->SetMax(
5513 (long)ImplCalcLongValue( Value
, pNumericFormatter
->GetDecimalDigits() ) );
5516 double VCLXNumericField::getMax() throw(::com::sun::star::uno::RuntimeException
)
5518 SolarMutexGuard aGuard
;
5520 NumericFormatter
* pNumericFormatter
= (NumericFormatter
*) GetFormatter();
5521 return pNumericFormatter
5522 ? ImplCalcDoubleValue( (double)pNumericFormatter
->GetMax(), pNumericFormatter
->GetDecimalDigits() )
5526 void VCLXNumericField::setFirst( double Value
) throw(::com::sun::star::uno::RuntimeException
)
5528 SolarMutexGuard aGuard
;
5530 NumericField
* pNumericField
= (NumericField
*) GetWindow();
5531 if ( pNumericField
)
5532 pNumericField
->SetFirst(
5533 (long)ImplCalcLongValue( Value
, pNumericField
->GetDecimalDigits() ) );
5536 double VCLXNumericField::getFirst() throw(::com::sun::star::uno::RuntimeException
)
5538 SolarMutexGuard aGuard
;
5540 NumericField
* pNumericField
= (NumericField
*) GetWindow();
5541 return pNumericField
5542 ? ImplCalcDoubleValue( (double)pNumericField
->GetFirst(), pNumericField
->GetDecimalDigits() )
5546 void VCLXNumericField::setLast( double Value
) throw(::com::sun::star::uno::RuntimeException
)
5548 SolarMutexGuard aGuard
;
5550 NumericField
* pNumericField
= (NumericField
*) GetWindow();
5551 if ( pNumericField
)
5552 pNumericField
->SetLast(
5553 (long)ImplCalcLongValue( Value
, pNumericField
->GetDecimalDigits() ) );
5556 double VCLXNumericField::getLast() throw(::com::sun::star::uno::RuntimeException
)
5558 SolarMutexGuard aGuard
;
5560 NumericField
* pNumericField
= (NumericField
*) GetWindow();
5561 return pNumericField
5562 ? ImplCalcDoubleValue( (double)pNumericField
->GetLast(), pNumericField
->GetDecimalDigits() )
5566 void VCLXNumericField::setStrictFormat( sal_Bool bStrict
) throw(::com::sun::star::uno::RuntimeException
)
5568 VCLXFormattedSpinField::setStrictFormat( bStrict
);
5571 sal_Bool
VCLXNumericField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException
)
5573 return VCLXFormattedSpinField::isStrictFormat();
5577 void VCLXNumericField::setSpinSize( double Value
) throw(::com::sun::star::uno::RuntimeException
)
5579 SolarMutexGuard aGuard
;
5581 NumericField
* pNumericField
= (NumericField
*) GetWindow();
5582 if ( pNumericField
)
5583 pNumericField
->SetSpinSize(
5584 (long)ImplCalcLongValue( Value
, pNumericField
->GetDecimalDigits() ) );
5587 double VCLXNumericField::getSpinSize() throw(::com::sun::star::uno::RuntimeException
)
5589 SolarMutexGuard aGuard
;
5591 NumericField
* pNumericField
= (NumericField
*) GetWindow();
5592 return pNumericField
5593 ? ImplCalcDoubleValue( (double)pNumericField
->GetSpinSize(), pNumericField
->GetDecimalDigits() )
5597 void VCLXNumericField::setDecimalDigits( sal_Int16 Value
) throw(::com::sun::star::uno::RuntimeException
)
5599 SolarMutexGuard aGuard
;
5601 NumericFormatter
* pNumericFormatter
= (NumericFormatter
*) GetFormatter();
5602 if ( pNumericFormatter
)
5604 double n
= getValue();
5605 pNumericFormatter
->SetDecimalDigits( Value
);
5610 sal_Int16
VCLXNumericField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException
)
5612 SolarMutexGuard aGuard
;
5614 NumericFormatter
* pNumericFormatter
= (NumericFormatter
*) GetFormatter();
5615 return pNumericFormatter
? pNumericFormatter
->GetDecimalDigits() : 0;
5618 void VCLXNumericField::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
)
5620 SolarMutexGuard aGuard
;
5624 sal_Bool bVoid
= Value
.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID
;
5626 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
5627 switch ( nPropType
)
5629 case BASEPROPERTY_VALUE_DOUBLE
:
5633 ((NumericField
*)GetWindow())->EnableEmptyFieldValue( sal_True
);
5634 ((NumericField
*)GetWindow())->SetEmptyFieldValue();
5644 case BASEPROPERTY_VALUEMIN_DOUBLE
:
5651 case BASEPROPERTY_VALUEMAX_DOUBLE
:
5658 case BASEPROPERTY_VALUESTEP_DOUBLE
:
5665 case BASEPROPERTY_DECIMALACCURACY
:
5667 sal_Int16 n
= sal_Int16();
5669 setDecimalDigits( n
);
5672 case BASEPROPERTY_NUMSHOWTHOUSANDSEP
:
5674 sal_Bool b
= sal_Bool();
5676 ((NumericField
*)GetWindow())->SetUseThousandSep( b
);
5681 VCLXFormattedSpinField::setProperty( PropertyName
, Value
);
5687 ::com::sun::star::uno::Any
VCLXNumericField::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
)
5689 SolarMutexGuard aGuard
;
5691 ::com::sun::star::uno::Any aProp
;
5692 FormatterBase
* pFormatter
= GetFormatter();
5695 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
5696 switch ( nPropType
)
5698 case BASEPROPERTY_VALUE_DOUBLE
:
5700 aProp
<<= (double) getValue();
5703 case BASEPROPERTY_VALUEMIN_DOUBLE
:
5705 aProp
<<= (double) getMin();
5708 case BASEPROPERTY_VALUEMAX_DOUBLE
:
5710 aProp
<<= (double) getMax();
5713 case BASEPROPERTY_VALUESTEP_DOUBLE
:
5715 aProp
<<= (double) getSpinSize();
5718 case BASEPROPERTY_NUMSHOWTHOUSANDSEP
:
5720 aProp
<<= (sal_Bool
) ((NumericField
*)GetWindow())->IsUseThousandSep();
5725 aProp
<<= VCLXFormattedSpinField::getProperty( PropertyName
);
5733 // ----------------------------------------------------
5734 // class VCLXMetricField
5735 // ----------------------------------------------------
5737 void VCLXMetricField::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
5739 PushPropertyIds( rIds
,
5741 BASEPROPERTY_BACKGROUNDCOLOR
,
5742 BASEPROPERTY_BORDER
,
5743 BASEPROPERTY_BORDERCOLOR
,
5744 BASEPROPERTY_DECIMALACCURACY
,
5745 BASEPROPERTY_DEFAULTCONTROL
,
5746 BASEPROPERTY_ENABLED
,
5747 BASEPROPERTY_ENABLEVISIBLE
,
5748 BASEPROPERTY_FONTDESCRIPTOR
,
5749 BASEPROPERTY_HELPTEXT
,
5750 BASEPROPERTY_HELPURL
,
5751 BASEPROPERTY_NUMSHOWTHOUSANDSEP
,
5752 BASEPROPERTY_PRINTABLE
,
5753 BASEPROPERTY_READONLY
,
5754 BASEPROPERTY_REPEAT
,
5755 BASEPROPERTY_REPEAT_DELAY
,
5757 BASEPROPERTY_STRICTFORMAT
,
5758 BASEPROPERTY_TABSTOP
,
5759 BASEPROPERTY_ENFORCE_FORMAT
,
5760 BASEPROPERTY_HIDEINACTIVESELECTION
,
5762 BASEPROPERTY_CUSTOMUNITTEXT
,
5763 BASEPROPERTY_WRITING_MODE
,
5764 BASEPROPERTY_CONTEXT_WRITING_MODE
,
5765 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR
,
5767 VCLXFormattedSpinField::ImplGetPropertyIds( rIds
);
5770 VCLXMetricField::VCLXMetricField()
5774 VCLXMetricField::~VCLXMetricField()
5778 MetricFormatter
*VCLXMetricField::GetMetricFormatter() throw(::com::sun::star::uno::RuntimeException
)
5780 MetricFormatter
*pFormatter
= (MetricFormatter
*) GetFormatter();
5782 throw ::com::sun::star::uno::RuntimeException();
5786 MetricField
*VCLXMetricField::GetMetricField() throw(::com::sun::star::uno::RuntimeException
)
5788 MetricField
*pField
= (MetricField
*) GetWindow();
5790 throw ::com::sun::star::uno::RuntimeException();
5794 // ::com::sun::star::uno::XInterface
5795 ::com::sun::star::uno::Any
VCLXMetricField::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
)
5797 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
5798 (static_cast< ::com::sun::star::awt::XMetricField
* >(this)) );
5799 return (aRet
.hasValue() ? aRet
: VCLXFormattedSpinField::queryInterface( rType
));
5802 // ::com::sun::star::lang::XTypeProvider
5803 IMPL_XTYPEPROVIDER_START( VCLXMetricField
)
5804 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XMetricField
>* ) NULL
),
5805 VCLXFormattedSpinField::getTypes()
5806 IMPL_XTYPEPROVIDER_END
5809 #define MetricUnitUnoToVcl(a) ((FieldUnit)(a))
5811 #define METRIC_MAP_PAIR(method,parent) \
5812 sal_Int64 VCLXMetricField::get##method( sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException) \
5814 SolarMutexGuard aGuard; \
5815 return GetMetric##parent()->Get##method( MetricUnitUnoToVcl( nUnit ) ); \
5817 void VCLXMetricField::set##method( sal_Int64 nValue, sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException) \
5819 SolarMutexGuard aGuard; \
5820 GetMetric##parent()->Set##method( nValue, MetricUnitUnoToVcl( nUnit ) ); \
5823 METRIC_MAP_PAIR(Min
, Formatter
)
5824 METRIC_MAP_PAIR(Max
, Formatter
)
5825 METRIC_MAP_PAIR(First
, Field
)
5826 METRIC_MAP_PAIR(Last
, Field
)
5828 #undef METRIC_MAP_PAIR
5830 ::sal_Int64
VCLXMetricField::getValue( ::sal_Int16 nUnit
) throw (::com::sun::star::uno::RuntimeException
)
5832 SolarMutexGuard aGuard
;
5833 return GetMetricFormatter()->GetValue( MetricUnitUnoToVcl( nUnit
) );
5836 ::sal_Int64
VCLXMetricField::getCorrectedValue( ::sal_Int16 nUnit
) throw (::com::sun::star::uno::RuntimeException
)
5838 SolarMutexGuard aGuard
;
5839 return GetMetricFormatter()->GetCorrectedValue( MetricUnitUnoToVcl( nUnit
) );
5842 // FIXME: acute cut/paste evilness - move this to the parent Edit class ?
5843 void VCLXMetricField::CallListeners()
5845 // #107218# Call same listeners like VCL would do after user interaction
5846 Edit
* pEdit
= (Edit
*)GetWindow();
5849 SetSynthesizingVCLEvent( sal_True
);
5850 pEdit
->SetModifyFlag();
5852 SetSynthesizingVCLEvent( sal_False
);
5856 void VCLXMetricField::setValue( ::sal_Int64 Value
, ::sal_Int16 Unit
) throw (::com::sun::star::uno::RuntimeException
)
5858 SolarMutexGuard aGuard
;
5859 GetMetricFormatter()->SetValue( Value
, MetricUnitUnoToVcl( Unit
) );
5863 void VCLXMetricField::setUserValue( ::sal_Int64 Value
, ::sal_Int16 Unit
) throw (::com::sun::star::uno::RuntimeException
)
5865 SolarMutexGuard aGuard
;
5866 GetMetricFormatter()->SetUserValue( Value
, MetricUnitUnoToVcl( Unit
) );
5870 void VCLXMetricField::setStrictFormat( sal_Bool bStrict
) throw(::com::sun::star::uno::RuntimeException
)
5872 VCLXFormattedSpinField::setStrictFormat( bStrict
);
5875 sal_Bool
VCLXMetricField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException
)
5877 return VCLXFormattedSpinField::isStrictFormat();
5880 void VCLXMetricField::setSpinSize( sal_Int64 Value
) throw(::com::sun::star::uno::RuntimeException
)
5882 SolarMutexGuard aGuard
;
5883 GetMetricField()->SetSpinSize( Value
);
5886 sal_Int64
VCLXMetricField::getSpinSize() throw(::com::sun::star::uno::RuntimeException
)
5888 SolarMutexGuard aGuard
;
5889 return GetMetricField()->GetSpinSize();
5892 void VCLXMetricField::setDecimalDigits( sal_Int16 Value
) throw(::com::sun::star::uno::RuntimeException
)
5894 SolarMutexGuard aGuard
;
5895 GetMetricFormatter()->SetDecimalDigits( Value
);
5898 sal_Int16
VCLXMetricField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException
)
5900 SolarMutexGuard aGuard
;
5902 NumericFormatter
* pNumericFormatter
= (NumericFormatter
*) GetFormatter();
5903 return pNumericFormatter
? pNumericFormatter
->GetDecimalDigits() : 0;
5906 void VCLXMetricField::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
)
5908 SolarMutexGuard aGuard
;
5912 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
5913 switch ( nPropType
)
5915 case BASEPROPERTY_DECIMALACCURACY
:
5919 setDecimalDigits( n
);
5922 case BASEPROPERTY_NUMSHOWTHOUSANDSEP
:
5924 sal_Bool b
= sal_False
;
5926 ((NumericField
*)GetWindow())->SetUseThousandSep( b
);
5929 case BASEPROPERTY_UNIT
:
5931 sal_uInt16 nVal
= 0;
5932 if ( Value
>>= nVal
)
5933 ((MetricField
*)GetWindow())->SetUnit( (FieldUnit
) nVal
);
5936 case BASEPROPERTY_CUSTOMUNITTEXT
:
5939 if ( Value
>>= aStr
)
5940 ((MetricField
*)GetWindow())->SetCustomUnitText( aStr
);
5945 VCLXFormattedSpinField::setProperty( PropertyName
, Value
);
5952 ::com::sun::star::uno::Any
VCLXMetricField::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
)
5954 SolarMutexGuard aGuard
;
5956 ::com::sun::star::uno::Any aProp
;
5957 FormatterBase
* pFormatter
= GetFormatter();
5960 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
5961 switch ( nPropType
)
5963 case BASEPROPERTY_NUMSHOWTHOUSANDSEP
:
5964 aProp
<<= (sal_Bool
) ((NumericField
*)GetWindow())->IsUseThousandSep();
5966 case BASEPROPERTY_UNIT
:
5967 aProp
<<= (sal_uInt16
) ((MetricField
*)GetWindow())->GetUnit();
5969 case BASEPROPERTY_CUSTOMUNITTEXT
:
5970 aProp
<<= OUString (((MetricField
*)GetWindow())->GetCustomUnitText());
5974 aProp
<<= VCLXFormattedSpinField::getProperty( PropertyName
);
5983 // ----------------------------------------------------
5984 // class VCLXCurrencyField
5985 // ----------------------------------------------------
5987 void VCLXCurrencyField::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
5989 PushPropertyIds( rIds
,
5991 BASEPROPERTY_BACKGROUNDCOLOR
,
5992 BASEPROPERTY_BORDER
,
5993 BASEPROPERTY_BORDERCOLOR
,
5994 BASEPROPERTY_CURRENCYSYMBOL
,
5995 BASEPROPERTY_CURSYM_POSITION
,
5996 BASEPROPERTY_DECIMALACCURACY
,
5997 BASEPROPERTY_DEFAULTCONTROL
,
5998 BASEPROPERTY_ENABLED
,
5999 BASEPROPERTY_ENABLEVISIBLE
,
6000 BASEPROPERTY_FONTDESCRIPTOR
,
6001 BASEPROPERTY_HELPTEXT
,
6002 BASEPROPERTY_HELPURL
,
6003 BASEPROPERTY_NUMSHOWTHOUSANDSEP
,
6004 BASEPROPERTY_PRINTABLE
,
6005 BASEPROPERTY_READONLY
,
6006 BASEPROPERTY_REPEAT
,
6007 BASEPROPERTY_REPEAT_DELAY
,
6009 BASEPROPERTY_STRICTFORMAT
,
6010 BASEPROPERTY_TABSTOP
,
6011 BASEPROPERTY_VALUEMAX_DOUBLE
,
6012 BASEPROPERTY_VALUEMIN_DOUBLE
,
6013 BASEPROPERTY_VALUESTEP_DOUBLE
,
6014 BASEPROPERTY_VALUE_DOUBLE
,
6015 BASEPROPERTY_ENFORCE_FORMAT
,
6016 BASEPROPERTY_HIDEINACTIVESELECTION
,
6017 BASEPROPERTY_VERTICALALIGN
,
6018 BASEPROPERTY_WRITING_MODE
,
6019 BASEPROPERTY_CONTEXT_WRITING_MODE
,
6020 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR
,
6022 VCLXFormattedSpinField::ImplGetPropertyIds( rIds
);
6025 VCLXCurrencyField::VCLXCurrencyField()
6029 VCLXCurrencyField::~VCLXCurrencyField()
6033 // ::com::sun::star::uno::XInterface
6034 ::com::sun::star::uno::Any
VCLXCurrencyField::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
)
6036 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
6037 (static_cast< ::com::sun::star::awt::XCurrencyField
* >(this)) );
6038 return (aRet
.hasValue() ? aRet
: VCLXFormattedSpinField::queryInterface( rType
));
6041 // ::com::sun::star::lang::XTypeProvider
6042 IMPL_XTYPEPROVIDER_START( VCLXCurrencyField
)
6043 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XCurrencyField
>* ) NULL
),
6044 VCLXFormattedSpinField::getTypes()
6045 IMPL_XTYPEPROVIDER_END
6047 void VCLXCurrencyField::setValue( double Value
) throw(::com::sun::star::uno::RuntimeException
)
6049 SolarMutexGuard aGuard
;
6051 LongCurrencyFormatter
* pCurrencyFormatter
= (LongCurrencyFormatter
*) GetFormatter();
6052 if ( pCurrencyFormatter
)
6054 // shift long value using decimal digits
6055 // (e.g., input 105 using 2 digits returns 1,05)
6056 // Thus, to set a value of 1,05, insert 105 and 2 digits
6057 pCurrencyFormatter
->SetValue(
6058 ImplCalcLongValue( Value
, pCurrencyFormatter
->GetDecimalDigits() ) );
6060 // #107218# Call same listeners like VCL would do after user interaction
6061 Edit
* pEdit
= (Edit
*)GetWindow();
6064 SetSynthesizingVCLEvent( sal_True
);
6065 pEdit
->SetModifyFlag();
6067 SetSynthesizingVCLEvent( sal_False
);
6072 double VCLXCurrencyField::getValue() throw(::com::sun::star::uno::RuntimeException
)
6074 SolarMutexGuard aGuard
;
6076 LongCurrencyFormatter
* pCurrencyFormatter
= (LongCurrencyFormatter
*) GetFormatter();
6077 return pCurrencyFormatter
6078 ? ImplCalcDoubleValue( (double)pCurrencyFormatter
->GetValue(), pCurrencyFormatter
->GetDecimalDigits() )
6082 void VCLXCurrencyField::setMin( double Value
) throw(::com::sun::star::uno::RuntimeException
)
6084 SolarMutexGuard aGuard
;
6086 LongCurrencyFormatter
* pCurrencyFormatter
= (LongCurrencyFormatter
*) GetFormatter();
6087 if ( pCurrencyFormatter
)
6088 pCurrencyFormatter
->SetMin(
6089 ImplCalcLongValue( Value
, pCurrencyFormatter
->GetDecimalDigits() ) );
6092 double VCLXCurrencyField::getMin() throw(::com::sun::star::uno::RuntimeException
)
6094 SolarMutexGuard aGuard
;
6096 LongCurrencyFormatter
* pCurrencyFormatter
= (LongCurrencyFormatter
*) GetFormatter();
6097 return pCurrencyFormatter
6098 ? ImplCalcDoubleValue( (double)pCurrencyFormatter
->GetMin(), pCurrencyFormatter
->GetDecimalDigits() )
6102 void VCLXCurrencyField::setMax( double Value
) throw(::com::sun::star::uno::RuntimeException
)
6104 SolarMutexGuard aGuard
;
6106 LongCurrencyFormatter
* pCurrencyFormatter
= (LongCurrencyFormatter
*) GetFormatter();
6107 if ( pCurrencyFormatter
)
6108 pCurrencyFormatter
->SetMax(
6109 ImplCalcLongValue( Value
, pCurrencyFormatter
->GetDecimalDigits() ) );
6112 double VCLXCurrencyField::getMax() throw(::com::sun::star::uno::RuntimeException
)
6114 SolarMutexGuard aGuard
;
6116 LongCurrencyFormatter
* pCurrencyFormatter
= (LongCurrencyFormatter
*) GetFormatter();
6117 return pCurrencyFormatter
6118 ? ImplCalcDoubleValue( (double)pCurrencyFormatter
->GetMax(), pCurrencyFormatter
->GetDecimalDigits() )
6122 void VCLXCurrencyField::setFirst( double Value
) throw(::com::sun::star::uno::RuntimeException
)
6124 SolarMutexGuard aGuard
;
6126 LongCurrencyField
* pCurrencyField
= (LongCurrencyField
*) GetWindow();
6127 if ( pCurrencyField
)
6128 pCurrencyField
->SetFirst(
6129 ImplCalcLongValue( Value
, pCurrencyField
->GetDecimalDigits() ) );
6132 double VCLXCurrencyField::getFirst() throw(::com::sun::star::uno::RuntimeException
)
6134 SolarMutexGuard aGuard
;
6136 LongCurrencyField
* pCurrencyField
= (LongCurrencyField
*) GetWindow();
6137 return pCurrencyField
6138 ? ImplCalcDoubleValue( (double)pCurrencyField
->GetFirst(), pCurrencyField
->GetDecimalDigits() )
6142 void VCLXCurrencyField::setLast( double Value
) throw(::com::sun::star::uno::RuntimeException
)
6144 SolarMutexGuard aGuard
;
6146 LongCurrencyField
* pCurrencyField
= (LongCurrencyField
*) GetWindow();
6147 if ( pCurrencyField
)
6148 pCurrencyField
->SetLast(
6149 ImplCalcLongValue( Value
, pCurrencyField
->GetDecimalDigits() ) );
6152 double VCLXCurrencyField::getLast() throw(::com::sun::star::uno::RuntimeException
)
6154 SolarMutexGuard aGuard
;
6156 LongCurrencyField
* pCurrencyField
= (LongCurrencyField
*) GetWindow();
6157 return pCurrencyField
6158 ? ImplCalcDoubleValue( (double)pCurrencyField
->GetLast(), pCurrencyField
->GetDecimalDigits() )
6162 void VCLXCurrencyField::setSpinSize( double Value
) throw(::com::sun::star::uno::RuntimeException
)
6164 SolarMutexGuard aGuard
;
6166 LongCurrencyField
* pCurrencyField
= (LongCurrencyField
*) GetWindow();
6167 if ( pCurrencyField
)
6168 pCurrencyField
->SetSpinSize(
6169 ImplCalcLongValue( Value
, pCurrencyField
->GetDecimalDigits() ) );
6172 double VCLXCurrencyField::getSpinSize() throw(::com::sun::star::uno::RuntimeException
)
6174 SolarMutexGuard aGuard
;
6176 LongCurrencyField
* pCurrencyField
= (LongCurrencyField
*) GetWindow();
6177 return pCurrencyField
6178 ? ImplCalcDoubleValue( (double)pCurrencyField
->GetSpinSize(), pCurrencyField
->GetDecimalDigits() )
6182 void VCLXCurrencyField::setStrictFormat( sal_Bool bStrict
) throw(::com::sun::star::uno::RuntimeException
)
6184 VCLXFormattedSpinField::setStrictFormat( bStrict
);
6187 sal_Bool
VCLXCurrencyField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException
)
6189 return VCLXFormattedSpinField::isStrictFormat();
6193 void VCLXCurrencyField::setDecimalDigits( sal_Int16 Value
) throw(::com::sun::star::uno::RuntimeException
)
6195 SolarMutexGuard aGuard
;
6197 LongCurrencyFormatter
* pCurrencyFormatter
= (LongCurrencyFormatter
*) GetFormatter();
6198 if ( pCurrencyFormatter
)
6200 double n
= getValue();
6201 pCurrencyFormatter
->SetDecimalDigits( Value
);
6206 sal_Int16
VCLXCurrencyField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException
)
6208 SolarMutexGuard aGuard
;
6210 LongCurrencyFormatter
* pCurrencyFormatter
= (LongCurrencyFormatter
*) GetFormatter();
6211 return pCurrencyFormatter
? pCurrencyFormatter
->GetDecimalDigits() : 0;
6214 void VCLXCurrencyField::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
)
6216 SolarMutexGuard aGuard
;
6220 sal_Bool bVoid
= Value
.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID
;
6222 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
6223 switch ( nPropType
)
6225 case BASEPROPERTY_VALUE_DOUBLE
:
6229 ((LongCurrencyField
*)GetWindow())->EnableEmptyFieldValue( sal_True
);
6230 ((LongCurrencyField
*)GetWindow())->SetEmptyFieldValue();
6240 case BASEPROPERTY_VALUEMIN_DOUBLE
:
6247 case BASEPROPERTY_VALUEMAX_DOUBLE
:
6254 case BASEPROPERTY_VALUESTEP_DOUBLE
:
6261 case BASEPROPERTY_DECIMALACCURACY
:
6263 sal_Int16 n
= sal_Int16();
6265 setDecimalDigits( n
);
6268 case BASEPROPERTY_CURRENCYSYMBOL
:
6271 if ( Value
>>= aString
)
6272 ((LongCurrencyField
*)GetWindow())->SetCurrencySymbol( aString
);
6275 case BASEPROPERTY_NUMSHOWTHOUSANDSEP
:
6277 sal_Bool b
= sal_Bool();
6279 ((LongCurrencyField
*)GetWindow())->SetUseThousandSep( b
);
6284 VCLXFormattedSpinField::setProperty( PropertyName
, Value
);
6290 ::com::sun::star::uno::Any
VCLXCurrencyField::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
)
6292 SolarMutexGuard aGuard
;
6294 ::com::sun::star::uno::Any aProp
;
6295 FormatterBase
* pFormatter
= GetFormatter();
6298 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
6299 switch ( nPropType
)
6301 case BASEPROPERTY_VALUE_DOUBLE
:
6303 aProp
<<= (double) getValue();
6306 case BASEPROPERTY_VALUEMIN_DOUBLE
:
6308 aProp
<<= (double) getMin();
6311 case BASEPROPERTY_VALUEMAX_DOUBLE
:
6313 aProp
<<= (double) getMax();
6316 case BASEPROPERTY_VALUESTEP_DOUBLE
:
6318 aProp
<<= (double) getSpinSize();
6321 case BASEPROPERTY_CURRENCYSYMBOL
:
6323 aProp
<<= OUString( ((LongCurrencyField
*)GetWindow())->GetCurrencySymbol() );
6326 case BASEPROPERTY_NUMSHOWTHOUSANDSEP
:
6328 aProp
<<= (sal_Bool
) ((LongCurrencyField
*)GetWindow())->IsUseThousandSep();
6333 aProp
<<= VCLXFormattedSpinField::getProperty( PropertyName
);
6340 // ----------------------------------------------------
6341 // class VCLXPatternField
6342 // ----------------------------------------------------
6344 void VCLXPatternField::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
6346 PushPropertyIds( rIds
,
6348 BASEPROPERTY_BACKGROUNDCOLOR
,
6349 BASEPROPERTY_BORDER
,
6350 BASEPROPERTY_BORDERCOLOR
,
6351 BASEPROPERTY_DEFAULTCONTROL
,
6352 BASEPROPERTY_EDITMASK
,
6353 BASEPROPERTY_ENABLED
,
6354 BASEPROPERTY_ENABLEVISIBLE
,
6355 BASEPROPERTY_FONTDESCRIPTOR
,
6356 BASEPROPERTY_HELPTEXT
,
6357 BASEPROPERTY_HELPURL
,
6358 BASEPROPERTY_LITERALMASK
,
6359 BASEPROPERTY_MAXTEXTLEN
,
6360 BASEPROPERTY_PRINTABLE
,
6361 BASEPROPERTY_READONLY
,
6362 BASEPROPERTY_STRICTFORMAT
,
6363 BASEPROPERTY_TABSTOP
,
6365 BASEPROPERTY_HIDEINACTIVESELECTION
,
6366 BASEPROPERTY_VERTICALALIGN
,
6367 BASEPROPERTY_WRITING_MODE
,
6368 BASEPROPERTY_CONTEXT_WRITING_MODE
,
6369 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR
,
6371 VCLXFormattedSpinField::ImplGetPropertyIds( rIds
);
6374 VCLXPatternField::VCLXPatternField()
6378 VCLXPatternField::~VCLXPatternField()
6382 // ::com::sun::star::uno::XInterface
6383 ::com::sun::star::uno::Any
VCLXPatternField::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
)
6385 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
6386 (static_cast< ::com::sun::star::awt::XPatternField
* >(this)) );
6387 return (aRet
.hasValue() ? aRet
: VCLXFormattedSpinField::queryInterface( rType
));
6390 // ::com::sun::star::lang::XTypeProvider
6391 IMPL_XTYPEPROVIDER_START( VCLXPatternField
)
6392 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XPatternField
>* ) NULL
),
6393 VCLXFormattedSpinField::getTypes()
6394 IMPL_XTYPEPROVIDER_END
6396 void VCLXPatternField::setMasks( const OUString
& EditMask
, const OUString
& LiteralMask
) throw(::com::sun::star::uno::RuntimeException
)
6398 SolarMutexGuard aGuard
;
6400 PatternField
* pPatternField
= (PatternField
*) GetWindow();
6401 if ( pPatternField
)
6403 pPatternField
->SetMask( OUStringToOString(EditMask
, RTL_TEXTENCODING_ASCII_US
), LiteralMask
);
6407 void VCLXPatternField::getMasks( OUString
& EditMask
, OUString
& LiteralMask
) throw(::com::sun::star::uno::RuntimeException
)
6409 SolarMutexGuard aGuard
;
6411 PatternField
* pPatternField
= (PatternField
*) GetWindow();
6412 if ( pPatternField
)
6414 EditMask
= OStringToOUString(pPatternField
->GetEditMask(), RTL_TEXTENCODING_ASCII_US
);
6415 LiteralMask
= pPatternField
->GetLiteralMask();
6419 void VCLXPatternField::setString( const OUString
& Str
) throw(::com::sun::star::uno::RuntimeException
)
6421 SolarMutexGuard aGuard
;
6423 PatternField
* pPatternField
= (PatternField
*) GetWindow();
6424 if ( pPatternField
)
6426 pPatternField
->SetString( Str
);
6430 OUString
VCLXPatternField::getString() throw(::com::sun::star::uno::RuntimeException
)
6432 SolarMutexGuard aGuard
;
6435 PatternField
* pPatternField
= (PatternField
*) GetWindow();
6436 if ( pPatternField
)
6437 aString
= pPatternField
->GetString();
6441 void VCLXPatternField::setStrictFormat( sal_Bool bStrict
) throw(::com::sun::star::uno::RuntimeException
)
6443 VCLXFormattedSpinField::setStrictFormat( bStrict
);
6446 sal_Bool
VCLXPatternField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException
)
6448 return VCLXFormattedSpinField::isStrictFormat();
6451 void VCLXPatternField::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
)
6453 SolarMutexGuard aGuard
;
6457 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
6458 switch ( nPropType
)
6460 case BASEPROPERTY_EDITMASK
:
6461 case BASEPROPERTY_LITERALMASK
:
6464 if ( Value
>>= aString
)
6466 OUString aEditMask
, aLiteralMask
;
6467 getMasks( aEditMask
, aLiteralMask
);
6468 if ( nPropType
== BASEPROPERTY_EDITMASK
)
6469 aEditMask
= aString
;
6471 aLiteralMask
= aString
;
6472 setMasks( aEditMask
, aLiteralMask
);
6478 VCLXFormattedSpinField::setProperty( PropertyName
, Value
);
6484 ::com::sun::star::uno::Any
VCLXPatternField::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
)
6486 SolarMutexGuard aGuard
;
6488 ::com::sun::star::uno::Any aProp
;
6491 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
6492 switch ( nPropType
)
6494 case BASEPROPERTY_EDITMASK
:
6495 case BASEPROPERTY_LITERALMASK
:
6497 OUString aEditMask
, aLiteralMask
;
6498 getMasks( aEditMask
, aLiteralMask
);
6499 if ( nPropType
== BASEPROPERTY_EDITMASK
)
6500 aProp
<<= aEditMask
;
6502 aProp
<<= aLiteralMask
;
6507 aProp
<<= VCLXFormattedSpinField::getProperty( PropertyName
);
6514 // ----------------------------------------------------
6515 // class VCLXToolBox
6516 // ----------------------------------------------------
6517 VCLXToolBox::VCLXToolBox()
6521 VCLXToolBox::~VCLXToolBox()
6525 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> VCLXToolBox::CreateAccessibleContext()
6527 return getAccessibleFactory().createAccessibleContext( this );
6530 // ----------------------------------------------------
6532 // ----------------------------------------------------
6533 VCLXFrame::VCLXFrame()
6537 void VCLXFrame::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
6539 PushPropertyIds( rIds
,
6540 BASEPROPERTY_BACKGROUNDCOLOR
,
6541 BASEPROPERTY_DEFAULTCONTROL
,
6542 BASEPROPERTY_ENABLED
,
6543 BASEPROPERTY_ENABLEVISIBLE
,
6544 BASEPROPERTY_FONTDESCRIPTOR
,
6545 BASEPROPERTY_GRAPHIC
,
6546 BASEPROPERTY_HELPTEXT
,
6547 BASEPROPERTY_HELPURL
,
6548 BASEPROPERTY_PRINTABLE
,
6551 VCLXContainer::ImplGetPropertyIds( rIds
);
6554 VCLXFrame::~VCLXFrame()
6558 ::com::sun::star::uno::Any SAL_CALL
VCLXFrame::queryInterface(const ::com::sun::star::uno::Type
& rType
)
6559 throw(::com::sun::star::uno::RuntimeException
)
6561 return VCLXContainer::queryInterface( rType
);
6564 // ::com::sun::star::lang::XTypeProvider
6565 IMPL_XTYPEPROVIDER_START( VCLXFrame
)
6566 VCLXContainer::getTypes()
6567 IMPL_XTYPEPROVIDER_END
6569 // ::com::sun::star::awt::XView
6570 void SAL_CALL
VCLXFrame::draw( sal_Int32 nX
, sal_Int32 nY
)
6571 throw(::com::sun::star::uno::RuntimeException
)
6573 SolarMutexGuard aGuard
;
6574 Window
* pWindow
= GetWindow();
6578 OutputDevice
* pDev
= VCLUnoHelper::GetOutputDevice( getGraphics() );
6580 pDev
= pWindow
->GetParent();
6582 Size aSize
= pDev
->PixelToLogic( pWindow
->GetSizePixel() );
6583 Point aPos
= pDev
->PixelToLogic( Point( nX
, nY
) );
6585 pWindow
->Draw( pDev
, aPos
, aSize
, WINDOW_DRAW_NOCONTROLS
);
6589 // ::com::sun::star::awt::XDevice,
6590 ::com::sun::star::awt::DeviceInfo SAL_CALL
VCLXFrame::getInfo()
6591 throw(::com::sun::star::uno::RuntimeException
)
6593 ::com::sun::star::awt::DeviceInfo aInfo
= VCLXDevice::getInfo();
6597 void SAL_CALL
VCLXFrame::setProperty(
6598 const OUString
& PropertyName
,
6599 const ::com::sun::star::uno::Any
& Value
)
6600 throw(::com::sun::star::uno::RuntimeException
)
6602 SolarMutexGuard aGuard
;
6604 VCLXContainer::setProperty( PropertyName
, Value
);
6607 void VCLXFrame::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
6609 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xKeepAlive( this );
6610 VCLXContainer::ProcessWindowEvent( rVclWindowEvent
);
6613 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */