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