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