cui/source/options/optdeepl.cxx | 15 +-- cui/source/options/optgdlg.cxx | 32 ++++--- cui/source/options/optgdlg.hxx | 3 desktop/source/app/app.cxx | 9 -- desktop/source/lib/init.cxx | 8 - include/svtools/apearcfg.hxx | 45 ---------- include/svtools/deeplcfg.hxx | 50 ------------ svtools/Library_svt.mk | 1 svtools/source/config/apearcfg.cxx | 116 ++-------------------------- svtools/source/config/deeplcfg.cxx | 124 ------------------------------ sw/source/ui/misc/translatelangselect.cxx | 14 +-- sw/source/uibase/shells/textsh1.cxx | 16 ++- 12 files changed, 66 insertions(+), 367 deletions(-)
New commits: commit 69b0fa8a6267a1fa77e77405000f42e8aeba5fa0 Author: Noel Grandin <[email protected]> AuthorDate: Tue Mar 14 16:24:09 2023 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Wed Mar 15 07:30:30 2023 +0000 Use officecfg instead of SvxDeeplOptions Change-Id: I977d9be45fa17b960cccb0915c5f2762bf11288f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148885 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/cui/source/options/optdeepl.cxx b/cui/source/options/optdeepl.cxx index 5343f72a59c9..6544a8fbc645 100644 --- a/cui/source/options/optdeepl.cxx +++ b/cui/source/options/optdeepl.cxx @@ -18,7 +18,7 @@ */ #include "optdeepl.hxx" -#include <svtools/deeplcfg.hxx> +#include <officecfg/Office/Linguistic.hxx> OptDeeplTabPage::OptDeeplTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) @@ -32,16 +32,17 @@ OptDeeplTabPage::~OptDeeplTabPage() {} void OptDeeplTabPage::Reset(const SfxItemSet*) { - SvxDeeplOptions& rDeeplOptions = SvxDeeplOptions::Get(); - m_xAPIUrl->set_text(rDeeplOptions.getAPIUrl()); - m_xAuthKey->set_text(rDeeplOptions.getAuthKey()); + m_xAPIUrl->set_text(*officecfg::Office::Linguistic::Translation::Deepl::ApiURL::get()); + m_xAuthKey->set_text(*officecfg::Office::Linguistic::Translation::Deepl::AuthKey::get()); } bool OptDeeplTabPage::FillItemSet(SfxItemSet*) { - SvxDeeplOptions& rDeeplOptions = SvxDeeplOptions::Get(); - rDeeplOptions.setAPIUrl(m_xAPIUrl->get_text()); - rDeeplOptions.setAuthKey(m_xAuthKey->get_text()); + std::shared_ptr<comphelper::ConfigurationChanges> batch( + comphelper::ConfigurationChanges::create()); + officecfg::Office::Linguistic::Translation::Deepl::ApiURL::set(m_xAPIUrl->get_text(), batch); + officecfg::Office::Linguistic::Translation::Deepl::AuthKey::set(m_xAuthKey->get_text(), batch); + batch->commit(); return false; } diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 1a29cdd4ce05..bdab0c035563 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -143,7 +143,6 @@ #include <tools/json_writer.hxx> #include <svtools/ctrltool.hxx> #include <svtools/langtab.hxx> -#include <svtools/deeplcfg.hxx> #include <vcl/fontcharmap.hxx> #ifdef IOS #include <vcl/sysdata.hxx> @@ -7351,9 +7350,10 @@ void setDeeplConfig() OUString aAuthKey = OStringToOUString(pAuthKeyString, RTL_TEXTENCODING_UTF8); try { - SvxDeeplOptions& rDeeplOptions = SvxDeeplOptions::Get(); - rDeeplOptions.setAPIUrl(aAPIUrl); - rDeeplOptions.setAuthKey(aAuthKey); + std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create()); + officecfg::Office::Linguistic::Translation::Deepl::ApiURL::set(aAPIUrl, batch); + officecfg::Office::Linguistic::Translation::Deepl::AuthKey::set(aAuthKey, batch); + batch->commit(); } catch(uno::Exception const& rException) { diff --git a/include/svtools/deeplcfg.hxx b/include/svtools/deeplcfg.hxx deleted file mode 100644 index a943d72d4d7e..000000000000 --- a/include/svtools/deeplcfg.hxx +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#pragma once -#include <unotools/configitem.hxx> -#include <com/sun/star/uno/Sequence.hxx> -#include <svtools/svtdllapi.h> - -using namespace utl; -using namespace com::sun::star::uno; - -struct DeeplOptions_Impl; - -class SVT_DLLPUBLIC SvxDeeplOptions final : public utl::ConfigItem -{ -public: - SvxDeeplOptions(); - virtual ~SvxDeeplOptions() override; - - virtual void Notify(const css::uno::Sequence<OUString>& _rPropertyNames) override; - static SvxDeeplOptions& Get(); - - const OUString& getAPIUrl() const; - void setAPIUrl(const OUString& rVal); - - const OUString& getAuthKey() const; - void setAuthKey(const OUString& rVal); - -private: - std::unique_ptr<DeeplOptions_Impl> pImpl; - void Load(const css::uno::Sequence<OUString>& rPropertyNames); - virtual void ImplCommit() override; - static const Sequence<OUString>& GetPropertyNames(); -}; diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk index 96714fdcfea1..46b68fb149e6 100644 --- a/svtools/Library_svt.mk +++ b/svtools/Library_svt.mk @@ -84,7 +84,6 @@ $(eval $(call gb_Library_add_exception_objects,svt,\ svtools/source/config/extcolorcfg \ svtools/source/config/fontsubstconfig \ svtools/source/config/htmlcfg \ - svtools/source/config/deeplcfg \ svtools/source/config/itemholder2 \ svtools/source/config/miscopt \ svtools/source/config/slidesorterbaropt \ diff --git a/svtools/source/config/deeplcfg.cxx b/svtools/source/config/deeplcfg.cxx deleted file mode 100644 index 3b022b70804b..000000000000 --- a/svtools/source/config/deeplcfg.cxx +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <sal/log.hxx> -#include <sal/config.h> -#include <svtools/deeplcfg.hxx> -#include <com/sun/star/uno/Sequence.hxx> -#include <tools/debug.hxx> - -using namespace utl; -using namespace com::sun::star::uno; - -struct DeeplOptions_Impl -{ - OUString sAPIUrl; - OUString sAuthKey; -}; - -const Sequence<OUString>& SvxDeeplOptions::GetPropertyNames() -{ - static Sequence<OUString> const aNames{ - "Deepl/ApiURL", - "Deepl/AuthKey", - }; - return aNames; -} - -const OUString& SvxDeeplOptions::getAPIUrl() const { return pImpl->sAPIUrl; } - -void SvxDeeplOptions::setAPIUrl(const OUString& rVal) -{ - pImpl->sAPIUrl = rVal; - SetModified(); -} - -const OUString& SvxDeeplOptions::getAuthKey() const { return pImpl->sAuthKey; } - -void SvxDeeplOptions::setAuthKey(const OUString& rVal) -{ - pImpl->sAuthKey = rVal; - SetModified(); -} - -namespace -{ -class theSvxDeeplOptions : public rtl::Static<SvxDeeplOptions, theSvxDeeplOptions> -{ -}; -} - -SvxDeeplOptions& SvxDeeplOptions::Get() { return theSvxDeeplOptions::get(); } - -SvxDeeplOptions::SvxDeeplOptions() - : ConfigItem("Office.Linguistic/Translation") - , pImpl(new DeeplOptions_Impl) -{ - Load(GetPropertyNames()); -} - -SvxDeeplOptions::~SvxDeeplOptions() {} -void SvxDeeplOptions::Notify(const css::uno::Sequence<OUString>&) { Load(GetPropertyNames()); } - -void SvxDeeplOptions::Load(const css::uno::Sequence<OUString>& aNames) -{ - Sequence<Any> aValues = GetProperties(aNames); - const Any* pValues = aValues.getConstArray(); - DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed"); - if (aValues.getLength() != aNames.getLength()) - return; - for (int nProp = 0; nProp < aNames.getLength(); nProp++) - { - if (!pValues[nProp].hasValue()) - continue; - switch (nProp) - { - case 0: - pValues[nProp] >>= pImpl->sAPIUrl; - break; - case 1: - pValues[nProp] >>= pImpl->sAuthKey; - break; - default: - break; - } - } -} - -void SvxDeeplOptions::ImplCommit() -{ - const Sequence<OUString>& aNames = GetPropertyNames(); - Sequence<Any> aValues(aNames.getLength()); - Any* pValues = aValues.getArray(); - for (int nProp = 0; nProp < aNames.getLength(); nProp++) - { - switch (nProp) - { - case 0: - pValues[nProp] <<= pImpl->sAPIUrl; - break; - case 1: - pValues[nProp] <<= pImpl->sAuthKey; - break; - default: - break; - } - } - PutProperties(aNames, aValues); -} \ No newline at end of file diff --git a/sw/source/ui/misc/translatelangselect.cxx b/sw/source/ui/misc/translatelangselect.cxx index 2d438edf59d1..8036cd11dec3 100644 --- a/sw/source/ui/misc/translatelangselect.cxx +++ b/sw/source/ui/misc/translatelangselect.cxx @@ -30,7 +30,6 @@ #include <sal/log.hxx> #include <ndtxt.hxx> #include <shellio.hxx> -#include <svtools/deeplcfg.hxx> #include <vcl/idle.hxx> #include <mdiexp.hxx> #include <strings.hrc> @@ -38,6 +37,7 @@ #include <sfx2/viewfrm.hxx> #include <com/sun/star/task/XStatusIndicatorFactory.hpp> #include <linguistic/translate.hxx> +#include <officecfg/Office/Linguistic.hxx> static const std::vector<SwLanguageListItem>& getLanguageVec() { @@ -133,8 +133,11 @@ IMPL_LINK_NOARG(SwTranslateLangSelectDlg, LangSelectTranslateHdl, weld::Button&, return; } - SvxDeeplOptions& rDeeplOptions = SvxDeeplOptions::Get(); - if (rDeeplOptions.getAPIUrl().isEmpty() || rDeeplOptions.getAuthKey().isEmpty()) + std::optional<OUString> oDeeplAPIUrl + = officecfg::Office::Linguistic::Translation::Deepl::ApiURL::get(); + std::optional<OUString> oDeeplKey + = officecfg::Office::Linguistic::Translation::Deepl::AuthKey::get(); + if (!oDeeplAPIUrl || oDeeplAPIUrl->isEmpty() || !oDeeplKey || oDeeplKey->isEmpty()) { SAL_WARN("sw.ui", "SwTranslateLangSelectDlg: API options are not set"); m_xDialog->response(RET_CANCEL); @@ -142,11 +145,10 @@ IMPL_LINK_NOARG(SwTranslateLangSelectDlg, LangSelectTranslateHdl, weld::Button&, } const OString aAPIUrl - = OUStringToOString(rtl::Concat2View(rDeeplOptions.getAPIUrl() + "?tag_handling=html"), + = OUStringToOString(rtl::Concat2View(*oDeeplAPIUrl + "?tag_handling=html"), RTL_TEXTENCODING_UTF8) .trim(); - const OString aAuthKey - = OUStringToOString(rDeeplOptions.getAuthKey(), RTL_TEXTENCODING_UTF8).trim(); + const OString aAuthKey = OUStringToOString(*oDeeplKey, RTL_TEXTENCODING_UTF8).trim(); const auto aTargetLang = getLanguageVec().at(SwTranslateLangSelectDlg::selectedLangIdx).getLanguage(); diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index b52e26778388..c79d2bec1fbe 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -108,9 +108,9 @@ #include <config_wasm_strip.h> #if !ENABLE_WASM_STRIP_EXTRA #include <officecfg/Office/Common.hxx> +#include <officecfg/Office/Linguistic.hxx> #include <svl/visitem.hxx> #include <translatelangselect.hxx> -#include <svtools/deeplcfg.hxx> #endif // ENABLE_WASM_STRIP_EXTRA #include <translatehelper.hxx> #include <IDocumentContentOperations.hxx> @@ -1940,14 +1940,15 @@ void SwTextShell::Execute(SfxRequest &rReq) const SfxPoolItem* pTargetLangStringItem = nullptr; if (pArgs && SfxItemState::SET == pArgs->GetItemState(SID_ATTR_TARGETLANG_STR, false, &pTargetLangStringItem)) { - SvxDeeplOptions& rDeeplOptions = SvxDeeplOptions::Get(); - if (rDeeplOptions.getAPIUrl().isEmpty() || rDeeplOptions.getAuthKey().isEmpty()) + std::optional<OUString> oDeeplAPIUrl = officecfg::Office::Linguistic::Translation::Deepl::ApiURL::get(); + std::optional<OUString> oDeeplKey = officecfg::Office::Linguistic::Translation::Deepl::AuthKey::get(); + if (!oDeeplAPIUrl || oDeeplAPIUrl->isEmpty() || !oDeeplKey || oDeeplKey->isEmpty()) { SAL_WARN("sw.ui", "SID_FM_TRANSLATE: API options are not set"); break; } - const OString aAPIUrl = OUStringToOString(rtl::Concat2View(rDeeplOptions.getAPIUrl() + "?tag_handling=html"), RTL_TEXTENCODING_UTF8).trim(); - const OString aAuthKey = OUStringToOString(rDeeplOptions.getAuthKey(), RTL_TEXTENCODING_UTF8).trim(); + const OString aAPIUrl = OUStringToOString(rtl::Concat2View(*oDeeplAPIUrl + "?tag_handling=html"), RTL_TEXTENCODING_UTF8).trim(); + const OString aAuthKey = OUStringToOString(*oDeeplKey, RTL_TEXTENCODING_UTF8).trim(); OString aTargetLang = OUStringToOString(static_cast<const SfxStringItem*>(pTargetLangStringItem)->GetValue(), RTL_TEXTENCODING_UTF8); SwTranslateHelper::TranslateAPIConfig aConfig({aAPIUrl, aAuthKey, aTargetLang}); SwTranslateHelper::TranslateDocument(rWrtSh, aConfig); @@ -2474,8 +2475,9 @@ void SwTextShell::GetState( SfxItemSet &rSet ) rSet.Put(SfxVisibilityItem(nWhich, false)); break; } - const SvxDeeplOptions& rDeeplOptions = SvxDeeplOptions::Get(); - if (rDeeplOptions.getAPIUrl().isEmpty() || rDeeplOptions.getAuthKey().isEmpty()) + std::optional<OUString> oDeeplAPIUrl = officecfg::Office::Linguistic::Translation::Deepl::ApiURL::get(); + std::optional<OUString> oDeeplKey = officecfg::Office::Linguistic::Translation::Deepl::AuthKey::get(); + if (!oDeeplAPIUrl || oDeeplAPIUrl->isEmpty() || !oDeeplKey || oDeeplKey->isEmpty()) { rSet.DisableItem(nWhich); } commit c95bfc87ce4e229a93cb69325d815404a9883f20 Author: Noel Grandin <[email protected]> AuthorDate: Tue Mar 14 16:08:17 2023 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Wed Mar 15 07:30:22 2023 +0000 Use officecfg instead of SvtTabAppearanceCfg but we need to keep a small chunk of logic which is used by two different classes Change-Id: I57390144eae2ecdb49b5b2ca3f4ce1fbc3d69420 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148884 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx index 57eaee46d908..8774ad120225 100644 --- a/cui/source/options/optgdlg.cxx +++ b/cui/source/options/optgdlg.cxx @@ -520,7 +520,6 @@ OfaViewTabPage::OfaViewTabPage(weld::Container* pPage, weld::DialogController* p , nSidebarSizeLB_InitialSelection(0) , nNotebookbarSizeLB_InitialSelection(0) , nStyleLB_InitialSelection(0) - , pAppearanceCfg(new SvtTabAppearanceCfg) , pCanvasSettings(new CanvasSettings) , m_xIconSizeLB(m_xBuilder->weld_combo_box("iconsize")) , m_xSidebarIconSizeLB(m_xBuilder->weld_combo_box("sidebariconsize")) @@ -736,40 +735,43 @@ bool OfaViewTabPage::FillItemSet( SfxItemSet* ) } bool bAppearanceChanged = false; + std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create()); // Mouse Snap Mode - SnapType eOldSnap = pAppearanceCfg->GetSnapMode(); + SnapType eOldSnap = static_cast<SnapType>(officecfg::Office::Common::View::Dialog::MousePositioning::get()); SnapType eNewSnap = static_cast<SnapType>(m_xMousePosLB->get_active()); if(eNewSnap > SnapType::NONE) eNewSnap = SnapType::NONE; if ( eNewSnap != eOldSnap ) { - pAppearanceCfg->SetSnapMode(eNewSnap ); + officecfg::Office::Common::View::Dialog::MousePositioning::set(static_cast<sal_Int16>(eNewSnap), batch); bAppearanceChanged = true; } // Middle Mouse Button - MouseMiddleButtonAction eOldMiddleMouse = pAppearanceCfg->GetMiddleMouseButton(); + MouseMiddleButtonAction eOldMiddleMouse = static_cast<MouseMiddleButtonAction>(officecfg::Office::Common::View::Dialog::MiddleMouseButton::get()); short eNewMiddleMouse = m_xMouseMiddleLB->get_active(); if(eNewMiddleMouse > 2) eNewMiddleMouse = 2; if ( eNewMiddleMouse != static_cast<short>(eOldMiddleMouse) ) { - pAppearanceCfg->SetMiddleMouseButton( static_cast<MouseMiddleButtonAction>(eNewMiddleMouse) ); + officecfg::Office::Common::View::Dialog::MiddleMouseButton::set(eNewMiddleMouse, batch); bAppearanceChanged = true; } if (m_xFontAntiAliasing->get_state_changed_from_saved()) { - pAppearanceCfg->SetFontAntiAliasing(m_xFontAntiAliasing->get_active()); + bool b = m_xFontAntiAliasing->get_active(); + officecfg::Office::Common::View::FontAntiAliasing::Enabled::set(b, batch); bAppearanceChanged = true; } if (m_xAAPointLimit->get_value_changed_from_saved()) { - pAppearanceCfg->SetFontAntialiasingMinPixelHeight(m_xAAPointLimit->get_value(FieldUnit::PIXEL)); + sal_Int64 i = m_xAAPointLimit->get_value(FieldUnit::PIXEL); + officecfg::Office::Common::View::FontAntiAliasing::MinPixelHeight::set(i, batch); bAppearanceChanged = true; } @@ -857,8 +859,8 @@ bool OfaViewTabPage::FillItemSet( SfxItemSet* ) if ( bAppearanceChanged ) { - pAppearanceCfg->Commit(); - pAppearanceCfg->SetApplicationDefaults ( GetpApp() ); + batch->commit(); + SvtTabAppearanceCfg::SetApplicationDefaults ( GetpApp() ); } if(bRepaintWindows) @@ -940,15 +942,19 @@ void OfaViewTabPage::Reset( const SfxItemSet* ) m_xAppearanceStyleLB->save_value(); // Mouse Snap - m_xMousePosLB->set_active(static_cast<sal_Int32>(pAppearanceCfg->GetSnapMode())); + sal_Int16 nMouseSnap = officecfg::Office::Common::View::Dialog::MousePositioning::get(); + m_xMousePosLB->set_active(static_cast<sal_Int32>(nMouseSnap)); m_xMousePosLB->save_value(); // Mouse Snap - m_xMouseMiddleLB->set_active(static_cast<short>(pAppearanceCfg->GetMiddleMouseButton())); + sal_Int16 nMiddleMouseButton = officecfg::Office::Common::View::Dialog::MiddleMouseButton::get(); + m_xMouseMiddleLB->set_active(static_cast<short>(nMiddleMouseButton)); m_xMouseMiddleLB->save_value(); - m_xFontAntiAliasing->set_active( pAppearanceCfg->IsFontAntiAliasing() ); - m_xAAPointLimit->set_value(pAppearanceCfg->GetFontAntialiasingMinPixelHeight(), FieldUnit::PIXEL); + bool bFontAntiAliasing = officecfg::Office::Common::View::FontAntiAliasing::Enabled::get(); + m_xFontAntiAliasing->set_active( bFontAntiAliasing ); + sal_Int16 nFontAntiAliasingMinPixelHeight = officecfg::Office::Common::View::FontAntiAliasing::MinPixelHeight::get(); + m_xAAPointLimit->set_value(nFontAntiAliasingMinPixelHeight, FieldUnit::PIXEL); // WorkingSet m_xFontShowCB->set_active(officecfg::Office::Common::Font::View::ShowFontBoxWYSIWYG::get()); diff --git a/cui/source/options/optgdlg.hxx b/cui/source/options/optgdlg.hxx index 3fbf194afc7c..4e9c67e65f3c 100644 --- a/cui/source/options/optgdlg.hxx +++ b/cui/source/options/optgdlg.hxx @@ -72,8 +72,6 @@ public: virtual void Reset( const SfxItemSet* rSet ) override; }; -class SvtTabAppearanceCfg; - class OfaViewTabPage : public SfxTabPage { private: @@ -82,7 +80,6 @@ private: sal_Int32 nNotebookbarSizeLB_InitialSelection; sal_Int32 nStyleLB_InitialSelection; - std::unique_ptr<SvtTabAppearanceCfg> pAppearanceCfg; std::unique_ptr<CanvasSettings> pCanvasSettings; std::vector<vcl::IconThemeInfo> mInstalledIconThemes; diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index d2eb5f3e2a9b..5a35b5a745c2 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1541,9 +1541,8 @@ int Desktop::Main() svtools::ApplyFontSubstitutionsToVcl(); - SvtTabAppearanceCfg aAppearanceCfg; SvtTabAppearanceCfg::SetInitialized(); - aAppearanceCfg.SetApplicationDefaults( this ); + SvtTabAppearanceCfg::SetApplicationDefaults( this ); SvtAccessibilityOptions aOptions; aOptions.SetVCLSettings(); SetSplashScreenProgress(60); @@ -1851,8 +1850,7 @@ void Desktop::OverrideSystemSettings( AllSettings& rSettings ) DragFullOptions nDragFullOptions = hStyleSettings.GetDragFullOptions(); - SvtTabAppearanceCfg aAppearanceCfg; - DragMode nDragMode = aAppearanceCfg.GetDragMode(); + DragMode nDragMode = static_cast<DragMode>(officecfg::Office::Common::View::Window::Drag::get()); switch ( nDragMode ) { case DragMode::FullWindow: @@ -1867,7 +1865,8 @@ void Desktop::OverrideSystemSettings( AllSettings& rSettings ) } MouseFollowFlags nFollow = hMouseSettings.GetFollow(); - hMouseSettings.SetFollow( aAppearanceCfg.IsMenuMouseFollow() ? (nFollow|MouseFollowFlags::Menu) : (nFollow&~MouseFollowFlags::Menu)); + bool bMenuFollowMouse = officecfg::Office::Common::View::Menu::FollowMouse::get(); + hMouseSettings.SetFollow( bMenuFollowMouse ? (nFollow|MouseFollowFlags::Menu) : (nFollow&~MouseFollowFlags::Menu)); rSettings.SetMouseSettings(hMouseSettings); bool bMenuIcons = officecfg::Office::Common::View::Menu::ShowIconsInMenues::get(); diff --git a/include/svtools/apearcfg.hxx b/include/svtools/apearcfg.hxx index 900155856e81..85a521862ba7 100644 --- a/include/svtools/apearcfg.hxx +++ b/include/svtools/apearcfg.hxx @@ -19,7 +19,6 @@ #pragma once #include <svtools/svtdllapi.h> -#include <unotools/configitem.hxx> class Application; enum class MouseMiddleButtonAction; @@ -37,47 +36,11 @@ enum class DragMode { }; -class SVT_DLLPUBLIC SvtTabAppearanceCfg final : public utl::ConfigItem +namespace SvtTabAppearanceCfg { - DragMode nDragMode ; - SnapType nSnapMode ; - MouseMiddleButtonAction nMiddleMouse; - short nAAMinPixelHeight ; - bool bFontAntialiasing ; - - bool bMenuMouseFollow ; - - static bool bInitialized ; - - SVT_DLLPRIVATE static const css::uno::Sequence<OUString>& GetPropertyNames(); - virtual void ImplCommit() override; - -public: - SvtTabAppearanceCfg( ); - virtual ~SvtTabAppearanceCfg( ) override; - - virtual void Notify( const css::uno::Sequence< OUString >& _rPropertyNames) override; - - DragMode GetDragMode () const { return nDragMode; } - - SnapType GetSnapMode () const { return nSnapMode; } - void SetSnapMode ( SnapType nSet ); - - MouseMiddleButtonAction GetMiddleMouseButton () const { return nMiddleMouse; } - void SetMiddleMouseButton ( MouseMiddleButtonAction nSet ); - - void SetApplicationDefaults ( Application* pApp ); - - bool IsMenuMouseFollow() const{return bMenuMouseFollow;} - - void SetFontAntiAliasing( bool bSet ) { bFontAntialiasing = bSet; SetModified(); } - bool IsFontAntiAliasing() const { return bFontAntialiasing; } - - sal_uInt16 GetFontAntialiasingMinPixelHeight( ) const { return nAAMinPixelHeight; } - void SetFontAntialiasingMinPixelHeight( sal_uInt16 _nMinHeight ) { nAAMinPixelHeight = _nMinHeight; SetModified(); } - - static bool IsInitialized() { return bInitialized; } - static void SetInitialized() { bInitialized = true; } + SVT_DLLPUBLIC void SetApplicationDefaults ( Application* pApp ); + SVT_DLLPUBLIC bool IsInitialized(); + SVT_DLLPUBLIC void SetInitialized(); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/config/apearcfg.cxx b/svtools/source/config/apearcfg.cxx index 35670657e24c..fec538b62a71 100644 --- a/svtools/source/config/apearcfg.cxx +++ b/svtools/source/config/apearcfg.cxx @@ -21,120 +21,18 @@ #include <svtools/apearcfg.hxx> #include <o3tl/any.hxx> +#include <officecfg/Office/Common.hxx> #include <tools/debug.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> #include <com/sun/star/uno/Sequence.hxx> -#define DEFAULT_DRAGMODE DragMode::SystemDep -#define DEFAULT_SNAPMODE SnapType::ToButton -#define DEFAULT_AAMINHEIGHT 8 +static bool bInitialized = false; -using namespace ::com::sun::star::uno; +bool SvtTabAppearanceCfg::IsInitialized() { return bInitialized; } -bool SvtTabAppearanceCfg::bInitialized = false; - -SvtTabAppearanceCfg::SvtTabAppearanceCfg() - :ConfigItem("Office.Common/View") - ,nDragMode ( DEFAULT_DRAGMODE ) - ,nSnapMode ( DEFAULT_SNAPMODE ) - ,nMiddleMouse ( MouseMiddleButtonAction::AutoScroll ) - ,nAAMinPixelHeight ( DEFAULT_AAMINHEIGHT ) - ,bFontAntialiasing ( true ) - ,bMenuMouseFollow ( false ) -{ - const Sequence<OUString>& rNames = GetPropertyNames(); - Sequence<Any> aValues = GetProperties(rNames); - const Any* pValues = aValues.getConstArray(); - DBG_ASSERT(aValues.getLength() == rNames.getLength(), "GetProperties failed"); - - if(aValues.getLength() != rNames.getLength()) - return; - - for(int nProp = 0; nProp < rNames.getLength(); ++nProp, ++pValues) - { - if(pValues->hasValue()) - { - switch(nProp) - { - case 0: //"Window/Drag" - { - short nTmp; - if (*pValues >>= nTmp) - nDragMode = static_cast<DragMode>(nTmp); - break; - } - case 1: bMenuMouseFollow = *o3tl::doAccess<bool>(*pValues); break; //"Menu/FollowMouse", - case 2: - { - short nTmp; - if (*pValues >>= nTmp) - nSnapMode = static_cast<SnapType>(nTmp); //"Dialog/MousePositioning", - break; - } - case 3: { short nTmp = 0; *pValues >>= nTmp; nMiddleMouse = static_cast<MouseMiddleButtonAction>(nTmp); break; } //"Dialog/MiddleMouseButton", - case 4: bFontAntialiasing = *o3tl::doAccess<bool>(*pValues); break; // "FontAntialiasing/Enabled", - case 5: *pValues >>= nAAMinPixelHeight; break; // "FontAntialiasing/MinPixelHeight", - } - } - } -} - -SvtTabAppearanceCfg::~SvtTabAppearanceCfg( ) -{ -} - -const Sequence<OUString>& SvtTabAppearanceCfg::GetPropertyNames() -{ - static Sequence<OUString> const aNames - { - "Window/Drag" // 0 - ,"Menu/FollowMouse" // 1 - ,"Dialog/MousePositioning" // 2 - ,"Dialog/MiddleMouseButton" // 3 - ,"FontAntiAliasing/Enabled" // 4 - ,"FontAntiAliasing/MinPixelHeight" // 5 - }; - return aNames; -} - -void SvtTabAppearanceCfg::ImplCommit() -{ - const Sequence<OUString>& rNames = GetPropertyNames(); - Sequence<Any> aValues(rNames.getLength()); - Any* pValues = aValues.getArray(); - - for(int nProp = 0; nProp < rNames.getLength(); nProp++) - { - switch(nProp) - { - case 0: pValues[nProp] <<= static_cast<short>(nDragMode); break; // "Window/Drag", - case 1: pValues[nProp] <<= bMenuMouseFollow; break; // "Menu/FollowMouse", - case 2: pValues[nProp] <<= static_cast<short>(nSnapMode); break; // "Dialog/MousePositioning", - case 3: pValues[nProp] <<= static_cast<short>(nMiddleMouse); break; // "Dialog/MiddleMouseButton", - case 4: pValues[nProp] <<= bFontAntialiasing; break; // "FontAntialiasing/Enabled", - case 5: pValues[nProp] <<= nAAMinPixelHeight; break; // "FontAntialiasing/MinPixelHeight", - } - } - PutProperties(rNames, aValues); -} - -void SvtTabAppearanceCfg::Notify( const css::uno::Sequence< OUString >& ) -{ -} - -void SvtTabAppearanceCfg::SetSnapMode ( SnapType nSet ) -{ - nSnapMode = nSet; - SetModified(); -} - -void SvtTabAppearanceCfg::SetMiddleMouseButton ( MouseMiddleButtonAction nSet ) -{ - nMiddleMouse = nSet; - SetModified(); -} +void SvtTabAppearanceCfg::SetInitialized() { bInitialized = true; } void SvtTabAppearanceCfg::SetApplicationDefaults ( Application* pApp ) { @@ -150,6 +48,11 @@ void SvtTabAppearanceCfg::SetApplicationDefaults ( Application* pApp ) // and set it here hAppStyle.SetUseSystemUIFonts( bUseSystemUIFonts ); + bool bFontAntialiasing = officecfg::Office::Common::View::FontAntiAliasing::Enabled::get(); + sal_Int16 nAAMinPixelHeight = officecfg::Office::Common::View::FontAntiAliasing::MinPixelHeight::get(); + MouseMiddleButtonAction nMiddleMouse = static_cast<MouseMiddleButtonAction>(officecfg::Office::Common::View::Dialog::MiddleMouseButton::get()); + bool bMenuMouseFollow = officecfg::Office::Common::View::Menu::FollowMouse::get(); + // font anti aliasing hAppStyle.SetAntialiasingMinPixelHeight( nAAMinPixelHeight ); hAppStyle.SetDisplayOptions( bFontAntialiasing ? DisplayOptions::NONE : DisplayOptions::AADisable ); @@ -161,6 +64,7 @@ void SvtTabAppearanceCfg::SetApplicationDefaults ( Application* pApp ) nMouseOptions &= ~ MouseSettingsOptions(MouseSettingsOptions::AutoCenterPos | MouseSettingsOptions::AutoDefBtnPos); + SnapType nSnapMode = static_cast<SnapType>(officecfg::Office::Common::View::Dialog::MousePositioning::get()); switch ( nSnapMode ) { case SnapType::ToButton:
