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