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