diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-07-24 22:18:46 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-07-25 09:06:38 +0200 |
commit | 9117fb44bc7bd6b8764911c731c84a9e5dcc37f0 (patch) | |
tree | 9ae340801e5becad5ebd8a098d2d763bc407eecc /svtools | |
parent | d5b9283985633fdb423269cab961bba2acc3539e (diff) |
use officecfg for help options
Change-Id: I2d19541cff07bf8159715d8f32d771cbf201ece4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119475
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/Library_svt.mk | 1 | ||||
-rw-r--r-- | svtools/source/config/helpopt.cxx | 248 | ||||
-rw-r--r-- | svtools/source/config/itemholder2.cxx | 5 |
3 files changed, 0 insertions, 254 deletions
diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk index ee4361331125..6a23e69b3842 100644 --- a/svtools/Library_svt.mk +++ b/svtools/Library_svt.mk @@ -80,7 +80,6 @@ $(eval $(call gb_Library_add_exception_objects,svt,\ svtools/source/config/colorcfg \ svtools/source/config/extcolorcfg \ svtools/source/config/fontsubstconfig \ - svtools/source/config/helpopt \ svtools/source/config/htmlcfg \ svtools/source/config/itemholder2 \ svtools/source/config/menuoptions \ diff --git a/svtools/source/config/helpopt.cxx b/svtools/source/config/helpopt.cxx deleted file mode 100644 index 88c9d9865905..000000000000 --- a/svtools/source/config/helpopt.cxx +++ /dev/null @@ -1,248 +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/config.h> - -#include <svtools/helpopt.hxx> -#include <unotools/configitem.hxx> -#include <tools/debug.hxx> -#include <com/sun/star/uno/Any.hxx> -#include <com/sun/star/uno/Sequence.hxx> -#include <comphelper/sequence.hxx> -#include <vcl/help.hxx> -#include <osl/mutex.hxx> -#include <sal/log.hxx> - -#include "itemholder2.hxx" - -using namespace utl; -using namespace com::sun::star::uno; -using namespace com::sun::star; - -namespace { - //global - std::weak_ptr<SvtHelpOptions_Impl> g_pHelpOptions; - -enum class HelpProperty -{ - ExtendedHelp = 0, - HelpTips = 1, - Locale = 2 -}; - -} - -class SvtHelpOptions_Impl : public utl::ConfigItem -{ - bool bExtendedHelp; - bool bHelpTips; - OUString aLocale; - OUString sHelpStyleSheet; - - static Sequence< OUString > const & GetPropertyNames(); - - virtual void ImplCommit() final override; - -public: - SvtHelpOptions_Impl(); - ~SvtHelpOptions_Impl() override; - - virtual void Notify( const css::uno::Sequence< OUString >& aPropertyNames ) override; - void Load( const css::uno::Sequence< OUString>& aPropertyNames); - - void SetExtendedHelp( bool b ) { bExtendedHelp= b; SetModified(); } - bool IsExtendedHelp() const { return bExtendedHelp; } - void SetHelpTips( bool b ) { bHelpTips = b; SetModified(); } - bool IsHelpTips() const { return bHelpTips; } - - static ::osl::Mutex & getInitMutex(); -}; - -Sequence< OUString > const & SvtHelpOptions_Impl::GetPropertyNames() -{ - static Sequence<OUString> const aNames - { - "ExtendedTip", - "Tip", - "Locale" - }; - - return aNames; -} - -::osl::Mutex & SvtHelpOptions_Impl::getInitMutex() -{ - static ::osl::Mutex ourMutex; - - return ourMutex; -} - -SvtHelpOptions_Impl::SvtHelpOptions_Impl() - : ConfigItem( "Office.Common/Help" ) - , bExtendedHelp( false ) - , bHelpTips( true ) -{ - Sequence< OUString > aNames = GetPropertyNames(); - Load( aNames ); - EnableNotification( aNames ); -} - -SvtHelpOptions_Impl::~SvtHelpOptions_Impl() -{ - if ( IsModified() ) - Commit(); -} - -void SvtHelpOptions_Impl::Load(const uno::Sequence< OUString>& rPropertyNames) -{ - const uno::Sequence< OUString> aInternalPropertyNames( GetPropertyNames()); - Sequence< Any > aValues = GetProperties( rPropertyNames ); - const Any* pValues = aValues.getConstArray(); - DBG_ASSERT( aValues.getLength() == rPropertyNames.getLength(), "GetProperties failed" ); - if ( aValues.getLength() != rPropertyNames.getLength() ) - return; - - for ( int nProp = 0; nProp < rPropertyNames.getLength(); nProp++ ) - { - assert(pValues[nProp].hasValue() && "property value missing"); - if ( pValues[nProp].hasValue() ) - { - bool bTmp; - OUString aTmpStr; - sal_Int32 nTmpInt = 0; - if ( pValues[nProp] >>= bTmp ) - { - switch ( static_cast< HelpProperty >( - comphelper::findValue(aInternalPropertyNames, rPropertyNames[nProp]) ) ) - { - case HelpProperty::ExtendedHelp: - bExtendedHelp = bTmp; - break; - case HelpProperty::HelpTips: - bHelpTips = bTmp; - break; - default: - SAL_WARN( "svtools.config", "Wrong Member!" ); - break; - } - } - else if ( pValues[nProp] >>= aTmpStr ) - { - switch ( static_cast< HelpProperty >(nProp) ) - { - case HelpProperty::Locale: - aLocale = aTmpStr; - break; - - default: - SAL_WARN( "svtools.config", "Wrong Member!" ); - break; - } - } - else if ( pValues[nProp] >>= nTmpInt ) - { - SAL_WARN( "svtools.config", "Wrong Member!" ); - } - else - { - SAL_WARN( "svtools.config", "Wrong Type!" ); - } - } - } - if ( IsHelpTips() != Help::IsQuickHelpEnabled() ) - IsHelpTips() ? Help::EnableQuickHelp() : Help::DisableQuickHelp(); - if ( IsExtendedHelp() != Help::IsBalloonHelpEnabled() ) - IsExtendedHelp() ? Help::EnableBalloonHelp() : Help::DisableBalloonHelp(); -} - -void SvtHelpOptions_Impl::ImplCommit() -{ - Sequence< OUString > aNames = GetPropertyNames(); - Sequence< Any > aValues( aNames.getLength() ); - Any* pValues = aValues.getArray(); - for ( int nProp = 0; nProp < aNames.getLength(); nProp++ ) - { - switch ( static_cast< HelpProperty >(nProp) ) - { - case HelpProperty::ExtendedHelp: - pValues[nProp] <<= bExtendedHelp; - break; - - case HelpProperty::HelpTips: - pValues[nProp] <<= bHelpTips; - break; - - case HelpProperty::Locale: - pValues[nProp] <<= aLocale; - break; - - } - } - - PutProperties( aNames, aValues ); -} - -void SvtHelpOptions_Impl::Notify( const Sequence<OUString>& aPropertyNames ) -{ - Load( aPropertyNames ); -} - -SvtHelpOptions::SvtHelpOptions() -{ - // Global access, must be guarded (multithreading) - ::osl::MutexGuard aGuard( SvtHelpOptions_Impl::getInitMutex() ); - - pImpl = g_pHelpOptions.lock(); - if ( !pImpl ) - { - pImpl = std::make_shared<SvtHelpOptions_Impl>(); - g_pHelpOptions = pImpl; - svtools::ItemHolder2::holdConfigItem(EItem::HelpOptions); - } -} - -SvtHelpOptions::~SvtHelpOptions() -{ - // Global access, must be guarded (multithreading) - ::osl::MutexGuard aGuard( SvtHelpOptions_Impl::getInitMutex() ); - - pImpl.reset(); -} - -void SvtHelpOptions::SetExtendedHelp( bool b ) -{ - pImpl->SetExtendedHelp( b ); -} - -bool SvtHelpOptions::IsExtendedHelp() const -{ - return pImpl->IsExtendedHelp(); -} - -void SvtHelpOptions::SetHelpTips( bool b ) -{ - pImpl->SetHelpTips( b ); -} - -bool SvtHelpOptions::IsHelpTips() const -{ - return pImpl->IsHelpTips(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/config/itemholder2.cxx b/svtools/source/config/itemholder2.cxx index cb02d6de5e5c..adb68024b020 100644 --- a/svtools/source/config/itemholder2.cxx +++ b/svtools/source/config/itemholder2.cxx @@ -28,7 +28,6 @@ #include <svtools/accessibilityoptions.hxx> #include <svtools/menuoptions.hxx> #include <svtools/colorcfg.hxx> -#include <svtools/helpopt.hxx> #include <svtools/printoptions.hxx> #include <unotools/options.hxx> #include <svtools/miscopt.hxx> @@ -129,10 +128,6 @@ void ItemHolder2::impl_newItem(TItemInfo& rItem) rItem.pItem.reset( new ::svtools::ColorConfig() ); break; - case EItem::HelpOptions : - rItem.pItem.reset( new SvtHelpOptions() ); - break; - case EItem::MenuOptions : rItem.pItem.reset( new SvtMenuOptions() ); break; |