LibreOffice Module cui (master) 1
optgdlg.cxx
Go to the documentation of this file.
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 <config_features.h>
21#include <svl/numformat.hxx>
22#include <svl/zforlist.hxx>
23#include <svl/currencytable.hxx>
24#include <svtools/langhelp.hxx>
25#include <unotools/lingucfg.hxx>
26#if defined(_WIN32)
27#include <unotools/resmgr.hxx>
28#endif
29#include <sfx2/bindings.hxx>
30#include <sfx2/viewfrm.hxx>
35#include <svl/cjkoptions.hxx>
36#include <svl/ctloptions.hxx>
37#include <svtools/miscopt.hxx>
39#include <sfx2/objsh.hxx>
42#include <svtools/langtab.hxx>
43#include <editeng/unolingu.hxx>
44#include <editeng/langitem.hxx>
46#include <comphelper/string.hxx>
47#include <rtl/ustrbuf.hxx>
48#include <editeng/editids.hrc>
49#include <svx/svxids.hrc>
50#include <svl/intitem.hxx>
53#include <sal/log.hxx>
54#include <officecfg/Office/Common.hxx>
55#include <officecfg/Setup.hxx>
58#if HAVE_FEATURE_BREAKPAD
60#endif
61
62#include <com/sun/star/configuration/theDefaultProvider.hpp>
63#include <com/sun/star/container/XNameAccess.hpp>
64#include <com/sun/star/container/XNameReplace.hpp>
65#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
66#include <com/sun/star/beans/NamedValue.hpp>
67#include <com/sun/star/beans/PropertyAttribute.hpp>
68#include <com/sun/star/beans/XPropertySet.hpp>
69#include <com/sun/star/util/XChangesBatch.hpp>
70#include <com/sun/star/uno/Any.hxx>
71#include <com/sun/star/container/XContentEnumerationAccess.hpp>
72#include <com/sun/star/container/XSet.hpp>
73#include <com/sun/star/i18n/ScriptType.hpp>
74#include <com/sun/star/office/Quickstart.hpp>
75#include <com/sun/star/linguistic2/XLinguProperties.hpp>
77
78#include <vcl/vclenum.hxx>
79#include <vcl/svapp.hxx>
80#include <vcl/settings.hxx>
81#include <vcl/window.hxx>
82#include <vcl/IconThemeInfo.hxx>
84#include <bitmaps.hlst>
85
86#include "optgdlg.hxx"
87#include <svtools/apearcfg.hxx>
90#include <svtools/imgdef.hxx>
91#include <com/sun/star/datatransfer/clipboard/SystemClipboard.hpp>
92#include <vcl/unohelp2.hxx>
93
94#if defined(_WIN32)
95#include <systools/win32/winstoreutil.hxx>
97#endif
98using namespace ::com::sun::star::uno;
99using namespace ::com::sun::star::lang;
100using namespace ::com::sun::star::beans;
101using namespace ::com::sun::star::container;
102using namespace ::com::sun::star::util;
103using namespace ::utl;
104
105// class OfaMiscTabPage --------------------------------------------------
106
108{
109 if ( pSet_ )
110 FillItemSet( pSet_ );
111 return DeactivateRC::LeavePage;
112}
113
114namespace
115{
116OUString impl_SystemFileOpenServiceName()
117{
118 #if defined(_WIN32)
119 return "com.sun.star.ui.dialogs.SystemFilePicker";
120 #elif defined MACOSX
121 return "com.sun.star.ui.dialogs.AquaFilePicker";
122 #else
123 return OUString();
124 #endif
125}
126
127bool lcl_HasSystemFilePicker()
128{
130 return true;
131
132 // Otherwise fall-back on querying services
133 bool bRet = false;
135
136 Reference< XContentEnumerationAccess > xEnumAccess( xFactory, UNO_QUERY );
137 Reference< XSet > xSet( xFactory, UNO_QUERY );
138
139 if ( ! xEnumAccess.is() || ! xSet.is() )
140 return bRet;
141
142 try
143 {
144 OUString aFileService = impl_SystemFileOpenServiceName();
145 Reference< XEnumeration > xEnum = xEnumAccess->createContentEnumeration( aFileService );
146 if ( xEnum.is() && xEnum->hasMoreElements() )
147 bRet = true;
148 }
149 catch (const IllegalArgumentException&)
150 {
151 }
152 catch (const ElementExistException&)
153 {
154 }
155 return bRet;
156}
157}
158
160 : SfxTabPage(pPage, pController, "cui/ui/optgeneralpage.ui", "OptGeneralPage", &rSet)
161 , m_xExtHelpCB(m_xBuilder->weld_check_button("exthelp"))
162 , m_xPopUpNoHelpCB(m_xBuilder->weld_check_button("popupnohelp"))
163 , m_xShowTipOfTheDay(m_xBuilder->weld_check_button("cbShowTipOfTheDay"))
164 , m_xFileDlgFrame(m_xBuilder->weld_widget("filedlgframe"))
165 , m_xFileDlgROImage(m_xBuilder->weld_widget("lockimage"))
166 , m_xFileDlgCB(m_xBuilder->weld_check_button("filedlg"))
167 , m_xDocStatusCB(m_xBuilder->weld_check_button("docstatus"))
168 , m_xYearFrame(m_xBuilder->weld_widget("yearframe"))
169 , m_xYearValueField(m_xBuilder->weld_spin_button("year"))
170 , m_xToYearFT(m_xBuilder->weld_label("toyear"))
171#if HAVE_FEATURE_BREAKPAD
172 , m_xPrivacyFrame(m_xBuilder->weld_widget("privacyframe"))
173 , m_xCrashReport(m_xBuilder->weld_check_button("crashreport"))
174#endif
175#if defined(_WIN32)
176 , m_xQuickStarterFrame(m_xBuilder->weld_widget("quickstarter"))
177 , m_xQuickLaunchCB(m_xBuilder->weld_check_button("quicklaunch"))
178 , m_xFileAssocFrame(m_xBuilder->weld_widget("fileassoc"))
179 , m_xFileAssocBtn(m_xBuilder->weld_button("assocfiles"))
180 , m_xPerformFileExtCheck(m_xBuilder->weld_check_button("cbPerformFileExtCheck"))
181#endif
182{
183 if (!lcl_HasSystemFilePicker())
184 m_xFileDlgFrame->hide();
185 else if (officecfg::Office::Common::Misc::UseSystemFileDialog::isReadOnly())
186 {
187 m_xFileDlgROImage->show();
188 m_xFileDlgCB->set_sensitive(false);
189 }
190
191#if HAVE_FEATURE_BREAKPAD
192 m_xPrivacyFrame->show();
193#endif
194
195#if defined(_WIN32)
196 // Store-packaged apps (located under the protected Program Files\WindowsApps) can't use normal
197 // shell shortcuts to their exe. TODO: show a button to open "Startup Apps" system applet?
198 if (!sal::systools::IsStorePackagedApp())
199 m_xQuickStarterFrame->show();
200
201 m_xFileAssocFrame->show();
202 m_xFileAssocBtn->connect_clicked(LINK(this, OfaMiscTabPage, FileAssocClick));
203#endif
204
205 m_aStrDateInfo = m_xToYearFT->get_label();
206 m_xYearValueField->connect_value_changed( LINK( this, OfaMiscTabPage, TwoFigureHdl ) );
207
209}
210
212{
213}
214
215std::unique_ptr<SfxTabPage> OfaMiscTabPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet )
216{
217 return std::make_unique<OfaMiscTabPage>( pPage, pController, *rAttrSet );
218}
219
221{
222 bool bModified = false;
223 std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
224
225 if ( m_xPopUpNoHelpCB->get_state_changed_from_saved() )
226 officecfg::Office::Common::Help::BuiltInHelpNotInstalledPopUp::set(m_xPopUpNoHelpCB->get_active(), batch);
227
228 if ( m_xExtHelpCB->get_state_changed_from_saved() )
229 officecfg::Office::Common::Help::ExtendedTip::set(m_xExtHelpCB->get_active(), batch);
230
231 if ( m_xShowTipOfTheDay->get_state_changed_from_saved() )
232 {
233 officecfg::Office::Common::Misc::ShowTipOfTheDay::set(m_xShowTipOfTheDay->get_active(), batch);
234 bModified = true;
235 }
236
237 if ( m_xFileDlgCB->get_state_changed_from_saved() )
238 {
239 officecfg::Office::Common::Misc::UseSystemFileDialog::set( !m_xFileDlgCB->get_active(), batch );
240 bModified = true;
241 }
242
243 if (m_xDocStatusCB->get_state_changed_from_saved())
244 {
245 officecfg::Office::Common::Print::PrintingModifiesDocument::set(m_xDocStatusCB->get_active(), batch);
246 bModified = true;
247 }
248
249 const SfxUInt16Item* pUInt16Item = GetOldItem( *rSet, SID_ATTR_YEAR2000 );
250 sal_uInt16 nNum = static_cast<sal_uInt16>(m_xYearValueField->get_text().toInt32());
251 if ( pUInt16Item && pUInt16Item->GetValue() != nNum )
252 {
253 bModified = true;
254 rSet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, nNum ) );
255 }
256
257#if HAVE_FEATURE_BREAKPAD
258 if (m_xCrashReport->get_state_changed_from_saved())
259 {
260 officecfg::Office::Common::Misc::CrashReport::set(m_xCrashReport->get_active(), batch);
261 bModified = true;
262 }
263#endif
264
265#if defined(_WIN32)
266 if (m_xPerformFileExtCheck->get_state_changed_from_saved())
267 {
268 officecfg::Office::Common::Misc::PerformFileExtCheck::set(
269 m_xPerformFileExtCheck->get_active(), batch);
270 bModified = true;
271 }
272
273 if( m_xQuickLaunchCB->get_state_changed_from_saved())
274 {
275 rSet->Put(SfxBoolItem(SID_ATTR_QUICKLAUNCHER, m_xQuickLaunchCB->get_active()));
276 bModified = true;
277 }
278#endif
279
280 batch->commit();
281
282 return bModified;
283}
284
286{
287 m_xExtHelpCB->set_active( officecfg::Office::Common::Help::Tip::get() &&
288 officecfg::Office::Common::Help::ExtendedTip::get() );
289 m_xExtHelpCB->save_state();
290 m_xPopUpNoHelpCB->set_active( officecfg::Office::Common::Help::BuiltInHelpNotInstalledPopUp::get() );
291 m_xPopUpNoHelpCB->save_state();
292 m_xShowTipOfTheDay->set_active( officecfg::Office::Common::Misc::ShowTipOfTheDay::get() );
293 m_xShowTipOfTheDay->save_state();
294 m_xFileDlgCB->set_active( !officecfg::Office::Common::Misc::UseSystemFileDialog::get() );
295 m_xFileDlgCB->save_state();
296
297 m_xDocStatusCB->set_active(officecfg::Office::Common::Print::PrintingModifiesDocument::get());
298 m_xDocStatusCB->save_state();
299
300 if ( const SfxUInt16Item* pYearItem = rSet->GetItemIfSet( SID_ATTR_YEAR2000, false ) )
301 {
302 m_xYearValueField->set_value( pYearItem->GetValue() );
303 TwoFigureHdl(*m_xYearValueField);
304 }
305 else
306 m_xYearFrame->set_sensitive(false);
307
308#if HAVE_FEATURE_BREAKPAD
309 m_xCrashReport->set_active(officecfg::Office::Common::Misc::CrashReport::get() && CrashReporter::IsDumpEnable());
310 m_xCrashReport->set_sensitive(!officecfg::Office::Common::Misc::CrashReport::isReadOnly() && CrashReporter::IsDumpEnable());
311 m_xCrashReport->save_state();
312#endif
313
314#if defined(_WIN32)
315 const SfxPoolItem* pItem = nullptr;
316 SfxItemState eState = rSet->GetItemState( SID_ATTR_QUICKLAUNCHER, false, &pItem );
317 if ( SfxItemState::SET == eState )
318 m_xQuickLaunchCB->set_active( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
319 else if ( SfxItemState::DISABLED == eState )
320 {
321 // quickstart not installed
322 m_xQuickStarterFrame->hide();
323 }
324
325 m_xQuickLaunchCB->save_state();
326
327 m_xPerformFileExtCheck->set_active(
328 officecfg::Office::Common::Misc::PerformFileExtCheck::get());
329 m_xPerformFileExtCheck->save_state();
330 m_xPerformFileExtCheck->set_sensitive(!officecfg::Office::Common::Misc::PerformFileExtCheck::isReadOnly());
331#endif
332}
333
335{
336 OUString aOutput( m_aStrDateInfo );
337 OUString aStr( m_xYearValueField->get_text() );
338 sal_Int32 nNum = aStr.toInt32();
339 if ( aStr.getLength() != 4 || nNum < m_xYearValueField->get_min() || nNum > m_xYearValueField->get_max() )
340 aOutput += "????";
341 else
342 {
343 nNum += 99;
344 aOutput += OUString::number( nNum );
345 }
346 m_xToYearFT->set_label( aOutput );
347}
348
349#if defined(_WIN32)
351{
353}
354#endif
355
357{
358public:
360
363 bool IsHardwareAccelerationRO() const;
364 void EnabledHardwareAcceleration( bool _bEnabled ) const;
365
366private:
367 typedef std::vector< std::pair<OUString,Sequence<OUString> > > ServiceVector;
368
369 Reference<XNameAccess> mxForceFlagNameAccess;
371 mutable bool mbHWAccelAvailable;
372 mutable bool mbHWAccelChecked;
373};
374
376 mbHWAccelAvailable(false),
377 mbHWAccelChecked(false)
378{
379 try
380 {
381 Reference<XMultiServiceFactory> xConfigProvider(
382 css::configuration::theDefaultProvider::get(
384
385 Sequence<Any> aArgs1(comphelper::InitAnyPropertySequence(
386 {
387 {"nodepath", Any(OUString("/org.openoffice.Office.Canvas"))}
388 }));
390 xConfigProvider->createInstanceWithArguments(
391 "com.sun.star.configuration.ConfigurationUpdateAccess",
392 aArgs1 ),
393 UNO_QUERY_THROW );
394
395 Sequence<Any> aArgs2(comphelper::InitAnyPropertySequence(
396 {
397 {"nodepath", Any(OUString("/org.openoffice.Office.Canvas/CanvasServiceList"))}
398 }));
399 Reference<XNameAccess> xNameAccess(
400 xConfigProvider->createInstanceWithArguments(
401 "com.sun.star.configuration.ConfigurationAccess",
402 aArgs2 ), UNO_QUERY_THROW );
403 Reference<XHierarchicalNameAccess> xHierarchicalNameAccess(
404 xNameAccess, UNO_QUERY_THROW);
405
406 Sequence<OUString> serviceNames = xNameAccess->getElementNames();
407 const OUString* pCurr = serviceNames.getConstArray();
408 const OUString* const pEnd = pCurr + serviceNames.getLength();
409 while( pCurr != pEnd )
410 {
411 Reference<XNameAccess> xEntryNameAccess(
412 xHierarchicalNameAccess->getByHierarchicalName(*pCurr),
413 UNO_QUERY );
414
415 if( xEntryNameAccess.is() )
416 {
417 Sequence<OUString> preferredImplementations;
418 if( xEntryNameAccess->getByName("PreferredImplementations") >>= preferredImplementations )
419 maAvailableImplementations.emplace_back(*pCurr,preferredImplementations );
420 }
421
422 ++pCurr;
423 }
424 }
425 catch (const Exception&)
426 {
427 }
428}
429
431{
432 if( !mbHWAccelChecked )
433 {
434 mbHWAccelChecked = true;
435
437
438 // check whether any of the service lists has an
439 // implementation that presents the "HardwareAcceleration" property
440 for (auto const& availableImpl : maAvailableImplementations)
441 {
442 const OUString* pCurrImpl = availableImpl.second.getConstArray();
443 const OUString* const pEndImpl = pCurrImpl + availableImpl.second.getLength();
444
445 while( pCurrImpl != pEndImpl )
446 {
447 try
448 {
449 Reference<XPropertySet> xPropSet( xFactory->createInstance(
450 pCurrImpl->trim() ),
451 UNO_QUERY_THROW );
452 bool bHasAccel(false);
453 if( xPropSet->getPropertyValue("HardwareAcceleration") >>= bHasAccel )
454 if( bHasAccel )
455 {
456 mbHWAccelAvailable = true;
457 return mbHWAccelAvailable;
458 }
459 }
460 catch (const Exception&)
461 {
462 }
463
464 ++pCurrImpl;
465 }
466 }
467 }
468
469 return mbHWAccelAvailable;
470}
471
473{
474 bool bForceLastEntry(false);
475 if( !mxForceFlagNameAccess.is() )
476 return true;
477
478 if( !(mxForceFlagNameAccess->getByName("ForceSafeServiceImpl") >>= bForceLastEntry) )
479 return true;
480
481 return !bForceLastEntry;
482}
483
485{
487 if (!xSet.is())
488 return true;
489
490 Reference< XPropertySetInfo > xInfo = xSet->getPropertySetInfo();
491 Property aProp = xInfo->getPropertyByName("ForceSafeServiceImpl");
492 return ((aProp.Attributes & css::beans::PropertyAttribute::READONLY ) == css::beans::PropertyAttribute::READONLY);
493}
494
496{
497 Reference< XNameReplace > xNameReplace(
498 mxForceFlagNameAccess, UNO_QUERY );
499
500 if( !xNameReplace.is() )
501 return;
502
503 xNameReplace->replaceByName( "ForceSafeServiceImpl", Any(!_bEnabled) );
504
505 Reference< XChangesBatch > xChangesBatch(
506 mxForceFlagNameAccess, UNO_QUERY );
507
508 if( !xChangesBatch.is() )
509 return;
510
511 xChangesBatch->commitChanges();
512}
513
514// class OfaViewTabPage --------------------------------------------------
515
516static bool DisplayNameCompareLessThan(const vcl::IconThemeInfo& rInfo1, const vcl::IconThemeInfo& rInfo2)
517{
518 return rInfo1.GetDisplayName().compareTo(rInfo2.GetDisplayName()) < 0;
519}
520
522 : SfxTabPage(pPage, pController, "cui/ui/optviewpage.ui", "OptViewPage", &rSet)
523 , nSizeLB_InitialSelection(0)
524 , nSidebarSizeLB_InitialSelection(0)
525 , nNotebookbarSizeLB_InitialSelection(0)
526 , nStyleLB_InitialSelection(0)
527 , pCanvasSettings(new CanvasSettings)
528 , m_xIconSizeLB(m_xBuilder->weld_combo_box("iconsize"))
529 , m_xSidebarIconSizeLB(m_xBuilder->weld_combo_box("sidebariconsize"))
530 , m_xNotebookbarIconSizeLB(m_xBuilder->weld_combo_box("notebookbariconsize"))
531 , m_xDarkModeFrame(m_xBuilder->weld_widget("darkmode"))
532 , m_xAppearanceStyleLB(m_xBuilder->weld_combo_box("appearance"))
533 , m_xIconStyleLB(m_xBuilder->weld_combo_box("iconstyle"))
534 , m_xFontAntiAliasing(m_xBuilder->weld_check_button("aafont"))
535 , m_xAAPointLimitLabel(m_xBuilder->weld_label("aafrom"))
536 , m_xAAPointLimit(m_xBuilder->weld_metric_spin_button("aanf", FieldUnit::PIXEL))
537 , m_xFontShowCB(m_xBuilder->weld_check_button("showfontpreview"))
538 , m_xUseHardwareAccell(m_xBuilder->weld_check_button("useaccel"))
539 , m_xUseAntiAliase(m_xBuilder->weld_check_button("useaa"))
540 , m_xUseSkia(m_xBuilder->weld_check_button("useskia"))
541 , m_xForceSkiaRaster(m_xBuilder->weld_check_button("forceskiaraster"))
542 , m_xSkiaStatusEnabled(m_xBuilder->weld_label("skiaenabled"))
543 , m_xSkiaStatusDisabled(m_xBuilder->weld_label("skiadisabled"))
544 , m_xSkiaLog(m_xBuilder->weld_button("btnSkialog"))
545 , m_xMouseMiddleLB(m_xBuilder->weld_combo_box("mousemiddle"))
546 , m_xMoreIcons(m_xBuilder->weld_button("btnMoreIcons"))
547 , m_xRunGPTests(m_xBuilder->weld_button("btn_rungptest"))
548 , m_sAutoStr(m_xIconStyleLB->get_text(0))
549{
550 OUString sToolKitName(Application::GetToolkitName());
551 const bool bHasDarkMode = sToolKitName.startsWith("gtk") || sToolKitName == "osx" || sToolKitName == "win";
552 if (!bHasDarkMode)
553 m_xDarkModeFrame->hide();
554
555 m_xFontAntiAliasing->connect_toggled( LINK( this, OfaViewTabPage, OnAntialiasingToggled ) );
556
557 m_xUseSkia->connect_toggled(LINK(this, OfaViewTabPage, OnUseSkiaToggled));
558 m_xSkiaLog->connect_clicked(LINK(this, OfaViewTabPage, OnCopySkiaLog));
559
561
562 m_xIconStyleLB->set_active(0);
563
564 m_xMoreIcons->connect_clicked(LINK(this, OfaViewTabPage, OnMoreIconsClick));
565 m_xRunGPTests->connect_clicked( LINK( this, OfaViewTabPage, OnRunGPTestClick));
566}
567
569{
570 // Set known icon themes
571 m_xIconStyleLB->clear();
575
576 // Start with the automatically chosen icon theme
577 OUString autoThemeId = aStyleSettings.GetAutomaticallyChosenIconTheme();
579
580 OUString entryForAuto = m_sAutoStr + " (" + autoIconTheme.GetDisplayName() + ")";
581 m_xIconStyleLB->append("auto", entryForAuto); // index 0 means choose style automatically
582
583 // separate auto and other icon themes
584 m_xIconStyleLB->append_separator("");
585
586 for (auto const& installIconTheme : mInstalledIconThemes)
587 m_xIconStyleLB->append(installIconTheme.GetThemeId(), installIconTheme.GetDisplayName());
588}
589
591{
592}
593
595{
596 GraphicsTestsDialog m_xGraphicsTestDialog(m_xContainer.get());
597 m_xGraphicsTestDialog.run();
598}
599
601{
602 css::uno::Sequence<css::beans::PropertyValue> aArgs{ comphelper::makePropertyValue(
603 "AdditionsTag", OUString("Icons")) };
604 comphelper::dispatchCommand(".uno:AdditionsDialog", aArgs);
605}
606
607IMPL_LINK_NOARG( OfaViewTabPage, OnAntialiasingToggled, weld::Toggleable&, void )
608{
609 bool bAAEnabled = m_xFontAntiAliasing->get_active();
610
611 m_xAAPointLimitLabel->set_sensitive(bAAEnabled);
612 m_xAAPointLimit->set_sensitive(bAAEnabled);
613}
614
616{
617 UpdateSkiaStatus();
618}
619
621{
622#if HAVE_FEATURE_SKIA
623 css::uno::Reference<css::datatransfer::clipboard::XClipboard> xClipboard =
624 css::datatransfer::clipboard::SystemClipboard::create(
626 OUString sInfo = SkiaHelper::readLog();
628 m_xSkiaLog->set_from_icon_name(RID_SVXBMP_COPY);
629#endif
630}
631
633{
634 m_xUseSkia->hide();
635 m_xForceSkiaRaster->hide();
636 m_xSkiaStatusEnabled->hide();
637 m_xSkiaStatusDisabled->hide();
638 m_xSkiaLog->hide();
639}
640
642{
643#if HAVE_FEATURE_SKIA
644 bool skiaHidden = true;
645
646 // For now Skia is used mainly on Windows, enable the controls there.
647 if (Application::GetToolkitName() == "win")
648 skiaHidden = false;
649 // It can also be used on Linux, but only with the rarely used 'gen' backend.
650 if (Application::GetToolkitName() == "x11")
651 skiaHidden = false;
652 // OSX backend has Skia support too.
653 if (Application::GetToolkitName() == "osx")
654 skiaHidden = false;
655
656 if (skiaHidden)
657 {
659 return;
660 }
661
662 // Easier than a custom translation string.
663 bool bEnabled = SkiaHelper::isVCLSkiaEnabled();
664 m_xSkiaStatusEnabled->set_visible(bEnabled);
665 m_xSkiaStatusDisabled->set_visible(!bEnabled);
666
667 // FIXME: should really add code to show a 'lock' icon here.
668 m_xUseSkia->set_sensitive(!officecfg::Office::Common::VCL::UseSkia::isReadOnly());
669 m_xForceSkiaRaster->set_sensitive(m_xUseSkia->get_active() && !officecfg::Office::Common::VCL::ForceSkiaRaster::isReadOnly());
670 m_xSkiaLog->set_sensitive(bEnabled);
671
672 // Technically the 'use hardware acceleration' option could be used to mean !forceSkiaRaster, but the implementation
673 // of the option is so tied to the implementation of the canvas module that it's simpler to ignore it.
675#else
677#endif
678}
679
680std::unique_ptr<SfxTabPage> OfaViewTabPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet )
681{
682 return std::make_unique<OfaViewTabPage>(pPage, pController, *rAttrSet);
683}
684
686{
687 bool bModified = false;
688 bool bDarkModeOptModified = false;
689 bool bRepaintWindows(false);
690 std::shared_ptr<comphelper::ConfigurationChanges> xChanges(comphelper::ConfigurationChanges::create());
691
692 SvtMiscOptions aMiscOptions;
693 const sal_Int32 nSizeLB_NewSelection = m_xIconSizeLB->get_active();
694 if( nSizeLB_InitialSelection != nSizeLB_NewSelection )
695 {
696 // from now on it's modified, even if via auto setting the same size was set as now selected in the LB
697 sal_Int16 eSet = SFX_SYMBOLS_SIZE_AUTO;
698 switch( nSizeLB_NewSelection )
699 {
700 case 0: eSet = SFX_SYMBOLS_SIZE_AUTO; break;
701 case 1: eSet = SFX_SYMBOLS_SIZE_SMALL; break;
702 case 2: eSet = SFX_SYMBOLS_SIZE_LARGE; break;
703 case 3: eSet = SFX_SYMBOLS_SIZE_32; break;
704 default:
705 SAL_WARN("cui.options", "OfaViewTabPage::FillItemSet(): This state of m_xIconSizeLB should not be possible!");
706 }
707 aMiscOptions.SetSymbolsSize( eSet );
708 }
709
710 const sal_Int32 nSidebarSizeLB_NewSelection = m_xSidebarIconSizeLB->get_active();
711 if( nSidebarSizeLB_InitialSelection != nSidebarSizeLB_NewSelection )
712 {
713 // from now on it's modified, even if via auto setting the same size was set as now selected in the LB
714 ToolBoxButtonSize eSet = ToolBoxButtonSize::DontCare;
715 switch( nSidebarSizeLB_NewSelection )
716 {
717 case 0: eSet = ToolBoxButtonSize::DontCare; break;
718 case 1: eSet = ToolBoxButtonSize::Small; break;
719 case 2: eSet = ToolBoxButtonSize::Large; break;
720 default:
721 SAL_WARN("cui.options", "OfaViewTabPage::FillItemSet(): This state of m_xSidebarIconSizeLB should not be possible!");
722 }
723 officecfg::Office::Common::Misc::SidebarIconSize::set(static_cast<sal_Int16>(eSet), xChanges);
724 }
725
726 const sal_Int32 nNotebookbarSizeLB_NewSelection = m_xNotebookbarIconSizeLB->get_active();
727 if( nNotebookbarSizeLB_InitialSelection != nNotebookbarSizeLB_NewSelection )
728 {
729 // from now on it's modified, even if via auto setting the same size was set as now selected in the LB
730 ToolBoxButtonSize eSet = ToolBoxButtonSize::DontCare;
731 switch( nNotebookbarSizeLB_NewSelection )
732 {
733 case 0: eSet = ToolBoxButtonSize::DontCare; break;
734 case 1: eSet = ToolBoxButtonSize::Small; break;
735 case 2: eSet = ToolBoxButtonSize::Large; break;
736 default:
737 SAL_WARN("cui.options", "OfaViewTabPage::FillItemSet(): This state of m_xNotebookbarIconSizeLB should not be possible!");
738 }
739 officecfg::Office::Common::Misc::NotebookbarIconSize::set(static_cast<sal_Int16>(eSet), xChanges);
740 }
741
742 const sal_Int32 nStyleLB_NewSelection = m_xIconStyleLB->get_active();
743 if( nStyleLB_InitialSelection != nStyleLB_NewSelection )
744 {
745 aMiscOptions.SetIconTheme(m_xIconStyleLB->get_active_id());
746 nStyleLB_InitialSelection = nStyleLB_NewSelection;
747 }
748
749 bool bAppearanceChanged = false;
750 std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
751
752 // Middle Mouse Button
753 MouseMiddleButtonAction eOldMiddleMouse = static_cast<MouseMiddleButtonAction>(officecfg::Office::Common::View::Dialog::MiddleMouseButton::get());
754 short eNewMiddleMouse = m_xMouseMiddleLB->get_active();
755 if(eNewMiddleMouse > 2)
756 eNewMiddleMouse = 2;
757
758 if ( eNewMiddleMouse != static_cast<short>(eOldMiddleMouse) )
759 {
760 officecfg::Office::Common::View::Dialog::MiddleMouseButton::set(eNewMiddleMouse, batch);
761 bAppearanceChanged = true;
762 }
763
764 if (m_xFontAntiAliasing->get_state_changed_from_saved())
765 {
766 bool b = m_xFontAntiAliasing->get_active();
767 officecfg::Office::Common::View::FontAntiAliasing::Enabled::set(b, batch);
768 bAppearanceChanged = true;
769 }
770
771 if (m_xAAPointLimit->get_value_changed_from_saved())
772 {
773 sal_Int64 i = m_xAAPointLimit->get_value(FieldUnit::PIXEL);
774 officecfg::Office::Common::View::FontAntiAliasing::MinPixelHeight::set(i, batch);
775 bAppearanceChanged = true;
776 }
777
778 if (m_xFontShowCB->get_state_changed_from_saved())
779 {
780 officecfg::Office::Common::Font::View::ShowFontBoxWYSIWYG::set(m_xFontShowCB->get_active(), xChanges);
781 bModified = true;
782 }
783
784 if (m_xAppearanceStyleLB->get_value_changed_from_saved())
785 {
786 bDarkModeOptModified = true;
787 bModified = true;
788 }
789
790 // #i95644# if disabled, do not use value, see in ::Reset()
791 if (m_xUseHardwareAccell->get_sensitive())
792 {
793 if(m_xUseHardwareAccell->get_state_changed_from_saved())
794 {
795 pCanvasSettings->EnabledHardwareAcceleration(m_xUseHardwareAccell->get_active());
796 bModified = true;
797 }
798 }
799
800 // #i95644# if disabled, do not use value, see in ::Reset()
801 if (m_xUseAntiAliase->get_sensitive())
802 {
804 {
805 SvtOptionsDrawinglayer::SetAntiAliasing(m_xUseAntiAliase->get_active(), /*bTemporary*/false);
806 bModified = true;
807 bRepaintWindows = true;
808 }
809 }
810
811 if (m_xUseSkia->get_state_changed_from_saved() ||
812 m_xForceSkiaRaster->get_state_changed_from_saved())
813 {
814 officecfg::Office::Common::VCL::UseSkia::set(m_xUseSkia->get_active(), xChanges);
815 officecfg::Office::Common::VCL::ForceSkiaRaster::set(m_xForceSkiaRaster->get_active(), xChanges);
816 bModified = true;
817 }
818
819 xChanges->commit();
820
821 if (bDarkModeOptModified)
823
824 if ( bAppearanceChanged )
825 {
826 batch->commit();
828 }
829
830 if(bRepaintWindows)
831 {
833
834 while(pAppWindow)
835 {
836 pAppWindow->Invalidate();
837 pAppWindow = Application::GetNextTopLevelWindow(pAppWindow);
838 }
839 }
840
841 if (m_xUseSkia->get_state_changed_from_saved() ||
842 m_xForceSkiaRaster->get_state_changed_from_saved())
843 {
844 SolarMutexGuard aGuard;
848 GetDialogController()->response(RET_OK);
849 }
850
851 return bModified;
852}
853
855{
856 SvtMiscOptions aMiscOptions;
857
859 {
861
866 }
868 m_xIconSizeLB->save_value();
869
870 ToolBoxButtonSize eSidebarIconSize = static_cast<ToolBoxButtonSize>(officecfg::Office::Common::Misc::SidebarIconSize::get());
871 if( eSidebarIconSize == ToolBoxButtonSize::DontCare )
872 ; // do nothing
873 else if( eSidebarIconSize == ToolBoxButtonSize::Small )
875 else if( eSidebarIconSize == ToolBoxButtonSize::Large )
878 m_xSidebarIconSizeLB->save_value();
879 ToolBoxButtonSize eNotebookbarIconSize = static_cast<ToolBoxButtonSize>(officecfg::Office::Common::Misc::NotebookbarIconSize::get());
880 if( eNotebookbarIconSize == ToolBoxButtonSize::DontCare )
881 ; // do nothing
882 else if( eNotebookbarIconSize == ToolBoxButtonSize::Small )
884 else if( eNotebookbarIconSize == ToolBoxButtonSize::Large )
887 m_xNotebookbarIconSizeLB->save_value();
888
889 // tdf#153497 set name of automatic icon theme, it may have changed due to "Apply" while this page is visible
891
892 if (aMiscOptions.IconThemeWasSetAutomatically()) {
894 }
895 else {
896 const OUString& selected = SvtMiscOptions::GetIconTheme();
897 const vcl::IconThemeInfo& selectedInfo =
899 nStyleLB_InitialSelection = m_xIconStyleLB->find_text(selectedInfo.GetDisplayName());
900 }
901
903 m_xIconStyleLB->save_value();
904
905 m_xAppearanceStyleLB->set_active(officecfg::Office::Common::Misc::Appearance::get());
906 m_xAppearanceStyleLB->save_value();
907
908 // Middle Mouse Button
909 sal_Int16 nMiddleMouseButton = officecfg::Office::Common::View::Dialog::MiddleMouseButton::get();
910 m_xMouseMiddleLB->set_active(static_cast<short>(nMiddleMouseButton));
911 m_xMouseMiddleLB->save_value();
912
913 bool bFontAntiAliasing = officecfg::Office::Common::View::FontAntiAliasing::Enabled::get();
914 m_xFontAntiAliasing->set_active( bFontAntiAliasing );
915 sal_Int16 nFontAntiAliasingMinPixelHeight = officecfg::Office::Common::View::FontAntiAliasing::MinPixelHeight::get();
916 m_xAAPointLimit->set_value(nFontAntiAliasingMinPixelHeight, FieldUnit::PIXEL);
917
918 // WorkingSet
919 m_xFontShowCB->set_active(officecfg::Office::Common::Font::View::ShowFontBoxWYSIWYG::get());
920
922 m_xUseHardwareAccell->save_state();
923
924 { // #i95644# AntiAliasing
926 {
928 }
929 else
930 {
931 m_xUseAntiAliase->set_active(false);
932 m_xUseAntiAliase->set_sensitive(false);
933 }
934
935 m_xUseAntiAliase->save_state();
936 }
937
938 m_xUseSkia->set_active(officecfg::Office::Common::VCL::UseSkia::get());
939 m_xForceSkiaRaster->set_active(officecfg::Office::Common::VCL::ForceSkiaRaster::get());
940 m_xUseSkia->save_state();
941 m_xForceSkiaRaster->save_state();
942
943 m_xFontAntiAliasing->save_state();
944 m_xAAPointLimit->save_value();
945 m_xFontShowCB->save_state();
946
947 OnAntialiasingToggled(*m_xFontAntiAliasing);
949}
950
952{
953 // #i95644# HW accel (unified to disable mechanism)
954 if(pCanvasSettings->IsHardwareAccelerationAvailable())
955 {
956 m_xUseHardwareAccell->set_active(pCanvasSettings->IsHardwareAccelerationEnabled());
957 m_xUseHardwareAccell->set_sensitive(!pCanvasSettings->IsHardwareAccelerationRO());
958 }
959 else
960 {
961 m_xUseHardwareAccell->set_active(false);
962 m_xUseHardwareAccell->set_sensitive(false);
963 }
964#if HAVE_FEATURE_SKIA
965 m_xUseHardwareAccell->set_sensitive(!m_xUseSkia->get_active());
966#endif
967}
968
970{
974};
975
976static bool bLanguageCurrentDoc_Impl = false;
977
978// some things we'll need...
979constexpr OUStringLiteral sAccessSrvc = u"com.sun.star.configuration.ConfigurationAccess";
980constexpr OUStringLiteral sAccessUpdSrvc = u"com.sun.star.configuration.ConfigurationUpdateAccess";
981constexpr OUStringLiteral sInstalledLocalesPath = u"org.openoffice.Setup/Office/InstalledLocales";
982constexpr OUStringLiteral sUserLocalePath = u"org.openoffice.Office.Linguistic/General";
983constexpr OUStringLiteral sUserLocaleKey = u"UILocale";
985
986static OUString lcl_getDatePatternsConfigString( const LocaleDataWrapper& rLocaleWrapper )
987{
988 Sequence< OUString > aDateAcceptancePatterns = rLocaleWrapper.getDateAcceptancePatterns();
989 sal_Int32 nPatterns = aDateAcceptancePatterns.getLength();
990 OUStringBuffer aBuf( nPatterns * 6 ); // 6 := length of Y-M-D;
991 SAL_WARN_IF( !nPatterns, "cui.options", "No date acceptance pattern");
992 if (nPatterns)
993 {
994 const OUString* pPatterns = aDateAcceptancePatterns.getConstArray();
995 aBuf.append( pPatterns[0]);
996 for (sal_Int32 i=1; i < nPatterns; ++i)
997 aBuf.append(";" + pPatterns[i]);
998 }
999 return aBuf.makeStringAndClear();
1000}
1001
1002namespace
1003{
1004 //what ui language will be selected by default if the user override of General::UILocale is unset ?
1005 LanguageTag GetInstalledLocaleForSystemUILanguage()
1006 {
1007 css::uno::Sequence<OUString> inst(officecfg::Setup::Office::InstalledLocales::get()->getElementNames());
1009 }
1010}
1011
1013 : SfxTabPage(pPage, pController, "cui/ui/optlanguagespage.ui", "OptLanguagesPage", &rSet)
1014 , pLangConfig(new LanguageConfig_Impl)
1015 , m_bDatePatternsValid(false)
1016 , m_xUserInterfaceLB(m_xBuilder->weld_combo_box("userinterface"))
1017 , m_xLocaleSettingFT(m_xBuilder->weld_label("localesettingFT"))
1018 , m_xLocaleSettingLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("localesetting")))
1019 , m_xDecimalSeparatorCB(m_xBuilder->weld_check_button("decimalseparator"))
1020 , m_xCurrencyFT(m_xBuilder->weld_label("defaultcurrency"))
1021 , m_xCurrencyLB(m_xBuilder->weld_combo_box("currencylb"))
1022 , m_xDatePatternsFT(m_xBuilder->weld_label("dataaccpatterns"))
1023 , m_xDatePatternsED(m_xBuilder->weld_entry("datepatterns"))
1024 , m_xWesternLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("westernlanguage")))
1025 , m_xWesternLanguageFT(m_xBuilder->weld_label("western"))
1026 , m_xAsianLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("asianlanguage")))
1027 , m_xComplexLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("complexlanguage")))
1028 , m_xCurrentDocCB(m_xBuilder->weld_check_button("currentdoc"))
1029 , m_xAsianSupportCB(m_xBuilder->weld_check_button("asiansupport"))
1030 , m_xCTLSupportCB(m_xBuilder->weld_check_button("ctlsupport"))
1031 , m_xIgnoreLanguageChangeCB(m_xBuilder->weld_check_button("ignorelanguagechange"))
1032{
1033 // tdf#125483 save original default label
1035
1036 // initialize user interface language selection
1038
1039 OUString aUILang = m_sSystemDefaultString +
1040 " - " +
1041 SvtLanguageTable::GetLanguageString(GetInstalledLocaleForSystemUILanguage().getLanguageType());
1042
1043 m_xUserInterfaceLB->append("0", aUILang);
1044 m_xUserInterfaceLB->append_separator("");
1045 try
1046 {
1047 Reference< XMultiServiceFactory > theConfigProvider(
1048 css::configuration::theDefaultProvider::get(
1050 // find out which locales are currently installed and add them to the listbox
1051 Sequence< Any > theArgs{ Any(NamedValue("nodepath", Any(OUString(sInstalledLocalesPath)))) };
1052 Reference< XNameAccess > theNameAccess(
1053 theConfigProvider->createInstanceWithArguments(sAccessSrvc, theArgs ), UNO_QUERY_THROW );
1054 seqInstalledLanguages = theNameAccess->getElementNames();
1056 std::vector< std::pair<sal_Int32, OUString> > aUILanguages;
1057 for (sal_Int32 i=0; i<seqInstalledLanguages.getLength(); i++)
1058 {
1060 if (aLang != LANGUAGE_DONTKNOW)
1061 {
1062 OUString aLangStr( SvtLanguageTable::GetLanguageString( aLang ) );
1063 aUILanguages.emplace_back(i+1, aLangStr);
1064 }
1065 }
1066
1067 std::sort(aUILanguages.begin(), aUILanguages.end(), [](const auto& l1, const auto& l2) {
1068 static const auto aSorter = comphelper::string::NaturalStringSorter(
1069 comphelper::getProcessComponentContext(),
1070 Application::GetSettings().GetUILanguageTag().getLocale());
1071 return aSorter.compare(l1.second, l2.second) < 0;
1072 });
1073
1074 // tdf#114694: append the sorted list after the default entry and separator.
1075 for (const auto & [ nGroupID, sGroupName ] : aUILanguages)
1076 {
1077 m_xUserInterfaceLB->append(OUString::number(nGroupID), sGroupName);
1078 }
1079
1080 m_xUserInterfaceLB->set_active(0);
1081
1082 // find out whether the user has a specific locale specified
1083 Sequence< Any > theArgs2{ Any(NamedValue("nodepath", Any(OUString(sUserLocalePath)))) };
1084 theNameAccess.set(
1085 theConfigProvider->createInstanceWithArguments(sAccessSrvc, theArgs2 ), UNO_QUERY_THROW );
1086 if (theNameAccess->hasByName(sUserLocaleKey))
1087 theNameAccess->getByName(sUserLocaleKey) >>= m_sUserLocaleValue;
1088 // select the user specified locale in the listbox
1089 if (!m_sUserLocaleValue.isEmpty())
1090 {
1091 for (sal_Int32 i = 0, nEntryCount = m_xUserInterfaceLB->get_count(); i < nEntryCount; ++i)
1092 {
1093 sal_Int32 d = m_xUserInterfaceLB->get_id(i).toInt32();
1094 if ( d > 0 && seqInstalledLanguages.getLength() > d-1 && seqInstalledLanguages[d-1] == m_sUserLocaleValue)
1095 m_xUserInterfaceLB->set_active(i);
1096 }
1097 }
1098
1099 }
1100 catch (const Exception &)
1101 {
1102 // we'll just leave the box in its default setting and won't
1103 // even give it event handler...
1104 TOOLS_WARN_EXCEPTION("cui.options", "ignoring" );
1105 }
1106
1107 m_xWesternLanguageLB->SetLanguageList(
1108 SvxLanguageListFlags::WESTERN | SvxLanguageListFlags::ONLY_KNOWN, true, false, true, true,
1109 LANGUAGE_SYSTEM, css::i18n::ScriptType::LATIN);
1110
1111 m_xAsianLanguageLB->SetLanguageList(
1112 SvxLanguageListFlags::CJK | SvxLanguageListFlags::ONLY_KNOWN, true, false, true, true,
1113 LANGUAGE_SYSTEM, css::i18n::ScriptType::ASIAN);
1114
1115 m_xComplexLanguageLB->SetLanguageList(
1116 SvxLanguageListFlags::CTL | SvxLanguageListFlags::ONLY_KNOWN, true, false, true, true,
1117 LANGUAGE_SYSTEM, css::i18n::ScriptType::COMPLEX);
1118
1119 m_xLocaleSettingLB->SetLanguageList(
1120 SvxLanguageListFlags::ALL | SvxLanguageListFlags::ONLY_KNOWN, false, false, false, true,
1121 LANGUAGE_USER_SYSTEM_CONFIG, css::i18n::ScriptType::WEAK);
1122
1124 const NfCurrencyEntry& rCurr = SvNumberFormatter::GetCurrencyEntry( LANGUAGE_SYSTEM );
1125 // insert SYSTEM entry
1126 OUString aDefaultCurr = m_sSystemDefaultString + " - " + rCurr.GetBankSymbol();
1127 m_xCurrencyLB->append("default", aDefaultCurr);
1128 m_xCurrencyLB->append_separator("");
1129
1130 assert(m_xCurrencyLB->find_id("default") != -1);
1131 // all currencies
1132 OUString aTwoSpace( " " );
1133 sal_uInt16 nCurrCount = rCurrTab.size();
1134 std::vector< const NfCurrencyEntry* > aCurrencies;
1135 // first entry is SYSTEM, skip it
1136 for ( sal_uInt16 j=1; j < nCurrCount; ++j )
1137 {
1138 aCurrencies.push_back(&rCurrTab[j]);
1139 }
1140 std::sort(aCurrencies.begin(), aCurrencies.end(),
1141 [](const NfCurrencyEntry* c1, const NfCurrencyEntry* c2) {
1142 return c1->GetBankSymbol().compareTo(c2->GetBankSymbol()) < 0;
1143 });
1144
1145 for (auto &v : aCurrencies)
1146 {
1147 OUString aStr_ = v->GetBankSymbol() +
1148 aTwoSpace +
1149 v->GetSymbol();
1150 aStr_ = ApplyLreOrRleEmbedding( aStr_ ) +
1151 aTwoSpace +
1153 m_xCurrencyLB->append(weld::toId(v), aStr_);
1154 }
1155
1156 m_xCurrencyLB->set_active(0);
1157
1158 m_xLocaleSettingLB->connect_changed( LINK( this, OfaLanguagesTabPage, LocaleSettingHdl ) );
1159 m_xDatePatternsED->connect_changed( LINK( this, OfaLanguagesTabPage, DatePatternsHdl ) );
1160
1161 Link<weld::Toggleable&,void> aLink( LINK( this, OfaLanguagesTabPage, SupportHdl ) );
1162 m_xAsianSupportCB->connect_toggled( aLink );
1163 m_xCTLSupportCB->connect_toggled( aLink );
1164
1166 m_xAsianSupportCB->set_active(m_bOldAsian);
1167 m_xAsianSupportCB->save_state();
1168 bool bReadonly = SvtCJKOptions::IsAnyReadOnly();
1169 m_xAsianSupportCB->set_sensitive(!bReadonly);
1170 SupportHdl(*m_xAsianSupportCB);
1171
1173 m_xCTLSupportCB->set_active(m_bOldCtl);
1174 m_xCTLSupportCB->save_state();
1175 bReadonly = pLangConfig->aCTLLanguageOptions.IsReadOnly(SvtCTLOptions::E_CTLFONT);
1176 m_xCTLSupportCB->set_sensitive(!bReadonly);
1177 SupportHdl(*m_xCTLSupportCB);
1178
1179 m_xIgnoreLanguageChangeCB->set_active( pLangConfig->aSysLocaleOptions.IsIgnoreLanguageChange() );
1180}
1181
1183{
1184}
1185
1186std::unique_ptr<SfxTabPage> OfaLanguagesTabPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet )
1187{
1188 return std::make_unique<OfaLanguagesTabPage>(pPage, pController, *rAttrSet);
1189}
1190
1191static void lcl_Update(std::unique_ptr<SfxVoidItem> pInvalidItems[], std::unique_ptr<SfxBoolItem> pBoolItems[], sal_uInt16 nCount)
1192{
1193 SfxViewFrame* pCurrentFrm = SfxViewFrame::Current();
1195 while(pViewFrm)
1196 {
1197 SfxBindings& rBind = pViewFrm->GetBindings();
1198 for(sal_uInt16 i = 0; i < nCount; i++)
1199 {
1200 if(pCurrentFrm == pViewFrm)
1201 rBind.InvalidateAll(false);
1202 rBind.SetState( *pInvalidItems[i] );
1203 rBind.SetState( *pBoolItems[i] );
1204 }
1205 pViewFrm = SfxViewFrame::GetNext(*pViewFrm);
1206 }
1207}
1208
1210{
1211 // lock configuration broadcasters so that we can coordinate the notifications
1212 pLangConfig->aSysLocaleOptions.BlockBroadcasts( true );
1213 pLangConfig->aCTLLanguageOptions.BlockBroadcasts( true );
1214 pLangConfig->aLinguConfig.BlockBroadcasts( true );
1215
1216 /*
1217 * Sequence checking only matters when CTL support is enabled.
1218 *
1219 * So we only need to check for sequence checking if
1220 * a) previously it was unchecked and is now checked or
1221 * b) it was already checked but the CTL language has changed
1222 */
1223 if (
1224 m_xCTLSupportCB->get_active() &&
1225 (m_xCTLSupportCB->get_saved_state() != TRISTATE_TRUE ||
1226 m_xComplexLanguageLB->get_active_id_changed_from_saved())
1227 )
1228 {
1229 //sequence checking has to be switched on depending on the selected CTL language
1230 LanguageType eCTLLang = m_xComplexLanguageLB->get_active_id();
1231 bool bOn = MsLangId::needsSequenceChecking( eCTLLang);
1232 pLangConfig->aCTLLanguageOptions.SetCTLSequenceCheckingRestricted(bOn);
1233 pLangConfig->aCTLLanguageOptions.SetCTLSequenceChecking(bOn);
1234 pLangConfig->aCTLLanguageOptions.SetCTLSequenceCheckingTypeAndReplace(bOn);
1235 }
1236 try
1237 {
1238 // handle settings for UI Language
1239 // a change of setting needs to bring up a warning message
1240 OUString aLangString;
1241 sal_Int32 d = m_xUserInterfaceLB->get_active_id().toInt32();
1242 if( d > 0 && seqInstalledLanguages.getLength() > d-1)
1243 aLangString = seqInstalledLanguages[d-1];
1244
1245 /*
1246 if( m_xUserInterfaceLB->GetSelectedEntryPos() > 0)
1247 aLangString = ConvertLanguageToIsoString(m_xUserInterfaceLB->get_active_id());
1248 */
1249 Reference< XMultiServiceFactory > theConfigProvider(
1250 css::configuration::theDefaultProvider::get(
1252 Sequence< Any > theArgs{ Any(NamedValue("nodepath", Any(OUString(sUserLocalePath)))) };
1254 theConfigProvider->createInstanceWithArguments(sAccessUpdSrvc, theArgs ), UNO_QUERY_THROW );
1255 if ( m_sUserLocaleValue != aLangString)
1256 {
1257 // OSL_FAIL("UserInterface language was changed, restart.");
1258 // write new value
1259 xProp->setPropertyValue(sUserLocaleKey, Any(aLangString));
1260 Reference< XChangesBatch >(xProp, UNO_QUERY_THROW)->commitChanges();
1261 // display info
1262 SolarMutexGuard aGuard;
1266 GetDialogController()->response(RET_OK);
1267
1268 // tell quickstarter to stop being a veto listener
1269
1270 Reference< XComponentContext > xContext(
1272 css::office::Quickstart::createAndSetVeto(xContext, false, false, false/*DisableVeto*/);
1273 }
1274 }
1275 catch (const Exception&)
1276 {
1277 // we'll just leave the box in its default setting and won't
1278 // even give it event handler...
1279 TOOLS_WARN_EXCEPTION("cui.options", "ignoring");
1280 }
1281
1282 LanguageTag aLanguageTag( pLangConfig->aSysLocaleOptions.GetLanguageTag());
1283 LanguageType eOldLocale = (aLanguageTag.isSystemLocale() ? LANGUAGE_SYSTEM :
1284 aLanguageTag.makeFallback().getLanguageType());
1285 LanguageType eNewLocale = m_xLocaleSettingLB->get_active_id();
1286
1287 // If the "Default ..." entry was selected that means SYSTEM, the actual
1288 // eNewLocale value is temporary for the dialog only, do not resolve to
1289 // what system currently is.
1290 if (eNewLocale == LANGUAGE_USER_SYSTEM_CONFIG)
1291 eNewLocale = LANGUAGE_SYSTEM;
1292
1293 if ( eOldLocale != eNewLocale )
1294 {
1295 // an empty string denotes SYSTEM locale
1296 OUString sNewLang;
1297 if ( eNewLocale != LANGUAGE_SYSTEM )
1298 sNewLang = LanguageTag::convertToBcp47( eNewLocale);
1299
1300 // locale nowadays get to AppSettings via notification
1301 // this will happen after releasing the lock on the ConfigurationBroadcaster at
1302 // the end of this method
1303 pLangConfig->aSysLocaleOptions.SetLocaleConfigString( sNewLang );
1304 rSet->Put( SfxBoolItem( SID_OPT_LOCALE_CHANGED, true ) );
1305
1307 bool bNewCJK = bool( nNewType & SvtScriptType::ASIAN );
1308 SvtCompatibilityOptions aCompatOpts;
1310 }
1311
1312 if(m_xDecimalSeparatorCB->get_state_changed_from_saved())
1313 pLangConfig->aSysLocaleOptions.SetDecimalSeparatorAsLocale(m_xDecimalSeparatorCB->get_active());
1314
1315 if(m_xIgnoreLanguageChangeCB->get_state_changed_from_saved())
1316 pLangConfig->aSysLocaleOptions.SetIgnoreLanguageChange(m_xIgnoreLanguageChangeCB->get_active());
1317
1318 // Configured currency, for example, USD-en-US or EUR-de-DE, or empty for locale default.
1319 OUString sOldCurr = pLangConfig->aSysLocaleOptions.GetCurrencyConfigString();
1320 OUString sId = m_xCurrencyLB->get_active_id();
1321 const NfCurrencyEntry* pCurr = sId == "default" ? nullptr : weld::fromId<const NfCurrencyEntry*>(sId);
1322 OUString sNewCurr;
1323 if ( pCurr )
1325 pCurr->GetBankSymbol(), pCurr->GetLanguage() );
1326 if ( sOldCurr != sNewCurr )
1327 pLangConfig->aSysLocaleOptions.SetCurrencyConfigString( sNewCurr );
1328
1329 // Configured date acceptance patterns, for example Y-M-D;M-D or empty for
1330 // locale default.
1331 if (m_bDatePatternsValid && m_xDatePatternsED->get_value_changed_from_saved())
1332 pLangConfig->aSysLocaleOptions.SetDatePatternsConfigString( m_xDatePatternsED->get_text());
1333
1334 SfxObjectShell* pCurrentDocShell = SfxObjectShell::Current();
1335 Reference< css::linguistic2::XLinguProperties > xLinguProp = LinguMgr::GetLinguPropertySet();
1336 bool bCurrentDocCBChecked = m_xCurrentDocCB->get_active();
1337 if (m_xCurrentDocCB->get_sensitive())
1338 bLanguageCurrentDoc_Impl = bCurrentDocCBChecked;
1339 bool bCurrentDocCBChanged = m_xCurrentDocCB->get_state_changed_from_saved();
1340
1341 bool bValChanged = m_xWesternLanguageLB->get_active_id_changed_from_saved();
1342 if( (bCurrentDocCBChanged && !bCurrentDocCBChecked) || bValChanged)
1343 {
1344 LanguageType eSelectLang = m_xWesternLanguageLB->get_active_id();
1345 if(!bCurrentDocCBChecked)
1346 {
1347 Any aValue;
1348 Locale aLocale = LanguageTag::convertToLocale( eSelectLang, false);
1349 aValue <<= aLocale;
1350 pLangConfig->aLinguConfig.SetProperty( u"DefaultLocale", aValue );
1351 if (xLinguProp.is())
1352 xLinguProp->setDefaultLocale( aLocale );
1353 }
1354 if(pCurrentDocShell)
1355 {
1356 rSet->Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, css::i18n::ScriptType::LATIN),
1357 SID_ATTR_LANGUAGE));
1358 }
1359 }
1360 bValChanged = m_xAsianLanguageLB->get_active_id_changed_from_saved();
1361 if( (bCurrentDocCBChanged && !bCurrentDocCBChecked) || bValChanged)
1362 {
1363 LanguageType eSelectLang = m_xAsianLanguageLB->get_active_id();
1364 if(!bCurrentDocCBChecked)
1365 {
1366 Any aValue;
1367 Locale aLocale = LanguageTag::convertToLocale( eSelectLang, false);
1368 aValue <<= aLocale;
1369 pLangConfig->aLinguConfig.SetProperty( u"DefaultLocale_CJK", aValue );
1370 if (xLinguProp.is())
1371 xLinguProp->setDefaultLocale_CJK( aLocale );
1372 }
1373 if(pCurrentDocShell)
1374 {
1375 rSet->Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, css::i18n::ScriptType::ASIAN),
1376 SID_ATTR_CHAR_CJK_LANGUAGE));
1377 }
1378 }
1379 bValChanged = m_xComplexLanguageLB->get_active_id_changed_from_saved();
1380 if( (bCurrentDocCBChanged && !bCurrentDocCBChecked) || bValChanged)
1381 {
1382 LanguageType eSelectLang = m_xComplexLanguageLB->get_active_id();
1383 if(!bCurrentDocCBChecked)
1384 {
1385 Any aValue;
1386 Locale aLocale = LanguageTag::convertToLocale( eSelectLang, false);
1387 aValue <<= aLocale;
1388 pLangConfig->aLinguConfig.SetProperty( u"DefaultLocale_CTL", aValue );
1389 if (xLinguProp.is())
1390 xLinguProp->setDefaultLocale_CTL( aLocale );
1391 }
1392 if(pCurrentDocShell)
1393 {
1394 rSet->Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, css::i18n::ScriptType::COMPLEX),
1395 SID_ATTR_CHAR_CTL_LANGUAGE));
1396 }
1397 }
1398
1399 if(m_xAsianSupportCB->get_state_changed_from_saved() )
1400 {
1401 bool bChecked = m_xAsianSupportCB->get_active();
1402 SvtCJKOptions::SetAll(bChecked);
1403
1404 //iterate over all bindings to invalidate vertical text direction
1405 const sal_uInt16 STATE_COUNT = 2;
1406
1407 std::unique_ptr<SfxBoolItem> pBoolItems[STATE_COUNT];
1408 pBoolItems[0].reset(new SfxBoolItem(SID_VERTICALTEXT_STATE, false));
1409 pBoolItems[1].reset(new SfxBoolItem(SID_TEXT_FITTOSIZE_VERTICAL, false));
1410
1411 std::unique_ptr<SfxVoidItem> pInvalidItems[STATE_COUNT];
1412 pInvalidItems[0].reset(new SfxVoidItem(SID_VERTICALTEXT_STATE));
1413 pInvalidItems[1].reset(new SfxVoidItem(SID_TEXT_FITTOSIZE_VERTICAL));
1414
1415 lcl_Update(pInvalidItems, pBoolItems, STATE_COUNT);
1416 }
1417
1418 if ( m_xCTLSupportCB->get_state_changed_from_saved() )
1419 {
1420 SvtSearchOptions aOpt;
1421 aOpt.SetIgnoreDiacritics_CTL(true);
1422 aOpt.SetIgnoreKashida_CTL(true);
1423 aOpt.Commit();
1424 pLangConfig->aCTLLanguageOptions.SetCTLFontEnabled( m_xCTLSupportCB->get_active() );
1425
1426 const sal_uInt16 STATE_COUNT = 1;
1427 std::unique_ptr<SfxBoolItem> pBoolItems[STATE_COUNT];
1428 pBoolItems[0].reset(new SfxBoolItem(SID_CTLFONT_STATE, false));
1429 std::unique_ptr<SfxVoidItem> pInvalidItems[STATE_COUNT];
1430 pInvalidItems[0].reset(new SfxVoidItem(SID_CTLFONT_STATE));
1431 lcl_Update(pInvalidItems, pBoolItems, STATE_COUNT);
1432 }
1433
1434 if ( pLangConfig->aSysLocaleOptions.IsModified() )
1435 pLangConfig->aSysLocaleOptions.Commit();
1436
1437 // first release the lock on the ConfigurationBroadcaster for Locale changes
1438 // it seems that our code relies on the fact that before other changes like e.g. currency
1439 // are broadcasted locale changes have been done
1440 pLangConfig->aSysLocaleOptions.BlockBroadcasts( false );
1441 pLangConfig->aCTLLanguageOptions.BlockBroadcasts( false );
1442 pLangConfig->aLinguConfig.BlockBroadcasts( false );
1443
1444 return false;
1445}
1446
1448{
1449 LanguageTag aLanguageTag( pLangConfig->aSysLocaleOptions.GetLanguageTag());
1450 if ( aLanguageTag.isSystemLocale() )
1452 else
1453 m_xLocaleSettingLB->set_active_id( aLanguageTag.makeFallback().getLanguageType());
1454 bool bReadonly = pLangConfig->aSysLocaleOptions.IsReadOnly(SvtSysLocaleOptions::EOption::Locale);
1455 m_xLocaleSettingLB->set_sensitive(!bReadonly);
1456 m_xLocaleSettingFT->set_sensitive(!bReadonly);
1457
1458
1459 m_xDecimalSeparatorCB->set_active( pLangConfig->aSysLocaleOptions.IsDecimalSeparatorAsLocale());
1460 m_xDecimalSeparatorCB->save_state();
1461
1462 m_xIgnoreLanguageChangeCB->set_active( pLangConfig->aSysLocaleOptions.IsIgnoreLanguageChange());
1463 m_xIgnoreLanguageChangeCB->save_state();
1464
1465 // let LocaleSettingHdl enable/disable checkboxes for CJK/CTL support
1466 // #i15812# must be done *before* the configured currency is set
1467 // and update the decimal separator used for the given locale
1468 LocaleSettingHdl(*m_xLocaleSettingLB->get_widget());
1469
1470 // configured currency, for example, USD-en-US or EUR-de-DE, or empty for locale default
1471 const NfCurrencyEntry* pCurr = nullptr;
1472 OUString sCurrency = pLangConfig->aSysLocaleOptions.GetCurrencyConfigString();
1473 if ( !sCurrency.isEmpty() )
1474 {
1475 LanguageType eLang;
1476 OUString aAbbrev;
1477 SvtSysLocaleOptions::GetCurrencyAbbrevAndLanguage( aAbbrev, eLang, sCurrency );
1478 pCurr = SvNumberFormatter::GetCurrencyEntry( aAbbrev, eLang );
1479 }
1480 // if pCurr==nullptr the SYSTEM entry is selected
1481 OUString sId = !pCurr ? OUString("default") : weld::toId(pCurr);
1482 m_xCurrencyLB->set_active_id(sId);
1483 bReadonly = pLangConfig->aSysLocaleOptions.IsReadOnly(SvtSysLocaleOptions::EOption::Currency);
1484 m_xCurrencyLB->set_sensitive(!bReadonly);
1485 m_xCurrencyFT->set_sensitive(!bReadonly);
1486
1487 // date acceptance patterns
1488 OUString aDatePatternsString = pLangConfig->aSysLocaleOptions.GetDatePatternsConfigString();
1489 if (aDatePatternsString.isEmpty())
1490 {
1492 aDatePatternsString = lcl_getDatePatternsConfigString( rLocaleWrapper);
1493 // Let's assume patterns are valid at this point.
1494 m_bDatePatternsValid = true;
1495 }
1496 else
1497 {
1498 bool bModified = false;
1499 m_bDatePatternsValid = validateDatePatterns( bModified, aDatePatternsString);
1500 }
1501 m_xDatePatternsED->set_text(aDatePatternsString);
1502 m_xDatePatternsED->set_message_type( m_bDatePatternsValid ?
1504 bReadonly = pLangConfig->aSysLocaleOptions.IsReadOnly(SvtSysLocaleOptions::EOption::DatePatterns);
1505 m_xDatePatternsED->set_sensitive(!bReadonly);
1506 m_xDatePatternsFT->set_sensitive(!bReadonly);
1507 m_xDatePatternsED->save_value();
1508
1509 //western/CJK/CLK language
1510 LanguageType eCurLang = LANGUAGE_NONE;
1511 LanguageType eCurLangCJK = LANGUAGE_NONE;
1512 LanguageType eCurLangCTL = LANGUAGE_NONE;
1513 SfxObjectShell* pCurrentDocShell = SfxObjectShell::Current();
1514 //collect the configuration values first
1515 m_xCurrentDocCB->set_sensitive(false);
1516
1517 Any aWestLang;
1518 Any aCJKLang;
1519 Any aCTLLang;
1520 try
1521 {
1522 aWestLang = pLangConfig->aLinguConfig.GetProperty(u"DefaultLocale");
1523 Locale aLocale;
1524 aWestLang >>= aLocale;
1525
1526 eCurLang = LanguageTag::convertToLanguageType( aLocale, false);
1527
1528 aCJKLang = pLangConfig->aLinguConfig.GetProperty(u"DefaultLocale_CJK");
1529 aLocale = Locale();
1530 aCJKLang >>= aLocale;
1531 eCurLangCJK = LanguageTag::convertToLanguageType( aLocale, false);
1532
1533 aCTLLang = pLangConfig->aLinguConfig.GetProperty(u"DefaultLocale_CTL");
1534 aLocale = Locale();
1535 aCTLLang >>= aLocale;
1536 eCurLangCTL = LanguageTag::convertToLanguageType( aLocale, false);
1537 }
1538 catch (const Exception&)
1539 {
1540 }
1541 //overwrite them by the values provided by the DocShell
1542 if(pCurrentDocShell)
1543 {
1544 m_xCurrentDocCB->set_sensitive(true);
1546 if( const SvxLanguageItem* pLangItem = rSet->GetItemIfSet(SID_ATTR_LANGUAGE, false))
1547 {
1548 LanguageType eTempCurLang = pLangItem->GetValue();
1549 if (MsLangId::resolveSystemLanguageByScriptType(eCurLang, css::i18n::ScriptType::LATIN) != eTempCurLang)
1550 eCurLang = eTempCurLang;
1551 }
1552
1553 if( const SvxLanguageItem* pLang = rSet->GetItemIfSet(SID_ATTR_CHAR_CJK_LANGUAGE, false))
1554 {
1555 LanguageType eTempCurLang = pLang->GetValue();
1556 if (MsLangId::resolveSystemLanguageByScriptType(eCurLangCJK, css::i18n::ScriptType::ASIAN) != eTempCurLang)
1557 eCurLangCJK = eTempCurLang;
1558 }
1559
1560 if( const SvxLanguageItem* pLang = rSet->GetItemIfSet(SID_ATTR_CHAR_CTL_LANGUAGE, false))
1561 {
1562 LanguageType eTempCurLang = pLang->GetValue();
1563 if (MsLangId::resolveSystemLanguageByScriptType(eCurLangCTL, css::i18n::ScriptType::COMPLEX) != eTempCurLang)
1564 eCurLangCTL = eTempCurLang;
1565 }
1566 }
1567 if(LANGUAGE_NONE == eCurLang || LANGUAGE_DONTKNOW == eCurLang)
1568 m_xWesternLanguageLB->set_active_id(LANGUAGE_NONE);
1569 else
1570 m_xWesternLanguageLB->set_active_id(eCurLang);
1571
1572 if(LANGUAGE_NONE == eCurLangCJK || LANGUAGE_DONTKNOW == eCurLangCJK)
1573 m_xAsianLanguageLB->set_active_id(LANGUAGE_NONE);
1574 else
1575 m_xAsianLanguageLB->set_active_id(eCurLangCJK);
1576
1577 if(LANGUAGE_NONE == eCurLangCTL || LANGUAGE_DONTKNOW == eCurLangCTL)
1578 m_xComplexLanguageLB->set_active_id(LANGUAGE_NONE);
1579 else
1580 m_xComplexLanguageLB->set_active_id(eCurLangCTL);
1581
1582 m_xWesternLanguageLB->save_active_id();
1583 m_xAsianLanguageLB->save_active_id();
1584 m_xComplexLanguageLB->save_active_id();
1585 m_xIgnoreLanguageChangeCB->save_state();
1586 m_xCurrentDocCB->save_state();
1587
1588 bool bEnable = !pLangConfig->aLinguConfig.IsReadOnly( u"DefaultLocale" );
1589 m_xWesternLanguageFT->set_sensitive( bEnable );
1590 m_xWesternLanguageLB->set_sensitive( bEnable );
1591
1592 // check the box "For the current document only"
1593 // set the focus to the Western Language box
1594 const SfxBoolItem* pLang = rSet->GetItemIfSet(SID_SET_DOCUMENT_LANGUAGE, false );
1595 if ( pLang && pLang->GetValue() )
1596 {
1597 m_xWesternLanguageLB->grab_focus();
1598 m_xCurrentDocCB->set_sensitive(true);
1599 m_xCurrentDocCB->set_active(true);
1600 }
1601}
1602
1604{
1605 bool bCheck = rBox.get_active();
1606 if ( m_xAsianSupportCB.get() == &rBox )
1607 {
1608 bool bReadonly = pLangConfig->aLinguConfig.IsReadOnly(u"DefaultLocale_CJK");
1609 bCheck = ( bCheck && !bReadonly );
1610 m_xAsianLanguageLB->set_sensitive( bCheck );
1611 if (rBox.get_sensitive())
1612 m_bOldAsian = bCheck;
1613 }
1614 else if ( m_xCTLSupportCB.get() == &rBox )
1615 {
1616 bool bReadonly = pLangConfig->aLinguConfig.IsReadOnly(u"DefaultLocale_CTL");
1617 bCheck = ( bCheck && !bReadonly );
1618 m_xComplexLanguageLB->set_sensitive( bCheck );
1619 if (rBox.get_sensitive())
1620 m_bOldCtl = bCheck;
1621 }
1622 else
1623 SAL_WARN( "cui.options", "OfaLanguagesTabPage::SupportHdl(): wrong rBox" );
1624}
1625
1626namespace
1627{
1628 void lcl_checkLanguageCheckBox(weld::CheckButton& _rCB, bool _bNewValue, bool _bOldValue)
1629 {
1630 if ( _bNewValue )
1631 _rCB.set_active(true);
1632 else
1633 _rCB.set_active( _bOldValue );
1634// #i15082# do not call save_state() in running dialog...
1635// _rCB.save_state();
1636 _rCB.set_sensitive( !_bNewValue );
1637 }
1638}
1639
1641{
1642 LanguageType eLang = m_xLocaleSettingLB->get_active_id();
1644 // first check if CTL must be enabled
1645 // #103299# - if CTL font setting is not readonly
1646 if(!pLangConfig->aCTLLanguageOptions.IsReadOnly(SvtCTLOptions::E_CTLFONT))
1647 {
1648 bool bIsCTLFixed = bool(nType & SvtScriptType::COMPLEX);
1649 lcl_checkLanguageCheckBox(*m_xCTLSupportCB, bIsCTLFixed, m_bOldCtl);
1650 SupportHdl(*m_xCTLSupportCB);
1651 }
1652 // second check if CJK must be enabled
1653 // #103299# - if CJK support is not readonly
1655 {
1656 bool bIsCJKFixed = bool(nType & SvtScriptType::ASIAN);
1657 lcl_checkLanguageCheckBox(*m_xAsianSupportCB, bIsCJKFixed, m_bOldAsian);
1658 SupportHdl(*m_xAsianSupportCB);
1659 }
1660
1661 const NfCurrencyEntry& rCurr = SvNumberFormatter::GetCurrencyEntry(
1663 const OUString aDefaultID = "default";
1664 // Update the "Default ..." currency.
1665 m_xCurrencyLB->remove_id(aDefaultID);
1666 OUString aDefaultCurr = m_sSystemDefaultString + " - " + rCurr.GetBankSymbol();
1667 m_xCurrencyLB->insert(0, aDefaultCurr, &aDefaultID, nullptr, nullptr);
1668 assert(m_xCurrencyLB->find_id(aDefaultID) != -1);
1669 m_xCurrencyLB->set_active_text(aDefaultCurr);
1670
1671 // obtain corresponding locale data
1672 LocaleDataWrapper aLocaleWrapper(( LanguageTag(eLang) ));
1673
1674 // update the decimal separator key of the related CheckBox
1675 OUString sTempLabel(m_sDecimalSeparatorLabel);
1676 sTempLabel = sTempLabel.replaceFirst("%1", aLocaleWrapper.getNumDecimalSep() );
1677 m_xDecimalSeparatorCB->set_label(sTempLabel);
1678
1679 // update the date acceptance patterns
1680 OUString aDatePatternsString = lcl_getDatePatternsConfigString( aLocaleWrapper);
1681 m_bDatePatternsValid = true;
1682 m_xDatePatternsED->set_text( aDatePatternsString);
1683 m_xDatePatternsED->set_message_type(weld::EntryMessageType::Normal);
1684}
1685
1686IMPL_LINK( OfaLanguagesTabPage, DatePatternsHdl, weld::Entry&, rEd, void )
1687{
1688 OUString aPatterns(rEd.get_text());
1689 bool bModified = false;
1690 const bool bValid = validateDatePatterns( bModified, aPatterns);
1691 if (bModified)
1692 {
1693 // gtk3 keeps the cursor position on equal length set_text() but at
1694 // least the 'gen' backend does not and resets to 0.
1695 const int nCursorPos = rEd.get_position();
1696 rEd.set_text(aPatterns);
1697 rEd.set_position(nCursorPos);
1698 }
1699 if (bValid)
1700 rEd.set_message_type(weld::EntryMessageType::Normal);
1701 else
1702 rEd.set_message_type(weld::EntryMessageType::Error);
1703 m_bDatePatternsValid = bValid;
1704}
1705
1706bool OfaLanguagesTabPage::validateDatePatterns( bool& rbModified, OUString& rPatterns )
1707{
1708 bool bValid = true;
1709 if (!rPatterns.isEmpty())
1710 {
1711 OUStringBuffer aBuf( rPatterns);
1712 sal_Int32 nChar = 0;
1713 for (sal_Int32 nIndex=0; nIndex >= 0 && bValid; ++nChar)
1714 {
1715 const OUString aPat( rPatterns.getToken( 0, ';', nIndex));
1716 if (aPat.isEmpty() && nIndex < 0)
1717 {
1718 // Indicating failure when about to append a pattern is too
1719 // confusing. Empty patterns are ignored anyway when sequencing
1720 // to SvtSysLocale.
1721 continue; // for
1722 }
1723 else if (aPat.getLength() < 2)
1724 bValid = false;
1725 else
1726 {
1727 bool bY, bM, bD;
1728 bY = bM = bD = false;
1729 bool bSep = true;
1730 if (aPat.getLength() == 3)
1731 {
1732 // Disallow a pattern that would match a numeric input with
1733 // decimal separator, like M.D
1734 const LanguageType eLang = m_xLocaleSettingLB->get_active_id();
1735 const LocaleDataWrapper aLocaleWrapper(( LanguageTag(eLang)));
1736 if ( aPat[1] == aLocaleWrapper.getNumDecimalSep().toChar()
1737 || aPat[1] == aLocaleWrapper.getNumDecimalSepAlt().toChar())
1738 {
1739 bValid = false;
1740 }
1741 }
1742 for (sal_Int32 i = 0; i < aPat.getLength() && bValid; /*nop*/)
1743 {
1744 const sal_Int32 j = i;
1745 const sal_uInt32 c = aPat.iterateCodePoints( &i);
1746 // Only one Y,M,D per pattern, separated by any character(s).
1747 switch (c)
1748 {
1749 case 'y':
1750 case 'Y':
1751 if (bY || !bSep)
1752 bValid = false;
1753 else if (c == 'y')
1754 {
1755 aBuf[nChar] = 'Y';
1756 rbModified = true;
1757 }
1758 bY = true;
1759 bSep = false;
1760 break;
1761 case 'm':
1762 case 'M':
1763 if (bM || !bSep)
1764 bValid = false;
1765 else if (c == 'm')
1766 {
1767 aBuf[nChar] = 'M';
1768 rbModified = true;
1769 }
1770 bM = true;
1771 bSep = false;
1772 break;
1773 case 'd':
1774 case 'D':
1775 if (bD || !bSep)
1776 bValid = false;
1777 else if (c == 'd')
1778 {
1779 aBuf[nChar] = 'D';
1780 rbModified = true;
1781 }
1782 bD = true;
1783 bSep = false;
1784 break;
1785 default:
1786 // A pattern must not start with a separator (but
1787 // may end with).
1788 if (!(bY || bM || bD))
1789 bValid = false;
1790 bSep = true;
1791 }
1792 nChar += i-j;
1793 }
1794 // At least one of Y,M,D
1795 bValid &= (bY || bM || bD);
1796 }
1797 }
1798 if (rbModified)
1799 rPatterns = aBuf.makeStringAndClear();
1800 }
1801 return bValid;
1802}
1803
1804/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
double d
const StyleSettings & GetStyleSettings() const
static OUString GetToolkitName()
static bool hasNativeFileSelection()
static vcl::Window * GetNextTopLevelWindow(vcl::Window const *pWindow)
static const AllSettings & GetSettings()
static vcl::Window * GetFirstTopLevelWindow()
void EnabledHardwareAcceleration(bool _bEnabled) const
Definition: optgdlg.cxx:495
bool mbHWAccelAvailable
Definition: optgdlg.cxx:371
bool IsHardwareAccelerationRO() const
Definition: optgdlg.cxx:484
bool IsHardwareAccelerationAvailable() const
Definition: optgdlg.cxx:430
std::vector< std::pair< OUString, Sequence< OUString > > > ServiceVector
Definition: optgdlg.cxx:367
Reference< XNameAccess > mxForceFlagNameAccess
Definition: optgdlg.cxx:369
ServiceVector maAvailableImplementations
Definition: optgdlg.cxx:370
bool mbHWAccelChecked
Definition: optgdlg.cxx:372
bool IsHardwareAccelerationEnabled() const
Definition: optgdlg.cxx:472
sal_uInt16 GetValue() const
virtual short run() override
LanguageType getLanguageType(bool bResolveSystem=true) const
bool isSystemLocale() const
static css::lang::Locale convertToLocale(LanguageType nLangID, bool bResolveSystem=true)
LanguageTag & makeFallback()
static OUString convertToBcp47(LanguageType nLangID)
static LanguageType convertToLanguageType(const css::lang::Locale &rLocale, bool bResolveSystem=true)
static LanguageType convertToLanguageTypeWithFallback(const OUString &rBcp47)
static css::uno::Reference< css::linguistic2::XLinguProperties > GetLinguPropertySet()
const OUString & getNumDecimalSepAlt() const
const css::uno::Sequence< OUString > & getDateAcceptancePatterns() const
const OUString & getNumDecimalSep() const
static void SetDarkMode(int nMode)
static bool needsSequenceChecking(LanguageType nLang)
static LanguageType resolveSystemLanguageByScriptType(LanguageType nLang, sal_Int16 nType)
static LanguageType getConfiguredSystemLanguage()
size_t size() const
std::unique_ptr< weld::CheckButton > m_xCurrentDocCB
Definition: optgdlg.hxx:162
std::unique_ptr< weld::ComboBox > m_xUserInterfaceLB
Definition: optgdlg.hxx:149
std::unique_ptr< weld::CheckButton > m_xDecimalSeparatorCB
Definition: optgdlg.hxx:152
OUString m_sSystemDefaultString
Definition: optgdlg.hxx:144
std::unique_ptr< weld::Label > m_xLocaleSettingFT
Definition: optgdlg.hxx:150
std::unique_ptr< SvxLanguageBox > m_xLocaleSettingLB
Definition: optgdlg.hxx:151
OUString m_sDecimalSeparatorLabel
Definition: optgdlg.hxx:145
std::unique_ptr< SvxLanguageBox > m_xAsianLanguageLB
Definition: optgdlg.hxx:160
std::unique_ptr< weld::CheckButton > m_xCTLSupportCB
Definition: optgdlg.hxx:164
std::unique_ptr< weld::CheckButton > m_xAsianSupportCB
Definition: optgdlg.hxx:163
std::unique_ptr< weld::Label > m_xDatePatternsFT
Definition: optgdlg.hxx:155
std::unique_ptr< weld::Label > m_xWesternLanguageFT
Definition: optgdlg.hxx:159
std::unique_ptr< weld::Entry > m_xDatePatternsED
Definition: optgdlg.hxx:156
OUString m_sUserLocaleValue
Definition: optgdlg.hxx:143
std::unique_ptr< weld::CheckButton > m_xIgnoreLanguageChangeCB
Definition: optgdlg.hxx:165
bool validateDatePatterns(bool &rbModified, OUString &rPatterns)
Definition: optgdlg.cxx:1706
std::unique_ptr< LanguageConfig_Impl > pLangConfig
Definition: optgdlg.hxx:141
virtual ~OfaLanguagesTabPage() override
Definition: optgdlg.cxx:1182
std::unique_ptr< SvxLanguageBox > m_xComplexLanguageLB
Definition: optgdlg.hxx:161
std::unique_ptr< weld::Label > m_xCurrencyFT
Definition: optgdlg.hxx:153
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optgdlg.cxx:1186
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: optgdlg.cxx:1209
std::unique_ptr< SvxLanguageBox > m_xWesternLanguageLB
Definition: optgdlg.hxx:158
OfaLanguagesTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: optgdlg.cxx:1012
std::unique_ptr< weld::ComboBox > m_xCurrencyLB
Definition: optgdlg.hxx:154
virtual void Reset(const SfxItemSet *rSet) override
Definition: optgdlg.cxx:1447
std::unique_ptr< weld::CheckButton > m_xFileDlgCB
Definition: optgdlg.hxx:41
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optgdlg.cxx:215
OUString m_aStrDateInfo
Definition: optgdlg.hxx:34
std::unique_ptr< weld::CheckButton > m_xExtHelpCB
Definition: optgdlg.hxx:36
std::unique_ptr< weld::CheckButton > m_xDocStatusCB
Definition: optgdlg.hxx:42
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: optgdlg.cxx:107
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: optgdlg.cxx:220
std::unique_ptr< weld::Widget > m_xYearFrame
Definition: optgdlg.hxx:43
std::unique_ptr< weld::Widget > m_xFileDlgFrame
Definition: optgdlg.hxx:39
std::unique_ptr< weld::CheckButton > m_xPopUpNoHelpCB
Definition: optgdlg.hxx:37
std::unique_ptr< weld::SpinButton > m_xYearValueField
Definition: optgdlg.hxx:44
virtual ~OfaMiscTabPage() override
Definition: optgdlg.cxx:211
std::unique_ptr< weld::CheckButton > m_xShowTipOfTheDay
Definition: optgdlg.hxx:38
OfaMiscTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: optgdlg.cxx:159
std::unique_ptr< weld::Widget > m_xFileDlgROImage
Definition: optgdlg.hxx:40
virtual void Reset(const SfxItemSet *rSet) override
Definition: optgdlg.cxx:285
std::unique_ptr< weld::Label > m_xToYearFT
Definition: optgdlg.hxx:45
std::unique_ptr< weld::Button > m_xSkiaLog
Definition: optgdlg.hxx:107
std::unique_ptr< weld::CheckButton > m_xForceSkiaRaster
Definition: optgdlg.hxx:103
std::unique_ptr< weld::ComboBox > m_xSidebarIconSizeLB
Definition: optgdlg.hxx:88
sal_Int32 nStyleLB_InitialSelection
Definition: optgdlg.hxx:81
void UpdateHardwareAccelStatus()
Definition: optgdlg.cxx:951
std::unique_ptr< weld::MetricSpinButton > m_xAAPointLimit
Definition: optgdlg.hxx:96
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optgdlg.cxx:680
std::unique_ptr< weld::ComboBox > m_xIconStyleLB
Definition: optgdlg.hxx:92
void HideSkiaWidgets()
Definition: optgdlg.cxx:632
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: optgdlg.cxx:685
void UpdateSkiaStatus()
Definition: optgdlg.cxx:641
OUString m_sAutoStr
Definition: optgdlg.hxx:113
std::unique_ptr< weld::ComboBox > m_xNotebookbarIconSizeLB
Definition: optgdlg.hxx:89
std::unique_ptr< weld::Label > m_xSkiaStatusDisabled
Definition: optgdlg.hxx:106
void UpdateIconThemes()
Definition: optgdlg.cxx:568
std::unique_ptr< weld::CheckButton > m_xUseAntiAliase
Definition: optgdlg.hxx:101
std::unique_ptr< weld::Label > m_xSkiaStatusEnabled
Definition: optgdlg.hxx:105
std::unique_ptr< weld::CheckButton > m_xFontShowCB
Definition: optgdlg.hxx:98
std::unique_ptr< weld::ComboBox > m_xAppearanceStyleLB
Definition: optgdlg.hxx:91
std::unique_ptr< weld::Button > m_xRunGPTests
Definition: optgdlg.hxx:111
sal_Int32 nNotebookbarSizeLB_InitialSelection
Definition: optgdlg.hxx:80
std::unique_ptr< CanvasSettings > pCanvasSettings
Definition: optgdlg.hxx:83
OfaViewTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: optgdlg.cxx:521
std::unique_ptr< weld::CheckButton > m_xUseSkia
Definition: optgdlg.hxx:102
std::unique_ptr< weld::ComboBox > m_xIconSizeLB
Definition: optgdlg.hxx:87
virtual void Reset(const SfxItemSet *rSet) override
Definition: optgdlg.cxx:854
std::unique_ptr< weld::CheckButton > m_xUseHardwareAccell
Definition: optgdlg.hxx:100
std::unique_ptr< weld::Button > m_xMoreIcons
Definition: optgdlg.hxx:110
std::unique_ptr< weld::CheckButton > m_xFontAntiAliasing
Definition: optgdlg.hxx:94
sal_Int32 nSidebarSizeLB_InitialSelection
Definition: optgdlg.hxx:79
std::unique_ptr< weld::ComboBox > m_xMouseMiddleLB
Definition: optgdlg.hxx:109
std::unique_ptr< weld::Widget > m_xDarkModeFrame
Definition: optgdlg.hxx:90
std::vector< vcl::IconThemeInfo > mInstalledIconThemes
Definition: optgdlg.hxx:85
sal_Int32 nSizeLB_InitialSelection
Definition: optgdlg.hxx:78
virtual ~OfaViewTabPage() override
Definition: optgdlg.cxx:590
void SetState(const SfxItemSet &rSet)
void InvalidateAll(bool bWithMsg)
bool GetValue() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
SfxOkDialogController * GetDialogController() const
void SetExchangeSupport()
const SfxPoolItem * GetOldItem(const SfxItemSet &rSet, sal_uInt16 nSlot, bool bDeep=true)
weld::Window * GetFrameWeld() const
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
SfxBindings & GetBindings()
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetNext(const SfxViewFrame &rPrev, const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
std::vector< vcl::IconThemeInfo > const & GetInstalledIconThemes() const
OUString GetAutomaticallyChosenIconTheme() const
static const NfCurrencyTable & GetTheCurrencyTable()
static const NfCurrencyEntry & GetCurrencyEntry(LanguageType)
static bool IsCTLFontEnabled()
void SetDefault(SvtCompatibilityEntry::Index rIdx, bool rValue)
static OUString GetLanguageString(const LanguageType eType)
bool IconThemeWasSetAutomatically() const
static sal_Int16 GetSymbolsSize()
void SetIconTheme(const OUString &)
void SetSymbolsSize(sal_Int16 eSet)
static OUString GetIconTheme()
void SetIgnoreKashida_CTL(bool bVal)
void SetIgnoreDiacritics_CTL(bool bVal)
void GetCurrencyAbbrevAndLanguage(OUString &rAbbrev, LanguageType &eLang) const
static OUString CreateCurrencyConfigString(const OUString &rAbbrev, LanguageType eLang)
static std::shared_ptr< ConfigurationChanges > create()
static const vcl::IconThemeInfo & FindIconThemeById(const std::vector< vcl::IconThemeInfo > &themes, const OUString &themeId)
const OUString & GetDisplayName() const
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
static void CopyStringTo(const OUString &rContent, const css::uno::Reference< css::datatransfer::clipboard::XClipboard > &rxClipboard, const vcl::ILibreOfficeKitNotifier *pNotifier=nullptr)
virtual void set_active(bool active)=0
virtual void set_sensitive(bool sensitive)=0
int nCount
#define TOOLS_WARN_EXCEPTION(area, stream)
virtual tools::Long GetValue() const override
float v
float u
Reference< XSingleServiceFactory > xFactory
FieldUnit
TRISTATE_TRUE
SFX_SYMBOLS_SIZE_SMALL
SFX_SYMBOLS_SIZE_32
SFX_SYMBOLS_SIZE_LARGE
SFX_SYMBOLS_SIZE_AUTO
sal_Int32 nIndex
#define LANGUAGE_SYSTEM
#define LANGUAGE_NONE
#define LANGUAGE_USER_SYSTEM_CONFIG
#define LANGUAGE_DONTKNOW
OUString SVT_DLLPUBLIC getInstalledLocaleForSystemUILanguage(css::uno::Sequence< OUString > const &installed, bool bRequestInstallIfMissing, const OUString &rPreferredLocale=OUString())
SVT_DLLPUBLIC OUString ApplyLreOrRleEmbedding(const OUString &rText)
SvtScriptType
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
if(aStr !=aBuf) UpdateName_Impl(m_xFollowLb.get()
aStr
aBuf
VCL_DLLPUBLIC OUString readLog()
VCL_DLLPUBLIC bool isVCLSkiaEnabled()
bool IsAnyReadOnly()
void SetAll(bool bSet)
bool IsAnyEnabled()
SvtScriptType GetScriptTypeOfLanguage(LanguageType nLang)
void SetAntiAliasing(bool bOn, bool bTemporary)
SVT_DLLPUBLIC void SetApplicationDefaults(Application *pApp)
@ Exception
css::uno::Sequence< css::uno::Any > InitAnyPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
bool dispatchCommand(const OUString &rCommand, const uno::Reference< css::frame::XFrame > &rFrame, const css::uno::Sequence< css::beans::PropertyValue > &rArguments, const uno::Reference< css::frame::XDispatchResultListener > &rListener)
Reference< XMultiServiceFactory > getProcessServiceFactory()
Reference< XComponentContext > getProcessComponentContext()
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
int i
const LocaleDataWrapper & GetLocaleDataWrapper(LanguageType nLang)
RESTART_REASON_LANGUAGE_CHANGE
RESTART_REASON_SKIA
SVT_DLLPUBLIC bool executeRestartDialog(css::uno::Reference< css::uno::XComponentContext > const &context, weld::Window *parent, RestartReason reason)
VCL_DLLPUBLIC void LaunchRegistrationUI()
OUString toId(const void *pValue)
Reference< XNameAccess > m_xContainer
IMPL_LINK_NOARG(OfaMiscTabPage, TwoFigureHdl, weld::SpinButton &, void)
Definition: optgdlg.cxx:334
constexpr OUStringLiteral sAccessUpdSrvc
Definition: optgdlg.cxx:980
constexpr OUStringLiteral sUserLocalePath
Definition: optgdlg.cxx:982
IMPL_LINK(OfaLanguagesTabPage, SupportHdl, weld::Toggleable &, rBox, void)
Definition: optgdlg.cxx:1603
static OUString lcl_getDatePatternsConfigString(const LocaleDataWrapper &rLocaleWrapper)
Definition: optgdlg.cxx:986
static bool DisplayNameCompareLessThan(const vcl::IconThemeInfo &rInfo1, const vcl::IconThemeInfo &rInfo2)
Definition: optgdlg.cxx:516
static void lcl_Update(std::unique_ptr< SfxVoidItem > pInvalidItems[], std::unique_ptr< SfxBoolItem > pBoolItems[], sal_uInt16 nCount)
Definition: optgdlg.cxx:1191
constexpr OUStringLiteral sInstalledLocalesPath
Definition: optgdlg.cxx:981
constexpr OUStringLiteral sUserLocaleKey
Definition: optgdlg.cxx:983
static Sequence< OUString > seqInstalledLanguages
Definition: optgdlg.cxx:984
IMPL_STATIC_LINK_NOARG(OfaViewTabPage, OnMoreIconsClick, weld::Button &, void)
Definition: optgdlg.cxx:600
static bool bLanguageCurrentDoc_Impl
Definition: optgdlg.cxx:976
constexpr OUStringLiteral sAccessSrvc
Definition: optgdlg.cxx:979
SfxItemState
QPRO_FUNC_TYPE nType
MouseMiddleButtonAction
static SfxItemSet & rSet
SvtCTLOptions aCTLLanguageOptions
Definition: optgdlg.cxx:971
SvtLinguConfig aLinguConfig
Definition: optgdlg.cxx:973
SvtSysLocaleOptions aSysLocaleOptions
Definition: optgdlg.cxx:972
VCL_DLLPUBLIC Application * GetpApp()
DeactivateRC
OUString sId
ToolBoxButtonSize
RET_OK