LCOV - code coverage report
Current view: top level - toolkit/source/awt - vclxtoolkit.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 332 813 40.8 %
Date: 2015-06-13 12:38:46 Functions: 31 55 56.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <boost/ptr_container/ptr_vector.hpp>
      21             : 
      22             : #include <stdio.h>
      23             : #ifdef WNT
      24             : #include <prewin.h>
      25             : #include <postwin.h>
      26             : #endif
      27             : #include <com/sun/star/awt/WindowAttribute.hpp>
      28             : #include <com/sun/star/awt/VclWindowPeerAttribute.hpp>
      29             : #include <com/sun/star/awt/WindowClass.hpp>
      30             : #include <com/sun/star/awt/MessageBoxButtons.hpp>
      31             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      32             : #include <com/sun/star/lang/SystemDependent.hpp>
      33             : #include <com/sun/star/awt/FocusEvent.hpp>
      34             : #include <com/sun/star/awt/KeyEvent.hpp>
      35             : #include <com/sun/star/awt/KeyModifier.hpp>
      36             : #include <com/sun/star/lang/EventObject.hpp>
      37             : #include <com/sun/star/uno/Reference.hxx>
      38             : #include <com/sun/star/uno/Sequence.hxx>
      39             : #include <com/sun/star/uno/XComponentContext.hpp>
      40             : #include <com/sun/star/uno/XInterface.hpp>
      41             : #include <com/sun/star/beans/NamedValue.hpp>
      42             : #include <com/sun/star/datatransfer/clipboard/SystemClipboard.hpp>
      43             : #include <com/sun/star/lang/XServiceInfo.hpp>
      44             : #include <com/sun/star/awt/XToolkitExperimental.hpp>
      45             : #include <com/sun/star/awt/XMessageBoxFactory.hpp>
      46             : 
      47             : #include <cppuhelper/bootstrap.hxx>
      48             : #include <cppuhelper/compbase2.hxx>
      49             : #include <cppuhelper/interfacecontainer.hxx>
      50             : #include <cppuhelper/supportsservice.hxx>
      51             : #include <cppuhelper/typeprovider.hxx>
      52             : #include <osl/conditn.hxx>
      53             : #include <osl/module.h>
      54             : #include <osl/thread.h>
      55             : #include <osl/mutex.hxx>
      56             : #include <rtl/uuid.h>
      57             : #include <rtl/process.h>
      58             : #include <tools/link.hxx>
      59             : #include <tools/fract.hxx>
      60             : #include <tools/wintypes.hxx>
      61             : 
      62             : #ifdef MACOSX
      63             : #include "premac.h"
      64             : #include <Cocoa/Cocoa.h>
      65             : #include "postmac.h"
      66             : #endif
      67             : 
      68             : #include <vcl/sysdata.hxx>
      69             : 
      70             : #include <toolkit/awt/vclxwindows.hxx>
      71             : #include <toolkit/awt/vclxsystemdependentwindow.hxx>
      72             : #include <toolkit/awt/vclxregion.hxx>
      73             : #include <toolkit/awt/vclxtabpagecontainer.hxx>
      74             : 
      75             : #include <toolkit/awt/animatedimagespeer.hxx>
      76             : #include <toolkit/awt/vclxtopwindow.hxx>
      77             : #include <toolkit/awt/vclxwindow.hxx>
      78             : #include <toolkit/helper/vclunohelper.hxx>
      79             : #include <toolkit/helper/servicenames.hxx>
      80             : 
      81             : #include <toolkit/helper/macros.hxx>
      82             : #include <toolkit/helper/convert.hxx>
      83             : #include <vcl/unohelp.hxx>
      84             : #include <vcl/button.hxx>
      85             : #include <vcl/combobox.hxx>
      86             : #include <vcl/ctrl.hxx>
      87             : #include <vcl/dialog.hxx>
      88             : #include <vcl/dockingarea.hxx>
      89             : #include <vcl/dockwin.hxx>
      90             : #include <vcl/edit.hxx>
      91             : #include <vcl/field.hxx>
      92             : #include <vcl/fixed.hxx>
      93             : #include <vcl/floatwin.hxx>
      94             : #include <vcl/group.hxx>
      95             : #include <vcl/scheduler.hxx>
      96             : #include <vcl/imgctrl.hxx>
      97             : #include <vcl/longcurr.hxx>
      98             : #include <vcl/lstbox.hxx>
      99             : #include <vcl/menubtn.hxx>
     100             : #include <vcl/morebtn.hxx>
     101             : #include <vcl/msgbox.hxx>
     102             : #include <vcl/scrbar.hxx>
     103             : #include <vcl/spin.hxx>
     104             : #include <vcl/split.hxx>
     105             : #include <vcl/splitwin.hxx>
     106             : #include <vcl/status.hxx>
     107             : #include <vcl/svapp.hxx>
     108             : #include <vcl/syschild.hxx>
     109             : #include <vcl/tabctrl.hxx>
     110             : #include <vcl/tabdlg.hxx>
     111             : #include <vcl/tabpage.hxx>
     112             : #include <vcl/toolbox.hxx>
     113             : #include <vcl/virdev.hxx>
     114             : #include <vcl/window.hxx>
     115             : #include <vcl/wrkwin.hxx>
     116             : #include <vcl/throbber.hxx>
     117             : #include "toolkit/awt/vclxspinbutton.hxx"
     118             : #include <tools/debug.hxx>
     119             : #include <comphelper/processfactory.hxx>
     120             : #include <toolkit/awt/scrollabledialog.hxx>
     121             : 
     122             : #include "helper/unowrapper.hxx"
     123             : 
     124             : #define VCLWINDOW_FRAMEWINDOW               0x1000
     125             : #define VCLWINDOW_SYSTEMCHILDWINDOW         0x1001
     126             : 
     127             : #if (defined WNT)
     128             : #define SYSTEM_DEPENDENT_TYPE ::com::sun::star::lang::SystemDependent::SYSTEM_WIN32
     129             : #elif (defined MACOSX)
     130             : #define SYSTEM_DEPENDENT_TYPE ::com::sun::star::lang::SystemDependent::SYSTEM_MAC
     131             : #elif (defined UNX)
     132             : #define SYSTEM_DEPENDENT_TYPE ::com::sun::star::lang::SystemDependent::SYSTEM_XWINDOW
     133             : #endif
     134             : 
     135             : namespace {
     136             : 
     137             : extern "C" typedef vcl::Window* (SAL_CALL *FN_SvtCreateWindow)(
     138             :         VCLXWindow** ppNewComp,
     139             :         const css::awt::WindowDescriptor* pDescriptor,
     140             :         vcl::Window* pParent,
     141             :         WinBits nWinBits );
     142             : 
     143       98594 : class VCLXToolkit_Impl
     144             : {
     145             : protected:
     146             :     ::osl::Mutex    maMutex;
     147             : };
     148             : 
     149             : class VCLXToolkit : public VCLXToolkit_Impl,
     150             :                     public cppu::WeakComponentImplHelper2<
     151             :                     css::awt::XToolkitExperimental,
     152             :                     css::lang::XServiceInfo >
     153             : {
     154             :     css::uno::Reference< css::datatransfer::clipboard::XClipboard > mxClipboard;
     155             :     css::uno::Reference< css::datatransfer::clipboard::XClipboard > mxSelection;
     156             : 
     157             :     oslModule           hSvToolsLib;
     158             :     FN_SvtCreateWindow  fnSvtCreateWindow;
     159             : 
     160             :     ::cppu::OInterfaceContainerHelper m_aTopWindowListeners;
     161             :     ::cppu::OInterfaceContainerHelper m_aKeyHandlers;
     162             :     ::cppu::OInterfaceContainerHelper m_aFocusListeners;
     163             :     ::Link<> m_aEventListenerLink;
     164             :     ::Link<> m_aKeyListenerLink;
     165             :     bool m_bEventListener;
     166             :     bool m_bKeyListener;
     167             : 
     168             :     DECL_LINK(eventListenerHandler, ::VclSimpleEvent const *);
     169             : 
     170             :     DECL_LINK(keyListenerHandler, ::VclSimpleEvent const *);
     171             : 
     172             :     void callTopWindowListeners(
     173             :         ::VclSimpleEvent const * pEvent,
     174             :         void (SAL_CALL css::awt::XTopWindowListener::* pFn)(
     175             :             css::lang::EventObject const &));
     176             : 
     177             :     long callKeyHandlers(::VclSimpleEvent const * pEvent, bool bPressed);
     178             : 
     179             :     void callFocusListeners(::VclSimpleEvent const * pEvent, bool bGained);
     180             : 
     181             : protected:
     182       79243 :     ::osl::Mutex&   GetMutex() { return maMutex; }
     183             : 
     184             :     virtual void SAL_CALL disposing() SAL_OVERRIDE;
     185             : 
     186             :     static vcl::Window* ImplCreateWindow( VCLXWindow** ppNewComp, const css::awt::WindowDescriptor& rDescriptor, vcl::Window* pParent, WinBits nWinBits );
     187             :     css::uno::Reference< css::awt::XWindowPeer > ImplCreateWindow( const css::awt::WindowDescriptor& Descriptor, WinBits nWinBits );
     188             : 
     189             : public:
     190             : 
     191             :     VCLXToolkit();
     192             :     virtual ~VCLXToolkit();
     193             : 
     194             :     // css::awt::XToolkitExperimental
     195             :     virtual void SAL_CALL processEventsToIdle()
     196             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     197             : 
     198             :     // css::awt::XToolkit
     199             :     css::uno::Reference< css::awt::XWindowPeer >  SAL_CALL getDesktopWindow(  ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     200             :     css::awt::Rectangle                                        SAL_CALL getWorkArea(  ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     201             :     css::uno::Reference< css::awt::XWindowPeer >  SAL_CALL createWindow( const css::awt::WindowDescriptor& Descriptor ) throw(css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     202             :     css::uno::Sequence< css::uno::Reference< css::awt::XWindowPeer > > SAL_CALL createWindows( const css::uno::Sequence< css::awt::WindowDescriptor >& Descriptors ) throw(css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     203             :     css::uno::Reference< css::awt::XDevice >      SAL_CALL createScreenCompatibleDevice( sal_Int32 Width, sal_Int32 Height ) throw
     204             : (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     205             :     css::uno::Reference< css::awt::XRegion >      SAL_CALL createRegion(  ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     206             : 
     207             :     // css::awt::XSystemChildFactory
     208             :     css::uno::Reference< css::awt::XWindowPeer > SAL_CALL createSystemChild( const css::uno::Any& Parent, const css::uno::Sequence< sal_Int8 >& ProcessId, sal_Int16 SystemType ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     209             : 
     210             :     // css::awt::XMessageBoxFactory
     211             :     virtual css::uno::Reference< css::awt::XMessageBox > SAL_CALL createMessageBox( const css::uno::Reference< css::awt::XWindowPeer >& aParent, css::awt::MessageBoxType eType, ::sal_Int32 aButtons, const OUString& aTitle, const OUString& aMessage ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     212             : 
     213             :     // css::awt::XDataTransfer
     214             :     css::uno::Reference< css::datatransfer::dnd::XDragGestureRecognizer > SAL_CALL getDragGestureRecognizer( const css::uno::Reference< css::awt::XWindow >& window ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     215             :     css::uno::Reference< css::datatransfer::dnd::XDragSource > SAL_CALL getDragSource( const css::uno::Reference< css::awt::XWindow >& window ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     216             :     css::uno::Reference< css::datatransfer::dnd::XDropTarget > SAL_CALL getDropTarget( const css::uno::Reference< css::awt::XWindow >& window ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     217             :     css::uno::Reference< css::datatransfer::clipboard::XClipboard > SAL_CALL getClipboard( const OUString& clipboardName ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     218             : 
     219             :     // css::lang::XServiceInfo
     220             :     OUString SAL_CALL getImplementationName(  ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     221             :     sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     222             :     css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     223             : 
     224             :     // css::awt::XExtendedToolkit:
     225             : 
     226             :     virtual ::sal_Int32 SAL_CALL getTopWindowCount()
     227             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     228             : 
     229             :     virtual css::uno::Reference< css::awt::XTopWindow >
     230             :     SAL_CALL getTopWindow(::sal_Int32 nIndex)
     231             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     232             : 
     233             :     virtual css::uno::Reference< css::awt::XTopWindow >
     234             :     SAL_CALL getActiveTopWindow()
     235             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     236             : 
     237             :     virtual void SAL_CALL addTopWindowListener(
     238             :         css::uno::Reference<
     239             :         css::awt::XTopWindowListener > const & rListener)
     240             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     241             : 
     242             :     virtual void SAL_CALL removeTopWindowListener(
     243             :         css::uno::Reference<
     244             :         css::awt::XTopWindowListener > const & rListener)
     245             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     246             : 
     247             :     virtual void SAL_CALL addKeyHandler(
     248             :         css::uno::Reference<
     249             :         css::awt::XKeyHandler > const & rHandler)
     250             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     251             : 
     252             :     virtual void SAL_CALL removeKeyHandler(
     253             :         css::uno::Reference<
     254             :         css::awt::XKeyHandler > const & rHandler)
     255             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     256             : 
     257             :     virtual void SAL_CALL addFocusListener(
     258             :         css::uno::Reference<
     259             :         css::awt::XFocusListener > const & rListener)
     260             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     261             : 
     262             :     virtual void SAL_CALL removeFocusListener(
     263             :         css::uno::Reference<
     264             :         css::awt::XFocusListener > const & rListener)
     265             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     266             : 
     267             :     virtual void SAL_CALL fireFocusGained(
     268             :         css::uno::Reference<
     269             :         css::uno::XInterface > const & source)
     270             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     271             : 
     272             :     virtual void SAL_CALL fireFocusLost(
     273             :         css::uno::Reference<
     274             :         css::uno::XInterface > const & source)
     275             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     276             : 
     277             :     // css::awt::XReschedule:
     278             :     virtual void SAL_CALL reschedule()
     279             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     280             : };
     281             : 
     282       29910 : WinBits ImplGetWinBits( sal_uInt32 nComponentAttribs, sal_uInt16 nCompType )
     283             : {
     284       29910 :     WinBits nWinBits = 0;
     285             : 
     286       29910 :     bool bMessBox = false;
     287       29910 :     if ( ( nCompType == WINDOW_INFOBOX ) ||
     288       29910 :          ( nCompType == WINDOW_MESSBOX ) ||
     289       29910 :          ( nCompType == WINDOW_QUERYBOX ) ||
     290       29910 :          ( nCompType == WINDOW_WARNINGBOX ) ||
     291             :          ( nCompType == WINDOW_ERRORBOX ) )
     292             :     {
     293           0 :         bMessBox = true;
     294             :     }
     295             : 
     296       29910 :     bool bDecoratedWindow = false;
     297       29910 :     if  (   bMessBox
     298       29910 :         ||  ( nCompType == WINDOW_DIALOG )
     299       29906 :         ||  ( nCompType == WINDOW_MODELESSDIALOG )
     300       29903 :         ||  ( nCompType == WINDOW_MODALDIALOG )
     301       29903 :         ||  ( nCompType == WINDOW_SYSTEMDIALOG )
     302       29903 :         ||  ( nCompType == WINDOW_PATHDIALOG )
     303       29903 :         ||  ( nCompType == WINDOW_FILEDIALOG )
     304       29903 :         ||  ( nCompType == WINDOW_PRINTERSETUPDIALOG )
     305       29903 :         ||  ( nCompType == WINDOW_PRINTDIALOG )
     306       29903 :         ||  ( nCompType == WINDOW_COLORDIALOG )
     307       29903 :         ||  ( nCompType == WINDOW_FONTDIALOG )
     308       29903 :         ||  ( nCompType == WINDOW_DOCKINGWINDOW )
     309       29902 :         ||  ( nCompType == WINDOW_TABDIALOG )
     310       29902 :         ||  ( nCompType == WINDOW_BUTTONDIALOG )
     311       29902 :         ||  ( nCompType == WINDOW_SYSTEMCHILDWINDOW )
     312             :         )
     313             :     {
     314           8 :         bDecoratedWindow = true;
     315             :     }
     316             : 
     317       29910 :     if( nComponentAttribs & ::com::sun::star::awt::WindowAttribute::BORDER )
     318        3505 :         nWinBits |= WB_BORDER;
     319       29910 :     if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::NOBORDER )
     320           3 :         nWinBits |= WB_NOBORDER;
     321       29910 :     if( nComponentAttribs & ::com::sun::star::awt::WindowAttribute::SIZEABLE )
     322        3283 :         nWinBits |= WB_SIZEABLE;
     323       29910 :     if( nComponentAttribs & ::com::sun::star::awt::WindowAttribute::MOVEABLE )
     324        3287 :         nWinBits |= WB_MOVEABLE;
     325       29910 :     if( nComponentAttribs & ::com::sun::star::awt::WindowAttribute::CLOSEABLE )
     326        3287 :         nWinBits |= WB_CLOSEABLE;
     327       29910 :     if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::HSCROLL )
     328          11 :         nWinBits |= WB_HSCROLL;
     329       29910 :     if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::VSCROLL )
     330          11 :         nWinBits |= WB_VSCROLL;
     331       29910 :     if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::LEFT )
     332         228 :         nWinBits |= WB_LEFT;
     333       29910 :     if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::CENTER )
     334          76 :         nWinBits |= WB_CENTER;
     335       29910 :     if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::RIGHT )
     336           0 :         nWinBits |= WB_RIGHT;
     337       29910 :     if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::SPIN )
     338          24 :         nWinBits |= WB_SPIN;
     339       29910 :     if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::SORT )
     340           0 :         nWinBits |= WB_SORT;
     341       29910 :     if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::DROPDOWN )
     342          39 :         nWinBits |= WB_DROPDOWN;
     343       29910 :     if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::DEFBUTTON )
     344           0 :         nWinBits |= WB_DEFBUTTON;
     345       29910 :     if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::READONLY )
     346           0 :         nWinBits |= WB_READONLY;
     347       29910 :     if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::CLIPCHILDREN )
     348        3282 :         nWinBits |= WB_CLIPCHILDREN;
     349       29910 :     if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::GROUP )
     350           0 :         nWinBits |= WB_GROUP;
     351       29910 :     if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::NOLABEL ) //added for issue79712
     352           0 :         nWinBits |= WB_NOLABEL;
     353             : 
     354             :     // These bits are not uniqe
     355       29910 :     if ( bMessBox )
     356             :     {
     357           0 :         if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::OK )
     358           0 :             nWinBits |= WB_OK;
     359           0 :         if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::OK_CANCEL )
     360           0 :             nWinBits |= WB_OK_CANCEL;
     361           0 :         if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::YES_NO )
     362           0 :             nWinBits |= WB_YES_NO;
     363           0 :         if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::YES_NO_CANCEL )
     364           0 :             nWinBits |= WB_YES_NO_CANCEL;
     365           0 :         if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::RETRY_CANCEL )
     366           0 :             nWinBits |= WB_RETRY_CANCEL;
     367           0 :         if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::DEF_OK )
     368           0 :             nWinBits |= WB_DEF_OK;
     369           0 :         if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::DEF_CANCEL )
     370           0 :             nWinBits |= WB_DEF_CANCEL;
     371           0 :         if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::DEF_RETRY )
     372           0 :             nWinBits |= WB_DEF_RETRY;
     373           0 :         if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::DEF_YES )
     374           0 :             nWinBits |= WB_DEF_YES;
     375           0 :         if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::DEF_NO )
     376           0 :             nWinBits |= WB_DEF_NO;
     377             :     }
     378       29910 :     if ( nCompType == WINDOW_MULTILINEEDIT || nCompType == WINDOW_DIALOG || nCompType == WINDOW_GROUPBOX )
     379             :     {
     380          24 :         if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::AUTOHSCROLL )
     381           0 :             nWinBits |= WB_AUTOHSCROLL;
     382          24 :         if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::AUTOVSCROLL )
     383           0 :             nWinBits |= WB_AUTOVSCROLL;
     384             :     }
     385             : 
     386             : 
     387       29910 :     if ( bDecoratedWindow )
     388             :     {
     389           8 :         if( nComponentAttribs & ::com::sun::star::awt::WindowAttribute::NODECORATION )
     390             :         {
     391             :             // No decoration removes several window attributes and must
     392             :             // set WB_NOBORDER!
     393           0 :             nWinBits &= ~WB_BORDER;
     394           0 :             nWinBits &= ~WB_SIZEABLE;
     395           0 :             nWinBits &= ~WB_MOVEABLE;
     396           0 :             nWinBits &= ~WB_CLOSEABLE;
     397           0 :             nWinBits |= WB_NOBORDER;
     398             :         }
     399             :     }
     400             : 
     401       29910 :     return nWinBits;
     402             : }
     403             : 
     404             : struct ComponentInfo
     405             : {
     406             :     const char*     pName;
     407             :     WindowType      nWinType;
     408             : };
     409             : 
     410             : static ComponentInfo aComponentInfos [] =
     411             : {
     412             :     { "buttondialog",       WINDOW_BUTTONDIALOG },
     413             :     { "cancelbutton",       WINDOW_CANCELBUTTON },
     414             :     { "checkbox",           WINDOW_CHECKBOX },
     415             :     { "combobox",           WINDOW_COMBOBOX },
     416             :     { "control",            WINDOW_CONTROL },
     417             :     { "currencybox",        WINDOW_CURRENCYBOX },
     418             :     { "currencyfield",      WINDOW_CURRENCYFIELD },
     419             :     { "datebox",            WINDOW_DATEBOX },
     420             :     { "datefield",          WINDOW_DATEFIELD },
     421             :     { "dialog",             WINDOW_DIALOG },
     422             :     { "dockingarea",        WINDOW_DOCKINGAREA },
     423             :     { "dockingwindow",      WINDOW_DOCKINGWINDOW },
     424             :     { "edit",               WINDOW_EDIT },
     425             :     { "errorbox",           WINDOW_ERRORBOX },
     426             :     { "fixedbitmap",        WINDOW_FIXEDBITMAP },
     427             :     { "fixedimage",         WINDOW_FIXEDIMAGE },
     428             :     { "fixedline",          WINDOW_FIXEDLINE },
     429             :     { "fixedtext",          WINDOW_FIXEDTEXT },
     430             :     { "floatingwindow",     WINDOW_FLOATINGWINDOW },
     431             :     { "framewindow",        VCLWINDOW_FRAMEWINDOW },
     432             :     { "groupbox",           WINDOW_GROUPBOX },
     433             :     { "frame",          WINDOW_GROUPBOX },
     434             :     { "helpbutton",         WINDOW_HELPBUTTON },
     435             :     { "imagebutton",        WINDOW_IMAGEBUTTON },
     436             :     { "infobox",            WINDOW_INFOBOX },
     437             :     { "listbox",            WINDOW_LISTBOX },
     438             :     { "longcurrencybox",    WINDOW_LONGCURRENCYBOX },
     439             :     { "longcurrencyfield",  WINDOW_LONGCURRENCYFIELD },
     440             :     { "menubutton",         WINDOW_MENUBUTTON },
     441             :     { "messbox",            WINDOW_MESSBOX },
     442             :     { "metricbox",          WINDOW_METRICBOX },
     443             :     { "metricfield",        WINDOW_METRICFIELD },
     444             :     { "modaldialog",        WINDOW_MODALDIALOG },
     445             :     { "modelessdialog",     WINDOW_MODELESSDIALOG },
     446             :     { "morebutton",         WINDOW_MOREBUTTON },
     447             :     { "multilineedit",      WINDOW_MULTILINEEDIT },
     448             :     { "multilistbox",       WINDOW_MULTILISTBOX },
     449             :     { "numericbox",         WINDOW_NUMERICBOX },
     450             :     { "numericfield",       WINDOW_NUMERICFIELD },
     451             :     { "okbutton",           WINDOW_OKBUTTON },
     452             :     { "patternbox",         WINDOW_PATTERNBOX },
     453             :     { "patternfield",       WINDOW_PATTERNFIELD },
     454             :     { "pushbutton",         WINDOW_PUSHBUTTON },
     455             :     { "querybox",           WINDOW_QUERYBOX },
     456             :     { "radiobutton",        WINDOW_RADIOBUTTON },
     457             :     { "scrollbar",          WINDOW_SCROLLBAR },
     458             :     { "scrollbarbox",       WINDOW_SCROLLBARBOX },
     459             :     { "animatedimages",     WINDOW_CONTROL },
     460             :     { "spinbutton",         WINDOW_SPINBUTTON },
     461             :     { "spinfield",          WINDOW_SPINFIELD },
     462             :     { "splitter",           WINDOW_SPLITTER },
     463             :     { "splitwindow",        WINDOW_SPLITWINDOW },
     464             :     { "statusbar",          WINDOW_STATUSBAR },
     465             :     { "systemchildwindow",  VCLWINDOW_SYSTEMCHILDWINDOW },
     466             :     { "tabcontrol",         WINDOW_TABCONTROL },
     467             :     { "tabdialog",          WINDOW_TABDIALOG },
     468             :     { "tabpage",            WINDOW_TABPAGE },
     469             :     { "timebox",            WINDOW_TIMEBOX },
     470             :     { "timefield",          WINDOW_TIMEFIELD },
     471             :     { "toolbox",            WINDOW_TOOLBOX },
     472             :     { "tristatebox",        WINDOW_TRISTATEBOX },
     473             :     { "warningbox",         WINDOW_WARNINGBOX },
     474             :     { "window",             WINDOW_WINDOW },
     475             :     { "workwindow",         WINDOW_WORKWINDOW },
     476             :     { "tabpagecontainer",   WINDOW_CONTROL },
     477             :     { "tabpagemodel",       WINDOW_TABPAGE }
     478             : };
     479             : 
     480             : extern "C"
     481             : {
     482      374726 : static int SAL_CALL ComponentInfoCompare( const void* pFirst, const void* pSecond)
     483             : {
     484             :     return( strcmp( static_cast<ComponentInfo const *>(pFirst)->pName,
     485      374726 :                     static_cast<ComponentInfo const *>(pSecond)->pName ) );
     486             : }
     487             : }
     488             : 
     489       59739 : sal_uInt16 ImplGetComponentType( const OUString& rServiceName )
     490             : {
     491             :     static bool bSorted = false;
     492       59739 :     if( !bSorted )
     493             :     {
     494             :         qsort(  static_cast<void*>(aComponentInfos),
     495             :                 sizeof( aComponentInfos ) / sizeof( ComponentInfo ),
     496             :                 sizeof( ComponentInfo ),
     497         113 :                 ComponentInfoCompare );
     498         113 :         bSorted = true;
     499             :     }
     500             : 
     501             : 
     502             :     ComponentInfo aSearch;
     503       59739 :     OString aServiceName(OUStringToOString(rServiceName, osl_getThreadTextEncoding()).toAsciiLowerCase());
     504       59739 :     if ( !aServiceName.isEmpty() )
     505       59733 :         aSearch.pName = aServiceName.getStr();
     506             :     else
     507           6 :         aSearch.pName = "window";
     508             : 
     509             :     ComponentInfo* pInf = static_cast<ComponentInfo*>(bsearch( &aSearch,
     510             :                         static_cast<void*>(aComponentInfos),
     511             :                         sizeof( aComponentInfos ) / sizeof( ComponentInfo ),
     512             :                         sizeof( ComponentInfo ),
     513       59739 :                         ComponentInfoCompare ));
     514             : 
     515       59739 :     return pInf ? pInf->nWinType : 0;
     516             : }
     517             : 
     518             : 
     519             : namespace
     520             : {
     521             :     struct MessageBoxTypeInfo
     522             :     {
     523             :         css::awt::MessageBoxType eType;
     524             :         const sal_Char          *pName;
     525             :         sal_Int32                nLen;
     526             :     };
     527             : 
     528             :     static const MessageBoxTypeInfo aMessageBoxTypeInfo[] =
     529             :     {
     530             :         { css::awt::MessageBoxType_MESSAGEBOX,      RTL_CONSTASCII_STRINGPARAM("messbox") },
     531             :         { css::awt::MessageBoxType_INFOBOX,         RTL_CONSTASCII_STRINGPARAM("infobox") },
     532             :         { css::awt::MessageBoxType_WARNINGBOX,      RTL_CONSTASCII_STRINGPARAM("warningbox") },
     533             :         { css::awt::MessageBoxType_ERRORBOX,        RTL_CONSTASCII_STRINGPARAM("errorbox") },
     534             :         { css::awt::MessageBoxType_QUERYBOX,        RTL_CONSTASCII_STRINGPARAM("querybox") },
     535             :         { css::awt::MessageBoxType_MAKE_FIXED_SIZE, 0, 0 }
     536             :     };
     537             : 
     538           0 :     static bool lcl_convertMessageBoxType(
     539             :         rtl::OUString &sType,
     540             :         css::awt::MessageBoxType eType )
     541             :     {
     542           0 :         const MessageBoxTypeInfo *pMap = aMessageBoxTypeInfo;
     543           0 :         css::awt::MessageBoxType eVal = css::awt::MessageBoxType_MAKE_FIXED_SIZE;
     544             : 
     545           0 :         while ( pMap->pName )
     546             :         {
     547           0 :             if ( pMap->eType == eType )
     548             :             {
     549           0 :                 eVal = eType;
     550           0 :                 sType = rtl::OUString( pMap->pName, pMap->nLen, RTL_TEXTENCODING_ASCII_US );
     551           0 :                 break;
     552             :             }
     553           0 :             pMap++;
     554             :         }
     555             : 
     556           0 :         return ( eVal != css::awt::MessageBoxType_MAKE_FIXED_SIZE );
     557             :     }
     558             : }
     559             : 
     560             : static sal_Int32                            nVCLToolkitInstanceCount = 0;
     561             : static bool                                 bInitedByVCLToolkit = false;
     562             : 
     563       98594 : static osl::Mutex & getInitMutex()
     564             : {
     565             :     static osl::Mutex * pM;
     566       98594 :     if( !pM )
     567             :     {
     568         114 :         osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
     569         114 :         if( !pM )
     570             :         {
     571         114 :             static osl::Mutex aMutex;
     572         114 :             pM = &aMutex;
     573         114 :         }
     574             :     }
     575       98594 :     return *pM;
     576             : }
     577             : 
     578         323 : static osl::Condition & getInitCondition()
     579             : {
     580             :     static osl::Condition * pC = 0;
     581         323 :     if( !pC )
     582             :     {
     583           2 :         osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
     584           2 :         if( !pC )
     585             :         {
     586           2 :             static osl::Condition aCondition;
     587           2 :             pC = &aCondition;
     588           2 :         }
     589             :     }
     590         323 :     return *pC;
     591             : }
     592             : 
     593             : extern "C"
     594             : {
     595         162 : static void SAL_CALL ToolkitWorkerFunction( void* pArgs )
     596             : {
     597         162 :     osl_setThreadName("VCLXToolkit VCL main thread");
     598             : 
     599         162 :     css::uno::Reference<css::lang::XMultiServiceFactory> xServiceManager;
     600             :     try
     601             :     {
     602         162 :         xServiceManager = ::comphelper::getProcessServiceFactory();
     603             :     }
     604           0 :     catch (const css::uno::DeploymentException&)
     605             :     {
     606             :     }
     607         162 :     if (!xServiceManager.is())
     608             :     {
     609             :         css::uno::Reference<css::uno::XComponentContext> xContext =
     610           0 :             ::cppu::defaultBootstrap_InitialComponentContext();
     611             : 
     612           0 :         xServiceManager = css::uno::Reference<css::lang::XMultiServiceFactory>(
     613           0 :             xContext->getServiceManager(), css::uno::UNO_QUERY_THROW );
     614             :         // set global process service factory used by unotools config helpers
     615           0 :         ::comphelper::setProcessServiceFactory( xServiceManager );
     616             :     }
     617             : 
     618         162 :     VCLXToolkit * pTk = static_cast<VCLXToolkit *>(pArgs);
     619         162 :     bInitedByVCLToolkit = InitVCL();
     620         162 :     if( bInitedByVCLToolkit )
     621             :     {
     622           0 :         UnoWrapper* pUnoWrapper = new UnoWrapper( pTk );
     623           0 :         Application::SetUnoWrapper( pUnoWrapper );
     624             :     }
     625         162 :     getInitCondition().set();
     626         162 :     if( bInitedByVCLToolkit )
     627             :     {
     628             :         {
     629           0 :             SolarMutexGuard aGuard;
     630           0 :             Application::Execute();
     631             :         }
     632             :         try
     633             :         {
     634           0 :             pTk->dispose();
     635             :         }
     636           0 :         catch( com::sun::star::uno::Exception & )
     637             :         {
     638             :         }
     639           0 :         DeInitVCL();
     640             :     }
     641             :     else
     642             :     {
     643         162 :         JoinMainLoopThread();
     644         162 :     }
     645         162 : }
     646             : }
     647             : 
     648             : // constructor, which might initialize VCL
     649       49297 : VCLXToolkit::VCLXToolkit():
     650             :     cppu::WeakComponentImplHelper2<
     651             :     ::com::sun::star::awt::XToolkitExperimental,
     652       49297 :     ::com::sun::star::lang::XServiceInfo>( GetMutex() ),
     653             :     m_aTopWindowListeners(rBHelper.rMutex),
     654             :     m_aKeyHandlers(rBHelper.rMutex),
     655             :     m_aFocusListeners(rBHelper.rMutex),
     656             :     m_aEventListenerLink(LINK(this, VCLXToolkit, eventListenerHandler)),
     657             :     m_aKeyListenerLink(LINK(this, VCLXToolkit, keyListenerHandler)),
     658             :     m_bEventListener(false),
     659       98594 :     m_bKeyListener(false)
     660             : {
     661       49297 :     hSvToolsLib = NULL;
     662       49297 :     fnSvtCreateWindow = NULL;
     663             : 
     664       49297 :     osl::Guard< osl::Mutex > aGuard( getInitMutex() );
     665       49297 :     nVCLToolkitInstanceCount++;
     666       49297 :     if( ( nVCLToolkitInstanceCount == 1 ) && ( !Application::IsInMain() ) )
     667             :     {
     668             :         // setup execute thread
     669         162 :         CreateMainLoopThread( ToolkitWorkerFunction, this );
     670         162 :         getInitCondition().wait();
     671       49297 :     }
     672       49297 : }
     673             : 
     674       98594 : VCLXToolkit::~VCLXToolkit()
     675             : {
     676       98594 : }
     677             : 
     678             : 
     679       49297 : void SAL_CALL VCLXToolkit::disposing()
     680             : {
     681             : #ifndef DISABLE_DYNLOADING
     682       49297 :     if ( hSvToolsLib )
     683             :     {
     684       29603 :         osl_unloadModule( hSvToolsLib );
     685       29603 :         hSvToolsLib = NULL;
     686       29603 :         fnSvtCreateWindow = NULL;
     687             :     }
     688             : #endif
     689             : 
     690             :     {
     691       49297 :         osl::Guard< osl::Mutex > aGuard( getInitMutex() );
     692       49297 :         if( --nVCLToolkitInstanceCount == 0 )
     693             :         {
     694       40831 :             if( bInitedByVCLToolkit )
     695             :             {
     696           0 :                 Application::Quit();
     697           0 :                 JoinMainLoopThread();
     698           0 :                 bInitedByVCLToolkit = false;
     699             :             }
     700       49297 :         }
     701             :     }
     702             : 
     703       49297 :     if (m_bEventListener)
     704             :     {
     705           0 :         ::Application::RemoveEventListener(m_aEventListenerLink);
     706           0 :         m_bEventListener = false;
     707             :     }
     708       49297 :     if (m_bKeyListener)
     709             :     {
     710           0 :         ::Application::RemoveKeyListener(m_aKeyListenerLink);
     711           0 :         m_bKeyListener = false;
     712             :     }
     713             :     css::lang::EventObject aEvent(
     714       49297 :         static_cast< ::cppu::OWeakObject * >(this));
     715       49297 :     m_aTopWindowListeners.disposeAndClear(aEvent);
     716       49297 :     m_aKeyHandlers.disposeAndClear(aEvent);
     717       49297 :     m_aFocusListeners.disposeAndClear(aEvent);
     718       49297 : }
     719             : 
     720             : 
     721           1 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > VCLXToolkit::getDesktopWindow(  ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     722             : {
     723           1 :     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xRef;
     724             :     // 07/00: AppWindow doesn't exist anymore...
     725           1 :     return xRef;
     726             : }
     727             : 
     728           1 : ::com::sun::star::awt::Rectangle VCLXToolkit::getWorkArea(  ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     729             : {
     730           1 :     sal_Int32 nDisplay = Application::GetDisplayBuiltInScreen();
     731           1 :     Rectangle aWorkRect = Application::GetScreenPosSizePixel( nDisplay );
     732           1 :     com::sun::star::awt::Rectangle aNotherRect;
     733           1 :     aNotherRect.X = aWorkRect.getX();
     734           1 :     aNotherRect.Y = aWorkRect.getY();
     735           1 :     aNotherRect.Width = aWorkRect.getWidth();
     736           1 :     aNotherRect.Height = aWorkRect.getHeight();
     737           1 :     return aNotherRect;
     738             : }
     739             : 
     740       29910 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > VCLXToolkit::createWindow( const ::com::sun::star::awt::WindowDescriptor& rDescriptor ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception)
     741             : {
     742       29910 :     return ImplCreateWindow( rDescriptor, WinBits(0) );
     743             : }
     744             : 
     745          34 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > VCLXToolkit::createScreenCompatibleDevice( sal_Int32 Width, sal_Int32 Height ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     746             : {
     747          34 :     ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
     748             : 
     749          34 :     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > xRef;
     750          34 :     VCLXVirtualDevice* pVDev = new VCLXVirtualDevice;
     751             : 
     752          68 :     SolarMutexGuard aSolarGuard;
     753             : 
     754          68 :     VclPtrInstance<VirtualDevice> pV;
     755          34 :     pV->SetOutputSizePixel( Size( Width, Height ) );
     756          34 :     pVDev->SetVirtualDevice( pV );
     757             : 
     758          34 :     xRef = pVDev;
     759          68 :     return xRef;
     760             : }
     761             : 
     762           1 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion > VCLXToolkit::createRegion(  ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     763             : {
     764           1 :     ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
     765             : 
     766           1 :     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >  xRef = new VCLXRegion;
     767           1 :     return xRef;
     768             : }
     769             : 
     770       29829 : vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp,
     771             :     const ::com::sun::star::awt::WindowDescriptor& rDescriptor,
     772             :     vcl::Window* pParent, WinBits nWinBits )
     773             : {
     774       29829 :     OUString aServiceName( rDescriptor.WindowServiceName );
     775       29829 :     aServiceName = aServiceName.toAsciiLowerCase();
     776             : 
     777       29829 :     vcl::Window* pNewWindow = NULL;
     778       29829 :     sal_uInt16 nType = ImplGetComponentType( aServiceName );
     779       29829 :     bool bFrameControl = false;
     780       29829 :     if ( aServiceName == "frame" )
     781           0 :         bFrameControl = true;
     782       29829 :     if ( aServiceName == "tabcontrolnotabs" )
     783             :     {
     784           0 :         nWinBits |= WB_NOBORDER;
     785           0 :         nType = ImplGetComponentType( OUString( "tabcontrol" ) );
     786             :     }
     787       29829 :     if ( !pParent )
     788             :     {
     789             :         // Wenn die Component einen Parent braucht, dann NULL zurueckgeben,
     790             :         // spaeter mal ::com::sun::star::uno::Exception...
     791        3287 :         bool bException = true;
     792        3287 :         if  (   ( nType == WINDOW_DIALOG )
     793        3285 :             ||  ( nType == WINDOW_MODALDIALOG )
     794        3285 :             ||  ( nType == WINDOW_MODELESSDIALOG )
     795        3282 :             ||  ( nType == WINDOW_MESSBOX )
     796        3282 :             ||  ( nType == WINDOW_INFOBOX )
     797        3282 :             ||  ( nType == WINDOW_WARNINGBOX )
     798        3282 :             ||  ( nType == WINDOW_ERRORBOX )
     799        3282 :             ||  ( nType == WINDOW_QUERYBOX )
     800             :             )
     801           5 :             bException = false;
     802        3282 :         else if ( ( nType == WINDOW_WINDOW ) ||
     803           0 :                   ( nType == WINDOW_WORKWINDOW ) ||
     804             :                   ( nType == VCLWINDOW_FRAMEWINDOW ) )
     805             :         {
     806        3282 :             if ( rDescriptor.Type == ::com::sun::star::awt::WindowClass_TOP )
     807        3282 :                 bException = false;
     808             :         }
     809             : 
     810        3287 :         if ( bException )
     811             :         {
     812           0 :             *ppNewComp = NULL;
     813           0 :             return NULL;
     814             :         }
     815             :     }
     816             : 
     817       29829 :     if ( nType )
     818             :     {
     819       29829 :         SolarMutexGuard aVclGuard;
     820       29829 :         switch ( (WindowType)nType )
     821             :         {
     822             :             case WINDOW_CANCELBUTTON:
     823           0 :                 pNewWindow = VclPtr<CancelButton>::Create( pParent, nWinBits );
     824           0 :                 *ppNewComp = new VCLXButton;
     825           0 :             break;
     826             :             case WINDOW_CHECKBOX:
     827          21 :                  pNewWindow = VclPtr<CheckBox>::Create( pParent, nWinBits );
     828          21 :                 *ppNewComp = new VCLXCheckBox;
     829          21 :             break;
     830             :             case WINDOW_COMBOBOX:
     831          28 :                 pNewWindow = VclPtr<ComboBox>::Create( pParent, nWinBits|WB_AUTOHSCROLL );
     832          28 :                 static_cast<ComboBox*>(pNewWindow)->EnableAutoSize( false );
     833          28 :                 *ppNewComp = new VCLXComboBox;
     834          28 :             break;
     835             :             case WINDOW_CURRENCYBOX:
     836           0 :                 pNewWindow = VclPtr<CurrencyBox>::Create( pParent, nWinBits );
     837           0 :             break;
     838             :             case WINDOW_CURRENCYFIELD:
     839           0 :                 pNewWindow = VclPtr<CurrencyField>::Create( pParent, nWinBits );
     840           0 :                 static_cast<CurrencyField*>(pNewWindow)->EnableEmptyFieldValue( true );
     841           0 :                 *ppNewComp = new VCLXNumericField;
     842           0 :                 static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<CurrencyField*>(pNewWindow)) );
     843           0 :             break;
     844             :             case WINDOW_DATEBOX:
     845           0 :                 pNewWindow = VclPtr<DateBox>::Create( pParent, nWinBits );
     846           0 :             break;
     847             :             case WINDOW_DATEFIELD:
     848           0 :                 pNewWindow = VclPtr<DateField>::Create( pParent, nWinBits );
     849           0 :                 static_cast<DateField*>(pNewWindow)->EnableEmptyFieldValue( true );
     850           0 :                 *ppNewComp = new VCLXDateField;
     851           0 :                 static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<DateField*>(pNewWindow)) );
     852           0 :             break;
     853             :             case WINDOW_DOCKINGAREA:
     854       26292 :                 pNewWindow = VclPtr<DockingAreaWindow>::Create( pParent );
     855       26292 :             break;
     856             :             case WINDOW_MULTILINEEDIT:
     857             :             case WINDOW_EDIT:
     858          54 :                 pNewWindow = VclPtr<Edit>::Create( pParent, nWinBits );
     859          54 :                 *ppNewComp = new VCLXEdit;
     860          54 :             break;
     861             :             case WINDOW_ERRORBOX:
     862           0 :                 pNewWindow = VclPtr<ErrorBox>::Create( pParent, nWinBits, OUString() );
     863           0 :                 *ppNewComp = new VCLXMessageBox;
     864           0 :             break;
     865             :             case WINDOW_FIXEDBITMAP:
     866           0 :                 pNewWindow = VclPtr<FixedBitmap>::Create( pParent, nWinBits );
     867           0 :             break;
     868             :             case WINDOW_FIXEDIMAGE:
     869          11 :                 pNewWindow = VclPtr<ImageControl>::Create( pParent, nWinBits );
     870          11 :                 *ppNewComp = new VCLXImageControl;
     871          11 :             break;
     872             :             case WINDOW_FIXEDLINE:
     873           0 :                 pNewWindow = VclPtr<FixedLine>::Create( pParent, nWinBits );
     874           0 :             break;
     875             :             case WINDOW_FIXEDTEXT:
     876           2 :                 pNewWindow = VclPtr<FixedText>::Create( pParent, nWinBits );
     877           2 :                 *ppNewComp = new VCLXFixedText;
     878           2 :             break;
     879             :             case WINDOW_FLOATINGWINDOW:
     880           0 :                 pNewWindow = VclPtr<FloatingWindow>::Create( pParent, nWinBits );
     881           0 :             break;
     882             :             case WINDOW_GROUPBOX:
     883           9 :                 pNewWindow = VclPtr<GroupBox>::Create( pParent, nWinBits );
     884           9 :                 if ( bFrameControl )
     885             :                 {
     886           0 :                     GroupBox* pGroupBox =  static_cast< GroupBox* >( pNewWindow );
     887           0 :                     *ppNewComp = new VCLXFrame;
     888             :                     // Frame control needs to receive
     889             :                     // Mouse events
     890           0 :                 pGroupBox->SetMouseTransparent( false );
     891             :                 }
     892           9 :             break;
     893             :             case WINDOW_HELPBUTTON:
     894           0 :                 pNewWindow = VclPtr<HelpButton>::Create( pParent, nWinBits );
     895           0 :                 *ppNewComp = new VCLXButton;
     896           0 :             break;
     897             :             case WINDOW_IMAGEBUTTON:
     898           0 :                  pNewWindow = VclPtr<ImageButton>::Create( pParent, nWinBits );
     899           0 :                 *ppNewComp = new VCLXButton;
     900           0 :             break;
     901             :             case WINDOW_INFOBOX:
     902           0 :                 pNewWindow = VclPtr<InfoBox>::Create( pParent, OUString() );
     903           0 :                 *ppNewComp = new VCLXMessageBox;
     904           0 :             break;
     905             :             case WINDOW_LISTBOX:
     906          21 :                 pNewWindow = VclPtr<ListBox>::Create( pParent, nWinBits|WB_SIMPLEMODE|WB_AUTOHSCROLL );
     907          21 :                 static_cast<ListBox*>(pNewWindow)->EnableAutoSize( false );
     908          21 :                 *ppNewComp = new VCLXListBox;
     909          21 :             break;
     910             :             case WINDOW_LONGCURRENCYBOX:
     911           0 :                 pNewWindow = VclPtr<LongCurrencyBox>::Create( pParent, nWinBits );
     912           0 :             break;
     913             :             case WINDOW_LONGCURRENCYFIELD:
     914           0 :                 pNewWindow = VclPtr<LongCurrencyField>::Create( pParent, nWinBits );
     915           0 :                 *ppNewComp = new VCLXCurrencyField;
     916           0 :                 static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<LongCurrencyField*>(pNewWindow)) );
     917           0 :             break;
     918             :             case WINDOW_MENUBUTTON:
     919           0 :                 pNewWindow = VclPtr<MenuButton>::Create( pParent, nWinBits );
     920           0 :                 *ppNewComp = new VCLXButton;
     921           0 :             break;
     922             :             case WINDOW_MESSBOX:
     923           0 :                 pNewWindow = VclPtr<MessBox>::Create( pParent, nWinBits, OUString(), OUString() );
     924           0 :                 *ppNewComp = new VCLXMessageBox;
     925           0 :             break;
     926             :             case WINDOW_METRICBOX:
     927           0 :                 pNewWindow = VclPtr<MetricBox>::Create( pParent, nWinBits );
     928           0 :             break;
     929             :             case WINDOW_METRICFIELD:
     930           0 :                 pNewWindow = VclPtr<MetricField>::Create( pParent, nWinBits );
     931           0 :                 *ppNewComp = new VCLXMetricField;
     932           0 :                 static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<MetricField*>(pNewWindow)) );
     933           0 :             break;
     934             :             case WINDOW_DIALOG:
     935             :             case WINDOW_MODALDIALOG:
     936             :             case WINDOW_MODELESSDIALOG:
     937             :             {
     938             :                 // Modal/Modeless nur durch Show/Execute
     939           7 :                 if ( (pParent == NULL ) && ( rDescriptor.ParentIndex == -1 ) )
     940           3 :                     pNewWindow = VclPtr<toolkit::ScrollableWrapper<Dialog>>::Create( nullptr, nWinBits, Dialog::InitFlag::NoParent );
     941             :                 else
     942           4 :                     pNewWindow = VclPtr<toolkit::ScrollableWrapper<Dialog>>::Create( pParent, nWinBits );
     943             :                 // #i70217# Don't always create a new component object. It's possible that VCL has called
     944             :                 // GetComponentInterface( sal_True ) in the Dialog ctor itself (see Window::IsTopWindow() )
     945             :                 // which creates a component object.
     946           7 :                 css::uno::Reference< css::awt::XWindowPeer > xWinPeer = pNewWindow->GetComponentInterface( false );
     947           7 :                 if ( xWinPeer.is() )
     948           7 :                     *ppNewComp = dynamic_cast< VCLXDialog* >( xWinPeer.get() );
     949             :                 else
     950           0 :                     *ppNewComp = new VCLXDialog;
     951             :             }
     952           7 :             break;
     953             :             case WINDOW_MOREBUTTON:
     954           0 :                 pNewWindow = VclPtr<MoreButton>::Create( pParent, nWinBits );
     955           0 :                 *ppNewComp = new VCLXButton;
     956           0 :             break;
     957             :             case WINDOW_MULTILISTBOX:
     958           0 :                 pNewWindow = VclPtr<MultiListBox>::Create( pParent, nWinBits );
     959           0 :                 *ppNewComp = new VCLXListBox;
     960           0 :             break;
     961             :             case WINDOW_NUMERICBOX:
     962           0 :                 pNewWindow = VclPtr<NumericBox>::Create( pParent, nWinBits );
     963           0 :             break;
     964             :             case WINDOW_NUMERICFIELD:
     965           0 :                 pNewWindow = VclPtr<NumericField>::Create( pParent, nWinBits );
     966           0 :                 static_cast<NumericField*>(pNewWindow)->EnableEmptyFieldValue( true );
     967           0 :                 *ppNewComp = new VCLXNumericField;
     968           0 :                 static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<NumericField*>(pNewWindow)) );
     969           0 :             break;
     970             :             case WINDOW_OKBUTTON:
     971           0 :                 pNewWindow = VclPtr<OKButton>::Create( pParent, nWinBits );
     972           0 :                 *ppNewComp = new VCLXButton;
     973           0 :             break;
     974             :             case WINDOW_PATTERNBOX:
     975           0 :                 pNewWindow = VclPtr<PatternBox>::Create( pParent, nWinBits );
     976           0 :             break;
     977             :             case WINDOW_PATTERNFIELD:
     978           8 :                 pNewWindow = VclPtr<PatternField>::Create( pParent, nWinBits );
     979           8 :                 *ppNewComp = new VCLXPatternField;
     980           8 :                 static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<PatternField*>(pNewWindow)) );
     981           8 :             break;
     982             :             case WINDOW_PUSHBUTTON:
     983          51 :                 pNewWindow = VclPtr<PushButton>::Create( pParent, nWinBits );
     984          51 :                 *ppNewComp = new VCLXButton;
     985          51 :             break;
     986             :             case WINDOW_QUERYBOX:
     987           0 :                 pNewWindow = VclPtr<QueryBox>::Create( pParent, nWinBits, OUString() );
     988           0 :                 *ppNewComp = new VCLXMessageBox;
     989           0 :             break;
     990             :             case WINDOW_RADIOBUTTON:
     991          21 :                 pNewWindow = VclPtr<RadioButton>::Create( pParent, nWinBits );
     992          21 :                 *ppNewComp = new VCLXRadioButton;
     993             : 
     994             :                 // by default, disable RadioCheck
     995             :                 // Since the VCLXRadioButton really cares for it's RadioCheck settings, this is important:
     996             :                 // if we enable it, the VCLXRadioButton will use RadioButton::Check instead of RadioButton::SetState
     997             :                 // This leads to a strange behaviour if the control is newly created: when settings the initial
     998             :                 // state to "checked", the RadioButton::Check (called because RadioCheck=sal_True) will uncheck
     999             :                 // _all_other_ radio buttons in the same group. However, at this moment the grouping of the controls
    1000             :                 // is not really valid: the controls are grouped after they have been created, but we're still in
    1001             :                 // the creation process, so the RadioButton::Check relies on invalid grouping information.
    1002             :                 // 07.08.2001 - #87254# - frank.schoenheit@sun.com
    1003          21 :                 static_cast<RadioButton*>(pNewWindow)->EnableRadioCheck( false );
    1004          21 :             break;
    1005             :             case WINDOW_SCROLLBAR:
    1006           1 :                 pNewWindow = VclPtr<ScrollBar>::Create( pParent, nWinBits );
    1007           1 :                 *ppNewComp = new VCLXScrollBar;
    1008           1 :             break;
    1009             :             case WINDOW_SCROLLBARBOX:
    1010           0 :                 pNewWindow = VclPtr<ScrollBarBox>::Create( pParent, nWinBits );
    1011           0 :             break;
    1012             :             case WINDOW_SPINBUTTON:
    1013           1 :                 pNewWindow = VclPtr<SpinButton>::Create( pParent, nWinBits );
    1014           1 :                 *ppNewComp = new ::toolkit::VCLXSpinButton;
    1015           1 :             break;
    1016             :             case WINDOW_SPINFIELD:
    1017           0 :                 pNewWindow = VclPtr<SpinField>::Create( pParent, nWinBits );
    1018           0 :                 *ppNewComp = new VCLXNumericField;
    1019           0 :             break;
    1020             :             case WINDOW_SPLITTER:
    1021           0 :                 pNewWindow = VclPtr<Splitter>::Create( pParent, nWinBits );
    1022           0 :             break;
    1023             :             case WINDOW_SPLITWINDOW:
    1024           0 :                 pNewWindow = VclPtr<SplitWindow>::Create( pParent, nWinBits );
    1025           0 :             break;
    1026             :             case WINDOW_STATUSBAR:
    1027           0 :                 pNewWindow = VclPtr<StatusBar>::Create( pParent, nWinBits );
    1028           0 :             break;
    1029             :             case VCLWINDOW_SYSTEMCHILDWINDOW:
    1030           0 :                 pNewWindow = VclPtr<SystemChildWindow>::Create( pParent, nWinBits );
    1031           0 :                 *ppNewComp = new VCLXSystemDependentWindow();
    1032           0 :             break;
    1033             :             case WINDOW_TABCONTROL:
    1034           0 :                 pNewWindow = VclPtr<TabControl>::Create( pParent, nWinBits );
    1035           0 :                 *ppNewComp = new VCLXMultiPage;
    1036           0 :             break;
    1037             :             case WINDOW_TABDIALOG:
    1038           0 :                 pNewWindow = VclPtr<TabDialog>::Create( pParent, nWinBits );
    1039           0 :             break;
    1040             :             case WINDOW_TABPAGE:
    1041             :                 {
    1042           0 :                     pNewWindow = VclPtr<TabPage>::Create( pParent, nWinBits );
    1043           0 :                     *ppNewComp = new VCLXTabPage;
    1044             :                 }
    1045           0 :             break;
    1046             :             case WINDOW_TIMEBOX:
    1047           0 :                 pNewWindow = VclPtr<TimeBox>::Create( pParent, nWinBits );
    1048           0 :             break;
    1049             :             case WINDOW_TIMEFIELD:
    1050          18 :                 pNewWindow = VclPtr<TimeField>::Create( pParent, nWinBits );
    1051          18 :                 static_cast<TimeField*>(pNewWindow)->EnableEmptyFieldValue( true );
    1052          18 :                 *ppNewComp = new VCLXTimeField;
    1053          18 :                 static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<TimeField*>(pNewWindow)) );
    1054          18 :             break;
    1055             :             case WINDOW_TOOLBOX:
    1056           0 :                 pNewWindow = VclPtr<ToolBox>::Create( pParent, nWinBits );
    1057           0 :                 *ppNewComp = new VCLXToolBox;
    1058           0 :             break;
    1059             :             case WINDOW_TRISTATEBOX:
    1060           0 :                 pNewWindow = VclPtr<TriStateBox>::Create( pParent, nWinBits );
    1061           0 :             break;
    1062             :             case WINDOW_WARNINGBOX:
    1063           0 :                 pNewWindow = VclPtr<WarningBox>::Create( pParent, nWinBits, OUString() );
    1064           0 :                 *ppNewComp = new VCLXMessageBox;
    1065           0 :             break;
    1066             :             case WINDOW_WORKWINDOW:
    1067             :             case WINDOW_WINDOW:
    1068             :             case VCLWINDOW_FRAMEWINDOW:
    1069             :             case WINDOW_DOCKINGWINDOW:
    1070        3284 :                 if ( rDescriptor.Type == ::com::sun::star::awt::WindowClass_TOP )
    1071             :                 {
    1072        3284 :                     if (nType == WINDOW_DOCKINGWINDOW )
    1073           1 :                         pNewWindow = VclPtr<DockingWindow>::Create( pParent, nWinBits );
    1074             :                     else
    1075             :                     {
    1076        3283 :                         if ((pParent == NULL) && rDescriptor.Parent.is())
    1077             :                         {
    1078             :                             // try to get a system dependent window handle
    1079           0 :                             ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSystemDependentWindowPeer > xSystemDepParent(rDescriptor.Parent, ::com::sun::star::uno::UNO_QUERY);
    1080             : 
    1081           0 :                             if (xSystemDepParent.is())
    1082             :                             {
    1083             :                                 sal_Int8 processID[16];
    1084             : 
    1085           0 :                                 rtl_getGlobalProcessId( reinterpret_cast<sal_uInt8*>(processID) );
    1086             : 
    1087           0 :                                 ::com::sun::star::uno::Sequence<sal_Int8> processIdSeq(processID, 16);
    1088             : 
    1089           0 :                                 ::com::sun::star::uno::Any anyHandle = xSystemDepParent->getWindowHandle(processIdSeq, SYSTEM_DEPENDENT_TYPE);
    1090             : 
    1091             :                                 // use sal_Int64 here to accommodate all int types
    1092             :                                 // uno::Any shift operator whill upcast if necessary
    1093           0 :                                 sal_Int64 nWindowHandle = 0;
    1094           0 :                                 bool bXEmbed = false;
    1095             : 
    1096           0 :                                 bool bUseParentData = true;
    1097           0 :                                 if( ! (anyHandle >>= nWindowHandle) )
    1098             :                                 {
    1099           0 :                                     css::uno::Sequence< css::beans::NamedValue > aProps;
    1100           0 :                                     if( anyHandle >>= aProps )
    1101             :                                     {
    1102           0 :                                         const int nProps = aProps.getLength();
    1103           0 :                                         const css::beans::NamedValue* pProps = aProps.getConstArray();
    1104           0 :                                         for( int i = 0; i < nProps; i++ )
    1105             :                                         {
    1106           0 :                                             if ( pProps[i].Name == "WINDOW" )
    1107           0 :                                                 pProps[i].Value >>= nWindowHandle;
    1108           0 :                                             else if ( pProps[i].Name == "XEMBED" )
    1109           0 :                                                 pProps[i].Value >>= bXEmbed;
    1110             :                                         }
    1111             :                                     }
    1112             :                                     else
    1113           0 :                                         bUseParentData = false;
    1114             :                                 }
    1115             : 
    1116           0 :                                 if( bUseParentData )
    1117             :                                 {
    1118             :                                     SystemParentData aParentData;
    1119           0 :                                     aParentData.nSize   = sizeof( aParentData );
    1120             :                                     #if defined MACOSX
    1121             :                                     aParentData.pView   = reinterpret_cast<NSView*>(nWindowHandle);
    1122             :                                     #elif defined ANDROID
    1123             :                                     // Nothing
    1124             :                                     #elif defined IOS
    1125             :                                     // Nothing
    1126             :                                     #elif defined UNX
    1127           0 :                                     aParentData.aWindow = nWindowHandle;
    1128           0 :                                     aParentData.bXEmbedSupport = bXEmbed;
    1129             :                                     #elif defined WNT
    1130             :                                     aParentData.hWnd = reinterpret_cast<HWND>(nWindowHandle);
    1131             :                                     #endif
    1132           0 :                                     pNewWindow = VclPtr<WorkWindow>::Create( &aParentData );
    1133           0 :                                 }
    1134           0 :                             }
    1135             :                         }
    1136             : 
    1137        3283 :                         if (!pNewWindow)
    1138        3283 :                             pNewWindow = VclPtr<WorkWindow>::Create( pParent, nWinBits );
    1139             :                     }
    1140             : 
    1141        3284 :                     *ppNewComp = new VCLXTopWindow( pNewWindow->GetType() == WINDOW_WORKWINDOW );
    1142             :                 }
    1143           0 :                 else if ( rDescriptor.Type == ::com::sun::star::awt::WindowClass_CONTAINER )
    1144             :                 {
    1145           0 :                     if (nType == WINDOW_DOCKINGWINDOW )
    1146           0 :                         pNewWindow = VclPtr<DockingWindow>::Create( pParent, nWinBits );
    1147             :                     else
    1148           0 :                         pNewWindow = VclPtr<vcl::Window>::Create( pParent, nWinBits );
    1149           0 :                     *ppNewComp = new VCLXContainer;
    1150             :                 }
    1151             :                 else
    1152             :                 {
    1153           0 :                     if (nType == WINDOW_DOCKINGWINDOW )
    1154           0 :                         pNewWindow = VclPtr<DockingWindow>::Create( pParent, nWinBits );
    1155             :                     else
    1156           0 :                         pNewWindow = VclPtr<vcl::Window>::Create( pParent, nWinBits );
    1157           0 :                     *ppNewComp = new VCLXWindow;
    1158             :                 }
    1159        3284 :             break;
    1160             :             case WINDOW_CONTROL:
    1161           0 :                 if ( rDescriptor.WindowServiceName.equalsIgnoreAsciiCase(
    1162           0 :                         "tabpagecontainer" ) )
    1163             :                 {
    1164           0 :                     pNewWindow = VclPtr<TabControl>::Create( pParent, nWinBits );
    1165           0 :                     *ppNewComp = new VCLXTabPageContainer;
    1166             :                 }
    1167           0 :                 else if ( aServiceName == "animatedimages" )
    1168             :                 {
    1169           0 :                     pNewWindow = VclPtr<Throbber>::Create( pParent, nWinBits );
    1170           0 :                     *ppNewComp = new ::toolkit::AnimatedImagesPeer;
    1171             :                 }
    1172           0 :             break;
    1173             :             default:
    1174             :                 OSL_ENSURE( false, "VCLXToolkit::ImplCreateWindow: unknown window type!" );
    1175           0 :                 break;
    1176       29829 :         }
    1177             :     }
    1178             : 
    1179       29829 :     return pNewWindow;
    1180             : }
    1181             : 
    1182             : #ifndef DISABLE_DYNLOADING
    1183             : 
    1184           0 : extern "C" { static void SAL_CALL thisModule() {} }
    1185             : 
    1186             : #else
    1187             : 
    1188             : extern "C" vcl::Window* SAL_CALL CreateWindow( VCLXWindow** ppNewComp, const ::com::sun::star::awt::WindowDescriptor* pDescriptor, vcl::Window* pParent, WinBits nWinBits );
    1189             : 
    1190             : #endif
    1191             : 
    1192       29910 : css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::ImplCreateWindow(
    1193             :     const css::awt::WindowDescriptor& rDescriptor,
    1194             :     WinBits nForceWinBits )
    1195             : {
    1196       29910 :     ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
    1197             : 
    1198       59820 :     SolarMutexGuard aSolarGuard;
    1199             : 
    1200       29910 :     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xRef;
    1201             : 
    1202       29910 :     vcl::Window* pParent = NULL;
    1203       29910 :     if ( rDescriptor.Parent.is() )
    1204             :     {
    1205       26623 :         VCLXWindow* pParentComponent = VCLXWindow::GetImplementation( rDescriptor.Parent );
    1206             : 
    1207             :         // #103939# Don't throw assertion, may be it's a system dependent window, used in ImplCreateWindow.
    1208             :         // DBG_ASSERT( pParentComponent, "ParentComponent not valid" );
    1209             : 
    1210       26623 :         if ( pParentComponent )
    1211       26623 :             pParent = pParentComponent->GetWindow();
    1212             :     }
    1213             :     WinBits nWinBits = ImplGetWinBits( rDescriptor.WindowAttributes,
    1214       29910 :         ImplGetComponentType( rDescriptor.WindowServiceName ) );
    1215       29910 :     nWinBits |= nForceWinBits;
    1216             : 
    1217       29910 :     VCLXWindow* pNewComp = NULL;
    1218             : 
    1219       29910 :     vcl::Window* pNewWindow = NULL;
    1220             :     // Try to create the window with SvTools
    1221             :     // (do this _before_ creating it on our own: The old mechanism (extended toolkit in SvTools) did it this way,
    1222             :     // and we need to stay compatible)
    1223             :     // try to load the lib
    1224       29910 :     if ( !fnSvtCreateWindow
    1225             : #ifndef DISABLE_DYNLOADING
    1226       29603 :          && !hSvToolsLib
    1227             : #endif
    1228             :          )
    1229             :     {
    1230             : #ifndef DISABLE_DYNLOADING
    1231       29603 :         OUString aLibName(SVT_DLL_NAME);
    1232             :         hSvToolsLib = osl_loadModuleRelative(
    1233       29603 :             &thisModule, aLibName.pData, SAL_LOADMODULE_DEFAULT );
    1234       29603 :         if ( hSvToolsLib )
    1235             :         {
    1236       29603 :             OUString aFunctionName( "CreateWindow" );
    1237       29603 :             fnSvtCreateWindow = reinterpret_cast<FN_SvtCreateWindow>(osl_getFunctionSymbol( hSvToolsLib, aFunctionName.pData ));
    1238       29603 :         }
    1239             : #else
    1240             :         fnSvtCreateWindow = CreateWindow;
    1241             : #endif
    1242             :     }
    1243             :     // ask the SvTool creation function
    1244       29910 :     if ( fnSvtCreateWindow )
    1245       29910 :         pNewWindow = fnSvtCreateWindow( &pNewComp, &rDescriptor, pParent, nWinBits );
    1246             : 
    1247             :     // if SvTools could not provide a window, create it ourself
    1248       29910 :     if ( !pNewWindow )
    1249       29829 :         pNewWindow = ImplCreateWindow( &pNewComp, rDescriptor, pParent, nWinBits );
    1250             : 
    1251             :     DBG_ASSERT( pNewWindow, "createWindow: Unknown Component!" );
    1252             :     DBG_ASSERTWARNING( pNewComp, "createWindow: No special Interface!" );
    1253             : 
    1254       29910 :     if ( pNewWindow )
    1255             :     {
    1256       29910 :         pNewWindow->SetCreatedWithToolkit( true );
    1257             :         //pNewWindow->SetPosPixel( Point() ); // do not force (0,0) position, keep default pos instead
    1258             : 
    1259       29910 :         if ( rDescriptor.WindowAttributes & ::com::sun::star::awt::WindowAttribute::MINSIZE )
    1260             :         {
    1261           0 :             pNewWindow->SetSizePixel( Size() );
    1262             :         }
    1263       29910 :         else if ( rDescriptor.WindowAttributes & ::com::sun::star::awt::WindowAttribute::FULLSIZE )
    1264             :         {
    1265           0 :             if ( pParent )
    1266           0 :                 pNewWindow->SetSizePixel( pParent->GetOutputSizePixel() );
    1267             :         }
    1268       29910 :         else if ( !VCLUnoHelper::IsZero( rDescriptor.Bounds ) )
    1269             :         {
    1270         336 :             Rectangle aRect = VCLRectangle( rDescriptor.Bounds );
    1271         336 :             pNewWindow->SetPosSizePixel( aRect.TopLeft(), aRect.GetSize() );
    1272             :         }
    1273             : 
    1274       29910 :         if ( !pNewComp )
    1275             :         {
    1276             :             // Default-Interface
    1277       26301 :             xRef = pNewWindow->GetComponentInterface( true );
    1278             :         }
    1279             :         else
    1280             :         {
    1281        3609 :             pNewComp->SetCreatedWithToolkit( true );
    1282        3609 :             xRef = pNewComp;
    1283        3609 :             pNewWindow->SetComponentInterface( xRef );
    1284             :         }
    1285             :         DBG_ASSERT( pNewWindow->GetComponentInterface( false ) == xRef,
    1286             :             "VCLXToolkit::createWindow: did #133706# resurge?" );
    1287             : 
    1288       29910 :         if ( rDescriptor.WindowAttributes & ::com::sun::star::awt::WindowAttribute::SHOW )
    1289           4 :             pNewWindow->Show();
    1290             :     }
    1291             : 
    1292       59820 :     return xRef;
    1293             : }
    1294             : 
    1295           1 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > > VCLXToolkit::createWindows( const ::com::sun::star::uno::Sequence< ::com::sun::star::awt::WindowDescriptor >& rDescriptors ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception)
    1296             : {
    1297           1 :     ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
    1298             : 
    1299           1 :     sal_uInt32 nComponents = rDescriptors.getLength();
    1300           1 :     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > > aSeq( nComponents );
    1301           3 :     for ( sal_uInt32 n = 0; n < nComponents; n++ )
    1302             :     {
    1303           2 :         ::com::sun::star::awt::WindowDescriptor aDescr = rDescriptors.getConstArray()[n];
    1304             : 
    1305           2 :         if ( aDescr.ParentIndex == (-1) )
    1306           2 :             aDescr.Parent = NULL;
    1307           0 :         else if ( ( aDescr.ParentIndex >= 0 ) && ( aDescr.ParentIndex < (short)n ) )
    1308           0 :             aDescr.Parent = aSeq.getConstArray()[aDescr.ParentIndex];
    1309           2 :         aSeq.getArray()[n] = createWindow( aDescr );
    1310           2 :     }
    1311           1 :     return aSeq;
    1312             : }
    1313             : 
    1314             : // ::com::sun::star::awt::XSystemChildFactory
    1315           0 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > VCLXToolkit::createSystemChild( const ::com::sun::star::uno::Any& Parent, const ::com::sun::star::uno::Sequence< sal_Int8 >& /*ProcessId*/, sal_Int16 nSystemType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
    1316             : {
    1317           0 :     VclPtr<vcl::Window> pChildWindow;
    1318           0 :     if ( nSystemType == SYSTEM_DEPENDENT_TYPE )
    1319             :     {
    1320             :         // use sal_Int64 here to accommodate all int types
    1321             :         // uno::Any shift operator whill upcast if necessary
    1322           0 :         sal_Int64 nWindowHandle = 0;
    1323           0 :         bool bXEmbed = false;
    1324             : 
    1325           0 :         bool bUseParentData = true;
    1326           0 :         if( ! (Parent >>= nWindowHandle) )
    1327             :         {
    1328           0 :             css::uno::Sequence< css::beans::NamedValue > aProps;
    1329           0 :             if( Parent >>= aProps )
    1330             :             {
    1331           0 :                 const int nProps = aProps.getLength();
    1332           0 :                 const css::beans::NamedValue* pProps = aProps.getConstArray();
    1333           0 :                 for( int i = 0; i < nProps; i++ )
    1334             :                 {
    1335           0 :                     if ( pProps[i].Name == "WINDOW" )
    1336           0 :                         pProps[i].Value >>= nWindowHandle;
    1337           0 :                     else if ( pProps[i].Name == "XEMBED" )
    1338           0 :                         pProps[i].Value >>= bXEmbed;
    1339             :                 }
    1340             :             }
    1341             :             else
    1342           0 :                 bUseParentData = false;
    1343             :         }
    1344             : 
    1345           0 :         if( bUseParentData )
    1346             :         {
    1347             :             SystemParentData aParentData;
    1348           0 :             aParentData.nSize   = sizeof( aParentData );
    1349             :             #if defined MACOSX
    1350             :             aParentData.pView   = reinterpret_cast<NSView*>(nWindowHandle);
    1351             :             #elif defined ANDROID
    1352             :             // Nothing
    1353             :             #elif defined IOS
    1354             :             // Nothing
    1355             :             #elif defined UNX
    1356           0 :             aParentData.aWindow = nWindowHandle;
    1357           0 :             aParentData.bXEmbedSupport = bXEmbed;
    1358             :             #elif defined WNT
    1359             :             aParentData.hWnd = reinterpret_cast<HWND>(nWindowHandle);
    1360             :             #endif
    1361           0 :             SolarMutexGuard aGuard;
    1362             :             try
    1363             :             {
    1364           0 :                 pChildWindow.reset( VclPtr<WorkWindow>::Create( &aParentData ) );
    1365             :             }
    1366           0 :             catch ( const ::com::sun::star::uno::RuntimeException & rEx )
    1367             :             {
    1368             :                 // system child window could not be created
    1369             :                 OSL_TRACE(
    1370             :                     "VCLXToolkit::createSystemChild: caught %s\n",
    1371             :                     OUStringToOString(
    1372             :                         rEx.Message, RTL_TEXTENCODING_UTF8).getStr());
    1373           0 :                 pChildWindow.clear();
    1374           0 :             }
    1375             :         }
    1376             :     }
    1377           0 :     else if (nSystemType == com::sun::star::lang::SystemDependent::SYSTEM_JAVA)
    1378             :     {
    1379           0 :         SolarMutexGuard aGuard;
    1380           0 :         pChildWindow.reset(VclPtr<WorkWindow>::Create(nullptr, Parent));
    1381             :     }
    1382             : 
    1383           0 :     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xPeer;
    1384           0 :     if ( pChildWindow )
    1385             :     {
    1386           0 :         VCLXTopWindow* pPeer = new VCLXTopWindow(true);
    1387           0 :         SolarMutexGuard aGuard;
    1388           0 :         pPeer->SetWindow( pChildWindow );
    1389           0 :         xPeer = pPeer;
    1390             :     }
    1391             : 
    1392           0 :     return xPeer;
    1393             : }
    1394             : 
    1395             : // ::com::sun::star::awt::XMessageBoxFactory
    1396           0 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMessageBox > SAL_CALL VCLXToolkit::createMessageBox(
    1397             :     const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& aParent,
    1398             :     ::com::sun::star::awt::MessageBoxType eType,
    1399             :     ::sal_Int32 aButtons,
    1400             :     const OUString& aTitle,
    1401             :     const OUString& aMessage ) throw (::com::sun::star::uno::RuntimeException, std::exception)
    1402             : {
    1403           0 :     ::com::sun::star::awt::WindowDescriptor aDescriptor;
    1404             : 
    1405           0 :     sal_Int32 nWindowAttributes = css::awt::WindowAttribute::BORDER|css::awt::WindowAttribute::MOVEABLE|css::awt::WindowAttribute::CLOSEABLE;
    1406             : 
    1407             :     // Map button definitions to window attributes
    1408           0 :     if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_OK )
    1409           0 :         nWindowAttributes |= css::awt::VclWindowPeerAttribute::OK;
    1410           0 :     else if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_OK_CANCEL )
    1411           0 :         nWindowAttributes |= css::awt::VclWindowPeerAttribute::OK_CANCEL;
    1412           0 :     else if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_YES_NO )
    1413           0 :         nWindowAttributes |= css::awt::VclWindowPeerAttribute::YES_NO;
    1414           0 :     else if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_YES_NO_CANCEL )
    1415           0 :         nWindowAttributes |= css::awt::VclWindowPeerAttribute::YES_NO_CANCEL;
    1416           0 :     else if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_RETRY_CANCEL )
    1417           0 :         nWindowAttributes |= css::awt::VclWindowPeerAttribute::RETRY_CANCEL;
    1418             : 
    1419             :     // Map default button definitions to window attributes
    1420           0 :     if (sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_OK )
    1421           0 :         nWindowAttributes |= css::awt::VclWindowPeerAttribute::DEF_OK;
    1422           0 :     else if (sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_CANCEL )
    1423           0 :         nWindowAttributes |= css::awt::VclWindowPeerAttribute::DEF_CANCEL;
    1424           0 :     else if (sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_YES )
    1425           0 :         nWindowAttributes |= css::awt::VclWindowPeerAttribute::DEF_YES;
    1426           0 :     else if (sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_NO )
    1427           0 :         nWindowAttributes |= css::awt::VclWindowPeerAttribute::DEF_NO;
    1428           0 :     else if (sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_RETRY )
    1429           0 :         nWindowAttributes |= css::awt::VclWindowPeerAttribute::DEF_RETRY;
    1430             : 
    1431             :     // No more bits for VclWindowPeerAttribute possible. Mapping must be
    1432             :     // done explicitly using VCL methods
    1433           0 :     WinBits nAddWinBits( 0 );
    1434           0 :     if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_ABORT_IGNORE_RETRY )
    1435           0 :         nAddWinBits |= WB_ABORT_RETRY_IGNORE;
    1436           0 :     if ( sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_IGNORE )
    1437           0 :         nAddWinBits |= WB_DEF_IGNORE;
    1438             : 
    1439           0 :     rtl::OUString aType;
    1440           0 :     lcl_convertMessageBoxType( aType, eType );
    1441             : 
    1442           0 :     aDescriptor.Type              = css::awt::WindowClass_MODALTOP;
    1443           0 :     aDescriptor.WindowServiceName = aType;
    1444           0 :     aDescriptor.ParentIndex       = -1;
    1445           0 :     aDescriptor.Parent            = aParent;
    1446           0 :     aDescriptor.WindowAttributes  = nWindowAttributes;
    1447             :     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMessageBox > xMsgBox(
    1448           0 :         ImplCreateWindow( aDescriptor, nAddWinBits ), css::uno::UNO_QUERY );
    1449           0 :     css::uno::Reference< css::awt::XWindow > xWindow( xMsgBox, css::uno::UNO_QUERY );
    1450           0 :     if ( xMsgBox.is() && xWindow.is() )
    1451             :     {
    1452           0 :         vcl::Window * pWindow = VCLUnoHelper::GetWindow( xWindow );
    1453           0 :         if ( pWindow )
    1454             :         {
    1455           0 :             SolarMutexGuard aGuard;
    1456           0 :             xMsgBox->setCaptionText( aTitle );
    1457           0 :             xMsgBox->setMessageText( aMessage );
    1458             :         }
    1459             :     }
    1460             : 
    1461           0 :     return xMsgBox;
    1462             : }
    1463             : 
    1464           1 : ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragGestureRecognizer > SAL_CALL VCLXToolkit::getDragGestureRecognizer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& window ) throw(::com::sun::star::uno::RuntimeException, std::exception)
    1465             : {
    1466           1 :     vcl::Window * pWindow = VCLUnoHelper::GetWindow( window );
    1467             : 
    1468           1 :     if( pWindow )
    1469           1 :         return pWindow->GetDragGestureRecognizer();
    1470             : 
    1471           0 :     return ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragGestureRecognizer >();
    1472             : }
    1473             : 
    1474           1 : ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSource > SAL_CALL VCLXToolkit::getDragSource( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& window ) throw(::com::sun::star::uno::RuntimeException, std::exception)
    1475             : {
    1476           1 :     SolarMutexGuard g;
    1477             : 
    1478           1 :     vcl::Window * pWindow = VCLUnoHelper::GetWindow( window );
    1479             : 
    1480           1 :     if( pWindow )
    1481           1 :         return pWindow->GetDragSource();
    1482             : 
    1483           0 :     return ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSource >();
    1484             : }
    1485             : 
    1486       19688 : ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTarget > SAL_CALL VCLXToolkit::getDropTarget( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& window ) throw(::com::sun::star::uno::RuntimeException, std::exception)
    1487             : {
    1488       19688 :     SolarMutexGuard g;
    1489             : 
    1490       19688 :     vcl::Window * pWindow = VCLUnoHelper::GetWindow( window );
    1491             : 
    1492       19688 :     if( pWindow )
    1493       19688 :         return pWindow->GetDropTarget();
    1494             : 
    1495           0 :     return ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTarget >();
    1496             : }
    1497             : 
    1498           1 : ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard > SAL_CALL VCLXToolkit::getClipboard( const OUString& clipboardName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
    1499             : {
    1500           1 :     if( clipboardName.isEmpty() )
    1501             :     {
    1502           1 :         if( !mxClipboard.is() )
    1503             :         {
    1504             :             // remember clipboard here
    1505           2 :             mxClipboard = css::datatransfer::clipboard::SystemClipboard::create(
    1506           1 :                 comphelper::getProcessComponentContext());
    1507             :         }
    1508             : 
    1509           1 :         return mxClipboard;
    1510             :     }
    1511             : 
    1512           0 :     else if( clipboardName == "Selection" )
    1513             :     {
    1514           0 :         return mxSelection;
    1515             :     }
    1516             : 
    1517           0 :     return ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >();
    1518             : }
    1519             : 
    1520             : // XServiceInfo
    1521           2 : OUString VCLXToolkit::getImplementationName() throw(::com::sun::star::uno::RuntimeException, std::exception)
    1522             : {
    1523           2 :     return OUString("stardiv.Toolkit.VCLXToolkit");
    1524             : }
    1525             : 
    1526           0 : sal_Bool VCLXToolkit::supportsService( const OUString& rServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
    1527             : {
    1528           0 :     return cppu::supportsService(this, rServiceName);
    1529             : }
    1530             : 
    1531           1 : ::com::sun::star::uno::Sequence< OUString > VCLXToolkit::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException, std::exception)
    1532             : {
    1533             :     return css::uno::Sequence<OUString>{
    1534           1 :         "com.sun.star.awt.Toolkit", "stardiv.vcl.VclToolkit"};
    1535             : }
    1536             : 
    1537             : // css::awt::XExtendedToolkit:
    1538             : 
    1539             : // virtual
    1540           0 : ::sal_Int32 SAL_CALL VCLXToolkit::getTopWindowCount()
    1541             :     throw (css::uno::RuntimeException, std::exception)
    1542             : {
    1543           0 :     return static_cast< ::sal_Int32 >(::Application::GetTopWindowCount());
    1544             :         // XXX  numeric overflow
    1545             : }
    1546             : 
    1547             : // virtual
    1548             : css::uno::Reference< css::awt::XTopWindow > SAL_CALL
    1549           0 : VCLXToolkit::getTopWindow(::sal_Int32 nIndex)
    1550             :     throw (css::uno::RuntimeException, std::exception)
    1551             : {
    1552           0 :     vcl::Window * p = ::Application::GetTopWindow(static_cast< long >(nIndex));
    1553             :         // XXX  numeric overflow
    1554             :     return css::uno::Reference< css::awt::XTopWindow >(
    1555           0 :         p == 0 ? 0 : static_cast< css::awt::XWindow * >(p->GetWindowPeer()),
    1556           0 :         css::uno::UNO_QUERY);
    1557             : }
    1558             : 
    1559             : // virtual
    1560             : css::uno::Reference< css::awt::XTopWindow > SAL_CALL
    1561           0 : VCLXToolkit::getActiveTopWindow() throw (css::uno::RuntimeException, std::exception)
    1562             : {
    1563           0 :     vcl::Window * p = ::Application::GetActiveTopWindow();
    1564             :     return css::uno::Reference< css::awt::XTopWindow >(
    1565           0 :         p == 0 ? 0 : static_cast< css::awt::XWindow * >(p->GetWindowPeer()),
    1566           0 :         css::uno::UNO_QUERY);
    1567             : }
    1568             : 
    1569             : // virtual
    1570           0 : void SAL_CALL VCLXToolkit::addTopWindowListener(
    1571             :     css::uno::Reference< css::awt::XTopWindowListener > const & rListener)
    1572             :     throw (css::uno::RuntimeException, std::exception)
    1573             : {
    1574             :     OSL_ENSURE(rListener.is(), "Null rListener");
    1575           0 :     ::osl::ClearableMutexGuard aGuard(rBHelper.rMutex);
    1576           0 :     if (rBHelper.bDisposed || rBHelper.bInDispose)
    1577             :     {
    1578           0 :         aGuard.clear();
    1579           0 :         rListener->disposing(
    1580             :             css::lang::EventObject(
    1581           0 :                 static_cast< ::cppu::OWeakObject * >(this)));
    1582             :     }
    1583           0 :     else if (m_aTopWindowListeners.addInterface(rListener) == 1
    1584           0 :              && !m_bEventListener)
    1585             :     {
    1586           0 :         m_bEventListener = true;
    1587           0 :         ::Application::AddEventListener(m_aEventListenerLink);
    1588           0 :     }
    1589           0 : }
    1590             : 
    1591             : // virtual
    1592           0 : void SAL_CALL VCLXToolkit::removeTopWindowListener(
    1593             :     css::uno::Reference< css::awt::XTopWindowListener > const & rListener)
    1594             :     throw (css::uno::RuntimeException, std::exception)
    1595             : {
    1596           0 :     ::osl::MutexGuard aGuard(rBHelper.rMutex);
    1597           0 :     if (!(rBHelper.bDisposed || rBHelper.bInDispose)
    1598           0 :         && m_aTopWindowListeners.removeInterface(rListener) == 0
    1599           0 :         && m_aFocusListeners.getLength() == 0 && m_bEventListener)
    1600             :     {
    1601           0 :         ::Application::RemoveEventListener(m_aEventListenerLink);
    1602           0 :         m_bEventListener = false;
    1603           0 :     }
    1604           0 : }
    1605             : 
    1606             : // virtual
    1607           0 : void SAL_CALL VCLXToolkit::addKeyHandler(
    1608             :     css::uno::Reference< css::awt::XKeyHandler > const & rHandler)
    1609             :     throw (css::uno::RuntimeException, std::exception)
    1610             : {
    1611             :     OSL_ENSURE(rHandler.is(), "Null rHandler");
    1612           0 :     ::osl::ClearableMutexGuard aGuard(rBHelper.rMutex);
    1613           0 :     if (rBHelper.bDisposed || rBHelper.bInDispose)
    1614             :     {
    1615           0 :         aGuard.clear();
    1616           0 :         rHandler->disposing(
    1617             :             css::lang::EventObject(
    1618           0 :                 static_cast< ::cppu::OWeakObject * >(this)));
    1619             :     }
    1620           0 :     else if (m_aKeyHandlers.addInterface(rHandler) == 1 && !m_bKeyListener)
    1621             :     {
    1622           0 :         m_bKeyListener = true;
    1623           0 :         ::Application::AddKeyListener(m_aKeyListenerLink);
    1624           0 :     }
    1625           0 : }
    1626             : 
    1627             : // virtual
    1628           0 : void SAL_CALL VCLXToolkit::removeKeyHandler(
    1629             :     css::uno::Reference< css::awt::XKeyHandler > const & rHandler)
    1630             :     throw (css::uno::RuntimeException, std::exception)
    1631             : {
    1632           0 :     ::osl::MutexGuard aGuard(rBHelper.rMutex);
    1633           0 :     if (!(rBHelper.bDisposed || rBHelper.bInDispose)
    1634           0 :         && m_aKeyHandlers.removeInterface(rHandler) == 0 && m_bKeyListener)
    1635             :     {
    1636           0 :         ::Application::RemoveKeyListener(m_aKeyListenerLink);
    1637           0 :         m_bKeyListener = false;
    1638           0 :     }
    1639           0 : }
    1640             : 
    1641             : // virtual
    1642           0 : void SAL_CALL VCLXToolkit::addFocusListener(
    1643             :     css::uno::Reference< css::awt::XFocusListener > const & rListener)
    1644             :     throw (css::uno::RuntimeException, std::exception)
    1645             : {
    1646             :     OSL_ENSURE(rListener.is(), "Null rListener");
    1647           0 :     ::osl::ClearableMutexGuard aGuard(rBHelper.rMutex);
    1648           0 :     if (rBHelper.bDisposed || rBHelper.bInDispose)
    1649             :     {
    1650           0 :         aGuard.clear();
    1651           0 :         rListener->disposing(
    1652             :             css::lang::EventObject(
    1653           0 :                 static_cast< ::cppu::OWeakObject * >(this)));
    1654             :     }
    1655           0 :     else if (m_aFocusListeners.addInterface(rListener) == 1
    1656           0 :              && !m_bEventListener)
    1657             :     {
    1658           0 :         m_bEventListener = true;
    1659           0 :         ::Application::AddEventListener(m_aEventListenerLink);
    1660           0 :     }
    1661           0 : }
    1662             : 
    1663             : // virtual
    1664           0 : void SAL_CALL VCLXToolkit::removeFocusListener(
    1665             :     css::uno::Reference< css::awt::XFocusListener > const & rListener)
    1666             :     throw (css::uno::RuntimeException, std::exception)
    1667             : {
    1668           0 :     ::osl::MutexGuard aGuard(rBHelper.rMutex);
    1669           0 :     if (!(rBHelper.bDisposed || rBHelper.bInDispose)
    1670           0 :         && m_aFocusListeners.removeInterface(rListener) == 0
    1671           0 :         && m_aTopWindowListeners.getLength() == 0 && m_bEventListener)
    1672             :     {
    1673           0 :         ::Application::RemoveEventListener(m_aEventListenerLink);
    1674           0 :         m_bEventListener = false;
    1675           0 :     }
    1676           0 : }
    1677             : 
    1678             : // virtual
    1679           0 : void SAL_CALL VCLXToolkit::fireFocusGained(
    1680             :     ::com::sun::star::uno::Reference<
    1681             :     ::com::sun::star::uno::XInterface > const &)
    1682             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
    1683             : {
    1684           0 : }
    1685             : 
    1686             : // virtual
    1687          10 : void SAL_CALL VCLXToolkit::fireFocusLost(
    1688             :     ::com::sun::star::uno::Reference<
    1689             :     ::com::sun::star::uno::XInterface > const &)
    1690             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
    1691             : {
    1692          10 : }
    1693             : 
    1694             : 
    1695           0 : IMPL_LINK(VCLXToolkit, eventListenerHandler, ::VclSimpleEvent const *, pEvent)
    1696             : {
    1697           0 :     switch (pEvent->GetId())
    1698             :     {
    1699             :     case VCLEVENT_WINDOW_SHOW:
    1700             :         callTopWindowListeners(
    1701           0 :             pEvent, &css::awt::XTopWindowListener::windowOpened);
    1702           0 :         break;
    1703             :     case VCLEVENT_WINDOW_HIDE:
    1704             :         callTopWindowListeners(
    1705           0 :             pEvent, &css::awt::XTopWindowListener::windowClosed);
    1706           0 :         break;
    1707             :     case VCLEVENT_WINDOW_ACTIVATE:
    1708             :         callTopWindowListeners(
    1709           0 :             pEvent, &css::awt::XTopWindowListener::windowActivated);
    1710           0 :         break;
    1711             :     case VCLEVENT_WINDOW_DEACTIVATE:
    1712             :         callTopWindowListeners(
    1713           0 :             pEvent, &css::awt::XTopWindowListener::windowDeactivated);
    1714           0 :         break;
    1715             :     case VCLEVENT_WINDOW_CLOSE:
    1716             :         callTopWindowListeners(
    1717           0 :             pEvent, &css::awt::XTopWindowListener::windowClosing);
    1718           0 :         break;
    1719             :     case VCLEVENT_WINDOW_GETFOCUS:
    1720           0 :         callFocusListeners(pEvent, true);
    1721           0 :         break;
    1722             :     case VCLEVENT_WINDOW_LOSEFOCUS:
    1723           0 :         callFocusListeners(pEvent, false);
    1724           0 :         break;
    1725             :     case VCLEVENT_WINDOW_MINIMIZE:
    1726             :         callTopWindowListeners(
    1727           0 :             pEvent, &css::awt::XTopWindowListener::windowMinimized);
    1728           0 :         break;
    1729             :     case VCLEVENT_WINDOW_NORMALIZE:
    1730             :         callTopWindowListeners(
    1731           0 :             pEvent, &css::awt::XTopWindowListener::windowNormalized);
    1732           0 :         break;
    1733             :     }
    1734           0 :     return 0;
    1735             : }
    1736             : 
    1737           0 : IMPL_LINK(VCLXToolkit, keyListenerHandler, ::VclSimpleEvent const *, pEvent)
    1738             : {
    1739           0 :     switch (pEvent->GetId())
    1740             :     {
    1741             :     case VCLEVENT_WINDOW_KEYINPUT:
    1742           0 :         return callKeyHandlers(pEvent, true);
    1743             :     case VCLEVENT_WINDOW_KEYUP:
    1744           0 :         return callKeyHandlers(pEvent, false);
    1745             :     }
    1746           0 :     return 0;
    1747             : }
    1748             : 
    1749           0 : void VCLXToolkit::callTopWindowListeners(
    1750             :     ::VclSimpleEvent const * pEvent,
    1751             :     void (SAL_CALL css::awt::XTopWindowListener::* pFn)(
    1752             :         css::lang::EventObject const &))
    1753             : {
    1754             :     vcl::Window * pWindow
    1755           0 :           = static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow();
    1756           0 :     if (pWindow->IsTopWindow())
    1757             :     {
    1758             :         css::uno::Sequence< css::uno::Reference< css::uno::XInterface > >
    1759           0 :               aListeners(m_aTopWindowListeners.getElements());
    1760           0 :         if (aListeners.hasElements())
    1761             :         {
    1762             :             css::lang::EventObject aAwtEvent(
    1763           0 :                 static_cast< css::awt::XWindow * >(pWindow->GetWindowPeer()));
    1764           0 :             for (::sal_Int32 i = 0; i < aListeners.getLength(); ++i)
    1765             :             {
    1766             :                 css::uno::Reference< css::awt::XTopWindowListener >
    1767           0 :                       xListener(aListeners[i], css::uno::UNO_QUERY);
    1768             :                 try
    1769             :                 {
    1770           0 :                     (xListener.get()->*pFn)(aAwtEvent);
    1771             :                 }
    1772           0 :                 catch (const css::uno::RuntimeException & rEx)
    1773             :                 {
    1774             :                     OSL_TRACE(
    1775             :                         "VCLXToolkit::callTopWindowListeners: caught %s\n",
    1776             :                         OUStringToOString(
    1777             :                             rEx.Message, RTL_TEXTENCODING_UTF8).getStr());
    1778             :                 }
    1779           0 :             }
    1780           0 :         }
    1781             :     }
    1782           0 : }
    1783             : 
    1784           0 : long VCLXToolkit::callKeyHandlers(::VclSimpleEvent const * pEvent,
    1785             :                                   bool bPressed)
    1786             : {
    1787             :     css::uno::Sequence< css::uno::Reference< css::uno::XInterface > >
    1788           0 :           aHandlers(m_aKeyHandlers.getElements());
    1789             : 
    1790           0 :     if (aHandlers.hasElements())
    1791             :     {
    1792           0 :         vcl::Window * pWindow = static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow();
    1793             : 
    1794             :         // See implementation in vclxwindow.cxx for mapping between VCL and UNO AWT event
    1795             :         ::KeyEvent * pKeyEvent = static_cast< ::KeyEvent * >(
    1796           0 :             static_cast< ::VclWindowEvent const * >(pEvent)->GetData());
    1797             :         css::awt::KeyEvent aAwtEvent(
    1798           0 :             static_cast< css::awt::XWindow * >(pWindow->GetWindowPeer()),
    1799           0 :             (pKeyEvent->GetKeyCode().IsShift()
    1800             :              ? css::awt::KeyModifier::SHIFT : 0)
    1801           0 :             | (pKeyEvent->GetKeyCode().IsMod1()
    1802             :                ? css::awt::KeyModifier::MOD1 : 0)
    1803           0 :             | (pKeyEvent->GetKeyCode().IsMod2()
    1804             :                ? css::awt::KeyModifier::MOD2 : 0)
    1805           0 :             | (pKeyEvent->GetKeyCode().IsMod3()
    1806             :                ? css::awt::KeyModifier::MOD3 : 0),
    1807           0 :             pKeyEvent->GetKeyCode().GetCode(), pKeyEvent->GetCharCode(),
    1808             :             sal::static_int_cast< sal_Int16 >(
    1809           0 :                 pKeyEvent->GetKeyCode().GetFunction()));
    1810           0 :         for (::sal_Int32 i = 0; i < aHandlers.getLength(); ++i)
    1811             :         {
    1812             :             css::uno::Reference< css::awt::XKeyHandler > xHandler(
    1813           0 :                 aHandlers[i], css::uno::UNO_QUERY);
    1814             :             try
    1815             :             {
    1816           0 :                 if ((bPressed ? xHandler->keyPressed(aAwtEvent)
    1817           0 :                       : xHandler->keyReleased(aAwtEvent)))
    1818           0 :                     return 1;
    1819             :             }
    1820           0 :             catch (const css::uno::RuntimeException & rEx)
    1821             :             {
    1822             :                 OSL_TRACE(
    1823             :                     "VCLXToolkit::callKeyHandlers: caught %s\n",
    1824             :                     OUStringToOString(
    1825             :                        rEx.Message, RTL_TEXTENCODING_UTF8).getStr());
    1826             :             }
    1827           0 :         }
    1828             :     }
    1829           0 :     return 0;
    1830             : }
    1831             : 
    1832           0 : void VCLXToolkit::callFocusListeners(::VclSimpleEvent const * pEvent,
    1833             :                                      bool bGained)
    1834             : {
    1835             :     vcl::Window * pWindow
    1836           0 :           = static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow();
    1837           0 :     if (pWindow->IsTopWindow())
    1838             :     {
    1839             :         css::uno::Sequence< css::uno::Reference< css::uno::XInterface > >
    1840           0 :               aListeners(m_aFocusListeners.getElements());
    1841           0 :         if (aListeners.hasElements())
    1842             :         {
    1843             :             // Ignore the interior of compound controls when determining the
    1844             :             // window that gets the focus next (see implementation in
    1845             :             // vclxwindow.cxx for mapping between VCL and UNO AWT event):
    1846           0 :             css::uno::Reference< css::uno::XInterface > xNext;
    1847           0 :             vcl::Window * pFocus = ::Application::GetFocusWindow();
    1848           0 :             for (vcl::Window * p = pFocus; p != 0; p = p->GetParent())
    1849           0 :                 if (!p->IsCompoundControl())
    1850             :                 {
    1851           0 :                     pFocus = p;
    1852           0 :                     break;
    1853             :                 }
    1854           0 :             if (pFocus != 0)
    1855           0 :                 xNext = pFocus->GetComponentInterface(true);
    1856             :             css::awt::FocusEvent aAwtEvent(
    1857           0 :                 static_cast< css::awt::XWindow * >(pWindow->GetWindowPeer()),
    1858           0 :                 static_cast<sal_Int16>(pWindow->GetGetFocusFlags()),
    1859           0 :                 xNext, false);
    1860           0 :             for (::sal_Int32 i = 0; i < aListeners.getLength(); ++i)
    1861             :             {
    1862             :                 css::uno::Reference< css::awt::XFocusListener > xListener(
    1863           0 :                     aListeners[i], css::uno::UNO_QUERY);
    1864             :                 try
    1865             :                 {
    1866           0 :                     bGained ? xListener->focusGained(aAwtEvent)
    1867           0 :                         : xListener->focusLost(aAwtEvent);
    1868             :                 }
    1869           0 :                 catch (const css::uno::RuntimeException & rEx)
    1870             :                 {
    1871             :                     OSL_TRACE(
    1872             :                         "VCLXToolkit::callFocusListeners: caught %s\n",
    1873             :                         OUStringToOString(
    1874             :                             rEx.Message, RTL_TEXTENCODING_UTF8).getStr());
    1875             :                 }
    1876           0 :             }
    1877           0 :         }
    1878             :     }
    1879           0 : }
    1880             : 
    1881             : // css::awt::XReschedule:
    1882             : 
    1883           0 : void SAL_CALL VCLXToolkit::reschedule()
    1884             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
    1885             : {
    1886           0 :     SolarMutexGuard aSolarGuard;
    1887           0 :     Application::Reschedule(true);
    1888           0 : }
    1889             : 
    1890           0 : void SAL_CALL VCLXToolkit::processEventsToIdle()
    1891             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
    1892             : {
    1893           0 :     SolarMutexGuard aSolarGuard;
    1894           0 :     Scheduler::ProcessTaskScheduling(false);
    1895           0 : }
    1896             : 
    1897             : }
    1898             : 
    1899             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
    1900       49297 : stardiv_Toolkit_VCLXToolkit_get_implementation(
    1901             :     css::uno::XComponentContext *,
    1902             :     css::uno::Sequence<css::uno::Any> const &)
    1903             : {
    1904       49297 :     return cppu::acquire(new VCLXToolkit());
    1905         798 : }
    1906             : 
    1907             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11