xref: /trunk/main/vcl/source/app/svdata.cxx (revision 91144cd0085a7583d2099b982122deb2184ab956) !
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 uninitialized
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 private:
339     com::sun::star::uno::Reference< com::sun::star::uno::XCurrentContext > m_prevContext;
340 };
341 
getValueByName(const rtl::OUString & Name)342 com::sun::star::uno::Any AccessBridgeCurrentContext::getValueByName( const rtl::OUString & Name )
343 {
344     com::sun::star::uno::Any ret;
345     if( Name.equalsAscii( "java-vm.interaction-handler" ) )
346     {
347         // Currently, for accessibility no interaction handler shall be offered.
348         // There may be introduced later on a handler using native toolkits
349         // jbu->obr: Instantiate here your interaction handler
350     }
351     else if( m_prevContext.is() )
352     {
353         ret = m_prevContext->getValueByName( Name );
354     }
355     return ret;
356 }
357 #ifdef WNT
AccessBridgehandleExistingWindow(Window * pWindow,bool bShow)358 void AccessBridgehandleExistingWindow(Window * pWindow, bool bShow)
359 {
360     if ( pWindow )
361     {
362         css::uno::Reference< css::accessibility::XAccessible > xAccessible;
363 
364         // Test for combo box - drop down floating windows first
365         Window * pParentWindow = pWindow->GetParent();
366 
367         if ( pParentWindow )
368         {
369             try
370             {
371                 // The parent window of a combo box floating window should have the role COMBO_BOX
372                 css::uno::Reference< css::accessibility::XAccessible > xParentAccessible(pParentWindow->GetAccessible());
373                 if ( xParentAccessible.is() )
374                 {
375                     css::uno::Reference< css::accessibility::XAccessibleContext > xParentAC( xParentAccessible->getAccessibleContext() );
376                     if ( xParentAC.is() && (css::accessibility::AccessibleRole::COMBO_BOX == xParentAC->getAccessibleRole()) )
377                     {
378                         // O.k. - this is a combo box floating window corresponding to the child of role LIST of the parent.
379                         // Let's not rely on a specific child order, just search for the child with the role LIST
380                         sal_Int32 nCount = xParentAC->getAccessibleChildCount();
381                         for ( sal_Int32 n = 0; (n < nCount) && !xAccessible.is(); n++)
382                         {
383                             css::uno::Reference< css::accessibility::XAccessible > xChild = xParentAC->getAccessibleChild(n);
384                             if ( xChild.is() )
385                             {
386                                 css::uno::Reference< css::accessibility::XAccessibleContext > xChildAC = xChild->getAccessibleContext();
387                                 if ( xChildAC.is() && (css::accessibility::AccessibleRole::LIST == xChildAC->getAccessibleRole()) )
388                                 {
389                                     xAccessible = xChild;
390                                 }
391                             }
392                         }
393                     }
394                 }
395             }
396             catch (::com::sun::star::uno::RuntimeException e)
397             {
398                 // Ignore show events that throw DisposedExceptions in getAccessibleContext(),
399                 // but keep revoking these windows in hide(s).
400                 if (bShow)
401                     return;
402             }
403         }
404 
405         // We have to rely on the fact that Window::GetAccessible()->getAccessibleContext() returns a valid XAccessibleContext
406         // also for other menus than menubar or toplevel popup window. Otherwise we had to traverse the hierarchy to find the
407         // context object to this menu floater. This makes the call to Window->IsMenuFloatingWindow() obsolete.
408         if ( ! xAccessible.is() )
409             xAccessible = pWindow->GetAccessible();
410 
411         if ( xAccessible.is() && g_acc_manager1 )
412         {
413             g_acc_manager1->handleWindowOpened( (sal_Int64)(xAccessible.get()));
414         }
415     }
416 }
417 
AccessBridgeupdateOldTopWindows()418 void AccessBridgeupdateOldTopWindows()
419 {
420     sal_uInt16 nTopWindowCount = (sal_uInt16)Application::GetTopWindowCount();
421     for (sal_uInt16 i = 0; i < nTopWindowCount; i++)
422     {
423         Window* pTopWindow = Application::GetTopWindow( i );
424         css::uno::Reference< css::accessibility::XAccessible > xAccessible = pTopWindow->GetAccessible();
425         if ( xAccessible.is() )
426         {
427             css::uno::Reference< css::accessibility::XAccessibleContext > xAC(xAccessible->getAccessibleContext());
428             if ( xAC.is())
429             {
430                 short role = xAC->getAccessibleRole();
431                 if(xAC->getAccessibleName().getLength() > 0)
432                     AccessBridgehandleExistingWindow(pTopWindow, true);
433             }
434         }
435     }
436 }
437 #endif
438 
ImplInitAccessBridge(sal_Bool bAllowCancel,sal_Bool & rCancelled)439 bool ImplInitAccessBridge(sal_Bool bAllowCancel, sal_Bool &rCancelled)
440 {
441     rCancelled = sal_False;
442 
443     sal_Bool bErrorMessage = sal_True;
444 
445     // Note:
446     // if bAllowCancel is sal_True we were called from application startup
447     //  where we will disable any Java errorboxes and show our own accessibility dialog if Java throws an exception
448     // if bAllowCancel is sal_False we were called from Tools->Options
449     //  where we will see Java errorboxes, so we do not show our dialogs in addition to Java's
450 
451     try
452     {
453         sal_Bool bSuccess = sal_True;
454 
455         // No error messages when env var is set...
456         static const char* pEnv = getenv("SAL_ACCESSIBILITY_ENABLED" );
457         if( pEnv && *pEnv )
458         {
459             bErrorMessage = sal_False;
460         }
461 
462         ImplSVData* pSVData = ImplGetSVData();
463         if( ! pSVData->mxAccessBridge.is() )
464         {
465             css::uno::Reference< XMultiServiceFactory > xFactory(vcl::unohelper::GetMultiServiceFactory());
466 
467             if( xFactory.is() )
468             {
469 #ifdef WNT
470                 pSVData->mxAccessBridge = xFactory->createInstance(
471                            OUString::createFromAscii( "com.sun.star.accessibility.MSAAService" ) );
472                 if( pSVData->mxAccessBridge.is() )
473                 {
474                     css::uno::Reference< css::uno::XInterface > pRManager= pSVData->mxAccessBridge;
475                     g_acc_manager1 = (css::accessibility::XMSAAService*)(pRManager.get());
476                     AccessBridgeupdateOldTopWindows();
477                 }
478 
479                 if( !pSVData->mxAccessBridge.is() )
480                     bSuccess = sal_False;
481                 return bSuccess;
482 #endif
483                 css::uno::Reference< XExtendedToolkit > xToolkit =
484                     css::uno::Reference< XExtendedToolkit >(Application::GetVCLToolkit(), UNO_QUERY);
485 
486                 Sequence< Any > arguments(1);
487                 arguments[0] = makeAny(xToolkit);
488 
489                 // Disable default java error messages on startup, because they were probably unreadable
490                 // for a disabled user. Use native message boxes which are accessible without java support.
491                 // No need to do this when activated by Tools-Options dialog...
492                 if( bAllowCancel )
493                 {
494                     // customize the java-not-available-interaction-handler entry within the
495                     // current context when called at startup.
496                     com::sun::star::uno::ContextLayer layer(
497                         new AccessBridgeCurrentContext( com::sun::star::uno::getCurrentContext() ) );
498 
499                     pSVData->mxAccessBridge = xFactory->createInstanceWithArguments(
500                             OUString::createFromAscii( "com.sun.star.accessibility.AccessBridge" ),
501                             arguments
502                         );
503                 }
504                 else
505                 {
506                     pSVData->mxAccessBridge = xFactory->createInstanceWithArguments(
507                             OUString::createFromAscii( "com.sun.star.accessibility.AccessBridge" ),
508                             arguments
509                         );
510                 }
511 
512                 if( !pSVData->mxAccessBridge.is() )
513                     bSuccess = sal_False;
514             }
515         }
516 
517         return bSuccess;
518     }
519 
520     catch(::com::sun::star::java::JavaNotConfiguredException&)
521     {
522         ResMgr *pResMgr = ImplGetResMgr();
523         if( bErrorMessage && bAllowCancel && pResMgr )
524         {
525             String aTitle(ResId(SV_ACCESSERROR_JAVA_NOT_CONFIGURED, *pResMgr));
526             String aMessage(ResId(SV_ACCESSERROR_JAVA_MSG, *pResMgr));
527 
528             aMessage += String(" ", 1, RTL_TEXTENCODING_ASCII_US);
529             aMessage += String(ResId(SV_ACCESSERROR_OK_CANCEL_MSG, *pResMgr));
530 
531             int ret = ImplGetSalSystem()->ShowNativeMessageBox(
532                 aTitle,
533                 ReplaceJavaErrorMessages(aMessage),
534                 SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL,
535                 SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL);
536 
537             // Do not change the setting in case the user chooses to cancel
538             if( SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL == ret )
539                 rCancelled = sal_True;
540         }
541 
542         return sal_False;
543     }
544 
545     catch(::com::sun::star::java::JavaVMCreationFailureException&)
546     {
547         ResMgr *pResMgr = ImplGetResMgr();
548         if( bErrorMessage && bAllowCancel && pResMgr )
549         {
550             String aTitle(ResId(SV_ACCESSERROR_FAULTY_JAVA, *pResMgr));
551             String aMessage(ResId(SV_ACCESSERROR_JAVA_MSG, *pResMgr));
552 
553             aMessage += String(" ", 1, RTL_TEXTENCODING_ASCII_US);
554             aMessage += String(ResId(SV_ACCESSERROR_OK_CANCEL_MSG, *pResMgr));
555 
556             int ret = ImplGetSalSystem()->ShowNativeMessageBox(
557                 aTitle,
558                 ReplaceJavaErrorMessages(aMessage),
559                 SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL,
560                 SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL);
561 
562             // Do not change the setting in case the user chooses to cancel
563             if( SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL == ret )
564                 rCancelled = sal_True;
565         }
566 
567         return sal_False;
568     }
569 
570     catch(::com::sun::star::java::MissingJavaRuntimeException&)
571     {
572         ResMgr *pResMgr = ImplGetResMgr();
573         if( bErrorMessage && bAllowCancel && pResMgr )
574         {
575             String aTitle(ResId(SV_ACCESSERROR_MISSING_JAVA, *pResMgr));
576             String aMessage(ResId(SV_ACCESSERROR_JAVA_MSG, *pResMgr));
577 
578             aMessage += String(" ", 1, RTL_TEXTENCODING_ASCII_US);
579             aMessage += String(ResId(SV_ACCESSERROR_OK_CANCEL_MSG, *pResMgr));
580 
581             int ret = ImplGetSalSystem()->ShowNativeMessageBox(
582                 aTitle,
583                 ReplaceJavaErrorMessages(aMessage),
584                 SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL,
585                 SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL);
586 
587             // Do not change the setting in case the user chooses to cancel
588             if( SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL == ret )
589                 rCancelled = sal_True;
590         }
591 
592         return sal_False;
593     }
594 
595     catch(::com::sun::star::java::JavaDisabledException&)
596     {
597         ResMgr *pResMgr = ImplGetResMgr();
598         if( bErrorMessage && bAllowCancel && pResMgr )
599         {
600             String aTitle(ResId(SV_ACCESSERROR_JAVA_DISABLED, *pResMgr));
601             String aMessage(ResId(SV_ACCESSERROR_JAVA_MSG, *pResMgr));
602 
603             aMessage += String(" ", 1, RTL_TEXTENCODING_ASCII_US);
604             aMessage += String(ResId(SV_ACCESSERROR_OK_CANCEL_MSG, *pResMgr));
605 
606             int ret = ImplGetSalSystem()->ShowNativeMessageBox(
607                 aTitle,
608                 ReplaceJavaErrorMessages(aMessage),
609                 SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL,
610                 SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL);
611 
612             // Do not change the setting in case the user chooses to cancel
613             if( SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL == ret )
614                 rCancelled = sal_True;
615         }
616 
617         return sal_False;
618     }
619 
620 
621     catch(::com::sun::star::uno::RuntimeException& e)
622     {
623         ResMgr *pResMgr = ImplGetResMgr();
624         if( bErrorMessage && pResMgr )
625         {
626             String aTitle;
627             String aMessage(ResId(SV_ACCESSERROR_BRIDGE_MSG, *pResMgr));
628 
629             if( 0 == e.Message.compareTo(::rtl::OUString::createFromAscii("ClassNotFound"), 13) )
630             {
631                 aTitle = String(ResId(SV_ACCESSERROR_MISSING_BRIDGE, *pResMgr));
632             }
633             else if( 0 == e.Message.compareTo(::rtl::OUString::createFromAscii("NoSuchMethod"), 12) )
634             {
635                 aTitle = String(ResId(SV_ACCESSERROR_WRONG_VERSION, *pResMgr));
636             }
637 
638             if( aTitle.Len() != 0 )
639             {
640                 if( bAllowCancel )
641                 {
642                     // Something went wrong initializing the Java AccessBridge (on Windows) during the
643                     // startup. Since the office will be probably unusable for a disabled user, we offer
644                     // to terminate directly.
645                     aMessage += String(" ", 1, RTL_TEXTENCODING_ASCII_US);
646                     aMessage += String(ResId(SV_ACCESSERROR_OK_CANCEL_MSG, *pResMgr));
647 
648                     int ret = ImplGetSalSystem()->ShowNativeMessageBox(
649                         aTitle,
650                         ReplaceJavaErrorMessages(aMessage),
651                         SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL,
652                         SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL);
653 
654                     // Do not change the setting in case the user chooses to cancel
655                     if( SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL == ret )
656                         rCancelled = sal_True;
657                 }
658                 else
659                 {
660                     // The user tried to activate accessibility support using Tools-Options dialog,
661                     // so we don't offer to terminate here !
662                     ImplGetSalSystem()->ShowNativeMessageBox(
663                         aTitle,
664                         ReplaceJavaErrorMessages(aMessage),
665                         SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK,
666                         SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK);
667                 }
668             }
669         }
670 
671         return sal_False;
672     }
673 
674     catch (...)
675     {
676         return sal_False;
677     }
678 }
679 
680 // -----------------------------------------------------------------------
681 
ImplFindWindow(const SalFrame * pFrame,::Point & rSalFramePos)682 Window* ImplFindWindow( const SalFrame* pFrame, ::Point& rSalFramePos )
683 {
684     ImplSVData* pSVData = ImplGetSVData();
685     Window*  pFrameWindow = pSVData->maWinData.mpFirstFrame;
686     while ( pFrameWindow )
687     {
688         if ( pFrameWindow->ImplGetFrame() == pFrame )
689         {
690             Window* pWindow = pFrameWindow->ImplFindWindow( rSalFramePos );
691             if ( !pWindow )
692                 pWindow = pFrameWindow->ImplGetWindow();
693             rSalFramePos = pWindow->ImplFrameToOutput( rSalFramePos );
694             return pWindow;
695         }
696         pFrameWindow = pFrameWindow->ImplGetFrameData()->mpNextFrame;
697     }
698 
699     return NULL;
700 }
701 
ConfigurationChanged(utl::ConfigurationBroadcaster *,sal_uInt32 nHint)702 void LocaleConfigurationListener::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 nHint )
703 {
704     AllSettings::LocaleSettingsChanged( nHint );
705 }
706