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