Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include <com/sun/star/awt/WindowEvent.hpp>
22 : #include <com/sun/star/awt/KeyEvent.hpp>
23 : #include <com/sun/star/awt/KeyModifier.hpp>
24 : #include <com/sun/star/awt/MouseEvent.hpp>
25 : #include <com/sun/star/awt/MouseButton.hpp>
26 : #include <com/sun/star/awt/MouseWheelBehavior.hpp>
27 : #include <com/sun/star/awt/XTopWindow.hpp>
28 : #include <com/sun/star/awt/Style.hpp>
29 : #include <com/sun/star/accessibility/AccessibleRole.hpp>
30 : #include <com/sun/star/awt/DockingEvent.hpp>
31 : #include <com/sun/star/awt/EndDockingEvent.hpp>
32 : #include <com/sun/star/awt/EndPopupModeEvent.hpp>
33 : #include <com/sun/star/awt/XWindowListener2.hpp>
34 : #include <com/sun/star/style/VerticalAlignment.hpp>
35 : #include <com/sun/star/lang/DisposedException.hpp>
36 : #include <com/sun/star/text/WritingMode2.hpp>
37 : #include <toolkit/awt/vclxwindow.hxx>
38 : #include <toolkit/awt/vclxpointer.hxx>
39 : #include <toolkit/awt/vclxwindows.hxx>
40 : #include <toolkit/helper/macros.hxx>
41 : #include <toolkit/helper/vclunohelper.hxx>
42 : #include <toolkit/helper/convert.hxx>
43 : #include <toolkit/helper/property.hxx>
44 : #include <toolkit/helper/accessibilityclient.hxx>
45 : #include <cppuhelper/typeprovider.hxx>
46 : #include <rtl/uuid.h>
47 : #include <rtl/ustrbuf.hxx>
48 : #include <vcl/svapp.hxx>
49 : #include <vcl/window.hxx>
50 : #include <tools/color.hxx>
51 : #include <vcl/dockwin.hxx>
52 : #include <vcl/pdfextoutdevdata.hxx>
53 : #include <vcl/tabpage.hxx>
54 : #include <vcl/button.hxx>
55 : #include <vcl/settings.hxx>
56 : #include <comphelper/asyncnotification.hxx>
57 : #include <comphelper/flagguard.hxx>
58 : #include "stylesettings.hxx"
59 : #include <tools/urlobj.hxx>
60 : #include <toolkit/helper/unopropertyarrayhelper.hxx>
61 :
62 : #include <boost/bind.hpp>
63 : #include <boost/noncopyable.hpp>
64 :
65 : using namespace ::com::sun::star;
66 :
67 : using ::com::sun::star::uno::Reference;
68 : using ::com::sun::star::uno::UNO_QUERY;
69 : using ::com::sun::star::uno::RuntimeException;
70 : using ::com::sun::star::lang::EventObject;
71 : using ::com::sun::star::awt::XWindowListener2;
72 : using ::com::sun::star::awt::XDockableWindowListener;
73 : using ::com::sun::star::awt::XDevice;
74 : using ::com::sun::star::awt::XStyleSettings;
75 : using ::com::sun::star::lang::DisposedException;
76 : using ::com::sun::star::style::VerticalAlignment;
77 : using ::com::sun::star::style::VerticalAlignment_TOP;
78 : using ::com::sun::star::style::VerticalAlignment_MIDDLE;
79 : using ::com::sun::star::style::VerticalAlignment_BOTTOM;
80 : using ::com::sun::star::style::VerticalAlignment_MAKE_FIXED_SIZE;
81 :
82 : namespace WritingMode2 = ::com::sun::star::text::WritingMode2;
83 : namespace MouseWheelBehavior = ::com::sun::star::awt::MouseWheelBehavior;
84 :
85 :
86 : //= VCLXWindowImpl
87 :
88 : class VCLXWindowImpl: private boost::noncopyable
89 : {
90 : private:
91 : typedef ::std::vector< VCLXWindow::Callback > CallbackArray;
92 :
93 : private:
94 : VCLXWindow& mrAntiImpl;
95 : ::toolkit::AccessibilityClient maAccFactory;
96 : bool mbDisposed;
97 : bool mbDrawingOntoParent; // no bit mask, is passed around by reference
98 : bool mbEnableVisible;
99 : bool mbDirectVisible;
100 :
101 : ::osl::Mutex maListenerContainerMutex;
102 : ::cppu::OInterfaceContainerHelper maWindow2Listeners;
103 : ::cppu::OInterfaceContainerHelper maDockableWindowListeners;
104 : EventListenerMultiplexer maEventListeners;
105 : FocusListenerMultiplexer maFocusListeners;
106 : WindowListenerMultiplexer maWindowListeners;
107 : KeyListenerMultiplexer maKeyListeners;
108 : MouseListenerMultiplexer maMouseListeners;
109 : MouseMotionListenerMultiplexer maMouseMotionListeners;
110 : PaintListenerMultiplexer maPaintListeners;
111 : VclContainerListenerMultiplexer maContainerListeners;
112 : TopWindowListenerMultiplexer maTopWindowListeners;
113 :
114 : CallbackArray maCallbackEvents;
115 : sal_uLong mnCallbackEventId;
116 :
117 : public:
118 : bool mbDisposing : 1;
119 : bool mbDesignMode : 1;
120 : bool mbSynthesizingVCLEvent : 1;
121 : bool mbWithDefaultProps : 1;
122 :
123 : sal_uLong mnListenerLockLevel;
124 : sal_Int16 mnWritingMode;
125 : sal_Int16 mnContextWritingMode;
126 :
127 : UnoPropertyArrayHelper* mpPropHelper;
128 :
129 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPointer >
130 : mxPointer;
131 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
132 : mxAccessibleContext;
133 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >
134 : mxViewGraphics;
135 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XStyleSettings >
136 : mxWindowStyleSettings;
137 :
138 : public:
139 0 : bool& getDrawingOntoParent_ref() { return mbDrawingOntoParent; }
140 :
141 : public:
142 : /** ctor
143 : @param _pAntiImpl
144 : the <type>VCLXWindow</type> instance which the object belongs to. Must
145 : live longer then the object just being constructed.
146 : */
147 : VCLXWindowImpl( VCLXWindow& _rAntiImpl, bool _bWithDefaultProps );
148 :
149 : /** synchronously mbEnableVisible
150 : */
151 0 : void setEnableVisible( bool bEnableVisible ) { mbEnableVisible = bEnableVisible; }
152 0 : bool isEnableVisible() { return mbEnableVisible; }
153 : /** synchronously mbDirectVisible;
154 : */
155 0 : void setDirectVisible( bool bDirectVisible ) { mbDirectVisible = bDirectVisible; }
156 0 : bool isDirectVisible() { return mbDirectVisible; }
157 :
158 : /** impl-version of VCLXWindow::ImplExecuteAsyncWithoutSolarLock
159 : */
160 : void callBackAsync( const VCLXWindow::Callback& i_callback );
161 :
162 : /** notifies the object that its VCLXWindow is being disposed
163 : */
164 : void disposing();
165 :
166 0 : inline ::toolkit::AccessibilityClient& getAccessibleFactory()
167 : {
168 0 : return maAccFactory;
169 : }
170 :
171 : Reference< XStyleSettings > getStyleSettings();
172 :
173 : /** returns the container of registered XWindowListener2 listeners
174 : */
175 0 : inline ::cppu::OInterfaceContainerHelper& getWindow2Listeners() { return maWindow2Listeners; }
176 0 : inline ::cppu::OInterfaceContainerHelper& getDockableWindowListeners(){ return maDockableWindowListeners; }
177 0 : inline EventListenerMultiplexer& getEventListeners() { return maEventListeners; }
178 0 : inline FocusListenerMultiplexer& getFocusListeners() { return maFocusListeners; }
179 0 : inline WindowListenerMultiplexer& getWindowListeners() { return maWindowListeners; }
180 0 : inline KeyListenerMultiplexer& getKeyListeners() { return maKeyListeners; }
181 0 : inline MouseListenerMultiplexer& getMouseListeners() { return maMouseListeners; }
182 0 : inline MouseMotionListenerMultiplexer& getMouseMotionListeners() { return maMouseMotionListeners; }
183 0 : inline PaintListenerMultiplexer& getPaintListeners() { return maPaintListeners; }
184 0 : inline VclContainerListenerMultiplexer& getContainerListeners() { return maContainerListeners; }
185 0 : inline TopWindowListenerMultiplexer& getTopWindowListeners() { return maTopWindowListeners; }
186 :
187 : ~VCLXWindowImpl();
188 :
189 : private:
190 : DECL_LINK( OnProcessCallbacks, void* );
191 : };
192 :
193 :
194 0 : VCLXWindowImpl::VCLXWindowImpl( VCLXWindow& _rAntiImpl, bool _bWithDefaultProps )
195 : :mrAntiImpl( _rAntiImpl )
196 : ,mbDisposed( false )
197 : ,mbDrawingOntoParent( false )
198 : ,mbEnableVisible(true)
199 : ,mbDirectVisible(true)
200 : ,maListenerContainerMutex( )
201 : ,maWindow2Listeners( maListenerContainerMutex )
202 : ,maDockableWindowListeners( maListenerContainerMutex )
203 : ,maEventListeners( _rAntiImpl )
204 : ,maFocusListeners( _rAntiImpl )
205 : ,maWindowListeners( _rAntiImpl )
206 : ,maKeyListeners( _rAntiImpl )
207 : ,maMouseListeners( _rAntiImpl )
208 : ,maMouseMotionListeners( _rAntiImpl )
209 : ,maPaintListeners( _rAntiImpl )
210 : ,maContainerListeners( _rAntiImpl )
211 : ,maTopWindowListeners( _rAntiImpl )
212 : ,mnCallbackEventId( 0 )
213 : ,mbDisposing( false )
214 : ,mbDesignMode( false )
215 : ,mbSynthesizingVCLEvent( false )
216 : ,mbWithDefaultProps( _bWithDefaultProps )
217 : ,mnListenerLockLevel( 0 )
218 : ,mnWritingMode( WritingMode2::CONTEXT )
219 : ,mnContextWritingMode( WritingMode2::CONTEXT )
220 0 : ,mpPropHelper( NULL )
221 : {
222 0 : }
223 :
224 0 : VCLXWindowImpl::~VCLXWindowImpl()
225 : {
226 0 : delete mpPropHelper;
227 0 : }
228 :
229 :
230 0 : void VCLXWindowImpl::disposing()
231 : {
232 0 : SolarMutexGuard aGuard;
233 0 : if ( mnCallbackEventId )
234 0 : Application::RemoveUserEvent( mnCallbackEventId );
235 0 : mnCallbackEventId = 0;
236 :
237 0 : mbDisposed= true;
238 :
239 0 : ::com::sun::star::lang::EventObject aEvent;
240 0 : aEvent.Source = mrAntiImpl;
241 :
242 0 : maDockableWindowListeners.disposeAndClear( aEvent );
243 0 : maEventListeners.disposeAndClear( aEvent );
244 0 : maFocusListeners.disposeAndClear( aEvent );
245 0 : maWindowListeners.disposeAndClear( aEvent );
246 0 : maKeyListeners.disposeAndClear( aEvent );
247 0 : maMouseListeners.disposeAndClear( aEvent );
248 0 : maMouseMotionListeners.disposeAndClear( aEvent );
249 0 : maPaintListeners.disposeAndClear( aEvent );
250 0 : maContainerListeners.disposeAndClear( aEvent );
251 0 : maTopWindowListeners.disposeAndClear( aEvent );
252 :
253 0 : ::toolkit::WindowStyleSettings* pStyleSettings = static_cast< ::toolkit::WindowStyleSettings* >( mxWindowStyleSettings.get() );
254 0 : if ( pStyleSettings != NULL )
255 0 : pStyleSettings->dispose();
256 0 : mxWindowStyleSettings.clear();
257 0 : }
258 :
259 :
260 0 : void VCLXWindowImpl::callBackAsync( const VCLXWindow::Callback& i_callback )
261 : {
262 : DBG_TESTSOLARMUTEX();
263 0 : maCallbackEvents.push_back( i_callback );
264 0 : if ( !mnCallbackEventId )
265 : {
266 : // ensure our VCLXWindow is not destroyed while the event is underway
267 0 : mrAntiImpl.acquire();
268 0 : mnCallbackEventId = Application::PostUserEvent( LINK( this, VCLXWindowImpl, OnProcessCallbacks ) );
269 : }
270 0 : }
271 :
272 :
273 0 : IMPL_LINK_NOARG(VCLXWindowImpl, OnProcessCallbacks)
274 : {
275 0 : const Reference< uno::XInterface > xKeepAlive( mrAntiImpl );
276 :
277 : // work on a copy of the callback array
278 0 : CallbackArray aCallbacksCopy;
279 : {
280 0 : SolarMutexGuard aGuard;
281 0 : aCallbacksCopy = maCallbackEvents;
282 0 : maCallbackEvents.clear();
283 :
284 : // we acquired our VCLXWindow once before posting the event, release this one ref now
285 0 : mrAntiImpl.release();
286 :
287 0 : if ( !mnCallbackEventId )
288 : // we were disposed while waiting for the mutex to lock
289 0 : return 1L;
290 :
291 0 : mnCallbackEventId = 0;
292 : }
293 :
294 : {
295 0 : SolarMutexReleaser aReleaseSolar;
296 0 : for ( CallbackArray::const_iterator loop = aCallbacksCopy.begin();
297 0 : loop != aCallbacksCopy.end();
298 : ++loop
299 : )
300 : {
301 0 : (*loop)();
302 0 : }
303 : }
304 :
305 0 : return 0L;
306 : }
307 :
308 0 : Reference< XStyleSettings > VCLXWindowImpl::getStyleSettings()
309 : {
310 0 : SolarMutexGuard aGuard;
311 0 : if ( mbDisposed )
312 0 : throw DisposedException( OUString(), mrAntiImpl );
313 0 : if ( !mxWindowStyleSettings.is() )
314 0 : mxWindowStyleSettings = new ::toolkit::WindowStyleSettings( maListenerContainerMutex, mrAntiImpl );
315 0 : return mxWindowStyleSettings;
316 : }
317 :
318 :
319 :
320 :
321 : // Uses an out-parameter instead of return value, due to the object reference
322 :
323 0 : void ImplInitWindowEvent( ::com::sun::star::awt::WindowEvent& rEvent, Window* pWindow )
324 : {
325 0 : Point aPos = pWindow->GetPosPixel();
326 0 : Size aSz = pWindow->GetSizePixel();
327 :
328 0 : rEvent.X = aPos.X();
329 0 : rEvent.Y = aPos.Y();
330 :
331 0 : rEvent.Width = aSz.Width();
332 0 : rEvent.Height = aSz.Height();
333 :
334 0 : pWindow->GetBorder( rEvent.LeftInset, rEvent.TopInset, rEvent.RightInset, rEvent.BottomInset );
335 0 : }
336 :
337 0 : VCLXWindow::VCLXWindow( bool _bWithDefaultProps )
338 0 : :mpImpl( NULL )
339 : {
340 0 : mpImpl = new VCLXWindowImpl( *this, _bWithDefaultProps );
341 0 : }
342 :
343 0 : VCLXWindow::~VCLXWindow()
344 : {
345 0 : delete mpImpl;
346 :
347 0 : if ( GetWindow() )
348 : {
349 0 : GetWindow()->RemoveEventListener( LINK( this, VCLXWindow, WindowEventListener ) );
350 0 : GetWindow()->SetWindowPeer( NULL, NULL );
351 0 : GetWindow()->SetAccessible( NULL );
352 : }
353 0 : }
354 :
355 :
356 0 : void VCLXWindow::ImplExecuteAsyncWithoutSolarLock( const Callback& i_callback )
357 : {
358 0 : mpImpl->callBackAsync( i_callback );
359 0 : }
360 :
361 :
362 0 : ::toolkit::IAccessibleFactory& VCLXWindow::getAccessibleFactory()
363 : {
364 0 : return mpImpl->getAccessibleFactory().getFactory();
365 : }
366 :
367 0 : void VCLXWindow::SetWindow( Window* pWindow )
368 : {
369 0 : if ( GetWindow() )
370 : {
371 0 : GetWindow()->RemoveEventListener( LINK( this, VCLXWindow, WindowEventListener ) );
372 : // GetWindow()->DbgAssertNoEventListeners();
373 : }
374 :
375 0 : SetOutputDevice( pWindow );
376 :
377 0 : if ( GetWindow() )
378 : {
379 0 : GetWindow()->AddEventListener( LINK( this, VCLXWindow, WindowEventListener ) );
380 0 : bool bDirectVisible = pWindow ? pWindow->IsVisible() : false;
381 0 : mpImpl->setDirectVisible( bDirectVisible );
382 : }
383 0 : }
384 :
385 0 : void VCLXWindow::suspendVclEventListening( )
386 : {
387 0 : ++mpImpl->mnListenerLockLevel;
388 0 : }
389 :
390 0 : void VCLXWindow::resumeVclEventListening( )
391 : {
392 : DBG_ASSERT( mpImpl->mnListenerLockLevel, "VCLXWindow::resumeVclEventListening: not suspended!" );
393 0 : --mpImpl->mnListenerLockLevel;
394 0 : }
395 :
396 0 : void VCLXWindow::notifyWindowRemoved( Window& _rWindow )
397 : {
398 0 : if ( mpImpl->getContainerListeners().getLength() )
399 : {
400 0 : awt::VclContainerEvent aEvent;
401 0 : aEvent.Source = *this;
402 0 : aEvent.Child = static_cast< XWindow* >( _rWindow.GetWindowPeer() );
403 0 : mpImpl->getContainerListeners().windowRemoved( aEvent );
404 : }
405 0 : }
406 :
407 0 : IMPL_LINK( VCLXWindow, WindowEventListener, VclSimpleEvent*, pEvent )
408 : {
409 0 : if ( mpImpl->mnListenerLockLevel )
410 0 : return 0L;
411 :
412 : DBG_ASSERT( pEvent && pEvent->ISA( VclWindowEvent ), "Unknown WindowEvent!" );
413 0 : if ( pEvent && pEvent->ISA( VclWindowEvent ) )
414 : {
415 : DBG_ASSERT( ((VclWindowEvent*)pEvent)->GetWindow() && GetWindow(), "Window???" );
416 0 : ProcessWindowEvent( *(VclWindowEvent*)pEvent );
417 : }
418 0 : return 0;
419 : }
420 :
421 : namespace
422 : {
423 0 : struct CallWindow2Listener
424 : {
425 0 : CallWindow2Listener( ::cppu::OInterfaceContainerHelper& i_rWindow2Listeners, const bool i_bEnabled, const EventObject& i_rEvent )
426 : :m_rWindow2Listeners( i_rWindow2Listeners )
427 : ,m_bEnabled( i_bEnabled )
428 0 : ,m_aEvent( i_rEvent )
429 : {
430 0 : }
431 :
432 0 : void operator()()
433 : {
434 0 : m_rWindow2Listeners.notifyEach( m_bEnabled ? &XWindowListener2::windowEnabled : &XWindowListener2::windowDisabled, m_aEvent );
435 0 : }
436 :
437 : ::cppu::OInterfaceContainerHelper& m_rWindow2Listeners;
438 : const bool m_bEnabled;
439 : const EventObject m_aEvent;
440 : };
441 : }
442 :
443 0 : void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
444 : {
445 0 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xThis( (::cppu::OWeakObject*)this );
446 :
447 0 : switch ( rVclWindowEvent.GetId() )
448 : {
449 : case VCLEVENT_WINDOW_ENABLED:
450 : case VCLEVENT_WINDOW_DISABLED:
451 : {
452 : Callback aCallback = CallWindow2Listener(
453 0 : mpImpl->getWindow2Listeners(),
454 0 : ( VCLEVENT_WINDOW_ENABLED == rVclWindowEvent.GetId() ),
455 : EventObject( *this )
456 0 : );
457 0 : ImplExecuteAsyncWithoutSolarLock( aCallback );
458 : }
459 0 : break;
460 :
461 : case VCLEVENT_WINDOW_PAINT:
462 : {
463 0 : if ( mpImpl->getPaintListeners().getLength() )
464 : {
465 0 : ::com::sun::star::awt::PaintEvent aEvent;
466 0 : aEvent.Source = (::cppu::OWeakObject*)this;
467 0 : aEvent.UpdateRect = AWTRectangle( *(Rectangle*)rVclWindowEvent.GetData() );
468 0 : aEvent.Count = 0;
469 0 : mpImpl->getPaintListeners().windowPaint( aEvent );
470 : }
471 : }
472 0 : break;
473 : case VCLEVENT_WINDOW_MOVE:
474 : {
475 0 : if ( mpImpl->getWindowListeners().getLength() )
476 : {
477 0 : ::com::sun::star::awt::WindowEvent aEvent;
478 0 : aEvent.Source = (::cppu::OWeakObject*)this;
479 0 : ImplInitWindowEvent( aEvent, rVclWindowEvent.GetWindow() );
480 0 : mpImpl->getWindowListeners().windowMoved( aEvent );
481 : }
482 : }
483 0 : break;
484 : case VCLEVENT_WINDOW_RESIZE:
485 : {
486 0 : if ( mpImpl->getWindowListeners().getLength() )
487 : {
488 0 : ::com::sun::star::awt::WindowEvent aEvent;
489 0 : aEvent.Source = (::cppu::OWeakObject*)this;
490 0 : ImplInitWindowEvent( aEvent, rVclWindowEvent.GetWindow() );
491 0 : mpImpl->getWindowListeners().windowResized( aEvent );
492 : }
493 : }
494 0 : break;
495 : case VCLEVENT_WINDOW_SHOW:
496 : {
497 0 : if ( mpImpl->getWindowListeners().getLength() )
498 : {
499 0 : ::com::sun::star::awt::WindowEvent aEvent;
500 0 : aEvent.Source = (::cppu::OWeakObject*)this;
501 0 : ImplInitWindowEvent( aEvent, rVclWindowEvent.GetWindow() );
502 0 : mpImpl->getWindowListeners().windowShown( aEvent );
503 : }
504 :
505 : // For TopWindows this means opened...
506 0 : if ( mpImpl->getTopWindowListeners().getLength() )
507 : {
508 0 : ::com::sun::star::lang::EventObject aEvent;
509 0 : aEvent.Source = (::cppu::OWeakObject*)this;
510 0 : mpImpl->getTopWindowListeners().windowOpened( aEvent );
511 : }
512 : }
513 0 : break;
514 : case VCLEVENT_WINDOW_HIDE:
515 : {
516 0 : if ( mpImpl->getWindowListeners().getLength() )
517 : {
518 0 : ::com::sun::star::awt::WindowEvent aEvent;
519 0 : aEvent.Source = (::cppu::OWeakObject*)this;
520 0 : ImplInitWindowEvent( aEvent, rVclWindowEvent.GetWindow() );
521 0 : mpImpl->getWindowListeners().windowHidden( aEvent );
522 : }
523 :
524 : // For TopWindows this means closed...
525 0 : if ( mpImpl->getTopWindowListeners().getLength() )
526 : {
527 0 : ::com::sun::star::lang::EventObject aEvent;
528 0 : aEvent.Source = (::cppu::OWeakObject*)this;
529 0 : mpImpl->getTopWindowListeners().windowClosed( aEvent );
530 : }
531 : }
532 0 : break;
533 : case VCLEVENT_WINDOW_ACTIVATE:
534 : {
535 0 : if ( mpImpl->getTopWindowListeners().getLength() )
536 : {
537 0 : ::com::sun::star::lang::EventObject aEvent;
538 0 : aEvent.Source = (::cppu::OWeakObject*)this;
539 0 : mpImpl->getTopWindowListeners().windowActivated( aEvent );
540 : }
541 : }
542 0 : break;
543 : case VCLEVENT_WINDOW_DEACTIVATE:
544 : {
545 0 : if ( mpImpl->getTopWindowListeners().getLength() )
546 : {
547 0 : ::com::sun::star::lang::EventObject aEvent;
548 0 : aEvent.Source = (::cppu::OWeakObject*)this;
549 0 : mpImpl->getTopWindowListeners().windowDeactivated( aEvent );
550 : }
551 : }
552 0 : break;
553 : case VCLEVENT_WINDOW_CLOSE:
554 : {
555 0 : if ( mpImpl->getDockableWindowListeners().getLength() )
556 : {
557 0 : ::com::sun::star::lang::EventObject aEvent;
558 0 : aEvent.Source = (::cppu::OWeakObject*)this;
559 0 : mpImpl->getDockableWindowListeners().notifyEach( &XDockableWindowListener::closed, aEvent );
560 : }
561 0 : if ( mpImpl->getTopWindowListeners().getLength() )
562 : {
563 0 : ::com::sun::star::lang::EventObject aEvent;
564 0 : aEvent.Source = (::cppu::OWeakObject*)this;
565 0 : mpImpl->getTopWindowListeners().windowClosing( aEvent );
566 : }
567 : }
568 0 : break;
569 : case VCLEVENT_CONTROL_GETFOCUS:
570 : case VCLEVENT_WINDOW_GETFOCUS:
571 : {
572 0 : if ( ( rVclWindowEvent.GetWindow()->IsCompoundControl()
573 0 : && rVclWindowEvent.GetId() == VCLEVENT_CONTROL_GETFOCUS
574 : )
575 0 : || ( !rVclWindowEvent.GetWindow()->IsCompoundControl()
576 0 : && rVclWindowEvent.GetId() == VCLEVENT_WINDOW_GETFOCUS
577 : )
578 : )
579 : {
580 0 : if ( mpImpl->getFocusListeners().getLength() )
581 : {
582 0 : ::com::sun::star::awt::FocusEvent aEvent;
583 0 : aEvent.Source = (::cppu::OWeakObject*)this;
584 0 : aEvent.FocusFlags = rVclWindowEvent.GetWindow()->GetGetFocusFlags();
585 0 : aEvent.Temporary = sal_False;
586 0 : mpImpl->getFocusListeners().focusGained( aEvent );
587 : }
588 : }
589 : }
590 0 : break;
591 : case VCLEVENT_CONTROL_LOSEFOCUS:
592 : case VCLEVENT_WINDOW_LOSEFOCUS:
593 : {
594 0 : if ( ( rVclWindowEvent.GetWindow()->IsCompoundControl()
595 0 : && rVclWindowEvent.GetId() == VCLEVENT_CONTROL_LOSEFOCUS
596 : )
597 0 : || ( !rVclWindowEvent.GetWindow()->IsCompoundControl()
598 0 : && rVclWindowEvent.GetId() == VCLEVENT_WINDOW_LOSEFOCUS
599 : )
600 : )
601 : {
602 0 : if ( mpImpl->getFocusListeners().getLength() )
603 : {
604 0 : ::com::sun::star::awt::FocusEvent aEvent;
605 0 : aEvent.Source = (::cppu::OWeakObject*)this;
606 0 : aEvent.FocusFlags = rVclWindowEvent.GetWindow()->GetGetFocusFlags();
607 0 : aEvent.Temporary = sal_False;
608 :
609 0 : Window* pNext = Application::GetFocusWindow();
610 0 : if ( pNext )
611 : {
612 : // Don't care about internals if this control is compound
613 0 : Window* pNextC = pNext;
614 0 : while ( pNextC && !pNextC->IsCompoundControl() )
615 0 : pNextC = pNextC->GetParent();
616 0 : if ( pNextC )
617 0 : pNext = pNextC;
618 :
619 0 : pNext->GetComponentInterface( sal_True );
620 0 : aEvent.NextFocus = (::cppu::OWeakObject*)pNext->GetWindowPeer();
621 : }
622 0 : mpImpl->getFocusListeners().focusLost( aEvent );
623 : }
624 : }
625 : }
626 0 : break;
627 : case VCLEVENT_WINDOW_MINIMIZE:
628 : {
629 0 : if ( mpImpl->getTopWindowListeners().getLength() )
630 : {
631 0 : ::com::sun::star::lang::EventObject aEvent;
632 0 : aEvent.Source = (::cppu::OWeakObject*)this;
633 0 : mpImpl->getTopWindowListeners().windowMinimized( aEvent );
634 : }
635 : }
636 0 : break;
637 : case VCLEVENT_WINDOW_NORMALIZE:
638 : {
639 0 : if ( mpImpl->getTopWindowListeners().getLength() )
640 : {
641 0 : ::com::sun::star::lang::EventObject aEvent;
642 0 : aEvent.Source = (::cppu::OWeakObject*)this;
643 0 : mpImpl->getTopWindowListeners().windowNormalized( aEvent );
644 : }
645 : }
646 0 : break;
647 : case VCLEVENT_WINDOW_KEYINPUT:
648 : {
649 0 : if ( mpImpl->getKeyListeners().getLength() )
650 : {
651 : ::com::sun::star::awt::KeyEvent aEvent( VCLUnoHelper::createKeyEvent(
652 0 : *(KeyEvent*)rVclWindowEvent.GetData(), *this
653 0 : ) );
654 0 : mpImpl->getKeyListeners().keyPressed( aEvent );
655 : }
656 : }
657 0 : break;
658 : case VCLEVENT_WINDOW_KEYUP:
659 : {
660 0 : if ( mpImpl->getKeyListeners().getLength() )
661 : {
662 : ::com::sun::star::awt::KeyEvent aEvent( VCLUnoHelper::createKeyEvent(
663 0 : *(KeyEvent*)rVclWindowEvent.GetData(), *this
664 0 : ) );
665 0 : mpImpl->getKeyListeners().keyReleased( aEvent );
666 : }
667 : }
668 0 : break;
669 : case VCLEVENT_WINDOW_COMMAND:
670 : {
671 0 : CommandEvent* pCmdEvt = (CommandEvent*)rVclWindowEvent.GetData();
672 0 : if ( mpImpl->getMouseListeners().getLength() && ( pCmdEvt->GetCommand() == COMMAND_CONTEXTMENU ) )
673 : {
674 : // COMMAND_CONTEXTMENU als mousePressed mit PopupTrigger = sal_True versenden...
675 0 : Point aWhere = static_cast< CommandEvent* >( rVclWindowEvent.GetData() )->GetMousePosPixel();
676 0 : if ( !pCmdEvt->IsMouseEvent() )
677 : { // for keyboard events, we set the coordinates to -1,-1. This is a slight HACK, but the current API
678 : // handles a context menu command as special case of a mouse event, which is simply wrong.
679 : // Without extending the API, we would not have another chance to notify listeners of a
680 : // keyboard-triggered context menu request
681 0 : aWhere = Point( -1, -1 );
682 : }
683 :
684 0 : MouseEvent aMEvt( aWhere, 1, MOUSE_SIMPLECLICK, MOUSE_LEFT, 0 );
685 0 : awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( aMEvt, *this ) );
686 0 : aEvent.PopupTrigger = sal_True;
687 :
688 : Callback aCallback = ::boost::bind(
689 : &MouseListenerMultiplexer::mousePressed,
690 0 : &mpImpl->getMouseListeners(),
691 : aEvent
692 0 : );
693 0 : ImplExecuteAsyncWithoutSolarLock( aCallback );
694 : }
695 : }
696 0 : break;
697 : case VCLEVENT_WINDOW_MOUSEMOVE:
698 : {
699 0 : MouseEvent* pMouseEvt = (MouseEvent*)rVclWindowEvent.GetData();
700 0 : if ( mpImpl->getMouseListeners().getLength() && ( pMouseEvt->IsEnterWindow() || pMouseEvt->IsLeaveWindow() ) )
701 : {
702 0 : awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *pMouseEvt, *this ) );
703 :
704 : Callback aCallback = ::boost::bind(
705 0 : pMouseEvt->IsEnterWindow() ? &MouseListenerMultiplexer::mouseEntered : &MouseListenerMultiplexer::mouseExited,
706 0 : &mpImpl->getMouseListeners(),
707 : aEvent
708 0 : );
709 0 : ImplExecuteAsyncWithoutSolarLock( aCallback );
710 : }
711 :
712 0 : if ( mpImpl->getMouseMotionListeners().getLength() && !pMouseEvt->IsEnterWindow() && !pMouseEvt->IsLeaveWindow() )
713 : {
714 0 : awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *pMouseEvt, *this ) );
715 0 : aEvent.ClickCount = 0; // #92138#
716 0 : if ( pMouseEvt->GetMode() & MOUSE_SIMPLEMOVE )
717 0 : mpImpl->getMouseMotionListeners().mouseMoved( aEvent );
718 : else
719 0 : mpImpl->getMouseMotionListeners().mouseDragged( aEvent );
720 : }
721 : }
722 0 : break;
723 : case VCLEVENT_WINDOW_MOUSEBUTTONDOWN:
724 : {
725 0 : if ( mpImpl->getMouseListeners().getLength() )
726 : {
727 0 : awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *(MouseEvent*)rVclWindowEvent.GetData(), *this ) );
728 : Callback aCallback = ::boost::bind(
729 : &MouseListenerMultiplexer::mousePressed,
730 0 : &mpImpl->getMouseListeners(),
731 : aEvent
732 0 : );
733 0 : ImplExecuteAsyncWithoutSolarLock( aCallback );
734 : }
735 : }
736 0 : break;
737 : case VCLEVENT_WINDOW_MOUSEBUTTONUP:
738 : {
739 0 : if ( mpImpl->getMouseListeners().getLength() )
740 : {
741 0 : awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *(MouseEvent*)rVclWindowEvent.GetData(), *this ) );
742 : Callback aCallback = ::boost::bind(
743 : &MouseListenerMultiplexer::mouseReleased,
744 0 : &mpImpl->getMouseListeners(),
745 : aEvent
746 0 : );
747 0 : ImplExecuteAsyncWithoutSolarLock( aCallback );
748 : }
749 : }
750 0 : break;
751 : case VCLEVENT_WINDOW_STARTDOCKING:
752 : {
753 0 : if ( mpImpl->getDockableWindowListeners().getLength() )
754 : {
755 0 : DockingData *pData = (DockingData*)rVclWindowEvent.GetData();
756 :
757 0 : if( pData )
758 : {
759 0 : ::com::sun::star::awt::DockingEvent aEvent;
760 0 : aEvent.Source = (::cppu::OWeakObject*)this;
761 0 : aEvent.TrackingRectangle = AWTRectangle( pData->maTrackRect );
762 0 : aEvent.MousePos.X = pData->maMousePos.X();
763 0 : aEvent.MousePos.Y = pData->maMousePos.Y();
764 0 : aEvent.bLiveMode = pData->mbLivemode;
765 0 : aEvent.bInteractive = pData->mbInteractive;
766 :
767 0 : mpImpl->getDockableWindowListeners().notifyEach( &XDockableWindowListener::startDocking, aEvent );
768 : }
769 : }
770 : }
771 0 : break;
772 : case VCLEVENT_WINDOW_DOCKING:
773 : {
774 0 : if ( mpImpl->getDockableWindowListeners().getLength() )
775 : {
776 0 : DockingData *pData = (DockingData*)rVclWindowEvent.GetData();
777 :
778 0 : if( pData )
779 : {
780 0 : ::com::sun::star::awt::DockingEvent aEvent;
781 0 : aEvent.Source = (::cppu::OWeakObject*)this;
782 0 : aEvent.TrackingRectangle = AWTRectangle( pData->maTrackRect );
783 0 : aEvent.MousePos.X = pData->maMousePos.X();
784 0 : aEvent.MousePos.Y = pData->maMousePos.Y();
785 0 : aEvent.bLiveMode = pData->mbLivemode;
786 0 : aEvent.bInteractive = pData->mbInteractive;
787 :
788 0 : Reference< XDockableWindowListener > xFirstListener;
789 0 : ::cppu::OInterfaceIteratorHelper aIter( mpImpl->getDockableWindowListeners() );
790 0 : while ( aIter.hasMoreElements() && !xFirstListener.is() )
791 : {
792 0 : xFirstListener.set( aIter.next(), UNO_QUERY );
793 : }
794 :
795 : ::com::sun::star::awt::DockingData aDockingData =
796 0 : xFirstListener->docking( aEvent );
797 0 : pData->maTrackRect = VCLRectangle( aDockingData.TrackingRectangle );
798 0 : pData->mbFloating = aDockingData.bFloating;
799 : }
800 : }
801 : }
802 0 : break;
803 : case VCLEVENT_WINDOW_ENDDOCKING:
804 : {
805 0 : if ( mpImpl->getDockableWindowListeners().getLength() )
806 : {
807 0 : EndDockingData *pData = (EndDockingData*)rVclWindowEvent.GetData();
808 :
809 0 : if( pData )
810 : {
811 0 : ::com::sun::star::awt::EndDockingEvent aEvent;
812 0 : aEvent.Source = (::cppu::OWeakObject*)this;
813 0 : aEvent.WindowRectangle = AWTRectangle( pData->maWindowRect );
814 0 : aEvent.bFloating = pData->mbFloating;
815 0 : aEvent.bCancelled = pData->mbCancelled;
816 0 : mpImpl->getDockableWindowListeners().notifyEach( &XDockableWindowListener::endDocking, aEvent );
817 : }
818 : }
819 : }
820 0 : break;
821 : case VCLEVENT_WINDOW_PREPARETOGGLEFLOATING:
822 : {
823 0 : if ( mpImpl->getDockableWindowListeners().getLength() )
824 : {
825 0 : sal_Bool *p_bFloating = (sal_Bool*)rVclWindowEvent.GetData();
826 :
827 0 : ::com::sun::star::lang::EventObject aEvent;
828 0 : aEvent.Source = (::cppu::OWeakObject*)this;
829 :
830 0 : Reference< XDockableWindowListener > xFirstListener;
831 0 : ::cppu::OInterfaceIteratorHelper aIter( mpImpl->getDockableWindowListeners() );
832 0 : while ( aIter.hasMoreElements() && !xFirstListener.is() )
833 : {
834 0 : xFirstListener.set( aIter.next(), UNO_QUERY );
835 : }
836 :
837 0 : *p_bFloating = xFirstListener->prepareToggleFloatingMode( aEvent );
838 : }
839 : }
840 0 : break;
841 : case VCLEVENT_WINDOW_TOGGLEFLOATING:
842 : {
843 0 : if ( mpImpl->getDockableWindowListeners().getLength() )
844 : {
845 0 : ::com::sun::star::lang::EventObject aEvent;
846 0 : aEvent.Source = (::cppu::OWeakObject*)this;
847 0 : mpImpl->getDockableWindowListeners().notifyEach( &XDockableWindowListener::toggleFloatingMode, aEvent );
848 : }
849 : }
850 0 : break;
851 : case VCLEVENT_WINDOW_ENDPOPUPMODE:
852 : {
853 0 : if ( mpImpl->getDockableWindowListeners().getLength() )
854 : {
855 0 : EndPopupModeData *pData = (EndPopupModeData*)rVclWindowEvent.GetData();
856 :
857 0 : if( pData )
858 : {
859 0 : ::com::sun::star::awt::EndPopupModeEvent aEvent;
860 0 : aEvent.Source = (::cppu::OWeakObject*)this;
861 0 : aEvent.FloatingPosition.X = pData->maFloatingPos.X();
862 0 : aEvent.FloatingPosition.Y = pData->maFloatingPos.Y();
863 0 : aEvent.bTearoff = pData->mbTearoff;
864 0 : mpImpl->getDockableWindowListeners().notifyEach( &XDockableWindowListener::endPopupMode, aEvent );
865 : }
866 : }
867 : }
868 0 : break;
869 :
870 0 : }
871 0 : }
872 :
873 0 : uno::Reference< accessibility::XAccessibleContext > VCLXWindow::CreateAccessibleContext()
874 : {
875 0 : SolarMutexGuard aGuard;
876 0 : return getAccessibleFactory().createAccessibleContext( this );
877 : }
878 :
879 0 : void VCLXWindow::SetSynthesizingVCLEvent( bool _b )
880 : {
881 0 : mpImpl->mbSynthesizingVCLEvent = _b;
882 0 : }
883 :
884 0 : bool VCLXWindow::IsSynthesizingVCLEvent() const
885 : {
886 0 : return mpImpl->mbSynthesizingVCLEvent;
887 : }
888 :
889 0 : Size VCLXWindow::ImplCalcWindowSize( const Size& rOutSz ) const
890 : {
891 0 : Size aSz = rOutSz;
892 :
893 0 : Window* pWindow = GetWindow();
894 0 : if ( pWindow )
895 : {
896 : sal_Int32 nLeft, nTop, nRight, nBottom;
897 0 : pWindow->GetBorder( nLeft, nTop, nRight, nBottom );
898 0 : aSz.Width() += nLeft+nRight;
899 0 : aSz.Height() += nTop+nBottom;
900 : }
901 0 : return aSz;
902 : }
903 :
904 :
905 : // ::com::sun::star::lang::XUnoTunnel
906 0 : IMPL_XUNOTUNNEL2( VCLXWindow, VCLXDevice )
907 :
908 : // ::com::sun::star::lang::Component
909 0 : void VCLXWindow::dispose( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
910 : {
911 0 : SolarMutexGuard aGuard;
912 :
913 0 : mpImpl->mxViewGraphics = NULL;
914 :
915 0 : if ( !mpImpl->mbDisposing )
916 : {
917 0 : mpImpl->mbDisposing = true;
918 :
919 0 : mpImpl->disposing();
920 :
921 0 : if ( GetWindow() )
922 : {
923 0 : OutputDevice* pOutDev = GetOutputDevice();
924 0 : SetWindow( NULL ); // so that handlers are logged off, if necessary (virtual)
925 0 : SetOutputDevice( pOutDev );
926 0 : DestroyOutputDevice();
927 : }
928 :
929 : // #i14103# dispose the accessible context after the window has been destroyed,
930 : // otherwise the old value in the child event fired in VCLXAccessibleComponent::ProcessWindowEvent()
931 : // for VCLEVENT_WINDOW_CHILDDESTROYED contains a reference to an already disposed accessible object
932 : try
933 : {
934 0 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComponent( mpImpl->mxAccessibleContext, ::com::sun::star::uno::UNO_QUERY );
935 0 : if ( xComponent.is() )
936 0 : xComponent->dispose();
937 : }
938 0 : catch ( const ::com::sun::star::uno::Exception& )
939 : {
940 : OSL_FAIL( "VCLXWindow::dispose: could not dispose the accessible context!" );
941 : }
942 0 : mpImpl->mxAccessibleContext.clear();
943 :
944 0 : mpImpl->mbDisposing = false;
945 0 : }
946 0 : }
947 :
948 0 : void VCLXWindow::addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception)
949 : {
950 0 : SolarMutexGuard aGuard;
951 :
952 0 : mpImpl->getEventListeners().addInterface( rxListener );
953 0 : }
954 :
955 0 : void VCLXWindow::removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception)
956 : {
957 0 : SolarMutexGuard aGuard;
958 :
959 0 : mpImpl->getEventListeners().removeInterface( rxListener );
960 0 : }
961 :
962 :
963 : // ::com::sun::star::awt::XWindow
964 0 : void VCLXWindow::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags ) throw(::com::sun::star::uno::RuntimeException, std::exception)
965 : {
966 0 : SolarMutexGuard aGuard;
967 :
968 0 : if ( GetWindow() )
969 : {
970 0 : if( Window::GetDockingManager()->IsDockable( GetWindow() ) )
971 0 : Window::GetDockingManager()->SetPosSizePixel( GetWindow() , X, Y, Width, Height, Flags );
972 : else
973 0 : GetWindow()->setPosSizePixel( X, Y, Width, Height, Flags );
974 0 : }
975 0 : }
976 :
977 0 : ::com::sun::star::awt::Rectangle VCLXWindow::getPosSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
978 : {
979 0 : SolarMutexGuard aGuard;
980 :
981 0 : ::com::sun::star::awt::Rectangle aBounds;
982 0 : if ( GetWindow() )
983 : {
984 0 : if( Window::GetDockingManager()->IsDockable( GetWindow() ) )
985 0 : aBounds = AWTRectangle( Window::GetDockingManager()->GetPosSizePixel( GetWindow() ) );
986 : else
987 0 : aBounds = AWTRectangle( Rectangle( GetWindow()->GetPosPixel(), GetWindow()->GetSizePixel() ) );
988 : }
989 :
990 0 : return aBounds;
991 : }
992 :
993 0 : void VCLXWindow::setVisible( sal_Bool bVisible ) throw(::com::sun::star::uno::RuntimeException, std::exception)
994 : {
995 0 : SolarMutexGuard aGuard;
996 :
997 0 : Window* pWindow = GetWindow();
998 0 : if ( pWindow )
999 : {
1000 0 : mpImpl->setDirectVisible( bVisible );
1001 0 : pWindow->Show( bVisible && mpImpl->isEnableVisible() );
1002 0 : }
1003 0 : }
1004 :
1005 0 : void VCLXWindow::setEnable( sal_Bool bEnable ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1006 : {
1007 0 : SolarMutexGuard aGuard;
1008 :
1009 0 : Window* pWindow = GetWindow();
1010 0 : if ( pWindow )
1011 : {
1012 0 : pWindow->Enable( bEnable, false ); // #95824# without children!
1013 0 : pWindow->EnableInput( bEnable );
1014 0 : }
1015 0 : }
1016 :
1017 0 : void VCLXWindow::setFocus( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1018 : {
1019 0 : SolarMutexGuard aGuard;
1020 :
1021 0 : if ( GetWindow() )
1022 0 : GetWindow()->GrabFocus();
1023 0 : }
1024 :
1025 0 : void VCLXWindow::addWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1026 : {
1027 0 : SolarMutexGuard aGuard;
1028 :
1029 0 : mpImpl->getWindowListeners().addInterface( rxListener );
1030 :
1031 0 : Reference< XWindowListener2 > xListener2( rxListener, UNO_QUERY );
1032 0 : if ( xListener2.is() )
1033 0 : mpImpl->getWindow2Listeners().addInterface( xListener2 );
1034 :
1035 : // #100119# Get all resize events, even if height or width 0, or invisible
1036 0 : if ( GetWindow() )
1037 0 : GetWindow()->EnableAllResize( true );
1038 0 : }
1039 :
1040 0 : void VCLXWindow::removeWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1041 : {
1042 0 : SolarMutexGuard aGuard;
1043 :
1044 0 : Reference< XWindowListener2 > xListener2( rxListener, UNO_QUERY );
1045 0 : if ( xListener2.is() )
1046 0 : mpImpl->getWindow2Listeners().removeInterface( xListener2 );
1047 :
1048 0 : mpImpl->getWindowListeners().removeInterface( rxListener );
1049 0 : }
1050 :
1051 0 : void VCLXWindow::addFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1052 : {
1053 0 : SolarMutexGuard aGuard;
1054 0 : mpImpl->getFocusListeners().addInterface( rxListener );
1055 0 : }
1056 :
1057 0 : void VCLXWindow::removeFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1058 : {
1059 0 : SolarMutexGuard aGuard;
1060 0 : mpImpl->getFocusListeners().removeInterface( rxListener );
1061 0 : }
1062 :
1063 0 : void VCLXWindow::addKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1064 : {
1065 0 : SolarMutexGuard aGuard;
1066 0 : mpImpl->getKeyListeners().addInterface( rxListener );
1067 0 : }
1068 :
1069 0 : void VCLXWindow::removeKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1070 : {
1071 0 : SolarMutexGuard aGuard;
1072 0 : mpImpl->getKeyListeners().removeInterface( rxListener );
1073 0 : }
1074 :
1075 0 : void VCLXWindow::addMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1076 : {
1077 0 : SolarMutexGuard aGuard;
1078 0 : mpImpl->getMouseListeners().addInterface( rxListener );
1079 0 : }
1080 :
1081 0 : void VCLXWindow::removeMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1082 : {
1083 0 : SolarMutexGuard aGuard;
1084 0 : mpImpl->getMouseListeners().removeInterface( rxListener );
1085 0 : }
1086 :
1087 0 : void VCLXWindow::addMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1088 : {
1089 0 : SolarMutexGuard aGuard;
1090 0 : mpImpl->getMouseMotionListeners().addInterface( rxListener );
1091 0 : }
1092 :
1093 0 : void VCLXWindow::removeMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1094 : {
1095 0 : SolarMutexGuard aGuard;
1096 0 : mpImpl->getMouseMotionListeners().removeInterface( rxListener );
1097 0 : }
1098 :
1099 0 : void VCLXWindow::addPaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1100 : {
1101 0 : SolarMutexGuard aGuard;
1102 0 : mpImpl->getPaintListeners().addInterface( rxListener );
1103 0 : }
1104 :
1105 0 : void VCLXWindow::removePaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1106 : {
1107 0 : SolarMutexGuard aGuard;
1108 0 : mpImpl->getPaintListeners().removeInterface( rxListener );
1109 0 : }
1110 :
1111 : // ::com::sun::star::awt::XWindowPeer
1112 0 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > VCLXWindow::getToolkit( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1113 : {
1114 : // no guard. nothing to guard here.
1115 : // 82463 - 12/21/00 - fs
1116 0 : return Application::GetVCLToolkit();
1117 : }
1118 :
1119 0 : void VCLXWindow::setPointer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPointer >& rxPointer ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1120 : {
1121 0 : SolarMutexGuard aGuard;
1122 :
1123 0 : VCLXPointer* pPointer = VCLXPointer::GetImplementation( rxPointer );
1124 0 : if ( pPointer )
1125 : {
1126 0 : mpImpl->mxPointer = rxPointer;
1127 0 : if ( GetWindow() )
1128 0 : GetWindow()->SetPointer( pPointer->GetPointer() );
1129 0 : }
1130 0 : }
1131 :
1132 0 : void VCLXWindow::setBackground( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1133 : {
1134 0 : SolarMutexGuard aGuard;
1135 :
1136 0 : if ( GetWindow() )
1137 : {
1138 0 : Color aColor( (sal_uInt32)nColor );
1139 0 : GetWindow()->SetBackground( aColor );
1140 0 : GetWindow()->SetControlBackground( aColor );
1141 :
1142 0 : WindowType eWinType = GetWindow()->GetType();
1143 0 : if ( ( eWinType == WINDOW_WINDOW ) ||
1144 0 : ( eWinType == WINDOW_WORKWINDOW ) ||
1145 : ( eWinType == WINDOW_FLOATINGWINDOW ) )
1146 : {
1147 0 : GetWindow()->Invalidate();
1148 : }
1149 0 : }
1150 0 : }
1151 :
1152 0 : void VCLXWindow::invalidate( sal_Int16 nInvalidateFlags ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1153 : {
1154 0 : SolarMutexGuard aGuard;
1155 :
1156 0 : if ( GetWindow() )
1157 0 : GetWindow()->Invalidate( (sal_uInt16) nInvalidateFlags );
1158 0 : }
1159 :
1160 0 : void VCLXWindow::invalidateRect( const ::com::sun::star::awt::Rectangle& rRect, sal_Int16 nInvalidateFlags ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1161 : {
1162 0 : SolarMutexGuard aGuard;
1163 :
1164 0 : if ( GetWindow() )
1165 0 : GetWindow()->Invalidate( VCLRectangle(rRect), (sal_uInt16) nInvalidateFlags );
1166 0 : }
1167 :
1168 :
1169 : // ::com::sun::star::awt::XVclWindowPeer
1170 0 : sal_Bool VCLXWindow::isChild( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& rxPeer ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1171 : {
1172 0 : SolarMutexGuard aGuard;
1173 :
1174 0 : bool bIsChild = false;
1175 0 : Window* pWindow = GetWindow();
1176 0 : if ( pWindow )
1177 : {
1178 0 : Window* pPeerWindow = VCLUnoHelper::GetWindow( rxPeer );
1179 0 : bIsChild = pPeerWindow && pWindow->IsChild( pPeerWindow );
1180 : }
1181 :
1182 0 : return bIsChild;
1183 : }
1184 :
1185 0 : void VCLXWindow::setDesignMode( sal_Bool bOn ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1186 : {
1187 0 : SolarMutexGuard aGuard;
1188 :
1189 0 : mpImpl->mbDesignMode = bOn;
1190 0 : }
1191 :
1192 0 : sal_Bool VCLXWindow::isDesignMode( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1193 : {
1194 0 : SolarMutexGuard aGuard;
1195 0 : return mpImpl->mbDesignMode;
1196 : }
1197 :
1198 0 : void VCLXWindow::enableClipSiblings( sal_Bool bClip ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1199 : {
1200 0 : SolarMutexGuard aGuard;
1201 :
1202 0 : if ( GetWindow() )
1203 0 : GetWindow()->EnableClipSiblings( bClip );
1204 0 : }
1205 :
1206 0 : void VCLXWindow::setForeground( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1207 : {
1208 0 : SolarMutexGuard aGuard;
1209 :
1210 0 : if ( GetWindow() )
1211 : {
1212 0 : Color aColor( (sal_uInt32)nColor );
1213 0 : GetWindow()->SetControlForeground( aColor );
1214 0 : }
1215 0 : }
1216 :
1217 0 : void VCLXWindow::setControlFont( const ::com::sun::star::awt::FontDescriptor& rFont ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1218 : {
1219 0 : SolarMutexGuard aGuard;
1220 :
1221 0 : if ( GetWindow() )
1222 0 : GetWindow()->SetControlFont( VCLUnoHelper::CreateFont( rFont, GetWindow()->GetControlFont() ) );
1223 0 : }
1224 :
1225 0 : void VCLXWindow::getStyles( sal_Int16 nType, ::com::sun::star::awt::FontDescriptor& Font, sal_Int32& ForegroundColor, sal_Int32& BackgroundColor ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1226 : {
1227 0 : SolarMutexGuard aGuard;
1228 :
1229 0 : if ( GetWindow() )
1230 : {
1231 0 : const StyleSettings& rStyleSettings = GetWindow()->GetSettings().GetStyleSettings();
1232 :
1233 0 : switch ( nType )
1234 : {
1235 : case ::com::sun::star::awt::Style::FRAME:
1236 : {
1237 0 : Font = VCLUnoHelper::CreateFontDescriptor( rStyleSettings.GetAppFont() );
1238 0 : ForegroundColor = rStyleSettings.GetWindowTextColor().GetColor();
1239 0 : BackgroundColor = rStyleSettings.GetWindowColor().GetColor();
1240 : }
1241 0 : break;
1242 : case ::com::sun::star::awt::Style::DIALOG:
1243 : {
1244 0 : Font = VCLUnoHelper::CreateFontDescriptor( rStyleSettings.GetAppFont() );
1245 0 : ForegroundColor = rStyleSettings.GetDialogTextColor().GetColor();
1246 0 : BackgroundColor = rStyleSettings.GetDialogColor().GetColor();
1247 : }
1248 0 : break;
1249 : default: OSL_FAIL( "VCLWindow::getStyles() - unknown Type" );
1250 : }
1251 :
1252 0 : }
1253 0 : }
1254 :
1255 : namespace toolkit
1256 : {
1257 0 : static void setColorSettings( Window* _pWindow, const ::com::sun::star::uno::Any& _rValue,
1258 : void (StyleSettings::*pSetter)( const Color& ), const Color& (StyleSettings::*pGetter)( ) const )
1259 : {
1260 0 : sal_Int32 nColor = 0;
1261 0 : if ( !( _rValue >>= nColor ) )
1262 0 : nColor = (Application::GetSettings().GetStyleSettings().*pGetter)().GetColor();
1263 :
1264 0 : AllSettings aSettings = _pWindow->GetSettings();
1265 0 : StyleSettings aStyleSettings = aSettings.GetStyleSettings();
1266 :
1267 0 : (aStyleSettings.*pSetter)( Color( nColor ) );
1268 :
1269 0 : aSettings.SetStyleSettings( aStyleSettings );
1270 0 : _pWindow->SetSettings( aSettings, true );
1271 0 : }
1272 : }
1273 :
1274 : // Terminated by BASEPROPERTY_NOTFOUND (or 0)
1275 0 : void VCLXWindow::PushPropertyIds( std::list< sal_uInt16 > &rIds,
1276 : int nFirstId, ...)
1277 : {
1278 : va_list pVarArgs;
1279 0 : va_start( pVarArgs, nFirstId );
1280 :
1281 0 : for ( int nId = nFirstId; nId != BASEPROPERTY_NOTFOUND;
1282 0 : nId = va_arg( pVarArgs, int ) )
1283 0 : rIds.push_back( (sal_uInt16) nId );
1284 :
1285 0 : va_end( pVarArgs );
1286 0 : }
1287 :
1288 0 : void VCLXWindow::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds, bool bWithDefaults )
1289 : {
1290 : // These are common across ~all VCLXWindow derived classes
1291 0 : if( bWithDefaults )
1292 : PushPropertyIds( rIds,
1293 : BASEPROPERTY_ALIGN,
1294 : BASEPROPERTY_BACKGROUNDCOLOR,
1295 : BASEPROPERTY_BORDER,
1296 : BASEPROPERTY_BORDERCOLOR,
1297 : BASEPROPERTY_DEFAULTCONTROL,
1298 : BASEPROPERTY_ENABLED,
1299 : BASEPROPERTY_FONTDESCRIPTOR,
1300 : BASEPROPERTY_HELPTEXT,
1301 : BASEPROPERTY_HELPURL,
1302 : BASEPROPERTY_TEXT,
1303 : BASEPROPERTY_PRINTABLE,
1304 : BASEPROPERTY_ENABLEVISIBLE, // for visibility
1305 : BASEPROPERTY_TABSTOP,
1306 0 : 0);
1307 :
1308 : // lovely hack from:
1309 : // void UnoControlModel::ImplRegisterProperty( sal_uInt16 nPropId )
1310 0 : std::list< sal_uInt16 >::const_iterator iter;
1311 0 : for( iter = rIds.begin(); iter != rIds.end(); ++iter) {
1312 0 : if( *iter == BASEPROPERTY_FONTDESCRIPTOR )
1313 : {
1314 : // some properties are not included in the FontDescriptor, but everytime
1315 : // when we have a FontDescriptor we want to have these properties too.
1316 : // => Easier to register the here, istead everywhere where I register the FontDescriptor...
1317 :
1318 0 : rIds.push_back( BASEPROPERTY_TEXTCOLOR );
1319 0 : rIds.push_back( BASEPROPERTY_TEXTLINECOLOR );
1320 0 : rIds.push_back( BASEPROPERTY_FONTRELIEF );
1321 0 : rIds.push_back( BASEPROPERTY_FONTEMPHASISMARK );
1322 0 : break;
1323 : }
1324 : }
1325 0 : }
1326 :
1327 0 : void VCLXWindow::GetPropertyIds( std::list< sal_uInt16 >& _out_rIds )
1328 : {
1329 0 : return ImplGetPropertyIds( _out_rIds, mpImpl->mbWithDefaultProps );
1330 : }
1331 :
1332 0 : ::cppu::OInterfaceContainerHelper& VCLXWindow::GetContainerListeners()
1333 : {
1334 0 : return mpImpl->getContainerListeners();
1335 : }
1336 :
1337 0 : ::cppu::OInterfaceContainerHelper& VCLXWindow::GetTopWindowListeners()
1338 : {
1339 0 : return mpImpl->getTopWindowListeners();
1340 : }
1341 :
1342 : namespace
1343 : {
1344 0 : void lcl_updateWritingMode( Window& _rWindow, const sal_Int16 _nWritingMode, const sal_Int16 _nContextWritingMode )
1345 : {
1346 0 : bool bEnableRTL = false;
1347 0 : switch ( _nWritingMode )
1348 : {
1349 0 : case WritingMode2::LR_TB: bEnableRTL = false; break;
1350 0 : case WritingMode2::RL_TB: bEnableRTL = true; break;
1351 : case WritingMode2::CONTEXT:
1352 : {
1353 : // consult our ContextWritingMode. If it has an explicit RTL/LTR value, then use
1354 : // it. If it doesn't (but is CONTEXT itself), then just ask the parent window of our
1355 : // own window for its RTL mode
1356 0 : switch ( _nContextWritingMode )
1357 : {
1358 0 : case WritingMode2::LR_TB: bEnableRTL = false; break;
1359 0 : case WritingMode2::RL_TB: bEnableRTL = true; break;
1360 : case WritingMode2::CONTEXT:
1361 : {
1362 0 : const Window* pParent = _rWindow.GetParent();
1363 : OSL_ENSURE( pParent, "lcl_updateWritingMode: cannot determine context's writing mode!" );
1364 0 : if ( pParent )
1365 0 : bEnableRTL = pParent->IsRTLEnabled();
1366 : }
1367 0 : break;
1368 : }
1369 : }
1370 0 : break;
1371 : default:
1372 : OSL_FAIL( "lcl_updateWritingMode: unsupported WritingMode!" );
1373 : } // switch ( nWritingMode )
1374 :
1375 0 : _rWindow.EnableRTL( bEnableRTL );
1376 0 : }
1377 : }
1378 :
1379 0 : void VCLXWindow::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value )
1380 : throw(::com::sun::star::uno::RuntimeException,
1381 : std::exception)
1382 : {
1383 0 : SolarMutexGuard aGuard;
1384 :
1385 0 : Window* pWindow = GetWindow();
1386 0 : if ( !pWindow )
1387 0 : return;
1388 :
1389 0 : bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
1390 :
1391 0 : WindowType eWinType = pWindow->GetType();
1392 0 : sal_uInt16 nPropType = GetPropertyId( PropertyName );
1393 0 : switch ( nPropType )
1394 : {
1395 : case BASEPROPERTY_REFERENCE_DEVICE:
1396 : {
1397 0 : Control* pControl = dynamic_cast< Control* >( pWindow );
1398 : OSL_ENSURE( pControl, "VCLXWindow::setProperty( RefDevice ): need a Control for this!" );
1399 0 : if ( !pControl )
1400 0 : break;
1401 0 : Reference< XDevice > xDevice( Value, UNO_QUERY );
1402 0 : OutputDevice* pDevice = VCLUnoHelper::GetOutputDevice( xDevice );
1403 0 : pControl->SetReferenceDevice( pDevice );
1404 : }
1405 0 : break;
1406 :
1407 : case BASEPROPERTY_CONTEXT_WRITING_MODE:
1408 : {
1409 0 : OSL_VERIFY( Value >>= mpImpl->mnContextWritingMode );
1410 0 : if ( mpImpl->mnWritingMode == WritingMode2::CONTEXT )
1411 0 : lcl_updateWritingMode( *pWindow, mpImpl->mnWritingMode, mpImpl->mnContextWritingMode );
1412 : }
1413 0 : break;
1414 :
1415 : case BASEPROPERTY_WRITING_MODE:
1416 : {
1417 0 : bool bProperType = ( Value >>= mpImpl->mnWritingMode );
1418 : OSL_ENSURE( bProperType, "VCLXWindow::setProperty( 'WritingMode' ): illegal value type!" );
1419 0 : if ( bProperType )
1420 0 : lcl_updateWritingMode( *pWindow, mpImpl->mnWritingMode, mpImpl->mnContextWritingMode );
1421 : }
1422 0 : break;
1423 :
1424 : case BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR:
1425 : {
1426 0 : sal_uInt16 nWheelBehavior( MouseWheelBehavior::SCROLL_FOCUS_ONLY );
1427 0 : OSL_VERIFY( Value >>= nWheelBehavior );
1428 :
1429 0 : AllSettings aSettings = pWindow->GetSettings();
1430 0 : MouseSettings aMouseSettings = aSettings.GetMouseSettings();
1431 :
1432 0 : sal_uInt16 nVclBehavior( MOUSE_WHEEL_FOCUS_ONLY );
1433 0 : switch ( nWheelBehavior )
1434 : {
1435 0 : case MouseWheelBehavior::SCROLL_DISABLED: nVclBehavior = MOUSE_WHEEL_DISABLE; break;
1436 0 : case MouseWheelBehavior::SCROLL_FOCUS_ONLY: nVclBehavior = MOUSE_WHEEL_FOCUS_ONLY; break;
1437 0 : case MouseWheelBehavior::SCROLL_ALWAYS: nVclBehavior = MOUSE_WHEEL_ALWAYS; break;
1438 : default:
1439 : OSL_FAIL( "VCLXWindow::setProperty( 'MouseWheelBehavior' ): illegal property value!" );
1440 : }
1441 :
1442 0 : aMouseSettings.SetWheelBehavior( nVclBehavior );
1443 0 : aSettings.SetMouseSettings( aMouseSettings );
1444 0 : pWindow->SetSettings( aSettings, true );
1445 : }
1446 0 : break;
1447 :
1448 : case BASEPROPERTY_NATIVE_WIDGET_LOOK:
1449 : {
1450 0 : bool bEnable( true );
1451 0 : OSL_VERIFY( Value >>= bEnable );
1452 0 : pWindow->EnableNativeWidget( bEnable );
1453 : }
1454 0 : break;
1455 :
1456 : case BASEPROPERTY_PLUGINPARENT:
1457 : {
1458 : // set parent handle
1459 0 : SetSystemParent_Impl( Value );
1460 : }
1461 0 : break;
1462 :
1463 : case BASEPROPERTY_ENABLED:
1464 : {
1465 0 : bool b = bool();
1466 0 : if ( Value >>= b )
1467 0 : setEnable( b );
1468 : }
1469 0 : break;
1470 : case BASEPROPERTY_ENABLEVISIBLE:
1471 : {
1472 0 : bool b = false;
1473 0 : if ( Value >>= b )
1474 : {
1475 0 : if( b != mpImpl->isEnableVisible() )
1476 : {
1477 0 : mpImpl->setEnableVisible( b );
1478 0 : pWindow->Show( b && mpImpl->isDirectVisible() );
1479 : }
1480 : }
1481 : }
1482 0 : break;
1483 : case BASEPROPERTY_TEXT:
1484 : case BASEPROPERTY_LABEL:
1485 : case BASEPROPERTY_TITLE:
1486 : {
1487 0 : OUString aText;
1488 0 : if ( Value >>= aText )
1489 : {
1490 0 : switch (eWinType)
1491 : {
1492 : case WINDOW_OKBUTTON:
1493 : case WINDOW_CANCELBUTTON:
1494 : case WINDOW_HELPBUTTON:
1495 : // Standard Button: overwrite only if not empty.
1496 0 : if (!aText.isEmpty())
1497 0 : pWindow->SetText( aText );
1498 0 : break;
1499 :
1500 : default:
1501 0 : pWindow->SetText( aText );
1502 0 : break;
1503 : }
1504 0 : }
1505 : }
1506 0 : break;
1507 : case BASEPROPERTY_ACCESSIBLENAME:
1508 : {
1509 0 : OUString aText;
1510 0 : if ( Value >>= aText )
1511 0 : pWindow->SetAccessibleName( aText );
1512 : }
1513 0 : break;
1514 : case BASEPROPERTY_HELPURL:
1515 : {
1516 0 : OUString aURL;
1517 0 : if ( Value >>= aURL )
1518 : {
1519 0 : INetURLObject aHelpURL( aURL );
1520 0 : if ( aHelpURL.GetProtocol() == INET_PROT_HID )
1521 0 : pWindow->SetHelpId( OUStringToOString( aHelpURL.GetURLPath(), RTL_TEXTENCODING_UTF8 ) );
1522 : else
1523 0 : pWindow->SetHelpId( OUStringToOString( aURL, RTL_TEXTENCODING_UTF8 ) );
1524 0 : }
1525 : }
1526 0 : break;
1527 : case BASEPROPERTY_HELPTEXT:
1528 : {
1529 0 : OUString aHelpText;
1530 0 : if ( Value >>= aHelpText )
1531 : {
1532 0 : pWindow->SetQuickHelpText( aHelpText );
1533 0 : }
1534 : }
1535 0 : break;
1536 : case BASEPROPERTY_FONTDESCRIPTOR:
1537 : {
1538 0 : if ( bVoid )
1539 0 : pWindow->SetControlFont( Font() );
1540 : else
1541 : {
1542 0 : ::com::sun::star::awt::FontDescriptor aFont;
1543 0 : if ( Value >>= aFont )
1544 0 : pWindow->SetControlFont( VCLUnoHelper::CreateFont( aFont, pWindow->GetControlFont() ) );
1545 : }
1546 : }
1547 0 : break;
1548 : case BASEPROPERTY_FONTRELIEF:
1549 : {
1550 0 : sal_Int16 n = sal_Int16();
1551 0 : if ( Value >>= n )
1552 : {
1553 0 : Font aFont = pWindow->GetControlFont();
1554 0 : aFont.SetRelief( (FontRelief)n );
1555 0 : pWindow->SetControlFont( aFont );
1556 : }
1557 : }
1558 0 : break;
1559 : case BASEPROPERTY_FONTEMPHASISMARK:
1560 : {
1561 0 : sal_Int16 n = sal_Int16();
1562 0 : if ( Value >>= n )
1563 : {
1564 0 : Font aFont = pWindow->GetControlFont();
1565 0 : aFont.SetEmphasisMark( n );
1566 0 : pWindow->SetControlFont( aFont );
1567 : }
1568 : }
1569 0 : break;
1570 : case BASEPROPERTY_BACKGROUNDCOLOR:
1571 0 : if ( bVoid )
1572 : {
1573 0 : switch ( eWinType )
1574 : {
1575 : // set dialog color for default
1576 : case WINDOW_DIALOG:
1577 : case WINDOW_MESSBOX:
1578 : case WINDOW_INFOBOX:
1579 : case WINDOW_WARNINGBOX:
1580 : case WINDOW_ERRORBOX:
1581 : case WINDOW_QUERYBOX:
1582 : case WINDOW_TABPAGE:
1583 : {
1584 0 : Color aColor = pWindow->GetSettings().GetStyleSettings().GetDialogColor();
1585 0 : pWindow->SetBackground( aColor );
1586 0 : pWindow->SetControlBackground( aColor );
1587 0 : break;
1588 : }
1589 :
1590 : case WINDOW_FIXEDTEXT:
1591 : case WINDOW_CHECKBOX:
1592 : case WINDOW_RADIOBUTTON:
1593 : case WINDOW_GROUPBOX:
1594 : case WINDOW_FIXEDLINE:
1595 : {
1596 : // support transparency only for special controls
1597 0 : pWindow->SetBackground();
1598 0 : pWindow->SetControlBackground();
1599 0 : pWindow->SetPaintTransparent( true );
1600 0 : break;
1601 : }
1602 :
1603 : default:
1604 : {
1605 : // default code which enables transparency for
1606 : // compound controls. It's not real transparency
1607 : // as most of these controls repaint their client
1608 : // area completely new.
1609 0 : if ( pWindow->IsCompoundControl() )
1610 0 : pWindow->SetBackground();
1611 0 : pWindow->SetControlBackground();
1612 0 : break;
1613 : }
1614 : }
1615 : }
1616 : else
1617 : {
1618 0 : sal_Int32 nColor = 0;
1619 0 : if ( Value >>= nColor )
1620 : {
1621 0 : Color aColor( nColor );
1622 0 : pWindow->SetControlBackground( aColor );
1623 0 : pWindow->SetBackground( aColor );
1624 0 : switch ( eWinType )
1625 : {
1626 : // reset paint transparent mode
1627 : case WINDOW_FIXEDTEXT:
1628 : case WINDOW_CHECKBOX:
1629 : case WINDOW_RADIOBUTTON:
1630 : case WINDOW_GROUPBOX:
1631 : case WINDOW_FIXEDLINE:
1632 0 : pWindow->SetPaintTransparent( false );
1633 : default: ;
1634 : }
1635 0 : pWindow->Invalidate(); // Invalidate if control does not respond to it
1636 : }
1637 : }
1638 0 : break;
1639 : case BASEPROPERTY_TEXTCOLOR:
1640 0 : if ( bVoid )
1641 : {
1642 0 : pWindow->SetControlForeground();
1643 : }
1644 : else
1645 : {
1646 0 : sal_Int32 nColor = 0;
1647 0 : if ( Value >>= nColor )
1648 : {
1649 0 : Color aColor( nColor );
1650 0 : pWindow->SetTextColor( aColor );
1651 0 : pWindow->SetControlForeground( aColor );
1652 : }
1653 : }
1654 0 : break;
1655 : case BASEPROPERTY_TEXTLINECOLOR:
1656 0 : if ( bVoid )
1657 : {
1658 0 : pWindow->SetTextLineColor();
1659 : }
1660 : else
1661 : {
1662 0 : sal_Int32 nColor = 0;
1663 0 : if ( Value >>= nColor )
1664 : {
1665 0 : Color aColor( nColor );
1666 0 : pWindow->SetTextLineColor( aColor );
1667 : }
1668 : }
1669 0 : break;
1670 : case BASEPROPERTY_FILLCOLOR:
1671 0 : if ( bVoid )
1672 0 : pWindow->SetFillColor();
1673 : else
1674 : {
1675 0 : sal_Int32 nColor = 0;
1676 0 : if ( Value >>= nColor )
1677 : {
1678 0 : Color aColor( nColor );
1679 0 : pWindow->SetFillColor( aColor );
1680 : }
1681 : }
1682 0 : break;
1683 : case BASEPROPERTY_LINECOLOR:
1684 0 : if ( bVoid )
1685 0 : pWindow->SetLineColor();
1686 : else
1687 : {
1688 0 : sal_Int32 nColor = 0;
1689 0 : if ( Value >>= nColor )
1690 : {
1691 0 : Color aColor( nColor );
1692 0 : pWindow->SetLineColor( aColor );
1693 : }
1694 : }
1695 0 : break;
1696 : case BASEPROPERTY_BORDER:
1697 : {
1698 0 : WinBits nStyle = pWindow->GetStyle();
1699 0 : sal_uInt16 nBorder = 0;
1700 0 : Value >>= nBorder;
1701 0 : if ( !nBorder )
1702 : {
1703 0 : pWindow->SetStyle( nStyle & ~WB_BORDER );
1704 : }
1705 : else
1706 : {
1707 0 : pWindow->SetStyle( nStyle | WB_BORDER );
1708 0 : pWindow->SetBorderStyle( nBorder );
1709 : }
1710 : }
1711 0 : break;
1712 : case BASEPROPERTY_TABSTOP:
1713 : {
1714 0 : WinBits nStyle = pWindow->GetStyle() & ~WB_TABSTOP;
1715 0 : if ( !bVoid )
1716 : {
1717 0 : bool bTab = false;
1718 0 : Value >>= bTab;
1719 0 : if ( bTab )
1720 0 : nStyle |= WB_TABSTOP;
1721 : else
1722 0 : nStyle |= WB_NOTABSTOP;
1723 : }
1724 0 : pWindow->SetStyle( nStyle );
1725 : }
1726 0 : break;
1727 : case BASEPROPERTY_VERTICALALIGN:
1728 : {
1729 0 : VerticalAlignment eAlign = VerticalAlignment_MAKE_FIXED_SIZE;
1730 0 : WinBits nStyle = pWindow->GetStyle();
1731 0 : nStyle &= ~(WB_TOP|WB_VCENTER|WB_BOTTOM);
1732 0 : if ( !bVoid )
1733 0 : Value >>= eAlign;
1734 0 : switch ( eAlign )
1735 : {
1736 : case VerticalAlignment_TOP:
1737 0 : nStyle |= WB_TOP;
1738 0 : break;
1739 : case VerticalAlignment_MIDDLE:
1740 0 : nStyle |= WB_VCENTER;
1741 0 : break;
1742 : case VerticalAlignment_BOTTOM:
1743 0 : nStyle |= WB_BOTTOM;
1744 0 : break;
1745 : default: ; // for warning free code, MAKE_FIXED_SIZE
1746 : }
1747 0 : pWindow->SetStyle( nStyle );
1748 : }
1749 0 : break;
1750 : case BASEPROPERTY_ALIGN:
1751 : {
1752 0 : sal_Int16 nAlign = PROPERTY_ALIGN_LEFT;
1753 0 : switch ( eWinType )
1754 : {
1755 : case WINDOW_COMBOBOX:
1756 : case WINDOW_BUTTON:
1757 : case WINDOW_PUSHBUTTON:
1758 : case WINDOW_OKBUTTON:
1759 : case WINDOW_CANCELBUTTON:
1760 : case WINDOW_HELPBUTTON:
1761 0 : nAlign = PROPERTY_ALIGN_CENTER;
1762 : // no break here!
1763 : case WINDOW_FIXEDTEXT:
1764 : case WINDOW_EDIT:
1765 : case WINDOW_MULTILINEEDIT:
1766 : case WINDOW_CHECKBOX:
1767 : case WINDOW_RADIOBUTTON:
1768 : case WINDOW_LISTBOX:
1769 : {
1770 0 : WinBits nStyle = pWindow->GetStyle();
1771 0 : nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT);
1772 0 : if ( !bVoid )
1773 0 : Value >>= nAlign;
1774 0 : if ( nAlign == PROPERTY_ALIGN_LEFT )
1775 0 : nStyle |= WB_LEFT;
1776 0 : else if ( nAlign == PROPERTY_ALIGN_CENTER )
1777 0 : nStyle |= WB_CENTER;
1778 : else
1779 0 : nStyle |= WB_RIGHT;
1780 0 : pWindow->SetStyle( nStyle );
1781 : }
1782 0 : break;
1783 : }
1784 : }
1785 0 : break;
1786 : case BASEPROPERTY_MULTILINE:
1787 : {
1788 0 : if ( ( eWinType == WINDOW_FIXEDTEXT )
1789 0 : || ( eWinType == WINDOW_CHECKBOX )
1790 0 : || ( eWinType == WINDOW_RADIOBUTTON )
1791 0 : || ( eWinType == WINDOW_BUTTON )
1792 0 : || ( eWinType == WINDOW_PUSHBUTTON )
1793 0 : || ( eWinType == WINDOW_OKBUTTON )
1794 0 : || ( eWinType == WINDOW_CANCELBUTTON )
1795 0 : || ( eWinType == WINDOW_HELPBUTTON )
1796 : )
1797 : {
1798 0 : WinBits nStyle = pWindow->GetStyle();
1799 0 : bool bMulti = false;
1800 0 : Value >>= bMulti;
1801 0 : if ( bMulti )
1802 0 : nStyle |= WB_WORDBREAK;
1803 : else
1804 0 : nStyle &= ~WB_WORDBREAK;
1805 0 : pWindow->SetStyle( nStyle );
1806 : }
1807 : }
1808 0 : break;
1809 : case BASEPROPERTY_ORIENTATION:
1810 : {
1811 0 : switch ( eWinType )
1812 : {
1813 : case WINDOW_FIXEDLINE:
1814 : {
1815 0 : sal_Int32 nOrientation = 0;
1816 0 : if ( Value >>= nOrientation )
1817 : {
1818 0 : WinBits nStyle = pWindow->GetStyle();
1819 0 : nStyle &= ~(WB_HORZ|WB_VERT);
1820 0 : if ( nOrientation == 0 )
1821 0 : nStyle |= WB_HORZ;
1822 : else
1823 0 : nStyle |= WB_VERT;
1824 :
1825 0 : pWindow->SetStyle( nStyle );
1826 : }
1827 : }
1828 0 : break;
1829 : }
1830 : }
1831 0 : break;
1832 : case BASEPROPERTY_AUTOMNEMONICS:
1833 : {
1834 0 : bool bAutoMnemonics = false;
1835 0 : Value >>= bAutoMnemonics;
1836 0 : AllSettings aSettings = pWindow->GetSettings();
1837 0 : StyleSettings aStyleSettings = aSettings.GetStyleSettings();
1838 0 : if ( aStyleSettings.GetAutoMnemonic() != bAutoMnemonics )
1839 : {
1840 0 : aStyleSettings.SetAutoMnemonic( bAutoMnemonics );
1841 0 : aSettings.SetStyleSettings( aStyleSettings );
1842 0 : pWindow->SetSettings( aSettings );
1843 0 : }
1844 : }
1845 0 : break;
1846 : case BASEPROPERTY_MOUSETRANSPARENT:
1847 : {
1848 0 : bool bMouseTransparent = false;
1849 0 : Value >>= bMouseTransparent;
1850 0 : pWindow->SetMouseTransparent( bMouseTransparent );
1851 : }
1852 0 : break;
1853 : case BASEPROPERTY_PAINTTRANSPARENT:
1854 : {
1855 0 : bool bPaintTransparent = false;
1856 0 : Value >>= bPaintTransparent;
1857 0 : pWindow->SetPaintTransparent( bPaintTransparent );
1858 : // pWindow->SetBackground();
1859 : }
1860 0 : break;
1861 :
1862 : case BASEPROPERTY_REPEAT:
1863 : {
1864 0 : bool bRepeat( false );
1865 0 : Value >>= bRepeat;
1866 :
1867 0 : WinBits nStyle = pWindow->GetStyle();
1868 0 : if ( bRepeat )
1869 0 : nStyle |= WB_REPEAT;
1870 : else
1871 0 : nStyle &= ~WB_REPEAT;
1872 0 : pWindow->SetStyle( nStyle );
1873 : }
1874 0 : break;
1875 :
1876 : case BASEPROPERTY_REPEAT_DELAY:
1877 : {
1878 0 : sal_Int32 nRepeatDelay = 0;
1879 0 : if ( Value >>= nRepeatDelay )
1880 : {
1881 0 : AllSettings aSettings = pWindow->GetSettings();
1882 0 : MouseSettings aMouseSettings = aSettings.GetMouseSettings();
1883 :
1884 0 : aMouseSettings.SetButtonRepeat( nRepeatDelay );
1885 0 : aSettings.SetMouseSettings( aMouseSettings );
1886 :
1887 0 : pWindow->SetSettings( aSettings, true );
1888 : }
1889 : }
1890 0 : break;
1891 :
1892 : case BASEPROPERTY_SYMBOL_COLOR:
1893 0 : ::toolkit::setColorSettings( pWindow, Value, &StyleSettings::SetButtonTextColor, &StyleSettings::GetButtonTextColor );
1894 0 : break;
1895 :
1896 : case BASEPROPERTY_BORDERCOLOR:
1897 0 : ::toolkit::setColorSettings( pWindow, Value, &StyleSettings::SetMonoColor, &StyleSettings::GetMonoColor);
1898 0 : break;
1899 : case BASEPROPERTY_DEFAULTCONTROL:
1900 : {
1901 0 : OUString aName;
1902 0 : Value >>= aName;
1903 0 : break;
1904 : }
1905 0 : }
1906 : }
1907 :
1908 0 : ::com::sun::star::uno::Any VCLXWindow::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1909 : {
1910 0 : SolarMutexGuard aGuard;
1911 :
1912 0 : ::com::sun::star::uno::Any aProp;
1913 0 : if ( GetWindow() )
1914 : {
1915 0 : WindowType eWinType = GetWindow()->GetType();
1916 0 : sal_uInt16 nPropType = GetPropertyId( PropertyName );
1917 0 : switch ( nPropType )
1918 : {
1919 : case BASEPROPERTY_REFERENCE_DEVICE:
1920 : {
1921 0 : Control* pControl = dynamic_cast< Control* >( GetWindow() );
1922 : OSL_ENSURE( pControl, "VCLXWindow::setProperty( RefDevice ): need a Control for this!" );
1923 0 : if ( !pControl )
1924 0 : break;
1925 :
1926 0 : VCLXDevice* pDevice = new VCLXDevice;
1927 0 : pDevice->SetOutputDevice( pControl->GetReferenceDevice() );
1928 0 : aProp <<= Reference< XDevice >( pDevice );
1929 : }
1930 0 : break;
1931 :
1932 : case BASEPROPERTY_CONTEXT_WRITING_MODE:
1933 0 : aProp <<= mpImpl->mnContextWritingMode;
1934 0 : break;
1935 :
1936 : case BASEPROPERTY_WRITING_MODE:
1937 0 : aProp <<= mpImpl->mnWritingMode;
1938 0 : break;
1939 :
1940 : case BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR:
1941 : {
1942 0 : sal_uInt16 nVclBehavior = GetWindow()->GetSettings().GetMouseSettings().GetWheelBehavior();
1943 0 : sal_Int16 nBehavior = MouseWheelBehavior::SCROLL_FOCUS_ONLY;
1944 0 : switch ( nVclBehavior )
1945 : {
1946 0 : case MOUSE_WHEEL_DISABLE: nBehavior = MouseWheelBehavior::SCROLL_DISABLED; break;
1947 0 : case MOUSE_WHEEL_FOCUS_ONLY: nBehavior = MouseWheelBehavior::SCROLL_FOCUS_ONLY; break;
1948 0 : case MOUSE_WHEEL_ALWAYS: nBehavior = MouseWheelBehavior::SCROLL_ALWAYS; break;
1949 : default:
1950 : OSL_FAIL( "VCLXWindow::getProperty( 'MouseWheelBehavior' ): illegal VCL value!" );
1951 : }
1952 0 : aProp <<= nBehavior;
1953 : }
1954 0 : break;
1955 :
1956 : case BASEPROPERTY_NATIVE_WIDGET_LOOK:
1957 0 : aProp <<= GetWindow()->IsNativeWidgetEnabled();
1958 0 : break;
1959 :
1960 : case BASEPROPERTY_ENABLED:
1961 0 : aProp <<= GetWindow()->IsEnabled();
1962 0 : break;
1963 :
1964 : case BASEPROPERTY_ENABLEVISIBLE:
1965 0 : aProp <<= mpImpl->isEnableVisible();
1966 0 : break;
1967 :
1968 : case BASEPROPERTY_HIGHCONTRASTMODE:
1969 0 : aProp <<= GetWindow()->GetSettings().GetStyleSettings().GetHighContrastMode();
1970 0 : break;
1971 :
1972 : case BASEPROPERTY_TEXT:
1973 : case BASEPROPERTY_LABEL:
1974 : case BASEPROPERTY_TITLE:
1975 : {
1976 0 : OUString aText = GetWindow()->GetText();
1977 0 : aProp <<= aText;
1978 : }
1979 0 : break;
1980 : case BASEPROPERTY_ACCESSIBLENAME:
1981 : {
1982 0 : OUString aText = GetWindow()->GetAccessibleName();
1983 0 : aProp <<= aText;
1984 : }
1985 0 : break;
1986 : case BASEPROPERTY_HELPTEXT:
1987 : {
1988 0 : OUString aText = GetWindow()->GetQuickHelpText();
1989 0 : aProp <<= aText;
1990 : }
1991 0 : break;
1992 : case BASEPROPERTY_HELPURL:
1993 : {
1994 0 : OUString aHelpId( OStringToOUString( GetWindow()->GetHelpId(), RTL_TEXTENCODING_UTF8 ) );
1995 0 : aProp <<= OUString( aHelpId );
1996 : }
1997 0 : break;
1998 : case BASEPROPERTY_FONTDESCRIPTOR:
1999 : {
2000 0 : Font aFont = GetWindow()->GetControlFont();
2001 0 : ::com::sun::star::awt::FontDescriptor aFD = VCLUnoHelper::CreateFontDescriptor( aFont );
2002 0 : aProp <<= aFD;
2003 : }
2004 0 : break;
2005 : case BASEPROPERTY_BACKGROUNDCOLOR:
2006 0 : aProp <<= (sal_Int32) GetWindow()->GetControlBackground().GetColor();
2007 0 : break;
2008 : case BASEPROPERTY_DISPLAYBACKGROUNDCOLOR:
2009 0 : aProp <<= (sal_Int32) GetWindow()->GetDisplayBackground().GetColor().GetColor();
2010 0 : break;
2011 : case BASEPROPERTY_FONTRELIEF:
2012 0 : aProp <<= (sal_Int16) GetWindow()->GetControlFont().GetRelief();
2013 0 : break;
2014 : case BASEPROPERTY_FONTEMPHASISMARK:
2015 0 : aProp <<= (sal_Int16) GetWindow()->GetControlFont().GetEmphasisMark();
2016 0 : break;
2017 : case BASEPROPERTY_TEXTCOLOR:
2018 0 : aProp <<= (sal_Int32) GetWindow()->GetControlForeground().GetColor();
2019 0 : break;
2020 : case BASEPROPERTY_TEXTLINECOLOR:
2021 0 : aProp <<= (sal_Int32) GetWindow()->GetTextLineColor().GetColor();
2022 0 : break;
2023 : case BASEPROPERTY_FILLCOLOR:
2024 0 : aProp <<= (sal_Int32) GetWindow()->GetFillColor().GetColor();
2025 0 : break;
2026 : case BASEPROPERTY_LINECOLOR:
2027 0 : aProp <<= (sal_Int32) GetWindow()->GetLineColor().GetColor();
2028 0 : break;
2029 : case BASEPROPERTY_BORDER:
2030 : {
2031 0 : sal_Int16 nBorder = 0;
2032 0 : if ( GetWindow()->GetStyle() & WB_BORDER )
2033 0 : nBorder = GetWindow()->GetBorderStyle();
2034 0 : aProp <<= nBorder;
2035 : }
2036 0 : break;
2037 : case BASEPROPERTY_TABSTOP:
2038 0 : aProp <<= ( GetWindow()->GetStyle() & WB_TABSTOP ) != 0;
2039 0 : break;
2040 : case BASEPROPERTY_VERTICALALIGN:
2041 : {
2042 0 : WinBits nStyle = GetWindow()->GetStyle();
2043 0 : if ( nStyle & WB_TOP )
2044 0 : aProp <<= VerticalAlignment_TOP;
2045 0 : else if ( nStyle & WB_VCENTER )
2046 0 : aProp <<= VerticalAlignment_MIDDLE;
2047 0 : else if ( nStyle & WB_BOTTOM )
2048 0 : aProp <<= VerticalAlignment_BOTTOM;
2049 : }
2050 0 : break;
2051 : case BASEPROPERTY_ALIGN:
2052 : {
2053 0 : switch ( eWinType )
2054 : {
2055 : case WINDOW_FIXEDTEXT:
2056 : case WINDOW_EDIT:
2057 : case WINDOW_MULTILINEEDIT:
2058 : case WINDOW_CHECKBOX:
2059 : case WINDOW_RADIOBUTTON:
2060 : case WINDOW_LISTBOX:
2061 : case WINDOW_COMBOBOX:
2062 : case WINDOW_BUTTON:
2063 : case WINDOW_PUSHBUTTON:
2064 : case WINDOW_OKBUTTON:
2065 : case WINDOW_CANCELBUTTON:
2066 : case WINDOW_HELPBUTTON:
2067 : {
2068 0 : WinBits nStyle = GetWindow()->GetStyle();
2069 0 : if ( nStyle & WB_LEFT )
2070 0 : aProp <<= (sal_Int16) PROPERTY_ALIGN_LEFT;
2071 0 : else if ( nStyle & WB_CENTER )
2072 0 : aProp <<= (sal_Int16) PROPERTY_ALIGN_CENTER;
2073 0 : else if ( nStyle & WB_RIGHT )
2074 0 : aProp <<= (sal_Int16) PROPERTY_ALIGN_RIGHT;
2075 : }
2076 0 : break;
2077 : }
2078 : }
2079 : case BASEPROPERTY_MULTILINE:
2080 : {
2081 0 : if ( ( eWinType == WINDOW_FIXEDTEXT )
2082 0 : || ( eWinType == WINDOW_CHECKBOX )
2083 0 : || ( eWinType == WINDOW_RADIOBUTTON )
2084 0 : || ( eWinType == WINDOW_BUTTON )
2085 0 : || ( eWinType == WINDOW_PUSHBUTTON )
2086 0 : || ( eWinType == WINDOW_OKBUTTON )
2087 0 : || ( eWinType == WINDOW_CANCELBUTTON )
2088 0 : || ( eWinType == WINDOW_HELPBUTTON )
2089 : )
2090 0 : aProp <<= ( GetWindow()->GetStyle() & WB_WORDBREAK ) != 0;
2091 : }
2092 0 : break;
2093 : case BASEPROPERTY_AUTOMNEMONICS:
2094 : {
2095 0 : bool bAutoMnemonics = GetWindow()->GetSettings().GetStyleSettings().GetAutoMnemonic();
2096 0 : aProp <<= bAutoMnemonics;
2097 : }
2098 0 : break;
2099 : case BASEPROPERTY_MOUSETRANSPARENT:
2100 : {
2101 0 : bool bMouseTransparent = GetWindow()->IsMouseTransparent();
2102 0 : aProp <<= bMouseTransparent;
2103 : }
2104 0 : break;
2105 : case BASEPROPERTY_PAINTTRANSPARENT:
2106 : {
2107 0 : bool bPaintTransparent = GetWindow()->IsPaintTransparent();
2108 0 : aProp <<= bPaintTransparent;
2109 : }
2110 0 : break;
2111 :
2112 : case BASEPROPERTY_REPEAT:
2113 0 : aProp <<= ( 0 != ( GetWindow()->GetStyle() & WB_REPEAT ) );
2114 0 : break;
2115 :
2116 : case BASEPROPERTY_REPEAT_DELAY:
2117 : {
2118 0 : sal_Int32 nButtonRepeat = GetWindow()->GetSettings().GetMouseSettings().GetButtonRepeat();
2119 0 : aProp <<= (sal_Int32)nButtonRepeat;
2120 : }
2121 0 : break;
2122 :
2123 : case BASEPROPERTY_SYMBOL_COLOR:
2124 0 : aProp <<= (sal_Int32)GetWindow()->GetSettings().GetStyleSettings().GetButtonTextColor().GetColor();
2125 0 : break;
2126 :
2127 : case BASEPROPERTY_BORDERCOLOR:
2128 0 : aProp <<= (sal_Int32)GetWindow()->GetSettings().GetStyleSettings().GetMonoColor().GetColor();
2129 0 : break;
2130 : }
2131 : }
2132 0 : return aProp;
2133 : }
2134 :
2135 :
2136 : // ::com::sun::star::awt::XLayoutConstrains
2137 0 : ::com::sun::star::awt::Size VCLXWindow::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2138 : {
2139 0 : SolarMutexGuard aGuard;
2140 :
2141 : // Use this method only for those components which can be created through
2142 : // ::com::sun::star::awt::Toolkit , but do not have an interface
2143 :
2144 0 : Size aSz;
2145 0 : if ( GetWindow() )
2146 : {
2147 0 : WindowType nWinType = GetWindow()->GetType();
2148 0 : switch ( nWinType )
2149 : {
2150 : case WINDOW_CONTROL:
2151 0 : aSz.Width() = GetWindow()->GetTextWidth( GetWindow()->GetText() )+2*12;
2152 0 : aSz.Height() = GetWindow()->GetTextHeight()+2*6;
2153 0 : break;
2154 :
2155 : case WINDOW_PATTERNBOX:
2156 : case WINDOW_NUMERICBOX:
2157 : case WINDOW_METRICBOX:
2158 : case WINDOW_CURRENCYBOX:
2159 : case WINDOW_DATEBOX:
2160 : case WINDOW_TIMEBOX:
2161 : case WINDOW_LONGCURRENCYBOX:
2162 0 : aSz.Width() = GetWindow()->GetTextWidth( GetWindow()->GetText() )+2*2;
2163 0 : aSz.Height() = GetWindow()->GetTextHeight()+2*2;
2164 0 : break;
2165 : case WINDOW_SCROLLBARBOX:
2166 0 : return VCLXScrollBar::implGetMinimumSize( GetWindow() );
2167 : default:
2168 0 : aSz = GetWindow()->GetOptimalSize();
2169 : }
2170 : }
2171 :
2172 0 : return ::com::sun::star::awt::Size( aSz.Width(), aSz.Height() );
2173 : }
2174 :
2175 0 : ::com::sun::star::awt::Size VCLXWindow::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2176 : {
2177 0 : return getMinimumSize();
2178 : }
2179 :
2180 0 : ::com::sun::star::awt::Size VCLXWindow::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2181 : {
2182 0 : SolarMutexGuard aGuard;
2183 :
2184 0 : ::com::sun::star::awt::Size aNewSize( rNewSize );
2185 0 : ::com::sun::star::awt::Size aMinSize = getMinimumSize();
2186 :
2187 0 : if ( aNewSize.Width < aMinSize.Width )
2188 0 : aNewSize.Width = aMinSize.Width;
2189 0 : if ( aNewSize.Height < aMinSize.Height )
2190 0 : aNewSize.Height = aMinSize.Height;
2191 :
2192 0 : return aNewSize;
2193 : }
2194 :
2195 :
2196 : // ::com::sun::star::awt::XView
2197 0 : sal_Bool VCLXWindow::setGraphics( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& rxDevice ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2198 : {
2199 0 : SolarMutexGuard aGuard;
2200 :
2201 0 : if ( VCLUnoHelper::GetOutputDevice( rxDevice ) )
2202 0 : mpImpl->mxViewGraphics = rxDevice;
2203 : else
2204 0 : mpImpl->mxViewGraphics = NULL;
2205 :
2206 0 : return mpImpl->mxViewGraphics.is();
2207 : }
2208 :
2209 0 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics > VCLXWindow::getGraphics( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2210 : {
2211 0 : SolarMutexGuard aGuard;
2212 :
2213 0 : return mpImpl->mxViewGraphics;
2214 : }
2215 :
2216 0 : ::com::sun::star::awt::Size VCLXWindow::getSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2217 : {
2218 0 : SolarMutexGuard aGuard;
2219 :
2220 0 : Size aSz;
2221 0 : if ( GetWindow() )
2222 0 : aSz = GetWindow()->GetSizePixel();
2223 0 : return ::com::sun::star::awt::Size( aSz.Width(), aSz.Height() );
2224 : }
2225 :
2226 0 : void VCLXWindow::draw( sal_Int32 nX, sal_Int32 nY ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2227 : {
2228 0 : SolarMutexGuard aGuard;
2229 :
2230 0 : Window* pWindow = GetWindow();
2231 0 : if ( !pWindow )
2232 0 : return;
2233 :
2234 0 : if ( isDesignMode() || mpImpl->isEnableVisible() )
2235 : {
2236 0 : OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( mpImpl->mxViewGraphics );
2237 0 : if (!pDev)
2238 0 : pDev = pWindow->GetParent();
2239 0 : TabPage* pTabPage = dynamic_cast< TabPage* >( pWindow );
2240 0 : if ( pTabPage )
2241 : {
2242 0 : Point aPos( nX, nY );
2243 0 : Size aSize = pWindow->GetSizePixel();
2244 :
2245 0 : aPos = pDev->PixelToLogic( aPos );
2246 0 : aSize = pDev->PixelToLogic( aSize );
2247 :
2248 0 : pTabPage->Draw( pDev, aPos, aSize, 0 );
2249 0 : return;
2250 : }
2251 :
2252 0 : Point aPos( nX, nY );
2253 :
2254 0 : if ( pWindow->GetParent() && !pWindow->IsSystemWindow() && ( pWindow->GetParent() == pDev ) )
2255 : {
2256 : // #i40647# don't draw here if this is a recursive call
2257 : // sometimes this is called recursively, because the Update call on the parent
2258 : // (strangely) triggers another paint. Prevent a stack overflow here
2259 : // Yes, this is only fixing symptoms for the moment ....
2260 : // #i40647# / 2005-01-18 / frank.schoenheit@sun.com
2261 0 : if ( !mpImpl->getDrawingOntoParent_ref() )
2262 : {
2263 0 : ::comphelper::FlagGuard aDrawingflagGuard( mpImpl->getDrawingOntoParent_ref() );
2264 :
2265 0 : bool bWasVisible = pWindow->IsVisible();
2266 0 : Point aOldPos( pWindow->GetPosPixel() );
2267 :
2268 0 : if ( bWasVisible && aOldPos == aPos )
2269 : {
2270 0 : pWindow->Update();
2271 0 : return;
2272 : }
2273 :
2274 0 : pWindow->SetPosPixel( aPos );
2275 :
2276 : // Update parent first to avoid painting the parent upon the update
2277 : // of this window, as it may otherwise cause the parent
2278 : // to hide this window again
2279 0 : if( pWindow->GetParent() )
2280 0 : pWindow->GetParent()->Update();
2281 :
2282 0 : pWindow->Show();
2283 0 : pWindow->Update();
2284 0 : pWindow->SetParentUpdateMode( false );
2285 0 : pWindow->Hide();
2286 0 : pWindow->SetParentUpdateMode( true );
2287 :
2288 0 : pWindow->SetPosPixel( aOldPos );
2289 0 : if ( bWasVisible )
2290 0 : pWindow->Show( true );
2291 : }
2292 : }
2293 0 : else if ( pDev )
2294 : {
2295 0 : Size aSz = pWindow->GetSizePixel();
2296 0 : aSz = pDev->PixelToLogic( aSz );
2297 0 : Point aP = pDev->PixelToLogic( aPos );
2298 :
2299 0 : vcl::PDFExtOutDevData* pPDFExport = dynamic_cast<vcl::PDFExtOutDevData*>(pDev->GetExtOutDevData());
2300 0 : bool bDrawSimple = ( pDev->GetOutDevType() == OUTDEV_PRINTER )
2301 0 : || ( pDev->GetOutDevViewType() == OUTDEV_VIEWTYPE_PRINTPREVIEW )
2302 0 : || ( pPDFExport != NULL );
2303 0 : if ( bDrawSimple )
2304 : {
2305 0 : pWindow->Draw( pDev, aP, aSz, WINDOW_DRAW_NOCONTROLS );
2306 : }
2307 : else
2308 : {
2309 0 : bool bOldNW =pWindow->IsNativeWidgetEnabled();
2310 0 : if( bOldNW )
2311 0 : pWindow->EnableNativeWidget(false);
2312 0 : pWindow->PaintToDevice( pDev, aP, aSz );
2313 0 : if( bOldNW )
2314 0 : pWindow->EnableNativeWidget(true);
2315 : }
2316 : }
2317 0 : }
2318 : }
2319 :
2320 0 : void VCLXWindow::setZoom( float fZoomX, float /*fZoomY*/ ) throw(::com::sun::star::uno::RuntimeException, std::exception)
2321 : {
2322 0 : SolarMutexGuard aGuard;
2323 :
2324 0 : if ( GetWindow() )
2325 : {
2326 : // Fraction::Fraction takes a double, but we have a float only.
2327 : // The implicit conversion from float to double can result in a precision loss, i.e. 1.2 is converted to
2328 : // 1.200000000047something. To prevent this, we convert explicitly to double, and round it.
2329 0 : double nZoom( fZoomX );
2330 0 : nZoom = ::rtl::math::round( nZoom, 4 );
2331 0 : GetWindow()->SetZoom( Fraction( nZoom ) );
2332 0 : }
2333 0 : }
2334 :
2335 : // ::com::sun::star::lang::XEventListener
2336 0 : void SAL_CALL VCLXWindow::disposing( const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException, std::exception)
2337 : {
2338 0 : SolarMutexGuard aGuard;
2339 :
2340 : // check if it comes from our AccessibleContext
2341 0 : uno::Reference< uno::XInterface > aAC( mpImpl->mxAccessibleContext, uno::UNO_QUERY );
2342 0 : uno::Reference< uno::XInterface > xSource( _rSource.Source, uno::UNO_QUERY );
2343 :
2344 0 : if ( aAC.get() == xSource.get() )
2345 : { // yep, it does
2346 0 : mpImpl->mxAccessibleContext = uno::Reference< accessibility::XAccessibleContext >();
2347 0 : }
2348 0 : }
2349 :
2350 : // ::com::sun::star::accessibility::XAccessible
2351 0 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXWindow::getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
2352 : {
2353 : using namespace ::com::sun::star;
2354 :
2355 0 : SolarMutexGuard aGuard;
2356 :
2357 : // already disposed
2358 0 : if( ! mpImpl )
2359 0 : return uno::Reference< accessibility::XAccessibleContext >();
2360 :
2361 0 : if ( !mpImpl->mxAccessibleContext.is() && GetWindow() )
2362 : {
2363 0 : mpImpl->mxAccessibleContext = CreateAccessibleContext();
2364 :
2365 : // add as event listener to this component
2366 : // in case somebody disposes it, we do not want to have a (though weak) reference to a dead
2367 : // object
2368 0 : uno::Reference< lang::XComponent > xComp( mpImpl->mxAccessibleContext, uno::UNO_QUERY );
2369 0 : if ( xComp.is() )
2370 0 : xComp->addEventListener( this );
2371 : }
2372 :
2373 0 : return mpImpl->mxAccessibleContext;
2374 : }
2375 :
2376 : // ::com::sun::star::awt::XDockable
2377 0 : void SAL_CALL VCLXWindow::addDockableWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDockableWindowListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception)
2378 : {
2379 0 : SolarMutexGuard aGuard;
2380 :
2381 0 : if ( xListener.is() )
2382 0 : mpImpl->getDockableWindowListeners().addInterface( xListener );
2383 :
2384 0 : }
2385 :
2386 0 : void SAL_CALL VCLXWindow::removeDockableWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDockableWindowListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception)
2387 : {
2388 0 : SolarMutexGuard aGuard;
2389 :
2390 0 : mpImpl->getDockableWindowListeners().removeInterface( xListener );
2391 0 : }
2392 :
2393 0 : void SAL_CALL VCLXWindow::enableDocking( sal_Bool bEnable ) throw (::com::sun::star::uno::RuntimeException, std::exception)
2394 : {
2395 0 : SolarMutexGuard aGuard;
2396 :
2397 0 : Window* pWindow = GetWindow();
2398 0 : if ( pWindow )
2399 0 : pWindow->EnableDocking( bEnable );
2400 0 : }
2401 :
2402 0 : sal_Bool SAL_CALL VCLXWindow::isFloating( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
2403 : {
2404 0 : SolarMutexGuard aGuard;
2405 :
2406 0 : Window* pWindow = GetWindow();
2407 0 : if( pWindow )
2408 0 : return Window::GetDockingManager()->IsFloating( pWindow );
2409 : else
2410 0 : return sal_False;
2411 : }
2412 :
2413 0 : void SAL_CALL VCLXWindow::setFloatingMode( sal_Bool bFloating ) throw (::com::sun::star::uno::RuntimeException, std::exception)
2414 : {
2415 0 : SolarMutexGuard aGuard;
2416 :
2417 0 : Window* pWindow = GetWindow();
2418 0 : if( pWindow )
2419 0 : Window::GetDockingManager()->SetFloatingMode( pWindow, bFloating );
2420 0 : }
2421 :
2422 0 : sal_Bool SAL_CALL VCLXWindow::isLocked( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
2423 : {
2424 0 : SolarMutexGuard aGuard;
2425 :
2426 0 : Window* pWindow = GetWindow();
2427 0 : if( pWindow )
2428 0 : return Window::GetDockingManager()->IsLocked( pWindow );
2429 : else
2430 0 : return sal_False;
2431 : }
2432 :
2433 0 : void SAL_CALL VCLXWindow::lock( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
2434 : {
2435 0 : SolarMutexGuard aGuard;
2436 :
2437 0 : Window* pWindow = GetWindow();
2438 0 : if( pWindow && !Window::GetDockingManager()->IsFloating( pWindow ) )
2439 0 : Window::GetDockingManager()->Lock( pWindow );
2440 0 : }
2441 :
2442 0 : void SAL_CALL VCLXWindow::unlock( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
2443 : {
2444 0 : SolarMutexGuard aGuard;
2445 :
2446 0 : Window* pWindow = GetWindow();
2447 0 : if( pWindow && !Window::GetDockingManager()->IsFloating( pWindow ) )
2448 0 : Window::GetDockingManager()->Unlock( pWindow );
2449 0 : }
2450 0 : void SAL_CALL VCLXWindow::startPopupMode( const ::com::sun::star::awt::Rectangle& ) throw (::com::sun::star::uno::RuntimeException, std::exception)
2451 : {
2452 : // TODO: remove interface in the next incompatible build
2453 0 : SolarMutexGuard aGuard;
2454 :
2455 0 : }
2456 :
2457 0 : sal_Bool SAL_CALL VCLXWindow::isInPopupMode( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
2458 : {
2459 : // TODO: remove interface in the next incompatible build
2460 0 : SolarMutexGuard aGuard;
2461 0 : return sal_False;
2462 : }
2463 :
2464 :
2465 : // ::com::sun::star::awt::XWindow2
2466 :
2467 0 : void SAL_CALL VCLXWindow::setOutputSize( const ::com::sun::star::awt::Size& aSize ) throw (::com::sun::star::uno::RuntimeException, std::exception)
2468 : {
2469 0 : SolarMutexGuard aGuard;
2470 : Window *pWindow;
2471 0 : if( (pWindow = GetWindow()) != NULL )
2472 : {
2473 0 : DockingWindow *pDockingWindow = dynamic_cast< DockingWindow* >(pWindow);
2474 0 : if( pDockingWindow )
2475 0 : pDockingWindow->SetOutputSizePixel( VCLSize( aSize ) );
2476 : else
2477 0 : pWindow->SetOutputSizePixel( VCLSize( aSize ) );
2478 0 : }
2479 0 : }
2480 :
2481 0 : ::com::sun::star::awt::Size SAL_CALL VCLXWindow::getOutputSize( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
2482 : {
2483 0 : SolarMutexGuard aGuard;
2484 : Window *pWindow;
2485 0 : if( (pWindow = GetWindow()) != NULL )
2486 : {
2487 0 : DockingWindow *pDockingWindow = dynamic_cast< DockingWindow* >(pWindow);
2488 0 : if( pDockingWindow )
2489 0 : return AWTSize( pDockingWindow->GetOutputSizePixel() );
2490 : else
2491 0 : return AWTSize( pWindow->GetOutputSizePixel() );
2492 : }
2493 : else
2494 0 : return ::com::sun::star::awt::Size();
2495 : }
2496 :
2497 0 : sal_Bool SAL_CALL VCLXWindow::isVisible( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
2498 : {
2499 0 : SolarMutexGuard aGuard;
2500 0 : if( GetWindow() )
2501 0 : return GetWindow()->IsVisible();
2502 : else
2503 0 : return sal_False;
2504 : }
2505 :
2506 0 : sal_Bool SAL_CALL VCLXWindow::isActive( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
2507 : {
2508 0 : SolarMutexGuard aGuard;
2509 0 : if( GetWindow() )
2510 0 : return GetWindow()->IsActive();
2511 : else
2512 0 : return sal_False;
2513 :
2514 : }
2515 :
2516 0 : sal_Bool SAL_CALL VCLXWindow::isEnabled( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
2517 : {
2518 0 : SolarMutexGuard aGuard;
2519 0 : if( GetWindow() )
2520 0 : return GetWindow()->IsEnabled();
2521 : else
2522 0 : return sal_False;
2523 : }
2524 :
2525 0 : sal_Bool SAL_CALL VCLXWindow::hasFocus( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
2526 : {
2527 0 : SolarMutexGuard aGuard;
2528 0 : if( GetWindow() )
2529 0 : return GetWindow()->HasFocus();
2530 : else
2531 0 : return sal_False;
2532 : }
2533 :
2534 : // ::com::sun::star::beans::XPropertySetInfo
2535 :
2536 : UnoPropertyArrayHelper *
2537 0 : VCLXWindow::GetPropHelper()
2538 : {
2539 0 : SolarMutexGuard aGuard;
2540 0 : if ( mpImpl->mpPropHelper == NULL )
2541 : {
2542 0 : std::list< sal_uInt16 > aIDs;
2543 0 : GetPropertyIds( aIDs );
2544 0 : mpImpl->mpPropHelper = new UnoPropertyArrayHelper( aIDs );
2545 : }
2546 0 : return mpImpl->mpPropHelper;
2547 : }
2548 :
2549 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL
2550 0 : VCLXWindow::getProperties() throw (::com::sun::star::uno::RuntimeException, std::exception)
2551 : {
2552 0 : return GetPropHelper()->getProperties();
2553 : }
2554 : ::com::sun::star::beans::Property SAL_CALL
2555 0 : VCLXWindow::getPropertyByName( const OUString& rName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception)
2556 : {
2557 0 : return GetPropHelper()->getPropertyByName( rName );
2558 : }
2559 :
2560 : sal_Bool SAL_CALL
2561 0 : VCLXWindow::hasPropertyByName( const OUString& rName ) throw (::com::sun::star::uno::RuntimeException, std::exception)
2562 : {
2563 0 : return GetPropHelper()->hasPropertyByName( rName );
2564 : }
2565 :
2566 0 : Reference< XStyleSettings > SAL_CALL VCLXWindow::getStyleSettings() throw (RuntimeException, std::exception)
2567 : {
2568 0 : return mpImpl->getStyleSettings();
2569 3 : }
2570 :
2571 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|