1*9f62ea84SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9f62ea84SAndrew Rist * distributed with this work for additional information 6*9f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9f62ea84SAndrew Rist * "License"); you may not use this file except in compliance 9*9f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at 10*9f62ea84SAndrew Rist * 11*9f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*9f62ea84SAndrew Rist * 13*9f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9f62ea84SAndrew Rist * software distributed under the License is distributed on an 15*9f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9f62ea84SAndrew Rist * KIND, either express or implied. See the License for the 17*9f62ea84SAndrew Rist * specific language governing permissions and limitations 18*9f62ea84SAndrew Rist * under the License. 19*9f62ea84SAndrew Rist * 20*9f62ea84SAndrew Rist *************************************************************/ 21*9f62ea84SAndrew Rist 22*9f62ea84SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_vcl.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir //#include "svsys.h" 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include "comphelper/processfactory.hxx" 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include "osl/module.h" 32cdf0e10cSrcweir #include "osl/file.hxx" 33cdf0e10cSrcweir #include "osl/thread.h" 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include "rtl/tencinfo.h" 36cdf0e10cSrcweir #include "rtl/instance.hxx" 37cdf0e10cSrcweir 38cdf0e10cSrcweir #include "vos/process.hxx" 39cdf0e10cSrcweir #include "vos/mutex.hxx" 40cdf0e10cSrcweir 41cdf0e10cSrcweir #include "tools/tools.h" 42cdf0e10cSrcweir #include "tools/debug.hxx" 43cdf0e10cSrcweir #include "tools/time.hxx" 44cdf0e10cSrcweir 45cdf0e10cSrcweir #include "i18npool/mslangid.hxx" 46cdf0e10cSrcweir 47cdf0e10cSrcweir #include "unotools/syslocaleoptions.hxx" 48cdf0e10cSrcweir 49cdf0e10cSrcweir #include "vcl/settings.hxx" 50cdf0e10cSrcweir #include "vcl/keycod.hxx" 51cdf0e10cSrcweir #include "vcl/event.hxx" 52cdf0e10cSrcweir #include "vcl/vclevent.hxx" 53cdf0e10cSrcweir #include "vcl/virdev.hxx" 54cdf0e10cSrcweir #include "vcl/wrkwin.hxx" 55cdf0e10cSrcweir #include "vcl/svapp.hxx" 56cdf0e10cSrcweir #include "vcl/cvtgrf.hxx" 57cdf0e10cSrcweir #include "vcl/unowrap.hxx" 58cdf0e10cSrcweir #include "vcl/timer.hxx" 59cdf0e10cSrcweir #include "vcl/unohelp.hxx" 60cdf0e10cSrcweir #include "vcl/lazydelete.hxx" 61cdf0e10cSrcweir 62cdf0e10cSrcweir #include "salinst.hxx" 63cdf0e10cSrcweir #include "salframe.hxx" 64cdf0e10cSrcweir #include "salsys.hxx" 65cdf0e10cSrcweir #include "svdata.hxx" 66cdf0e10cSrcweir #include "salimestatus.hxx" 67cdf0e10cSrcweir #include "xconnection.hxx" 68cdf0e10cSrcweir #include "window.h" 69cdf0e10cSrcweir #include "accmgr.hxx" 70cdf0e10cSrcweir #include "idlemgr.hxx" 71cdf0e10cSrcweir #include "svids.hrc" 72cdf0e10cSrcweir 73cdf0e10cSrcweir #include "com/sun/star/uno/Reference.h" 74cdf0e10cSrcweir #include "com/sun/star/awt/XToolkit.hpp" 75cdf0e10cSrcweir #include "com/sun/star/uno/XNamingService.hpp" 76cdf0e10cSrcweir #include "com/sun/star/lang/XMultiServiceFactory.hpp" 77cdf0e10cSrcweir 78cdf0e10cSrcweir #include <utility> 79cdf0e10cSrcweir 80cdf0e10cSrcweir using namespace ::com::sun::star::uno; 81cdf0e10cSrcweir 82cdf0e10cSrcweir // keycodes handled internally by VCL 83cdf0e10cSrcweir class ImplReservedKey 84cdf0e10cSrcweir { 85cdf0e10cSrcweir public: 86cdf0e10cSrcweir ImplReservedKey( KeyCode aKeyCode, sal_uInt16 nResId ) : 87cdf0e10cSrcweir mKeyCode(aKeyCode), mnResId( nResId) 88cdf0e10cSrcweir {} 89cdf0e10cSrcweir 90cdf0e10cSrcweir KeyCode mKeyCode; 91cdf0e10cSrcweir sal_uInt16 mnResId; 92cdf0e10cSrcweir }; 93cdf0e10cSrcweir 94cdf0e10cSrcweir typedef std::pair<ImplReservedKey*, size_t> ReservedKeys; 95cdf0e10cSrcweir namespace 96cdf0e10cSrcweir { 97cdf0e10cSrcweir struct ImplReservedKeysImpl 98cdf0e10cSrcweir { 99cdf0e10cSrcweir ReservedKeys* operator()() 100cdf0e10cSrcweir { 101cdf0e10cSrcweir static ImplReservedKey ImplReservedKeys[] = 102cdf0e10cSrcweir { 103cdf0e10cSrcweir ImplReservedKey(KeyCode(KEY_F1,0), SV_SHORTCUT_HELP), 104cdf0e10cSrcweir ImplReservedKey(KeyCode(KEY_F1,KEY_SHIFT), SV_SHORTCUT_ACTIVEHELP), 105cdf0e10cSrcweir ImplReservedKey(KeyCode(KEY_F1,KEY_MOD1), SV_SHORTCUT_CONTEXTHELP), 106cdf0e10cSrcweir ImplReservedKey(KeyCode(KEY_F2,KEY_SHIFT), SV_SHORTCUT_CONTEXTHELP), 107cdf0e10cSrcweir ImplReservedKey(KeyCode(KEY_F4,KEY_MOD1), SV_SHORTCUT_DOCKUNDOCK), 108cdf0e10cSrcweir ImplReservedKey(KeyCode(KEY_F4,KEY_MOD2), SV_SHORTCUT_DOCKUNDOCK), 109cdf0e10cSrcweir ImplReservedKey(KeyCode(KEY_F4,KEY_MOD1|KEY_MOD2), SV_SHORTCUT_DOCKUNDOCK), 110cdf0e10cSrcweir ImplReservedKey(KeyCode(KEY_F6,0), SV_SHORTCUT_NEXTSUBWINDOW), 111cdf0e10cSrcweir ImplReservedKey(KeyCode(KEY_F6,KEY_MOD1), SV_SHORTCUT_TODOCUMENT), 112cdf0e10cSrcweir ImplReservedKey(KeyCode(KEY_F6,KEY_SHIFT), SV_SHORTCUT_PREVSUBWINDOW), 113cdf0e10cSrcweir ImplReservedKey(KeyCode(KEY_F6,KEY_MOD1|KEY_SHIFT), SV_SHORTCUT_SPLITTER), 114cdf0e10cSrcweir ImplReservedKey(KeyCode(KEY_F10,0), SV_SHORTCUT_MENUBAR) 115cdf0e10cSrcweir #ifdef UNX 116cdf0e10cSrcweir , 117cdf0e10cSrcweir ImplReservedKey(KeyCode(KEY_1,KEY_SHIFT|KEY_MOD1), 0), 118cdf0e10cSrcweir ImplReservedKey(KeyCode(KEY_2,KEY_SHIFT|KEY_MOD1), 0), 119cdf0e10cSrcweir ImplReservedKey(KeyCode(KEY_3,KEY_SHIFT|KEY_MOD1), 0), 120cdf0e10cSrcweir ImplReservedKey(KeyCode(KEY_4,KEY_SHIFT|KEY_MOD1), 0), 121cdf0e10cSrcweir ImplReservedKey(KeyCode(KEY_5,KEY_SHIFT|KEY_MOD1), 0), 122cdf0e10cSrcweir ImplReservedKey(KeyCode(KEY_6,KEY_SHIFT|KEY_MOD1), 0), 123cdf0e10cSrcweir ImplReservedKey(KeyCode(KEY_7,KEY_SHIFT|KEY_MOD1), 0), 124cdf0e10cSrcweir ImplReservedKey(KeyCode(KEY_8,KEY_SHIFT|KEY_MOD1), 0), 125cdf0e10cSrcweir ImplReservedKey(KeyCode(KEY_9,KEY_SHIFT|KEY_MOD1), 0), 126cdf0e10cSrcweir ImplReservedKey(KeyCode(KEY_0,KEY_SHIFT|KEY_MOD1), 0), 127cdf0e10cSrcweir ImplReservedKey(KeyCode(KEY_ADD,KEY_SHIFT|KEY_MOD1), 0) 128cdf0e10cSrcweir #endif 129cdf0e10cSrcweir }; 130cdf0e10cSrcweir static ReservedKeys aKeys 131cdf0e10cSrcweir ( 132cdf0e10cSrcweir &ImplReservedKeys[0], 133cdf0e10cSrcweir sizeof(ImplReservedKeys) / sizeof(ImplReservedKey) 134cdf0e10cSrcweir ); 135cdf0e10cSrcweir return &aKeys; 136cdf0e10cSrcweir } 137cdf0e10cSrcweir }; 138cdf0e10cSrcweir 139cdf0e10cSrcweir struct ImplReservedKeys 140cdf0e10cSrcweir : public rtl::StaticAggregate<ReservedKeys, ImplReservedKeysImpl> {}; 141cdf0e10cSrcweir } 142cdf0e10cSrcweir 143cdf0e10cSrcweir 144cdf0e10cSrcweir // #include <usr/refl.hxx> 145cdf0e10cSrcweir class Reflection; 146cdf0e10cSrcweir 147cdf0e10cSrcweir 148cdf0e10cSrcweir 149cdf0e10cSrcweir extern "C" { 150cdf0e10cSrcweir typedef UnoWrapperBase* (SAL_CALL *FN_TkCreateUnoWrapper)(); 151cdf0e10cSrcweir } 152cdf0e10cSrcweir 153cdf0e10cSrcweir // ======================================================================= 154cdf0e10cSrcweir 155cdf0e10cSrcweir // -------------- 156cdf0e10cSrcweir // - ImplHotKey - 157cdf0e10cSrcweir // -------------- 158cdf0e10cSrcweir 159cdf0e10cSrcweir struct ImplHotKey 160cdf0e10cSrcweir { 161cdf0e10cSrcweir ImplHotKey* mpNext; 162cdf0e10cSrcweir void* mpUserData; 163cdf0e10cSrcweir KeyCode maKeyCode; 164cdf0e10cSrcweir Link maLink; 165cdf0e10cSrcweir }; 166cdf0e10cSrcweir 167cdf0e10cSrcweir // ======================================================================= 168cdf0e10cSrcweir 169cdf0e10cSrcweir // ----------------- 170cdf0e10cSrcweir // - ImplEventHook - 171cdf0e10cSrcweir // ----------------- 172cdf0e10cSrcweir 173cdf0e10cSrcweir struct ImplEventHook 174cdf0e10cSrcweir { 175cdf0e10cSrcweir ImplEventHook* mpNext; 176cdf0e10cSrcweir void* mpUserData; 177cdf0e10cSrcweir VCLEventHookProc mpProc; 178cdf0e10cSrcweir }; 179cdf0e10cSrcweir 180cdf0e10cSrcweir // ======================================================================= 181cdf0e10cSrcweir 182cdf0e10cSrcweir // --------------------- 183cdf0e10cSrcweir // - ImplPostEventData - 184cdf0e10cSrcweir // --------------------- 185cdf0e10cSrcweir 186cdf0e10cSrcweir struct ImplPostEventData 187cdf0e10cSrcweir { 188cdf0e10cSrcweir sal_uLong mnEvent; 189cdf0e10cSrcweir const Window* mpWin; 190cdf0e10cSrcweir sal_uLong mnEventId; 191cdf0e10cSrcweir KeyEvent maKeyEvent; 192cdf0e10cSrcweir MouseEvent maMouseEvent; 193cdf0e10cSrcweir 194cdf0e10cSrcweir 195cdf0e10cSrcweir ImplPostEventData( sal_uLong nEvent, const Window* pWin, const KeyEvent& rKeyEvent ) : 196cdf0e10cSrcweir mnEvent( nEvent ), mpWin( pWin ), mnEventId( 0 ), maKeyEvent( rKeyEvent ) {} 197cdf0e10cSrcweir ImplPostEventData( sal_uLong nEvent, const Window* pWin, const MouseEvent& rMouseEvent ) : 198cdf0e10cSrcweir mnEvent( nEvent ), mpWin( pWin ), mnEventId( 0 ), maMouseEvent( rMouseEvent ) {} 199cdf0e10cSrcweir 200cdf0e10cSrcweir ~ImplPostEventData() {} 201cdf0e10cSrcweir }; 202cdf0e10cSrcweir 203cdf0e10cSrcweir typedef ::std::pair< Window*, ImplPostEventData* > ImplPostEventPair; 204cdf0e10cSrcweir 205cdf0e10cSrcweir static ::std::list< ImplPostEventPair > aPostedEventList; 206cdf0e10cSrcweir 207cdf0e10cSrcweir // ======================================================================= 208cdf0e10cSrcweir 209cdf0e10cSrcweir Application* GetpApp() 210cdf0e10cSrcweir { 211cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 212cdf0e10cSrcweir if ( !pSVData ) 213cdf0e10cSrcweir return NULL; 214cdf0e10cSrcweir return pSVData->mpApp; 215cdf0e10cSrcweir } 216cdf0e10cSrcweir 217cdf0e10cSrcweir // ----------------------------------------------------------------------- 218cdf0e10cSrcweir 219cdf0e10cSrcweir Application::Application() 220cdf0e10cSrcweir { 221cdf0e10cSrcweir if( ! ImplGetSVData() ) 222cdf0e10cSrcweir ImplInitSVData(); 223cdf0e10cSrcweir ImplGetSVData()->mpApp = this; 224cdf0e10cSrcweir InitSalData(); 225cdf0e10cSrcweir } 226cdf0e10cSrcweir 227cdf0e10cSrcweir // ----------------------------------------------------------------------- 228cdf0e10cSrcweir 229cdf0e10cSrcweir Application::~Application() 230cdf0e10cSrcweir { 231cdf0e10cSrcweir ImplDeInitSVData(); 232cdf0e10cSrcweir DeInitSalData(); 233cdf0e10cSrcweir ImplGetSVData()->mpApp = NULL; 234cdf0e10cSrcweir ImplDestroySVData(); 235cdf0e10cSrcweir GlobalDeInitTools(); 236cdf0e10cSrcweir } 237cdf0e10cSrcweir 238cdf0e10cSrcweir // ----------------------------------------------------------------------- 239cdf0e10cSrcweir 240cdf0e10cSrcweir void Application::InitAppRes( const ResId& ) 241cdf0e10cSrcweir { 242cdf0e10cSrcweir } 243cdf0e10cSrcweir 244cdf0e10cSrcweir // ----------------------------------------------------------------------- 245cdf0e10cSrcweir 246cdf0e10cSrcweir sal_Bool Application::QueryExit() 247cdf0e10cSrcweir { 248cdf0e10cSrcweir WorkWindow* pAppWin = ImplGetSVData()->maWinData.mpAppWin; 249cdf0e10cSrcweir 250cdf0e10cSrcweir // Aufruf des Close-Handlers des Applikationsfensters 251cdf0e10cSrcweir if ( pAppWin ) 252cdf0e10cSrcweir return pAppWin->Close(); 253cdf0e10cSrcweir else 254cdf0e10cSrcweir return sal_True; 255cdf0e10cSrcweir } 256cdf0e10cSrcweir 257cdf0e10cSrcweir // ----------------------------------------------------------------------- 258cdf0e10cSrcweir 259cdf0e10cSrcweir void Application::UserEvent( sal_uLong, void* ) 260cdf0e10cSrcweir { 261cdf0e10cSrcweir } 262cdf0e10cSrcweir 263cdf0e10cSrcweir // ----------------------------------------------------------------------- 264cdf0e10cSrcweir 265cdf0e10cSrcweir void Application::ShowStatusText( const XubString& ) 266cdf0e10cSrcweir { 267cdf0e10cSrcweir } 268cdf0e10cSrcweir 269cdf0e10cSrcweir // ----------------------------------------------------------------------- 270cdf0e10cSrcweir 271cdf0e10cSrcweir void Application::ShowHelpStatusText( const XubString& ) 272cdf0e10cSrcweir { 273cdf0e10cSrcweir } 274cdf0e10cSrcweir 275cdf0e10cSrcweir // ----------------------------------------------------------------------- 276cdf0e10cSrcweir 277cdf0e10cSrcweir void Application::ActivateExtHelp() 278cdf0e10cSrcweir { 279cdf0e10cSrcweir } 280cdf0e10cSrcweir 281cdf0e10cSrcweir // ----------------------------------------------------------------------- 282cdf0e10cSrcweir 283cdf0e10cSrcweir void Application::DeactivateExtHelp() 284cdf0e10cSrcweir { 285cdf0e10cSrcweir } 286cdf0e10cSrcweir 287cdf0e10cSrcweir // ----------------------------------------------------------------------- 288cdf0e10cSrcweir 289cdf0e10cSrcweir void Application::HideStatusText() 290cdf0e10cSrcweir { 291cdf0e10cSrcweir } 292cdf0e10cSrcweir 293cdf0e10cSrcweir // ----------------------------------------------------------------------- 294cdf0e10cSrcweir 295cdf0e10cSrcweir void Application::HideHelpStatusText() 296cdf0e10cSrcweir { 297cdf0e10cSrcweir } 298cdf0e10cSrcweir 299cdf0e10cSrcweir // ----------------------------------------------------------------------- 300cdf0e10cSrcweir 301cdf0e10cSrcweir void Application::FocusChanged() 302cdf0e10cSrcweir { 303cdf0e10cSrcweir } 304cdf0e10cSrcweir 305cdf0e10cSrcweir // ----------------------------------------------------------------------- 306cdf0e10cSrcweir 307cdf0e10cSrcweir void Application::DataChanged( const DataChangedEvent& ) 308cdf0e10cSrcweir { 309cdf0e10cSrcweir } 310cdf0e10cSrcweir 311cdf0e10cSrcweir // ----------------------------------------------------------------------- 312cdf0e10cSrcweir void Application::Init() 313cdf0e10cSrcweir { 314cdf0e10cSrcweir } 315cdf0e10cSrcweir 316cdf0e10cSrcweir // ----------------------------------------------------------------------- 317cdf0e10cSrcweir 318cdf0e10cSrcweir void Application::DeInit() 319cdf0e10cSrcweir { 320cdf0e10cSrcweir } 321cdf0e10cSrcweir 322cdf0e10cSrcweir // ----------------------------------------------------------------------- 323cdf0e10cSrcweir 324cdf0e10cSrcweir sal_uInt16 Application::GetCommandLineParamCount() 325cdf0e10cSrcweir { 326cdf0e10cSrcweir vos::OStartupInfo aStartInfo; 327cdf0e10cSrcweir return (sal_uInt16)aStartInfo.getCommandArgCount(); 328cdf0e10cSrcweir } 329cdf0e10cSrcweir 330cdf0e10cSrcweir // ----------------------------------------------------------------------- 331cdf0e10cSrcweir 332cdf0e10cSrcweir XubString Application::GetCommandLineParam( sal_uInt16 nParam ) 333cdf0e10cSrcweir { 334cdf0e10cSrcweir vos::OStartupInfo aStartInfo; 335cdf0e10cSrcweir rtl::OUString aParam; 336cdf0e10cSrcweir aStartInfo.getCommandArg( nParam, aParam ); 337cdf0e10cSrcweir return XubString( aParam ); 338cdf0e10cSrcweir } 339cdf0e10cSrcweir 340cdf0e10cSrcweir // ----------------------------------------------------------------------- 341cdf0e10cSrcweir 342cdf0e10cSrcweir const XubString& Application::GetAppFileName() 343cdf0e10cSrcweir { 344cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 345cdf0e10cSrcweir DBG_ASSERT( pSVData->maAppData.mpAppFileName, "AppFileName vor SVMain ?!" ); 346cdf0e10cSrcweir if ( pSVData->maAppData.mpAppFileName ) 347cdf0e10cSrcweir return *pSVData->maAppData.mpAppFileName; 348cdf0e10cSrcweir 349cdf0e10cSrcweir /* 350cdf0e10cSrcweir * #91147# provide a fallback for people without initialized 351cdf0e10cSrcweir * vcl here (like setup in responsefile mode) 352cdf0e10cSrcweir */ 353cdf0e10cSrcweir static String aAppFileName; 354cdf0e10cSrcweir if( !aAppFileName.Len() ) 355cdf0e10cSrcweir { 356cdf0e10cSrcweir vos::OStartupInfo aStartInfo; 357cdf0e10cSrcweir ::rtl::OUString aExeFileName; 358cdf0e10cSrcweir 359cdf0e10cSrcweir aStartInfo.getExecutableFile( aExeFileName ); 360cdf0e10cSrcweir 361cdf0e10cSrcweir // convert path to native file format 362cdf0e10cSrcweir rtl::OUString aNativeFileName; 363cdf0e10cSrcweir osl::FileBase::getSystemPathFromFileURL( aExeFileName, aNativeFileName ); 364cdf0e10cSrcweir aAppFileName = aNativeFileName; 365cdf0e10cSrcweir } 366cdf0e10cSrcweir 367cdf0e10cSrcweir return aAppFileName; 368cdf0e10cSrcweir } 369cdf0e10cSrcweir 370cdf0e10cSrcweir // ----------------------------------------------------------------------- 371cdf0e10cSrcweir 372cdf0e10cSrcweir sal_uInt16 Application::Exception( sal_uInt16 nError ) 373cdf0e10cSrcweir { 374cdf0e10cSrcweir switch ( nError & EXC_MAJORTYPE ) 375cdf0e10cSrcweir { 376cdf0e10cSrcweir // Bei System machen wir nichts und lassen dem System den 377cdf0e10cSrcweir // vortritt 378cdf0e10cSrcweir case EXC_SYSTEM: 379cdf0e10cSrcweir return 0; 380cdf0e10cSrcweir 381cdf0e10cSrcweir case EXC_DISPLAY: 382cdf0e10cSrcweir case EXC_REMOTE: 383cdf0e10cSrcweir return 0; 384cdf0e10cSrcweir 385cdf0e10cSrcweir #ifdef DBG_UTIL 386cdf0e10cSrcweir case EXC_RSCNOTLOADED: 387cdf0e10cSrcweir Abort( XubString( RTL_CONSTASCII_USTRINGPARAM( "Resource not loaded" ) ) ); 388cdf0e10cSrcweir break; 389cdf0e10cSrcweir case EXC_SYSOBJNOTCREATED: 390cdf0e10cSrcweir Abort( XubString( RTL_CONSTASCII_USTRINGPARAM( "System Object not created" ) ) ); 391cdf0e10cSrcweir break; 392cdf0e10cSrcweir default: 393cdf0e10cSrcweir Abort( XubString( RTL_CONSTASCII_USTRINGPARAM( "Unknown Error" ) ) ); 394cdf0e10cSrcweir break; 395cdf0e10cSrcweir #else 396cdf0e10cSrcweir default: 397cdf0e10cSrcweir Abort( ImplGetSVEmptyStr() ); 398cdf0e10cSrcweir break; 399cdf0e10cSrcweir #endif 400cdf0e10cSrcweir } 401cdf0e10cSrcweir 402cdf0e10cSrcweir return 0; 403cdf0e10cSrcweir } 404cdf0e10cSrcweir 405cdf0e10cSrcweir // ----------------------------------------------------------------------- 406cdf0e10cSrcweir 407cdf0e10cSrcweir void Application::Abort( const XubString& rErrorText ) 408cdf0e10cSrcweir { 409cdf0e10cSrcweir SalAbort( rErrorText ); 410cdf0e10cSrcweir } 411cdf0e10cSrcweir 412cdf0e10cSrcweir // ----------------------------------------------------------------------- 413cdf0e10cSrcweir 414cdf0e10cSrcweir sal_uLong Application::GetReservedKeyCodeCount() 415cdf0e10cSrcweir { 416cdf0e10cSrcweir return ImplReservedKeys::get()->second; 417cdf0e10cSrcweir } 418cdf0e10cSrcweir 419cdf0e10cSrcweir const KeyCode* Application::GetReservedKeyCode( sal_uLong i ) 420cdf0e10cSrcweir { 421cdf0e10cSrcweir if( i >= GetReservedKeyCodeCount() ) 422cdf0e10cSrcweir return NULL; 423cdf0e10cSrcweir else 424cdf0e10cSrcweir return &ImplReservedKeys::get()->first[i].mKeyCode; 425cdf0e10cSrcweir } 426cdf0e10cSrcweir 427cdf0e10cSrcweir String Application::GetReservedKeyCodeDescription( sal_uLong i ) 428cdf0e10cSrcweir { 429cdf0e10cSrcweir ResMgr* pResMgr = ImplGetResMgr(); 430cdf0e10cSrcweir if( ! pResMgr ) 431cdf0e10cSrcweir return String(); 432cdf0e10cSrcweir ImplReservedKey *pImplReservedKeys = ImplReservedKeys::get()->first; 433cdf0e10cSrcweir if( i >= GetReservedKeyCodeCount() || ! pImplReservedKeys[i].mnResId ) 434cdf0e10cSrcweir return String(); 435cdf0e10cSrcweir else 436cdf0e10cSrcweir return String( ResId( pImplReservedKeys[i].mnResId, *pResMgr ) ); 437cdf0e10cSrcweir } 438cdf0e10cSrcweir 439cdf0e10cSrcweir // ----------------------------------------------------------------------- 440cdf0e10cSrcweir 441cdf0e10cSrcweir void Application::Execute() 442cdf0e10cSrcweir { 443cdf0e10cSrcweir DBG_STARTAPPEXECUTE(); 444cdf0e10cSrcweir 445cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 446cdf0e10cSrcweir pSVData->maAppData.mbInAppExecute = sal_True; 447cdf0e10cSrcweir 448cdf0e10cSrcweir while ( !pSVData->maAppData.mbAppQuit ) 449cdf0e10cSrcweir Application::Yield(); 450cdf0e10cSrcweir 451cdf0e10cSrcweir pSVData->maAppData.mbInAppExecute = sal_False; 452cdf0e10cSrcweir 453cdf0e10cSrcweir DBG_ENDAPPEXECUTE(); 454cdf0e10cSrcweir } 455cdf0e10cSrcweir 456cdf0e10cSrcweir // ----------------------------------------------------------------------- 457cdf0e10cSrcweir 458cdf0e10cSrcweir inline void ImplYield( bool i_bWait, bool i_bAllEvents ) 459cdf0e10cSrcweir { 460cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 461cdf0e10cSrcweir 462cdf0e10cSrcweir // run timers that have timed out 463cdf0e10cSrcweir if ( !pSVData->mbNoCallTimer ) 464cdf0e10cSrcweir while ( pSVData->mbNotAllTimerCalled ) 465cdf0e10cSrcweir Timer::ImplTimerCallbackProc(); 466cdf0e10cSrcweir 467cdf0e10cSrcweir pSVData->maAppData.mnDispatchLevel++; 468cdf0e10cSrcweir // do not wait for events if application was already quit; in that 469cdf0e10cSrcweir // case only dispatch events already available 470cdf0e10cSrcweir // do not wait for events either if the app decided that it is too busy for timers 471cdf0e10cSrcweir // (feature added for the slideshow) 472cdf0e10cSrcweir pSVData->mpDefInst->Yield( i_bWait && !pSVData->maAppData.mbAppQuit && !pSVData->maAppData.mbNoYield, i_bAllEvents ); 473cdf0e10cSrcweir pSVData->maAppData.mnDispatchLevel--; 474cdf0e10cSrcweir 475cdf0e10cSrcweir // flush lazy deleted objects 476cdf0e10cSrcweir if( pSVData->maAppData.mnDispatchLevel == 0 ) 477cdf0e10cSrcweir vcl::LazyDelete::flush(); 478cdf0e10cSrcweir 479cdf0e10cSrcweir // the system timer events will not necesseraly come in in non waiting mode 480cdf0e10cSrcweir // e.g. on aqua; need to trigger timer checks manually 481cdf0e10cSrcweir if( pSVData->maAppData.mbNoYield && !pSVData->mbNoCallTimer ) 482cdf0e10cSrcweir { 483cdf0e10cSrcweir do 484cdf0e10cSrcweir { 485cdf0e10cSrcweir Timer::ImplTimerCallbackProc(); 486cdf0e10cSrcweir } 487cdf0e10cSrcweir while( pSVData->mbNotAllTimerCalled ); 488cdf0e10cSrcweir } 489cdf0e10cSrcweir 490cdf0e10cSrcweir // call post yield listeners 491cdf0e10cSrcweir if( pSVData->maAppData.mpPostYieldListeners ) 492cdf0e10cSrcweir pSVData->maAppData.mpPostYieldListeners->callListeners( NULL ); 493cdf0e10cSrcweir } 494cdf0e10cSrcweir 495cdf0e10cSrcweir // ----------------------------------------------------------------------- 496cdf0e10cSrcweir 497cdf0e10cSrcweir void Application::Reschedule( bool i_bAllEvents ) 498cdf0e10cSrcweir { 499cdf0e10cSrcweir ImplYield( false, i_bAllEvents ); 500cdf0e10cSrcweir } 501cdf0e10cSrcweir 502cdf0e10cSrcweir // ----------------------------------------------------------------------- 503cdf0e10cSrcweir 504cdf0e10cSrcweir void Application::Yield( bool i_bAllEvents ) 505cdf0e10cSrcweir { 506cdf0e10cSrcweir ImplYield( true, i_bAllEvents ); 507cdf0e10cSrcweir } 508cdf0e10cSrcweir 509cdf0e10cSrcweir // ----------------------------------------------------------------------- 510cdf0e10cSrcweir 511cdf0e10cSrcweir IMPL_STATIC_LINK_NOINSTANCE( ImplSVAppData, ImplQuitMsg, void*, EMPTYARG ) 512cdf0e10cSrcweir { 513cdf0e10cSrcweir ImplGetSVData()->maAppData.mbAppQuit = sal_True; 514cdf0e10cSrcweir return 0; 515cdf0e10cSrcweir } 516cdf0e10cSrcweir 517cdf0e10cSrcweir // ----------------------------------------------------------------------- 518cdf0e10cSrcweir 519cdf0e10cSrcweir void Application::Quit() 520cdf0e10cSrcweir { 521cdf0e10cSrcweir Application::PostUserEvent( STATIC_LINK( NULL, ImplSVAppData, ImplQuitMsg ) ); 522cdf0e10cSrcweir } 523cdf0e10cSrcweir 524cdf0e10cSrcweir // ----------------------------------------------------------------------- 525cdf0e10cSrcweir 526cdf0e10cSrcweir vos::IMutex& Application::GetSolarMutex() 527cdf0e10cSrcweir { 528cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 529cdf0e10cSrcweir return *(pSVData->mpDefInst->GetYieldMutex()); 530cdf0e10cSrcweir } 531cdf0e10cSrcweir 532cdf0e10cSrcweir // ----------------------------------------------------------------------- 533cdf0e10cSrcweir 534cdf0e10cSrcweir vos::OThread::TThreadIdentifier Application::GetMainThreadIdentifier() 535cdf0e10cSrcweir { 536cdf0e10cSrcweir return ImplGetSVData()->mnMainThreadId; 537cdf0e10cSrcweir } 538cdf0e10cSrcweir 539cdf0e10cSrcweir // ----------------------------------------------------------------------- 540cdf0e10cSrcweir 541cdf0e10cSrcweir sal_uLong Application::ReleaseSolarMutex() 542cdf0e10cSrcweir { 543cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 544cdf0e10cSrcweir return pSVData->mpDefInst->ReleaseYieldMutex(); 545cdf0e10cSrcweir } 546cdf0e10cSrcweir 547cdf0e10cSrcweir // ----------------------------------------------------------------------- 548cdf0e10cSrcweir 549cdf0e10cSrcweir void Application::AcquireSolarMutex( sal_uLong nCount ) 550cdf0e10cSrcweir { 551cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 552cdf0e10cSrcweir pSVData->mpDefInst->AcquireYieldMutex( nCount ); 553cdf0e10cSrcweir } 554cdf0e10cSrcweir 555cdf0e10cSrcweir // ----------------------------------------------------------------------- 556cdf0e10cSrcweir 557cdf0e10cSrcweir sal_Bool Application::IsInMain() 558cdf0e10cSrcweir { 559cdf0e10cSrcweir return ImplGetSVData()->maAppData.mbInAppMain; 560cdf0e10cSrcweir } 561cdf0e10cSrcweir 562cdf0e10cSrcweir // ----------------------------------------------------------------------- 563cdf0e10cSrcweir 564cdf0e10cSrcweir sal_Bool Application::IsInExecute() 565cdf0e10cSrcweir { 566cdf0e10cSrcweir return ImplGetSVData()->maAppData.mbInAppExecute; 567cdf0e10cSrcweir } 568cdf0e10cSrcweir 569cdf0e10cSrcweir // ----------------------------------------------------------------------- 570cdf0e10cSrcweir 571cdf0e10cSrcweir sal_Bool Application::IsShutDown() 572cdf0e10cSrcweir { 573cdf0e10cSrcweir return ImplGetSVData()->maAppData.mbAppQuit; 574cdf0e10cSrcweir } 575cdf0e10cSrcweir 576cdf0e10cSrcweir // ----------------------------------------------------------------------- 577cdf0e10cSrcweir 578cdf0e10cSrcweir sal_Bool Application::IsInModalMode() 579cdf0e10cSrcweir { 580cdf0e10cSrcweir return (ImplGetSVData()->maAppData.mnModalMode != 0); 581cdf0e10cSrcweir } 582cdf0e10cSrcweir 583cdf0e10cSrcweir // ----------------------------------------------------------------------- 584cdf0e10cSrcweir 585cdf0e10cSrcweir sal_uInt16 Application::GetModalModeCount() 586cdf0e10cSrcweir { 587cdf0e10cSrcweir return ImplGetSVData()->maAppData.mnModalMode; 588cdf0e10cSrcweir } 589cdf0e10cSrcweir 590cdf0e10cSrcweir // ----------------------------------------------------------------------- 591cdf0e10cSrcweir 592cdf0e10cSrcweir sal_uInt16 Application::GetDispatchLevel() 593cdf0e10cSrcweir { 594cdf0e10cSrcweir return ImplGetSVData()->maAppData.mnDispatchLevel; 595cdf0e10cSrcweir } 596cdf0e10cSrcweir 597cdf0e10cSrcweir // ----------------------------------------------------------------------- 598cdf0e10cSrcweir 599cdf0e10cSrcweir sal_Bool Application::AnyInput( sal_uInt16 nType ) 600cdf0e10cSrcweir { 601cdf0e10cSrcweir return (sal_Bool)ImplGetSVData()->mpDefInst->AnyInput( nType ); 602cdf0e10cSrcweir } 603cdf0e10cSrcweir 604cdf0e10cSrcweir // ----------------------------------------------------------------------- 605cdf0e10cSrcweir 606cdf0e10cSrcweir sal_uLong Application::GetLastInputInterval() 607cdf0e10cSrcweir { 608cdf0e10cSrcweir return (Time::GetSystemTicks()-ImplGetSVData()->maAppData.mnLastInputTime); 609cdf0e10cSrcweir } 610cdf0e10cSrcweir 611cdf0e10cSrcweir // ----------------------------------------------------------------------- 612cdf0e10cSrcweir 613cdf0e10cSrcweir extern int nImplSysDialog; 614cdf0e10cSrcweir 615cdf0e10cSrcweir sal_Bool Application::IsUICaptured() 616cdf0e10cSrcweir { 617cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 618cdf0e10cSrcweir // Wenn Mouse gecaptured, oder im TrackingModus oder im Auswahlmodus 619cdf0e10cSrcweir // eines FloatingWindows (wie Menus, Aufklapp-ToolBoxen) soll kein 620cdf0e10cSrcweir // weiteres Fenster aufgezogen werden 621cdf0e10cSrcweir // D&D aktive !!! 622cdf0e10cSrcweir if ( pSVData->maWinData.mpCaptureWin || pSVData->maWinData.mpTrackWin || 623cdf0e10cSrcweir pSVData->maWinData.mpFirstFloat || nImplSysDialog ) 624cdf0e10cSrcweir return sal_True; 625cdf0e10cSrcweir else 626cdf0e10cSrcweir return sal_False; 627cdf0e10cSrcweir } 628cdf0e10cSrcweir 629cdf0e10cSrcweir // ----------------------------------------------------------------------- 630cdf0e10cSrcweir 631cdf0e10cSrcweir sal_Bool Application::IsUserActive( sal_uInt16 nTest ) 632cdf0e10cSrcweir { 633cdf0e10cSrcweir if ( nTest & (USERACTIVE_MOUSEDRAG | USERACTIVE_INPUT) ) 634cdf0e10cSrcweir { 635cdf0e10cSrcweir if ( IsUICaptured() ) 636cdf0e10cSrcweir return sal_True; 637cdf0e10cSrcweir } 638cdf0e10cSrcweir 639cdf0e10cSrcweir if ( nTest & USERACTIVE_INPUT ) 640cdf0e10cSrcweir { 641cdf0e10cSrcweir if ( GetLastInputInterval() < 500 ) 642cdf0e10cSrcweir return sal_True; 643cdf0e10cSrcweir 644cdf0e10cSrcweir if ( AnyInput( INPUT_KEYBOARD ) ) 645cdf0e10cSrcweir return sal_True; 646cdf0e10cSrcweir } 647cdf0e10cSrcweir 648cdf0e10cSrcweir if ( nTest & USERACTIVE_MODALDIALOG ) 649cdf0e10cSrcweir { 650cdf0e10cSrcweir if ( ImplGetSVData()->maAppData.mnModalDialog ) 651cdf0e10cSrcweir return sal_True; 652cdf0e10cSrcweir } 653cdf0e10cSrcweir 654cdf0e10cSrcweir return sal_False; 655cdf0e10cSrcweir } 656cdf0e10cSrcweir 657cdf0e10cSrcweir // ----------------------------------------------------------------------- 658cdf0e10cSrcweir 659cdf0e10cSrcweir void Application::SystemSettingsChanging( AllSettings& /*rSettings*/, 660cdf0e10cSrcweir Window* /*pFrame*/ ) 661cdf0e10cSrcweir { 662cdf0e10cSrcweir } 663cdf0e10cSrcweir 664cdf0e10cSrcweir // ----------------------------------------------------------------------- 665cdf0e10cSrcweir 666cdf0e10cSrcweir void Application::MergeSystemSettings( AllSettings& rSettings ) 667cdf0e10cSrcweir { 668cdf0e10cSrcweir Window* pWindow = ImplGetSVData()->maWinData.mpFirstFrame; 669cdf0e10cSrcweir if( ! pWindow ) 670cdf0e10cSrcweir pWindow = ImplGetDefaultWindow(); 671cdf0e10cSrcweir if( pWindow ) 672cdf0e10cSrcweir { 673cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 674cdf0e10cSrcweir if ( !pSVData->maAppData.mbSettingsInit ) 675cdf0e10cSrcweir { 676cdf0e10cSrcweir // side effect: ImplUpdateGlobalSettings does an ImplGetFrame()->UpdateSettings 677cdf0e10cSrcweir pWindow->ImplUpdateGlobalSettings( *pSVData->maAppData.mpSettings ); 678cdf0e10cSrcweir pSVData->maAppData.mbSettingsInit = sal_True; 679cdf0e10cSrcweir } 680cdf0e10cSrcweir // side effect: ImplUpdateGlobalSettings does an ImplGetFrame()->UpdateSettings 681cdf0e10cSrcweir pWindow->ImplUpdateGlobalSettings( rSettings, sal_False ); 682cdf0e10cSrcweir } 683cdf0e10cSrcweir } 684cdf0e10cSrcweir 685cdf0e10cSrcweir // ----------------------------------------------------------------------- 686cdf0e10cSrcweir 687cdf0e10cSrcweir bool Application::ValidateSystemFont() 688cdf0e10cSrcweir { 689cdf0e10cSrcweir Window* pWindow = ImplGetSVData()->maWinData.mpFirstFrame; 690cdf0e10cSrcweir if( ! pWindow ) 691cdf0e10cSrcweir pWindow = ImplGetDefaultWindow(); 692cdf0e10cSrcweir 693cdf0e10cSrcweir if( pWindow ) 694cdf0e10cSrcweir { 695cdf0e10cSrcweir AllSettings aSettings; 696cdf0e10cSrcweir pWindow->ImplGetFrame()->UpdateSettings( aSettings ); 697cdf0e10cSrcweir return pWindow->ImplCheckUIFont( aSettings.GetStyleSettings().GetAppFont() ); 698cdf0e10cSrcweir } 699cdf0e10cSrcweir return false; 700cdf0e10cSrcweir } 701cdf0e10cSrcweir 702cdf0e10cSrcweir // ----------------------------------------------------------------------- 703cdf0e10cSrcweir 704cdf0e10cSrcweir void Application::SetSettings( const AllSettings& rSettings ) 705cdf0e10cSrcweir { 706cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 707cdf0e10cSrcweir if ( !pSVData->maAppData.mpSettings ) 708cdf0e10cSrcweir { 709cdf0e10cSrcweir GetSettings(); 710cdf0e10cSrcweir *pSVData->maAppData.mpSettings = rSettings; 711cdf0e10cSrcweir ResMgr::SetDefaultLocale( rSettings.GetUILocale() ); 712cdf0e10cSrcweir } 713cdf0e10cSrcweir else 714cdf0e10cSrcweir { 715cdf0e10cSrcweir AllSettings aOldSettings = *pSVData->maAppData.mpSettings; 716cdf0e10cSrcweir if( aOldSettings.GetUILanguage() != rSettings.GetUILanguage() && pSVData->mpResMgr ) 717cdf0e10cSrcweir { 718cdf0e10cSrcweir delete pSVData->mpResMgr; 719cdf0e10cSrcweir pSVData->mpResMgr = NULL; 720cdf0e10cSrcweir } 721cdf0e10cSrcweir ResMgr::SetDefaultLocale( rSettings.GetUILocale() ); 722cdf0e10cSrcweir *pSVData->maAppData.mpSettings = rSettings; 723cdf0e10cSrcweir sal_uLong nChangeFlags = aOldSettings.GetChangeFlags( *pSVData->maAppData.mpSettings ); 724cdf0e10cSrcweir if ( nChangeFlags ) 725cdf0e10cSrcweir { 726cdf0e10cSrcweir DataChangedEvent aDCEvt( DATACHANGED_SETTINGS, &aOldSettings, nChangeFlags ); 727cdf0e10cSrcweir GetpApp()->DataChanged( aDCEvt ); 728cdf0e10cSrcweir 729cdf0e10cSrcweir // notify data change handler 730cdf0e10cSrcweir ImplCallEventListeners( VCLEVENT_APPLICATION_DATACHANGED, NULL, &aDCEvt); 731cdf0e10cSrcweir 732cdf0e10cSrcweir // Update all windows 733cdf0e10cSrcweir Window* pFirstFrame = pSVData->maWinData.mpFirstFrame; 734cdf0e10cSrcweir // Daten, die neu berechnet werden muessen, zuruecksetzen 735cdf0e10cSrcweir long nOldDPIX = 0; 736cdf0e10cSrcweir long nOldDPIY = 0; 737cdf0e10cSrcweir if ( pFirstFrame ) 738cdf0e10cSrcweir { 739cdf0e10cSrcweir nOldDPIX = pFirstFrame->mnDPIX; 740cdf0e10cSrcweir nOldDPIY = pFirstFrame->mnDPIY; 741cdf0e10cSrcweir pSVData->maGDIData.mnAppFontX = 0; 742cdf0e10cSrcweir } 743cdf0e10cSrcweir Window* pFrame = pFirstFrame; 744cdf0e10cSrcweir while ( pFrame ) 745cdf0e10cSrcweir { 746cdf0e10cSrcweir // AppFont-Cache-Daten zuruecksetzen 747cdf0e10cSrcweir pFrame->mpWindowImpl->mpFrameData->meMapUnit = MAP_PIXEL; 748cdf0e10cSrcweir 749cdf0e10cSrcweir // UpdateSettings am ClientWindow aufrufen, damit 750cdf0e10cSrcweir // die Daten nicht doppelt geupdatet werden 751cdf0e10cSrcweir Window* pClientWin = pFrame; 752cdf0e10cSrcweir while ( pClientWin->ImplGetClientWindow() ) 753cdf0e10cSrcweir pClientWin = pClientWin->ImplGetClientWindow(); 754cdf0e10cSrcweir pClientWin->UpdateSettings( rSettings, sal_True ); 755cdf0e10cSrcweir 756cdf0e10cSrcweir Window* pTempWin = pFrame->mpWindowImpl->mpFrameData->mpFirstOverlap; 757cdf0e10cSrcweir while ( pTempWin ) 758cdf0e10cSrcweir { 759cdf0e10cSrcweir // UpdateSettings am ClientWindow aufrufen, damit 760cdf0e10cSrcweir // die Daten nicht doppelt geupdatet werden 761cdf0e10cSrcweir pClientWin = pTempWin; 762cdf0e10cSrcweir while ( pClientWin->ImplGetClientWindow() ) 763cdf0e10cSrcweir pClientWin = pClientWin->ImplGetClientWindow(); 764cdf0e10cSrcweir pClientWin->UpdateSettings( rSettings, sal_True ); 765cdf0e10cSrcweir pTempWin = pTempWin->mpWindowImpl->mpNextOverlap; 766cdf0e10cSrcweir } 767cdf0e10cSrcweir 768cdf0e10cSrcweir pFrame = pFrame->mpWindowImpl->mpFrameData->mpNextFrame; 769cdf0e10cSrcweir } 770cdf0e10cSrcweir 771cdf0e10cSrcweir // Wenn sich die DPI-Aufloesung fuer Screen-Ausgaben 772cdf0e10cSrcweir // geaendert hat, setzen wir auch bei allen 773cdf0e10cSrcweir // Screen-Kompatiblen VirDev's die neue Aufloesung 774cdf0e10cSrcweir pFirstFrame = pSVData->maWinData.mpFirstFrame; 775cdf0e10cSrcweir if ( pFirstFrame ) 776cdf0e10cSrcweir { 777cdf0e10cSrcweir if ( (pFirstFrame->mnDPIX != nOldDPIX) || 778cdf0e10cSrcweir (pFirstFrame->mnDPIY != nOldDPIY) ) 779cdf0e10cSrcweir { 780cdf0e10cSrcweir VirtualDevice* pVirDev = pSVData->maGDIData.mpFirstVirDev; 781cdf0e10cSrcweir while ( pVirDev ) 782cdf0e10cSrcweir { 783cdf0e10cSrcweir if ( pVirDev->mbScreenComp && 784cdf0e10cSrcweir (pVirDev->mnDPIX == nOldDPIX) && 785cdf0e10cSrcweir (pVirDev->mnDPIY == nOldDPIY) ) 786cdf0e10cSrcweir { 787cdf0e10cSrcweir pVirDev->mnDPIX = pFirstFrame->mnDPIX; 788cdf0e10cSrcweir pVirDev->mnDPIY = pFirstFrame->mnDPIY; 789cdf0e10cSrcweir if ( pVirDev->IsMapMode() ) 790cdf0e10cSrcweir { 791cdf0e10cSrcweir MapMode aMapMode = pVirDev->GetMapMode(); 792cdf0e10cSrcweir pVirDev->SetMapMode(); 793cdf0e10cSrcweir pVirDev->SetMapMode( aMapMode ); 794cdf0e10cSrcweir } 795cdf0e10cSrcweir } 796cdf0e10cSrcweir 797cdf0e10cSrcweir pVirDev = pVirDev->mpNext; 798cdf0e10cSrcweir } 799cdf0e10cSrcweir } 800cdf0e10cSrcweir } 801cdf0e10cSrcweir } 802cdf0e10cSrcweir } 803cdf0e10cSrcweir } 804cdf0e10cSrcweir 805cdf0e10cSrcweir // ----------------------------------------------------------------------- 806cdf0e10cSrcweir 807cdf0e10cSrcweir const AllSettings& Application::GetSettings() 808cdf0e10cSrcweir { 809cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 810cdf0e10cSrcweir if ( !pSVData->maAppData.mpSettings ) 811cdf0e10cSrcweir { 812cdf0e10cSrcweir pSVData->maAppData.mpCfgListener = new LocaleConfigurationListener; 813cdf0e10cSrcweir pSVData->maAppData.mpSettings = new AllSettings(); 814cdf0e10cSrcweir pSVData->maAppData.mpSettings->GetSysLocale().GetOptions().AddListener( pSVData->maAppData.mpCfgListener ); 815cdf0e10cSrcweir } 816cdf0e10cSrcweir 817cdf0e10cSrcweir return *(pSVData->maAppData.mpSettings); 818cdf0e10cSrcweir } 819cdf0e10cSrcweir 820cdf0e10cSrcweir // ----------------------------------------------------------------------- 821cdf0e10cSrcweir 822cdf0e10cSrcweir void Application::NotifyAllWindows( DataChangedEvent& rDCEvt ) 823cdf0e10cSrcweir { 824cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 825cdf0e10cSrcweir Window* pFrame = pSVData->maWinData.mpFirstFrame; 826cdf0e10cSrcweir while ( pFrame ) 827cdf0e10cSrcweir { 828cdf0e10cSrcweir pFrame->NotifyAllChilds( rDCEvt ); 829cdf0e10cSrcweir 830cdf0e10cSrcweir Window* pSysWin = pFrame->mpWindowImpl->mpFrameData->mpFirstOverlap; 831cdf0e10cSrcweir while ( pSysWin ) 832cdf0e10cSrcweir { 833cdf0e10cSrcweir pSysWin->NotifyAllChilds( rDCEvt ); 834cdf0e10cSrcweir pSysWin = pSysWin->mpWindowImpl->mpNextOverlap; 835cdf0e10cSrcweir } 836cdf0e10cSrcweir 837cdf0e10cSrcweir pFrame = pFrame->mpWindowImpl->mpFrameData->mpNextFrame; 838cdf0e10cSrcweir } 839cdf0e10cSrcweir } 840cdf0e10cSrcweir 841cdf0e10cSrcweir // ----------------------------------------------------------------------- 842cdf0e10cSrcweir 843cdf0e10cSrcweir void Application::ImplCallEventListeners( sal_uLong nEvent, Window *pWin, void* pData ) 844cdf0e10cSrcweir { 845cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 846cdf0e10cSrcweir VclWindowEvent aEvent( pWin, nEvent, pData ); 847cdf0e10cSrcweir 848cdf0e10cSrcweir if ( pSVData->maAppData.mpEventListeners ) 849cdf0e10cSrcweir if ( !pSVData->maAppData.mpEventListeners->empty() ) 850cdf0e10cSrcweir pSVData->maAppData.mpEventListeners->Call( &aEvent ); 851cdf0e10cSrcweir } 852cdf0e10cSrcweir 853cdf0e10cSrcweir // ----------------------------------------------------------------------- 854cdf0e10cSrcweir 855cdf0e10cSrcweir void Application::ImplCallEventListeners( VclSimpleEvent* pEvent ) 856cdf0e10cSrcweir { 857cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 858cdf0e10cSrcweir 859cdf0e10cSrcweir if ( pSVData->maAppData.mpEventListeners ) 860cdf0e10cSrcweir if ( !pSVData->maAppData.mpEventListeners->empty() ) 861cdf0e10cSrcweir pSVData->maAppData.mpEventListeners->Call( pEvent ); 862cdf0e10cSrcweir } 863cdf0e10cSrcweir 864cdf0e10cSrcweir // ----------------------------------------------------------------------- 865cdf0e10cSrcweir 866cdf0e10cSrcweir void Application::AddEventListener( const Link& rEventListener ) 867cdf0e10cSrcweir { 868cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 869cdf0e10cSrcweir if( !pSVData->maAppData.mpEventListeners ) 870cdf0e10cSrcweir pSVData->maAppData.mpEventListeners = new VclEventListeners; 871cdf0e10cSrcweir pSVData->maAppData.mpEventListeners->push_back( rEventListener ); 872cdf0e10cSrcweir } 873cdf0e10cSrcweir 874cdf0e10cSrcweir // ----------------------------------------------------------------------- 875cdf0e10cSrcweir 876cdf0e10cSrcweir void Application::RemoveEventListener( const Link& rEventListener ) 877cdf0e10cSrcweir { 878cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 879cdf0e10cSrcweir if( pSVData->maAppData.mpEventListeners ) 880cdf0e10cSrcweir pSVData->maAppData.mpEventListeners->remove( rEventListener ); 881cdf0e10cSrcweir } 882cdf0e10cSrcweir 883cdf0e10cSrcweir // ----------------------------------------------------------------------- 884cdf0e10cSrcweir void Application::AddKeyListener( const Link& rKeyListener ) 885cdf0e10cSrcweir { 886cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 887cdf0e10cSrcweir if( !pSVData->maAppData.mpKeyListeners ) 888cdf0e10cSrcweir pSVData->maAppData.mpKeyListeners = new VclEventListeners; 889cdf0e10cSrcweir pSVData->maAppData.mpKeyListeners->push_back( rKeyListener ); 890cdf0e10cSrcweir } 891cdf0e10cSrcweir 892cdf0e10cSrcweir // ----------------------------------------------------------------------- 893cdf0e10cSrcweir 894cdf0e10cSrcweir void Application::RemoveKeyListener( const Link& rKeyListener ) 895cdf0e10cSrcweir { 896cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 897cdf0e10cSrcweir if( pSVData->maAppData.mpKeyListeners ) 898cdf0e10cSrcweir pSVData->maAppData.mpKeyListeners->remove( rKeyListener ); 899cdf0e10cSrcweir } 900cdf0e10cSrcweir 901cdf0e10cSrcweir // ----------------------------------------------------------------------- 902cdf0e10cSrcweir 903cdf0e10cSrcweir sal_Bool Application::HandleKey( sal_uLong nEvent, Window *pWin, KeyEvent* pKeyEvent ) 904cdf0e10cSrcweir { 905cdf0e10cSrcweir // let listeners process the key event 906cdf0e10cSrcweir VclWindowEvent aEvent( pWin, nEvent, (void *) pKeyEvent ); 907cdf0e10cSrcweir 908cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 909cdf0e10cSrcweir sal_Bool bProcessed = sal_False; 910cdf0e10cSrcweir 911cdf0e10cSrcweir if ( pSVData->maAppData.mpKeyListeners ) 912cdf0e10cSrcweir if ( !pSVData->maAppData.mpKeyListeners->empty() ) 913cdf0e10cSrcweir bProcessed = pSVData->maAppData.mpKeyListeners->Process( &aEvent ); 914cdf0e10cSrcweir 915cdf0e10cSrcweir return bProcessed; 916cdf0e10cSrcweir } 917cdf0e10cSrcweir 918cdf0e10cSrcweir // ----------------------------------------------------------------------------- 919cdf0e10cSrcweir 920cdf0e10cSrcweir sal_uLong Application::PostKeyEvent( sal_uLong nEvent, Window *pWin, KeyEvent* pKeyEvent ) 921cdf0e10cSrcweir { 922cdf0e10cSrcweir const ::vos::OGuard aGuard( GetSolarMutex() ); 923cdf0e10cSrcweir sal_uLong nEventId = 0; 924cdf0e10cSrcweir 925cdf0e10cSrcweir if( pWin && pKeyEvent ) 926cdf0e10cSrcweir { 927cdf0e10cSrcweir ImplPostEventData* pPostEventData = new ImplPostEventData( nEvent, pWin, *pKeyEvent ); 928cdf0e10cSrcweir 929cdf0e10cSrcweir PostUserEvent( nEventId, 930cdf0e10cSrcweir STATIC_LINK( NULL, Application, PostEventHandler ), 931cdf0e10cSrcweir pPostEventData ); 932cdf0e10cSrcweir 933cdf0e10cSrcweir if( nEventId ) 934cdf0e10cSrcweir { 935cdf0e10cSrcweir pPostEventData->mnEventId = nEventId; 936cdf0e10cSrcweir aPostedEventList.push_back( ImplPostEventPair( pWin, pPostEventData ) ); 937cdf0e10cSrcweir } 938cdf0e10cSrcweir else 939cdf0e10cSrcweir delete pPostEventData; 940cdf0e10cSrcweir } 941cdf0e10cSrcweir 942cdf0e10cSrcweir return nEventId; 943cdf0e10cSrcweir } 944cdf0e10cSrcweir 945cdf0e10cSrcweir // ----------------------------------------------------------------------------- 946cdf0e10cSrcweir 947cdf0e10cSrcweir sal_uLong Application::PostMouseEvent( sal_uLong nEvent, Window *pWin, MouseEvent* pMouseEvent ) 948cdf0e10cSrcweir { 949cdf0e10cSrcweir const ::vos::OGuard aGuard( GetSolarMutex() ); 950cdf0e10cSrcweir sal_uLong nEventId = 0; 951cdf0e10cSrcweir 952cdf0e10cSrcweir if( pWin && pMouseEvent ) 953cdf0e10cSrcweir { 954cdf0e10cSrcweir Point aTransformedPos( pMouseEvent->GetPosPixel() ); 955cdf0e10cSrcweir 956cdf0e10cSrcweir aTransformedPos.X() += pWin->mnOutOffX; 957cdf0e10cSrcweir aTransformedPos.Y() += pWin->mnOutOffY; 958cdf0e10cSrcweir 959cdf0e10cSrcweir const MouseEvent aTransformedEvent( aTransformedPos, pMouseEvent->GetClicks(), pMouseEvent->GetMode(), 960cdf0e10cSrcweir pMouseEvent->GetButtons(), pMouseEvent->GetModifier() ); 961cdf0e10cSrcweir 962cdf0e10cSrcweir ImplPostEventData* pPostEventData = new ImplPostEventData( nEvent, pWin, aTransformedEvent ); 963cdf0e10cSrcweir 964cdf0e10cSrcweir PostUserEvent( nEventId, 965cdf0e10cSrcweir STATIC_LINK( NULL, Application, PostEventHandler ), 966cdf0e10cSrcweir pPostEventData ); 967cdf0e10cSrcweir 968cdf0e10cSrcweir if( nEventId ) 969cdf0e10cSrcweir { 970cdf0e10cSrcweir pPostEventData->mnEventId = nEventId; 971cdf0e10cSrcweir aPostedEventList.push_back( ImplPostEventPair( pWin, pPostEventData ) ); 972cdf0e10cSrcweir } 973cdf0e10cSrcweir else 974cdf0e10cSrcweir delete pPostEventData; 975cdf0e10cSrcweir } 976cdf0e10cSrcweir 977cdf0e10cSrcweir return nEventId; 978cdf0e10cSrcweir } 979cdf0e10cSrcweir 980cdf0e10cSrcweir // ----------------------------------------------------------------------------- 981cdf0e10cSrcweir 982cdf0e10cSrcweir IMPL_STATIC_LINK_NOINSTANCE( Application, PostEventHandler, void*, pCallData ) 983cdf0e10cSrcweir { 984cdf0e10cSrcweir const ::vos::OGuard aGuard( GetSolarMutex() ); 985cdf0e10cSrcweir ImplPostEventData* pData = static_cast< ImplPostEventData * >( pCallData ); 986cdf0e10cSrcweir const void* pEventData; 987cdf0e10cSrcweir sal_uLong nEvent; 988cdf0e10cSrcweir const sal_uLong nEventId = pData->mnEventId; 989cdf0e10cSrcweir 990cdf0e10cSrcweir switch( pData->mnEvent ) 991cdf0e10cSrcweir { 992cdf0e10cSrcweir case VCLEVENT_WINDOW_MOUSEMOVE: 993cdf0e10cSrcweir nEvent = SALEVENT_EXTERNALMOUSEMOVE; 994cdf0e10cSrcweir pEventData = &pData->maMouseEvent; 995cdf0e10cSrcweir break; 996cdf0e10cSrcweir 997cdf0e10cSrcweir case VCLEVENT_WINDOW_MOUSEBUTTONDOWN: 998cdf0e10cSrcweir nEvent = SALEVENT_EXTERNALMOUSEBUTTONDOWN; 999cdf0e10cSrcweir pEventData = &pData->maMouseEvent; 1000cdf0e10cSrcweir break; 1001cdf0e10cSrcweir 1002cdf0e10cSrcweir case VCLEVENT_WINDOW_MOUSEBUTTONUP: 1003cdf0e10cSrcweir nEvent = SALEVENT_EXTERNALMOUSEBUTTONUP; 1004cdf0e10cSrcweir pEventData = &pData->maMouseEvent; 1005cdf0e10cSrcweir break; 1006cdf0e10cSrcweir 1007cdf0e10cSrcweir case VCLEVENT_WINDOW_KEYINPUT: 1008cdf0e10cSrcweir nEvent = SALEVENT_EXTERNALKEYINPUT; 1009cdf0e10cSrcweir pEventData = &pData->maKeyEvent; 1010cdf0e10cSrcweir break; 1011cdf0e10cSrcweir 1012cdf0e10cSrcweir case VCLEVENT_WINDOW_KEYUP: 1013cdf0e10cSrcweir nEvent = SALEVENT_EXTERNALKEYUP; 1014cdf0e10cSrcweir pEventData = &pData->maKeyEvent; 1015cdf0e10cSrcweir break; 1016cdf0e10cSrcweir 1017cdf0e10cSrcweir default: 1018cdf0e10cSrcweir nEvent = 0; 1019cdf0e10cSrcweir pEventData = NULL; 1020cdf0e10cSrcweir break; 1021cdf0e10cSrcweir }; 1022cdf0e10cSrcweir 1023cdf0e10cSrcweir if( pData->mpWin && pData->mpWin->mpWindowImpl->mpFrameWindow && pEventData ) 1024cdf0e10cSrcweir ImplWindowFrameProc( pData->mpWin->mpWindowImpl->mpFrameWindow, NULL, (sal_uInt16) nEvent, pEventData ); 1025cdf0e10cSrcweir 1026cdf0e10cSrcweir // remove this event from list of posted events, watch for destruction of internal data 1027cdf0e10cSrcweir ::std::list< ImplPostEventPair >::iterator aIter( aPostedEventList.begin() ); 1028cdf0e10cSrcweir 1029cdf0e10cSrcweir while( aIter != aPostedEventList.end() ) 1030cdf0e10cSrcweir { 1031cdf0e10cSrcweir if( nEventId == (*aIter).second->mnEventId ) 1032cdf0e10cSrcweir { 1033cdf0e10cSrcweir delete (*aIter).second; 1034cdf0e10cSrcweir aIter = aPostedEventList.erase( aIter ); 1035cdf0e10cSrcweir } 1036cdf0e10cSrcweir else 1037cdf0e10cSrcweir ++aIter; 1038cdf0e10cSrcweir } 1039cdf0e10cSrcweir 1040cdf0e10cSrcweir return 0; 1041cdf0e10cSrcweir } 1042cdf0e10cSrcweir 1043cdf0e10cSrcweir // ----------------------------------------------------------------------- 1044cdf0e10cSrcweir 1045cdf0e10cSrcweir void Application::RemoveMouseAndKeyEvents( Window* pWin ) 1046cdf0e10cSrcweir { 1047cdf0e10cSrcweir const ::vos::OGuard aGuard( GetSolarMutex() ); 1048cdf0e10cSrcweir 1049cdf0e10cSrcweir // remove all events for specific window, watch for destruction of internal data 1050cdf0e10cSrcweir ::std::list< ImplPostEventPair >::iterator aIter( aPostedEventList.begin() ); 1051cdf0e10cSrcweir 1052cdf0e10cSrcweir while( aIter != aPostedEventList.end() ) 1053cdf0e10cSrcweir { 1054cdf0e10cSrcweir if( pWin == (*aIter).first ) 1055cdf0e10cSrcweir { 1056cdf0e10cSrcweir if( (*aIter).second->mnEventId ) 1057cdf0e10cSrcweir RemoveUserEvent( (*aIter).second->mnEventId ); 1058cdf0e10cSrcweir 1059cdf0e10cSrcweir delete (*aIter).second; 1060cdf0e10cSrcweir aIter = aPostedEventList.erase( aIter ); 1061cdf0e10cSrcweir } 1062cdf0e10cSrcweir else 1063cdf0e10cSrcweir ++aIter; 1064cdf0e10cSrcweir } 1065cdf0e10cSrcweir } 1066cdf0e10cSrcweir 1067cdf0e10cSrcweir // ----------------------------------------------------------------------- 1068cdf0e10cSrcweir 1069cdf0e10cSrcweir sal_Bool Application::IsProcessedMouseOrKeyEvent( sal_uLong nEventId ) 1070cdf0e10cSrcweir { 1071cdf0e10cSrcweir const ::vos::OGuard aGuard( GetSolarMutex() ); 1072cdf0e10cSrcweir 1073cdf0e10cSrcweir // find event 1074cdf0e10cSrcweir ::std::list< ImplPostEventPair >::iterator aIter( aPostedEventList.begin() ); 1075cdf0e10cSrcweir 1076cdf0e10cSrcweir while( aIter != aPostedEventList.end() ) 1077cdf0e10cSrcweir { 1078cdf0e10cSrcweir if( (*aIter).second->mnEventId == nEventId ) 1079cdf0e10cSrcweir return sal_False; 1080cdf0e10cSrcweir 1081cdf0e10cSrcweir else 1082cdf0e10cSrcweir ++aIter; 1083cdf0e10cSrcweir } 1084cdf0e10cSrcweir return sal_True; 1085cdf0e10cSrcweir } 1086cdf0e10cSrcweir 1087cdf0e10cSrcweir // ----------------------------------------------------------------------- 1088cdf0e10cSrcweir 1089cdf0e10cSrcweir sal_uLong Application::PostUserEvent( sal_uLong nEvent, void* pEventData ) 1090cdf0e10cSrcweir { 1091cdf0e10cSrcweir sal_uLong nEventId; 1092cdf0e10cSrcweir PostUserEvent( nEventId, nEvent, pEventData ); 1093cdf0e10cSrcweir return nEventId; 1094cdf0e10cSrcweir } 1095cdf0e10cSrcweir 1096cdf0e10cSrcweir // ----------------------------------------------------------------------- 1097cdf0e10cSrcweir 1098cdf0e10cSrcweir sal_uLong Application::PostUserEvent( const Link& rLink, void* pCaller ) 1099cdf0e10cSrcweir { 1100cdf0e10cSrcweir sal_uLong nEventId; 1101cdf0e10cSrcweir PostUserEvent( nEventId, rLink, pCaller ); 1102cdf0e10cSrcweir return nEventId; 1103cdf0e10cSrcweir } 1104cdf0e10cSrcweir 1105cdf0e10cSrcweir // ----------------------------------------------------------------------- 1106cdf0e10cSrcweir 1107cdf0e10cSrcweir sal_Bool Application::PostUserEvent( sal_uLong& rEventId, sal_uLong nEvent, void* pEventData ) 1108cdf0e10cSrcweir { 1109cdf0e10cSrcweir ImplSVEvent* pSVEvent = new ImplSVEvent; 1110cdf0e10cSrcweir pSVEvent->mnEvent = nEvent; 1111cdf0e10cSrcweir pSVEvent->mpData = pEventData; 1112cdf0e10cSrcweir pSVEvent->mpLink = NULL; 1113cdf0e10cSrcweir pSVEvent->mpWindow = NULL; 1114cdf0e10cSrcweir pSVEvent->mbCall = sal_True; 1115cdf0e10cSrcweir rEventId = (sal_uLong)pSVEvent; 1116cdf0e10cSrcweir Window* pDefWindow = ImplGetDefaultWindow(); 1117cdf0e10cSrcweir if ( pDefWindow && pDefWindow->ImplGetFrame()->PostEvent( pSVEvent ) ) 1118cdf0e10cSrcweir return sal_True; 1119cdf0e10cSrcweir else 1120cdf0e10cSrcweir { 1121cdf0e10cSrcweir rEventId = 0; 1122cdf0e10cSrcweir delete pSVEvent; 1123cdf0e10cSrcweir return sal_False; 1124cdf0e10cSrcweir } 1125cdf0e10cSrcweir } 1126cdf0e10cSrcweir 1127cdf0e10cSrcweir // ----------------------------------------------------------------------- 1128cdf0e10cSrcweir 1129cdf0e10cSrcweir sal_Bool Application::PostUserEvent( sal_uLong& rEventId, const Link& rLink, void* pCaller ) 1130cdf0e10cSrcweir { 1131cdf0e10cSrcweir ImplSVEvent* pSVEvent = new ImplSVEvent; 1132cdf0e10cSrcweir pSVEvent->mnEvent = 0; 1133cdf0e10cSrcweir pSVEvent->mpData = pCaller; 1134cdf0e10cSrcweir pSVEvent->mpLink = new Link( rLink ); 1135cdf0e10cSrcweir pSVEvent->mpWindow = NULL; 1136cdf0e10cSrcweir pSVEvent->mbCall = sal_True; 1137cdf0e10cSrcweir rEventId = (sal_uLong)pSVEvent; 1138cdf0e10cSrcweir Window* pDefWindow = ImplGetDefaultWindow(); 1139cdf0e10cSrcweir if ( pDefWindow && pDefWindow->ImplGetFrame()->PostEvent( pSVEvent ) ) 1140cdf0e10cSrcweir return sal_True; 1141cdf0e10cSrcweir else 1142cdf0e10cSrcweir { 1143cdf0e10cSrcweir rEventId = 0; 1144cdf0e10cSrcweir delete pSVEvent; 1145cdf0e10cSrcweir return sal_False; 1146cdf0e10cSrcweir } 1147cdf0e10cSrcweir } 1148cdf0e10cSrcweir 1149cdf0e10cSrcweir // ----------------------------------------------------------------------- 1150cdf0e10cSrcweir 1151cdf0e10cSrcweir void Application::RemoveUserEvent( sal_uLong nUserEvent ) 1152cdf0e10cSrcweir { 1153cdf0e10cSrcweir if(nUserEvent) 1154cdf0e10cSrcweir { 1155cdf0e10cSrcweir ImplSVEvent* pSVEvent = (ImplSVEvent*)nUserEvent; 1156cdf0e10cSrcweir 1157cdf0e10cSrcweir DBG_ASSERT( !pSVEvent->mpWindow, 1158cdf0e10cSrcweir "Application::RemoveUserEvent(): Event is send to a window" ); 1159cdf0e10cSrcweir DBG_ASSERT( pSVEvent->mbCall, 1160cdf0e10cSrcweir "Application::RemoveUserEvent(): Event is already removed" ); 1161cdf0e10cSrcweir 1162cdf0e10cSrcweir if ( pSVEvent->mpWindow ) 1163cdf0e10cSrcweir { 1164cdf0e10cSrcweir if( ! pSVEvent->maDelData.IsDelete() ) 1165cdf0e10cSrcweir pSVEvent->mpWindow->ImplRemoveDel( &(pSVEvent->maDelData) ); 1166cdf0e10cSrcweir pSVEvent->mpWindow = NULL; 1167cdf0e10cSrcweir } 1168cdf0e10cSrcweir 1169cdf0e10cSrcweir pSVEvent->mbCall = sal_False; 1170cdf0e10cSrcweir } 1171cdf0e10cSrcweir } 1172cdf0e10cSrcweir 1173cdf0e10cSrcweir // ----------------------------------------------------------------------- 1174cdf0e10cSrcweir 1175cdf0e10cSrcweir sal_Bool Application::InsertIdleHdl( const Link& rLink, sal_uInt16 nPrio ) 1176cdf0e10cSrcweir { 1177cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1178cdf0e10cSrcweir 1179cdf0e10cSrcweir // Falls er noch nicht existiert, dann anlegen 1180cdf0e10cSrcweir if ( !pSVData->maAppData.mpIdleMgr ) 1181cdf0e10cSrcweir pSVData->maAppData.mpIdleMgr = new ImplIdleMgr; 1182cdf0e10cSrcweir 1183cdf0e10cSrcweir return pSVData->maAppData.mpIdleMgr->InsertIdleHdl( rLink, nPrio ); 1184cdf0e10cSrcweir } 1185cdf0e10cSrcweir 1186cdf0e10cSrcweir // ----------------------------------------------------------------------- 1187cdf0e10cSrcweir 1188cdf0e10cSrcweir void Application::RemoveIdleHdl( const Link& rLink ) 1189cdf0e10cSrcweir { 1190cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1191cdf0e10cSrcweir 1192cdf0e10cSrcweir if ( pSVData->maAppData.mpIdleMgr ) 1193cdf0e10cSrcweir pSVData->maAppData.mpIdleMgr->RemoveIdleHdl( rLink ); 1194cdf0e10cSrcweir } 1195cdf0e10cSrcweir 1196cdf0e10cSrcweir // ----------------------------------------------------------------------- 1197cdf0e10cSrcweir 1198cdf0e10cSrcweir void Application::EnableNoYieldMode( bool i_bNoYield ) 1199cdf0e10cSrcweir { 1200cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1201cdf0e10cSrcweir pSVData->maAppData.mbNoYield = i_bNoYield; 1202cdf0e10cSrcweir } 1203cdf0e10cSrcweir 1204cdf0e10cSrcweir // ----------------------------------------------------------------------- 1205cdf0e10cSrcweir 1206cdf0e10cSrcweir void Application::AddPostYieldListener( const Link& i_rListener ) 1207cdf0e10cSrcweir { 1208cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1209cdf0e10cSrcweir if( ! pSVData->maAppData.mpPostYieldListeners ) 1210cdf0e10cSrcweir pSVData->maAppData.mpPostYieldListeners = new VclEventListeners2(); 1211cdf0e10cSrcweir pSVData->maAppData.mpPostYieldListeners->addListener( i_rListener ); 1212cdf0e10cSrcweir } 1213cdf0e10cSrcweir 1214cdf0e10cSrcweir // ----------------------------------------------------------------------- 1215cdf0e10cSrcweir 1216cdf0e10cSrcweir void Application::RemovePostYieldListener( const Link& i_rListener ) 1217cdf0e10cSrcweir { 1218cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1219cdf0e10cSrcweir if( pSVData->maAppData.mpPostYieldListeners ) 1220cdf0e10cSrcweir pSVData->maAppData.mpPostYieldListeners->removeListener( i_rListener ); 1221cdf0e10cSrcweir } 1222cdf0e10cSrcweir 1223cdf0e10cSrcweir // ----------------------------------------------------------------------- 1224cdf0e10cSrcweir 1225cdf0e10cSrcweir WorkWindow* Application::GetAppWindow() 1226cdf0e10cSrcweir { 1227cdf0e10cSrcweir return ImplGetSVData()->maWinData.mpAppWin; 1228cdf0e10cSrcweir } 1229cdf0e10cSrcweir 1230cdf0e10cSrcweir // ----------------------------------------------------------------------- 1231cdf0e10cSrcweir 1232cdf0e10cSrcweir Window* Application::GetFocusWindow() 1233cdf0e10cSrcweir { 1234cdf0e10cSrcweir return ImplGetSVData()->maWinData.mpFocusWin; 1235cdf0e10cSrcweir } 1236cdf0e10cSrcweir 1237cdf0e10cSrcweir // ----------------------------------------------------------------------- 1238cdf0e10cSrcweir 1239cdf0e10cSrcweir OutputDevice* Application::GetDefaultDevice() 1240cdf0e10cSrcweir { 1241cdf0e10cSrcweir return ImplGetDefaultWindow(); 1242cdf0e10cSrcweir } 1243cdf0e10cSrcweir 1244cdf0e10cSrcweir // ----------------------------------------------------------------------- 1245cdf0e10cSrcweir 1246cdf0e10cSrcweir Window* Application::GetFirstTopLevelWindow() 1247cdf0e10cSrcweir { 1248cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1249cdf0e10cSrcweir return pSVData->maWinData.mpFirstFrame; 1250cdf0e10cSrcweir } 1251cdf0e10cSrcweir 1252cdf0e10cSrcweir // ----------------------------------------------------------------------- 1253cdf0e10cSrcweir 1254cdf0e10cSrcweir Window* Application::GetNextTopLevelWindow( Window* pWindow ) 1255cdf0e10cSrcweir { 1256cdf0e10cSrcweir return pWindow->mpWindowImpl->mpFrameData->mpNextFrame; 1257cdf0e10cSrcweir } 1258cdf0e10cSrcweir 1259cdf0e10cSrcweir // ----------------------------------------------------------------------- 1260cdf0e10cSrcweir 1261cdf0e10cSrcweir long Application::GetTopWindowCount() 1262cdf0e10cSrcweir { 1263cdf0e10cSrcweir long nRet = 0; 1264cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1265cdf0e10cSrcweir Window *pWin = pSVData ? pSVData->maWinData.mpFirstFrame : NULL; 1266cdf0e10cSrcweir while( pWin ) 1267cdf0e10cSrcweir { 1268cdf0e10cSrcweir if( pWin->ImplGetWindow()->IsTopWindow() ) 1269cdf0e10cSrcweir nRet++; 1270cdf0e10cSrcweir pWin = pWin->mpWindowImpl->mpFrameData->mpNextFrame; 1271cdf0e10cSrcweir } 1272cdf0e10cSrcweir return nRet; 1273cdf0e10cSrcweir } 1274cdf0e10cSrcweir 1275cdf0e10cSrcweir // ----------------------------------------------------------------------- 1276cdf0e10cSrcweir 1277cdf0e10cSrcweir Window* Application::GetTopWindow( long nIndex ) 1278cdf0e10cSrcweir { 1279cdf0e10cSrcweir long nIdx = 0; 1280cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1281cdf0e10cSrcweir Window *pWin = pSVData ? pSVData->maWinData.mpFirstFrame : NULL; 1282cdf0e10cSrcweir while( pWin ) 1283cdf0e10cSrcweir { 1284cdf0e10cSrcweir if( pWin->ImplGetWindow()->IsTopWindow() ) 1285cdf0e10cSrcweir { 1286cdf0e10cSrcweir if( nIdx == nIndex ) 1287cdf0e10cSrcweir return pWin->ImplGetWindow(); 1288cdf0e10cSrcweir else 1289cdf0e10cSrcweir nIdx++; 1290cdf0e10cSrcweir } 1291cdf0e10cSrcweir pWin = pWin->mpWindowImpl->mpFrameData->mpNextFrame; 1292cdf0e10cSrcweir } 1293cdf0e10cSrcweir return NULL; 1294cdf0e10cSrcweir } 1295cdf0e10cSrcweir 1296cdf0e10cSrcweir // ----------------------------------------------------------------------- 1297cdf0e10cSrcweir 1298cdf0e10cSrcweir Window* Application::GetActiveTopWindow() 1299cdf0e10cSrcweir { 1300cdf0e10cSrcweir Window *pWin = ImplGetSVData()->maWinData.mpFocusWin; 1301cdf0e10cSrcweir while( pWin ) 1302cdf0e10cSrcweir { 1303cdf0e10cSrcweir if( pWin->IsTopWindow() ) 1304cdf0e10cSrcweir return pWin; 1305cdf0e10cSrcweir pWin = pWin->mpWindowImpl->mpParent; 1306cdf0e10cSrcweir } 1307cdf0e10cSrcweir return NULL; 1308cdf0e10cSrcweir } 1309cdf0e10cSrcweir 1310cdf0e10cSrcweir // ----------------------------------------------------------------------- 1311cdf0e10cSrcweir 1312cdf0e10cSrcweir void Application::SetAppName( const XubString& rUniqueName ) 1313cdf0e10cSrcweir { 1314cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1315cdf0e10cSrcweir 1316cdf0e10cSrcweir // Falls er noch nicht existiert, dann anlegen 1317cdf0e10cSrcweir if ( !pSVData->maAppData.mpAppName ) 1318cdf0e10cSrcweir pSVData->maAppData.mpAppName = new XubString( rUniqueName ); 1319cdf0e10cSrcweir else 1320cdf0e10cSrcweir *(pSVData->maAppData.mpAppName) = rUniqueName; 1321cdf0e10cSrcweir } 1322cdf0e10cSrcweir 1323cdf0e10cSrcweir // ----------------------------------------------------------------------- 1324cdf0e10cSrcweir 1325cdf0e10cSrcweir XubString Application::GetAppName() 1326cdf0e10cSrcweir { 1327cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1328cdf0e10cSrcweir if ( pSVData->maAppData.mpAppName ) 1329cdf0e10cSrcweir return *(pSVData->maAppData.mpAppName); 1330cdf0e10cSrcweir else 1331cdf0e10cSrcweir return ImplGetSVEmptyStr(); 1332cdf0e10cSrcweir } 1333cdf0e10cSrcweir 1334cdf0e10cSrcweir // ----------------------------------------------------------------------- 1335cdf0e10cSrcweir 1336cdf0e10cSrcweir void Application::SetDisplayName( const UniString& rName ) 1337cdf0e10cSrcweir { 1338cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1339cdf0e10cSrcweir 1340cdf0e10cSrcweir // Falls er noch nicht existiert, dann anlegen 1341cdf0e10cSrcweir if ( !pSVData->maAppData.mpDisplayName ) 1342cdf0e10cSrcweir pSVData->maAppData.mpDisplayName = new UniString( rName ); 1343cdf0e10cSrcweir else 1344cdf0e10cSrcweir *(pSVData->maAppData.mpDisplayName) = rName; 1345cdf0e10cSrcweir } 1346cdf0e10cSrcweir 1347cdf0e10cSrcweir // ----------------------------------------------------------------------- 1348cdf0e10cSrcweir 1349cdf0e10cSrcweir UniString Application::GetDisplayName() 1350cdf0e10cSrcweir { 1351cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1352cdf0e10cSrcweir if ( pSVData->maAppData.mpDisplayName ) 1353cdf0e10cSrcweir return *(pSVData->maAppData.mpDisplayName); 1354cdf0e10cSrcweir else if ( pSVData->maWinData.mpAppWin ) 1355cdf0e10cSrcweir return pSVData->maWinData.mpAppWin->GetText(); 1356cdf0e10cSrcweir else 1357cdf0e10cSrcweir return ImplGetSVEmptyStr(); 1358cdf0e10cSrcweir } 1359cdf0e10cSrcweir 1360cdf0e10cSrcweir // ----------------------------------------------------------------------- 1361cdf0e10cSrcweir 1362cdf0e10cSrcweir unsigned int Application::GetScreenCount() 1363cdf0e10cSrcweir { 1364cdf0e10cSrcweir SalSystem* pSys = ImplGetSalSystem(); 1365cdf0e10cSrcweir return pSys ? pSys->GetDisplayScreenCount() : 0; 1366cdf0e10cSrcweir } 1367cdf0e10cSrcweir 1368cdf0e10cSrcweir rtl::OUString Application::GetScreenName( unsigned int nScreen ) 1369cdf0e10cSrcweir { 1370cdf0e10cSrcweir SalSystem* pSys = ImplGetSalSystem(); 1371cdf0e10cSrcweir return pSys ? pSys->GetScreenName( nScreen ) : rtl::OUString(); 1372cdf0e10cSrcweir } 1373cdf0e10cSrcweir 1374cdf0e10cSrcweir bool Application::IsMultiDisplay() 1375cdf0e10cSrcweir { 1376cdf0e10cSrcweir SalSystem* pSys = ImplGetSalSystem(); 1377cdf0e10cSrcweir return pSys ? pSys->IsMultiDisplay() : false; 1378cdf0e10cSrcweir } 1379cdf0e10cSrcweir 1380cdf0e10cSrcweir unsigned int Application::GetDefaultDisplayNumber() 1381cdf0e10cSrcweir { 1382cdf0e10cSrcweir SalSystem* pSys = ImplGetSalSystem(); 1383cdf0e10cSrcweir return pSys ? pSys->GetDefaultDisplayNumber() : 0; 1384cdf0e10cSrcweir } 1385cdf0e10cSrcweir 1386cdf0e10cSrcweir Rectangle Application::GetScreenPosSizePixel( unsigned int nScreen ) 1387cdf0e10cSrcweir { 1388cdf0e10cSrcweir SalSystem* pSys = ImplGetSalSystem(); 1389cdf0e10cSrcweir return pSys ? pSys->GetDisplayScreenPosSizePixel( nScreen ) : Rectangle(); 1390cdf0e10cSrcweir } 1391cdf0e10cSrcweir 1392cdf0e10cSrcweir Rectangle Application::GetWorkAreaPosSizePixel( unsigned int nScreen ) 1393cdf0e10cSrcweir { 1394cdf0e10cSrcweir SalSystem* pSys = ImplGetSalSystem(); 1395cdf0e10cSrcweir return pSys ? pSys->GetDisplayWorkAreaPosSizePixel( nScreen ) : Rectangle(); 1396cdf0e10cSrcweir } 1397cdf0e10cSrcweir 1398cdf0e10cSrcweir namespace { 1399cdf0e10cSrcweir unsigned long calcDistSquare( const Point& i_rPoint, const Rectangle& i_rRect ) 1400cdf0e10cSrcweir { 1401cdf0e10cSrcweir const Point aRectCenter( (i_rRect.Left() + i_rRect.Right())/2, 1402cdf0e10cSrcweir (i_rRect.Top() + i_rRect.Bottom())/ 2 ); 1403cdf0e10cSrcweir const long nDX = aRectCenter.X() - i_rPoint.X(); 1404cdf0e10cSrcweir const long nDY = aRectCenter.Y() - i_rPoint.Y(); 1405cdf0e10cSrcweir return nDX*nDX + nDY*nDY; 1406cdf0e10cSrcweir } 1407cdf0e10cSrcweir } 1408cdf0e10cSrcweir 1409cdf0e10cSrcweir unsigned int Application::GetBestScreen( const Rectangle& i_rRect ) 1410cdf0e10cSrcweir { 1411cdf0e10cSrcweir if( IsMultiDisplay() ) 1412cdf0e10cSrcweir return GetDefaultDisplayNumber(); 1413cdf0e10cSrcweir 1414cdf0e10cSrcweir const unsigned int nScreens = GetScreenCount(); 1415cdf0e10cSrcweir unsigned int nBestMatchScreen = 0; 1416cdf0e10cSrcweir unsigned long nOverlap = 0; 1417cdf0e10cSrcweir for( unsigned int i = 0; i < nScreens; i++ ) 1418cdf0e10cSrcweir { 1419cdf0e10cSrcweir const Rectangle aCurScreenRect( GetScreenPosSizePixel( i ) ); 1420cdf0e10cSrcweir // if a screen contains the rectangle completely it is obviously the best screen 1421cdf0e10cSrcweir if( aCurScreenRect.IsInside( i_rRect ) ) 1422cdf0e10cSrcweir return i; 1423cdf0e10cSrcweir // next the screen which contains most of the area of the rect is the best 1424cdf0e10cSrcweir Rectangle aIntersection( aCurScreenRect.GetIntersection( i_rRect ) ); 1425cdf0e10cSrcweir if( ! aIntersection.IsEmpty() ) 1426cdf0e10cSrcweir { 1427cdf0e10cSrcweir const unsigned long nCurOverlap( aIntersection.GetWidth() * aIntersection.GetHeight() ); 1428cdf0e10cSrcweir if( nCurOverlap > nOverlap ) 1429cdf0e10cSrcweir { 1430cdf0e10cSrcweir nOverlap = nCurOverlap; 1431cdf0e10cSrcweir nBestMatchScreen = i; 1432cdf0e10cSrcweir } 1433cdf0e10cSrcweir } 1434cdf0e10cSrcweir } 1435cdf0e10cSrcweir if( nOverlap > 0 ) 1436cdf0e10cSrcweir return nBestMatchScreen; 1437cdf0e10cSrcweir 1438cdf0e10cSrcweir // finally the screen which center is nearest to the rect is the best 1439cdf0e10cSrcweir const Point aCenter( (i_rRect.Left() + i_rRect.Right())/2, 1440cdf0e10cSrcweir (i_rRect.Top() + i_rRect.Bottom())/2 ); 1441cdf0e10cSrcweir unsigned long nDist = ULONG_MAX; 1442cdf0e10cSrcweir for( unsigned int i = 0; i < nScreens; i++ ) 1443cdf0e10cSrcweir { 1444cdf0e10cSrcweir const Rectangle aCurScreenRect( GetScreenPosSizePixel( i ) ); 1445cdf0e10cSrcweir const unsigned long nCurDist( calcDistSquare( aCenter, aCurScreenRect ) ); 1446cdf0e10cSrcweir if( nCurDist < nDist ) 1447cdf0e10cSrcweir { 1448cdf0e10cSrcweir nBestMatchScreen = i; 1449cdf0e10cSrcweir nDist = nCurDist; 1450cdf0e10cSrcweir } 1451cdf0e10cSrcweir } 1452cdf0e10cSrcweir return nBestMatchScreen; 1453cdf0e10cSrcweir } 1454cdf0e10cSrcweir 1455cdf0e10cSrcweir // ----------------------------------------------------------------------- 1456cdf0e10cSrcweir 1457cdf0e10cSrcweir sal_Bool Application::InsertAccel( Accelerator* pAccel ) 1458cdf0e10cSrcweir { 1459cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1460cdf0e10cSrcweir 1461cdf0e10cSrcweir if ( !pSVData->maAppData.mpAccelMgr ) 1462cdf0e10cSrcweir pSVData->maAppData.mpAccelMgr = new ImplAccelManager(); 1463cdf0e10cSrcweir return pSVData->maAppData.mpAccelMgr->InsertAccel( pAccel ); 1464cdf0e10cSrcweir } 1465cdf0e10cSrcweir 1466cdf0e10cSrcweir // ----------------------------------------------------------------------- 1467cdf0e10cSrcweir 1468cdf0e10cSrcweir void Application::RemoveAccel( Accelerator* pAccel ) 1469cdf0e10cSrcweir { 1470cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1471cdf0e10cSrcweir 1472cdf0e10cSrcweir if ( pSVData->maAppData.mpAccelMgr ) 1473cdf0e10cSrcweir pSVData->maAppData.mpAccelMgr->RemoveAccel( pAccel ); 1474cdf0e10cSrcweir } 1475cdf0e10cSrcweir 1476cdf0e10cSrcweir // ----------------------------------------------------------------------- 1477cdf0e10cSrcweir 1478cdf0e10cSrcweir void Application::FlushAccel() 1479cdf0e10cSrcweir { 1480cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1481cdf0e10cSrcweir 1482cdf0e10cSrcweir if ( pSVData->maAppData.mpAccelMgr ) 1483cdf0e10cSrcweir pSVData->maAppData.mpAccelMgr->FlushAccel(); 1484cdf0e10cSrcweir } 1485cdf0e10cSrcweir 1486cdf0e10cSrcweir // ----------------------------------------------------------------------- 1487cdf0e10cSrcweir 1488cdf0e10cSrcweir sal_Bool Application::CallAccel( const KeyCode& rKeyCode, sal_uInt16 nRepeat ) 1489cdf0e10cSrcweir { 1490cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1491cdf0e10cSrcweir 1492cdf0e10cSrcweir if ( pSVData->maAppData.mpAccelMgr ) 1493cdf0e10cSrcweir { 1494cdf0e10cSrcweir if ( pSVData->maAppData.mpAccelMgr->IsAccelKey( rKeyCode, nRepeat ) ) 1495cdf0e10cSrcweir return sal_True; 1496cdf0e10cSrcweir } 1497cdf0e10cSrcweir 1498cdf0e10cSrcweir return sal_False; 1499cdf0e10cSrcweir } 1500cdf0e10cSrcweir 1501cdf0e10cSrcweir // ----------------------------------------------------------------------- 1502cdf0e10cSrcweir 1503cdf0e10cSrcweir void Application::SetHelp( Help* pHelp ) 1504cdf0e10cSrcweir { 1505cdf0e10cSrcweir ImplGetSVData()->maAppData.mpHelp = pHelp; 1506cdf0e10cSrcweir } 1507cdf0e10cSrcweir 1508cdf0e10cSrcweir // ----------------------------------------------------------------------- 1509cdf0e10cSrcweir 1510cdf0e10cSrcweir Help* Application::GetHelp() 1511cdf0e10cSrcweir { 1512cdf0e10cSrcweir return ImplGetSVData()->maAppData.mpHelp; 1513cdf0e10cSrcweir } 1514cdf0e10cSrcweir 1515cdf0e10cSrcweir // ----------------------------------------------------------------------- 1516cdf0e10cSrcweir 1517cdf0e10cSrcweir void Application::EnableAutoHelpId( sal_Bool bEnabled ) 1518cdf0e10cSrcweir { 1519cdf0e10cSrcweir ImplGetSVData()->maHelpData.mbAutoHelpId = bEnabled; 1520cdf0e10cSrcweir } 1521cdf0e10cSrcweir 1522cdf0e10cSrcweir // ----------------------------------------------------------------------- 1523cdf0e10cSrcweir 1524cdf0e10cSrcweir sal_Bool Application::IsAutoHelpIdEnabled() 1525cdf0e10cSrcweir { 1526cdf0e10cSrcweir return ImplGetSVData()->maHelpData.mbAutoHelpId; 1527cdf0e10cSrcweir } 1528cdf0e10cSrcweir 1529cdf0e10cSrcweir // ----------------------------------------------------------------------- 1530cdf0e10cSrcweir 1531cdf0e10cSrcweir void Application::EnableAutoMnemonic( sal_Bool bEnabled ) 1532cdf0e10cSrcweir { 1533cdf0e10cSrcweir AllSettings aSettings = GetSettings(); 1534cdf0e10cSrcweir StyleSettings aStyle = aSettings.GetStyleSettings(); 1535cdf0e10cSrcweir aStyle.SetAutoMnemonic( bEnabled ); 1536cdf0e10cSrcweir aSettings.SetStyleSettings( aStyle ); 1537cdf0e10cSrcweir SetSettings( aSettings ); 1538cdf0e10cSrcweir } 1539cdf0e10cSrcweir 1540cdf0e10cSrcweir // ----------------------------------------------------------------------- 1541cdf0e10cSrcweir 1542cdf0e10cSrcweir sal_Bool Application::IsAutoMnemonicEnabled() 1543cdf0e10cSrcweir { 1544cdf0e10cSrcweir return GetSettings().GetStyleSettings().GetAutoMnemonic(); 1545cdf0e10cSrcweir } 1546cdf0e10cSrcweir 1547cdf0e10cSrcweir // ----------------------------------------------------------------------- 1548cdf0e10cSrcweir 1549cdf0e10cSrcweir void Application::SetDialogScaleX( short nScale ) 1550cdf0e10cSrcweir { 1551cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1552cdf0e10cSrcweir pSVData->maAppData.mnDialogScaleX = nScale; 1553cdf0e10cSrcweir pSVData->maGDIData.mnAppFontX = pSVData->maGDIData.mnRealAppFontX; 1554cdf0e10cSrcweir if ( nScale ) 1555cdf0e10cSrcweir pSVData->maGDIData.mnAppFontX += (pSVData->maGDIData.mnAppFontX*nScale)/100; 1556cdf0e10cSrcweir } 1557cdf0e10cSrcweir 1558cdf0e10cSrcweir // ----------------------------------------------------------------------- 1559cdf0e10cSrcweir 1560cdf0e10cSrcweir short Application::GetDialogScaleX() 1561cdf0e10cSrcweir { 1562cdf0e10cSrcweir return ImplGetSVData()->maAppData.mnDialogScaleX; 1563cdf0e10cSrcweir } 1564cdf0e10cSrcweir 1565cdf0e10cSrcweir // ----------------------------------------------------------------------- 1566cdf0e10cSrcweir 1567cdf0e10cSrcweir void Application::SetDefDialogParent( Window* pWindow ) 1568cdf0e10cSrcweir { 1569cdf0e10cSrcweir ImplGetSVData()->maWinData.mpDefDialogParent = pWindow; 1570cdf0e10cSrcweir } 1571cdf0e10cSrcweir 1572cdf0e10cSrcweir // ----------------------------------------------------------------------- 1573cdf0e10cSrcweir 1574cdf0e10cSrcweir Window* Application::GetDefDialogParent() 1575cdf0e10cSrcweir { 1576cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1577cdf0e10cSrcweir // #103442# find some useful dialog parent if there 1578cdf0e10cSrcweir // was no default set 1579cdf0e10cSrcweir // NOTE: currently even the default is not used 1580cdf0e10cSrcweir if( sal_False && pSVData->maWinData.mpDefDialogParent != NULL ) 1581cdf0e10cSrcweir return pSVData->maWinData.mpDefDialogParent; 1582cdf0e10cSrcweir else 1583cdf0e10cSrcweir { 1584cdf0e10cSrcweir // always use the topmost parent of the candidate 1585cdf0e10cSrcweir // window to avoid using dialogs or floaters 1586cdf0e10cSrcweir // as DefDialogParent 1587cdf0e10cSrcweir 1588cdf0e10cSrcweir // current focus frame 1589cdf0e10cSrcweir Window *pWin = NULL; 1590cdf0e10cSrcweir if( (pWin = pSVData->maWinData.mpFocusWin) != NULL ) 1591cdf0e10cSrcweir { 1592cdf0e10cSrcweir while( pWin->mpWindowImpl && pWin->mpWindowImpl->mpParent ) 1593cdf0e10cSrcweir pWin = pWin->mpWindowImpl->mpParent; 1594cdf0e10cSrcweir 1595cdf0e10cSrcweir if( (pWin->mpWindowImpl->mnStyle & WB_INTROWIN) == 0 ) 1596cdf0e10cSrcweir { 1597cdf0e10cSrcweir // check for corrupted window hierarchy, #122232#, may be we now crash somewhere else 1598cdf0e10cSrcweir if( !pWin->mpWindowImpl ) 1599cdf0e10cSrcweir { 1600cdf0e10cSrcweir DBG_ERROR( "Window hierarchy corrupted!" ); 1601cdf0e10cSrcweir pSVData->maWinData.mpFocusWin = NULL; // avoid further access 1602cdf0e10cSrcweir return NULL; 1603cdf0e10cSrcweir } 1604cdf0e10cSrcweir 1605cdf0e10cSrcweir // MAV: before the implementation has used only decorated windows, 1606cdf0e10cSrcweir // but it is not true in case of ActiveX or plugin scenario, 1607cdf0e10cSrcweir // so this check is commented out 1608cdf0e10cSrcweir // if( pWin->mpWindowImpl->mpFrameWindow->GetStyle() & (WB_MOVEABLE | WB_SIZEABLE) ) 1609cdf0e10cSrcweir return pWin->mpWindowImpl->mpFrameWindow->ImplGetWindow(); 1610cdf0e10cSrcweir // else 1611cdf0e10cSrcweir // return NULL; 1612cdf0e10cSrcweir } 1613cdf0e10cSrcweir } 1614cdf0e10cSrcweir // last active application frame 1615cdf0e10cSrcweir if( NULL != (pWin = pSVData->maWinData.mpActiveApplicationFrame) ) 1616cdf0e10cSrcweir { 1617cdf0e10cSrcweir return pWin->mpWindowImpl->mpFrameWindow->ImplGetWindow(); 1618cdf0e10cSrcweir } 1619cdf0e10cSrcweir else 1620cdf0e10cSrcweir { 1621cdf0e10cSrcweir // first visible top window (may be totally wrong....) 1622cdf0e10cSrcweir pWin = pSVData->maWinData.mpFirstFrame; 1623cdf0e10cSrcweir while( pWin ) 1624cdf0e10cSrcweir { 1625cdf0e10cSrcweir if( pWin->ImplGetWindow()->IsTopWindow() && 1626cdf0e10cSrcweir pWin->mpWindowImpl->mbReallyVisible && 1627cdf0e10cSrcweir (pWin->mpWindowImpl->mnStyle & WB_INTROWIN) == 0 1628cdf0e10cSrcweir ) 1629cdf0e10cSrcweir { 1630cdf0e10cSrcweir while( pWin->mpWindowImpl->mpParent ) 1631cdf0e10cSrcweir pWin = pWin->mpWindowImpl->mpParent; 1632cdf0e10cSrcweir return pWin->mpWindowImpl->mpFrameWindow->ImplGetWindow(); 1633cdf0e10cSrcweir } 1634cdf0e10cSrcweir pWin = pWin->mpWindowImpl->mpFrameData->mpNextFrame; 1635cdf0e10cSrcweir } 1636cdf0e10cSrcweir // use the desktop 1637cdf0e10cSrcweir return NULL; 1638cdf0e10cSrcweir } 1639cdf0e10cSrcweir } 1640cdf0e10cSrcweir } 1641cdf0e10cSrcweir 1642cdf0e10cSrcweir // ----------------------------------------------------------------------- 1643cdf0e10cSrcweir 1644cdf0e10cSrcweir void Application::EnableDialogCancel( sal_Bool bDialogCancel ) 1645cdf0e10cSrcweir { 1646cdf0e10cSrcweir ImplGetSVData()->maAppData.mbDialogCancel = bDialogCancel; 1647cdf0e10cSrcweir } 1648cdf0e10cSrcweir 1649cdf0e10cSrcweir // ----------------------------------------------------------------------- 1650cdf0e10cSrcweir 1651cdf0e10cSrcweir sal_Bool Application::IsDialogCancelEnabled() 1652cdf0e10cSrcweir { 1653cdf0e10cSrcweir return ImplGetSVData()->maAppData.mbDialogCancel; 1654cdf0e10cSrcweir } 1655cdf0e10cSrcweir 1656cdf0e10cSrcweir // ----------------------------------------------------------------------- 1657cdf0e10cSrcweir 1658cdf0e10cSrcweir void Application::SetSystemWindowMode( sal_uInt16 nMode ) 1659cdf0e10cSrcweir { 1660cdf0e10cSrcweir ImplGetSVData()->maAppData.mnSysWinMode = nMode; 1661cdf0e10cSrcweir } 1662cdf0e10cSrcweir 1663cdf0e10cSrcweir // ----------------------------------------------------------------------- 1664cdf0e10cSrcweir 1665cdf0e10cSrcweir sal_uInt16 Application::GetSystemWindowMode() 1666cdf0e10cSrcweir { 1667cdf0e10cSrcweir return ImplGetSVData()->maAppData.mnSysWinMode; 1668cdf0e10cSrcweir } 1669cdf0e10cSrcweir 1670cdf0e10cSrcweir // ----------------------------------------------------------------------- 1671cdf0e10cSrcweir 1672cdf0e10cSrcweir const String& Application::GetFontPath() 1673cdf0e10cSrcweir { 1674cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1675cdf0e10cSrcweir if( !pSVData->maAppData.mpFontPath ) 1676cdf0e10cSrcweir { 1677cdf0e10cSrcweir if( const char* pFontPath = ::getenv( "SAL_FONTPATH_PRIVATE" ) ) 1678cdf0e10cSrcweir pSVData->maAppData.mpFontPath = new String( String::CreateFromAscii( pFontPath ) ); 1679cdf0e10cSrcweir } 1680cdf0e10cSrcweir 1681cdf0e10cSrcweir if( pSVData->maAppData.mpFontPath ) 1682cdf0e10cSrcweir return *(pSVData->maAppData.mpFontPath); 1683cdf0e10cSrcweir return ImplGetSVEmptyStr(); 1684cdf0e10cSrcweir } 1685cdf0e10cSrcweir 1686cdf0e10cSrcweir // ----------------------------------------------------------------------- 1687cdf0e10cSrcweir 1688cdf0e10cSrcweir void Application::SetFontPath( const String& rPath ) 1689cdf0e10cSrcweir { 1690cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1691cdf0e10cSrcweir 1692cdf0e10cSrcweir // if it doesn't exist create a new one 1693cdf0e10cSrcweir if( !pSVData->maAppData.mpFontPath ) 1694cdf0e10cSrcweir pSVData->maAppData.mpFontPath = new String( rPath ); 1695cdf0e10cSrcweir else 1696cdf0e10cSrcweir *(pSVData->maAppData.mpFontPath) = rPath; 1697cdf0e10cSrcweir } 1698cdf0e10cSrcweir 1699cdf0e10cSrcweir // ----------------------------------------------------------------------- 1700cdf0e10cSrcweir 1701cdf0e10cSrcweir UniqueItemId Application::CreateUniqueId() 1702cdf0e10cSrcweir { 1703cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1704cdf0e10cSrcweir 1705cdf0e10cSrcweir if ( !pSVData->maAppData.mpUniqueIdCont ) 1706cdf0e10cSrcweir pSVData->maAppData.mpUniqueIdCont = new UniqueIdContainer( UNIQUEID_SV_BEGIN ); 1707cdf0e10cSrcweir return pSVData->maAppData.mpUniqueIdCont->CreateId(); 1708cdf0e10cSrcweir } 1709cdf0e10cSrcweir 1710cdf0e10cSrcweir // ----------------------------------------------------------------------- 1711cdf0e10cSrcweir 1712cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > Application::GetVCLToolkit() 1713cdf0e10cSrcweir { 1714cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > xT; 1715cdf0e10cSrcweir UnoWrapperBase* pWrapper = Application::GetUnoWrapper( sal_True ); 1716cdf0e10cSrcweir if ( pWrapper ) 1717cdf0e10cSrcweir xT = pWrapper->GetVCLToolkit(); 1718cdf0e10cSrcweir return xT; 1719cdf0e10cSrcweir } 1720cdf0e10cSrcweir 1721cdf0e10cSrcweir // ----------------------------------------------------------------------- 1722cdf0e10cSrcweir 1723cdf0e10cSrcweir extern "C" { static void SAL_CALL thisModule() {} } 1724cdf0e10cSrcweir 1725cdf0e10cSrcweir UnoWrapperBase* Application::GetUnoWrapper( sal_Bool bCreateIfNotExist ) 1726cdf0e10cSrcweir { 1727cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1728cdf0e10cSrcweir static sal_Bool bAlreadyTriedToCreate = sal_False; 1729cdf0e10cSrcweir if ( !pSVData->mpUnoWrapper && bCreateIfNotExist && !bAlreadyTriedToCreate ) 1730cdf0e10cSrcweir { 1731cdf0e10cSrcweir ::rtl::OUString aLibName = ::vcl::unohelper::CreateLibraryName( "tk", sal_True ); 1732cdf0e10cSrcweir oslModule hTkLib = osl_loadModuleRelative( 1733cdf0e10cSrcweir &thisModule, aLibName.pData, SAL_LOADMODULE_DEFAULT ); 1734cdf0e10cSrcweir if ( hTkLib ) 1735cdf0e10cSrcweir { 1736cdf0e10cSrcweir ::rtl::OUString aFunctionName( RTL_CONSTASCII_USTRINGPARAM( "CreateUnoWrapper" ) ); 1737cdf0e10cSrcweir FN_TkCreateUnoWrapper fnCreateWrapper = (FN_TkCreateUnoWrapper)osl_getFunctionSymbol( hTkLib, aFunctionName.pData ); 1738cdf0e10cSrcweir if ( fnCreateWrapper ) 1739cdf0e10cSrcweir { 1740cdf0e10cSrcweir pSVData->mpUnoWrapper = fnCreateWrapper(); 1741cdf0e10cSrcweir } 1742cdf0e10cSrcweir } 1743cdf0e10cSrcweir DBG_ASSERT( pSVData->mpUnoWrapper, "UnoWrapper could not be created!" ); 1744cdf0e10cSrcweir bAlreadyTriedToCreate = sal_True; 1745cdf0e10cSrcweir } 1746cdf0e10cSrcweir return pSVData->mpUnoWrapper; 1747cdf0e10cSrcweir } 1748cdf0e10cSrcweir 1749cdf0e10cSrcweir // ----------------------------------------------------------------------- 1750cdf0e10cSrcweir 1751cdf0e10cSrcweir void Application::SetUnoWrapper( UnoWrapperBase* pWrapper ) 1752cdf0e10cSrcweir { 1753cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1754cdf0e10cSrcweir DBG_ASSERT( !pSVData->mpUnoWrapper, "SetUnoWrapper: Wrapper allready exists" ); 1755cdf0e10cSrcweir pSVData->mpUnoWrapper = pWrapper; 1756cdf0e10cSrcweir } 1757cdf0e10cSrcweir 1758cdf0e10cSrcweir // ----------------------------------------------------------------------- 1759cdf0e10cSrcweir 1760cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDisplayConnection > Application::GetDisplayConnection() 1761cdf0e10cSrcweir { 1762cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1763cdf0e10cSrcweir 1764cdf0e10cSrcweir if( !pSVData->mxDisplayConnection.is() ) 1765cdf0e10cSrcweir { 1766cdf0e10cSrcweir pSVData->mxDisplayConnection.set( new ::vcl::DisplayConnection ); 1767cdf0e10cSrcweir pSVData->mxDisplayConnection->start(); 1768cdf0e10cSrcweir } 1769cdf0e10cSrcweir 1770cdf0e10cSrcweir return pSVData->mxDisplayConnection.get(); 1771cdf0e10cSrcweir } 1772cdf0e10cSrcweir 1773cdf0e10cSrcweir // ----------------------------------------------------------------------- 1774cdf0e10cSrcweir 1775cdf0e10cSrcweir void Application::SetFilterHdl( const Link& rLink ) 1776cdf0e10cSrcweir { 1777cdf0e10cSrcweir ImplGetSVData()->maGDIData.mpGrfConverter->SetFilterHdl( rLink ); 1778cdf0e10cSrcweir } 1779cdf0e10cSrcweir 1780cdf0e10cSrcweir // ----------------------------------------------------------------------- 1781cdf0e10cSrcweir 1782cdf0e10cSrcweir const Link& Application::GetFilterHdl() 1783cdf0e10cSrcweir { 1784cdf0e10cSrcweir return ImplGetSVData()->maGDIData.mpGrfConverter->GetFilterHdl(); 1785cdf0e10cSrcweir } 1786cdf0e10cSrcweir 1787cdf0e10cSrcweir // ----------------------------------------------------------------------- 1788cdf0e10cSrcweir 1789cdf0e10cSrcweir sal_Bool ImplCallHotKey( const KeyCode& rKeyCode ) 1790cdf0e10cSrcweir { 1791cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1792cdf0e10cSrcweir ImplHotKey* pHotKeyData = pSVData->maAppData.mpFirstHotKey; 1793cdf0e10cSrcweir while ( pHotKeyData ) 1794cdf0e10cSrcweir { 1795cdf0e10cSrcweir if ( pHotKeyData->maKeyCode.IsDefinedKeyCodeEqual( rKeyCode ) ) 1796cdf0e10cSrcweir { 1797cdf0e10cSrcweir pHotKeyData->maLink.Call( pHotKeyData->mpUserData ); 1798cdf0e10cSrcweir return sal_True; 1799cdf0e10cSrcweir } 1800cdf0e10cSrcweir 1801cdf0e10cSrcweir pHotKeyData = pHotKeyData->mpNext; 1802cdf0e10cSrcweir } 1803cdf0e10cSrcweir 1804cdf0e10cSrcweir return sal_False; 1805cdf0e10cSrcweir } 1806cdf0e10cSrcweir 1807cdf0e10cSrcweir // ----------------------------------------------------------------------- 1808cdf0e10cSrcweir 1809cdf0e10cSrcweir void ImplFreeHotKeyData() 1810cdf0e10cSrcweir { 1811cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1812cdf0e10cSrcweir ImplHotKey* pTempHotKeyData; 1813cdf0e10cSrcweir ImplHotKey* pHotKeyData = pSVData->maAppData.mpFirstHotKey; 1814cdf0e10cSrcweir while ( pHotKeyData ) 1815cdf0e10cSrcweir { 1816cdf0e10cSrcweir pTempHotKeyData = pHotKeyData->mpNext; 1817cdf0e10cSrcweir delete pHotKeyData; 1818cdf0e10cSrcweir pHotKeyData = pTempHotKeyData; 1819cdf0e10cSrcweir } 1820cdf0e10cSrcweir 1821cdf0e10cSrcweir pSVData->maAppData.mpFirstHotKey = NULL; 1822cdf0e10cSrcweir } 1823cdf0e10cSrcweir 1824cdf0e10cSrcweir // ----------------------------------------------------------------------- 1825cdf0e10cSrcweir 1826cdf0e10cSrcweir sal_uIntPtr Application::AddHotKey( const KeyCode& rKeyCode, const Link& rLink, void* pData ) 1827cdf0e10cSrcweir { 1828cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1829cdf0e10cSrcweir ImplHotKey* pHotKeyData = new ImplHotKey; 1830cdf0e10cSrcweir pHotKeyData->mpUserData = pData; 1831cdf0e10cSrcweir pHotKeyData->maKeyCode = rKeyCode; 1832cdf0e10cSrcweir pHotKeyData->maLink = rLink; 1833cdf0e10cSrcweir pHotKeyData->mpNext = pSVData->maAppData.mpFirstHotKey; 1834cdf0e10cSrcweir pSVData->maAppData.mpFirstHotKey = pHotKeyData; 1835cdf0e10cSrcweir return (sal_uIntPtr)pHotKeyData; 1836cdf0e10cSrcweir } 1837cdf0e10cSrcweir 1838cdf0e10cSrcweir // ----------------------------------------------------------------------- 1839cdf0e10cSrcweir 1840cdf0e10cSrcweir void Application::RemoveHotKey( sal_uIntPtr nId ) 1841cdf0e10cSrcweir { 1842cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1843cdf0e10cSrcweir ImplHotKey* pFindHotKeyData = (ImplHotKey*)nId; 1844cdf0e10cSrcweir ImplHotKey* pPrevHotKeyData = NULL; 1845cdf0e10cSrcweir ImplHotKey* pHotKeyData = pSVData->maAppData.mpFirstHotKey; 1846cdf0e10cSrcweir while ( pHotKeyData ) 1847cdf0e10cSrcweir { 1848cdf0e10cSrcweir if ( pHotKeyData == pFindHotKeyData ) 1849cdf0e10cSrcweir { 1850cdf0e10cSrcweir if ( pPrevHotKeyData ) 1851cdf0e10cSrcweir pPrevHotKeyData->mpNext = pFindHotKeyData->mpNext; 1852cdf0e10cSrcweir else 1853cdf0e10cSrcweir pSVData->maAppData.mpFirstHotKey = pFindHotKeyData->mpNext; 1854cdf0e10cSrcweir delete pFindHotKeyData; 1855cdf0e10cSrcweir break; 1856cdf0e10cSrcweir } 1857cdf0e10cSrcweir 1858cdf0e10cSrcweir pPrevHotKeyData = pHotKeyData; 1859cdf0e10cSrcweir pHotKeyData = pHotKeyData->mpNext; 1860cdf0e10cSrcweir } 1861cdf0e10cSrcweir 1862cdf0e10cSrcweir DBG_ASSERT( pHotKeyData, "Application::RemoveHotKey() - HotKey is not added" ); 1863cdf0e10cSrcweir } 1864cdf0e10cSrcweir 1865cdf0e10cSrcweir // ----------------------------------------------------------------------- 1866cdf0e10cSrcweir 1867cdf0e10cSrcweir void ImplFreeEventHookData() 1868cdf0e10cSrcweir { 1869cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1870cdf0e10cSrcweir ImplEventHook* pTempEventHookData; 1871cdf0e10cSrcweir ImplEventHook* pEventHookData = pSVData->maAppData.mpFirstEventHook; 1872cdf0e10cSrcweir while ( pEventHookData ) 1873cdf0e10cSrcweir { 1874cdf0e10cSrcweir pTempEventHookData = pEventHookData->mpNext; 1875cdf0e10cSrcweir delete pEventHookData; 1876cdf0e10cSrcweir pEventHookData = pTempEventHookData; 1877cdf0e10cSrcweir } 1878cdf0e10cSrcweir 1879cdf0e10cSrcweir pSVData->maAppData.mpFirstEventHook = NULL; 1880cdf0e10cSrcweir } 1881cdf0e10cSrcweir 1882cdf0e10cSrcweir // ----------------------------------------------------------------------- 1883cdf0e10cSrcweir 1884cdf0e10cSrcweir sal_uIntPtr Application::AddEventHook( VCLEventHookProc pProc, void* pData ) 1885cdf0e10cSrcweir { 1886cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1887cdf0e10cSrcweir ImplEventHook* pEventHookData = new ImplEventHook; 1888cdf0e10cSrcweir pEventHookData->mpUserData = pData; 1889cdf0e10cSrcweir pEventHookData->mpProc = pProc; 1890cdf0e10cSrcweir pEventHookData->mpNext = pSVData->maAppData.mpFirstEventHook; 1891cdf0e10cSrcweir pSVData->maAppData.mpFirstEventHook = pEventHookData; 1892cdf0e10cSrcweir return (sal_uIntPtr)pEventHookData; 1893cdf0e10cSrcweir } 1894cdf0e10cSrcweir 1895cdf0e10cSrcweir // ----------------------------------------------------------------------- 1896cdf0e10cSrcweir 1897cdf0e10cSrcweir void Application::RemoveEventHook( sal_uIntPtr nId ) 1898cdf0e10cSrcweir { 1899cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1900cdf0e10cSrcweir ImplEventHook* pFindEventHookData = (ImplEventHook*)nId; 1901cdf0e10cSrcweir ImplEventHook* pPrevEventHookData = NULL; 1902cdf0e10cSrcweir ImplEventHook* pEventHookData = pSVData->maAppData.mpFirstEventHook; 1903cdf0e10cSrcweir while ( pEventHookData ) 1904cdf0e10cSrcweir { 1905cdf0e10cSrcweir if ( pEventHookData == pFindEventHookData ) 1906cdf0e10cSrcweir { 1907cdf0e10cSrcweir if ( pPrevEventHookData ) 1908cdf0e10cSrcweir pPrevEventHookData->mpNext = pFindEventHookData->mpNext; 1909cdf0e10cSrcweir else 1910cdf0e10cSrcweir pSVData->maAppData.mpFirstEventHook = pFindEventHookData->mpNext; 1911cdf0e10cSrcweir delete pFindEventHookData; 1912cdf0e10cSrcweir break; 1913cdf0e10cSrcweir } 1914cdf0e10cSrcweir 1915cdf0e10cSrcweir pPrevEventHookData = pEventHookData; 1916cdf0e10cSrcweir pEventHookData = pEventHookData->mpNext; 1917cdf0e10cSrcweir } 1918cdf0e10cSrcweir 1919cdf0e10cSrcweir DBG_ASSERT( pEventHookData, "Application::RemoveEventHook() - EventHook is not added" ); 1920cdf0e10cSrcweir } 1921cdf0e10cSrcweir 1922cdf0e10cSrcweir // ----------------------------------------------------------------------- 1923cdf0e10cSrcweir 1924cdf0e10cSrcweir long Application::CallEventHooks( NotifyEvent& rEvt ) 1925cdf0e10cSrcweir { 1926cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1927cdf0e10cSrcweir long nRet = 0; 1928cdf0e10cSrcweir ImplEventHook* pTempEventHookData; 1929cdf0e10cSrcweir ImplEventHook* pEventHookData = pSVData->maAppData.mpFirstEventHook; 1930cdf0e10cSrcweir while ( pEventHookData ) 1931cdf0e10cSrcweir { 1932cdf0e10cSrcweir pTempEventHookData = pEventHookData->mpNext; 1933cdf0e10cSrcweir nRet = pEventHookData->mpProc( rEvt, pEventHookData->mpUserData ); 1934cdf0e10cSrcweir if ( nRet ) 1935cdf0e10cSrcweir break; 1936cdf0e10cSrcweir pEventHookData = pTempEventHookData; 1937cdf0e10cSrcweir } 1938cdf0e10cSrcweir 1939cdf0e10cSrcweir return nRet; 1940cdf0e10cSrcweir } 1941cdf0e10cSrcweir 1942cdf0e10cSrcweir // ----------------------------------------------------------------------- 1943cdf0e10cSrcweir 1944cdf0e10cSrcweir long Application::CallPreNotify( NotifyEvent& rEvt ) 1945cdf0e10cSrcweir { 1946cdf0e10cSrcweir return ImplCallPreNotify( rEvt ); 1947cdf0e10cSrcweir } 1948cdf0e10cSrcweir 1949cdf0e10cSrcweir // ----------------------------------------------------------------------- 1950cdf0e10cSrcweir 1951cdf0e10cSrcweir long Application::CallEvent( NotifyEvent& rEvt ) 1952cdf0e10cSrcweir { 1953cdf0e10cSrcweir return ImplCallEvent( rEvt ); 1954cdf0e10cSrcweir } 1955cdf0e10cSrcweir 1956cdf0e10cSrcweir // ----------------------------------------------------------------------- 1957cdf0e10cSrcweir 1958cdf0e10cSrcweir const LocaleDataWrapper& Application::GetAppLocaleDataWrapper() 1959cdf0e10cSrcweir { 1960cdf0e10cSrcweir return GetSettings().GetLocaleDataWrapper(); 1961cdf0e10cSrcweir } 1962cdf0e10cSrcweir 1963cdf0e10cSrcweir // ----------------------------------------------------------------------- 1964cdf0e10cSrcweir 1965cdf0e10cSrcweir void Application::EnableHeadlessMode( sal_Bool bEnable ) 1966cdf0e10cSrcweir { 1967cdf0e10cSrcweir EnableDialogCancel( bEnable ); 1968cdf0e10cSrcweir } 1969cdf0e10cSrcweir 1970cdf0e10cSrcweir // ----------------------------------------------------------------------- 1971cdf0e10cSrcweir 1972cdf0e10cSrcweir sal_Bool Application::IsHeadlessModeEnabled() 1973cdf0e10cSrcweir { 1974cdf0e10cSrcweir return IsDialogCancelEnabled(); 1975cdf0e10cSrcweir } 1976cdf0e10cSrcweir 1977cdf0e10cSrcweir // ----------------------------------------------------------------------- 1978cdf0e10cSrcweir 1979cdf0e10cSrcweir void Application::ShowNativeErrorBox(const String& sTitle , 1980cdf0e10cSrcweir const String& sMessage) 1981cdf0e10cSrcweir { 1982cdf0e10cSrcweir int btn = ImplGetSalSystem()->ShowNativeMessageBox ( 1983cdf0e10cSrcweir sTitle, 1984cdf0e10cSrcweir sMessage, 1985cdf0e10cSrcweir SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK, 1986cdf0e10cSrcweir SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK); 1987cdf0e10cSrcweir if (btn != SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK) { 1988cdf0e10cSrcweir OSL_TRACE("ShowNativeMessageBox returned %d\n", btn); 1989cdf0e10cSrcweir } 1990cdf0e10cSrcweir } 1991cdf0e10cSrcweir 1992cdf0e10cSrcweir // ----------------------------------------------------------------------- 1993cdf0e10cSrcweir 1994cdf0e10cSrcweir bool Application::CanToggleImeStatusWindow() 1995cdf0e10cSrcweir { 1996cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 1997cdf0e10cSrcweir if( ! pSVData->mpImeStatus ) 1998cdf0e10cSrcweir pSVData->mpImeStatus = pSVData->mpDefInst->CreateI18NImeStatus(); 1999cdf0e10cSrcweir return pSVData->mpImeStatus->canToggle(); 2000cdf0e10cSrcweir } 2001cdf0e10cSrcweir 2002cdf0e10cSrcweir void Application::ShowImeStatusWindow(bool bShow) 2003cdf0e10cSrcweir { 2004cdf0e10cSrcweir ImplGetSVData()->maAppData.meShowImeStatusWindow = bShow 2005cdf0e10cSrcweir ? ImplSVAppData::ImeStatusWindowMode_SHOW 2006cdf0e10cSrcweir : ImplSVAppData::ImeStatusWindowMode_HIDE; 2007cdf0e10cSrcweir 2008cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 2009cdf0e10cSrcweir if( ! pSVData->mpImeStatus ) 2010cdf0e10cSrcweir pSVData->mpImeStatus = pSVData->mpDefInst->CreateI18NImeStatus(); 2011cdf0e10cSrcweir pSVData->mpImeStatus->toggle(); 2012cdf0e10cSrcweir } 2013cdf0e10cSrcweir 2014cdf0e10cSrcweir bool Application::GetShowImeStatusWindowDefault() 2015cdf0e10cSrcweir { 2016cdf0e10cSrcweir rtl_TextEncodingInfo aInfo; 2017cdf0e10cSrcweir aInfo.StructSize = sizeof aInfo; 2018cdf0e10cSrcweir return rtl_getTextEncodingInfo(osl_getThreadTextEncoding(), &aInfo) 2019cdf0e10cSrcweir && aInfo.MaximumCharSize > 1; 2020cdf0e10cSrcweir } 2021cdf0e10cSrcweir 2022cdf0e10cSrcweir const ::rtl::OUString& Application::GetDesktopEnvironment() 2023cdf0e10cSrcweir { 2024cdf0e10cSrcweir return SalGetDesktopEnvironment(); 2025cdf0e10cSrcweir } 2026cdf0e10cSrcweir 2027cdf0e10cSrcweir void Application::AddToRecentDocumentList(const rtl::OUString& rFileUrl, const rtl::OUString& rMimeType) 2028cdf0e10cSrcweir { 2029cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 2030cdf0e10cSrcweir pSVData->mpDefInst->AddToRecentDocumentList(rFileUrl, rMimeType); 2031cdf0e10cSrcweir } 2032cdf0e10cSrcweir 2033cdf0e10cSrcweir sal_Bool Application::IsAccessibilityEnabled() 2034cdf0e10cSrcweir { 2035cdf0e10cSrcweir return sal_False; 2036cdf0e10cSrcweir } 2037cdf0e10cSrcweir 2038cdf0e10cSrcweir sal_Bool InitAccessBridge( sal_Bool bShowCancel, sal_Bool &rCancelled ) 2039cdf0e10cSrcweir { 2040cdf0e10cSrcweir sal_Bool bRet = true; 2041cdf0e10cSrcweir 2042cdf0e10cSrcweir // Disable Java bridge on UNIX 2043cdf0e10cSrcweir #if defined UNX 2044cdf0e10cSrcweir (void) bShowCancel; // unsued 2045cdf0e10cSrcweir (void) rCancelled; // unused 2046cdf0e10cSrcweir #else 2047cdf0e10cSrcweir bRet = ImplInitAccessBridge( bShowCancel, rCancelled ); 2048cdf0e10cSrcweir 2049cdf0e10cSrcweir if( !bRet && bShowCancel && !rCancelled ) 2050cdf0e10cSrcweir { 2051cdf0e10cSrcweir // disable accessibility if the user chooses to continue 2052cdf0e10cSrcweir AllSettings aSettings = Application::GetSettings(); 2053cdf0e10cSrcweir MiscSettings aMisc = aSettings.GetMiscSettings(); 2054cdf0e10cSrcweir aMisc.SetEnableATToolSupport( sal_False ); 2055cdf0e10cSrcweir aSettings.SetMiscSettings( aMisc ); 2056cdf0e10cSrcweir Application::SetSettings( aSettings ); 2057cdf0e10cSrcweir } 2058cdf0e10cSrcweir #endif // !UNX 2059cdf0e10cSrcweir 2060cdf0e10cSrcweir return bRet; 2061cdf0e10cSrcweir } 2062cdf0e10cSrcweir 2063cdf0e10cSrcweir // MT: AppProperty, AppEvent was in oldsv.cxx, but is still needed... 2064cdf0e10cSrcweir // ------------------------------------------------------------------------ 2065cdf0e10cSrcweir 2066cdf0e10cSrcweir TYPEINIT0(ApplicationProperty) 2067cdf0e10cSrcweir 2068cdf0e10cSrcweir // ------------------------------------------------------------------------ 2069cdf0e10cSrcweir 2070cdf0e10cSrcweir static PropertyHandler* pHandler=NULL; 2071cdf0e10cSrcweir 2072cdf0e10cSrcweir void Application::Property( ApplicationProperty& rProp ) 2073cdf0e10cSrcweir { 2074cdf0e10cSrcweir if ( pHandler ) 2075cdf0e10cSrcweir pHandler->Property( rProp ); 2076cdf0e10cSrcweir } 2077cdf0e10cSrcweir 2078cdf0e10cSrcweir void Application::SetPropertyHandler( PropertyHandler* p ) 2079cdf0e10cSrcweir { 2080cdf0e10cSrcweir if ( pHandler ) 2081cdf0e10cSrcweir delete pHandler; 2082cdf0e10cSrcweir pHandler = p; 2083cdf0e10cSrcweir } 2084cdf0e10cSrcweir 2085cdf0e10cSrcweir 2086cdf0e10cSrcweir 2087cdf0e10cSrcweir void Application::AppEvent( const ApplicationEvent& /*rAppEvent*/ ) 2088cdf0e10cSrcweir { 2089cdf0e10cSrcweir } 2090