Bug Summary

File:home/maarten/src/libreoffice/core/include/rtl/ref.hxx
Warning:line 113, column 13
Use of memory after it is freed

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name vclxwindows.cxx -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -D BOOST_ERROR_CODE_HEADER_ONLY -D BOOST_SYSTEM_NO_DEPRECATED -D CPPU_ENV=gcc3 -D LINUX -D OSL_DEBUG_LEVEL=1 -D SAL_LOG_INFO -D SAL_LOG_WARN -D UNIX -D UNX -D X86_64 -D _PTHREADS -D _REENTRANT -D TOOLKIT_DLLIMPLEMENTATION -D SVT_DLL_NAME="libsvtlo.so" -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/epoxy/include -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -I /home/maarten/src/libreoffice/core/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include/linux -I /home/maarten/src/libreoffice/core/config_host -I /home/maarten/src/libreoffice/core/toolkit/inc -I /home/maarten/src/libreoffice/core/toolkit/source -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/offapi/normal -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-missing-braces -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/maarten/src/libreoffice/core -ferror-limit 19 -fvisibility hidden -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -debug-info-kind=constructor -analyzer-output=html -faddrsig -o /home/maarten/tmp/wis/scan-build-libreoffice/output/report/2020-10-07-141433-9725-1 -x c++ /home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx

/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx

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/helper/accessiblefactory.hxx>
22#include <com/sun/star/awt/LineEndFormat.hpp>
23#include <com/sun/star/awt/ScrollBarOrientation.hpp>
24#include <com/sun/star/graphic/GraphicProvider.hpp>
25#include <com/sun/star/graphic/XGraphicProvider.hpp>
26#include <toolkit/helper/vclunohelper.hxx>
27#include <toolkit/helper/macros.hxx>
28#include <toolkit/helper/property.hxx>
29#include <toolkit/helper/convert.hxx>
30#include <cppuhelper/typeprovider.hxx>
31#include <cppuhelper/queryinterface.hxx>
32#include <com/sun/star/awt/VisualEffect.hpp>
33#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
34#include <com/sun/star/system/SystemShellExecute.hpp>
35#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
36#include <com/sun/star/resource/XStringResourceResolver.hpp>
37#include <com/sun/star/awt/ImageScaleMode.hpp>
38#include <com/sun/star/awt/XItemList.hpp>
39#include <com/sun/star/awt/TextAlign.hpp>
40#include <comphelper/namedvaluecollection.hxx>
41#include <comphelper/processfactory.hxx>
42#include <sal/log.hxx>
43
44#include <controls/filectrl.hxx>
45#include <controls/svmedit.hxx>
46#include <svl/zforlist.hxx>
47#include <vcl/toolkit/button.hxx>
48#include <vcl/toolkit/fmtfield.hxx>
49#include <vcl/graph.hxx>
50#include <vcl/toolkit/lstbox.hxx>
51#include <vcl/toolkit/combobox.hxx>
52#include <vcl/toolkit/field.hxx>
53#include <vcl/toolkit/fixedhyper.hxx>
54#include <vcl/toolkit/imgctrl.hxx>
55#include <vcl/toolkit/dialog.hxx>
56#include <vcl/toolkit/prgsbar.hxx>
57#include <vcl/scrbar.hxx>
58#include <vcl/svapp.hxx>
59#include <vcl/tabpage.hxx>
60#include <vcl/tabctrl.hxx>
61#include <vcl/settings.hxx>
62#include <tools/diagnose_ex.h>
63#include <tools/debug.hxx>
64
65#include <helper/imagealign.hxx>
66#include <helper/msgbox.hxx>
67#include <helper/tkresmgr.hxx>
68#include "vclxwindows_internal.hxx"
69
70using ::com::sun::star::uno::Any;
71using ::com::sun::star::uno::Reference;
72using ::com::sun::star::uno::makeAny;
73using ::com::sun::star::uno::RuntimeException;
74using ::com::sun::star::lang::EventObject;
75using ::com::sun::star::awt::ItemListEvent;
76using ::com::sun::star::awt::XItemList;
77using ::com::sun::star::graphic::XGraphic;
78using ::com::sun::star::graphic::XGraphicProvider;
79
80using namespace ::com::sun::star;
81using namespace ::com::sun::star::awt::VisualEffect;
82namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode;
83
84static double ImplCalcLongValue( double nValue, sal_uInt16 nDigits )
85{
86 double n = nValue;
87 for ( sal_uInt16 d = 0; d < nDigits; d++ )
88 n *= 10;
89 return n;
90}
91
92static double ImplCalcDoubleValue( double nValue, sal_uInt16 nDigits )
93{
94 double n = nValue;
95 for ( sal_uInt16 d = 0; d < nDigits; d++ )
96 n /= 10;
97 return n;
98}
99
100namespace toolkit
101{
102 /** sets the "face color" for button like controls (scroll bar, spin button)
103 */
104 void setButtonLikeFaceColor( vcl::Window* _pWindow, const css::uno::Any& _rColorValue )
105 {
106 AllSettings aSettings = _pWindow->GetSettings();
107 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
108
109 if ( !_rColorValue.hasValue() )
110 {
111 const StyleSettings& aAppStyle = Application::GetSettings().GetStyleSettings();
112 aStyleSettings.SetFaceColor( aAppStyle.GetFaceColor( ) );
113 aStyleSettings.SetCheckedColor( aAppStyle.GetCheckedColor( ) );
114 aStyleSettings.SetLightBorderColor( aAppStyle.GetLightBorderColor() );
115 aStyleSettings.SetLightColor( aAppStyle.GetLightColor() );
116 aStyleSettings.SetShadowColor( aAppStyle.GetShadowColor() );
117 aStyleSettings.SetDarkShadowColor( aAppStyle.GetDarkShadowColor() );
118 }
119 else
120 {
121 sal_Int32 nBackgroundColor = 0;
122 _rColorValue >>= nBackgroundColor;
123 aStyleSettings.SetFaceColor( Color(nBackgroundColor) );
124
125 // for the real background (everything except the buttons and the thumb),
126 // use an average between the desired color and "white"
127 Color aWhite( COL_WHITE );
128 Color aBackground( nBackgroundColor );
129 aBackground.SetRed( ( aBackground.GetRed() + aWhite.GetRed() ) / 2 );
130 aBackground.SetGreen( ( aBackground.GetGreen() + aWhite.GetGreen() ) / 2 );
131 aBackground.SetBlue( ( aBackground.GetBlue() + aWhite.GetBlue() ) / 2 );
132 aStyleSettings.SetCheckedColor( aBackground );
133
134 sal_Int32 nBackgroundLuminance = Color( nBackgroundColor ).GetLuminance();
135 sal_Int32 nWhiteLuminance = COL_WHITE.GetLuminance();
136
137 Color aLightShadow( nBackgroundColor );
138 aLightShadow.IncreaseLuminance( static_cast<sal_uInt8>( ( nWhiteLuminance - nBackgroundLuminance ) * 2 / 3 ) );
139 aStyleSettings.SetLightBorderColor( aLightShadow );
140
141 Color aLight( nBackgroundColor );
142 aLight.IncreaseLuminance( static_cast<sal_uInt8>( ( nWhiteLuminance - nBackgroundLuminance ) * 1 / 3 ) );
143 aStyleSettings.SetLightColor( aLight );
144
145 Color aShadow( nBackgroundColor );
146 aShadow.DecreaseLuminance( static_cast<sal_uInt8>( nBackgroundLuminance * 1 / 3 ) );
147 aStyleSettings.SetShadowColor( aShadow );
148
149 Color aDarkShadow( nBackgroundColor );
150 aDarkShadow.DecreaseLuminance( static_cast<sal_uInt8>( nBackgroundLuminance * 2 / 3 ) );
151 aStyleSettings.SetDarkShadowColor( aDarkShadow );
152 }
153
154 aSettings.SetStyleSettings( aStyleSettings );
155 _pWindow->SetSettings( aSettings, true );
156 }
157
158 Any getButtonLikeFaceColor( const vcl::Window* _pWindow )
159 {
160 Color nBackgroundColor = _pWindow->GetSettings().GetStyleSettings().GetFaceColor();
161 return makeAny( sal_Int32(nBackgroundColor) );
162 }
163
164 static void adjustBooleanWindowStyle( const Any& _rValue, vcl::Window* _pWindow, WinBits _nBits, bool _bInverseSemantics )
165 {
166 WinBits nStyle = _pWindow->GetStyle();
167 bool bValue( false );
168 OSL_VERIFY( _rValue >>= bValue )do { if (!(_rValue >>= bValue)) do { if (true &&
(!(0))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), (
"legacy.osl"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "168" ": "), "OSL_ASSERT: %s", "0"); } } while (false); }
while (0)
;
169 if ( bValue != _bInverseSemantics )
170 nStyle |= _nBits;
171 else
172 nStyle &= ~_nBits;
173 _pWindow->SetStyle( nStyle );
174 }
175
176 static void setVisualEffect( const Any& _rValue, vcl::Window* _pWindow )
177 {
178 AllSettings aSettings = _pWindow->GetSettings();
179 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
180
181 sal_Int16 nStyle = LOOK3D;
182 OSL_VERIFY( _rValue >>= nStyle )do { if (!(_rValue >>= nStyle)) do { if (true &&
(!(0))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), (
"legacy.osl"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "182" ": "), "OSL_ASSERT: %s", "0"); } } while (false); }
while (0)
;
183 switch ( nStyle )
184 {
185 case FLAT:
186 aStyleSettings.SetOptions( aStyleSettings.GetOptions() | StyleSettingsOptions::Mono );
187 break;
188 case LOOK3D:
189 default:
190 aStyleSettings.SetOptions( aStyleSettings.GetOptions() & ~StyleSettingsOptions::Mono );
191 }
192 aSettings.SetStyleSettings( aStyleSettings );
193 _pWindow->SetSettings( aSettings );
194 }
195
196 static Any getVisualEffect( vcl::Window const * _pWindow )
197 {
198 Any aEffect;
199
200 StyleSettings aStyleSettings = _pWindow->GetSettings().GetStyleSettings();
201 if ( aStyleSettings.GetOptions() & StyleSettingsOptions::Mono )
202 aEffect <<= sal_Int16(FLAT);
203 else
204 aEffect <<= sal_Int16(LOOK3D);
205 return aEffect;
206 }
207}
208
209
210
211
212void VCLXGraphicControl::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
213{
214 VCLXWindow::ImplGetPropertyIds( rIds );
215}
216
217void VCLXGraphicControl::ImplSetNewImage()
218{
219 OSL_PRECOND( GetWindow(), "VCLXGraphicControl::ImplSetNewImage: window is required to be not-NULL!" )do { if (true && (!(GetWindow()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "219" ": "), "%s", "VCLXGraphicControl::ImplSetNewImage: window is required to be not-NULL!"
); } } while (false)
;
220 VclPtr< Button > pButton = GetAsDynamic< Button >();
221 pButton->SetModeImage( GetImage() );
222}
223
224void VCLXGraphicControl::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags )
225{
226 SolarMutexGuard aGuard;
227
228 if ( GetWindow() )
229 {
230 Size aOldSize = GetWindow()->GetSizePixel();
231 VCLXWindow::setPosSize( X, Y, Width, Height, Flags );
232 if ( ( aOldSize.Width() != Width ) || ( aOldSize.Height() != Height ) )
233 ImplSetNewImage();
234 }
235}
236
237void VCLXGraphicControl::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
238{
239 SolarMutexGuard aGuard;
240
241 if ( !GetWindow() )
242 return;
243
244 sal_uInt16 nPropType = GetPropertyId( PropertyName );
245 switch ( nPropType )
246 {
247 case BASEPROPERTY_GRAPHIC117:
248 {
249 Reference< XGraphic > xGraphic;
250 OSL_VERIFY( Value >>= xGraphic )do { if (!(Value >>= xGraphic)) do { if (true &&
(!(0))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), (
"legacy.osl"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "250" ": "), "OSL_ASSERT: %s", "0"); } } while (false); }
while (0)
;
251 maImage = Image( xGraphic );
252 ImplSetNewImage();
253 }
254 break;
255
256 case BASEPROPERTY_IMAGEALIGN86:
257 {
258 WindowType eType = GetWindow()->GetType();
259 if ( ( eType == WindowType::PUSHBUTTON )
260 || ( eType == WindowType::RADIOBUTTON )
261 || ( eType == WindowType::CHECKBOX )
262 )
263 {
264 sal_Int16 nAlignment = sal_Int16();
265 if ( Value >>= nAlignment )
266 GetAs< Button >()->SetImageAlign( static_cast< ImageAlign >( nAlignment ) );
267 }
268 }
269 break;
270 case BASEPROPERTY_IMAGEPOSITION113:
271 {
272 WindowType eType = GetWindow()->GetType();
273 if ( ( eType == WindowType::PUSHBUTTON )
274 || ( eType == WindowType::RADIOBUTTON )
275 || ( eType == WindowType::CHECKBOX )
276 )
277 {
278 sal_Int16 nImagePosition = 2;
279 OSL_VERIFY( Value >>= nImagePosition )do { if (!(Value >>= nImagePosition)) do { if (true &&
(!(0))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), (
"legacy.osl"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "279" ": "), "OSL_ASSERT: %s", "0"); } } while (false); }
while (0)
;
280 GetAs<Button>()->SetImageAlign( ::toolkit::translateImagePosition( nImagePosition ) );
281 }
282 }
283 break;
284 default:
285 VCLXWindow::setProperty( PropertyName, Value );
286 break;
287 }
288}
289
290css::uno::Any VCLXGraphicControl::getProperty( const OUString& PropertyName )
291{
292 SolarMutexGuard aGuard;
293
294 css::uno::Any aProp;
295 if ( !GetWindow() )
296 return aProp;
297
298 sal_uInt16 nPropType = GetPropertyId( PropertyName );
299 switch ( nPropType )
300 {
301 case BASEPROPERTY_GRAPHIC117:
302 aProp <<= Graphic(maImage.GetBitmapEx()).GetXGraphic();
303 break;
304 case BASEPROPERTY_IMAGEALIGN86:
305 {
306 WindowType eType = GetWindow()->GetType();
307 if ( ( eType == WindowType::PUSHBUTTON )
308 || ( eType == WindowType::RADIOBUTTON )
309 || ( eType == WindowType::CHECKBOX )
310 )
311 {
312 aProp <<= ::toolkit::getCompatibleImageAlign(
313 GetAs<Button>()->GetImageAlign() );
314 }
315 }
316 break;
317 case BASEPROPERTY_IMAGEPOSITION113:
318 {
319 WindowType eType = GetWindow()->GetType();
320 if ( ( eType == WindowType::PUSHBUTTON )
321 || ( eType == WindowType::RADIOBUTTON )
322 || ( eType == WindowType::CHECKBOX )
323 )
324 {
325 aProp <<= ::toolkit::translateImagePosition(
326 GetAs< Button >()->GetImageAlign() );
327 }
328 }
329 break;
330 default:
331 {
332 aProp = VCLXWindow::getProperty( PropertyName );
333 }
334 break;
335 }
336 return aProp;
337}
338
339
340
341
342void VCLXButton::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
343{
344 PushPropertyIds( rIds,
345 BASEPROPERTY_BACKGROUNDCOLOR2,
346 BASEPROPERTY_DEFAULTBUTTON57,
347 BASEPROPERTY_DEFAULTCONTROL19,
348 BASEPROPERTY_ENABLED44,
349 BASEPROPERTY_ENABLEVISIBLE145,
350 BASEPROPERTY_FONTDESCRIPTOR8,
351 BASEPROPERTY_GRAPHIC117,
352 BASEPROPERTY_HELPTEXT73,
353 BASEPROPERTY_HELPURL58,
354 BASEPROPERTY_IMAGEALIGN86,
355 BASEPROPERTY_IMAGEPOSITION113,
356 BASEPROPERTY_IMAGEURL42,
357 BASEPROPERTY_LABEL20,
358 BASEPROPERTY_PRINTABLE45,
359 BASEPROPERTY_PUSHBUTTONTYPE88,
360 BASEPROPERTY_REPEAT101,
361 BASEPROPERTY_REPEAT_DELAY95,
362 BASEPROPERTY_STATE15,
363 BASEPROPERTY_TABSTOP14,
364 BASEPROPERTY_TOGGLE108,
365 BASEPROPERTY_FOCUSONCLICK109,
366 BASEPROPERTY_MULTILINE10,
367 BASEPROPERTY_ALIGN7,
368 BASEPROPERTY_VERTICALALIGN115,
369 BASEPROPERTY_WRITING_MODE138,
370 BASEPROPERTY_CONTEXT_WRITING_MODE139,
371 BASEPROPERTY_REFERENCE_DEVICE146,
372 0);
373 VCLXGraphicControl::ImplGetPropertyIds( rIds );
374}
375
376VCLXButton::VCLXButton()
377 :maActionListeners( *this )
378 ,maItemListeners( *this )
379{
380}
381
382VCLXButton::~VCLXButton()
383{
384}
385
386css::uno::Reference< css::accessibility::XAccessibleContext > VCLXButton::CreateAccessibleContext()
387{
388 return getAccessibleFactory().createAccessibleContext( this );
389}
390
391void VCLXButton::dispose()
392{
393 SolarMutexGuard aGuard;
394
395 css::lang::EventObject aObj;
396 aObj.Source = static_cast<cppu::OWeakObject*>(this);
397 maActionListeners.disposeAndClear( aObj );
398 maItemListeners.disposeAndClear( aObj );
399 VCLXGraphicControl::dispose();
400}
401
402void VCLXButton::addActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
403{
404 SolarMutexGuard aGuard;
405 maActionListeners.addInterface( l );
406}
407
408void VCLXButton::removeActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
409{
410 SolarMutexGuard aGuard;
411 maActionListeners.removeInterface( l );
412}
413
414void VCLXButton::addItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
415{
416 SolarMutexGuard aGuard;
417 maItemListeners.addInterface( l );
418}
419
420void VCLXButton::removeItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
421{
422 SolarMutexGuard aGuard;
423 maItemListeners.removeInterface( l );
424}
425
426void VCLXButton::setLabel( const OUString& rLabel )
427{
428 SolarMutexGuard aGuard;
429
430 VclPtr<vcl::Window> pWindow = GetWindow();
431 if ( pWindow )
432 pWindow->SetText( rLabel );
433}
434
435void VCLXButton::setActionCommand( const OUString& rCommand )
436{
437 SolarMutexGuard aGuard;
438
439 maActionCommand = rCommand;
440}
441
442css::awt::Size VCLXButton::getMinimumSize( )
443{
444 SolarMutexGuard aGuard;
445
446 Size aSz;
447 VclPtr< PushButton > pButton = GetAs< PushButton >();
448 if ( pButton )
449 aSz = pButton->CalcMinimumSize();
450 return AWTSize(aSz);
451}
452
453css::awt::Size VCLXButton::getPreferredSize( )
454{
455 css::awt::Size aSz = getMinimumSize();
456 aSz.Width += 16;
457 aSz.Height += 10;
458 return aSz;
459}
460
461css::awt::Size VCLXButton::calcAdjustedSize( const css::awt::Size& rNewSize )
462{
463 SolarMutexGuard aGuard;
464
465 Size aSz = VCLSize(rNewSize);
466 VclPtr< PushButton > pButton = GetAs< PushButton >();
467 if ( pButton )
468 {
469 Size aMinSz = pButton->CalcMinimumSize();
470 // no text, thus image
471 if ( pButton->GetText().isEmpty() )
472 {
473 if ( aSz.Width() < aMinSz.Width() )
474 aSz.setWidth( aMinSz.Width() );
475 if ( aSz.Height() < aMinSz.Height() )
476 aSz.setHeight( aMinSz.Height() );
477 }
478 else
479 {
480 if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
481 aSz.setHeight( aMinSz.Height() );
482 else
483 aSz = aMinSz;
484 }
485 }
486 return AWTSize(aSz);
487}
488
489void VCLXButton::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
490{
491 SolarMutexGuard aGuard;
492
493 VclPtr< Button > pButton = GetAs< Button >();
494 if ( !pButton )
495 return;
496
497 sal_uInt16 nPropType = GetPropertyId( PropertyName );
498 switch ( nPropType )
499 {
500 case BASEPROPERTY_FOCUSONCLICK109:
501 ::toolkit::adjustBooleanWindowStyle( Value, pButton, WB_NOPOINTERFOCUS, true );
502 break;
503
504 case BASEPROPERTY_TOGGLE108:
505 ::toolkit::adjustBooleanWindowStyle( Value, pButton, WB_TOGGLE, false );
506 break;
507
508 case BASEPROPERTY_DEFAULTBUTTON57:
509 {
510 WinBits nStyle = pButton->GetStyle() | WB_DEFBUTTON;
511 bool b = bool();
512 if ( ( Value >>= b ) && !b )
513 nStyle &= ~WB_DEFBUTTON;
514 pButton->SetStyle( nStyle );
515 }
516 break;
517 case BASEPROPERTY_STATE15:
518 {
519 if ( GetWindow()->GetType() == WindowType::PUSHBUTTON )
520 {
521 sal_Int16 n = sal_Int16();
522 if ( Value >>= n )
523 static_cast<PushButton*>(pButton.get())->SetState( static_cast<TriState>(n) );
524 }
525 }
526 break;
527 default:
528 {
529 VCLXGraphicControl::setProperty( PropertyName, Value );
530 }
531 }
532}
533
534css::uno::Any VCLXButton::getProperty( const OUString& PropertyName )
535{
536 SolarMutexGuard aGuard;
537
538 css::uno::Any aProp;
539 VclPtr< Button > pButton = GetAs< Button >();
540 if ( pButton )
541 {
542 sal_uInt16 nPropType = GetPropertyId( PropertyName );
543 switch ( nPropType )
544 {
545 case BASEPROPERTY_FOCUSONCLICK109:
546 aProp <<= ( ( pButton->GetStyle() & WB_NOPOINTERFOCUS ) == 0 );
547 break;
548
549 case BASEPROPERTY_TOGGLE108:
550 aProp <<= ( ( pButton->GetStyle() & WB_TOGGLE ) != 0 );
551 break;
552
553 case BASEPROPERTY_DEFAULTBUTTON57:
554 {
555 aProp <<= ( pButton->GetStyle() & WB_DEFBUTTON ) != 0;
556 }
557 break;
558 case BASEPROPERTY_STATE15:
559 {
560 if ( GetWindow()->GetType() == WindowType::PUSHBUTTON )
561 {
562 aProp <<= static_cast<sal_Int16>(static_cast<PushButton*>(pButton.get())->GetState());
563 }
564 }
565 break;
566 default:
567 {
568 aProp = VCLXGraphicControl::getProperty( PropertyName );
569 }
570 }
571 }
572 return aProp;
573}
574
575void VCLXButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
576{
577 switch ( rVclWindowEvent.GetId() )
578 {
579 case VclEventId::ButtonClick:
580 {
581 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
582 // since we call listeners below, there is a potential that we will be destroyed
583 // during the listener call. To prevent the resulting crashes, we keep us
584 // alive as long as we're here
585
586 if ( maActionListeners.getLength() )
587 {
588 css::awt::ActionEvent aEvent;
589 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
590 aEvent.ActionCommand = maActionCommand;
591
592 Callback aCallback = [ this, aEvent ]()
593 { this->maActionListeners.actionPerformed( aEvent ); };
594
595 ImplExecuteAsyncWithoutSolarLock( aCallback );
596 }
597 }
598 break;
599
600 case VclEventId::PushbuttonToggle:
601 {
602 PushButton& rButton = dynamic_cast< PushButton& >( *rVclWindowEvent.GetWindow() );
603
604 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
605 if ( maItemListeners.getLength() )
606 {
607 css::awt::ItemEvent aEvent;
608 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
609 aEvent.Selected = ( rButton.GetState() == TRISTATE_TRUE ) ? 1 : 0;
610 maItemListeners.itemStateChanged( aEvent );
611 }
612 }
613 break;
614
615 default:
616 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent );
617 break;
618 }
619}
620
621
622
623
624void VCLXImageControl::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
625{
626 PushPropertyIds( rIds,
627 BASEPROPERTY_BACKGROUNDCOLOR2,
628 BASEPROPERTY_BORDER6,
629 BASEPROPERTY_BORDERCOLOR112,
630 BASEPROPERTY_DEFAULTCONTROL19,
631 BASEPROPERTY_ENABLED44,
632 BASEPROPERTY_ENABLEVISIBLE145,
633 BASEPROPERTY_GRAPHIC117,
634 BASEPROPERTY_HELPTEXT73,
635 BASEPROPERTY_HELPURL58,
636 BASEPROPERTY_IMAGEURL42,
637 BASEPROPERTY_PRINTABLE45,
638 BASEPROPERTY_SCALEIMAGE87,
639 BASEPROPERTY_IMAGE_SCALE_MODE137,
640 BASEPROPERTY_TABSTOP14,
641 BASEPROPERTY_WRITING_MODE138,
642 BASEPROPERTY_CONTEXT_WRITING_MODE139,
643 0);
644 VCLXGraphicControl::ImplGetPropertyIds( rIds );
645}
646
647VCLXImageControl::VCLXImageControl()
648{
649}
650
651VCLXImageControl::~VCLXImageControl()
652{
653}
654
655void VCLXImageControl::ImplSetNewImage()
656{
657 OSL_PRECOND( GetWindow(), "VCLXImageControl::ImplSetNewImage: window is required to be not-NULL!" )do { if (true && (!(GetWindow()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "657" ": "), "%s", "VCLXImageControl::ImplSetNewImage: window is required to be not-NULL!"
); } } while (false)
;
658 VclPtr<ImageControl> pControl = GetAs< ImageControl >();
659 pControl->SetImage( GetImage() );
660}
661
662css::awt::Size VCLXImageControl::getMinimumSize( )
663{
664 SolarMutexGuard aGuard;
665
666 Size aSz = GetImage().GetSizePixel();
667 aSz = ImplCalcWindowSize( aSz );
668
669 return AWTSize(aSz);
670}
671
672css::awt::Size VCLXImageControl::getPreferredSize( )
673{
674 return getMinimumSize();
675}
676
677css::awt::Size VCLXImageControl::calcAdjustedSize( const css::awt::Size& rNewSize )
678{
679 SolarMutexGuard aGuard;
680
681 css::awt::Size aSz = rNewSize;
682 css::awt::Size aMinSz = getMinimumSize();
683 if ( aSz.Width < aMinSz.Width )
684 aSz.Width = aMinSz.Width;
685 if ( aSz.Height < aMinSz.Height )
686 aSz.Height = aMinSz.Height;
687 return aSz;
688}
689
690void VCLXImageControl::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
691{
692 SolarMutexGuard aGuard;
693
694 VclPtr< ImageControl > pImageControl = GetAs< ImageControl >();
695
696 sal_uInt16 nPropType = GetPropertyId( PropertyName );
697 switch ( nPropType )
698 {
699 case BASEPROPERTY_IMAGE_SCALE_MODE137:
700 {
701 sal_Int16 nScaleMode( ImageScaleMode::ANISOTROPIC );
702 if ( pImageControl && ( Value >>= nScaleMode ) )
703 {
704 pImageControl->SetScaleMode( nScaleMode );
705 }
706 }
707 break;
708
709 case BASEPROPERTY_SCALEIMAGE87:
710 {
711 // this is for compatibility only, nowadays, the ImageScaleMode property should be used
712 bool bScaleImage = false;
713 if ( pImageControl && ( Value >>= bScaleImage ) )
714 {
715 pImageControl->SetScaleMode( bScaleImage ? ImageScaleMode::ANISOTROPIC : ImageScaleMode::NONE );
716 }
717 }
718 break;
719
720 default:
721 VCLXGraphicControl::setProperty( PropertyName, Value );
722 break;
723 }
724}
725
726css::uno::Any VCLXImageControl::getProperty( const OUString& PropertyName )
727{
728 SolarMutexGuard aGuard;
729
730 css::uno::Any aProp;
731 VclPtr< ImageControl > pImageControl = GetAs< ImageControl >();
732 sal_uInt16 nPropType = GetPropertyId( PropertyName );
733
734 switch ( nPropType )
735 {
736 case BASEPROPERTY_IMAGE_SCALE_MODE137:
737 aProp <<= ( pImageControl ? pImageControl->GetScaleMode() : ImageScaleMode::ANISOTROPIC );
738 break;
739
740 case BASEPROPERTY_SCALEIMAGE87:
741 aProp <<= ( pImageControl && pImageControl->GetScaleMode() != ImageScaleMode::NONE );
742 break;
743
744 default:
745 aProp = VCLXGraphicControl::getProperty( PropertyName );
746 break;
747 }
748 return aProp;
749}
750
751
752
753
754void VCLXCheckBox::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
755{
756 PushPropertyIds( rIds,
757 BASEPROPERTY_DEFAULTCONTROL19,
758 BASEPROPERTY_ENABLED44,
759 BASEPROPERTY_ENABLEVISIBLE145,
760 BASEPROPERTY_FONTDESCRIPTOR8,
761 BASEPROPERTY_GRAPHIC117,
762 BASEPROPERTY_HELPTEXT73,
763 BASEPROPERTY_HELPURL58,
764 BASEPROPERTY_IMAGEPOSITION113,
765 BASEPROPERTY_IMAGEURL42,
766 BASEPROPERTY_LABEL20,
767 BASEPROPERTY_PRINTABLE45,
768 BASEPROPERTY_STATE15,
769 BASEPROPERTY_TABSTOP14,
770 BASEPROPERTY_TRISTATE56,
771 BASEPROPERTY_VISUALEFFECT111,
772 BASEPROPERTY_MULTILINE10,
773 BASEPROPERTY_BACKGROUNDCOLOR2,
774 BASEPROPERTY_ALIGN7,
775 BASEPROPERTY_VERTICALALIGN115,
776 BASEPROPERTY_WRITING_MODE138,
777 BASEPROPERTY_CONTEXT_WRITING_MODE139,
778 BASEPROPERTY_REFERENCE_DEVICE146,
779 0);
780 VCLXGraphicControl::ImplGetPropertyIds( rIds );
781}
782
783VCLXCheckBox::VCLXCheckBox() : maActionListeners( *this ), maItemListeners( *this )
784{
785}
786
787// css::uno::XInterface
788css::uno::Any VCLXCheckBox::queryInterface( const css::uno::Type & rType )
789{
790 css::uno::Any aRet = ::cppu::queryInterface( rType,
791 static_cast< css::awt::XButton* >(this),
792 static_cast< css::awt::XCheckBox* >(this) );
793 return (aRet.hasValue() ? aRet : VCLXGraphicControl::queryInterface( rType ));
794}
795
796IMPL_IMPLEMENTATION_ID( VCLXCheckBox )css::uno::Sequence< sal_Int8 > VCLXCheckBox::getImplementationId
() { return css::uno::Sequence<sal_Int8>(); }
797
798// css::lang::XTypeProvider
799css::uno::Sequence< css::uno::Type > VCLXCheckBox::getTypes()
800{
801 static const ::cppu::OTypeCollection aTypeList(
802 cppu::UnoType<css::lang::XTypeProvider>::get(),
803 cppu::UnoType<css::awt::XButton>::get(),
804 cppu::UnoType<css::awt::XCheckBox>::get(),
805 VCLXGraphicControl::getTypes()
806 );
807 return aTypeList.getTypes();
808}
809
810css::uno::Reference< css::accessibility::XAccessibleContext > VCLXCheckBox::CreateAccessibleContext()
811{
812 return getAccessibleFactory().createAccessibleContext( this );
813}
814
815void VCLXCheckBox::dispose()
816{
817 SolarMutexGuard aGuard;
818
819 css::lang::EventObject aObj;
820 aObj.Source = static_cast<cppu::OWeakObject*>(this);
821 maItemListeners.disposeAndClear( aObj );
822 VCLXGraphicControl::dispose();
823}
824
825void VCLXCheckBox::addItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
826{
827 SolarMutexGuard aGuard;
828 maItemListeners.addInterface( l );
829}
830
831void VCLXCheckBox::removeItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
832{
833 SolarMutexGuard aGuard;
834 maItemListeners.removeInterface( l );
835}
836
837void VCLXCheckBox::addActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
838{
839 SolarMutexGuard aGuard;
840 maActionListeners.addInterface( l );
841}
842
843void VCLXCheckBox::removeActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
844{
845 SolarMutexGuard aGuard;
846 maActionListeners.removeInterface( l );
847}
848
849void VCLXCheckBox::setActionCommand( const OUString& rCommand )
850{
851 SolarMutexGuard aGuard;
852 maActionCommand = rCommand;
853}
854
855void VCLXCheckBox::setLabel( const OUString& rLabel )
856{
857 SolarMutexGuard aGuard;
858
859 VclPtr<vcl::Window> pWindow = GetWindow();
860 if ( pWindow )
861 pWindow->SetText( rLabel );
862}
863
864void VCLXCheckBox::setState( sal_Int16 n )
865{
866 SolarMutexGuard aGuard;
867
868 VclPtr< CheckBox> pCheckBox = GetAs< CheckBox >();
869 if ( !pCheckBox)
870 return;
871
872 TriState eState;
873 switch ( n )
874 {
875 case 0: eState = TRISTATE_FALSE; break;
876 case 1: eState = TRISTATE_TRUE; break;
877 case 2: eState = TRISTATE_INDET; break;
878 default: eState = TRISTATE_FALSE;
879 }
880 pCheckBox->SetState( eState );
881
882 // #105198# call C++ click listeners (needed for accessibility)
883 // pCheckBox->GetClickHdl().Call( pCheckBox );
884
885 // #107218# Call same virtual methods and listeners like VCL would do after user interaction
886 SetSynthesizingVCLEvent( true );
887 pCheckBox->Toggle();
888 pCheckBox->Click();
889 SetSynthesizingVCLEvent( false );
890}
891
892sal_Int16 VCLXCheckBox::getState()
893{
894 SolarMutexGuard aGuard;
895
896 sal_Int16 nState = -1;
897 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
898 if ( pCheckBox )
899 {
900 switch ( pCheckBox->GetState() )
901 {
902 case TRISTATE_FALSE: nState = 0; break;
903 case TRISTATE_TRUE: nState = 1; break;
904 case TRISTATE_INDET: nState = 2; break;
905 default: OSL_FAIL( "VCLXCheckBox::getState(): unknown TriState!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "905" ": "), "%s", "VCLXCheckBox::getState(): unknown TriState!"
); } } while (false)
;
906 }
907 }
908
909 return nState;
910}
911
912void VCLXCheckBox::enableTriState( sal_Bool b )
913{
914 SolarMutexGuard aGuard;
915
916 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
917 if ( pCheckBox)
918 pCheckBox->EnableTriState( b );
919}
920
921css::awt::Size VCLXCheckBox::getMinimumSize()
922{
923 SolarMutexGuard aGuard;
924
925 Size aSz;
926 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
927 if ( pCheckBox )
928 aSz = pCheckBox->CalcMinimumSize();
929 return AWTSize(aSz);
930}
931
932css::awt::Size VCLXCheckBox::getPreferredSize()
933{
934 return getMinimumSize();
935}
936
937css::awt::Size VCLXCheckBox::calcAdjustedSize( const css::awt::Size& rNewSize )
938{
939 SolarMutexGuard aGuard;
940
941 Size aSz = VCLSize(rNewSize);
942 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
943 if ( pCheckBox )
944 {
945 Size aMinSz = pCheckBox->CalcMinimumSize(rNewSize.Width);
946 if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
947 aSz.setHeight( aMinSz.Height() );
948 else
949 aSz = aMinSz;
950 }
951 return AWTSize(aSz);
952}
953
954void VCLXCheckBox::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
955{
956 SolarMutexGuard aGuard;
957
958 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
959 if ( !pCheckBox )
960 return;
961
962 sal_uInt16 nPropType = GetPropertyId( PropertyName );
963 switch ( nPropType )
964 {
965 case BASEPROPERTY_VISUALEFFECT111:
966 ::toolkit::setVisualEffect( Value, pCheckBox );
967 break;
968
969 case BASEPROPERTY_TRISTATE56:
970 {
971 bool b = bool();
972 if ( Value >>= b )
973 pCheckBox->EnableTriState( b );
974 }
975 break;
976 case BASEPROPERTY_STATE15:
977 {
978 sal_Int16 n = sal_Int16();
979 if ( Value >>= n )
980 setState( n );
981 }
982 break;
983 default:
984 {
985 VCLXGraphicControl::setProperty( PropertyName, Value );
986 }
987 }
988}
989
990css::uno::Any VCLXCheckBox::getProperty( const OUString& PropertyName )
991{
992 SolarMutexGuard aGuard;
993
994 css::uno::Any aProp;
995 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
996 if ( pCheckBox )
997 {
998 sal_uInt16 nPropType = GetPropertyId( PropertyName );
999 switch ( nPropType )
1000 {
1001 case BASEPROPERTY_VISUALEFFECT111:
1002 aProp = ::toolkit::getVisualEffect( pCheckBox );
1003 break;
1004 case BASEPROPERTY_TRISTATE56:
1005 aProp <<= pCheckBox->IsTriStateEnabled();
1006 break;
1007 case BASEPROPERTY_STATE15:
1008 aProp <<= static_cast<sal_Int16>(pCheckBox->GetState());
1009 break;
1010 default:
1011 {
1012 aProp = VCLXGraphicControl::getProperty( PropertyName );
1013 }
1014 }
1015 }
1016 return aProp;
1017}
1018
1019void VCLXCheckBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1020{
1021 switch ( rVclWindowEvent.GetId() )
1022 {
1023 case VclEventId::CheckboxToggle:
1024 {
1025 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
1026 // since we call listeners below, there is a potential that we will be destroyed
1027 // in during the listener call. To prevent the resulting crashes, we keep us
1028 // alive as long as we're here
1029
1030 VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
1031 if ( pCheckBox )
1032 {
1033 if ( maItemListeners.getLength() )
1034 {
1035 css::awt::ItemEvent aEvent;
1036 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
1037 aEvent.Highlighted = 0;
1038 aEvent.Selected = pCheckBox->GetState();
1039 maItemListeners.itemStateChanged( aEvent );
1040 }
1041 if ( !IsSynthesizingVCLEvent() && maActionListeners.getLength() )
1042 {
1043 css::awt::ActionEvent aEvent;
1044 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
1045 aEvent.ActionCommand = maActionCommand;
1046 maActionListeners.actionPerformed( aEvent );
1047 }
1048 }
1049 }
1050 break;
1051
1052 default:
1053 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent );
1054 break;
1055 }
1056}
1057
1058
1059
1060void VCLXRadioButton::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
1061{
1062 PushPropertyIds( rIds,
1063 BASEPROPERTY_DEFAULTCONTROL19,
1064 BASEPROPERTY_ENABLED44,
1065 BASEPROPERTY_ENABLEVISIBLE145,
1066 BASEPROPERTY_FONTDESCRIPTOR8,
1067 BASEPROPERTY_GRAPHIC117,
1068 BASEPROPERTY_HELPTEXT73,
1069 BASEPROPERTY_HELPURL58,
1070 BASEPROPERTY_IMAGEPOSITION113,
1071 BASEPROPERTY_IMAGEURL42,
1072 BASEPROPERTY_LABEL20,
1073 BASEPROPERTY_PRINTABLE45,
1074 BASEPROPERTY_STATE15,
1075 BASEPROPERTY_TABSTOP14,
1076 BASEPROPERTY_VISUALEFFECT111,
1077 BASEPROPERTY_MULTILINE10,
1078 BASEPROPERTY_BACKGROUNDCOLOR2,
1079 BASEPROPERTY_ALIGN7,
1080 BASEPROPERTY_VERTICALALIGN115,
1081 BASEPROPERTY_WRITING_MODE138,
1082 BASEPROPERTY_CONTEXT_WRITING_MODE139,
1083 BASEPROPERTY_REFERENCE_DEVICE146,
1084 BASEPROPERTY_GROUPNAME154,
1085 0);
1086 VCLXGraphicControl::ImplGetPropertyIds( rIds );
1087}
1088
1089
1090VCLXRadioButton::VCLXRadioButton() : maItemListeners( *this ), maActionListeners( *this )
1091{
1092}
1093
1094// css::uno::XInterface
1095css::uno::Any VCLXRadioButton::queryInterface( const css::uno::Type & rType )
1096{
1097 css::uno::Any aRet = ::cppu::queryInterface( rType,
1098 static_cast< css::awt::XRadioButton* >(this),
1099 static_cast< css::awt::XButton* >(this) );
1100 return (aRet.hasValue() ? aRet : VCLXGraphicControl::queryInterface( rType ));
1101}
1102
1103IMPL_IMPLEMENTATION_ID( VCLXRadioButton )css::uno::Sequence< sal_Int8 > VCLXRadioButton::getImplementationId
() { return css::uno::Sequence<sal_Int8>(); }
1104
1105// css::lang::XTypeProvider
1106css::uno::Sequence< css::uno::Type > VCLXRadioButton::getTypes()
1107{
1108 static const ::cppu::OTypeCollection aTypeList(
1109 cppu::UnoType<css::lang::XTypeProvider>::get(),
1110 cppu::UnoType<css::awt::XRadioButton>::get(),
1111 cppu::UnoType<css::awt::XButton>::get(),
1112 VCLXGraphicControl::getTypes()
1113 );
1114 return aTypeList.getTypes();
1115}
1116
1117css::uno::Reference< css::accessibility::XAccessibleContext > VCLXRadioButton::CreateAccessibleContext()
1118{
1119 return getAccessibleFactory().createAccessibleContext( this );
1120}
1121
1122void VCLXRadioButton::dispose()
1123{
1124 SolarMutexGuard aGuard;
1125
1126 css::lang::EventObject aObj;
1127 aObj.Source = static_cast<cppu::OWeakObject*>(this);
1128 maItemListeners.disposeAndClear( aObj );
1129 VCLXGraphicControl::dispose();
1130}
1131
1132void VCLXRadioButton::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
1133{
1134 SolarMutexGuard aGuard;
1135
1136 VclPtr< RadioButton > pButton = GetAs< RadioButton >();
1137 if ( !pButton )
1138 return;
1139
1140 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1141 switch ( nPropType )
1142 {
1143 case BASEPROPERTY_VISUALEFFECT111:
1144 ::toolkit::setVisualEffect( Value, pButton );
1145 break;
1146
1147 case BASEPROPERTY_STATE15:
1148 {
1149 sal_Int16 n = sal_Int16();
1150 if ( Value >>= n )
1151 {
1152 bool b = n != 0;
1153 if ( pButton->IsRadioCheckEnabled() )
1154 pButton->Check( b );
1155 else
1156 pButton->SetState( b );
1157 }
1158 }
1159 break;
1160 case BASEPROPERTY_AUTOTOGGLE59:
1161 {
1162 bool b = bool();
1163 if ( Value >>= b )
1164 pButton->EnableRadioCheck( b );
1165 }
1166 break;
1167 default:
1168 {
1169 VCLXGraphicControl::setProperty( PropertyName, Value );
1170 }
1171 }
1172}
1173
1174css::uno::Any VCLXRadioButton::getProperty( const OUString& PropertyName )
1175{
1176 SolarMutexGuard aGuard;
1177
1178 css::uno::Any aProp;
1179 VclPtr< RadioButton > pButton = GetAs< RadioButton >();
1180 if ( pButton )
1181 {
1182 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1183 switch ( nPropType )
1184 {
1185 case BASEPROPERTY_VISUALEFFECT111:
1186 aProp = ::toolkit::getVisualEffect( pButton );
1187 break;
1188 case BASEPROPERTY_STATE15:
1189 aProp <<= static_cast<sal_Int16>( pButton->IsChecked() ? 1 : 0 );
1190 break;
1191 case BASEPROPERTY_AUTOTOGGLE59:
1192 aProp <<= pButton->IsRadioCheckEnabled();
1193 break;
1194 default:
1195 {
1196 aProp = VCLXGraphicControl::getProperty( PropertyName );
1197 }
1198 }
1199 }
1200 return aProp;
1201}
1202
1203void VCLXRadioButton::addItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
1204{
1205 SolarMutexGuard aGuard;
1206 maItemListeners.addInterface( l );
1207}
1208
1209void VCLXRadioButton::removeItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
1210{
1211 SolarMutexGuard aGuard;
1212 maItemListeners.removeInterface( l );
1213}
1214
1215void VCLXRadioButton::addActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
1216{
1217 SolarMutexGuard aGuard;
1218 maActionListeners.addInterface( l );
1219}
1220
1221void VCLXRadioButton::removeActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
1222{
1223 SolarMutexGuard aGuard;
1224 maActionListeners.removeInterface( l );
1225}
1226
1227void VCLXRadioButton::setLabel( const OUString& rLabel )
1228{
1229 SolarMutexGuard aGuard;
1230
1231 VclPtr<vcl::Window> pWindow = GetWindow();
1232 if ( pWindow )
1233 pWindow->SetText( rLabel );
1234}
1235
1236void VCLXRadioButton::setActionCommand( const OUString& rCommand )
1237{
1238 SolarMutexGuard aGuard;
1239 maActionCommand = rCommand;
1240}
1241
1242void VCLXRadioButton::setState( sal_Bool b )
1243{
1244 SolarMutexGuard aGuard;
1245
1246 VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >();
1247 if ( pRadioButton)
1248 {
1249 pRadioButton->Check( b );
1250 // #102717# item listeners are called, but not C++ click listeners in StarOffice code => call click hdl
1251 // But this is needed in old code because Accessibility API uses it.
1252 // pRadioButton->GetClickHdl().Call( pRadioButton );
1253
1254 // #107218# Call same virtual methods and listeners like VCL would do after user interaction
1255 SetSynthesizingVCLEvent( true );
1256 pRadioButton->Click();
1257 SetSynthesizingVCLEvent( false );
1258 }
1259}
1260
1261sal_Bool VCLXRadioButton::getState()
1262{
1263 SolarMutexGuard aGuard;
1264
1265 VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >();
1266 return pRadioButton && pRadioButton->IsChecked();
1267}
1268
1269css::awt::Size VCLXRadioButton::getMinimumSize( )
1270{
1271 SolarMutexGuard aGuard;
1272
1273 Size aSz;
1274 VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >();
1275 if ( pRadioButton )
1276 aSz = pRadioButton->CalcMinimumSize();
1277 return AWTSize(aSz);
1278}
1279
1280css::awt::Size VCLXRadioButton::getPreferredSize( )
1281{
1282 return getMinimumSize();
1283}
1284
1285css::awt::Size VCLXRadioButton::calcAdjustedSize( const css::awt::Size& rNewSize )
1286{
1287 SolarMutexGuard aGuard;
1288
1289 Size aSz = VCLSize(rNewSize);
1290 VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >();
1291 if ( pRadioButton )
1292 {
1293 Size aMinSz = pRadioButton->CalcMinimumSize(rNewSize.Width);
1294 if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
1295 aSz.setHeight( aMinSz.Height() );
1296 else
1297 aSz = aMinSz;
1298 }
1299 return AWTSize(aSz);
1300}
1301
1302void VCLXRadioButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1303{
1304 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
1305 // since we call listeners below, there is a potential that we will be destroyed
1306 // in during the listener call. To prevent the resulting crashes, we keep us
1307 // alive as long as we're here
1308
1309 switch ( rVclWindowEvent.GetId() )
1310 {
1311 case VclEventId::ButtonClick:
1312 if ( !IsSynthesizingVCLEvent() && maActionListeners.getLength() )
1313 {
1314 css::awt::ActionEvent aEvent;
1315 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
1316 aEvent.ActionCommand = maActionCommand;
1317 maActionListeners.actionPerformed( aEvent );
1318 }
1319 ImplClickedOrToggled( false );
1320 break;
1321
1322 case VclEventId::RadiobuttonToggle:
1323 ImplClickedOrToggled( true );
1324 break;
1325
1326 default:
1327 VCLXGraphicControl::ProcessWindowEvent( rVclWindowEvent );
1328 break;
1329 }
1330}
1331
1332void VCLXRadioButton::ImplClickedOrToggled( bool bToggled )
1333{
1334 // In the forms, RadioChecked is not enabled, call itemStateChanged only for click
1335 // In the dialog editor, RadioChecked is enabled, call itemStateChanged only for bToggled
1336 VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >();
1337 if ( pRadioButton && ( pRadioButton->IsRadioCheckEnabled() == bToggled ) && ( bToggled || pRadioButton->IsStateChanged() ) && maItemListeners.getLength() )
1338 {
1339 css::awt::ItemEvent aEvent;
1340 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
1341 aEvent.Highlighted = 0;
1342 aEvent.Selected = pRadioButton->IsChecked() ? 1 : 0;
1343 maItemListeners.itemStateChanged( aEvent );
1344 }
1345}
1346
1347
1348
1349void VCLXSpinField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
1350{
1351 PushPropertyIds( rIds,
1352 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR116,
1353 0 );
1354 VCLXEdit::ImplGetPropertyIds( rIds );
1355}
1356
1357VCLXSpinField::VCLXSpinField() : maSpinListeners( *this )
1358{
1359}
1360
1361// css::uno::XInterface
1362css::uno::Any VCLXSpinField::queryInterface( const css::uno::Type & rType )
1363{
1364 css::uno::Any aRet = ::cppu::queryInterface( rType,
1365 static_cast< css::awt::XSpinField* >(this) );
1366 return (aRet.hasValue() ? aRet : VCLXEdit::queryInterface( rType ));
1367}
1368
1369IMPL_IMPLEMENTATION_ID( VCLXSpinField )css::uno::Sequence< sal_Int8 > VCLXSpinField::getImplementationId
() { return css::uno::Sequence<sal_Int8>(); }
1370
1371// css::lang::XTypeProvider
1372css::uno::Sequence< css::uno::Type > VCLXSpinField::getTypes()
1373{
1374 static const ::cppu::OTypeCollection aTypeList(
1375 cppu::UnoType<css::lang::XTypeProvider>::get(),
1376 cppu::UnoType<css::awt::XSpinField>::get(),
1377 VCLXEdit::getTypes()
1378 );
1379 return aTypeList.getTypes();
1380}
1381
1382void VCLXSpinField::addSpinListener( const css::uno::Reference< css::awt::XSpinListener > & l )
1383{
1384 SolarMutexGuard aGuard;
1385 maSpinListeners.addInterface( l );
1386}
1387
1388void VCLXSpinField::removeSpinListener( const css::uno::Reference< css::awt::XSpinListener > & l )
1389{
1390 SolarMutexGuard aGuard;
1391 maSpinListeners.removeInterface( l );
1392}
1393
1394void VCLXSpinField::up()
1395{
1396 SolarMutexGuard aGuard;
1397
1398 VclPtr< SpinField > pSpinField = GetAs< SpinField >();
1399 if ( pSpinField )
1400 pSpinField->Up();
1401}
1402
1403void VCLXSpinField::down()
1404{
1405 SolarMutexGuard aGuard;
1406
1407 VclPtr< SpinField > pSpinField = GetAs< SpinField >();
1408 if ( pSpinField )
1409 pSpinField->Down();
1410}
1411
1412void VCLXSpinField::first()
1413{
1414 SolarMutexGuard aGuard;
1415
1416 VclPtr< SpinField > pSpinField = GetAs< SpinField >();
1417 if ( pSpinField )
1418 pSpinField->First();
1419}
1420
1421void VCLXSpinField::last()
1422{
1423 SolarMutexGuard aGuard;
1424
1425 VclPtr< SpinField > pSpinField = GetAs< SpinField >();
1426 if ( pSpinField )
1427 pSpinField->Last();
1428}
1429
1430void VCLXSpinField::enableRepeat( sal_Bool bRepeat )
1431{
1432 SolarMutexGuard aGuard;
1433
1434 VclPtr<vcl::Window> pWindow = GetWindow();
1435 if ( pWindow )
1436 {
1437 WinBits nStyle = pWindow->GetStyle();
1438 if ( bRepeat )
1439 nStyle |= WB_REPEAT;
1440 else
1441 nStyle &= ~WB_REPEAT;
1442 pWindow->SetStyle( nStyle );
1443 }
1444}
1445
1446void VCLXSpinField::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1447{
1448 switch ( rVclWindowEvent.GetId() )
1449 {
1450 case VclEventId::SpinfieldUp:
1451 case VclEventId::SpinfieldDown:
1452 case VclEventId::SpinfieldFirst:
1453 case VclEventId::SpinfieldLast:
1454 {
1455 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
1456 // since we call listeners below, there is a potential that we will be destroyed
1457 // in during the listener call. To prevent the resulting crashes, we keep us
1458 // alive as long as we're here
1459
1460 if ( maSpinListeners.getLength() )
1461 {
1462 css::awt::SpinEvent aEvent;
1463 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
1464 switch ( rVclWindowEvent.GetId() )
1465 {
1466 case VclEventId::SpinfieldUp: maSpinListeners.up( aEvent );
1467 break;
1468 case VclEventId::SpinfieldDown: maSpinListeners.down( aEvent );
1469 break;
1470 case VclEventId::SpinfieldFirst: maSpinListeners.first( aEvent );
1471 break;
1472 case VclEventId::SpinfieldLast: maSpinListeners.last( aEvent );
1473 break;
1474 default: break;
1475 }
1476
1477 }
1478 }
1479 break;
1480
1481 default:
1482 VCLXEdit::ProcessWindowEvent( rVclWindowEvent );
1483 break;
1484 }
1485}
1486
1487
1488
1489void VCLXListBox::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
1490{
1491 PushPropertyIds( rIds,
1492 BASEPROPERTY_BACKGROUNDCOLOR2,
1493 BASEPROPERTY_BORDER6,
1494 BASEPROPERTY_BORDERCOLOR112,
1495 BASEPROPERTY_DEFAULTCONTROL19,
1496 BASEPROPERTY_DROPDOWN9,
1497 BASEPROPERTY_ENABLED44,
1498 BASEPROPERTY_ENABLEVISIBLE145,
1499 BASEPROPERTY_FONTDESCRIPTOR8,
1500 BASEPROPERTY_HELPTEXT73,
1501 BASEPROPERTY_HELPURL58,
1502 BASEPROPERTY_LINECOUNT21,
1503 BASEPROPERTY_MULTISELECTION50,
1504 BASEPROPERTY_MULTISELECTION_SIMPLEMODE152,
1505 BASEPROPERTY_ITEM_SEPARATOR_POS153,
1506 BASEPROPERTY_PRINTABLE45,
1507 BASEPROPERTY_SELECTEDITEMS51,
1508 BASEPROPERTY_STRINGITEMLIST11,
1509 BASEPROPERTY_TYPEDITEMLIST169,
1510 BASEPROPERTY_TABSTOP14,
1511 BASEPROPERTY_READONLY43,
1512 BASEPROPERTY_ALIGN7,
1513 BASEPROPERTY_WRITING_MODE138,
1514 BASEPROPERTY_CONTEXT_WRITING_MODE139,
1515 BASEPROPERTY_REFERENCE_DEVICE146,
1516 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR116,
1517 0);
1518 VCLXWindow::ImplGetPropertyIds( rIds );
1519}
1520
1521
1522VCLXListBox::VCLXListBox()
1523 : maActionListeners( *this ),
1524 maItemListeners( *this )
1525{
1526}
1527
1528void VCLXListBox::dispose()
1529{
1530 SolarMutexGuard aGuard;
1531
1532 css::lang::EventObject aObj;
1533 aObj.Source = static_cast<cppu::OWeakObject*>(this);
1534 maItemListeners.disposeAndClear( aObj );
1535 maActionListeners.disposeAndClear( aObj );
1536 VCLXWindow::dispose();
1537}
1538
1539void VCLXListBox::addItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
1540{
1541 SolarMutexGuard aGuard;
1542 maItemListeners.addInterface( l );
1543}
1544
1545void VCLXListBox::removeItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
1546{
1547 SolarMutexGuard aGuard;
1548 maItemListeners.removeInterface( l );
1549}
1550
1551void VCLXListBox::addActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
1552{
1553 SolarMutexGuard aGuard;
1554 maActionListeners.addInterface( l );
1555}
1556
1557void VCLXListBox::removeActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
1558{
1559 SolarMutexGuard aGuard;
1560 maActionListeners.removeInterface( l );
1561}
1562
1563void VCLXListBox::addItem( const OUString& aItem, sal_Int16 nPos )
1564{
1565 SolarMutexGuard aGuard;
1566 VclPtr< ListBox > pBox = GetAs< ListBox >();
1567 if ( pBox )
1568 pBox->InsertEntry( aItem, nPos );
1569}
1570
1571void VCLXListBox::addItems( const css::uno::Sequence< OUString>& aItems, sal_Int16 nPos )
1572{
1573 SolarMutexGuard aGuard;
1574 VclPtr< ListBox > pBox = GetAs< ListBox >();
1575 if ( !pBox )
1576 return;
1577
1578 sal_uInt16 nP = nPos;
1579 for ( auto const & item : aItems )
1580 {
1581 if ( nP == 0xFFFF )
1582 {
1583 OSL_FAIL( "VCLXListBox::addItems: too many entries!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "1583" ": "), "%s", "VCLXListBox::addItems: too many entries!"
); } } while (false)
;
1584 // skip remaining entries, list cannot hold them, anyway
1585 break;
1586 }
1587
1588 pBox->InsertEntry( item, nP++ );
1589 }
1590}
1591
1592void VCLXListBox::removeItems( sal_Int16 nPos, sal_Int16 nCount )
1593{
1594 SolarMutexGuard aGuard;
1595 VclPtr< ListBox > pBox = GetAs< ListBox >();
1596 if ( pBox )
1597 {
1598 for ( sal_Int16 n = nCount; n; )
1599 pBox->RemoveEntry( nPos + (--n) );
1600 }
1601}
1602
1603sal_Int16 VCLXListBox::getItemCount()
1604{
1605 SolarMutexGuard aGuard;
1606
1607 VclPtr< ListBox > pBox = GetAs< ListBox >();
1608 return pBox ? pBox->GetEntryCount() : 0;
1609}
1610
1611OUString VCLXListBox::getItem( sal_Int16 nPos )
1612{
1613 SolarMutexGuard aGuard;
1614
1615 OUString aItem;
1616 VclPtr< ListBox > pBox = GetAs< ListBox >();
1617 if ( pBox )
1618 aItem = pBox->GetEntry( nPos );
1619 return aItem;
1620}
1621
1622css::uno::Sequence< OUString> VCLXListBox::getItems()
1623{
1624 SolarMutexGuard aGuard;
1625
1626 css::uno::Sequence< OUString> aSeq;
1627 VclPtr< ListBox > pBox = GetAs< ListBox >();
1628 if ( pBox )
1629 {
1630 auto n = pBox->GetEntryCount();
1631 aSeq = css::uno::Sequence< OUString>( n );
1632 while (n)
1633 {
1634 --n;
1635 aSeq.getArray()[n] = pBox->GetEntry( n );
1636 }
1637 }
1638 return aSeq;
1639}
1640
1641sal_Int16 VCLXListBox::getSelectedItemPos()
1642{
1643 SolarMutexGuard aGuard;
1644 VclPtr< ListBox > pBox = GetAs< ListBox >();
1645 return pBox ? pBox->GetSelectedEntryPos() : 0;
1646}
1647
1648css::uno::Sequence<sal_Int16> VCLXListBox::getSelectedItemsPos()
1649{
1650 SolarMutexGuard aGuard;
1651
1652 css::uno::Sequence<sal_Int16> aSeq;
1653 VclPtr< ListBox > pBox = GetAs< ListBox >();
1654 if ( pBox )
1655 {
1656 const sal_Int32 nSelEntries = pBox->GetSelectedEntryCount();
1657 aSeq = css::uno::Sequence<sal_Int16>( nSelEntries );
1658 for ( sal_Int32 n = 0; n < nSelEntries; ++n )
1659 aSeq.getArray()[n] = pBox->GetSelectedEntryPos( n );
1660 }
1661 return aSeq;
1662}
1663
1664OUString VCLXListBox::getSelectedItem()
1665{
1666 SolarMutexGuard aGuard;
1667
1668 OUString aItem;
1669 VclPtr< ListBox > pBox = GetAs< ListBox >();
1670 if ( pBox )
1671 aItem = pBox->GetSelectedEntry();
1672 return aItem;
1673}
1674
1675css::uno::Sequence< OUString> VCLXListBox::getSelectedItems()
1676{
1677 SolarMutexGuard aGuard;
1678
1679 css::uno::Sequence< OUString> aSeq;
1680 VclPtr< ListBox > pBox = GetAs< ListBox >();
1681 if ( pBox )
1682 {
1683 const sal_Int32 nSelEntries = pBox->GetSelectedEntryCount();
1684 aSeq = css::uno::Sequence< OUString>( nSelEntries );
1685 for ( sal_Int32 n = 0; n < nSelEntries; ++n )
1686 aSeq.getArray()[n] = pBox->GetSelectedEntry( n );
1687 }
1688 return aSeq;
1689}
1690
1691void VCLXListBox::selectItemPos( sal_Int16 nPos, sal_Bool bSelect )
1692{
1693 SolarMutexGuard aGuard;
1694
1695 VclPtr< ListBox > pBox = GetAs< ListBox >();
1696 if ( pBox && ( pBox->IsEntryPosSelected( nPos ) != bool(bSelect) ) )
1697 {
1698 pBox->SelectEntryPos( nPos, bSelect );
1699
1700 // VCL doesn't call select handler after API call.
1701 // ImplCallItemListeners();
1702
1703 // #107218# Call same listeners like VCL would do after user interaction
1704 SetSynthesizingVCLEvent( true );
1705 pBox->Select();
1706 SetSynthesizingVCLEvent( false );
1707 }
1708}
1709
1710void VCLXListBox::selectItemsPos( const css::uno::Sequence<sal_Int16>& aPositions, sal_Bool bSelect )
1711{
1712 SolarMutexGuard aGuard;
1713
1714 VclPtr< ListBox > pBox = GetAs< ListBox >();
1715 if ( !pBox )
1716 return;
1717
1718 std::vector<sal_Int32> aPositionVec;
1719 aPositionVec.reserve(aPositions.getLength());
1720
1721 bool bChanged = false;
1722 for ( auto n = aPositions.getLength(); n; )
1723 {
1724 const auto nPos = aPositions.getConstArray()[--n];
1725 if ( pBox->IsEntryPosSelected( nPos ) != bool(bSelect) )
1726 {
1727 aPositionVec.push_back(nPos);
1728 bChanged = true;
1729 }
1730 }
1731
1732 if ( !bChanged )
1733 return;
1734
1735 bool bOrigUpdateMode = pBox->IsUpdateMode();
1736 pBox->SetUpdateMode(false);
1737
1738 pBox->SelectEntriesPos(aPositionVec, bSelect);
1739
1740 pBox->SetUpdateMode(bOrigUpdateMode);
1741
1742 // VCL doesn't call select handler after API call.
1743 // ImplCallItemListeners();
1744
1745 // #107218# Call same listeners like VCL would do after user interaction
1746 SetSynthesizingVCLEvent( true );
1747 pBox->Select();
1748 SetSynthesizingVCLEvent( false );
1749}
1750
1751void VCLXListBox::selectItem( const OUString& rItemText, sal_Bool bSelect )
1752{
1753 SolarMutexGuard aGuard;
1754
1755 VclPtr< ListBox > pBox = GetAs< ListBox >();
1756 if ( pBox )
1757 {
1758 selectItemPos( pBox->GetEntryPos( rItemText ), bSelect );
1759 }
1760}
1761
1762void VCLXListBox::setDropDownLineCount( sal_Int16 nLines )
1763{
1764 SolarMutexGuard aGuard;
1765 VclPtr< ListBox > pBox = GetAs< ListBox >();
1766 if ( pBox )
1767 pBox->SetDropDownLineCount( nLines );
1768}
1769
1770sal_Int16 VCLXListBox::getDropDownLineCount()
1771{
1772 SolarMutexGuard aGuard;
1773
1774 sal_Int16 nLines = 0;
1775 VclPtr< ListBox > pBox = GetAs< ListBox >();
1776 if ( pBox )
1777 nLines = pBox->GetDropDownLineCount();
1778 return nLines;
1779}
1780
1781sal_Bool VCLXListBox::isMutipleMode()
1782{
1783 SolarMutexGuard aGuard;
1784 bool bMulti = false;
1785 VclPtr< ListBox > pBox = GetAs< ListBox >();
1786 if ( pBox )
1787 bMulti = pBox->IsMultiSelectionEnabled();
1788 return bMulti;
1789}
1790
1791void VCLXListBox::setMultipleMode( sal_Bool bMulti )
1792{
1793 SolarMutexGuard aGuard;
1794 VclPtr< ListBox > pBox = GetAs< ListBox >();
1795 if ( pBox )
1796 pBox->EnableMultiSelection( bMulti );
1797}
1798
1799void VCLXListBox::makeVisible( sal_Int16 nEntry )
1800{
1801 SolarMutexGuard aGuard;
1802 VclPtr< ListBox > pBox = GetAs< ListBox >();
1803 if ( pBox )
1804 pBox->SetTopEntry( nEntry );
1805}
1806
1807void VCLXListBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1808{
1809 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
1810 // since we call listeners below, there is a potential that we will be destroyed
1811 // in during the listener call. To prevent the resulting crashes, we keep us
1812 // alive as long as we're here
1813
1814 switch ( rVclWindowEvent.GetId() )
1815 {
1816 case VclEventId::ListboxSelect:
1817 {
1818 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1819 if( pListBox )
1820 {
1821 bool bDropDown = ( pListBox->GetStyle() & WB_DROPDOWN ) != 0;
1822 if ( bDropDown && !IsSynthesizingVCLEvent() && maActionListeners.getLength() )
1823 {
1824 // Call ActionListener on DropDown event
1825 css::awt::ActionEvent aEvent;
1826 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
1827 aEvent.ActionCommand = pListBox->GetSelectedEntry();
1828 maActionListeners.actionPerformed( aEvent );
1829 }
1830
1831 if ( maItemListeners.getLength() )
1832 {
1833 ImplCallItemListeners();
1834 }
1835 }
1836 }
1837 break;
1838
1839 case VclEventId::ListboxDoubleClick:
1840 if ( GetWindow() && maActionListeners.getLength() )
1841 {
1842 css::awt::ActionEvent aEvent;
1843 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
1844 aEvent.ActionCommand = GetAs<ListBox>()->GetSelectedEntry();
1845 maActionListeners.actionPerformed( aEvent );
1846 }
1847 break;
1848
1849 default:
1850 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
1851 break;
1852 }
1853}
1854
1855css::uno::Reference< css::accessibility::XAccessibleContext > VCLXListBox::CreateAccessibleContext()
1856{
1857 SolarMutexGuard aGuard;
1858
1859 return getAccessibleFactory().createAccessibleContext( this );
1860}
1861
1862void VCLXListBox::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
1863{
1864 SolarMutexGuard aGuard;
1865 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1866 if ( !pListBox )
1867 return;
1868
1869 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1870 switch ( nPropType )
1871 {
1872 case BASEPROPERTY_ITEM_SEPARATOR_POS153:
1873 {
1874 sal_Int16 nSeparatorPos(0);
1875 if ( Value >>= nSeparatorPos )
1876 pListBox->SetSeparatorPos( nSeparatorPos );
1877 }
1878 break;
1879 case BASEPROPERTY_READONLY43:
1880 {
1881 bool b = false;
1882 if ( Value >>= b )
1883 pListBox->SetReadOnly( b);
1884 }
1885 break;
1886 case BASEPROPERTY_MULTISELECTION50:
1887 {
1888 bool b = false;
1889 if ( Value >>= b )
1890 pListBox->EnableMultiSelection( b );
1891 }
1892 break;
1893 case BASEPROPERTY_MULTISELECTION_SIMPLEMODE152:
1894 ::toolkit::adjustBooleanWindowStyle( Value, pListBox, WB_SIMPLEMODE, false );
1895 break;
1896 case BASEPROPERTY_LINECOUNT21:
1897 {
1898 sal_Int16 n = 0;
1899 if ( Value >>= n )
1900 pListBox->SetDropDownLineCount( n );
1901 }
1902 break;
1903 case BASEPROPERTY_STRINGITEMLIST11:
1904 {
1905 css::uno::Sequence< OUString> aItems;
1906 if ( Value >>= aItems )
1907 {
1908 pListBox->Clear();
1909 addItems( aItems, 0 );
1910 }
1911 }
1912 break;
1913 case BASEPROPERTY_SELECTEDITEMS51:
1914 {
1915 css::uno::Sequence<sal_Int16> aItems;
1916 if ( Value >>= aItems )
1917 {
1918 for ( auto n = pListBox->GetEntryCount(); n; )
1919 pListBox->SelectEntryPos( --n, false );
1920
1921 if ( aItems.hasElements() )
1922 selectItemsPos( aItems, true );
1923 else
1924 pListBox->SetNoSelection();
1925
1926 if ( !pListBox->GetSelectedEntryCount() )
1927 pListBox->SetTopEntry( 0 );
1928 }
1929 }
1930 break;
1931 default:
1932 {
1933 VCLXWindow::setProperty( PropertyName, Value );
1934 }
1935 }
1936}
1937
1938css::uno::Any VCLXListBox::getProperty( const OUString& PropertyName )
1939{
1940 SolarMutexGuard aGuard;
1941 css::uno::Any aProp;
1942 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1943 if ( pListBox )
1944 {
1945 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1946 switch ( nPropType )
1947 {
1948 case BASEPROPERTY_ITEM_SEPARATOR_POS153:
1949 aProp <<= sal_Int16( pListBox->GetSeparatorPos() );
1950 break;
1951 case BASEPROPERTY_READONLY43:
1952 {
1953 aProp <<= pListBox->IsReadOnly();
1954 }
1955 break;
1956 case BASEPROPERTY_MULTISELECTION50:
1957 {
1958 aProp <<= pListBox->IsMultiSelectionEnabled();
1959 }
1960 break;
1961 case BASEPROPERTY_MULTISELECTION_SIMPLEMODE152:
1962 {
1963 aProp <<= ( ( pListBox->GetStyle() & WB_SIMPLEMODE ) == 0 );
1964 }
1965 break;
1966 case BASEPROPERTY_LINECOUNT21:
1967 {
1968 aProp <<= static_cast<sal_Int16>(pListBox->GetDropDownLineCount());
1969 }
1970 break;
1971 case BASEPROPERTY_STRINGITEMLIST11:
1972 {
1973 const sal_Int32 nItems = pListBox->GetEntryCount();
1974 css::uno::Sequence< OUString> aSeq( nItems );
1975 OUString* pStrings = aSeq.getArray();
1976 for ( sal_Int32 n = 0; n < nItems; ++n )
1977 pStrings[n] = pListBox->GetEntry( n );
1978 aProp <<= aSeq;
1979
1980 }
1981 break;
1982 default:
1983 {
1984 aProp = VCLXWindow::getProperty( PropertyName );
1985 }
1986 }
1987 }
1988 return aProp;
1989}
1990
1991css::awt::Size VCLXListBox::getMinimumSize( )
1992{
1993 SolarMutexGuard aGuard;
1994 Size aSz;
1995 VclPtr< ListBox > pListBox = GetAs< ListBox >();
1996 if ( pListBox )
1997 aSz = pListBox->CalcMinimumSize();
1998 return AWTSize(aSz);
1999}
2000
2001css::awt::Size VCLXListBox::getPreferredSize( )
2002{
2003 SolarMutexGuard aGuard;
2004 Size aSz;
2005 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2006 if ( pListBox )
2007 {
2008 aSz = pListBox->CalcMinimumSize();
2009 if ( pListBox->GetStyle() & WB_DROPDOWN )
2010 aSz.AdjustHeight(4 );
2011 }
2012 return AWTSize(aSz);
2013}
2014
2015css::awt::Size VCLXListBox::calcAdjustedSize( const css::awt::Size& rNewSize )
2016{
2017 SolarMutexGuard aGuard;
2018 Size aSz = VCLSize(rNewSize);
2019 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2020 if ( pListBox )
2021 aSz = pListBox->CalcAdjustedSize( aSz );
2022 return AWTSize(aSz);
2023}
2024
2025css::awt::Size VCLXListBox::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines )
2026{
2027 SolarMutexGuard aGuard;
2028 Size aSz;
2029 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2030 if ( pListBox )
2031 aSz = pListBox->CalcBlockSize( nCols, nLines );
2032 return AWTSize(aSz);
2033}
2034
2035void VCLXListBox::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines )
2036{
2037 SolarMutexGuard aGuard;
2038 nCols = nLines = 0;
2039 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2040 if ( pListBox )
2041 {
2042 sal_uInt16 nC, nL;
2043 pListBox->GetMaxVisColumnsAndLines( nC, nL );
2044 nCols = nC;
2045 nLines = nL;
2046 }
2047}
2048
2049void VCLXListBox::ImplCallItemListeners()
2050{
2051 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2052 if ( pListBox && maItemListeners.getLength() )
2053 {
2054 css::awt::ItemEvent aEvent;
2055 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
2056 aEvent.Highlighted = 0;
2057
2058 // Set to 0xFFFF on multiple selection, selected entry ID otherwise
2059 aEvent.Selected = (pListBox->GetSelectedEntryCount() == 1 ) ? pListBox->GetSelectedEntryPos() : 0xFFFF;
2060
2061 maItemListeners.itemStateChanged( aEvent );
2062 }
2063}
2064namespace
2065{
2066 Image lcl_getImageFromURL( const OUString& i_rImageURL )
2067 {
2068 if ( i_rImageURL.isEmpty() )
2069 return Image();
2070
2071 try
2072 {
2073 Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
2074 Reference< XGraphicProvider > xProvider(graphic::GraphicProvider::create(xContext));
2075 ::comphelper::NamedValueCollection aMediaProperties;
2076 aMediaProperties.put( "URL", i_rImageURL );
2077 Reference< XGraphic > xGraphic = xProvider->queryGraphic( aMediaProperties.getPropertyValues() );
2078 return Image( xGraphic );
2079 }
2080 catch( const uno::Exception& )
2081 {
2082 DBG_UNHANDLED_EXCEPTION("toolkit")DbgUnhandledException( DbgGetCaughtException(), __func__, "/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2082" ": ", "toolkit" );
;
2083 }
2084 return Image();
2085 }
2086}
2087void SAL_CALL VCLXListBox::listItemInserted( const ItemListEvent& i_rEvent )
2088{
2089 SolarMutexGuard aGuard;
2090 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2091
2092 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemInserted: no ListBox?!" )if( !(pListBox) ) { do { if (true && (!(pListBox))) {
sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2092" ": "), "%s", "VCLXListBox::listItemInserted: no ListBox?!"
); } } while (false); return; }
;
2093 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition <= pListBox->GetEntryCount() ),if( !(( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent
.ItemPosition <= pListBox->GetEntryCount() )) ) { do { if
(true && (!(( i_rEvent.ItemPosition >= 0 ) &&
( i_rEvent.ItemPosition <= pListBox->GetEntryCount() )
))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2094" ": "), "%s", "VCLXListBox::listItemInserted: illegal (inconsistent) item position!"
); } } while (false); return; }
2094 "VCLXListBox::listItemInserted: illegal (inconsistent) item position!" )if( !(( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent
.ItemPosition <= pListBox->GetEntryCount() )) ) { do { if
(true && (!(( i_rEvent.ItemPosition >= 0 ) &&
( i_rEvent.ItemPosition <= pListBox->GetEntryCount() )
))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2094" ": "), "%s", "VCLXListBox::listItemInserted: illegal (inconsistent) item position!"
); } } while (false); return; }
;
2095 pListBox->InsertEntry(
2096 i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : OUString(),
2097 i_rEvent.ItemImageURL.IsPresent ? TkResMgr::getImageFromURL( i_rEvent.ItemImageURL.Value ) : Image(),
2098 i_rEvent.ItemPosition );
2099}
2100
2101void SAL_CALL VCLXListBox::listItemRemoved( const ItemListEvent& i_rEvent )
2102{
2103 SolarMutexGuard aGuard;
2104 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2105
2106 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemRemoved: no ListBox?!" )if( !(pListBox) ) { do { if (true && (!(pListBox))) {
sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2106" ": "), "%s", "VCLXListBox::listItemRemoved: no ListBox?!"
); } } while (false); return; }
;
2107 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < pListBox->GetEntryCount() ),if( !(( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent
.ItemPosition < pListBox->GetEntryCount() )) ) { do { if
(true && (!(( i_rEvent.ItemPosition >= 0 ) &&
( i_rEvent.ItemPosition < pListBox->GetEntryCount() ))
)) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2108" ": "), "%s", "VCLXListBox::listItemRemoved: illegal (inconsistent) item position!"
); } } while (false); return; }
2108 "VCLXListBox::listItemRemoved: illegal (inconsistent) item position!" )if( !(( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent
.ItemPosition < pListBox->GetEntryCount() )) ) { do { if
(true && (!(( i_rEvent.ItemPosition >= 0 ) &&
( i_rEvent.ItemPosition < pListBox->GetEntryCount() ))
)) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2108" ": "), "%s", "VCLXListBox::listItemRemoved: illegal (inconsistent) item position!"
); } } while (false); return; }
;
2109
2110 pListBox->RemoveEntry( i_rEvent.ItemPosition );
2111}
2112
2113void SAL_CALL VCLXListBox::listItemModified( const ItemListEvent& i_rEvent )
2114{
2115 SolarMutexGuard aGuard;
2116 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2117
2118 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" )if( !(pListBox) ) { do { if (true && (!(pListBox))) {
sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2118" ": "), "%s", "VCLXListBox::listItemModified: no ListBox?!"
); } } while (false); return; }
;
2119 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < pListBox->GetEntryCount() ),if( !(( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent
.ItemPosition < pListBox->GetEntryCount() )) ) { do { if
(true && (!(( i_rEvent.ItemPosition >= 0 ) &&
( i_rEvent.ItemPosition < pListBox->GetEntryCount() ))
)) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2120" ": "), "%s", "VCLXListBox::listItemModified: illegal (inconsistent) item position!"
); } } while (false); return; }
2120 "VCLXListBox::listItemModified: illegal (inconsistent) item position!" )if( !(( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent
.ItemPosition < pListBox->GetEntryCount() )) ) { do { if
(true && (!(( i_rEvent.ItemPosition >= 0 ) &&
( i_rEvent.ItemPosition < pListBox->GetEntryCount() ))
)) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2120" ": "), "%s", "VCLXListBox::listItemModified: illegal (inconsistent) item position!"
); } } while (false); return; }
;
2121
2122 // VCL's ListBox does not support changing an entry's text or image, so remove and re-insert
2123
2124 const OUString sNewText = i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : pListBox->GetEntry( i_rEvent.ItemPosition );
2125 const Image aNewImage( i_rEvent.ItemImageURL.IsPresent ? TkResMgr::getImageFromURL( i_rEvent.ItemImageURL.Value ) : pListBox->GetEntryImage( i_rEvent.ItemPosition ) );
2126
2127 pListBox->RemoveEntry( i_rEvent.ItemPosition );
2128 pListBox->InsertEntry( sNewText, aNewImage, i_rEvent.ItemPosition );
2129}
2130
2131void SAL_CALL VCLXListBox::allItemsRemoved( const EventObject& )
2132{
2133 SolarMutexGuard aGuard;
2134
2135 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2136 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" )if( !(pListBox) ) { do { if (true && (!(pListBox))) {
sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2136" ": "), "%s", "VCLXListBox::listItemModified: no ListBox?!"
); } } while (false); return; }
;
2137
2138 pListBox->Clear();
2139}
2140
2141void SAL_CALL VCLXListBox::itemListChanged( const EventObject& i_rEvent )
2142{
2143 SolarMutexGuard aGuard;
2144
2145 VclPtr< ListBox > pListBox = GetAs< ListBox >();
2146 ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" )if( !(pListBox) ) { do { if (true && (!(pListBox))) {
sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2146" ": "), "%s", "VCLXListBox::listItemModified: no ListBox?!"
); } } while (false); return; }
;
2147
2148 pListBox->Clear();
2149
2150 uno::Reference< beans::XPropertySet > xPropSet( i_rEvent.Source, uno::UNO_QUERY_THROW );
2151 uno::Reference< beans::XPropertySetInfo > xPSI( xPropSet->getPropertySetInfo(), uno::UNO_SET_THROW );
2152 uno::Reference< resource::XStringResourceResolver > xStringResourceResolver;
2153 if ( xPSI->hasPropertyByName("ResourceResolver") )
2154 {
2155 xStringResourceResolver.set(
2156 xPropSet->getPropertyValue("ResourceResolver"),
2157 uno::UNO_QUERY
2158 );
2159 }
2160
2161
2162 Reference< XItemList > xItemList( i_rEvent.Source, uno::UNO_QUERY_THROW );
2163 const uno::Sequence< beans::Pair< OUString, OUString > > aItems = xItemList->getAllItems();
2164 for ( const auto& rItem : aItems )
2165 {
2166 OUString aLocalizationKey( rItem.First );
2167 if ( xStringResourceResolver.is() && aLocalizationKey.startsWith("&") )
2168 {
2169 aLocalizationKey = xStringResourceResolver->resolveString(aLocalizationKey.copy( 1 ));
2170 }
2171 pListBox->InsertEntry( aLocalizationKey, lcl_getImageFromURL( rItem.Second ) );
2172 }
2173}
2174
2175void SAL_CALL VCLXListBox::disposing( const EventObject& i_rEvent )
2176{
2177 // just disambiguate
2178 VCLXWindow::disposing( i_rEvent );
2179}
2180
2181
2182
2183
2184void VCLXMessageBox::GetPropertyIds( std::vector< sal_uInt16 > &rIds )
2185{
2186 VCLXTopWindow::ImplGetPropertyIds( rIds );
2187}
2188
2189VCLXMessageBox::VCLXMessageBox()
2190{
2191}
2192
2193VCLXMessageBox::~VCLXMessageBox()
2194{
2195}
2196
2197// css::uno::XInterface
2198css::uno::Any VCLXMessageBox::queryInterface( const css::uno::Type & rType )
2199{
2200 css::uno::Any aRet = ::cppu::queryInterface( rType,
2201 static_cast< css::awt::XMessageBox* >(this) );
2202 return (aRet.hasValue() ? aRet : VCLXTopWindow::queryInterface( rType ));
2203}
2204
2205IMPL_IMPLEMENTATION_ID( VCLXMessageBox )css::uno::Sequence< sal_Int8 > VCLXMessageBox::getImplementationId
() { return css::uno::Sequence<sal_Int8>(); }
2206
2207// css::lang::XTypeProvider
2208css::uno::Sequence< css::uno::Type > VCLXMessageBox::getTypes()
2209{
2210 static const ::cppu::OTypeCollection aTypeList(
2211 cppu::UnoType<css::lang::XTypeProvider>::get(),
2212 cppu::UnoType<css::awt::XMessageBox>::get(),
2213 VCLXTopWindow::getTypes()
2214 );
2215 return aTypeList.getTypes();
2216}
2217
2218void VCLXMessageBox::setCaptionText( const OUString& rText )
2219{
2220 SolarMutexGuard aGuard;
2221
2222 VclPtr<vcl::Window> pWindow = GetWindow();
2223 if ( pWindow )
2224 pWindow->SetText( rText );
2225}
2226
2227OUString VCLXMessageBox::getCaptionText()
2228{
2229 SolarMutexGuard aGuard;
2230
2231 OUString aText;
2232 VclPtr<vcl::Window> pWindow = GetWindow();
2233 if ( pWindow )
2234 aText = pWindow->GetText();
2235 return aText;
2236}
2237
2238void VCLXMessageBox::setMessageText( const OUString& rText )
2239{
2240 SolarMutexGuard aGuard;
2241 VclPtr< MessBox > pBox = GetAs< MessBox >();
2242 if ( pBox )
2243 pBox->SetMessText( rText );
2244}
2245
2246OUString VCLXMessageBox::getMessageText()
2247{
2248 SolarMutexGuard aGuard;
2249 OUString aText;
2250 VclPtr< MessBox > pBox = GetAs< MessBox >();
2251 if ( pBox )
2252 aText = pBox->GetMessText();
2253 return aText;
2254}
2255
2256sal_Int16 VCLXMessageBox::execute()
2257{
2258 SolarMutexGuard aGuard;
2259 VclPtr< MessBox > pBox = GetAs< MessBox >();
2260 return pBox ? pBox->Execute() : 0;
2261}
2262
2263css::awt::Size SAL_CALL VCLXMessageBox::getMinimumSize()
2264{
2265 SolarMutexGuard aGuard;
2266 return css::awt::Size( 250, 100 );
2267}
2268
2269
2270
2271void VCLXDialog::GetPropertyIds( std::vector< sal_uInt16 > &rIds )
2272{
2273 VCLXTopWindow::ImplGetPropertyIds( rIds );
2274}
2275
2276VCLXDialog::VCLXDialog()
2277{
2278 SAL_INFO("toolkit", "XDialog created")do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "toolkit")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "XDialog created") ==
1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("toolkit"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2278" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "XDialog created"), 0); } else { ::std
::ostringstream sal_detail_stream; sal_detail_stream <<
"XDialog created"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2278" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "XDialog created") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2278" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "XDialog created"), 0); } else { ::std
::ostringstream sal_detail_stream; sal_detail_stream <<
"XDialog created"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2278" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
2279}
2280
2281VCLXDialog::~VCLXDialog()
2282{
2283 SAL_INFO("toolkit", __FUNCTION__)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "toolkit")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << __FUNCTION__) == 1) {
::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("toolkit")
, ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2283" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << __FUNCTION__), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << __FUNCTION__; ::
sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("toolkit"),
("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2283" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << __FUNCTION__) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2283" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << __FUNCTION__), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << __FUNCTION__; ::
sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("toolkit"),
("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2283" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
2284}
2285
2286// css::uno::XInterface
2287css::uno::Any VCLXDialog::queryInterface( const css::uno::Type & rType )
2288{
2289 css::uno::Any aRet = ::cppu::queryInterface( rType,
2290 static_cast< css::awt::XDialog2* >(this),
2291 static_cast< css::awt::XDialog* >(this) );
2292 return (aRet.hasValue() ? aRet : VCLXTopWindow::queryInterface( rType ));
2293}
2294
2295IMPL_IMPLEMENTATION_ID( VCLXDialog )css::uno::Sequence< sal_Int8 > VCLXDialog::getImplementationId
() { return css::uno::Sequence<sal_Int8>(); }
2296
2297// css::lang::XTypeProvider
2298css::uno::Sequence< css::uno::Type > VCLXDialog::getTypes()
2299{
2300 static const ::cppu::OTypeCollection aTypeList(
2301 cppu::UnoType<css::lang::XTypeProvider>::get(),
2302 cppu::UnoType<css::awt::XDialog2>::get(),
2303 cppu::UnoType<css::awt::XDialog>::get(),
2304 VCLXTopWindow::getTypes()
2305 );
2306 return aTypeList.getTypes();
2307}
2308
2309void SAL_CALL VCLXDialog::endDialog( ::sal_Int32 i_result )
2310{
2311 SolarMutexGuard aGuard;
2312 VclPtr<Dialog> pDialog = GetAsDynamic< Dialog >();
2313 if ( pDialog )
2314 pDialog->EndDialog( i_result );
2315}
2316
2317void SAL_CALL VCLXDialog::setHelpId( const OUString& rId )
2318{
2319 SolarMutexGuard aGuard;
2320 VclPtr< vcl::Window > pWindow = GetWindow();
2321 if ( pWindow )
2322 pWindow->SetHelpId( OUStringToOString( rId, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ) );
2323}
2324
2325void VCLXDialog::setTitle( const OUString& Title )
2326{
2327 SolarMutexGuard aGuard;
2328 VclPtr< vcl::Window > pWindow = GetWindow();
2329 if ( pWindow )
2330 pWindow->SetText( Title );
2331}
2332
2333OUString VCLXDialog::getTitle()
2334{
2335 SolarMutexGuard aGuard;
2336
2337 OUString aTitle;
2338 VclPtr< vcl::Window > pWindow = GetWindow();
2339 if ( pWindow )
2340 aTitle = pWindow->GetText();
2341 return aTitle;
2342}
2343
2344sal_Int16 VCLXDialog::execute()
2345{
2346 SolarMutexGuard aGuard;
2347
2348 sal_Int16 nRet = 0;
2349 if ( GetWindow() )
2350 {
2351 VclPtr< Dialog > pDlg = GetAs< Dialog >();
2352 vcl::Window* pParent = pDlg->GetWindow( GetWindowType::ParentOverlap );
2353 vcl::Window* pOldParent = nullptr;
2354 vcl::Window* pSetParent = nullptr;
2355 if ( pParent && !pParent->IsReallyVisible() )
2356 {
2357 pOldParent = pDlg->GetParent();
2358 vcl::Window* pFrame = pDlg->GetWindow( GetWindowType::Frame );
2359 if( pFrame != pDlg )
2360 {
2361 pDlg->SetParent( pFrame );
2362 pSetParent = pFrame;
2363 }
2364 }
2365
2366 nRet = pDlg->Execute();
2367
2368 // set the parent back only in case no new parent was set from outside
2369 // in other words, revert only own changes
2370 if ( pOldParent && pDlg->GetParent() == pSetParent )
2371 pDlg->SetParent( pOldParent );
2372 }
2373 return nRet;
2374}
2375
2376void VCLXDialog::endExecute()
2377{
2378 endDialog(0);
2379}
2380
2381void SAL_CALL VCLXDialog::draw( sal_Int32 nX, sal_Int32 nY )
2382{
2383 SolarMutexGuard aGuard;
2384 VclPtr< vcl::Window > pWindow = GetWindow();
2385 if ( pWindow )
2386 {
2387 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
2388 if ( !pDev )
2389 pDev = pWindow->GetParent();
2390
2391 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
2392 pWindow->Draw( pDev, aPos, DrawFlags::NoControls );
2393 }
2394}
2395
2396css::awt::DeviceInfo VCLXDialog::getInfo()
2397{
2398 css::awt::DeviceInfo aInfo = VCLXDevice::getInfo();
2399
2400 SolarMutexGuard aGuard;
2401 VclPtr< Dialog > pDlg = GetAs< Dialog >();
2402 if ( pDlg )
2403 pDlg->GetDrawWindowBorder( aInfo.LeftInset, aInfo.TopInset, aInfo.RightInset, aInfo.BottomInset );
2404
2405 return aInfo;
2406}
2407
2408void SAL_CALL VCLXDialog::setProperty(
2409 const OUString& PropertyName,
2410 const css::uno::Any& Value )
2411{
2412 SolarMutexGuard aGuard;
2413 VclPtr< Dialog > pDialog = GetAs< Dialog >();
2414 if ( !pDialog )
2415 return;
2416
2417 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
2418
2419 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2420 switch ( nPropType )
2421 {
2422 case BASEPROPERTY_GRAPHIC117:
2423 {
2424 Reference< XGraphic > xGraphic;
2425 if (( Value >>= xGraphic ) && xGraphic.is() )
2426 {
2427 Graphic aImage(xGraphic);
2428
2429 Wallpaper aWallpaper(aImage.GetBitmapEx());
2430 aWallpaper.SetStyle( WallpaperStyle::Scale );
2431 pDialog->SetBackground( aWallpaper );
2432 }
2433 else if ( bVoid || !xGraphic.is() )
2434 {
2435 Color aColor = pDialog->GetControlBackground();
2436 if ( aColor == COL_AUTO )
2437 aColor = pDialog->GetSettings().GetStyleSettings().GetDialogColor();
2438
2439 Wallpaper aWallpaper( aColor );
2440 pDialog->SetBackground( aWallpaper );
2441 }
2442 }
2443 break;
2444
2445 default:
2446 {
2447 VCLXContainer::setProperty( PropertyName, Value );
2448 }
2449 }
2450}
2451
2452
2453
2454VCLXMultiPage::VCLXMultiPage() : maTabListeners( *this ), mTabId( 1 )
2455{
2456 SAL_INFO("toolkit", "VCLXMultiPage::VCLXMultiPage()" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "toolkit")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "VCLXMultiPage::VCLXMultiPage()"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("toolkit"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2456" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "VCLXMultiPage::VCLXMultiPage()"), 0
); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "VCLXMultiPage::VCLXMultiPage()"; ::sal::detail::log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2456" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "VCLXMultiPage::VCLXMultiPage()") == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2456" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "VCLXMultiPage::VCLXMultiPage()"), 0
); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "VCLXMultiPage::VCLXMultiPage()"; ::sal::detail::log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2456" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
2457}
2458
2459void VCLXMultiPage::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
2460{
2461 PushPropertyIds( rIds,
2462 BASEPROPERTY_BACKGROUNDCOLOR2,
2463 BASEPROPERTY_DEFAULTCONTROL19,
2464 BASEPROPERTY_ENABLED44,
2465 BASEPROPERTY_MULTIPAGEVALUE155,
2466 BASEPROPERTY_ENABLEVISIBLE145,
2467 BASEPROPERTY_FONTDESCRIPTOR8,
2468 BASEPROPERTY_GRAPHIC117,
2469 BASEPROPERTY_HELPTEXT73,
2470 BASEPROPERTY_HELPURL58,
2471 BASEPROPERTY_IMAGEALIGN86,
2472 BASEPROPERTY_IMAGEPOSITION113,
2473 BASEPROPERTY_IMAGEURL42,
2474 BASEPROPERTY_PRINTABLE45,
2475 BASEPROPERTY_TABSTOP14,
2476 BASEPROPERTY_FOCUSONCLICK109,
2477 0);
2478 VCLXContainer::ImplGetPropertyIds( rIds );
2479}
2480
2481VCLXMultiPage::~VCLXMultiPage()
2482{
2483}
2484void SAL_CALL VCLXMultiPage::dispose()
2485{
2486 SolarMutexGuard aGuard;
2487
2488 css::lang::EventObject aObj;
2489 aObj.Source = static_cast<cppu::OWeakObject*>(this);
2490 maTabListeners.disposeAndClear( aObj );
2491 VCLXContainer::dispose();
2492}
2493css::uno::Any SAL_CALL VCLXMultiPage::queryInterface(const css::uno::Type & rType )
2494{
2495 uno::Any aRet = ::cppu::queryInterface( rType, static_cast< awt::XSimpleTabController*>( this ) );
2496
2497 return ( aRet.hasValue() ? aRet : VCLXContainer::queryInterface( rType ) );
2498}
2499IMPL_IMPLEMENTATION_ID( VCLXMultiPage )css::uno::Sequence< sal_Int8 > VCLXMultiPage::getImplementationId
() { return css::uno::Sequence<sal_Int8>(); }
2500// css::awt::XView
2501void SAL_CALL VCLXMultiPage::draw( sal_Int32 nX, sal_Int32 nY )
2502{
2503 SolarMutexGuard aGuard;
2504 VclPtr< vcl::Window > pWindow = GetWindow();
2505
2506 if ( pWindow )
2507 {
2508 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
2509 if ( !pDev )
2510 pDev = pWindow->GetParent();
2511
2512 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
2513 pWindow->Draw( pDev, aPos, DrawFlags::NoControls );
2514 }
2515}
2516
2517uno::Any SAL_CALL VCLXMultiPage::getProperty( const OUString& PropertyName )
2518{
2519 SAL_INFO("toolkit", " **** VCLXMultiPage::getProperty " << PropertyName )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "toolkit")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << " **** VCLXMultiPage::getProperty "
<< PropertyName) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2519" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << " **** VCLXMultiPage::getProperty " <<
PropertyName), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << " **** VCLXMultiPage::getProperty "
<< PropertyName; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2519" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << " **** VCLXMultiPage::getProperty " << PropertyName
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("toolkit"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2519" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << " **** VCLXMultiPage::getProperty " <<
PropertyName), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << " **** VCLXMultiPage::getProperty "
<< PropertyName; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2519" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
2520 SolarMutexGuard aGuard;
2521 css::uno::Any aProp;
2522 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2523 switch ( nPropType )
2524 {
2525
2526 case BASEPROPERTY_MULTIPAGEVALUE155:
2527 {
2528 aProp <<= getActiveTabID();
2529 }
2530 break;
2531 default:
2532 aProp = VCLXContainer::getProperty( PropertyName );
2533 }
2534 return aProp;
2535}
2536
2537void SAL_CALL VCLXMultiPage::setProperty(
2538 const OUString& PropertyName,
2539 const css::uno::Any& Value )
2540{
2541 SAL_INFO("toolkit", " **** VCLXMultiPage::setProperty " << PropertyName )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "toolkit")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << " **** VCLXMultiPage::setProperty "
<< PropertyName) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2541" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << " **** VCLXMultiPage::setProperty " <<
PropertyName), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << " **** VCLXMultiPage::setProperty "
<< PropertyName; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2541" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << " **** VCLXMultiPage::setProperty " << PropertyName
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("toolkit"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2541" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << " **** VCLXMultiPage::setProperty " <<
PropertyName), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << " **** VCLXMultiPage::setProperty "
<< PropertyName; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2541" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
2542 SolarMutexGuard aGuard;
2543
2544 VclPtr< TabControl > pTabControl = GetAs< TabControl >();
2545 if ( !pTabControl )
2546 return;
2547
2548 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
2549
2550 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2551 switch ( nPropType )
2552 {
2553 case BASEPROPERTY_MULTIPAGEVALUE155:
2554 {
2555 SAL_INFO("toolkit", "***MULTIPAGE VALUE")do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "toolkit")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "***MULTIPAGE VALUE")
== 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("toolkit"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2555" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "***MULTIPAGE VALUE"), 0); } else { ::
std::ostringstream sal_detail_stream; sal_detail_stream <<
"***MULTIPAGE VALUE"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2555" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "***MULTIPAGE VALUE") == 1) { ::sal_detail_log( (
::SAL_DETAIL_LOG_LEVEL_INFO), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2555" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "***MULTIPAGE VALUE"), 0); } else { ::
std::ostringstream sal_detail_stream; sal_detail_stream <<
"***MULTIPAGE VALUE"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2555" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
2556 sal_Int32 nId(0);
2557 Value >>= nId;
2558 // when the multipage is created we attempt to set the activepage
2559 // but no pages created
2560 if ( nId && nId <= getWindows().getLength() )
2561 activateTab( nId );
2562 break;
2563 }
2564 case BASEPROPERTY_GRAPHIC117:
2565 {
2566 Reference< XGraphic > xGraphic;
2567 if (( Value >>= xGraphic ) && xGraphic.is() )
2568 {
2569 Graphic aImage(xGraphic);
2570
2571 Wallpaper aWallpaper(aImage.GetBitmapEx());
2572 aWallpaper.SetStyle( WallpaperStyle::Scale );
2573 pTabControl->SetBackground( aWallpaper );
2574 }
2575 else if ( bVoid || !xGraphic.is() )
2576 {
2577 Color aColor = pTabControl->GetControlBackground();
2578 if ( aColor == COL_AUTO )
2579 aColor = pTabControl->GetSettings().GetStyleSettings().GetDialogColor();
2580
2581 Wallpaper aWallpaper( aColor );
2582 pTabControl->SetBackground( aWallpaper );
2583 }
2584 }
2585 break;
2586
2587 default:
2588 {
2589 VCLXContainer::setProperty( PropertyName, Value );
2590 }
2591 }
2592}
2593
2594TabControl *VCLXMultiPage::getTabControl() const
2595{
2596 VclPtr<TabControl> pTabControl = GetAsDynamic< TabControl >();
2597 if ( pTabControl )
2598 return pTabControl;
2599 throw uno::RuntimeException();
2600}
2601sal_Int32 SAL_CALL VCLXMultiPage::insertTab()
2602{
2603 TabControl *pTabControl = getTabControl();
2604 VclPtrInstance<TabPage> pTab( pTabControl );
2605 return static_cast< sal_Int32 >( insertTab( pTab, OUString() ) );
2606}
2607
2608sal_uInt16 VCLXMultiPage::insertTab( TabPage* pPage, OUString const & sTitle )
2609{
2610 TabControl *pTabControl = getTabControl();
2611 sal_uInt16 id = sal::static_int_cast< sal_uInt16 >( mTabId++ );
2612 pTabControl->InsertPage( id, sTitle );
2613 pTabControl->SetTabPage( id, pPage );
2614 return id;
2615}
2616
2617void SAL_CALL VCLXMultiPage::removeTab( sal_Int32 ID )
2618{
2619 TabControl *pTabControl = getTabControl();
2620 if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == nullptr )
2621 throw lang::IndexOutOfBoundsException();
2622 pTabControl->RemovePage( sal::static_int_cast< sal_uInt16 >( ID ) );
2623}
2624
2625void SAL_CALL VCLXMultiPage::activateTab( sal_Int32 ID )
2626{
2627 TabControl *pTabControl = getTabControl();
2628 SAL_INFO(do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "toolkit")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "Attempting to activate tab "
<< ID << ", active tab is " << getActiveTabID
() << ", numtabs is " << getWindows().getLength()
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("toolkit"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2631" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Attempting to activate tab " <<
ID << ", active tab is " << getActiveTabID() <<
", numtabs is " << getWindows().getLength()), 0); } else
{ ::std::ostringstream sal_detail_stream; sal_detail_stream <<
"Attempting to activate tab " << ID << ", active tab is "
<< getActiveTabID() << ", numtabs is " << getWindows
().getLength(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2631" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Attempting to activate tab " << ID <<
", active tab is " << getActiveTabID() << ", numtabs is "
<< getWindows().getLength()) == 1) { ::sal_detail_log(
(::SAL_DETAIL_LOG_LEVEL_INFO), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2631" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Attempting to activate tab " <<
ID << ", active tab is " << getActiveTabID() <<
", numtabs is " << getWindows().getLength()), 0); } else
{ ::std::ostringstream sal_detail_stream; sal_detail_stream <<
"Attempting to activate tab " << ID << ", active tab is "
<< getActiveTabID() << ", numtabs is " << getWindows
().getLength(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2631" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
2629 "toolkit",do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "toolkit")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "Attempting to activate tab "
<< ID << ", active tab is " << getActiveTabID
() << ", numtabs is " << getWindows().getLength()
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("toolkit"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2631" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Attempting to activate tab " <<
ID << ", active tab is " << getActiveTabID() <<
", numtabs is " << getWindows().getLength()), 0); } else
{ ::std::ostringstream sal_detail_stream; sal_detail_stream <<
"Attempting to activate tab " << ID << ", active tab is "
<< getActiveTabID() << ", numtabs is " << getWindows
().getLength(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2631" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Attempting to activate tab " << ID <<
", active tab is " << getActiveTabID() << ", numtabs is "
<< getWindows().getLength()) == 1) { ::sal_detail_log(
(::SAL_DETAIL_LOG_LEVEL_INFO), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2631" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Attempting to activate tab " <<
ID << ", active tab is " << getActiveTabID() <<
", numtabs is " << getWindows().getLength()), 0); } else
{ ::std::ostringstream sal_detail_stream; sal_detail_stream <<
"Attempting to activate tab " << ID << ", active tab is "
<< getActiveTabID() << ", numtabs is " << getWindows
().getLength(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2631" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
2630 "Attempting to activate tab " << ID << ", active tab is "do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "toolkit")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "Attempting to activate tab "
<< ID << ", active tab is " << getActiveTabID
() << ", numtabs is " << getWindows().getLength()
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("toolkit"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2631" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Attempting to activate tab " <<
ID << ", active tab is " << getActiveTabID() <<
", numtabs is " << getWindows().getLength()), 0); } else
{ ::std::ostringstream sal_detail_stream; sal_detail_stream <<
"Attempting to activate tab " << ID << ", active tab is "
<< getActiveTabID() << ", numtabs is " << getWindows
().getLength(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2631" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Attempting to activate tab " << ID <<
", active tab is " << getActiveTabID() << ", numtabs is "
<< getWindows().getLength()) == 1) { ::sal_detail_log(
(::SAL_DETAIL_LOG_LEVEL_INFO), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2631" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Attempting to activate tab " <<
ID << ", active tab is " << getActiveTabID() <<
", numtabs is " << getWindows().getLength()), 0); } else
{ ::std::ostringstream sal_detail_stream; sal_detail_stream <<
"Attempting to activate tab " << ID << ", active tab is "
<< getActiveTabID() << ", numtabs is " << getWindows
().getLength(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2631" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
2631 << getActiveTabID() << ", numtabs is " << getWindows().getLength())do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "toolkit")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "Attempting to activate tab "
<< ID << ", active tab is " << getActiveTabID
() << ", numtabs is " << getWindows().getLength()
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("toolkit"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2631" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Attempting to activate tab " <<
ID << ", active tab is " << getActiveTabID() <<
", numtabs is " << getWindows().getLength()), 0); } else
{ ::std::ostringstream sal_detail_stream; sal_detail_stream <<
"Attempting to activate tab " << ID << ", active tab is "
<< getActiveTabID() << ", numtabs is " << getWindows
().getLength(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2631" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Attempting to activate tab " << ID <<
", active tab is " << getActiveTabID() << ", numtabs is "
<< getWindows().getLength()) == 1) { ::sal_detail_log(
(::SAL_DETAIL_LOG_LEVEL_INFO), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2631" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Attempting to activate tab " <<
ID << ", active tab is " << getActiveTabID() <<
", numtabs is " << getWindows().getLength()), 0); } else
{ ::std::ostringstream sal_detail_stream; sal_detail_stream <<
"Attempting to activate tab " << ID << ", active tab is "
<< getActiveTabID() << ", numtabs is " << getWindows
().getLength(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "2631" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
2632 if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == nullptr )
2633 throw lang::IndexOutOfBoundsException();
2634 pTabControl->SelectTabPage( sal::static_int_cast< sal_uInt16 >( ID ) );
2635}
2636
2637sal_Int32 SAL_CALL VCLXMultiPage::getActiveTabID()
2638{
2639 return getTabControl()->GetCurPageId( );
2640}
2641
2642void SAL_CALL VCLXMultiPage::addTabListener( const uno::Reference< awt::XTabListener >& xListener )
2643{
2644 SolarMutexGuard aGuard;
2645 maTabListeners.addInterface( xListener );
2646}
2647
2648void SAL_CALL VCLXMultiPage::removeTabListener( const uno::Reference< awt::XTabListener >& xListener )
2649{
2650 SolarMutexGuard aGuard;
2651 maTabListeners.addInterface( xListener );
2652}
2653
2654void SAL_CALL VCLXMultiPage::setTabProps( sal_Int32 ID, const uno::Sequence< beans::NamedValue >& Properties )
2655{
2656 SolarMutexGuard aGuard;
2657 TabControl *pTabControl = getTabControl();
2658 if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == nullptr )
2659 throw lang::IndexOutOfBoundsException();
2660
2661 for (const auto& rProp : Properties)
2662 {
2663 const OUString &name = rProp.Name;
2664 const uno::Any &value = rProp.Value;
2665
2666 if (name == "Title")
2667 {
2668 OUString title = value.get<OUString>();
2669 pTabControl->SetPageText( sal::static_int_cast< sal_uInt16 >( ID ), title );
2670 }
2671 }
2672}
2673
2674uno::Sequence< beans::NamedValue > SAL_CALL VCLXMultiPage::getTabProps( sal_Int32 ID )
2675{
2676 SolarMutexGuard aGuard;
2677 TabControl *pTabControl = getTabControl();
2678 if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == nullptr )
2679 throw lang::IndexOutOfBoundsException();
2680
2681 uno::Sequence< beans::NamedValue > props
2682 {
2683 { "Title", css::uno::makeAny(pTabControl->GetPageText( sal::static_int_cast< sal_uInt16 >( ID ) )) },
2684 { "Position", css::uno::makeAny(pTabControl->GetPagePos( sal::static_int_cast< sal_uInt16 >( ID ) )) }
2685 };
2686 return props;
2687}
2688void VCLXMultiPage::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
2689{
2690 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
2691 switch ( rVclWindowEvent.GetId() )
2692 {
2693 case VclEventId::TabpageDeactivate:
2694 {
2695 sal_uLong nPageID = reinterpret_cast<sal_uLong>( rVclWindowEvent.GetData() );
2696 maTabListeners.deactivated( nPageID );
2697 break;
2698
2699 }
2700 case VclEventId::TabpageActivate:
2701 {
2702 sal_uLong nPageID = reinterpret_cast<sal_uLong>( rVclWindowEvent.GetData() );
2703 maTabListeners.activated( nPageID );
2704 break;
2705 }
2706 default:
2707 VCLXContainer::ProcessWindowEvent( rVclWindowEvent );
2708 break;
2709 }
2710}
2711
2712
2713
2714VCLXTabPage::VCLXTabPage()
2715{
2716}
2717
2718void VCLXTabPage::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
2719{
2720 PushPropertyIds( rIds,
2721 BASEPROPERTY_BACKGROUNDCOLOR2,
2722 BASEPROPERTY_DEFAULTCONTROL19,
2723 BASEPROPERTY_ENABLED44,
2724 BASEPROPERTY_ENABLEVISIBLE145,
2725 BASEPROPERTY_FONTDESCRIPTOR8,
2726 BASEPROPERTY_GRAPHIC117,
2727 BASEPROPERTY_HELPTEXT73,
2728 BASEPROPERTY_HELPURL58,
2729 BASEPROPERTY_IMAGEALIGN86,
2730 BASEPROPERTY_IMAGEPOSITION113,
2731 BASEPROPERTY_IMAGEURL42,
2732 BASEPROPERTY_PRINTABLE45,
2733 BASEPROPERTY_TABSTOP14,
2734 BASEPROPERTY_FOCUSONCLICK109,
2735 0);
2736 VCLXContainer::ImplGetPropertyIds( rIds );
2737}
2738
2739VCLXTabPage::~VCLXTabPage()
2740{
2741}
2742
2743IMPL_IMPLEMENTATION_ID( VCLXTabPage )css::uno::Sequence< sal_Int8 > VCLXTabPage::getImplementationId
() { return css::uno::Sequence<sal_Int8>(); }
2744
2745// css::awt::XView
2746void SAL_CALL VCLXTabPage::draw( sal_Int32 nX, sal_Int32 nY )
2747{
2748 SolarMutexGuard aGuard;
2749 VclPtr< vcl::Window > pWindow = GetWindow();
2750
2751 if ( pWindow )
2752 {
2753 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
2754 if ( !pDev )
2755 pDev = pWindow->GetParent();
2756
2757 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
2758 pWindow->Draw( pDev, aPos, DrawFlags::NoControls );
2759 }
2760}
2761
2762void SAL_CALL VCLXTabPage::setProperty(
2763 const OUString& PropertyName,
2764 const css::uno::Any& Value )
2765{
2766 SolarMutexGuard aGuard;
2767 VclPtr< TabPage > pTabPage = GetAs< TabPage >();
2768 if ( !pTabPage )
2769 return;
2770
2771 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
2772
2773 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2774 switch ( nPropType )
2775 {
2776 case BASEPROPERTY_GRAPHIC117:
2777 {
2778 Reference< XGraphic > xGraphic;
2779 if (( Value >>= xGraphic ) && xGraphic.is() )
2780 {
2781 Graphic aImage(xGraphic);
2782
2783 Wallpaper aWallpaper(aImage.GetBitmapEx());
2784 aWallpaper.SetStyle( WallpaperStyle::Scale );
2785 pTabPage->SetBackground( aWallpaper );
2786 }
2787 else if ( bVoid || !xGraphic.is() )
2788 {
2789 Color aColor = pTabPage->GetControlBackground();
2790 if ( aColor == COL_AUTO )
2791 aColor = pTabPage->GetSettings().GetStyleSettings().GetDialogColor();
2792
2793 Wallpaper aWallpaper( aColor );
2794 pTabPage->SetBackground( aWallpaper );
2795 }
2796 }
2797 break;
2798 case BASEPROPERTY_TITLE69:
2799 {
2800 OUString sTitle;
2801 if ( Value >>= sTitle )
2802 {
2803 pTabPage->SetText(sTitle);
2804 }
2805 }
2806 break;
2807
2808 default:
2809 {
2810 VCLXContainer::setProperty( PropertyName, Value );
2811 }
2812 }
2813}
2814
2815TabPage *VCLXTabPage::getTabPage() const
2816{
2817 VclPtr< TabPage > pTabPage = GetAsDynamic< TabPage >();
2818 if ( pTabPage )
2819 return pTabPage;
2820 throw uno::RuntimeException();
2821}
2822
2823
2824
2825
2826VCLXFixedHyperlink::VCLXFixedHyperlink() :
2827
2828 maActionListeners( *this )
2829
2830{
2831}
2832
2833VCLXFixedHyperlink::~VCLXFixedHyperlink()
2834{
2835}
2836
2837// css::uno::XInterface
2838css::uno::Any VCLXFixedHyperlink::queryInterface( const css::uno::Type & rType )
2839{
2840 css::uno::Any aRet = ::cppu::queryInterface( rType,
2841 static_cast< css::awt::XFixedHyperlink* >(this) );
2842 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
2843}
2844
2845void VCLXFixedHyperlink::dispose()
2846{
2847 SolarMutexGuard aGuard;
2848
2849 css::lang::EventObject aObj;
2850 aObj.Source = static_cast<cppu::OWeakObject*>(this);
2851 maActionListeners.disposeAndClear( aObj );
2852 VCLXWindow::dispose();
2853}
2854
2855IMPL_IMPLEMENTATION_ID( VCLXFixedHyperlink )css::uno::Sequence< sal_Int8 > VCLXFixedHyperlink::getImplementationId
() { return css::uno::Sequence<sal_Int8>(); }
2856
2857// css::lang::XTypeProvider
2858css::uno::Sequence< css::uno::Type > VCLXFixedHyperlink::getTypes()
2859{
2860 static const ::cppu::OTypeCollection aTypeList(
2861 cppu::UnoType<css::lang::XTypeProvider>::get(),
2862 cppu::UnoType<css::awt::XFixedHyperlink>::get(),
2863 VCLXWindow::getTypes()
2864 );
2865 return aTypeList.getTypes();
2866}
2867
2868void VCLXFixedHyperlink::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
2869{
2870 switch ( rVclWindowEvent.GetId() )
2871 {
2872 case VclEventId::ButtonClick:
2873 {
2874 if ( maActionListeners.getLength() )
2875 {
2876 css::awt::ActionEvent aEvent;
2877 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
2878 maActionListeners.actionPerformed( aEvent );
2879 }
2880 else
2881 {
2882 // open the URL
2883 OUString sURL;
2884 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
2885 if ( pBase )
2886 sURL = pBase->GetURL();
2887 Reference< css::system::XSystemShellExecute > xSystemShellExecute( css::system::SystemShellExecute::create(
2888 ::comphelper::getProcessComponentContext() ) );
2889 if ( !sURL.isEmpty() )
2890 {
2891 try
2892 {
2893 // start browser
2894 xSystemShellExecute->execute(
2895 sURL, OUString(), css::system::SystemShellExecuteFlags::URIS_ONLY );
2896 }
2897 catch( uno::Exception& )
2898 {
2899 }
2900 }
2901 }
2902 [[fallthrough]];
2903 }
2904 default:
2905 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
2906 break;
2907 }
2908}
2909
2910css::uno::Reference< css::accessibility::XAccessibleContext > VCLXFixedHyperlink::CreateAccessibleContext()
2911{
2912 return getAccessibleFactory().createAccessibleContext( this );
2913}
2914
2915void VCLXFixedHyperlink::setText( const OUString& Text )
2916{
2917 SolarMutexGuard aGuard;
2918 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
2919 if (pBase)
2920 pBase->SetText(Text);
2921}
2922
2923OUString VCLXFixedHyperlink::getText()
2924{
2925 SolarMutexGuard aGuard;
2926
2927 OUString aText;
2928 VclPtr< vcl::Window > pWindow = GetWindow();
2929 if ( pWindow )
2930 aText = pWindow->GetText();
2931 return aText;
2932}
2933
2934void VCLXFixedHyperlink::setURL( const OUString& URL )
2935{
2936 SolarMutexGuard aGuard;
2937 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
2938 if ( pBase )
2939 pBase->SetURL( URL );
2940}
2941
2942OUString VCLXFixedHyperlink::getURL( )
2943{
2944 SolarMutexGuard aGuard;
2945
2946 OUString aText;
2947 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
2948 if ( pBase )
2949 aText = pBase->GetURL();
2950 return aText;
2951}
2952
2953void VCLXFixedHyperlink::setAlignment( sal_Int16 nAlign )
2954{
2955 SolarMutexGuard aGuard;
2956
2957 VclPtr< vcl::Window > pWindow = GetWindow();
2958 if ( !pWindow )
2959 return;
2960
2961 WinBits nNewBits = 0;
2962 if ( nAlign == css::awt::TextAlign::LEFT )
2963 nNewBits = WB_LEFT;
2964 else if ( nAlign == css::awt::TextAlign::CENTER )
2965 nNewBits = WB_CENTER;
2966 else
2967 nNewBits = WB_RIGHT;
2968
2969 WinBits nStyle = pWindow->GetStyle();
2970 nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT);
2971 pWindow->SetStyle( nStyle | nNewBits );
2972}
2973
2974sal_Int16 VCLXFixedHyperlink::getAlignment()
2975{
2976 SolarMutexGuard aGuard;
2977
2978 sal_Int16 nAlign = 0;
2979 VclPtr< vcl::Window > pWindow = GetWindow();
2980 if ( pWindow )
2981 {
2982 WinBits nStyle = pWindow->GetStyle();
2983 if ( nStyle & WB_LEFT )
2984 nAlign = css::awt::TextAlign::LEFT;
2985 else if ( nStyle & WB_CENTER )
2986 nAlign = css::awt::TextAlign::CENTER;
2987 else
2988 nAlign = css::awt::TextAlign::RIGHT;
2989 }
2990 return nAlign;
2991}
2992
2993void VCLXFixedHyperlink::addActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
2994{
2995 SolarMutexGuard aGuard;
2996 maActionListeners.addInterface( l );
2997}
2998
2999void VCLXFixedHyperlink::removeActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
3000{
3001 SolarMutexGuard aGuard;
3002 maActionListeners.removeInterface( l );
3003}
3004
3005css::awt::Size VCLXFixedHyperlink::getMinimumSize( )
3006{
3007 SolarMutexGuard aGuard;
3008 Size aSz;
3009 VclPtr< FixedText > pFixedText = GetAs< FixedText >();
3010 if ( pFixedText )
3011 aSz = pFixedText->CalcMinimumSize();
3012 return AWTSize(aSz);
3013}
3014
3015css::awt::Size VCLXFixedHyperlink::getPreferredSize( )
3016{
3017 return getMinimumSize();
3018}
3019
3020css::awt::Size VCLXFixedHyperlink::calcAdjustedSize( const css::awt::Size& rNewSize )
3021{
3022 SolarMutexGuard aGuard;
3023 Size aSz( VCLUnoHelper::ConvertToVCLSize( rNewSize ));
3024 VclPtr< FixedText > pFixedText = GetAs< FixedText >();
3025 if (pFixedText)
3026 {
3027 Size aMinSz = pFixedText->CalcMinimumSize(rNewSize.Width);
3028 if ( ( aSz.Width() > aMinSz.Width() ) && ( aSz.Height() < aMinSz.Height() ) )
3029 aSz.setHeight( aMinSz.Height() );
3030 else
3031 aSz = aMinSz;
3032 }
3033
3034 return VCLUnoHelper::ConvertToAWTSize(aSz);
3035}
3036
3037void VCLXFixedHyperlink::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
3038{
3039 SolarMutexGuard aGuard;
3040
3041 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
3042 if ( !pBase )
3043 return;
3044
3045 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3046 switch ( nPropType )
3047 {
3048 case BASEPROPERTY_LABEL20:
3049 {
3050 OUString sNewLabel;
3051 if ( Value >>= sNewLabel )
3052 pBase->SetText(sNewLabel);
3053 break;
3054 }
3055
3056 case BASEPROPERTY_URL134:
3057 {
3058 OUString sNewURL;
3059 if ( Value >>= sNewURL )
3060 pBase->SetURL( sNewURL );
3061 break;
3062 }
3063
3064 default:
3065 {
3066 VCLXWindow::setProperty( PropertyName, Value );
3067 }
3068 }
3069}
3070
3071css::uno::Any VCLXFixedHyperlink::getProperty( const OUString& PropertyName )
3072{
3073 SolarMutexGuard aGuard;
3074
3075 css::uno::Any aProp;
3076 VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >();
3077 if ( pBase )
3078 {
3079 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3080 switch ( nPropType )
3081 {
3082 case BASEPROPERTY_URL134:
3083 {
3084 aProp <<= pBase->GetURL();
3085 break;
3086 }
3087
3088 default:
3089 {
3090 aProp = VCLXWindow::getProperty( PropertyName );
3091 }
3092 }
3093 }
3094 return aProp;
3095}
3096
3097void VCLXFixedHyperlink::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
3098{
3099 PushPropertyIds( rIds,
3100 BASEPROPERTY_ALIGN7,
3101 BASEPROPERTY_BACKGROUNDCOLOR2,
3102 BASEPROPERTY_BORDER6,
3103 BASEPROPERTY_BORDERCOLOR112,
3104 BASEPROPERTY_DEFAULTCONTROL19,
3105 BASEPROPERTY_ENABLED44,
3106 BASEPROPERTY_ENABLEVISIBLE145,
3107 BASEPROPERTY_FONTDESCRIPTOR8,
3108 BASEPROPERTY_HELPTEXT73,
3109 BASEPROPERTY_HELPURL58,
3110 BASEPROPERTY_LABEL20,
3111 BASEPROPERTY_MULTILINE10,
3112 BASEPROPERTY_NOLABEL133,
3113 BASEPROPERTY_PRINTABLE45,
3114 BASEPROPERTY_TABSTOP14,
3115 BASEPROPERTY_VERTICALALIGN115,
3116 BASEPROPERTY_URL134,
3117 BASEPROPERTY_WRITING_MODE138,
3118 BASEPROPERTY_CONTEXT_WRITING_MODE139,
3119 0);
3120 VCLXWindow::ImplGetPropertyIds( rIds );
3121}
3122
3123
3124
3125void VCLXFixedText::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
3126{
3127 PushPropertyIds( rIds,
3128 BASEPROPERTY_ALIGN7,
3129 BASEPROPERTY_BACKGROUNDCOLOR2,
3130 BASEPROPERTY_BORDER6,
3131 BASEPROPERTY_BORDERCOLOR112,
3132 BASEPROPERTY_DEFAULTCONTROL19,
3133 BASEPROPERTY_ENABLED44,
3134 BASEPROPERTY_ENABLEVISIBLE145,
3135 BASEPROPERTY_FONTDESCRIPTOR8,
3136 BASEPROPERTY_HELPTEXT73,
3137 BASEPROPERTY_HELPURL58,
3138 BASEPROPERTY_LABEL20,
3139 BASEPROPERTY_MULTILINE10,
3140 BASEPROPERTY_NOLABEL133,
3141 BASEPROPERTY_PRINTABLE45,
3142 BASEPROPERTY_TABSTOP14,
3143 BASEPROPERTY_VERTICALALIGN115,
3144 BASEPROPERTY_WRITING_MODE138,
3145 BASEPROPERTY_CONTEXT_WRITING_MODE139,
3146 BASEPROPERTY_REFERENCE_DEVICE146,
3147 0);
3148 VCLXWindow::ImplGetPropertyIds( rIds );
3149}
3150
3151VCLXFixedText::VCLXFixedText()
3152{
3153}
3154
3155VCLXFixedText::~VCLXFixedText()
3156{
3157}
3158
3159// css::uno::XInterface
3160css::uno::Any VCLXFixedText::queryInterface( const css::uno::Type & rType )
3161{
3162 css::uno::Any aRet = ::cppu::queryInterface( rType,
3163 static_cast< css::awt::XFixedText* >(this) );
3164 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
3165}
3166
3167IMPL_IMPLEMENTATION_ID( VCLXFixedText )css::uno::Sequence< sal_Int8 > VCLXFixedText::getImplementationId
() { return css::uno::Sequence<sal_Int8>(); }
3168
3169// css::lang::XTypeProvider
3170css::uno::Sequence< css::uno::Type > VCLXFixedText::getTypes()
3171{
3172 static const ::cppu::OTypeCollection aTypeList(
3173 cppu::UnoType<css::lang::XTypeProvider>::get(),
3174 cppu::UnoType<css::awt::XFixedText>::get(),
3175 VCLXWindow::getTypes()
3176 );
3177 return aTypeList.getTypes();
3178}
3179
3180css::uno::Reference< css::accessibility::XAccessibleContext > VCLXFixedText::CreateAccessibleContext()
3181{
3182 return getAccessibleFactory().createAccessibleContext( this );
3183}
3184
3185void VCLXFixedText::setText( const OUString& Text )
3186{
3187 SolarMutexGuard aGuard;
3188
3189 VclPtr< vcl::Window > pWindow = GetWindow();
3190 if ( pWindow )
3191 pWindow->SetText( Text );
3192}
3193
3194OUString VCLXFixedText::getText()
3195{
3196 SolarMutexGuard aGuard;
3197
3198 OUString aText;
3199 VclPtr< vcl::Window > pWindow = GetWindow();
3200 if ( pWindow )
3201 aText = pWindow->GetText();
3202 return aText;
3203}
3204
3205void VCLXFixedText::setAlignment( sal_Int16 nAlign )
3206{
3207 SolarMutexGuard aGuard;
3208
3209 VclPtr< vcl::Window > pWindow = GetWindow();
3210 if ( !pWindow )
3211 return;
3212
3213 WinBits nNewBits = 0;
3214 if ( nAlign == css::awt::TextAlign::LEFT )
3215 nNewBits = WB_LEFT;
3216 else if ( nAlign == css::awt::TextAlign::CENTER )
3217 nNewBits = WB_CENTER;
3218 else
3219 nNewBits = WB_RIGHT;
3220
3221 WinBits nStyle = pWindow->GetStyle();
3222 nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT);
3223 pWindow->SetStyle( nStyle | nNewBits );
3224}
3225
3226sal_Int16 VCLXFixedText::getAlignment()
3227{
3228 SolarMutexGuard aGuard;
3229
3230 sal_Int16 nAlign = 0;
3231 VclPtr< vcl::Window > pWindow = GetWindow();
3232 if ( pWindow )
3233 {
3234 WinBits nStyle = pWindow->GetStyle();
3235 if ( nStyle & WB_LEFT )
3236 nAlign = css::awt::TextAlign::LEFT;
3237 else if ( nStyle & WB_CENTER )
3238 nAlign = css::awt::TextAlign::CENTER;
3239 else
3240 nAlign = css::awt::TextAlign::RIGHT;
3241 }
3242 return nAlign;
3243}
3244
3245css::awt::Size VCLXFixedText::getMinimumSize( )
3246{
3247 SolarMutexGuard aGuard;
3248
3249 Size aSz;
3250 VclPtr< FixedText > pFixedText = GetAs< FixedText >();
3251 if ( pFixedText )
3252 aSz = pFixedText->CalcMinimumSize();
3253 return AWTSize(aSz);
3254}
3255
3256css::awt::Size VCLXFixedText::getPreferredSize( )
3257{
3258 return getMinimumSize();
3259}
3260
3261css::awt::Size VCLXFixedText::calcAdjustedSize( const css::awt::Size& rMaxSize )
3262{
3263 SolarMutexGuard aGuard;
3264
3265 Size aAdjustedSize( VCLUnoHelper::ConvertToVCLSize( rMaxSize ) );
3266 VclPtr< FixedText > pFixedText = GetAs< FixedText >();
3267 if ( pFixedText )
3268 aAdjustedSize = pFixedText->CalcMinimumSize( rMaxSize.Width );
3269 return VCLUnoHelper::ConvertToAWTSize( aAdjustedSize );
3270}
3271
3272
3273
3274void VCLXScrollBar::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
3275{
3276 PushPropertyIds( rIds,
3277 BASEPROPERTY_BACKGROUNDCOLOR2,
3278 BASEPROPERTY_BLOCKINCREMENT80,
3279 BASEPROPERTY_BORDER6,
3280 BASEPROPERTY_BORDERCOLOR112,
3281 BASEPROPERTY_DEFAULTCONTROL19,
3282 BASEPROPERTY_ENABLED44,
3283 BASEPROPERTY_ENABLEVISIBLE145,
3284 BASEPROPERTY_HELPTEXT73,
3285 BASEPROPERTY_HELPURL58,
3286 BASEPROPERTY_LINEINCREMENT79,
3287 BASEPROPERTY_LIVE_SCROLL103,
3288 BASEPROPERTY_ORIENTATION82,
3289 BASEPROPERTY_PRINTABLE45,
3290 BASEPROPERTY_REPEAT_DELAY95,
3291 BASEPROPERTY_SCROLLVALUE77,
3292 BASEPROPERTY_SCROLLVALUE_MAX78,
3293 BASEPROPERTY_SCROLLVALUE_MIN94,
3294 BASEPROPERTY_SYMBOL_COLOR96,
3295 BASEPROPERTY_TABSTOP14,
3296 BASEPROPERTY_VISIBLESIZE81,
3297 BASEPROPERTY_WRITING_MODE138,
3298 BASEPROPERTY_CONTEXT_WRITING_MODE139,
3299 0);
3300 VCLXWindow::ImplGetPropertyIds( rIds );
3301}
3302
3303VCLXScrollBar::VCLXScrollBar() : maAdjustmentListeners( *this )
3304{
3305}
3306
3307// css::uno::XInterface
3308css::uno::Any VCLXScrollBar::queryInterface( const css::uno::Type & rType )
3309{
3310 css::uno::Any aRet = ::cppu::queryInterface( rType,
3311 static_cast< css::awt::XScrollBar* >(this) );
3312 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
3313}
3314
3315IMPL_IMPLEMENTATION_ID( VCLXScrollBar )css::uno::Sequence< sal_Int8 > VCLXScrollBar::getImplementationId
() { return css::uno::Sequence<sal_Int8>(); }
3316
3317// css::lang::XTypeProvider
3318css::uno::Sequence< css::uno::Type > VCLXScrollBar::getTypes()
3319{
3320 static const ::cppu::OTypeCollection aTypeList(
3321 cppu::UnoType<css::lang::XTypeProvider>::get(),
3322 cppu::UnoType<css::awt::XScrollBar>::get(),
3323 VCLXWindow::getTypes()
3324 );
3325 return aTypeList.getTypes();
3326}
3327
3328css::uno::Reference< css::accessibility::XAccessibleContext > VCLXScrollBar::CreateAccessibleContext()
3329{
3330 return getAccessibleFactory().createAccessibleContext( this );
3331}
3332
3333// css::lang::XComponent
3334void VCLXScrollBar::dispose()
3335{
3336 SolarMutexGuard aGuard;
3337
3338 css::lang::EventObject aObj;
3339 aObj.Source = static_cast<cppu::OWeakObject*>(this);
3340 maAdjustmentListeners.disposeAndClear( aObj );
3341 VCLXWindow::dispose();
3342}
3343
3344// css::awt::XScrollbar
3345void VCLXScrollBar::addAdjustmentListener( const css::uno::Reference< css::awt::XAdjustmentListener > & l )
3346{
3347 SolarMutexGuard aGuard;
3348 maAdjustmentListeners.addInterface( l );
3349}
3350
3351void VCLXScrollBar::removeAdjustmentListener( const css::uno::Reference< css::awt::XAdjustmentListener > & l )
3352{
3353 SolarMutexGuard aGuard;
3354 maAdjustmentListeners.removeInterface( l );
3355}
3356
3357void VCLXScrollBar::setValue( sal_Int32 n )
3358{
3359 SolarMutexGuard aGuard;
3360
3361 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3362 if ( pScrollBar )
3363 pScrollBar->DoScroll( n );
3364}
3365
3366void VCLXScrollBar::setValues( sal_Int32 nValue, sal_Int32 nVisible, sal_Int32 nMax )
3367{
3368 SolarMutexGuard aGuard;
3369
3370 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3371 if ( pScrollBar )
3372 {
3373 pScrollBar->SetVisibleSize( nVisible );
3374 pScrollBar->SetRangeMax( nMax );
3375 pScrollBar->DoScroll( nValue );
3376 }
3377}
3378
3379sal_Int32 VCLXScrollBar::getValue()
3380{
3381 SolarMutexGuard aGuard;
3382
3383 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3384 return pScrollBar ? pScrollBar->GetThumbPos() : 0;
3385}
3386
3387void VCLXScrollBar::setMaximum( sal_Int32 n )
3388{
3389 SolarMutexGuard aGuard;
3390
3391 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3392 if ( pScrollBar )
3393 pScrollBar->SetRangeMax( n );
3394}
3395
3396sal_Int32 VCLXScrollBar::getMaximum()
3397{
3398 SolarMutexGuard aGuard;
3399
3400 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3401 return pScrollBar ? pScrollBar->GetRangeMax() : 0;
3402}
3403
3404void VCLXScrollBar::setMinimum( sal_Int32 n )
3405{
3406 SolarMutexGuard aGuard;
3407
3408 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3409 if ( pScrollBar )
3410 pScrollBar->SetRangeMin( n );
3411}
3412
3413sal_Int32 VCLXScrollBar::getMinimum() const
3414{
3415 SolarMutexGuard aGuard;
3416
3417 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3418 return pScrollBar ? pScrollBar->GetRangeMin() : 0;
3419}
3420
3421void VCLXScrollBar::setLineIncrement( sal_Int32 n )
3422{
3423 SolarMutexGuard aGuard;
3424
3425 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3426 if ( pScrollBar )
3427 pScrollBar->SetLineSize( n );
3428}
3429
3430sal_Int32 VCLXScrollBar::getLineIncrement()
3431{
3432 SolarMutexGuard aGuard;
3433
3434 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3435 return pScrollBar ? pScrollBar->GetLineSize() : 0;
3436}
3437
3438void VCLXScrollBar::setBlockIncrement( sal_Int32 n )
3439{
3440 SolarMutexGuard aGuard;
3441
3442 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3443 if ( pScrollBar )
3444 pScrollBar->SetPageSize( n );
3445}
3446
3447sal_Int32 VCLXScrollBar::getBlockIncrement()
3448{
3449 SolarMutexGuard aGuard;
3450
3451 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3452 return pScrollBar ? pScrollBar->GetPageSize() : 0;
3453}
3454
3455void VCLXScrollBar::setVisibleSize( sal_Int32 n )
3456{
3457 SolarMutexGuard aGuard;
3458
3459 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3460 if ( pScrollBar )
3461 pScrollBar->SetVisibleSize( n );
3462}
3463
3464sal_Int32 VCLXScrollBar::getVisibleSize()
3465{
3466 SolarMutexGuard aGuard;
3467
3468 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3469 return pScrollBar ? pScrollBar->GetVisibleSize() : 0;
3470}
3471
3472void VCLXScrollBar::setOrientation( sal_Int32 n )
3473{
3474 SolarMutexGuard aGuard;
3475
3476 VclPtr< vcl::Window > pWindow = GetWindow();
3477 if ( pWindow )
3478 {
3479 WinBits nStyle = pWindow->GetStyle();
3480 nStyle &= ~(WB_HORZ|WB_VERT);
3481 if ( n == css::awt::ScrollBarOrientation::HORIZONTAL )
3482 nStyle |= WB_HORZ;
3483 else
3484 nStyle |= WB_VERT;
3485
3486 pWindow->SetStyle( nStyle );
3487 pWindow->Resize();
3488 }
3489}
3490
3491sal_Int32 VCLXScrollBar::getOrientation()
3492{
3493 SolarMutexGuard aGuard;
3494
3495 sal_Int32 n = 0;
3496 VclPtr< vcl::Window > pWindow = GetWindow();
3497 if ( pWindow )
3498 {
3499 WinBits nStyle = pWindow->GetStyle();
3500 if ( nStyle & WB_HORZ )
3501 n = css::awt::ScrollBarOrientation::HORIZONTAL;
3502 else
3503 n = css::awt::ScrollBarOrientation::VERTICAL;
3504 }
3505 return n;
3506
3507}
3508
3509// css::awt::VclWindowPeer
3510void VCLXScrollBar::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
3511{
3512 SolarMutexGuard aGuard;
3513
3514 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3515 if ( !pScrollBar )
3516 return;
3517
3518 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
3519
3520 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3521 switch ( nPropType )
3522 {
3523 case BASEPROPERTY_LIVE_SCROLL103:
3524 {
3525 bool bDo = false;
3526 if ( !bVoid )
3527 {
3528 OSL_VERIFY( Value >>= bDo )do { if (!(Value >>= bDo)) do { if (true && (!(
0))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "3528" ": "), "OSL_ASSERT: %s", "0"); } } while (false);
} while (0)
;
3529 }
3530 AllSettings aSettings( pScrollBar->GetSettings() );
3531 StyleSettings aStyle( aSettings.GetStyleSettings() );
3532 DragFullOptions nDragOptions = aStyle.GetDragFullOptions();
3533 if ( bDo )
3534 nDragOptions |= DragFullOptions::Scroll;
3535 else
3536 nDragOptions &= ~DragFullOptions::Scroll;
3537 aStyle.SetDragFullOptions( nDragOptions );
3538 aSettings.SetStyleSettings( aStyle );
3539 pScrollBar->SetSettings( aSettings );
3540 }
3541 break;
3542
3543 case BASEPROPERTY_SCROLLVALUE77:
3544 {
3545 if ( !bVoid )
3546 {
3547 sal_Int32 n = 0;
3548 if ( Value >>= n )
3549 setValue( n );
3550 }
3551 }
3552 break;
3553 case BASEPROPERTY_SCROLLVALUE_MAX78:
3554 case BASEPROPERTY_SCROLLVALUE_MIN94:
3555 {
3556 if ( !bVoid )
3557 {
3558 sal_Int32 n = 0;
3559 if ( Value >>= n )
3560 {
3561 if ( nPropType == BASEPROPERTY_SCROLLVALUE_MAX78 )
3562 setMaximum( n );
3563 else
3564 setMinimum( n );
3565 }
3566 }
3567 }
3568 break;
3569 case BASEPROPERTY_LINEINCREMENT79:
3570 {
3571 if ( !bVoid )
3572 {
3573 sal_Int32 n = 0;
3574 if ( Value >>= n )
3575 setLineIncrement( n );
3576 }
3577 }
3578 break;
3579 case BASEPROPERTY_BLOCKINCREMENT80:
3580 {
3581 if ( !bVoid )
3582 {
3583 sal_Int32 n = 0;
3584 if ( Value >>= n )
3585 setBlockIncrement( n );
3586 }
3587 }
3588 break;
3589 case BASEPROPERTY_VISIBLESIZE81:
3590 {
3591 if ( !bVoid )
3592 {
3593 sal_Int32 n = 0;
3594 if ( Value >>= n )
3595 setVisibleSize( n );
3596 }
3597 }
3598 break;
3599 case BASEPROPERTY_ORIENTATION82:
3600 {
3601 if ( !bVoid )
3602 {
3603 sal_Int32 n = 0;
3604 if ( Value >>= n )
3605 setOrientation( n );
3606 }
3607 }
3608 break;
3609
3610 case BASEPROPERTY_BACKGROUNDCOLOR2:
3611 {
3612 // the default implementation of the base class doesn't work here, since our
3613 // interpretation for this property is slightly different
3614 ::toolkit::setButtonLikeFaceColor( pScrollBar, Value);
3615 }
3616 break;
3617
3618 default:
3619 {
3620 VCLXWindow::setProperty( PropertyName, Value );
3621 }
3622 }
3623}
3624
3625css::uno::Any VCLXScrollBar::getProperty( const OUString& PropertyName )
3626{
3627 SolarMutexGuard aGuard;
3628
3629 css::uno::Any aProp;
3630 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3631 if ( pScrollBar )
3632 {
3633 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3634
3635 switch ( nPropType )
3636 {
3637 case BASEPROPERTY_LIVE_SCROLL103:
3638 {
3639 aProp <<= bool( pScrollBar->GetSettings().GetStyleSettings().GetDragFullOptions() & DragFullOptions::Scroll );
3640 }
3641 break;
3642 case BASEPROPERTY_SCROLLVALUE77:
3643 {
3644 aProp <<= getValue();
3645 }
3646 break;
3647 case BASEPROPERTY_SCROLLVALUE_MAX78:
3648 {
3649 aProp <<= getMaximum();
3650 }
3651 break;
3652 case BASEPROPERTY_SCROLLVALUE_MIN94:
3653 {
3654 aProp <<= getMinimum();
3655 }
3656 break;
3657 case BASEPROPERTY_LINEINCREMENT79:
3658 {
3659 aProp <<= getLineIncrement();
3660 }
3661 break;
3662 case BASEPROPERTY_BLOCKINCREMENT80:
3663 {
3664 aProp <<= getBlockIncrement();
3665 }
3666 break;
3667 case BASEPROPERTY_VISIBLESIZE81:
3668 {
3669 aProp <<= getVisibleSize();
3670 }
3671 break;
3672 case BASEPROPERTY_ORIENTATION82:
3673 {
3674 aProp <<= getOrientation();
3675 }
3676 break;
3677 case BASEPROPERTY_BACKGROUNDCOLOR2:
3678 {
3679 // the default implementation of the base class doesn't work here, since our
3680 // interpretation for this property is slightly different
3681 aProp = ::toolkit::getButtonLikeFaceColor( pScrollBar );
3682 }
3683 break;
3684
3685 default:
3686 {
3687 aProp = VCLXWindow::getProperty( PropertyName );
3688 }
3689 }
3690 }
3691 return aProp;
3692}
3693
3694void VCLXScrollBar::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
3695{
3696 switch ( rVclWindowEvent.GetId() )
3697 {
3698 case VclEventId::ScrollbarScroll:
3699 {
3700 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
3701 // since we call listeners below, there is a potential that we will be destroyed
3702 // in during the listener call. To prevent the resulting crashes, we keep us
3703 // alive as long as we're here
3704
3705 if ( maAdjustmentListeners.getLength() )
3706 {
3707 VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >();
3708
3709 if( pScrollBar )
3710 {
3711 css::awt::AdjustmentEvent aEvent;
3712 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
3713 aEvent.Value = pScrollBar->GetThumbPos();
3714
3715 // set adjustment type
3716 ScrollType aType = pScrollBar->GetType();
3717 if ( aType == ScrollType::LineUp || aType == ScrollType::LineDown )
3718 {
3719 aEvent.Type = css::awt::AdjustmentType_ADJUST_LINE;
3720 }
3721 else if ( aType == ScrollType::PageUp || aType == ScrollType::PageDown )
3722 {
3723 aEvent.Type = css::awt::AdjustmentType_ADJUST_PAGE;
3724 }
3725 else if ( aType == ScrollType::Drag )
3726 {
3727 aEvent.Type = css::awt::AdjustmentType_ADJUST_ABS;
3728 }
3729
3730 maAdjustmentListeners.adjustmentValueChanged( aEvent );
3731 }
3732 }
3733 }
3734 break;
3735
3736 default:
3737 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
3738 break;
3739 }
3740}
3741
3742css::awt::Size VCLXScrollBar::implGetMinimumSize( vcl::Window const * p )
3743{
3744 long n = p->GetSettings().GetStyleSettings().GetScrollBarSize();
3745 return css::awt::Size( n, n );
3746}
3747
3748css::awt::Size SAL_CALL VCLXScrollBar::getMinimumSize()
3749{
3750 SolarMutexGuard aGuard;
3751 return implGetMinimumSize( GetWindow() );
3752}
3753
3754
3755
3756
3757void VCLXEdit::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
3758{
3759 PushPropertyIds( rIds,
3760 BASEPROPERTY_ALIGN7,
3761 BASEPROPERTY_BACKGROUNDCOLOR2,
3762 BASEPROPERTY_BORDER6,
3763 BASEPROPERTY_BORDERCOLOR112,
3764 BASEPROPERTY_DEFAULTCONTROL19,
3765 BASEPROPERTY_ECHOCHAR46,
3766 BASEPROPERTY_ENABLED44,
3767 BASEPROPERTY_ENABLEVISIBLE145,
3768 BASEPROPERTY_FONTDESCRIPTOR8,
3769 BASEPROPERTY_HARDLINEBREAKS48,
3770 BASEPROPERTY_HELPTEXT73,
3771 BASEPROPERTY_HELPURL58,
3772 BASEPROPERTY_HSCROLL12,
3773 BASEPROPERTY_LINE_END_FORMAT104,
3774 BASEPROPERTY_MAXTEXTLEN47,
3775 BASEPROPERTY_MULTILINE10,
3776 BASEPROPERTY_PRINTABLE45,
3777 BASEPROPERTY_READONLY43,
3778 BASEPROPERTY_TABSTOP14,
3779 BASEPROPERTY_TEXT1,
3780 BASEPROPERTY_VSCROLL13,
3781 BASEPROPERTY_HIDEINACTIVESELECTION110,
3782 BASEPROPERTY_PAINTTRANSPARENT120,
3783 BASEPROPERTY_AUTOHSCROLL121,
3784 BASEPROPERTY_AUTOVSCROLL122,
3785 BASEPROPERTY_VERTICALALIGN115,
3786 BASEPROPERTY_WRITING_MODE138,
3787 BASEPROPERTY_CONTEXT_WRITING_MODE139,
3788 0);
3789 VCLXWindow::ImplGetPropertyIds( rIds );
3790}
3791
3792VCLXEdit::VCLXEdit() : maTextListeners( *this )
3793{
3794}
3795
3796// css::uno::XInterface
3797css::uno::Any VCLXEdit::queryInterface( const css::uno::Type & rType )
3798{
3799 css::uno::Any aRet = ::cppu::queryInterface( rType,
3800 static_cast< css::awt::XTextComponent* >(this),
3801 static_cast< css::awt::XTextEditField* >(this),
3802 static_cast< css::awt::XTextLayoutConstrains* >(this) );
3803 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
3804}
3805
3806IMPL_IMPLEMENTATION_ID( VCLXEdit )css::uno::Sequence< sal_Int8 > VCLXEdit::getImplementationId
() { return css::uno::Sequence<sal_Int8>(); }
3807
3808// css::lang::XTypeProvider
3809css::uno::Sequence< css::uno::Type > VCLXEdit::getTypes()
3810{
3811 static const ::cppu::OTypeCollection aTypeList(
3812 cppu::UnoType<css::lang::XTypeProvider>::get(),
3813 cppu::UnoType<css::awt::XTextComponent>::get(),
3814 cppu::UnoType<css::awt::XTextEditField>::get(),
3815 cppu::UnoType<css::awt::XTextLayoutConstrains>::get(),
3816 VCLXWindow::getTypes()
3817 );
3818 return aTypeList.getTypes();
3819}
3820
3821css::uno::Reference< css::accessibility::XAccessibleContext > VCLXEdit::CreateAccessibleContext()
3822{
3823 return getAccessibleFactory().createAccessibleContext( this );
3824}
3825
3826void VCLXEdit::dispose()
3827{
3828 SolarMutexGuard aGuard;
3829
3830 css::lang::EventObject aObj;
3831 aObj.Source = static_cast<cppu::OWeakObject*>(this);
3832 maTextListeners.disposeAndClear( aObj );
3833 VCLXWindow::dispose();
3834}
3835
3836void VCLXEdit::addTextListener( const css::uno::Reference< css::awt::XTextListener > & l )
3837{
3838 SolarMutexGuard aGuard;
3839 GetTextListeners().addInterface( l );
3840}
3841
3842void VCLXEdit::removeTextListener( const css::uno::Reference< css::awt::XTextListener > & l )
3843{
3844 SolarMutexGuard aGuard;
3845 GetTextListeners().removeInterface( l );
3846}
3847
3848void VCLXEdit::setText( const OUString& aText )
3849{
3850 SolarMutexGuard aGuard;
3851
3852 VclPtr< Edit > pEdit = GetAs< Edit >();
3853 if ( pEdit )
3854 {
3855 pEdit->SetText( aText );
3856
3857 // #107218# Call same listeners like VCL would do after user interaction
3858 SetSynthesizingVCLEvent( true );
3859 pEdit->SetModifyFlag();
3860 pEdit->Modify();
3861 SetSynthesizingVCLEvent( false );
3862 }
3863}
3864
3865void VCLXEdit::insertText( const css::awt::Selection& rSel, const OUString& aText )
3866{
3867 SolarMutexGuard aGuard;
3868
3869 VclPtr< Edit > pEdit = GetAs< Edit >();
3870 if ( pEdit )
3871 {
3872 pEdit->SetSelection( Selection( rSel.Min, rSel.Max ) );
3873 pEdit->ReplaceSelected( aText );
3874
3875 // #107218# Call same listeners like VCL would do after user interaction
3876 SetSynthesizingVCLEvent( true );
3877 pEdit->SetModifyFlag();
3878 pEdit->Modify();
3879 SetSynthesizingVCLEvent( false );
3880 }
3881}
3882
3883OUString VCLXEdit::getText()
3884{
3885 SolarMutexGuard aGuard;
3886
3887 OUString aText;
3888 VclPtr< vcl::Window > pWindow = GetWindow();
3889 if ( pWindow )
3890 aText = pWindow->GetText();
3891 return aText;
3892}
3893
3894OUString VCLXEdit::getSelectedText()
3895{
3896 SolarMutexGuard aGuard;
3897
3898 OUString aText;
3899 VclPtr< Edit > pEdit = GetAs< Edit >();
3900 if ( pEdit)
3901 aText = pEdit->GetSelected();
3902 return aText;
3903
3904}
3905
3906void VCLXEdit::setSelection( const css::awt::Selection& aSelection )
3907{
3908 SolarMutexGuard aGuard;
3909
3910 VclPtr< Edit > pEdit = GetAs< Edit >();
3911 if ( pEdit )
3912 pEdit->SetSelection( Selection( aSelection.Min, aSelection.Max ) );
3913}
3914
3915css::awt::Selection VCLXEdit::getSelection()
3916{
3917 SolarMutexGuard aGuard;
3918
3919 Selection aSel;
3920 VclPtr< Edit > pEdit = GetAs< Edit >();
3921 if ( pEdit )
3922 aSel = pEdit->GetSelection();
3923 return css::awt::Selection( aSel.Min(), aSel.Max() );
3924}
3925
3926sal_Bool VCLXEdit::isEditable()
3927{
3928 SolarMutexGuard aGuard;
3929
3930 VclPtr< Edit > pEdit = GetAs< Edit >();
3931 return pEdit && !pEdit->IsReadOnly() && pEdit->IsEnabled();
3932}
3933
3934void VCLXEdit::setEditable( sal_Bool bEditable )
3935{
3936 SolarMutexGuard aGuard;
3937
3938 VclPtr< Edit > pEdit = GetAs< Edit >();
3939 if ( pEdit )
3940 pEdit->SetReadOnly( !bEditable );
3941}
3942
3943
3944void VCLXEdit::setMaxTextLen( sal_Int16 nLen )
3945{
3946 SolarMutexGuard aGuard;
3947
3948 VclPtr< Edit > pEdit = GetAs< Edit >();
3949 if ( pEdit )
3950 pEdit->SetMaxTextLen( nLen );
3951}
3952
3953sal_Int16 VCLXEdit::getMaxTextLen()
3954{
3955 SolarMutexGuard aGuard;
3956
3957 VclPtr< Edit > pEdit = GetAs< Edit >();
3958 return pEdit ? pEdit->GetMaxTextLen() : 0;
3959}
3960
3961void VCLXEdit::setEchoChar( sal_Unicode cEcho )
3962{
3963 SolarMutexGuard aGuard;
3964
3965 VclPtr< Edit > pEdit = GetAs< Edit >();
3966 if ( pEdit )
3967 pEdit->SetEchoChar( cEcho );
3968}
3969
3970void VCLXEdit::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
3971{
3972 SolarMutexGuard aGuard;
3973
3974 VclPtr< Edit > pEdit = GetAs< Edit >();
3975 if ( !pEdit )
3976 return;
3977
3978 sal_uInt16 nPropType = GetPropertyId( PropertyName );
3979 switch ( nPropType )
3980 {
3981 case BASEPROPERTY_HIDEINACTIVESELECTION110:
3982 ::toolkit::adjustBooleanWindowStyle( Value, pEdit, WB_NOHIDESELECTION, true );
3983 if ( pEdit->GetSubEdit() )
3984 ::toolkit::adjustBooleanWindowStyle( Value, pEdit->GetSubEdit(), WB_NOHIDESELECTION, true );
3985 break;
3986
3987 case BASEPROPERTY_READONLY43:
3988 {
3989 bool b = bool();
3990 if ( Value >>= b )
3991 pEdit->SetReadOnly( b );
3992 }
3993 break;
3994 case BASEPROPERTY_ECHOCHAR46:
3995 {
3996 sal_Int16 n = sal_Int16();
3997 if ( Value >>= n )
3998 pEdit->SetEchoChar( n );
3999 }
4000 break;
4001 case BASEPROPERTY_MAXTEXTLEN47:
4002 {
4003 sal_Int16 n = sal_Int16();
4004 if ( Value >>= n )
4005 pEdit->SetMaxTextLen( n );
4006 }
4007 break;
4008 default:
4009 {
4010 VCLXWindow::setProperty( PropertyName, Value );
4011 }
4012 }
4013}
4014
4015css::uno::Any VCLXEdit::getProperty( const OUString& PropertyName )
4016{
4017 SolarMutexGuard aGuard;
4018
4019 css::uno::Any aProp;
4020 VclPtr< Edit > pEdit = GetAs< Edit >();
4021 if ( pEdit )
4022 {
4023 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4024 switch ( nPropType )
4025 {
4026 case BASEPROPERTY_HIDEINACTIVESELECTION110:
4027 aProp <<= ( ( pEdit->GetStyle() & WB_NOHIDESELECTION ) == 0 );
4028 break;
4029 case BASEPROPERTY_READONLY43:
4030 aProp <<= pEdit->IsReadOnly();
4031 break;
4032 case BASEPROPERTY_ECHOCHAR46:
4033 aProp <<= static_cast<sal_Int16>(pEdit->GetEchoChar());
4034 break;
4035 case BASEPROPERTY_MAXTEXTLEN47:
4036 aProp <<= static_cast<sal_Int16>(pEdit->GetMaxTextLen());
4037 break;
4038 default:
4039 {
4040 aProp = VCLXWindow::getProperty( PropertyName );
4041 }
4042 }
4043 }
4044 return aProp;
4045}
4046
4047css::awt::Size VCLXEdit::getMinimumSize( )
4048{
4049 SolarMutexGuard aGuard;
4050
4051 Size aSz;
4052 VclPtr< Edit > pEdit = GetAs< Edit >();
4053 if ( pEdit )
4054 aSz = pEdit->CalcMinimumSize();
4055 return AWTSize(aSz);
4056}
4057
4058css::awt::Size VCLXEdit::getPreferredSize( )
4059{
4060 SolarMutexGuard aGuard;
4061
4062 Size aSz;
4063 VclPtr< Edit > pEdit = GetAs< Edit >();
4064 if ( pEdit )
4065 {
4066 aSz = pEdit->CalcMinimumSize();
4067 aSz.AdjustHeight(4 );
4068 }
4069 return AWTSize(aSz);
4070}
4071
4072css::awt::Size VCLXEdit::calcAdjustedSize( const css::awt::Size& rNewSize )
4073{
4074 SolarMutexGuard aGuard;
4075
4076 css::awt::Size aSz = rNewSize;
4077 css::awt::Size aMinSz = getMinimumSize();
4078 if ( aSz.Height != aMinSz.Height )
4079 aSz.Height = aMinSz.Height;
4080
4081 return aSz;
4082}
4083
4084css::awt::Size VCLXEdit::getMinimumSize( sal_Int16 nCols, sal_Int16 )
4085{
4086 SolarMutexGuard aGuard;
4087
4088 Size aSz;
4089 VclPtr< Edit > pEdit = GetAs< Edit >();
4090 if ( pEdit )
4091 {
4092 if ( nCols )
4093 aSz = pEdit->CalcSize( nCols );
4094 else
4095 aSz = pEdit->CalcMinimumSize();
4096 }
4097 return AWTSize(aSz);
4098}
4099
4100void VCLXEdit::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines )
4101{
4102 SolarMutexGuard aGuard;
4103
4104 nLines = 1;
4105 nCols = 0;
4106 VclPtr< Edit > pEdit = GetAs< Edit >();
4107 if ( pEdit )
4108 nCols = pEdit->GetMaxVisChars();
4109}
4110
4111void VCLXEdit::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
4112{
4113 switch ( rVclWindowEvent.GetId() )
4114 {
4115 case VclEventId::EditModify:
4116 {
4117 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
4118 // since we call listeners below, there is a potential that we will be destroyed
4119 // during the listener call. To prevent the resulting crashes, we keep us
4120 // alive as long as we're here
4121
4122 if ( GetTextListeners().getLength() )
4123 {
4124 css::awt::TextEvent aEvent;
4125 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
4126 GetTextListeners().textChanged( aEvent );
4127 }
4128 }
4129 break;
4130
4131 default:
4132 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
4133 break;
4134 }
4135}
4136
4137
4138
4139
4140void VCLXComboBox::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
4141{
4142 PushPropertyIds( rIds,
4143 BASEPROPERTY_AUTOCOMPLETE49,
4144 BASEPROPERTY_BACKGROUNDCOLOR2,
4145 BASEPROPERTY_BORDER6,
4146 BASEPROPERTY_BORDERCOLOR112,
4147 BASEPROPERTY_DEFAULTCONTROL19,
4148 BASEPROPERTY_DROPDOWN9,
4149 BASEPROPERTY_ENABLED44,
4150 BASEPROPERTY_ENABLEVISIBLE145,
4151 BASEPROPERTY_FONTDESCRIPTOR8,
4152 BASEPROPERTY_HELPTEXT73,
4153 BASEPROPERTY_HELPURL58,
4154 BASEPROPERTY_LINECOUNT21,
4155 BASEPROPERTY_MAXTEXTLEN47,
4156 BASEPROPERTY_PRINTABLE45,
4157 BASEPROPERTY_READONLY43,
4158 BASEPROPERTY_STRINGITEMLIST11,
4159 BASEPROPERTY_TYPEDITEMLIST169,
4160 BASEPROPERTY_TABSTOP14,
4161 BASEPROPERTY_TEXT1,
4162 BASEPROPERTY_HIDEINACTIVESELECTION110,
4163 BASEPROPERTY_ALIGN7,
4164 BASEPROPERTY_WRITING_MODE138,
4165 BASEPROPERTY_CONTEXT_WRITING_MODE139,
4166 BASEPROPERTY_REFERENCE_DEVICE146,
4167 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR116,
4168 0);
4169 // no, don't call VCLXEdit here - it has properties which we do *not* want to have at combo box
4170 // #i92690# / 2008-08-12 / frank.schoenheit@sun.com
4171 // VCLXEdit::ImplGetPropertyIds( rIds );
4172 VCLXWindow::ImplGetPropertyIds( rIds );
4173}
4174
4175VCLXComboBox::VCLXComboBox()
4176 : maActionListeners( *this ), maItemListeners( *this )
4177{
4178}
4179
4180VCLXComboBox::~VCLXComboBox()
4181{
4182 SAL_INFO("toolkit", __FUNCTION__)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "toolkit")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << __FUNCTION__) == 1) {
::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("toolkit")
, ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "4182" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << __FUNCTION__), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << __FUNCTION__; ::
sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("toolkit"),
("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "4182" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << __FUNCTION__) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("toolkit"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "4182" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << __FUNCTION__), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << __FUNCTION__; ::
sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("toolkit"),
("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "4182" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
4183}
4184
4185css::uno::Reference< css::accessibility::XAccessibleContext > VCLXComboBox::CreateAccessibleContext()
4186{
4187 SolarMutexGuard aGuard;
4188
4189 return getAccessibleFactory().createAccessibleContext( this );
4190}
4191
4192void VCLXComboBox::dispose()
4193{
4194 SolarMutexGuard aGuard;
4195
4196 css::lang::EventObject aObj;
4197 aObj.Source = static_cast<cppu::OWeakObject*>(this);
4198 maItemListeners.disposeAndClear( aObj );
4199 maActionListeners.disposeAndClear( aObj );
4200 VCLXEdit::dispose();
4201}
4202
4203
4204void VCLXComboBox::addItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
4205{
4206 SolarMutexGuard aGuard;
4207 maItemListeners.addInterface( l );
4208}
4209
4210void VCLXComboBox::removeItemListener( const css::uno::Reference< css::awt::XItemListener > & l )
4211{
4212 SolarMutexGuard aGuard;
4213 maItemListeners.removeInterface( l );
4214}
4215
4216void VCLXComboBox::addActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
4217{
4218 SolarMutexGuard aGuard;
4219 maActionListeners.addInterface( l );
4220}
4221
4222void VCLXComboBox::removeActionListener( const css::uno::Reference< css::awt::XActionListener > & l )
4223{
4224 SolarMutexGuard aGuard;
4225 maActionListeners.removeInterface( l );
4226}
4227
4228void VCLXComboBox::addItem( const OUString& aItem, sal_Int16 nPos )
4229{
4230 SolarMutexGuard aGuard;
4231
4232 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4233 if ( pBox )
4234 pBox->InsertEntry( aItem, nPos );
4235}
4236
4237void VCLXComboBox::addItems( const css::uno::Sequence< OUString>& aItems, sal_Int16 nPos )
4238{
4239 SolarMutexGuard aGuard;
4240
4241 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4242 if ( !pBox )
4243 return;
4244
4245 sal_uInt16 nP = nPos;
4246 for ( const auto& rItem : aItems )
4247 {
4248 pBox->InsertEntry( rItem, nP );
4249 if ( nP == 0xFFFF )
4250 {
4251 OSL_FAIL( "VCLXComboBox::addItems: too many entries!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "4251" ": "), "%s", "VCLXComboBox::addItems: too many entries!"
); } } while (false)
;
4252 // skip remaining entries, list cannot hold them, anyway
4253 break;
4254 }
4255 }
4256}
4257
4258void VCLXComboBox::removeItems( sal_Int16 nPos, sal_Int16 nCount )
4259{
4260 SolarMutexGuard aGuard;
4261
4262 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4263 if ( pBox )
4264 {
4265 for ( sal_uInt16 n = nCount; n; )
4266 pBox->RemoveEntryAt( nPos + (--n) );
4267 }
4268}
4269
4270sal_Int16 VCLXComboBox::getItemCount()
4271{
4272 SolarMutexGuard aGuard;
4273
4274 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4275 return pBox ? pBox->GetEntryCount() : 0;
4276}
4277
4278OUString VCLXComboBox::getItem( sal_Int16 nPos )
4279{
4280 SolarMutexGuard aGuard;
4281
4282 OUString aItem;
4283 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4284 if ( pBox )
4285 aItem = pBox->GetEntry( nPos );
4286 return aItem;
4287}
4288
4289css::uno::Sequence< OUString> VCLXComboBox::getItems()
4290{
4291 SolarMutexGuard aGuard;
4292
4293 css::uno::Sequence< OUString> aSeq;
4294 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4295 if ( pBox )
4296 {
4297 auto n = pBox->GetEntryCount();
4298 aSeq = css::uno::Sequence< OUString>( n );
4299 while ( n )
4300 {
4301 --n;
4302 aSeq.getArray()[n] = pBox->GetEntry( n );
4303 }
4304 }
4305 return aSeq;
4306}
4307
4308void VCLXComboBox::setDropDownLineCount( sal_Int16 nLines )
4309{
4310 SolarMutexGuard aGuard;
4311
4312 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4313 if ( pBox )
4314 pBox->SetDropDownLineCount( nLines );
4315}
4316
4317sal_Int16 VCLXComboBox::getDropDownLineCount()
4318{
4319 SolarMutexGuard aGuard;
4320
4321 sal_Int16 nLines = 0;
4322 VclPtr< ComboBox > pBox = GetAs< ComboBox >();
4323 if ( pBox )
4324 nLines = pBox->GetDropDownLineCount();
4325 return nLines;
4326}
4327
4328void VCLXComboBox::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
4329{
4330 SolarMutexGuard aGuard;
4331
4332 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4333 if ( !pComboBox )
4334 return;
4335
4336 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4337 switch ( nPropType )
4338 {
4339 case BASEPROPERTY_LINECOUNT21:
4340 {
4341 sal_Int16 n = sal_Int16();
4342 if ( Value >>= n )
4343 pComboBox->SetDropDownLineCount( n );
4344 }
4345 break;
4346 case BASEPROPERTY_AUTOCOMPLETE49:
4347 {
4348 sal_Int16 n = sal_Int16();
4349 if ( Value >>= n )
4350 pComboBox->EnableAutocomplete( n != 0 );
4351 else
4352 {
4353 bool b = bool();
4354 if ( Value >>= b )
4355 pComboBox->EnableAutocomplete( b );
4356 }
4357 }
4358 break;
4359 case BASEPROPERTY_STRINGITEMLIST11:
4360 {
4361 css::uno::Sequence< OUString> aItems;
4362 if ( Value >>= aItems )
4363 {
4364 pComboBox->Clear();
4365 addItems( aItems, 0 );
4366 }
4367 }
4368 break;
4369 default:
4370 {
4371 VCLXEdit::setProperty( PropertyName, Value );
4372
4373 // #109385# SetBorderStyle is not virtual
4374 if ( nPropType == BASEPROPERTY_BORDER6 )
4375 {
4376 sal_uInt16 nBorder = sal_uInt16();
4377 if ( (Value >>= nBorder) && nBorder != 0 )
4378 pComboBox->SetBorderStyle( static_cast<WindowBorderStyle>(nBorder) );
4379 }
4380 }
4381 }
4382}
4383
4384css::uno::Any VCLXComboBox::getProperty( const OUString& PropertyName )
4385{
4386 SolarMutexGuard aGuard;
4387
4388 css::uno::Any aProp;
4389 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4390 if ( pComboBox )
4391 {
4392 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4393 switch ( nPropType )
4394 {
4395 case BASEPROPERTY_LINECOUNT21:
4396 {
4397 aProp <<= static_cast<sal_Int16>(pComboBox->GetDropDownLineCount());
4398 }
4399 break;
4400 case BASEPROPERTY_AUTOCOMPLETE49:
4401 {
4402 aProp <<= pComboBox->IsAutocompleteEnabled();
4403 }
4404 break;
4405 case BASEPROPERTY_STRINGITEMLIST11:
4406 {
4407 const sal_Int32 nItems = pComboBox->GetEntryCount();
4408 css::uno::Sequence< OUString> aSeq( nItems );
4409 OUString* pStrings = aSeq.getArray();
4410 for ( sal_Int32 n = 0; n < nItems; ++n )
4411 pStrings[n] = pComboBox->GetEntry( n );
4412 aProp <<= aSeq;
4413
4414 }
4415 break;
4416 default:
4417 {
4418 aProp = VCLXEdit::getProperty( PropertyName );
4419 }
4420 }
4421 }
4422 return aProp;
4423}
4424
4425void VCLXComboBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
4426{
4427 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
4428 // since we call listeners below, there is a potential that we will be destroyed
4429 // during the listener call. To prevent the resulting crashes, we keep us
4430 // alive as long as we're here
4431
4432 switch ( rVclWindowEvent.GetId() )
4433 {
4434 case VclEventId::ComboboxSelect:
4435 if ( maItemListeners.getLength() )
4436 {
4437 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4438 if( pComboBox )
4439 {
4440 if ( !pComboBox->IsTravelSelect() )
4441 {
4442 css::awt::ItemEvent aEvent;
4443 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
4444 aEvent.Highlighted = 0;
4445
4446 // Set to 0xFFFF on multiple selection, selected entry ID otherwise
4447 aEvent.Selected = pComboBox->GetEntryPos( pComboBox->GetText() );
4448
4449 maItemListeners.itemStateChanged( aEvent );
4450 }
4451 }
4452 }
4453 break;
4454
4455 case VclEventId::ComboboxDoubleClick:
4456 if ( maActionListeners.getLength() )
4457 {
4458 css::awt::ActionEvent aEvent;
4459 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
4460// aEvent.ActionCommand = ...;
4461 maActionListeners.actionPerformed( aEvent );
4462 }
4463 break;
4464
4465 default:
4466 VCLXEdit::ProcessWindowEvent( rVclWindowEvent );
4467 break;
4468 }
4469}
4470
4471css::awt::Size VCLXComboBox::getMinimumSize( )
4472{
4473 SolarMutexGuard aGuard;
4474
4475 Size aSz;
4476 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4477 if ( pComboBox )
4478 aSz = pComboBox->CalcMinimumSize();
4479 return AWTSize(aSz);
4480}
4481
4482css::awt::Size VCLXComboBox::getPreferredSize( )
4483{
4484 SolarMutexGuard aGuard;
4485
4486 Size aSz;
4487 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4488 if ( pComboBox )
4489 {
4490 aSz = pComboBox->CalcMinimumSize();
4491 if ( pComboBox->GetStyle() & WB_DROPDOWN )
4492 aSz.AdjustHeight(4 );
4493 }
4494 return AWTSize(aSz);
4495}
4496
4497css::awt::Size VCLXComboBox::calcAdjustedSize( const css::awt::Size& rNewSize )
4498{
4499 SolarMutexGuard aGuard;
4500
4501 Size aSz = VCLSize(rNewSize);
4502 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4503 if ( pComboBox )
4504 aSz = pComboBox->CalcAdjustedSize( aSz );
4505 return AWTSize(aSz);
4506}
4507
4508css::awt::Size VCLXComboBox::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines )
4509{
4510 SolarMutexGuard aGuard;
4511
4512 Size aSz;
4513 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4514 if ( pComboBox )
4515 aSz = pComboBox->CalcBlockSize( nCols, nLines );
4516 return AWTSize(aSz);
4517}
4518
4519void VCLXComboBox::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines )
4520{
4521 SolarMutexGuard aGuard;
4522
4523 nCols = nLines = 0;
4524 VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
4525 if ( pComboBox )
4526 {
4527 sal_uInt16 nC, nL;
4528 pComboBox->GetMaxVisColumnsAndLines( nC, nL );
4529 nCols = nC;
4530 nLines = nL;
4531 }
4532}
4533void SAL_CALL VCLXComboBox::listItemInserted( const ItemListEvent& i_rEvent )
4534{
4535 SolarMutexGuard aGuard;
4536
4537 VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >();
4538
4539 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemInserted: no ComboBox?!" )if( !(pComboBox) ) { do { if (true && (!(pComboBox)))
{ sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "4539" ": "), "%s", "VCLXComboBox::listItemInserted: no ComboBox?!"
); } } while (false); return; }
;
4540 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition <= pComboBox->GetEntryCount() ),if( !(( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent
.ItemPosition <= pComboBox->GetEntryCount() )) ) { do {
if (true && (!(( i_rEvent.ItemPosition >= 0 ) &&
( i_rEvent.ItemPosition <= pComboBox->GetEntryCount() )
))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "4541" ": "), "%s", "VCLXComboBox::listItemInserted: illegal (inconsistent) item position!"
); } } while (false); return; }
4541 "VCLXComboBox::listItemInserted: illegal (inconsistent) item position!" )if( !(( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent
.ItemPosition <= pComboBox->GetEntryCount() )) ) { do {
if (true && (!(( i_rEvent.ItemPosition >= 0 ) &&
( i_rEvent.ItemPosition <= pComboBox->GetEntryCount() )
))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "4541" ": "), "%s", "VCLXComboBox::listItemInserted: illegal (inconsistent) item position!"
); } } while (false); return; }
;
4542 pComboBox->InsertEntryWithImage(
4543 i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : OUString(),
4544 i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : Image(),
4545 i_rEvent.ItemPosition );
4546}
4547
4548void SAL_CALL VCLXComboBox::listItemRemoved( const ItemListEvent& i_rEvent )
4549{
4550 SolarMutexGuard aGuard;
4551
4552 VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >();
4553
4554 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemRemoved: no ComboBox?!" )if( !(pComboBox) ) { do { if (true && (!(pComboBox)))
{ sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "4554" ": "), "%s", "VCLXComboBox::listItemRemoved: no ComboBox?!"
); } } while (false); return; }
;
4555 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < pComboBox->GetEntryCount() ),if( !(( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent
.ItemPosition < pComboBox->GetEntryCount() )) ) { do { if
(true && (!(( i_rEvent.ItemPosition >= 0 ) &&
( i_rEvent.ItemPosition < pComboBox->GetEntryCount() )
))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "4556" ": "), "%s", "VCLXComboBox::listItemRemoved: illegal (inconsistent) item position!"
); } } while (false); return; }
4556 "VCLXComboBox::listItemRemoved: illegal (inconsistent) item position!" )if( !(( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent
.ItemPosition < pComboBox->GetEntryCount() )) ) { do { if
(true && (!(( i_rEvent.ItemPosition >= 0 ) &&
( i_rEvent.ItemPosition < pComboBox->GetEntryCount() )
))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "4556" ": "), "%s", "VCLXComboBox::listItemRemoved: illegal (inconsistent) item position!"
); } } while (false); return; }
;
4557
4558 pComboBox->RemoveEntryAt( i_rEvent.ItemPosition );
4559}
4560
4561void SAL_CALL VCLXComboBox::listItemModified( const ItemListEvent& i_rEvent )
4562{
4563 SolarMutexGuard aGuard;
4564
4565 VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >();
4566
4567 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" )if( !(pComboBox) ) { do { if (true && (!(pComboBox)))
{ sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "4567" ": "), "%s", "VCLXComboBox::listItemModified: no ComboBox?!"
); } } while (false); return; }
;
4568 ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < pComboBox->GetEntryCount() ),if( !(( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent
.ItemPosition < pComboBox->GetEntryCount() )) ) { do { if
(true && (!(( i_rEvent.ItemPosition >= 0 ) &&
( i_rEvent.ItemPosition < pComboBox->GetEntryCount() )
))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "4569" ": "), "%s", "VCLXComboBox::listItemModified: illegal (inconsistent) item position!"
); } } while (false); return; }
4569 "VCLXComboBox::listItemModified: illegal (inconsistent) item position!" )if( !(( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent
.ItemPosition < pComboBox->GetEntryCount() )) ) { do { if
(true && (!(( i_rEvent.ItemPosition >= 0 ) &&
( i_rEvent.ItemPosition < pComboBox->GetEntryCount() )
))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "4569" ": "), "%s", "VCLXComboBox::listItemModified: illegal (inconsistent) item position!"
); } } while (false); return; }
;
4570
4571 // VCL's ComboBox does not support changing an entry's text or image, so remove and re-insert
4572
4573 const OUString sNewText = i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : pComboBox->GetEntry( i_rEvent.ItemPosition );
4574 const Image aNewImage( i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : pComboBox->GetEntryImage( i_rEvent.ItemPosition ) );
4575
4576 pComboBox->RemoveEntryAt( i_rEvent.ItemPosition );
4577 pComboBox->InsertEntryWithImage(sNewText, aNewImage, i_rEvent.ItemPosition);
4578}
4579
4580void SAL_CALL VCLXComboBox::allItemsRemoved( const EventObject& )
4581{
4582 SolarMutexGuard aGuard;
4583
4584 VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >();
4585 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" )if( !(pComboBox) ) { do { if (true && (!(pComboBox)))
{ sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "4585" ": "), "%s", "VCLXComboBox::listItemModified: no ComboBox?!"
); } } while (false); return; }
;
4586
4587 pComboBox->Clear();
4588}
4589
4590void SAL_CALL VCLXComboBox::itemListChanged( const EventObject& i_rEvent )
4591{
4592 SolarMutexGuard aGuard;
4593
4594 VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >();
4595 ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" )if( !(pComboBox) ) { do { if (true && (!(pComboBox)))
{ sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "4595" ": "), "%s", "VCLXComboBox::listItemModified: no ComboBox?!"
); } } while (false); return; }
;
4596
4597 pComboBox->Clear();
4598
4599 uno::Reference< beans::XPropertySet > xPropSet( i_rEvent.Source, uno::UNO_QUERY_THROW );
4600 uno::Reference< beans::XPropertySetInfo > xPSI( xPropSet->getPropertySetInfo(), uno::UNO_SET_THROW );
4601 // bool localize = xPSI->hasPropertyByName("ResourceResolver");
4602 uno::Reference< resource::XStringResourceResolver > xStringResourceResolver;
4603 if ( xPSI->hasPropertyByName("ResourceResolver") )
4604 {
4605 xStringResourceResolver.set(
4606 xPropSet->getPropertyValue("ResourceResolver"),
4607 uno::UNO_QUERY
4608 );
4609 }
4610
4611
4612 Reference< XItemList > xItemList( i_rEvent.Source, uno::UNO_QUERY_THROW );
4613 const uno::Sequence< beans::Pair< OUString, OUString > > aItems = xItemList->getAllItems();
4614 for ( const auto& rItem : aItems )
4615 {
4616 OUString aLocalizationKey( rItem.First );
4617 if ( xStringResourceResolver.is() && !aLocalizationKey.isEmpty() && aLocalizationKey[0] == '&' )
4618 {
4619 aLocalizationKey = xStringResourceResolver->resolveString(aLocalizationKey.copy( 1 ));
4620 }
4621 pComboBox->InsertEntryWithImage(aLocalizationKey,
4622 lcl_getImageFromURL(rItem.Second));
4623 }
4624}
4625void SAL_CALL VCLXComboBox::disposing( const EventObject& i_rEvent )
4626{
4627 // just disambiguate
4628 VCLXEdit::disposing( i_rEvent );
4629}
4630
4631
4632
4633void VCLXFormattedSpinField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
4634{
4635 // Interestingly in the UnoControl API this is
4636 // - not derived from XEdit ultimately, (correct ?) - so cut this here ...
4637// VCLXSpinField::ImplGetPropertyIds( rIds );
4638 VCLXWindow::ImplGetPropertyIds( rIds );
4639}
4640
4641VCLXFormattedSpinField::VCLXFormattedSpinField()
4642 : mpFormatter(nullptr)
4643{
4644}
4645
4646VCLXFormattedSpinField::~VCLXFormattedSpinField()
4647{
4648}
4649
4650void VCLXFormattedSpinField::setStrictFormat( bool bStrict )
4651{
4652 SolarMutexGuard aGuard;
4653
4654 FormatterBase* pFormatter = GetFormatter();
4655 if ( pFormatter )
4656 pFormatter->SetStrictFormat( bStrict );
4657}
4658
4659bool VCLXFormattedSpinField::isStrictFormat() const
4660{
4661 FormatterBase* pFormatter = GetFormatter();
4662 return pFormatter && pFormatter->IsStrictFormat();
4663}
4664
4665
4666void VCLXFormattedSpinField::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
4667{
4668 SolarMutexGuard aGuard;
4669
4670 FormatterBase* pFormatter = GetFormatter();
4671 if ( !pFormatter )
4672 return;
4673
4674 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4675 switch ( nPropType )
4676 {
4677 case BASEPROPERTY_SPIN27:
4678 {
4679 bool b = bool();
4680 if ( Value >>= b )
4681 {
4682 WinBits nStyle = GetWindow()->GetStyle() | WB_SPIN;
4683 if ( !b )
4684 nStyle &= ~WB_SPIN;
4685 GetWindow()->SetStyle( nStyle );
4686 }
4687 }
4688 break;
4689 case BASEPROPERTY_STRICTFORMAT28:
4690 {
4691 bool b = bool();
4692 if ( Value >>= b )
4693 {
4694 pFormatter->SetStrictFormat( b );
4695 }
4696 }
4697 break;
4698 default:
4699 {
4700 VCLXSpinField::setProperty( PropertyName, Value );
4701 }
4702 }
4703}
4704
4705css::uno::Any VCLXFormattedSpinField::getProperty( const OUString& PropertyName )
4706{
4707 SolarMutexGuard aGuard;
4708
4709 css::uno::Any aProp;
4710 FormatterBase* pFormatter = GetFormatter();
4711 if ( pFormatter )
4712 {
4713 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4714 switch ( nPropType )
4715 {
4716 case BASEPROPERTY_TABSTOP14:
4717 {
4718 aProp <<= ( GetWindow()->GetStyle() & WB_SPIN ) != 0;
4719 }
4720 break;
4721 case BASEPROPERTY_STRICTFORMAT28:
4722 {
4723 aProp <<= pFormatter->IsStrictFormat();
4724 }
4725 break;
4726 default:
4727 {
4728 aProp = VCLXSpinField::getProperty( PropertyName );
4729 }
4730 }
4731 }
4732 return aProp;
4733}
4734
4735
4736
4737
4738void VCLXDateField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
4739{
4740 PushPropertyIds( rIds,
4741 BASEPROPERTY_ALIGN7,
4742 BASEPROPERTY_BACKGROUNDCOLOR2,
4743 BASEPROPERTY_BORDER6,
4744 BASEPROPERTY_BORDERCOLOR112,
4745 BASEPROPERTY_DATE30,
4746 BASEPROPERTY_DATEMAX32,
4747 BASEPROPERTY_DATEMIN31,
4748 BASEPROPERTY_DATESHOWCENTURY23,
4749 BASEPROPERTY_DEFAULTCONTROL19,
4750 BASEPROPERTY_DROPDOWN9,
4751 BASEPROPERTY_ENABLED44,
4752 BASEPROPERTY_ENABLEVISIBLE145,
4753 BASEPROPERTY_EXTDATEFORMAT22,
4754 BASEPROPERTY_FONTDESCRIPTOR8,
4755 BASEPROPERTY_HELPTEXT73,
4756 BASEPROPERTY_HELPURL58,
4757 BASEPROPERTY_PRINTABLE45,
4758 BASEPROPERTY_READONLY43,
4759 BASEPROPERTY_REPEAT101,
4760 BASEPROPERTY_REPEAT_DELAY95,
4761 BASEPROPERTY_SPIN27,
4762 BASEPROPERTY_STRICTFORMAT28,
4763 BASEPROPERTY_TABSTOP14,
4764 BASEPROPERTY_ENFORCE_FORMAT102,
4765 BASEPROPERTY_TEXT1,
4766 BASEPROPERTY_HIDEINACTIVESELECTION110,
4767 BASEPROPERTY_VERTICALALIGN115,
4768 BASEPROPERTY_WRITING_MODE138,
4769 BASEPROPERTY_CONTEXT_WRITING_MODE139,
4770 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR116,
4771 0);
4772 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
4773}
4774
4775VCLXDateField::VCLXDateField()
4776{
4777}
4778
4779VCLXDateField::~VCLXDateField()
4780{
4781}
4782
4783//change the window type here to match the role
4784css::uno::Reference< css::accessibility::XAccessibleContext > VCLXDateField::CreateAccessibleContext()
4785{
4786 VclPtr< vcl::Window > pWindow = GetWindow();
4787 if ( pWindow )
4788 {
4789 pWindow->SetType( WindowType::DATEFIELD );
4790 }
4791 return getAccessibleFactory().createAccessibleContext( this );
4792}
4793
4794// css::uno::XInterface
4795css::uno::Any VCLXDateField::queryInterface( const css::uno::Type & rType )
4796{
4797 css::uno::Any aRet = ::cppu::queryInterface( rType,
4798 static_cast< css::awt::XDateField* >(this) );
4799 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
4800}
4801
4802IMPL_IMPLEMENTATION_ID( VCLXDateField )css::uno::Sequence< sal_Int8 > VCLXDateField::getImplementationId
() { return css::uno::Sequence<sal_Int8>(); }
4803
4804// css::lang::XTypeProvider
4805css::uno::Sequence< css::uno::Type > VCLXDateField::getTypes()
4806{
4807 static const ::cppu::OTypeCollection aTypeList(
4808 cppu::UnoType<css::lang::XTypeProvider>::get(),
4809 cppu::UnoType<css::awt::XDateField>::get(),
4810 VCLXFormattedSpinField::getTypes()
4811 );
4812 return aTypeList.getTypes();
4813}
4814
4815void VCLXDateField::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
4816{
4817 SolarMutexGuard aGuard;
4818
4819 if ( !(GetWindow()) )
4820 return;
4821
4822 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
4823
4824 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4825 switch ( nPropType )
4826 {
4827 case BASEPROPERTY_DATE30:
4828 {
4829 if ( bVoid )
4830 {
4831 GetAs< DateField >()->EnableEmptyFieldValue( true );
4832 GetAs< DateField >()->SetEmptyFieldValue();
4833 }
4834 else
4835 {
4836 util::Date d;
4837 if ( Value >>= d )
4838 setDate( d );
4839 }
4840 }
4841 break;
4842 case BASEPROPERTY_DATEMIN31:
4843 {
4844 util::Date d;
4845 if ( Value >>= d )
4846 setMin( d );
4847 }
4848 break;
4849 case BASEPROPERTY_DATEMAX32:
4850 {
4851 util::Date d;
4852 if ( Value >>= d )
4853 setMax( d );
4854 }
4855 break;
4856 case BASEPROPERTY_EXTDATEFORMAT22:
4857 {
4858 sal_Int16 n = sal_Int16();
4859 if ( Value >>= n )
4860 GetAs< DateField >()->SetExtDateFormat( static_cast<ExtDateFieldFormat>(n) );
4861 }
4862 break;
4863 case BASEPROPERTY_DATESHOWCENTURY23:
4864 {
4865 bool b = bool();
4866 if ( Value >>= b )
4867 GetAs< DateField >()->SetShowDateCentury( b );
4868 }
4869 break;
4870 case BASEPROPERTY_ENFORCE_FORMAT102:
4871 {
4872 bool bEnforce( true );
4873 OSL_VERIFY( Value >>= bEnforce )do { if (!(Value >>= bEnforce)) do { if (true &&
(!(0))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), (
"legacy.osl"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "4873" ": "), "OSL_ASSERT: %s", "0"); } } while (false);
} while (0)
;
4874 GetAs< DateField >()->EnforceValidValue( bEnforce );
4875 }
4876 break;
4877 default:
4878 {
4879 VCLXFormattedSpinField::setProperty( PropertyName, Value );
4880 }
4881 }
4882}
4883
4884css::uno::Any VCLXDateField::getProperty( const OUString& PropertyName )
4885{
4886 SolarMutexGuard aGuard;
4887
4888 css::uno::Any aProp;
4889 FormatterBase* pFormatter = GetFormatter();
4890 if ( pFormatter )
4891 {
4892 sal_uInt16 nPropType = GetPropertyId( PropertyName );
4893 switch ( nPropType )
4894 {
4895 case BASEPROPERTY_DATE30:
4896 {
4897 aProp <<= getDate();
4898 }
4899 break;
4900 case BASEPROPERTY_DATEMIN31:
4901 {
4902 aProp <<= getMin();
4903 }
4904 break;
4905 case BASEPROPERTY_DATEMAX32:
4906 {
4907 aProp <<= getMax();
4908 }
4909 break;
4910 case BASEPROPERTY_DATESHOWCENTURY23:
4911 {
4912 aProp <<= GetAs< DateField >()->IsShowDateCentury();
4913 }
4914 break;
4915 case BASEPROPERTY_ENFORCE_FORMAT102:
4916 {
4917 aProp <<= GetAs< DateField >()->IsEnforceValidValue( );
4918 }
4919 break;
4920 default:
4921 {
4922 aProp = VCLXFormattedSpinField::getProperty( PropertyName );
4923 }
4924 }
4925 }
4926 return aProp;
4927}
4928
4929
4930void VCLXDateField::setDate( const util::Date& aDate )
4931{
4932 SolarMutexGuard aGuard;
4933
4934 VclPtr< DateField > pDateField = GetAs< DateField >();
4935 if ( pDateField )
4936 {
4937 pDateField->SetDate( aDate );
4938
4939 // #107218# Call same listeners like VCL would do after user interaction
4940 SetSynthesizingVCLEvent( true );
4941 pDateField->SetModifyFlag();
4942 pDateField->Modify();
4943 SetSynthesizingVCLEvent( false );
4944 }
4945}
4946
4947util::Date VCLXDateField::getDate()
4948{
4949 SolarMutexGuard aGuard;
4950
4951 VclPtr< DateField > pDateField = GetAs< DateField >();
4952 if ( pDateField )
4953 return pDateField->GetDate().GetUNODate();
4954 else
4955 return util::Date();
4956}
4957
4958void VCLXDateField::setMin( const util::Date& aDate )
4959{
4960 SolarMutexGuard aGuard;
4961
4962 VclPtr< DateField > pDateField = GetAs< DateField >();
4963 if ( pDateField )
4964 pDateField->SetMin( aDate );
4965}
4966
4967util::Date VCLXDateField::getMin()
4968{
4969 SolarMutexGuard aGuard;
4970
4971 VclPtr< DateField > pDateField = GetAs< DateField >();
4972 if ( pDateField )
4973 return pDateField->GetMin().GetUNODate();
4974 else
4975 return util::Date();
4976}
4977
4978void VCLXDateField::setMax( const util::Date& aDate )
4979{
4980 SolarMutexGuard aGuard;
4981
4982 VclPtr< DateField > pDateField = GetAs< DateField >();
4983 if ( pDateField )
4984 pDateField->SetMax( aDate );
4985}
4986
4987util::Date VCLXDateField::getMax()
4988{
4989 SolarMutexGuard aGuard;
4990
4991 VclPtr< DateField > pDateField = GetAs< DateField >();
4992 if ( pDateField )
4993 return pDateField->GetMax().GetUNODate();
4994 else
4995 return util::Date();
4996}
4997
4998void VCLXDateField::setFirst( const util::Date& aDate )
4999{
5000 SolarMutexGuard aGuard;
5001
5002 VclPtr< DateField > pDateField = GetAs< DateField >();
5003 if ( pDateField )
5004 pDateField->SetFirst( aDate );
5005}
5006
5007util::Date VCLXDateField::getFirst()
5008{
5009 SolarMutexGuard aGuard;
5010
5011 VclPtr< DateField > pDateField = GetAs< DateField >();
5012 if ( pDateField )
5013 return pDateField->GetFirst().GetUNODate();
5014 else
5015 return util::Date();
5016}
5017
5018void VCLXDateField::setLast( const util::Date& aDate )
5019{
5020 SolarMutexGuard aGuard;
5021
5022 VclPtr< DateField > pDateField = GetAs< DateField >();
5023 if ( pDateField )
5024 pDateField->SetLast( aDate );
5025}
5026
5027util::Date VCLXDateField::getLast()
5028{
5029 SolarMutexGuard aGuard;
5030
5031 VclPtr< DateField > pDateField = GetAs< DateField >();
5032 if ( pDateField )
5033 return pDateField->GetLast().GetUNODate();
5034 else
5035 return util::Date();
5036}
5037
5038void VCLXDateField::setLongFormat( sal_Bool bLong )
5039{
5040 SolarMutexGuard aGuard;
5041
5042 VclPtr< DateField > pDateField = GetAs< DateField >();
5043 if ( pDateField )
5044 pDateField->SetLongFormat( bLong );
5045}
5046
5047sal_Bool VCLXDateField::isLongFormat()
5048{
5049 SolarMutexGuard aGuard;
5050
5051 VclPtr< DateField > pDateField = GetAs< DateField >();
5052 return pDateField && pDateField->IsLongFormat();
5053}
5054
5055void VCLXDateField::setEmpty()
5056{
5057 SolarMutexGuard aGuard;
5058
5059 VclPtr< DateField > pDateField = GetAs< DateField >();
5060 if ( pDateField )
5061 {
5062 pDateField->SetEmptyDate();
5063
5064 // #107218# Call same listeners like VCL would do after user interaction
5065 SetSynthesizingVCLEvent( true );
5066 pDateField->SetModifyFlag();
5067 pDateField->Modify();
5068 SetSynthesizingVCLEvent( false );
5069 }
5070}
5071
5072sal_Bool VCLXDateField::isEmpty()
5073{
5074 SolarMutexGuard aGuard;
5075
5076 VclPtr< DateField > pDateField = GetAs< DateField >();
5077 return pDateField && pDateField->IsEmptyDate();
5078}
5079
5080void VCLXDateField::setStrictFormat( sal_Bool bStrict )
5081{
5082 VCLXFormattedSpinField::setStrictFormat( bStrict );
5083}
5084
5085sal_Bool VCLXDateField::isStrictFormat()
5086{
5087 return VCLXFormattedSpinField::isStrictFormat();
5088}
5089
5090
5091
5092
5093void VCLXTimeField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
5094{
5095 PushPropertyIds( rIds,
5096 BASEPROPERTY_ALIGN7,
5097 BASEPROPERTY_BACKGROUNDCOLOR2,
5098 BASEPROPERTY_BORDER6,
5099 BASEPROPERTY_BORDERCOLOR112,
5100 BASEPROPERTY_DEFAULTCONTROL19,
5101 BASEPROPERTY_ENABLED44,
5102 BASEPROPERTY_ENABLEVISIBLE145,
5103 BASEPROPERTY_EXTTIMEFORMAT24,
5104 BASEPROPERTY_FONTDESCRIPTOR8,
5105 BASEPROPERTY_HELPTEXT73,
5106 BASEPROPERTY_HELPURL58,
5107 BASEPROPERTY_PRINTABLE45,
5108 BASEPROPERTY_READONLY43,
5109 BASEPROPERTY_REPEAT101,
5110 BASEPROPERTY_REPEAT_DELAY95,
5111 BASEPROPERTY_SPIN27,
5112 BASEPROPERTY_STRICTFORMAT28,
5113 BASEPROPERTY_TABSTOP14,
5114 BASEPROPERTY_TIME33,
5115 BASEPROPERTY_TIMEMAX35,
5116 BASEPROPERTY_TIMEMIN34,
5117 BASEPROPERTY_ENFORCE_FORMAT102,
5118 BASEPROPERTY_TEXT1,
5119 BASEPROPERTY_HIDEINACTIVESELECTION110,
5120 BASEPROPERTY_VERTICALALIGN115,
5121 BASEPROPERTY_WRITING_MODE138,
5122 BASEPROPERTY_CONTEXT_WRITING_MODE139,
5123 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR116,
5124 0);
5125 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5126}
5127
5128VCLXTimeField::VCLXTimeField()
5129{
5130}
5131
5132VCLXTimeField::~VCLXTimeField()
5133{
5134}
5135
5136//change the window type here to match the role
5137css::uno::Reference< css::accessibility::XAccessibleContext > VCLXTimeField::CreateAccessibleContext()
5138{
5139 VclPtr< vcl::Window > pWindow = GetWindow();
5140 if ( pWindow )
5141 {
5142 pWindow->SetType( WindowType::TIMEFIELD );
5143 }
5144 return getAccessibleFactory().createAccessibleContext( this );
5145}
5146
5147// css::uno::XInterface
5148css::uno::Any VCLXTimeField::queryInterface( const css::uno::Type & rType )
5149{
5150 css::uno::Any aRet = ::cppu::queryInterface( rType,
5151 static_cast< css::awt::XTimeField* >(this) );
5152 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
5153}
5154
5155IMPL_IMPLEMENTATION_ID( VCLXTimeField )css::uno::Sequence< sal_Int8 > VCLXTimeField::getImplementationId
() { return css::uno::Sequence<sal_Int8>(); }
5156
5157// css::lang::XTypeProvider
5158css::uno::Sequence< css::uno::Type > VCLXTimeField::getTypes()
5159{
5160 static const ::cppu::OTypeCollection aTypeList(
5161 cppu::UnoType<css::lang::XTypeProvider>::get(),
5162 cppu::UnoType<css::awt::XTimeField>::get(),
5163 VCLXFormattedSpinField::getTypes()
5164 );
5165 return aTypeList.getTypes();
5166}
5167
5168void VCLXTimeField::setTime( const util::Time& aTime )
5169{
5170 SolarMutexGuard aGuard;
5171
5172 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5173 if ( pTimeField )
5174 {
5175 pTimeField->SetTime( aTime );
5176
5177 // #107218# Call same listeners like VCL would do after user interaction
5178 SetSynthesizingVCLEvent( true );
5179 pTimeField->SetModifyFlag();
5180 pTimeField->Modify();
5181 SetSynthesizingVCLEvent( false );
5182 }
5183}
5184
5185util::Time VCLXTimeField::getTime()
5186{
5187 SolarMutexGuard aGuard;
5188
5189 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5190 if ( pTimeField )
5191 return pTimeField->GetTime().GetUNOTime();
5192 else
5193 return util::Time();
5194}
5195
5196void VCLXTimeField::setMin( const util::Time& aTime )
5197{
5198 SolarMutexGuard aGuard;
5199
5200 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5201 if ( pTimeField )
5202 pTimeField->SetMin( aTime );
5203}
5204
5205util::Time VCLXTimeField::getMin()
5206{
5207 SolarMutexGuard aGuard;
5208
5209 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5210 if ( pTimeField )
5211 return pTimeField->GetMin().GetUNOTime();
5212 else
5213 return util::Time();
5214}
5215
5216void VCLXTimeField::setMax( const util::Time& aTime )
5217{
5218 SolarMutexGuard aGuard;
5219
5220 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5221 if ( pTimeField )
5222 pTimeField->SetMax( aTime );
5223}
5224
5225util::Time VCLXTimeField::getMax()
5226{
5227 SolarMutexGuard aGuard;
5228
5229 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5230 if ( pTimeField )
5231 return pTimeField->GetMax().GetUNOTime();
5232 else
5233 return util::Time();
5234}
5235
5236void VCLXTimeField::setFirst( const util::Time& aTime )
5237{
5238 SolarMutexGuard aGuard;
5239
5240 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5241 if ( pTimeField )
5242 pTimeField->SetFirst( aTime );
5243}
5244
5245util::Time VCLXTimeField::getFirst()
5246{
5247 SolarMutexGuard aGuard;
5248
5249 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5250 if ( pTimeField )
5251 return pTimeField->GetFirst().GetUNOTime();
5252 else
5253 return util::Time();
5254}
5255
5256void VCLXTimeField::setLast( const util::Time& aTime )
5257{
5258 SolarMutexGuard aGuard;
5259
5260 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5261 if ( pTimeField )
5262 pTimeField->SetLast( aTime );
5263}
5264
5265util::Time VCLXTimeField::getLast()
5266{
5267 SolarMutexGuard aGuard;
5268
5269 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5270 if ( pTimeField )
5271 return pTimeField->GetLast().GetUNOTime();
5272 else
5273 return util::Time();
5274}
5275
5276void VCLXTimeField::setEmpty()
5277{
5278 SolarMutexGuard aGuard;
5279
5280 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5281 if ( pTimeField )
5282 pTimeField->SetEmptyTime();
5283}
5284
5285sal_Bool VCLXTimeField::isEmpty()
5286{
5287 SolarMutexGuard aGuard;
5288
5289 VclPtr< TimeField > pTimeField = GetAs< TimeField >();
5290 return pTimeField && pTimeField->IsEmptyTime();
5291}
5292
5293void VCLXTimeField::setStrictFormat( sal_Bool bStrict )
5294{
5295 VCLXFormattedSpinField::setStrictFormat( bStrict );
5296}
5297
5298sal_Bool VCLXTimeField::isStrictFormat()
5299{
5300 return VCLXFormattedSpinField::isStrictFormat();
5301}
5302
5303
5304void VCLXTimeField::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
5305{
5306 SolarMutexGuard aGuard;
5307
5308 if ( !(GetWindow()) )
5309 return;
5310
5311 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
5312
5313 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5314 switch ( nPropType )
5315 {
5316 case BASEPROPERTY_TIME33:
5317 {
5318 if ( bVoid )
5319 {
5320 GetAs< TimeField >()->EnableEmptyFieldValue( true );
5321 GetAs< TimeField >()->SetEmptyFieldValue();
5322 }
5323 else
5324 {
5325 util::Time t;
5326 if ( Value >>= t )
5327 setTime( t );
5328 }
5329 }
5330 break;
5331 case BASEPROPERTY_TIMEMIN34:
5332 {
5333 util::Time t;
5334 if ( Value >>= t )
5335 setMin( t );
5336 }
5337 break;
5338 case BASEPROPERTY_TIMEMAX35:
5339 {
5340 util::Time t;
5341 if ( Value >>= t )
5342 setMax( t );
5343 }
5344 break;
5345 case BASEPROPERTY_EXTTIMEFORMAT24:
5346 {
5347 sal_Int16 n = sal_Int16();
5348 if ( Value >>= n )
5349 GetAs< TimeField >()->SetExtFormat( static_cast<ExtTimeFieldFormat>(n) );
5350 }
5351 break;
5352 case BASEPROPERTY_ENFORCE_FORMAT102:
5353 {
5354 bool bEnforce( true );
5355 OSL_VERIFY( Value >>= bEnforce )do { if (!(Value >>= bEnforce)) do { if (true &&
(!(0))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), (
"legacy.osl"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "5355" ": "), "OSL_ASSERT: %s", "0"); } } while (false);
} while (0)
;
5356 GetAs< TimeField >()->EnforceValidValue( bEnforce );
5357 }
5358 break;
5359 default:
5360 {
5361 VCLXFormattedSpinField::setProperty( PropertyName, Value );
5362 }
5363 }
5364}
5365
5366css::uno::Any VCLXTimeField::getProperty( const OUString& PropertyName )
5367{
5368 SolarMutexGuard aGuard;
5369
5370 css::uno::Any aProp;
5371 if ( GetWindow() )
5372 {
5373 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5374 switch ( nPropType )
5375 {
5376 case BASEPROPERTY_TIME33:
5377 {
5378 aProp <<= getTime();
5379 }
5380 break;
5381 case BASEPROPERTY_TIMEMIN34:
5382 {
5383 aProp <<= getMin();
5384 }
5385 break;
5386 case BASEPROPERTY_TIMEMAX35:
5387 {
5388 aProp <<= getMax();
5389 }
5390 break;
5391 case BASEPROPERTY_ENFORCE_FORMAT102:
5392 {
5393 aProp <<= GetAs< TimeField >()->IsEnforceValidValue( );
5394 }
5395 break;
5396 default:
5397 {
5398 aProp = VCLXFormattedSpinField::getProperty( PropertyName );
5399 }
5400 }
5401 }
5402 return aProp;
5403}
5404
5405
5406
5407
5408void VCLXNumericField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
5409{
5410 PushPropertyIds( rIds,
5411 BASEPROPERTY_ALIGN7,
5412 BASEPROPERTY_BACKGROUNDCOLOR2,
5413 BASEPROPERTY_BORDER6,
5414 BASEPROPERTY_BORDERCOLOR112,
5415 BASEPROPERTY_DECIMALACCURACY29,
5416 BASEPROPERTY_DEFAULTCONTROL19,
5417 BASEPROPERTY_ENABLED44,
5418 BASEPROPERTY_ENABLEVISIBLE145,
5419 BASEPROPERTY_FONTDESCRIPTOR8,
5420 BASEPROPERTY_HELPTEXT73,
5421 BASEPROPERTY_HELPURL58,
5422 BASEPROPERTY_NUMSHOWTHOUSANDSEP25,
5423 BASEPROPERTY_PRINTABLE45,
5424 BASEPROPERTY_READONLY43,
5425 BASEPROPERTY_REPEAT101,
5426 BASEPROPERTY_REPEAT_DELAY95,
5427 BASEPROPERTY_SPIN27,
5428 BASEPROPERTY_STRICTFORMAT28,
5429 BASEPROPERTY_TABSTOP14,
5430 BASEPROPERTY_VALUEMAX_DOUBLE54,
5431 BASEPROPERTY_VALUEMIN_DOUBLE53,
5432 BASEPROPERTY_VALUESTEP_DOUBLE55,
5433 BASEPROPERTY_VALUE_DOUBLE52,
5434 BASEPROPERTY_ENFORCE_FORMAT102,
5435 BASEPROPERTY_HIDEINACTIVESELECTION110,
5436 BASEPROPERTY_VERTICALALIGN115,
5437 BASEPROPERTY_WRITING_MODE138,
5438 BASEPROPERTY_CONTEXT_WRITING_MODE139,
5439 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR116,
5440 0);
5441 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5442}
5443
5444VCLXNumericField::VCLXNumericField()
5445{
5446}
5447
5448VCLXNumericField::~VCLXNumericField()
5449{
5450}
5451
5452// css::uno::XInterface
5453css::uno::Any VCLXNumericField::queryInterface( const css::uno::Type & rType )
5454{
5455 css::uno::Any aRet = ::cppu::queryInterface( rType,
5456 static_cast< css::awt::XNumericField* >(this) );
5457 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
5458}
5459
5460IMPL_IMPLEMENTATION_ID( VCLXNumericField )css::uno::Sequence< sal_Int8 > VCLXNumericField::getImplementationId
() { return css::uno::Sequence<sal_Int8>(); }
5461
5462// css::lang::XTypeProvider
5463css::uno::Sequence< css::uno::Type > VCLXNumericField::getTypes()
5464{
5465 static const ::cppu::OTypeCollection aTypeList(
5466 cppu::UnoType<css::lang::XTypeProvider>::get(),
5467 cppu::UnoType<css::awt::XNumericField>::get(),
5468 VCLXFormattedSpinField::getTypes()
5469 );
5470 return aTypeList.getTypes();
5471}
5472
5473void VCLXNumericField::setValue( double Value )
5474{
5475 SolarMutexGuard aGuard;
5476
5477 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5478 if ( !pNumericFormatter )
5479 return;
5480
5481 // shift long value using decimal digits
5482 // (e.g., input 105 using 2 digits returns 1,05)
5483 // Thus, to set a value of 1,05, insert 105 and 2 digits
5484 pNumericFormatter->SetValue(
5485 static_cast<long>(ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() )) );
5486
5487 // #107218# Call same listeners like VCL would do after user interaction
5488 VclPtr< Edit > pEdit = GetAs< Edit >();
5489 if ( pEdit )
5490 {
5491 SetSynthesizingVCLEvent( true );
5492 pEdit->SetModifyFlag();
5493 pEdit->Modify();
5494 SetSynthesizingVCLEvent( false );
5495 }
5496}
5497
5498double VCLXNumericField::getValue()
5499{
5500 SolarMutexGuard aGuard;
5501
5502 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5503 return pNumericFormatter
5504 ? ImplCalcDoubleValue( static_cast<double>(pNumericFormatter->GetValue()), pNumericFormatter->GetDecimalDigits() )
5505 : 0;
5506}
5507
5508void VCLXNumericField::setMin( double Value )
5509{
5510 SolarMutexGuard aGuard;
5511
5512 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5513 if ( pNumericFormatter )
5514 pNumericFormatter->SetMin(
5515 static_cast<long>(ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() )) );
5516}
5517
5518double VCLXNumericField::getMin()
5519{
5520 SolarMutexGuard aGuard;
5521
5522 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5523 return pNumericFormatter
5524 ? ImplCalcDoubleValue( static_cast<double>(pNumericFormatter->GetMin()), pNumericFormatter->GetDecimalDigits() )
5525 : 0;
5526}
5527
5528void VCLXNumericField::setMax( double Value )
5529{
5530 SolarMutexGuard aGuard;
5531
5532 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5533 if ( pNumericFormatter )
5534 pNumericFormatter->SetMax(
5535 static_cast<long>(ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() )) );
5536}
5537
5538double VCLXNumericField::getMax()
5539{
5540 SolarMutexGuard aGuard;
5541
5542 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5543 return pNumericFormatter
5544 ? ImplCalcDoubleValue( static_cast<double>(pNumericFormatter->GetMax()), pNumericFormatter->GetDecimalDigits() )
5545 : 0;
5546}
5547
5548void VCLXNumericField::setFirst( double Value )
5549{
5550 SolarMutexGuard aGuard;
5551
5552 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5553 if ( pNumericFormatter )
5554 pNumericFormatter->SetFirst(
5555 static_cast<long>(ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() )) );
5556}
5557
5558double VCLXNumericField::getFirst()
5559{
5560 SolarMutexGuard aGuard;
5561
5562 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5563 return pNumericFormatter
5564 ? ImplCalcDoubleValue( static_cast<double>(pNumericFormatter->GetFirst()), pNumericFormatter->GetDecimalDigits() )
5565 : 0;
5566}
5567
5568void VCLXNumericField::setLast( double Value )
5569{
5570 SolarMutexGuard aGuard;
5571
5572 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5573 if ( pNumericFormatter )
5574 pNumericFormatter->SetLast(
5575 static_cast<long>(ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() )) );
5576}
5577
5578double VCLXNumericField::getLast()
5579{
5580 SolarMutexGuard aGuard;
5581
5582 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5583 return pNumericFormatter
5584 ? ImplCalcDoubleValue( static_cast<double>(pNumericFormatter->GetLast()), pNumericFormatter->GetDecimalDigits() )
5585 : 0;
5586}
5587
5588void VCLXNumericField::setStrictFormat( sal_Bool bStrict )
5589{
5590 VCLXFormattedSpinField::setStrictFormat( bStrict );
5591}
5592
5593sal_Bool VCLXNumericField::isStrictFormat()
5594{
5595 return VCLXFormattedSpinField::isStrictFormat();
5596}
5597
5598void VCLXNumericField::setSpinSize( double Value )
5599{
5600 SolarMutexGuard aGuard;
5601
5602 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5603 if ( pNumericFormatter )
5604 pNumericFormatter->SetSpinSize(
5605 static_cast<long>(ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() )) );
5606}
5607
5608double VCLXNumericField::getSpinSize()
5609{
5610 SolarMutexGuard aGuard;
5611
5612 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5613 return pNumericFormatter
5614 ? ImplCalcDoubleValue( static_cast<double>(pNumericFormatter->GetSpinSize()), pNumericFormatter->GetDecimalDigits() )
5615 : 0;
5616}
5617
5618void VCLXNumericField::setDecimalDigits( sal_Int16 Value )
5619{
5620 SolarMutexGuard aGuard;
5621
5622 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5623 if ( pNumericFormatter )
5624 {
5625 double n = getValue();
5626 pNumericFormatter->SetDecimalDigits( Value );
5627 setValue( n );
5628 }
5629}
5630
5631sal_Int16 VCLXNumericField::getDecimalDigits()
5632{
5633 SolarMutexGuard aGuard;
5634
5635 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5636 return pNumericFormatter ? pNumericFormatter->GetDecimalDigits() : 0;
5637}
5638
5639void VCLXNumericField::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
5640{
5641 SolarMutexGuard aGuard;
5642
5643 if ( !(GetWindow()) )
5644 return;
5645
5646 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
5647
5648 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5649 switch ( nPropType )
5650 {
5651 case BASEPROPERTY_VALUE_DOUBLE52:
5652 {
5653 if ( bVoid )
5654 {
5655 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5656 if (!pNumericFormatter)
5657 return;
5658 pNumericFormatter->EnableEmptyFieldValue( true );
5659 pNumericFormatter->SetEmptyFieldValue();
5660 }
5661 else
5662 {
5663 double d = 0;
5664 if ( Value >>= d )
5665 setValue( d );
5666 }
5667 }
5668 break;
5669 case BASEPROPERTY_VALUEMIN_DOUBLE53:
5670 {
5671 double d = 0;
5672 if ( Value >>= d )
5673 setMin( d );
5674 }
5675 break;
5676 case BASEPROPERTY_VALUEMAX_DOUBLE54:
5677 {
5678 double d = 0;
5679 if ( Value >>= d )
5680 setMax( d );
5681 }
5682 break;
5683 case BASEPROPERTY_VALUESTEP_DOUBLE55:
5684 {
5685 double d = 0;
5686 if ( Value >>= d )
5687 setSpinSize( d );
5688 }
5689 break;
5690 case BASEPROPERTY_DECIMALACCURACY29:
5691 {
5692 sal_Int16 n = sal_Int16();
5693 if ( Value >>= n )
5694 setDecimalDigits( n );
5695 }
5696 break;
5697 case BASEPROPERTY_NUMSHOWTHOUSANDSEP25:
5698 {
5699 bool b = bool();
5700 if ( Value >>= b )
5701 {
5702 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5703 if (!pNumericFormatter)
5704 return;
5705 pNumericFormatter->SetUseThousandSep( b );
5706 }
5707 }
5708 break;
5709 default:
5710 {
5711 VCLXFormattedSpinField::setProperty( PropertyName, Value );
5712 }
5713 }
5714}
5715
5716css::uno::Any VCLXNumericField::getProperty( const OUString& PropertyName )
5717{
5718 SolarMutexGuard aGuard;
5719
5720 css::uno::Any aProp;
5721 FormatterBase* pFormatter = GetFormatter();
5722 if ( pFormatter )
5723 {
5724 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5725 switch ( nPropType )
5726 {
5727 case BASEPROPERTY_VALUE_DOUBLE52:
5728 {
5729 aProp <<= getValue();
5730 }
5731 break;
5732 case BASEPROPERTY_VALUEMIN_DOUBLE53:
5733 {
5734 aProp <<= getMin();
5735 }
5736 break;
5737 case BASEPROPERTY_VALUEMAX_DOUBLE54:
5738 {
5739 aProp <<= getMax();
5740 }
5741 break;
5742 case BASEPROPERTY_VALUESTEP_DOUBLE55:
5743 {
5744 aProp <<= getSpinSize();
5745 }
5746 break;
5747 case BASEPROPERTY_NUMSHOWTHOUSANDSEP25:
5748 {
5749 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5750 aProp <<= pNumericFormatter->IsUseThousandSep();
5751 }
5752 break;
5753 default:
5754 {
5755 aProp = VCLXFormattedSpinField::getProperty( PropertyName );
5756 }
5757 }
5758 }
5759 return aProp;
5760}
5761
5762
5763// ----------------------------------------------------
5764// ----------------------------------------------------
5765
5766void VCLXMetricField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
5767{
5768 PushPropertyIds( rIds,
5769 BASEPROPERTY_ALIGN7,
5770 BASEPROPERTY_BACKGROUNDCOLOR2,
5771 BASEPROPERTY_BORDER6,
5772 BASEPROPERTY_BORDERCOLOR112,
5773 BASEPROPERTY_DECIMALACCURACY29,
5774 BASEPROPERTY_DEFAULTCONTROL19,
5775 BASEPROPERTY_ENABLED44,
5776 BASEPROPERTY_ENABLEVISIBLE145,
5777 BASEPROPERTY_FONTDESCRIPTOR8,
5778 BASEPROPERTY_HELPTEXT73,
5779 BASEPROPERTY_HELPURL58,
5780 BASEPROPERTY_NUMSHOWTHOUSANDSEP25,
5781 BASEPROPERTY_PRINTABLE45,
5782 BASEPROPERTY_READONLY43,
5783 BASEPROPERTY_REPEAT101,
5784 BASEPROPERTY_REPEAT_DELAY95,
5785 BASEPROPERTY_SPIN27,
5786 BASEPROPERTY_STRICTFORMAT28,
5787 BASEPROPERTY_TABSTOP14,
5788 BASEPROPERTY_ENFORCE_FORMAT102,
5789 BASEPROPERTY_HIDEINACTIVESELECTION110,
5790 BASEPROPERTY_UNIT135,
5791 BASEPROPERTY_CUSTOMUNITTEXT136,
5792 BASEPROPERTY_WRITING_MODE138,
5793 BASEPROPERTY_CONTEXT_WRITING_MODE139,
5794 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR116,
5795 0);
5796 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
5797}
5798
5799VCLXMetricField::VCLXMetricField()
5800{
5801}
5802
5803VCLXMetricField::~VCLXMetricField()
5804{
5805}
5806
5807MetricFormatter *VCLXMetricField::GetMetricFormatter()
5808{
5809 MetricFormatter *pFormatter = static_cast<MetricFormatter *>(GetFormatter());
5810 if (!pFormatter)
5811 throw css::uno::RuntimeException();
5812 return pFormatter;
5813}
5814
5815MetricField *VCLXMetricField::GetMetricField()
5816{
5817 VclPtr< MetricField > pField = GetAs< MetricField >();
5818 if (!pField)
5819 throw css::uno::RuntimeException();
5820 return pField;
5821}
5822
5823// css::uno::XInterface
5824css::uno::Any VCLXMetricField::queryInterface( const css::uno::Type & rType )
5825{
5826 css::uno::Any aRet = ::cppu::queryInterface( rType, static_cast< css::awt::XMetricField* >(this) );
5827 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
5828}
5829
5830IMPL_IMPLEMENTATION_ID( VCLXMetricField )css::uno::Sequence< sal_Int8 > VCLXMetricField::getImplementationId
() { return css::uno::Sequence<sal_Int8>(); }
5831
5832// css::lang::XTypeProvider
5833css::uno::Sequence< css::uno::Type > VCLXMetricField::getTypes()
5834{
5835 static const ::cppu::OTypeCollection aTypeList(
5836 cppu::UnoType<css::lang::XTypeProvider>::get(),
5837 cppu::UnoType<css::awt::XMetricField>::get(),
5838 VCLXFormattedSpinField::getTypes()
5839 );
5840 return aTypeList.getTypes();
5841}
5842
5843// FIXME: later ...
5844#define MetricUnitUnoToVcl(a)(static_cast<FieldUnit>(a)) (static_cast<FieldUnit>(a))
5845
5846#define METRIC_MAP_PAIR(method,parent) \
5847 sal_Int64 VCLXMetricField::get##method( sal_Int16 nUnit ) \
5848 { \
5849 SolarMutexGuard aGuard; \
5850 return GetMetric##parent()->Get##method( MetricUnitUnoToVcl( nUnit )(static_cast<FieldUnit>(nUnit)) ); \
5851 } \
5852 void VCLXMetricField::set##method( sal_Int64 nValue, sal_Int16 nUnit ) \
5853 { \
5854 SolarMutexGuard aGuard; \
5855 GetMetric##parent()->Set##method( nValue, MetricUnitUnoToVcl( nUnit )(static_cast<FieldUnit>(nUnit)) ); \
5856 }
5857
5858METRIC_MAP_PAIR(Min, Formatter)
5859METRIC_MAP_PAIR(Max, Formatter)
5860METRIC_MAP_PAIR(First, Field)
5861METRIC_MAP_PAIR(Last, Field)
5862
5863#undef METRIC_MAP_PAIR
5864
5865::sal_Int64 VCLXMetricField::getValue( ::sal_Int16 nUnit )
5866{
5867 SolarMutexGuard aGuard;
5868 return GetMetricFormatter()->GetValue( MetricUnitUnoToVcl( nUnit )(static_cast<FieldUnit>(nUnit)) );
5869}
5870
5871::sal_Int64 VCLXMetricField::getCorrectedValue( ::sal_Int16 nUnit )
5872{
5873 SolarMutexGuard aGuard;
5874 return GetMetricFormatter()->GetCorrectedValue( MetricUnitUnoToVcl( nUnit )(static_cast<FieldUnit>(nUnit)) );
5875}
5876
5877// FIXME: acute cut/paste evilness - move this to the parent Edit class ?
5878void VCLXMetricField::CallListeners()
5879{
5880 // #107218# Call same listeners like VCL would do after user interaction
5881 VclPtr< Edit > pEdit = GetAs< Edit >();
5882 if ( pEdit )
5883 {
5884 SetSynthesizingVCLEvent( true );
5885 pEdit->SetModifyFlag();
5886 pEdit->Modify();
5887 SetSynthesizingVCLEvent( false );
5888 }
5889}
5890
5891void VCLXMetricField::setValue( ::sal_Int64 Value, ::sal_Int16 Unit )
5892{
5893 SolarMutexGuard aGuard;
5894 GetMetricFormatter()->SetValue( Value, MetricUnitUnoToVcl( Unit )(static_cast<FieldUnit>(Unit)) );
5895 CallListeners();
5896}
5897
5898void VCLXMetricField::setUserValue( ::sal_Int64 Value, ::sal_Int16 Unit )
5899{
5900 SolarMutexGuard aGuard;
5901 GetMetricFormatter()->SetUserValue( Value, MetricUnitUnoToVcl( Unit )(static_cast<FieldUnit>(Unit)) );
5902 CallListeners();
5903}
5904
5905void VCLXMetricField::setStrictFormat( sal_Bool bStrict )
5906{
5907 VCLXFormattedSpinField::setStrictFormat( bStrict );
5908}
5909
5910sal_Bool VCLXMetricField::isStrictFormat()
5911{
5912 return VCLXFormattedSpinField::isStrictFormat();
5913}
5914
5915void VCLXMetricField::setSpinSize( sal_Int64 Value )
5916{
5917 SolarMutexGuard aGuard;
5918 GetMetricField()->SetSpinSize( Value );
5919}
5920
5921sal_Int64 VCLXMetricField::getSpinSize()
5922{
5923 SolarMutexGuard aGuard;
5924 return GetMetricField()->GetSpinSize();
5925}
5926
5927void VCLXMetricField::setDecimalDigits( sal_Int16 Value )
5928{
5929 SolarMutexGuard aGuard;
5930 GetMetricFormatter()->SetDecimalDigits( Value );
5931}
5932
5933sal_Int16 VCLXMetricField::getDecimalDigits()
5934{
5935 SolarMutexGuard aGuard;
5936
5937 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5938 return pNumericFormatter ? pNumericFormatter->GetDecimalDigits() : 0;
5939}
5940
5941void VCLXMetricField::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
5942{
5943 SolarMutexGuard aGuard;
5944
5945 if ( !(GetWindow()) )
5946 return;
5947
5948 sal_uInt16 nPropType = GetPropertyId( PropertyName );
5949 switch ( nPropType )
5950 {
5951 case BASEPROPERTY_DECIMALACCURACY29:
5952 {
5953 sal_Int16 n = 0;
5954 if ( Value >>= n )
5955 setDecimalDigits( n );
5956 break;
5957 }
5958 case BASEPROPERTY_NUMSHOWTHOUSANDSEP25:
5959 {
5960 bool b = false;
5961 if ( Value >>= b )
5962 {
5963 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
5964 if (!pNumericFormatter)
5965 return;
5966 pNumericFormatter->SetUseThousandSep( b );
5967 }
5968 }
5969 break;
5970 case BASEPROPERTY_UNIT135:
5971 {
5972 sal_uInt16 nVal = 0;
5973 if ( Value >>= nVal )
5974 GetAs< MetricField >()->SetUnit( static_cast<FieldUnit>(nVal) );
5975 break;
5976 }
5977 case BASEPROPERTY_CUSTOMUNITTEXT136:
5978 {
5979 OUString aStr;
5980 if ( Value >>= aStr )
5981 GetAs< MetricField >()->SetCustomUnitText( aStr );
5982 break;
5983 }
5984 default:
5985 {
5986 VCLXFormattedSpinField::setProperty( PropertyName, Value );
5987 break;
5988 }
5989 }
5990}
5991
5992css::uno::Any VCLXMetricField::getProperty( const OUString& PropertyName )
5993{
5994 SolarMutexGuard aGuard;
5995
5996 css::uno::Any aProp;
5997 FormatterBase* pFormatter = GetFormatter();
5998 if ( pFormatter )
5999 {
6000 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6001 switch ( nPropType )
6002 {
6003 case BASEPROPERTY_NUMSHOWTHOUSANDSEP25:
6004 {
6005 NumericFormatter* pNumericFormatter = static_cast<NumericFormatter*>(GetFormatter());
6006 aProp <<= pNumericFormatter->IsUseThousandSep();
6007 break;
6008 }
6009 case BASEPROPERTY_UNIT135:
6010 aProp <<= static_cast<sal_uInt16>(GetAs< MetricField >()->GetUnit());
6011 break;
6012 case BASEPROPERTY_CUSTOMUNITTEXT136:
6013 aProp <<= GetAs< MetricField >()->GetCustomUnitText();
6014 break;
6015 default:
6016 {
6017 aProp = VCLXFormattedSpinField::getProperty( PropertyName );
6018 break;
6019 }
6020 }
6021 }
6022 return aProp;
6023}
6024
6025void VCLXPatternField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
6026{
6027 PushPropertyIds( rIds,
6028 BASEPROPERTY_ALIGN7,
6029 BASEPROPERTY_BACKGROUNDCOLOR2,
6030 BASEPROPERTY_BORDER6,
6031 BASEPROPERTY_BORDERCOLOR112,
6032 BASEPROPERTY_DEFAULTCONTROL19,
6033 BASEPROPERTY_EDITMASK40,
6034 BASEPROPERTY_ENABLED44,
6035 BASEPROPERTY_ENABLEVISIBLE145,
6036 BASEPROPERTY_FONTDESCRIPTOR8,
6037 BASEPROPERTY_HELPTEXT73,
6038 BASEPROPERTY_HELPURL58,
6039 BASEPROPERTY_LITERALMASK41,
6040 BASEPROPERTY_MAXTEXTLEN47,
6041 BASEPROPERTY_PRINTABLE45,
6042 BASEPROPERTY_READONLY43,
6043 BASEPROPERTY_STRICTFORMAT28,
6044 BASEPROPERTY_TABSTOP14,
6045 BASEPROPERTY_TEXT1,
6046 BASEPROPERTY_HIDEINACTIVESELECTION110,
6047 BASEPROPERTY_VERTICALALIGN115,
6048 BASEPROPERTY_WRITING_MODE138,
6049 BASEPROPERTY_CONTEXT_WRITING_MODE139,
6050 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR116,
6051 0);
6052 VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
6053}
6054
6055VCLXPatternField::VCLXPatternField()
6056{
6057}
6058
6059VCLXPatternField::~VCLXPatternField()
6060{
6061}
6062
6063// css::uno::XInterface
6064css::uno::Any VCLXPatternField::queryInterface( const css::uno::Type & rType )
6065{
6066 css::uno::Any aRet = ::cppu::queryInterface( rType,
6067 static_cast< css::awt::XPatternField* >(this) );
6068 return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
6069}
6070
6071IMPL_IMPLEMENTATION_ID( VCLXPatternField )css::uno::Sequence< sal_Int8 > VCLXPatternField::getImplementationId
() { return css::uno::Sequence<sal_Int8>(); }
6072
6073// css::lang::XTypeProvider
6074css::uno::Sequence< css::uno::Type > VCLXPatternField::getTypes()
6075{
6076 static const ::cppu::OTypeCollection aTypeList(
6077 cppu::UnoType<css::lang::XTypeProvider>::get(),
6078 cppu::UnoType<css::awt::XPatternField>::get(),
6079 VCLXFormattedSpinField::getTypes()
6080 );
6081 return aTypeList.getTypes();
6082}
6083
6084void VCLXPatternField::setMasks( const OUString& EditMask, const OUString& LiteralMask )
6085{
6086 SolarMutexGuard aGuard;
6087
6088 VclPtr< PatternField > pPatternField = GetAs< PatternField >();
6089 if ( pPatternField )
6090 {
6091 pPatternField->SetMask( OUStringToOString(EditMask, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11))), LiteralMask );
6092 }
6093}
6094
6095void VCLXPatternField::getMasks( OUString& EditMask, OUString& LiteralMask )
6096{
6097 SolarMutexGuard aGuard;
6098
6099 VclPtr< PatternField > pPatternField = GetAs< PatternField >();
6100 if ( pPatternField )
6101 {
6102 EditMask = OStringToOUString(pPatternField->GetEditMask(), RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)));
6103 LiteralMask = pPatternField->GetLiteralMask();
6104 }
6105}
6106
6107void VCLXPatternField::setString( const OUString& Str )
6108{
6109 SolarMutexGuard aGuard;
6110 VclPtr< PatternField > pPatternField = GetAs< PatternField >();
6111 if ( pPatternField )
6112 pPatternField->SetString( Str );
6113}
6114
6115OUString VCLXPatternField::getString()
6116{
6117 SolarMutexGuard aGuard;
6118
6119 OUString aString;
6120 VclPtr< PatternField > pPatternField = GetAs< PatternField >();
6121 if ( pPatternField )
6122 aString = pPatternField->GetString();
6123 return aString;
6124}
6125
6126void VCLXPatternField::setStrictFormat( sal_Bool bStrict )
6127{
6128 VCLXFormattedSpinField::setStrictFormat( bStrict );
6129}
6130
6131sal_Bool VCLXPatternField::isStrictFormat()
6132{
6133 return VCLXFormattedSpinField::isStrictFormat();
6134}
6135
6136void VCLXPatternField::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
6137{
6138 SolarMutexGuard aGuard;
6139
6140 if ( !(GetWindow()) )
6141 return;
6142
6143 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6144 switch ( nPropType )
6145 {
6146 case BASEPROPERTY_EDITMASK40:
6147 case BASEPROPERTY_LITERALMASK41:
6148 {
6149 OUString aString;
6150 if ( Value >>= aString )
6151 {
6152 OUString aEditMask, aLiteralMask;
6153 getMasks( aEditMask, aLiteralMask );
6154 if ( nPropType == BASEPROPERTY_EDITMASK40 )
6155 aEditMask = aString;
6156 else
6157 aLiteralMask = aString;
6158 setMasks( aEditMask, aLiteralMask );
6159 }
6160 }
6161 break;
6162 default:
6163 {
6164 VCLXFormattedSpinField::setProperty( PropertyName, Value );
6165 }
6166 }
6167}
6168
6169css::uno::Any VCLXPatternField::getProperty( const OUString& PropertyName )
6170{
6171 SolarMutexGuard aGuard;
6172
6173 css::uno::Any aProp;
6174 if ( GetWindow() )
6175 {
6176 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6177 switch ( nPropType )
6178 {
6179 case BASEPROPERTY_EDITMASK40:
6180 case BASEPROPERTY_LITERALMASK41:
6181 {
6182 OUString aEditMask, aLiteralMask;
6183 getMasks( aEditMask, aLiteralMask );
6184 if ( nPropType == BASEPROPERTY_EDITMASK40 )
6185 aProp <<= aEditMask;
6186 else
6187 aProp <<= aLiteralMask;
6188 }
6189 break;
6190 default:
6191 {
6192 aProp = VCLXFormattedSpinField::getProperty( PropertyName );
6193 }
6194 }
6195 }
6196 return aProp;
6197}
6198
6199
6200
6201VCLXToolBox::VCLXToolBox()
6202{
6203}
6204
6205VCLXToolBox::~VCLXToolBox()
6206{
6207}
6208
6209css::uno::Reference< css::accessibility::XAccessibleContext > VCLXToolBox::CreateAccessibleContext()
6210{
6211 return getAccessibleFactory().createAccessibleContext( this );
6212}
6213
6214VCLXHeaderBar::VCLXHeaderBar()
6215{
6216}
6217
6218VCLXHeaderBar::~VCLXHeaderBar()
6219{
6220}
6221
6222css::uno::Reference< css::accessibility::XAccessibleContext > VCLXHeaderBar::CreateAccessibleContext()
6223{
6224 return getAccessibleFactory().createAccessibleContext( this );
6225}
6226
6227
6228VCLXFrame::VCLXFrame()
6229{
6230}
6231
6232void VCLXFrame::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
6233{
6234 PushPropertyIds( rIds,
6235 BASEPROPERTY_BACKGROUNDCOLOR2,
6236 BASEPROPERTY_DEFAULTCONTROL19,
6237 BASEPROPERTY_ENABLED44,
6238 BASEPROPERTY_ENABLEVISIBLE145,
6239 BASEPROPERTY_FONTDESCRIPTOR8,
6240 BASEPROPERTY_GRAPHIC117,
6241 BASEPROPERTY_HELPTEXT73,
6242 BASEPROPERTY_HELPURL58,
6243 BASEPROPERTY_PRINTABLE45,
6244 BASEPROPERTY_LABEL20,
6245 0);
6246 VCLXContainer::ImplGetPropertyIds( rIds );
6247}
6248
6249VCLXFrame::~VCLXFrame()
6250{
6251}
6252
6253IMPL_IMPLEMENTATION_ID( VCLXFrame )css::uno::Sequence< sal_Int8 > VCLXFrame::getImplementationId
() { return css::uno::Sequence<sal_Int8>(); }
6254
6255// css::awt::XView
6256void SAL_CALL VCLXFrame::draw( sal_Int32 nX, sal_Int32 nY )
6257{
6258 SolarMutexGuard aGuard;
6259 VclPtr< vcl::Window > pWindow = GetWindow();
6260
6261 if ( pWindow )
6262 {
6263 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
6264 if ( !pDev )
6265 pDev = pWindow->GetParent();
6266
6267 Point aPos = pDev->PixelToLogic( Point( nX, nY ) );
6268 pWindow->Draw( pDev, aPos, DrawFlags::NoControls );
6269 }
6270}
6271
6272void SAL_CALL VCLXFrame::setProperty(
6273 const OUString& PropertyName,
6274 const css::uno::Any& Value )
6275{
6276 SolarMutexGuard aGuard;
6277
6278 VCLXContainer::setProperty( PropertyName, Value );
6279}
6280
6281void VCLXFrame::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
6282{
6283 css::uno::Reference< css::awt::XWindow > xKeepAlive( this );
6284 VCLXContainer::ProcessWindowEvent( rVclWindowEvent );
6285}
6286
6287VCLXProgressBar::VCLXProgressBar()
6288 :m_nValue(0)
6289 ,m_nValueMin(0)
6290 ,m_nValueMax(100)
6291{
6292}
6293
6294VCLXProgressBar::~VCLXProgressBar()
6295{
6296}
6297
6298void VCLXProgressBar::ImplUpdateValue()
6299{
6300 VclPtr< ProgressBar > pProgressBar = GetAs< ProgressBar >();
6301 if ( !pProgressBar )
6302 return;
6303
6304 sal_Int32 nVal;
6305 sal_Int32 nValMin;
6306 sal_Int32 nValMax;
6307
6308 // check min and max
6309 if (m_nValueMin < m_nValueMax)
6310 {
6311 nValMin = m_nValueMin;
6312 nValMax = m_nValueMax;
6313 }
6314 else
6315 {
6316 nValMin = m_nValueMax;
6317 nValMax = m_nValueMin;
6318 }
6319
6320 // check value
6321 if (m_nValue < nValMin)
6322 {
6323 nVal = nValMin;
6324 }
6325 else if (m_nValue > nValMax)
6326 {
6327 nVal = nValMax;
6328 }
6329 else
6330 {
6331 nVal = m_nValue;
6332 }
6333
6334 // calculate percent
6335 sal_Int32 nPercent;
6336 if (nValMin != nValMax)
6337 {
6338 nPercent = 100 * (nVal - nValMin) / (nValMax - nValMin);
6339 }
6340 else
6341 {
6342 nPercent = 0;
6343 }
6344
6345 // set progressbar value
6346 pProgressBar->SetValue( static_cast<sal_uInt16>(nPercent) );
6347}
6348
6349// css::uno::XInterface
6350css::uno::Any VCLXProgressBar::queryInterface( const css::uno::Type & rType )
6351{
6352 css::uno::Any aRet = ::cppu::queryInterface( rType,
6353 static_cast< css::awt::XProgressBar* >(this),
6354 static_cast< css::lang::XTypeProvider* >(this) );
6355 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
6356}
6357
6358IMPL_IMPLEMENTATION_ID( VCLXProgressBar )css::uno::Sequence< sal_Int8 > VCLXProgressBar::getImplementationId
() { return css::uno::Sequence<sal_Int8>(); }
6359
6360// css::lang::XTypeProvider
6361css::uno::Sequence< css::uno::Type > VCLXProgressBar::getTypes()
6362{
6363 static const ::cppu::OTypeCollection aTypeList(
6364 cppu::UnoType<css::lang::XTypeProvider>::get(),
6365 cppu::UnoType<css::awt::XProgressBar>::get(),
6366 VCLXWindow::getTypes()
6367 );
6368 return aTypeList.getTypes();
6369}
6370
6371// css::awt::XProgressBar
6372void VCLXProgressBar::setForegroundColor( sal_Int32 nColor )
6373{
6374 SolarMutexGuard aGuard;
6375
6376 VclPtr<vcl::Window> pWindow = GetWindow();
6377 if ( pWindow )
6378 {
6379 pWindow->SetControlForeground( Color(nColor) );
6380 }
6381}
6382
6383void VCLXProgressBar::setBackgroundColor( sal_Int32 nColor )
6384{
6385 SolarMutexGuard aGuard;
6386
6387 VclPtr<vcl::Window> pWindow = GetWindow();
6388 if ( pWindow )
6389 {
6390 Color aColor( nColor );
6391 pWindow->SetBackground( aColor );
6392 pWindow->SetControlBackground( aColor );
6393 pWindow->Invalidate();
6394 }
6395}
6396
6397void VCLXProgressBar::setValue( sal_Int32 nValue )
6398{
6399 SolarMutexGuard aGuard;
6400
6401 m_nValue = nValue;
6402 ImplUpdateValue();
6403}
6404
6405void VCLXProgressBar::setRange( sal_Int32 nMin, sal_Int32 nMax )
6406{
6407 SolarMutexGuard aGuard;
6408
6409 if ( nMin < nMax )
6410 {
6411 // take correct min and max
6412 m_nValueMin = nMin;
6413 m_nValueMax = nMax;
6414 }
6415 else
6416 {
6417 // change min and max
6418 m_nValueMin = nMax;
6419 m_nValueMax = nMin;
6420 }
6421
6422 ImplUpdateValue();
6423}
6424
6425sal_Int32 VCLXProgressBar::getValue()
6426{
6427 SolarMutexGuard aGuard;
6428
6429 return m_nValue;
6430}
6431
6432// css::awt::VclWindowPeer
6433void VCLXProgressBar::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
6434{
6435 SolarMutexGuard aGuard;
6436
6437 VclPtr< ProgressBar > pProgressBar = GetAs< ProgressBar >();
6438 if ( !pProgressBar )
6439 return;
6440
6441 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6442 switch ( nPropType )
6443 {
6444 case BASEPROPERTY_PROGRESSVALUE74:
6445 {
6446 if ( Value >>= m_nValue )
6447 ImplUpdateValue();
6448 }
6449 break;
6450 case BASEPROPERTY_PROGRESSVALUE_MIN75:
6451 {
6452 if ( Value >>= m_nValueMin )
6453 ImplUpdateValue();
6454 }
6455 break;
6456 case BASEPROPERTY_PROGRESSVALUE_MAX76:
6457 {
6458 if ( Value >>= m_nValueMax )
6459 ImplUpdateValue();
6460 }
6461 break;
6462 case BASEPROPERTY_FILLCOLOR3:
6463 {
6464 VclPtr<vcl::Window> pWindow = GetWindow();
6465 if ( pWindow )
6466 {
6467 bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID;
6468
6469 if ( bVoid )
6470 {
6471 pWindow->SetControlForeground();
6472 }
6473 else
6474 {
6475 sal_Int32 nColor = 0;
6476 if ( Value >>= nColor )
6477 {
6478 Color aColor( nColor );
6479 pWindow->SetControlForeground( aColor );
6480 }
6481 }
6482 }
6483 }
6484 break;
6485 default:
6486 VCLXWindow::setProperty( PropertyName, Value );
6487 break;
6488 }
6489}
6490
6491css::uno::Any VCLXProgressBar::getProperty( const OUString& PropertyName )
6492{
6493 SolarMutexGuard aGuard;
6494
6495 css::uno::Any aProp;
6496 VclPtr< ProgressBar > pProgressBar = GetAs< ProgressBar >();
6497 if ( pProgressBar )
6498 {
6499 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6500 switch ( nPropType )
6501 {
6502 case BASEPROPERTY_PROGRESSVALUE74:
6503 {
6504 aProp <<= m_nValue;
6505 }
6506 break;
6507 case BASEPROPERTY_PROGRESSVALUE_MIN75:
6508 {
6509 aProp <<= m_nValueMin;
6510 }
6511 break;
6512 case BASEPROPERTY_PROGRESSVALUE_MAX76:
6513 {
6514 aProp <<= m_nValueMax;
6515 }
6516 break;
6517 default:
6518 aProp = VCLXWindow::getProperty( PropertyName );
6519 break;
6520 }
6521 }
6522 return aProp;
6523}
6524
6525void VCLXProgressBar::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
6526{
6527 PushPropertyIds( rIds,
6528 BASEPROPERTY_PROGRESSVALUE74,
6529 BASEPROPERTY_PROGRESSVALUE_MIN75,
6530 BASEPROPERTY_PROGRESSVALUE_MAX76,
6531 BASEPROPERTY_FILLCOLOR3,
6532 0);
6533 VCLXWindow::ImplGetPropertyIds( rIds, true );
6534}
6535
6536VCLXFileControl::VCLXFileControl() : maTextListeners( *this )
6537{
6538}
6539
6540VCLXFileControl::~VCLXFileControl()
6541{
6542 VclPtr< FileControl > pControl = GetAs< FileControl >();
6543 if ( pControl )
6544 pControl->GetEdit().SetModifyHdl( Link<Edit&,void>() );
6545}
6546
6547css::uno::Any VCLXFileControl::queryInterface( const css::uno::Type & rType )
6548{
6549 css::uno::Any aRet = ::cppu::queryInterface( rType,
6550 static_cast< css::awt::XTextComponent* >(this),
6551 static_cast< css::awt::XTextLayoutConstrains* >(this),
6552 static_cast< css::lang::XTypeProvider* >(this) );
6553 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
6554}
6555
6556IMPL_IMPLEMENTATION_ID( VCLXFileControl )css::uno::Sequence< sal_Int8 > VCLXFileControl::getImplementationId
() { return css::uno::Sequence<sal_Int8>(); }
6557
6558// css::lang::XTypeProvider
6559css::uno::Sequence< css::uno::Type > VCLXFileControl::getTypes()
6560{
6561 static const ::cppu::OTypeCollection aTypeList(
6562 cppu::UnoType<css::lang::XTypeProvider>::get(),
6563 cppu::UnoType<css::awt::XTextComponent>::get(),
6564 cppu::UnoType<css::awt::XTextLayoutConstrains>::get(),
6565 VCLXWindow::getTypes()
6566 );
6567 return aTypeList.getTypes();
6568}
6569
6570namespace
6571{
6572 void lcl_setWinBits( vcl::Window* _pWindow, WinBits _nBits, bool _bSet )
6573 {
6574 WinBits nStyle = _pWindow->GetStyle();
6575 if ( _bSet )
6576 nStyle |= _nBits;
6577 else
6578 nStyle &= ~_nBits;
6579 _pWindow->SetStyle( nStyle );
6580 }
6581}
6582
6583void SAL_CALL VCLXFileControl::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
6584{
6585 SolarMutexGuard aGuard;
6586
6587 VclPtr< FileControl > pControl = GetAs< FileControl >();
6588 if ( !pControl )
6589 return;
6590
6591 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6592 switch ( nPropType )
6593 {
6594 case BASEPROPERTY_HIDEINACTIVESELECTION110:
6595 {
6596 bool bValue(false);
6597 OSL_VERIFY( Value >>= bValue )do { if (!(Value >>= bValue)) do { if (true && (
!(0))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "6597" ": "), "OSL_ASSERT: %s", "0"); } } while (false);
} while (0)
;
6598
6599 lcl_setWinBits( pControl, WB_NOHIDESELECTION, !bValue );
6600 lcl_setWinBits( &pControl->GetEdit(), WB_NOHIDESELECTION, !bValue );
6601 }
6602 break;
6603
6604 default:
6605 VCLXWindow::setProperty( PropertyName, Value );
6606 break;
6607 }
6608}
6609
6610void VCLXFileControl::SetWindow( const VclPtr< vcl::Window > &pWindow )
6611{
6612 VclPtr< FileControl > pPrevFileControl = GetAsDynamic< FileControl >();
6613 if ( pPrevFileControl )
6614 pPrevFileControl->SetEditModifyHdl( Link<Edit&,void>() );
6615
6616 FileControl* pNewFileControl = dynamic_cast<FileControl*>( pWindow.get() );
6617 if ( pNewFileControl )
6618 pNewFileControl->SetEditModifyHdl( LINK( this, VCLXFileControl, ModifyHdl )::tools::detail::makeLink( ::tools::detail::castTo<VCLXFileControl
*>(this), &VCLXFileControl::LinkStubModifyHdl)
);
6619
6620 VCLXWindow::SetWindow( pWindow );
6621}
6622
6623void VCLXFileControl::addTextListener( const css::uno::Reference< css::awt::XTextListener > & l )
6624{
6625 maTextListeners.addInterface( l );
6626}
6627
6628void VCLXFileControl::removeTextListener( const css::uno::Reference< css::awt::XTextListener > & l )
6629{
6630 maTextListeners.removeInterface( l );
6631}
6632
6633void VCLXFileControl::setText( const OUString& aText )
6634{
6635 SolarMutexGuard aGuard;
6636
6637 VclPtr<vcl::Window> pWindow = GetWindow();
6638 if ( pWindow )
6639 {
6640 pWindow->SetText( aText );
6641
6642 // also in Java a textChanged is triggered, not in VCL.
6643 // css::awt::Toolkit should be JAVA-compliant...
6644 ModifyHdl();
6645 }
6646}
6647
6648void VCLXFileControl::insertText( const css::awt::Selection& rSel, const OUString& aText )
6649{
6650 SolarMutexGuard aGuard;
6651
6652 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
6653 if ( pFileControl )
6654 {
6655 pFileControl->GetEdit().SetSelection( Selection( rSel.Min, rSel.Max ) );
6656 pFileControl->GetEdit().ReplaceSelected( aText );
6657 }
6658}
6659
6660OUString VCLXFileControl::getText()
6661{
6662 SolarMutexGuard aGuard;
6663
6664 OUString aText;
6665 VclPtr<vcl::Window> pWindow = GetWindow();
6666 if ( pWindow )
6667 aText = pWindow->GetText();
6668 return aText;
6669}
6670
6671OUString VCLXFileControl::getSelectedText()
6672{
6673 SolarMutexGuard aGuard;
6674
6675 OUString aText;
6676 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
6677 if ( pFileControl)
6678 aText = pFileControl->GetEdit().GetSelected();
6679 return aText;
6680
6681}
6682
6683void VCLXFileControl::setSelection( const css::awt::Selection& aSelection )
6684{
6685 SolarMutexGuard aGuard;
6686
6687 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
6688 if ( pFileControl )
6689 pFileControl->GetEdit().SetSelection( Selection( aSelection.Min, aSelection.Max ) );
6690}
6691
6692css::awt::Selection VCLXFileControl::getSelection()
6693{
6694 SolarMutexGuard aGuard;
6695
6696 css::awt::Selection aSel;
6697 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
6698 if ( pFileControl )
6699 {
6700 aSel.Min = pFileControl->GetEdit().GetSelection().Min();
6701 aSel.Max = pFileControl->GetEdit().GetSelection().Max();
6702 }
6703 return aSel;
6704}
6705
6706sal_Bool VCLXFileControl::isEditable()
6707{
6708 SolarMutexGuard aGuard;
6709
6710 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
6711 return pFileControl && !pFileControl->GetEdit().IsReadOnly() && pFileControl->GetEdit().IsEnabled();
6712}
6713
6714void VCLXFileControl::setEditable( sal_Bool bEditable )
6715{
6716 SolarMutexGuard aGuard;
6717
6718 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
6719 if ( pFileControl )
6720 pFileControl->GetEdit().SetReadOnly( !bEditable );
6721}
6722
6723void VCLXFileControl::setMaxTextLen( sal_Int16 nLen )
6724{
6725 SolarMutexGuard aGuard;
6726
6727 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
6728 if ( pFileControl )
6729 pFileControl->GetEdit().SetMaxTextLen( nLen );
6730}
6731
6732sal_Int16 VCLXFileControl::getMaxTextLen()
6733{
6734 SolarMutexGuard aGuard;
6735
6736 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
6737 return pFileControl ? pFileControl->GetEdit().GetMaxTextLen() : 0;
6738}
6739
6740
6741IMPL_LINK_NOARG(VCLXFileControl, ModifyHdl, Edit&, void)void VCLXFileControl::LinkStubModifyHdl(void * instance, Edit
& data) { return static_cast<VCLXFileControl *>(instance
)->ModifyHdl(data); } void VCLXFileControl::ModifyHdl(__attribute__
((unused)) Edit&)
6742{
6743 ModifyHdl();
6744}
6745
6746void VCLXFileControl::ModifyHdl()
6747{
6748 css::awt::TextEvent aEvent;
6749 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
6750 maTextListeners.textChanged( aEvent );
6751}
6752
6753css::awt::Size VCLXFileControl::getMinimumSize()
6754{
6755 SolarMutexGuard aGuard;
6756
6757 css::awt::Size aSz;
6758 VclPtr< FileControl > pControl = GetAs< FileControl >();
6759 if ( pControl )
6760 {
6761 Size aTmpSize = pControl->GetEdit().CalcMinimumSize();
6762 aTmpSize.AdjustWidth(pControl->GetButton().CalcMinimumSize().Width() );
6763 aSz = AWTSize(pControl->CalcWindowSize( aTmpSize ));
6764 }
6765 return aSz;
6766}
6767
6768css::awt::Size VCLXFileControl::getPreferredSize()
6769{
6770 css::awt::Size aSz = getMinimumSize();
6771 aSz.Height += 4;
6772 return aSz;
6773}
6774
6775css::awt::Size VCLXFileControl::calcAdjustedSize( const css::awt::Size& rNewSize )
6776{
6777 SolarMutexGuard aGuard;
6778
6779 css::awt::Size aSz =rNewSize;
6780 VclPtr< FileControl > pControl = GetAs< FileControl >();
6781 if ( pControl )
6782 {
6783 css::awt::Size aMinSz = getMinimumSize();
6784 if ( aSz.Height != aMinSz.Height )
6785 aSz.Height = aMinSz.Height;
6786 }
6787 return aSz;
6788}
6789
6790css::awt::Size VCLXFileControl::getMinimumSize( sal_Int16 nCols, sal_Int16 )
6791{
6792 SolarMutexGuard aGuard;
6793
6794 css::awt::Size aSz;
6795 VclPtr< FileControl > pControl = GetAs< FileControl >();
6796 if ( pControl )
6797 {
6798 aSz = AWTSize(pControl->GetEdit().CalcSize( nCols ));
6799 aSz.Width += pControl->GetButton().CalcMinimumSize().Width();
6800 }
6801 return aSz;
6802}
6803
6804void VCLXFileControl::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines )
6805{
6806 SolarMutexGuard aGuard;
6807
6808 nCols = 0;
6809 nLines = 1;
6810 VclPtr< FileControl > pControl = GetAs< FileControl >();
6811 if ( pControl )
6812 nCols = pControl->GetEdit().GetMaxVisChars();
6813}
6814
6815void VCLXFileControl::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
6816{
6817 PushPropertyIds( rIds,
6818 // FIXME: elide duplication ?
6819 BASEPROPERTY_HIDEINACTIVESELECTION110,
6820 0);
6821 VCLXWindow::ImplGetPropertyIds( rIds, true );
6822}
6823
6824SVTXFormattedField::SVTXFormattedField()
6825 :bIsStandardSupplier(true)
6826 ,nKeyToSetDelayed(-1)
6827{
6828}
6829
6830SVTXFormattedField::~SVTXFormattedField()
6831{
6832}
6833
6834void SVTXFormattedField::SetWindow( const VclPtr< vcl::Window > &_pWindow )
6835{
6836 VCLXSpinField::SetWindow(_pWindow);
6837 if (GetAs< FormattedField >())
6838 GetAs< FormattedField >()->GetFormatter().SetAutoColor(true);
6839}
6840
6841void SVTXFormattedField::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
6842{
6843 SolarMutexGuard aGuard;
6844
6845 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6846 if ( pField )
6847 {
6848 Formatter& rFormatter = pField->GetFormatter();
6849 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6850 switch (nPropType)
6851 {
6852 case BASEPROPERTY_ENFORCE_FORMAT102:
6853 {
6854 bool bEnable( true );
6855 if ( Value >>= bEnable )
6856 rFormatter.EnableNotANumber( !bEnable );
6857 }
6858 break;
6859
6860 case BASEPROPERTY_EFFECTIVE_MIN66:
6861 case BASEPROPERTY_VALUEMIN_DOUBLE53:
6862 SetMinValue(Value);
6863 break;
6864
6865 case BASEPROPERTY_EFFECTIVE_MAX67:
6866 case BASEPROPERTY_VALUEMAX_DOUBLE54:
6867 SetMaxValue(Value);
6868 break;
6869
6870 case BASEPROPERTY_EFFECTIVE_DEFAULT65:
6871 SetDefaultValue(Value);
6872 break;
6873
6874 case BASEPROPERTY_TREATASNUMBER64:
6875 {
6876 bool b;
6877 if ( Value >>= b )
6878 SetTreatAsNumber(b);
6879 }
6880 break;
6881
6882 case BASEPROPERTY_FORMATSSUPPLIER62:
6883 if (!Value.hasValue())
6884 setFormatsSupplier(css::uno::Reference< css::util::XNumberFormatsSupplier > (nullptr));
6885 else
6886 {
6887 css::uno::Reference< css::util::XNumberFormatsSupplier > xNFS;
6888 if ( Value >>= xNFS )
6889 setFormatsSupplier(xNFS);
6890 }
6891 break;
6892 case BASEPROPERTY_FORMATKEY61:
6893 if (!Value.hasValue())
6894 setFormatKey(0);
6895 else
6896 {
6897 sal_Int32 n = 0;
6898 if ( Value >>= n )
6899 setFormatKey(n);
6900 }
6901 break;
6902
6903 case BASEPROPERTY_EFFECTIVE_VALUE63:
6904 case BASEPROPERTY_VALUE_DOUBLE52:
6905 {
6906 const css::uno::TypeClass rTC = Value.getValueType().getTypeClass();
6907 if (rTC != css::uno::TypeClass_STRING)
6908 // no string
6909 if (rTC != css::uno::TypeClass_DOUBLE)
6910 // no double
6911 if (Value.hasValue())
6912 { // but a value
6913 // try if it is something convertible
6914 sal_Int32 nValue = 0;
6915 if (!(Value >>= nValue))
6916 throw css::lang::IllegalArgumentException();
6917 SetValue(css::uno::makeAny(static_cast<double>(nValue)));
6918 break;
6919 }
6920
6921 SetValue(Value);
6922 }
6923 break;
6924 case BASEPROPERTY_VALUESTEP_DOUBLE55:
6925 {
6926 double d = 0.0;
6927 if ( Value >>= d )
6928 rFormatter.SetSpinSize( d );
6929 else
6930 {
6931 sal_Int32 n = 0;
6932 if ( Value >>= n )
6933 rFormatter.SetSpinSize( n );
6934 }
6935 }
6936 break;
6937 case BASEPROPERTY_DECIMALACCURACY29:
6938 {
6939 sal_Int32 n = 0;
6940 if ( Value >>= n )
6941 rFormatter.SetDecimalDigits( static_cast<sal_uInt16>(n) );
6942 }
6943 break;
6944 case BASEPROPERTY_NUMSHOWTHOUSANDSEP25:
6945 {
6946 bool b;
6947 if ( Value >>= b )
6948 rFormatter.SetThousandsSep( b );
6949 }
6950 break;
6951
6952 default:
6953 VCLXSpinField::setProperty( PropertyName, Value );
6954 }
6955
6956 if (BASEPROPERTY_TEXTCOLOR4 == nPropType)
6957 { // after setting a new text color, think again about the AutoColor flag of the control
6958 // 17.05.2001 - 86859 - frank.schoenheit@germany.sun.com
6959 rFormatter.SetAutoColor(!Value.hasValue());
6960 }
6961 }
6962 else
6963 VCLXSpinField::setProperty( PropertyName, Value );
6964}
6965
6966css::uno::Any SVTXFormattedField::getProperty( const OUString& PropertyName )
6967{
6968 SolarMutexGuard aGuard;
6969
6970 css::uno::Any aReturn;
6971
6972 VclPtr<FormattedField> pField = GetAs< FormattedField >();
6973 if ( pField )
6974 {
6975 Formatter& rFormatter = pField->GetFormatter();
6976 sal_uInt16 nPropType = GetPropertyId( PropertyName );
6977 switch (nPropType)
6978 {
6979 case BASEPROPERTY_EFFECTIVE_MIN66:
6980 case BASEPROPERTY_VALUEMIN_DOUBLE53:
6981 aReturn = GetMinValue();
6982 break;
6983
6984 case BASEPROPERTY_EFFECTIVE_MAX67:
6985 case BASEPROPERTY_VALUEMAX_DOUBLE54:
6986 aReturn = GetMaxValue();
6987 break;
6988
6989 case BASEPROPERTY_EFFECTIVE_DEFAULT65:
6990 aReturn = GetDefaultValue();
6991 break;
6992
6993 case BASEPROPERTY_TREATASNUMBER64:
6994 aReturn <<= GetTreatAsNumber();
6995 break;
6996
6997 case BASEPROPERTY_EFFECTIVE_VALUE63:
6998 case BASEPROPERTY_VALUE_DOUBLE52:
6999 aReturn = GetValue();
7000 break;
7001
7002 case BASEPROPERTY_VALUESTEP_DOUBLE55:
7003 aReturn <<= rFormatter.GetSpinSize();
7004 break;
7005
7006 case BASEPROPERTY_DECIMALACCURACY29:
7007 aReturn <<= rFormatter.GetDecimalDigits();
7008 break;
7009
7010 case BASEPROPERTY_FORMATSSUPPLIER62:
7011 {
7012 if (!bIsStandardSupplier)
7013 { // ansonsten void
7014 css::uno::Reference< css::util::XNumberFormatsSupplier > xSupplier = m_xCurrentSupplier.get();
7015 aReturn <<= xSupplier;
7016 }
7017 }
7018 break;
7019
7020 case BASEPROPERTY_FORMATKEY61:
7021 {
7022 if (!bIsStandardSupplier)
7023 aReturn <<= getFormatKey();
7024 }
7025 break;
7026
7027 default:
7028 aReturn = VCLXSpinField::getProperty(PropertyName);
7029 }
7030 }
7031 return aReturn;
7032}
7033
7034css::uno::Any SVTXFormattedField::convertEffectiveValue(const css::uno::Any& rValue)
7035{
7036 css::uno::Any aReturn;
7037
7038 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7039 if (!pField)
7040 return aReturn;
7041
7042 Formatter& rFieldFormatter = pField->GetFormatter();
7043 switch (rValue.getValueType().getTypeClass())
7044 {
7045 case css::uno::TypeClass_DOUBLE:
7046 if (rFieldFormatter.TreatingAsNumber())
7047 {
7048 double d = 0.0;
7049 rValue >>= d;
7050 aReturn <<= d;
7051 }
7052 else
7053 {
7054 SvNumberFormatter* pFormatter = rFieldFormatter.GetFormatter();
7055 if (!pFormatter)
7056 pFormatter = rFieldFormatter.StandardFormatter();
7057 // should never fail
7058
7059 const Color* pDum;
7060 double d = 0.0;
7061 rValue >>= d;
7062 OUString sConverted;
7063 pFormatter->GetOutputString(d, 0, sConverted, &pDum);
7064 aReturn <<= sConverted;
7065 }
7066 break;
7067 case css::uno::TypeClass_STRING:
7068 {
7069 OUString aStr;
7070 rValue >>= aStr;
7071 if (rFieldFormatter.TreatingAsNumber())
7072 {
7073 SvNumberFormatter* pFormatter = rFieldFormatter.GetFormatter();
7074 if (!pFormatter)
7075 pFormatter = rFieldFormatter.StandardFormatter();
7076
7077 double dVal;
7078 sal_uInt32 nTestFormat(0);
7079 if (!pFormatter->IsNumberFormat(aStr, nTestFormat, dVal))
7080 aReturn.clear();
7081 aReturn <<= dVal;
7082 }
7083 else
7084 aReturn <<= aStr;
7085 }
7086 break;
7087 default:
7088 aReturn.clear();
7089 break;
7090 }
7091 return aReturn;
7092}
7093
7094void SVTXFormattedField::SetMinValue(const css::uno::Any& rValue)
7095{
7096 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7097 if (!pField)
7098 return;
7099
7100 Formatter& rFormatter = pField->GetFormatter();
7101 switch (rValue.getValueType().getTypeClass())
7102
7103 {
7104 case css::uno::TypeClass_DOUBLE:
7105 {
7106 double d = 0.0;
7107 rValue >>= d;
7108 rFormatter.SetMinValue(d);
7109 break;
7110 }
7111 default:
7112 DBG_ASSERT(rValue.getValueType().getTypeClass() == css::uno::TypeClass_VOID, "SVTXFormattedField::SetMinValue : invalid argument (an exception will be thrown) !")do { if (true && (!(rValue.getValueType().getTypeClass
() == css::uno::TypeClass_VOID))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN
), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "7112" ": "), "%s", "SVTXFormattedField::SetMinValue : invalid argument (an exception will be thrown) !"
); } } while (false)
;
7113 if ( rValue.getValueType().getTypeClass() != css::uno::TypeClass_VOID )
7114
7115 {
7116 throw css::lang::IllegalArgumentException();
7117 }
7118 rFormatter.ClearMinValue();
7119 break;
7120 }
7121}
7122
7123css::uno::Any SVTXFormattedField::GetMinValue() const
7124{
7125 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7126 if (!pField)
7127 return css::uno::Any();
7128 Formatter& rFormatter = pField->GetFormatter();
7129 if (!rFormatter.HasMinValue())
7130 return css::uno::Any();
7131
7132 css::uno::Any aReturn;
7133 aReturn <<= rFormatter.GetMinValue();
7134 return aReturn;
7135}
7136
7137void SVTXFormattedField::SetMaxValue(const css::uno::Any& rValue)
7138{
7139 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7140 if (!pField)
7141 return;
7142
7143 Formatter& rFormatter = pField->GetFormatter();
7144 switch (rValue.getValueType().getTypeClass())
7145 {
7146 case css::uno::TypeClass_DOUBLE:
7147 {
7148 double d = 0.0;
7149 rValue >>= d;
7150 rFormatter.SetMaxValue(d);
7151 break;
7152 }
7153 default:
7154 if (rValue.getValueType().getTypeClass() != css::uno::TypeClass_VOID)
7155
7156 {
7157 throw css::lang::IllegalArgumentException();
7158 }
7159 rFormatter.ClearMaxValue();
7160 break;
7161 }
7162}
7163
7164css::uno::Any SVTXFormattedField::GetMaxValue() const
7165{
7166 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7167 if (!pField)
7168 return css::uno::Any();
7169 Formatter& rFormatter = pField->GetFormatter();
7170 if (!rFormatter.HasMaxValue())
7171 return css::uno::Any();
7172
7173 css::uno::Any aReturn;
7174 aReturn <<= rFormatter.GetMaxValue();
7175 return aReturn;
7176}
7177
7178void SVTXFormattedField::SetDefaultValue(const css::uno::Any& rValue)
7179{
7180 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7181 if (!pField)
7182 return;
7183
7184 css::uno::Any aConverted = convertEffectiveValue(rValue);
7185
7186 Formatter& rFormatter = pField->GetFormatter();
7187 switch (aConverted.getValueType().getTypeClass())
7188 {
7189 case css::uno::TypeClass_DOUBLE:
7190 {
7191 double d = 0.0;
7192 aConverted >>= d;
7193 rFormatter.SetDefaultValue(d);
7194 }
7195 break;
7196 case css::uno::TypeClass_STRING:
7197 {
7198 OUString aStr;
7199 aConverted >>= aStr;
7200 rFormatter.SetDefaultText( aStr );
7201 }
7202 break;
7203 default:
7204 rFormatter.EnableEmptyField(true);
7205 // only void accepted
7206 break;
7207 }
7208}
7209
7210css::uno::Any SVTXFormattedField::GetDefaultValue() const
7211{
7212 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7213 if (!pField)
7214 return css::uno::Any();
7215 Formatter& rFormatter = pField->GetFormatter();
7216 if (rFormatter.IsEmptyFieldEnabled())
7217 return css::uno::Any();
7218
7219 css::uno::Any aReturn;
7220 if (rFormatter.TreatingAsNumber())
7221 aReturn <<= rFormatter.GetDefaultValue();
7222 else
7223 aReturn <<= rFormatter.GetDefaultText();
7224 return aReturn;
7225}
7226
7227bool SVTXFormattedField::GetTreatAsNumber() const
7228{
7229 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7230 if (pField)
7231 return pField->GetFormatter().TreatingAsNumber();
7232
7233 return true;
7234}
7235
7236void SVTXFormattedField::SetTreatAsNumber(bool bSet)
7237{
7238 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7239 if (pField)
7240 pField->GetFormatter().TreatAsNumber(bSet);
7241}
7242
7243css::uno::Any SVTXFormattedField::GetValue() const
7244{
7245 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7246 if (!pField)
7247 return css::uno::Any();
7248
7249 Formatter& rFormatter = pField->GetFormatter();
7250 css::uno::Any aReturn;
7251 if (!rFormatter.TreatingAsNumber())
7252 {
7253 OUString sText = rFormatter.GetTextValue();
7254 aReturn <<= sText;
7255 }
7256 else
7257 {
7258 if (!pField->GetText().isEmpty()) // empty is returned as void by default
7259 aReturn <<= rFormatter.GetValue();
7260 }
7261
7262 return aReturn;
7263}
7264
7265void SVTXFormattedField::SetValue(const css::uno::Any& rValue)
7266{
7267 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7268 if (!pField)
7269 return;
7270
7271 if (!rValue.hasValue())
7272 {
7273 pField->SetText("");
7274 }
7275 else
7276 {
7277 Formatter& rFormatter = pField->GetFormatter();
7278 if (rValue.getValueType().getTypeClass() == css::uno::TypeClass_DOUBLE )
7279 {
7280 double d = 0.0;
7281 rValue >>= d;
7282 rFormatter.SetValue(d);
7283 }
7284 else
7285 {
7286 DBG_ASSERT(rValue.getValueType().getTypeClass() == css::uno::TypeClass_STRING, "SVTXFormattedField::SetValue : invalid argument !")do { if (true && (!(rValue.getValueType().getTypeClass
() == css::uno::TypeClass_STRING))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN
), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "7286" ": "), "%s", "SVTXFormattedField::SetValue : invalid argument !"
); } } while (false)
;
7287
7288 OUString sText;
7289 rValue >>= sText;
7290 if (!rFormatter.TreatingAsNumber())
7291 rFormatter.SetTextFormatted(sText);
7292 else
7293 rFormatter.SetTextValue(sText);
7294 }
7295 }
7296// NotifyTextListeners();
7297}
7298
7299void SVTXFormattedField::setFormatsSupplier(const css::uno::Reference< css::util::XNumberFormatsSupplier > & xSupplier)
7300{
7301 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7302
7303 SvNumberFormatsSupplierObj* pNew = nullptr;
7304 if (!xSupplier.is())
7305 {
7306 if (pField)
7307 {
7308 Formatter& rFormatter = pField->GetFormatter();
7309 pNew = new SvNumberFormatsSupplierObj(rFormatter.StandardFormatter());
7310 bIsStandardSupplier = true;
7311 }
7312 }
7313 else
7314 {
7315 pNew = comphelper::getUnoTunnelImplementation<SvNumberFormatsSupplierObj>(xSupplier);
7316 bIsStandardSupplier = false;
7317 }
7318
7319 if (!pNew)
7320 return; // TODO : how to process ?
7321
7322 m_xCurrentSupplier = pNew;
7323 if (!pField)
7324 return;
7325
7326 // save the actual value
7327 css::uno::Any aCurrent = GetValue();
7328 Formatter& rFormatter = pField->GetFormatter();
7329 rFormatter.SetFormatter(m_xCurrentSupplier->GetNumberFormatter(), false);
7330 if (nKeyToSetDelayed != -1)
7331 {
7332 rFormatter.SetFormatKey(nKeyToSetDelayed);
7333 nKeyToSetDelayed = -1;
7334 }
7335 SetValue(aCurrent);
7336 NotifyTextListeners();
7337}
7338
7339sal_Int32 SVTXFormattedField::getFormatKey() const
7340{
7341 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7342 return pField ? pField->GetFormatter().GetFormatKey() : 0;
7343}
7344
7345void SVTXFormattedField::setFormatKey(sal_Int32 nKey)
7346{
7347 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7348 if (!pField)
7349 return;
7350
7351 Formatter& rFormatter = pField->GetFormatter();
7352 if (rFormatter.GetFormatter())
7353 rFormatter.SetFormatKey(nKey);
7354 else
7355 {
7356 // probably I am in a block, in which first the key and next the formatter will be set,
7357 // initially this happens quite certain, as the properties are set in alphabetic sequence,
7358 // and the FormatsSupplier is processed before the FormatKey
7359 nKeyToSetDelayed = nKey;
7360 }
7361 NotifyTextListeners();
7362}
7363
7364void SVTXFormattedField::NotifyTextListeners()
7365{
7366 if ( GetTextListeners().getLength() )
7367 {
7368 css::awt::TextEvent aEvent;
7369 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
7370 GetTextListeners().textChanged( aEvent );
7371 }
7372}
7373
7374void SVTXFormattedField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
7375{
7376 PushPropertyIds( rIds,
7377 // FIXME: elide duplication ?
7378 BASEPROPERTY_EFFECTIVE_MIN66,
7379 BASEPROPERTY_VALUEMIN_DOUBLE53,
7380 BASEPROPERTY_EFFECTIVE_MAX67,
7381 BASEPROPERTY_VALUEMAX_DOUBLE54,
7382 BASEPROPERTY_EFFECTIVE_DEFAULT65,
7383 BASEPROPERTY_TREATASNUMBER64,
7384 BASEPROPERTY_EFFECTIVE_VALUE63,
7385 BASEPROPERTY_VALUE_DOUBLE52,
7386 BASEPROPERTY_VALUESTEP_DOUBLE55,
7387 BASEPROPERTY_DECIMALACCURACY29,
7388 BASEPROPERTY_FORMATSSUPPLIER62,
7389 BASEPROPERTY_NUMSHOWTHOUSANDSEP25,
7390 BASEPROPERTY_FORMATKEY61,
7391 BASEPROPERTY_TREATASNUMBER64,
7392 BASEPROPERTY_ENFORCE_FORMAT102,
7393 0);
7394 VCLXWindow::ImplGetPropertyIds( rIds, true );
7395 VCLXSpinField::ImplGetPropertyIds( rIds );
7396}
7397
7398SVTXCurrencyField::SVTXCurrencyField()
7399{
7400}
7401
7402SVTXCurrencyField::~SVTXCurrencyField()
7403{
7404}
7405
7406css::uno::Any SVTXCurrencyField::queryInterface( const css::uno::Type & rType )
7407{
7408 css::uno::Any aRet = ::cppu::queryInterface( rType,
7409 static_cast< css::awt::XCurrencyField* >(this),
7410 static_cast< css::lang::XTypeProvider* >(this) );
7411 return (aRet.hasValue() ? aRet : SVTXFormattedField::queryInterface( rType ));
7412}
7413
7414IMPL_IMPLEMENTATION_ID( SVTXCurrencyField )css::uno::Sequence< sal_Int8 > SVTXCurrencyField::getImplementationId
() { return css::uno::Sequence<sal_Int8>(); }
7415
7416// css::lang::XTypeProvider
7417css::uno::Sequence< css::uno::Type > SVTXCurrencyField::getTypes()
7418{
7419 static const ::cppu::OTypeCollection aTypeList(
7420 cppu::UnoType<css::lang::XTypeProvider>::get(),
7421 cppu::UnoType<css::awt::XCurrencyField>::get(),
7422 SVTXFormattedField::getTypes()
7423 );
7424 return aTypeList.getTypes();
7425}
7426
7427void SVTXCurrencyField::setValue( double Value )
7428{
7429 SolarMutexGuard aGuard;
7430
7431 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7432 if ( pField )
7433 pField->GetFormatter().SetValue( Value );
7434}
7435
7436double SVTXCurrencyField::getValue()
7437{
7438 SolarMutexGuard aGuard;
7439
7440 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7441 return pField ? pField->GetFormatter().GetValue() : 0;
7442}
7443
7444void SVTXCurrencyField::setMin( double Value )
7445{
7446 SolarMutexGuard aGuard;
7447
7448 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7449 if ( pField )
7450 pField->GetFormatter().SetMinValue( Value );
7451}
7452
7453double SVTXCurrencyField::getMin()
7454{
7455 SolarMutexGuard aGuard;
7456
7457 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7458 return pField ? pField->GetFormatter().GetMinValue() : 0;
7459}
7460
7461void SVTXCurrencyField::setMax( double Value )
7462{
7463 SolarMutexGuard aGuard;
7464
7465 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7466 if ( pField )
7467 pField->GetFormatter().SetMaxValue( Value );
7468}
7469
7470double SVTXCurrencyField::getMax()
7471{
7472 SolarMutexGuard aGuard;
7473
7474 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7475 return pField ? pField->GetFormatter().GetMaxValue() : 0;
7476}
7477
7478void SVTXCurrencyField::setFirst( double Value )
7479{
7480 SolarMutexGuard aGuard;
7481
7482 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7483 if ( pField )
7484 pField->GetFormatter().SetSpinFirst( Value );
7485}
7486
7487double SVTXCurrencyField::getFirst()
7488{
7489 SolarMutexGuard aGuard;
7490
7491 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7492 return pField ? pField->GetFormatter().GetSpinFirst() : 0;
7493}
7494
7495void SVTXCurrencyField::setLast( double Value )
7496{
7497 SolarMutexGuard aGuard;
7498
7499 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7500 if ( pField )
7501 pField->GetFormatter().SetSpinLast( Value );
7502}
7503
7504double SVTXCurrencyField::getLast()
7505{
7506 SolarMutexGuard aGuard;
7507
7508 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7509 return pField ? pField->GetFormatter().GetSpinLast() : 0;
7510}
7511
7512void SVTXCurrencyField::setSpinSize( double Value )
7513{
7514 SolarMutexGuard aGuard;
7515
7516 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7517 if ( pField )
7518 pField->GetFormatter().SetSpinSize( Value );
7519}
7520
7521double SVTXCurrencyField::getSpinSize()
7522{
7523 SolarMutexGuard aGuard;
7524
7525 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7526 return pField ? pField->GetFormatter().GetSpinSize() : 0;
7527}
7528
7529void SVTXCurrencyField::setDecimalDigits( sal_Int16 Value )
7530{
7531 SolarMutexGuard aGuard;
7532
7533 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7534 if ( pField )
7535 pField->GetFormatter().SetDecimalDigits( Value );
7536}
7537
7538sal_Int16 SVTXCurrencyField::getDecimalDigits()
7539{
7540 SolarMutexGuard aGuard;
7541
7542 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7543 return pField ? pField->GetFormatter().GetDecimalDigits() : 0;
7544}
7545
7546void SVTXCurrencyField::setStrictFormat( sal_Bool bStrict )
7547{
7548 SolarMutexGuard aGuard;
7549
7550 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7551 if ( pField )
7552 pField->GetFormatter().SetStrictFormat( bStrict );
7553}
7554
7555sal_Bool SVTXCurrencyField::isStrictFormat()
7556{
7557 SolarMutexGuard aGuard;
7558
7559 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7560 return pField && pField->GetFormatter().IsStrictFormat();
7561}
7562
7563void SVTXCurrencyField::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
7564{
7565 SolarMutexGuard aGuard;
7566
7567 VclPtr< DoubleCurrencyField > pField = GetAs< DoubleCurrencyField >();
7568 if ( pField )
7569 {
7570 sal_uInt16 nPropType = GetPropertyId( PropertyName );
7571 switch (nPropType)
7572 {
7573 case BASEPROPERTY_CURRENCYSYMBOL26:
7574 {
7575 OUString aStr;
7576 Value >>= aStr;
7577 pField->setCurrencySymbol( aStr );
7578 }
7579 break;
7580 case BASEPROPERTY_CURSYM_POSITION68:
7581 {
7582 bool b = false;
7583 Value >>= b;
7584 pField->setPrependCurrSym(b);
7585 }
7586 break;
7587
7588 default:
7589 SVTXFormattedField::setProperty(PropertyName, Value);
7590 }
7591 }
7592 else
7593 SVTXFormattedField::setProperty(PropertyName, Value);
7594}
7595
7596css::uno::Any SVTXCurrencyField::getProperty( const OUString& PropertyName )
7597{
7598 SolarMutexGuard aGuard;
7599
7600 css::uno::Any aReturn;
7601
7602 VclPtr< DoubleCurrencyField > pField = GetAs< DoubleCurrencyField >();
7603 if ( pField )
7604 {
7605 sal_uInt16 nPropType = GetPropertyId( PropertyName );
7606 switch (nPropType)
7607 {
7608 case BASEPROPERTY_CURRENCYSYMBOL26:
7609 {
7610 aReturn <<= pField->getCurrencySymbol();
7611 }
7612 break;
7613 case BASEPROPERTY_CURSYM_POSITION68:
7614 {
7615 aReturn <<= pField->getPrependCurrSym();
7616 }
7617 break;
7618 default:
7619 return SVTXFormattedField::getProperty(PropertyName);
7620 }
7621 }
7622 return SVTXFormattedField::getProperty(PropertyName);
7623}
7624
7625void SVTXCurrencyField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
7626{
7627 PushPropertyIds( rIds,
7628 BASEPROPERTY_ALIGN7,
7629 BASEPROPERTY_BACKGROUNDCOLOR2,
7630 BASEPROPERTY_BORDER6,
7631 BASEPROPERTY_BORDERCOLOR112,
7632 BASEPROPERTY_CURRENCYSYMBOL26,
7633 BASEPROPERTY_CURSYM_POSITION68,
7634 BASEPROPERTY_DECIMALACCURACY29,
7635 BASEPROPERTY_DEFAULTCONTROL19,
7636 BASEPROPERTY_ENABLED44,
7637 BASEPROPERTY_ENABLEVISIBLE145,
7638 BASEPROPERTY_FONTDESCRIPTOR8,
7639 BASEPROPERTY_HELPTEXT73,
7640 BASEPROPERTY_HELPURL58,
7641 BASEPROPERTY_NUMSHOWTHOUSANDSEP25,
7642 BASEPROPERTY_PRINTABLE45,
7643 BASEPROPERTY_READONLY43,
7644 BASEPROPERTY_REPEAT101,
7645 BASEPROPERTY_REPEAT_DELAY95,
7646 BASEPROPERTY_SPIN27,
7647 BASEPROPERTY_STRICTFORMAT28,
7648 BASEPROPERTY_TABSTOP14,
7649 BASEPROPERTY_VALUEMAX_DOUBLE54,
7650 BASEPROPERTY_VALUEMIN_DOUBLE53,
7651 BASEPROPERTY_VALUESTEP_DOUBLE55,
7652 BASEPROPERTY_VALUE_DOUBLE52,
7653 BASEPROPERTY_ENFORCE_FORMAT102,
7654 BASEPROPERTY_HIDEINACTIVESELECTION110,
7655 BASEPROPERTY_VERTICALALIGN115,
7656 BASEPROPERTY_WRITING_MODE138,
7657 BASEPROPERTY_CONTEXT_WRITING_MODE139,
7658 BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR116,
7659 0);
7660 VCLXWindow::ImplGetPropertyIds( rIds );
7661}
7662
7663SVTXNumericField::SVTXNumericField()
7664{
7665}
7666
7667SVTXNumericField::~SVTXNumericField()
7668{
7669}
7670
7671css::uno::Any SVTXNumericField::queryInterface( const css::uno::Type & rType )
7672{
7673 css::uno::Any aRet = ::cppu::queryInterface( rType,
7674 static_cast< css::awt::XNumericField* >(this),
7675 static_cast< css::lang::XTypeProvider* >(this) );
7676 return (aRet.hasValue() ? aRet : SVTXFormattedField::queryInterface( rType ));
7677}
7678
7679IMPL_IMPLEMENTATION_ID( SVTXNumericField )css::uno::Sequence< sal_Int8 > SVTXNumericField::getImplementationId
() { return css::uno::Sequence<sal_Int8>(); }
7680
7681// css::lang::XTypeProvider
7682css::uno::Sequence< css::uno::Type > SVTXNumericField::getTypes()
7683{
7684 static const ::cppu::OTypeCollection aTypeList(
7685 cppu::UnoType<css::lang::XTypeProvider>::get(),
7686 cppu::UnoType<css::awt::XNumericField>::get(),
7687 SVTXFormattedField::getTypes()
7688 );
7689 return aTypeList.getTypes();
7690}
7691
7692void SVTXNumericField::setValue( double Value )
7693{
7694 SolarMutexGuard aGuard;
7695
7696 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7697 if ( pField )
7698 pField->GetFormatter().SetValue( Value );
7699}
7700
7701double SVTXNumericField::getValue()
7702{
7703 SolarMutexGuard aGuard;
7704
7705 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7706 return pField ? pField->GetFormatter().GetValue() : 0;
7707}
7708
7709void SVTXNumericField::setMin( double Value )
7710{
7711 SolarMutexGuard aGuard;
7712
7713 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7714 if ( pField )
7715 pField->GetFormatter().SetMinValue( Value );
7716}
7717
7718double SVTXNumericField::getMin()
7719{
7720 SolarMutexGuard aGuard;
7721
7722 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7723 return pField ? pField->GetFormatter().GetMinValue() : 0;
7724}
7725
7726void SVTXNumericField::setMax( double Value )
7727{
7728 SolarMutexGuard aGuard;
7729
7730 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7731 if ( pField )
7732 pField->GetFormatter().SetMaxValue( Value );
7733}
7734
7735double SVTXNumericField::getMax()
7736{
7737 SolarMutexGuard aGuard;
7738
7739 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7740 return pField ? pField->GetFormatter().GetMaxValue() : 0;
7741}
7742
7743void SVTXNumericField::setFirst( double Value )
7744{
7745 SolarMutexGuard aGuard;
7746
7747 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7748 if ( pField )
7749 pField->GetFormatter().SetSpinFirst( Value );
7750}
7751
7752double SVTXNumericField::getFirst()
7753{
7754 SolarMutexGuard aGuard;
7755
7756 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7757 return pField ? pField->GetFormatter().GetSpinFirst() : 0;
7758}
7759
7760void SVTXNumericField::setLast( double Value )
7761{
7762 SolarMutexGuard aGuard;
7763
7764 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7765 if ( pField )
7766 pField->GetFormatter().SetSpinLast( Value );
7767}
7768
7769double SVTXNumericField::getLast()
7770{
7771 SolarMutexGuard aGuard;
7772
7773 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7774 return pField ? pField->GetFormatter().GetSpinLast() : 0;
7775}
7776
7777void SVTXNumericField::setSpinSize( double Value )
7778{
7779 SolarMutexGuard aGuard;
7780
7781 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7782 if ( pField )
7783 pField->GetFormatter().SetSpinSize( Value );
7784}
7785
7786double SVTXNumericField::getSpinSize()
7787{
7788 SolarMutexGuard aGuard;
7789
7790 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7791 return pField ? pField->GetFormatter().GetSpinSize() : 0;
7792}
7793
7794void SVTXNumericField::setDecimalDigits( sal_Int16 Value )
7795{
7796 SolarMutexGuard aGuard;
7797
7798 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7799 if ( pField )
7800 pField->GetFormatter().SetDecimalDigits( Value );
7801}
7802
7803sal_Int16 SVTXNumericField::getDecimalDigits()
7804{
7805 SolarMutexGuard aGuard;
7806
7807 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7808 return pField ? pField->GetFormatter().GetDecimalDigits() : 0;
7809}
7810
7811void SVTXNumericField::setStrictFormat( sal_Bool bStrict )
7812{
7813 SolarMutexGuard aGuard;
7814
7815 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7816 if ( pField )
7817 pField->GetFormatter().SetStrictFormat( bStrict );
7818}
7819
7820sal_Bool SVTXNumericField::isStrictFormat()
7821{
7822 SolarMutexGuard aGuard;
7823
7824 VclPtr<FormattedField> pField = GetAs< FormattedField >();
7825 return pField && pField->GetFormatter().IsStrictFormat();
7826}
7827
7828void SVTXNumericField::GetPropertyIds( std::vector< sal_uInt16 > &rIds )
7829{
7830 SVTXFormattedField::ImplGetPropertyIds( rIds );
7831}
7832
7833SVTXDateField::SVTXDateField()
7834 :VCLXDateField()
7835{
7836}
7837
7838SVTXDateField::~SVTXDateField()
7839{
7840}
7841
7842void SAL_CALL SVTXDateField::setProperty( const OUString& PropertyName, const css::uno::Any& Value )
7843{
7844 VCLXDateField::setProperty( PropertyName, Value );
7845
7846 // some properties need to be forwarded to the sub edit, too
7847 SolarMutexGuard g;
7848 VclPtr< Edit > pSubEdit = GetWindow() ? static_cast< Edit* >( GetWindow().get() )->GetSubEdit() : nullptr;
7849 if ( !pSubEdit )
7850 return;
7851
7852 switch ( GetPropertyId( PropertyName ) )
7853 {
7854 case BASEPROPERTY_TEXTLINECOLOR85:
7855 if ( !Value.hasValue() )
7856 pSubEdit->SetTextLineColor();
7857 else
7858 {
7859 sal_Int32 nColor = 0;
7860 if ( Value >>= nColor )
7861 pSubEdit->SetTextLineColor( Color( nColor ) );
7862 }
7863 break;
7864 }
7865}
7866
7867void SVTXDateField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
7868{
7869 PushPropertyIds( rIds,
7870 BASEPROPERTY_TEXTLINECOLOR85,
7871 0);
7872 VCLXDateField::ImplGetPropertyIds( rIds );
7873}
7874
7875VCLXMultiLineEdit::VCLXMultiLineEdit()
7876 :maTextListeners( *this )
7877 ,meLineEndType( LINEEND_LF ) // default behavior before introducing this property: LF (unix-like)
7878{
7879}
7880
7881VCLXMultiLineEdit::~VCLXMultiLineEdit()
7882{
7883}
7884
7885css::uno::Any VCLXMultiLineEdit::queryInterface( const css::uno::Type & rType )
7886{
7887 css::uno::Any aRet = ::cppu::queryInterface( rType,
7888 static_cast< css::awt::XTextComponent* >(this),
7889 static_cast< css::awt::XTextArea* >(this),
7890 static_cast< css::awt::XTextLayoutConstrains* >(this),
7891 static_cast< css::lang::XTypeProvider* >(this) );
7892 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
7893}
7894
7895IMPL_IMPLEMENTATION_ID( VCLXMultiLineEdit )css::uno::Sequence< sal_Int8 > VCLXMultiLineEdit::getImplementationId
() { return css::uno::Sequence<sal_Int8>(); }
7896
7897// css::lang::XTypeProvider
7898css::uno::Sequence< css::uno::Type > VCLXMultiLineEdit::getTypes()
7899{
7900 static const ::cppu::OTypeCollection aTypeList(
7901 cppu::UnoType<css::lang::XTypeProvider>::get(),
7902 cppu::UnoType<css::awt::XTextComponent>::get(),
7903 cppu::UnoType<css::awt::XTextArea>::get(),
7904 cppu::UnoType<css::awt::XTextLayoutConstrains>::get(),
7905 VCLXWindow::getTypes()
7906 );
7907 return aTypeList.getTypes();
7908}
7909
7910void VCLXMultiLineEdit::addTextListener( const css::uno::Reference< css::awt::XTextListener > & l )
7911{
7912 maTextListeners.addInterface( l );
7913}
7914
7915void VCLXMultiLineEdit::removeTextListener( const css::uno::Reference< css::awt::XTextListener > & l )
7916{
7917 maTextListeners.removeInterface( l );
7918}
7919
7920void VCLXMultiLineEdit::setText( const OUString& aText )
7921{
7922 SolarMutexGuard aGuard;
7923
7924 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
7925 if ( pEdit )
7926 {
7927 pEdit->SetText( aText );
7928
7929 // #107218# Call same listeners like VCL would do after user interaction
7930 SetSynthesizingVCLEvent( true );
7931 pEdit->SetModifyFlag();
7932 pEdit->Modify();
7933 SetSynthesizingVCLEvent( false );
7934 }
7935}
7936
7937void VCLXMultiLineEdit::insertText( const css::awt::Selection& rSel, const OUString& aText )
7938{
7939 SolarMutexGuard aGuard;
7940
7941 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
7942 if ( pEdit )
7943 {
7944 setSelection( rSel );
7945 pEdit->ReplaceSelected( aText );
7946 }
7947}
7948
7949OUString VCLXMultiLineEdit::getText()
7950{
7951 SolarMutexGuard aGuard;
7952
7953 OUString aText;
7954 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
7955 if ( pEdit )
7956 aText = pEdit->GetText( meLineEndType );
7957 return aText;
7958}
7959
7960OUString VCLXMultiLineEdit::getSelectedText()
7961{
7962 SolarMutexGuard aGuard;
7963
7964 OUString aText;
7965 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
7966 if ( pMultiLineEdit)
7967 aText = pMultiLineEdit->GetSelected( meLineEndType );
7968 return aText;
7969
7970}
7971
7972void VCLXMultiLineEdit::setSelection( const css::awt::Selection& aSelection )
7973{
7974 SolarMutexGuard aGuard;
7975
7976 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
7977 if ( pMultiLineEdit )
7978 {
7979 pMultiLineEdit->SetSelection( Selection( aSelection.Min, aSelection.Max ) );
7980 }
7981}
7982
7983css::awt::Selection VCLXMultiLineEdit::getSelection()
7984{
7985 SolarMutexGuard aGuard;
7986
7987 css::awt::Selection aSel;
7988 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
7989 if ( pMultiLineEdit )
7990 {
7991 aSel.Min = pMultiLineEdit->GetSelection().Min();
7992 aSel.Max = pMultiLineEdit->GetSelection().Max();
7993 }
7994 return aSel;
7995}
7996
7997sal_Bool VCLXMultiLineEdit::isEditable()
7998{
7999 SolarMutexGuard aGuard;
8000
8001 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
8002 return pMultiLineEdit && !pMultiLineEdit->IsReadOnly() && pMultiLineEdit->IsEnabled();
8003}
8004
8005void VCLXMultiLineEdit::setEditable( sal_Bool bEditable )
8006{
8007 SolarMutexGuard aGuard;
8008
8009 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
8010 if ( pMultiLineEdit )
8011 pMultiLineEdit->SetReadOnly( !bEditable );
8012}
8013
8014void VCLXMultiLineEdit::setMaxTextLen( sal_Int16 nLen )
8015{
8016 SolarMutexGuard aGuard;
8017
8018 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
8019 if ( pMultiLineEdit )
8020 pMultiLineEdit->SetMaxTextLen( nLen );
8021}
8022
8023sal_Int16 VCLXMultiLineEdit::getMaxTextLen()
8024{
8025 SolarMutexGuard aGuard;
8026
8027 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
8028 return pMultiLineEdit ? static_cast<sal_Int16>(pMultiLineEdit->GetMaxTextLen()) : sal_Int16(0);
8029}
8030
8031OUString VCLXMultiLineEdit::getTextLines()
8032{
8033 SolarMutexGuard aGuard;
8034
8035 OUString aText;
8036 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
8037 if ( pEdit )
8038 aText = pEdit->GetTextLines( meLineEndType );
8039 return aText;
8040}
8041
8042css::awt::Size VCLXMultiLineEdit::getMinimumSize()
8043{
8044 SolarMutexGuard aGuard;
8045
8046 css::awt::Size aSz;
8047 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
8048 if ( pEdit )
8049 aSz = AWTSize(pEdit->CalcMinimumSize());
8050 return aSz;
8051}
8052
8053css::awt::Size VCLXMultiLineEdit::getPreferredSize()
8054{
8055 return getMinimumSize();
8056}
8057
8058css::awt::Size VCLXMultiLineEdit::calcAdjustedSize( const css::awt::Size& rNewSize )
8059{
8060 SolarMutexGuard aGuard;
8061
8062 css::awt::Size aSz = rNewSize;
8063 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
8064 if ( pEdit )
8065 aSz = AWTSize(pEdit->CalcAdjustedSize( VCLSize(rNewSize )));
8066 return aSz;
8067}
8068
8069css::awt::Size VCLXMultiLineEdit::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines )
8070{
8071 SolarMutexGuard aGuard;
8072
8073 css::awt::Size aSz;
8074 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
8075 if ( pEdit )
8076 aSz = AWTSize(pEdit->CalcBlockSize( nCols, nLines ));
8077 return aSz;
8078}
8079
8080void VCLXMultiLineEdit::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines )
8081{
8082 SolarMutexGuard aGuard;
8083
8084 nCols = nLines = 0;
8085 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
8086 if ( pEdit )
8087 {
8088 sal_uInt16 nC, nL;
8089 pEdit->GetMaxVisColumnsAndLines( nC, nL );
8090 nCols = nC;
8091 nLines = nL;
8092 }
8093}
8094
8095void VCLXMultiLineEdit::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
8096{
8097 switch ( rVclWindowEvent.GetId() )
8098 {
8099 case VclEventId::EditModify:
8100 {
8101 if ( maTextListeners.getLength() )
8102 {
8103 css::awt::TextEvent aEvent;
8104 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
8105 maTextListeners.textChanged( aEvent );
8106 }
8107 }
8108 break;
8109 default:
8110 {
8111 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
8112 }
8113 break;
8114 }
8115}
8116
8117void VCLXMultiLineEdit::setProperty( const OUString& PropertyName, const css::uno::Any& Value)
8118{
8119 SolarMutexGuard aGuard;
8120
8121 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
8122 if ( !pMultiLineEdit )
8123 return;
8124
8125 sal_uInt16 nPropType = GetPropertyId( PropertyName );
8126 switch ( nPropType )
8127 {
8128 case BASEPROPERTY_LINE_END_FORMAT104:
8129 {
8130 sal_Int16 nLineEndType = css::awt::LineEndFormat::LINE_FEED;
8131 OSL_VERIFY( Value >>= nLineEndType )do { if (!(Value >>= nLineEndType)) do { if (true &&
(!(0))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), (
"legacy.osl"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "8131" ": "), "OSL_ASSERT: %s", "0"); } } while (false);
} while (0)
;
8132 switch ( nLineEndType )
8133 {
8134 case css::awt::LineEndFormat::CARRIAGE_RETURN: meLineEndType = LINEEND_CR; break;
8135 case css::awt::LineEndFormat::LINE_FEED: meLineEndType = LINEEND_LF; break;
8136 case css::awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED: meLineEndType = LINEEND_CRLF; break;
8137 default: OSL_FAIL( "VCLXMultiLineEdit::setProperty: invalid line end value!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "8137" ": "), "%s", "VCLXMultiLineEdit::setProperty: invalid line end value!"
); } } while (false)
; break;
8138 }
8139 }
8140 break;
8141
8142 case BASEPROPERTY_READONLY43:
8143 {
8144 bool b;
8145 if ( Value >>= b )
8146 pMultiLineEdit->SetReadOnly( b );
8147 }
8148 break;
8149 case BASEPROPERTY_MAXTEXTLEN47:
8150 {
8151 sal_Int16 n = sal_Int16();
8152 if ( Value >>= n )
8153 pMultiLineEdit->SetMaxTextLen( n );
8154 }
8155 break;
8156 case BASEPROPERTY_HIDEINACTIVESELECTION110:
8157 {
8158 bool b;
8159 if ( Value >>= b )
8160 {
8161 pMultiLineEdit->EnableFocusSelectionHide( b );
8162 lcl_setWinBits( pMultiLineEdit, WB_NOHIDESELECTION, !b );
8163 }
8164 }
8165 break;
8166 default:
8167 {
8168 VCLXWindow::setProperty( PropertyName, Value );
8169 }
8170 }
8171}
8172
8173css::uno::Any VCLXMultiLineEdit::getProperty( const OUString& PropertyName )
8174{
8175 SolarMutexGuard aGuard;
8176
8177 css::uno::Any aProp;
8178 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
8179 if ( pMultiLineEdit )
8180 {
8181 sal_uInt16 nPropType = GetPropertyId( PropertyName );
8182 switch ( nPropType )
8183 {
8184 case BASEPROPERTY_LINE_END_FORMAT104:
8185 {
8186 sal_Int16 nLineEndType = css::awt::LineEndFormat::LINE_FEED;
8187 switch ( meLineEndType )
8188 {
8189 case LINEEND_CR: nLineEndType = css::awt::LineEndFormat::CARRIAGE_RETURN; break;
8190 case LINEEND_LF: nLineEndType = css::awt::LineEndFormat::LINE_FEED; break;
8191 case LINEEND_CRLF: nLineEndType = css::awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED; break;
8192 default: OSL_FAIL( "VCLXMultiLineEdit::getProperty: invalid line end value!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/toolkit/source/awt/vclxwindows.cxx"
":" "8192" ": "), "%s", "VCLXMultiLineEdit::getProperty: invalid line end value!"
); } } while (false)
; break;
8193 }
8194 aProp <<= nLineEndType;
8195 }
8196 break;
8197
8198 case BASEPROPERTY_READONLY43:
8199 {
8200 aProp <<= pMultiLineEdit->IsReadOnly();
8201 }
8202 break;
8203 case BASEPROPERTY_MAXTEXTLEN47:
8204 {
8205 aProp <<= static_cast<sal_Int16>(pMultiLineEdit->GetMaxTextLen());
8206 }
8207 break;
8208 default:
8209 {
8210 aProp = VCLXWindow::getProperty( PropertyName );
8211 }
8212 }
8213 }
8214 return aProp;
8215}
8216
8217void SAL_CALL VCLXMultiLineEdit::setFocus( )
8218{
8219 SolarMutexGuard aGuard;
8220
8221 // don't grab the focus if we already have it. Reason is that the only thing which the edit
8222 // does is forwarding the focus to its text window. This text window then does a "select all".
8223 // So if the text window already has the focus, and we give the focus to the multi line
8224 // edit, then all which happens is that everything is selected.
8225 // #i27072#
8226 if ( GetWindow() && !GetWindow()->HasChildPathFocus() )
1
Calling 'VCLXWindow::GetWindow'
10
Returning from 'VCLXWindow::GetWindow'
11
Assuming the condition is false
12
Calling implicit destructor for 'VclPtr<vcl::Window>'
13
Calling '~Reference'
20
Returning from '~Reference'
21
Returning from destructor for 'VclPtr<vcl::Window>'
22
Calling implicit destructor for 'VclPtr<vcl::Window>'
23
Calling '~Reference'
8227 GetWindow()->GrabFocus();
8228}
8229
8230void VCLXMultiLineEdit::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
8231{
8232 PushPropertyIds( rIds,
8233 // FIXME: elide duplication ?
8234 BASEPROPERTY_LINE_END_FORMAT104,
8235 BASEPROPERTY_READONLY43,
8236 BASEPROPERTY_MAXTEXTLEN47,
8237 BASEPROPERTY_HIDEINACTIVESELECTION110,
8238 0);
8239 VCLXWindow::ImplGetPropertyIds( rIds, true );
8240}
8241
8242/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/home/maarten/src/libreoffice/core/include/toolkit/awt/vclxwindow.hxx

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#ifndef INCLUDED_TOOLKIT_AWT_VCLXWINDOW_HXX
21#define INCLUDED_TOOLKIT_AWT_VCLXWINDOW_HXX
22
23#include <toolkit/dllapi.h>
24#include <toolkit/awt/vclxdevice.hxx>
25#include <vcl/window.hxx>
26
27#include <com/sun/star/awt/XWindow2.hpp>
28#include <com/sun/star/awt/XVclWindowPeer.hpp>
29#include <com/sun/star/awt/XLayoutConstrains.hpp>
30#include <com/sun/star/awt/XView.hpp>
31#include <com/sun/star/beans/XPropertySetInfo.hpp>
32#include <com/sun/star/accessibility/XAccessible.hpp>
33#include <com/sun/star/awt/XDockableWindow.hpp>
34#include <com/sun/star/awt/XStyleSettingsSupplier.hpp>
35
36#include <comphelper/servicehelper.hxx>
37#include <cppuhelper/implbase.hxx>
38
39#include <tools/gen.hxx>
40#include <tools/link.hxx>
41
42#include <memory>
43#include <vector>
44#include <functional>
45
46namespace comphelper { class OInterfaceContainerHelper2; }
47namespace com::sun::star::accessibility { class XAccessibleContext; }
48
49class VclWindowEvent;
50
51namespace toolkit
52{
53 class IAccessibleFactory;
54}
55
56
57class UnoPropertyArrayHelper;
58class VCLXWindowImpl;
59typedef cppu::ImplInheritanceHelper< VCLXDevice,
60 css::awt::XWindow2,
61 css::awt::XVclWindowPeer,
62 css::awt::XLayoutConstrains,
63 css::awt::XView,
64 css::awt::XDockableWindow,
65 css::accessibility::XAccessible,
66 css::lang::XEventListener,
67 css::beans::XPropertySetInfo,
68 css::awt::XStyleSettingsSupplier
69 > VCLXWindow_Base;
70
71class TOOLKIT_DLLPUBLIC__attribute__ ((visibility("default"))) VCLXWindow : public VCLXWindow_Base
72{
73private:
74 std::unique_ptr<VCLXWindowImpl> mpImpl;
75
76 UnoPropertyArrayHelper *GetPropHelper();
77
78protected:
79 Size ImplCalcWindowSize( const Size& rOutSz ) const;
80 DECL_LINK(WindowEventListener, VclWindowEvent&, void )static void LinkStubWindowEventListener(void *, VclWindowEvent
&); void WindowEventListener(VclWindowEvent&)
;
81
82 virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent );
83 virtual css::uno::Reference< css::accessibility::XAccessibleContext >
84 CreateAccessibleContext();
85
86 void SetSynthesizingVCLEvent( bool b );
87 bool IsSynthesizingVCLEvent() const;
88
89 void SetSystemParent_Impl( const css::uno::Any& rHandle );
90
91 ::toolkit::IAccessibleFactory& getAccessibleFactory();
92
93 // helper ...
94 static void PushPropertyIds( std::vector< sal_uInt16 > &aIds, int nFirstId, ...);
95 // for use in controls/
96 static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds,
97 bool bWithDefaults = false );
98 virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds );
99
100 ::comphelper::OInterfaceContainerHelper2& GetContainerListeners();
101 ::comphelper::OInterfaceContainerHelper2& GetTopWindowListeners();
102
103public:
104 typedef ::std::function<void ()> Callback;
105
106protected:
107 /** executes the given callback asynchronously
108
109 At the moment the callback is called, the Solar Mutex is not locked. In particular, this implies that
110 you cannot rely on |this| not being disposed. However, you *can* rely on |this| being still alive (i.e.
111 having a ref count > 0).
112
113 As a consequence, this can be used for doing listener notifications, using event multiplexers. Those multiplexers
114 care for the disposed state themself, and are alive as long as |this| is alive.
115 */
116 void ImplExecuteAsyncWithoutSolarLock(
117 const Callback& i_callback
118 );
119
120public:
121 VCLXWindow( bool bWithDefaultProps = false );
122 virtual ~VCLXWindow() override;
123
124 virtual void SetWindow( const VclPtr< vcl::Window > &pWindow );
125 template< class derived_type > VclPtr< derived_type > GetAs() const {
126 return VclPtr< derived_type >( static_cast< derived_type * >( GetOutputDevice().get() ) ); }
3
Calling constructor for 'VclPtr<vcl::Window>'
8
Returning from constructor for 'VclPtr<vcl::Window>'
127 template< class derived_type > VclPtr< derived_type > GetAsDynamic() const {
128 return VclPtr< derived_type >( dynamic_cast< derived_type * >( GetOutputDevice().get() ) ); }
129 VclPtr<vcl::Window> GetWindow() const { return GetAs<vcl::Window>(); }
2
Calling 'VCLXWindow::GetAs'
9
Returning from 'VCLXWindow::GetAs'
130
131 void suspendVclEventListening( );
132 void resumeVclEventListening( );
133
134 void notifyWindowRemoved( vcl::Window const & _rWindow );
135
136 // css::lang::XUnoTunnel
137 UNO3_GETIMPLEMENTATION_DECL(VCLXWindow)static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId
() throw(); virtual sal_Int64 getSomething( const css::uno::Sequence
< sal_Int8 >& aIdentifier ) override;
138
139 // css::lang::XEventListener
140 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
141
142 // css::lang::XComponent
143 void SAL_CALL dispose( ) override;
144 void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& rxListener ) override;
145 void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& rxListener ) override;
146
147 // css::awt::XWindow
148 void SAL_CALL setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags ) override;
149 css::awt::Rectangle SAL_CALL getPosSize( ) override;
150 void SAL_CALL setVisible( sal_Bool Visible ) override;
151 void SAL_CALL setEnable( sal_Bool Enable ) override;
152 void SAL_CALL setFocus( ) override;
153 void SAL_CALL addWindowListener( const css::uno::Reference< css::awt::XWindowListener >& rrxListener ) override;
154 void SAL_CALL removeWindowListener( const css::uno::Reference< css::awt::XWindowListener >& rrxListener ) override;
155 void SAL_CALL addFocusListener( const css::uno::Reference< css::awt::XFocusListener >& rrxListener ) override;
156 void SAL_CALL removeFocusListener( const css::uno::Reference< css::awt::XFocusListener >& rrxListener ) override;
157 void SAL_CALL addKeyListener( const css::uno::Reference< css::awt::XKeyListener >& rrxListener ) override;
158 void SAL_CALL removeKeyListener( const css::uno::Reference< css::awt::XKeyListener >& rrxListener ) override;
159 void SAL_CALL addMouseListener( const css::uno::Reference< css::awt::XMouseListener >& rrxListener ) override;
160 void SAL_CALL removeMouseListener( const css::uno::Reference< css::awt::XMouseListener >& rrxListener ) override;
161 void SAL_CALL addMouseMotionListener( const css::uno::Reference< css::awt::XMouseMotionListener >& rrxListener ) override;
162 void SAL_CALL removeMouseMotionListener( const css::uno::Reference< css::awt::XMouseMotionListener >& rrxListener ) override;
163 void SAL_CALL addPaintListener( const css::uno::Reference< css::awt::XPaintListener >& rrxListener ) override;
164 void SAL_CALL removePaintListener( const css::uno::Reference< css::awt::XPaintListener >& rrxListener ) override;
165
166 // css::awt::XWindowPeer
167 css::uno::Reference< css::awt::XToolkit > SAL_CALL getToolkit( ) override;
168 void SAL_CALL setPointer( const css::uno::Reference< css::awt::XPointer >& Pointer ) override;
169 void SAL_CALL setBackground( sal_Int32 Color ) override;
170 void SAL_CALL invalidate( sal_Int16 Flags ) override;
171 void SAL_CALL invalidateRect( const css::awt::Rectangle& Rect, sal_Int16 Flags ) override;
172
173 // css::awt::XVclWindowPeer
174 sal_Bool SAL_CALL isChild( const css::uno::Reference< css::awt::XWindowPeer >& Peer ) override;
175 void SAL_CALL setDesignMode( sal_Bool bOn ) override;
176 sal_Bool SAL_CALL isDesignMode( ) override;
177 void SAL_CALL enableClipSiblings( sal_Bool bClip ) override;
178 void SAL_CALL setForeground( sal_Int32 Color ) override;
179 void SAL_CALL setControlFont( const css::awt::FontDescriptor& aFont ) override;
180 void SAL_CALL getStyles( sal_Int16 nType, css::awt::FontDescriptor& Font, sal_Int32& ForegroundColor, sal_Int32& BackgroundColor ) override;
181 void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override;
182 css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override;
183
184 // css::awt::XLayoutConstrains
185 css::awt::Size SAL_CALL getMinimumSize( ) override;
186 css::awt::Size SAL_CALL getPreferredSize( ) override;
187 css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& aNewSize ) override;
188
189 // css::awt::XView
190 sal_Bool SAL_CALL setGraphics( const css::uno::Reference< css::awt::XGraphics >& aDevice ) override;
191 css::uno::Reference< css::awt::XGraphics > SAL_CALL getGraphics( ) override;
192 css::awt::Size SAL_CALL getSize( ) override;
193 void SAL_CALL draw( sal_Int32 nX, sal_Int32 nY ) override;
194 void SAL_CALL setZoom( float fZoomX, float fZoomY ) override;
195
196 // css::accessibility::XAccessible
197 css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override;
198
199 // css::awt::XDockableWindow
200 void SAL_CALL addDockableWindowListener( const css::uno::Reference< css::awt::XDockableWindowListener >& xListener ) override;
201 void SAL_CALL removeDockableWindowListener( const css::uno::Reference< css::awt::XDockableWindowListener >& xListener ) override;
202 void SAL_CALL enableDocking( sal_Bool bEnable ) override;
203 sal_Bool SAL_CALL isFloating( ) override;
204 void SAL_CALL setFloatingMode( sal_Bool bFloating ) override;
205 void SAL_CALL lock( ) override;
206 void SAL_CALL unlock( ) override;
207 sal_Bool SAL_CALL isLocked( ) override;
208 void SAL_CALL startPopupMode( const css::awt::Rectangle& WindowRect ) override;
209 sal_Bool SAL_CALL isInPopupMode( ) override;
210
211 // css::awt::XWindow2
212 void SAL_CALL setOutputSize( const css::awt::Size& aSize ) override;
213 css::awt::Size SAL_CALL getOutputSize( ) override;
214 sal_Bool SAL_CALL isVisible( ) override;
215 sal_Bool SAL_CALL isActive( ) override;
216 sal_Bool SAL_CALL isEnabled( ) override;
217 sal_Bool SAL_CALL hasFocus( ) override;
218
219 // css::beans::XPropertySetInfo
220 css::uno::Sequence< css::beans::Property > SAL_CALL getProperties( ) override;
221 css::beans::Property SAL_CALL getPropertyByName( const OUString& aName ) override;
222 sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) override;
223
224 // XStyleSettingsSupplier
225 virtual css::uno::Reference< css::awt::XStyleSettings > SAL_CALL getStyleSettings() override;
226};
227
228#endif // INCLUDED_TOOLKIT_AWT_VCLXWINDOW_HXX
229
230/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx

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#ifndef INCLUDED_VCL_PTR_HXX
21#define INCLUDED_VCL_PTR_HXX
22
23#include <sal/config.h>
24
25#include <rtl/ref.hxx>
26
27#include <utility>
28#include <type_traits>
29
30#ifdef DBG_UTIL
31#ifndef _WIN32
32#include <vcl/vclmain.hxx>
33#endif
34#endif
35
36class VclReferenceBase;
37
38namespace vcl::detail {
39
40template<typename>
41constexpr bool isIncompleteOrDerivedFromVclReferenceBase(...) { return true; }
42
43template<typename T> constexpr bool isIncompleteOrDerivedFromVclReferenceBase(
44 int (*)[sizeof(T)])
45{ return std::is_base_of<VclReferenceBase, T>::value; }
46
47} // namespace vcl::detail
48
49/**
50 * A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for references to vcl::Window subclasses.
51 *
52 * For more details on the design please see vcl/README.lifecycle
53 *
54 * @param reference_type must be a subclass of vcl::Window
55 */
56template <class reference_type>
57class VclPtr
58{
59 static_assert(
60 vcl::detail::isIncompleteOrDerivedFromVclReferenceBase<reference_type>(
61 nullptr),
62 "template argument type must be derived from VclReferenceBase");
63
64 ::rtl::Reference<reference_type> m_rInnerRef;
65
66public:
67 /** Constructor...
68 */
69 VclPtr()
70 : m_rInnerRef()
71 {}
72
73 /** Constructor...
74 */
75 VclPtr (reference_type * pBody)
76 : m_rInnerRef(pBody)
4
Calling constructor for 'Reference<vcl::Window>'
7
Returning from constructor for 'Reference<vcl::Window>'
77 {}
78
79 /** Constructor... that doesn't take a ref.
80 */
81 VclPtr (reference_type * pBody, __sal_NoAcquire)
82 : m_rInnerRef(pBody, SAL_NO_ACQUIRE)
83 {}
84
85 /** Up-casting conversion constructor: Copies interface reference.
86
87 Does not work for up-casts to ambiguous bases. For the special case of
88 up-casting to Reference< XInterface >, see the corresponding conversion
89 operator.
90
91 @param rRef another reference
92 */
93 template< class derived_type >
94 VclPtr(
95 const VclPtr< derived_type > & rRef,
96 typename std::enable_if<
97 std::is_base_of<reference_type, derived_type>::value, int>::type
98 = 0 )
99 : m_rInnerRef( static_cast<reference_type*>(rRef) )
100 {
101 }
102
103#if defined(DBG_UTIL) && !defined(_WIN32)
104 virtual ~VclPtr()
105 {
106 assert(m_rInnerRef.get() == nullptr || vclmain::isAlive())(static_cast <bool> (m_rInnerRef.get() == nullptr || vclmain
::isAlive()) ? void (0) : __assert_fail ("m_rInnerRef.get() == nullptr || vclmain::isAlive()"
, "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx"
, 106, __extension__ __PRETTY_FUNCTION__))
;
107 // We can be one of the intermediate counts, but if we are the last
108 // VclPtr keeping this object alive, then something forgot to call dispose().
109 assert((!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1)(static_cast <bool> ((!m_rInnerRef.get() || m_rInnerRef
->isDisposed() || m_rInnerRef->getRefCount() > 1) &&
"someone forgot to call dispose()") ? void (0) : __assert_fail
("(!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1) && \"someone forgot to call dispose()\""
, "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx"
, 110, __extension__ __PRETTY_FUNCTION__))
110 && "someone forgot to call dispose()")(static_cast <bool> ((!m_rInnerRef.get() || m_rInnerRef
->isDisposed() || m_rInnerRef->getRefCount() > 1) &&
"someone forgot to call dispose()") ? void (0) : __assert_fail
("(!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1) && \"someone forgot to call dispose()\""
, "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx"
, 110, __extension__ __PRETTY_FUNCTION__))
;
111 }
112 VclPtr(VclPtr const &) = default;
113 VclPtr(VclPtr &&) = default;
114 VclPtr & operator =(VclPtr const &) = default;
115 VclPtr & operator =(VclPtr &&) = default;
116#endif
117
118 /**
119 * A construction helper for VclPtr. Since VclPtr types are created
120 * with a reference-count of one - to help fit into the existing
121 * code-flow; this helps us to construct them easily.
122 *
123 * For more details on the design please see vcl/README.lifecycle
124 *
125 * @tparam reference_type must be a subclass of vcl::Window
126 */
127 template<typename... Arg> [[nodiscard]] static VclPtr< reference_type > Create(Arg &&... arg)
128 {
129 return VclPtr< reference_type >( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE );
130 }
131
132 /** Probably most common used: handle->someBodyOp().
133 */
134 reference_type * operator->() const
135 {
136 return m_rInnerRef.get();
137 }
138
139 /** Get the body. Can be used instead of operator->().
140 I.e. handle->someBodyOp() and handle.get()->someBodyOp()
141 are the same.
142 */
143 reference_type * get() const
144 {
145 return m_rInnerRef.get();
146 }
147
148 void set(reference_type *pBody)
149 {
150 m_rInnerRef.set(pBody);
151 }
152
153 void reset(reference_type *pBody)
154 {
155 m_rInnerRef.set(pBody);
156 }
157
158 /** Up-casting copy assignment operator.
159
160 Does not work for up-casts to ambiguous bases.
161
162 @param rRef another reference
163 */
164 template<typename derived_type>
165 typename std::enable_if<
166 std::is_base_of<reference_type, derived_type>::value,
167 VclPtr &>::type
168 operator =(VclPtr<derived_type> const & rRef)
169 {
170 m_rInnerRef.set(rRef.get());
171 return *this;
172 }
173
174 VclPtr & operator =(reference_type * pBody)
175 {
176 m_rInnerRef.set(pBody);
177 return *this;
178 }
179
180 operator reference_type * () const
181 {
182 return m_rInnerRef.get();
183 }
184
185 explicit operator bool () const
186 {
187 return m_rInnerRef.get() != nullptr;
188 }
189
190 void clear()
191 {
192 m_rInnerRef.clear();
193 }
194
195 void reset()
196 {
197 m_rInnerRef.clear();
198 }
199
200 void disposeAndClear()
201 {
202 // hold it alive for the lifetime of this method
203 ::rtl::Reference<reference_type> aTmp(m_rInnerRef);
204 m_rInnerRef.clear(); // we should use some 'swap' method ideally ;-)
205 if (aTmp.get()) {
206 aTmp->disposeOnce();
207 }
208 }
209
210 /** Needed to place VclPtr's into STL collection.
211 */
212 bool operator< (const VclPtr<reference_type> & handle) const
213 {
214 return (m_rInnerRef < handle.m_rInnerRef);
215 }
216}; // class VclPtr
217
218template<typename T1, typename T2>
219inline bool operator ==(VclPtr<T1> const & p1, VclPtr<T2> const & p2) {
220 return p1.get() == p2.get();
221}
222
223template<typename T> inline bool operator ==(VclPtr<T> const & p1, T const * p2)
224{
225 return p1.get() == p2;
226}
227
228template<typename T> inline bool operator ==(VclPtr<T> const & p1, T * p2) {
229 return p1.get() == p2;
230}
231
232template<typename T> inline bool operator ==(T const * p1, VclPtr<T> const & p2)
233{
234 return p1 == p2.get();
235}
236
237template<typename T> inline bool operator ==(T * p1, VclPtr<T> const & p2) {
238 return p1 == p2.get();
239}
240
241template<typename T1, typename T2>
242inline bool operator !=(VclPtr<T1> const & p1, VclPtr<T2> const & p2) {
243 return !(p1 == p2);
244}
245
246template<typename T> inline bool operator !=(VclPtr<T> const & p1, T const * p2)
247{
248 return !(p1 == p2);
249}
250
251template<typename T> inline bool operator !=(VclPtr<T> const & p1, T * p2) {
252 return !(p1 == p2);
253}
254
255template<typename T> inline bool operator !=(T const * p1, VclPtr<T> const & p2)
256{
257 return !(p1 == p2);
258}
259
260template<typename T> inline bool operator !=(T * p1, VclPtr<T> const & p2) {
261 return !(p1 == p2);
262}
263
264/**
265 * A construction helper for a temporary VclPtr. Since VclPtr types
266 * are created with a reference-count of one - to help fit into
267 * the existing code-flow; this helps us to construct them easily.
268 * see also VclPtr::Create and ScopedVclPtr
269 *
270 * For more details on the design please see vcl/README.lifecycle
271 *
272 * @param reference_type must be a subclass of vcl::Window
273 */
274template <class reference_type>
275class SAL_WARN_UNUSED__attribute__((warn_unused)) VclPtrInstance final : public VclPtr<reference_type>
276{
277public:
278 template<typename... Arg> VclPtrInstance(Arg &&... arg)
279 : VclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE )
280 {
281 }
282
283 /**
284 * Override and disallow this, to prevent people accidentally calling it and actually
285 * getting VclPtr::Create and getting a naked VclPtr<> instance
286 */
287 template<typename... Arg> static VclPtrInstance< reference_type > Create(Arg &&... ) = delete;
288};
289
290template <class reference_type>
291class ScopedVclPtr : public VclPtr<reference_type>
292{
293public:
294 /** Constructor...
295 */
296 ScopedVclPtr()
297 : VclPtr<reference_type>()
298 {}
299
300 /** Constructor
301 */
302 ScopedVclPtr (reference_type * pBody)
303 : VclPtr<reference_type>(pBody)
304 {}
305
306 /** Copy constructor...
307 */
308 ScopedVclPtr (const VclPtr<reference_type> & handle)
309 : VclPtr<reference_type>(handle)
310 {}
311
312 /**
313 Assignment that releases the last reference.
314 */
315 void disposeAndReset(reference_type *pBody)
316 {
317 if (pBody != this->get()) {
318 VclPtr<reference_type>::disposeAndClear();
319 VclPtr<reference_type>::set(pBody);
320 }
321 }
322
323 /**
324 Assignment that releases the last reference.
325 */
326 ScopedVclPtr<reference_type>& operator = (reference_type * pBody)
327 {
328 disposeAndReset(pBody);
329 return *this;
330 }
331
332 /** Up-casting conversion constructor: Copies interface reference.
333
334 Does not work for up-casts to ambiguous bases. For the special case of
335 up-casting to Reference< XInterface >, see the corresponding conversion
336 operator.
337
338 @param rRef another reference
339 */
340 template< class derived_type >
341 ScopedVclPtr(
342 const VclPtr< derived_type > & rRef,
343 typename std::enable_if<
344 std::is_base_of<reference_type, derived_type>::value, int>::type
345 = 0 )
346 : VclPtr<reference_type>( rRef )
347 {
348 }
349
350 /** Up-casting assignment operator.
351
352 Does not work for up-casts to ambiguous bases.
353
354 @param rRef another VclPtr
355 */
356 template<typename derived_type>
357 typename std::enable_if<
358 std::is_base_of<reference_type, derived_type>::value,
359 ScopedVclPtr &>::type
360 operator =(VclPtr<derived_type> const & rRef)
361 {
362 disposeAndReset(rRef.get());
363 return *this;
364 }
365
366 /**
367 * Override and disallow this, to prevent people accidentally calling it and actually
368 * getting VclPtr::Create and getting a naked VclPtr<> instance
369 */
370 template<typename... Arg> static ScopedVclPtr< reference_type > Create(Arg &&... ) = delete;
371
372 ~ScopedVclPtr()
373 {
374 VclPtr<reference_type>::disposeAndClear();
375 assert(VclPtr<reference_type>::get() == nullptr)(static_cast <bool> (VclPtr<reference_type>::get(
) == nullptr) ? void (0) : __assert_fail ("VclPtr<reference_type>::get() == nullptr"
, "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx"
, 375, __extension__ __PRETTY_FUNCTION__))
; // make sure there are no lingering references
376 }
377
378private:
379 // Most likely we don't want this default copy-constructor.
380 ScopedVclPtr (const ScopedVclPtr<reference_type> &) = delete;
381 // And certainly we don't want a default assignment operator.
382 ScopedVclPtr<reference_type>& operator = (const ScopedVclPtr<reference_type> &) = delete;
383 // And disallow reset as that doesn't call disposeAndClear on the original reference
384 void reset() = delete;
385 void reset(reference_type *pBody) = delete;
386
387protected:
388 ScopedVclPtr (reference_type * pBody, __sal_NoAcquire)
389 : VclPtr<reference_type>(pBody, SAL_NO_ACQUIRE)
390 {}
391};
392
393/**
394 * A construction helper for ScopedVclPtr. Since VclPtr types are created
395 * with a reference-count of one - to help fit into the existing
396 * code-flow; this helps us to construct them easily.
397 *
398 * For more details on the design please see vcl/README.lifecycle
399 *
400 * @param reference_type must be a subclass of vcl::Window
401 */
402#if defined _MSC_VER
403#pragma warning(push)
404#pragma warning(disable: 4521) // " multiple copy constructors specified"
405#endif
406template <class reference_type>
407class SAL_WARN_UNUSED__attribute__((warn_unused)) ScopedVclPtrInstance final : public ScopedVclPtr<reference_type>
408{
409public:
410 template<typename... Arg> ScopedVclPtrInstance(Arg &&... arg)
411 : ScopedVclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE )
412 {
413 }
414
415 /**
416 * Override and disallow this, to prevent people accidentally calling it and actually
417 * getting VclPtr::Create and getting a naked VclPtr<> instance
418 */
419 template<typename... Arg> static ScopedVclPtrInstance< reference_type > Create(Arg &&...) = delete;
420
421private:
422 // Prevent the above perfect forwarding ctor from hijacking (accidental)
423 // attempts at ScopedVclPtrInstance copy construction (where the hijacking
424 // would typically lead to somewhat obscure error messages); both non-const
425 // and const variants are needed here, as the ScopedVclPtr base class has a
426 // const--variant copy ctor, so the implicitly declared copy ctor for
427 // ScopedVclPtrInstance would also be the const variant, so non-const copy
428 // construction attempts would be hijacked by the perfect forwarding ctor;
429 // but if we only declared a non-const variant here, the const variant would
430 // no longer be implicitly declared (as there would already be an explicitly
431 // declared copy ctor), so const copy construction attempts would then be
432 // hijacked by the perfect forwarding ctor:
433 ScopedVclPtrInstance(ScopedVclPtrInstance &) = delete;
434 ScopedVclPtrInstance(ScopedVclPtrInstance const &) = delete;
435};
436#if defined _MSC_VER
437#pragma warning(pop)
438#endif
439
440#endif // INCLUDED_VCL_PTR_HXX
441
442/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/home/maarten/src/libreoffice/core/include/rtl/ref.hxx

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#ifndef INCLUDED_RTL_REF_HXX
21#define INCLUDED_RTL_REF_HXX
22
23#include "sal/config.h"
24
25#include <cassert>
26#include <cstddef>
27#include <functional>
28#ifdef LIBO_INTERNAL_ONLY1
29#include <type_traits>
30#endif
31
32#include "sal/types.h"
33
34namespace rtl
35{
36
37/** Template reference class for reference type.
38*/
39template <class reference_type>
40class Reference
41{
42 /** The <b>reference_type</b> body pointer.
43 */
44 reference_type * m_pBody;
45
46
47public:
48 /** Constructor...
49 */
50 Reference()
51 : m_pBody (NULL__null)
52 {}
53
54
55 /** Constructor...
56 */
57 Reference (reference_type * pBody, __sal_NoAcquire)
58 : m_pBody (pBody)
59 {
60 }
61
62 /** Constructor...
63 */
64 Reference (reference_type * pBody)
65 : m_pBody (pBody)
66 {
67 if (m_pBody)
5
Assuming field 'm_pBody' is non-null
6
Taking true branch
68 m_pBody->acquire();
69 }
70
71 /** Copy constructor...
72 */
73 Reference (const Reference<reference_type> & handle)
74 : m_pBody (handle.m_pBody)
75 {
76 if (m_pBody)
77 m_pBody->acquire();
78 }
79
80#ifdef LIBO_INTERNAL_ONLY1
81 /** Move constructor...
82 */
83 Reference (Reference<reference_type> && handle) noexcept
84 : m_pBody (handle.m_pBody)
85 {
86 handle.m_pBody = nullptr;
87 }
88#endif
89
90#if defined LIBO_INTERNAL_ONLY1
91 /** Up-casting conversion constructor: Copies interface reference.
92
93 Does not work for up-casts to ambiguous bases.
94
95 @param rRef another reference
96 */
97 template< class derived_type >
98 inline Reference(
99 const Reference< derived_type > & rRef,
100 std::enable_if_t<std::is_base_of_v<reference_type, derived_type>, int> = 0 )
101 : m_pBody (rRef.get())
102 {
103 if (m_pBody)
104 m_pBody->acquire();
105 }
106#endif
107
108 /** Destructor...
109 */
110 ~Reference() COVERITY_NOEXCEPT_FALSE
111 {
112 if (m_pBody
13.1
Field 'm_pBody' is non-null
23.1
Field 'm_pBody' is non-null
13.1
Field 'm_pBody' is non-null
23.1
Field 'm_pBody' is non-null
13.1
Field 'm_pBody' is non-null
23.1
Field 'm_pBody' is non-null
13.1
Field 'm_pBody' is non-null
23.1
Field 'm_pBody' is non-null
13.1
Field 'm_pBody' is non-null
23.1
Field 'm_pBody' is non-null
)
14
Taking true branch
24
Taking true branch
113 m_pBody->release();
15
Calling 'VclReferenceBase::release'
19
Returning; memory was released
25
Use of memory after it is freed
114 }
115
116 /** Set...
117 Similar to assignment.
118 */
119 Reference<reference_type> &
120 SAL_CALL set (reference_type * pBody)
121 {
122 if (pBody)
123 pBody->acquire();
124 reference_type * const pOld = m_pBody;
125 m_pBody = pBody;
126 if (pOld)
127 pOld->release();
128 return *this;
129 }
130
131 /** Assignment.
132 Unbinds this instance from its body (if bound) and
133 bind it to the body represented by the handle.
134 */
135 Reference<reference_type> &
136 SAL_CALL operator= (const Reference<reference_type> & handle)
137 {
138 return set( handle.m_pBody );
139 }
140
141#ifdef LIBO_INTERNAL_ONLY1
142 /** Assignment.
143 * Unbinds this instance from its body (if bound),
144 * bind it to the body represented by the handle, and
145 * set the body represented by the handle to nullptr.
146 */
147 Reference<reference_type> &
148 operator= (Reference<reference_type> && handle)
149 {
150 // self-movement guts ourself
151 if (m_pBody)
152 m_pBody->release();
153 m_pBody = handle.m_pBody;
154 handle.m_pBody = nullptr;
155 return *this;
156 }
157#endif
158
159 /** Assignment...
160 */
161 Reference<reference_type> &
162 SAL_CALL operator= (reference_type * pBody)
163 {
164 return set( pBody );
165 }
166
167 /** Unbind the body from this handle.
168 Note that for a handle representing a large body,
169 "handle.clear().set(new body());" _might_
170 perform a little bit better than "handle.set(new body());",
171 since in the second case two large objects exist in memory
172 (the old body and the new body).
173 */
174 Reference<reference_type> & SAL_CALL clear()
175 {
176 if (m_pBody)
177 {
178 reference_type * const pOld = m_pBody;
179 m_pBody = NULL__null;
180 pOld->release();
181 }
182 return *this;
183 }
184
185
186 /** Get the body. Can be used instead of operator->().
187 I.e. handle->someBodyOp() and handle.get()->someBodyOp()
188 are the same.
189 */
190 reference_type * SAL_CALL get() const
191 {
192 return m_pBody;
193 }
194
195
196 /** Probably most common used: handle->someBodyOp().
197 */
198 reference_type * SAL_CALL operator->() const
199 {
200 assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail
("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx"
, 200, __extension__ __PRETTY_FUNCTION__))
;
201 return m_pBody;
202 }
203
204
205 /** Allows (*handle).someBodyOp().
206 */
207 reference_type & SAL_CALL operator*() const
208 {
209 assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail
("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx"
, 209, __extension__ __PRETTY_FUNCTION__))
;
210 return *m_pBody;
211 }
212
213
214 /** Returns True if the handle does point to a valid body.
215 */
216 bool SAL_CALL is() const
217 {
218 return (m_pBody != NULL__null);
219 }
220
221#if defined LIBO_INTERNAL_ONLY1
222 /** Returns True if the handle does point to a valid body.
223 */
224 explicit operator bool() const
225 {
226 return is();
227 }
228#endif
229
230 /** Returns True if this points to pBody.
231 */
232 bool SAL_CALL operator== (const reference_type * pBody) const
233 {
234 return (m_pBody == pBody);
235 }
236
237
238 /** Returns True if handle points to the same body.
239 */
240 bool
241 SAL_CALL operator== (const Reference<reference_type> & handle) const
242 {
243 return (m_pBody == handle.m_pBody);
244 }
245
246
247 /** Needed to place References into STL collection.
248 */
249 bool
250 SAL_CALL operator!= (const Reference<reference_type> & handle) const
251 {
252 return (m_pBody != handle.m_pBody);
253 }
254
255
256 /** Needed to place References into STL collection.
257 */
258 bool
259 SAL_CALL operator< (const Reference<reference_type> & handle) const
260 {
261 return (m_pBody < handle.m_pBody);
262 }
263
264
265 /** Needed to place References into STL collection.
266 */
267 bool
268 SAL_CALL operator> (const Reference<reference_type> & handle) const
269 {
270 return (m_pBody > handle.m_pBody);
271 }
272};
273
274} // namespace rtl
275
276#if defined LIBO_INTERNAL_ONLY1
277namespace std
278{
279
280/// @cond INTERNAL
281/**
282 Make rtl::Reference hashable by default for use in STL containers.
283
284 @since LibreOffice 6.3
285*/
286template<typename T>
287struct hash<::rtl::Reference<T>>
288{
289 std::size_t operator()(::rtl::Reference<T> const & s) const
290 { return std::size_t(s.get()); }
291};
292/// @endcond
293
294}
295
296#endif
297
298#endif /* ! INCLUDED_RTL_REF_HXX */
299
300/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/home/maarten/src/libreoffice/core/include/vcl/vclreferencebase.hxx

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#ifndef INCLUDED_VCL_Reference_HXX
20#define INCLUDED_VCL_Reference_HXX
21
22#include <vcl/dllapi.h>
23#include <osl/interlck.h>
24
25class VCL_DLLPUBLIC__attribute__ ((visibility("default"))) VclReferenceBase
26{
27 mutable oslInterlockedCount mnRefCnt;
28
29 template<typename T> friend class VclPtr;
30
31public:
32 void acquire() const
33 {
34 osl_atomic_increment(&mnRefCnt)__sync_add_and_fetch((&mnRefCnt), 1);
35 }
36
37 void release() const
38 {
39 if (osl_atomic_decrement(&mnRefCnt)__sync_sub_and_fetch((&mnRefCnt), 1) == 0)
16
Assuming the condition is true
17
Taking true branch
40 delete this;
18
Memory is released
41 }
42#ifdef DBG_UTIL
43#ifndef _WIN32
44 sal_Int32 getRefCount() const { return mnRefCnt; }
45#endif
46#endif
47
48
49private:
50 VclReferenceBase(const VclReferenceBase&) = delete;
51 VclReferenceBase& operator=(const VclReferenceBase&) = delete;
52
53 bool mbDisposed : 1;
54
55protected:
56 VclReferenceBase();
57protected:
58 virtual ~VclReferenceBase();
59
60protected:
61 virtual void dispose();
62
63public:
64 void disposeOnce();
65 bool isDisposed() const { return mbDisposed; }
66
67};
68#endif