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

Generated by: LCOV version 1.10