xref: /AOO41X/main/cui/source/options/optgdlg.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
30 #include <svl/zforlist.hxx>
31 #include <svtools/grfmgr.hxx>
32 #include <svl/flagitem.hxx>
33 #include <sfx2/dispatch.hxx>
34 #include <unotools/lingucfg.hxx>
35 #include <svl/szitem.hxx>
36 #include <sfx2/viewsh.hxx>
37 #include <sfx2/viewfrm.hxx>
38 #include <sfx2/imgmgr.hxx>
39 #include <vcl/configsettings.hxx>
40 #include <vcl/msgbox.hxx>
41 #include <vcl/mnemonic.hxx>
42 #include <i18npool/mslangid.hxx>
43 #include <unotools/useroptions.hxx>
44 #include <unotools/cacheoptions.hxx>
45 #include <unotools/fontoptions.hxx>
46 #include <svtools/menuoptions.hxx>
47 #include <unotools/startoptions.hxx>
48 #include <svl/languageoptions.hxx>
49 #include <svtools/miscopt.hxx>
50 #include <unotools/printwarningoptions.hxx>
51 #include <unotools/syslocaleoptions.hxx>
52 #include <svtools/helpopt.hxx>
53 #include <svtools/accessibilityoptions.hxx>
54 #include <unotools/configitem.hxx>
55 #include <sfx2/objsh.hxx>
56 #include <comphelper/types.hxx>
57 #include <svl/ctloptions.hxx>
58 #include <svtools/langtab.hxx>
59 #include <unotools/localfilehelper.hxx>
60 #include <unotools/configmgr.hxx>
61 #include "cuioptgenrl.hxx"
62 #include "optpath.hxx"
63 #include "optsave.hxx"
64 #include "optlingu.hxx"
65 #include <svx/xpool.hxx>
66 #include <svx/dlgutil.hxx>
67 #include "cuitabarea.hxx"
68 #include <cuires.hrc>
69 #include <editeng/unolingu.hxx>
70 #include <editeng/langitem.hxx>
71 #include <comphelper/processfactory.hxx>
72 #include <rtl/ustrbuf.hxx>
73 #include <editeng/editids.hrc>
74 #include <svx/svxids.hrc>
75 #include <svl/intitem.hxx>
76 #include <dialmgr.hxx>
77 #include <svtools/helpopt.hxx>
78 #include <unotools/saveopt.hxx>
79 
80 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
81 #include <com/sun/star/container/XNameAccess.hpp>
82 #include <com/sun/star/container/XNameReplace.hpp>
83 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
84 #include <com/sun/star/lang/XComponent.hpp>
85 #include <com/sun/star/lang/XInitialization.hpp>
86 #include <com/sun/star/beans/NamedValue.hpp>
87 #include <com/sun/star/beans/XPropertySet.hpp>
88 #include <com/sun/star/util/XChangesBatch.hpp>
89 #include <com/sun/star/uno/Any.hxx>
90 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
91 #include <com/sun/star/container/XSet.hpp>
92 #include <com/sun/star/i18n/ScriptType.hpp>
93 
94 #include <vcl/svapp.hxx>
95 
96 #include "optgdlg.hrc"
97 #include "optgdlg.hxx"
98 #include <svx/ofaitem.hxx>
99 #include <svtools/apearcfg.hxx>
100 #include <svtools/optionsdrawinglayer.hxx>
101 
102 #define CONFIG_LANGUAGES "OfficeLanguages"
103 
104 using namespace ::com::sun::star::uno;
105 using namespace ::com::sun::star::lang;
106 using namespace ::com::sun::star::beans;
107 using namespace ::com::sun::star::container;
108 using namespace ::com::sun::star::util;
109 using namespace ::utl;
110 using ::rtl::OString;
111 using ::rtl::OUString;
112 
113 #define C2U(cChar) OUString::createFromAscii(cChar)
114 
115 #define MAX_PROGRAM_ENTRIES		3
116 
117 // class OfaMiscTabPage --------------------------------------------------
118 
119 int OfaMiscTabPage::DeactivatePage( SfxItemSet* pSet_ )
120 {
121 	if ( pSet_ )
122 		FillItemSet( *pSet_ );
123 	return LEAVE_PAGE;
124 }
125 
126 namespace
127 {
128 		::rtl::OUString impl_SystemFileOpenServiceName()
129 		{
130 			const ::rtl::OUString &rDesktopEnvironment =
131 				Application::GetDesktopEnvironment();
132 
133 			if ( rDesktopEnvironment.equalsIgnoreAsciiCaseAscii( "gnome" ) )
134 			{
135                 #ifdef ENABLE_GTK
136 				return ::rtl::OUString::createFromAscii( "com.sun.star.ui.dialogs.GtkFilePicker" );
137                 #else
138                 return rtl::OUString();
139                 #endif
140 			}
141 			else if ( rDesktopEnvironment.equalsIgnoreAsciiCaseAscii( "kde4" ) )
142 			{
143                 #ifdef ENABLE_KDE4
144 				return ::rtl::OUString::createFromAscii( "com.sun.star.ui.dialogs.KDE4FilePicker" );
145                 #else
146                 return rtl::OUString();
147                 #endif
148 			}
149 			else if ( rDesktopEnvironment.equalsIgnoreAsciiCaseAscii( "kde" ) )
150 			{
151                 #ifdef ENABLE_KDE
152 				return ::rtl::OUString::createFromAscii( "com.sun.star.ui.dialogs.KDEFilePicker" );
153                 #else
154                 return rtl::OUString();
155                 #endif
156 			}
157             #if defined WNT
158 			return ::rtl::OUString::createFromAscii( "com.sun.star.ui.dialogs.SystemFilePicker" );
159             #elif (defined MACOSX && defined QUARTZ)
160 			return ::rtl::OUString::createFromAscii( "com.sun.star.ui.dialogs.AquaFilePicker" );
161             #else
162             return rtl::OUString();
163             #endif
164 		}
165 
166 		sal_Bool lcl_HasSystemFilePicker()
167 		{
168         	Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
169 			sal_Bool bRet = sal_False;
170 
171 			Reference< XContentEnumerationAccess > xEnumAccess( xFactory, UNO_QUERY );
172 			Reference< XSet > xSet( xFactory, UNO_QUERY );
173 
174 			if ( ! xEnumAccess.is() || ! xSet.is() )
175 				return bRet;
176 
177 			try
178 			{
179 				::rtl::OUString aFileService = impl_SystemFileOpenServiceName();
180 				Reference< XEnumeration > xEnum = xEnumAccess->createContentEnumeration( aFileService );
181 				if ( xEnum.is() && xEnum->hasMoreElements() )
182 					bRet = sal_True;
183 			}
184 
185 			catch( IllegalArgumentException ) {}
186 			catch( ElementExistException ) {}
187 			return bRet;
188 		}
189 }
190 
191 // -----------------------------------------------------------------------
192 
193 OfaMiscTabPage::OfaMiscTabPage(Window* pParent, const SfxItemSet& rSet ) :
194 
195 	SfxTabPage( pParent, CUI_RES( OFA_TP_MISC ), rSet ),
196 
197 	aHelpFL				( this, CUI_RES( FL_HELP ) ),
198 	aToolTipsCB			( this, CUI_RES( CB_TOOLTIP ) ),
199 	aExtHelpCB			( this, CUI_RES( CB_EXTHELP ) ),
200 	aHelpAgentCB		( this, CUI_RES( CB_HELPAGENT ) ),
201 	aHelpAgentResetBtn	( this, CUI_RES( PB_HELPAGENT_RESET ) ),
202 	aHelpFormatFT		( this, CUI_RES( FT_HELPFORMAT ) ),
203 	aHelpFormatLB		( this, CUI_RES( LB_HELPFORMAT ) ),
204 	aFileDlgFL			( this, CUI_RES( FL_FILEDLG ) ),
205     aFileDlgROImage     ( this, CUI_RES( FI_FILEDLG_RO ) ),
206 	aFileDlgCB			( this, CUI_RES( CB_FILEDLG ) ),
207 	aPrintDlgFL			( this, CUI_RES( FL_PRINTDLG ) ),
208 	aPrintDlgCB			( this, CUI_RES( CB_PRINTDLG ) ),
209 	aDocStatusFL		( this, CUI_RES( FL_DOCSTATUS ) ),
210 	aDocStatusCB		( this, CUI_RES( CB_DOCSTATUS ) ),
211 	aTwoFigureFL		( this, CUI_RES( FL_TWOFIGURE ) ),
212 	aInterpretFT		( this, CUI_RES( FT_INTERPRET ) ),
213 	aYearValueField		( this, CUI_RES( NF_YEARVALUE ) ),
214 	aToYearFT			( this, CUI_RES( FT_TOYEAR ) )
215 
216 {
217 	FreeResource();
218 
219 	if (!lcl_HasSystemFilePicker())
220 	{
221         aFileDlgFL.Hide();
222         aFileDlgCB.Hide();
223 	}
224 
225     #if ! defined(QUARTZ)
226     aPrintDlgFL.Hide();
227     aPrintDlgCB.Hide();
228     #endif
229 
230     if ( !aFileDlgCB.IsVisible() )
231     {
232         // rearrange the following controls
233         Point aNewPos = aDocStatusFL.GetPosPixel();
234         long nDelta = aNewPos.Y() - aFileDlgFL.GetPosPixel().Y();
235 
236         Window* pWins[] =
237         {
238             &aPrintDlgFL, &aPrintDlgCB, &aDocStatusFL, &aDocStatusCB, &aTwoFigureFL,
239             &aInterpretFT, &aYearValueField, &aToYearFT
240         };
241         Window** pCurrent = pWins;
242         const sal_Int32 nCount = sizeof( pWins ) / sizeof( pWins[ 0 ] );
243         for ( sal_Int32 i = 0; i < nCount; ++i, ++pCurrent )
244         {
245             aNewPos = (*pCurrent)->GetPosPixel();
246             aNewPos.Y() -= nDelta;
247             (*pCurrent)->SetPosPixel( aNewPos );
248         }
249     }
250     else if ( SvtMiscOptions().IsUseSystemFileDialogReadOnly() )
251     {
252         aFileDlgROImage.Show();
253         aFileDlgCB.Disable();
254     }
255 
256     if ( aPrintDlgCB.IsVisible() )
257     {
258         // rearrange the following controls
259         Point aNewPos = aDocStatusFL.GetPosPixel();
260         long nDelta = aNewPos.Y() - aFileDlgFL.GetPosPixel().Y();
261 
262         Window* pWins[] =
263         {
264             &aDocStatusFL, &aDocStatusCB, &aTwoFigureFL,
265             &aInterpretFT, &aYearValueField, &aToYearFT
266         };
267         Window** pCurrent = pWins;
268         const sal_Int32 nCount = sizeof( pWins ) / sizeof( pWins[ 0 ] );
269         for ( sal_Int32 i = 0; i < nCount; ++i, ++pCurrent )
270         {
271             aNewPos = (*pCurrent)->GetPosPixel();
272             aNewPos.Y() += nDelta;
273             (*pCurrent)->SetPosPixel( aNewPos );
274         }
275     }
276 
277     // at least the button is as wide as its text
278 	long nTxtWidth = aHelpAgentResetBtn.GetTextWidth( aHelpAgentResetBtn.GetText() );
279 	Size aBtnSz = aHelpAgentResetBtn.GetSizePixel();
280 	if ( aBtnSz.Width() < nTxtWidth )
281 	{
282 		aBtnSz.Width() = nTxtWidth;
283 		aHelpAgentResetBtn.SetSizePixel( aBtnSz );
284 	}
285 
286     aStrDateInfo = aToYearFT.GetText();
287     aYearValueField.SetModifyHdl( LINK( this, OfaMiscTabPage, TwoFigureHdl ) );
288 	Link aLink = LINK( this, OfaMiscTabPage, TwoFigureConfigHdl );
289 	aYearValueField.SetDownHdl( aLink );
290 	aYearValueField.SetUpHdl( aLink );
291 	aYearValueField.SetLoseFocusHdl( aLink );
292 	aYearValueField.SetFirstHdl( aLink );
293 	TwoFigureConfigHdl( &aYearValueField );
294 
295     SetExchangeSupport();
296 
297 	aLink = LINK( this, OfaMiscTabPage, HelpCheckHdl_Impl );
298 	aToolTipsCB.SetClickHdl( aLink );
299 	aHelpAgentCB.SetClickHdl( aLink );
300 	aHelpAgentResetBtn.SetClickHdl( LINK( this, OfaMiscTabPage, HelpAgentResetHdl_Impl ) );
301 
302     //fill default names as user data
303     static const char* aHelpFormatNames[] =
304 	{
305         "Default",
306         "HighContrast1",
307         "HighContrast2",
308         "HighContrastBlack",
309         "HighContrastWhite"
310     };
311 
312     for ( sal_uInt16 i = 0; i < aHelpFormatLB.GetEntryCount(); i++ )
313     {
314         String* pData = new String( String::CreateFromAscii( aHelpFormatNames[i] ) );
315         aHelpFormatLB.SetEntryData( i, pData );
316     }
317 }
318 
319 // -----------------------------------------------------------------------
320 
321 OfaMiscTabPage::~OfaMiscTabPage()
322 {
323     for(sal_uInt16 i = 0; i < aHelpFormatLB.GetEntryCount(); i++)
324     {
325         delete static_cast< String* >( aHelpFormatLB.GetEntryData(i) );
326     }
327 }
328 
329 // -----------------------------------------------------------------------
330 
331 SfxTabPage*	OfaMiscTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
332 {
333 	return new OfaMiscTabPage( pParent, rAttrSet );
334 }
335 
336 // -----------------------------------------------------------------------
337 
338 sal_Bool OfaMiscTabPage::FillItemSet( SfxItemSet& rSet )
339 {
340 	sal_Bool bModified = sal_False;
341 
342     SvtHelpOptions aHelpOptions;
343     sal_Bool bChecked = aToolTipsCB.IsChecked();
344 	if ( bChecked != aToolTipsCB.GetSavedValue() )
345 		aHelpOptions.SetHelpTips( bChecked );
346     bChecked = ( aExtHelpCB.IsChecked() && aToolTipsCB.IsChecked() );
347 	if ( bChecked != aExtHelpCB.GetSavedValue() )
348 		aHelpOptions.SetExtendedHelp( bChecked );
349     bChecked = aHelpAgentCB.IsChecked();
350 	if ( bChecked != aHelpAgentCB.GetSavedValue() )
351 		aHelpOptions.SetHelpAgentAutoStartMode( bChecked );
352 	sal_uInt16 nHelpFormatPos = aHelpFormatLB.GetSelectEntryPos();
353     if ( nHelpFormatPos != LISTBOX_ENTRY_NOTFOUND &&
354          nHelpFormatPos != aHelpFormatLB.GetSavedValue() )
355     {
356         aHelpOptions.SetHelpStyleSheet( *static_cast< String* >( aHelpFormatLB.GetEntryData( nHelpFormatPos ) ) );
357     }
358 
359     if ( aFileDlgCB.IsChecked() != aFileDlgCB.GetSavedValue() )
360     {
361         SvtMiscOptions aMiscOpt;
362         aMiscOpt.SetUseSystemFileDialog( !aFileDlgCB.IsChecked() );
363         bModified = sal_True;
364     }
365 
366     if ( aPrintDlgCB.IsChecked() != aPrintDlgCB.GetSavedValue() )
367     {
368         SvtMiscOptions aMiscOpt;
369         aMiscOpt.SetUseSystemPrintDialog( !aPrintDlgCB.IsChecked() );
370         bModified = sal_True;
371     }
372 
373 	if ( aDocStatusCB.IsChecked() != aDocStatusCB.GetSavedValue() )
374     {
375         SvtPrintWarningOptions aPrintOptions;
376         aPrintOptions.SetModifyDocumentOnPrintingAllowed( aDocStatusCB.IsChecked() );
377         bModified = sal_True;
378     }
379 
380 	const SfxUInt16Item* pUInt16Item =
381 		PTR_CAST( SfxUInt16Item, GetOldItem( rSet, SID_ATTR_YEAR2000 ) );
382 	sal_uInt16 nNum = (sal_uInt16)aYearValueField.GetText().ToInt32();
383     if ( pUInt16Item && pUInt16Item->GetValue() != nNum )
384 	{
385 		bModified = sal_True;
386 		rSet.Put( SfxUInt16Item( SID_ATTR_YEAR2000, nNum ) );
387 	}
388 
389     return bModified;
390 }
391 
392 // -----------------------------------------------------------------------
393 
394 void OfaMiscTabPage::Reset( const SfxItemSet& rSet )
395 {
396 	SvtHelpOptions aHelpOptions;
397 	aToolTipsCB.Check( aHelpOptions.IsHelpTips() );
398 	aExtHelpCB.Check( aHelpOptions.IsHelpTips() && aHelpOptions.IsExtendedHelp() );
399 	aHelpAgentCB.Check( aHelpOptions.IsHelpAgentAutoStartMode() );
400 	String sStyleSheet = aHelpOptions.GetHelpStyleSheet();
401     for ( sal_uInt16 i = 0; i < aHelpFormatLB.GetEntryCount(); ++i )
402     {
403         if ( *static_cast< String* >( aHelpFormatLB.GetEntryData(i) ) == sStyleSheet )
404         {
405             aHelpFormatLB.SelectEntryPos(i);
406             break;
407         }
408     }
409 
410 	aToolTipsCB.SaveValue();
411 	aExtHelpCB.SaveValue();
412 	aHelpAgentCB.SaveValue();
413     aHelpFormatLB.SaveValue();
414     HelpCheckHdl_Impl( &aHelpAgentCB );
415 
416     SvtMiscOptions aMiscOpt;
417     aFileDlgCB.Check( !aMiscOpt.UseSystemFileDialog() );
418     aFileDlgCB.SaveValue();
419     aPrintDlgCB.Check( !aMiscOpt.UseSystemPrintDialog() );
420     aPrintDlgCB.SaveValue();
421 
422     SvtPrintWarningOptions aPrintOptions;
423     aDocStatusCB.Check(aPrintOptions.IsModifyDocumentOnPrintingAllowed());
424     aDocStatusCB.SaveValue();
425 
426 	const SfxPoolItem* pItem = NULL;
427 	if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_YEAR2000, sal_False, &pItem ) )
428     {
429 		aYearValueField.SetValue( ((SfxUInt16Item*)pItem)->GetValue() );
430         TwoFigureConfigHdl( &aYearValueField );
431     }
432     else
433     {
434         aYearValueField.Enable(sal_False);
435         aTwoFigureFL.Enable(sal_False);
436         aInterpretFT.Enable(sal_False);
437         aToYearFT.Enable(sal_False);
438     }
439 }
440 
441 // -----------------------------------------------------------------------
442 
443 IMPL_LINK( OfaMiscTabPage, TwoFigureHdl, NumericField*, pEd )
444 {
445 	(void)pEd;
446 
447 	String aOutput( aStrDateInfo );
448 	String aStr( aYearValueField.GetText() );
449     String sSep( SvtSysLocale().GetLocaleData().getNumThousandSep() );
450     xub_StrLen nIndex = 0;
451     while ((nIndex = aStr.Search( sSep, nIndex)) != STRING_NOTFOUND)
452         aStr.Erase( nIndex, sSep.Len());
453 	long nNum = aStr.ToInt32();
454     if ( aStr.Len() != 4 || nNum < aYearValueField.GetMin() || nNum > aYearValueField.GetMax() )
455 		aOutput.AppendAscii("????");
456 	else
457 	{
458 		nNum += 99;
459 		aOutput += String::CreateFromInt32( nNum );
460 	}
461 	aToYearFT.SetText( aOutput );
462 	return 0;
463 }
464 
465 // -----------------------------------------------------------------------
466 
467 IMPL_LINK( OfaMiscTabPage, TwoFigureConfigHdl, NumericField*, pEd )
468 {
469 	sal_Int64 nNum = aYearValueField.GetValue();
470 	String aOutput( String::CreateFromInt64( nNum ) );
471 	aYearValueField.SetText( aOutput );
472 	aYearValueField.SetSelection( Selection( 0, aOutput.Len() ) );
473 	TwoFigureHdl( pEd );
474 	return 0;
475 }
476 
477 // -----------------------------------------------------------------------
478 
479 IMPL_LINK( OfaMiscTabPage, HelpCheckHdl_Impl, CheckBox*, EMPTYARG )
480 {
481 	aExtHelpCB.Enable( aToolTipsCB.IsChecked() );
482 	aHelpAgentResetBtn.Enable( aHelpAgentCB.IsChecked() );
483 	return 0;
484 }
485 
486 // -----------------------------------------------------------------------
487 
488 IMPL_LINK( OfaMiscTabPage, HelpAgentResetHdl_Impl, PushButton*, EMPTYARG )
489 {
490 	SvtHelpOptions().resetAgentIgnoreURLCounter();
491 	return 0;
492 }
493 
494 // -----------------------------------------------------------------------
495 
496 // -------------------------------------------------------------------
497 class CanvasSettings
498 {
499 public:
500     CanvasSettings();
501 
502     sal_Bool    IsHardwareAccelerationEnabled() const;
503     sal_Bool    IsHardwareAccelerationAvailable() const;
504     void    EnabledHardwareAcceleration( sal_Bool _bEnabled ) const;
505 
506 private:
507     typedef std::vector< std::pair<OUString,Sequence<OUString> > > ServiceVector;
508 
509     Reference<XNameAccess> mxForceFlagNameAccess;
510     ServiceVector          maAvailableImplementations;
511     mutable sal_Bool           mbHWAccelAvailable;
512     mutable sal_Bool           mbHWAccelChecked;
513 };
514 
515 // -------------------------------------------------------------------
516 CanvasSettings::CanvasSettings() :
517     mxForceFlagNameAccess(),
518     mbHWAccelAvailable(sal_False),
519     mbHWAccelChecked(sal_False)
520 {
521     try
522     {
523         Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
524         Reference<XMultiServiceFactory> xConfigProvider(
525             xFactory->createInstance(
526                 OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")),
527 				UNO_QUERY_THROW );
528 
529         Any propValue(
530             makeAny( PropertyValue(
531                          OUString::createFromAscii("nodepath"), -1,
532                          makeAny( OUString::createFromAscii("/org.openoffice.Office.Canvas") ),
533                          PropertyState_DIRECT_VALUE ) ) );
534 
535         mxForceFlagNameAccess.set(
536             xConfigProvider->createInstanceWithArguments(
537                 OUString::createFromAscii("com.sun.star.configuration.ConfigurationUpdateAccess"),
538                 Sequence<Any>( &propValue, 1 ) ),
539             UNO_QUERY_THROW );
540 
541         propValue = makeAny(
542             PropertyValue(
543                 OUString::createFromAscii("nodepath"), -1,
544                 makeAny( OUString::createFromAscii("/org.openoffice.Office.Canvas/CanvasServiceList") ),
545                 PropertyState_DIRECT_VALUE ) );
546 
547         Reference<XNameAccess> xNameAccess(
548             xConfigProvider->createInstanceWithArguments(
549                 OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess"),
550                 Sequence<Any>( &propValue, 1 ) ), UNO_QUERY_THROW );
551         Reference<XHierarchicalNameAccess> xHierarchicalNameAccess(
552             xNameAccess, UNO_QUERY_THROW);
553 
554         Sequence<OUString> serviceNames = xNameAccess->getElementNames();
555         const OUString* pCurr = serviceNames.getConstArray();
556         const OUString* const pEnd = pCurr + serviceNames.getLength();
557         while( pCurr != pEnd )
558         {
559             Reference<XNameAccess> xEntryNameAccess(
560                 xHierarchicalNameAccess->getByHierarchicalName(*pCurr),
561                 UNO_QUERY );
562 
563             if( xEntryNameAccess.is() )
564             {
565                 Sequence<OUString> preferredImplementations;
566                 if( (xEntryNameAccess->getByName( OUString::createFromAscii("PreferredImplementations") ) >>= preferredImplementations) )
567                     maAvailableImplementations.push_back( std::make_pair(*pCurr,preferredImplementations) );
568             }
569 
570             ++pCurr;
571         }
572     }
573     catch( Exception& )
574     {
575     }
576 }
577 
578 // -------------------------------------------------------------------
579 sal_Bool CanvasSettings::IsHardwareAccelerationAvailable() const
580 {
581     if( !mbHWAccelChecked )
582     {
583         mbHWAccelChecked = true;
584 
585         Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
586 
587         // check whether any of the service lists has an
588         // implementation that presents the "HardwareAcceleration" property
589         ServiceVector::const_iterator       aCurr=maAvailableImplementations.begin();
590         const ServiceVector::const_iterator aEnd=maAvailableImplementations.end();
591         while( aCurr != aEnd )
592         {
593             const OUString* pCurrImpl = aCurr->second.getConstArray();
594             const OUString* const pEndImpl = pCurrImpl + aCurr->second.getLength();
595 
596             while( pCurrImpl != pEndImpl )
597             {
598                 try
599                 {
600                     Reference<XPropertySet> xPropSet( xFactory->createInstance(
601                                                           pCurrImpl->trim() ),
602                                                       UNO_QUERY_THROW );
603                     bool bHasAccel(false);
604                     if( (xPropSet->getPropertyValue(OUString::createFromAscii("HardwareAcceleration")) >>= bHasAccel) )
605                         if( bHasAccel )
606                         {
607                             mbHWAccelAvailable = true;
608                             return mbHWAccelAvailable;
609                         }
610                 }
611                 catch (Exception &)
612                 {}
613 
614                 ++pCurrImpl;
615             }
616 
617 			++aCurr;
618         }
619     }
620 
621     return mbHWAccelAvailable;
622 }
623 
624 // -------------------------------------------------------------------
625 sal_Bool CanvasSettings::IsHardwareAccelerationEnabled() const
626 {
627     bool bForceLastEntry(false);
628     if( !mxForceFlagNameAccess.is() )
629         return true;
630 
631     if( !(mxForceFlagNameAccess->getByName( OUString::createFromAscii("ForceSafeServiceImpl") ) >>= bForceLastEntry) )
632         return true;
633 
634     return !bForceLastEntry;
635 }
636 
637 // -------------------------------------------------------------------
638 void CanvasSettings::EnabledHardwareAcceleration( sal_Bool _bEnabled ) const
639 {
640     Reference< XNameReplace > xNameReplace(
641         mxForceFlagNameAccess, UNO_QUERY );
642 
643     if( !xNameReplace.is() )
644         return;
645 
646     xNameReplace->replaceByName( OUString::createFromAscii("ForceSafeServiceImpl"),
647                                  makeAny(!_bEnabled) );
648 
649     Reference< XChangesBatch > xChangesBatch(
650         mxForceFlagNameAccess, UNO_QUERY );
651 
652     if( !xChangesBatch.is() )
653         return;
654 
655     xChangesBatch->commitChanges();
656 }
657 
658 // class OfaViewTabPage --------------------------------------------------
659 
660 OfaViewTabPage::OfaViewTabPage(Window* pParent, const SfxItemSet& rSet ) :
661 
662 	SfxTabPage( pParent, CUI_RES( OFA_TP_VIEW ), rSet ),
663 
664     aUserInterfaceFL    ( this, CUI_RES( FL_USERINTERFACE ) ),
665     aWindowSizeFT       ( this, CUI_RES( FT_WINDOWSIZE ) ),
666     aWindowSizeMF       ( this, CUI_RES( MF_WINDOWSIZE ) ),
667     aIconSizeStyleFT    ( this, CUI_RES( FT_ICONSIZESTYLE ) ),
668     aIconSizeLB              ( this, CUI_RES( LB_ICONSIZE ) ),
669     aIconStyleLB        ( this, CUI_RES( LB_ICONSTYLE ) ),
670     m_aSystemFont				(this, CUI_RES( CB_SYSTEM_FONT ) ),
671 #if defined( UNX )
672 	aFontAntiAliasing	( this, CUI_RES( CB_FONTANTIALIASING )),
673 	aAAPointLimitLabel	( this, CUI_RES( FT_POINTLIMIT_LABEL )),
674 	aAAPointLimit		( this, CUI_RES( NF_AA_POINTLIMIT )),
675 	aAAPointLimitUnits	( this, CUI_RES( FT_POINTLIMIT_UNIT )),
676 #endif
677     aMenuFL             ( this, CUI_RES( FL_MENU ) ),
678     aMenuIconsFT        ( this, CUI_RES( FT_MENU_ICONS )),
679     aMenuIconsLB        ( this, CUI_RES( LB_MENU_ICONS )),
680     aFontListsFL        ( this, CUI_RES( FL_FONTLISTS) ),
681     aFontShowCB         ( this, CUI_RES( CB_FONT_SHOW ) ),
682     aFontHistoryCB      ( this, CUI_RES( CB_FONT_HISTORY ) ),
683     aRenderingFL        ( this, CUI_RES( FL_RENDERING ) ),
684     aUseHardwareAccell  ( this, CUI_RES( CB_USE_HARDACCELL ) ),
685     aUseAntiAliase		( this, CUI_RES( CB_USE_ANTIALIASE ) ),
686     aMouseFL            ( this, CUI_RES( FL_MOUSE ) ),
687     aMousePosFT         ( this, CUI_RES( FT_MOUSEPOS ) ),
688     aMousePosLB         ( this, CUI_RES( LB_MOUSEPOS ) ),
689     aMouseMiddleFT      ( this, CUI_RES( FT_MOUSEMIDDLE ) ),
690     aMouseMiddleLB      ( this, CUI_RES( LB_MOUSEMIDDLE ) ),
691 
692 	// #i97672#
693     maSelectionFL(this, CUI_RES(FL_SELECTION)),
694     maSelectionCB(this, CUI_RES(CB_SELECTION)),
695     maSelectionMF(this, CUI_RES(MF_SELECTION)),
696 
697 	nSizeLB_InitialSelection(0),
698     nStyleLB_InitialSelection(0),
699     pAppearanceCfg(new SvtTabAppearanceCfg),
700     pCanvasSettings(new CanvasSettings),
701 	mpDrawinglayerOpt(new SvtOptionsDrawinglayer)
702 {
703 #if defined( UNX )
704 	aFontAntiAliasing.SetToggleHdl( LINK( this, OfaViewTabPage, OnAntialiasingToggled ) );
705 
706 	// depending on the size of the text in aAAPointLimitLabel, we slightly re-arrange aAAPointLimit and aAAPointLimitUnits
707     //#110391#  if the label has no mnemonic and we are in a CJK version the mnemonic "(X)" will be added which
708     //          influences the width calculation
709     MnemonicGenerator aMnemonicGenerator;
710     String sLabel(aAAPointLimitLabel.GetText());
711     aMnemonicGenerator.RegisterMnemonic( sLabel );
712     aMnemonicGenerator.CreateMnemonic( sLabel );
713     sLabel.EraseAllChars('~');
714 
715     sal_Int32 nLabelWidth = aAAPointLimitLabel.GetTextWidth( sLabel );
716 	nLabelWidth += 3;	// small gap
717 	// pixels to move both controls to the left
718 	Size aSize = aAAPointLimitLabel.GetSizePixel();
719 	sal_Int32 nMoveLeft = aSize.Width() - nLabelWidth;
720 	// resize the first label
721 	aSize.Width() = nLabelWidth;
722 	aAAPointLimitLabel.SetSizePixel( aSize );
723 
724 	// move the numeric field
725 	Point aPos( aAAPointLimit.GetPosPixel() );
726 	aPos.X() -= nMoveLeft;
727 	aAAPointLimit.SetPosPixel( aPos );
728 
729 	// move (and resize) the units FixedText
730 	aPos = ( aAAPointLimitUnits.GetPosPixel() );
731 	aPos.X() -= nMoveLeft;
732 	aSize = aAAPointLimitUnits.GetSizePixel();
733 	aSize.Width() += nMoveLeft;
734 	aAAPointLimitUnits.SetPosSizePixel( aPos, aSize );
735 #else
736 	// on this platform, we do not have the anti aliasing options - move the other checkboxes accordingly
737 	// (in the resource, the coordinates are calculated for the AA options beeing present)
738 	Control* pMiscOptions[] =
739 	{
740         &aMenuFL, &aMenuIconsFT, &aMenuIconsLB,
741         &aFontListsFL, &aFontShowCB, &aFontHistoryCB
742 	};
743 
744 	// temporaryly create the checkbox for the anti aliasing (we need to to determine it's pos)
745 	CheckBox* pFontAntiAliasing	= new CheckBox( this, CUI_RES( CB_FONTANTIALIASING ) );
746     sal_Int32 nMoveUp = aMenuFL.GetPosPixel().Y() - pFontAntiAliasing->GetPosPixel().Y();
747 	DELETEZ( pFontAntiAliasing );
748 
749 	Point aPos;
750 	for ( sal_Int32 i = 0; i < sizeof( pMiscOptions ) / sizeof( pMiscOptions[0] ); ++i )
751 	{
752 		aPos = pMiscOptions[i]->GetPosPixel( );
753 		aPos.Y() -= nMoveUp;
754 		pMiscOptions[i]->SetPosPixel( aPos );
755 	}
756 
757 #endif
758 
759 	// #i97672#
760 	maSelectionCB.SetToggleHdl( LINK( this, OfaViewTabPage, OnSelectionToggled ) );
761 
762 	FreeResource();
763 
764     if( ! Application::ValidateSystemFont() )
765     {
766         m_aSystemFont.Check( sal_False );
767         m_aSystemFont.Enable( sal_False );
768     }
769 
770     const StyleSettings& aStyleSettings = Application::GetSettings().GetStyleSettings();
771 
772     // remove non-installed icon themes
773     if( aIconStyleLB.GetEntryCount() == STYLE_SYMBOLS_THEMES_MAX )
774     {
775         // do not check 0th item == auto; it is not a real theme
776         aIconStyleItemId[0] = 0;
777         sal_uLong nItem = 1;
778         for ( sal_uLong n=0; ++n < STYLE_SYMBOLS_THEMES_MAX; )
779         {
780             if ( aStyleSettings.CheckSymbolStyle( n ) )
781             {
782                 // existing style => save the item id
783                 aIconStyleItemId[n] = nItem++;
784             }
785             else
786             {
787                 // non-existing style => remove item;
788                 aIconStyleLB.RemoveEntry( nItem );
789                 aIconStyleItemId[n] = 0;
790             }
791         }
792     }
793 
794     // add real theme name to 'auto' theme, e.g. 'auto' => 'auto (classic)'
795     if( aIconStyleLB.GetEntryCount() > 1 )
796     {
797         ::rtl::OUString aAutoStr( aIconStyleLB.GetEntry( 0 ) );
798 
799         aAutoStr += ::rtl::OUString::createFromAscii( " (" );
800 
801         sal_uLong nAutoStyle = aStyleSettings.GetAutoSymbolsStyle();
802         if ( aIconStyleItemId[nAutoStyle] )
803             aAutoStr += aIconStyleLB.GetEntry( aIconStyleItemId[nAutoStyle] );
804 
805         aIconStyleLB.RemoveEntry( 0 );
806         aIconStyleLB.InsertEntry( aAutoStr += ::rtl::OUString::createFromAscii( ")" ), 0 );
807         // separate auto and other icon themes
808         aIconStyleLB.SetSeparatorPos( 0 );
809     }
810 }
811 
812 OfaViewTabPage::~OfaViewTabPage()
813 {
814 	delete mpDrawinglayerOpt;
815     delete pCanvasSettings;
816     delete pAppearanceCfg;
817 }
818 
819 #if defined( UNX )
820 //--- 20.08.01 10:16:12 ---------------------------------------------------
821 IMPL_LINK( OfaViewTabPage, OnAntialiasingToggled, void*, NOTINTERESTEDIN )
822 {
823 	(void)NOTINTERESTEDIN;
824 
825 	sal_Bool bAAEnabled = aFontAntiAliasing.IsChecked();
826 
827 	aAAPointLimitLabel.Enable( bAAEnabled );
828 	aAAPointLimit.Enable( bAAEnabled );
829 	aAAPointLimitUnits.Enable( bAAEnabled );
830 
831 	return 0L;
832 }
833 #endif
834 
835 // #i97672#
836 IMPL_LINK( OfaViewTabPage, OnSelectionToggled, void*, NOTINTERESTEDIN )
837 {
838 	(void)NOTINTERESTEDIN;
839 	const bool bSelectionEnabled(maSelectionCB.IsChecked());
840 	maSelectionMF.Enable(bSelectionEnabled);
841 	return 0;
842 }
843 
844 /*-----------------06.12.96 11.50-------------------
845 
846 --------------------------------------------------*/
847 
848 SfxTabPage*	OfaViewTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
849 {
850 	return new OfaViewTabPage(pParent, rAttrSet);
851 }
852 
853 /*-----------------06.12.96 11.50-------------------
854 
855 --------------------------------------------------*/
856 
857 sal_Bool OfaViewTabPage::FillItemSet( SfxItemSet& )
858 {
859 	SvtFontOptions aFontOpt;
860 	SvtMenuOptions aMenuOpt;
861 	SvtStartOptions aStartOpt;
862 
863 	sal_Bool bModified = sal_False;
864 	sal_Bool bMenuOptModified = sal_False;
865 	bool bRepaintWindows(false);
866 
867     SvtMiscOptions aMiscOptions;
868     sal_uInt16 nSizeLB_NewSelection = aIconSizeLB.GetSelectEntryPos();
869     if( nSizeLB_InitialSelection != nSizeLB_NewSelection )
870 	{
871 		// from now on it's modified, even if via auto setting the same size was set as now selected in the LB
872         sal_Int16 eSet = SFX_SYMBOLS_SIZE_AUTO;
873         switch( nSizeLB_NewSelection )
874 		{
875             case 0: eSet = SFX_SYMBOLS_SIZE_AUTO;  break;
876             case 1: eSet = SFX_SYMBOLS_SIZE_SMALL; break;
877             case 2: eSet = SFX_SYMBOLS_SIZE_LARGE; break;
878             default:
879                 DBG_ERROR( "OfaViewTabPage::FillItemSet(): This state of aIconSizeLB should not be possible!" );
880 		}
881         aMiscOptions.SetSymbolsSize( eSet );
882     }
883 
884     sal_uInt16 nStyleLB_NewSelection = aIconStyleLB.GetSelectEntryPos();
885     if( nStyleLB_InitialSelection != nStyleLB_NewSelection )
886     {
887         // find the style name in the aIconStyleItemId table
888         // items from the non-installed icon themes were removed
889         for ( sal_uLong n=0; n < STYLE_SYMBOLS_THEMES_MAX; n++ )
890         {
891             if ( aIconStyleItemId[n] == nStyleLB_NewSelection )
892             {
893                 aMiscOptions.SetSymbolsStyle( n );
894                 n = STYLE_SYMBOLS_THEMES_MAX;
895             }
896         }
897     }
898 
899     sal_Bool bAppearanceChanged = sal_False;
900 
901 
902 	// Screen Scaling
903     sal_uInt16 nOldScale = pAppearanceCfg->GetScaleFactor();
904 	sal_uInt16 nNewScale = (sal_uInt16)aWindowSizeMF.GetValue();
905 
906 	if ( nNewScale != nOldScale )
907 	{
908         pAppearanceCfg->SetScaleFactor(nNewScale);
909         bAppearanceChanged = sal_True;
910 	}
911 
912 	// Mouse Snap Mode
913     short eOldSnap = pAppearanceCfg->GetSnapMode();
914     short eNewSnap = aMousePosLB.GetSelectEntryPos();
915     if(eNewSnap > 2)
916         eNewSnap = 2;
917 
918 	if ( eNewSnap != eOldSnap )
919 	{
920         pAppearanceCfg->SetSnapMode(eNewSnap );
921         bAppearanceChanged = sal_True;
922     }
923 
924     // Middle Mouse Button
925     short eOldMiddleMouse = pAppearanceCfg->GetMiddleMouseButton();
926     short eNewMiddleMouse = aMouseMiddleLB.GetSelectEntryPos();
927     if(eNewMiddleMouse > 2)
928         eNewMiddleMouse = 2;
929 
930     if ( eNewMiddleMouse != eOldMiddleMouse )
931 	{
932         pAppearanceCfg->SetMiddleMouseButton( eNewMiddleMouse );
933         bAppearanceChanged = sal_True;
934     }
935 
936 #if defined( UNX )
937 	if ( aFontAntiAliasing.IsChecked() != aFontAntiAliasing.GetSavedValue() )
938 	{
939         pAppearanceCfg->SetFontAntiAliasing( aFontAntiAliasing.IsChecked() );
940         bAppearanceChanged = sal_True;
941     }
942 
943 	if ( aAAPointLimit.GetValue() != aAAPointLimit.GetSavedValue().ToInt32() )
944 	{
945         pAppearanceCfg->SetFontAntialiasingMinPixelHeight( aAAPointLimit.GetValue() );
946         bAppearanceChanged = sal_True;
947     }
948 #endif
949 
950     if ( aFontShowCB.IsChecked() != aFontShowCB.GetSavedValue() )
951 	{
952 		aFontOpt.EnableFontWYSIWYG( aFontShowCB.IsChecked() );
953 		bModified = sal_True;
954 	}
955 
956     if(aMenuIconsLB.GetSelectEntryPos() != aMenuIconsLB.GetSavedValue())
957     {
958         aMenuOpt.SetMenuIconsState( aMenuIconsLB.GetSelectEntryPos() == 0 ? 2 : aMenuIconsLB.GetSelectEntryPos() - 1);
959         bModified = sal_True;
960         bMenuOptModified = sal_True;
961     	bAppearanceChanged = sal_True;
962 	}
963 
964 	if ( aFontHistoryCB.IsChecked() != aFontHistoryCB.GetSavedValue() )
965 	{
966 		aFontOpt.EnableFontHistory( aFontHistoryCB.IsChecked() );
967 		bModified = sal_True;
968 	}
969 
970 	// #i95644#  if disabled, do not use value, see in ::Reset()
971     if(aUseHardwareAccell.IsEnabled())
972     {
973         if(aUseHardwareAccell.IsChecked() != aUseHardwareAccell.GetSavedValue())
974         {
975             pCanvasSettings->EnabledHardwareAcceleration(aUseHardwareAccell.IsChecked());
976 	        bModified = sal_True;
977         }
978     }
979 
980 	// #i95644#  if disabled, do not use value, see in ::Reset()
981 	if(aUseAntiAliase.IsEnabled())
982 	{
983 	    if(aUseAntiAliase.IsChecked() != mpDrawinglayerOpt->IsAntiAliasing())
984 	    {
985 			mpDrawinglayerOpt->SetAntiAliasing(aUseAntiAliase.IsChecked());
986 			bModified = sal_True;
987 			bRepaintWindows = true;
988 		}
989 	}
990 
991 	// #i97672#
992     if(maSelectionCB.IsEnabled())
993     {
994         const bool bNewSelection(maSelectionCB.IsChecked());
995         const sal_uInt16 nNewTransparence((sal_uInt16)maSelectionMF.GetValue());
996 
997         if(bNewSelection != (bool)mpDrawinglayerOpt->IsTransparentSelection())
998 	    {
999 		    mpDrawinglayerOpt->SetTransparentSelection(maSelectionCB.IsChecked());
1000 		    bModified = sal_True;
1001 		    bRepaintWindows = true;
1002 	    }
1003 
1004         // #i104150# even read the value when maSelectionMF is disabled; it may have been
1005         // modified by enabling-modify-disabling by the user
1006 	    if(nNewTransparence != mpDrawinglayerOpt->GetTransparentSelectionPercent())
1007 	    {
1008 		    mpDrawinglayerOpt->SetTransparentSelectionPercent(nNewTransparence);
1009 		    bModified = sal_True;
1010 		    bRepaintWindows = true;
1011 	    }
1012     }
1013 
1014 	SvtAccessibilityOptions 	aAccessibilityOptions;
1015     if( aAccessibilityOptions.GetIsSystemFont() != m_aSystemFont.IsChecked() &&
1016         m_aSystemFont.IsEnabled() )
1017     {
1018         aAccessibilityOptions.SetIsSystemFont( m_aSystemFont.IsChecked() );
1019         bModified = sal_True;
1020         bMenuOptModified = sal_True;
1021     }
1022 
1023     if( bMenuOptModified )
1024     {
1025 		// Set changed settings to the application instance
1026 		AllSettings aAllSettings = Application::GetSettings();
1027         StyleSettings aStyleSettings = aAllSettings.GetStyleSettings();
1028         if( m_aSystemFont.IsEnabled() )
1029             aStyleSettings.SetUseSystemUIFonts( m_aSystemFont.IsChecked() );
1030         aAllSettings.SetStyleSettings(aStyleSettings);
1031         Application::MergeSystemSettings( aAllSettings );
1032 		Application::SetSettings(aAllSettings);
1033     }
1034 
1035     if ( bAppearanceChanged )
1036     {
1037         pAppearanceCfg->Commit();
1038         pAppearanceCfg->SetApplicationDefaults ( GetpApp() );
1039     }
1040 
1041 	if(bRepaintWindows)
1042 	{
1043 		Window* pAppWindow = Application::GetFirstTopLevelWindow();
1044 
1045 		while(pAppWindow)
1046 		{
1047 			pAppWindow->Invalidate();
1048 			pAppWindow = Application::GetNextTopLevelWindow(pAppWindow);
1049 		}
1050 	}
1051 
1052     return bModified;
1053 }
1054 
1055 /*-----------------06.12.96 11.50-------------------
1056 
1057 --------------------------------------------------*/
1058 void OfaViewTabPage::Reset( const SfxItemSet& )
1059 {
1060     SvtMiscOptions aMiscOptions;
1061 
1062     if( aMiscOptions.GetSymbolsSize() != SFX_SYMBOLS_SIZE_AUTO )
1063         nSizeLB_InitialSelection = ( aMiscOptions.AreCurrentSymbolsLarge() )? 2 : 1;
1064     aIconSizeLB.SelectEntryPos( nSizeLB_InitialSelection );
1065     aIconSizeLB.SaveValue();
1066 
1067     if( aMiscOptions.GetSymbolsStyle() != STYLE_SYMBOLS_AUTO )
1068         nStyleLB_InitialSelection = aIconStyleItemId[aMiscOptions.GetCurrentSymbolsStyle()];
1069 
1070     aIconStyleLB.SelectEntryPos( nStyleLB_InitialSelection );
1071     aIconStyleLB.SaveValue();
1072 
1073     if( m_aSystemFont.IsEnabled() )
1074     {
1075         SvtAccessibilityOptions aAccessibilityOptions;
1076         m_aSystemFont.Check( aAccessibilityOptions.GetIsSystemFont() );
1077     }
1078 
1079 	// Screen Scaling
1080     aWindowSizeMF.SetValue ( pAppearanceCfg->GetScaleFactor() );
1081 	// Mouse Snap
1082     aMousePosLB.SelectEntryPos(pAppearanceCfg->GetSnapMode());
1083     aMousePosLB.SaveValue();
1084 
1085     // Mouse Snap
1086     aMouseMiddleLB.SelectEntryPos(pAppearanceCfg->GetMiddleMouseButton());
1087     aMouseMiddleLB.SaveValue();
1088 
1089 #if defined( UNX )
1090     aFontAntiAliasing.Check( pAppearanceCfg->IsFontAntiAliasing() );
1091     aAAPointLimit.SetValue( pAppearanceCfg->GetFontAntialiasingMinPixelHeight() );
1092 #endif
1093 
1094     // WorkingSet
1095     SvtFontOptions aFontOpt;
1096 	aFontShowCB.Check( aFontOpt.IsFontWYSIWYGEnabled() );
1097     SvtMenuOptions aMenuOpt;
1098     aMenuIconsLB.SelectEntryPos(aMenuOpt.GetMenuIconsState() == 2 ? 0 : aMenuOpt.GetMenuIconsState() + 1);
1099     aMenuIconsLB.SaveValue();
1100     aFontHistoryCB.Check( aFontOpt.IsFontHistoryEnabled() );
1101 
1102     { // #i95644# HW accel (unified to disable mechanism)
1103         if(pCanvasSettings->IsHardwareAccelerationAvailable())
1104         {
1105             aUseHardwareAccell.Check(pCanvasSettings->IsHardwareAccelerationEnabled());
1106         }
1107         else
1108         {
1109             aUseHardwareAccell.Check(false);
1110 		    aUseHardwareAccell.Disable();
1111         }
1112 
1113         aUseHardwareAccell.SaveValue();
1114     }
1115 
1116     { // #i95644# AntiAliasing
1117 	    if(mpDrawinglayerOpt->IsAAPossibleOnThisSystem())
1118         {
1119 	        aUseAntiAliase.Check(mpDrawinglayerOpt->IsAntiAliasing());
1120         }
1121         else
1122 	    {
1123             aUseAntiAliase.Check(false);
1124 		    aUseAntiAliase.Disable();
1125 	    }
1126 
1127         aUseAntiAliase.SaveValue();
1128     }
1129 
1130 	{
1131         // #i97672# Selection
1132         // check if transparent selection is possible on this system
1133         const bool bTransparentSelectionPossible(
1134             !GetSettings().GetStyleSettings().GetHighContrastMode()
1135             && supportsOperation(OutDevSupport_TransparentRect));
1136 
1137         // enter values
1138         if(bTransparentSelectionPossible)
1139         {
1140             maSelectionCB.Check(mpDrawinglayerOpt->IsTransparentSelection());
1141         }
1142         else
1143         {
1144             maSelectionCB.Enable(false);
1145         }
1146 
1147         maSelectionMF.SetValue(mpDrawinglayerOpt->GetTransparentSelectionPercent());
1148 		maSelectionMF.Enable(mpDrawinglayerOpt->IsTransparentSelection() && bTransparentSelectionPossible);
1149     }
1150 
1151 #if defined( UNX )
1152 	aFontAntiAliasing.SaveValue();
1153 	aAAPointLimit.SaveValue();
1154 #endif
1155 	aFontShowCB.SaveValue();
1156 	aFontHistoryCB.SaveValue();
1157 
1158 #if defined( UNX )
1159 	LINK( this, OfaViewTabPage, OnAntialiasingToggled ).Call( NULL );
1160 #endif
1161 }
1162 /* -----------------22.07.2003 10:33-----------------
1163 
1164  --------------------------------------------------*/
1165 struct LanguageConfig_Impl
1166 {
1167     SvtLanguageOptions aLanguageOptions;
1168     SvtSysLocaleOptions aSysLocaleOptions;
1169     SvtLinguConfig aLinguConfig;
1170 };
1171 /* -----------------------------23.11.00 13:06--------------------------------
1172 
1173  ---------------------------------------------------------------------------*/
1174 static sal_Bool bLanguageCurrentDoc_Impl = sal_False;
1175 
1176 // some things we'll need...
1177 static const OUString sConfigSrvc = OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider");
1178 static const OUString sAccessSrvc = OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess");
1179 static const OUString sAccessUpdSrvc = OUString::createFromAscii("com.sun.star.configuration.ConfigurationUpdateAccess");
1180 static const OUString sInstalledLocalesPath = OUString::createFromAscii("org.openoffice.Setup/Office/InstalledLocales");
1181 static OUString sUserLocalePath = OUString::createFromAscii("org.openoffice.Office.Linguistic/General");
1182 //static const OUString sUserLocalePath = OUString::createFromAscii("org.openoffice.Office/Linguistic");
1183 static const OUString sUserLocaleKey = OUString::createFromAscii("UILocale");
1184 static const OUString sSystemLocalePath = OUString::createFromAscii("org.openoffice.System/L10N");
1185 static const OUString sSystemLocaleKey = OUString::createFromAscii("UILocale");
1186 static const OUString sOfficeLocalePath = OUString::createFromAscii("org.openoffice.Office/L10N");
1187 static const OUString sOfficeLocaleKey = OUString::createFromAscii("ooLocale");
1188 static Sequence< OUString > seqInstalledLanguages;
1189 
1190 OfaLanguagesTabPage::OfaLanguagesTabPage( Window* pParent, const SfxItemSet& rSet ) :
1191 	SfxTabPage( pParent, CUI_RES( OFA_TP_LANGUAGES ), rSet ),
1192 	aUILanguageGB(this, 		CUI_RES(FL_UI_LANG		)),
1193     aLocaleSettingFI(this,      CUI_RES(FI_LOCALESETTING)),
1194     aUserInterfaceFT(this,      CUI_RES(FT_USERINTERFACE)),
1195     aUserInterfaceLB(this,      CUI_RES(LB_USERINTERFACE)),
1196     aLocaleSettingFT(this,      CUI_RES(FT_LOCALESETTING)),
1197     aLocaleSettingLB(this,      CUI_RES(LB_LOCALESETTING)),
1198     aCurrencyFI( this,          CUI_RES(FI_CURRENCY       )),
1199     aDecimalSeparatorFT(this,   CUI_RES(FT_DECIMALSEPARATOR)),
1200     aDecimalSeparatorCB(this,   CUI_RES(CB_DECIMALSEPARATOR)),
1201     aCurrencyFT( this,          CUI_RES(FT_CURRENCY       )),
1202     aCurrencyLB( this,          CUI_RES(LB_CURRENCY       )),
1203 	aLinguLanguageGB(this, 		CUI_RES(FL_LINGU_LANG		)),
1204     aWesternLanguageFI(this,    CUI_RES(FI_WEST_LANG      )),
1205     aWesternLanguageFT(this,    CUI_RES(FT_WEST_LANG      )),
1206 	aWesternLanguageLB(this, 	CUI_RES(LB_WEST_LANG		)),
1207     aAsianLanguageFI(this,      CUI_RES(FI_ASIAN_LANG     )),
1208     aAsianLanguageFT(this,      CUI_RES(FT_ASIAN_LANG     )),
1209 	aAsianLanguageLB(this, 		CUI_RES(LB_ASIAN_LANG		)),
1210     aComplexLanguageFI(this,    CUI_RES(FI_COMPLEX_LANG   )),
1211     aComplexLanguageFT(this,    CUI_RES(FT_COMPLEX_LANG   )),
1212 	aComplexLanguageLB(this, 	CUI_RES(LB_COMPLEX_LANG	)),
1213 	aCurrentDocCB(this, 		CUI_RES(CB_CURRENT_DOC	)),
1214     aEnhancedFL(this,           CUI_RES(FL_ENHANCED    )),
1215     aAsianSupportFI(this,       CUI_RES(FI_ASIANSUPPORT   )),
1216     aAsianSupportCB(this,       CUI_RES(CB_ASIANSUPPORT   )),
1217     aCTLSupportFI(this,         CUI_RES(FI_CTLSUPPORT    )),
1218     aCTLSupportCB(this,         CUI_RES(CB_CTLSUPPORT   )),
1219     sDecimalSeparatorLabel(aDecimalSeparatorCB.GetText()),
1220     pLangConfig(new LanguageConfig_Impl)
1221 {
1222     FreeResource();
1223 
1224     // initialize user interface language selection
1225     SvtLanguageTable* pLanguageTable = new SvtLanguageTable;
1226     const String aStr( pLanguageTable->GetString( LANGUAGE_SYSTEM ) );
1227 
1228     String aUILang(aStr);
1229     aUILang += String::CreateFromAscii(" - ");
1230     aUILang += pLanguageTable->GetString( Application::GetSettings().GetUILanguage() );
1231 
1232     aUserInterfaceLB.InsertEntry(aUILang);
1233     aUserInterfaceLB.SetEntryData(0, 0);
1234     aUserInterfaceLB.SelectEntryPos(0);
1235     try
1236     {
1237         OUString sOfficeLocaleValue;
1238         OUString sSystemLocaleValue;
1239 
1240         Reference< XMultiServiceFactory > theMSF = comphelper::getProcessServiceFactory();
1241         Reference< XMultiServiceFactory > theConfigProvider = Reference< XMultiServiceFactory > (
1242             theMSF->createInstance( sConfigSrvc ),UNO_QUERY_THROW);
1243         Sequence< Any > theArgs(2);
1244         Reference< XNameAccess > theNameAccess;
1245 
1246         // find out which locales are currently installed and add them to the listbox
1247         theArgs[0] = makeAny(NamedValue(OUString::createFromAscii("NodePath"), makeAny(sInstalledLocalesPath)));
1248         theArgs[1] = makeAny(NamedValue(OUString::createFromAscii("reload"), makeAny(sal_True)));
1249 	theNameAccess = Reference< XNameAccess > (
1250             theConfigProvider->createInstanceWithArguments(sAccessSrvc, theArgs ), UNO_QUERY_THROW );
1251         seqInstalledLanguages = theNameAccess->getElementNames();
1252         LanguageType aLang = LANGUAGE_DONTKNOW;
1253         for (sal_Int32 i=0; i<seqInstalledLanguages.getLength(); i++)
1254         {
1255             aLang = MsLangId::convertIsoStringToLanguage(seqInstalledLanguages[i]);
1256             if (aLang != LANGUAGE_DONTKNOW)
1257             {
1258                 //sal_uInt16 p = aUserInterfaceLB.InsertLanguage(aLang);
1259                 String aLangStr( pLanguageTable->GetString( aLang ) );
1260                 sal_uInt16 p = aUserInterfaceLB.InsertEntry(aLangStr);
1261                 aUserInterfaceLB.SetEntryData(p, (void*)(i+1));
1262             }
1263         }
1264 
1265         // find out whether the user has a specific locale specified
1266         Sequence< Any > theArgs2(1);
1267         theArgs2[0] = makeAny(NamedValue(OUString::createFromAscii("NodePath"), makeAny(sUserLocalePath)));
1268         theNameAccess = Reference< XNameAccess > (
1269             theConfigProvider->createInstanceWithArguments(sAccessSrvc, theArgs2 ), UNO_QUERY_THROW );
1270         if (theNameAccess->hasByName(sUserLocaleKey))
1271             theNameAccess->getByName(sUserLocaleKey) >>= m_sUserLocaleValue;
1272         // select the user specified locale in the listbox
1273         if (m_sUserLocaleValue.getLength() > 0)
1274         {
1275             sal_Int32 d = 0;
1276             for (sal_uInt16 i=0; i < aUserInterfaceLB.GetEntryCount(); i++)
1277             {
1278                 d = (sal_Int32)(sal_IntPtr)aUserInterfaceLB.GetEntryData(i);
1279                 if ( d > 0 && seqInstalledLanguages.getLength() > d-1 && seqInstalledLanguages[d-1].equals(m_sUserLocaleValue))
1280                     aUserInterfaceLB.SelectEntryPos(i);
1281             }
1282         }
1283 
1284     }
1285     catch (Exception &e)
1286     {
1287         // we'll just leave the box in it's default setting and won't
1288         // even give it event handler...
1289         OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US);
1290         OSL_ENSURE(sal_False, aMsg.getStr());
1291     }
1292 
1293     aWesternLanguageLB.SetLanguageList( LANG_LIST_WESTERN | LANG_LIST_ONLY_KNOWN, sal_True,  sal_False, sal_True );
1294     aWesternLanguageLB.InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::LATIN );
1295     aAsianLanguageLB.SetLanguageList( LANG_LIST_CJK     | LANG_LIST_ONLY_KNOWN, sal_True,  sal_False, sal_True );
1296     aAsianLanguageLB.InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::ASIAN );
1297     aComplexLanguageLB.SetLanguageList( LANG_LIST_CTL     | LANG_LIST_ONLY_KNOWN, sal_True,  sal_False, sal_True );
1298     aComplexLanguageLB.InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::COMPLEX );
1299 
1300     aLocaleSettingLB.SetLanguageList( LANG_LIST_ALL     | LANG_LIST_ONLY_KNOWN, sal_False, sal_False, sal_False);
1301     aLocaleSettingLB.InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::WEAK );
1302 
1303     const NfCurrencyTable& rCurrTab = SvNumberFormatter::GetTheCurrencyTable();
1304     const NfCurrencyEntry& rCurr = SvNumberFormatter::GetCurrencyEntry( LANGUAGE_SYSTEM );
1305     // insert SYSTEM entry
1306     String aDefaultCurr(aStr);
1307     aDefaultCurr += String::CreateFromAscii(" - ");
1308     aDefaultCurr += rCurr.GetBankSymbol();
1309     aCurrencyLB.InsertEntry( aDefaultCurr );
1310     // all currencies
1311     String aTwoSpace( RTL_CONSTASCII_USTRINGPARAM( "  " ) );
1312     sal_uInt16 nCurrCount = rCurrTab.Count();
1313     // first entry is SYSTEM, skip it
1314     for ( sal_uInt16 j=1; j < nCurrCount; ++j )
1315     {
1316         const NfCurrencyEntry* pCurr = rCurrTab[j];
1317         String aStr_( pCurr->GetBankSymbol() );
1318         aStr_ += aTwoSpace;
1319         aStr_ += pCurr->GetSymbol();
1320         aStr_ = ApplyLreOrRleEmbedding( aStr_ );
1321         aStr_ += aTwoSpace;
1322         aStr_ += ApplyLreOrRleEmbedding( pLanguageTable->GetString( pCurr->GetLanguage() ) );
1323         sal_uInt16 nPos = aCurrencyLB.InsertEntry( aStr_ );
1324         aCurrencyLB.SetEntryData( nPos, (void*) pCurr );
1325     }
1326     delete pLanguageTable;
1327 
1328     aLocaleSettingLB.SetSelectHdl( LINK( this, OfaLanguagesTabPage, LocaleSettingHdl ) );
1329 	Link aLink( LINK( this, OfaLanguagesTabPage, SupportHdl ) );
1330 	aAsianSupportCB.SetClickHdl( aLink );
1331     aCTLSupportCB.SetClickHdl( aLink );
1332 
1333     aAsianSupportCB.Check( m_bOldAsian = pLangConfig->aLanguageOptions.IsAnyEnabled() );
1334     aAsianSupportCB.SaveValue();
1335     sal_Bool bReadonly = pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_ALLCJK);
1336     aAsianSupportCB.Enable(!bReadonly);
1337     aAsianSupportFI.Show(bReadonly);
1338     SupportHdl( &aAsianSupportCB );
1339 
1340     aCTLSupportCB.Check( m_bOldCtl = pLangConfig->aLanguageOptions.IsCTLFontEnabled() );
1341     aCTLSupportCB.SaveValue();
1342     bReadonly = pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_CTLFONT);
1343     aCTLSupportCB.Enable(!bReadonly);
1344     aCTLSupportFI.Show(bReadonly);
1345     SupportHdl( &aCTLSupportCB );
1346 }
1347 /*-- 23.11.00 13:06:40---------------------------------------------------
1348 
1349   -----------------------------------------------------------------------*/
1350 OfaLanguagesTabPage::~OfaLanguagesTabPage()
1351 {
1352     delete pLangConfig;
1353 }
1354 /*-- 23.11.00 13:06:40---------------------------------------------------
1355 
1356   -----------------------------------------------------------------------*/
1357 SfxTabPage*	OfaLanguagesTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
1358 {
1359 	return new OfaLanguagesTabPage(pParent, rAttrSet);
1360 }
1361 /*-- 23.11.00 13:06:41---------------------------------------------------
1362 
1363   -----------------------------------------------------------------------*/
1364 LanguageType lcl_LangStringToLangType(const OUString& rLang)
1365 {
1366 	Locale aLocale;
1367     sal_Int32 nSep = rLang.indexOf('-');
1368     if (nSep < 0)
1369         aLocale.Language = rLang;
1370     else
1371     {
1372         aLocale.Language = rLang.copy(0, nSep);
1373         if (nSep < rLang.getLength())
1374             aLocale.Country = rLang.copy(nSep+1, rLang.getLength() - (nSep+1));
1375     }
1376 	LanguageType eLangType = SvxLocaleToLanguage( aLocale );
1377 	return eLangType;
1378 }
1379 
1380 /*-- 23.11.00 13:06:40---------------------------------------------------
1381 
1382   -----------------------------------------------------------------------*/
1383 void lcl_UpdateAndDelete(SfxVoidItem* pInvalidItems[], SfxBoolItem* pBoolItems[], sal_uInt16 nCount)
1384 {
1385     SfxViewFrame* pCurrentFrm = SfxViewFrame::Current();
1386     SfxViewFrame* pViewFrm = SfxViewFrame::GetFirst();
1387     while(pViewFrm)
1388     {
1389         SfxBindings& rBind = pViewFrm->GetBindings();
1390         for(sal_Int16 i = 0; i < nCount; i++)
1391         {
1392             if(pCurrentFrm == pViewFrm)
1393                 rBind.InvalidateAll(sal_False);
1394             rBind.SetState( *pInvalidItems[i] );
1395             rBind.SetState( *pBoolItems[i] );
1396         }
1397         pViewFrm = SfxViewFrame::GetNext(*pViewFrm);
1398     }
1399     for(sal_Int16 i = 0; i < nCount; i++)
1400     {
1401         delete pInvalidItems[i];
1402         delete pBoolItems[i] ;
1403     }
1404 }
1405 
1406 sal_Bool OfaLanguagesTabPage::FillItemSet( SfxItemSet& rSet )
1407 {
1408 	// lock configuration broadcasters so that we can coordinate the notifications
1409 	pLangConfig->aSysLocaleOptions.BlockBroadcasts( sal_True );
1410     pLangConfig->aLanguageOptions.BlockBroadcasts( sal_True );
1411     pLangConfig->aLinguConfig.BlockBroadcasts( sal_True );
1412 
1413     if(aCTLSupportCB.IsChecked() &&
1414             (aCTLSupportCB.GetSavedValue() != aCTLSupportCB.IsChecked()) ||
1415             (aComplexLanguageLB.GetSavedValue() != aComplexLanguageLB.GetSelectEntryPos()))
1416     {
1417         //sequence checking has to be switched on depending on the selected CTL language
1418         LanguageType eCTLLang = aComplexLanguageLB.GetSelectLanguage();
1419         sal_Bool bOn = MsLangId::needsSequenceChecking( eCTLLang);
1420         pLangConfig->aLanguageOptions.SetCTLSequenceCheckingRestricted(bOn);
1421         pLangConfig->aLanguageOptions.SetCTLSequenceChecking(bOn);
1422         pLangConfig->aLanguageOptions.SetCTLSequenceCheckingTypeAndReplace(bOn);
1423     }
1424     try
1425     {
1426         // handle settings for UI Language
1427         // a change of setting needs to bring up a warning message
1428         OUString aLangString;
1429         sal_Int32 d = (sal_Int32)(sal_IntPtr)aUserInterfaceLB.GetEntryData(aUserInterfaceLB.GetSelectEntryPos());
1430         if( d > 0 && seqInstalledLanguages.getLength() > d-1)
1431             aLangString = seqInstalledLanguages[d-1];
1432 
1433         /*
1434         if( aUserInterfaceLB.GetSelectEntryPos() > 0)
1435             aLangString = ConvertLanguageToIsoString(aUserInterfaceLB.GetSelectLanguage());
1436         */
1437         Reference< XMultiServiceFactory > theMSF = comphelper::getProcessServiceFactory();
1438         Reference< XMultiServiceFactory > theConfigProvider = Reference< XMultiServiceFactory > (
1439             theMSF->createInstance( sConfigSrvc ),UNO_QUERY_THROW);
1440         Sequence< Any > theArgs(1);
1441         theArgs[0] = makeAny(sUserLocalePath);
1442         Reference< XPropertySet >xProp(
1443             theConfigProvider->createInstanceWithArguments(sAccessUpdSrvc, theArgs ), UNO_QUERY_THROW );
1444         if ( !m_sUserLocaleValue.equals(aLangString))
1445         {
1446             // OSL_ENSURE(sal_False, "UserInterface language was changed, restart.");
1447             // write new value
1448             xProp->setPropertyValue(sUserLocaleKey, makeAny(aLangString));
1449             Reference< XChangesBatch >(xProp, UNO_QUERY_THROW)->commitChanges();
1450             // display info
1451             InfoBox aBox(this, CUI_RES(RID_SVX_MSGBOX_LANGUAGE_RESTART));
1452             aBox.Execute();
1453 
1454             // tell quickstarter to stop being a veto listener
1455 
1456             Reference< XInitialization > xInit(theMSF->createInstance(
1457                 OUString::createFromAscii("com.sun.star.office.Quickstart")), UNO_QUERY);
1458             if (xInit.is())
1459             {
1460                 Sequence< Any > args(3);
1461                 args[0] = makeAny(sal_False); // will be ignored
1462                 args[1] = makeAny(sal_False); // will be ignored
1463                 args[2] = makeAny(sal_False); // disable veto
1464                 xInit->initialize(args);
1465             }
1466         }
1467     }
1468     catch (Exception& e)
1469     {
1470         // we'll just leave the box in it's default setting and won't
1471         // even give it event handler...
1472         OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US);
1473         OSL_ENSURE(sal_False, aMsg.getStr());
1474     }
1475 
1476     OUString sLang = pLangConfig->aSysLocaleOptions.GetLocaleConfigString();
1477     LanguageType eOldLocale = (sLang.getLength() ?
1478         lcl_LangStringToLangType( sLang ) : LANGUAGE_SYSTEM);
1479     LanguageType eNewLocale = aLocaleSettingLB.GetSelectLanguage();
1480     if ( eOldLocale != eNewLocale )
1481     {
1482         // an empty string denotes SYSTEM locale
1483         OUString sNewLang;
1484         if ( eNewLocale != LANGUAGE_SYSTEM )
1485         {
1486             Locale aLocale;
1487             SvxLanguageToLocale( aLocale, eNewLocale );
1488             sNewLang = aLocale.Language;
1489             if ( aLocale.Country.getLength() > 0 )
1490             {
1491                 sNewLang += C2U("-");
1492                 sNewLang += aLocale.Country;
1493             }
1494         }
1495 
1496 		// locale nowadays get to AppSettings via notification
1497 		// this will happen after releasing the lock on the ConfigurationBroadcaster at
1498 		// the end of this method
1499 		pLangConfig->aSysLocaleOptions.SetLocaleConfigString( sNewLang );
1500         rSet.Put( SfxBoolItem( SID_OPT_LOCALE_CHANGED, sal_True ) );
1501     }
1502 
1503     if(aDecimalSeparatorCB.GetSavedValue() != aDecimalSeparatorCB.IsChecked())
1504         pLangConfig->aSysLocaleOptions.SetDecimalSeparatorAsLocale(aDecimalSeparatorCB.IsChecked());
1505 
1506     // Configured currency, for example, USD-en-US or EUR-de-DE, or empty for locale default.
1507     OUString sOldCurr = pLangConfig->aSysLocaleOptions.GetCurrencyConfigString();
1508     sal_uInt16 nCurrPos = aCurrencyLB.GetSelectEntryPos();
1509     const NfCurrencyEntry* pCurr = (const NfCurrencyEntry*)
1510         aCurrencyLB.GetEntryData( nCurrPos );
1511     OUString sNewCurr;
1512     if ( pCurr )
1513         sNewCurr = SvtSysLocaleOptions::CreateCurrencyConfigString(
1514             pCurr->GetBankSymbol(), pCurr->GetLanguage() );
1515     if ( sOldCurr != sNewCurr )
1516         pLangConfig->aSysLocaleOptions.SetCurrencyConfigString( sNewCurr );
1517 
1518     sal_Bool bRet = sal_False;
1519 	SfxObjectShell* pCurrentDocShell = SfxObjectShell::Current();
1520 	Reference< XPropertySet > xLinguProp( LinguMgr::GetLinguPropertySet(), UNO_QUERY );
1521 	sal_Bool bCurrentDocCBChecked = aCurrentDocCB.IsChecked();
1522     if(aCurrentDocCB.IsEnabled())
1523         bLanguageCurrentDoc_Impl = bCurrentDocCBChecked;
1524 	sal_Bool bCurrentDocCBChanged = bCurrentDocCBChecked != aCurrentDocCB.GetSavedValue();
1525 
1526 	sal_Bool bValChanged = aWesternLanguageLB.GetSavedValue() != aWesternLanguageLB.GetSelectEntryPos();
1527 	if( (bCurrentDocCBChanged && !bCurrentDocCBChecked) || bValChanged)
1528 	{
1529 		LanguageType eSelectLang = aWesternLanguageLB.GetSelectLanguage();
1530 		if(!bCurrentDocCBChecked)
1531 		{
1532 			Any aValue;
1533 			Locale aLocale = MsLangId::convertLanguageToLocale( eSelectLang, false );
1534 			aValue <<= aLocale;
1535 			OUString aPropName( C2U("DefaultLocale") );
1536             pLangConfig->aLinguConfig.SetProperty( aPropName, aValue );
1537             if (xLinguProp.is())
1538 				xLinguProp->setPropertyValue( aPropName, aValue );
1539 		}
1540 		if(pCurrentDocShell)
1541 		{
1542 			rSet.Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, ::com::sun::star::i18n::ScriptType::LATIN),
1543                 SID_ATTR_LANGUAGE));
1544 			bRet = sal_True;
1545 		}
1546 	}
1547 	bValChanged = aAsianLanguageLB.GetSavedValue() != aAsianLanguageLB.GetSelectEntryPos();
1548 	if( (bCurrentDocCBChanged && !bCurrentDocCBChecked) || bValChanged)
1549 	{
1550 		LanguageType eSelectLang = aAsianLanguageLB.GetSelectLanguage();
1551 		if(!bCurrentDocCBChecked)
1552 		{
1553 			Any aValue;
1554 			Locale aLocale = MsLangId::convertLanguageToLocale( eSelectLang, false );
1555 			aValue <<= aLocale;
1556 			OUString aPropName( C2U("DefaultLocale_CJK") );
1557             pLangConfig->aLinguConfig.SetProperty( aPropName, aValue );
1558             if (xLinguProp.is())
1559 				xLinguProp->setPropertyValue( aPropName, aValue );
1560 		}
1561 		if(pCurrentDocShell)
1562 		{
1563 			rSet.Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, ::com::sun::star::i18n::ScriptType::ASIAN),
1564 				SID_ATTR_CHAR_CJK_LANGUAGE));
1565 			bRet = sal_True;
1566 		}
1567 	}
1568 	bValChanged = aComplexLanguageLB.GetSavedValue() != aComplexLanguageLB.GetSelectEntryPos();
1569 	if( (bCurrentDocCBChanged && !bCurrentDocCBChecked) || bValChanged)
1570 	{
1571 		LanguageType eSelectLang = aComplexLanguageLB.GetSelectLanguage();
1572 		if(!bCurrentDocCBChecked)
1573 		{
1574 			Any aValue;
1575 			Locale aLocale = MsLangId::convertLanguageToLocale( eSelectLang, false );
1576 			aValue <<= aLocale;
1577 			OUString aPropName( C2U("DefaultLocale_CTL") );
1578             pLangConfig->aLinguConfig.SetProperty( aPropName, aValue );
1579             if (xLinguProp.is())
1580 				xLinguProp->setPropertyValue( aPropName, aValue );
1581 		}
1582 		if(pCurrentDocShell)
1583 		{
1584 			rSet.Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, ::com::sun::star::i18n::ScriptType::COMPLEX),
1585 				SID_ATTR_CHAR_CTL_LANGUAGE));
1586 			bRet = sal_True;
1587 		}
1588 	}
1589 
1590     if(aAsianSupportCB.GetSavedValue() != aAsianSupportCB.IsChecked() )
1591     {
1592         sal_Bool bChecked = aAsianSupportCB.IsChecked();
1593         pLangConfig->aLanguageOptions.SetAll(bChecked);
1594 
1595         //iterate over all bindings to invalidate vertical text direction
1596 		const sal_uInt16 STATE_COUNT = 2;
1597 
1598         SfxBoolItem* pBoolItems[STATE_COUNT];
1599         pBoolItems[0] = new SfxBoolItem(SID_VERTICALTEXT_STATE, sal_False);
1600         pBoolItems[1] = new SfxBoolItem(SID_TEXT_FITTOSIZE_VERTICAL, sal_False);
1601 
1602         SfxVoidItem* pInvalidItems[STATE_COUNT];
1603         pInvalidItems[0] = new SfxVoidItem(SID_VERTICALTEXT_STATE);
1604         pInvalidItems[1] = new SfxVoidItem(SID_TEXT_FITTOSIZE_VERTICAL);
1605 
1606 	    lcl_UpdateAndDelete(pInvalidItems, pBoolItems, STATE_COUNT);
1607     }
1608 
1609 	if ( aCTLSupportCB.GetSavedValue() != aCTLSupportCB.IsChecked() )
1610     {
1611         pLangConfig->aLanguageOptions.SetCTLFontEnabled( aCTLSupportCB.IsChecked() );
1612 
1613         const sal_uInt16 STATE_COUNT = 1;
1614         SfxBoolItem* pBoolItems[STATE_COUNT];
1615         pBoolItems[0] = new SfxBoolItem(SID_CTLFONT_STATE, sal_False);
1616         SfxVoidItem* pInvalidItems[STATE_COUNT];
1617         pInvalidItems[0] = new SfxVoidItem(SID_CTLFONT_STATE);
1618         lcl_UpdateAndDelete(pInvalidItems, pBoolItems, STATE_COUNT);
1619     }
1620 
1621     if ( pLangConfig->aSysLocaleOptions.IsModified() )
1622         pLangConfig->aSysLocaleOptions.Commit();
1623 
1624 	// first release the lock on the ConfigurationBroadcaster for Locale changes
1625 	// it seems that our code relies on the fact that before other changes like e.g. currency
1626 	// are broadcasted locale changes have been done
1627 	pLangConfig->aSysLocaleOptions.BlockBroadcasts( sal_False );
1628     pLangConfig->aLanguageOptions.BlockBroadcasts( sal_False );
1629     pLangConfig->aLinguConfig.BlockBroadcasts( sal_False );
1630 
1631 	return sal_False;
1632 }
1633 //-----------------------------------------------------------------------------
1634 void OfaLanguagesTabPage::Reset( const SfxItemSet& rSet )
1635 {
1636     OUString sLang = pLangConfig->aSysLocaleOptions.GetLocaleConfigString();
1637     if ( sLang.getLength() )
1638         aLocaleSettingLB.SelectLanguage(lcl_LangStringToLangType(sLang));
1639     else
1640         aLocaleSettingLB.SelectLanguage( LANGUAGE_SYSTEM );
1641     sal_Bool bReadonly = pLangConfig->aSysLocaleOptions.IsReadOnly(SvtSysLocaleOptions::E_LOCALE);
1642     aLocaleSettingLB.Enable(!bReadonly);
1643     aLocaleSettingFT.Enable(!bReadonly);
1644     aLocaleSettingFI.Show(bReadonly);
1645 
1646     //
1647     aDecimalSeparatorCB.Check( pLangConfig->aSysLocaleOptions.IsDecimalSeparatorAsLocale());
1648     aDecimalSeparatorCB.SaveValue();
1649 
1650     // let LocaleSettingHdl enable/disable checkboxes for CJK/CTL support
1651     // #i15812# must be done *before* the configured currency is set
1652     // and update the decimal separator used for the given locale
1653     LocaleSettingHdl(&aLocaleSettingLB);
1654 
1655     // configured currency, for example, USD-en-US or EUR-de-DE, or empty for locale default
1656     String aAbbrev;
1657     LanguageType eLang;
1658     const NfCurrencyEntry* pCurr = NULL;
1659     sLang = pLangConfig->aSysLocaleOptions.GetCurrencyConfigString();
1660     if ( sLang.getLength() )
1661     {
1662         SvtSysLocaleOptions::GetCurrencyAbbrevAndLanguage( aAbbrev, eLang, sLang );
1663         pCurr = SvNumberFormatter::GetCurrencyEntry( aAbbrev, eLang );
1664     }
1665     // if pCurr==NULL the SYSTEM entry is selected
1666     sal_uInt16 nPos = aCurrencyLB.GetEntryPos( (void*) pCurr );
1667     aCurrencyLB.SelectEntryPos( nPos );
1668     bReadonly = pLangConfig->aSysLocaleOptions.IsReadOnly(SvtSysLocaleOptions::E_CURRENCY);
1669     aCurrencyLB.Enable(!bReadonly);
1670     aCurrencyFT.Enable(!bReadonly);
1671     aCurrencyFI.Show(bReadonly);
1672 
1673 	//western/CJK/CLK language
1674 	LanguageType eCurLang = LANGUAGE_NONE;
1675 	LanguageType eCurLangCJK = LANGUAGE_NONE;
1676 	LanguageType eCurLangCTL = LANGUAGE_NONE;
1677 	SfxObjectShell* pCurrentDocShell = SfxObjectShell::Current();
1678     //collect the configuration values first
1679     aCurrentDocCB.Enable(sal_False);
1680     //
1681     Any aWestLang;
1682     Any aCJKLang;
1683     Any aCTLLang;
1684     try
1685     {
1686         aWestLang = pLangConfig->aLinguConfig.GetProperty(C2U("DefaultLocale"));
1687         Locale aLocale;
1688         aWestLang >>= aLocale;
1689 
1690         eCurLang = MsLangId::convertLocaleToLanguage( aLocale );
1691 
1692         aCJKLang = pLangConfig->aLinguConfig.GetProperty(C2U("DefaultLocale_CJK"));
1693         aLocale = Locale();
1694         aCJKLang >>= aLocale;
1695         eCurLangCJK = MsLangId::convertLocaleToLanguage( aLocale );
1696 
1697         aCTLLang = pLangConfig->aLinguConfig.GetProperty(C2U("DefaultLocale_CTL"));
1698         aLocale = Locale();
1699         aCTLLang >>= aLocale;
1700         eCurLangCTL = MsLangId::convertLocaleToLanguage( aLocale );
1701     }
1702     catch(Exception&)
1703     {
1704     }
1705     //overwrite them by the values provided by the DocShell
1706     if(pCurrentDocShell)
1707 	{
1708         aCurrentDocCB.Enable(sal_True);
1709         aCurrentDocCB.Check(bLanguageCurrentDoc_Impl);
1710 		const SfxPoolItem* pLang;
1711 		if( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_LANGUAGE, sal_False, &pLang))
1712 		{
1713 			LanguageType eTempCurLang = ((const SvxLanguageItem*)pLang)->GetValue();
1714 			if (MsLangId::resolveSystemLanguageByScriptType(eCurLang, ::com::sun::star::i18n::ScriptType::LATIN) != eTempCurLang)
1715 				eCurLang = eTempCurLang;
1716 		}
1717 
1718 		if( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_CHAR_CJK_LANGUAGE, sal_False, &pLang))
1719 		{
1720 			LanguageType eTempCurLang = ((const SvxLanguageItem*)pLang)->GetValue();
1721 			if (MsLangId::resolveSystemLanguageByScriptType(eCurLangCJK, ::com::sun::star::i18n::ScriptType::ASIAN) != eTempCurLang)
1722 				eCurLangCJK = eTempCurLang;
1723 		}
1724 
1725 		if( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_CHAR_CTL_LANGUAGE, sal_False, &pLang))
1726 		{
1727 			LanguageType eTempCurLang = ((const SvxLanguageItem*)pLang)->GetValue();
1728 			if (MsLangId::resolveSystemLanguageByScriptType(eCurLangCTL, ::com::sun::star::i18n::ScriptType::COMPLEX) != eTempCurLang)
1729 				eCurLangCTL = eTempCurLang;
1730 		}
1731 	}
1732     if(LANGUAGE_NONE == eCurLang || LANGUAGE_DONTKNOW == eCurLang)
1733         aWesternLanguageLB.SelectLanguage(LANGUAGE_NONE);
1734 	else
1735 		aWesternLanguageLB.SelectLanguage(eCurLang);
1736 
1737     if(LANGUAGE_NONE == eCurLangCJK || LANGUAGE_DONTKNOW == eCurLangCJK)
1738         aAsianLanguageLB.SelectLanguage(LANGUAGE_NONE);
1739 	else
1740 		aAsianLanguageLB.SelectLanguage(eCurLangCJK);
1741 
1742     if(LANGUAGE_NONE == eCurLangCTL || LANGUAGE_DONTKNOW == eCurLangCTL)
1743         aComplexLanguageLB.SelectLanguage(LANGUAGE_NONE);
1744 	else
1745 		aComplexLanguageLB.SelectLanguage(eCurLangCTL);
1746 
1747 	aWesternLanguageLB.SaveValue();
1748 	aAsianLanguageLB.SaveValue();
1749 	aComplexLanguageLB.SaveValue();
1750 	aCurrentDocCB.SaveValue();
1751 
1752 	sal_Bool bEnable = !pLangConfig->aLinguConfig.IsReadOnly( C2U("DefaultLocale") );
1753     aWesternLanguageFT.Enable( bEnable );
1754     aWesternLanguageLB.Enable( bEnable );
1755 
1756 
1757     aWesternLanguageFI.Show(!bEnable);
1758 
1759     // #i15812# controls for CJK/CTL already enabled/disabled from LocaleSettingHdl
1760 #if 0
1761     bEnable = ( !pLangConfig->aLinguConfig.IsReadOnly( C2U("DefaultLocale_CJK") ) && aAsianSupportCB.IsChecked() );
1762     aAsianLanguageFT.Enable( bEnable );
1763 	aAsianLanguageLB.Enable( bEnable );
1764 
1765     bEnable = ( !pLangConfig->aLinguConfig.IsReadOnly( C2U("DefaultLocale_CTL") ) && aCTLSupportCB.IsChecked() );
1766     aComplexLanguageFT.Enable( bEnable );
1767 	aComplexLanguageLB.Enable( bEnable );
1768 #endif
1769 	/*---------------------07-05-07--------------------------
1770 	check the box "For the current document only"
1771 	set the focus to the Western Language box
1772 	--------------------------------------------------------*/
1773     const SfxPoolItem* pLang = 0;
1774     if ( SFX_ITEM_SET == rSet.GetItemState(SID_SET_DOCUMENT_LANGUAGE, sal_False, &pLang ) &&( (const SfxBoolItem*)pLang)->GetValue() == sal_True )
1775 	{
1776 		aWesternLanguageLB.GrabFocus();
1777 		aCurrentDocCB.Enable(sal_True);
1778 		aCurrentDocCB.Check(sal_True);
1779 	}
1780 }
1781 /* -----------------------------20.04.01 15:09--------------------------------
1782 
1783  ---------------------------------------------------------------------------*/
1784 IMPL_LINK(  OfaLanguagesTabPage, SupportHdl, CheckBox*, pBox )
1785 {
1786 	DBG_ASSERT( pBox, "OfaLanguagesTabPage::SupportHdl(): pBox invalid" );
1787 
1788     sal_Bool bCheck = pBox->IsChecked();
1789 	if ( &aAsianSupportCB == pBox )
1790 	{
1791         sal_Bool bReadonly = pLangConfig->aLinguConfig.IsReadOnly( C2U("DefaultLocale_CJK"));
1792         bCheck = ( bCheck && !bReadonly );
1793         aAsianLanguageFT.Enable( bCheck );
1794     	aAsianLanguageLB.Enable( bCheck );
1795         aAsianLanguageFI.Show(bReadonly);
1796         if( pBox->IsEnabled() )
1797             m_bOldAsian = bCheck;
1798 	}
1799 	else if ( &aCTLSupportCB == pBox )
1800 	{
1801         sal_Bool bReadonly = pLangConfig->aLinguConfig.IsReadOnly( C2U("DefaultLocale_CTL"));
1802         bCheck = ( bCheck && !bReadonly  );
1803         aComplexLanguageFT.Enable( bCheck );
1804     	aComplexLanguageLB.Enable( bCheck );
1805         aComplexLanguageFI.Show(bReadonly);
1806         if( pBox->IsEnabled() )
1807             m_bOldCtl = bCheck;
1808 	}
1809 	else
1810 	{
1811 		DBG_ERRORFILE( "OfaLanguagesTabPage::SupportHdl(): wrong pBox" );
1812 	}
1813 
1814     return 0;
1815 }
1816 
1817 namespace
1818 {
1819 	void lcl_checkLanguageCheckBox(CheckBox& _rCB,sal_Bool _bNewValue,sal_Bool _bOldValue)
1820 	{
1821 		if ( _bNewValue )
1822 			_rCB.Check(sal_True);
1823 		else
1824 			_rCB.Check( _bOldValue );
1825 // #i15082# do not call SaveValue() in running dialog...
1826 //		_rCB.SaveValue();
1827 		_rCB.Enable( !_bNewValue );
1828 	}
1829 }
1830 /* -----------------08.06.01 17:56-------------------
1831 
1832  --------------------------------------------------*/
1833 IMPL_LINK( OfaLanguagesTabPage, LocaleSettingHdl, SvxLanguageBox*, pBox )
1834 {
1835     LanguageType eLang = pBox->GetSelectLanguage();
1836 	sal_uInt16 nType = SvtLanguageOptions::GetScriptTypeOfLanguage(eLang);
1837 	// first check if CTL must be enabled
1838     // #103299# - if CTL font setting is not readonly
1839     if(!pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_CTLFONT))
1840     {
1841         bool bIsCTLFixed = (nType & SCRIPTTYPE_COMPLEX) != 0;
1842         lcl_checkLanguageCheckBox(aCTLSupportCB, bIsCTLFixed, m_bOldCtl);
1843         SupportHdl( &aCTLSupportCB );
1844     }
1845     // second check if CJK must be enabled
1846     // #103299# - if CJK support is not readonly
1847     if(!pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_ALLCJK))
1848     {
1849         bool bIsCJKFixed = (nType & SCRIPTTYPE_ASIAN) != 0;
1850         lcl_checkLanguageCheckBox(aAsianSupportCB, bIsCJKFixed, m_bOldAsian);
1851         SupportHdl( &aAsianSupportCB );
1852     }
1853 
1854     sal_uInt16 nPos;
1855     if ( eLang == LANGUAGE_SYSTEM )
1856         nPos = aCurrencyLB.GetEntryPos( (void*) NULL );
1857     else
1858     {
1859         const NfCurrencyEntry* pCurr = &SvNumberFormatter::GetCurrencyEntry( eLang );
1860         nPos = aCurrencyLB.GetEntryPos( (void*) pCurr );
1861     }
1862     aCurrencyLB.SelectEntryPos( nPos );
1863 
1864     //update the decimal separator key of the related CheckBox
1865     Locale aTempLocale;
1866     SvxLanguageToLocale( aTempLocale, eLang );
1867     LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), aTempLocale );
1868     String sTempLabel(sDecimalSeparatorLabel);
1869     sTempLabel.SearchAndReplaceAscii("%1", aLocaleWrapper.getNumDecimalSep() );
1870     aDecimalSeparatorCB.SetText(sTempLabel);
1871 
1872     return 0;
1873 }
1874 
1875