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