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/layout.hxx>
31 : #include <vcl/mnemonic.hxx>
32 : #include <i18nlangtag/mslangid.hxx>
33 : #include <i18nlangtag/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 <unotools/searchopt.hxx>
69 : #include <sal/macros.h>
70 : #include <officecfg/Office/Common.hxx>
71 :
72 : #include <com/sun/star/configuration/theDefaultProvider.hpp>
73 : #include <com/sun/star/container/XNameAccess.hpp>
74 : #include <com/sun/star/container/XNameReplace.hpp>
75 : #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
76 : #include <com/sun/star/lang/XComponent.hpp>
77 : #include <com/sun/star/lang/XInitialization.hpp>
78 : #include <com/sun/star/beans/NamedValue.hpp>
79 : #include <com/sun/star/beans/XPropertySet.hpp>
80 : #include <com/sun/star/util/XChangesBatch.hpp>
81 : #include <com/sun/star/uno/Any.hxx>
82 : #include <com/sun/star/container/XContentEnumerationAccess.hpp>
83 : #include <com/sun/star/container/XSet.hpp>
84 : #include <com/sun/star/i18n/ScriptType.hpp>
85 : #include <com/sun/star/office/Quickstart.hpp>
86 :
87 : #include <vcl/svapp.hxx>
88 : #include <vcl/settings.hxx>
89 : #include <vcl/IconThemeInfo.hxx>
90 :
91 : #include "optgdlg.hxx"
92 : #include <svx/ofaitem.hxx>
93 : #include <svtools/apearcfg.hxx>
94 : #include <svtools/optionsdrawinglayer.hxx>
95 :
96 : #include <config_vclplug.h>
97 :
98 : using namespace ::com::sun::star::uno;
99 : using namespace ::com::sun::star::lang;
100 : using namespace ::com::sun::star::beans;
101 : using namespace ::com::sun::star::container;
102 : using namespace ::com::sun::star::util;
103 : using namespace ::utl;
104 :
105 : // class OfaMiscTabPage --------------------------------------------------
106 :
107 0 : int OfaMiscTabPage::DeactivatePage( SfxItemSet* pSet_ )
108 : {
109 0 : if ( pSet_ )
110 0 : FillItemSet( pSet_ );
111 0 : return LEAVE_PAGE;
112 : }
113 :
114 : namespace
115 : {
116 0 : static OUString impl_SystemFileOpenServiceName()
117 : {
118 0 : const OUString &rDesktopEnvironment = Application::GetDesktopEnvironment();
119 :
120 0 : if ( rDesktopEnvironment.equalsIgnoreAsciiCase("kde4") )
121 : {
122 : #if ENABLE_KDE4
123 : return OUString("com.sun.star.ui.dialogs.KDE4FilePicker" );
124 : #else
125 0 : return OUString();
126 : #endif
127 : }
128 0 : else if ( rDesktopEnvironment.equalsIgnoreAsciiCase("kde") )
129 : {
130 : #if ENABLE_KDE
131 : return OUString("com.sun.star.ui.dialogs.KDEFilePicker");
132 : #else
133 0 : return OUString();
134 : #endif
135 : }
136 0 : else if ( rDesktopEnvironment.equalsIgnoreAsciiCase("tde") )
137 : {
138 : #if ENABLE_TDE
139 : return OUString("com.sun.star.ui.dialogs.TDEFilePicker");
140 : #else
141 0 : return OUString();
142 : #endif
143 : }
144 : #if defined WNT
145 : return OUString("com.sun.star.ui.dialogs.SystemFilePicker");
146 : #elif defined MACOSX
147 : return OUString("com.sun.star.ui.dialogs.AquaFilePicker");
148 : #else
149 0 : return OUString();
150 : #endif
151 : }
152 :
153 0 : static bool lcl_HasSystemFilePicker()
154 : {
155 0 : if( Application::hasNativeFileSelection() )
156 0 : return true;
157 :
158 : // Otherwise fall-back on querying services
159 0 : bool bRet = false;
160 0 : Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
161 :
162 0 : Reference< XContentEnumerationAccess > xEnumAccess( xFactory, UNO_QUERY );
163 0 : Reference< XSet > xSet( xFactory, UNO_QUERY );
164 :
165 0 : if ( ! xEnumAccess.is() || ! xSet.is() )
166 0 : return bRet;
167 :
168 : try
169 : {
170 0 : OUString aFileService = impl_SystemFileOpenServiceName();
171 0 : Reference< XEnumeration > xEnum = xEnumAccess->createContentEnumeration( aFileService );
172 0 : if ( xEnum.is() && xEnum->hasMoreElements() )
173 0 : bRet = true;
174 : }
175 0 : catch (const IllegalArgumentException&)
176 : {
177 : }
178 0 : catch (const ElementExistException&)
179 : {
180 : }
181 0 : return bRet;
182 : }
183 : }
184 :
185 :
186 :
187 0 : OfaMiscTabPage::OfaMiscTabPage(vcl::Window* pParent, const SfxItemSet& rSet)
188 0 : : SfxTabPage(pParent, "OptGeneralPage", "cui/ui/optgeneralpage.ui", &rSet)
189 : {
190 0 : get(m_pToolTipsCB, "tooltips");
191 0 : get(m_pExtHelpCB, "exthelp");
192 0 : if (!lcl_HasSystemFilePicker())
193 0 : get<VclContainer>("filedlgframe")->Hide();
194 : #if ! ENABLE_GTK
195 : get<VclContainer>("printdlgframe")->Hide();
196 : #else
197 0 : if (!SvtMiscOptions().IsExperimentalMode())
198 : {
199 0 : get<VclContainer>("printdlgframe")->Hide();
200 : }
201 : #endif
202 0 : get(m_pFileDlgCB, "filedlg");
203 0 : get(m_pFileDlgROImage, "lockimage");
204 0 : get(m_pPrintDlgCB, "printdlg");
205 0 : get(m_pDocStatusCB, "docstatus");
206 0 : get(m_pSaveAlwaysCB, "savealways");
207 0 : get(m_pYearFrame, "yearframe");
208 0 : get(m_pYearValueField, "year");
209 0 : get(m_pToYearFT, "toyear");
210 0 : get(m_pCollectUsageInfo, "collectusageinfo");
211 :
212 0 : if (m_pFileDlgCB->IsVisible() && SvtMiscOptions().IsUseSystemFileDialogReadOnly())
213 : {
214 0 : m_pFileDlgROImage->Show();
215 0 : m_pFileDlgCB->Disable();
216 : }
217 :
218 0 : m_aStrDateInfo = m_pToYearFT->GetText();
219 0 : m_pYearValueField->SetModifyHdl( LINK( this, OfaMiscTabPage, TwoFigureHdl ) );
220 0 : Link aLink = LINK( this, OfaMiscTabPage, TwoFigureConfigHdl );
221 0 : m_pYearValueField->SetDownHdl( aLink );
222 0 : m_pYearValueField->SetUpHdl( aLink );
223 0 : m_pYearValueField->SetLoseFocusHdl( aLink );
224 0 : m_pYearValueField->SetFirstHdl( aLink );
225 0 : TwoFigureConfigHdl(m_pYearValueField);
226 :
227 0 : SetExchangeSupport();
228 :
229 0 : aLink = LINK( this, OfaMiscTabPage, HelpCheckHdl_Impl );
230 0 : m_pToolTipsCB->SetClickHdl( aLink );
231 0 : }
232 :
233 :
234 :
235 0 : OfaMiscTabPage::~OfaMiscTabPage()
236 : {
237 0 : }
238 :
239 :
240 :
241 0 : SfxTabPage* OfaMiscTabPage::Create( vcl::Window* pParent, const SfxItemSet* rAttrSet )
242 : {
243 0 : return new OfaMiscTabPage( pParent, *rAttrSet );
244 : }
245 :
246 :
247 :
248 0 : bool OfaMiscTabPage::FillItemSet( SfxItemSet* rSet )
249 : {
250 0 : bool bModified = false;
251 0 : boost::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
252 :
253 0 : SvtHelpOptions aHelpOptions;
254 0 : if ( m_pToolTipsCB->IsValueChangedFromSaved() )
255 0 : aHelpOptions.SetHelpTips( m_pToolTipsCB->IsChecked() );
256 0 : bool bChecked = ( m_pExtHelpCB->IsChecked() && m_pToolTipsCB->IsChecked() );
257 0 : if ( bChecked != (m_pExtHelpCB->GetSavedValue() == TRISTATE_TRUE) )
258 0 : aHelpOptions.SetExtendedHelp( bChecked );
259 :
260 0 : if ( m_pFileDlgCB->IsValueChangedFromSaved() )
261 : {
262 0 : SvtMiscOptions aMiscOpt;
263 0 : aMiscOpt.SetUseSystemFileDialog( !m_pFileDlgCB->IsChecked() );
264 0 : bModified = true;
265 : }
266 :
267 0 : if ( m_pPrintDlgCB->IsValueChangedFromSaved() )
268 : {
269 0 : SvtMiscOptions aMiscOpt;
270 0 : aMiscOpt.SetUseSystemPrintDialog( !m_pPrintDlgCB->IsChecked() );
271 0 : bModified = true;
272 : }
273 :
274 0 : if ( m_pDocStatusCB->IsValueChangedFromSaved() )
275 : {
276 0 : SvtPrintWarningOptions aPrintOptions;
277 0 : aPrintOptions.SetModifyDocumentOnPrintingAllowed( m_pDocStatusCB->IsChecked() );
278 0 : bModified = true;
279 : }
280 :
281 0 : if ( m_pSaveAlwaysCB->IsValueChangedFromSaved() )
282 : {
283 0 : SvtMiscOptions aMiscOpt;
284 0 : aMiscOpt.SetSaveAlwaysAllowed( m_pSaveAlwaysCB->IsChecked() );
285 0 : bModified = true;
286 : }
287 :
288 : const SfxUInt16Item* pUInt16Item =
289 0 : PTR_CAST( SfxUInt16Item, GetOldItem( *rSet, SID_ATTR_YEAR2000 ) );
290 0 : sal_uInt16 nNum = (sal_uInt16)m_pYearValueField->GetText().toInt32();
291 0 : if ( pUInt16Item && pUInt16Item->GetValue() != nNum )
292 : {
293 0 : bModified = true;
294 0 : rSet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, nNum ) );
295 : }
296 :
297 0 : if (m_pCollectUsageInfo->IsValueChangedFromSaved())
298 : {
299 0 : officecfg::Office::Common::Misc::CollectUsageInformation::set(m_pCollectUsageInfo->IsChecked(), batch);
300 0 : bModified = true;
301 : }
302 :
303 0 : batch->commit();
304 :
305 0 : return bModified;
306 : }
307 :
308 :
309 :
310 0 : void OfaMiscTabPage::Reset( const SfxItemSet* rSet )
311 : {
312 0 : SvtHelpOptions aHelpOptions;
313 0 : m_pToolTipsCB->Check( aHelpOptions.IsHelpTips() );
314 0 : m_pExtHelpCB->Check( aHelpOptions.IsHelpTips() && aHelpOptions.IsExtendedHelp() );
315 :
316 0 : m_pToolTipsCB->SaveValue();
317 0 : m_pExtHelpCB->SaveValue();
318 :
319 0 : SvtMiscOptions aMiscOpt;
320 0 : m_pFileDlgCB->Check( !aMiscOpt.UseSystemFileDialog() );
321 0 : m_pFileDlgCB->SaveValue();
322 0 : m_pPrintDlgCB->Check( !aMiscOpt.UseSystemPrintDialog() );
323 0 : m_pPrintDlgCB->SaveValue();
324 0 : m_pSaveAlwaysCB->Check( aMiscOpt.IsSaveAlwaysAllowed() );
325 0 : m_pSaveAlwaysCB->SaveValue();
326 :
327 0 : SvtPrintWarningOptions aPrintOptions;
328 0 : m_pDocStatusCB->Check(aPrintOptions.IsModifyDocumentOnPrintingAllowed());
329 0 : m_pDocStatusCB->SaveValue();
330 :
331 0 : const SfxPoolItem* pItem = NULL;
332 0 : if ( SfxItemState::SET == rSet->GetItemState( SID_ATTR_YEAR2000, false, &pItem ) )
333 : {
334 0 : m_pYearValueField->SetValue( static_cast<const SfxUInt16Item*>(pItem)->GetValue() );
335 0 : TwoFigureConfigHdl(m_pYearValueField);
336 : }
337 : else
338 : {
339 0 : m_pYearFrame->Enable(false);
340 : }
341 :
342 0 : m_pCollectUsageInfo->Check(officecfg::Office::Common::Misc::CollectUsageInformation::get());
343 0 : m_pCollectUsageInfo->SaveValue();
344 0 : }
345 :
346 :
347 :
348 0 : IMPL_LINK( OfaMiscTabPage, TwoFigureHdl, NumericField*, pEd )
349 : {
350 : (void)pEd;
351 :
352 0 : OUString aOutput( m_aStrDateInfo );
353 0 : OUString aStr( m_pYearValueField->GetText() );
354 0 : OUString sSep( SvtSysLocale().GetLocaleData().getNumThousandSep() );
355 0 : sal_Int32 nIndex = 0;
356 0 : while ((nIndex = aStr.indexOf( sSep, nIndex)) != -1)
357 0 : aStr = aStr.replaceAt( nIndex, sSep.getLength(), "");
358 0 : sal_Int32 nNum = aStr.toInt32();
359 0 : if ( aStr.getLength() != 4 || nNum < m_pYearValueField->GetMin() || nNum > m_pYearValueField->GetMax() )
360 0 : aOutput += "????";
361 : else
362 : {
363 0 : nNum += 99;
364 0 : aOutput += OUString::number( nNum );
365 : }
366 0 : m_pToYearFT->SetText( aOutput );
367 0 : return 0;
368 : }
369 :
370 :
371 :
372 0 : IMPL_LINK( OfaMiscTabPage, TwoFigureConfigHdl, NumericField*, pEd )
373 : {
374 0 : sal_Int64 nNum = m_pYearValueField->GetValue();
375 0 : OUString aOutput(OUString::number(nNum));
376 0 : m_pYearValueField->SetText(aOutput);
377 0 : m_pYearValueField->SetSelection( Selection( 0, aOutput.getLength() ) );
378 0 : TwoFigureHdl( pEd );
379 0 : return 0;
380 : }
381 :
382 :
383 :
384 0 : IMPL_LINK_NOARG(OfaMiscTabPage, HelpCheckHdl_Impl)
385 : {
386 0 : m_pExtHelpCB->Enable( m_pToolTipsCB->IsChecked() );
387 0 : return 0;
388 : }
389 :
390 :
391 :
392 0 : class CanvasSettings
393 : {
394 : public:
395 : CanvasSettings();
396 :
397 : bool IsHardwareAccelerationEnabled() const;
398 : bool IsHardwareAccelerationAvailable() const;
399 : void EnabledHardwareAcceleration( bool _bEnabled ) const;
400 :
401 : private:
402 : typedef std::vector< std::pair<OUString,Sequence<OUString> > > ServiceVector;
403 :
404 : Reference<XNameAccess> mxForceFlagNameAccess;
405 : ServiceVector maAvailableImplementations;
406 : mutable bool mbHWAccelAvailable;
407 : mutable bool mbHWAccelChecked;
408 : };
409 :
410 :
411 0 : CanvasSettings::CanvasSettings() :
412 : mxForceFlagNameAccess(),
413 : mbHWAccelAvailable(false),
414 0 : mbHWAccelChecked(false)
415 : {
416 : try
417 : {
418 : Reference<XMultiServiceFactory> xConfigProvider(
419 : com::sun::star::configuration::theDefaultProvider::get(
420 0 : comphelper::getProcessComponentContext()));
421 :
422 : Any propValue(
423 : makeAny( NamedValue(
424 : OUString("nodepath"),
425 0 : makeAny( OUString("/org.openoffice.Office.Canvas") ) ) ) );
426 :
427 : mxForceFlagNameAccess.set(
428 0 : xConfigProvider->createInstanceWithArguments(
429 : OUString("com.sun.star.configuration.ConfigurationUpdateAccess"),
430 0 : Sequence<Any>( &propValue, 1 ) ),
431 0 : UNO_QUERY_THROW );
432 :
433 0 : propValue = makeAny(
434 : NamedValue(
435 : OUString("nodepath"),
436 0 : makeAny( OUString("/org.openoffice.Office.Canvas/CanvasServiceList") ) ) );
437 :
438 : Reference<XNameAccess> xNameAccess(
439 0 : xConfigProvider->createInstanceWithArguments(
440 : OUString("com.sun.star.configuration.ConfigurationAccess"),
441 0 : Sequence<Any>( &propValue, 1 ) ), UNO_QUERY_THROW );
442 : Reference<XHierarchicalNameAccess> xHierarchicalNameAccess(
443 0 : xNameAccess, UNO_QUERY_THROW);
444 :
445 0 : Sequence<OUString> serviceNames = xNameAccess->getElementNames();
446 0 : const OUString* pCurr = serviceNames.getConstArray();
447 0 : const OUString* const pEnd = pCurr + serviceNames.getLength();
448 0 : while( pCurr != pEnd )
449 : {
450 : Reference<XNameAccess> xEntryNameAccess(
451 0 : xHierarchicalNameAccess->getByHierarchicalName(*pCurr),
452 0 : UNO_QUERY );
453 :
454 0 : if( xEntryNameAccess.is() )
455 : {
456 0 : Sequence<OUString> preferredImplementations;
457 0 : if( (xEntryNameAccess->getByName("PreferredImplementations") >>= preferredImplementations) )
458 0 : maAvailableImplementations.push_back( std::make_pair(*pCurr,preferredImplementations) );
459 : }
460 :
461 0 : ++pCurr;
462 0 : }
463 : }
464 0 : catch (const Exception&)
465 : {
466 : }
467 0 : }
468 :
469 :
470 0 : bool CanvasSettings::IsHardwareAccelerationAvailable() const
471 : {
472 0 : if( !mbHWAccelChecked )
473 : {
474 0 : mbHWAccelChecked = true;
475 :
476 0 : Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
477 :
478 : // check whether any of the service lists has an
479 : // implementation that presents the "HardwareAcceleration" property
480 0 : ServiceVector::const_iterator aCurr=maAvailableImplementations.begin();
481 0 : const ServiceVector::const_iterator aEnd=maAvailableImplementations.end();
482 0 : while( aCurr != aEnd )
483 : {
484 0 : const OUString* pCurrImpl = aCurr->second.getConstArray();
485 0 : const OUString* const pEndImpl = pCurrImpl + aCurr->second.getLength();
486 :
487 0 : while( pCurrImpl != pEndImpl )
488 : {
489 : try
490 : {
491 0 : Reference<XPropertySet> xPropSet( xFactory->createInstance(
492 0 : pCurrImpl->trim() ),
493 0 : UNO_QUERY_THROW );
494 0 : bool bHasAccel(false);
495 0 : if( (xPropSet->getPropertyValue("HardwareAcceleration") >>= bHasAccel) )
496 0 : if( bHasAccel )
497 : {
498 0 : mbHWAccelAvailable = true;
499 0 : return mbHWAccelAvailable;
500 0 : }
501 : }
502 0 : catch (const Exception&)
503 : {
504 : }
505 :
506 0 : ++pCurrImpl;
507 : }
508 :
509 0 : ++aCurr;
510 0 : }
511 : }
512 :
513 0 : return mbHWAccelAvailable;
514 : }
515 :
516 :
517 0 : bool CanvasSettings::IsHardwareAccelerationEnabled() const
518 : {
519 0 : bool bForceLastEntry(false);
520 0 : if( !mxForceFlagNameAccess.is() )
521 0 : return true;
522 :
523 0 : if( !(mxForceFlagNameAccess->getByName("ForceSafeServiceImpl") >>= bForceLastEntry) )
524 0 : return true;
525 :
526 0 : return !bForceLastEntry;
527 : }
528 :
529 :
530 0 : void CanvasSettings::EnabledHardwareAcceleration( bool _bEnabled ) const
531 : {
532 : Reference< XNameReplace > xNameReplace(
533 0 : mxForceFlagNameAccess, UNO_QUERY );
534 :
535 0 : if( !xNameReplace.is() )
536 0 : return;
537 :
538 0 : xNameReplace->replaceByName( OUString("ForceSafeServiceImpl"),
539 0 : makeAny(!_bEnabled) );
540 :
541 : Reference< XChangesBatch > xChangesBatch(
542 0 : mxForceFlagNameAccess, UNO_QUERY );
543 :
544 0 : if( !xChangesBatch.is() )
545 0 : return;
546 :
547 0 : xChangesBatch->commitChanges();
548 : }
549 :
550 : // class OfaViewTabPage --------------------------------------------------
551 :
552 0 : OfaViewTabPage::OfaViewTabPage(vcl::Window* pParent, const SfxItemSet& rSet)
553 : : SfxTabPage(pParent, "OptViewPage", "cui/ui/optviewpage.ui", &rSet)
554 : , nSizeLB_InitialSelection(0)
555 : , nStyleLB_InitialSelection(0)
556 0 : , pAppearanceCfg(new SvtTabAppearanceCfg)
557 0 : , pCanvasSettings(new CanvasSettings)
558 0 : , mpDrawinglayerOpt(new SvtOptionsDrawinglayer)
559 : {
560 0 : get(m_pWindowSizeMF, "windowsize");
561 0 : get(m_pIconSizeLB, "iconsize");
562 0 : get(m_pIconStyleLB, "iconstyle");
563 0 : get(m_pSystemFont, "systemfont");
564 :
565 0 : VclContainer *pRef = get<VclContainer>("refgrid");
566 : //fdo#65595, we need height-for-width support here, but for now we can
567 : //bodge it
568 0 : Size aPrefSize(m_pSystemFont->get_preferred_size());
569 0 : Size aSize(pRef->get_preferred_size());
570 0 : if (aPrefSize.Width() > aSize.Width())
571 : {
572 0 : aSize = m_pSystemFont->CalcMinimumSize(aSize.Width());
573 0 : m_pSystemFont->set_width_request(aSize.Width());
574 0 : m_pSystemFont->set_height_request(aSize.Height());
575 : }
576 :
577 0 : get(m_pFontAntiAliasing, "aafont");
578 0 : get(m_pAAPointLimitLabel, "aafrom");
579 0 : get(m_pAAPointLimit, "aanf");
580 0 : get(m_pMenuIconsLB, "menuicons");
581 0 : get(m_pFontShowCB, "showfontpreview");
582 0 : get(m_pFontHistoryCB, "showfonthistory");
583 0 : get(m_pUseHardwareAccell, "useaccel");
584 0 : get(m_pUseAntiAliase, "useaa");
585 0 : get(m_pMousePosLB, "mousepos");
586 0 : get(m_pMouseMiddleLB, "mousemiddle");
587 : // #i97672#
588 0 : get(m_pSelectionCB, "trans");
589 0 : get(m_pSelectionMF, "transmf");
590 :
591 : #if defined( UNX )
592 0 : m_pFontAntiAliasing->SetToggleHdl( LINK( this, OfaViewTabPage, OnAntialiasingToggled ) );
593 : #else
594 : // on this platform, we do not have the anti aliasing options
595 : m_pFontAntiAliasing->Hide();
596 : m_pAAPointLimitLabel->Hide();
597 : m_pAAPointLimit->Hide();
598 :
599 : #endif
600 :
601 : // #i97672#
602 0 : m_pSelectionCB->SetToggleHdl( LINK( this, OfaViewTabPage, OnSelectionToggled ) );
603 :
604 0 : if( ! Application::ValidateSystemFont() )
605 : {
606 0 : m_pSystemFont->Check(false);
607 0 : m_pSystemFont->Enable(false);
608 : }
609 :
610 : // Set known icon themes
611 0 : OUString sAutoStr( m_pIconStyleLB->GetEntry( 0 ) );
612 0 : m_pIconStyleLB->Clear();
613 0 : StyleSettings aStyleSettings = Application::GetSettings().GetStyleSettings();
614 0 : mInstalledIconThemes = aStyleSettings.GetInstalledIconThemes();
615 :
616 : // Start with the automatically chosen icon theme
617 0 : OUString autoThemeId = aStyleSettings.GetAutomaticallyChosenIconTheme();
618 0 : const vcl::IconThemeInfo& autoIconTheme = vcl::IconThemeInfo::FindIconThemeById(mInstalledIconThemes, autoThemeId);
619 :
620 0 : OUString entryForAuto = sAutoStr + OUString(" (") +
621 0 : autoIconTheme.GetDisplayName() +
622 0 : OUString(")");
623 0 : m_pIconStyleLB->InsertEntry(entryForAuto);
624 :
625 0 : for (std::vector<vcl::IconThemeInfo>::const_iterator aI = mInstalledIconThemes.begin(); aI != mInstalledIconThemes.end(); ++aI) {
626 0 : m_pIconStyleLB->InsertEntry(aI->GetDisplayName());
627 : }
628 :
629 : // separate auto and other icon themes
630 0 : m_pIconStyleLB->SetSeparatorPos( 0 );
631 0 : m_pIconStyleLB->SelectEntryPos(0);
632 0 : }
633 :
634 0 : OfaViewTabPage::~OfaViewTabPage()
635 : {
636 0 : delete mpDrawinglayerOpt;
637 0 : delete pCanvasSettings;
638 0 : delete pAppearanceCfg;
639 0 : }
640 :
641 : #if defined( UNX )
642 0 : IMPL_LINK( OfaViewTabPage, OnAntialiasingToggled, void*, NOTINTERESTEDIN )
643 : {
644 : (void)NOTINTERESTEDIN;
645 :
646 0 : bool bAAEnabled = m_pFontAntiAliasing->IsChecked();
647 :
648 0 : m_pAAPointLimitLabel->Enable( bAAEnabled );
649 0 : m_pAAPointLimit->Enable( bAAEnabled );
650 :
651 0 : return 0L;
652 : }
653 : #endif
654 :
655 : // #i97672#
656 0 : IMPL_LINK( OfaViewTabPage, OnSelectionToggled, void*, NOTINTERESTEDIN )
657 : {
658 : (void)NOTINTERESTEDIN;
659 0 : const bool bSelectionEnabled(m_pSelectionCB->IsChecked());
660 0 : m_pSelectionMF->Enable(bSelectionEnabled);
661 0 : return 0;
662 : }
663 :
664 0 : SfxTabPage* OfaViewTabPage::Create( vcl::Window* pParent, const SfxItemSet* rAttrSet )
665 : {
666 0 : return new OfaViewTabPage(pParent, *rAttrSet);
667 : }
668 :
669 0 : bool OfaViewTabPage::FillItemSet( SfxItemSet* )
670 : {
671 0 : SvtFontOptions aFontOpt;
672 0 : SvtMenuOptions aMenuOpt;
673 :
674 0 : bool bModified = false;
675 0 : bool bMenuOptModified = false;
676 0 : bool bRepaintWindows(false);
677 :
678 0 : SvtMiscOptions aMiscOptions;
679 0 : sal_uInt16 nSizeLB_NewSelection = m_pIconSizeLB->GetSelectEntryPos();
680 0 : if( nSizeLB_InitialSelection != nSizeLB_NewSelection )
681 : {
682 : // from now on it's modified, even if via auto setting the same size was set as now selected in the LB
683 0 : sal_Int16 eSet = SFX_SYMBOLS_SIZE_AUTO;
684 0 : switch( nSizeLB_NewSelection )
685 : {
686 0 : case 0: eSet = SFX_SYMBOLS_SIZE_AUTO; break;
687 0 : case 1: eSet = SFX_SYMBOLS_SIZE_SMALL; break;
688 0 : case 2: eSet = SFX_SYMBOLS_SIZE_LARGE; break;
689 : default:
690 : OSL_FAIL( "OfaViewTabPage::FillItemSet(): This state of m_pIconSizeLB should not be possible!" );
691 : }
692 0 : aMiscOptions.SetSymbolsSize( eSet );
693 : }
694 :
695 0 : sal_uInt16 nStyleLB_NewSelection = m_pIconStyleLB->GetSelectEntryPos();
696 0 : if( nStyleLB_InitialSelection != nStyleLB_NewSelection )
697 : {
698 : // 0 means choose style automatically
699 0 : if (nStyleLB_NewSelection == 0) {
700 0 : aMiscOptions.SetIconThemeAutomatically();
701 : }
702 : else {
703 0 : sal_uInt16 pos = m_pIconStyleLB->GetSelectEntryPos();
704 0 : const vcl::IconThemeInfo& iconThemeId = mInstalledIconThemes.at(pos-1);
705 0 : aMiscOptions.SetIconTheme(iconThemeId.GetThemeId());
706 : }
707 0 : nStyleLB_InitialSelection = nStyleLB_NewSelection;
708 : }
709 :
710 0 : bool bAppearanceChanged = false;
711 :
712 :
713 : // Screen Scaling
714 0 : sal_uInt16 nOldScale = pAppearanceCfg->GetScaleFactor();
715 0 : sal_uInt16 nNewScale = (sal_uInt16)m_pWindowSizeMF->GetValue();
716 :
717 0 : if ( nNewScale != nOldScale )
718 : {
719 0 : pAppearanceCfg->SetScaleFactor(nNewScale);
720 0 : bAppearanceChanged = true;
721 : }
722 :
723 : // Mouse Snap Mode
724 0 : short eOldSnap = pAppearanceCfg->GetSnapMode();
725 0 : short eNewSnap = m_pMousePosLB->GetSelectEntryPos();
726 0 : if(eNewSnap > 2)
727 0 : eNewSnap = 2;
728 :
729 0 : if ( eNewSnap != eOldSnap )
730 : {
731 0 : pAppearanceCfg->SetSnapMode(eNewSnap );
732 0 : bAppearanceChanged = true;
733 : }
734 :
735 : // Middle Mouse Button
736 0 : short eOldMiddleMouse = pAppearanceCfg->GetMiddleMouseButton();
737 0 : short eNewMiddleMouse = m_pMouseMiddleLB->GetSelectEntryPos();
738 0 : if(eNewMiddleMouse > 2)
739 0 : eNewMiddleMouse = 2;
740 :
741 0 : if ( eNewMiddleMouse != eOldMiddleMouse )
742 : {
743 0 : pAppearanceCfg->SetMiddleMouseButton( eNewMiddleMouse );
744 0 : bAppearanceChanged = true;
745 : }
746 :
747 : #if defined( UNX )
748 0 : if ( m_pFontAntiAliasing->IsValueChangedFromSaved() )
749 : {
750 0 : pAppearanceCfg->SetFontAntiAliasing( m_pFontAntiAliasing->IsChecked() );
751 0 : bAppearanceChanged = true;
752 : }
753 :
754 0 : if ( m_pAAPointLimit->IsValueChangedFromSaved() )
755 : {
756 0 : pAppearanceCfg->SetFontAntialiasingMinPixelHeight( m_pAAPointLimit->GetValue() );
757 0 : bAppearanceChanged = true;
758 : }
759 : #endif
760 :
761 0 : if ( m_pFontShowCB->IsValueChangedFromSaved() )
762 : {
763 0 : aFontOpt.EnableFontWYSIWYG( m_pFontShowCB->IsChecked() );
764 0 : bModified = true;
765 : }
766 :
767 0 : if(m_pMenuIconsLB->IsValueChangedFromSaved())
768 : {
769 0 : aMenuOpt.SetMenuIconsState(m_pMenuIconsLB->GetSelectEntryPos() == 0 ?
770 : TRISTATE_INDET :
771 0 : static_cast<TriState>(m_pMenuIconsLB->GetSelectEntryPos() - 1));
772 0 : bModified = true;
773 0 : bMenuOptModified = true;
774 0 : bAppearanceChanged = true;
775 : }
776 :
777 0 : if ( m_pFontHistoryCB->IsValueChangedFromSaved() )
778 : {
779 0 : aFontOpt.EnableFontHistory( m_pFontHistoryCB->IsChecked() );
780 0 : bModified = true;
781 : }
782 :
783 : // #i95644# if disabled, do not use value, see in ::Reset()
784 0 : if(m_pUseHardwareAccell->IsEnabled())
785 : {
786 0 : if(m_pUseHardwareAccell->IsValueChangedFromSaved())
787 : {
788 0 : pCanvasSettings->EnabledHardwareAcceleration(m_pUseHardwareAccell->IsChecked());
789 0 : bModified = true;
790 : }
791 : }
792 :
793 : // #i95644# if disabled, do not use value, see in ::Reset()
794 0 : if(m_pUseAntiAliase->IsEnabled())
795 : {
796 0 : if(m_pUseAntiAliase->IsChecked() != mpDrawinglayerOpt->IsAntiAliasing())
797 : {
798 0 : mpDrawinglayerOpt->SetAntiAliasing(m_pUseAntiAliase->IsChecked());
799 0 : bModified = true;
800 0 : bRepaintWindows = true;
801 : }
802 : }
803 :
804 : // #i97672#
805 0 : if(m_pSelectionCB->IsEnabled())
806 : {
807 0 : const bool bNewSelection(m_pSelectionCB->IsChecked());
808 0 : const sal_uInt16 nNewTransparence((sal_uInt16)m_pSelectionMF->GetValue());
809 :
810 0 : if(bNewSelection != (bool)mpDrawinglayerOpt->IsTransparentSelection())
811 : {
812 0 : mpDrawinglayerOpt->SetTransparentSelection(m_pSelectionCB->IsChecked());
813 0 : bModified = true;
814 0 : bRepaintWindows = true;
815 : }
816 :
817 : // #i104150# even read the value when m_pSelectionMF is disabled; it may have been
818 : // modified by enabling-modify-disabling by the user
819 0 : if(nNewTransparence != mpDrawinglayerOpt->GetTransparentSelectionPercent())
820 : {
821 0 : mpDrawinglayerOpt->SetTransparentSelectionPercent(nNewTransparence);
822 0 : bModified = true;
823 0 : bRepaintWindows = true;
824 : }
825 : }
826 :
827 0 : SvtAccessibilityOptions aAccessibilityOptions;
828 0 : if( aAccessibilityOptions.GetIsSystemFont() != m_pSystemFont->IsChecked() &&
829 0 : m_pSystemFont->IsEnabled() )
830 : {
831 0 : aAccessibilityOptions.SetIsSystemFont( m_pSystemFont->IsChecked() );
832 0 : bModified = true;
833 0 : bMenuOptModified = true;
834 : }
835 :
836 0 : if( bMenuOptModified )
837 : {
838 : // Set changed settings to the application instance
839 0 : AllSettings aAllSettings = Application::GetSettings();
840 0 : StyleSettings aStyleSettings = aAllSettings.GetStyleSettings();
841 0 : if( m_pSystemFont->IsEnabled() )
842 0 : aStyleSettings.SetUseSystemUIFonts( m_pSystemFont->IsChecked() );
843 0 : aAllSettings.SetStyleSettings(aStyleSettings);
844 0 : Application::MergeSystemSettings( aAllSettings );
845 0 : Application::SetSettings(aAllSettings);
846 : }
847 :
848 0 : if ( bAppearanceChanged )
849 : {
850 0 : pAppearanceCfg->Commit();
851 0 : pAppearanceCfg->SetApplicationDefaults ( GetpApp() );
852 : }
853 :
854 0 : if(bRepaintWindows)
855 : {
856 0 : vcl::Window* pAppWindow = Application::GetFirstTopLevelWindow();
857 :
858 0 : while(pAppWindow)
859 : {
860 0 : pAppWindow->Invalidate();
861 0 : pAppWindow = Application::GetNextTopLevelWindow(pAppWindow);
862 : }
863 : }
864 :
865 0 : return bModified;
866 : }
867 :
868 0 : void OfaViewTabPage::Reset( const SfxItemSet* )
869 : {
870 0 : SvtMiscOptions aMiscOptions;
871 :
872 0 : if( aMiscOptions.GetSymbolsSize() != SFX_SYMBOLS_SIZE_AUTO )
873 0 : nSizeLB_InitialSelection = ( aMiscOptions.AreCurrentSymbolsLarge() )? 2 : 1;
874 0 : m_pIconSizeLB->SelectEntryPos( nSizeLB_InitialSelection );
875 0 : m_pIconSizeLB->SaveValue();
876 :
877 0 : if (aMiscOptions.IconThemeWasSetAutomatically()) {
878 0 : nStyleLB_InitialSelection = 0;
879 : }
880 : else {
881 0 : const OUString& selected = aMiscOptions.GetIconTheme();
882 : const vcl::IconThemeInfo& selectedInfo =
883 0 : vcl::IconThemeInfo::FindIconThemeById(mInstalledIconThemes, selected);
884 0 : nStyleLB_InitialSelection = m_pIconStyleLB->GetEntryPos(selectedInfo.GetDisplayName());
885 : }
886 :
887 0 : m_pIconStyleLB->SelectEntryPos( nStyleLB_InitialSelection );
888 0 : m_pIconStyleLB->SaveValue();
889 :
890 0 : if( m_pSystemFont->IsEnabled() )
891 : {
892 0 : SvtAccessibilityOptions aAccessibilityOptions;
893 0 : m_pSystemFont->Check( aAccessibilityOptions.GetIsSystemFont() );
894 : }
895 :
896 : // Screen Scaling
897 0 : m_pWindowSizeMF->SetValue ( pAppearanceCfg->GetScaleFactor() );
898 : // Mouse Snap
899 0 : m_pMousePosLB->SelectEntryPos(pAppearanceCfg->GetSnapMode());
900 0 : m_pMousePosLB->SaveValue();
901 :
902 : // Mouse Snap
903 0 : m_pMouseMiddleLB->SelectEntryPos(pAppearanceCfg->GetMiddleMouseButton());
904 0 : m_pMouseMiddleLB->SaveValue();
905 :
906 : #if defined( UNX )
907 0 : m_pFontAntiAliasing->Check( pAppearanceCfg->IsFontAntiAliasing() );
908 0 : m_pAAPointLimit->SetValue( pAppearanceCfg->GetFontAntialiasingMinPixelHeight() );
909 : #endif
910 :
911 : // WorkingSet
912 0 : SvtFontOptions aFontOpt;
913 0 : m_pFontShowCB->Check( aFontOpt.IsFontWYSIWYGEnabled() );
914 0 : SvtMenuOptions aMenuOpt;
915 0 : m_pMenuIconsLB->SelectEntryPos(aMenuOpt.GetMenuIconsState() == 2 ? 0 : aMenuOpt.GetMenuIconsState() + 1);
916 0 : m_pMenuIconsLB->SaveValue();
917 0 : m_pFontHistoryCB->Check( aFontOpt.IsFontHistoryEnabled() );
918 :
919 : { // #i95644# HW accel (unified to disable mechanism)
920 0 : if(pCanvasSettings->IsHardwareAccelerationAvailable())
921 : {
922 0 : m_pUseHardwareAccell->Check(pCanvasSettings->IsHardwareAccelerationEnabled());
923 : }
924 : else
925 : {
926 0 : m_pUseHardwareAccell->Check(false);
927 0 : m_pUseHardwareAccell->Disable();
928 : }
929 :
930 0 : m_pUseHardwareAccell->SaveValue();
931 : }
932 :
933 : { // #i95644# AntiAliasing
934 0 : if(mpDrawinglayerOpt->IsAAPossibleOnThisSystem())
935 : {
936 0 : m_pUseAntiAliase->Check(mpDrawinglayerOpt->IsAntiAliasing());
937 : }
938 : else
939 : {
940 0 : m_pUseAntiAliase->Check(false);
941 0 : m_pUseAntiAliase->Disable();
942 : }
943 :
944 0 : m_pUseAntiAliase->SaveValue();
945 : }
946 :
947 : {
948 : // #i97672# Selection
949 : // check if transparent selection is possible on this system
950 : const bool bTransparentSelectionPossible(
951 0 : !GetSettings().GetStyleSettings().GetHighContrastMode()
952 0 : && SupportsOperation(OutDevSupport_TransparentRect));
953 :
954 : // enter values
955 0 : if(bTransparentSelectionPossible)
956 : {
957 0 : m_pSelectionCB->Check(mpDrawinglayerOpt->IsTransparentSelection());
958 : }
959 : else
960 : {
961 0 : m_pSelectionCB->Enable(false);
962 : }
963 :
964 0 : m_pSelectionMF->SetValue(mpDrawinglayerOpt->GetTransparentSelectionPercent());
965 0 : m_pSelectionMF->Enable(mpDrawinglayerOpt->IsTransparentSelection() && bTransparentSelectionPossible);
966 : }
967 :
968 : #if defined( UNX )
969 0 : m_pFontAntiAliasing->SaveValue();
970 0 : m_pAAPointLimit->SaveValue();
971 : #endif
972 0 : m_pFontShowCB->SaveValue();
973 0 : m_pFontHistoryCB->SaveValue();
974 :
975 : #if defined( UNX )
976 0 : LINK( this, OfaViewTabPage, OnAntialiasingToggled ).Call( NULL );
977 : #endif
978 0 : }
979 :
980 0 : struct LanguageConfig_Impl
981 : {
982 : SvtLanguageOptions aLanguageOptions;
983 : SvtSysLocaleOptions aSysLocaleOptions;
984 : SvtLinguConfig aLinguConfig;
985 : };
986 :
987 : static bool bLanguageCurrentDoc_Impl = false;
988 :
989 : // some things we'll need...
990 0 : static const OUString sAccessSrvc("com.sun.star.configuration.ConfigurationAccess");
991 0 : static const OUString sAccessUpdSrvc("com.sun.star.configuration.ConfigurationUpdateAccess");
992 0 : static const OUString sInstalledLocalesPath("org.openoffice.Setup/Office/InstalledLocales");
993 0 : static OUString sUserLocalePath("org.openoffice.Office.Linguistic/General");
994 : //static const OUString sUserLocalePath("org.openoffice.Office/Linguistic");
995 0 : static const OUString sUserLocaleKey("UILocale");
996 0 : static Sequence< OUString > seqInstalledLanguages;
997 :
998 0 : static OUString lcl_getDatePatternsConfigString( const LocaleDataWrapper& rLocaleWrapper )
999 : {
1000 0 : Sequence< OUString > aDateAcceptancePatterns = rLocaleWrapper.getDateAcceptancePatterns();
1001 0 : sal_Int32 nPatterns = aDateAcceptancePatterns.getLength();
1002 0 : OUStringBuffer aBuf( nPatterns * 6 ); // 6 := length of Y-M-D;
1003 : SAL_WARN_IF( !nPatterns, "cui.options", "No date acceptance pattern");
1004 0 : if (nPatterns)
1005 : {
1006 0 : const OUString* pPatterns = aDateAcceptancePatterns.getConstArray();
1007 0 : aBuf.append( pPatterns[0]);
1008 0 : for (sal_Int32 i=1; i < nPatterns; ++i)
1009 0 : aBuf.append(';').append( pPatterns[i]);
1010 : }
1011 0 : return aBuf.makeStringAndClear();
1012 : }
1013 :
1014 0 : OfaLanguagesTabPage::OfaLanguagesTabPage(vcl::Window* pParent, const SfxItemSet& rSet)
1015 : : SfxTabPage(pParent,"OptLanguagesPage","cui/ui/optlanguagespage.ui", &rSet)
1016 0 : , pLangConfig(new LanguageConfig_Impl)
1017 0 : , m_bDatePatternsValid(false)
1018 : {
1019 0 : get(m_pUserInterfaceLB, "userinterface");
1020 0 : m_pUserInterfaceLB->SetStyle(m_pUserInterfaceLB->GetStyle() | WB_SORT);
1021 0 : get(m_pLocaleSettingLB, "localesetting");
1022 0 : m_pLocaleSettingLB->SetStyle(m_pLocaleSettingLB->GetStyle() | WB_SORT);
1023 0 : get(m_pLocaleSettingFT, "localesettingFT");
1024 0 : get(m_pDecimalSeparatorCB, "decimalseparator");
1025 0 : get(m_pCurrencyFT, "defaultcurrency");
1026 0 : get(m_pCurrencyLB, "currencylb");
1027 0 : m_pCurrencyLB->SetStyle(m_pCurrencyLB->GetStyle() | WB_SORT);
1028 0 : get(m_pDatePatternsFT,"dataaccpatterns");
1029 0 : get(m_pDatePatternsED, "datepatterns");
1030 :
1031 0 : get(m_pWesternLanguageLB, "westernlanguage");
1032 0 : m_pWesternLanguageLB->SetStyle(m_pWesternLanguageLB->GetStyle() | WB_SORT);
1033 0 : get(m_pWesternLanguageFT, "western");
1034 0 : get(m_pAsianLanguageLB, "asianlanguage");
1035 0 : m_pAsianLanguageLB->SetStyle(m_pAsianLanguageLB->GetStyle() | WB_SORT);
1036 0 : get(m_pComplexLanguageLB, "complexlanguage");
1037 0 : m_pComplexLanguageLB->SetStyle(m_pComplexLanguageLB->GetStyle() | WB_SORT);
1038 0 : get(m_pCurrentDocCB, "currentdoc");
1039 0 : get(m_pAsianSupportCB, "asiansupport");
1040 0 : get(m_pCTLSupportCB, "ctlsupport");
1041 0 : get(m_pIgnoreLanguageChangeCB, "ignorelanguagechange");
1042 :
1043 : // initialize user interface language selection
1044 0 : m_sSystemDefaultString = SvtLanguageTable::GetLanguageString( LANGUAGE_SYSTEM );
1045 :
1046 0 : OUString aUILang = m_sSystemDefaultString +
1047 0 : " - " +
1048 0 : SvtLanguageTable::GetLanguageString( Application::GetSettings().GetUILanguageTag().getLanguageType(), true );
1049 :
1050 0 : m_pUserInterfaceLB->InsertEntry(aUILang);
1051 0 : m_pUserInterfaceLB->SetEntryData(0, 0);
1052 0 : m_pUserInterfaceLB->SelectEntryPos(0);
1053 : try
1054 : {
1055 : Reference< XMultiServiceFactory > theConfigProvider(
1056 : com::sun::star::configuration::theDefaultProvider::get(
1057 0 : comphelper::getProcessComponentContext()));
1058 0 : Sequence< Any > theArgs(1);
1059 0 : Reference< XNameAccess > theNameAccess;
1060 :
1061 : // find out which locales are currently installed and add them to the listbox
1062 0 : theArgs[0] = makeAny(NamedValue(OUString("nodepath"), makeAny(sInstalledLocalesPath)));
1063 0 : theNameAccess = Reference< XNameAccess > (
1064 0 : theConfigProvider->createInstanceWithArguments(sAccessSrvc, theArgs ), UNO_QUERY_THROW );
1065 0 : seqInstalledLanguages = theNameAccess->getElementNames();
1066 0 : LanguageType aLang = LANGUAGE_DONTKNOW;
1067 0 : for (sal_IntPtr i=0; i<seqInstalledLanguages.getLength(); i++)
1068 : {
1069 0 : aLang = LanguageTag::convertToLanguageTypeWithFallback(seqInstalledLanguages[i]);
1070 0 : if (aLang != LANGUAGE_DONTKNOW)
1071 : {
1072 : //sal_uInt16 p = m_pUserInterfaceLB->InsertLanguage(aLang);
1073 0 : OUString aLangStr( SvtLanguageTable::GetLanguageString( aLang, true ) );
1074 0 : sal_uInt16 p = m_pUserInterfaceLB->InsertEntry(aLangStr);
1075 0 : m_pUserInterfaceLB->SetEntryData(p, reinterpret_cast<void*>(i+1));
1076 : }
1077 : }
1078 :
1079 : // find out whether the user has a specific locale specified
1080 0 : Sequence< Any > theArgs2(1);
1081 0 : theArgs2[0] = makeAny(NamedValue(OUString("nodepath"), makeAny(sUserLocalePath)));
1082 0 : theNameAccess = Reference< XNameAccess > (
1083 0 : theConfigProvider->createInstanceWithArguments(sAccessSrvc, theArgs2 ), UNO_QUERY_THROW );
1084 0 : if (theNameAccess->hasByName(sUserLocaleKey))
1085 0 : theNameAccess->getByName(sUserLocaleKey) >>= m_sUserLocaleValue;
1086 : // select the user specified locale in the listbox
1087 0 : if (!m_sUserLocaleValue.isEmpty())
1088 : {
1089 0 : sal_Int32 d = 0;
1090 0 : for (sal_uInt16 i=0; i < m_pUserInterfaceLB->GetEntryCount(); i++)
1091 : {
1092 0 : d = (sal_Int32)reinterpret_cast<sal_IntPtr>(m_pUserInterfaceLB->GetEntryData(i));
1093 0 : if ( d > 0 && seqInstalledLanguages.getLength() > d-1 && seqInstalledLanguages[d-1].equals(m_sUserLocaleValue))
1094 0 : m_pUserInterfaceLB->SelectEntryPos(i);
1095 : }
1096 0 : }
1097 :
1098 : }
1099 0 : catch (const Exception &e)
1100 : {
1101 : // we'll just leave the box in it's default setting and won't
1102 : // even give it event handler...
1103 : SAL_WARN("cui.options", "ignoring Exception \"" << e.Message << "\"");
1104 : }
1105 :
1106 0 : m_pWesternLanguageLB->SetLanguageList( LANG_LIST_WESTERN | LANG_LIST_ONLY_KNOWN, true, false, true );
1107 0 : m_pWesternLanguageLB->InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::LATIN );
1108 0 : m_pAsianLanguageLB->SetLanguageList( LANG_LIST_CJK | LANG_LIST_ONLY_KNOWN, true, false, true );
1109 0 : m_pAsianLanguageLB->InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::ASIAN );
1110 0 : m_pComplexLanguageLB->SetLanguageList( LANG_LIST_CTL | LANG_LIST_ONLY_KNOWN, true, false, true );
1111 0 : m_pComplexLanguageLB->InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::COMPLEX );
1112 :
1113 0 : m_pLocaleSettingLB->SetLanguageList( LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN, false, false, false);
1114 0 : m_pLocaleSettingLB->InsertSystemLanguage( );
1115 :
1116 0 : const NfCurrencyTable& rCurrTab = SvNumberFormatter::GetTheCurrencyTable();
1117 0 : const NfCurrencyEntry& rCurr = SvNumberFormatter::GetCurrencyEntry( LANGUAGE_SYSTEM );
1118 : // insert SYSTEM entry
1119 0 : OUString aDefaultCurr = m_sSystemDefaultString + " - " + rCurr.GetBankSymbol();
1120 0 : m_pCurrencyLB->InsertEntry( aDefaultCurr );
1121 : // all currencies
1122 0 : OUString aTwoSpace( " " );
1123 0 : sal_uInt16 nCurrCount = rCurrTab.size();
1124 : // first entry is SYSTEM, skip it
1125 0 : for ( sal_uInt16 j=1; j < nCurrCount; ++j )
1126 : {
1127 0 : const NfCurrencyEntry* pCurr = &rCurrTab[j];
1128 0 : OUString aStr_ = pCurr->GetBankSymbol() +
1129 0 : aTwoSpace +
1130 0 : pCurr->GetSymbol();
1131 0 : aStr_ = ApplyLreOrRleEmbedding( aStr_ ) +
1132 0 : aTwoSpace +
1133 0 : ApplyLreOrRleEmbedding( SvtLanguageTable::GetLanguageString( pCurr->GetLanguage() ) );
1134 0 : sal_uInt16 nPos = m_pCurrencyLB->InsertEntry( aStr_ );
1135 0 : m_pCurrencyLB->SetEntryData( nPos, (void*) pCurr );
1136 0 : }
1137 :
1138 0 : m_pLocaleSettingLB->SetSelectHdl( LINK( this, OfaLanguagesTabPage, LocaleSettingHdl ) );
1139 0 : m_pDatePatternsED->SetModifyHdl( LINK( this, OfaLanguagesTabPage, DatePatternsHdl ) );
1140 :
1141 0 : Link aLink( LINK( this, OfaLanguagesTabPage, SupportHdl ) );
1142 0 : m_pAsianSupportCB->SetClickHdl( aLink );
1143 0 : m_pCTLSupportCB->SetClickHdl( aLink );
1144 :
1145 0 : m_bOldAsian = pLangConfig->aLanguageOptions.IsAnyEnabled();
1146 0 : m_pAsianSupportCB->Check(m_bOldAsian);
1147 0 : m_pAsianSupportCB->SaveValue();
1148 0 : bool bReadonly = pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_ALLCJK);
1149 0 : m_pAsianSupportCB->Enable(!bReadonly);
1150 0 : SupportHdl( m_pAsianSupportCB );
1151 :
1152 0 : m_bOldCtl = pLangConfig->aLanguageOptions.IsCTLFontEnabled();
1153 0 : m_pCTLSupportCB->Check(m_bOldCtl);
1154 0 : m_pCTLSupportCB->SaveValue();
1155 0 : bReadonly = pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_CTLFONT);
1156 0 : m_pCTLSupportCB->Enable(!bReadonly);
1157 0 : SupportHdl( m_pCTLSupportCB );
1158 :
1159 0 : m_pIgnoreLanguageChangeCB->Check( pLangConfig->aSysLocaleOptions.IsIgnoreLanguageChange() );
1160 0 : }
1161 :
1162 0 : OfaLanguagesTabPage::~OfaLanguagesTabPage()
1163 : {
1164 0 : delete pLangConfig;
1165 0 : }
1166 :
1167 0 : SfxTabPage* OfaLanguagesTabPage::Create( vcl::Window* pParent, const SfxItemSet* rAttrSet )
1168 : {
1169 0 : return new OfaLanguagesTabPage(pParent, *rAttrSet);
1170 : }
1171 :
1172 0 : static void lcl_UpdateAndDelete(SfxVoidItem* pInvalidItems[], SfxBoolItem* pBoolItems[], sal_uInt16 nCount)
1173 : {
1174 0 : SfxViewFrame* pCurrentFrm = SfxViewFrame::Current();
1175 0 : SfxViewFrame* pViewFrm = SfxViewFrame::GetFirst();
1176 0 : while(pViewFrm)
1177 : {
1178 0 : SfxBindings& rBind = pViewFrm->GetBindings();
1179 0 : for(sal_Int16 i = 0; i < nCount; i++)
1180 : {
1181 0 : if(pCurrentFrm == pViewFrm)
1182 0 : rBind.InvalidateAll(false);
1183 0 : rBind.SetState( *pInvalidItems[i] );
1184 0 : rBind.SetState( *pBoolItems[i] );
1185 : }
1186 0 : pViewFrm = SfxViewFrame::GetNext(*pViewFrm);
1187 : }
1188 0 : for(sal_Int16 i = 0; i < nCount; i++)
1189 : {
1190 0 : delete pInvalidItems[i];
1191 0 : delete pBoolItems[i] ;
1192 : }
1193 0 : }
1194 :
1195 0 : bool OfaLanguagesTabPage::FillItemSet( SfxItemSet* rSet )
1196 : {
1197 : // lock configuration broadcasters so that we can coordinate the notifications
1198 0 : pLangConfig->aSysLocaleOptions.BlockBroadcasts( true );
1199 0 : pLangConfig->aLanguageOptions.BlockBroadcasts( true );
1200 0 : pLangConfig->aLinguConfig.BlockBroadcasts( true );
1201 :
1202 : /*
1203 : * Sequence checking only matters when CTL support is enabled.
1204 : *
1205 : * So we only need to check for sequence checking if
1206 : * a) previously it was unchecked and is now checked or
1207 : * b) it was already checked but the CTL language has changed
1208 : */
1209 0 : if (
1210 0 : m_pCTLSupportCB->IsChecked() &&
1211 0 : (m_pCTLSupportCB->GetSavedValue() != TRISTATE_TRUE ||
1212 0 : m_pComplexLanguageLB->IsValueChangedFromSaved())
1213 : )
1214 : {
1215 : //sequence checking has to be switched on depending on the selected CTL language
1216 0 : LanguageType eCTLLang = m_pComplexLanguageLB->GetSelectLanguage();
1217 0 : bool bOn = MsLangId::needsSequenceChecking( eCTLLang);
1218 0 : pLangConfig->aLanguageOptions.SetCTLSequenceCheckingRestricted(bOn);
1219 0 : pLangConfig->aLanguageOptions.SetCTLSequenceChecking(bOn);
1220 0 : pLangConfig->aLanguageOptions.SetCTLSequenceCheckingTypeAndReplace(bOn);
1221 : }
1222 : try
1223 : {
1224 : // handle settings for UI Language
1225 : // a change of setting needs to bring up a warning message
1226 0 : OUString aLangString;
1227 0 : sal_Int32 d = (sal_Int32)reinterpret_cast<sal_IntPtr>(m_pUserInterfaceLB->GetEntryData(m_pUserInterfaceLB->GetSelectEntryPos()));
1228 0 : if( d > 0 && seqInstalledLanguages.getLength() > d-1)
1229 0 : aLangString = seqInstalledLanguages[d-1];
1230 :
1231 : /*
1232 : if( m_pUserInterfaceLB->GetSelectEntryPos() > 0)
1233 : aLangString = ConvertLanguageToIsoString(m_pUserInterfaceLB->GetSelectLanguage());
1234 : */
1235 : Reference< XMultiServiceFactory > theConfigProvider(
1236 : com::sun::star::configuration::theDefaultProvider::get(
1237 0 : comphelper::getProcessComponentContext()));
1238 0 : Sequence< Any > theArgs(1);
1239 0 : theArgs[0] = makeAny(NamedValue(OUString("nodepath"), makeAny(sUserLocalePath)));
1240 : Reference< XPropertySet >xProp(
1241 0 : theConfigProvider->createInstanceWithArguments(sAccessUpdSrvc, theArgs ), UNO_QUERY_THROW );
1242 0 : if ( !m_sUserLocaleValue.equals(aLangString))
1243 : {
1244 : // OSL_FAIL("UserInterface language was changed, restart.");
1245 : // write new value
1246 0 : xProp->setPropertyValue(sUserLocaleKey, makeAny(aLangString));
1247 0 : Reference< XChangesBatch >(xProp, UNO_QUERY_THROW)->commitChanges();
1248 : // display info
1249 0 : MessageDialog aBox(this, CUI_RES(RID_SVXSTR_LANGUAGE_RESTART), VCL_MESSAGE_INFO);
1250 0 : aBox.Execute();
1251 :
1252 : // tell quickstarter to stop being a veto listener
1253 :
1254 : Reference< XComponentContext > xContext(
1255 0 : comphelper::getProcessComponentContext());
1256 0 : css::office::Quickstart::createAndSetVeto(xContext, false, false, false/*DisableVeto*/);
1257 0 : }
1258 : }
1259 0 : catch (const Exception& e)
1260 : {
1261 : // we'll just leave the box in it's default setting and won't
1262 : // even give it event handler...
1263 : SAL_WARN("cui.options", "ignoring Exception \"" << e.Message << "\"");
1264 : }
1265 :
1266 0 : OUString sLang = pLangConfig->aSysLocaleOptions.GetLocaleConfigString();
1267 0 : LanguageType eOldLocale = (!sLang.isEmpty() ?
1268 0 : LanguageTag::convertToLanguageTypeWithFallback( sLang ) : LANGUAGE_SYSTEM);
1269 0 : LanguageType eNewLocale = m_pLocaleSettingLB->GetSelectLanguage();
1270 :
1271 : // If the "Default ..." entry was selected that means SYSTEM, the actual
1272 : // eNewLocale value is temporary for the dialog only, do not resolve to
1273 : // what system currently is.
1274 0 : if (eNewLocale == LANGUAGE_USER_SYSTEM_CONFIG)
1275 0 : eNewLocale = LANGUAGE_SYSTEM;
1276 :
1277 0 : if ( eOldLocale != eNewLocale )
1278 : {
1279 : // an empty string denotes SYSTEM locale
1280 0 : OUString sNewLang;
1281 0 : if ( eNewLocale != LANGUAGE_SYSTEM )
1282 0 : sNewLang = LanguageTag::convertToBcp47( eNewLocale);
1283 :
1284 : // locale nowadays get to AppSettings via notification
1285 : // this will happen after releasing the lock on the ConfigurationBroadcaster at
1286 : // the end of this method
1287 0 : pLangConfig->aSysLocaleOptions.SetLocaleConfigString( sNewLang );
1288 0 : rSet->Put( SfxBoolItem( SID_OPT_LOCALE_CHANGED, true ) );
1289 :
1290 0 : sal_uInt16 nNewType = SvtLanguageOptions::GetScriptTypeOfLanguage( eNewLocale );
1291 0 : bool bNewCJK = ( nNewType & SCRIPTTYPE_ASIAN ) != 0;
1292 0 : SvtCompatibilityOptions aCompatOpts;
1293 0 : aCompatOpts.SetDefault( COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE, !bNewCJK );
1294 : }
1295 :
1296 0 : if(m_pDecimalSeparatorCB->IsValueChangedFromSaved())
1297 0 : pLangConfig->aSysLocaleOptions.SetDecimalSeparatorAsLocale(m_pDecimalSeparatorCB->IsChecked());
1298 :
1299 0 : if(m_pIgnoreLanguageChangeCB->IsValueChangedFromSaved())
1300 0 : pLangConfig->aSysLocaleOptions.SetIgnoreLanguageChange(m_pIgnoreLanguageChangeCB->IsChecked());
1301 :
1302 : // Configured currency, for example, USD-en-US or EUR-de-DE, or empty for locale default.
1303 0 : OUString sOldCurr = pLangConfig->aSysLocaleOptions.GetCurrencyConfigString();
1304 0 : sal_Int32 nCurrPos = m_pCurrencyLB->GetSelectEntryPos();
1305 : const NfCurrencyEntry* pCurr = (const NfCurrencyEntry*)
1306 0 : m_pCurrencyLB->GetEntryData( nCurrPos );
1307 0 : OUString sNewCurr;
1308 0 : if ( pCurr )
1309 0 : sNewCurr = SvtSysLocaleOptions::CreateCurrencyConfigString(
1310 0 : pCurr->GetBankSymbol(), pCurr->GetLanguage() );
1311 0 : if ( sOldCurr != sNewCurr )
1312 0 : pLangConfig->aSysLocaleOptions.SetCurrencyConfigString( sNewCurr );
1313 :
1314 : // Configured date acceptance patterns, for example Y-M-D;M-D or empty for
1315 : // locale default.
1316 0 : if (m_bDatePatternsValid && m_pDatePatternsED->IsValueChangedFromSaved())
1317 0 : pLangConfig->aSysLocaleOptions.SetDatePatternsConfigString( m_pDatePatternsED->GetText());
1318 :
1319 0 : SfxObjectShell* pCurrentDocShell = SfxObjectShell::Current();
1320 0 : Reference< css::linguistic2::XLinguProperties > xLinguProp = LinguMgr::GetLinguPropertySet();
1321 0 : bool bCurrentDocCBChecked = m_pCurrentDocCB->IsChecked();
1322 0 : if(m_pCurrentDocCB->IsEnabled())
1323 0 : bLanguageCurrentDoc_Impl = bCurrentDocCBChecked;
1324 0 : bool bCurrentDocCBChanged = m_pCurrentDocCB->IsValueChangedFromSaved();
1325 :
1326 0 : bool bValChanged = m_pWesternLanguageLB->IsValueChangedFromSaved();
1327 0 : if( (bCurrentDocCBChanged && !bCurrentDocCBChecked) || bValChanged)
1328 : {
1329 0 : LanguageType eSelectLang = m_pWesternLanguageLB->GetSelectLanguage();
1330 0 : if(!bCurrentDocCBChecked)
1331 : {
1332 0 : Any aValue;
1333 0 : Locale aLocale = LanguageTag::convertToLocale( eSelectLang, false);
1334 0 : aValue <<= aLocale;
1335 0 : OUString aPropName( "DefaultLocale" );
1336 0 : pLangConfig->aLinguConfig.SetProperty( aPropName, aValue );
1337 0 : if (xLinguProp.is())
1338 0 : xLinguProp->setDefaultLocale( aLocale );
1339 : }
1340 0 : if(pCurrentDocShell)
1341 : {
1342 0 : rSet->Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, ::com::sun::star::i18n::ScriptType::LATIN),
1343 0 : SID_ATTR_LANGUAGE));
1344 : }
1345 : }
1346 0 : bValChanged = m_pAsianLanguageLB->IsValueChangedFromSaved();
1347 0 : if( (bCurrentDocCBChanged && !bCurrentDocCBChecked) || bValChanged)
1348 : {
1349 0 : LanguageType eSelectLang = m_pAsianLanguageLB->GetSelectLanguage();
1350 0 : if(!bCurrentDocCBChecked)
1351 : {
1352 0 : Any aValue;
1353 0 : Locale aLocale = LanguageTag::convertToLocale( eSelectLang, false);
1354 0 : aValue <<= aLocale;
1355 0 : OUString aPropName( "DefaultLocale_CJK" );
1356 0 : pLangConfig->aLinguConfig.SetProperty( aPropName, aValue );
1357 0 : if (xLinguProp.is())
1358 0 : xLinguProp->setDefaultLocale_CJK( aLocale );
1359 : }
1360 0 : if(pCurrentDocShell)
1361 : {
1362 0 : rSet->Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, ::com::sun::star::i18n::ScriptType::ASIAN),
1363 0 : SID_ATTR_CHAR_CJK_LANGUAGE));
1364 : }
1365 : }
1366 0 : bValChanged = m_pComplexLanguageLB->IsValueChangedFromSaved();
1367 0 : if( (bCurrentDocCBChanged && !bCurrentDocCBChecked) || bValChanged)
1368 : {
1369 0 : LanguageType eSelectLang = m_pComplexLanguageLB->GetSelectLanguage();
1370 0 : if(!bCurrentDocCBChecked)
1371 : {
1372 0 : Any aValue;
1373 0 : Locale aLocale = LanguageTag::convertToLocale( eSelectLang, false);
1374 0 : aValue <<= aLocale;
1375 0 : OUString aPropName( "DefaultLocale_CTL" );
1376 0 : pLangConfig->aLinguConfig.SetProperty( aPropName, aValue );
1377 0 : if (xLinguProp.is())
1378 0 : xLinguProp->setDefaultLocale_CTL( aLocale );
1379 : }
1380 0 : if(pCurrentDocShell)
1381 : {
1382 0 : rSet->Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, ::com::sun::star::i18n::ScriptType::COMPLEX),
1383 0 : SID_ATTR_CHAR_CTL_LANGUAGE));
1384 : }
1385 : }
1386 :
1387 0 : if(m_pAsianSupportCB->IsValueChangedFromSaved() )
1388 : {
1389 0 : bool bChecked = m_pAsianSupportCB->IsChecked();
1390 0 : pLangConfig->aLanguageOptions.SetAll(bChecked);
1391 :
1392 : //iterate over all bindings to invalidate vertical text direction
1393 0 : const sal_uInt16 STATE_COUNT = 2;
1394 :
1395 : SfxBoolItem* pBoolItems[STATE_COUNT];
1396 0 : pBoolItems[0] = new SfxBoolItem(SID_VERTICALTEXT_STATE, false);
1397 0 : pBoolItems[1] = new SfxBoolItem(SID_TEXT_FITTOSIZE_VERTICAL, false);
1398 :
1399 : SfxVoidItem* pInvalidItems[STATE_COUNT];
1400 0 : pInvalidItems[0] = new SfxVoidItem(SID_VERTICALTEXT_STATE);
1401 0 : pInvalidItems[1] = new SfxVoidItem(SID_TEXT_FITTOSIZE_VERTICAL);
1402 :
1403 0 : lcl_UpdateAndDelete(pInvalidItems, pBoolItems, STATE_COUNT);
1404 : }
1405 :
1406 0 : if ( m_pCTLSupportCB->IsValueChangedFromSaved() )
1407 : {
1408 0 : SvtSearchOptions aOpt;
1409 0 : aOpt.SetIgnoreDiacritics_CTL (true);
1410 0 : aOpt.SetIgnoreKashida_CTL (true);
1411 0 : pLangConfig->aLanguageOptions.SetCTLFontEnabled( m_pCTLSupportCB->IsChecked() );
1412 :
1413 0 : const sal_uInt16 STATE_COUNT = 1;
1414 : SfxBoolItem* pBoolItems[STATE_COUNT];
1415 0 : pBoolItems[0] = new SfxBoolItem(SID_CTLFONT_STATE, false);
1416 : SfxVoidItem* pInvalidItems[STATE_COUNT];
1417 0 : pInvalidItems[0] = new SfxVoidItem(SID_CTLFONT_STATE);
1418 0 : lcl_UpdateAndDelete(pInvalidItems, pBoolItems, STATE_COUNT);
1419 : }
1420 :
1421 0 : if ( pLangConfig->aSysLocaleOptions.IsModified() )
1422 0 : pLangConfig->aSysLocaleOptions.Commit();
1423 :
1424 : // first release the lock on the ConfigurationBroadcaster for Locale changes
1425 : // it seems that our code relies on the fact that before other changes like e.g. currency
1426 : // are broadcasted locale changes have been done
1427 0 : pLangConfig->aSysLocaleOptions.BlockBroadcasts( false );
1428 0 : pLangConfig->aLanguageOptions.BlockBroadcasts( false );
1429 0 : pLangConfig->aLinguConfig.BlockBroadcasts( false );
1430 :
1431 0 : return false;
1432 : }
1433 :
1434 0 : void OfaLanguagesTabPage::Reset( const SfxItemSet* rSet )
1435 : {
1436 0 : OUString sLang = pLangConfig->aSysLocaleOptions.GetLocaleConfigString();
1437 0 : if ( !sLang.isEmpty() )
1438 0 : m_pLocaleSettingLB->SelectLanguage(LanguageTag::convertToLanguageTypeWithFallback(sLang));
1439 : else
1440 0 : m_pLocaleSettingLB->SelectLanguage( LANGUAGE_USER_SYSTEM_CONFIG );
1441 0 : bool bReadonly = pLangConfig->aSysLocaleOptions.IsReadOnly(SvtSysLocaleOptions::E_LOCALE);
1442 0 : m_pLocaleSettingLB->Enable(!bReadonly);
1443 0 : m_pLocaleSettingFT->Enable(!bReadonly);
1444 :
1445 :
1446 0 : m_pDecimalSeparatorCB->Check( pLangConfig->aSysLocaleOptions.IsDecimalSeparatorAsLocale());
1447 0 : m_pDecimalSeparatorCB->SaveValue();
1448 :
1449 0 : m_pIgnoreLanguageChangeCB->Check( pLangConfig->aSysLocaleOptions.IsIgnoreLanguageChange());
1450 0 : m_pIgnoreLanguageChangeCB->SaveValue();
1451 :
1452 : // let LocaleSettingHdl enable/disable checkboxes for CJK/CTL support
1453 : // #i15812# must be done *before* the configured currency is set
1454 : // and update the decimal separator used for the given locale
1455 0 : LocaleSettingHdl(m_pLocaleSettingLB);
1456 :
1457 : // configured currency, for example, USD-en-US or EUR-de-DE, or empty for locale default
1458 0 : OUString aAbbrev;
1459 : LanguageType eLang;
1460 0 : const NfCurrencyEntry* pCurr = NULL;
1461 0 : sLang = pLangConfig->aSysLocaleOptions.GetCurrencyConfigString();
1462 0 : if ( !sLang.isEmpty() )
1463 : {
1464 0 : SvtSysLocaleOptions::GetCurrencyAbbrevAndLanguage( aAbbrev, eLang, sLang );
1465 0 : pCurr = SvNumberFormatter::GetCurrencyEntry( aAbbrev, eLang );
1466 : }
1467 : // if pCurr==NULL the SYSTEM entry is selected
1468 0 : sal_uInt16 nPos = m_pCurrencyLB->GetEntryPos( (void*) pCurr );
1469 0 : m_pCurrencyLB->SelectEntryPos( nPos );
1470 0 : bReadonly = pLangConfig->aSysLocaleOptions.IsReadOnly(SvtSysLocaleOptions::E_CURRENCY);
1471 0 : m_pCurrencyLB->Enable(!bReadonly);
1472 0 : m_pCurrencyFT->Enable(!bReadonly);
1473 :
1474 : // date acceptance patterns
1475 0 : OUString aDatePatternsString = pLangConfig->aSysLocaleOptions.GetDatePatternsConfigString();
1476 0 : if (aDatePatternsString.isEmpty())
1477 : {
1478 0 : const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
1479 0 : aDatePatternsString = lcl_getDatePatternsConfigString( rLocaleWrapper);
1480 : }
1481 : // Let's assume patterns are valid at this point.
1482 0 : m_bDatePatternsValid = true;
1483 0 : m_pDatePatternsED->SetText( aDatePatternsString);
1484 0 : bReadonly = pLangConfig->aSysLocaleOptions.IsReadOnly(SvtSysLocaleOptions::E_DATEPATTERNS);
1485 0 : m_pDatePatternsED->Enable(!bReadonly);
1486 0 : m_pDatePatternsFT->Enable(!bReadonly);
1487 0 : m_pDatePatternsED->SaveValue();
1488 :
1489 : //western/CJK/CLK language
1490 0 : LanguageType eCurLang = LANGUAGE_NONE;
1491 0 : LanguageType eCurLangCJK = LANGUAGE_NONE;
1492 0 : LanguageType eCurLangCTL = LANGUAGE_NONE;
1493 0 : SfxObjectShell* pCurrentDocShell = SfxObjectShell::Current();
1494 : //collect the configuration values first
1495 0 : m_pCurrentDocCB->Enable(false);
1496 :
1497 0 : Any aWestLang;
1498 0 : Any aCJKLang;
1499 0 : Any aCTLLang;
1500 : try
1501 : {
1502 0 : aWestLang = pLangConfig->aLinguConfig.GetProperty("DefaultLocale");
1503 0 : Locale aLocale;
1504 0 : aWestLang >>= aLocale;
1505 :
1506 0 : eCurLang = LanguageTag::convertToLanguageType( aLocale, false);
1507 :
1508 0 : aCJKLang = pLangConfig->aLinguConfig.GetProperty("DefaultLocale_CJK");
1509 0 : aLocale = Locale();
1510 0 : aCJKLang >>= aLocale;
1511 0 : eCurLangCJK = LanguageTag::convertToLanguageType( aLocale, false);
1512 :
1513 0 : aCTLLang = pLangConfig->aLinguConfig.GetProperty("DefaultLocale_CTL");
1514 0 : aLocale = Locale();
1515 0 : aCTLLang >>= aLocale;
1516 0 : eCurLangCTL = LanguageTag::convertToLanguageType( aLocale, false);
1517 : }
1518 0 : catch (const Exception&)
1519 : {
1520 : }
1521 : //overwrite them by the values provided by the DocShell
1522 0 : if(pCurrentDocShell)
1523 : {
1524 0 : m_pCurrentDocCB->Enable(true);
1525 0 : m_pCurrentDocCB->Check(bLanguageCurrentDoc_Impl);
1526 : const SfxPoolItem* pLang;
1527 0 : if( SfxItemState::SET == rSet->GetItemState(SID_ATTR_LANGUAGE, false, &pLang))
1528 : {
1529 0 : LanguageType eTempCurLang = static_cast<const SvxLanguageItem*>(pLang)->GetValue();
1530 0 : if (MsLangId::resolveSystemLanguageByScriptType(eCurLang, ::com::sun::star::i18n::ScriptType::LATIN) != eTempCurLang)
1531 0 : eCurLang = eTempCurLang;
1532 : }
1533 :
1534 0 : if( SfxItemState::SET == rSet->GetItemState(SID_ATTR_CHAR_CJK_LANGUAGE, false, &pLang))
1535 : {
1536 0 : LanguageType eTempCurLang = static_cast<const SvxLanguageItem*>(pLang)->GetValue();
1537 0 : if (MsLangId::resolveSystemLanguageByScriptType(eCurLangCJK, ::com::sun::star::i18n::ScriptType::ASIAN) != eTempCurLang)
1538 0 : eCurLangCJK = eTempCurLang;
1539 : }
1540 :
1541 0 : if( SfxItemState::SET == rSet->GetItemState(SID_ATTR_CHAR_CTL_LANGUAGE, false, &pLang))
1542 : {
1543 0 : LanguageType eTempCurLang = static_cast<const SvxLanguageItem*>(pLang)->GetValue();
1544 0 : if (MsLangId::resolveSystemLanguageByScriptType(eCurLangCTL, ::com::sun::star::i18n::ScriptType::COMPLEX) != eTempCurLang)
1545 0 : eCurLangCTL = eTempCurLang;
1546 : }
1547 : }
1548 0 : if(LANGUAGE_NONE == eCurLang || LANGUAGE_DONTKNOW == eCurLang)
1549 0 : m_pWesternLanguageLB->SelectLanguage(LANGUAGE_NONE);
1550 : else
1551 0 : m_pWesternLanguageLB->SelectLanguage(eCurLang);
1552 :
1553 0 : if(LANGUAGE_NONE == eCurLangCJK || LANGUAGE_DONTKNOW == eCurLangCJK)
1554 0 : m_pAsianLanguageLB->SelectLanguage(LANGUAGE_NONE);
1555 : else
1556 0 : m_pAsianLanguageLB->SelectLanguage(eCurLangCJK);
1557 :
1558 0 : if(LANGUAGE_NONE == eCurLangCTL || LANGUAGE_DONTKNOW == eCurLangCTL)
1559 0 : m_pComplexLanguageLB->SelectLanguage(LANGUAGE_NONE);
1560 : else
1561 0 : m_pComplexLanguageLB->SelectLanguage(eCurLangCTL);
1562 :
1563 0 : m_pWesternLanguageLB->SaveValue();
1564 0 : m_pAsianLanguageLB->SaveValue();
1565 0 : m_pComplexLanguageLB->SaveValue();
1566 0 : m_pIgnoreLanguageChangeCB->SaveValue();
1567 0 : m_pCurrentDocCB->SaveValue();
1568 :
1569 0 : bool bEnable = !pLangConfig->aLinguConfig.IsReadOnly( "DefaultLocale" );
1570 0 : m_pWesternLanguageFT->Enable( bEnable );
1571 0 : m_pWesternLanguageLB->Enable( bEnable );
1572 :
1573 :
1574 :
1575 : // #i15812# controls for CJK/CTL already enabled/disabled from LocaleSettingHdl
1576 : #if 0
1577 : bEnable = ( !pLangConfig->aLinguConfig.IsReadOnly( "DefaultLocale_CJK" ) && m_pAsianSupportCB->IsChecked() );
1578 : m_pAsianLanguageLB->Enable( bEnable );
1579 :
1580 : bEnable = ( !pLangConfig->aLinguConfig.IsReadOnly( "DefaultLocale_CTL" ) && m_pCTLSupportCB->IsChecked() );
1581 : m_pComplexLanguageLB->Enable( bEnable );
1582 : #endif
1583 : // check the box "For the current document only"
1584 : // set the focus to the Western Language box
1585 0 : const SfxPoolItem* pLang = 0;
1586 0 : if ( SfxItemState::SET == rSet->GetItemState(SID_SET_DOCUMENT_LANGUAGE, false, &pLang ) && static_cast<const SfxBoolItem*>(pLang)->GetValue() )
1587 : {
1588 0 : m_pWesternLanguageLB->GrabFocus();
1589 0 : m_pCurrentDocCB->Enable(true);
1590 0 : m_pCurrentDocCB->Check(true);
1591 0 : }
1592 0 : }
1593 :
1594 0 : IMPL_LINK( OfaLanguagesTabPage, SupportHdl, CheckBox*, pBox )
1595 : {
1596 : DBG_ASSERT( pBox, "OfaLanguagesTabPage::SupportHdl(): pBox invalid" );
1597 :
1598 0 : bool bCheck = pBox->IsChecked();
1599 0 : if ( m_pAsianSupportCB == pBox )
1600 : {
1601 0 : bool bReadonly = pLangConfig->aLinguConfig.IsReadOnly("DefaultLocale_CJK");
1602 0 : bCheck = ( bCheck && !bReadonly );
1603 0 : m_pAsianLanguageLB->Enable( bCheck );
1604 0 : if( pBox->IsEnabled() )
1605 0 : m_bOldAsian = bCheck;
1606 : }
1607 0 : else if ( m_pCTLSupportCB == pBox )
1608 : {
1609 0 : bool bReadonly = pLangConfig->aLinguConfig.IsReadOnly("DefaultLocale_CTL");
1610 0 : bCheck = ( bCheck && !bReadonly );
1611 0 : m_pComplexLanguageLB->Enable( bCheck );
1612 0 : if( pBox->IsEnabled() )
1613 0 : m_bOldCtl = bCheck;
1614 : }
1615 : else
1616 : SAL_WARN( "cui.options", "OfaLanguagesTabPage::SupportHdl(): wrong pBox" );
1617 :
1618 0 : return 0;
1619 : }
1620 :
1621 : namespace
1622 : {
1623 0 : void lcl_checkLanguageCheckBox(CheckBox* _rCB,bool _bNewValue,bool _bOldValue)
1624 : {
1625 0 : if ( _bNewValue )
1626 0 : _rCB->Check(true);
1627 : else
1628 0 : _rCB->Check( _bOldValue );
1629 : // #i15082# do not call SaveValue() in running dialog...
1630 : // _rCB.SaveValue();
1631 0 : _rCB->Enable( !_bNewValue );
1632 0 : }
1633 : }
1634 :
1635 0 : IMPL_LINK( OfaLanguagesTabPage, LocaleSettingHdl, SvxLanguageBox*, pBox )
1636 : {
1637 0 : LanguageType eLang = pBox->GetSelectLanguage();
1638 0 : sal_uInt16 nType = SvtLanguageOptions::GetScriptTypeOfLanguage(eLang);
1639 : // first check if CTL must be enabled
1640 : // #103299# - if CTL font setting is not readonly
1641 0 : if(!pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_CTLFONT))
1642 : {
1643 0 : bool bIsCTLFixed = (nType & SCRIPTTYPE_COMPLEX) != 0;
1644 0 : lcl_checkLanguageCheckBox(m_pCTLSupportCB, bIsCTLFixed, m_bOldCtl);
1645 0 : SupportHdl( m_pCTLSupportCB );
1646 : }
1647 : // second check if CJK must be enabled
1648 : // #103299# - if CJK support is not readonly
1649 0 : if(!pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_ALLCJK))
1650 : {
1651 0 : bool bIsCJKFixed = (nType & SCRIPTTYPE_ASIAN) != 0;
1652 0 : lcl_checkLanguageCheckBox(m_pAsianSupportCB, bIsCJKFixed, m_bOldAsian);
1653 0 : SupportHdl( m_pAsianSupportCB );
1654 : }
1655 :
1656 : const NfCurrencyEntry* pCurr = &SvNumberFormatter::GetCurrencyEntry(
1657 0 : ((eLang == LANGUAGE_USER_SYSTEM_CONFIG) ? MsLangId::getSystemLanguage() : eLang));
1658 0 : sal_uInt16 nPos = m_pCurrencyLB->GetEntryPos( (void*) NULL );
1659 0 : if (pCurr)
1660 : {
1661 : // Update the "Default ..." currency.
1662 0 : m_pCurrencyLB->RemoveEntry( nPos );
1663 0 : OUString aDefaultCurr = m_sSystemDefaultString + " - " + pCurr->GetBankSymbol();
1664 0 : nPos = m_pCurrencyLB->InsertEntry( aDefaultCurr );
1665 : }
1666 0 : m_pCurrencyLB->SelectEntryPos( nPos );
1667 :
1668 : // obtain corresponding locale data
1669 0 : LanguageTag aLanguageTag( eLang);
1670 0 : LocaleDataWrapper aLocaleWrapper( aLanguageTag );
1671 :
1672 : // update the decimal separator key of the related CheckBox
1673 0 : OUString sTempLabel(m_pDecimalSeparatorCB->GetText());
1674 0 : sTempLabel = sTempLabel.replaceFirst("%1", aLocaleWrapper.getNumDecimalSep() );
1675 0 : m_pDecimalSeparatorCB->SetText(sTempLabel);
1676 :
1677 : // update the date acceptance patterns
1678 0 : OUString aDatePatternsString = lcl_getDatePatternsConfigString( aLocaleWrapper);
1679 0 : m_bDatePatternsValid = true;
1680 0 : m_pDatePatternsED->SetText( aDatePatternsString);
1681 :
1682 0 : return 0;
1683 : }
1684 :
1685 0 : IMPL_LINK( OfaLanguagesTabPage, DatePatternsHdl, Edit*, pEd )
1686 : {
1687 0 : const OUString aPatterns( pEd->GetText());
1688 0 : OUStringBuffer aBuf( aPatterns);
1689 0 : sal_Int32 nChar = 0;
1690 0 : bool bValid = true;
1691 0 : bool bModified = false;
1692 0 : if (!aPatterns.isEmpty())
1693 : {
1694 0 : for (sal_Int32 nIndex=0; nIndex >= 0 && bValid; ++nChar)
1695 : {
1696 0 : const OUString aPat( aPatterns.getToken( 0, ';', nIndex));
1697 0 : if (aPat.isEmpty() && nIndex < 0)
1698 : {
1699 : // Indicating failure when about to append a pattern is too
1700 : // confusing. Empty patterns are ignored anyway when sequencing
1701 : // to SvtSysLocale.
1702 0 : continue; // for
1703 : }
1704 0 : else if (aPat.getLength() < 2)
1705 0 : bValid = false;
1706 : else
1707 : {
1708 : bool bY, bM, bD;
1709 0 : bY = bM = bD = false;
1710 0 : bool bSep = true;
1711 0 : for (sal_Int32 i = 0; i < aPat.getLength() && bValid; /*nop*/)
1712 : {
1713 0 : const sal_Int32 j = i;
1714 0 : const sal_uInt32 c = aPat.iterateCodePoints( &i);
1715 : // Only one Y,M,D per pattern, separated by any character(s).
1716 0 : switch (c)
1717 : {
1718 : case 'y':
1719 : case 'Y':
1720 0 : if (bY || !bSep)
1721 0 : bValid = false;
1722 0 : else if (c == 'y')
1723 : {
1724 0 : aBuf[nChar] = 'Y';
1725 0 : bModified = true;
1726 : }
1727 0 : bY = true;
1728 0 : bSep = false;
1729 0 : break;
1730 : case 'm':
1731 : case 'M':
1732 0 : if (bM || !bSep)
1733 0 : bValid = false;
1734 0 : else if (c == 'm')
1735 : {
1736 0 : aBuf[nChar] = 'M';
1737 0 : bModified = true;
1738 : }
1739 0 : bM = true;
1740 0 : bSep = false;
1741 0 : break;
1742 : case 'd':
1743 : case 'D':
1744 0 : if (bD || !bSep)
1745 0 : bValid = false;
1746 0 : else if (c == 'd')
1747 : {
1748 0 : aBuf[nChar] = 'D';
1749 0 : bModified = true;
1750 : }
1751 0 : bD = true;
1752 0 : bSep = false;
1753 0 : break;
1754 : default:
1755 : // A pattern must not start with a separator (but
1756 : // may end with).
1757 0 : if (!(bY || bM || bD))
1758 0 : bValid = false;
1759 0 : bSep = true;
1760 : }
1761 0 : nChar += i-j;
1762 : }
1763 : // At least one of Y,M,D
1764 0 : bValid &= (bY || bM || bD);
1765 : }
1766 0 : }
1767 : }
1768 0 : if (bModified)
1769 : {
1770 : // Do not use SetText(...,GetSelection()) because internally the
1771 : // reference's pointer of the selection is obtained resulting in the
1772 : // entire text being selected at the end.
1773 0 : Selection aSelection( pEd->GetSelection());
1774 0 : pEd->SetText( aBuf.makeStringAndClear(), aSelection);
1775 : }
1776 0 : if (bValid)
1777 : {
1778 0 : pEd->SetControlForeground();
1779 0 : pEd->SetControlBackground();
1780 : }
1781 : else
1782 : {
1783 : #if 0
1784 : //! Gives white on white!?! instead of white on reddish.
1785 : pEd->SetControlBackground( ::Color( RGB_COLORDATA( 0xff, 0x65, 0x63)));
1786 : pEd->SetControlForeground( ::Color( COL_WHITE));
1787 : #else
1788 0 : pEd->SetControlForeground( ::Color( RGB_COLORDATA( 0xf0, 0, 0)));
1789 : #endif
1790 : }
1791 0 : m_bDatePatternsValid = bValid;
1792 0 : return 0;
1793 0 : }
1794 :
1795 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|