LCOV - code coverage report
Current view: top level - toolkit/source/awt - vclxtoolkit.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 329 804 40.9 %
Date: 2014-11-03 Functions: 31 55 56.4 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10