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