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