1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_toolkit.hxx"
26 #include <toolkit/awt/vclxwindows.hxx>
27 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
28 #include <com/sun/star/graphic/XGraphicProvider.hpp>
29 #include <toolkit/helper/vclunohelper.hxx>
30 #include <toolkit/helper/macros.hxx>
31 #include <toolkit/helper/property.hxx>
32 #include <toolkit/helper/convert.hxx>
33 #include <toolkit/helper/imagealign.hxx>
34 #include <toolkit/helper/accessibilityclient.hxx>
35 #include <toolkit/helper/fixedhyperbase.hxx>
36 #include <toolkit/helper/tkresmgr.hxx>
37 #include <cppuhelper/typeprovider.hxx>
38 #include <com/sun/star/awt/VisualEffect.hpp>
39 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
40 #include <com/sun/star/system/SystemShellExecute.hpp>
41 #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
42 #include <com/sun/star/resource/XStringResourceResolver.hpp>
43 #include <com/sun/star/awt/ImageScaleMode.hpp>
44 #include <com/sun/star/awt/XItemList.hpp>
45 #include <comphelper/componentcontext.hxx>
46 #include <comphelper/namedvaluecollection.hxx>
47 #include <comphelper/processfactory.hxx>
48
49 #ifndef _SV_BUTTON_HXX
50 #include <vcl/button.hxx>
51 #endif
52 #include <vcl/lstbox.hxx>
53 #include <vcl/combobox.hxx>
54 #include <vcl/field.hxx>
55 #include <vcl/longcurr.hxx>
56 #include <vcl/imgctrl.hxx>
57 #include <vcl/dialog.hxx>
58 #include <vcl/msgbox.hxx>
59 #include <vcl/scrbar.hxx>
60 #include <vcl/svapp.hxx>
61 #include <vcl/tabpage.hxx>
62 #include <vcl/tabctrl.hxx>
63 #include <tools/diagnose_ex.h>
64
65 #include <boost/bind.hpp>
66 #include <boost/function.hpp>
67
68 using ::com::sun::star::uno::Any;
69 using ::com::sun::star::uno::Reference;
70 using ::com::sun::star::uno::makeAny;
71 using ::com::sun::star::uno::RuntimeException;
72 using ::com::sun::star::lang::EventObject;
73 using ::com::sun::star::awt::ItemListEvent;
74 using ::com::sun::star::awt::XItemList;
75 using ::com::sun::star::graphic::XGraphic;
76 using ::com::sun::star::graphic::XGraphicProvider;
77
78 using namespace ::com::sun::star;
79 using namespace ::com::sun::star::awt::VisualEffect;
80 namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode;
81
ImplCalcLongValue(double nValue,sal_uInt16 nDigits)82 static double ImplCalcLongValue( double nValue, sal_uInt16 nDigits )
83 {
84 double n = nValue;
85 for ( sal_uInt16 d = 0; d < nDigits; d++ )
86 n *= 10;
87 return n;
88 }
89
ImplCalcDoubleValue(double nValue,sal_uInt16 nDigits)90 static double ImplCalcDoubleValue( double nValue, sal_uInt16 nDigits )
91 {
92 double n = nValue;
93 for ( sal_uInt16 d = 0; d < nDigits; d++ )
94 n /= 10;
95 return n;
96 }
97
98 namespace toolkit
99 {
100 /** sets the "face color" for button like controls (scroll bar, spin button)
101 */
setButtonLikeFaceColor(Window * _pWindow,const::com::sun::star::uno::Any & _rColorValue)102 void setButtonLikeFaceColor( Window* _pWindow, const ::com::sun::star::uno::Any& _rColorValue )
103 {
104 AllSettings aSettings = _pWindow->GetSettings();
105 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
106
107 if ( !_rColorValue.hasValue() )
108 {
109 const StyleSettings& aAppStyle = Application::GetSettings().GetStyleSettings();
110 aStyleSettings.SetFaceColor( aAppStyle.GetFaceColor( ) );
111 aStyleSettings.SetCheckedColor( aAppStyle.GetCheckedColor( ) );
112 aStyleSettings.SetLightBorderColor( aAppStyle.GetLightBorderColor() );
113 aStyleSettings.SetLightColor( aAppStyle.GetLightColor() );
114 aStyleSettings.SetShadowColor( aAppStyle.GetShadowColor() );
115 aStyleSettings.SetDarkShadowColor( aAppStyle.GetDarkShadowColor() );
116 }
117 else
118 {
119 sal_Int32 nBackgroundColor = 0;
120 _rColorValue >>= nBackgroundColor;
121 aStyleSettings.SetFaceColor( nBackgroundColor );
122
123 // for the real background (everything except the buttons and the thumb),
124 // use an average between the desired color and "white"
125 Color aWhite( COL_WHITE );
126 Color aBackground( nBackgroundColor );
127 aBackground.SetRed( ( aBackground.GetRed() + aWhite.GetRed() ) / 2 );
128 aBackground.SetGreen( ( aBackground.GetGreen() + aWhite.GetGreen() ) / 2 );
129 aBackground.SetBlue( ( aBackground.GetBlue() + aWhite.GetBlue() ) / 2 );
130 aStyleSettings.SetCheckedColor( aBackground );
131
132 sal_Int32 nBackgroundLuminance = Color( nBackgroundColor ).GetLuminance();
133 sal_Int32 nWhiteLuminance = Color( COL_WHITE ).GetLuminance();
134
135 Color aLightShadow( nBackgroundColor );
136 aLightShadow.IncreaseLuminance( (sal_uInt8)( ( nWhiteLuminance - nBackgroundLuminance ) * 2 / 3 ) );
137 aStyleSettings.SetLightBorderColor( aLightShadow );
138
139 Color aLight( nBackgroundColor );
140 aLight.IncreaseLuminance( (sal_uInt8)( ( nWhiteLuminance - nBackgroundLuminance ) * 1 / 3 ) );
141 aStyleSettings.SetLightColor( aLight );
142
143 Color aShadow( nBackgroundColor );
144 aShadow.DecreaseLuminance( (sal_uInt8)( nBackgroundLuminance * 1 / 3 ) );
145 aStyleSettings.SetShadowColor( aShadow );
146
147 Color aDarkShadow( nBackgroundColor );
148 aDarkShadow.DecreaseLuminance( (sal_uInt8)( nBackgroundLuminance * 2 / 3 ) );
149 aStyleSettings.SetDarkShadowColor( aDarkShadow );
150 }
151
152 aSettings.SetStyleSettings( aStyleSettings );
153 _pWindow->SetSettings( aSettings, sal_True );
154 }
155
getButtonLikeFaceColor(const Window * _pWindow)156 Any getButtonLikeFaceColor( const Window* _pWindow )
157 {
158 sal_Int32 nBackgroundColor = _pWindow->GetSettings().GetStyleSettings().GetFaceColor().GetColor();
159 return makeAny( nBackgroundColor );
160 }
161
adjustBooleanWindowStyle(const Any & _rValue,Window * _pWindow,WinBits _nBits,sal_Bool _bInverseSemantics)162 static void adjustBooleanWindowStyle( const Any& _rValue, Window* _pWindow, WinBits _nBits, sal_Bool _bInverseSemantics )
163 {
164 WinBits nStyle = _pWindow->GetStyle();
165 sal_Bool bValue( sal_False );
166 OSL_VERIFY( _rValue >>= bValue );
167 if ( bValue != _bInverseSemantics )
168 nStyle |= _nBits;
169 else
170 nStyle &= ~_nBits;
171 _pWindow->SetStyle( nStyle );
172 }
173
setVisualEffect(const Any & _rValue,Window * _pWindow)174 static void setVisualEffect( const Any& _rValue, Window* _pWindow )
175 {
176 AllSettings aSettings = _pWindow->GetSettings();
177 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
178
179 sal_Int16 nStyle = LOOK3D;
180 OSL_VERIFY( _rValue >>= nStyle );
181 switch ( nStyle )
182 {
183 case FLAT:
184 aStyleSettings.SetOptions( aStyleSettings.GetOptions() & ~STYLE_OPTION_MONO );
185 break;
186 case LOOK3D:
187 default:
188 aStyleSettings.SetOptions( aStyleSettings.GetOptions() | STYLE_OPTION_MONO );
189 }
190 aSettings.SetStyleSettings( aStyleSettings );
191 _pWindow->SetSettings( aSettings );
192 }
193
getVisualEffect(Window * _pWindow)194 static Any getVisualEffect( Window* _pWindow )
195 {
196 Any aEffect;
197
198 StyleSettings aStyleSettings = _pWindow->GetSettings().GetStyleSettings();
199 if ( (aStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
200 aEffect <<= (sal_Int16)FLAT;
201 else
202 aEffect <<= (sal_Int16)LOOK3D;
203 return aEffect;
204 }
205 }
206
207 // ----------------------------------------------------
208 // class VCLXGraphicControl
209 // ----------------------------------------------------
210
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)211 void VCLXGraphicControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
212 {
213 VCLXWindow::ImplGetPropertyIds( rIds );
214 }
215
ImplSetNewImage()216 void VCLXGraphicControl::ImplSetNewImage()
217 {
218 OSL_PRECOND( GetWindow(), "VCLXGraphicControl::ImplSetNewImage: window is required to be not-NULL!" );
219 Button* pButton = static_cast< Button* >( GetWindow() );
220 pButton->SetModeImage( GetImage() );
221 }
222
setPosSize(sal_Int32 X,sal_Int32 Y,sal_Int32 Width,sal_Int32 Height,short Flags)223 void VCLXGraphicControl::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, short Flags )
224 {
225 ::vos::OGuard aGuard( GetMutex() );
226
227 if ( GetWindow() )
228 {
229 Size aOldSize = GetWindow()->GetSizePixel();
230 VCLXWindow::setPosSize( X, Y, Width, Height, Flags );
231 if ( ( aOldSize.Width() != Width ) || ( aOldSize.Height() != Height ) )
232 ImplSetNewImage();
233 }
234 }
235
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)236 void VCLXGraphicControl::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value)
237 {
238 ::vos::OGuard aGuard( GetMutex() );
239
240 Button* pButton = static_cast< Button* >( GetWindow() );
241 if ( !pButton )
242 return;
243 sal_uInt16 nPropType = GetPropertyId( PropertyName );
244 switch ( nPropType )
245 {
246 case BASEPROPERTY_GRAPHIC:
247 {
248 Reference< XGraphic > xGraphic;
249 OSL_VERIFY( Value >>= xGraphic );
250 maImage = Image( xGraphic );
251 ImplSetNewImage();
252 }
253 break;
254
255 case BASEPROPERTY_IMAGEALIGN:
256 {
257 WindowType eType = GetWindow()->GetType();
258 if ( ( eType == WINDOW_PUSHBUTTON )
259 || ( eType == WINDOW_RADIOBUTTON )
260 || ( eType == WINDOW_CHECKBOX )
261 )
262 {
263 sal_Int16 nAlignment = sal_Int16();
264 if ( Value >>= nAlignment )
265 pButton->SetImageAlign( static_cast< ImageAlign >( nAlignment ) );
266 }
267 }
268 break;
269 case BASEPROPERTY_IMAGEPOSITION:
270 {
271 WindowType eType = GetWindow()->GetType();
272 if ( ( eType == WINDOW_PUSHBUTTON )
273 || ( eType == WINDOW_RADIOBUTTON )
274 || ( eType == WINDOW_CHECKBOX )
275 )
276 {
277 sal_Int16 nImagePosition = 2;
278 OSL_VERIFY( Value >>= nImagePosition );
279 pButton->SetImageAlign( ::toolkit::translateImagePosition( nImagePosition ) );
280 }
281 }
282 break;
283 default:
284 VCLXWindow::setProperty( PropertyName, Value );
285 break;
286 }
287 }
288
getProperty(const::rtl::OUString & PropertyName)289 ::com::sun::star::uno::Any VCLXGraphicControl::getProperty( const ::rtl::OUString& PropertyName )
290 {
291 ::vos::OGuard aGuard( GetMutex() );
292
293 ::com::sun::star::uno::Any aProp;
294 if ( !GetWindow() )
295 return aProp;
296
297 sal_uInt16 nPropType = GetPropertyId( PropertyName );
298 switch ( nPropType )
299 {
300 case BASEPROPERTY_GRAPHIC:
301 aProp <<= maImage.GetXGraphic();
302 break;
303 case BASEPROPERTY_IMAGEALIGN:
304 {
305 WindowType eType = GetWindow()->GetType();
306 if ( ( eType == WINDOW_PUSHBUTTON )
307 || ( eType == WINDOW_RADIOBUTTON )
308 || ( eType == WINDOW_CHECKBOX )
309 )
310 {
311 aProp <<= ::toolkit::getCompatibleImageAlign( static_cast< Button* >( GetWindow() )->GetImageAlign() );
312 }
313 }
314 break;
315 case BASEPROPERTY_IMAGEPOSITION:
316 {
317 WindowType eType = GetWindow()->GetType();
318 if ( ( eType == WINDOW_PUSHBUTTON )
319 || ( eType == WINDOW_RADIOBUTTON )
320 || ( eType == WINDOW_CHECKBOX )
321 )
322 {
323 aProp <<= ::toolkit::translateImagePosition( static_cast< Button* >( GetWindow() )->GetImageAlign() );
324 }
325 }
326 break;
327 default:
328 {
329 aProp <<= VCLXWindow::getProperty( PropertyName );
330 }
331 break;
332 }
333 return aProp;
334 }
335
336 //--------------------------------------------------------------------
337 // class VCLXButton
338 // ----------------------------------------------------
339
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)340 void VCLXButton::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
341 {
342 PushPropertyIds( rIds,
343 BASEPROPERTY_BACKGROUNDCOLOR,
344 BASEPROPERTY_DEFAULTBUTTON,
345 BASEPROPERTY_DEFAULTCONTROL,
346 BASEPROPERTY_ENABLED,
347 BASEPROPERTY_ENABLEVISIBLE,
348 BASEPROPERTY_FONTDESCRIPTOR,
349 BASEPROPERTY_GRAPHIC,
350 BASEPROPERTY_HELPTEXT,
351 BASEPROPERTY_HELPURL,
352 BASEPROPERTY_IMAGEALIGN,
353 BASEPROPERTY_IMAGEPOSITION,
354 BASEPROPERTY_IMAGEURL,
355 BASEPROPERTY_LABEL,
356 BASEPROPERTY_PRINTABLE,
357 BASEPROPERTY_PUSHBUTTONTYPE,
358 BASEPROPERTY_REPEAT,
359 BASEPROPERTY_REPEAT_DELAY,
360 BASEPROPERTY_STATE,
361 BASEPROPERTY_TABSTOP,
362 BASEPROPERTY_TOGGLE,
363 BASEPROPERTY_FOCUSONCLICK,
364 BASEPROPERTY_MULTILINE,
365 BASEPROPERTY_ALIGN,
366 BASEPROPERTY_VERTICALALIGN,
367 BASEPROPERTY_WRITING_MODE,
368 BASEPROPERTY_CONTEXT_WRITING_MODE,
369 BASEPROPERTY_REFERENCE_DEVICE,
370 0);
371 VCLXGraphicControl::ImplGetPropertyIds( rIds );
372 }
373
VCLXButton()374 VCLXButton::VCLXButton()
375 :maActionListeners( *this )
376 ,maItemListeners( *this )
377 {
378 }
379
~VCLXButton()380 VCLXButton::~VCLXButton()
381 {
382 }
383
CreateAccessibleContext()384 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXButton::CreateAccessibleContext()
385 {
386 return getAccessibleFactory().createAccessibleContext( this );
387 }
388
dispose()389 void VCLXButton::dispose()
390 {
391 ::vos::OGuard aGuard( GetMutex() );
392
393 ::com::sun::star::lang::EventObject aObj;
394 aObj.Source = (::cppu::OWeakObject*)this;
395 maActionListeners.disposeAndClear( aObj );
396 maItemListeners.disposeAndClear( aObj );
397 VCLXGraphicControl::dispose();
398 }
399
addActionListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XActionListener> & l)400 void VCLXButton::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )
401 {
402 ::vos::OGuard aGuard( GetMutex() );
403 maActionListeners.addInterface( l );
404 }
405
removeActionListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XActionListener> & l)406 void VCLXButton::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )
407 {
408 ::vos::OGuard aGuard( GetMutex() );
409 maActionListeners.removeInterface( l );
410 }
411
addItemListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XItemListener> & l)412 void VCLXButton::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l )
413 {
414 ::vos::OGuard aGuard( GetMutex() );
415 maItemListeners.addInterface( l );
416 }
417
removeItemListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XItemListener> & l)418 void VCLXButton::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l )
419 {
420 ::vos::OGuard aGuard( GetMutex() );
421 maItemListeners.removeInterface( l );
422 }
423
setLabel(const::rtl::OUString & rLabel)424 void VCLXButton::setLabel( const ::rtl::OUString& rLabel )
425 {
426 ::vos::OGuard aGuard( GetMutex() );
427
428 Window* pWindow = GetWindow();
429 if ( pWindow )
430 pWindow->SetText( rLabel );
431 }
432
setActionCommand(const::rtl::OUString & rCommand)433 void VCLXButton::setActionCommand( const ::rtl::OUString& rCommand )
434 {
435 ::vos::OGuard aGuard( GetMutex() );
436
437 maActionCommand = rCommand;
438 }
439
getMinimumSize()440 ::com::sun::star::awt::Size VCLXButton::getMinimumSize( )
441 {
442 ::vos::OGuard aGuard( GetMutex() );
443
444 Size aSz;
445 PushButton* pButton = (PushButton*) GetWindow();
446 if ( pButton )
447 aSz = pButton->CalcMinimumSize();
448 return AWTSize(aSz);
449 }
450
getPreferredSize()451 ::com::sun::star::awt::Size VCLXButton::getPreferredSize( )
452 {
453 ::com::sun::star::awt::Size aSz = getMinimumSize();
454 aSz.Width += 16;
455 aSz.Height += 10;
456 return aSz;
457 }
458
calcAdjustedSize(const::com::sun::star::awt::Size & rNewSize)459 ::com::sun::star::awt::Size VCLXButton::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize )
460 {
461 ::vos::OGuard aGuard( GetMutex() );
462
463 Size aSz = VCLSize(rNewSize);
464 PushButton* pButton = (PushButton*) GetWindow();
465 if ( pButton )
466 {
467 Size aMinSz = pButton->CalcMinimumSize();
468 // Kein Text, also Image
469 if ( !pButton->GetText().Len() )
470 {
471 if ( aSz.Width() < aMinSz.Width() )
472 aSz.Width() = aMinSz.Width();
473 if ( aSz.Height() < aMinSz.Height() )
474 aSz.Height() = aMinSz.Height();
475 }
476 else
477 {
478 if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
479 aSz.Height() = aMinSz.Height();
480 else
481 aSz = aMinSz;
482 }
483 }
484 return AWTSize(aSz);
485 }
486
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)487 void VCLXButton::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value)
488 {
489 ::vos::OGuard aGuard( GetMutex() );
490
491 Button* pButton = (Button*)GetWindow();
492 if ( pButton )
493 {
494 sal_uInt16 nPropType = GetPropertyId( PropertyName );
495 switch ( nPropType )
496 {
497 case BASEPROPERTY_FOCUSONCLICK:
498 ::toolkit::adjustBooleanWindowStyle( Value, pButton, WB_NOPOINTERFOCUS, sal_True );
499 break;
500
501 case BASEPROPERTY_TOGGLE:
502 ::toolkit::adjustBooleanWindowStyle( Value, pButton, WB_TOGGLE, sal_False );
503 break;
504
505 case BASEPROPERTY_DEFAULTBUTTON:
506 {
507 WinBits nStyle = pButton->GetStyle() | WB_DEFBUTTON;
508 sal_Bool b = sal_Bool();
509 if ( ( Value >>= b ) && !b )
510 nStyle &= ~WB_DEFBUTTON;
511 pButton->SetStyle( nStyle );
512 }
513 break;
514 case BASEPROPERTY_STATE:
515 {
516 if ( GetWindow()->GetType() == WINDOW_PUSHBUTTON )
517 {
518 sal_Int16 n = sal_Int16();
519 if ( Value >>= n )
520 ((PushButton*)pButton)->SetState( (TriState)n );
521 }
522 }
523 break;
524 default:
525 {
526 VCLXGraphicControl::setProperty( PropertyName, Value );
527 }
528 }
529 }
530 }
531
getProperty(const::rtl::OUString & PropertyName)532 ::com::sun::star::uno::Any VCLXButton::getProperty( const ::rtl::OUString& PropertyName )
533 {
534 ::vos::OGuard aGuard( GetMutex() );
535
536 ::com::sun::star::uno::Any aProp;
537 Button* pButton = (Button*)GetWindow();
538 if ( pButton )
539 {
540 sal_uInt16 nPropType = GetPropertyId( PropertyName );
541 switch ( nPropType )
542 {
543 case BASEPROPERTY_FOCUSONCLICK:
544 aProp <<= (sal_Bool)( ( pButton->GetStyle() & WB_NOPOINTERFOCUS ) == 0 );
545 break;
546
547 case BASEPROPERTY_TOGGLE:
548 aProp <<= (sal_Bool)( ( pButton->GetStyle() & WB_TOGGLE ) != 0 );
549 break;
550
551 case BASEPROPERTY_DEFAULTBUTTON:
552 {
553 aProp <<= (sal_Bool) ( ( pButton->GetStyle() & WB_DEFBUTTON ) ? sal_True : sal_False );
554 }
555 break;
556 case BASEPROPERTY_STATE:
557 {
558 if ( GetWindow()->GetType() == WINDOW_PUSHBUTTON )
559 {
560 aProp <<= (sal_Int16)((PushButton*)pButton)->GetState();
561 }
562 }
563 break;
564 default:
565 {
566 aProp <<= VCLXGraphicControl::getProperty( PropertyName );
567 }
568 }
569 }
570 return aProp;
571 }
572
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)573 void VCLXButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
574 {
575 switch ( rVclWindowEvent.GetId() )
576 {
577 case VCLEVENT_BUTTON_CLICK:
578 {
579 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
580 // since we call listeners below, there is a potential that we will be destroyed
581 // during the listener call. To prevent the resulting crashs, we keep us
582 // alive as long as we're here
583 // #20178# - 2003-10-01 - fs@openoffice.org
584
585 if ( maActionListeners.getLength() )
586 {
587 ::com::sun::star::awt::ActionEvent aEvent;
588 aEvent.Source = (::cppu::OWeakObject*)this;
589 aEvent.ActionCommand = maActionCommand;
590
591 Callback aCallback = ::boost::bind(
592 &ActionListenerMultiplexer::actionPerformed,
593 &maActionListeners,
594 aEvent
595 );
596 ImplExecuteAsyncWithoutSolarLock( aCallback );
597 }
598 }
599 break;
600
601 case VCLEVENT_PUSHBUTTON_TOGGLE:
602 {
603 PushButton& rButton = dynamic_cast< PushButton& >( *rVclWindowEvent.GetWindow() );
604
605 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
606 if ( maItemListeners.getLength() )
607 {
608 ::com::sun::star::awt::ItemEvent aEvent;
609 aEvent.Source = (::cppu::OWeakObject*)this;
610 aEvent.Selected = ( rButton.GetState() == STATE_CHECK ) ? 1 : 0;
611 maItemListeners.itemStateChanged( aEvent );
612 }
613 }
614 break;
615
616 default:
617 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent );
618 break;
619 }
620 }
621
622 // ----------------------------------------------------
623 // class VCLXImageControl
624 // ----------------------------------------------------
625
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)626 void VCLXImageControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
627 {
628 PushPropertyIds( rIds,
629 BASEPROPERTY_BACKGROUNDCOLOR,
630 BASEPROPERTY_BORDER,
631 BASEPROPERTY_BORDERCOLOR,
632 BASEPROPERTY_DEFAULTCONTROL,
633 BASEPROPERTY_ENABLED,
634 BASEPROPERTY_ENABLEVISIBLE,
635 BASEPROPERTY_GRAPHIC,
636 BASEPROPERTY_HELPTEXT,
637 BASEPROPERTY_HELPURL,
638 BASEPROPERTY_IMAGEURL,
639 BASEPROPERTY_PRINTABLE,
640 BASEPROPERTY_SCALEIMAGE,
641 BASEPROPERTY_IMAGE_SCALE_MODE,
642 BASEPROPERTY_TABSTOP,
643 BASEPROPERTY_WRITING_MODE,
644 BASEPROPERTY_CONTEXT_WRITING_MODE,
645 0);
646 VCLXGraphicControl::ImplGetPropertyIds( rIds );
647 }
648
VCLXImageControl()649 VCLXImageControl::VCLXImageControl()
650 {
651 }
652
~VCLXImageControl()653 VCLXImageControl::~VCLXImageControl()
654 {
655 }
656
ImplSetNewImage()657 void VCLXImageControl::ImplSetNewImage()
658 {
659 OSL_PRECOND( GetWindow(), "VCLXImageControl::ImplSetNewImage: window is required to be not-NULL!" );
660 ImageControl* pControl = static_cast< ImageControl* >( GetWindow() );
661 pControl->SetImage( GetImage() );
662 }
663
getMinimumSize()664 ::com::sun::star::awt::Size VCLXImageControl::getMinimumSize( )
665 {
666 ::vos::OGuard aGuard( GetMutex() );
667
668 Size aSz = GetImage().GetSizePixel();
669 aSz = ImplCalcWindowSize( aSz );
670
671 return AWTSize(aSz);
672 }
673
getPreferredSize()674 ::com::sun::star::awt::Size VCLXImageControl::getPreferredSize( )
675 {
676 return getMinimumSize();
677 }
678
calcAdjustedSize(const::com::sun::star::awt::Size & rNewSize)679 ::com::sun::star::awt::Size VCLXImageControl::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize )
680 {
681 ::vos::OGuard aGuard( GetMutex() );
682
683 ::com::sun::star::awt::Size aSz = rNewSize;
684 ::com::sun::star::awt::Size aMinSz = getMinimumSize();
685 if ( aSz.Width < aMinSz.Width )
686 aSz.Width = aMinSz.Width;
687 if ( aSz.Height < aMinSz.Height )
688 aSz.Height = aMinSz.Height;
689 return aSz;
690 }
691
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)692 void VCLXImageControl::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value)
693 {
694 ::vos::OGuard aGuard( GetMutex() );
695
696 ImageControl* pImageControl = (ImageControl*)GetWindow();
697
698 sal_uInt16 nPropType = GetPropertyId( PropertyName );
699 switch ( nPropType )
700 {
701 case BASEPROPERTY_IMAGE_SCALE_MODE:
702 {
703 sal_Int16 nScaleMode( ImageScaleMode::ANISOTROPIC );
704 if ( pImageControl && ( Value >>= nScaleMode ) )
705 {
706 pImageControl->SetScaleMode( nScaleMode );
707 }
708 }
709 break;
710
711 case BASEPROPERTY_SCALEIMAGE:
712 {
713 // this is for compatibility only, nowadays, the ImageScaleMode property should be used
714 sal_Bool bScaleImage = sal_False;
715 if ( pImageControl && ( Value >>= bScaleImage ) )
716 {
717 pImageControl->SetScaleMode( bScaleImage ? ImageScaleMode::ANISOTROPIC : ImageScaleMode::NONE );
718 }
719 }
720 break;
721
722 default:
723 VCLXGraphicControl::setProperty( PropertyName, Value );
724 break;
725 }
726 }
727
getProperty(const::rtl::OUString & PropertyName)728 ::com::sun::star::uno::Any VCLXImageControl::getProperty( const ::rtl::OUString& PropertyName )
729 {
730 ::vos::OGuard aGuard( GetMutex() );
731
732 ::com::sun::star::uno::Any aProp;
733 ImageControl* pImageControl = (ImageControl*)GetWindow();
734 sal_uInt16 nPropType = GetPropertyId( PropertyName );
735
736 switch ( nPropType )
737 {
738 case BASEPROPERTY_IMAGE_SCALE_MODE:
739 aProp <<= ( pImageControl ? pImageControl->GetScaleMode() : ImageScaleMode::ANISOTROPIC );
740 break;
741
742 case BASEPROPERTY_SCALEIMAGE:
743 aProp <<= ( pImageControl && pImageControl->GetScaleMode() != ImageScaleMode::NONE ) ? sal_True : sal_False;
744 break;
745
746 default:
747 aProp = VCLXGraphicControl::getProperty( PropertyName );
748 break;
749 }
750 return aProp;
751 }
752
753 // ----------------------------------------------------
754 // class VCLXCheckBox
755 // ----------------------------------------------------
756
757
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)758 void VCLXCheckBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
759 {
760 PushPropertyIds( rIds,
761 BASEPROPERTY_DEFAULTCONTROL,
762 BASEPROPERTY_ENABLED,
763 BASEPROPERTY_ENABLEVISIBLE,
764 BASEPROPERTY_FONTDESCRIPTOR,
765 BASEPROPERTY_GRAPHIC,
766 BASEPROPERTY_HELPTEXT,
767 BASEPROPERTY_HELPURL,
768 BASEPROPERTY_IMAGEPOSITION,
769 BASEPROPERTY_IMAGEURL,
770 BASEPROPERTY_LABEL,
771 BASEPROPERTY_PRINTABLE,
772 BASEPROPERTY_STATE,
773 BASEPROPERTY_TABSTOP,
774 BASEPROPERTY_TRISTATE,
775 BASEPROPERTY_VISUALEFFECT,
776 BASEPROPERTY_MULTILINE,
777 BASEPROPERTY_BACKGROUNDCOLOR,
778 BASEPROPERTY_ALIGN,
779 BASEPROPERTY_VERTICALALIGN,
780 BASEPROPERTY_WRITING_MODE,
781 BASEPROPERTY_CONTEXT_WRITING_MODE,
782 BASEPROPERTY_REFERENCE_DEVICE,
783 0);
784 VCLXGraphicControl::ImplGetPropertyIds( rIds );
785 }
786
VCLXCheckBox()787 VCLXCheckBox::VCLXCheckBox() : maActionListeners( *this ), maItemListeners( *this )
788 {
789 }
790
791 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)792 ::com::sun::star::uno::Any VCLXCheckBox::queryInterface( const ::com::sun::star::uno::Type & rType )
793 {
794 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
795 SAL_STATIC_CAST( ::com::sun::star::awt::XButton*, this ),
796 SAL_STATIC_CAST( ::com::sun::star::awt::XCheckBox*, this ) );
797 return (aRet.hasValue() ? aRet : VCLXGraphicControl::queryInterface( rType ));
798 }
799
800 // ::com::sun::star::lang::XTypeProvider
801 IMPL_XTYPEPROVIDER_START( VCLXCheckBox )
802 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XButton>* ) NULL ),
803 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XCheckBox>* ) NULL ),
804 VCLXGraphicControl::getTypes()
805 IMPL_XTYPEPROVIDER_END
806
807 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXCheckBox::CreateAccessibleContext()
808 {
809 return getAccessibleFactory().createAccessibleContext( this );
810 }
811
dispose()812 void VCLXCheckBox::dispose()
813 {
814 ::vos::OGuard aGuard( GetMutex() );
815
816 ::com::sun::star::lang::EventObject aObj;
817 aObj.Source = (::cppu::OWeakObject*)this;
818 maItemListeners.disposeAndClear( aObj );
819 VCLXGraphicControl::dispose();
820 }
821
addItemListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XItemListener> & l)822 void VCLXCheckBox::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l )
823 {
824 ::vos::OGuard aGuard( GetMutex() );
825 maItemListeners.addInterface( l );
826 }
827
removeItemListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XItemListener> & l)828 void VCLXCheckBox::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l )
829 {
830 ::vos::OGuard aGuard( GetMutex() );
831 maItemListeners.removeInterface( l );
832 }
833
addActionListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XActionListener> & l)834 void VCLXCheckBox::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )
835 {
836 ::vos::OGuard aGuard( GetMutex() );
837 maActionListeners.addInterface( l );
838 }
839
removeActionListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XActionListener> & l)840 void VCLXCheckBox::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )
841 {
842 ::vos::OGuard aGuard( GetMutex() );
843 maActionListeners.removeInterface( l );
844 }
845
setActionCommand(const::rtl::OUString & rCommand)846 void VCLXCheckBox::setActionCommand( const ::rtl::OUString& rCommand )
847 {
848 ::vos::OGuard aGuard( GetMutex() );
849 maActionCommand = rCommand;
850 }
851
setLabel(const::rtl::OUString & rLabel)852 void VCLXCheckBox::setLabel( const ::rtl::OUString& rLabel )
853 {
854 ::vos::OGuard aGuard( GetMutex() );
855
856 Window* pWindow = GetWindow();
857 if ( pWindow )
858 pWindow->SetText( rLabel );
859 }
860
setState(short n)861 void VCLXCheckBox::setState( short n )
862 {
863 ::vos::OGuard aGuard( GetMutex() );
864
865 CheckBox* pCheckBox = (CheckBox*)GetWindow();
866 if ( pCheckBox)
867 {
868 TriState eState;
869 switch ( n )
870 {
871 case 0: eState = STATE_NOCHECK; break;
872 case 1: eState = STATE_CHECK; break;
873 case 2: eState = STATE_DONTKNOW; break;
874 default: eState = STATE_NOCHECK;
875 }
876 pCheckBox->SetState( eState );
877
878 // #105198# call C++ click listeners (needed for accessibility)
879 // pCheckBox->GetClickHdl().Call( pCheckBox );
880
881 // #107218# Call same virtual methods and listeners like VCL would do after user interaction
882 SetSynthesizingVCLEvent( sal_True );
883 pCheckBox->Toggle();
884 pCheckBox->Click();
885 SetSynthesizingVCLEvent( sal_False );
886 }
887 }
888
getState()889 short VCLXCheckBox::getState()
890 {
891 ::vos::OGuard aGuard( GetMutex() );
892
893 short nState = -1;
894 CheckBox* pCheckBox = (CheckBox*)GetWindow();
895 if ( pCheckBox )
896 {
897 switch ( pCheckBox->GetState() )
898 {
899 case STATE_NOCHECK: nState = 0; break;
900 case STATE_CHECK: nState = 1; break;
901 case STATE_DONTKNOW: nState = 2; break;
902 default: DBG_ERROR( "VCLXCheckBox::getState(): unknown TriState!" );
903 }
904 }
905
906 return nState;
907 }
908
enableTriState(sal_Bool b)909 void VCLXCheckBox::enableTriState( sal_Bool b )
910 {
911 ::vos::OGuard aGuard( GetMutex() );
912
913 CheckBox* pCheckBox = (CheckBox*)GetWindow();
914 if ( pCheckBox)
915 pCheckBox->EnableTriState( b );
916 }
917
getMinimumSize()918 ::com::sun::star::awt::Size VCLXCheckBox::getMinimumSize( )
919 {
920 ::vos::OGuard aGuard( GetMutex() );
921
922 Size aSz;
923 CheckBox* pCheckBox = (CheckBox*) GetWindow();
924 if ( pCheckBox )
925 aSz = pCheckBox->CalcMinimumSize();
926 return AWTSize(aSz);
927 }
928
getPreferredSize()929 ::com::sun::star::awt::Size VCLXCheckBox::getPreferredSize( )
930 {
931 return getMinimumSize();
932 }
933
calcAdjustedSize(const::com::sun::star::awt::Size & rNewSize)934 ::com::sun::star::awt::Size VCLXCheckBox::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize )
935 {
936 ::vos::OGuard aGuard( GetMutex() );
937
938 Size aSz = VCLSize(rNewSize);
939 CheckBox* pCheckBox = (CheckBox*) GetWindow();
940 if ( pCheckBox )
941 {
942 Size aMinSz = pCheckBox->CalcMinimumSize();
943 if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
944 aSz.Height() = aMinSz.Height();
945 else
946 aSz = aMinSz;
947 }
948 return AWTSize(aSz);
949 }
950
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)951 void VCLXCheckBox::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value)
952 {
953 ::vos::OGuard aGuard( GetMutex() );
954
955 CheckBox* pCheckBox = (CheckBox*)GetWindow();
956 if ( pCheckBox )
957 {
958 sal_uInt16 nPropType = GetPropertyId( PropertyName );
959 switch ( nPropType )
960 {
961 case BASEPROPERTY_VISUALEFFECT:
962 ::toolkit::setVisualEffect( Value, pCheckBox );
963 break;
964
965 case BASEPROPERTY_TRISTATE:
966 {
967 sal_Bool b = sal_Bool();
968 if ( Value >>= b )
969 pCheckBox->EnableTriState( b );
970 }
971 break;
972 case BASEPROPERTY_STATE:
973 {
974 sal_Int16 n = sal_Int16();
975 if ( Value >>= n )
976 setState( n );
977 }
978 break;
979 default:
980 {
981 VCLXGraphicControl::setProperty( PropertyName, Value );
982 }
983 }
984 }
985 }
986
getProperty(const::rtl::OUString & PropertyName)987 ::com::sun::star::uno::Any VCLXCheckBox::getProperty( const ::rtl::OUString& PropertyName )
988 {
989 ::vos::OGuard aGuard( GetMutex() );
990
991 ::com::sun::star::uno::Any aProp;
992 CheckBox* pCheckBox = (CheckBox*)GetWindow();
993 if ( pCheckBox )
994 {
995 sal_uInt16 nPropType = GetPropertyId( PropertyName );
996 switch ( nPropType )
997 {
998 case BASEPROPERTY_VISUALEFFECT:
999 aProp = ::toolkit::getVisualEffect( pCheckBox );
1000 break;
1001 case BASEPROPERTY_TRISTATE:
1002 aProp <<= (sal_Bool)pCheckBox->IsTriStateEnabled();
1003 break;
1004 case BASEPROPERTY_STATE:
1005 aProp <<= (sal_Int16)pCheckBox->GetState();
1006 break;
1007 default:
1008 {
1009 aProp <<= VCLXGraphicControl::getProperty( PropertyName );
1010 }
1011 }
1012 }
1013 return aProp;
1014 }
1015
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)1016 void VCLXCheckBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1017 {
1018 switch ( rVclWindowEvent.GetId() )
1019 {
1020 case VCLEVENT_CHECKBOX_TOGGLE:
1021 {
1022 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
1023 // since we call listeners below, there is a potential that we will be destroyed
1024 // in during the listener call. To prevent the resulting crashs, we keep us
1025 // alive as long as we're here
1026 // #20178# - 2003-10-01 - fs@openoffice.org
1027
1028 CheckBox* pCheckBox = (CheckBox*)GetWindow();
1029 if ( pCheckBox )
1030 {
1031 if ( maItemListeners.getLength() )
1032 {
1033 ::com::sun::star::awt::ItemEvent aEvent;
1034 aEvent.Source = (::cppu::OWeakObject*)this;
1035 aEvent.Highlighted = sal_False;
1036 aEvent.Selected = pCheckBox->GetState();
1037 maItemListeners.itemStateChanged( aEvent );
1038 }
1039 if ( !IsSynthesizingVCLEvent() && maActionListeners.getLength() )
1040 {
1041 ::com::sun::star::awt::ActionEvent aEvent;
1042 aEvent.Source = (::cppu::OWeakObject*)this;
1043 aEvent.ActionCommand = maActionCommand;
1044 maActionListeners.actionPerformed( aEvent );
1045 }
1046 }
1047 }
1048 break;
1049
1050 default:
1051 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent );
1052 break;
1053 }
1054 }
1055
1056 // ----------------------------------------------------
1057 // class VCLXRadioButton
1058 // ----------------------------------------------------
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)1059 void VCLXRadioButton::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1060 {
1061 PushPropertyIds( rIds,
1062 BASEPROPERTY_DEFAULTCONTROL,
1063 BASEPROPERTY_ENABLED,
1064 BASEPROPERTY_ENABLEVISIBLE,
1065 BASEPROPERTY_FONTDESCRIPTOR,
1066 BASEPROPERTY_GRAPHIC,
1067 BASEPROPERTY_HELPTEXT,
1068 BASEPROPERTY_HELPURL,
1069 BASEPROPERTY_IMAGEPOSITION,
1070 BASEPROPERTY_IMAGEURL,
1071 BASEPROPERTY_LABEL,
1072 BASEPROPERTY_PRINTABLE,
1073 BASEPROPERTY_STATE,
1074 BASEPROPERTY_TABSTOP,
1075 BASEPROPERTY_VISUALEFFECT,
1076 BASEPROPERTY_MULTILINE,
1077 BASEPROPERTY_BACKGROUNDCOLOR,
1078 BASEPROPERTY_ALIGN,
1079 BASEPROPERTY_VERTICALALIGN,
1080 BASEPROPERTY_WRITING_MODE,
1081 BASEPROPERTY_CONTEXT_WRITING_MODE,
1082 BASEPROPERTY_REFERENCE_DEVICE,
1083 0);
1084 VCLXGraphicControl::ImplGetPropertyIds( rIds );
1085 }
1086
1087
VCLXRadioButton()1088 VCLXRadioButton::VCLXRadioButton() : maItemListeners( *this ), maActionListeners( *this )
1089 {
1090 }
1091
1092 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)1093 ::com::sun::star::uno::Any VCLXRadioButton::queryInterface( const ::com::sun::star::uno::Type & rType )
1094 {
1095 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
1096 SAL_STATIC_CAST( ::com::sun::star::awt::XRadioButton*, this ),
1097 SAL_STATIC_CAST( ::com::sun::star::awt::XButton*, this ) );
1098 return (aRet.hasValue() ? aRet : VCLXGraphicControl::queryInterface( rType ));
1099 }
1100
1101 // ::com::sun::star::lang::XTypeProvider
1102 IMPL_XTYPEPROVIDER_START( VCLXRadioButton )
1103 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRadioButton>* ) NULL ),
1104 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XButton>* ) NULL ),
1105 VCLXGraphicControl::getTypes()
1106 IMPL_XTYPEPROVIDER_END
1107
1108 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXRadioButton::CreateAccessibleContext()
1109 {
1110 return getAccessibleFactory().createAccessibleContext( this );
1111 }
1112
dispose()1113 void VCLXRadioButton::dispose()
1114 {
1115 ::vos::OGuard aGuard( GetMutex() );
1116
1117 ::com::sun::star::lang::EventObject aObj;
1118 aObj.Source = (::cppu::OWeakObject*)this;
1119 maItemListeners.disposeAndClear( aObj );
1120 VCLXGraphicControl::dispose();
1121 }
1122
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)1123 void VCLXRadioButton::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value)
1124 {
1125 ::vos::OGuard aGuard( GetMutex() );
1126
1127 RadioButton* pButton = (RadioButton*)GetWindow();
1128 if ( pButton )
1129 {
1130 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1131 switch ( nPropType )
1132 {
1133 case BASEPROPERTY_VISUALEFFECT:
1134 ::toolkit::setVisualEffect( Value, pButton );
1135 break;
1136
1137 case BASEPROPERTY_STATE:
1138 {
1139 sal_Int16 n = sal_Int16();
1140 if ( Value >>= n )
1141 {
1142 sal_Bool b = n ? sal_True : sal_False;
1143 if ( pButton->IsRadioCheckEnabled() )
1144 pButton->Check( b );
1145 else
1146 pButton->SetState( b );
1147 }
1148 }
1149 break;
1150 case BASEPROPERTY_AUTOTOGGLE:
1151 {
1152 sal_Bool b = sal_Bool();
1153 if ( Value >>= b )
1154 pButton->EnableRadioCheck( b );
1155 }
1156 break;
1157 default:
1158 {
1159 VCLXGraphicControl::setProperty( PropertyName, Value );
1160 }
1161 }
1162 }
1163 }
1164
getProperty(const::rtl::OUString & PropertyName)1165 ::com::sun::star::uno::Any VCLXRadioButton::getProperty( const ::rtl::OUString& PropertyName )
1166 {
1167 ::vos::OGuard aGuard( GetMutex() );
1168
1169 ::com::sun::star::uno::Any aProp;
1170 RadioButton* pButton = (RadioButton*)GetWindow();
1171 if ( pButton )
1172 {
1173 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1174 switch ( nPropType )
1175 {
1176 case BASEPROPERTY_VISUALEFFECT:
1177 aProp = ::toolkit::getVisualEffect( pButton );
1178 break;
1179 case BASEPROPERTY_STATE:
1180 aProp <<= (sal_Int16) ( pButton->IsChecked() ? 1 : 0 );
1181 break;
1182 case BASEPROPERTY_AUTOTOGGLE:
1183 aProp <<= (sal_Bool) pButton->IsRadioCheckEnabled();
1184 break;
1185 default:
1186 {
1187 aProp <<= VCLXGraphicControl::getProperty( PropertyName );
1188 }
1189 }
1190 }
1191 return aProp;
1192 }
1193
addItemListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XItemListener> & l)1194 void VCLXRadioButton::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l )
1195 {
1196 ::vos::OGuard aGuard( GetMutex() );
1197 maItemListeners.addInterface( l );
1198 }
1199
removeItemListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XItemListener> & l)1200 void VCLXRadioButton::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l )
1201 {
1202 ::vos::OGuard aGuard( GetMutex() );
1203 maItemListeners.removeInterface( l );
1204 }
1205
addActionListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XActionListener> & l)1206 void VCLXRadioButton::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )
1207 {
1208 ::vos::OGuard aGuard( GetMutex() );
1209 maActionListeners.addInterface( l );
1210 }
1211
removeActionListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XActionListener> & l)1212 void VCLXRadioButton::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )
1213 {
1214 ::vos::OGuard aGuard( GetMutex() );
1215 maActionListeners.removeInterface( l );
1216 }
1217
setLabel(const::rtl::OUString & rLabel)1218 void VCLXRadioButton::setLabel( const ::rtl::OUString& rLabel )
1219 {
1220 ::vos::OGuard aGuard( GetMutex() );
1221
1222 Window* pWindow = GetWindow();
1223 if ( pWindow )
1224 pWindow->SetText( rLabel );
1225 }
1226
setActionCommand(const::rtl::OUString & rCommand)1227 void VCLXRadioButton::setActionCommand( const ::rtl::OUString& rCommand )
1228 {
1229 ::vos::OGuard aGuard( GetMutex() );
1230 maActionCommand = rCommand;
1231 }
1232
setState(sal_Bool b)1233 void VCLXRadioButton::setState( sal_Bool b )
1234 {
1235 ::vos::OGuard aGuard( GetMutex() );
1236
1237 RadioButton* pRadioButton = (RadioButton*)GetWindow();
1238 if ( pRadioButton)
1239 {
1240 pRadioButton->Check( b );
1241 // #102717# item listeners are called, but not C++ click listeners in StarOffice code => call click hdl
1242 // But this is needed in old code because Accessibility API uses it.
1243 // pRadioButton->GetClickHdl().Call( pRadioButton );
1244
1245 // #107218# Call same virtual methods and listeners like VCL would do after user interaction
1246 SetSynthesizingVCLEvent( sal_True );
1247 pRadioButton->Click();
1248 SetSynthesizingVCLEvent( sal_False );
1249 }
1250 }
1251
getState()1252 sal_Bool VCLXRadioButton::getState()
1253 {
1254 ::vos::OGuard aGuard( GetMutex() );
1255
1256 RadioButton* pRadioButton = (RadioButton*)GetWindow();
1257 return pRadioButton ? pRadioButton->IsChecked() : sal_False;
1258 }
1259
getMinimumSize()1260 ::com::sun::star::awt::Size VCLXRadioButton::getMinimumSize( )
1261 {
1262 ::vos::OGuard aGuard( GetMutex() );
1263
1264 Size aSz;
1265 RadioButton* pRadioButton = (RadioButton*) GetWindow();
1266 if ( pRadioButton )
1267 aSz = pRadioButton->CalcMinimumSize();
1268 return AWTSize(aSz);
1269 }
1270
getPreferredSize()1271 ::com::sun::star::awt::Size VCLXRadioButton::getPreferredSize( )
1272 {
1273 return getMinimumSize();
1274 }
1275
calcAdjustedSize(const::com::sun::star::awt::Size & rNewSize)1276 ::com::sun::star::awt::Size VCLXRadioButton::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize )
1277 {
1278 ::vos::OGuard aGuard( GetMutex() );
1279
1280 Size aSz = VCLSize(rNewSize);
1281 RadioButton* pRadioButton = (RadioButton*) GetWindow();
1282 if ( pRadioButton )
1283 {
1284 Size aMinSz = pRadioButton->CalcMinimumSize();
1285 if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
1286 aSz.Height() = aMinSz.Height();
1287 else
1288 aSz = aMinSz;
1289 }
1290 return AWTSize(aSz);
1291 }
1292
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)1293 void VCLXRadioButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1294 {
1295 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
1296 // since we call listeners below, there is a potential that we will be destroyed
1297 // in during the listener call. To prevent the resulting crashs, we keep us
1298 // alive as long as we're here
1299 // #20178# - 2003-10-01 - fs@openoffice.org
1300
1301 switch ( rVclWindowEvent.GetId() )
1302 {
1303 case VCLEVENT_BUTTON_CLICK:
1304 if ( !IsSynthesizingVCLEvent() && maActionListeners.getLength() )
1305 {
1306 ::com::sun::star::awt::ActionEvent aEvent;
1307 aEvent.Source = (::cppu::OWeakObject*)this;
1308 aEvent.ActionCommand = maActionCommand;
1309 maActionListeners.actionPerformed( aEvent );
1310 }
1311 ImplClickedOrToggled( sal_False );
1312 break;
1313
1314 case VCLEVENT_RADIOBUTTON_TOGGLE:
1315 ImplClickedOrToggled( sal_True );
1316 break;
1317
1318 default:
1319 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent );
1320 break;
1321 }
1322 }
1323
ImplClickedOrToggled(sal_Bool bToggled)1324 void VCLXRadioButton::ImplClickedOrToggled( sal_Bool bToggled )
1325 {
1326 // In the formulars, RadioChecked is not enabled, call itemStateChanged only for click
1327 // In the dialog editor, RadioChecked is enabled, call itemStateChanged only for bToggled
1328 RadioButton* pRadioButton = (RadioButton*)GetWindow();
1329 if ( pRadioButton && ( pRadioButton->IsRadioCheckEnabled() == bToggled ) && ( bToggled || pRadioButton->IsStateChanged() ) && maItemListeners.getLength() )
1330 {
1331 ::com::sun::star::awt::ItemEvent aEvent;
1332 aEvent.Source = (::cppu::OWeakObject*)this;
1333 aEvent.Highlighted = sal_False;
1334 aEvent.Selected = pRadioButton->IsChecked();
1335 maItemListeners.itemStateChanged( aEvent );
1336 }
1337 }
1338
getFirstActionListener()1339 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > VCLXRadioButton::getFirstActionListener ()
1340 {
1341 if (!maItemListeners.getLength ())
1342 return ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > ();
1343 return maActionListeners.getElements()[0];
1344 }
1345
1346 // ----------------------------------------------------
1347 // class VCLXSpinField
1348 // ----------------------------------------------------
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)1349 void VCLXSpinField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1350 {
1351 PushPropertyIds( rIds,
1352 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
1353 0 );
1354 VCLXEdit::ImplGetPropertyIds( rIds );
1355 }
1356
VCLXSpinField()1357 VCLXSpinField::VCLXSpinField() : maSpinListeners( *this )
1358 {
1359 }
1360
1361 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)1362 ::com::sun::star::uno::Any VCLXSpinField::queryInterface( const ::com::sun::star::uno::Type & rType )
1363 {
1364 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
1365 SAL_STATIC_CAST( ::com::sun::star::awt::XSpinField*, this ) );
1366 return (aRet.hasValue() ? aRet : VCLXEdit::queryInterface( rType ));
1367 }
1368
1369 // ::com::sun::star::lang::XTypeProvider
1370 IMPL_XTYPEPROVIDER_START( VCLXSpinField )
1371 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinField>* ) NULL ),
1372 VCLXEdit::getTypes()
1373 IMPL_XTYPEPROVIDER_END
1374
1375 void VCLXSpinField::addSpinListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinListener > & l )
1376 {
1377 ::vos::OGuard aGuard( GetMutex() );
1378 maSpinListeners.addInterface( l );
1379 }
1380
removeSpinListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XSpinListener> & l)1381 void VCLXSpinField::removeSpinListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinListener > & l )
1382 {
1383 ::vos::OGuard aGuard( GetMutex() );
1384 maSpinListeners.removeInterface( l );
1385 }
1386
up()1387 void VCLXSpinField::up()
1388 {
1389 ::vos::OGuard aGuard( GetMutex() );
1390
1391 SpinField* pSpinField = (SpinField*) GetWindow();
1392 if ( pSpinField )
1393 pSpinField->Up();
1394 }
1395
down()1396 void VCLXSpinField::down()
1397 {
1398 ::vos::OGuard aGuard( GetMutex() );
1399
1400 SpinField* pSpinField = (SpinField*) GetWindow();
1401 if ( pSpinField )
1402 pSpinField->Down();
1403 }
1404
first()1405 void VCLXSpinField::first()
1406 {
1407 ::vos::OGuard aGuard( GetMutex() );
1408
1409 SpinField* pSpinField = (SpinField*) GetWindow();
1410 if ( pSpinField )
1411 pSpinField->First();
1412 }
1413
last()1414 void VCLXSpinField::last()
1415 {
1416 ::vos::OGuard aGuard( GetMutex() );
1417
1418 SpinField* pSpinField = (SpinField*) GetWindow();
1419 if ( pSpinField )
1420 pSpinField->Last();
1421 }
1422
enableRepeat(sal_Bool bRepeat)1423 void VCLXSpinField::enableRepeat( sal_Bool bRepeat )
1424 {
1425 ::vos::OGuard aGuard( GetMutex() );
1426
1427 Window* pWindow = GetWindow();
1428 if ( pWindow )
1429 {
1430 WinBits nStyle = pWindow->GetStyle();
1431 if ( bRepeat )
1432 nStyle |= WB_REPEAT;
1433 else
1434 nStyle &= ~WB_REPEAT;
1435 pWindow->SetStyle( nStyle );
1436 }
1437 }
1438
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)1439 void VCLXSpinField::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1440 {
1441 switch ( rVclWindowEvent.GetId() )
1442 {
1443 case VCLEVENT_SPINFIELD_UP:
1444 case VCLEVENT_SPINFIELD_DOWN:
1445 case VCLEVENT_SPINFIELD_FIRST:
1446 case VCLEVENT_SPINFIELD_LAST:
1447 {
1448 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
1449 // since we call listeners below, there is a potential that we will be destroyed
1450 // in during the listener call. To prevent the resulting crashs, we keep us
1451 // alive as long as we're here
1452 // #20178# - 2003-10-01 - fs@openoffice.org
1453
1454 if ( maSpinListeners.getLength() )
1455 {
1456 ::com::sun::star::awt::SpinEvent aEvent;
1457 aEvent.Source = (::cppu::OWeakObject*)this;
1458 switch ( rVclWindowEvent.GetId() )
1459 {
1460 case VCLEVENT_SPINFIELD_UP: maSpinListeners.up( aEvent );
1461 break;
1462 case VCLEVENT_SPINFIELD_DOWN: maSpinListeners.down( aEvent );
1463 break;
1464 case VCLEVENT_SPINFIELD_FIRST: maSpinListeners.first( aEvent );
1465 break;
1466 case VCLEVENT_SPINFIELD_LAST: maSpinListeners.last( aEvent );
1467 break;
1468 }
1469
1470 }
1471 }
1472 break;
1473
1474 default:
1475 VCLXEdit::ProcessWindowEvent( rVclWindowEvent );
1476 break;
1477 }
1478 }
1479
1480
1481 // ----------------------------------------------------
1482 // class VCLXListBox
1483 // ----------------------------------------------------
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)1484 void VCLXListBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1485 {
1486 PushPropertyIds( rIds,
1487 BASEPROPERTY_BACKGROUNDCOLOR,
1488 BASEPROPERTY_BORDER,
1489 BASEPROPERTY_BORDERCOLOR,
1490 BASEPROPERTY_DEFAULTCONTROL,
1491 BASEPROPERTY_DROPDOWN,
1492 BASEPROPERTY_ENABLED,
1493 BASEPROPERTY_ENABLEVISIBLE,
1494 BASEPROPERTY_FONTDESCRIPTOR,
1495 BASEPROPERTY_HELPTEXT,
1496 BASEPROPERTY_HELPURL,
1497 BASEPROPERTY_LINECOUNT,
1498 BASEPROPERTY_MULTISELECTION,
1499 BASEPROPERTY_MULTISELECTION_SIMPLEMODE,
1500 BASEPROPERTY_ITEM_SEPARATOR_POS,
1501 BASEPROPERTY_PRINTABLE,
1502 BASEPROPERTY_SELECTEDITEMS,
1503 BASEPROPERTY_STRINGITEMLIST,
1504 BASEPROPERTY_TABSTOP,
1505 BASEPROPERTY_READONLY,
1506 BASEPROPERTY_ALIGN,
1507 BASEPROPERTY_WRITING_MODE,
1508 BASEPROPERTY_CONTEXT_WRITING_MODE,
1509 BASEPROPERTY_REFERENCE_DEVICE,
1510 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
1511 0);
1512 VCLXWindow::ImplGetPropertyIds( rIds );
1513 }
1514
1515
VCLXListBox()1516 VCLXListBox::VCLXListBox()
1517 : maActionListeners( *this ),
1518 maItemListeners( *this )
1519 {
1520 }
1521
dispose()1522 void VCLXListBox::dispose()
1523 {
1524 ::vos::OGuard aGuard( GetMutex() );
1525
1526 ::com::sun::star::lang::EventObject aObj;
1527 aObj.Source = (::cppu::OWeakObject*)this;
1528 maItemListeners.disposeAndClear( aObj );
1529 maActionListeners.disposeAndClear( aObj );
1530 VCLXWindow::dispose();
1531 }
1532
addItemListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XItemListener> & l)1533 void VCLXListBox::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l )
1534 {
1535 ::vos::OGuard aGuard( GetMutex() );
1536 maItemListeners.addInterface( l );
1537 }
1538
removeItemListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XItemListener> & l)1539 void VCLXListBox::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l )
1540 {
1541 ::vos::OGuard aGuard( GetMutex() );
1542 maItemListeners.removeInterface( l );
1543 }
1544
addActionListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XActionListener> & l)1545 void VCLXListBox::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )
1546 {
1547 ::vos::OGuard aGuard( GetMutex() );
1548 maActionListeners.addInterface( l );
1549 }
1550
removeActionListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XActionListener> & l)1551 void VCLXListBox::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )
1552 {
1553 ::vos::OGuard aGuard( GetMutex() );
1554 maActionListeners.removeInterface( l );
1555 }
1556
addItem(const::rtl::OUString & aItem,sal_Int16 nPos)1557 void VCLXListBox::addItem( const ::rtl::OUString& aItem, sal_Int16 nPos )
1558 {
1559 ::vos::OGuard aGuard( GetMutex() );
1560
1561 ListBox* pBox = (ListBox*) GetWindow();
1562 if ( pBox )
1563 pBox->InsertEntry( aItem, nPos );
1564 }
1565
addItems(const::com::sun::star::uno::Sequence<::rtl::OUString> & aItems,sal_Int16 nPos)1566 void VCLXListBox::addItems( const ::com::sun::star::uno::Sequence< ::rtl::OUString>& aItems, sal_Int16 nPos )
1567 {
1568 ::vos::OGuard aGuard( GetMutex() );
1569
1570 ListBox* pBox = (ListBox*) GetWindow();
1571 if ( pBox )
1572 {
1573 sal_uInt16 nP = nPos;
1574 const ::rtl::OUString* pItems = aItems.getConstArray();
1575 const ::rtl::OUString* pItemsEnd = aItems.getConstArray() + aItems.getLength();
1576 while ( pItems != pItemsEnd )
1577 {
1578 if ( (sal_uInt16)nP == 0xFFFF )
1579 {
1580 OSL_ENSURE( false, "VCLXListBox::addItems: too many entries!" );
1581 // skip remaining entries, list cannot hold them, anyway
1582 break;
1583 }
1584
1585 pBox->InsertEntry( *pItems++, nP++ );
1586 }
1587 }
1588 }
1589
removeItems(sal_Int16 nPos,sal_Int16 nCount)1590 void VCLXListBox::removeItems( sal_Int16 nPos, sal_Int16 nCount )
1591 {
1592 ::vos::OGuard aGuard( GetMutex() );
1593
1594 ListBox* pBox = (ListBox*) GetWindow();
1595 if ( pBox )
1596 {
1597 for ( sal_uInt16 n = nCount; n; )
1598 pBox->RemoveEntry( nPos + (--n) );
1599 }
1600 }
1601
getItemCount()1602 sal_Int16 VCLXListBox::getItemCount()
1603 {
1604 ::vos::OGuard aGuard( GetMutex() );
1605
1606 ListBox* pBox = (ListBox*) GetWindow();
1607 return pBox ? pBox->GetEntryCount() : 0;
1608 }
1609
getItem(sal_Int16 nPos)1610 ::rtl::OUString VCLXListBox::getItem( sal_Int16 nPos )
1611 {
1612 ::vos::OGuard aGuard( GetMutex() );
1613
1614 String aItem;
1615 ListBox* pBox = (ListBox*) GetWindow();
1616 if ( pBox )
1617 aItem = pBox->GetEntry( nPos );
1618 return aItem;
1619 }
1620
getItems()1621 ::com::sun::star::uno::Sequence< ::rtl::OUString> VCLXListBox::getItems()
1622 {
1623 ::vos::OGuard aGuard( GetMutex() );
1624
1625 ::com::sun::star::uno::Sequence< ::rtl::OUString> aSeq;
1626 ListBox* pBox = (ListBox*) GetWindow();
1627 if ( pBox )
1628 {
1629 sal_uInt16 nEntries = pBox->GetEntryCount();
1630 aSeq = ::com::sun::star::uno::Sequence< ::rtl::OUString>( nEntries );
1631 for ( sal_uInt16 n = nEntries; n; )
1632 {
1633 --n;
1634 aSeq.getArray()[n] = ::rtl::OUString( pBox->GetEntry( n ) );
1635 }
1636 }
1637 return aSeq;
1638 }
1639
getSelectedItemPos()1640 sal_Int16 VCLXListBox::getSelectedItemPos()
1641 {
1642 ::vos::OGuard aGuard( GetMutex() );
1643
1644 ListBox* pBox = (ListBox*) GetWindow();
1645 return pBox ? pBox->GetSelectEntryPos() : 0;
1646 }
1647
getSelectedItemsPos()1648 ::com::sun::star::uno::Sequence<sal_Int16> VCLXListBox::getSelectedItemsPos()
1649 {
1650 ::vos::OGuard aGuard( GetMutex() );
1651
1652 ::com::sun::star::uno::Sequence<sal_Int16> aSeq;
1653 ListBox* pBox = (ListBox*) GetWindow();
1654 if ( pBox )
1655 {
1656 sal_uInt16 nSelEntries = pBox->GetSelectEntryCount();
1657 aSeq = ::com::sun::star::uno::Sequence<sal_Int16>( nSelEntries );
1658 for ( sal_uInt16 n = 0; n < nSelEntries; n++ )
1659 aSeq.getArray()[n] = pBox->GetSelectEntryPos( n );
1660 }
1661 return aSeq;
1662 }
1663
getSelectedItem()1664 ::rtl::OUString VCLXListBox::getSelectedItem()
1665 {
1666 ::vos::OGuard aGuard( GetMutex() );
1667
1668 String aItem;
1669 ListBox* pBox = (ListBox*) GetWindow();
1670 if ( pBox )
1671 aItem = pBox->GetSelectEntry();
1672 return aItem;
1673 }
1674
getSelectedItems()1675 ::com::sun::star::uno::Sequence< ::rtl::OUString> VCLXListBox::getSelectedItems()
1676 {
1677 ::vos::OGuard aGuard( GetMutex() );
1678
1679 ::com::sun::star::uno::Sequence< ::rtl::OUString> aSeq;
1680 ListBox* pBox = (ListBox*) GetWindow();
1681 if ( pBox )
1682 {
1683 sal_uInt16 nSelEntries = pBox->GetSelectEntryCount();
1684 aSeq = ::com::sun::star::uno::Sequence< ::rtl::OUString>( nSelEntries );
1685 for ( sal_uInt16 n = 0; n < nSelEntries; n++ )
1686 aSeq.getArray()[n] = ::rtl::OUString( pBox->GetSelectEntry( n ) );
1687 }
1688 return aSeq;
1689 }
1690
selectItemPos(sal_Int16 nPos,sal_Bool bSelect)1691 void VCLXListBox::selectItemPos( sal_Int16 nPos, sal_Bool bSelect )
1692 {
1693 ::vos::OGuard aGuard( GetMutex() );
1694
1695 ListBox* pBox = (ListBox*) GetWindow();
1696 if ( pBox && ( pBox->IsEntryPosSelected( nPos ) != bSelect ) )
1697 {
1698 pBox->SelectEntryPos( nPos, bSelect );
1699
1700 // VCL doesn't call select handler after API call.
1701 // ImplCallItemListeners();
1702
1703 // #107218# Call same listeners like VCL would do after user interaction
1704 SetSynthesizingVCLEvent( sal_True );
1705 pBox->Select();
1706 SetSynthesizingVCLEvent( sal_False );
1707 }
1708 }
1709
selectItemsPos(const::com::sun::star::uno::Sequence<sal_Int16> & aPositions,sal_Bool bSelect)1710 void VCLXListBox::selectItemsPos( const ::com::sun::star::uno::Sequence<sal_Int16>& aPositions, sal_Bool bSelect )
1711 {
1712 ::vos::OGuard aGuard( GetMutex() );
1713
1714 ListBox* pBox = (ListBox*) GetWindow();
1715 if ( pBox )
1716 {
1717 sal_Bool bChanged = sal_False;
1718 for ( sal_uInt16 n = (sal_uInt16)aPositions.getLength(); n; )
1719 {
1720 sal_uInt16 nPos = (sal_uInt16) aPositions.getConstArray()[--n];
1721 if ( pBox->IsEntryPosSelected( nPos ) != bSelect )
1722 {
1723 pBox->SelectEntryPos( nPos, bSelect );
1724 bChanged = sal_True;
1725 }
1726 }
1727
1728 if ( bChanged )
1729 {
1730 // VCL doesn't call select handler after API call.
1731 // ImplCallItemListeners();
1732
1733 // #107218# Call same listeners like VCL would do after user interaction
1734 SetSynthesizingVCLEvent( sal_True );
1735 pBox->Select();
1736 SetSynthesizingVCLEvent( sal_False );
1737 }
1738 }
1739 }
1740
selectItem(const::rtl::OUString & rItemText,sal_Bool bSelect)1741 void VCLXListBox::selectItem( const ::rtl::OUString& rItemText, sal_Bool bSelect )
1742 {
1743 ::vos::OGuard aGuard( GetMutex() );
1744
1745 ListBox* pBox = (ListBox*) GetWindow();
1746 if ( pBox )
1747 {
1748 String aItemText( rItemText );
1749 selectItemPos( pBox->GetEntryPos( aItemText ), bSelect );
1750 }
1751 }
1752
1753
setDropDownLineCount(sal_Int16 nLines)1754 void VCLXListBox::setDropDownLineCount( sal_Int16 nLines )
1755 {
1756 ::vos::OGuard aGuard( GetMutex() );
1757
1758 ListBox* pBox = (ListBox*) GetWindow();
1759 if ( pBox )
1760 pBox->SetDropDownLineCount( nLines );
1761 }
1762
getDropDownLineCount()1763 sal_Int16 VCLXListBox::getDropDownLineCount()
1764 {
1765 ::vos::OGuard aGuard( GetMutex() );
1766
1767 sal_Int16 nLines = 0;
1768 ListBox* pBox = (ListBox*) GetWindow();
1769 if ( pBox )
1770 nLines = pBox->GetDropDownLineCount();
1771 return nLines;
1772 }
1773
isMutipleMode()1774 sal_Bool VCLXListBox::isMutipleMode()
1775 {
1776 ::vos::OGuard aGuard( GetMutex() );
1777
1778 sal_Bool bMulti = sal_False;
1779 ListBox* pBox = (ListBox*) GetWindow();
1780 if ( pBox )
1781 bMulti = pBox->IsMultiSelectionEnabled();
1782 return bMulti;
1783 }
1784
setMultipleMode(sal_Bool bMulti)1785 void VCLXListBox::setMultipleMode( sal_Bool bMulti )
1786 {
1787 ::vos::OGuard aGuard( GetMutex() );
1788
1789 ListBox* pBox = (ListBox*) GetWindow();
1790 if ( pBox )
1791 pBox->EnableMultiSelection( bMulti );
1792 }
1793
makeVisible(sal_Int16 nEntry)1794 void VCLXListBox::makeVisible( sal_Int16 nEntry )
1795 {
1796 ::vos::OGuard aGuard( GetMutex() );
1797
1798 ListBox* pBox = (ListBox*) GetWindow();
1799 if ( pBox )
1800 pBox->SetTopEntry( nEntry );
1801 }
1802
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)1803 void VCLXListBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1804 {
1805 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
1806 // since we call listeners below, there is a potential that we will be destroyed
1807 // in during the listener call. To prevent the resulting crashs, we keep us
1808 // alive as long as we're here
1809 // #20178# - 2003-10-01 - fs@openoffice.org
1810
1811 switch ( rVclWindowEvent.GetId() )
1812 {
1813 case VCLEVENT_LISTBOX_SELECT:
1814 {
1815 ListBox* pListBox = (ListBox*)GetWindow();
1816
1817 if( pListBox )
1818 {
1819 sal_Bool bDropDown = ( pListBox->GetStyle() & WB_DROPDOWN ) ? sal_True : sal_False;
1820 if ( bDropDown && !IsSynthesizingVCLEvent() && maActionListeners.getLength() )
1821 {
1822 // Bei DropDown den ActionListener rufen...
1823 ::com::sun::star::awt::ActionEvent aEvent;
1824 aEvent.Source = (::cppu::OWeakObject*)this;
1825 aEvent.ActionCommand = pListBox->GetSelectEntry();
1826 maActionListeners.actionPerformed( aEvent );
1827 }
1828
1829 if ( maItemListeners.getLength() )
1830 {
1831 ImplCallItemListeners();
1832 }
1833 }
1834 }
1835 break;
1836
1837 case VCLEVENT_LISTBOX_DOUBLECLICK:
1838 if ( GetWindow() && maActionListeners.getLength() )
1839 {
1840 ::com::sun::star::awt::ActionEvent aEvent;
1841 aEvent.Source = (::cppu::OWeakObject*)this;
1842 aEvent.ActionCommand = ((ListBox*)GetWindow())->GetSelectEntry();
1843 maActionListeners.actionPerformed( aEvent );
1844 }
1845 break;
1846
1847 default:
1848 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
1849 break;
1850 }
1851 }
1852
CreateAccessibleContext()1853 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXListBox::CreateAccessibleContext()
1854 {
1855 ::vos::OGuard aGuard( GetMutex() );
1856
1857 return getAccessibleFactory().createAccessibleContext( this );
1858 }
1859
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)1860 void VCLXListBox::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value)
1861 {
1862 ::vos::OGuard aGuard( GetMutex() );
1863
1864 ListBox* pListBox = (ListBox*)GetWindow();
1865 if ( pListBox )
1866 {
1867 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1868 switch ( nPropType )
1869 {
1870 case BASEPROPERTY_ITEM_SEPARATOR_POS:
1871 {
1872 sal_Int16 nSeparatorPos(0);
1873 if ( Value >>= nSeparatorPos )
1874 pListBox->SetSeparatorPos( nSeparatorPos );
1875 }
1876 break;
1877 case BASEPROPERTY_READONLY:
1878 {
1879 sal_Bool b = sal_Bool();
1880 if ( Value >>= b )
1881 pListBox->SetReadOnly( b);
1882 }
1883 break;
1884 case BASEPROPERTY_MULTISELECTION:
1885 {
1886 sal_Bool b = sal_Bool();
1887 if ( Value >>= b )
1888 pListBox->EnableMultiSelection( b );
1889 }
1890 break;
1891 case BASEPROPERTY_MULTISELECTION_SIMPLEMODE:
1892 ::toolkit::adjustBooleanWindowStyle( Value, pListBox, WB_SIMPLEMODE, sal_False );
1893 break;
1894 case BASEPROPERTY_LINECOUNT:
1895 {
1896 sal_Int16 n = sal_Int16();
1897 if ( Value >>= n )
1898 pListBox->SetDropDownLineCount( n );
1899 }
1900 break;
1901 case BASEPROPERTY_STRINGITEMLIST:
1902 {
1903 ::com::sun::star::uno::Sequence< ::rtl::OUString> aItems;
1904 if ( Value >>= aItems )
1905 {
1906 pListBox->Clear();
1907 addItems( aItems, 0 );
1908 }
1909 }
1910 break;
1911 case BASEPROPERTY_SELECTEDITEMS:
1912 {
1913 ::com::sun::star::uno::Sequence<sal_Int16> aItems;
1914 if ( Value >>= aItems )
1915 {
1916 for ( sal_uInt16 n = pListBox->GetEntryCount(); n; )
1917 pListBox->SelectEntryPos( --n, sal_False );
1918
1919 if ( aItems.getLength() )
1920 selectItemsPos( aItems, sal_True );
1921 else
1922 pListBox->SetNoSelection();
1923
1924 if ( !pListBox->GetSelectEntryCount() )
1925 pListBox->SetTopEntry( 0 );
1926 }
1927 }
1928 break;
1929 default:
1930 {
1931 VCLXWindow::setProperty( PropertyName, Value );
1932 }
1933 }
1934 }
1935 }
1936
getProperty(const::rtl::OUString & PropertyName)1937 ::com::sun::star::uno::Any VCLXListBox::getProperty( const ::rtl::OUString& PropertyName )
1938 {
1939 ::vos::OGuard aGuard( GetMutex() );
1940
1941 ::com::sun::star::uno::Any aProp;
1942 ListBox* pListBox = (ListBox*)GetWindow();
1943 if ( pListBox )
1944 {
1945 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1946 switch ( nPropType )
1947 {
1948 case BASEPROPERTY_ITEM_SEPARATOR_POS:
1949 aProp <<= sal_Int16( pListBox->GetSeparatorPos() );
1950 break;
1951 case BASEPROPERTY_READONLY:
1952 {
1953 aProp <<= (sal_Bool) pListBox->IsReadOnly();
1954 }
1955 break;
1956 case BASEPROPERTY_MULTISELECTION:
1957 {
1958 aProp <<= (sal_Bool) pListBox->IsMultiSelectionEnabled();
1959 }
1960 break;
1961 case BASEPROPERTY_MULTISELECTION_SIMPLEMODE:
1962 {
1963 aProp <<= (sal_Bool)( ( pListBox->GetStyle() & WB_SIMPLEMODE ) == 0 );
1964 }
1965 break;
1966 case BASEPROPERTY_LINECOUNT:
1967 {
1968 aProp <<= (sal_Int16) pListBox->GetDropDownLineCount();
1969 }
1970 break;
1971 case BASEPROPERTY_STRINGITEMLIST:
1972 {
1973 sal_uInt16 nItems = pListBox->GetEntryCount();
1974 ::com::sun::star::uno::Sequence< ::rtl::OUString> aSeq( nItems );
1975 ::rtl::OUString* pStrings = aSeq.getArray();
1976 for ( sal_uInt16 n = 0; n < nItems; n++ )
1977 pStrings[n] = pListBox->GetEntry( n );
1978 aProp <<= aSeq;
1979
1980 }
1981 break;
1982 default:
1983 {
1984 aProp <<= VCLXWindow::getProperty( PropertyName );
1985 }
1986 }
1987 }
1988 return aProp;
1989 }
1990
getMinimumSize()1991 ::com::sun::star::awt::Size VCLXListBox::getMinimumSize( )
1992 {
1993 ::vos::OGuard aGuard( GetMutex() );
1994
1995 Size aSz;
1996 ListBox* pListBox = (ListBox*) GetWindow();
1997 if ( pListBox )
1998 aSz = pListBox->CalcMinimumSize();
1999 return AWTSize(aSz);
2000 }
2001
getPreferredSize()2002 ::com::sun::star::awt::Size VCLXListBox::getPreferredSize( )
2003 {
2004 ::vos::OGuard aGuard( GetMutex() );
2005
2006 Size aSz;
2007 ListBox* pListBox = (ListBox*) GetWindow();
2008 if ( pListBox )
2009 {
2010 aSz = pListBox->CalcMinimumSize();
2011 if ( pListBox->GetStyle() & WB_DROPDOWN )
2012 aSz.Height() += 4;
2013 }
2014 return AWTSize(aSz);
2015 }
2016
calcAdjustedSize(const::com::sun::star::awt::Size & rNewSize)2017 ::com::sun::star::awt::Size VCLXListBox::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize )
2018 {
2019 ::vos::OGuard aGuard( GetMutex() );
2020
2021 Size aSz = VCLSize(rNewSize);
2022 ListBox* pListBox = (ListBox*) GetWindow();
2023 if ( pListBox )
2024 aSz = pListBox->CalcAdjustedSize( aSz );
2025 return AWTSize(aSz);
2026 }
2027
getMinimumSize(sal_Int16 nCols,sal_Int16 nLines)2028 ::com::sun::star::awt::Size VCLXListBox::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines )
2029 {
2030 ::vos::OGuard aGuard( GetMutex() );
2031
2032 Size aSz;
2033 ListBox* pListBox = (ListBox*) GetWindow();
2034 if ( pListBox )
2035 aSz = pListBox->CalcSize( nCols, nLines );
2036 return AWTSize(aSz);
2037 }
2038
getColumnsAndLines(sal_Int16 & nCols,sal_Int16 & nLines)2039 void VCLXListBox::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines )
2040 {
2041 ::vos::OGuard aGuard( GetMutex() );
2042
2043 nCols = nLines = 0;
2044 ListBox* pListBox = (ListBox*) GetWindow();
2045 if ( pListBox )
2046 {
2047 sal_uInt16 nC, nL;
2048 pListBox->GetMaxVisColumnsAndLines( nC, nL );
2049 nCols = nC;
2050 nLines = nL;
2051 }
2052 }
2053
ImplCallItemListeners()2054 void VCLXListBox::ImplCallItemListeners()
2055 {
2056 ListBox* pListBox = (ListBox*) GetWindow();
2057 if ( pListBox && maItemListeners.getLength() )
2058 {
2059 ::com::sun::star::awt::ItemEvent aEvent;
2060 aEvent.Source = (::cppu::OWeakObject*)this;
2061 aEvent.Highlighted = sal_False;
2062
2063 // Bei Mehrfachselektion 0xFFFF, sonst die ID
2064 aEvent.Selected = (pListBox->GetSelectEntryCount() == 1 ) ? pListBox->GetSelectEntryPos() : 0xFFFF;
2065
2066 maItemListeners.itemStateChanged( aEvent );
2067 }
2068 }
2069 namespace
2070 {
lcl_getImageFromURL(const::rtl::OUString & i_rImageURL)2071 Image lcl_getImageFromURL( const ::rtl::OUString& i_rImageURL )
2072 {
2073 if ( !i_rImageURL.getLength() )
2074 return Image();
2075
2076 try
2077 {
2078 ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
2079 Reference< XGraphicProvider > xProvider;
2080 if ( aContext.createComponent( "com.sun.star.graphic.GraphicProvider", xProvider ) )
2081 {
2082 ::comphelper::NamedValueCollection aMediaProperties;
2083 aMediaProperties.put( "URL", i_rImageURL );
2084 Reference< XGraphic > xGraphic = xProvider->queryGraphic( aMediaProperties.getPropertyValues() );
2085 return Image( xGraphic );
2086 }
2087 }
2088 catch( const uno::Exception& )
2089 {
2090 DBG_UNHANDLED_EXCEPTION();
2091 }
2092 return Image();
2093 }
2094 }
listItemInserted(const ItemListEvent & i_rEvent)2095 void SAL_CALL VCLXListBox::listItemInserted( const ItemListEvent& i_rEvent )
2096 {
2097 ::vos::OGuard aGuard( GetMutex() );
2098
2099 ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() );
2100
2101 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemInserted: no ListBox?!" );
2102 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition <= sal_Int32( pListBox->GetEntryCount() ) ),
2103 "VCLXListBox::listItemInserted: illegal (inconsistent) item position!" );
2104 pListBox->InsertEntry(
2105 i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : ::rtl::OUString(),
2106 i_rEvent.ItemImageURL.IsPresent ? TkResMgr::getImageFromURL( i_rEvent.ItemImageURL.Value ) : Image(),
2107 i_rEvent.ItemPosition );
2108 }
2109
listItemRemoved(const ItemListEvent & i_rEvent)2110 void SAL_CALL VCLXListBox::listItemRemoved( const ItemListEvent& i_rEvent )
2111 {
2112 ::vos::OGuard aGuard( GetMutex() );
2113
2114 ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() );
2115
2116 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemRemoved: no ListBox?!" );
2117 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pListBox->GetEntryCount() ) ),
2118 "VCLXListBox::listItemRemoved: illegal (inconsistent) item position!" );
2119
2120 pListBox->RemoveEntry( i_rEvent.ItemPosition );
2121 }
2122
listItemModified(const ItemListEvent & i_rEvent)2123 void SAL_CALL VCLXListBox::listItemModified( const ItemListEvent& i_rEvent )
2124 {
2125 ::vos::OGuard aGuard( GetMutex() );
2126
2127 ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() );
2128
2129 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" );
2130 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pListBox->GetEntryCount() ) ),
2131 "VCLXListBox::listItemModified: illegal (inconsistent) item position!" );
2132
2133 // VCL's ListBox does not support changing an entry's text or image, so remove and re-insert
2134
2135 const ::rtl::OUString sNewText = i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : ::rtl::OUString( pListBox->GetEntry( i_rEvent.ItemPosition ) );
2136 const Image aNewImage( i_rEvent.ItemImageURL.IsPresent ? TkResMgr::getImageFromURL( i_rEvent.ItemImageURL.Value ) : pListBox->GetEntryImage( i_rEvent.ItemPosition ) );
2137
2138 pListBox->RemoveEntry( i_rEvent.ItemPosition );
2139 pListBox->InsertEntry( sNewText, aNewImage, i_rEvent.ItemPosition );
2140 }
2141
allItemsRemoved(const EventObject & i_rEvent)2142 void SAL_CALL VCLXListBox::allItemsRemoved( const EventObject& i_rEvent )
2143 {
2144 ::vos::OGuard aGuard( GetMutex() );
2145
2146 ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() );
2147 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" );
2148
2149 pListBox->Clear();
2150
2151 (void)i_rEvent;
2152 }
2153
itemListChanged(const EventObject & i_rEvent)2154 void SAL_CALL VCLXListBox::itemListChanged( const EventObject& i_rEvent )
2155 {
2156 ::vos::OGuard aGuard( GetMutex() );
2157
2158 ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() );
2159 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" );
2160
2161 pListBox->Clear();
2162
2163 uno::Reference< beans::XPropertySet > xPropSet( i_rEvent.Source, uno::UNO_QUERY_THROW );
2164 uno::Reference< beans::XPropertySetInfo > xPSI( xPropSet->getPropertySetInfo(), uno::UNO_QUERY_THROW );
2165 uno::Reference< resource::XStringResourceResolver > xStringResourceResolver;
2166 if ( xPSI->hasPropertyByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" ) ) ) )
2167 {
2168 xStringResourceResolver.set(
2169 xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" ) ) ),
2170 uno::UNO_QUERY
2171 );
2172 }
2173
2174
2175 Reference< XItemList > xItemList( i_rEvent.Source, uno::UNO_QUERY_THROW );
2176 uno::Sequence< beans::Pair< ::rtl::OUString, ::rtl::OUString > > aItems = xItemList->getAllItems();
2177 for ( sal_Int32 i=0; i<aItems.getLength(); ++i )
2178 {
2179 ::rtl::OUString aLocalizationKey( aItems[i].First );
2180 if ( xStringResourceResolver.is() && aLocalizationKey.getLength() != 0 && aLocalizationKey[0] == '&' )
2181 {
2182 aLocalizationKey = xStringResourceResolver->resolveString(aLocalizationKey.copy( 1 ));
2183 }
2184 pListBox->InsertEntry( aLocalizationKey, lcl_getImageFromURL( aItems[i].Second ) );
2185 }
2186 }
2187
disposing(const EventObject & i_rEvent)2188 void SAL_CALL VCLXListBox::disposing( const EventObject& i_rEvent )
2189 {
2190 // just disambiguate
2191 VCLXWindow::disposing( i_rEvent );
2192 }
2193
2194 // ----------------------------------------------------
2195 // class VCLXMessageBox
2196 // ----------------------------------------------------
2197
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)2198 void VCLXMessageBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2199 {
2200 VCLXTopWindow::ImplGetPropertyIds( rIds );
2201 }
2202
VCLXMessageBox()2203 VCLXMessageBox::VCLXMessageBox()
2204 {
2205 }
2206
~VCLXMessageBox()2207 VCLXMessageBox::~VCLXMessageBox()
2208 {
2209 }
2210
2211 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)2212 ::com::sun::star::uno::Any VCLXMessageBox::queryInterface( const ::com::sun::star::uno::Type & rType )
2213 {
2214 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
2215 SAL_STATIC_CAST( ::com::sun::star::awt::XMessageBox*, this ) );
2216 return (aRet.hasValue() ? aRet : VCLXTopWindow::queryInterface( rType ));
2217 }
2218
2219 // ::com::sun::star::lang::XTypeProvider
2220 IMPL_XTYPEPROVIDER_START( VCLXMessageBox )
2221 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMessageBox>* ) NULL ),
2222 VCLXTopWindow::getTypes()
2223 IMPL_XTYPEPROVIDER_END
2224
2225 void VCLXMessageBox::setCaptionText( const ::rtl::OUString& rText )
2226 {
2227 ::vos::OGuard aGuard( GetMutex() );
2228
2229 Window* pWindow = GetWindow();
2230 if ( pWindow )
2231 pWindow->SetText( rText );
2232 }
2233
getCaptionText()2234 ::rtl::OUString VCLXMessageBox::getCaptionText()
2235 {
2236 ::vos::OGuard aGuard( GetMutex() );
2237
2238 String aText;
2239 Window* pWindow = GetWindow();
2240 if ( pWindow )
2241 aText = pWindow->GetText();
2242 return aText;
2243 }
2244
setMessageText(const::rtl::OUString & rText)2245 void VCLXMessageBox::setMessageText( const ::rtl::OUString& rText )
2246 {
2247 ::vos::OGuard aGuard( GetMutex() );
2248
2249 MessBox* pBox = (MessBox*)GetWindow();
2250 if ( pBox )
2251 pBox->SetMessText( rText );
2252 }
2253
getMessageText()2254 ::rtl::OUString VCLXMessageBox::getMessageText()
2255 {
2256 ::vos::OGuard aGuard( GetMutex() );
2257
2258 ::rtl::OUString aText;
2259 MessBox* pBox = (MessBox*)GetWindow();
2260 if ( pBox )
2261 aText = pBox->GetMessText();
2262 return aText;
2263 }
2264
execute()2265 sal_Int16 VCLXMessageBox::execute()
2266 {
2267 ::vos::OGuard aGuard( GetMutex() );
2268
2269 MessBox* pBox = (MessBox*)GetWindow();
2270 return pBox ? pBox->Execute() : 0;
2271 }
2272
getMinimumSize()2273 ::com::sun::star::awt::Size SAL_CALL VCLXMessageBox::getMinimumSize()
2274 {
2275 ::vos::OGuard aGuard( GetMutex() );
2276 return ::com::sun::star::awt::Size( 250, 100 );
2277 }
2278
2279 // ----------------------------------------------------
2280 // class VCLXDialog
2281 // ----------------------------------------------------
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)2282 void VCLXDialog::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2283 {
2284 VCLXTopWindow::ImplGetPropertyIds( rIds );
2285 }
2286
VCLXDialog()2287 VCLXDialog::VCLXDialog()
2288 {
2289 }
2290
~VCLXDialog()2291 VCLXDialog::~VCLXDialog()
2292 {
2293 #ifndef __SUNPRO_CC
2294 OSL_TRACE ("%s", __FUNCTION__);
2295 #endif
2296 }
2297
2298 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)2299 ::com::sun::star::uno::Any VCLXDialog::queryInterface( const ::com::sun::star::uno::Type & rType )
2300 {
2301 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
2302 SAL_STATIC_CAST( ::com::sun::star::awt::XDialog2*, this ),
2303 SAL_STATIC_CAST( ::com::sun::star::awt::XDialog*, this ) );
2304 return (aRet.hasValue() ? aRet : VCLXTopWindow::queryInterface( rType ));
2305 }
2306
2307 // ::com::sun::star::lang::XTypeProvider
2308 IMPL_XTYPEPROVIDER_START( VCLXDialog )
2309 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDialog2>* ) NULL ),
2310 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDialog>* ) NULL ),
2311 VCLXTopWindow::getTypes()
2312 IMPL_XTYPEPROVIDER_END
2313
2314 void SAL_CALL VCLXDialog::endDialog( ::sal_Int32 i_result )
2315 {
2316 ::vos::OGuard aGuard( GetMutex() );
2317
2318 Dialog* pDialog = dynamic_cast< Dialog* >( GetWindow() );
2319 if ( pDialog )
2320 pDialog->EndDialog( i_result );
2321 }
2322
setHelpId(const::rtl::OUString & rId)2323 void SAL_CALL VCLXDialog::setHelpId( const ::rtl::OUString& rId )
2324 {
2325 ::vos::OGuard aGuard( GetMutex() );
2326
2327 Window* pWindow = GetWindow();
2328 if ( pWindow )
2329 pWindow->SetHelpId( rtl::OUStringToOString( rId, RTL_TEXTENCODING_UTF8 ) );
2330 }
2331
setTitle(const::rtl::OUString & Title)2332 void VCLXDialog::setTitle( const ::rtl::OUString& Title )
2333 {
2334 ::vos::OGuard aGuard( GetMutex() );
2335
2336 Window* pWindow = GetWindow();
2337 if ( pWindow )
2338 pWindow->SetText( Title );
2339 }
2340
getTitle()2341 ::rtl::OUString VCLXDialog::getTitle()
2342 {
2343 ::vos::OGuard aGuard( GetMutex() );
2344
2345 ::rtl::OUString aTitle;
2346 Window* pWindow = GetWindow();
2347 if ( pWindow )
2348 aTitle = pWindow->GetText();
2349 return aTitle;
2350 }
2351
execute()2352 sal_Int16 VCLXDialog::execute()
2353 {
2354 ::vos::OGuard aGuard( GetMutex() );
2355
2356 sal_Int16 nRet = 0;
2357 if ( GetWindow() )
2358 {
2359 Dialog* pDlg = (Dialog*) GetWindow();
2360 Window* pParent = pDlg->GetWindow( WINDOW_PARENTOVERLAP );
2361 Window* pOldParent = NULL;
2362 Window* pSetParent = NULL;
2363 if ( pParent && !pParent->IsReallyVisible() )
2364 {
2365 pOldParent = pDlg->GetParent();
2366 Window* pFrame = pDlg->GetWindow( WINDOW_FRAME );
2367 if( pFrame != pDlg )
2368 {
2369 pDlg->SetParent( pFrame );
2370 pSetParent = pFrame;
2371 }
2372 }
2373
2374 nRet = pDlg->Execute();
2375
2376 // set the parent back only in case no new parent was set from outside
2377 // in other words, revert only own changes
2378 if ( pOldParent && pDlg->GetParent() == pSetParent )
2379 pDlg->SetParent( pOldParent );
2380 }
2381 return nRet;
2382 }
2383
endExecute()2384 void VCLXDialog::endExecute()
2385 {
2386 endDialog(0);
2387 }
2388
draw(sal_Int32 nX,sal_Int32 nY)2389 void SAL_CALL VCLXDialog::draw( sal_Int32 nX, sal_Int32 nY )
2390 {
2391 ::vos::OGuard aGuard( GetMutex() );
2392 Window* pWindow = GetWindow();
2393
2394 if ( pWindow )
2395 {
2396 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
2397 if ( !pDev )
2398 pDev = pWindow->GetParent();
2399
2400 Size aSize = pDev->PixelToLogic( pWindow->GetSizePixel() );
2401 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
2402
2403 pWindow->Draw( pDev, aPos, aSize, WINDOW_DRAW_NOCONTROLS );
2404 }
2405 }
2406
getInfo()2407 ::com::sun::star::awt::DeviceInfo VCLXDialog::getInfo()
2408 {
2409 ::com::sun::star::awt::DeviceInfo aInfo = VCLXDevice::getInfo();
2410
2411 ::vos::OGuard aGuard( GetMutex() );
2412 Dialog* pDlg = (Dialog*) GetWindow();
2413 if ( pDlg )
2414 pDlg->GetDrawWindowBorder( aInfo.LeftInset, aInfo.TopInset, aInfo.RightInset, aInfo.BottomInset );
2415
2416 return aInfo;
2417 }
2418
2419
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)2420 void SAL_CALL VCLXDialog::setProperty(
2421 const ::rtl::OUString& PropertyName,
2422 const ::com::sun::star::uno::Any& Value )
2423 {
2424 ::vos::OGuard aGuard( GetMutex() );
2425
2426 Dialog* pDialog = (Dialog*)GetWindow();
2427 if ( pDialog )
2428 {
2429 sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
2430
2431 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2432 switch ( nPropType )
2433 {
2434 case BASEPROPERTY_GRAPHIC:
2435 {
2436 Reference< XGraphic > xGraphic;
2437 if (( Value >>= xGraphic ) && xGraphic.is() )
2438 {
2439 Image aImage( xGraphic );
2440
2441 Wallpaper aWallpaper( aImage.GetBitmapEx());
2442 aWallpaper.SetStyle( WALLPAPER_SCALE );
2443 pDialog->SetBackground( aWallpaper );
2444 }
2445 else if ( bVoid || !xGraphic.is() )
2446 {
2447 Color aColor = pDialog->GetControlBackground().GetColor();
2448 if ( aColor == COL_AUTO )
2449 aColor = pDialog->GetSettings().GetStyleSettings().GetDialogColor();
2450
2451 Wallpaper aWallpaper( aColor );
2452 pDialog->SetBackground( aWallpaper );
2453 }
2454 }
2455 break;
2456
2457 default:
2458 {
2459 VCLXWindow::setProperty( PropertyName, Value );
2460 }
2461 }
2462 }
2463 }
2464
2465 // ----------------------------------------------------
2466 // class VCLXTabPage
2467 // ----------------------------------------------------
VCLXTabPage()2468 VCLXTabPage::VCLXTabPage()
2469 {
2470 }
2471
~VCLXTabPage()2472 VCLXTabPage::~VCLXTabPage()
2473 {
2474 }
2475
queryInterface(const::com::sun::star::uno::Type & rType)2476 ::com::sun::star::uno::Any SAL_CALL VCLXTabPage::queryInterface(const ::com::sun::star::uno::Type & rType )
2477 {
2478 return VCLXContainer::queryInterface( rType );
2479 }
2480
2481 // ::com::sun::star::lang::XTypeProvider
IMPL_XTYPEPROVIDER_START(VCLXTabPage)2482 IMPL_XTYPEPROVIDER_START( VCLXTabPage )
2483 VCLXContainer::getTypes()
2484 IMPL_XTYPEPROVIDER_END
2485
2486 // ::com::sun::star::awt::XView
2487 void SAL_CALL VCLXTabPage::draw( sal_Int32 nX, sal_Int32 nY )
2488 {
2489 ::vos::OGuard aGuard( GetMutex() );
2490 Window* pWindow = GetWindow();
2491
2492 if ( pWindow )
2493 {
2494 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
2495 if ( !pDev )
2496 pDev = pWindow->GetParent();
2497
2498 Size aSize = pDev->PixelToLogic( pWindow->GetSizePixel() );
2499 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
2500
2501 pWindow->Draw( pDev, aPos, aSize, WINDOW_DRAW_NOCONTROLS );
2502 }
2503 }
2504
2505 // ::com::sun::star::awt::XDevice,
getInfo()2506 ::com::sun::star::awt::DeviceInfo SAL_CALL VCLXTabPage::getInfo()
2507 {
2508 ::com::sun::star::awt::DeviceInfo aInfo = VCLXDevice::getInfo();
2509 return aInfo;
2510 }
2511
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)2512 void SAL_CALL VCLXTabPage::setProperty(
2513 const ::rtl::OUString& PropertyName,
2514 const ::com::sun::star::uno::Any& Value )
2515 {
2516 ::vos::OGuard aGuard( GetMutex() );
2517
2518 TabPage* pTabPage = (TabPage*)GetWindow();
2519 if ( pTabPage )
2520 {
2521 sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
2522
2523 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2524 switch ( nPropType )
2525 {
2526 case BASEPROPERTY_GRAPHIC:
2527 {
2528 Reference< XGraphic > xGraphic;
2529 if (( Value >>= xGraphic ) && xGraphic.is() )
2530 {
2531 Image aImage( xGraphic );
2532
2533 Wallpaper aWallpaper( aImage.GetBitmapEx());
2534 aWallpaper.SetStyle( WALLPAPER_SCALE );
2535 pTabPage->SetBackground( aWallpaper );
2536 }
2537 else if ( bVoid || !xGraphic.is() )
2538 {
2539 Color aColor = pTabPage->GetControlBackground().GetColor();
2540 if ( aColor == COL_AUTO )
2541 aColor = pTabPage->GetSettings().GetStyleSettings().GetDialogColor();
2542
2543 Wallpaper aWallpaper( aColor );
2544 pTabPage->SetBackground( aWallpaper );
2545 }
2546 }
2547 break;
2548 case BASEPROPERTY_TITLE:
2549 {
2550 ::rtl::OUString sTitle;
2551 if ( Value >>= sTitle )
2552 {
2553 pTabPage->SetText(sTitle);
2554 }
2555 }
2556 break;
2557
2558 default:
2559 {
2560 VCLXContainer::setProperty( PropertyName, Value );
2561 }
2562 }
2563 }
2564 }
2565
2566 // ----------------------------------------------------
2567 // class VCLXFixedHyperlink
2568 // ----------------------------------------------------
VCLXFixedHyperlink()2569 VCLXFixedHyperlink::VCLXFixedHyperlink() :
2570
2571 maActionListeners( *this )
2572
2573 {
2574 }
2575
~VCLXFixedHyperlink()2576 VCLXFixedHyperlink::~VCLXFixedHyperlink()
2577 {
2578 }
2579
2580 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)2581 ::com::sun::star::uno::Any VCLXFixedHyperlink::queryInterface( const ::com::sun::star::uno::Type & rType )
2582 {
2583 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
2584 SAL_STATIC_CAST( ::com::sun::star::awt::XFixedHyperlink*, this ) );
2585 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
2586 }
2587
dispose()2588 void VCLXFixedHyperlink::dispose()
2589 {
2590 ::vos::OGuard aGuard( GetMutex() );
2591
2592 ::com::sun::star::lang::EventObject aObj;
2593 aObj.Source = (::cppu::OWeakObject*)this;
2594 maActionListeners.disposeAndClear( aObj );
2595 VCLXWindow::dispose();
2596 }
2597
2598 // ::com::sun::star::lang::XTypeProvider
2599 IMPL_XTYPEPROVIDER_START( VCLXFixedHyperlink )
2600 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFixedHyperlink>* ) NULL ),
2601 VCLXWindow::getTypes()
2602 IMPL_XTYPEPROVIDER_END
2603
2604 void VCLXFixedHyperlink::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
2605 {
2606 switch ( rVclWindowEvent.GetId() )
2607 {
2608 case VCLEVENT_BUTTON_CLICK:
2609 {
2610 if ( maActionListeners.getLength() )
2611 {
2612 ::com::sun::star::awt::ActionEvent aEvent;
2613 aEvent.Source = (::cppu::OWeakObject*)this;
2614 maActionListeners.actionPerformed( aEvent );
2615 }
2616 else
2617 {
2618 // open the URL
2619 ::rtl::OUString sURL;
2620 ::toolkit::FixedHyperlinkBase* pBase = (::toolkit::FixedHyperlinkBase*)GetWindow();
2621 if ( pBase )
2622 sURL = pBase->GetURL();
2623 Reference< ::com::sun::star::system::XSystemShellExecute > xSystemShellExecute(
2624 ::com::sun::star::system::SystemShellExecute::create(
2625 ::comphelper::getProcessComponentContext() ) );
2626 if ( sURL.getLength() > 0 && xSystemShellExecute.is() )
2627 {
2628 try
2629 {
2630 // start browser
2631 xSystemShellExecute->execute(
2632 sURL, ::rtl::OUString(), ::com::sun::star::system::SystemShellExecuteFlags::DEFAULTS );
2633 }
2634 catch( uno::Exception& )
2635 {
2636 }
2637 }
2638 }
2639 }
2640
2641 default:
2642 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
2643 break;
2644 }
2645 }
2646
CreateAccessibleContext()2647 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXFixedHyperlink::CreateAccessibleContext()
2648 {
2649 return getAccessibleFactory().createAccessibleContext( this );
2650 }
2651
setText(const::rtl::OUString & Text)2652 void VCLXFixedHyperlink::setText( const ::rtl::OUString& Text )
2653 {
2654 ::vos::OGuard aGuard( GetMutex() );
2655
2656 ::toolkit::FixedHyperlinkBase* pBase = (::toolkit::FixedHyperlinkBase*)GetWindow();
2657 if ( pBase )
2658 pBase->SetDescription( Text );
2659 }
2660
getText()2661 ::rtl::OUString VCLXFixedHyperlink::getText()
2662 {
2663 ::vos::OGuard aGuard( GetMutex() );
2664
2665 ::rtl::OUString aText;
2666 Window* pWindow = GetWindow();
2667 if ( pWindow )
2668 aText = pWindow->GetText();
2669 return aText;
2670 }
2671
setURL(const::rtl::OUString & URL)2672 void VCLXFixedHyperlink::setURL( const ::rtl::OUString& URL )
2673 {
2674 ::vos::OGuard aGuard( GetMutex() );
2675
2676 ::toolkit::FixedHyperlinkBase* pBase = (::toolkit::FixedHyperlinkBase*)GetWindow();
2677 if ( pBase )
2678 pBase->SetURL( URL );
2679 }
2680
getURL()2681 ::rtl::OUString VCLXFixedHyperlink::getURL( )
2682 {
2683 ::vos::OGuard aGuard( GetMutex() );
2684
2685 ::rtl::OUString aText;
2686 ::toolkit::FixedHyperlinkBase* pBase = (::toolkit::FixedHyperlinkBase*)GetWindow();
2687 if ( pBase )
2688 aText = pBase->GetURL();
2689 return aText;
2690 }
2691
setAlignment(short nAlign)2692 void VCLXFixedHyperlink::setAlignment( short nAlign )
2693 {
2694 ::vos::OGuard aGuard( GetMutex() );
2695
2696 Window* pWindow = GetWindow();
2697 if ( pWindow )
2698 {
2699 WinBits nNewBits = 0;
2700 if ( nAlign == ::com::sun::star::awt::TextAlign::LEFT )
2701 nNewBits = WB_LEFT;
2702 else if ( nAlign == ::com::sun::star::awt::TextAlign::CENTER )
2703 nNewBits = WB_CENTER;
2704 else
2705 nNewBits = WB_RIGHT;
2706
2707 WinBits nStyle = pWindow->GetStyle();
2708 nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT);
2709 pWindow->SetStyle( nStyle | nNewBits );
2710 }
2711 }
2712
getAlignment()2713 short VCLXFixedHyperlink::getAlignment()
2714 {
2715 ::vos::OGuard aGuard( GetMutex() );
2716
2717 short nAlign = 0;
2718 Window* pWindow = GetWindow();
2719 if ( pWindow )
2720 {
2721 WinBits nStyle = pWindow->GetStyle();
2722 if ( nStyle & WB_LEFT )
2723 nAlign = ::com::sun::star::awt::TextAlign::LEFT;
2724 else if ( nStyle & WB_CENTER )
2725 nAlign = ::com::sun::star::awt::TextAlign::CENTER;
2726 else
2727 nAlign = ::com::sun::star::awt::TextAlign::RIGHT;
2728 }
2729 return nAlign;
2730 }
2731
addActionListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XActionListener> & l)2732 void VCLXFixedHyperlink::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )
2733 {
2734 ::vos::OGuard aGuard( GetMutex() );
2735 maActionListeners.addInterface( l );
2736 }
2737
removeActionListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XActionListener> & l)2738 void VCLXFixedHyperlink::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )
2739 {
2740 ::vos::OGuard aGuard( GetMutex() );
2741 maActionListeners.removeInterface( l );
2742 }
2743
getMinimumSize()2744 ::com::sun::star::awt::Size VCLXFixedHyperlink::getMinimumSize( )
2745 {
2746 ::vos::OGuard aGuard( GetMutex() );
2747
2748 Size aSz;
2749 FixedText* pFixedText = (FixedText*)GetWindow();
2750 if ( pFixedText )
2751 aSz = pFixedText->CalcMinimumSize();
2752 return AWTSize(aSz);
2753 }
2754
getPreferredSize()2755 ::com::sun::star::awt::Size VCLXFixedHyperlink::getPreferredSize( )
2756 {
2757 return getMinimumSize();
2758 }
2759
calcAdjustedSize(const::com::sun::star::awt::Size & rNewSize)2760 ::com::sun::star::awt::Size VCLXFixedHyperlink::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize )
2761 {
2762 ::vos::OGuard aGuard( GetMutex() );
2763
2764 ::com::sun::star::awt::Size aSz = rNewSize;
2765 ::com::sun::star::awt::Size aMinSz = getMinimumSize();
2766 if ( aSz.Height != aMinSz.Height )
2767 aSz.Height = aMinSz.Height;
2768
2769 return aSz;
2770 }
2771
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)2772 void VCLXFixedHyperlink::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value)
2773 {
2774 ::vos::OGuard aGuard( GetMutex() );
2775
2776 ::toolkit::FixedHyperlinkBase* pBase = (::toolkit::FixedHyperlinkBase*)GetWindow();
2777 if ( pBase )
2778 {
2779 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2780 switch ( nPropType )
2781 {
2782 case BASEPROPERTY_LABEL:
2783 {
2784 ::rtl::OUString sNewLabel;
2785 if ( Value >>= sNewLabel )
2786 pBase->SetDescription( sNewLabel );
2787 break;
2788 }
2789
2790 case BASEPROPERTY_URL:
2791 {
2792 ::rtl::OUString sNewURL;
2793 if ( Value >>= sNewURL )
2794 pBase->SetURL( sNewURL );
2795 break;
2796 }
2797
2798 default:
2799 {
2800 VCLXWindow::setProperty( PropertyName, Value );
2801 }
2802 }
2803 }
2804 }
2805
getProperty(const::rtl::OUString & PropertyName)2806 ::com::sun::star::uno::Any VCLXFixedHyperlink::getProperty( const ::rtl::OUString& PropertyName )
2807 {
2808 ::vos::OGuard aGuard( GetMutex() );
2809
2810 ::com::sun::star::uno::Any aProp;
2811 ::toolkit::FixedHyperlinkBase* pBase = (::toolkit::FixedHyperlinkBase*)GetWindow();
2812 if ( pBase )
2813 {
2814 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2815 switch ( nPropType )
2816 {
2817 case BASEPROPERTY_URL:
2818 {
2819 aProp = makeAny( ::rtl::OUString( pBase->GetURL() ) );
2820 break;
2821 }
2822
2823 default:
2824 {
2825 aProp <<= VCLXWindow::getProperty( PropertyName );
2826 }
2827 }
2828 }
2829 return aProp;
2830 }
2831
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)2832 void VCLXFixedHyperlink::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2833 {
2834 PushPropertyIds( rIds,
2835 BASEPROPERTY_ALIGN,
2836 BASEPROPERTY_BACKGROUNDCOLOR,
2837 BASEPROPERTY_BORDER,
2838 BASEPROPERTY_BORDERCOLOR,
2839 BASEPROPERTY_DEFAULTCONTROL,
2840 BASEPROPERTY_ENABLED,
2841 BASEPROPERTY_ENABLEVISIBLE,
2842 BASEPROPERTY_FONTDESCRIPTOR,
2843 BASEPROPERTY_HELPTEXT,
2844 BASEPROPERTY_HELPURL,
2845 BASEPROPERTY_LABEL,
2846 BASEPROPERTY_MULTILINE,
2847 BASEPROPERTY_NOLABEL,
2848 BASEPROPERTY_PRINTABLE,
2849 BASEPROPERTY_TABSTOP,
2850 BASEPROPERTY_VERTICALALIGN,
2851 BASEPROPERTY_URL,
2852 BASEPROPERTY_WRITING_MODE,
2853 BASEPROPERTY_CONTEXT_WRITING_MODE,
2854 0);
2855 VCLXWindow::ImplGetPropertyIds( rIds );
2856 }
2857
2858 // ----------------------------------------------------
2859 // class VCLXFixedText
2860 // ----------------------------------------------------
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)2861 void VCLXFixedText::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2862 {
2863 PushPropertyIds( rIds,
2864 BASEPROPERTY_ALIGN,
2865 BASEPROPERTY_BACKGROUNDCOLOR,
2866 BASEPROPERTY_BORDER,
2867 BASEPROPERTY_BORDERCOLOR,
2868 BASEPROPERTY_DEFAULTCONTROL,
2869 BASEPROPERTY_ENABLED,
2870 BASEPROPERTY_ENABLEVISIBLE,
2871 BASEPROPERTY_FONTDESCRIPTOR,
2872 BASEPROPERTY_HELPTEXT,
2873 BASEPROPERTY_HELPURL,
2874 BASEPROPERTY_LABEL,
2875 BASEPROPERTY_MULTILINE,
2876 BASEPROPERTY_NOLABEL,
2877 BASEPROPERTY_PRINTABLE,
2878 BASEPROPERTY_TABSTOP,
2879 BASEPROPERTY_VERTICALALIGN,
2880 BASEPROPERTY_WRITING_MODE,
2881 BASEPROPERTY_CONTEXT_WRITING_MODE,
2882 BASEPROPERTY_REFERENCE_DEVICE,
2883 0);
2884 VCLXWindow::ImplGetPropertyIds( rIds );
2885 }
2886
VCLXFixedText()2887 VCLXFixedText::VCLXFixedText()
2888 {
2889 }
2890
~VCLXFixedText()2891 VCLXFixedText::~VCLXFixedText()
2892 {
2893 }
2894
2895 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)2896 ::com::sun::star::uno::Any VCLXFixedText::queryInterface( const ::com::sun::star::uno::Type & rType )
2897 {
2898 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
2899 SAL_STATIC_CAST( ::com::sun::star::awt::XFixedText*, this ) );
2900 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
2901 }
2902
2903 // ::com::sun::star::lang::XTypeProvider
2904 IMPL_XTYPEPROVIDER_START( VCLXFixedText )
2905 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFixedText>* ) NULL ),
2906 VCLXWindow::getTypes()
2907 IMPL_XTYPEPROVIDER_END
2908
2909 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXFixedText::CreateAccessibleContext()
2910 {
2911 return getAccessibleFactory().createAccessibleContext( this );
2912 }
2913
setText(const::rtl::OUString & Text)2914 void VCLXFixedText::setText( const ::rtl::OUString& Text )
2915 {
2916 ::vos::OGuard aGuard( GetMutex() );
2917
2918 Window* pWindow = GetWindow();
2919 if ( pWindow )
2920 pWindow->SetText( Text );
2921 }
2922
getText()2923 ::rtl::OUString VCLXFixedText::getText()
2924 {
2925 ::vos::OGuard aGuard( GetMutex() );
2926
2927 ::rtl::OUString aText;
2928 Window* pWindow = GetWindow();
2929 if ( pWindow )
2930 aText = pWindow->GetText();
2931 return aText;
2932 }
2933
setAlignment(short nAlign)2934 void VCLXFixedText::setAlignment( short nAlign )
2935 {
2936 ::vos::OGuard aGuard( GetMutex() );
2937
2938 Window* pWindow = GetWindow();
2939 if ( pWindow )
2940 {
2941 WinBits nNewBits = 0;
2942 if ( nAlign == ::com::sun::star::awt::TextAlign::LEFT )
2943 nNewBits = WB_LEFT;
2944 else if ( nAlign == ::com::sun::star::awt::TextAlign::CENTER )
2945 nNewBits = WB_CENTER;
2946 else
2947 nNewBits = WB_RIGHT;
2948
2949 WinBits nStyle = pWindow->GetStyle();
2950 nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT);
2951 pWindow->SetStyle( nStyle | nNewBits );
2952 }
2953 }
2954
getAlignment()2955 short VCLXFixedText::getAlignment()
2956 {
2957 ::vos::OGuard aGuard( GetMutex() );
2958
2959 short nAlign = 0;
2960 Window* pWindow = GetWindow();
2961 if ( pWindow )
2962 {
2963 WinBits nStyle = pWindow->GetStyle();
2964 if ( nStyle & WB_LEFT )
2965 nAlign = ::com::sun::star::awt::TextAlign::LEFT;
2966 else if ( nStyle & WB_CENTER )
2967 nAlign = ::com::sun::star::awt::TextAlign::CENTER;
2968 else
2969 nAlign = ::com::sun::star::awt::TextAlign::RIGHT;
2970 }
2971 return nAlign;
2972 }
2973
getMinimumSize()2974 ::com::sun::star::awt::Size VCLXFixedText::getMinimumSize( )
2975 {
2976 ::vos::OGuard aGuard( GetMutex() );
2977
2978 Size aSz;
2979 FixedText* pFixedText = (FixedText*)GetWindow();
2980 if ( pFixedText )
2981 aSz = pFixedText->CalcMinimumSize();
2982 return AWTSize(aSz);
2983 }
2984
getPreferredSize()2985 ::com::sun::star::awt::Size VCLXFixedText::getPreferredSize( )
2986 {
2987 return getMinimumSize();
2988 }
2989
calcAdjustedSize(const::com::sun::star::awt::Size & rMaxSize)2990 ::com::sun::star::awt::Size VCLXFixedText::calcAdjustedSize( const ::com::sun::star::awt::Size& rMaxSize )
2991 {
2992 ::vos::OGuard aGuard( GetMutex() );
2993
2994 Size aAdjustedSize( VCLUnoHelper::ConvertToVCLSize( rMaxSize ) );
2995 FixedText* pFixedText = (FixedText*)GetWindow();
2996 if ( pFixedText )
2997 aAdjustedSize = pFixedText->CalcMinimumSize( rMaxSize.Width );
2998 return VCLUnoHelper::ConvertToAWTSize( aAdjustedSize );
2999 }
3000
3001 // ----------------------------------------------------
3002 // class VCLXScrollBar
3003 // ----------------------------------------------------
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)3004 void VCLXScrollBar::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
3005 {
3006 PushPropertyIds( rIds,
3007 BASEPROPERTY_BACKGROUNDCOLOR,
3008 BASEPROPERTY_BLOCKINCREMENT,
3009 BASEPROPERTY_BORDER,
3010 BASEPROPERTY_BORDERCOLOR,
3011 BASEPROPERTY_DEFAULTCONTROL,
3012 BASEPROPERTY_ENABLED,
3013 BASEPROPERTY_ENABLEVISIBLE,
3014 BASEPROPERTY_HELPTEXT,
3015 BASEPROPERTY_HELPURL,
3016 BASEPROPERTY_LINEINCREMENT,
3017 BASEPROPERTY_LIVE_SCROLL,
3018 BASEPROPERTY_ORIENTATION,
3019 BASEPROPERTY_PRINTABLE,
3020 BASEPROPERTY_REPEAT_DELAY,
3021 BASEPROPERTY_SCROLLVALUE,
3022 BASEPROPERTY_SCROLLVALUE_MAX,
3023 BASEPROPERTY_SCROLLVALUE_MIN,
3024 BASEPROPERTY_SYMBOL_COLOR,
3025 BASEPROPERTY_TABSTOP,
3026 BASEPROPERTY_VISIBLESIZE,
3027 BASEPROPERTY_WRITING_MODE,
3028 BASEPROPERTY_CONTEXT_WRITING_MODE,
3029 0);
3030 VCLXWindow::ImplGetPropertyIds( rIds );
3031 }
3032
VCLXScrollBar()3033 VCLXScrollBar::VCLXScrollBar() : maAdjustmentListeners( *this )
3034 {
3035 }
3036
3037 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)3038 ::com::sun::star::uno::Any VCLXScrollBar::queryInterface( const ::com::sun::star::uno::Type & rType )
3039 {
3040 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
3041 SAL_STATIC_CAST( ::com::sun::star::awt::XScrollBar*, this ) );
3042 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
3043 }
3044
3045 // ::com::sun::star::lang::XTypeProvider
3046 IMPL_XTYPEPROVIDER_START( VCLXScrollBar )
3047 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XScrollBar>* ) NULL ),
3048 VCLXWindow::getTypes()
3049 IMPL_XTYPEPROVIDER_END
3050
3051 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXScrollBar::CreateAccessibleContext()
3052 {
3053 return getAccessibleFactory().createAccessibleContext( this );
3054 }
3055
3056 // ::com::sun::star::lang::XComponent
dispose()3057 void VCLXScrollBar::dispose()
3058 {
3059 ::vos::OGuard aGuard( GetMutex() );
3060
3061 ::com::sun::star::lang::EventObject aObj;
3062 aObj.Source = (::cppu::OWeakObject*)this;
3063 maAdjustmentListeners.disposeAndClear( aObj );
3064 VCLXWindow::dispose();
3065 }
3066
3067 // ::com::sun::star::awt::XScrollbar
addAdjustmentListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XAdjustmentListener> & l)3068 void VCLXScrollBar::addAdjustmentListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XAdjustmentListener > & l )
3069 {
3070 ::vos::OGuard aGuard( GetMutex() );
3071 maAdjustmentListeners.addInterface( l );
3072 }
3073
removeAdjustmentListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XAdjustmentListener> & l)3074 void VCLXScrollBar::removeAdjustmentListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XAdjustmentListener > & l )
3075 {
3076 ::vos::OGuard aGuard( GetMutex() );
3077 maAdjustmentListeners.removeInterface( l );
3078 }
3079
setValue(sal_Int32 n)3080 void VCLXScrollBar::setValue( sal_Int32 n )
3081 {
3082 ::vos::OGuard aGuard( GetMutex() );
3083
3084 ScrollBar* pScrollBar = (ScrollBar*) GetWindow();
3085 if ( pScrollBar )
3086 pScrollBar->DoScroll( n );
3087 }
3088
setValues(sal_Int32 nValue,sal_Int32 nVisible,sal_Int32 nMax)3089 void VCLXScrollBar::setValues( sal_Int32 nValue, sal_Int32 nVisible, sal_Int32 nMax )
3090 {
3091 ::vos::OGuard aGuard( GetMutex() );
3092
3093 ScrollBar* pScrollBar = (ScrollBar*) GetWindow();
3094 if ( pScrollBar )
3095 {
3096 pScrollBar->SetVisibleSize( nVisible );
3097 pScrollBar->SetRangeMax( nMax );
3098 pScrollBar->DoScroll( nValue );
3099 }
3100 }
3101
getValue()3102 sal_Int32 VCLXScrollBar::getValue()
3103 {
3104 ::vos::OGuard aGuard( GetMutex() );
3105
3106 ScrollBar* pScrollBar = (ScrollBar*) GetWindow();
3107 return pScrollBar ? pScrollBar->GetThumbPos() : 0;
3108 }
3109
setMaximum(sal_Int32 n)3110 void VCLXScrollBar::setMaximum( sal_Int32 n )
3111 {
3112 ::vos::OGuard aGuard( GetMutex() );
3113
3114 ScrollBar* pScrollBar = (ScrollBar*) GetWindow();
3115 if ( pScrollBar )
3116 pScrollBar->SetRangeMax( n );
3117 }
3118
getMaximum()3119 sal_Int32 VCLXScrollBar::getMaximum()
3120 {
3121 ::vos::OGuard aGuard( GetMutex() );
3122
3123 ScrollBar* pScrollBar = (ScrollBar*) GetWindow();
3124 return pScrollBar ? pScrollBar->GetRangeMax() : 0;
3125 }
3126
setMinimum(sal_Int32 n)3127 void VCLXScrollBar::setMinimum( sal_Int32 n )
3128 {
3129 ::vos::OGuard aGuard( GetMutex() );
3130
3131 ScrollBar* pScrollBar = static_cast< ScrollBar* >( GetWindow() );
3132 if ( pScrollBar )
3133 pScrollBar->SetRangeMin( n );
3134 }
3135
getMinimum()3136 sal_Int32 VCLXScrollBar::getMinimum()
3137 {
3138 ::vos::OGuard aGuard( GetMutex() );
3139
3140 ScrollBar* pScrollBar = static_cast< ScrollBar* >( GetWindow() );
3141 return pScrollBar ? pScrollBar->GetRangeMin() : 0;
3142 }
3143
setLineIncrement(sal_Int32 n)3144 void VCLXScrollBar::setLineIncrement( sal_Int32 n )
3145 {
3146 ::vos::OGuard aGuard( GetMutex() );
3147
3148 ScrollBar* pScrollBar = (ScrollBar*) GetWindow();
3149 if ( pScrollBar )
3150 pScrollBar->SetLineSize( n );
3151 }
3152
getLineIncrement()3153 sal_Int32 VCLXScrollBar::getLineIncrement()
3154 {
3155 ::vos::OGuard aGuard( GetMutex() );
3156
3157 ScrollBar* pScrollBar = (ScrollBar*) GetWindow();
3158 return pScrollBar ? pScrollBar->GetLineSize() : 0;
3159 }
3160
setBlockIncrement(sal_Int32 n)3161 void VCLXScrollBar::setBlockIncrement( sal_Int32 n )
3162 {
3163 ::vos::OGuard aGuard( GetMutex() );
3164
3165 ScrollBar* pScrollBar = (ScrollBar*) GetWindow();
3166 if ( pScrollBar )
3167 pScrollBar->SetPageSize( n );
3168 }
3169
getBlockIncrement()3170 sal_Int32 VCLXScrollBar::getBlockIncrement()
3171 {
3172 ::vos::OGuard aGuard( GetMutex() );
3173
3174 ScrollBar* pScrollBar = (ScrollBar*) GetWindow();
3175 return pScrollBar ? pScrollBar->GetPageSize() : 0;
3176 }
3177
setVisibleSize(sal_Int32 n)3178 void VCLXScrollBar::setVisibleSize( sal_Int32 n )
3179 {
3180 ::vos::OGuard aGuard( GetMutex() );
3181
3182 ScrollBar* pScrollBar = (ScrollBar*) GetWindow();
3183 if ( pScrollBar )
3184 pScrollBar->SetVisibleSize( n );
3185 }
3186
getVisibleSize()3187 sal_Int32 VCLXScrollBar::getVisibleSize()
3188 {
3189 ::vos::OGuard aGuard( GetMutex() );
3190
3191 ScrollBar* pScrollBar = (ScrollBar*) GetWindow();
3192 return pScrollBar ? pScrollBar->GetVisibleSize() : 0;
3193 }
3194
setOrientation(sal_Int32 n)3195 void VCLXScrollBar::setOrientation( sal_Int32 n )
3196 {
3197 ::vos::OGuard aGuard( GetMutex() );
3198
3199 Window* pWindow = GetWindow();
3200 if ( pWindow )
3201 {
3202 WinBits nStyle = pWindow->GetStyle();
3203 nStyle &= ~(WB_HORZ|WB_VERT);
3204 if ( n == ::com::sun::star::awt::ScrollBarOrientation::HORIZONTAL )
3205 nStyle |= WB_HORZ;
3206 else
3207 nStyle |= WB_VERT;
3208
3209 pWindow->SetStyle( nStyle );
3210 pWindow->Resize();
3211 }
3212 }
3213
getOrientation()3214 sal_Int32 VCLXScrollBar::getOrientation()
3215 {
3216 ::vos::OGuard aGuard( GetMutex() );
3217
3218 sal_Int32 n = 0;
3219 Window* pWindow = GetWindow();
3220 if ( pWindow )
3221 {
3222 WinBits nStyle = pWindow->GetStyle();
3223 if ( nStyle & WB_HORZ )
3224 n = ::com::sun::star::awt::ScrollBarOrientation::HORIZONTAL;
3225 else
3226 n = ::com::sun::star::awt::ScrollBarOrientation::VERTICAL;
3227 }
3228 return n;
3229
3230 }
3231
3232 // ::com::sun::star::awt::VclWindowPeer
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)3233 void VCLXScrollBar::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value)
3234 {
3235 ::vos::OGuard aGuard( GetMutex() );
3236
3237 ScrollBar* pScrollBar = (ScrollBar*)GetWindow();
3238 if ( pScrollBar )
3239 {
3240 sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
3241
3242 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3243 switch ( nPropType )
3244 {
3245 case BASEPROPERTY_LIVE_SCROLL:
3246 {
3247 sal_Bool bDo = sal_False;
3248 if ( !bVoid )
3249 {
3250 OSL_VERIFY( Value >>= bDo );
3251 }
3252 AllSettings aSettings( pScrollBar->GetSettings() );
3253 StyleSettings aStyle( aSettings.GetStyleSettings() );
3254 sal_uLong nDragOptions = aStyle.GetDragFullOptions();
3255 if ( bDo )
3256 nDragOptions |= DRAGFULL_OPTION_SCROLL;
3257 else
3258 nDragOptions &= ~DRAGFULL_OPTION_SCROLL;
3259 aStyle.SetDragFullOptions( nDragOptions );
3260 aSettings.SetStyleSettings( aStyle );
3261 pScrollBar->SetSettings( aSettings );
3262 }
3263 break;
3264
3265 case BASEPROPERTY_SCROLLVALUE:
3266 {
3267 if ( !bVoid )
3268 {
3269 sal_Int32 n = 0;
3270 if ( Value >>= n )
3271 setValue( n );
3272 }
3273 }
3274 break;
3275 case BASEPROPERTY_SCROLLVALUE_MAX:
3276 case BASEPROPERTY_SCROLLVALUE_MIN:
3277 {
3278 if ( !bVoid )
3279 {
3280 sal_Int32 n = 0;
3281 if ( Value >>= n )
3282 {
3283 if ( nPropType == BASEPROPERTY_SCROLLVALUE_MAX )
3284 setMaximum( n );
3285 else
3286 setMinimum( n );
3287 }
3288 }
3289 }
3290 break;
3291 case BASEPROPERTY_LINEINCREMENT:
3292 {
3293 if ( !bVoid )
3294 {
3295 sal_Int32 n = 0;
3296 if ( Value >>= n )
3297 setLineIncrement( n );
3298 }
3299 }
3300 break;
3301 case BASEPROPERTY_BLOCKINCREMENT:
3302 {
3303 if ( !bVoid )
3304 {
3305 sal_Int32 n = 0;
3306 if ( Value >>= n )
3307 setBlockIncrement( n );
3308 }
3309 }
3310 break;
3311 case BASEPROPERTY_VISIBLESIZE:
3312 {
3313 if ( !bVoid )
3314 {
3315 sal_Int32 n = 0;
3316 if ( Value >>= n )
3317 setVisibleSize( n );
3318 }
3319 }
3320 break;
3321 case BASEPROPERTY_ORIENTATION:
3322 {
3323 if ( !bVoid )
3324 {
3325 sal_Int32 n = 0;
3326 if ( Value >>= n )
3327 setOrientation( n );
3328 }
3329 }
3330 break;
3331
3332 case BASEPROPERTY_BACKGROUNDCOLOR:
3333 {
3334 // the default implementation of the base class doesn't work here, since our
3335 // interpretation for this property is slightly different
3336 ::toolkit::setButtonLikeFaceColor( pScrollBar, Value);
3337 }
3338 break;
3339
3340 default:
3341 {
3342 VCLXWindow::setProperty( PropertyName, Value );
3343 }
3344 }
3345 }
3346 }
3347
getProperty(const::rtl::OUString & PropertyName)3348 ::com::sun::star::uno::Any VCLXScrollBar::getProperty( const ::rtl::OUString& PropertyName )
3349 {
3350 ::vos::OGuard aGuard( GetMutex() );
3351
3352 ::com::sun::star::uno::Any aProp;
3353 ScrollBar* pScrollBar = (ScrollBar*)GetWindow();
3354 if ( pScrollBar )
3355 {
3356 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3357
3358 switch ( nPropType )
3359 {
3360 case BASEPROPERTY_LIVE_SCROLL:
3361 {
3362 aProp <<= (sal_Bool)( 0 != ( pScrollBar->GetSettings().GetStyleSettings().GetDragFullOptions() & DRAGFULL_OPTION_SCROLL ) );
3363 }
3364 break;
3365 case BASEPROPERTY_SCROLLVALUE:
3366 {
3367 aProp <<= (sal_Int32) getValue();
3368 }
3369 break;
3370 case BASEPROPERTY_SCROLLVALUE_MAX:
3371 {
3372 aProp <<= (sal_Int32) getMaximum();
3373 }
3374 break;
3375 case BASEPROPERTY_SCROLLVALUE_MIN:
3376 {
3377 aProp <<= (sal_Int32) getMinimum();
3378 }
3379 break;
3380 case BASEPROPERTY_LINEINCREMENT:
3381 {
3382 aProp <<= (sal_Int32) getLineIncrement();
3383 }
3384 break;
3385 case BASEPROPERTY_BLOCKINCREMENT:
3386 {
3387 aProp <<= (sal_Int32) getBlockIncrement();
3388 }
3389 break;
3390 case BASEPROPERTY_VISIBLESIZE:
3391 {
3392 aProp <<= (sal_Int32) getVisibleSize();
3393 }
3394 break;
3395 case BASEPROPERTY_ORIENTATION:
3396 {
3397 aProp <<= (sal_Int32) getOrientation();
3398 }
3399 break;
3400 case BASEPROPERTY_BACKGROUNDCOLOR:
3401 {
3402 // the default implementation of the base class doesn't work here, since our
3403 // interpretation for this property is slightly different
3404 aProp = ::toolkit::getButtonLikeFaceColor( pScrollBar );
3405 }
3406 break;
3407
3408 default:
3409 {
3410 aProp <<= VCLXWindow::getProperty( PropertyName );
3411 }
3412 }
3413 }
3414 return aProp;
3415 }
3416
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)3417 void VCLXScrollBar::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
3418 {
3419 switch ( rVclWindowEvent.GetId() )
3420 {
3421 case VCLEVENT_SCROLLBAR_SCROLL:
3422 {
3423 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
3424 // since we call listeners below, there is a potential that we will be destroyed
3425 // in during the listener call. To prevent the resulting crashs, we keep us
3426 // alive as long as we're here
3427 // #20178# - 2003-10-01 - fs@openoffice.org
3428
3429 if ( maAdjustmentListeners.getLength() )
3430 {
3431 ScrollBar* pScrollBar = (ScrollBar*)GetWindow();
3432
3433 if( pScrollBar )
3434 {
3435 ::com::sun::star::awt::AdjustmentEvent aEvent;
3436 aEvent.Source = (::cppu::OWeakObject*)this;
3437 aEvent.Value = pScrollBar->GetThumbPos();
3438
3439 // set adjustment type
3440 ScrollType aType = pScrollBar->GetType();
3441 if ( aType == SCROLL_LINEUP || aType == SCROLL_LINEDOWN )
3442 {
3443 aEvent.Type = ::com::sun::star::awt::AdjustmentType_ADJUST_LINE;
3444 }
3445 else if ( aType == SCROLL_PAGEUP || aType == SCROLL_PAGEDOWN )
3446 {
3447 aEvent.Type = ::com::sun::star::awt::AdjustmentType_ADJUST_PAGE;
3448 }
3449 else if ( aType == SCROLL_DRAG )
3450 {
3451 aEvent.Type = ::com::sun::star::awt::AdjustmentType_ADJUST_ABS;
3452 }
3453
3454 maAdjustmentListeners.adjustmentValueChanged( aEvent );
3455 }
3456 }
3457 }
3458 break;
3459
3460 default:
3461 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
3462 break;
3463 }
3464 }
3465
implGetMinimumSize(Window * p)3466 ::com::sun::star::awt::Size SAL_CALL VCLXScrollBar::implGetMinimumSize( Window* p )
3467 {
3468 long n = p->GetSettings().GetStyleSettings().GetScrollBarSize();
3469 return ::com::sun::star::awt::Size( n, n );
3470 }
3471
getMinimumSize()3472 ::com::sun::star::awt::Size SAL_CALL VCLXScrollBar::getMinimumSize()
3473 {
3474 ::vos::OGuard aGuard( GetMutex() );
3475 return implGetMinimumSize( GetWindow() );
3476 }
3477
3478
3479 // ----------------------------------------------------
3480 // class VCLXEdit
3481 // ----------------------------------------------------
3482
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)3483 void VCLXEdit::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
3484 {
3485 PushPropertyIds( rIds,
3486 BASEPROPERTY_ALIGN,
3487 BASEPROPERTY_BACKGROUNDCOLOR,
3488 BASEPROPERTY_BORDER,
3489 BASEPROPERTY_BORDERCOLOR,
3490 BASEPROPERTY_DEFAULTCONTROL,
3491 BASEPROPERTY_ECHOCHAR,
3492 BASEPROPERTY_ENABLED,
3493 BASEPROPERTY_ENABLEVISIBLE,
3494 BASEPROPERTY_FONTDESCRIPTOR,
3495 BASEPROPERTY_HARDLINEBREAKS,
3496 BASEPROPERTY_HELPTEXT,
3497 BASEPROPERTY_HELPURL,
3498 BASEPROPERTY_HSCROLL,
3499 BASEPROPERTY_LINE_END_FORMAT,
3500 BASEPROPERTY_MAXTEXTLEN,
3501 BASEPROPERTY_MULTILINE,
3502 BASEPROPERTY_PRINTABLE,
3503 BASEPROPERTY_READONLY,
3504 BASEPROPERTY_TABSTOP,
3505 BASEPROPERTY_TEXT,
3506 BASEPROPERTY_VSCROLL,
3507 BASEPROPERTY_HIDEINACTIVESELECTION,
3508 BASEPROPERTY_PAINTTRANSPARENT,
3509 BASEPROPERTY_AUTOHSCROLL,
3510 BASEPROPERTY_AUTOVSCROLL,
3511 BASEPROPERTY_VERTICALALIGN,
3512 BASEPROPERTY_WRITING_MODE,
3513 BASEPROPERTY_CONTEXT_WRITING_MODE,
3514 0);
3515 VCLXWindow::ImplGetPropertyIds( rIds );
3516 }
3517
VCLXEdit()3518 VCLXEdit::VCLXEdit() : maTextListeners( *this )
3519 {
3520 }
3521
3522 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)3523 ::com::sun::star::uno::Any VCLXEdit::queryInterface( const ::com::sun::star::uno::Type & rType )
3524 {
3525 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
3526 SAL_STATIC_CAST( ::com::sun::star::awt::XTextComponent*, this ),
3527 SAL_STATIC_CAST( ::com::sun::star::awt::XTextEditField*, this ),
3528 SAL_STATIC_CAST( ::com::sun::star::awt::XTextLayoutConstrains*, this ) );
3529 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
3530 }
3531
3532 // ::com::sun::star::lang::XTypeProvider
3533 IMPL_XTYPEPROVIDER_START( VCLXEdit )
3534 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent>* ) NULL ),
3535 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextEditField>* ) NULL ),
3536 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextLayoutConstrains>* ) NULL ),
3537 VCLXWindow::getTypes()
3538 IMPL_XTYPEPROVIDER_END
3539
3540 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXEdit::CreateAccessibleContext()
3541 {
3542 return getAccessibleFactory().createAccessibleContext( this );
3543 }
3544
dispose()3545 void VCLXEdit::dispose()
3546 {
3547 ::vos::OGuard aGuard( GetMutex() );
3548
3549 ::com::sun::star::lang::EventObject aObj;
3550 aObj.Source = (::cppu::OWeakObject*)this;
3551 maTextListeners.disposeAndClear( aObj );
3552 VCLXWindow::dispose();
3553 }
3554
addTextListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XTextListener> & l)3555 void VCLXEdit::addTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l )
3556 {
3557 ::vos::OGuard aGuard( GetMutex() );
3558 GetTextListeners().addInterface( l );
3559 }
3560
removeTextListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XTextListener> & l)3561 void VCLXEdit::removeTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l )
3562 {
3563 ::vos::OGuard aGuard( GetMutex() );
3564 GetTextListeners().removeInterface( l );
3565 }
3566
setText(const::rtl::OUString & aText)3567 void VCLXEdit::setText( const ::rtl::OUString& aText )
3568 {
3569 ::vos::OGuard aGuard( GetMutex() );
3570
3571 Edit* pEdit = (Edit*)GetWindow();
3572 if ( pEdit )
3573 {
3574 pEdit->SetText( aText );
3575
3576 // #107218# Call same listeners like VCL would do after user interaction
3577 SetSynthesizingVCLEvent( sal_True );
3578 pEdit->SetModifyFlag();
3579 pEdit->Modify();
3580 SetSynthesizingVCLEvent( sal_False );
3581 }
3582 }
3583
insertText(const::com::sun::star::awt::Selection & rSel,const::rtl::OUString & aText)3584 void VCLXEdit::insertText( const ::com::sun::star::awt::Selection& rSel, const ::rtl::OUString& aText )
3585 {
3586 ::vos::OGuard aGuard( GetMutex() );
3587
3588 Edit* pEdit = (Edit*)GetWindow();
3589 if ( pEdit )
3590 {
3591 pEdit->SetSelection( Selection( rSel.Min, rSel.Max ) );
3592 pEdit->ReplaceSelected( aText );
3593
3594 // #107218# Call same listeners like VCL would do after user interaction
3595 SetSynthesizingVCLEvent( sal_True );
3596 pEdit->SetModifyFlag();
3597 pEdit->Modify();
3598 SetSynthesizingVCLEvent( sal_False );
3599 }
3600 }
3601
getText()3602 ::rtl::OUString VCLXEdit::getText()
3603 {
3604 ::vos::OGuard aGuard( GetMutex() );
3605
3606 ::rtl::OUString aText;
3607 Window* pWindow = GetWindow();
3608 if ( pWindow )
3609 aText = pWindow->GetText();
3610 return aText;
3611 }
3612
getSelectedText()3613 ::rtl::OUString VCLXEdit::getSelectedText()
3614 {
3615 ::vos::OGuard aGuard( GetMutex() );
3616
3617 ::rtl::OUString aText;
3618 Edit* pEdit = (Edit*) GetWindow();
3619 if ( pEdit)
3620 aText = pEdit->GetSelected();
3621 return aText;
3622
3623 }
3624
setSelection(const::com::sun::star::awt::Selection & aSelection)3625 void VCLXEdit::setSelection( const ::com::sun::star::awt::Selection& aSelection )
3626 {
3627 ::vos::OGuard aGuard( GetMutex() );
3628
3629 Edit* pEdit = (Edit*) GetWindow();
3630 if ( pEdit )
3631 pEdit->SetSelection( Selection( aSelection.Min, aSelection.Max ) );
3632 }
3633
getSelection()3634 ::com::sun::star::awt::Selection VCLXEdit::getSelection()
3635 {
3636 ::vos::OGuard aGuard( GetMutex() );
3637
3638 Selection aSel;
3639 Edit* pEdit = (Edit*) GetWindow();
3640 if ( pEdit )
3641 aSel = pEdit->GetSelection();
3642 return ::com::sun::star::awt::Selection( aSel.Min(), aSel.Max() );
3643 }
3644
isEditable()3645 sal_Bool VCLXEdit::isEditable()
3646 {
3647 ::vos::OGuard aGuard( GetMutex() );
3648
3649 Edit* pEdit = (Edit*) GetWindow();
3650 return ( pEdit && !pEdit->IsReadOnly() && pEdit->IsEnabled() ) ? sal_True : sal_False;
3651 }
3652
setEditable(sal_Bool bEditable)3653 void VCLXEdit::setEditable( sal_Bool bEditable )
3654 {
3655 ::vos::OGuard aGuard( GetMutex() );
3656
3657 Edit* pEdit = (Edit*) GetWindow();
3658 if ( pEdit )
3659 pEdit->SetReadOnly( !bEditable );
3660 }
3661
3662
setMaxTextLen(sal_Int16 nLen)3663 void VCLXEdit::setMaxTextLen( sal_Int16 nLen )
3664 {
3665 ::vos::OGuard aGuard( GetMutex() );
3666
3667 Edit* pEdit = (Edit*) GetWindow();
3668 if ( pEdit )
3669 pEdit->SetMaxTextLen( nLen );
3670 }
3671
getMaxTextLen()3672 sal_Int16 VCLXEdit::getMaxTextLen()
3673 {
3674 ::vos::OGuard aGuard( GetMutex() );
3675
3676 Edit* pEdit = (Edit*) GetWindow();
3677 return pEdit ? pEdit->GetMaxTextLen() : 0;
3678 }
3679
setEchoChar(sal_Unicode cEcho)3680 void VCLXEdit::setEchoChar( sal_Unicode cEcho )
3681 {
3682 ::vos::OGuard aGuard( GetMutex() );
3683
3684 Edit* pEdit = (Edit*) GetWindow();
3685 if ( pEdit )
3686 pEdit->SetEchoChar( cEcho );
3687 }
3688
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)3689 void VCLXEdit::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value)
3690 {
3691 ::vos::OGuard aGuard( GetMutex() );
3692
3693 Edit* pEdit = (Edit*)GetWindow();
3694 if ( pEdit )
3695 {
3696 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3697 switch ( nPropType )
3698 {
3699 case BASEPROPERTY_HIDEINACTIVESELECTION:
3700 ::toolkit::adjustBooleanWindowStyle( Value, pEdit, WB_NOHIDESELECTION, sal_True );
3701 if ( pEdit->GetSubEdit() )
3702 ::toolkit::adjustBooleanWindowStyle( Value, pEdit->GetSubEdit(), WB_NOHIDESELECTION, sal_True );
3703 break;
3704
3705 case BASEPROPERTY_READONLY:
3706 {
3707 sal_Bool b = sal_Bool();
3708 if ( Value >>= b )
3709 pEdit->SetReadOnly( b );
3710 }
3711 break;
3712 case BASEPROPERTY_ECHOCHAR:
3713 {
3714 sal_Int16 n = sal_Int16();
3715 if ( Value >>= n )
3716 pEdit->SetEchoChar( n );
3717 }
3718 break;
3719 case BASEPROPERTY_MAXTEXTLEN:
3720 {
3721 sal_Int16 n = sal_Int16();
3722 if ( Value >>= n )
3723 pEdit->SetMaxTextLen( n );
3724 }
3725 break;
3726 default:
3727 {
3728 VCLXWindow::setProperty( PropertyName, Value );
3729 }
3730 }
3731 }
3732 }
3733
getProperty(const::rtl::OUString & PropertyName)3734 ::com::sun::star::uno::Any VCLXEdit::getProperty( const ::rtl::OUString& PropertyName )
3735 {
3736 ::vos::OGuard aGuard( GetMutex() );
3737
3738 ::com::sun::star::uno::Any aProp;
3739 Edit* pEdit = (Edit*)GetWindow();
3740 if ( pEdit )
3741 {
3742 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3743 switch ( nPropType )
3744 {
3745 case BASEPROPERTY_HIDEINACTIVESELECTION:
3746 aProp <<= (sal_Bool)( ( pEdit->GetStyle() & WB_NOHIDESELECTION ) == 0 );
3747 break;
3748 case BASEPROPERTY_READONLY:
3749 aProp <<= (sal_Bool) pEdit->IsReadOnly();
3750 break;
3751 case BASEPROPERTY_ECHOCHAR:
3752 aProp <<= (sal_Int16) pEdit->GetEchoChar();
3753 break;
3754 case BASEPROPERTY_MAXTEXTLEN:
3755 aProp <<= (sal_Int16) pEdit->GetMaxTextLen();
3756 break;
3757 default:
3758 {
3759 aProp = VCLXWindow::getProperty( PropertyName );
3760 }
3761 }
3762 }
3763 return aProp;
3764 }
3765
getMinimumSize()3766 ::com::sun::star::awt::Size VCLXEdit::getMinimumSize( )
3767 {
3768 ::vos::OGuard aGuard( GetMutex() );
3769
3770 Size aSz;
3771 Edit* pEdit = (Edit*) GetWindow();
3772 if ( pEdit )
3773 aSz = pEdit->CalcMinimumSize();
3774 return AWTSize(aSz);
3775 }
3776
getPreferredSize()3777 ::com::sun::star::awt::Size VCLXEdit::getPreferredSize( )
3778 {
3779 ::vos::OGuard aGuard( GetMutex() );
3780
3781 Size aSz;
3782 Edit* pEdit = (Edit*) GetWindow();
3783 if ( pEdit )
3784 {
3785 aSz = pEdit->CalcMinimumSize();
3786 aSz.Height() += 4;
3787 }
3788 return AWTSize(aSz);
3789 }
3790
calcAdjustedSize(const::com::sun::star::awt::Size & rNewSize)3791 ::com::sun::star::awt::Size VCLXEdit::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize )
3792 {
3793 ::vos::OGuard aGuard( GetMutex() );
3794
3795 ::com::sun::star::awt::Size aSz = rNewSize;
3796 ::com::sun::star::awt::Size aMinSz = getMinimumSize();
3797 if ( aSz.Height != aMinSz.Height )
3798 aSz.Height = aMinSz.Height;
3799
3800 return aSz;
3801 }
3802
getMinimumSize(sal_Int16 nCols,sal_Int16)3803 ::com::sun::star::awt::Size VCLXEdit::getMinimumSize( sal_Int16 nCols, sal_Int16 )
3804 {
3805 ::vos::OGuard aGuard( GetMutex() );
3806
3807 Size aSz;
3808 Edit* pEdit = (Edit*) GetWindow();
3809 if ( pEdit )
3810 {
3811 if ( nCols )
3812 aSz = pEdit->CalcSize( nCols );
3813 else
3814 aSz = pEdit->CalcMinimumSize();
3815 }
3816 return AWTSize(aSz);
3817 }
3818
getColumnsAndLines(sal_Int16 & nCols,sal_Int16 & nLines)3819 void VCLXEdit::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines )
3820 {
3821 ::vos::OGuard aGuard( GetMutex() );
3822
3823 nLines = 1;
3824 nCols = 0;
3825 Edit* pEdit = (Edit*) GetWindow();
3826 if ( pEdit )
3827 nCols = pEdit->GetMaxVisChars();
3828 }
3829
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)3830 void VCLXEdit::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
3831 {
3832 switch ( rVclWindowEvent.GetId() )
3833 {
3834 case VCLEVENT_EDIT_MODIFY:
3835 {
3836 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
3837 // since we call listeners below, there is a potential that we will be destroyed
3838 // during the listener call. To prevent the resulting crashs, we keep us
3839 // alive as long as we're here
3840 // #20178# - 2003-10-01 - fs@openoffice.org
3841
3842 if ( GetTextListeners().getLength() )
3843 {
3844 ::com::sun::star::awt::TextEvent aEvent;
3845 aEvent.Source = (::cppu::OWeakObject*)this;
3846 GetTextListeners().textChanged( aEvent );
3847 }
3848 }
3849 break;
3850
3851 default:
3852 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
3853 break;
3854 }
3855 }
3856
3857 // ----------------------------------------------------
3858 // class VCLXComboBox
3859 // ----------------------------------------------------
3860
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)3861 void VCLXComboBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
3862 {
3863 PushPropertyIds( rIds,
3864 BASEPROPERTY_AUTOCOMPLETE,
3865 BASEPROPERTY_BACKGROUNDCOLOR,
3866 BASEPROPERTY_BORDER,
3867 BASEPROPERTY_BORDERCOLOR,
3868 BASEPROPERTY_DEFAULTCONTROL,
3869 BASEPROPERTY_DROPDOWN,
3870 BASEPROPERTY_ENABLED,
3871 BASEPROPERTY_ENABLEVISIBLE,
3872 BASEPROPERTY_FONTDESCRIPTOR,
3873 BASEPROPERTY_HELPTEXT,
3874 BASEPROPERTY_HELPURL,
3875 BASEPROPERTY_LINECOUNT,
3876 BASEPROPERTY_MAXTEXTLEN,
3877 BASEPROPERTY_PRINTABLE,
3878 BASEPROPERTY_READONLY,
3879 BASEPROPERTY_STRINGITEMLIST,
3880 BASEPROPERTY_TABSTOP,
3881 BASEPROPERTY_TEXT,
3882 BASEPROPERTY_HIDEINACTIVESELECTION,
3883 BASEPROPERTY_ALIGN,
3884 BASEPROPERTY_WRITING_MODE,
3885 BASEPROPERTY_CONTEXT_WRITING_MODE,
3886 BASEPROPERTY_REFERENCE_DEVICE,
3887 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
3888 0);
3889 // no, don't call VCLXEdit here - it has properties which we do *not* want to have at at combo box
3890 // #i92690# / 2008-08-12 / frank.schoenheit@sun.com
3891 // VCLXEdit::ImplGetPropertyIds( rIds );
3892 VCLXWindow::ImplGetPropertyIds( rIds );
3893 }
3894
VCLXComboBox()3895 VCLXComboBox::VCLXComboBox()
3896 : maActionListeners( *this ), maItemListeners( *this )
3897 {
3898 }
3899
~VCLXComboBox()3900 VCLXComboBox::~VCLXComboBox()
3901 {
3902 #ifndef __SUNPRO_CC
3903 OSL_TRACE ("%s", __FUNCTION__);
3904 #endif
3905 }
3906
CreateAccessibleContext()3907 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXComboBox::CreateAccessibleContext()
3908 {
3909 ::vos::OGuard aGuard( GetMutex() );
3910
3911 return getAccessibleFactory().createAccessibleContext( this );
3912 }
3913
dispose()3914 void VCLXComboBox::dispose()
3915 {
3916 ::vos::OGuard aGuard( GetMutex() );
3917
3918 ::com::sun::star::lang::EventObject aObj;
3919 aObj.Source = (::cppu::OWeakObject*)this;
3920 maItemListeners.disposeAndClear( aObj );
3921 maActionListeners.disposeAndClear( aObj );
3922 VCLXEdit::dispose();
3923 }
3924
3925
addItemListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XItemListener> & l)3926 void VCLXComboBox::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l )
3927 {
3928 ::vos::OGuard aGuard( GetMutex() );
3929 maItemListeners.addInterface( l );
3930 }
3931
removeItemListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XItemListener> & l)3932 void VCLXComboBox::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener > & l )
3933 {
3934 ::vos::OGuard aGuard( GetMutex() );
3935 maItemListeners.removeInterface( l );
3936 }
3937
addActionListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XActionListener> & l)3938 void VCLXComboBox::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )
3939 {
3940 ::vos::OGuard aGuard( GetMutex() );
3941 maActionListeners.addInterface( l );
3942 }
3943
removeActionListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XActionListener> & l)3944 void VCLXComboBox::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )
3945 {
3946 ::vos::OGuard aGuard( GetMutex() );
3947 maActionListeners.removeInterface( l );
3948 }
3949
addItem(const::rtl::OUString & aItem,sal_Int16 nPos)3950 void VCLXComboBox::addItem( const ::rtl::OUString& aItem, sal_Int16 nPos )
3951 {
3952 ::vos::OGuard aGuard( GetMutex() );
3953
3954 ComboBox* pBox = (ComboBox*) GetWindow();
3955 if ( pBox )
3956 pBox->InsertEntry( aItem, nPos );
3957 }
3958
addItems(const::com::sun::star::uno::Sequence<::rtl::OUString> & aItems,sal_Int16 nPos)3959 void VCLXComboBox::addItems( const ::com::sun::star::uno::Sequence< ::rtl::OUString>& aItems, sal_Int16 nPos )
3960 {
3961 ::vos::OGuard aGuard( GetMutex() );
3962
3963 ComboBox* pBox = (ComboBox*) GetWindow();
3964 if ( pBox )
3965 {
3966 sal_uInt16 nP = nPos;
3967 for ( sal_uInt16 n = 0; n < aItems.getLength(); n++ )
3968 {
3969 pBox->InsertEntry( aItems.getConstArray()[n], nP );
3970 if ( nP == 0xFFFF )
3971 {
3972 OSL_ENSURE( false, "VCLXComboBox::addItems: too many entries!" );
3973 // skip remaining entries, list cannot hold them, anyway
3974 break;
3975 }
3976 }
3977 }
3978 }
3979
removeItems(sal_Int16 nPos,sal_Int16 nCount)3980 void VCLXComboBox::removeItems( sal_Int16 nPos, sal_Int16 nCount )
3981 {
3982 ::vos::OGuard aGuard( GetMutex() );
3983
3984 ComboBox* pBox = (ComboBox*) GetWindow();
3985 if ( pBox )
3986 {
3987 for ( sal_uInt16 n = nCount; n; )
3988 pBox->RemoveEntry( nPos + (--n) );
3989 }
3990 }
3991
getItemCount()3992 sal_Int16 VCLXComboBox::getItemCount()
3993 {
3994 ::vos::OGuard aGuard( GetMutex() );
3995
3996 ComboBox* pBox = (ComboBox*) GetWindow();
3997 return pBox ? pBox->GetEntryCount() : 0;
3998 }
3999
getItem(sal_Int16 nPos)4000 ::rtl::OUString VCLXComboBox::getItem( sal_Int16 nPos )
4001 {
4002 ::vos::OGuard aGuard( GetMutex() );
4003
4004 ::rtl::OUString aItem;
4005 ComboBox* pBox = (ComboBox*) GetWindow();
4006 if ( pBox )
4007 aItem = pBox->GetEntry( nPos );
4008 return aItem;
4009 }
4010
getItems()4011 ::com::sun::star::uno::Sequence< ::rtl::OUString> VCLXComboBox::getItems()
4012 {
4013 ::vos::OGuard aGuard( GetMutex() );
4014
4015 ::com::sun::star::uno::Sequence< ::rtl::OUString> aSeq;
4016 ComboBox* pBox = (ComboBox*) GetWindow();
4017 if ( pBox )
4018 {
4019 sal_uInt16 nEntries = pBox->GetEntryCount();
4020 aSeq = ::com::sun::star::uno::Sequence< ::rtl::OUString>( nEntries );
4021 for ( sal_uInt16 n = nEntries; n; )
4022 {
4023 --n;
4024 aSeq.getArray()[n] = pBox->GetEntry( n );
4025 }
4026 }
4027 return aSeq;
4028 }
4029
setDropDownLineCount(sal_Int16 nLines)4030 void VCLXComboBox::setDropDownLineCount( sal_Int16 nLines )
4031 {
4032 ::vos::OGuard aGuard( GetMutex() );
4033
4034 ComboBox* pBox = (ComboBox*) GetWindow();
4035 if ( pBox )
4036 pBox->SetDropDownLineCount( nLines );
4037 }
4038
getDropDownLineCount()4039 sal_Int16 VCLXComboBox::getDropDownLineCount()
4040 {
4041 ::vos::OGuard aGuard( GetMutex() );
4042
4043 sal_Int16 nLines = 0;
4044 ComboBox* pBox = (ComboBox*) GetWindow();
4045 if ( pBox )
4046 nLines = pBox->GetDropDownLineCount();
4047 return nLines;
4048 }
4049
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)4050 void VCLXComboBox::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value)
4051 {
4052 ::vos::OGuard aGuard( GetMutex() );
4053
4054 ComboBox* pComboBox = (ComboBox*)GetWindow();
4055 if ( pComboBox )
4056 {
4057 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4058 switch ( nPropType )
4059 {
4060 case BASEPROPERTY_LINECOUNT:
4061 {
4062 sal_Int16 n = sal_Int16();
4063 if ( Value >>= n )
4064 pComboBox->SetDropDownLineCount( n );
4065 }
4066 break;
4067 case BASEPROPERTY_AUTOCOMPLETE:
4068 {
4069 sal_Int16 n = sal_Int16();
4070 if ( Value >>= n )
4071 pComboBox->EnableAutocomplete( n != 0 );
4072 else
4073 {
4074 sal_Bool b = sal_Bool();
4075 if ( Value >>= b )
4076 pComboBox->EnableAutocomplete( b );
4077 }
4078 }
4079 break;
4080 case BASEPROPERTY_STRINGITEMLIST:
4081 {
4082 ::com::sun::star::uno::Sequence< ::rtl::OUString> aItems;
4083 if ( Value >>= aItems )
4084 {
4085 pComboBox->Clear();
4086 addItems( aItems, 0 );
4087 }
4088 }
4089 break;
4090 default:
4091 {
4092 VCLXEdit::setProperty( PropertyName, Value );
4093
4094 // #109385# SetBorderStyle is not virtual
4095 if ( nPropType == BASEPROPERTY_BORDER )
4096 {
4097 sal_uInt16 nBorder = sal_uInt16();
4098 if ( (Value >>= nBorder) && nBorder != 0 )
4099 pComboBox->SetBorderStyle( nBorder );
4100 }
4101 }
4102 }
4103 }
4104 }
4105
getProperty(const::rtl::OUString & PropertyName)4106 ::com::sun::star::uno::Any VCLXComboBox::getProperty( const ::rtl::OUString& PropertyName )
4107 {
4108 ::vos::OGuard aGuard( GetMutex() );
4109
4110 ::com::sun::star::uno::Any aProp;
4111 ComboBox* pComboBox = (ComboBox*)GetWindow();
4112 if ( pComboBox )
4113 {
4114 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4115 switch ( nPropType )
4116 {
4117 case BASEPROPERTY_LINECOUNT:
4118 {
4119 aProp <<= (sal_Int16) pComboBox->GetDropDownLineCount();
4120 }
4121 break;
4122 case BASEPROPERTY_AUTOCOMPLETE:
4123 {
4124 aProp <<= (sal_Bool) pComboBox->IsAutocompleteEnabled();
4125 }
4126 break;
4127 case BASEPROPERTY_STRINGITEMLIST:
4128 {
4129 sal_uInt16 nItems = pComboBox->GetEntryCount();
4130 ::com::sun::star::uno::Sequence< ::rtl::OUString> aSeq( nItems );
4131 ::rtl::OUString* pStrings = aSeq.getArray();
4132 for ( sal_uInt16 n = 0; n < nItems; n++ )
4133 pStrings[n] = pComboBox->GetEntry( n );
4134 aProp <<= aSeq;
4135
4136 }
4137 break;
4138 default:
4139 {
4140 aProp <<= VCLXEdit::getProperty( PropertyName );
4141 }
4142 }
4143 }
4144 return aProp;
4145 }
4146
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)4147 void VCLXComboBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
4148 {
4149 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
4150 // since we call listeners below, there is a potential that we will be destroyed
4151 // during the listener call. To prevent the resulting crashs, we keep us
4152 // alive as long as we're here
4153 // #20178# - 2003-10-01 - fs@openoffice.org
4154
4155 switch ( rVclWindowEvent.GetId() )
4156 {
4157 case VCLEVENT_COMBOBOX_SELECT:
4158 if ( maItemListeners.getLength() )
4159 {
4160 ComboBox* pComboBox = (ComboBox*)GetWindow();
4161 if( pComboBox )
4162 {
4163 if ( !pComboBox->IsTravelSelect() )
4164 {
4165 ::com::sun::star::awt::ItemEvent aEvent;
4166 aEvent.Source = (::cppu::OWeakObject*)this;
4167 aEvent.Highlighted = sal_False;
4168
4169 // Bei Mehrfachselektion 0xFFFF, sonst die ID
4170 aEvent.Selected = pComboBox->GetEntryPos( pComboBox->GetText() );
4171
4172 maItemListeners.itemStateChanged( aEvent );
4173 }
4174 }
4175 }
4176 break;
4177
4178 case VCLEVENT_COMBOBOX_DOUBLECLICK:
4179 if ( maActionListeners.getLength() )
4180 {
4181 ::com::sun::star::awt::ActionEvent aEvent;
4182 aEvent.Source = (::cppu::OWeakObject*)this;
4183 // aEvent.ActionCommand = ...;
4184 maActionListeners.actionPerformed( aEvent );
4185 }
4186 break;
4187
4188 default:
4189 VCLXEdit::ProcessWindowEvent( rVclWindowEvent );
4190 break;
4191 }
4192 }
4193
getMinimumSize()4194 ::com::sun::star::awt::Size VCLXComboBox::getMinimumSize( )
4195 {
4196 ::vos::OGuard aGuard( GetMutex() );
4197
4198 Size aSz;
4199 ComboBox* pComboBox = (ComboBox*) GetWindow();
4200 if ( pComboBox )
4201 aSz = pComboBox->CalcMinimumSize();
4202 return AWTSize(aSz);
4203 }
4204
getPreferredSize()4205 ::com::sun::star::awt::Size VCLXComboBox::getPreferredSize( )
4206 {
4207 ::vos::OGuard aGuard( GetMutex() );
4208
4209 Size aSz;
4210 ComboBox* pComboBox = (ComboBox*) GetWindow();
4211 if ( pComboBox )
4212 {
4213 aSz = pComboBox->CalcMinimumSize();
4214 if ( pComboBox->GetStyle() & WB_DROPDOWN )
4215 aSz.Height() += 4;
4216 }
4217 return AWTSize(aSz);
4218 }
4219
calcAdjustedSize(const::com::sun::star::awt::Size & rNewSize)4220 ::com::sun::star::awt::Size VCLXComboBox::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize )
4221 {
4222 ::vos::OGuard aGuard( GetMutex() );
4223
4224 Size aSz = VCLSize(rNewSize);
4225 ComboBox* pComboBox = (ComboBox*) GetWindow();
4226 if ( pComboBox )
4227 aSz = pComboBox->CalcAdjustedSize( aSz );
4228 return AWTSize(aSz);
4229 }
4230
getMinimumSize(sal_Int16 nCols,sal_Int16 nLines)4231 ::com::sun::star::awt::Size VCLXComboBox::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines )
4232 {
4233 ::vos::OGuard aGuard( GetMutex() );
4234
4235 Size aSz;
4236 ComboBox* pComboBox = (ComboBox*) GetWindow();
4237 if ( pComboBox )
4238 aSz = pComboBox->CalcSize( nCols, nLines );
4239 return AWTSize(aSz);
4240 }
4241
getColumnsAndLines(sal_Int16 & nCols,sal_Int16 & nLines)4242 void VCLXComboBox::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines )
4243 {
4244 ::vos::OGuard aGuard( GetMutex() );
4245
4246 nCols = nLines = 0;
4247 ComboBox* pComboBox = (ComboBox*) GetWindow();
4248 if ( pComboBox )
4249 {
4250 sal_uInt16 nC, nL;
4251 pComboBox->GetMaxVisColumnsAndLines( nC, nL );
4252 nCols = nC;
4253 nLines = nL;
4254 }
4255 }
listItemInserted(const ItemListEvent & i_rEvent)4256 void SAL_CALL VCLXComboBox::listItemInserted( const ItemListEvent& i_rEvent )
4257 {
4258 ::vos::OGuard aGuard( GetMutex() );
4259
4260 ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() );
4261
4262 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemInserted: no ComboBox?!" );
4263 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition <= sal_Int32( pComboBox->GetEntryCount() ) ),
4264 "VCLXComboBox::listItemInserted: illegal (inconsistent) item position!" );
4265 pComboBox->InsertEntry(
4266 i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : ::rtl::OUString(),
4267 i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : Image(),
4268 i_rEvent.ItemPosition );
4269 }
4270
listItemRemoved(const ItemListEvent & i_rEvent)4271 void SAL_CALL VCLXComboBox::listItemRemoved( const ItemListEvent& i_rEvent )
4272 {
4273 ::vos::OGuard aGuard( GetMutex() );
4274
4275 ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() );
4276
4277 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemRemoved: no ComboBox?!" );
4278 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pComboBox->GetEntryCount() ) ),
4279 "VCLXComboBox::listItemRemoved: illegal (inconsistent) item position!" );
4280
4281 pComboBox->RemoveEntry( i_rEvent.ItemPosition );
4282 }
4283
listItemModified(const ItemListEvent & i_rEvent)4284 void SAL_CALL VCLXComboBox::listItemModified( const ItemListEvent& i_rEvent )
4285 {
4286 ::vos::OGuard aGuard( GetMutex() );
4287
4288 ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() );
4289
4290 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" );
4291 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pComboBox->GetEntryCount() ) ),
4292 "VCLXComboBox::listItemModified: illegal (inconsistent) item position!" );
4293
4294 // VCL's ComboBox does not support changing an entry's text or image, so remove and re-insert
4295
4296 const ::rtl::OUString sNewText = i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : ::rtl::OUString( pComboBox->GetEntry( i_rEvent.ItemPosition ) );
4297 const Image aNewImage( i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : pComboBox->GetEntryImage( i_rEvent.ItemPosition ) );
4298
4299 pComboBox->RemoveEntry( i_rEvent.ItemPosition );
4300 pComboBox->InsertEntry( sNewText, aNewImage, i_rEvent.ItemPosition );
4301 }
4302
allItemsRemoved(const EventObject & i_rEvent)4303 void SAL_CALL VCLXComboBox::allItemsRemoved( const EventObject& i_rEvent )
4304 {
4305 ::vos::OGuard aGuard( GetMutex() );
4306
4307 ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() );
4308 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" );
4309
4310 pComboBox->Clear();
4311
4312 (void)i_rEvent;
4313 }
4314
itemListChanged(const EventObject & i_rEvent)4315 void SAL_CALL VCLXComboBox::itemListChanged( const EventObject& i_rEvent )
4316 {
4317 ::vos::OGuard aGuard( GetMutex() );
4318
4319 ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() );
4320 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" );
4321
4322 pComboBox->Clear();
4323
4324 uno::Reference< beans::XPropertySet > xPropSet( i_rEvent.Source, uno::UNO_QUERY_THROW );
4325 uno::Reference< beans::XPropertySetInfo > xPSI( xPropSet->getPropertySetInfo(), uno::UNO_QUERY_THROW );
4326 // bool localize = xPSI->hasPropertyByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" ) ) );
4327 uno::Reference< resource::XStringResourceResolver > xStringResourceResolver;
4328 if ( xPSI->hasPropertyByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" ) ) ) )
4329 {
4330 xStringResourceResolver.set(
4331 xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" ) ) ),
4332 uno::UNO_QUERY
4333 );
4334 }
4335
4336
4337 Reference< XItemList > xItemList( i_rEvent.Source, uno::UNO_QUERY_THROW );
4338 uno::Sequence< beans::Pair< ::rtl::OUString, ::rtl::OUString > > aItems = xItemList->getAllItems();
4339 for ( sal_Int32 i=0; i<aItems.getLength(); ++i )
4340 {
4341 ::rtl::OUString aLocalizationKey( aItems[i].First );
4342 if ( xStringResourceResolver.is() && aLocalizationKey.getLength() != 0 && aLocalizationKey[0] == '&' )
4343 {
4344 aLocalizationKey = xStringResourceResolver->resolveString(aLocalizationKey.copy( 1 ));
4345 }
4346 pComboBox->InsertEntry( aLocalizationKey, lcl_getImageFromURL( aItems[i].Second ) );
4347 }
4348 }
disposing(const EventObject & i_rEvent)4349 void SAL_CALL VCLXComboBox::disposing( const EventObject& i_rEvent )
4350 {
4351 // just disambiguate
4352 VCLXEdit::disposing( i_rEvent );
4353 }
4354
4355 // ----------------------------------------------------
4356 // class VCLXFormattedSpinField
4357 // ----------------------------------------------------
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)4358 void VCLXFormattedSpinField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
4359 {
4360 // Interestingly in the UnoControl API this is
4361 // - not derived from XEdit ultimately, (correct ?) - so cut this here ...
4362 // VCLXSpinField::ImplGetPropertyIds( rIds );
4363 VCLXWindow::ImplGetPropertyIds( rIds );
4364 }
4365
VCLXFormattedSpinField()4366 VCLXFormattedSpinField::VCLXFormattedSpinField()
4367 {
4368 }
4369
~VCLXFormattedSpinField()4370 VCLXFormattedSpinField::~VCLXFormattedSpinField()
4371 {
4372 }
4373
setStrictFormat(sal_Bool bStrict)4374 void VCLXFormattedSpinField::setStrictFormat( sal_Bool bStrict )
4375 {
4376 ::vos::OGuard aGuard( GetMutex() );
4377
4378 FormatterBase* pFormatter = GetFormatter();
4379 if ( pFormatter )
4380 pFormatter->SetStrictFormat( bStrict );
4381 }
4382
isStrictFormat()4383 sal_Bool VCLXFormattedSpinField::isStrictFormat()
4384 {
4385 FormatterBase* pFormatter = GetFormatter();
4386 return pFormatter ? pFormatter->IsStrictFormat() : sal_False;
4387 }
4388
4389
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)4390 void VCLXFormattedSpinField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value)
4391 {
4392 ::vos::OGuard aGuard( GetMutex() );
4393
4394 FormatterBase* pFormatter = GetFormatter();
4395 if ( pFormatter )
4396 {
4397 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4398 switch ( nPropType )
4399 {
4400 case BASEPROPERTY_SPIN:
4401 {
4402 sal_Bool b = sal_Bool();
4403 if ( Value >>= b )
4404 {
4405 WinBits nStyle = GetWindow()->GetStyle() | WB_SPIN;
4406 if ( !b )
4407 nStyle &= ~WB_SPIN;
4408 GetWindow()->SetStyle( nStyle );
4409 }
4410 }
4411 break;
4412 case BASEPROPERTY_STRICTFORMAT:
4413 {
4414 sal_Bool b = sal_Bool();
4415 if ( Value >>= b )
4416 {
4417 pFormatter->SetStrictFormat( b );
4418 }
4419 }
4420 break;
4421 default:
4422 {
4423 VCLXSpinField::setProperty( PropertyName, Value );
4424 }
4425 }
4426 }
4427 }
4428
getProperty(const::rtl::OUString & PropertyName)4429 ::com::sun::star::uno::Any VCLXFormattedSpinField::getProperty( const ::rtl::OUString& PropertyName )
4430 {
4431 ::vos::OGuard aGuard( GetMutex() );
4432
4433 ::com::sun::star::uno::Any aProp;
4434 FormatterBase* pFormatter = GetFormatter();
4435 if ( pFormatter )
4436 {
4437 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4438 switch ( nPropType )
4439 {
4440 case BASEPROPERTY_TABSTOP:
4441 {
4442 aProp <<= (sal_Bool) ( ( GetWindow()->GetStyle() & WB_SPIN ) ? sal_True : sal_False );
4443 }
4444 break;
4445 case BASEPROPERTY_STRICTFORMAT:
4446 {
4447 aProp <<= (sal_Bool) pFormatter->IsStrictFormat();
4448 }
4449 break;
4450 default:
4451 {
4452 aProp <<= VCLXSpinField::getProperty( PropertyName );
4453 }
4454 }
4455 }
4456 return aProp;
4457 }
4458
4459
4460 // ----------------------------------------------------
4461 // class VCLXDateField
4462 // ----------------------------------------------------
4463
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)4464 void VCLXDateField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
4465 {
4466 PushPropertyIds( rIds,
4467 BASEPROPERTY_ALIGN,
4468 BASEPROPERTY_BACKGROUNDCOLOR,
4469 BASEPROPERTY_BORDER,
4470 BASEPROPERTY_BORDERCOLOR,
4471 BASEPROPERTY_DATE,
4472 BASEPROPERTY_DATEMAX,
4473 BASEPROPERTY_DATEMIN,
4474 BASEPROPERTY_DATESHOWCENTURY,
4475 BASEPROPERTY_DEFAULTCONTROL,
4476 BASEPROPERTY_DROPDOWN,
4477 BASEPROPERTY_ENABLED,
4478 BASEPROPERTY_ENABLEVISIBLE,
4479 BASEPROPERTY_EXTDATEFORMAT,
4480 BASEPROPERTY_FONTDESCRIPTOR,
4481 BASEPROPERTY_HELPTEXT,
4482 BASEPROPERTY_HELPURL,
4483 BASEPROPERTY_PRINTABLE,
4484 BASEPROPERTY_READONLY,
4485 BASEPROPERTY_REPEAT,
4486 BASEPROPERTY_REPEAT_DELAY,
4487 BASEPROPERTY_SPIN,
4488 BASEPROPERTY_STRICTFORMAT,
4489 BASEPROPERTY_TABSTOP,
4490 BASEPROPERTY_ENFORCE_FORMAT,
4491 BASEPROPERTY_TEXT,
4492 BASEPROPERTY_HIDEINACTIVESELECTION,
4493 BASEPROPERTY_VERTICALALIGN,
4494 BASEPROPERTY_WRITING_MODE,
4495 BASEPROPERTY_CONTEXT_WRITING_MODE,
4496 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
4497 0);
4498 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
4499 }
4500
VCLXDateField()4501 VCLXDateField::VCLXDateField()
4502 {
4503 }
4504
~VCLXDateField()4505 VCLXDateField::~VCLXDateField()
4506 {
4507 }
4508
4509 //change the window type here to match the role
CreateAccessibleContext()4510 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXDateField::CreateAccessibleContext()
4511 {
4512 Window* pWindow = GetWindow();
4513 if ( pWindow )
4514 {
4515 pWindow->SetType( WINDOW_DATEFIELD );
4516 }
4517 return getAccessibleFactory().createAccessibleContext( this );
4518 }
4519
4520 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)4521 ::com::sun::star::uno::Any VCLXDateField::queryInterface( const ::com::sun::star::uno::Type & rType )
4522 {
4523 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
4524 SAL_STATIC_CAST( ::com::sun::star::awt::XDateField*, this ) );
4525 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
4526 }
4527
4528 // ::com::sun::star::lang::XTypeProvider
4529 IMPL_XTYPEPROVIDER_START( VCLXDateField )
4530 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDateField>* ) NULL ),
4531 VCLXFormattedSpinField::getTypes()
4532 IMPL_XTYPEPROVIDER_END
4533
4534 void VCLXDateField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value)
4535 {
4536 ::vos::OGuard aGuard( GetMutex() );
4537
4538 if ( GetWindow() )
4539 {
4540 sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
4541
4542 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4543 switch ( nPropType )
4544 {
4545 case BASEPROPERTY_DATE:
4546 {
4547 if ( bVoid )
4548 {
4549 ((DateField*)GetWindow())->EnableEmptyFieldValue( sal_True );
4550 ((DateField*)GetWindow())->SetEmptyFieldValue();
4551 }
4552 else
4553 {
4554 sal_Int32 n = 0;
4555 if ( Value >>= n )
4556 setDate( n );
4557 }
4558 }
4559 break;
4560 case BASEPROPERTY_DATEMIN:
4561 {
4562 sal_Int32 n = 0;
4563 if ( Value >>= n )
4564 setMin( n );
4565 }
4566 break;
4567 case BASEPROPERTY_DATEMAX:
4568 {
4569 sal_Int32 n = 0;
4570 if ( Value >>= n )
4571 setMax( n );
4572 }
4573 break;
4574 case BASEPROPERTY_EXTDATEFORMAT:
4575 {
4576 sal_Int16 n = sal_Int16();
4577 if ( Value >>= n )
4578 ((DateField*)GetWindow())->SetExtDateFormat( (ExtDateFieldFormat) n );
4579 }
4580 break;
4581 case BASEPROPERTY_DATESHOWCENTURY:
4582 {
4583 sal_Bool b = sal_Bool();
4584 if ( Value >>= b )
4585 ((DateField*)GetWindow())->SetShowDateCentury( b );
4586 }
4587 break;
4588 case BASEPROPERTY_ENFORCE_FORMAT:
4589 {
4590 sal_Bool bEnforce( sal_True );
4591 OSL_VERIFY( Value >>= bEnforce );
4592 static_cast< DateField* >( GetWindow() )->EnforceValidValue( bEnforce );
4593 }
4594 break;
4595 default:
4596 {
4597 VCLXFormattedSpinField::setProperty( PropertyName, Value );
4598 }
4599 }
4600 }
4601 }
4602
getProperty(const::rtl::OUString & PropertyName)4603 ::com::sun::star::uno::Any VCLXDateField::getProperty( const ::rtl::OUString& PropertyName )
4604 {
4605 ::vos::OGuard aGuard( GetMutex() );
4606
4607 ::com::sun::star::uno::Any aProp;
4608 FormatterBase* pFormatter = GetFormatter();
4609 if ( pFormatter )
4610 {
4611 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4612 switch ( nPropType )
4613 {
4614 case BASEPROPERTY_DATE:
4615 {
4616 aProp <<= (sal_Int32) getDate();
4617 }
4618 break;
4619 case BASEPROPERTY_DATEMIN:
4620 {
4621 aProp <<= (sal_Int32) getMin();
4622 }
4623 break;
4624 case BASEPROPERTY_DATEMAX:
4625 {
4626 aProp <<= (sal_Int32) getMax();
4627 }
4628 break;
4629 case BASEPROPERTY_DATESHOWCENTURY:
4630 {
4631 aProp <<= ((DateField*)GetWindow())->IsShowDateCentury();
4632 }
4633 break;
4634 case BASEPROPERTY_ENFORCE_FORMAT:
4635 {
4636 aProp <<= (sal_Bool)static_cast< DateField* >( GetWindow() )->IsEnforceValidValue( );
4637 }
4638 break;
4639 default:
4640 {
4641 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
4642 }
4643 }
4644 }
4645 return aProp;
4646 }
4647
4648
setDate(sal_Int32 nDate)4649 void VCLXDateField::setDate( sal_Int32 nDate )
4650 {
4651 ::vos::OGuard aGuard( GetMutex() );
4652
4653 DateField* pDateField = (DateField*) GetWindow();
4654 if ( pDateField )
4655 {
4656 pDateField->SetDate( nDate );
4657
4658 // #107218# Call same listeners like VCL would do after user interaction
4659 SetSynthesizingVCLEvent( sal_True );
4660 pDateField->SetModifyFlag();
4661 pDateField->Modify();
4662 SetSynthesizingVCLEvent( sal_False );
4663 }
4664 }
4665
getDate()4666 sal_Int32 VCLXDateField::getDate()
4667 {
4668 ::vos::OGuard aGuard( GetMutex() );
4669
4670 sal_Int32 nDate = 0;
4671 DateField* pDateField = (DateField*) GetWindow();
4672 if ( pDateField )
4673 nDate = pDateField->GetDate().GetDate();
4674
4675 return nDate;
4676 }
4677
setMin(sal_Int32 nDate)4678 void VCLXDateField::setMin( sal_Int32 nDate )
4679 {
4680 ::vos::OGuard aGuard( GetMutex() );
4681
4682 DateField* pDateField = (DateField*) GetWindow();
4683 if ( pDateField )
4684 pDateField->SetMin( nDate );
4685 }
4686
getMin()4687 sal_Int32 VCLXDateField::getMin()
4688 {
4689 ::vos::OGuard aGuard( GetMutex() );
4690
4691 sal_Int32 nDate = 0;
4692 DateField* pDateField = (DateField*) GetWindow();
4693 if ( pDateField )
4694 nDate = pDateField->GetMin().GetDate();
4695
4696 return nDate;
4697 }
4698
setMax(sal_Int32 nDate)4699 void VCLXDateField::setMax( sal_Int32 nDate )
4700 {
4701 ::vos::OGuard aGuard( GetMutex() );
4702
4703 DateField* pDateField = (DateField*) GetWindow();
4704 if ( pDateField )
4705 pDateField->SetMax( nDate );
4706 }
4707
getMax()4708 sal_Int32 VCLXDateField::getMax()
4709 {
4710 ::vos::OGuard aGuard( GetMutex() );
4711
4712 sal_Int32 nDate = 0;
4713 DateField* pDateField = (DateField*) GetWindow();
4714 if ( pDateField )
4715 nDate = pDateField->GetMax().GetDate();
4716
4717 return nDate;
4718 }
4719
setFirst(sal_Int32 nDate)4720 void VCLXDateField::setFirst( sal_Int32 nDate )
4721 {
4722 ::vos::OGuard aGuard( GetMutex() );
4723
4724 DateField* pDateField = (DateField*) GetWindow();
4725 if ( pDateField )
4726 pDateField->SetFirst( nDate );
4727 }
4728
getFirst()4729 sal_Int32 VCLXDateField::getFirst()
4730 {
4731 ::vos::OGuard aGuard( GetMutex() );
4732
4733 sal_Int32 nDate = 0;
4734 DateField* pDateField = (DateField*) GetWindow();
4735 if ( pDateField )
4736 nDate = pDateField->GetFirst().GetDate();
4737
4738 return nDate;
4739 }
4740
setLast(sal_Int32 nDate)4741 void VCLXDateField::setLast( sal_Int32 nDate )
4742 {
4743 ::vos::OGuard aGuard( GetMutex() );
4744
4745 DateField* pDateField = (DateField*) GetWindow();
4746 if ( pDateField )
4747 pDateField->SetLast( nDate );
4748 }
4749
getLast()4750 sal_Int32 VCLXDateField::getLast()
4751 {
4752 ::vos::OGuard aGuard( GetMutex() );
4753
4754 sal_Int32 nDate = 0;
4755 DateField* pDateField = (DateField*) GetWindow();
4756 if ( pDateField )
4757 nDate = pDateField->GetLast().GetDate();
4758
4759 return nDate;
4760 }
4761
setLongFormat(sal_Bool bLong)4762 void VCLXDateField::setLongFormat( sal_Bool bLong )
4763 {
4764 ::vos::OGuard aGuard( GetMutex() );
4765
4766 DateField* pDateField = (DateField*) GetWindow();
4767 if ( pDateField )
4768 pDateField->SetLongFormat( bLong );
4769 }
4770
isLongFormat()4771 sal_Bool VCLXDateField::isLongFormat()
4772 {
4773 ::vos::OGuard aGuard( GetMutex() );
4774
4775 DateField* pDateField = (DateField*) GetWindow();
4776 return pDateField ? pDateField->IsLongFormat() : sal_False;
4777 }
4778
setEmpty()4779 void VCLXDateField::setEmpty()
4780 {
4781 ::vos::OGuard aGuard( GetMutex() );
4782
4783 DateField* pDateField = (DateField*) GetWindow();
4784 if ( pDateField )
4785 {
4786 pDateField->SetEmptyDate();
4787
4788 // #107218# Call same listeners like VCL would do after user interaction
4789 SetSynthesizingVCLEvent( sal_True );
4790 pDateField->SetModifyFlag();
4791 pDateField->Modify();
4792 SetSynthesizingVCLEvent( sal_False );
4793 }
4794 }
4795
isEmpty()4796 sal_Bool VCLXDateField::isEmpty()
4797 {
4798 ::vos::OGuard aGuard( GetMutex() );
4799
4800 DateField* pDateField = (DateField*) GetWindow();
4801 return pDateField ? pDateField->IsEmptyDate() : sal_False;
4802 }
4803
setStrictFormat(sal_Bool bStrict)4804 void VCLXDateField::setStrictFormat( sal_Bool bStrict )
4805 {
4806 VCLXFormattedSpinField::setStrictFormat( bStrict );
4807 }
4808
isStrictFormat()4809 sal_Bool VCLXDateField::isStrictFormat()
4810 {
4811 return VCLXFormattedSpinField::isStrictFormat();
4812 }
4813
4814
4815 // ----------------------------------------------------
4816 // class VCLXTimeField
4817 // ----------------------------------------------------
4818
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)4819 void VCLXTimeField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
4820 {
4821 PushPropertyIds( rIds,
4822 BASEPROPERTY_ALIGN,
4823 BASEPROPERTY_BACKGROUNDCOLOR,
4824 BASEPROPERTY_BORDER,
4825 BASEPROPERTY_BORDERCOLOR,
4826 BASEPROPERTY_DEFAULTCONTROL,
4827 BASEPROPERTY_ENABLED,
4828 BASEPROPERTY_ENABLEVISIBLE,
4829 BASEPROPERTY_EXTTIMEFORMAT,
4830 BASEPROPERTY_FONTDESCRIPTOR,
4831 BASEPROPERTY_HELPTEXT,
4832 BASEPROPERTY_HELPURL,
4833 BASEPROPERTY_PRINTABLE,
4834 BASEPROPERTY_READONLY,
4835 BASEPROPERTY_REPEAT,
4836 BASEPROPERTY_REPEAT_DELAY,
4837 BASEPROPERTY_SPIN,
4838 BASEPROPERTY_STRICTFORMAT,
4839 BASEPROPERTY_TABSTOP,
4840 BASEPROPERTY_TIME,
4841 BASEPROPERTY_TIMEMAX,
4842 BASEPROPERTY_TIMEMIN,
4843 BASEPROPERTY_ENFORCE_FORMAT,
4844 BASEPROPERTY_TEXT,
4845 BASEPROPERTY_HIDEINACTIVESELECTION,
4846 BASEPROPERTY_VERTICALALIGN,
4847 BASEPROPERTY_WRITING_MODE,
4848 BASEPROPERTY_CONTEXT_WRITING_MODE,
4849 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
4850 0);
4851 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
4852 }
4853
VCLXTimeField()4854 VCLXTimeField::VCLXTimeField()
4855 {
4856 }
4857
~VCLXTimeField()4858 VCLXTimeField::~VCLXTimeField()
4859 {
4860 }
4861 //change the window type here to match the role
CreateAccessibleContext()4862 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXTimeField::CreateAccessibleContext()
4863 {
4864 Window* pWindow = GetWindow();
4865 if ( pWindow )
4866 {
4867 pWindow->SetType( WINDOW_TIMEFIELD );
4868 }
4869 return getAccessibleFactory().createAccessibleContext( this );
4870 }
4871
4872 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)4873 ::com::sun::star::uno::Any VCLXTimeField::queryInterface( const ::com::sun::star::uno::Type & rType )
4874 {
4875 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
4876 SAL_STATIC_CAST( ::com::sun::star::awt::XTimeField*, this ) );
4877 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
4878 }
4879
4880 // ::com::sun::star::lang::XTypeProvider
4881 IMPL_XTYPEPROVIDER_START( VCLXTimeField )
4882 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTimeField>* ) NULL ),
4883 VCLXFormattedSpinField::getTypes()
4884 IMPL_XTYPEPROVIDER_END
4885
4886 void VCLXTimeField::setTime( sal_Int32 nTime )
4887 {
4888 ::vos::OGuard aGuard( GetMutex() );
4889
4890 TimeField* pTimeField = (TimeField*) GetWindow();
4891 if ( pTimeField )
4892 {
4893 pTimeField->SetTime( nTime );
4894
4895 // #107218# Call same listeners like VCL would do after user interaction
4896 SetSynthesizingVCLEvent( sal_True );
4897 pTimeField->SetModifyFlag();
4898 pTimeField->Modify();
4899 SetSynthesizingVCLEvent( sal_False );
4900 }
4901 }
4902
getTime()4903 sal_Int32 VCLXTimeField::getTime()
4904 {
4905 ::vos::OGuard aGuard( GetMutex() );
4906
4907 sal_Int32 nTime = 0;
4908 TimeField* pTimeField = (TimeField*) GetWindow();
4909 if ( pTimeField )
4910 nTime = pTimeField->GetTime().GetTime();
4911
4912 return nTime;
4913 }
4914
setMin(sal_Int32 nTime)4915 void VCLXTimeField::setMin( sal_Int32 nTime )
4916 {
4917 ::vos::OGuard aGuard( GetMutex() );
4918
4919 TimeField* pTimeField = (TimeField*) GetWindow();
4920 if ( pTimeField )
4921 pTimeField->SetMin( nTime );
4922 }
4923
getMin()4924 sal_Int32 VCLXTimeField::getMin()
4925 {
4926 ::vos::OGuard aGuard( GetMutex() );
4927
4928 sal_Int32 nTime = 0;
4929 TimeField* pTimeField = (TimeField*) GetWindow();
4930 if ( pTimeField )
4931 nTime = pTimeField->GetMin().GetTime();
4932
4933 return nTime;
4934 }
4935
setMax(sal_Int32 nTime)4936 void VCLXTimeField::setMax( sal_Int32 nTime )
4937 {
4938 ::vos::OGuard aGuard( GetMutex() );
4939
4940 TimeField* pTimeField = (TimeField*) GetWindow();
4941 if ( pTimeField )
4942 pTimeField->SetMax( nTime );
4943 }
4944
getMax()4945 sal_Int32 VCLXTimeField::getMax()
4946 {
4947 ::vos::OGuard aGuard( GetMutex() );
4948
4949 sal_Int32 nTime = 0;
4950 TimeField* pTimeField = (TimeField*) GetWindow();
4951 if ( pTimeField )
4952 nTime = pTimeField->GetMax().GetTime();
4953
4954 return nTime;
4955 }
4956
setFirst(sal_Int32 nTime)4957 void VCLXTimeField::setFirst( sal_Int32 nTime )
4958 {
4959 ::vos::OGuard aGuard( GetMutex() );
4960
4961 TimeField* pTimeField = (TimeField*) GetWindow();
4962 if ( pTimeField )
4963 pTimeField->SetFirst( nTime );
4964 }
4965
getFirst()4966 sal_Int32 VCLXTimeField::getFirst()
4967 {
4968 ::vos::OGuard aGuard( GetMutex() );
4969
4970 sal_Int32 nTime = 0;
4971 TimeField* pTimeField = (TimeField*) GetWindow();
4972 if ( pTimeField )
4973 nTime = pTimeField->GetFirst().GetTime();
4974
4975 return nTime;
4976 }
4977
setLast(sal_Int32 nTime)4978 void VCLXTimeField::setLast( sal_Int32 nTime )
4979 {
4980 ::vos::OGuard aGuard( GetMutex() );
4981
4982 TimeField* pTimeField = (TimeField*) GetWindow();
4983 if ( pTimeField )
4984 pTimeField->SetLast( nTime );
4985 }
4986
getLast()4987 sal_Int32 VCLXTimeField::getLast()
4988 {
4989 ::vos::OGuard aGuard( GetMutex() );
4990
4991 sal_Int32 nTime = 0;
4992 TimeField* pTimeField = (TimeField*) GetWindow();
4993 if ( pTimeField )
4994 nTime = pTimeField->GetLast().GetTime();
4995
4996 return nTime;
4997 }
4998
setEmpty()4999 void VCLXTimeField::setEmpty()
5000 {
5001 ::vos::OGuard aGuard( GetMutex() );
5002
5003 TimeField* pTimeField = (TimeField*) GetWindow();
5004 if ( pTimeField )
5005 pTimeField->SetEmptyTime();
5006 }
5007
isEmpty()5008 sal_Bool VCLXTimeField::isEmpty()
5009 {
5010 ::vos::OGuard aGuard( GetMutex() );
5011
5012 TimeField* pTimeField = (TimeField*) GetWindow();
5013 return pTimeField ? pTimeField->IsEmptyTime() : sal_False;
5014 }
5015
setStrictFormat(sal_Bool bStrict)5016 void VCLXTimeField::setStrictFormat( sal_Bool bStrict )
5017 {
5018 VCLXFormattedSpinField::setStrictFormat( bStrict );
5019 }
5020
isStrictFormat()5021 sal_Bool VCLXTimeField::isStrictFormat()
5022 {
5023 return VCLXFormattedSpinField::isStrictFormat();
5024 }
5025
5026
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)5027 void VCLXTimeField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value)
5028 {
5029 ::vos::OGuard aGuard( GetMutex() );
5030
5031 if ( GetWindow() )
5032 {
5033 sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
5034
5035 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5036 switch ( nPropType )
5037 {
5038 case BASEPROPERTY_TIME:
5039 {
5040 if ( bVoid )
5041 {
5042 ((TimeField*)GetWindow())->EnableEmptyFieldValue( sal_True );
5043 ((TimeField*)GetWindow())->SetEmptyFieldValue();
5044 }
5045 else
5046 {
5047 sal_Int32 n = 0;
5048 if ( Value >>= n )
5049 setTime( n );
5050 }
5051 }
5052 break;
5053 case BASEPROPERTY_TIMEMIN:
5054 {
5055 sal_Int32 n = 0;
5056 if ( Value >>= n )
5057 setMin( n );
5058 }
5059 break;
5060 case BASEPROPERTY_TIMEMAX:
5061 {
5062 sal_Int32 n = 0;
5063 if ( Value >>= n )
5064 setMax( n );
5065 }
5066 break;
5067 case BASEPROPERTY_EXTTIMEFORMAT:
5068 {
5069 sal_Int16 n = sal_Int16();
5070 if ( Value >>= n )
5071 ((TimeField*)GetWindow())->SetExtFormat( (ExtTimeFieldFormat) n );
5072 }
5073 break;
5074 case BASEPROPERTY_ENFORCE_FORMAT:
5075 {
5076 sal_Bool bEnforce( sal_True );
5077 OSL_VERIFY( Value >>= bEnforce );
5078 static_cast< TimeField* >( GetWindow() )->EnforceValidValue( bEnforce );
5079 }
5080 break;
5081 default:
5082 {
5083 VCLXFormattedSpinField::setProperty( PropertyName, Value );
5084 }
5085 }
5086 }
5087 }
5088
getProperty(const::rtl::OUString & PropertyName)5089 ::com::sun::star::uno::Any VCLXTimeField::getProperty( const ::rtl::OUString& PropertyName )
5090 {
5091 ::vos::OGuard aGuard( GetMutex() );
5092
5093 ::com::sun::star::uno::Any aProp;
5094 if ( GetWindow() )
5095 {
5096 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5097 switch ( nPropType )
5098 {
5099 case BASEPROPERTY_TIME:
5100 {
5101 aProp <<= (sal_Int32) getTime();
5102 }
5103 break;
5104 case BASEPROPERTY_TIMEMIN:
5105 {
5106 aProp <<= (sal_Int32) getMin();
5107 }
5108 break;
5109 case BASEPROPERTY_TIMEMAX:
5110 {
5111 aProp <<= (sal_Int32) getMax();
5112 }
5113 break;
5114 case BASEPROPERTY_ENFORCE_FORMAT:
5115 {
5116 aProp <<= (sal_Bool)static_cast< TimeField* >( GetWindow() )->IsEnforceValidValue( );
5117 }
5118 break;
5119 default:
5120 {
5121 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
5122 }
5123 }
5124 }
5125 return aProp;
5126 }
5127
5128 // ----------------------------------------------------
5129 // class VCLXNumericField
5130 // ----------------------------------------------------
5131
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)5132 void VCLXNumericField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
5133 {
5134 PushPropertyIds( rIds,
5135 BASEPROPERTY_ALIGN,
5136 BASEPROPERTY_BACKGROUNDCOLOR,
5137 BASEPROPERTY_BORDER,
5138 BASEPROPERTY_BORDERCOLOR,
5139 BASEPROPERTY_DECIMALACCURACY,
5140 BASEPROPERTY_DEFAULTCONTROL,
5141 BASEPROPERTY_ENABLED,
5142 BASEPROPERTY_ENABLEVISIBLE,
5143 BASEPROPERTY_FONTDESCRIPTOR,
5144 BASEPROPERTY_HELPTEXT,
5145 BASEPROPERTY_HELPURL,
5146 BASEPROPERTY_NUMSHOWTHOUSANDSEP,
5147 BASEPROPERTY_PRINTABLE,
5148 BASEPROPERTY_READONLY,
5149 BASEPROPERTY_REPEAT,
5150 BASEPROPERTY_REPEAT_DELAY,
5151 BASEPROPERTY_SPIN,
5152 BASEPROPERTY_STRICTFORMAT,
5153 BASEPROPERTY_TABSTOP,
5154 BASEPROPERTY_VALUEMAX_DOUBLE,
5155 BASEPROPERTY_VALUEMIN_DOUBLE,
5156 BASEPROPERTY_VALUESTEP_DOUBLE,
5157 BASEPROPERTY_VALUE_DOUBLE,
5158 BASEPROPERTY_ENFORCE_FORMAT,
5159 BASEPROPERTY_HIDEINACTIVESELECTION,
5160 BASEPROPERTY_VERTICALALIGN,
5161 BASEPROPERTY_WRITING_MODE,
5162 BASEPROPERTY_CONTEXT_WRITING_MODE,
5163 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
5164 0);
5165 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5166 }
5167
VCLXNumericField()5168 VCLXNumericField::VCLXNumericField()
5169 {
5170 }
5171
~VCLXNumericField()5172 VCLXNumericField::~VCLXNumericField()
5173 {
5174 }
5175
5176 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)5177 ::com::sun::star::uno::Any VCLXNumericField::queryInterface( const ::com::sun::star::uno::Type & rType )
5178 {
5179 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
5180 SAL_STATIC_CAST( ::com::sun::star::awt::XNumericField*, this ) );
5181 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
5182 }
5183
5184 // ::com::sun::star::lang::XTypeProvider
5185 IMPL_XTYPEPROVIDER_START( VCLXNumericField )
5186 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XNumericField>* ) NULL ),
5187 VCLXFormattedSpinField::getTypes()
5188 IMPL_XTYPEPROVIDER_END
5189
5190 void VCLXNumericField::setValue( double Value )
5191 {
5192 ::vos::OGuard aGuard( GetMutex() );
5193
5194 NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5195 if ( pNumericFormatter )
5196 {
5197 // z.B. 105, 2 Digits => 1,05
5198 // ein float 1,05 muss also eine 105 einstellen...
5199 pNumericFormatter->SetValue(
5200 (long)ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() ) );
5201
5202 // #107218# Call same listeners like VCL would do after user interaction
5203 Edit* pEdit = (Edit*)GetWindow();
5204 if ( pEdit )
5205 {
5206 SetSynthesizingVCLEvent( sal_True );
5207 pEdit->SetModifyFlag();
5208 pEdit->Modify();
5209 SetSynthesizingVCLEvent( sal_False );
5210 }
5211 }
5212 }
5213
getValue()5214 double VCLXNumericField::getValue()
5215 {
5216 ::vos::OGuard aGuard( GetMutex() );
5217
5218 NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5219 return pNumericFormatter
5220 ? ImplCalcDoubleValue( (double)pNumericFormatter->GetValue(), pNumericFormatter->GetDecimalDigits() )
5221 : 0;
5222 }
5223
setMin(double Value)5224 void VCLXNumericField::setMin( double Value )
5225 {
5226 ::vos::OGuard aGuard( GetMutex() );
5227
5228 NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5229 if ( pNumericFormatter )
5230 pNumericFormatter->SetMin(
5231 (long)ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() ) );
5232 }
5233
getMin()5234 double VCLXNumericField::getMin()
5235 {
5236 ::vos::OGuard aGuard( GetMutex() );
5237
5238 NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5239 return pNumericFormatter
5240 ? ImplCalcDoubleValue( (double)pNumericFormatter->GetMin(), pNumericFormatter->GetDecimalDigits() )
5241 : 0;
5242 }
5243
setMax(double Value)5244 void VCLXNumericField::setMax( double Value )
5245 {
5246 ::vos::OGuard aGuard( GetMutex() );
5247
5248 NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5249 if ( pNumericFormatter )
5250 pNumericFormatter->SetMax(
5251 (long)ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() ) );
5252 }
5253
getMax()5254 double VCLXNumericField::getMax()
5255 {
5256 ::vos::OGuard aGuard( GetMutex() );
5257
5258 NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5259 return pNumericFormatter
5260 ? ImplCalcDoubleValue( (double)pNumericFormatter->GetMax(), pNumericFormatter->GetDecimalDigits() )
5261 : 0;
5262 }
5263
setFirst(double Value)5264 void VCLXNumericField::setFirst( double Value )
5265 {
5266 ::vos::OGuard aGuard( GetMutex() );
5267
5268 NumericField* pNumericField = (NumericField*) GetWindow();
5269 if ( pNumericField )
5270 pNumericField->SetFirst(
5271 (long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) );
5272 }
5273
getFirst()5274 double VCLXNumericField::getFirst()
5275 {
5276 ::vos::OGuard aGuard( GetMutex() );
5277
5278 NumericField* pNumericField = (NumericField*) GetWindow();
5279 return pNumericField
5280 ? ImplCalcDoubleValue( (double)pNumericField->GetFirst(), pNumericField->GetDecimalDigits() )
5281 : 0;
5282 }
5283
setLast(double Value)5284 void VCLXNumericField::setLast( double Value )
5285 {
5286 ::vos::OGuard aGuard( GetMutex() );
5287
5288 NumericField* pNumericField = (NumericField*) GetWindow();
5289 if ( pNumericField )
5290 pNumericField->SetLast(
5291 (long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) );
5292 }
5293
getLast()5294 double VCLXNumericField::getLast()
5295 {
5296 ::vos::OGuard aGuard( GetMutex() );
5297
5298 NumericField* pNumericField = (NumericField*) GetWindow();
5299 return pNumericField
5300 ? ImplCalcDoubleValue( (double)pNumericField->GetLast(), pNumericField->GetDecimalDigits() )
5301 : 0;
5302 }
5303
setStrictFormat(sal_Bool bStrict)5304 void VCLXNumericField::setStrictFormat( sal_Bool bStrict )
5305 {
5306 VCLXFormattedSpinField::setStrictFormat( bStrict );
5307 }
5308
isStrictFormat()5309 sal_Bool VCLXNumericField::isStrictFormat()
5310 {
5311 return VCLXFormattedSpinField::isStrictFormat();
5312 }
5313
5314
setSpinSize(double Value)5315 void VCLXNumericField::setSpinSize( double Value )
5316 {
5317 ::vos::OGuard aGuard( GetMutex() );
5318
5319 NumericField* pNumericField = (NumericField*) GetWindow();
5320 if ( pNumericField )
5321 pNumericField->SetSpinSize(
5322 (long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) );
5323 }
5324
getSpinSize()5325 double VCLXNumericField::getSpinSize()
5326 {
5327 ::vos::OGuard aGuard( GetMutex() );
5328
5329 NumericField* pNumericField = (NumericField*) GetWindow();
5330 return pNumericField
5331 ? ImplCalcDoubleValue( (double)pNumericField->GetSpinSize(), pNumericField->GetDecimalDigits() )
5332 : 0;
5333 }
5334
setDecimalDigits(sal_Int16 Value)5335 void VCLXNumericField::setDecimalDigits( sal_Int16 Value )
5336 {
5337 ::vos::OGuard aGuard( GetMutex() );
5338
5339 NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5340 if ( pNumericFormatter )
5341 {
5342 double n = getValue();
5343 pNumericFormatter->SetDecimalDigits( Value );
5344 setValue( n );
5345 }
5346 }
5347
getDecimalDigits()5348 sal_Int16 VCLXNumericField::getDecimalDigits()
5349 {
5350 ::vos::OGuard aGuard( GetMutex() );
5351
5352 NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5353 return pNumericFormatter ? pNumericFormatter->GetDecimalDigits() : 0;
5354 }
5355
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)5356 void VCLXNumericField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value)
5357 {
5358 ::vos::OGuard aGuard( GetMutex() );
5359
5360 if ( GetWindow() )
5361 {
5362 sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
5363
5364 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5365 switch ( nPropType )
5366 {
5367 case BASEPROPERTY_VALUE_DOUBLE:
5368 {
5369 if ( bVoid )
5370 {
5371 ((NumericField*)GetWindow())->EnableEmptyFieldValue( sal_True );
5372 ((NumericField*)GetWindow())->SetEmptyFieldValue();
5373 }
5374 else
5375 {
5376 double d = 0;
5377 if ( Value >>= d )
5378 setValue( d );
5379 }
5380 }
5381 break;
5382 case BASEPROPERTY_VALUEMIN_DOUBLE:
5383 {
5384 double d = 0;
5385 if ( Value >>= d )
5386 setMin( d );
5387 }
5388 break;
5389 case BASEPROPERTY_VALUEMAX_DOUBLE:
5390 {
5391 double d = 0;
5392 if ( Value >>= d )
5393 setMax( d );
5394 }
5395 break;
5396 case BASEPROPERTY_VALUESTEP_DOUBLE:
5397 {
5398 double d = 0;
5399 if ( Value >>= d )
5400 setSpinSize( d );
5401 }
5402 break;
5403 case BASEPROPERTY_DECIMALACCURACY:
5404 {
5405 sal_Int16 n = sal_Int16();
5406 if ( Value >>= n )
5407 setDecimalDigits( n );
5408 }
5409 break;
5410 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5411 {
5412 sal_Bool b = sal_Bool();
5413 if ( Value >>= b )
5414 ((NumericField*)GetWindow())->SetUseThousandSep( b );
5415 }
5416 break;
5417 default:
5418 {
5419 VCLXFormattedSpinField::setProperty( PropertyName, Value );
5420 }
5421 }
5422 }
5423 }
5424
getProperty(const::rtl::OUString & PropertyName)5425 ::com::sun::star::uno::Any VCLXNumericField::getProperty( const ::rtl::OUString& PropertyName )
5426 {
5427 ::vos::OGuard aGuard( GetMutex() );
5428
5429 ::com::sun::star::uno::Any aProp;
5430 FormatterBase* pFormatter = GetFormatter();
5431 if ( pFormatter )
5432 {
5433 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5434 switch ( nPropType )
5435 {
5436 case BASEPROPERTY_VALUE_DOUBLE:
5437 {
5438 aProp <<= (double) getValue();
5439 }
5440 break;
5441 case BASEPROPERTY_VALUEMIN_DOUBLE:
5442 {
5443 aProp <<= (double) getMin();
5444 }
5445 break;
5446 case BASEPROPERTY_VALUEMAX_DOUBLE:
5447 {
5448 aProp <<= (double) getMax();
5449 }
5450 break;
5451 case BASEPROPERTY_VALUESTEP_DOUBLE:
5452 {
5453 aProp <<= (double) getSpinSize();
5454 }
5455 break;
5456 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5457 {
5458 aProp <<= (sal_Bool) ((NumericField*)GetWindow())->IsUseThousandSep();
5459 }
5460 break;
5461 default:
5462 {
5463 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
5464 }
5465 }
5466 }
5467 return aProp;
5468 }
5469
5470
5471 // ----------------------------------------------------
5472 // class VCLXMetricField
5473 // ----------------------------------------------------
5474
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)5475 void VCLXMetricField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
5476 {
5477 PushPropertyIds( rIds,
5478 BASEPROPERTY_ALIGN,
5479 BASEPROPERTY_BACKGROUNDCOLOR,
5480 BASEPROPERTY_BORDER,
5481 BASEPROPERTY_BORDERCOLOR,
5482 BASEPROPERTY_DECIMALACCURACY,
5483 BASEPROPERTY_DEFAULTCONTROL,
5484 BASEPROPERTY_ENABLED,
5485 BASEPROPERTY_ENABLEVISIBLE,
5486 BASEPROPERTY_FONTDESCRIPTOR,
5487 BASEPROPERTY_HELPTEXT,
5488 BASEPROPERTY_HELPURL,
5489 BASEPROPERTY_NUMSHOWTHOUSANDSEP,
5490 BASEPROPERTY_PRINTABLE,
5491 BASEPROPERTY_READONLY,
5492 BASEPROPERTY_REPEAT,
5493 BASEPROPERTY_REPEAT_DELAY,
5494 BASEPROPERTY_SPIN,
5495 BASEPROPERTY_STRICTFORMAT,
5496 BASEPROPERTY_TABSTOP,
5497 BASEPROPERTY_ENFORCE_FORMAT,
5498 BASEPROPERTY_HIDEINACTIVESELECTION,
5499 BASEPROPERTY_UNIT,
5500 BASEPROPERTY_CUSTOMUNITTEXT,
5501 BASEPROPERTY_WRITING_MODE,
5502 BASEPROPERTY_CONTEXT_WRITING_MODE,
5503 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
5504 0);
5505 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5506 }
5507
VCLXMetricField()5508 VCLXMetricField::VCLXMetricField()
5509 {
5510 }
5511
~VCLXMetricField()5512 VCLXMetricField::~VCLXMetricField()
5513 {
5514 }
5515
GetMetricFormatter()5516 MetricFormatter *VCLXMetricField::GetMetricFormatter()
5517 {
5518 MetricFormatter *pFormatter = (MetricFormatter *) GetFormatter();
5519 if (!pFormatter)
5520 throw ::com::sun::star::uno::RuntimeException();
5521 return pFormatter;
5522 }
5523
GetMetricField()5524 MetricField *VCLXMetricField::GetMetricField()
5525 {
5526 MetricField *pField = (MetricField *) GetWindow();
5527 if (!pField)
5528 throw ::com::sun::star::uno::RuntimeException();
5529 return pField;
5530 }
5531
5532 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)5533 ::com::sun::star::uno::Any VCLXMetricField::queryInterface( const ::com::sun::star::uno::Type & rType )
5534 {
5535 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
5536 SAL_STATIC_CAST( ::com::sun::star::awt::XMetricField*, this ) );
5537 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
5538 }
5539
5540 // ::com::sun::star::lang::XTypeProvider
5541 IMPL_XTYPEPROVIDER_START( VCLXMetricField )
5542 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMetricField>* ) NULL ),
5543 VCLXFormattedSpinField::getTypes()
5544 IMPL_XTYPEPROVIDER_END
5545
5546 // FIXME: later ...
5547 #define MetricUnitUnoToVcl(a) ((FieldUnit)(a))
5548
5549 #define METRIC_MAP_PAIR(method,parent) \
5550 sal_Int64 VCLXMetricField::get##method( sal_Int16 nUnit ) \
5551 { \
5552 ::vos::OGuard aGuard( GetMutex() ); \
5553 return GetMetric##parent()->Get##method( MetricUnitUnoToVcl( nUnit ) ); \
5554 } \
5555 void VCLXMetricField::set##method( sal_Int64 nValue, sal_Int16 nUnit ) \
5556 { \
5557 ::vos::OGuard aGuard( GetMutex() ); \
5558 GetMetric##parent()->Set##method( nValue, MetricUnitUnoToVcl( nUnit ) ); \
5559 }
5560
5561 METRIC_MAP_PAIR(Min, Formatter)
5562 METRIC_MAP_PAIR(Max, Formatter)
5563 METRIC_MAP_PAIR(First, Field)
5564 METRIC_MAP_PAIR(Last, Field)
5565
5566 #undef METRIC_MAP_PAIR
5567
5568 ::sal_Int64 VCLXMetricField::getValue( ::sal_Int16 nUnit )
5569 {
5570 ::vos::OGuard aGuard( GetMutex() );
5571 return GetMetricFormatter()->GetValue( MetricUnitUnoToVcl( nUnit ) );
5572 }
5573
getCorrectedValue(::sal_Int16 nUnit)5574 ::sal_Int64 VCLXMetricField::getCorrectedValue( ::sal_Int16 nUnit )
5575 {
5576 ::vos::OGuard aGuard( GetMutex() );
5577 return GetMetricFormatter()->GetCorrectedValue( MetricUnitUnoToVcl( nUnit ) );
5578 }
5579
5580 // FIXME: acute cut/paste evilness - move this to the parent Edit class ?
CallListeners()5581 void VCLXMetricField::CallListeners()
5582 {
5583 // #107218# Call same listeners like VCL would do after user interaction
5584 Edit* pEdit = (Edit*)GetWindow();
5585 if ( pEdit )
5586 {
5587 SetSynthesizingVCLEvent( sal_True );
5588 pEdit->SetModifyFlag();
5589 pEdit->Modify();
5590 SetSynthesizingVCLEvent( sal_False );
5591 }
5592 }
5593
setValue(::sal_Int64 Value,::sal_Int16 Unit)5594 void VCLXMetricField::setValue( ::sal_Int64 Value, ::sal_Int16 Unit )
5595 {
5596 ::vos::OGuard aGuard( GetMutex() );
5597 GetMetricFormatter()->SetValue( Value, MetricUnitUnoToVcl( Unit ) );
5598 CallListeners();
5599 }
5600
setUserValue(::sal_Int64 Value,::sal_Int16 Unit)5601 void VCLXMetricField::setUserValue( ::sal_Int64 Value, ::sal_Int16 Unit )
5602 {
5603 ::vos::OGuard aGuard( GetMutex() );
5604 GetMetricFormatter()->SetUserValue( Value, MetricUnitUnoToVcl( Unit ) );
5605 CallListeners();
5606 }
5607
setStrictFormat(sal_Bool bStrict)5608 void VCLXMetricField::setStrictFormat( sal_Bool bStrict )
5609 {
5610 VCLXFormattedSpinField::setStrictFormat( bStrict );
5611 }
5612
isStrictFormat()5613 sal_Bool VCLXMetricField::isStrictFormat()
5614 {
5615 return VCLXFormattedSpinField::isStrictFormat();
5616 }
5617
setSpinSize(sal_Int64 Value)5618 void VCLXMetricField::setSpinSize( sal_Int64 Value )
5619 {
5620 ::vos::OGuard aGuard( GetMutex() );
5621 GetMetricField()->SetSpinSize( Value );
5622 }
5623
getSpinSize()5624 sal_Int64 VCLXMetricField::getSpinSize()
5625 {
5626 ::vos::OGuard aGuard( GetMutex() );
5627 return GetMetricField()->GetSpinSize();
5628 }
5629
setDecimalDigits(sal_Int16 Value)5630 void VCLXMetricField::setDecimalDigits( sal_Int16 Value )
5631 {
5632 ::vos::OGuard aGuard( GetMutex() );
5633 GetMetricFormatter()->SetDecimalDigits( Value );
5634 }
5635
getDecimalDigits()5636 sal_Int16 VCLXMetricField::getDecimalDigits()
5637 {
5638 ::vos::OGuard aGuard( GetMutex() );
5639
5640 NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
5641 return pNumericFormatter ? pNumericFormatter->GetDecimalDigits() : 0;
5642 }
5643
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)5644 void VCLXMetricField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value)
5645 {
5646 ::vos::OGuard aGuard( GetMutex() );
5647
5648 if ( GetWindow() )
5649 {
5650 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5651 switch ( nPropType )
5652 {
5653 case BASEPROPERTY_DECIMALACCURACY:
5654 {
5655 sal_Int16 n = 0;
5656 if ( Value >>= n )
5657 setDecimalDigits( n );
5658 break;
5659 }
5660 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5661 {
5662 sal_Bool b = sal_False;
5663 if ( Value >>= b )
5664 ((NumericField*)GetWindow())->SetUseThousandSep( b );
5665 }
5666 break;
5667 case BASEPROPERTY_UNIT:
5668 {
5669 sal_uInt16 nVal = 0;
5670 if ( Value >>= nVal )
5671 ((MetricField*)GetWindow())->SetUnit( (FieldUnit) nVal );
5672 break;
5673 }
5674 case BASEPROPERTY_CUSTOMUNITTEXT:
5675 {
5676 rtl::OUString aStr;
5677 if ( Value >>= aStr )
5678 ((MetricField*)GetWindow())->SetCustomUnitText( aStr );
5679 break;
5680 }
5681 default:
5682 {
5683 VCLXFormattedSpinField::setProperty( PropertyName, Value );
5684 break;
5685 }
5686 }
5687 }
5688 }
5689
getProperty(const::rtl::OUString & PropertyName)5690 ::com::sun::star::uno::Any VCLXMetricField::getProperty( const ::rtl::OUString& PropertyName )
5691 {
5692 ::vos::OGuard aGuard( GetMutex() );
5693
5694 ::com::sun::star::uno::Any aProp;
5695 FormatterBase* pFormatter = GetFormatter();
5696 if ( pFormatter )
5697 {
5698 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5699 switch ( nPropType )
5700 {
5701 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
5702 aProp <<= (sal_Bool) ((NumericField*)GetWindow())->IsUseThousandSep();
5703 break;
5704 case BASEPROPERTY_UNIT:
5705 aProp <<= (sal_uInt16) ((MetricField*)GetWindow())->GetUnit();
5706 break;
5707 case BASEPROPERTY_CUSTOMUNITTEXT:
5708 aProp <<= rtl::OUString (((MetricField*)GetWindow())->GetCustomUnitText());
5709 break;
5710 default:
5711 {
5712 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
5713 break;
5714 }
5715 }
5716 }
5717 return aProp;
5718 }
5719
5720
5721 // ----------------------------------------------------
5722 // class VCLXCurrencyField
5723 // ----------------------------------------------------
5724
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)5725 void VCLXCurrencyField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
5726 {
5727 PushPropertyIds( rIds,
5728 BASEPROPERTY_ALIGN,
5729 BASEPROPERTY_BACKGROUNDCOLOR,
5730 BASEPROPERTY_BORDER,
5731 BASEPROPERTY_BORDERCOLOR,
5732 BASEPROPERTY_CURRENCYSYMBOL,
5733 BASEPROPERTY_CURSYM_POSITION,
5734 BASEPROPERTY_DECIMALACCURACY,
5735 BASEPROPERTY_DEFAULTCONTROL,
5736 BASEPROPERTY_ENABLED,
5737 BASEPROPERTY_ENABLEVISIBLE,
5738 BASEPROPERTY_FONTDESCRIPTOR,
5739 BASEPROPERTY_HELPTEXT,
5740 BASEPROPERTY_HELPURL,
5741 BASEPROPERTY_NUMSHOWTHOUSANDSEP,
5742 BASEPROPERTY_PRINTABLE,
5743 BASEPROPERTY_READONLY,
5744 BASEPROPERTY_REPEAT,
5745 BASEPROPERTY_REPEAT_DELAY,
5746 BASEPROPERTY_SPIN,
5747 BASEPROPERTY_STRICTFORMAT,
5748 BASEPROPERTY_TABSTOP,
5749 BASEPROPERTY_VALUEMAX_DOUBLE,
5750 BASEPROPERTY_VALUEMIN_DOUBLE,
5751 BASEPROPERTY_VALUESTEP_DOUBLE,
5752 BASEPROPERTY_VALUE_DOUBLE,
5753 BASEPROPERTY_ENFORCE_FORMAT,
5754 BASEPROPERTY_HIDEINACTIVESELECTION,
5755 BASEPROPERTY_VERTICALALIGN,
5756 BASEPROPERTY_WRITING_MODE,
5757 BASEPROPERTY_CONTEXT_WRITING_MODE,
5758 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
5759 0);
5760 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5761 }
5762
VCLXCurrencyField()5763 VCLXCurrencyField::VCLXCurrencyField()
5764 {
5765 }
5766
~VCLXCurrencyField()5767 VCLXCurrencyField::~VCLXCurrencyField()
5768 {
5769 }
5770
5771 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)5772 ::com::sun::star::uno::Any VCLXCurrencyField::queryInterface( const ::com::sun::star::uno::Type & rType )
5773 {
5774 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
5775 SAL_STATIC_CAST( ::com::sun::star::awt::XCurrencyField*, this ) );
5776 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
5777 }
5778
5779 // ::com::sun::star::lang::XTypeProvider
5780 IMPL_XTYPEPROVIDER_START( VCLXCurrencyField )
5781 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XCurrencyField>* ) NULL ),
5782 VCLXFormattedSpinField::getTypes()
5783 IMPL_XTYPEPROVIDER_END
5784
5785 void VCLXCurrencyField::setValue( double Value )
5786 {
5787 ::vos::OGuard aGuard( GetMutex() );
5788
5789 LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter();
5790 if ( pCurrencyFormatter )
5791 {
5792 // z.B. 105, 2 Digits => 1,05
5793 // ein float 1,05 muss also eine 105 einstellen...
5794 pCurrencyFormatter->SetValue(
5795 ImplCalcLongValue( Value, pCurrencyFormatter->GetDecimalDigits() ) );
5796
5797 // #107218# Call same listeners like VCL would do after user interaction
5798 Edit* pEdit = (Edit*)GetWindow();
5799 if ( pEdit )
5800 {
5801 SetSynthesizingVCLEvent( sal_True );
5802 pEdit->SetModifyFlag();
5803 pEdit->Modify();
5804 SetSynthesizingVCLEvent( sal_False );
5805 }
5806 }
5807 }
5808
getValue()5809 double VCLXCurrencyField::getValue()
5810 {
5811 ::vos::OGuard aGuard( GetMutex() );
5812
5813 LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter();
5814 return pCurrencyFormatter
5815 ? ImplCalcDoubleValue( (double)pCurrencyFormatter->GetValue(), pCurrencyFormatter->GetDecimalDigits() )
5816 : 0;
5817 }
5818
setMin(double Value)5819 void VCLXCurrencyField::setMin( double Value )
5820 {
5821 ::vos::OGuard aGuard( GetMutex() );
5822
5823 LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter();
5824 if ( pCurrencyFormatter )
5825 pCurrencyFormatter->SetMin(
5826 ImplCalcLongValue( Value, pCurrencyFormatter->GetDecimalDigits() ) );
5827 }
5828
getMin()5829 double VCLXCurrencyField::getMin()
5830 {
5831 ::vos::OGuard aGuard( GetMutex() );
5832
5833 LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter();
5834 return pCurrencyFormatter
5835 ? ImplCalcDoubleValue( (double)pCurrencyFormatter->GetMin(), pCurrencyFormatter->GetDecimalDigits() )
5836 : 0;
5837 }
5838
setMax(double Value)5839 void VCLXCurrencyField::setMax( double Value )
5840 {
5841 ::vos::OGuard aGuard( GetMutex() );
5842
5843 LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter();
5844 if ( pCurrencyFormatter )
5845 pCurrencyFormatter->SetMax(
5846 ImplCalcLongValue( Value, pCurrencyFormatter->GetDecimalDigits() ) );
5847 }
5848
getMax()5849 double VCLXCurrencyField::getMax()
5850 {
5851 ::vos::OGuard aGuard( GetMutex() );
5852
5853 LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter();
5854 return pCurrencyFormatter
5855 ? ImplCalcDoubleValue( (double)pCurrencyFormatter->GetMax(), pCurrencyFormatter->GetDecimalDigits() )
5856 : 0;
5857 }
5858
setFirst(double Value)5859 void VCLXCurrencyField::setFirst( double Value )
5860 {
5861 ::vos::OGuard aGuard( GetMutex() );
5862
5863 LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow();
5864 if ( pCurrencyField )
5865 pCurrencyField->SetFirst(
5866 ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) );
5867 }
5868
getFirst()5869 double VCLXCurrencyField::getFirst()
5870 {
5871 ::vos::OGuard aGuard( GetMutex() );
5872
5873 LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow();
5874 return pCurrencyField
5875 ? ImplCalcDoubleValue( (double)pCurrencyField->GetFirst(), pCurrencyField->GetDecimalDigits() )
5876 : 0;
5877 }
5878
setLast(double Value)5879 void VCLXCurrencyField::setLast( double Value )
5880 {
5881 ::vos::OGuard aGuard( GetMutex() );
5882
5883 LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow();
5884 if ( pCurrencyField )
5885 pCurrencyField->SetLast(
5886 ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) );
5887 }
5888
getLast()5889 double VCLXCurrencyField::getLast()
5890 {
5891 ::vos::OGuard aGuard( GetMutex() );
5892
5893 LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow();
5894 return pCurrencyField
5895 ? ImplCalcDoubleValue( (double)pCurrencyField->GetLast(), pCurrencyField->GetDecimalDigits() )
5896 : 0;
5897 }
5898
setSpinSize(double Value)5899 void VCLXCurrencyField::setSpinSize( double Value )
5900 {
5901 ::vos::OGuard aGuard( GetMutex() );
5902
5903 LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow();
5904 if ( pCurrencyField )
5905 pCurrencyField->SetSpinSize(
5906 ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) );
5907 }
5908
getSpinSize()5909 double VCLXCurrencyField::getSpinSize()
5910 {
5911 ::vos::OGuard aGuard( GetMutex() );
5912
5913 LongCurrencyField* pCurrencyField = (LongCurrencyField*) GetWindow();
5914 return pCurrencyField
5915 ? ImplCalcDoubleValue( (double)pCurrencyField->GetSpinSize(), pCurrencyField->GetDecimalDigits() )
5916 : 0;
5917 }
5918
setStrictFormat(sal_Bool bStrict)5919 void VCLXCurrencyField::setStrictFormat( sal_Bool bStrict )
5920 {
5921 VCLXFormattedSpinField::setStrictFormat( bStrict );
5922 }
5923
isStrictFormat()5924 sal_Bool VCLXCurrencyField::isStrictFormat()
5925 {
5926 return VCLXFormattedSpinField::isStrictFormat();
5927 }
5928
5929
setDecimalDigits(sal_Int16 Value)5930 void VCLXCurrencyField::setDecimalDigits( sal_Int16 Value )
5931 {
5932 ::vos::OGuard aGuard( GetMutex() );
5933
5934 LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter();
5935 if ( pCurrencyFormatter )
5936 {
5937 double n = getValue();
5938 pCurrencyFormatter->SetDecimalDigits( Value );
5939 setValue( n );
5940 }
5941 }
5942
getDecimalDigits()5943 sal_Int16 VCLXCurrencyField::getDecimalDigits()
5944 {
5945 ::vos::OGuard aGuard( GetMutex() );
5946
5947 LongCurrencyFormatter* pCurrencyFormatter = (LongCurrencyFormatter*) GetFormatter();
5948 return pCurrencyFormatter ? pCurrencyFormatter->GetDecimalDigits() : 0;
5949 }
5950
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)5951 void VCLXCurrencyField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value)
5952 {
5953 ::vos::OGuard aGuard( GetMutex() );
5954
5955 if ( GetWindow() )
5956 {
5957 sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
5958
5959 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5960 switch ( nPropType )
5961 {
5962 case BASEPROPERTY_VALUE_DOUBLE:
5963 {
5964 if ( bVoid )
5965 {
5966 ((LongCurrencyField*)GetWindow())->EnableEmptyFieldValue( sal_True );
5967 ((LongCurrencyField*)GetWindow())->SetEmptyFieldValue();
5968 }
5969 else
5970 {
5971 double d = 0;
5972 if ( Value >>= d )
5973 setValue( d );
5974 }
5975 }
5976 break;
5977 case BASEPROPERTY_VALUEMIN_DOUBLE:
5978 {
5979 double d = 0;
5980 if ( Value >>= d )
5981 setMin( d );
5982 }
5983 break;
5984 case BASEPROPERTY_VALUEMAX_DOUBLE:
5985 {
5986 double d = 0;
5987 if ( Value >>= d )
5988 setMax( d );
5989 }
5990 break;
5991 case BASEPROPERTY_VALUESTEP_DOUBLE:
5992 {
5993 double d = 0;
5994 if ( Value >>= d )
5995 setSpinSize( d );
5996 }
5997 break;
5998 case BASEPROPERTY_DECIMALACCURACY:
5999 {
6000 sal_Int16 n = sal_Int16();
6001 if ( Value >>= n )
6002 setDecimalDigits( n );
6003 }
6004 break;
6005 case BASEPROPERTY_CURRENCYSYMBOL:
6006 {
6007 ::rtl::OUString aString;
6008 if ( Value >>= aString )
6009 ((LongCurrencyField*)GetWindow())->SetCurrencySymbol( aString );
6010 }
6011 break;
6012 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
6013 {
6014 sal_Bool b = sal_Bool();
6015 if ( Value >>= b )
6016 ((LongCurrencyField*)GetWindow())->SetUseThousandSep( b );
6017 }
6018 break;
6019 default:
6020 {
6021 VCLXFormattedSpinField::setProperty( PropertyName, Value );
6022 }
6023 }
6024 }
6025 }
6026
getProperty(const::rtl::OUString & PropertyName)6027 ::com::sun::star::uno::Any VCLXCurrencyField::getProperty( const ::rtl::OUString& PropertyName )
6028 {
6029 ::vos::OGuard aGuard( GetMutex() );
6030
6031 ::com::sun::star::uno::Any aProp;
6032 FormatterBase* pFormatter = GetFormatter();
6033 if ( pFormatter )
6034 {
6035 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6036 switch ( nPropType )
6037 {
6038 case BASEPROPERTY_VALUE_DOUBLE:
6039 {
6040 aProp <<= (double) getValue();
6041 }
6042 break;
6043 case BASEPROPERTY_VALUEMIN_DOUBLE:
6044 {
6045 aProp <<= (double) getMin();
6046 }
6047 break;
6048 case BASEPROPERTY_VALUEMAX_DOUBLE:
6049 {
6050 aProp <<= (double) getMax();
6051 }
6052 break;
6053 case BASEPROPERTY_VALUESTEP_DOUBLE:
6054 {
6055 aProp <<= (double) getSpinSize();
6056 }
6057 break;
6058 case BASEPROPERTY_CURRENCYSYMBOL:
6059 {
6060 aProp <<= ::rtl::OUString( ((LongCurrencyField*)GetWindow())->GetCurrencySymbol() );
6061 }
6062 break;
6063 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
6064 {
6065 aProp <<= (sal_Bool) ((LongCurrencyField*)GetWindow())->IsUseThousandSep();
6066 }
6067 break;
6068 default:
6069 {
6070 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
6071 }
6072 }
6073 }
6074 return aProp;
6075 }
6076
6077 // ----------------------------------------------------
6078 // class VCLXPatternField
6079 // ----------------------------------------------------
6080
ImplGetPropertyIds(std::list<sal_uInt16> & rIds)6081 void VCLXPatternField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
6082 {
6083 PushPropertyIds( rIds,
6084 BASEPROPERTY_ALIGN,
6085 BASEPROPERTY_BACKGROUNDCOLOR,
6086 BASEPROPERTY_BORDER,
6087 BASEPROPERTY_BORDERCOLOR,
6088 BASEPROPERTY_DEFAULTCONTROL,
6089 BASEPROPERTY_EDITMASK,
6090 BASEPROPERTY_ENABLED,
6091 BASEPROPERTY_ENABLEVISIBLE,
6092 BASEPROPERTY_FONTDESCRIPTOR,
6093 BASEPROPERTY_HELPTEXT,
6094 BASEPROPERTY_HELPURL,
6095 BASEPROPERTY_LITERALMASK,
6096 BASEPROPERTY_MAXTEXTLEN,
6097 BASEPROPERTY_PRINTABLE,
6098 BASEPROPERTY_READONLY,
6099 BASEPROPERTY_STRICTFORMAT,
6100 BASEPROPERTY_TABSTOP,
6101 BASEPROPERTY_TEXT,
6102 BASEPROPERTY_HIDEINACTIVESELECTION,
6103 BASEPROPERTY_VERTICALALIGN,
6104 BASEPROPERTY_WRITING_MODE,
6105 BASEPROPERTY_CONTEXT_WRITING_MODE,
6106 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR,
6107 0);
6108 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
6109 }
6110
VCLXPatternField()6111 VCLXPatternField::VCLXPatternField()
6112 {
6113 }
6114
~VCLXPatternField()6115 VCLXPatternField::~VCLXPatternField()
6116 {
6117 }
6118
6119 // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)6120 ::com::sun::star::uno::Any VCLXPatternField::queryInterface( const ::com::sun::star::uno::Type & rType )
6121 {
6122 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
6123 SAL_STATIC_CAST( ::com::sun::star::awt::XPatternField*, this ) );
6124 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
6125 }
6126
6127 // ::com::sun::star::lang::XTypeProvider
6128 IMPL_XTYPEPROVIDER_START( VCLXPatternField )
6129 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPatternField>* ) NULL ),
6130 VCLXFormattedSpinField::getTypes()
6131 IMPL_XTYPEPROVIDER_END
6132
6133 void VCLXPatternField::setMasks( const ::rtl::OUString& EditMask, const ::rtl::OUString& LiteralMask )
6134 {
6135 ::vos::OGuard aGuard( GetMutex() );
6136
6137 PatternField* pPatternField = (PatternField*) GetWindow();
6138 if ( pPatternField )
6139 {
6140 pPatternField->SetMask( ByteString( UniString( EditMask ), RTL_TEXTENCODING_ASCII_US ), LiteralMask );
6141 }
6142 }
6143
getMasks(::rtl::OUString & EditMask,::rtl::OUString & LiteralMask)6144 void VCLXPatternField::getMasks( ::rtl::OUString& EditMask, ::rtl::OUString& LiteralMask )
6145 {
6146 ::vos::OGuard aGuard( GetMutex() );
6147
6148 PatternField* pPatternField = (PatternField*) GetWindow();
6149 if ( pPatternField )
6150 {
6151 EditMask = String( pPatternField->GetEditMask(), RTL_TEXTENCODING_ASCII_US );
6152 LiteralMask = pPatternField->GetLiteralMask();
6153 }
6154 }
6155
setString(const::rtl::OUString & Str)6156 void VCLXPatternField::setString( const ::rtl::OUString& Str )
6157 {
6158 ::vos::OGuard aGuard( GetMutex() );
6159
6160 PatternField* pPatternField = (PatternField*) GetWindow();
6161 if ( pPatternField )
6162 {
6163 pPatternField->SetString( Str );
6164 }
6165 }
6166
getString()6167 ::rtl::OUString VCLXPatternField::getString()
6168 {
6169 ::vos::OGuard aGuard( GetMutex() );
6170
6171 ::rtl::OUString aString;
6172 PatternField* pPatternField = (PatternField*) GetWindow();
6173 if ( pPatternField )
6174 aString = pPatternField->GetString();
6175 return aString;
6176 }
6177
setStrictFormat(sal_Bool bStrict)6178 void VCLXPatternField::setStrictFormat( sal_Bool bStrict )
6179 {
6180 VCLXFormattedSpinField::setStrictFormat( bStrict );
6181 }
6182
isStrictFormat()6183 sal_Bool VCLXPatternField::isStrictFormat()
6184 {
6185 return VCLXFormattedSpinField::isStrictFormat();
6186 }
6187
setProperty(const::rtl::OUString & PropertyName,const::com::sun::star::uno::Any & Value)6188 void VCLXPatternField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value)
6189 {
6190 ::vos::OGuard aGuard( GetMutex() );
6191
6192 if ( GetWindow() )
6193 {
6194 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6195 switch ( nPropType )
6196 {
6197 case BASEPROPERTY_EDITMASK:
6198 case BASEPROPERTY_LITERALMASK:
6199 {
6200 ::rtl::OUString aString;
6201 if ( Value >>= aString )
6202 {
6203 ::rtl::OUString aEditMask, aLiteralMask;
6204 getMasks( aEditMask, aLiteralMask );
6205 if ( nPropType == BASEPROPERTY_EDITMASK )
6206 aEditMask = aString;
6207 else
6208 aLiteralMask = aString;
6209 setMasks( aEditMask, aLiteralMask );
6210 }
6211 }
6212 break;
6213 default:
6214 {
6215 VCLXFormattedSpinField::setProperty( PropertyName, Value );
6216 }
6217 }
6218 }
6219 }
6220
getProperty(const::rtl::OUString & PropertyName)6221 ::com::sun::star::uno::Any VCLXPatternField::getProperty( const ::rtl::OUString& PropertyName )
6222 {
6223 ::vos::OGuard aGuard( GetMutex() );
6224
6225 ::com::sun::star::uno::Any aProp;
6226 if ( GetWindow() )
6227 {
6228 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6229 switch ( nPropType )
6230 {
6231 case BASEPROPERTY_EDITMASK:
6232 case BASEPROPERTY_LITERALMASK:
6233 {
6234 ::rtl::OUString aEditMask, aLiteralMask;
6235 getMasks( aEditMask, aLiteralMask );
6236 if ( nPropType == BASEPROPERTY_EDITMASK )
6237 aProp <<= aEditMask;
6238 else
6239 aProp <<= aLiteralMask;
6240 }
6241 break;
6242 default:
6243 {
6244 aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
6245 }
6246 }
6247 }
6248 return aProp;
6249 }
6250
6251 // ----------------------------------------------------
6252 // class VCLXToolBox
6253 // ----------------------------------------------------
VCLXToolBox()6254 VCLXToolBox::VCLXToolBox()
6255 {
6256 }
6257
~VCLXToolBox()6258 VCLXToolBox::~VCLXToolBox()
6259 {
6260 }
6261
CreateAccessibleContext()6262 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXToolBox::CreateAccessibleContext()
6263 {
6264 return getAccessibleFactory().createAccessibleContext( this );
6265 }
6266