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