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

Generated by: LCOV version 1.10