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