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