1cdf0e10cSrcweir /************************************************************************* 2cdf0e10cSrcweir * 3cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4cdf0e10cSrcweir * 5cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6cdf0e10cSrcweir * 7cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8cdf0e10cSrcweir * 9cdf0e10cSrcweir * This file is part of OpenOffice.org. 10cdf0e10cSrcweir * 11cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14cdf0e10cSrcweir * 15cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20cdf0e10cSrcweir * 21cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25cdf0e10cSrcweir * 26cdf0e10cSrcweir ************************************************************************/ 27cdf0e10cSrcweir 28cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29cdf0e10cSrcweir #include "precompiled_vcl.hxx" 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <string.h> 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include "rtl/instance.hxx" 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include "osl/process.h" 36cdf0e10cSrcweir #include "osl/file.hxx" 37cdf0e10cSrcweir 38cdf0e10cSrcweir #include "tools/debug.hxx" 39cdf0e10cSrcweir #include "tools/resary.hxx" 40cdf0e10cSrcweir 41cdf0e10cSrcweir #include "unotools/fontcfg.hxx" 42cdf0e10cSrcweir 43cdf0e10cSrcweir #include "vos/mutex.hxx" 44cdf0e10cSrcweir 45cdf0e10cSrcweir #include "cppuhelper/implbase1.hxx" 46cdf0e10cSrcweir 47cdf0e10cSrcweir #include "uno/current_context.hxx" 48cdf0e10cSrcweir 49cdf0e10cSrcweir #include "vcl/configsettings.hxx" 50cdf0e10cSrcweir #include "vcl/svapp.hxx" 51cdf0e10cSrcweir #include "vcl/wrkwin.hxx" 52cdf0e10cSrcweir #include "vcl/msgbox.hxx" 53cdf0e10cSrcweir #include "vcl/unohelp.hxx" 54cdf0e10cSrcweir #include "vcl/button.hxx" // for Button::GetStandardText 55cdf0e10cSrcweir #include "vcl/dockwin.hxx" // for DockingManager 56cdf0e10cSrcweir 57cdf0e10cSrcweir #include "salinst.hxx" 58cdf0e10cSrcweir #include "salframe.hxx" 59cdf0e10cSrcweir #include "svdata.hxx" 60cdf0e10cSrcweir #include "window.h" 61cdf0e10cSrcweir #include "salimestatus.hxx" 62cdf0e10cSrcweir #include "salsys.hxx" 63cdf0e10cSrcweir #include "svids.hrc" 64cdf0e10cSrcweir 65cdf0e10cSrcweir #include "com/sun/star/lang/XMultiServiceFactory.hpp" 66cdf0e10cSrcweir #include "com/sun/star/lang/XComponent.hpp" 67cdf0e10cSrcweir #include "com/sun/star/awt/XExtendedToolkit.hpp" 68cdf0e10cSrcweir #include "com/sun/star/java/JavaNotConfiguredException.hpp" 69cdf0e10cSrcweir #include "com/sun/star/java/JavaVMCreationFailureException.hpp" 70cdf0e10cSrcweir #include "com/sun/star/java/MissingJavaRuntimeException.hpp" 71cdf0e10cSrcweir #include "com/sun/star/java/JavaDisabledException.hpp" 72cdf0e10cSrcweir 73cdf0e10cSrcweir #include <stdio.h> 74cdf0e10cSrcweir 75cdf0e10cSrcweir namespace { 76cdf0e10cSrcweir 77cdf0e10cSrcweir namespace css = com::sun::star; 78cdf0e10cSrcweir 79cdf0e10cSrcweir } 80cdf0e10cSrcweir 81cdf0e10cSrcweir using namespace com::sun::star::uno; 82cdf0e10cSrcweir using namespace com::sun::star::lang; 83cdf0e10cSrcweir using namespace com::sun::star::awt; 84cdf0e10cSrcweir using namespace rtl; 85cdf0e10cSrcweir 86cdf0e10cSrcweir // ======================================================================= 87cdf0e10cSrcweir 88cdf0e10cSrcweir namespace 89cdf0e10cSrcweir { 90cdf0e10cSrcweir struct private_aImplSVData : 91cdf0e10cSrcweir public rtl::Static<ImplSVData, private_aImplSVData> {}; 92cdf0e10cSrcweir } 93cdf0e10cSrcweir 94cdf0e10cSrcweir // static SV-Data 95cdf0e10cSrcweir ImplSVData* pImplSVData = NULL; 96cdf0e10cSrcweir 97cdf0e10cSrcweir SalSystem* ImplGetSalSystem() 98cdf0e10cSrcweir { 99cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 100cdf0e10cSrcweir if( ! pSVData->mpSalSystem ) 101cdf0e10cSrcweir pSVData->mpSalSystem = pSVData->mpDefInst->CreateSalSystem(); 102cdf0e10cSrcweir return pSVData->mpSalSystem; 103cdf0e10cSrcweir } 104cdf0e10cSrcweir 105cdf0e10cSrcweir 106cdf0e10cSrcweir static String& ReplaceJavaErrorMessages( String& rString ) 107cdf0e10cSrcweir { 108cdf0e10cSrcweir rString.SearchAndReplaceAllAscii( "%OK", Button::GetStandardText( BUTTON_OK ) ); 109cdf0e10cSrcweir rString.SearchAndReplaceAllAscii( "%IGNORE", Button::GetStandardText( BUTTON_IGNORE ) ); 110cdf0e10cSrcweir rString.SearchAndReplaceAllAscii( "%CANCEL", Button::GetStandardText( BUTTON_CANCEL ) ); 111cdf0e10cSrcweir 112cdf0e10cSrcweir return rString; 113cdf0e10cSrcweir } 114cdf0e10cSrcweir 115cdf0e10cSrcweir // ======================================================================= 116cdf0e10cSrcweir 117cdf0e10cSrcweir void ImplInitSVData() 118cdf0e10cSrcweir { 119cdf0e10cSrcweir pImplSVData = &private_aImplSVData::get(); 120cdf0e10cSrcweir 121cdf0e10cSrcweir // init global instance data 122cdf0e10cSrcweir memset( pImplSVData, 0, sizeof( ImplSVData ) ); 123cdf0e10cSrcweir pImplSVData->maHelpData.mbAutoHelpId = sal_True; 124cdf0e10cSrcweir pImplSVData->maNWFData.maMenuBarHighlightTextColor = Color( COL_TRANSPARENT ); 125cdf0e10cSrcweir 126cdf0e10cSrcweir // find out whether we are running in the testtool 127cdf0e10cSrcweir // in this case we need some special workarounds 128cdf0e10cSrcweir sal_uInt32 nArgs = osl_getCommandArgCount(); 129cdf0e10cSrcweir for( sal_uInt32 i = 0; i < nArgs; i++ ) 130cdf0e10cSrcweir { 131cdf0e10cSrcweir rtl::OUString aArg; 132cdf0e10cSrcweir osl_getCommandArg( i, &aArg.pData ); 133cdf0e10cSrcweir if( aArg.equalsAscii( "-enableautomation" ) ) 134cdf0e10cSrcweir { 135cdf0e10cSrcweir pImplSVData->mbIsTestTool = true; 136cdf0e10cSrcweir break; 137cdf0e10cSrcweir } 138cdf0e10cSrcweir } 139cdf0e10cSrcweir 140cdf0e10cSrcweir // mark default layout border as unitialized 141cdf0e10cSrcweir pImplSVData->maAppData.mnDefaultLayoutBorder = -1; 142cdf0e10cSrcweir } 143cdf0e10cSrcweir 144cdf0e10cSrcweir // ----------------------------------------------------------------------- 145cdf0e10cSrcweir 146cdf0e10cSrcweir void ImplDeInitSVData() 147cdf0e10cSrcweir { 148cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 149cdf0e10cSrcweir 150cdf0e10cSrcweir // delete global instance data 151cdf0e10cSrcweir if( pSVData->mpSettingsConfigItem ) 152cdf0e10cSrcweir delete pSVData->mpSettingsConfigItem; 153cdf0e10cSrcweir 154cdf0e10cSrcweir if( pSVData->mpDockingManager ) 155cdf0e10cSrcweir delete pSVData->mpDockingManager; 156cdf0e10cSrcweir 157cdf0e10cSrcweir if( pSVData->maGDIData.mpDefaultFontConfiguration ) 158cdf0e10cSrcweir delete pSVData->maGDIData.mpDefaultFontConfiguration; 159cdf0e10cSrcweir if( pSVData->maGDIData.mpFontSubstConfiguration ) 160cdf0e10cSrcweir delete pSVData->maGDIData.mpFontSubstConfiguration; 161cdf0e10cSrcweir 162cdf0e10cSrcweir if ( pSVData->maAppData.mpMSFTempFileName ) 163cdf0e10cSrcweir { 164cdf0e10cSrcweir if ( pSVData->maAppData.mxMSF.is() ) 165cdf0e10cSrcweir { 166cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComp( pSVData->maAppData.mxMSF, ::com::sun::star::uno::UNO_QUERY ); 167cdf0e10cSrcweir xComp->dispose(); 168cdf0e10cSrcweir pSVData->maAppData.mxMSF = NULL; 169cdf0e10cSrcweir } 170cdf0e10cSrcweir 171cdf0e10cSrcweir ::rtl::OUString aFileUrl; 172cdf0e10cSrcweir ::osl::File::getFileURLFromSystemPath( *pSVData->maAppData.mpMSFTempFileName, aFileUrl ); 173cdf0e10cSrcweir osl::File::remove( aFileUrl ); 174cdf0e10cSrcweir delete pSVData->maAppData.mpMSFTempFileName; 175cdf0e10cSrcweir pSVData->maAppData.mpMSFTempFileName = NULL; 176cdf0e10cSrcweir } 177cdf0e10cSrcweir 178cdf0e10cSrcweir if( pSVData->maCtrlData.mpFieldUnitStrings ) 179cdf0e10cSrcweir delete pSVData->maCtrlData.mpFieldUnitStrings, pSVData->maCtrlData.mpFieldUnitStrings = NULL; 180cdf0e10cSrcweir if( pSVData->maCtrlData.mpCleanUnitStrings ) 181cdf0e10cSrcweir delete pSVData->maCtrlData.mpCleanUnitStrings, pSVData->maCtrlData.mpCleanUnitStrings = NULL; 182cdf0e10cSrcweir if( pSVData->mpPaperNames ) 183cdf0e10cSrcweir delete pSVData->mpPaperNames, pSVData->mpPaperNames = NULL; 184cdf0e10cSrcweir } 185cdf0e10cSrcweir 186cdf0e10cSrcweir // ----------------------------------------------------------------------- 187cdf0e10cSrcweir 188cdf0e10cSrcweir void ImplDestroySVData() 189cdf0e10cSrcweir { 190cdf0e10cSrcweir pImplSVData = NULL; 191cdf0e10cSrcweir } 192cdf0e10cSrcweir 193cdf0e10cSrcweir // ----------------------------------------------------------------------- 194cdf0e10cSrcweir 195cdf0e10cSrcweir Window* ImplGetDefaultWindow() 196cdf0e10cSrcweir { 197cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 198cdf0e10cSrcweir if ( pSVData->maWinData.mpAppWin ) 199cdf0e10cSrcweir return pSVData->maWinData.mpAppWin; 200cdf0e10cSrcweir 201cdf0e10cSrcweir // First test if we already have a default window. 202cdf0e10cSrcweir // Don't only place a single if..else inside solar mutex lockframe 203cdf0e10cSrcweir // because then we might have to wait for the solar mutex what is not neccessary 204cdf0e10cSrcweir // if we already have a default window. 205cdf0e10cSrcweir 206cdf0e10cSrcweir if ( !pSVData->mpDefaultWin ) 207cdf0e10cSrcweir { 208cdf0e10cSrcweir Application::GetSolarMutex().acquire(); 209cdf0e10cSrcweir 210cdf0e10cSrcweir // Test again because the thread who released the solar mutex could have called 211cdf0e10cSrcweir // the same method 212cdf0e10cSrcweir 213cdf0e10cSrcweir if ( !pSVData->mpDefaultWin && !pSVData->mbDeInit ) 214cdf0e10cSrcweir { 215cdf0e10cSrcweir DBG_WARNING( "ImplGetDefaultWindow(): No AppWindow" ); 216cdf0e10cSrcweir pSVData->mpDefaultWin = new WorkWindow( 0, WB_DEFAULTWIN ); 217cdf0e10cSrcweir pSVData->mpDefaultWin->SetText( OUString( RTL_CONSTASCII_USTRINGPARAM( "VCL ImplGetDefaultWindow" ) ) ); 218cdf0e10cSrcweir } 219cdf0e10cSrcweir Application::GetSolarMutex().release(); 220cdf0e10cSrcweir } 221cdf0e10cSrcweir 222cdf0e10cSrcweir return pSVData->mpDefaultWin; 223cdf0e10cSrcweir } 224cdf0e10cSrcweir 225cdf0e10cSrcweir // ----------------------------------------------------------------------- 226cdf0e10cSrcweir 227cdf0e10cSrcweir #define VCL_CREATERESMGR_NAME( Name ) #Name 228cdf0e10cSrcweir 229cdf0e10cSrcweir ResMgr* ImplGetResMgr() 230cdf0e10cSrcweir { 231cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 232cdf0e10cSrcweir if ( !pSVData->mpResMgr ) 233cdf0e10cSrcweir { 234cdf0e10cSrcweir ::com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale(); 235cdf0e10cSrcweir pSVData->mpResMgr = ResMgr::SearchCreateResMgr( VCL_CREATERESMGR_NAME( vcl ), aLocale ); 236cdf0e10cSrcweir 237cdf0e10cSrcweir static bool bMessageOnce = false; 238cdf0e10cSrcweir if( !pSVData->mpResMgr && ! bMessageOnce ) 239cdf0e10cSrcweir { 240cdf0e10cSrcweir bMessageOnce = true; 241cdf0e10cSrcweir const char* pMsg = 242cdf0e10cSrcweir "Missing vcl resource. This indicates that files vital to localization are missing. " 243cdf0e10cSrcweir "You might have a corrupt installation."; 244cdf0e10cSrcweir fprintf( stderr, "%s\n", pMsg ); 245cdf0e10cSrcweir ErrorBox aBox( NULL, WB_OK | WB_DEF_OK, rtl::OUString( pMsg, strlen( pMsg ), RTL_TEXTENCODING_ASCII_US ) ); 246cdf0e10cSrcweir aBox.Execute(); 247cdf0e10cSrcweir } 248cdf0e10cSrcweir } 249cdf0e10cSrcweir return pSVData->mpResMgr; 250cdf0e10cSrcweir } 251cdf0e10cSrcweir 252cdf0e10cSrcweir ResId VclResId( sal_Int32 nId ) 253cdf0e10cSrcweir { 254cdf0e10cSrcweir ResMgr* pMgr = ImplGetResMgr(); 255cdf0e10cSrcweir if( ! pMgr ) 256cdf0e10cSrcweir throw std::bad_alloc(); 257cdf0e10cSrcweir 258cdf0e10cSrcweir return ResId( nId, *pMgr ); 259cdf0e10cSrcweir } 260cdf0e10cSrcweir 261cdf0e10cSrcweir FieldUnitStringList* ImplGetFieldUnits() 262cdf0e10cSrcweir { 263cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 264cdf0e10cSrcweir if( ! pSVData->maCtrlData.mpFieldUnitStrings ) 265cdf0e10cSrcweir { 266cdf0e10cSrcweir ResMgr* pResMgr = ImplGetResMgr(); 267cdf0e10cSrcweir if( pResMgr ) 268cdf0e10cSrcweir { 269cdf0e10cSrcweir ResStringArray aUnits( ResId (SV_FUNIT_STRINGS, *pResMgr) ); 270cdf0e10cSrcweir sal_uInt32 nUnits = aUnits.Count(); 271cdf0e10cSrcweir pSVData->maCtrlData.mpFieldUnitStrings = new FieldUnitStringList(); 272cdf0e10cSrcweir pSVData->maCtrlData.mpFieldUnitStrings->reserve( nUnits ); 273cdf0e10cSrcweir for( sal_uInt32 i = 0; i < nUnits; i++ ) 274cdf0e10cSrcweir { 275cdf0e10cSrcweir std::pair< String, FieldUnit > aElement( aUnits.GetString(i), static_cast<FieldUnit>(aUnits.GetValue(i)) ); 276cdf0e10cSrcweir pSVData->maCtrlData.mpFieldUnitStrings->push_back( aElement ); 277cdf0e10cSrcweir } 278cdf0e10cSrcweir } 279cdf0e10cSrcweir } 280cdf0e10cSrcweir return pSVData->maCtrlData.mpFieldUnitStrings; 281cdf0e10cSrcweir } 282cdf0e10cSrcweir 283cdf0e10cSrcweir FieldUnitStringList* ImplGetCleanedFieldUnits() 284cdf0e10cSrcweir { 285cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 286cdf0e10cSrcweir if( ! pSVData->maCtrlData.mpCleanUnitStrings ) 287cdf0e10cSrcweir { 288cdf0e10cSrcweir FieldUnitStringList* pUnits = ImplGetFieldUnits(); 289cdf0e10cSrcweir if( pUnits ) 290cdf0e10cSrcweir { 291cdf0e10cSrcweir size_t nUnits = pUnits->size(); 292cdf0e10cSrcweir pSVData->maCtrlData.mpCleanUnitStrings = new FieldUnitStringList(); 293cdf0e10cSrcweir pSVData->maCtrlData.mpCleanUnitStrings->reserve( nUnits ); 294cdf0e10cSrcweir for( size_t i = 0; i < nUnits; i++ ) 295cdf0e10cSrcweir { 296cdf0e10cSrcweir String aUnit( (*pUnits)[i].first ); 297cdf0e10cSrcweir aUnit.EraseAllChars( sal_Unicode( ' ' ) ); 298cdf0e10cSrcweir aUnit.ToLowerAscii(); 299cdf0e10cSrcweir std::pair< String, FieldUnit > aElement( aUnit, (*pUnits)[i].second ); 300cdf0e10cSrcweir pSVData->maCtrlData.mpCleanUnitStrings->push_back( aElement ); 301cdf0e10cSrcweir } 302cdf0e10cSrcweir } 303cdf0e10cSrcweir } 304cdf0e10cSrcweir return pSVData->maCtrlData.mpCleanUnitStrings; 305cdf0e10cSrcweir } 306cdf0e10cSrcweir 307cdf0e10cSrcweir DockingManager* ImplGetDockingManager() 308cdf0e10cSrcweir { 309cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 310cdf0e10cSrcweir if ( !pSVData->mpDockingManager ) 311cdf0e10cSrcweir pSVData->mpDockingManager = new DockingManager(); 312cdf0e10cSrcweir 313cdf0e10cSrcweir return pSVData->mpDockingManager; 314cdf0e10cSrcweir } 315cdf0e10cSrcweir 316cdf0e10cSrcweir class AccessBridgeCurrentContext: public cppu::WeakImplHelper1< com::sun::star::uno::XCurrentContext > 317cdf0e10cSrcweir { 318cdf0e10cSrcweir public: 319cdf0e10cSrcweir AccessBridgeCurrentContext( 320cdf0e10cSrcweir const com::sun::star::uno::Reference< com::sun::star::uno::XCurrentContext > &context ) : 321cdf0e10cSrcweir m_prevContext( context ) {} 322cdf0e10cSrcweir 323cdf0e10cSrcweir // XCurrentContext 324cdf0e10cSrcweir virtual com::sun::star::uno::Any SAL_CALL getValueByName( const rtl::OUString& Name ) 325cdf0e10cSrcweir throw (com::sun::star::uno::RuntimeException); 326cdf0e10cSrcweir private: 327cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::uno::XCurrentContext > m_prevContext; 328cdf0e10cSrcweir }; 329cdf0e10cSrcweir 330cdf0e10cSrcweir com::sun::star::uno::Any AccessBridgeCurrentContext::getValueByName( const rtl::OUString & Name ) 331cdf0e10cSrcweir throw (com::sun::star::uno::RuntimeException) 332cdf0e10cSrcweir { 333cdf0e10cSrcweir com::sun::star::uno::Any ret; 334cdf0e10cSrcweir if( Name.equalsAscii( "java-vm.interaction-handler" ) ) 335cdf0e10cSrcweir { 336cdf0e10cSrcweir // Currently, for accessbility no interaction handler shall be offered. 337cdf0e10cSrcweir // There may be introduced later on a handler using native toolkits 338cdf0e10cSrcweir // jbu->obr: Instantiate here your interaction handler 339cdf0e10cSrcweir } 340cdf0e10cSrcweir else if( m_prevContext.is() ) 341cdf0e10cSrcweir { 342cdf0e10cSrcweir ret = m_prevContext->getValueByName( Name ); 343cdf0e10cSrcweir } 344cdf0e10cSrcweir return ret; 345cdf0e10cSrcweir } 346cdf0e10cSrcweir 347cdf0e10cSrcweir 348cdf0e10cSrcweir bool ImplInitAccessBridge(sal_Bool bAllowCancel, sal_Bool &rCancelled) 349cdf0e10cSrcweir { 350cdf0e10cSrcweir rCancelled = sal_False; 351cdf0e10cSrcweir 352cdf0e10cSrcweir bool bErrorMessage = true; 353cdf0e10cSrcweir 354cdf0e10cSrcweir // Note: 355cdf0e10cSrcweir // if bAllowCancel is sal_True we were called from application startup 356cdf0e10cSrcweir // where we will disable any Java errorboxes and show our own accessibility dialog if Java throws an exception 357cdf0e10cSrcweir // if bAllowCancel is sal_False we were called from Tools->Options 358cdf0e10cSrcweir // where we will see Java errorboxes, se we do not show our dialogs in addition to Java's 359cdf0e10cSrcweir 360cdf0e10cSrcweir try 361cdf0e10cSrcweir { 362cdf0e10cSrcweir bool bSuccess = true; 363cdf0e10cSrcweir 364cdf0e10cSrcweir // No error messages when env var is set .. 365cdf0e10cSrcweir static const char* pEnv = getenv("SAL_ACCESSIBILITY_ENABLED" ); 366cdf0e10cSrcweir if( pEnv && *pEnv ) 367cdf0e10cSrcweir { 368cdf0e10cSrcweir bErrorMessage = false; 369cdf0e10cSrcweir } 370cdf0e10cSrcweir 371cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 372cdf0e10cSrcweir if( ! pSVData->mxAccessBridge.is() ) 373cdf0e10cSrcweir { 374cdf0e10cSrcweir css::uno::Reference< XMultiServiceFactory > xFactory(vcl::unohelper::GetMultiServiceFactory()); 375cdf0e10cSrcweir 376cdf0e10cSrcweir if( xFactory.is() ) 377cdf0e10cSrcweir { 378cdf0e10cSrcweir css::uno::Reference< XExtendedToolkit > xToolkit = 379cdf0e10cSrcweir css::uno::Reference< XExtendedToolkit >(Application::GetVCLToolkit(), UNO_QUERY); 380cdf0e10cSrcweir 381cdf0e10cSrcweir Sequence< Any > arguments(1); 382cdf0e10cSrcweir arguments[0] = makeAny(xToolkit); 383cdf0e10cSrcweir 384cdf0e10cSrcweir // Disable default java error messages on startup, because they were probably unreadable 385cdf0e10cSrcweir // for a disabled user. Use native message boxes which are accessible without java support. 386cdf0e10cSrcweir // No need to do this when activated by Tools-Options dialog .. 387cdf0e10cSrcweir if( bAllowCancel ) 388cdf0e10cSrcweir { 389cdf0e10cSrcweir // customize the java-not-available-interaction-handler entry within the 390cdf0e10cSrcweir // current context when called at startup. 391cdf0e10cSrcweir com::sun::star::uno::ContextLayer layer( 392cdf0e10cSrcweir new AccessBridgeCurrentContext( com::sun::star::uno::getCurrentContext() ) ); 393cdf0e10cSrcweir 394cdf0e10cSrcweir pSVData->mxAccessBridge = xFactory->createInstanceWithArguments( 395cdf0e10cSrcweir OUString::createFromAscii( "com.sun.star.accessibility.AccessBridge" ), 396cdf0e10cSrcweir arguments 397cdf0e10cSrcweir ); 398cdf0e10cSrcweir } 399cdf0e10cSrcweir else 400cdf0e10cSrcweir { 401cdf0e10cSrcweir pSVData->mxAccessBridge = xFactory->createInstanceWithArguments( 402cdf0e10cSrcweir OUString::createFromAscii( "com.sun.star.accessibility.AccessBridge" ), 403cdf0e10cSrcweir arguments 404cdf0e10cSrcweir ); 405cdf0e10cSrcweir } 406cdf0e10cSrcweir 407cdf0e10cSrcweir if( !pSVData->mxAccessBridge.is() ) 408cdf0e10cSrcweir bSuccess = false; 409cdf0e10cSrcweir } 410cdf0e10cSrcweir } 411cdf0e10cSrcweir 412cdf0e10cSrcweir return bSuccess; 413cdf0e10cSrcweir } 414cdf0e10cSrcweir 415*adad3ae8SHerbert Dürr catch(::com::sun::star::java::JavaNotConfiguredException&) 416cdf0e10cSrcweir { 417cdf0e10cSrcweir ResMgr *pResMgr = ImplGetResMgr(); 418cdf0e10cSrcweir if( bErrorMessage && bAllowCancel && pResMgr ) 419cdf0e10cSrcweir { 420cdf0e10cSrcweir String aTitle(ResId(SV_ACCESSERROR_JAVA_NOT_CONFIGURED, *pResMgr)); 421cdf0e10cSrcweir String aMessage(ResId(SV_ACCESSERROR_JAVA_MSG, *pResMgr)); 422cdf0e10cSrcweir 423cdf0e10cSrcweir aMessage += String(" ", 1, RTL_TEXTENCODING_ASCII_US); 424cdf0e10cSrcweir aMessage += String(ResId(SV_ACCESSERROR_OK_CANCEL_MSG, *pResMgr)); 425cdf0e10cSrcweir 426cdf0e10cSrcweir int ret = ImplGetSalSystem()->ShowNativeMessageBox( 427cdf0e10cSrcweir aTitle, 428cdf0e10cSrcweir ReplaceJavaErrorMessages(aMessage), 429cdf0e10cSrcweir SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL, 430cdf0e10cSrcweir SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL); 431cdf0e10cSrcweir 432cdf0e10cSrcweir // Do not change the setting in case the user chooses to cancel 433cdf0e10cSrcweir if( SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL == ret ) 434cdf0e10cSrcweir rCancelled = sal_True; 435cdf0e10cSrcweir } 436cdf0e10cSrcweir 437cdf0e10cSrcweir return false; 438cdf0e10cSrcweir } 439cdf0e10cSrcweir 440*adad3ae8SHerbert Dürr catch(::com::sun::star::java::JavaVMCreationFailureException&) 441cdf0e10cSrcweir { 442cdf0e10cSrcweir ResMgr *pResMgr = ImplGetResMgr(); 443cdf0e10cSrcweir if( bErrorMessage && bAllowCancel && pResMgr ) 444cdf0e10cSrcweir { 445cdf0e10cSrcweir String aTitle(ResId(SV_ACCESSERROR_FAULTY_JAVA, *pResMgr)); 446cdf0e10cSrcweir String aMessage(ResId(SV_ACCESSERROR_JAVA_MSG, *pResMgr)); 447cdf0e10cSrcweir 448cdf0e10cSrcweir aMessage += String(" ", 1, RTL_TEXTENCODING_ASCII_US); 449cdf0e10cSrcweir aMessage += String(ResId(SV_ACCESSERROR_OK_CANCEL_MSG, *pResMgr)); 450cdf0e10cSrcweir 451cdf0e10cSrcweir int ret = ImplGetSalSystem()->ShowNativeMessageBox( 452cdf0e10cSrcweir aTitle, 453cdf0e10cSrcweir ReplaceJavaErrorMessages(aMessage), 454cdf0e10cSrcweir SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL, 455cdf0e10cSrcweir SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL); 456cdf0e10cSrcweir 457cdf0e10cSrcweir // Do not change the setting in case the user chooses to cancel 458cdf0e10cSrcweir if( SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL == ret ) 459cdf0e10cSrcweir rCancelled = sal_True; 460cdf0e10cSrcweir } 461cdf0e10cSrcweir 462cdf0e10cSrcweir return false; 463cdf0e10cSrcweir } 464cdf0e10cSrcweir 465*adad3ae8SHerbert Dürr catch(::com::sun::star::java::MissingJavaRuntimeException&) 466cdf0e10cSrcweir { 467cdf0e10cSrcweir ResMgr *pResMgr = ImplGetResMgr(); 468cdf0e10cSrcweir if( bErrorMessage && bAllowCancel && pResMgr ) 469cdf0e10cSrcweir { 470cdf0e10cSrcweir String aTitle(ResId(SV_ACCESSERROR_MISSING_JAVA, *pResMgr)); 471cdf0e10cSrcweir String aMessage(ResId(SV_ACCESSERROR_JAVA_MSG, *pResMgr)); 472cdf0e10cSrcweir 473cdf0e10cSrcweir aMessage += String(" ", 1, RTL_TEXTENCODING_ASCII_US); 474cdf0e10cSrcweir aMessage += String(ResId(SV_ACCESSERROR_OK_CANCEL_MSG, *pResMgr)); 475cdf0e10cSrcweir 476cdf0e10cSrcweir int ret = ImplGetSalSystem()->ShowNativeMessageBox( 477cdf0e10cSrcweir aTitle, 478cdf0e10cSrcweir ReplaceJavaErrorMessages(aMessage), 479cdf0e10cSrcweir SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL, 480cdf0e10cSrcweir SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL); 481cdf0e10cSrcweir 482cdf0e10cSrcweir // Do not change the setting in case the user chooses to cancel 483cdf0e10cSrcweir if( SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL == ret ) 484cdf0e10cSrcweir rCancelled = sal_True; 485cdf0e10cSrcweir } 486cdf0e10cSrcweir 487cdf0e10cSrcweir return false; 488cdf0e10cSrcweir } 489cdf0e10cSrcweir 490*adad3ae8SHerbert Dürr catch(::com::sun::star::java::JavaDisabledException&) 491cdf0e10cSrcweir { 492cdf0e10cSrcweir ResMgr *pResMgr = ImplGetResMgr(); 493cdf0e10cSrcweir if( bErrorMessage && bAllowCancel && pResMgr ) 494cdf0e10cSrcweir { 495cdf0e10cSrcweir String aTitle(ResId(SV_ACCESSERROR_JAVA_DISABLED, *pResMgr)); 496cdf0e10cSrcweir String aMessage(ResId(SV_ACCESSERROR_JAVA_MSG, *pResMgr)); 497cdf0e10cSrcweir 498cdf0e10cSrcweir aMessage += String(" ", 1, RTL_TEXTENCODING_ASCII_US); 499cdf0e10cSrcweir aMessage += String(ResId(SV_ACCESSERROR_OK_CANCEL_MSG, *pResMgr)); 500cdf0e10cSrcweir 501cdf0e10cSrcweir int ret = ImplGetSalSystem()->ShowNativeMessageBox( 502cdf0e10cSrcweir aTitle, 503cdf0e10cSrcweir ReplaceJavaErrorMessages(aMessage), 504cdf0e10cSrcweir SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL, 505cdf0e10cSrcweir SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL); 506cdf0e10cSrcweir 507cdf0e10cSrcweir // Do not change the setting in case the user chooses to cancel 508cdf0e10cSrcweir if( SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL == ret ) 509cdf0e10cSrcweir rCancelled = sal_True; 510cdf0e10cSrcweir } 511cdf0e10cSrcweir 512cdf0e10cSrcweir return false; 513cdf0e10cSrcweir } 514cdf0e10cSrcweir 515cdf0e10cSrcweir 516*adad3ae8SHerbert Dürr catch(::com::sun::star::uno::RuntimeException& e) 517cdf0e10cSrcweir { 518cdf0e10cSrcweir ResMgr *pResMgr = ImplGetResMgr(); 519cdf0e10cSrcweir if( bErrorMessage && pResMgr ) 520cdf0e10cSrcweir { 521cdf0e10cSrcweir String aTitle; 522cdf0e10cSrcweir String aMessage(ResId(SV_ACCESSERROR_BRIDGE_MSG, *pResMgr)); 523cdf0e10cSrcweir 524cdf0e10cSrcweir if( 0 == e.Message.compareTo(::rtl::OUString::createFromAscii("ClassNotFound"), 13) ) 525cdf0e10cSrcweir { 526cdf0e10cSrcweir aTitle = String(ResId(SV_ACCESSERROR_MISSING_BRIDGE, *pResMgr)); 527cdf0e10cSrcweir } 528cdf0e10cSrcweir else if( 0 == e.Message.compareTo(::rtl::OUString::createFromAscii("NoSuchMethod"), 12) ) 529cdf0e10cSrcweir { 530cdf0e10cSrcweir aTitle = String(ResId(SV_ACCESSERROR_WRONG_VERSION, *pResMgr)); 531cdf0e10cSrcweir } 532cdf0e10cSrcweir 533cdf0e10cSrcweir if( aTitle.Len() != 0 ) 534cdf0e10cSrcweir { 535cdf0e10cSrcweir if( bAllowCancel ) 536cdf0e10cSrcweir { 537cdf0e10cSrcweir // Something went wrong initializing the Java AccessBridge (on Windows) during the 538cdf0e10cSrcweir // startup. Since the office will be probably unusable for a disabled user, we offer 539cdf0e10cSrcweir // to terminate directly. 540cdf0e10cSrcweir aMessage += String(" ", 1, RTL_TEXTENCODING_ASCII_US); 541cdf0e10cSrcweir aMessage += String(ResId(SV_ACCESSERROR_OK_CANCEL_MSG, *pResMgr)); 542cdf0e10cSrcweir 543cdf0e10cSrcweir int ret = ImplGetSalSystem()->ShowNativeMessageBox( 544cdf0e10cSrcweir aTitle, 545cdf0e10cSrcweir ReplaceJavaErrorMessages(aMessage), 546cdf0e10cSrcweir SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL, 547cdf0e10cSrcweir SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL); 548cdf0e10cSrcweir 549cdf0e10cSrcweir // Do not change the setting in case the user chooses to cancel 550cdf0e10cSrcweir if( SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL == ret ) 551cdf0e10cSrcweir rCancelled = sal_True; 552cdf0e10cSrcweir } 553cdf0e10cSrcweir else 554cdf0e10cSrcweir { 555cdf0e10cSrcweir // The user tried to activate accessibility support using Tools-Options dialog, 556cdf0e10cSrcweir // so we don't offer to terminate here ! 557cdf0e10cSrcweir ImplGetSalSystem()->ShowNativeMessageBox( 558cdf0e10cSrcweir aTitle, 559cdf0e10cSrcweir ReplaceJavaErrorMessages(aMessage), 560cdf0e10cSrcweir SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK, 561cdf0e10cSrcweir SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK); 562cdf0e10cSrcweir } 563cdf0e10cSrcweir } 564cdf0e10cSrcweir } 565cdf0e10cSrcweir 566cdf0e10cSrcweir return false; 567cdf0e10cSrcweir } 568cdf0e10cSrcweir 569cdf0e10cSrcweir catch (...) 570cdf0e10cSrcweir { 571cdf0e10cSrcweir return false; 572cdf0e10cSrcweir } 573cdf0e10cSrcweir } 574cdf0e10cSrcweir 575cdf0e10cSrcweir // ----------------------------------------------------------------------- 576cdf0e10cSrcweir 577cdf0e10cSrcweir Window* ImplFindWindow( const SalFrame* pFrame, Point& rSalFramePos ) 578cdf0e10cSrcweir { 579cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 580cdf0e10cSrcweir Window* pFrameWindow = pSVData->maWinData.mpFirstFrame; 581cdf0e10cSrcweir while ( pFrameWindow ) 582cdf0e10cSrcweir { 583cdf0e10cSrcweir if ( pFrameWindow->ImplGetFrame() == pFrame ) 584cdf0e10cSrcweir { 585cdf0e10cSrcweir Window* pWindow = pFrameWindow->ImplFindWindow( rSalFramePos ); 586cdf0e10cSrcweir if ( !pWindow ) 587cdf0e10cSrcweir pWindow = pFrameWindow->ImplGetWindow(); 588cdf0e10cSrcweir rSalFramePos = pWindow->ImplFrameToOutput( rSalFramePos ); 589cdf0e10cSrcweir return pWindow; 590cdf0e10cSrcweir } 591cdf0e10cSrcweir pFrameWindow = pFrameWindow->ImplGetFrameData()->mpNextFrame; 592cdf0e10cSrcweir } 593cdf0e10cSrcweir 594cdf0e10cSrcweir return NULL; 595cdf0e10cSrcweir } 596cdf0e10cSrcweir 597cdf0e10cSrcweir void LocaleConfigurationListener::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 nHint ) 598cdf0e10cSrcweir { 599cdf0e10cSrcweir AllSettings::LocaleSettingsChanged( nHint ); 600cdf0e10cSrcweir } 601cdf0e10cSrcweir 602