summaryrefslogtreecommitdiffstats
path: root/svtools/source/config
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
commit940b4d1848e8c70ab7642901a68594e8016caffc (patch)
treeeb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /svtools/source/config
parentInitial commit. (diff)
downloadlibreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz
libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'svtools/source/config')
-rw-r--r--svtools/source/config/accessibilityoptions.cxx414
-rw-r--r--svtools/source/config/apearcfg.cxx198
-rw-r--r--svtools/source/config/colorcfg.cxx599
-rw-r--r--svtools/source/config/extcolorcfg.cxx664
-rw-r--r--svtools/source/config/fontsubstconfig.cxx181
-rw-r--r--svtools/source/config/helpopt.cxx305
-rw-r--r--svtools/source/config/htmlcfg.cxx415
-rw-r--r--svtools/source/config/itemholder2.cxx159
-rw-r--r--svtools/source/config/itemholder2.hxx64
-rw-r--r--svtools/source/config/menuoptions.cxx413
-rw-r--r--svtools/source/config/miscopt.cxx918
-rw-r--r--svtools/source/config/optionsdrawinglayer.cxx1020
-rw-r--r--svtools/source/config/printoptions.cxx510
-rw-r--r--svtools/source/config/slidesorterbaropt.cxx431
-rw-r--r--svtools/source/config/test/test.cxx215
15 files changed, 6506 insertions, 0 deletions
diff --git a/svtools/source/config/accessibilityoptions.cxx b/svtools/source/config/accessibilityoptions.cxx
new file mode 100644
index 000000000..43fa4287f
--- /dev/null
+++ b/svtools/source/config/accessibilityoptions.cxx
@@ -0,0 +1,414 @@
+/* -*- 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 <svtools/accessibilityoptions.hxx>
+
+#include <unotools/configmgr.hxx>
+#include <com/sun/star/uno/Any.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <comphelper/configurationhelper.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <vcl/settings.hxx>
+#include <vcl/svapp.hxx>
+#include <rtl/instance.hxx>
+#include <tools/diagnose_ex.h>
+
+#include "itemholder2.hxx"
+
+using namespace utl;
+using namespace com::sun::star::uno;
+
+#define HELP_TIP_TIMEOUT 0xffff // max. timeout setting to pretend a non-timeout
+
+// class SvtAccessibilityOptions_Impl ---------------------------------------------
+
+class SvtAccessibilityOptions_Impl
+{
+private:
+ css::uno::Reference< css::container::XNameAccess > m_xCfg;
+
+public:
+ SvtAccessibilityOptions_Impl();
+
+ void SetVCLSettings();
+ bool GetIsForPagePreviews() const;
+ bool GetIsHelpTipsDisappear() const;
+ bool GetIsAllowAnimatedGraphics() const;
+ bool GetIsAllowAnimatedText() const;
+ bool GetIsAutomaticFontColor() const;
+ sal_Int16 GetHelpTipSeconds() const;
+ bool IsSelectionInReadonly() const;
+ sal_Int16 GetEdgeBlending() const;
+ sal_Int16 GetListBoxMaximumLineCount() const;
+ sal_Int16 GetColorValueSetColumnCount() const;
+ bool GetPreviewUsesCheckeredBackground() const;
+};
+
+// initialization of static members --------------------------------------
+
+SvtAccessibilityOptions_Impl* SvtAccessibilityOptions::sm_pSingleImplConfig =nullptr;
+sal_Int32 SvtAccessibilityOptions::sm_nAccessibilityRefCount(0);
+
+namespace
+{
+ struct SingletonMutex
+ : public rtl::Static< ::osl::Mutex, SingletonMutex > {};
+}
+
+
+// class SvtAccessibilityOptions_Impl ---------------------------------------------
+
+SvtAccessibilityOptions_Impl::SvtAccessibilityOptions_Impl()
+{
+ try
+ {
+ m_xCfg.set(
+ ::comphelper::ConfigurationHelper::openConfig(
+ comphelper::getProcessComponentContext(),
+ "org.openoffice.Office.Common/Accessibility",
+ ::comphelper::EConfigurationModes::Standard ),
+ css::uno::UNO_QUERY);
+ }
+ catch(const css::uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("svtools.config");
+ m_xCfg.clear();
+ }
+}
+
+bool SvtAccessibilityOptions_Impl::GetIsForPagePreviews() const
+{
+ css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
+ bool bRet = true;
+
+ try
+ {
+ if(xNode.is())
+ xNode->getPropertyValue("IsForPagePreviews") >>= bRet;
+ }
+ catch(const css::uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("svtools.config");
+ }
+ return bRet;
+}
+
+bool SvtAccessibilityOptions_Impl::GetIsHelpTipsDisappear() const
+{
+ css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
+ bool bRet = true;
+
+ try
+ {
+ if(xNode.is())
+ xNode->getPropertyValue("IsHelpTipsDisappear") >>= bRet;
+ }
+ catch(const css::uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("svtools.config");
+ }
+
+ return bRet;
+}
+
+bool SvtAccessibilityOptions_Impl::GetIsAllowAnimatedGraphics() const
+{
+ css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
+ bool bRet = true;
+
+ try
+ {
+ if(xNode.is())
+ xNode->getPropertyValue("IsAllowAnimatedGraphics") >>= bRet;
+ }
+ catch(const css::uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("svtools.config");
+ }
+
+ return bRet;
+}
+
+bool SvtAccessibilityOptions_Impl::GetIsAllowAnimatedText() const
+{
+ css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
+ bool bRet = true;
+
+ try
+ {
+ if(xNode.is())
+ xNode->getPropertyValue("IsAllowAnimatedText") >>= bRet;
+ }
+ catch(const css::uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("svtools.config");
+ }
+
+ return bRet;
+}
+
+bool SvtAccessibilityOptions_Impl::GetIsAutomaticFontColor() const
+{
+ css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
+ bool bRet = false;
+
+ try
+ {
+ if(xNode.is())
+ xNode->getPropertyValue("IsAutomaticFontColor") >>= bRet;
+ }
+ catch(const css::uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("svtools.config");
+ }
+
+ return bRet;
+}
+
+sal_Int16 SvtAccessibilityOptions_Impl::GetHelpTipSeconds() const
+{
+ css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
+ sal_Int16 nRet = 4;
+
+ try
+ {
+ if(xNode.is())
+ xNode->getPropertyValue("HelpTipSeconds") >>= nRet;
+ }
+ catch(const css::uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("svtools.config");
+ }
+
+ return nRet;
+}
+
+bool SvtAccessibilityOptions_Impl::IsSelectionInReadonly() const
+{
+ css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
+ bool bRet = false;
+
+ try
+ {
+ if(xNode.is())
+ xNode->getPropertyValue("IsSelectionInReadonly") >>= bRet;
+ }
+ catch(const css::uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("svtools.config");
+ }
+
+ return bRet;
+}
+
+sal_Int16 SvtAccessibilityOptions_Impl::GetEdgeBlending() const
+{
+ css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
+ sal_Int16 nRet = 35;
+
+ try
+ {
+ if(xNode.is())
+ xNode->getPropertyValue("EdgeBlending") >>= nRet;
+ }
+ catch(const css::uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("svtools.config");
+ }
+
+ return nRet;
+}
+
+sal_Int16 SvtAccessibilityOptions_Impl::GetListBoxMaximumLineCount() const
+{
+ css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
+ sal_Int16 nRet = 25;
+
+ try
+ {
+ if(xNode.is())
+ xNode->getPropertyValue("ListBoxMaximumLineCount") >>= nRet;
+ }
+ catch(const css::uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("svtools.config");
+ }
+
+ return nRet;
+}
+
+sal_Int16 SvtAccessibilityOptions_Impl::GetColorValueSetColumnCount() const
+{
+#ifdef IOS
+ return 4;
+#else
+ css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
+ sal_Int16 nRet = 12;
+
+ try
+ {
+ if(xNode.is())
+ xNode->getPropertyValue("ColorValueSetColumnCount") >>= nRet;
+ }
+ catch(const css::uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("svtools.config");
+ }
+
+ return nRet;
+#endif
+}
+
+bool SvtAccessibilityOptions_Impl::GetPreviewUsesCheckeredBackground() const
+{
+ css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
+ bool bRet = false;
+
+ try
+ {
+ if(xNode.is())
+ xNode->getPropertyValue("PreviewUsesCheckeredBackground") >>= bRet;
+ }
+ catch(const css::uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("svtools.config");
+ }
+
+ return bRet;
+}
+
+void SvtAccessibilityOptions_Impl::SetVCLSettings()
+{
+ AllSettings aAllSettings(Application::GetSettings());
+ StyleSettings aStyleSettings(aAllSettings.GetStyleSettings());
+ HelpSettings aHelpSettings(aAllSettings.GetHelpSettings());
+ bool StyleSettingsChanged(false);
+
+ aHelpSettings.SetTipTimeout( GetIsHelpTipsDisappear() ? GetHelpTipSeconds() * 1000 : HELP_TIP_TIMEOUT);
+ aAllSettings.SetHelpSettings(aHelpSettings);
+
+ const sal_Int16 nEdgeBlendingCountA(GetEdgeBlending());
+ OSL_ENSURE(nEdgeBlendingCountA >= 0, "OOps, negative values for EdgeBlending are not allowed (!)");
+ const sal_uInt16 nEdgeBlendingCountB(static_cast< sal_uInt16 >(nEdgeBlendingCountA >= 0 ? nEdgeBlendingCountA : 0));
+
+ if(aStyleSettings.GetEdgeBlending() != nEdgeBlendingCountB)
+ {
+ aStyleSettings.SetEdgeBlending(nEdgeBlendingCountB);
+ StyleSettingsChanged = true;
+ }
+
+ const sal_Int16 nMaxLineCountA(GetListBoxMaximumLineCount());
+ OSL_ENSURE(nMaxLineCountA >= 0, "OOps, negative values for ListBoxMaximumLineCount are not allowed (!)");
+ const sal_uInt16 nMaxLineCountB(static_cast< sal_uInt16 >(nMaxLineCountA >= 0 ? nMaxLineCountA : 0));
+
+ if(aStyleSettings.GetListBoxMaximumLineCount() != nMaxLineCountB)
+ {
+ aStyleSettings.SetListBoxMaximumLineCount(nMaxLineCountB);
+ StyleSettingsChanged = true;
+ }
+
+ const sal_Int16 nMaxColumnCountA(GetColorValueSetColumnCount());
+ OSL_ENSURE(nMaxColumnCountA >= 0, "OOps, negative values for ColorValueSetColumnCount are not allowed (!)");
+ const sal_uInt16 nMaxColumnCountB(static_cast< sal_uInt16 >(nMaxColumnCountA >= 0 ? nMaxColumnCountA : 0));
+
+ if(aStyleSettings.GetColorValueSetColumnCount() != nMaxColumnCountB)
+ {
+ aStyleSettings.SetColorValueSetColumnCount(nMaxColumnCountB);
+ StyleSettingsChanged = true;
+ }
+
+ const bool bPreviewUsesCheckeredBackground(GetPreviewUsesCheckeredBackground());
+
+ if(aStyleSettings.GetPreviewUsesCheckeredBackground() != bPreviewUsesCheckeredBackground)
+ {
+ aStyleSettings.SetPreviewUsesCheckeredBackground(bPreviewUsesCheckeredBackground);
+ StyleSettingsChanged = true;
+ }
+
+ if(StyleSettingsChanged)
+ {
+ aAllSettings.SetStyleSettings(aStyleSettings);
+ Application::MergeSystemSettings(aAllSettings);
+ }
+
+ Application::SetSettings(aAllSettings);
+}
+
+// class SvtAccessibilityOptions --------------------------------------------------
+
+SvtAccessibilityOptions::SvtAccessibilityOptions()
+{
+ if (!utl::ConfigManager::IsFuzzing())
+ {
+ ::osl::MutexGuard aGuard( SingletonMutex::get() );
+ if(!sm_pSingleImplConfig)
+ {
+ sm_pSingleImplConfig = new SvtAccessibilityOptions_Impl;
+ svtools::ItemHolder2::holdConfigItem(EItem::AccessibilityOptions);
+ }
+ ++sm_nAccessibilityRefCount;
+ }
+ //StartListening( *sm_pSingleImplConfig, sal_True );
+}
+
+SvtAccessibilityOptions::~SvtAccessibilityOptions()
+{
+ //EndListening( *sm_pSingleImplConfig, sal_True );
+ ::osl::MutexGuard aGuard( SingletonMutex::get() );
+ if( !--sm_nAccessibilityRefCount )
+ {
+ //if( sm_pSingleImplConfig->IsModified() )
+ // sm_pSingleImplConfig->Commit();
+ DELETEZ( sm_pSingleImplConfig );
+ }
+}
+
+bool SvtAccessibilityOptions::GetIsForPagePreviews() const
+{
+ return sm_pSingleImplConfig->GetIsForPagePreviews();
+}
+bool SvtAccessibilityOptions::GetIsAllowAnimatedGraphics() const
+{
+ return sm_pSingleImplConfig->GetIsAllowAnimatedGraphics();
+}
+bool SvtAccessibilityOptions::GetIsAllowAnimatedText() const
+{
+ return sm_pSingleImplConfig->GetIsAllowAnimatedText();
+}
+bool SvtAccessibilityOptions::GetIsAutomaticFontColor() const
+{
+ return sm_pSingleImplConfig->GetIsAutomaticFontColor();
+}
+bool SvtAccessibilityOptions::IsSelectionInReadonly() const
+{
+ return sm_pSingleImplConfig->IsSelectionInReadonly();
+}
+
+
+void SvtAccessibilityOptions::SetVCLSettings()
+{
+ sm_pSingleImplConfig->SetVCLSettings();
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/config/apearcfg.cxx b/svtools/source/config/apearcfg.cxx
new file mode 100644
index 000000000..681b9282e
--- /dev/null
+++ b/svtools/source/config/apearcfg.cxx
@@ -0,0 +1,198 @@
+/* -*- 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 <svtools/apearcfg.hxx>
+
+#include <o3tl/any.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
+
+using namespace ::com::sun::star::uno;
+
+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; // "FontAntialising/Enabled",
+ case 5: *pValues >>= nAAMinPixelHeight; break; // "FontAntialising/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; // "FontAntialising/Enabled",
+ case 5: pValues[nProp] <<= nAAMinPixelHeight; break; // "FontAntialising/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::SetApplicationDefaults ( Application* pApp )
+{
+ AllSettings hAppSettings = Application::GetSettings();
+ StyleSettings hAppStyle = hAppSettings.GetStyleSettings();
+
+ // Look & Feel
+
+ // SetStandard...Styles() resets the UseSystemUIFonts flag,
+ // but we don't want to change it now, so save the flag before ...
+ bool bUseSystemUIFonts = hAppStyle.GetUseSystemUIFonts();
+ hAppStyle.SetStandardStyles();
+ // and set it here
+ hAppStyle.SetUseSystemUIFonts( bUseSystemUIFonts );
+
+ // font anti aliasing
+ hAppStyle.SetAntialiasingMinPixelHeight( nAAMinPixelHeight );
+ hAppStyle.SetDisplayOptions( bFontAntialiasing ? DisplayOptions::NONE : DisplayOptions::AADisable );
+
+ // Mouse Snap
+
+ MouseSettings hMouseSettings = hAppSettings.GetMouseSettings();
+ MouseSettingsOptions nMouseOptions = hMouseSettings.GetOptions();
+
+ nMouseOptions &= ~ MouseSettingsOptions(MouseSettingsOptions::AutoCenterPos | MouseSettingsOptions::AutoDefBtnPos);
+
+ switch ( nSnapMode )
+ {
+ case SnapType::ToButton:
+ nMouseOptions |= MouseSettingsOptions::AutoDefBtnPos;
+ break;
+ case SnapType::ToMiddle:
+ nMouseOptions |= MouseSettingsOptions::AutoCenterPos;
+ break;
+ case SnapType::NONE:
+ default:
+ break;
+ }
+ hMouseSettings.SetOptions(nMouseOptions);
+ hMouseSettings.SetMiddleButtonAction(nMiddleMouse);
+
+ // Merge and Publish Settings
+
+ MouseFollowFlags nFollow = hMouseSettings.GetFollow();
+ if(bMenuMouseFollow)
+ nFollow |= MouseFollowFlags::Menu;
+ else
+ nFollow &= ~MouseFollowFlags::Menu;
+ hMouseSettings.SetFollow( nFollow );
+
+ hAppSettings.SetMouseSettings( hMouseSettings );
+
+ hAppSettings.SetStyleSettings( hAppStyle );
+ Application::MergeSystemSettings ( hAppSettings ); // Allow system-settings to apply
+ pApp->OverrideSystemSettings ( hAppSettings );
+
+ Application::SetSettings ( hAppSettings );
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/config/colorcfg.cxx b/svtools/source/config/colorcfg.cxx
new file mode 100644
index 000000000..d2973a1d9
--- /dev/null
+++ b/svtools/source/config/colorcfg.cxx
@@ -0,0 +1,599 @@
+/* -*- 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 <svtools/colorcfg.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <comphelper/processfactory.hxx>
+#include <unotools/configitem.hxx>
+#include <unotools/confignode.hxx>
+#include <unotools/configmgr.hxx>
+#include <unotools/configpaths.hxx>
+#include <com/sun/star/uno/Sequence.h>
+#include <svl/poolitem.hxx>
+#include <osl/mutex.hxx>
+
+#include "itemholder2.hxx"
+
+#include <vcl/svapp.hxx>
+#include <vcl/event.hxx>
+#include <vcl/settings.hxx>
+#include <rtl/instance.hxx>
+
+
+using namespace utl;
+using namespace com::sun::star;
+
+static const char g_sIsVisible[] = "/IsVisible";
+
+
+namespace svtools
+{
+
+static sal_Int32 nColorRefCount_Impl = 0;
+namespace
+{
+ struct ColorMutex_Impl
+ : public rtl::Static< ::osl::Mutex, ColorMutex_Impl > {};
+}
+
+ColorConfig_Impl* ColorConfig::m_pImpl = nullptr;
+
+class ColorConfig_Impl : public utl::ConfigItem
+{
+ ColorConfigValue m_aConfigValues[ColorConfigEntryCount];
+ OUString m_sLoadedScheme;
+ bool m_bAutoDetectSystemHC;
+
+ virtual void ImplCommit() override;
+
+public:
+ explicit ColorConfig_Impl();
+ virtual ~ColorConfig_Impl() override;
+
+ void Load(const OUString& rScheme);
+ void CommitCurrentSchemeName();
+ //changes the name of the current scheme but doesn't load it!
+ void SetCurrentSchemeName(const OUString& rSchemeName) {m_sLoadedScheme = rSchemeName;}
+ virtual void Notify( const uno::Sequence<OUString>& aPropertyNames) override;
+
+ const ColorConfigValue& GetColorConfigValue(ColorConfigEntry eValue)
+ {return m_aConfigValues[eValue];}
+ void SetColorConfigValue(ColorConfigEntry eValue,
+ const ColorConfigValue& rValue );
+
+ const OUString& GetLoadedScheme() const {return m_sLoadedScheme;}
+
+ uno::Sequence< OUString> GetSchemeNames();
+
+ void AddScheme(const OUString& rNode);
+ void RemoveScheme(const OUString& rNode);
+ using ConfigItem::SetModified;
+ using ConfigItem::ClearModified;
+ void SettingsChanged();
+ bool GetAutoDetectSystemHC() const {return m_bAutoDetectSystemHC;}
+
+ DECL_LINK( DataChangedEventListener, VclSimpleEvent&, void );
+
+ void ImplUpdateApplicationSettings();
+};
+
+namespace {
+
+uno::Sequence< OUString> GetPropertyNames(const OUString& rScheme)
+{
+ struct ColorConfigEntryData_Impl
+ {
+ OUStringLiteral cName;
+ bool bCanBeVisible;
+ };
+ static const ColorConfigEntryData_Impl cNames[] =
+ {
+ { OUStringLiteral("/DocColor") ,false },
+ { OUStringLiteral("/DocBoundaries") ,true },
+ { OUStringLiteral("/AppBackground") ,false },
+ { OUStringLiteral("/ObjectBoundaries"),true },
+ { OUStringLiteral("/TableBoundaries") ,true },
+ { OUStringLiteral("/FontColor") ,false },
+ { OUStringLiteral("/Links") ,true },
+ { OUStringLiteral("/LinksVisited") ,true },
+ { OUStringLiteral("/Spell") ,false },
+ { OUStringLiteral("/SmartTags") ,false },
+ { OUStringLiteral("/Shadow") , true },
+ { OUStringLiteral("/WriterTextGrid") ,false },
+ { OUStringLiteral("/WriterFieldShadings"),true },
+ { OUStringLiteral("/WriterIdxShadings") ,true },
+ { OUStringLiteral("/WriterDirectCursor") ,true },
+ { OUStringLiteral("/WriterScriptIndicator") ,false },
+ { OUStringLiteral("/WriterSectionBoundaries") ,true },
+ { OUStringLiteral("/WriterHeaderFooterMark") ,false },
+ { OUStringLiteral("/WriterPageBreaks") ,false },
+ { OUStringLiteral("/HTMLSGML") ,false },
+ { OUStringLiteral("/HTMLComment") ,false },
+ { OUStringLiteral("/HTMLKeyword") ,false },
+ { OUStringLiteral("/HTMLUnknown") ,false },
+ { OUStringLiteral("/CalcGrid") ,false },
+ { OUStringLiteral("/CalcPageBreak"), false },
+ { OUStringLiteral("/CalcPageBreakManual"), false },
+ { OUStringLiteral("/CalcPageBreakAutomatic"), false },
+ { OUStringLiteral("/CalcDetective") ,false },
+ { OUStringLiteral("/CalcDetectiveError") ,false },
+ { OUStringLiteral("/CalcReference") ,false },
+ { OUStringLiteral("/CalcNotesBackground") ,false },
+ { OUStringLiteral("/CalcValue") ,false },
+ { OUStringLiteral("/CalcFormula") ,false },
+ { OUStringLiteral("/CalcText") ,false },
+ { OUStringLiteral("/CalcProtectedBackground") ,false },
+ { OUStringLiteral("/DrawGrid") ,true },
+ { OUStringLiteral("/BASICIdentifier"), false },
+ { OUStringLiteral("/BASICComment") , false },
+ { OUStringLiteral("/BASICNumber") , false },
+ { OUStringLiteral("/BASICString") , false },
+ { OUStringLiteral("/BASICOperator") , false },
+ { OUStringLiteral("/BASICKeyword") , false },
+ { OUStringLiteral("/BASICError"), false },
+ { OUStringLiteral("/SQLIdentifier"), false },
+ { OUStringLiteral("/SQLNumber"), false },
+ { OUStringLiteral("/SQLString"), false },
+ { OUStringLiteral("/SQLOperator"), false },
+ { OUStringLiteral("/SQLKeyword"), false },
+ { OUStringLiteral("/SQLParameter"), false },
+ { OUStringLiteral("/SQLComment"), false }
+ };
+
+ uno::Sequence<OUString> aNames(2 * ColorConfigEntryCount);
+ OUString* pNames = aNames.getArray();
+ int nIndex = 0;
+ OUString sBase = "ColorSchemes/"
+ + utl::wrapConfigurationElementName(rScheme);
+ for(sal_Int32 i = 0; i < ColorConfigEntryCount; ++i)
+ {
+ OUString sBaseName = sBase + cNames[i].cName;
+ pNames[nIndex++] = sBaseName + "/Color";
+ if(cNames[i].bCanBeVisible)
+ {
+ pNames[nIndex++] = sBaseName + g_sIsVisible;
+ }
+ }
+ aNames.realloc(nIndex);
+ return aNames;
+}
+
+}
+
+ColorConfig_Impl::ColorConfig_Impl() :
+ ConfigItem("Office.UI/ColorScheme"),
+ m_bAutoDetectSystemHC(true)
+{
+ //try to register on the root node - if possible
+ uno::Sequence < OUString > aNames(1);
+ EnableNotification( aNames );
+
+ if (!utl::ConfigManager::IsFuzzing())
+ Load(OUString());
+
+ ImplUpdateApplicationSettings();
+
+ ::Application::AddEventListener( LINK(this, ColorConfig_Impl, DataChangedEventListener) );
+
+}
+
+ColorConfig_Impl::~ColorConfig_Impl()
+{
+ ::Application::RemoveEventListener( LINK(this, ColorConfig_Impl, DataChangedEventListener) );
+}
+
+void ColorConfig_Impl::Load(const OUString& rScheme)
+{
+ OUString sScheme(rScheme);
+ if(sScheme.isEmpty())
+ {
+ //detect current scheme name
+ uno::Sequence < OUString > aCurrent { "CurrentColorScheme" };
+ uno::Sequence< uno::Any > aCurrentVal = GetProperties( aCurrent );
+ aCurrentVal.getConstArray()[0] >>= sScheme;
+ }
+ m_sLoadedScheme = sScheme;
+
+ uno::Sequence < OUString > aColorNames = GetPropertyNames(sScheme);
+ uno::Sequence< uno::Any > aColors = GetProperties( aColorNames );
+ const uno::Any* pColors = aColors.getConstArray();
+ const OUString* pColorNames = aColorNames.getConstArray();
+ sal_Int32 nIndex = 0;
+ for(int i = 0; i < ColorConfigEntryCount && aColors.getLength() > nIndex; ++i)
+ {
+ if(pColors[nIndex].hasValue())
+ {
+ sal_Int32 nTmp(0);
+ pColors[nIndex] >>= nTmp;
+ m_aConfigValues[i].nColor = Color(nTmp);
+ }
+ else
+ m_aConfigValues[i].nColor = COL_AUTO;
+ nIndex++;
+ if(nIndex >= aColors.getLength())
+ break;
+ //test for visibility property
+ if(pColorNames[nIndex].endsWith(g_sIsVisible))
+ m_aConfigValues[i].bIsVisible = Any2Bool(pColors[nIndex++]);
+ }
+ // fdo#71511: check if we are running in a11y autodetect
+ {
+ utl::OConfigurationNode aNode = utl::OConfigurationTreeRoot::tryCreateWithComponentContext(comphelper::getProcessComponentContext(),"org.openoffice.Office.Common/Accessibility" );
+ if(aNode.isValid())
+ {
+ uno::Any aValue = aNode.getNodeValue(OUString("AutoDetectSystemHC"));
+ aValue >>= m_bAutoDetectSystemHC;
+ }
+ }
+}
+
+void ColorConfig_Impl::Notify( const uno::Sequence<OUString>& )
+{
+ //loading via notification always uses the default setting
+ Load(OUString());
+ NotifyListeners(ConfigurationHints::NONE);
+}
+
+void ColorConfig_Impl::ImplCommit()
+{
+ uno::Sequence < OUString > aColorNames = GetPropertyNames(m_sLoadedScheme);
+ uno::Sequence < beans::PropertyValue > aPropValues(aColorNames.getLength());
+ beans::PropertyValue* pPropValues = aPropValues.getArray();
+ const OUString* pColorNames = aColorNames.getConstArray();
+ sal_Int32 nIndex = 0;
+ for(int i = 0; i < ColorConfigEntryCount && aColorNames.getLength() > nIndex; ++i)
+ {
+ pPropValues[nIndex].Name = pColorNames[nIndex];
+ //save automatic colors as void value
+ if(m_aConfigValues[i].nColor != COL_AUTO)
+ pPropValues[nIndex].Value <<= m_aConfigValues[i].nColor;
+
+ nIndex++;
+ if(nIndex >= aColorNames.getLength())
+ break;
+ //test for visibility property
+ if(pColorNames[nIndex].endsWith(g_sIsVisible))
+ {
+ pPropValues[nIndex].Name = pColorNames[nIndex];
+ pPropValues[nIndex].Value <<= m_aConfigValues[i].bIsVisible;
+ nIndex++;
+ }
+ }
+ SetSetProperties("ColorSchemes", aPropValues);
+
+ CommitCurrentSchemeName();
+}
+
+void ColorConfig_Impl::CommitCurrentSchemeName()
+{
+ //save current scheme name
+ uno::Sequence < OUString > aCurrent { "CurrentColorScheme" };
+ uno::Sequence< uno::Any > aCurrentVal(1);
+ aCurrentVal.getArray()[0] <<= m_sLoadedScheme;
+ PutProperties(aCurrent, aCurrentVal);
+}
+
+void ColorConfig_Impl::SetColorConfigValue(ColorConfigEntry eValue, const ColorConfigValue& rValue )
+{
+ if(rValue != m_aConfigValues[eValue])
+ {
+ m_aConfigValues[eValue] = rValue;
+ SetModified();
+ }
+}
+
+uno::Sequence< OUString> ColorConfig_Impl::GetSchemeNames()
+{
+ return GetNodeNames("ColorSchemes");
+}
+
+void ColorConfig_Impl::AddScheme(const OUString& rScheme)
+{
+ if(ConfigItem::AddNode("ColorSchemes", rScheme))
+ {
+ m_sLoadedScheme = rScheme;
+ Commit();
+ }
+}
+
+void ColorConfig_Impl::RemoveScheme(const OUString& rScheme)
+{
+ uno::Sequence< OUString > aElements { rScheme };
+ ClearNodeElements("ColorSchemes", aElements);
+}
+
+void ColorConfig_Impl::SettingsChanged()
+{
+ SolarMutexGuard aVclGuard;
+
+ ImplUpdateApplicationSettings();
+
+ NotifyListeners(ConfigurationHints::NONE);
+}
+
+IMPL_LINK( ColorConfig_Impl, DataChangedEventListener, VclSimpleEvent&, rEvent, void )
+{
+ if ( rEvent.GetId() == VclEventId::ApplicationDataChanged )
+ {
+ DataChangedEvent* pData = static_cast<DataChangedEvent*>(static_cast<VclWindowEvent&>(rEvent).GetData());
+ if ( (pData->GetType() == DataChangedEventType::SETTINGS) &&
+ (pData->GetFlags() & AllSettingsFlags::STYLE) )
+ {
+ SettingsChanged();
+ }
+ }
+}
+
+
+/** updates the font color in the vcl window settings */
+void ColorConfig_Impl::ImplUpdateApplicationSettings()
+{
+ Application* pApp = GetpApp();
+ if( !pApp )
+ return;
+
+ AllSettings aSettings = Application::GetSettings();
+ StyleSettings aStyleSettings( aSettings.GetStyleSettings() );
+
+ ColorConfigValue aRet = GetColorConfigValue(svtools::FONTCOLOR);
+ if(COL_AUTO == aRet.nColor)
+ aRet.nColor = ColorConfig::GetDefaultColor(svtools::FONTCOLOR);
+
+ Color aFontColor(aRet.nColor);
+
+ if( aStyleSettings.GetFontColor() != aFontColor )
+ {
+ aStyleSettings.SetFontColor( aFontColor );
+
+ aSettings.SetStyleSettings( aStyleSettings );
+ Application::SetSettings( aSettings );
+ }
+}
+
+ColorConfig::ColorConfig()
+{
+ if (utl::ConfigManager::IsFuzzing())
+ return;
+ ::osl::MutexGuard aGuard( ColorMutex_Impl::get() );
+ if ( !m_pImpl )
+ {
+ m_pImpl = new ColorConfig_Impl;
+ svtools::ItemHolder2::holdConfigItem(EItem::ColorConfig);
+ }
+ ++nColorRefCount_Impl;
+ m_pImpl->AddListener(this);
+}
+
+ColorConfig::~ColorConfig()
+{
+ if (utl::ConfigManager::IsFuzzing())
+ return;
+ ::osl::MutexGuard aGuard( ColorMutex_Impl::get() );
+ m_pImpl->RemoveListener(this);
+ if(!--nColorRefCount_Impl)
+ {
+ delete m_pImpl;
+ m_pImpl = nullptr;
+ }
+}
+
+Color ColorConfig::GetDefaultColor(ColorConfigEntry eEntry)
+{
+ static const Color aAutoColors[] =
+ {
+ COL_WHITE, // DOCCOLOR
+ COL_LIGHTGRAY, // DOCBOUNDARIES
+ Color(0xDFDFDE), // APPBACKGROUND
+ COL_LIGHTGRAY, // OBJECTBOUNDARIES
+ COL_LIGHTGRAY, // TABLEBOUNDARIES
+ COL_BLACK, // FONTCOLOR
+ COL_BLUE, // LINKS
+ Color(0x0000cc), // LINKSVISITED
+ COL_LIGHTRED, // SPELL
+ COL_LIGHTMAGENTA, // SMARTTAGS
+ COL_GRAY, // SHADOWCOLOR
+ COL_LIGHTGRAY, // WRITERTEXTGRID
+ COL_LIGHTGRAY, // WRITERFIELDSHADIN
+ COL_LIGHTGRAY, // WRITERIDXSHADINGS
+ COL_BLACK, // WRITERDIRECTCURSOR
+ COL_GREEN, //WRITERSCRIPTINDICATOR
+ COL_LIGHTGRAY, //WRITERSECTIONBOUNDARIES
+ Color(0x0369a3), //WRITERHEADERFOOTERMARK,
+ COL_BLUE, //WRITERPAGEBREAKS,
+ COL_LIGHTBLUE, // HTMLSGML
+ COL_LIGHTGREEN, // HTMLCOMMENT
+ COL_LIGHTRED, // HTMLKEYWORD
+ COL_GRAY, // HTMLUNKNOWN
+ COL_GRAY3, // CALCGRID
+ COL_BLUE, //CALCPAGEBREAK
+ Color(0x2300dc), //CALCPAGEBREAKMANUAL
+ COL_GRAY7, //CALCPAGEBREAKAUTOMATIC
+ COL_LIGHTBLUE, // CALCDETECTIVE
+ COL_LIGHTRED, // CALCDETECTIVEERROR
+ Color(0xef0fff), // CALCREFERENCE
+ Color(0xffffc0), // CALCNOTESBACKGROUND
+ COL_LIGHTBLUE, // CALCVALUE
+ COL_GREEN, // CALCFORMULA
+ COL_BLACK, // CALCTEXT
+ COL_LIGHTGRAY, // CALCPROTECTEDBACKGROUND
+ COL_GRAY7, // DRAWGRID
+ COL_GREEN, // BASICIDENTIFIER,
+ COL_GRAY, // BASICCOMMENT,
+ COL_LIGHTRED, // BASICNUMBER,
+ COL_LIGHTRED, // BASICSTRING,
+ COL_BLUE, // BASICOPERATOR,
+ COL_BLUE, // BASICKEYWORD,
+ COL_RED, //BASICERROR
+ Color(0x009900), // SQLIDENTIFIER
+ COL_BLACK, // SQLNUMBER
+ Color(0xCE7B00), // SQLSTRING
+ COL_BLACK, // SQLOPERATOR
+ Color(0x0000E6), // SQLKEYWORD
+ Color(0x259D9D), // SQLPARAMETER
+ COL_GRAY, // SQLCOMMENT
+ };
+ Color aRet;
+ switch(eEntry)
+ {
+ case APPBACKGROUND :
+ aRet = Application::GetSettings().GetStyleSettings().GetWorkspaceColor();
+ break;
+
+ case LINKS :
+ aRet = Application::GetSettings().GetStyleSettings().GetLinkColor();
+ break;
+
+ case LINKSVISITED :
+ aRet = Application::GetSettings().GetStyleSettings().GetVisitedLinkColor();
+ break;
+
+ default:
+ aRet = aAutoColors[eEntry];
+ }
+ // fdo#71511: if in autodetected a11y HC mode, do pull background color from theme
+ if(m_pImpl && m_pImpl->GetAutoDetectSystemHC())
+ {
+ switch(eEntry)
+ {
+ case DOCCOLOR :
+ aRet = Application::GetSettings().GetStyleSettings().GetWindowColor();
+ break;
+ case FONTCOLOR :
+ aRet = Application::GetSettings().GetStyleSettings().GetWindowTextColor();
+ break;
+ default:
+ break;
+ }
+ }
+ return aRet;
+}
+
+ColorConfigValue ColorConfig::GetColorValue(ColorConfigEntry eEntry, bool bSmart) const
+{
+ ColorConfigValue aRet;
+
+ if (m_pImpl)
+ aRet = m_pImpl->GetColorConfigValue(eEntry);
+
+ if (bSmart && aRet.nColor == COL_AUTO)
+ aRet.nColor = ColorConfig::GetDefaultColor(eEntry);
+
+ return aRet;
+}
+
+EditableColorConfig::EditableColorConfig() :
+ m_pImpl(new ColorConfig_Impl),
+ m_bModified(false)
+{
+ m_pImpl->BlockBroadcasts(true);
+}
+
+EditableColorConfig::~EditableColorConfig()
+{
+ m_pImpl->BlockBroadcasts(false);
+ if(m_bModified)
+ m_pImpl->SetModified();
+ if(m_pImpl->IsModified())
+ m_pImpl->Commit();
+}
+
+uno::Sequence< OUString > EditableColorConfig::GetSchemeNames() const
+{
+ return m_pImpl->GetSchemeNames();
+}
+
+void EditableColorConfig::DeleteScheme(const OUString& rScheme )
+{
+ m_pImpl->RemoveScheme(rScheme);
+}
+
+void EditableColorConfig::AddScheme(const OUString& rScheme )
+{
+ m_pImpl->AddScheme(rScheme);
+}
+
+void EditableColorConfig::LoadScheme(const OUString& rScheme )
+{
+ if(m_bModified)
+ m_pImpl->SetModified();
+ if(m_pImpl->IsModified())
+ m_pImpl->Commit();
+ m_bModified = false;
+ m_pImpl->Load(rScheme);
+ //the name of the loaded scheme has to be committed separately
+ m_pImpl->CommitCurrentSchemeName();
+}
+
+const OUString& EditableColorConfig::GetCurrentSchemeName()const
+{
+ return m_pImpl->GetLoadedScheme();
+}
+
+// Changes the name of the current scheme but doesn't load it!
+void EditableColorConfig::SetCurrentSchemeName(const OUString& rScheme)
+{
+ m_pImpl->SetCurrentSchemeName(rScheme);
+ m_pImpl->CommitCurrentSchemeName();
+}
+
+const ColorConfigValue& EditableColorConfig::GetColorValue(
+ ColorConfigEntry eEntry)const
+{
+ return m_pImpl->GetColorConfigValue(eEntry);
+}
+
+void EditableColorConfig::SetColorValue(
+ ColorConfigEntry eEntry, const ColorConfigValue& rValue)
+{
+ m_pImpl->SetColorConfigValue(eEntry, rValue);
+ m_pImpl->ClearModified();
+ m_bModified = true;
+}
+
+void EditableColorConfig::SetModified()
+{
+ m_bModified = true;
+}
+
+void EditableColorConfig::Commit()
+{
+ if(m_bModified)
+ m_pImpl->SetModified();
+ if(m_pImpl->IsModified())
+ m_pImpl->Commit();
+ m_bModified = false;
+}
+
+void EditableColorConfig::DisableBroadcast()
+{
+ m_pImpl->BlockBroadcasts(true);
+}
+
+void EditableColorConfig::EnableBroadcast()
+{
+ m_pImpl->BlockBroadcasts(false);
+}
+
+
+}//namespace svtools
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/config/extcolorcfg.cxx b/svtools/source/config/extcolorcfg.cxx
new file mode 100644
index 000000000..e23a2000b
--- /dev/null
+++ b/svtools/source/config/extcolorcfg.cxx
@@ -0,0 +1,664 @@
+/* -*- 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 <map>
+
+#include <svtools/extcolorcfg.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <tools/color.hxx>
+#include <unotools/configitem.hxx>
+#include <com/sun/star/uno/Sequence.h>
+#include <comphelper/sequence.hxx>
+#include <svl/hint.hxx>
+#include <osl/mutex.hxx>
+#include <sal/log.hxx>
+#include <osl/diagnose.h>
+
+#include <vcl/svapp.hxx>
+#include <vcl/settings.hxx>
+#include <vcl/event.hxx>
+#include <rtl/instance.hxx>
+
+
+using namespace utl;
+using namespace com::sun::star;
+
+
+namespace svtools
+{
+
+static sal_Int32 nExtendedColorRefCount_Impl = 0;
+namespace
+{
+ struct ColorMutex_Impl
+ : public rtl::Static< ::osl::Mutex, ColorMutex_Impl > {};
+}
+
+ExtendedColorConfig_Impl* ExtendedColorConfig::m_pImpl = nullptr;
+
+class ExtendedColorConfig_Impl : public utl::ConfigItem, public SfxBroadcaster
+{
+ typedef std::map<OUString, OUString> TDisplayNames;
+ typedef std::map<OUString, ExtendedColorConfigValue> TConfigValues;
+ typedef ::std::vector<TConfigValues::iterator> TMapPos;
+ typedef ::std::pair< TConfigValues, TMapPos > TComponentMapping;
+ typedef std::map<OUString, TComponentMapping> TComponents;
+ TComponents m_aConfigValues;
+ TDisplayNames m_aComponentDisplayNames;
+ ::std::vector<TComponents::iterator> m_aConfigValuesPos;
+
+ OUString m_sLoadedScheme;
+ bool m_bIsBroadcastEnabled;
+ static bool m_bLockBroadcast;
+ static bool m_bBroadcastWhenUnlocked;
+
+ uno::Sequence< OUString> GetPropertyNames(const OUString& rScheme);
+ void FillComponentColors(const uno::Sequence < OUString >& _rComponents,const TDisplayNames& _rDisplayNames);
+
+ virtual void ImplCommit() override;
+
+public:
+ explicit ExtendedColorConfig_Impl();
+ virtual ~ExtendedColorConfig_Impl() override;
+
+ void Load(const OUString& rScheme);
+ void CommitCurrentSchemeName();
+ //changes the name of the current scheme but doesn't load it!
+ void SetCurrentSchemeName(const OUString& rSchemeName) {m_sLoadedScheme = rSchemeName;}
+ bool ExistsScheme(const OUString& _sSchemeName);
+ virtual void Notify( const uno::Sequence<OUString>& aPropertyNames) override;
+
+ sal_Int32 GetComponentCount() const;
+ OUString GetComponentName(sal_uInt32 _nPos) const;
+ OUString GetComponentDisplayName(const OUString& _sComponentName) const;
+ sal_Int32 GetComponentColorCount(const OUString& _sName) const;
+ ExtendedColorConfigValue GetComponentColorConfigValue(const OUString& _sName,sal_uInt32 _nPos) const;
+
+ ExtendedColorConfigValue GetColorConfigValue(const OUString& _sComponentName,const OUString& _sName)
+ {
+ TComponents::iterator aFind = m_aConfigValues.find(_sComponentName);
+ if ( aFind != m_aConfigValues.end() )
+ {
+ TConfigValues::iterator aFind2 = aFind->second.first.find(_sName);
+ if ( aFind2 != aFind->second.first.end() )
+ return aFind2->second;
+ }
+#if OSL_DEBUG_LEVEL > 0
+ SAL_WARN( "svtools", "Could find the required config:\n"
+ "component: " << _sComponentName
+ << "\nname: " << _sName );
+#endif
+ return ExtendedColorConfigValue();
+ }
+ void SetColorConfigValue(const OUString& _sName,
+ const ExtendedColorConfigValue& rValue );
+
+ void AddScheme(const OUString& rNode);
+ void RemoveScheme(const OUString& rNode);
+ using ConfigItem::SetModified;
+ using ConfigItem::ClearModified;
+ void SettingsChanged();
+
+ static void DisableBroadcast();
+ static void EnableBroadcast();
+
+ static void LockBroadcast();
+ static void UnlockBroadcast();
+
+ DECL_LINK( DataChangedEventListener, VclSimpleEvent&, void );
+};
+
+uno::Sequence< OUString> ExtendedColorConfig_Impl::GetPropertyNames(const OUString& rScheme)
+{
+ uno::Sequence< OUString> aNames(GetNodeNames(rScheme));
+ for(OUString & i : aNames)
+ {
+ i = rScheme + "/" + i;
+ }
+ return aNames;
+}
+
+sal_Int32 ExtendedColorConfig_Impl::GetComponentCount() const
+{
+ return m_aConfigValues.size();
+}
+
+sal_Int32 ExtendedColorConfig_Impl::GetComponentColorCount(const OUString& _sName) const
+{
+ sal_Int32 nSize = 0;
+ TComponents::const_iterator aFind = m_aConfigValues.find(_sName);
+ if ( aFind != m_aConfigValues.end() )
+ {
+ nSize = aFind->second.first.size();
+ }
+ return nSize;
+}
+
+ExtendedColorConfigValue ExtendedColorConfig_Impl::GetComponentColorConfigValue(const OUString& _sName,sal_uInt32 _nPos) const
+{
+ TComponents::const_iterator aFind = m_aConfigValues.find(_sName);
+ if ( aFind != m_aConfigValues.end() )
+ {
+ if ( _nPos < aFind->second.second.size() )
+ {
+ return aFind->second.second[_nPos]->second;
+ }
+ }
+ return ExtendedColorConfigValue();
+}
+
+OUString ExtendedColorConfig_Impl::GetComponentDisplayName(const OUString& _sComponentName) const
+{
+ OUString sRet;
+ TDisplayNames::const_iterator aFind = m_aComponentDisplayNames.find(_sComponentName);
+ if ( aFind != m_aComponentDisplayNames.end() )
+ sRet = aFind->second;
+ return sRet;
+}
+
+OUString ExtendedColorConfig_Impl::GetComponentName(sal_uInt32 _nPos) const
+{
+ OUString sRet;
+ if ( _nPos < m_aConfigValuesPos.size() )
+ sRet = m_aConfigValuesPos[_nPos]->first;
+ return sRet;
+}
+
+bool ExtendedColorConfig_Impl::m_bLockBroadcast = false;
+bool ExtendedColorConfig_Impl::m_bBroadcastWhenUnlocked = false;
+ExtendedColorConfig_Impl::ExtendedColorConfig_Impl() :
+ ConfigItem("Office.ExtendedColorScheme"),
+ m_bIsBroadcastEnabled(true)
+{
+ //try to register on the root node - if possible
+ uno::Sequence < OUString > aNames(1);
+ EnableNotification( aNames );
+ Load(OUString());
+
+ ::Application::AddEventListener( LINK(this, ExtendedColorConfig_Impl, DataChangedEventListener) );
+
+}
+
+ExtendedColorConfig_Impl::~ExtendedColorConfig_Impl()
+{
+ ::Application::RemoveEventListener( LINK(this, ExtendedColorConfig_Impl, DataChangedEventListener) );
+}
+
+void ExtendedColorConfig_Impl::DisableBroadcast()
+{
+ if ( ExtendedColorConfig::m_pImpl )
+ ExtendedColorConfig::m_pImpl->m_bIsBroadcastEnabled = false;
+}
+
+void ExtendedColorConfig_Impl::EnableBroadcast()
+{
+ if ( ExtendedColorConfig::m_pImpl )
+ ExtendedColorConfig::m_pImpl->m_bIsBroadcastEnabled = true;
+}
+
+static void lcl_addString(uno::Sequence < OUString >& _rSeq,const OUString& _sAdd)
+{
+ for(OUString & i : _rSeq)
+ i += _sAdd;
+}
+
+void ExtendedColorConfig_Impl::Load(const OUString& rScheme)
+{
+ m_aComponentDisplayNames.clear();
+ m_aConfigValuesPos.clear();
+ m_aConfigValues.clear();
+
+ // fill display names
+ TDisplayNames aDisplayNameMap;
+ uno::Sequence < OUString > aComponentNames = GetPropertyNames("EntryNames");
+ OUString sDisplayName("/DisplayName");
+ for(OUString & componentName : aComponentNames)
+ {
+ uno::Sequence < OUString > aComponentDisplayNames(1);
+ aComponentDisplayNames[0] = componentName + sDisplayName;
+ uno::Sequence< uno::Any > aComponentDisplayNamesValue = GetProperties( aComponentDisplayNames );
+ OUString sComponentDisplayName;
+ if ( aComponentDisplayNamesValue.hasElements() && (aComponentDisplayNamesValue[0] >>= sComponentDisplayName) )
+ {
+ m_aComponentDisplayNames.emplace(componentName.getToken(1, '/'),sComponentDisplayName);
+ }
+
+ componentName += "/Entries";
+ uno::Sequence < OUString > aDisplayNames = GetPropertyNames(componentName);
+ lcl_addString(aDisplayNames,sDisplayName);
+
+ uno::Sequence< uno::Any > aDisplayNamesValue = GetProperties( aDisplayNames );
+
+ const OUString* pDispIter = aDisplayNames.getConstArray();
+ const OUString* pDispEnd = pDispIter + aDisplayNames.getLength();
+ for(sal_Int32 j = 0;pDispIter != pDispEnd;++pDispIter,++j)
+ {
+ sal_Int32 nIndex = 0;
+ pDispIter->getToken(0,'/',nIndex);
+ OUString sName = pDispIter->copy(nIndex);
+ sName = sName.copy(0,sName.lastIndexOf(sDisplayName));
+ OUString sCurrentDisplayName;
+ aDisplayNamesValue[j] >>= sCurrentDisplayName;
+ aDisplayNameMap.emplace(sName,sCurrentDisplayName);
+ }
+ }
+
+ // load color settings
+ OUString sScheme(rScheme);
+
+ if(sScheme.isEmpty())
+ {
+ //detect current scheme name
+ uno::Sequence < OUString > aCurrent { "ExtendedColorScheme/CurrentColorScheme" };
+ uno::Sequence< uno::Any > aCurrentVal = GetProperties( aCurrent );
+ aCurrentVal.getConstArray()[0] >>= sScheme;
+ } // if(!sScheme.getLength())
+
+ m_sLoadedScheme = sScheme;
+ OUString sBase = "ExtendedColorScheme/ColorSchemes/"
+ + sScheme;
+
+ bool bFound = ExistsScheme(sScheme);
+ if ( bFound )
+ {
+ aComponentNames = GetPropertyNames(sBase);
+ FillComponentColors(aComponentNames,aDisplayNameMap);
+ }
+
+ if ( m_sLoadedScheme.isEmpty() )
+ m_sLoadedScheme = "default";
+
+ if ( sScheme != "default" )
+ {
+ if ( ExistsScheme("default") )
+ {
+ aComponentNames = GetPropertyNames("ExtendedColorScheme/ColorSchemes/default");
+ FillComponentColors(aComponentNames,aDisplayNameMap);
+ }
+ }
+ if ( !bFound && !sScheme.isEmpty() )
+ {
+ AddScheme(sScheme);
+ CommitCurrentSchemeName();
+ }
+}
+
+void ExtendedColorConfig_Impl::FillComponentColors(const uno::Sequence < OUString >& _rComponents,const TDisplayNames& _rDisplayNames)
+{
+ const OUString sColorEntries("/Entries");
+ for(OUString const & component : _rComponents)
+ {
+ OUString sComponentName = component.copy(component.lastIndexOf('/')+1);
+ if ( m_aConfigValues.find(sComponentName) == m_aConfigValues.end() )
+ {
+ OUString sEntry = component + sColorEntries;
+
+ uno::Sequence < OUString > aColorNames = GetPropertyNames(sEntry);
+ uno::Sequence < OUString > aDefaultColorNames = aColorNames;
+
+ const OUString sColor("/Color");
+ const OUString sDefaultColor("/DefaultColor");
+ lcl_addString(aColorNames,sColor);
+ lcl_addString(aDefaultColorNames,sDefaultColor);
+ uno::Sequence< uno::Any > aColors = GetProperties( aColorNames );
+ const uno::Any* pColors = aColors.getConstArray();
+
+ uno::Sequence< uno::Any > aDefaultColors = GetProperties( aDefaultColorNames );
+ bool bDefaultColorFound = aDefaultColors.hasElements();
+ const uno::Any* pDefaultColors = aDefaultColors.getConstArray();
+
+ OUString* pColorIter = aColorNames.getArray();
+ OUString* pColorEnd = pColorIter + aColorNames.getLength();
+
+ m_aConfigValuesPos.push_back(m_aConfigValues.emplace(sComponentName,TComponentMapping(TConfigValues(),TMapPos())).first);
+ TConfigValues& aConfigValues = (*m_aConfigValuesPos.rbegin())->second.first;
+ TMapPos& aConfigValuesPos = (*m_aConfigValuesPos.rbegin())->second.second;
+ for(int i = 0; pColorIter != pColorEnd; ++pColorIter ,++i)
+ {
+ if ( aConfigValues.find(*pColorIter) == aConfigValues.end() )
+ {
+ sal_Int32 nIndex = 0;
+ pColorIter->getToken(2,'/',nIndex);
+ OUString sName(pColorIter->copy(nIndex)),sDisplayName;
+ OUString sTemp = sName.copy(0,sName.lastIndexOf(sColor));
+
+ TDisplayNames::const_iterator aFind = _rDisplayNames.find(sTemp);
+ sName = sName.getToken(2, '/');
+ OSL_ENSURE(aFind != _rDisplayNames.end(),"DisplayName is not in EntryNames config list!");
+ if ( aFind != _rDisplayNames.end() )
+ sDisplayName = aFind->second;
+
+ OSL_ENSURE(pColors[i].hasValue(),"Color config entry has NIL as color value set!");
+ OSL_ENSURE(pDefaultColors[i].hasValue(),"Color config entry has NIL as color value set!");
+ Color nColor, nDefaultColor;
+ pColors[i] >>= nColor;
+ if ( bDefaultColorFound )
+ pDefaultColors[i] >>= nDefaultColor;
+ else
+ nDefaultColor = nColor;
+ ExtendedColorConfigValue aValue(sName,sDisplayName,nColor,nDefaultColor);
+ aConfigValuesPos.push_back(aConfigValues.emplace(sName,aValue).first);
+ }
+ } // for(int i = 0; pColorIter != pColorEnd; ++pColorIter ,++i)
+ }
+ }
+}
+
+void ExtendedColorConfig_Impl::Notify( const uno::Sequence<OUString>& /*rPropertyNames*/)
+{
+ //loading via notification always uses the default setting
+ Load(OUString());
+
+ SolarMutexGuard aVclGuard;
+
+ if(m_bLockBroadcast)
+ {
+ m_bBroadcastWhenUnlocked = true;
+ }
+ else
+ Broadcast(SfxHint(SfxHintId::ColorsChanged));
+}
+
+void ExtendedColorConfig_Impl::ImplCommit()
+{
+ if ( m_sLoadedScheme.isEmpty() )
+ return;
+ const OUString sColorEntries("Entries");
+ const OUString sColor("/Color");
+ OUString sBase = "ExtendedColorScheme/ColorSchemes/"
+ + m_sLoadedScheme;
+ const OUString s_sSep("/");
+
+ for (auto const& configValue : m_aConfigValues)
+ {
+ if ( ConfigItem::AddNode(sBase, configValue.first) )
+ {
+ OUString sNode = sBase
+ + s_sSep
+ + configValue.first
+ //ConfigItem::AddNode(sNode, sColorEntries);
+ + s_sSep
+ + sColorEntries;
+
+ uno::Sequence < beans::PropertyValue > aPropValues(configValue.second.first.size());
+ beans::PropertyValue* pPropValues = aPropValues.getArray();
+ for (auto const& elem : configValue.second.first)
+ {
+ pPropValues->Name = sNode + s_sSep + elem.first;
+ ConfigItem::AddNode(sNode, elem.first);
+ pPropValues->Name += sColor;
+ pPropValues->Value <<= elem.second.getColor();
+ // the default color will never be changed
+ ++pPropValues;
+ }
+ SetSetProperties("ExtendedColorScheme/ColorSchemes", aPropValues);
+ }
+ }
+
+ CommitCurrentSchemeName();
+}
+
+void ExtendedColorConfig_Impl::CommitCurrentSchemeName()
+{
+ //save current scheme name
+ uno::Sequence < OUString > aCurrent { "ExtendedColorScheme/CurrentColorScheme" };
+ uno::Sequence< uno::Any > aCurrentVal(1);
+ aCurrentVal.getArray()[0] <<= m_sLoadedScheme;
+ PutProperties(aCurrent, aCurrentVal);
+}
+
+bool ExtendedColorConfig_Impl::ExistsScheme(const OUString& _sSchemeName)
+{
+ OUString sBase("ExtendedColorScheme/ColorSchemes");
+
+ uno::Sequence < OUString > aComponentNames = GetPropertyNames(sBase);
+ sBase += "/" + _sSchemeName;
+ return comphelper::findValue(aComponentNames, sBase) != -1;
+}
+
+void ExtendedColorConfig_Impl::SetColorConfigValue(const OUString& _sName, const ExtendedColorConfigValue& rValue )
+{
+ TComponents::iterator aFind = m_aConfigValues.find(_sName);
+ if ( aFind != m_aConfigValues.end() )
+ {
+ TConfigValues::iterator aFind2 = aFind->second.first.find(rValue.getName());
+ if ( aFind2 != aFind->second.first.end() )
+ aFind2->second = rValue;
+ SetModified();
+ }
+}
+
+void ExtendedColorConfig_Impl::AddScheme(const OUString& rScheme)
+{
+ if(ConfigItem::AddNode("ExtendedColorScheme/ColorSchemes", rScheme))
+ {
+ m_sLoadedScheme = rScheme;
+ Commit();
+ }
+}
+
+void ExtendedColorConfig_Impl::RemoveScheme(const OUString& rScheme)
+{
+ uno::Sequence< OUString > aElements { rScheme };
+ ClearNodeElements("ExtendedColorScheme/ColorSchemes", aElements);
+}
+
+void ExtendedColorConfig_Impl::SettingsChanged()
+{
+ SolarMutexGuard aVclGuard;
+
+ Broadcast( SfxHint( SfxHintId::ColorsChanged ) );
+}
+
+void ExtendedColorConfig_Impl::LockBroadcast()
+{
+ m_bLockBroadcast = true;
+}
+
+void ExtendedColorConfig_Impl::UnlockBroadcast()
+{
+ if ( m_bBroadcastWhenUnlocked )
+ {
+ m_bBroadcastWhenUnlocked = ExtendedColorConfig::m_pImpl != nullptr;
+ if ( m_bBroadcastWhenUnlocked )
+ {
+ if (ExtendedColorConfig::m_pImpl->m_bIsBroadcastEnabled)
+ {
+ m_bBroadcastWhenUnlocked = false;
+ ExtendedColorConfig::m_pImpl->Broadcast(SfxHint(SfxHintId::ColorsChanged));
+ }
+ }
+ }
+ m_bLockBroadcast = false;
+}
+
+IMPL_LINK( ExtendedColorConfig_Impl, DataChangedEventListener, VclSimpleEvent&, rEvent, void )
+{
+ if ( rEvent.GetId() == VclEventId::ApplicationDataChanged )
+ {
+ DataChangedEvent* pData = static_cast<DataChangedEvent*>(static_cast<VclWindowEvent&>(rEvent).GetData());
+ if ( (pData->GetType() == DataChangedEventType::SETTINGS) &&
+ (pData->GetFlags() & AllSettingsFlags::STYLE) )
+ {
+ SettingsChanged();
+ }
+ }
+}
+
+
+ExtendedColorConfig::ExtendedColorConfig()
+{
+ ::osl::MutexGuard aGuard( ColorMutex_Impl::get() );
+ if ( !m_pImpl )
+ m_pImpl = new ExtendedColorConfig_Impl;
+ ++nExtendedColorRefCount_Impl;
+ StartListening( *m_pImpl);
+}
+
+ExtendedColorConfig::~ExtendedColorConfig()
+{
+ ::osl::MutexGuard aGuard( ColorMutex_Impl::get() );
+ EndListening( *m_pImpl);
+ if(!--nExtendedColorRefCount_Impl)
+ {
+ delete m_pImpl;
+ m_pImpl = nullptr;
+ }
+}
+
+ExtendedColorConfigValue ExtendedColorConfig::GetColorValue(const OUString& _sComponentName,const OUString& _sName)const
+{
+ return m_pImpl->GetColorConfigValue(_sComponentName,_sName);
+}
+
+sal_Int32 ExtendedColorConfig::GetComponentCount() const
+{
+ return m_pImpl->GetComponentCount();
+}
+
+sal_Int32 ExtendedColorConfig::GetComponentColorCount(const OUString& _sName) const
+{
+ return m_pImpl->GetComponentColorCount(_sName);
+}
+
+ExtendedColorConfigValue ExtendedColorConfig::GetComponentColorConfigValue(const OUString& _sName,sal_uInt32 _nPos) const
+{
+ return m_pImpl->GetComponentColorConfigValue(_sName,_nPos);
+}
+
+OUString ExtendedColorConfig::GetComponentName(sal_uInt32 _nPos) const
+{
+ return m_pImpl->GetComponentName(_nPos);
+}
+
+OUString ExtendedColorConfig::GetComponentDisplayName(const OUString& _sComponentName) const
+{
+ return m_pImpl->GetComponentDisplayName(_sComponentName);
+}
+
+void ExtendedColorConfig::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
+{
+ SolarMutexGuard aVclGuard;
+
+ Broadcast( rHint );
+}
+
+EditableExtendedColorConfig::EditableExtendedColorConfig() :
+ m_pImpl(new ExtendedColorConfig_Impl),
+ m_bModified(false)
+{
+ ExtendedColorConfig_Impl::LockBroadcast();
+}
+
+EditableExtendedColorConfig::~EditableExtendedColorConfig()
+{
+ ExtendedColorConfig_Impl::UnlockBroadcast();
+ if(m_bModified)
+ m_pImpl->SetModified();
+ if(m_pImpl->IsModified())
+ m_pImpl->Commit();
+}
+
+void EditableExtendedColorConfig::DeleteScheme(const OUString& rScheme )
+{
+ m_pImpl->RemoveScheme(rScheme);
+}
+
+void EditableExtendedColorConfig::AddScheme(const OUString& rScheme )
+{
+ m_pImpl->AddScheme(rScheme);
+}
+
+void EditableExtendedColorConfig::LoadScheme(const OUString& rScheme )
+{
+ if(m_bModified)
+ m_pImpl->SetModified();
+ if(m_pImpl->IsModified())
+ m_pImpl->Commit();
+ m_bModified = false;
+ m_pImpl->Load(rScheme);
+ //the name of the loaded scheme has to be committed separately
+ m_pImpl->CommitCurrentSchemeName();
+}
+
+// Changes the name of the current scheme but doesn't load it!
+void EditableExtendedColorConfig::SetCurrentSchemeName(const OUString& rScheme)
+{
+ m_pImpl->SetCurrentSchemeName(rScheme);
+ m_pImpl->CommitCurrentSchemeName();
+}
+
+void EditableExtendedColorConfig::SetColorValue(
+ const OUString& _sName, const ExtendedColorConfigValue& rValue)
+{
+ m_pImpl->SetColorConfigValue(_sName, rValue);
+ m_pImpl->ClearModified();
+ m_bModified = true;
+}
+
+void EditableExtendedColorConfig::SetModified()
+{
+ m_bModified = true;
+}
+
+void EditableExtendedColorConfig::Commit()
+{
+ if(m_bModified)
+ m_pImpl->SetModified();
+ if(m_pImpl->IsModified())
+ m_pImpl->Commit();
+ m_bModified = false;
+}
+
+void EditableExtendedColorConfig::DisableBroadcast()
+{
+ ExtendedColorConfig_Impl::DisableBroadcast();
+}
+
+void EditableExtendedColorConfig::EnableBroadcast()
+{
+ ExtendedColorConfig_Impl::EnableBroadcast();
+}
+
+sal_Int32 EditableExtendedColorConfig::GetComponentCount() const
+{
+ return m_pImpl->GetComponentCount();
+}
+
+sal_Int32 EditableExtendedColorConfig::GetComponentColorCount(const OUString& _sName) const
+{
+ return m_pImpl->GetComponentColorCount(_sName);
+}
+
+ExtendedColorConfigValue EditableExtendedColorConfig::GetComponentColorConfigValue(const OUString& _sName,sal_uInt32 _nPos) const
+{
+ return m_pImpl->GetComponentColorConfigValue(_sName,_nPos);
+}
+
+OUString EditableExtendedColorConfig::GetComponentName(sal_uInt32 _nPos) const
+{
+ return m_pImpl->GetComponentName(_nPos);
+}
+}//namespace svtools
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/config/fontsubstconfig.cxx b/svtools/source/config/fontsubstconfig.cxx
new file mode 100644
index 000000000..e0fb350d8
--- /dev/null
+++ b/svtools/source/config/fontsubstconfig.cxx
@@ -0,0 +1,181 @@
+/* -*- 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 <svtools/fontsubstconfig.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <o3tl/any.hxx>
+#include <tools/debug.hxx>
+#include <vcl/outdev.hxx>
+
+#include <vector>
+
+using namespace utl;
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::beans;
+
+
+const char cReplacement[] = "Replacement";
+const char cFontPairs[] = "FontPairs";
+
+const char cReplaceFont[] = "ReplaceFont";
+const char cSubstituteFont[]= "SubstituteFont";
+const char cOnScreenOnly[] = "OnScreenOnly";
+const char cAlways[] = "Always";
+
+typedef std::vector<SubstitutionStruct> SubstitutionStructArr;
+
+struct SvtFontSubstConfig_Impl
+{
+ SubstitutionStructArr aSubstArr;
+};
+
+SvtFontSubstConfig::SvtFontSubstConfig() :
+ ConfigItem("Office.Common/Font/Substitution"),
+ bIsEnabled(false),
+ pImpl(new SvtFontSubstConfig_Impl)
+{
+ Sequence<OUString> aNames { cReplacement };
+ Sequence<Any> aValues = GetProperties(aNames);
+ DBG_ASSERT(aValues.getConstArray()[0].hasValue(), "no value available");
+ if(aValues.getConstArray()[0].hasValue())
+ bIsEnabled = *o3tl::doAccess<bool>(aValues.getConstArray()[0]);
+
+ OUString sPropPrefix(cFontPairs);
+ const Sequence<OUString> aNodeNames = GetNodeNames(sPropPrefix, ConfigNameFormat::LocalPath);
+ Sequence<OUString> aPropNames(aNodeNames.getLength() * 4);
+ OUString* pNames = aPropNames.getArray();
+ sal_Int32 nName = 0;
+ sPropPrefix += "/";
+ for(const OUString& rNodeName : aNodeNames)
+ {
+ OUString sStart = sPropPrefix + rNodeName + "/";
+ pNames[nName++] = sStart + cReplaceFont;
+ pNames[nName++] = sStart + cSubstituteFont;
+ pNames[nName++] = sStart + cAlways;
+ pNames[nName++] = sStart + cOnScreenOnly;
+ }
+ Sequence<Any> aNodeValues = GetProperties(aPropNames);
+ const Any* pNodeValues = aNodeValues.getConstArray();
+ nName = 0;
+ for(sal_Int32 nNode = 0; nNode < aNodeNames.getLength(); nNode++)
+ {
+ SubstitutionStruct aInsert;
+ pNodeValues[nName++] >>= aInsert.sFont;
+ pNodeValues[nName++] >>= aInsert.sReplaceBy;
+ aInsert.bReplaceAlways = *o3tl::doAccess<bool>(pNodeValues[nName++]);
+ aInsert.bReplaceOnScreenOnly = *o3tl::doAccess<bool>(pNodeValues[nName++]);
+ pImpl->aSubstArr.push_back(aInsert);
+ }
+}
+
+SvtFontSubstConfig::~SvtFontSubstConfig()
+{
+}
+
+void SvtFontSubstConfig::Notify( const css::uno::Sequence< OUString >& )
+{
+}
+
+void SvtFontSubstConfig::ImplCommit()
+{
+ PutProperties({cReplacement}, {css::uno::Any(bIsEnabled)});
+
+ OUString sNode(cFontPairs);
+ if(pImpl->aSubstArr.empty())
+ ClearNodeSet(sNode);
+ else
+ {
+ Sequence<PropertyValue> aSetValues(4 * pImpl->aSubstArr.size());
+ PropertyValue* pSetValues = aSetValues.getArray();
+ sal_Int32 nSetValue = 0;
+
+ const OUString sReplaceFont(cReplaceFont);
+ const OUString sSubstituteFont(cSubstituteFont);
+ const OUString sAlways(cAlways);
+ const OUString sOnScreenOnly(cOnScreenOnly);
+
+ for(size_t i = 0; i < pImpl->aSubstArr.size(); i++)
+ {
+ OUString sPrefix = sNode + "/_" + OUString::number(i) + "/";
+
+ SubstitutionStruct& rSubst = pImpl->aSubstArr[i];
+ pSetValues[nSetValue].Name = sPrefix; pSetValues[nSetValue].Name += sReplaceFont;
+ pSetValues[nSetValue++].Value <<= rSubst.sFont;
+ pSetValues[nSetValue].Name = sPrefix; pSetValues[nSetValue].Name += sSubstituteFont;
+ pSetValues[nSetValue++].Value <<= rSubst.sReplaceBy;
+ pSetValues[nSetValue].Name = sPrefix; pSetValues[nSetValue].Name += sAlways;
+ pSetValues[nSetValue++].Value <<= rSubst.bReplaceAlways;
+ pSetValues[nSetValue].Name = sPrefix; pSetValues[nSetValue].Name += sOnScreenOnly;
+ pSetValues[nSetValue++].Value <<= rSubst.bReplaceOnScreenOnly;
+ }
+ ReplaceSetProperties(sNode, aSetValues);
+ }
+}
+
+sal_Int32 SvtFontSubstConfig::SubstitutionCount() const
+{
+ return pImpl->aSubstArr.size();
+}
+
+void SvtFontSubstConfig::ClearSubstitutions()
+{
+ pImpl->aSubstArr.clear();
+}
+
+const SubstitutionStruct* SvtFontSubstConfig::GetSubstitution(sal_Int32 nPos)
+{
+ sal_Int32 nCount = static_cast<sal_Int32>(pImpl->aSubstArr.size());
+ DBG_ASSERT(nPos >= 0 && nPos < nCount, "illegal array index");
+ if(nPos >= 0 && nPos < nCount)
+ return &pImpl->aSubstArr[nPos];
+ return nullptr;
+}
+
+void SvtFontSubstConfig::AddSubstitution(const SubstitutionStruct& rToAdd)
+{
+ pImpl->aSubstArr.push_back(rToAdd);
+}
+
+void SvtFontSubstConfig::Apply()
+{
+ OutputDevice::BeginFontSubstitution();
+
+ // remove old substitutions
+ OutputDevice::RemoveFontsSubstitute();
+
+ // read new substitutions
+ sal_Int32 nCount = IsEnabled() ? SubstitutionCount() : 0;
+
+ for (sal_Int32 i = 0; i < nCount; i++)
+ {
+ AddFontSubstituteFlags nFlags = AddFontSubstituteFlags::NONE;
+ const SubstitutionStruct* pSubs = GetSubstitution(i);
+ if(pSubs->bReplaceAlways)
+ nFlags |= AddFontSubstituteFlags::ALWAYS;
+ if(pSubs->bReplaceOnScreenOnly)
+ nFlags |= AddFontSubstituteFlags::ScreenOnly;
+ OutputDevice::AddFontSubstitute( pSubs->sFont, pSubs->sReplaceBy, nFlags );
+ }
+
+ OutputDevice::EndFontSubstitution();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/config/helpopt.cxx b/svtools/source/config/helpopt.cxx
new file mode 100644
index 000000000..1137caaef
--- /dev/null
+++ b/svtools/source/config/helpopt.cxx
@@ -0,0 +1,305 @@
+/* -*- 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,
+ System = 3,
+ StyleSheet = 4,
+ OfflineHelpPopUp = 5
+};
+
+}
+
+class SvtHelpOptions_Impl : public utl::ConfigItem
+{
+ bool bExtendedHelp;
+ bool bHelpTips;
+ bool bOfflineHelpPopUp;
+ OUString aLocale;
+ OUString aSystem;
+ 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; }
+ void SetOfflineHelpPopUp(bool b) { bOfflineHelpPopUp = b; SetModified();}
+ bool IsOfflineHelpPopUp() const { return bOfflineHelpPopUp;}
+ const OUString& GetSystem() const { return aSystem; }
+
+ const OUString& GetHelpStyleSheet()const{return sHelpStyleSheet;}
+ void SetHelpStyleSheet(const OUString& rStyleSheet){sHelpStyleSheet = rStyleSheet; SetModified();}
+
+ static ::osl::Mutex & getInitMutex();
+};
+
+Sequence< OUString > const & SvtHelpOptions_Impl::GetPropertyNames()
+{
+ static Sequence<OUString> const aNames
+ {
+ "ExtendedTip",
+ "Tip",
+ "Locale",
+ "System",
+ "HelpStyleSheet",
+ "BuiltInHelpNotInstalledPopUp"
+ };
+
+ 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 )
+ , bOfflineHelpPopUp( 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;
+ case HelpProperty::OfflineHelpPopUp:
+ bOfflineHelpPopUp = 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;
+
+ case HelpProperty::System:
+ aSystem = aTmpStr;
+ break;
+ case HelpProperty::StyleSheet:
+ sHelpStyleSheet = 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;
+
+ case HelpProperty::System:
+ pValues[nProp] <<= aSystem;
+ break;
+ case HelpProperty::StyleSheet:
+ pValues[nProp] <<= sHelpStyleSheet;
+ break;
+ case HelpProperty::OfflineHelpPopUp:
+ pValues[nProp] <<= bOfflineHelpPopUp;
+ 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::SetOfflineHelpPopUp (bool b )
+{
+ pImpl->SetOfflineHelpPopUp( b );
+}
+
+bool SvtHelpOptions::IsOfflineHelpPopUp() const
+{
+ return pImpl->IsOfflineHelpPopUp();
+}
+void SvtHelpOptions::SetHelpTips( bool b )
+{
+ pImpl->SetHelpTips( b );
+}
+
+bool SvtHelpOptions::IsHelpTips() const
+{
+ return pImpl->IsHelpTips();
+}
+
+OUString const & SvtHelpOptions::GetSystem() const
+{
+ return pImpl->GetSystem();
+}
+
+const OUString& SvtHelpOptions::GetHelpStyleSheet()const
+{
+ return pImpl->GetHelpStyleSheet();
+}
+
+void SvtHelpOptions::SetHelpStyleSheet(const OUString& rStyleSheet)
+{
+ pImpl->SetHelpStyleSheet(rStyleSheet);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/config/htmlcfg.cxx b/svtools/source/config/htmlcfg.cxx
new file mode 100644
index 000000000..fbd7f57e2
--- /dev/null
+++ b/svtools/source/config/htmlcfg.cxx
@@ -0,0 +1,415 @@
+/* -*- 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 <o3tl/any.hxx>
+#include <osl/thread.h>
+#include <svtools/htmlcfg.hxx>
+#include <svtools/parhtml.hxx>
+#include <unotools/syslocale.hxx>
+#include <tools/debug.hxx>
+#include <rtl/instance.hxx>
+#include <o3tl/typed_flags_set.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+namespace {
+
+enum class HtmlCfgFlags {
+ NONE = 0x000,
+ UnknownTags = 0x001,
+ StarBasic = 0x008,
+ LocalGrf = 0x010,
+ PrintLayoutExtension = 0x020,
+ IgnoreFontFamily = 0x040,
+ IsBasicWarning = 0x080,
+ NumbersEnglishUS = 0x100,
+};
+
+}
+
+namespace o3tl {
+ template<> struct typed_flags<HtmlCfgFlags> : is_typed_flags<HtmlCfgFlags, 0x1f9> {};
+}
+
+using namespace utl;
+using namespace com::sun::star::uno;
+
+
+struct HtmlOptions_Impl
+{
+ HtmlCfgFlags nFlags;
+ sal_Int32 nExportMode;
+ sal_Int32 aFontSizeArr[HTML_FONT_COUNT];
+ sal_Int32 eEncoding;
+ bool bIsEncodingDefault;
+
+ HtmlOptions_Impl() :
+ nFlags(HtmlCfgFlags::LocalGrf|HtmlCfgFlags::IsBasicWarning),
+ nExportMode(HTML_CFG_NS40),
+ eEncoding( osl_getThreadTextEncoding() ),
+ bIsEncodingDefault(true)
+ {
+ aFontSizeArr[0] = HTMLFONTSZ1_DFLT;
+ aFontSizeArr[1] = HTMLFONTSZ2_DFLT;
+ aFontSizeArr[2] = HTMLFONTSZ3_DFLT;
+ aFontSizeArr[3] = HTMLFONTSZ4_DFLT;
+ aFontSizeArr[4] = HTMLFONTSZ5_DFLT;
+ aFontSizeArr[5] = HTMLFONTSZ6_DFLT;
+ aFontSizeArr[6] = HTMLFONTSZ7_DFLT;
+ }
+};
+
+const Sequence<OUString>& SvxHtmlOptions::GetPropertyNames()
+{
+ static Sequence<OUString> const aNames
+ {
+ "Import/UnknownTag", // 0
+ "Import/FontSetting", // 1
+ "Import/FontSize/Size_1", // 2
+ "Import/FontSize/Size_2", // 3
+ "Import/FontSize/Size_3", // 4
+ "Import/FontSize/Size_4", // 5
+ "Import/FontSize/Size_5", // 6
+ "Import/FontSize/Size_6", // 7
+ "Import/FontSize/Size_7", // 8
+ "Export/Browser", // 9
+ "Export/Basic", // 0
+ "Export/PrintLayout", // 11
+ "Export/LocalGraphic", // 12
+ "Export/Warning", // 13
+ "Export/Encoding", // 14
+ "Import/NumbersEnglishUS" // 15
+ };
+ return aNames;
+}
+
+SvxHtmlOptions::SvxHtmlOptions() :
+ ConfigItem("Office.Common/Filter/HTML"),
+ pImpl( new HtmlOptions_Impl )
+{
+ Load( GetPropertyNames() );
+}
+
+
+SvxHtmlOptions::~SvxHtmlOptions()
+{
+}
+
+void SvxHtmlOptions::Load( const 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;
+
+ pImpl->nFlags = HtmlCfgFlags::NONE;
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ if(pValues[nProp].hasValue())
+ {
+ switch(nProp)
+ {
+ case 0:
+ if(*o3tl::doAccess<bool>(pValues[nProp]))
+ pImpl->nFlags |= HtmlCfgFlags::UnknownTags;
+ break;//"Import/UnknownTag",
+ case 1:
+ if(*o3tl::doAccess<bool>(pValues[nProp]))
+ pImpl->nFlags |= HtmlCfgFlags::IgnoreFontFamily;
+ break;//"Import/FontSetting",
+ case 2: pValues[nProp] >>= pImpl->aFontSizeArr[0]; break;//"Import/FontSize/Size_1",
+ case 3: pValues[nProp] >>= pImpl->aFontSizeArr[1]; break;//"Import/FontSize/Size_2",
+ case 4: pValues[nProp] >>= pImpl->aFontSizeArr[2]; break;//"Import/FontSize/Size_3",
+ case 5: pValues[nProp] >>= pImpl->aFontSizeArr[3]; break;//"Import/FontSize/Size_4",
+ case 6: pValues[nProp] >>= pImpl->aFontSizeArr[4]; break;//"Import/FontSize/Size_5",
+ case 7: pValues[nProp] >>= pImpl->aFontSizeArr[5]; break;//"Import/FontSize/Size_6",
+ case 8: pValues[nProp] >>= pImpl->aFontSizeArr[6]; break;//"Import/FontSize/Size_7",
+ case 9://"Export/Browser",
+ {
+ sal_Int32 nExpMode = 0;
+ pValues[nProp] >>= nExpMode;
+ switch( nExpMode )
+ {
+ case 1: nExpMode = HTML_CFG_MSIE; break;
+ case 3: nExpMode = HTML_CFG_WRITER; break;
+ case 4: nExpMode = HTML_CFG_NS40; break;
+ default: nExpMode = HTML_CFG_NS40; break;
+ }
+
+ pImpl->nExportMode = nExpMode;
+ }
+ break;
+ case 10:
+ if(*o3tl::doAccess<bool>(pValues[nProp]))
+ pImpl->nFlags |= HtmlCfgFlags::StarBasic;
+ break;//"Export/Basic",
+ case 11:
+ if(*o3tl::doAccess<bool>(pValues[nProp]))
+ pImpl->nFlags |= HtmlCfgFlags::PrintLayoutExtension;
+ break;//"Export/PrintLayout",
+ case 12:
+ if(*o3tl::doAccess<bool>(pValues[nProp]))
+ pImpl->nFlags |= HtmlCfgFlags::LocalGrf;
+ break;//"Export/LocalGraphic",
+ case 13:
+ if(*o3tl::doAccess<bool>(pValues[nProp]))
+ pImpl->nFlags |= HtmlCfgFlags::IsBasicWarning;
+ break;//"Export/Warning"
+
+ case 14: pValues[nProp] >>= pImpl->eEncoding;
+ pImpl->bIsEncodingDefault = false;
+ break;//"Export/Encoding"
+
+ case 15:
+ if(*o3tl::doAccess<bool>(pValues[nProp]))
+ pImpl->nFlags |= HtmlCfgFlags::NumbersEnglishUS;
+ break;//"Import/NumbersEnglishUS"
+ }
+ }
+ }
+}
+
+
+void SvxHtmlOptions::ImplCommit()
+{
+ const Sequence<OUString>& aNames = GetPropertyNames();
+
+ Sequence<Any> aValues(aNames.getLength());
+ Any* pValues = aValues.getArray();
+
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ bool bSet = false;
+ switch(nProp)
+ {
+ case 0: bSet = bool(pImpl->nFlags & HtmlCfgFlags::UnknownTags);break;//"Import/UnknownTag",
+ case 1: bSet = bool(pImpl->nFlags & HtmlCfgFlags::IgnoreFontFamily);break;//"Import/FontSetting",
+ case 2: pValues[nProp] <<= pImpl->aFontSizeArr[0];break;//"Import/FontSize/Size_1",
+ case 3: pValues[nProp] <<= pImpl->aFontSizeArr[1];break;//"Import/FontSize/Size_2",
+ case 4: pValues[nProp] <<= pImpl->aFontSizeArr[2];break;//"Import/FontSize/Size_3",
+ case 5: pValues[nProp] <<= pImpl->aFontSizeArr[3];break;//"Import/FontSize/Size_4",
+ case 6: pValues[nProp] <<= pImpl->aFontSizeArr[4];break;//"Import/FontSize/Size_5",
+ case 7: pValues[nProp] <<= pImpl->aFontSizeArr[5];break;//"Import/FontSize/Size_6",
+ case 8: pValues[nProp] <<= pImpl->aFontSizeArr[6];break;//"Import/FontSize/Size_7",
+ case 9: //"Export/Browser",
+ {
+ sal_Int32 nExpMode = pImpl->nExportMode;
+
+ switch( nExpMode )
+ {
+ case HTML_CFG_MSIE: nExpMode = 1; break;
+ case HTML_CFG_WRITER: nExpMode = 3; break;
+ case HTML_CFG_NS40: nExpMode = 4; break;
+ default: nExpMode = 4; break; // NS40
+ }
+
+ pValues[nProp] <<= nExpMode;
+ break;
+ }
+ case 10: bSet = bool(pImpl->nFlags & HtmlCfgFlags::StarBasic);break;//"Export/Basic",
+ case 11: bSet = bool(pImpl->nFlags & HtmlCfgFlags::PrintLayoutExtension);break;//"Export/PrintLayout",
+ case 12: bSet = bool(pImpl->nFlags & HtmlCfgFlags::LocalGrf);break;//"Export/LocalGraphic",
+ case 13: bSet = bool(pImpl->nFlags & HtmlCfgFlags::IsBasicWarning);break;//"Export/Warning"
+ case 14:
+ if(!pImpl->bIsEncodingDefault)
+ pValues[nProp] <<= pImpl->eEncoding;
+ break;//"Export/Encoding",
+ case 15: bSet = bool(pImpl->nFlags & HtmlCfgFlags::NumbersEnglishUS);break;//"Import/NumbersEnglishUS"
+ }
+ if(nProp < 2 || ( nProp > 9 && nProp < 14 ) || nProp == 15)
+ pValues[nProp] <<= bSet;
+ }
+ PutProperties(aNames, aValues);
+}
+
+void SvxHtmlOptions::Notify( const css::uno::Sequence< OUString >& )
+{
+ Load( GetPropertyNames() );
+}
+
+
+sal_uInt16 SvxHtmlOptions::GetFontSize(sal_uInt16 nPos) const
+{
+ if(nPos < HTML_FONT_COUNT)
+ return static_cast<sal_uInt16>(pImpl->aFontSizeArr[nPos]);
+ return 0;
+}
+
+void SvxHtmlOptions::SetFontSize(sal_uInt16 nPos, sal_uInt16 nSize)
+{
+ if(nPos < HTML_FONT_COUNT)
+ {
+ pImpl->aFontSizeArr[nPos] = nSize;
+ SetModified();
+ }
+}
+
+
+bool SvxHtmlOptions::IsImportUnknown() const
+{
+ return bool(pImpl->nFlags & HtmlCfgFlags::UnknownTags) ;
+}
+
+
+void SvxHtmlOptions::SetImportUnknown(bool bSet)
+{
+ if(bSet)
+ pImpl->nFlags |= HtmlCfgFlags::UnknownTags;
+ else
+ pImpl->nFlags &= ~HtmlCfgFlags::UnknownTags;
+ SetModified();
+}
+
+
+sal_uInt16 SvxHtmlOptions::GetExportMode() const
+{
+ return static_cast<sal_uInt16>(pImpl->nExportMode);
+}
+
+
+bool SvxHtmlOptions::IsStarBasic() const
+{
+ return bool(pImpl->nFlags & HtmlCfgFlags::StarBasic) ;
+}
+
+
+void SvxHtmlOptions::SetStarBasic(bool bSet)
+{
+ if(bSet)
+ pImpl->nFlags |= HtmlCfgFlags::StarBasic;
+ else
+ pImpl->nFlags &= ~HtmlCfgFlags::StarBasic;
+ SetModified();
+}
+
+bool SvxHtmlOptions::IsSaveGraphicsLocal() const
+{
+ return bool(pImpl->nFlags & HtmlCfgFlags::LocalGrf) ;
+}
+
+void SvxHtmlOptions::SetSaveGraphicsLocal(bool bSet)
+{
+ if(bSet)
+ pImpl->nFlags |= HtmlCfgFlags::LocalGrf;
+ else
+ pImpl->nFlags &= ~HtmlCfgFlags::LocalGrf;
+ SetModified();
+}
+
+bool SvxHtmlOptions::IsPrintLayoutExtension() const
+{
+ bool bRet(pImpl->nFlags & HtmlCfgFlags::PrintLayoutExtension);
+ switch( pImpl->nExportMode )
+ {
+ case HTML_CFG_MSIE:
+ case HTML_CFG_NS40 :
+ case HTML_CFG_WRITER :
+ break;
+ default:
+ bRet = false;
+ }
+ return bRet;
+}
+
+void SvxHtmlOptions::SetPrintLayoutExtension(bool bSet)
+{
+ if(bSet)
+ pImpl->nFlags |= HtmlCfgFlags::PrintLayoutExtension;
+ else
+ pImpl->nFlags &= ~HtmlCfgFlags::PrintLayoutExtension;
+ SetModified();
+}
+
+bool SvxHtmlOptions::IsIgnoreFontFamily() const
+{
+ return bool(pImpl->nFlags & HtmlCfgFlags::IgnoreFontFamily) ;
+}
+
+void SvxHtmlOptions::SetIgnoreFontFamily(bool bSet)
+{
+ if(bSet)
+ pImpl->nFlags |= HtmlCfgFlags::IgnoreFontFamily;
+ else
+ pImpl->nFlags &= ~HtmlCfgFlags::IgnoreFontFamily;
+ SetModified();
+}
+
+bool SvxHtmlOptions::IsStarBasicWarning() const
+{
+ return bool(pImpl->nFlags & HtmlCfgFlags::IsBasicWarning) ;
+}
+
+void SvxHtmlOptions::SetStarBasicWarning(bool bSet)
+{
+ if(bSet)
+ pImpl->nFlags |= HtmlCfgFlags::IsBasicWarning;
+ else
+ pImpl->nFlags &= ~HtmlCfgFlags::IsBasicWarning;
+ SetModified();
+}
+
+rtl_TextEncoding SvxHtmlOptions::GetTextEncoding() const
+{
+ rtl_TextEncoding eRet;
+ if(pImpl->bIsEncodingDefault)
+ eRet = SvtSysLocale::GetBestMimeEncoding();
+ else
+ eRet = static_cast<rtl_TextEncoding>(pImpl->eEncoding);
+ return eRet;
+}
+
+void SvxHtmlOptions::SetTextEncoding( rtl_TextEncoding eEnc )
+{
+ pImpl->eEncoding = eEnc;
+ pImpl->bIsEncodingDefault = false;
+ SetModified();
+}
+
+bool SvxHtmlOptions::IsDefaultTextEncoding() const
+{
+ return pImpl->bIsEncodingDefault;
+}
+
+namespace
+{
+ class theSvxHtmlOptions : public rtl::Static<SvxHtmlOptions, theSvxHtmlOptions> {};
+}
+
+SvxHtmlOptions& SvxHtmlOptions::Get()
+{
+ return theSvxHtmlOptions::get();
+}
+
+bool SvxHtmlOptions::IsNumbersEnglishUS() const
+{
+ return bool(pImpl->nFlags & HtmlCfgFlags::NumbersEnglishUS) ;
+}
+
+void SvxHtmlOptions::SetNumbersEnglishUS(bool bSet)
+{
+ if(bSet)
+ pImpl->nFlags |= HtmlCfgFlags::NumbersEnglishUS;
+ else
+ pImpl->nFlags &= ~HtmlCfgFlags::NumbersEnglishUS;
+ SetModified();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/config/itemholder2.cxx b/svtools/source/config/itemholder2.cxx
new file mode 100644
index 000000000..692f182a0
--- /dev/null
+++ b/svtools/source/config/itemholder2.cxx
@@ -0,0 +1,159 @@
+/* -*- 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 "itemholder2.hxx"
+
+#include <osl/diagnose.h>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/configuration/theDefaultProvider.hpp>
+
+#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>
+#include <tools/diagnose_ex.h>
+
+namespace svtools {
+
+ItemHolder2::ItemHolder2()
+ : ItemHolderMutexBase()
+{
+ try
+ {
+ css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
+ css::uno::Reference< css::lang::XComponent > xCfg(
+ css::configuration::theDefaultProvider::get( xContext ),
+ css::uno::UNO_QUERY_THROW );
+ xCfg->addEventListener(static_cast< css::lang::XEventListener* >(this));
+ }
+ catch(const css::uno::RuntimeException&)
+ {
+ throw;
+ }
+#ifdef DBG_UTIL
+ catch(const css::uno::Exception&)
+ {
+ static bool bMessage = true;
+ if(bMessage)
+ {
+ bMessage = false;
+ TOOLS_WARN_EXCEPTION( "svtools", "CreateInstance with arguments" );
+ }
+ }
+#else
+ catch(css::uno::Exception&){}
+#endif
+}
+
+
+ItemHolder2::~ItemHolder2()
+{
+ impl_releaseAllItems();
+}
+
+
+void ItemHolder2::holdConfigItem(EItem eItem)
+{
+ static ItemHolder2* pHolder = new ItemHolder2();
+ pHolder->impl_addItem(eItem);
+}
+
+
+void SAL_CALL ItemHolder2::disposing(const css::lang::EventObject&)
+{
+ impl_releaseAllItems();
+}
+
+
+void ItemHolder2::impl_addItem(EItem eItem)
+{
+ osl::MutexGuard aLock(m_aLock);
+
+ for ( auto const & rInfo : m_lItems )
+ {
+ if (rInfo.eItem == eItem)
+ return;
+ }
+
+ TItemInfo aNewItem;
+ aNewItem.eItem = eItem;
+ impl_newItem(aNewItem);
+ if (aNewItem.pItem)
+ m_lItems.emplace_back(std::move(aNewItem));
+}
+
+
+void ItemHolder2::impl_releaseAllItems()
+{
+ std::vector<TItemInfo> items;
+ {
+ osl::MutexGuard aLock(m_aLock);
+ items.swap(m_lItems);
+ }
+
+ // items will be freed when the block exits
+}
+
+
+void ItemHolder2::impl_newItem(TItemInfo& rItem)
+{
+ switch(rItem.eItem)
+ {
+ case EItem::AccessibilityOptions :
+ rItem.pItem.reset( new SvtAccessibilityOptions() );
+ break;
+
+ case EItem::ColorConfig :
+ 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;
+
+ case EItem::PrintOptions :
+ rItem.pItem.reset( new SvtPrinterOptions() );
+ break;
+
+ case EItem::PrintFileOptions :
+ rItem.pItem.reset( new SvtPrintFileOptions() );
+ break;
+
+ case EItem::MiscOptions :
+ rItem.pItem.reset( new SvtMiscOptions() );
+ break;
+
+ default:
+ OSL_ASSERT(false);
+ break;
+ }
+}
+
+} // namespace svtools
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/config/itemholder2.hxx b/svtools/source/config/itemholder2.hxx
new file mode 100644
index 000000000..c4fd540cf
--- /dev/null
+++ b/svtools/source/config/itemholder2.hxx
@@ -0,0 +1,64 @@
+/* -*- 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/itemholderbase.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <com/sun/star/lang/XEventListener.hpp>
+
+namespace svtools {
+
+
+class ItemHolder2 : private ItemHolderMutexBase
+ , public ::cppu::WeakImplHelper< css::lang::XEventListener >
+{
+
+ // member
+ private:
+
+ std::vector<TItemInfo> m_lItems;
+
+
+ // c++ interface
+ public:
+
+ ItemHolder2();
+ virtual ~ItemHolder2() override;
+ static void holdConfigItem(EItem eItem);
+
+
+ // uno interface
+ public:
+
+ virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) override;
+
+
+ // helper
+ private:
+
+ void impl_addItem(EItem eItem);
+ void impl_releaseAllItems();
+ static void impl_newItem(TItemInfo& rItem);
+};
+
+} // namespace svtools
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/config/menuoptions.cxx b/svtools/source/config/menuoptions.cxx
new file mode 100644
index 000000000..a86bdc6e3
--- /dev/null
+++ b/svtools/source/config/menuoptions.cxx
@@ -0,0 +1,413 @@
+/* -*- 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 <svtools/menuoptions.hxx>
+#include <unotools/configitem.hxx>
+#include <tools/debug.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/settings.hxx>
+
+#include "itemholder2.hxx"
+
+// namespaces
+
+using namespace ::utl ;
+using namespace ::osl ;
+using namespace ::com::sun::star::uno ;
+
+#define ROOTNODE_MENU "Office.Common/View/Menu"
+#define DEFAULT_DONTHIDEDISABLEDENTRIES false
+#define DEFAULT_FOLLOWMOUSE true
+#define DEFAULT_MENUICONS TRISTATE_INDET
+#define DEFAULT_CONTEXTMENUSHORTCUTS TRISTATE_INDET
+
+#define PROPERTYNAME_DONTHIDEDISABLEDENTRIES "DontHideDisabledEntry"
+#define PROPERTYNAME_FOLLOWMOUSE "FollowMouse"
+#define PROPERTYNAME_SHOWICONSINMENUES "ShowIconsInMenues"
+#define PROPERTYNAME_SYSTEMICONSINMENUES "IsSystemIconsInMenus"
+#define PROPERTYNAME_SHORTCUTSINCONTEXMENU "ShortcutsInContextMenus"
+
+#define PROPERTYHANDLE_DONTHIDEDISABLEDENTRIES 0
+#define PROPERTYHANDLE_FOLLOWMOUSE 1
+#define PROPERTYHANDLE_SHOWICONSINMENUES 2
+#define PROPERTYHANDLE_SYSTEMICONSINMENUES 3
+#define PROPERTYHANDLE_SHORTCUTSINCONTEXMENU 4
+
+// private declarations!
+
+class SvtMenuOptions_Impl : public ConfigItem
+{
+
+ // private member
+
+ private:
+ bool m_bDontHideDisabledEntries ; /// cache "DontHideDisabledEntries" of Menu section
+ bool m_bFollowMouse ; /// cache "FollowMouse" of Menu section
+ TriState m_eMenuIcons ; /// cache "MenuIcons" of Menu section
+ TriState m_eContextMenuShortcuts ; /// cache "ShortcutsInContextMenus" of Menu section
+
+ // public methods
+
+ public:
+
+ // constructor / destructor
+
+ SvtMenuOptions_Impl();
+ virtual ~SvtMenuOptions_Impl() override;
+
+ // override methods of baseclass
+
+ /*-****************************************************************************************************
+ @short called for notify of configmanager
+ @descr This method is called from the ConfigManager before application ends or from the
+ PropertyChangeListener if the sub tree broadcasts changes. You must update your
+ internal values.
+
+ @seealso baseclass ConfigItem
+
+ @param "seqPropertyNames" is the list of properties which should be updated.
+ *//*-*****************************************************************************************************/
+
+ virtual void Notify( const Sequence< OUString >& seqPropertyNames ) override;
+
+ // public interface
+
+ /*-****************************************************************************************************
+ @short access method to get internal values
+ @descr These methods give us a chance to regulate access to our internal values.
+ It's not used at the moment - but it's possible for the future!
+ *//*-*****************************************************************************************************/
+
+ bool IsEntryHidingEnabled() const
+ { return m_bDontHideDisabledEntries; }
+
+ TriState GetMenuIconsState() const
+ { return m_eMenuIcons; }
+
+ void SetMenuIconsState(TriState eState)
+ {
+ m_eMenuIcons = eState;
+ SetModified();
+ // tdf#93451: don't Commit() here, it's too early
+ }
+
+ TriState GetContextMenuShortcuts() const
+ { return m_eContextMenuShortcuts; }
+
+ void SetContextMenuShortcuts(TriState eState)
+ {
+ m_eContextMenuShortcuts = eState;
+ SetModified();
+ Commit();
+ }
+
+ // private methods
+
+ private:
+
+ virtual void ImplCommit() override;
+
+ /*-****************************************************************************************************
+ @short return list of fix key names of our configuration management which represent our module tree
+ @descr This method returns a static const list of key names. We need it to get needed values from our
+ configuration management.
+ @return A list of needed configuration keys is returned.
+ *//*-*****************************************************************************************************/
+
+ static Sequence< OUString > const & impl_GetPropertyNames();
+};
+
+// constructor
+
+SvtMenuOptions_Impl::SvtMenuOptions_Impl()
+ // Init baseclasses first
+ : ConfigItem ( ROOTNODE_MENU )
+ // Init member then.
+ , m_bDontHideDisabledEntries ( DEFAULT_DONTHIDEDISABLEDENTRIES )
+ , m_bFollowMouse ( DEFAULT_FOLLOWMOUSE )
+ , m_eMenuIcons ( DEFAULT_MENUICONS )
+ , m_eContextMenuShortcuts ( DEFAULT_CONTEXTMENUSHORTCUTS )
+{
+ // Use our static list of configuration keys to get his values.
+ Sequence< OUString > seqNames = impl_GetPropertyNames();
+ Sequence< Any > seqValues = GetProperties( seqNames ) ;
+
+ // Safe impossible cases.
+ // We need values from ALL configuration keys.
+ // Follow assignment use order of values in relation to our list of key names!
+ DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nI miss some values of configuration keys!\n" );
+
+ bool bMenuIcons = true;
+ bool bSystemMenuIcons = true;
+ if (m_eMenuIcons == TRISTATE_INDET)
+ bMenuIcons = Application::GetSettings().GetStyleSettings().GetPreferredUseImagesInMenus();
+ else
+ {
+ bSystemMenuIcons = false;
+ bMenuIcons = m_eMenuIcons != TRISTATE_FALSE;
+ }
+
+ // Copy values from list in right order to our internal member.
+ sal_Int32 nPropertyCount = seqValues.getLength() ;
+ sal_Int32 nProperty = 0 ;
+ for( nProperty=0; nProperty<nPropertyCount; ++nProperty )
+ {
+ // Safe impossible cases.
+ // Check any for valid value.
+ DBG_ASSERT( seqValues[nProperty].hasValue(), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nInvalid property value for property detected!\n" );
+
+ if (!seqValues[nProperty].hasValue())
+ continue;
+
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_DONTHIDEDISABLEDENTRIES : {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\DontHideDisabledEntry\"?" );
+ seqValues[nProperty] >>= m_bDontHideDisabledEntries;
+ }
+ break;
+
+ case PROPERTYHANDLE_FOLLOWMOUSE : {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\FollowMouse\"?" );
+ seqValues[nProperty] >>= m_bFollowMouse;
+ }
+ break;
+ case PROPERTYHANDLE_SHOWICONSINMENUES : {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\ShowIconsInMenues\"?" );
+ seqValues[nProperty] >>= bMenuIcons;
+ }
+ break;
+ case PROPERTYHANDLE_SYSTEMICONSINMENUES : {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\IsSystemIconsInMenus\"?" );
+ seqValues[nProperty] >>= bSystemMenuIcons;
+ }
+ break;
+ case PROPERTYHANDLE_SHORTCUTSINCONTEXMENU : {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_SHORT), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\ShortcutsInContextMenus\"?" );
+ sal_Int16 nContextMenuShortcuts;
+ if ( seqValues[nProperty] >>= nContextMenuShortcuts )
+ m_eContextMenuShortcuts = static_cast<TriState>(nContextMenuShortcuts);
+ }
+ break;
+ }
+ }
+
+ m_eMenuIcons = bSystemMenuIcons ? TRISTATE_INDET : static_cast<TriState>(bMenuIcons);
+
+ EnableNotification( seqNames );
+}
+
+// destructor
+
+SvtMenuOptions_Impl::~SvtMenuOptions_Impl()
+{
+ assert(!IsModified()); // should have been committed
+}
+
+// public method
+
+void SvtMenuOptions_Impl::Notify( const Sequence< OUString >& seqPropertyNames )
+{
+ // Use given list of updated properties to get his values from configuration directly!
+ Sequence< Any > seqValues = GetProperties( seqPropertyNames );
+ // Safe impossible cases.
+ // We need values from ALL notified configuration keys.
+ DBG_ASSERT( !(seqPropertyNames.getLength()!=seqValues.getLength()), "SvtMenuOptions_Impl::Notify()\nI miss some values of configuration keys!\n" );
+
+ bool bMenuSettingsChanged = false;
+ bool bMenuIcons = true;
+ bool bSystemMenuIcons = true;
+ if (m_eMenuIcons == TRISTATE_INDET)
+ bMenuIcons = Application::GetSettings().GetStyleSettings().GetUseImagesInMenus();
+ else
+ {
+ bSystemMenuIcons = false;
+ bMenuIcons = m_eMenuIcons != TRISTATE_FALSE;
+ }
+
+ // Step over list of property names and get right value from coreesponding value list to set it on internal members!
+ sal_Int32 nCount = seqPropertyNames.getLength();
+ for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
+ {
+ if( seqPropertyNames[nProperty] == PROPERTYNAME_DONTHIDEDISABLEDENTRIES )
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\View\\Menu\\DontHideDisabledEntry\"?" );
+ seqValues[nProperty] >>= m_bDontHideDisabledEntries;
+ }
+ else if( seqPropertyNames[nProperty] == PROPERTYNAME_FOLLOWMOUSE )
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\View\\Menu\\FollowMouse\"?" );
+ seqValues[nProperty] >>= m_bFollowMouse;
+ }
+ else if( seqPropertyNames[nProperty] == PROPERTYNAME_SHOWICONSINMENUES )
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\ShowIconsInMenues\"?" );
+ bMenuSettingsChanged |= seqValues[nProperty] >>= bMenuIcons;
+ }
+ else if( seqPropertyNames[nProperty] == PROPERTYNAME_SYSTEMICONSINMENUES )
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\IsSystemIconsInMenus\"?" );
+ bMenuSettingsChanged |= seqValues[nProperty] >>= bSystemMenuIcons;
+ }
+ else if( seqPropertyNames[nProperty] == PROPERTYNAME_SHORTCUTSINCONTEXMENU )
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_SHORT), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\ShortcutsInContextMenus\"?" );
+ sal_Int16 nContextMenuShortcuts;
+ if ( seqValues[nProperty] >>= nContextMenuShortcuts )
+ m_eContextMenuShortcuts = static_cast<TriState>(nContextMenuShortcuts);
+ }
+ else assert( false && "SvtMenuOptions_Impl::Notify()\nUnknown property detected ... I can't handle these!" );
+ }
+
+ if ( bMenuSettingsChanged )
+ m_eMenuIcons = bSystemMenuIcons ? TRISTATE_INDET : static_cast<TriState>(bMenuIcons);
+}
+
+// public method
+
+void SvtMenuOptions_Impl::ImplCommit()
+{
+ // Get names of supported properties, create a list for values and copy current values to it.
+ Sequence< OUString > seqNames = impl_GetPropertyNames();
+ sal_Int32 nCount = seqNames.getLength();
+ Sequence< Any > seqValues ( nCount );
+ for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
+ {
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_DONTHIDEDISABLEDENTRIES : {
+ seqValues[nProperty] <<= m_bDontHideDisabledEntries;
+ }
+ break;
+
+ case PROPERTYHANDLE_FOLLOWMOUSE : {
+ seqValues[nProperty] <<= m_bFollowMouse;
+ }
+ break;
+ //Output cache of current setting as possibly modified by System Theme for older version
+ case PROPERTYHANDLE_SHOWICONSINMENUES : {
+ bool bValue = Application::GetSettings().GetStyleSettings().GetUseImagesInMenus();
+ seqValues[nProperty] <<= bValue;
+ }
+ break;
+ case PROPERTYHANDLE_SYSTEMICONSINMENUES : {
+ bool bValue = m_eMenuIcons == TRISTATE_INDET;
+ seqValues[nProperty] <<= bValue;
+ }
+ break;
+ case PROPERTYHANDLE_SHORTCUTSINCONTEXMENU : {
+ seqValues[nProperty] <<= static_cast<sal_Int16>(m_eContextMenuShortcuts);
+ }
+ break;
+ }
+ }
+ // Set properties in configuration.
+ PutProperties( seqNames, seqValues );
+}
+
+// private method
+
+Sequence< OUString > const & SvtMenuOptions_Impl::impl_GetPropertyNames()
+{
+ static const Sequence<OUString> seqPropertyNames {
+ OUString(PROPERTYNAME_DONTHIDEDISABLEDENTRIES) ,
+ OUString(PROPERTYNAME_FOLLOWMOUSE) ,
+ OUString(PROPERTYNAME_SHOWICONSINMENUES) ,
+ OUString(PROPERTYNAME_SYSTEMICONSINMENUES) ,
+ OUString(PROPERTYNAME_SHORTCUTSINCONTEXMENU)
+ };
+ return seqPropertyNames;
+}
+
+namespace {
+
+std::weak_ptr<SvtMenuOptions_Impl> g_pMenuOptions;
+
+}
+
+SvtMenuOptions::SvtMenuOptions()
+{
+ // Global access, must be guarded (multithreading!).
+ MutexGuard aGuard( GetOwnStaticMutex() );
+
+ m_pImpl = g_pMenuOptions.lock();
+ if( !m_pImpl )
+ {
+ m_pImpl = std::make_shared<SvtMenuOptions_Impl>();
+ g_pMenuOptions = m_pImpl;
+ svtools::ItemHolder2::holdConfigItem(EItem::MenuOptions);
+ }
+}
+
+SvtMenuOptions::~SvtMenuOptions()
+{
+ // Global access, must be guarded (multithreading!)
+ MutexGuard aGuard( GetOwnStaticMutex() );
+
+ m_pImpl.reset();
+}
+
+// public method
+
+bool SvtMenuOptions::IsEntryHidingEnabled() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->IsEntryHidingEnabled();
+}
+
+// public method
+
+TriState SvtMenuOptions::GetMenuIconsState() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->GetMenuIconsState();
+}
+
+// public method
+
+void SvtMenuOptions::SetMenuIconsState(TriState eState)
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ m_pImpl->SetMenuIconsState(eState);
+}
+
+TriState SvtMenuOptions::GetContextMenuShortcuts() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->GetContextMenuShortcuts();
+}
+
+void SvtMenuOptions::SetContextMenuShortcuts(TriState eState)
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ m_pImpl->SetContextMenuShortcuts(eState);
+}
+
+// private method
+
+Mutex& SvtMenuOptions::GetOwnStaticMutex()
+{
+ static Mutex ourMutex;
+
+ return ourMutex;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/config/miscopt.cxx b/svtools/source/config/miscopt.cxx
new file mode 100644
index 000000000..7e39fa901
--- /dev/null
+++ b/svtools/source/config/miscopt.cxx
@@ -0,0 +1,918 @@
+/* -*- 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 <svtools/miscopt.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 <tools/link.hxx>
+#include <osl/diagnose.h>
+
+#include <rtl/instance.hxx>
+#include "itemholder2.hxx"
+
+#include <svtools/imgdef.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/settings.hxx>
+#include <vcl/toolbox.hxx>
+
+#include <vector>
+
+using namespace ::utl ;
+using namespace ::osl ;
+using namespace ::com::sun::star::uno ;
+using namespace ::com::sun::star;
+
+#define ROOTNODE_MISC "Office.Common/Misc"
+
+// PROPERTYHANDLE defines must be sequential from zero for Commit/Load
+#define PROPERTYNAME_PLUGINSENABLED "PluginsEnabled"
+#define PROPERTYHANDLE_PLUGINSENABLED 0
+#define PROPERTYNAME_SYMBOLSET "SymbolSet"
+#define PROPERTYHANDLE_SYMBOLSET 1
+#define PROPERTYNAME_TOOLBOXSTYLE "ToolboxStyle"
+#define PROPERTYHANDLE_TOOLBOXSTYLE 2
+#define PROPERTYNAME_USESYSTEMFILEDIALOG "UseSystemFileDialog"
+#define PROPERTYHANDLE_USESYSTEMFILEDIALOG 3
+#define PROPERTYNAME_ICONTHEME "SymbolStyle"
+#define PROPERTYHANDLE_SYMBOLSTYLE 4
+#define PROPERTYNAME_USESYSTEMPRINTDIALOG "UseSystemPrintDialog"
+#define PROPERTYHANDLE_USESYSTEMPRINTDIALOG 5
+#define PROPERTYNAME_SHOWLINKWARNINGDIALOG "ShowLinkWarningDialog"
+#define PROPERTYHANDLE_SHOWLINKWARNINGDIALOG 6
+#define PROPERTYNAME_DISABLEUICUSTOMIZATION "DisableUICustomization"
+#define PROPERTYHANDLE_DISABLEUICUSTOMIZATION 7
+#define PROPERTYNAME_EXPERIMENTALMODE "ExperimentalMode"
+#define PROPERTYHANDLE_EXPERIMENTALMODE 8
+#define PROPERTYNAME_MACRORECORDERMODE "MacroRecorderMode"
+#define PROPERTYHANDLE_MACRORECORDERMODE 9
+#define PROPERTYNAME_SIDEBARICONSIZE "SidebarIconSize"
+#define PROPERTYHANDLE_SIDEBARICONSIZE 10
+#define PROPERTYNAME_NOTEBOOKBARICONSIZE "NotebookbarIconSize"
+#define PROPERTYHANDLE_NOTEBOOKBARICONSIZE 11
+
+#define VCL_TOOLBOX_STYLE_FLAT (sal_uInt16(0x0004)) // from <vcl/toolbox.hxx>
+
+class SvtMiscOptions_Impl : public ConfigItem
+{
+private:
+ ::std::vector<Link<LinkParamNone*,void>> aList;
+ bool m_bUseSystemFileDialog;
+ bool m_bIsUseSystemFileDialogRO;
+ bool m_bPluginsEnabled;
+ bool m_bIsPluginsEnabledRO;
+ sal_Int16 m_nSymbolsSize;
+ bool m_bIsSymbolsSizeRO;
+ ToolBoxButtonSize m_nSidebarIconSize;
+ bool m_bIsSidebarIconSizeRO;
+ ToolBoxButtonSize m_nNotebookbarIconSize;
+ bool m_bIsNotebookbarIconSizeRO;
+ bool m_bIsSymbolsStyleRO;
+ sal_Int16 m_nToolboxStyle;
+ bool m_bIsToolboxStyleRO;
+ bool m_bUseSystemPrintDialog;
+ bool m_bIsUseSystemPrintDialogRO;
+ bool m_bShowLinkWarningDialog;
+ bool m_bIsShowLinkWarningDialogRO;
+ bool m_bDisableUICustomization;
+ bool m_bExperimentalMode;
+ bool m_bMacroRecorderMode;
+ bool m_bIconThemeWasSetAutomatically;
+
+ virtual void ImplCommit() override;
+
+public:
+
+ SvtMiscOptions_Impl();
+ virtual ~SvtMiscOptions_Impl() override;
+
+ /*-****************************************************************************************************
+ @short called for notify of configmanager
+ @descr This method is called from the ConfigManager before the application ends or from the
+ PropertyChangeListener if the sub tree broadcasts changes. You must update your
+ internal values.
+
+ @seealso baseclass ConfigItem
+
+ @param "seqPropertyNames" is the list of properties which should be updated.
+ *//*-*****************************************************************************************************/
+
+ virtual void Notify( const Sequence< OUString >& seqPropertyNames ) override;
+
+ /** loads required data from the configuration. It's called in the constructor to
+ read all entries and form ::Notify to re-read changed settings
+
+ */
+ void Load( const Sequence< OUString >& rPropertyNames );
+
+ // public interface
+
+
+ bool UseSystemFileDialog() const
+ { return m_bUseSystemFileDialog; }
+
+ void SetUseSystemFileDialog( bool bSet )
+ { m_bUseSystemFileDialog = bSet; SetModified(); }
+
+ bool IsUseSystemFileDialogReadOnly() const
+ { return m_bIsUseSystemFileDialogRO; }
+
+ bool DisableUICustomization() const
+ { return m_bDisableUICustomization; }
+
+ void SetExperimentalMode( bool bSet )
+ { m_bExperimentalMode = bSet; SetModified(); }
+
+ bool IsExperimentalMode() const
+ { return m_bExperimentalMode; }
+
+ void SetMacroRecorderMode( bool bSet )
+ { m_bMacroRecorderMode = bSet; SetModified(); }
+
+ bool IsMacroRecorderMode() const
+ { return m_bMacroRecorderMode; }
+
+ bool IsPluginsEnabled() const
+ { return m_bPluginsEnabled; }
+
+ sal_Int16 GetSymbolsSize() const
+ { return m_nSymbolsSize; }
+
+ ToolBoxButtonSize GetSidebarIconSize() const
+ { return m_nSidebarIconSize; }
+
+ ToolBoxButtonSize GetNotebookbarIconSize() const
+ { return m_nNotebookbarIconSize; }
+
+ void SetSymbolsSize( sal_Int16 nSet );
+
+ void SetSidebarIconSize( ToolBoxButtonSize nSet );
+
+ void SetNotebookbarIconSize( ToolBoxButtonSize nSet );
+
+ static OUString GetIconTheme();
+
+ enum class SetModifiedFlag { SET, DONT_SET };
+
+ /** Set the icon theme
+ *
+ * @param theme
+ * The name of the icon theme to use.
+ *
+ * @param setModified
+ * Whether to call SetModified() and CallListeners().
+ *
+ * @internal
+ * The @p setModified flag was introduced because the unittests fail if we call SetModified()
+ * during initialization in the constructor.
+ */
+ void
+ SetIconTheme(const OUString &theme, SetModifiedFlag setModified );
+
+ bool IconThemeWasSetAutomatically()
+ {return m_bIconThemeWasSetAutomatically;}
+
+ // translate to VCL settings ( "0" = 3D, "1" = FLAT )
+ sal_Int16 GetToolboxStyle() const
+ { return m_nToolboxStyle ? VCL_TOOLBOX_STYLE_FLAT : 0; }
+
+ // translate from VCL settings
+ void SetToolboxStyle( sal_Int16 nStyle );
+
+ bool UseSystemPrintDialog() const
+ { return m_bUseSystemPrintDialog; }
+
+ void SetUseSystemPrintDialog( bool bSet )
+ { m_bUseSystemPrintDialog = bSet; SetModified(); }
+
+ bool ShowLinkWarningDialog() const
+ { return m_bShowLinkWarningDialog; }
+
+ void SetShowLinkWarningDialog( bool bSet )
+ { m_bShowLinkWarningDialog = bSet; SetModified(); }
+
+ bool IsShowLinkWarningDialogReadOnly() const
+ { return m_bIsShowLinkWarningDialogRO; }
+
+ void AddListenerLink( const Link<LinkParamNone*,void>& rLink );
+ void RemoveListenerLink( const Link<LinkParamNone*,void>& rLink );
+ void CallListeners();
+
+
+ // private methods
+
+
+private:
+
+ /*-****************************************************************************************************
+ @short return list of key names of our configuration management which represent our module tree
+ @descr These methods return a static const list of key names. We need it to get needed values from our
+ configuration management.
+ @return A list of needed configuration keys is returned.
+ *//*-*****************************************************************************************************/
+
+ static Sequence< OUString > GetPropertyNames();
+};
+
+
+// constructor
+
+SvtMiscOptions_Impl::SvtMiscOptions_Impl()
+ // Init baseclasses first
+ : ConfigItem( ROOTNODE_MISC )
+
+ , m_bUseSystemFileDialog( false )
+ , m_bIsUseSystemFileDialogRO( false )
+ , m_bPluginsEnabled( false )
+ , m_bIsPluginsEnabledRO( false )
+ , m_nSymbolsSize( 0 )
+ , m_bIsSymbolsSizeRO( false )
+ , m_nSidebarIconSize( ToolBoxButtonSize::DontCare )
+ , m_bIsSidebarIconSizeRO( false )
+ , m_nNotebookbarIconSize( ToolBoxButtonSize::DontCare )
+ , m_bIsNotebookbarIconSizeRO( false )
+ , m_bIsSymbolsStyleRO( false )
+ , m_nToolboxStyle( 1 )
+ , m_bIsToolboxStyleRO( false )
+ , m_bUseSystemPrintDialog( false )
+ , m_bIsUseSystemPrintDialogRO( false )
+ , m_bShowLinkWarningDialog( true )
+ , m_bIsShowLinkWarningDialogRO( false )
+ , m_bExperimentalMode( false )
+ , m_bMacroRecorderMode( false )
+ , m_bIconThemeWasSetAutomatically( false )
+{
+ // Use our static list of configuration keys to get his values.
+ Sequence< OUString > seqNames = GetPropertyNames ( );
+ Load( seqNames );
+ Sequence< Any > seqValues = GetProperties ( seqNames );
+ Sequence< sal_Bool > seqRO = GetReadOnlyStates ( seqNames );
+
+ // Safe impossible cases.
+ // We need values from ALL configuration keys.
+ // Follow assignment use order of values in relation to our list of key names!
+ DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtMiscOptions_Impl::SvtMiscOptions_Impl()\nI miss some values of configuration keys!\n" );
+
+ // Copy values from list in right order to our internal member.
+ sal_Int32 nPropertyCount = seqValues.getLength();
+ for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
+ {
+ if (!seqValues[nProperty].hasValue())
+ continue;
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_PLUGINSENABLED :
+ {
+ if( !(seqValues[nProperty] >>= m_bPluginsEnabled) )
+ {
+ OSL_FAIL("Wrong type of \"Misc\\PluginsEnabled\"!" );
+ }
+ m_bIsPluginsEnabledRO = seqRO[nProperty];
+ break;
+ }
+
+ case PROPERTYHANDLE_SYMBOLSET :
+ {
+ if( !(seqValues[nProperty] >>= m_nSymbolsSize) )
+ {
+ OSL_FAIL("Wrong type of \"Misc\\SymbolSet\"!" );
+ }
+ m_bIsSymbolsSizeRO = seqRO[nProperty];
+ break;
+ }
+
+ case PROPERTYHANDLE_SIDEBARICONSIZE :
+ {
+ sal_uInt16 nTmp;
+ if( !(seqValues[nProperty] >>= nTmp) )
+ {
+ OSL_FAIL("Wrong type of \"Misc\\SidebarIconSize\"!" );
+ } else
+ m_nSidebarIconSize = static_cast<ToolBoxButtonSize>(nTmp);
+ m_bIsSidebarIconSizeRO = seqRO[nProperty];
+ break;
+ }
+
+ case PROPERTYHANDLE_NOTEBOOKBARICONSIZE :
+ {
+ sal_uInt16 nTmp;
+ if( !(seqValues[nProperty] >>= nTmp) )
+ {
+ OSL_FAIL("Wrong type of \"Misc\\NotebookbarIconSize\"!" );
+ } else
+ m_nNotebookbarIconSize = static_cast<ToolBoxButtonSize>(nTmp);
+ m_bIsNotebookbarIconSizeRO = seqRO[nProperty];
+ break;
+ }
+
+ case PROPERTYHANDLE_TOOLBOXSTYLE :
+ {
+ if( !(seqValues[nProperty] >>= m_nToolboxStyle) )
+ {
+ OSL_FAIL("Wrong type of \"Misc\\ToolboxStyle\"!" );
+ }
+ m_bIsToolboxStyleRO = seqRO[nProperty];
+ break;
+ }
+
+ case PROPERTYHANDLE_USESYSTEMFILEDIALOG :
+ {
+ if( !(seqValues[nProperty] >>= m_bUseSystemFileDialog) )
+ {
+ OSL_FAIL("Wrong type of \"Misc\\UseSystemFileDialog\"!" );
+ }
+ m_bIsUseSystemFileDialogRO = seqRO[nProperty];
+ break;
+ }
+
+ case PROPERTYHANDLE_USESYSTEMPRINTDIALOG :
+ {
+ if( !(seqValues[nProperty] >>= m_bUseSystemPrintDialog) )
+ {
+ OSL_FAIL("Wrong type of \"Misc\\UseSystemPrintDialog\"!" );
+ }
+ m_bIsUseSystemPrintDialogRO = seqRO[nProperty];
+ break;
+ }
+
+ case PROPERTYHANDLE_SHOWLINKWARNINGDIALOG :
+ {
+ if( !(seqValues[nProperty] >>= m_bShowLinkWarningDialog) )
+ {
+ OSL_FAIL("Wrong type of \"Misc\\ShowLinkWarningDialog\"!" );
+ }
+ m_bIsShowLinkWarningDialogRO = seqRO[nProperty];
+ break;
+ }
+
+ case PROPERTYHANDLE_SYMBOLSTYLE :
+ {
+ OUString aIconTheme;
+ if (seqValues[nProperty] >>= aIconTheme)
+ SetIconTheme(aIconTheme, SetModifiedFlag::DONT_SET);
+ else
+ OSL_FAIL("Wrong type of \"Misc\\SymbolStyle\"!" );
+
+ m_bIsSymbolsStyleRO = seqRO[nProperty];
+ break;
+ }
+
+ case PROPERTYHANDLE_DISABLEUICUSTOMIZATION :
+ {
+ if( !(seqValues[nProperty] >>= m_bDisableUICustomization) )
+ OSL_FAIL("Wrong type of \"Misc\\DisableUICustomization\"!" );
+ break;
+ }
+ case PROPERTYHANDLE_EXPERIMENTALMODE :
+ {
+ if( !(seqValues[nProperty] >>= m_bExperimentalMode) )
+ OSL_FAIL("Wrong type of \"Misc\\ExperimentalMode\"!" );
+ break;
+ }
+ case PROPERTYHANDLE_MACRORECORDERMODE :
+ {
+ if( !(seqValues[nProperty] >>= m_bMacroRecorderMode) )
+ OSL_FAIL("Wrong type of \"Misc\\MacroRecorderMode\"!" );
+ break;
+ }
+ }
+ }
+
+ // Enable notification mechanism of our baseclass.
+ // We need it to get information about changes outside these class on our used configuration keys!
+ EnableNotification( seqNames );
+}
+
+
+// destructor
+
+SvtMiscOptions_Impl::~SvtMiscOptions_Impl()
+{
+ assert(!IsModified()); // should have been committed
+}
+
+void SvtMiscOptions_Impl::Load( const Sequence< OUString >& rPropertyNames )
+{
+ const uno::Sequence< OUString> aInternalPropertyNames( GetPropertyNames());
+ Sequence< Any > seqValues = GetProperties( rPropertyNames );
+
+ // Safe impossible cases.
+ // We need values from ALL configuration keys.
+ // Follow assignment use order of values in relation to our list of key names!
+ DBG_ASSERT( !(rPropertyNames.getLength()!=seqValues.getLength()), "SvtSecurityOptions_Impl::SvtSecurityOptions_Impl()\nI miss some values of configuration keys!\n" );
+
+ // Copy values from list in right order to our internal member.
+ sal_Int32 nPropertyCount = seqValues.getLength();
+ for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
+ {
+ if (!seqValues[nProperty].hasValue())
+ continue;
+ switch( comphelper::findValue(aInternalPropertyNames, rPropertyNames[nProperty]) )
+ {
+ case PROPERTYHANDLE_PLUGINSENABLED : {
+ if( !(seqValues[nProperty] >>= m_bPluginsEnabled) )
+ {
+ OSL_FAIL("Wrong type of \"Misc\\PluginsEnabled\"!" );
+ }
+ }
+ break;
+ case PROPERTYHANDLE_SYMBOLSET : {
+ if( !(seqValues[nProperty] >>= m_nSymbolsSize) )
+ {
+ OSL_FAIL("Wrong type of \"Misc\\SymbolSet\"!" );
+ }
+ }
+ break;
+ case PROPERTYHANDLE_SIDEBARICONSIZE : {
+ sal_uInt16 nTmp;
+ if( !(seqValues[nProperty] >>= nTmp) )
+ {
+ OSL_FAIL("Wrong type of \"Misc\\SidebarIconSize\"!" );
+ } else
+ m_nSidebarIconSize = static_cast<ToolBoxButtonSize>(nTmp);
+ }
+ break;
+ case PROPERTYHANDLE_NOTEBOOKBARICONSIZE : {
+ sal_uInt16 nTmp;
+ if( !(seqValues[nProperty] >>= nTmp ) )
+ {
+ OSL_FAIL("Wrong type of \"Misc\\NotebookbarIconSize\"!" );
+ } else
+ m_nNotebookbarIconSize = static_cast<ToolBoxButtonSize>(nTmp);
+ }
+ break;
+ case PROPERTYHANDLE_TOOLBOXSTYLE : {
+ if( !(seqValues[nProperty] >>= m_nToolboxStyle) )
+ {
+ OSL_FAIL("Wrong type of \"Misc\\ToolboxStyle\"!" );
+ }
+ }
+ break;
+ case PROPERTYHANDLE_USESYSTEMFILEDIALOG : {
+ if( !(seqValues[nProperty] >>= m_bUseSystemFileDialog) )
+ {
+ OSL_FAIL("Wrong type of \"Misc\\UseSystemFileDialog\"!" );
+ }
+ }
+ break;
+ case PROPERTYHANDLE_USESYSTEMPRINTDIALOG : {
+ if( !(seqValues[nProperty] >>= m_bUseSystemPrintDialog) )
+ {
+ OSL_FAIL("Wrong type of \"Misc\\UseSystemPrintDialog\"!" );
+ }
+ }
+ break;
+ case PROPERTYHANDLE_SHOWLINKWARNINGDIALOG : {
+ if( !(seqValues[nProperty] >>= m_bShowLinkWarningDialog) )
+ {
+ OSL_FAIL("Wrong type of \"Misc\\ShowLinkWarningDialog\"!" );
+ }
+ }
+ break;
+ case PROPERTYHANDLE_SYMBOLSTYLE : {
+ OUString aIconTheme;
+ if (seqValues[nProperty] >>= aIconTheme)
+ SetIconTheme(aIconTheme, SetModifiedFlag::DONT_SET);
+ else
+ OSL_FAIL("Wrong type of \"Misc\\SymbolStyle\"!" );
+ }
+ break;
+ case PROPERTYHANDLE_DISABLEUICUSTOMIZATION : {
+ if( !(seqValues[nProperty] >>= m_bDisableUICustomization) )
+ OSL_FAIL("Wrong type of \"Misc\\DisableUICustomization\"!" );
+ }
+ break;
+ }
+ }
+}
+
+void SvtMiscOptions_Impl::AddListenerLink( const Link<LinkParamNone*,void>& rLink )
+{
+ aList.push_back( rLink );
+}
+
+void SvtMiscOptions_Impl::RemoveListenerLink( const Link<LinkParamNone*,void>& rLink )
+{
+ aList.erase(std::remove(aList.begin(), aList.end(), rLink), aList.end());
+}
+
+void SvtMiscOptions_Impl::CallListeners()
+{
+ for (auto const& elem : aList)
+ elem.Call( nullptr );
+}
+
+void SvtMiscOptions_Impl::SetToolboxStyle( sal_Int16 nStyle )
+{
+ m_nToolboxStyle = nStyle ? 1 : 0;
+ SetModified();
+ CallListeners();
+}
+
+void SvtMiscOptions_Impl::SetSymbolsSize( sal_Int16 nSet )
+{
+ m_nSymbolsSize = nSet;
+ SetModified();
+ CallListeners();
+}
+
+void SvtMiscOptions_Impl::SetSidebarIconSize( ToolBoxButtonSize nSet )
+{
+ m_nSidebarIconSize = nSet;
+ SetModified();
+ CallListeners();
+}
+
+void SvtMiscOptions_Impl::SetNotebookbarIconSize( ToolBoxButtonSize nSet )
+{
+ m_nNotebookbarIconSize = nSet;
+ SetModified();
+ CallListeners();
+}
+
+OUString SvtMiscOptions_Impl::GetIconTheme()
+{
+ return Application::GetSettings().GetStyleSettings().DetermineIconTheme();
+}
+
+void
+SvtMiscOptions_Impl::SetIconTheme(const OUString &rName, SetModifiedFlag setModified)
+{
+ OUString aTheme(rName);
+ if (aTheme.isEmpty() || aTheme == "auto")
+ {
+ aTheme = Application::GetSettings().GetStyleSettings().GetAutomaticallyChosenIconTheme();
+ m_bIconThemeWasSetAutomatically = true;
+ }
+ else
+ m_bIconThemeWasSetAutomatically = false;
+
+ AllSettings aAllSettings = Application::GetSettings();
+ StyleSettings aStyleSettings = aAllSettings.GetStyleSettings();
+ aStyleSettings.SetIconTheme(aTheme);
+
+ aAllSettings.SetStyleSettings(aStyleSettings);
+ Application::MergeSystemSettings( aAllSettings );
+ Application::SetSettings(aAllSettings);
+
+ if (setModified == SetModifiedFlag::SET) {
+ SetModified();
+ }
+ CallListeners();
+}
+
+
+// public method
+
+void SvtMiscOptions_Impl::Notify( const Sequence< OUString >& rPropertyNames )
+{
+ Load( rPropertyNames );
+ CallListeners();
+}
+
+
+// public method
+
+void SvtMiscOptions_Impl::ImplCommit()
+{
+ // Get names of supported properties, create a list for values and copy current values to it.
+ Sequence< OUString > seqNames = GetPropertyNames ();
+ sal_Int32 nCount = seqNames.getLength();
+ Sequence< Any > seqValues ( nCount );
+ for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
+ {
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_PLUGINSENABLED :
+ {
+ if ( !m_bIsPluginsEnabledRO )
+ seqValues[nProperty] <<= m_bPluginsEnabled;
+ break;
+ }
+
+ case PROPERTYHANDLE_SYMBOLSET :
+ {
+ if ( !m_bIsSymbolsSizeRO )
+ seqValues[nProperty] <<= m_nSymbolsSize;
+ break;
+ }
+
+ case PROPERTYHANDLE_SIDEBARICONSIZE :
+ {
+ if ( !m_bIsSidebarIconSizeRO )
+ seqValues[nProperty] <<= static_cast<sal_uInt16>(m_nSidebarIconSize);
+ break;
+ }
+
+ case PROPERTYHANDLE_NOTEBOOKBARICONSIZE :
+ {
+ if ( !m_bIsNotebookbarIconSizeRO )
+ seqValues[nProperty] <<= static_cast<sal_uInt16>(m_nNotebookbarIconSize);
+ break;
+ }
+
+ case PROPERTYHANDLE_TOOLBOXSTYLE :
+ {
+ if ( !m_bIsToolboxStyleRO )
+ seqValues[nProperty] <<= m_nToolboxStyle;
+ break;
+ }
+
+ case PROPERTYHANDLE_USESYSTEMFILEDIALOG :
+ {
+ if ( !m_bIsUseSystemFileDialogRO )
+ seqValues[nProperty] <<= m_bUseSystemFileDialog;
+ break;
+ }
+
+ case PROPERTYHANDLE_SYMBOLSTYLE :
+ {
+ if ( !m_bIsSymbolsStyleRO ) {
+ OUString value;
+ if (m_bIconThemeWasSetAutomatically) {
+ value = "auto";
+ }
+ else {
+ value = GetIconTheme();
+ }
+ seqValues[nProperty] <<= value;
+ }
+ break;
+ }
+
+ case PROPERTYHANDLE_USESYSTEMPRINTDIALOG :
+ {
+ if ( !m_bIsUseSystemPrintDialogRO )
+ seqValues[nProperty] <<= m_bUseSystemPrintDialog;
+ break;
+ }
+
+ case PROPERTYHANDLE_SHOWLINKWARNINGDIALOG :
+ {
+ if ( !m_bIsShowLinkWarningDialogRO )
+ seqValues[nProperty] <<= m_bShowLinkWarningDialog;
+ break;
+ }
+
+ case PROPERTYHANDLE_DISABLEUICUSTOMIZATION :
+ {
+ seqValues[nProperty] <<= m_bDisableUICustomization;
+ break;
+ }
+ case PROPERTYHANDLE_EXPERIMENTALMODE :
+ {
+ seqValues[nProperty] <<= m_bExperimentalMode;
+ break;
+ }
+ case PROPERTYHANDLE_MACRORECORDERMODE :
+ {
+ seqValues[nProperty] <<= m_bMacroRecorderMode;
+ break;
+ }
+ }
+ }
+ // Set properties in configuration.
+ PutProperties( seqNames, seqValues );
+}
+
+
+// private method
+
+Sequence< OUString > SvtMiscOptions_Impl::GetPropertyNames()
+{
+ return Sequence<OUString>
+ {
+ PROPERTYNAME_PLUGINSENABLED,
+ PROPERTYNAME_SYMBOLSET,
+ PROPERTYNAME_TOOLBOXSTYLE,
+ PROPERTYNAME_USESYSTEMFILEDIALOG,
+ PROPERTYNAME_ICONTHEME,
+ PROPERTYNAME_USESYSTEMPRINTDIALOG,
+ PROPERTYNAME_SHOWLINKWARNINGDIALOG,
+ PROPERTYNAME_DISABLEUICUSTOMIZATION,
+ PROPERTYNAME_EXPERIMENTALMODE,
+ PROPERTYNAME_MACRORECORDERMODE,
+ PROPERTYNAME_SIDEBARICONSIZE,
+ PROPERTYNAME_NOTEBOOKBARICONSIZE
+ };
+}
+
+namespace {
+
+std::weak_ptr<SvtMiscOptions_Impl> g_pMiscOptions;
+
+}
+
+SvtMiscOptions::SvtMiscOptions()
+{
+ // Global access, must be guarded (multithreading!).
+ MutexGuard aGuard( GetInitMutex() );
+
+ m_pImpl = g_pMiscOptions.lock();
+ if( !m_pImpl )
+ {
+ m_pImpl = std::make_shared<SvtMiscOptions_Impl>();
+ g_pMiscOptions = m_pImpl;
+ svtools::ItemHolder2::holdConfigItem(EItem::MiscOptions);
+ }
+}
+
+SvtMiscOptions::~SvtMiscOptions()
+{
+ // Global access, must be guarded (multithreading!)
+ MutexGuard aGuard( GetInitMutex() );
+
+ m_pImpl.reset();
+}
+
+bool SvtMiscOptions::UseSystemFileDialog() const
+{
+ return m_pImpl->UseSystemFileDialog();
+}
+
+void SvtMiscOptions::SetUseSystemFileDialog( bool bEnable )
+{
+ m_pImpl->SetUseSystemFileDialog( bEnable );
+}
+
+bool SvtMiscOptions::IsUseSystemFileDialogReadOnly() const
+{
+ return m_pImpl->IsUseSystemFileDialogReadOnly();
+}
+
+bool SvtMiscOptions::IsPluginsEnabled() const
+{
+ return m_pImpl->IsPluginsEnabled();
+}
+
+sal_Int16 SvtMiscOptions::GetSymbolsSize() const
+{
+ return m_pImpl->GetSymbolsSize();
+}
+
+void SvtMiscOptions::SetSymbolsSize( sal_Int16 nSet )
+{
+ m_pImpl->SetSymbolsSize( nSet );
+}
+
+ToolBoxButtonSize SvtMiscOptions::GetSidebarIconSize() const
+{
+ return m_pImpl->GetSidebarIconSize();
+}
+
+ToolBoxButtonSize SvtMiscOptions::GetNotebookbarIconSize() const
+{
+ return m_pImpl->GetNotebookbarIconSize();
+}
+
+void SvtMiscOptions::SetSidebarIconSize( ToolBoxButtonSize nSet )
+{
+ m_pImpl->SetSidebarIconSize( nSet );
+}
+
+void SvtMiscOptions::SetNotebookbarIconSize( ToolBoxButtonSize nSet )
+{
+ m_pImpl->SetNotebookbarIconSize( nSet );
+}
+
+sal_Int16 SvtMiscOptions::GetCurrentSymbolsSize() const
+{
+ sal_Int16 eOptSymbolsSize = m_pImpl->GetSymbolsSize();
+
+ if ( eOptSymbolsSize == SFX_SYMBOLS_SIZE_AUTO )
+ {
+ // Use system settings, we have to retrieve the toolbar icon size from the
+ // Application class
+ ToolbarIconSize nStyleIconSize = Application::GetSettings().GetStyleSettings().GetToolbarIconSize();
+ if (nStyleIconSize == ToolbarIconSize::Size32)
+ eOptSymbolsSize = SFX_SYMBOLS_SIZE_32;
+ else if (nStyleIconSize == ToolbarIconSize::Large)
+ eOptSymbolsSize = SFX_SYMBOLS_SIZE_LARGE;
+ else
+ eOptSymbolsSize = SFX_SYMBOLS_SIZE_SMALL;
+ }
+
+ return eOptSymbolsSize;
+}
+
+bool SvtMiscOptions::AreCurrentSymbolsLarge() const
+{
+ return ( GetCurrentSymbolsSize() == SFX_SYMBOLS_SIZE_LARGE || GetCurrentSymbolsSize() == SFX_SYMBOLS_SIZE_32);
+}
+
+OUString SvtMiscOptions::GetIconTheme() const
+{
+ return SvtMiscOptions_Impl::GetIconTheme();
+}
+
+void SvtMiscOptions::SetIconTheme(const OUString& iconTheme)
+{
+ m_pImpl->SetIconTheme(iconTheme, SvtMiscOptions_Impl::SetModifiedFlag::SET);
+}
+
+bool SvtMiscOptions::DisableUICustomization() const
+{
+ return m_pImpl->DisableUICustomization();
+}
+
+sal_Int16 SvtMiscOptions::GetToolboxStyle() const
+{
+ return m_pImpl->GetToolboxStyle();
+}
+
+void SvtMiscOptions::SetToolboxStyle( sal_Int16 nStyle )
+{
+ m_pImpl->SetToolboxStyle( nStyle );
+}
+
+bool SvtMiscOptions::UseSystemPrintDialog() const
+{
+ return m_pImpl->UseSystemPrintDialog();
+}
+
+void SvtMiscOptions::SetUseSystemPrintDialog( bool bEnable )
+{
+ m_pImpl->SetUseSystemPrintDialog( bEnable );
+}
+
+bool SvtMiscOptions::ShowLinkWarningDialog() const
+{
+ return m_pImpl->ShowLinkWarningDialog();
+}
+
+void SvtMiscOptions::SetShowLinkWarningDialog( bool bSet )
+{
+ m_pImpl->SetShowLinkWarningDialog( bSet );
+}
+
+bool SvtMiscOptions::IsShowLinkWarningDialogReadOnly() const
+{
+ return m_pImpl->IsShowLinkWarningDialogReadOnly();
+}
+
+void SvtMiscOptions::SetExperimentalMode( bool bSet )
+{
+ m_pImpl->SetExperimentalMode( bSet );
+}
+
+bool SvtMiscOptions::IsExperimentalMode() const
+{
+ return m_pImpl->IsExperimentalMode();
+}
+
+void SvtMiscOptions::SetMacroRecorderMode( bool bSet )
+{
+ m_pImpl->SetMacroRecorderMode( bSet );
+}
+
+bool SvtMiscOptions::IsMacroRecorderMode() const
+{
+ return m_pImpl->IsMacroRecorderMode();
+}
+
+namespace
+{
+ class theSvtMiscOptionsMutex :
+ public rtl::Static< osl::Mutex, theSvtMiscOptionsMutex > {};
+}
+
+Mutex & SvtMiscOptions::GetInitMutex()
+{
+ return theSvtMiscOptionsMutex::get();
+}
+
+void SvtMiscOptions::AddListenerLink( const Link<LinkParamNone*,void>& rLink )
+{
+ m_pImpl->AddListenerLink( rLink );
+}
+
+void SvtMiscOptions::RemoveListenerLink( const Link<LinkParamNone*,void>& rLink )
+{
+ m_pImpl->RemoveListenerLink( rLink );
+}
+
+bool
+SvtMiscOptions::IconThemeWasSetAutomatically()
+{
+ return m_pImpl->IconThemeWasSetAutomatically();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/config/optionsdrawinglayer.cxx b/svtools/source/config/optionsdrawinglayer.cxx
new file mode 100644
index 000000000..18a2ab4a0
--- /dev/null
+++ b/svtools/source/config/optionsdrawinglayer.cxx
@@ -0,0 +1,1020 @@
+/* -*- 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 <svtools/optionsdrawinglayer.hxx>
+#include <unotools/configmgr.hxx>
+#include <unotools/configitem.hxx>
+#include <tools/debug.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/outdev.hxx>
+#include <vcl/settings.hxx>
+#include <rtl/instance.hxx>
+
+// namespaces
+
+using namespace ::utl ;
+using namespace ::osl ;
+using namespace ::com::sun::star::uno ;
+
+#define ROOTNODE_START "Office.Common/Drawinglayer"
+#define DEFAULT_OVERLAYBUFFER true
+#define DEFAULT_PAINTBUFFER true
+#define DEFAULT_STRIPE_COLOR_A Color(0)
+#define DEFAULT_STRIPE_COLOR_B Color(16581375)
+#define DEFAULT_STRIPE_LENGTH 4
+
+// #i73602#
+// #i74769#, #i75172# : Change default for Calc and Writer to True
+#define DEFAULT_OVERLAYBUFFER_CALC true
+#define DEFAULT_OVERLAYBUFFER_WRITER true
+#define DEFAULT_OVERLAYBUFFER_DRAWIMPRESS true
+
+// #i74769#, #i75172#
+#define DEFAULT_PAINTBUFFER_CALC true
+#define DEFAULT_PAINTBUFFER_WRITER true
+#define DEFAULT_PAINTBUFFER_DRAWIMPRESS true
+
+// #i4219#
+#define DEFAULT_MAXIMUMPAPERWIDTH 600
+#define DEFAULT_MAXIMUMPAPERHEIGHT 600
+#define DEFAULT_MAXIMUMPAPERLEFTMARGIN 9999
+#define DEFAULT_MAXIMUMPAPERRIGHTMARGIN 9999
+#define DEFAULT_MAXIMUMPAPERTOPMARGIN 9999
+#define DEFAULT_MAXIMUMPAPERBOTTOMMARGIN 9999
+
+// primitives
+#define DEFAULT_ANTIALIASING true
+#define DEFAULT_SNAPHORVERLINESTODISCRETE true
+#define DEFAULT_SOLIDDRAGCREATE true
+#define DEFAULT_RENDERDECORATEDTEXTDIRECT true
+#define DEFAULT_RENDERSIMPLETEXTDIRECT true
+#define DEFAULT_QUADRATIC3DRENDERLIMIT 1000000
+#define DEFAULT_QUADRATICFORMCONTROLRENDERLIMIT 45000
+
+// #i97672# selection settings
+#define DEFAULT_TRANSPARENTSELECTION true
+#define DEFAULT_TRANSPARENTSELECTIONPERCENT 75
+#define DEFAULT_SELECTIONMAXIMUMLUMINANCEPERCENT 70
+
+#define PROPERTYNAME_OVERLAYBUFFER OUString("OverlayBuffer" )
+#define PROPERTYNAME_PAINTBUFFER OUString("PaintBuffer" )
+#define PROPERTYNAME_STRIPE_COLOR_A OUString("StripeColorA" )
+#define PROPERTYNAME_STRIPE_COLOR_B OUString("StripeColorB" )
+#define PROPERTYNAME_STRIPE_LENGTH OUString("StripeLength" )
+
+// #i73602#
+#define PROPERTYNAME_OVERLAYBUFFER_CALC OUString("OverlayBuffer_Calc")
+#define PROPERTYNAME_OVERLAYBUFFER_WRITER OUString("OverlayBuffer_Writer")
+#define PROPERTYNAME_OVERLAYBUFFER_DRAWIMPRESS OUString("OverlayBuffer_DrawImpress")
+
+// #i74769#, #i75172#
+#define PROPERTYNAME_PAINTBUFFER_CALC OUString("PaintBuffer_Calc")
+#define PROPERTYNAME_PAINTBUFFER_WRITER OUString("PaintBuffer_Writer")
+#define PROPERTYNAME_PAINTBUFFER_DRAWIMPRESS OUString("PaintBuffer_DrawImpress")
+
+// #i4219#
+#define PROPERTYNAME_MAXIMUMPAPERWIDTH OUString("MaximumPaperWidth")
+#define PROPERTYNAME_MAXIMUMPAPERHEIGHT OUString("MaximumPaperHeight")
+#define PROPERTYNAME_MAXIMUMPAPERLEFTMARGIN OUString("MaximumPaperLeftMargin")
+#define PROPERTYNAME_MAXIMUMPAPERRIGHTMARGIN OUString("MaximumPaperRightMargin")
+#define PROPERTYNAME_MAXIMUMPAPERTOPMARGIN OUString("MaximumPaperTopMargin")
+#define PROPERTYNAME_MAXIMUMPAPERBOTTOMMARGIN OUString("MaximumPaperBottomMargin")
+
+// primitives
+#define PROPERTYNAME_ANTIALIASING OUString("AntiAliasing")
+#define PROPERTYNAME_SNAPHORVERLINESTODISCRETE OUString("SnapHorVerLinesToDiscrete")
+#define PROPERTYNAME_SOLIDDRAGCREATE OUString("SolidDragCreate")
+#define PROPERTYNAME_RENDERDECORATEDTEXTDIRECT OUString("RenderDecoratedTextDirect")
+#define PROPERTYNAME_RENDERSIMPLETEXTDIRECT OUString("RenderSimpleTextDirect")
+#define PROPERTYNAME_QUADRATIC3DRENDERLIMIT OUString("Quadratic3DRenderLimit")
+#define PROPERTYNAME_QUADRATICFORMCONTROLRENDERLIMIT OUString("QuadraticFormControlRenderLimit")
+
+// #i97672# selection settings
+#define PROPERTYNAME_TRANSPARENTSELECTION OUString("TransparentSelection")
+#define PROPERTYNAME_TRANSPARENTSELECTIONPERCENT OUString("TransparentSelectionPercent")
+#define PROPERTYNAME_SELECTIONMAXIMUMLUMINANCEPERCENT OUString("SelectionMaximumLuminancePercent")
+
+#define PROPERTYHANDLE_OVERLAYBUFFER 0
+#define PROPERTYHANDLE_PAINTBUFFER 1
+#define PROPERTYHANDLE_STRIPE_COLOR_A 2
+#define PROPERTYHANDLE_STRIPE_COLOR_B 3
+#define PROPERTYHANDLE_STRIPE_LENGTH 4
+
+// #i73602#
+#define PROPERTYHANDLE_OVERLAYBUFFER_CALC 5
+#define PROPERTYHANDLE_OVERLAYBUFFER_WRITER 6
+#define PROPERTYHANDLE_OVERLAYBUFFER_DRAWIMPRESS 7
+
+// #i74769#, #i75172#
+#define PROPERTYHANDLE_PAINTBUFFER_CALC 8
+#define PROPERTYHANDLE_PAINTBUFFER_WRITER 9
+#define PROPERTYHANDLE_PAINTBUFFER_DRAWIMPRESS 10
+
+// #i4219#
+#define PROPERTYHANDLE_MAXIMUMPAPERWIDTH 11
+#define PROPERTYHANDLE_MAXIMUMPAPERHEIGHT 12
+#define PROPERTYHANDLE_MAXIMUMPAPERLEFTMARGIN 13
+#define PROPERTYHANDLE_MAXIMUMPAPERRIGHTMARGIN 14
+#define PROPERTYHANDLE_MAXIMUMPAPERTOPMARGIN 15
+#define PROPERTYHANDLE_MAXIMUMPAPERBOTTOMMARGIN 16
+
+// primitives
+#define PROPERTYHANDLE_ANTIALIASING 17
+#define PROPERTYHANDLE_SNAPHORVERLINESTODISCRETE 18
+#define PROPERTYHANDLE_SOLIDDRAGCREATE 19
+#define PROPERTYHANDLE_RENDERDECORATEDTEXTDIRECT 20
+#define PROPERTYHANDLE_RENDERSIMPLETEXTDIRECT 21
+#define PROPERTYHANDLE_QUADRATIC3DRENDERLIMIT 22
+#define PROPERTYHANDLE_QUADRATICFORMCONTROLRENDERLIMIT 23
+
+// #i97672# selection settings
+#define PROPERTYHANDLE_TRANSPARENTSELECTION 24
+#define PROPERTYHANDLE_TRANSPARENTSELECTIONPERCENT 25
+#define PROPERTYHANDLE_SELECTIONMAXIMUMLUMINANCEPERCENT 26
+
+#define PROPERTYCOUNT 27
+
+class SvtOptionsDrawinglayer_Impl : public ConfigItem
+{
+public:
+ SvtOptionsDrawinglayer_Impl();
+ ~SvtOptionsDrawinglayer_Impl() override;
+
+ virtual void Notify( const css::uno::Sequence<OUString>& aPropertyNames) override;
+
+ bool IsOverlayBuffer() const { return m_bOverlayBuffer;}
+ bool IsPaintBuffer() const { return m_bPaintBuffer;}
+ const Color& GetStripeColorA() const { return m_bStripeColorA;}
+ const Color& GetStripeColorB() const { return m_bStripeColorB;}
+ sal_uInt16 GetStripeLength() const { return m_nStripeLength;}
+
+ // #i73602#
+ bool IsOverlayBuffer_Calc() const { return m_bOverlayBuffer_Calc;}
+ bool IsOverlayBuffer_Writer() const { return m_bOverlayBuffer_Writer;}
+ bool IsOverlayBuffer_DrawImpress() const { return m_bOverlayBuffer_DrawImpress;}
+
+ // #i74769#, #i75172#
+ bool IsPaintBuffer_Calc() const { return m_bPaintBuffer_Calc;}
+ bool IsPaintBuffer_Writer() const { return m_bPaintBuffer_Writer;}
+ bool IsPaintBuffer_DrawImpress() const { return m_bPaintBuffer_DrawImpress;}
+
+ // #i4219#
+ sal_uInt32 GetMaximumPaperWidth() const { return m_nMaximumPaperWidth;}
+ sal_uInt32 GetMaximumPaperHeight() const { return m_nMaximumPaperHeight;}
+ sal_uInt32 GetMaximumPaperLeftMargin() const { return m_nMaximumPaperLeftMargin;}
+ sal_uInt32 GetMaximumPaperRightMargin() const { return m_nMaximumPaperRightMargin;}
+ sal_uInt32 GetMaximumPaperTopMargin() const { return m_nMaximumPaperTopMargin;}
+ sal_uInt32 GetMaximumPaperBottomMargin() const { return m_nMaximumPaperBottomMargin;}
+
+ // helper
+ bool IsAAPossibleOnThisSystem() const;
+
+ // primitives
+ bool IsAntiAliasing() const { return m_bAntiAliasing;}
+ bool IsSnapHorVerLinesToDiscrete() const { return m_bSnapHorVerLinesToDiscrete;}
+ bool IsSolidDragCreate() const { return m_bSolidDragCreate;}
+ bool IsRenderDecoratedTextDirect() const { return m_bRenderDecoratedTextDirect;}
+ bool IsRenderSimpleTextDirect() const { return m_bRenderSimpleTextDirect;}
+ sal_uInt32 GetQuadratic3DRenderLimit() const { return m_nQuadratic3DRenderLimit;}
+ sal_uInt32 GetQuadraticFormControlRenderLimit() const { return m_nQuadraticFormControlRenderLimit;}
+
+ void SetAntiAliasing( bool bState );
+
+ // #i97672# selection settings
+ bool IsTransparentSelection() const { return m_bTransparentSelection;}
+ sal_uInt16 GetTransparentSelectionPercent() const { return m_nTransparentSelectionPercent;}
+ sal_uInt16 GetSelectionMaximumLuminancePercent() const { return m_nSelectionMaximumLuminancePercent;}
+
+// private methods
+
+private:
+ virtual void ImplCommit() final override;
+
+ static Sequence< OUString > impl_GetPropertyNames();
+
+// private member
+
+private:
+
+ bool m_bOverlayBuffer;
+ bool m_bPaintBuffer;
+ Color m_bStripeColorA;
+ Color m_bStripeColorB;
+ sal_uInt16 m_nStripeLength;
+
+ // #i73602#
+ bool m_bOverlayBuffer_Calc;
+ bool m_bOverlayBuffer_Writer;
+ bool m_bOverlayBuffer_DrawImpress;
+
+ // #i74769#, #i75172#
+ bool m_bPaintBuffer_Calc;
+ bool m_bPaintBuffer_Writer;
+ bool m_bPaintBuffer_DrawImpress;
+
+ // #i4219#
+ sal_uInt32 m_nMaximumPaperWidth;
+ sal_uInt32 m_nMaximumPaperHeight;
+ sal_uInt32 m_nMaximumPaperLeftMargin;
+ sal_uInt32 m_nMaximumPaperRightMargin;
+ sal_uInt32 m_nMaximumPaperTopMargin;
+ sal_uInt32 m_nMaximumPaperBottomMargin;
+
+ // primitives
+ bool m_bAntiAliasing;
+ bool m_bSnapHorVerLinesToDiscrete;
+ bool m_bSolidDragCreate;
+ bool m_bRenderDecoratedTextDirect;
+ bool m_bRenderSimpleTextDirect;
+ sal_uInt32 m_nQuadratic3DRenderLimit;
+ sal_uInt32 m_nQuadraticFormControlRenderLimit;
+
+ // #i97672# selection settings
+ sal_uInt16 m_nTransparentSelectionPercent;
+ sal_uInt16 m_nSelectionMaximumLuminancePercent;
+ bool m_bTransparentSelection;
+
+ // local values
+ bool m_bAllowAA : 1;
+ bool m_bAllowAAChecked : 1;
+};
+
+SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl() :
+ ConfigItem( ROOTNODE_START ),
+ m_bOverlayBuffer( DEFAULT_OVERLAYBUFFER ),
+ m_bPaintBuffer( DEFAULT_PAINTBUFFER ),
+ m_bStripeColorA(DEFAULT_STRIPE_COLOR_A),
+ m_bStripeColorB(DEFAULT_STRIPE_COLOR_B),
+ m_nStripeLength(DEFAULT_STRIPE_LENGTH),
+
+ // #i73602#
+ m_bOverlayBuffer_Calc( DEFAULT_OVERLAYBUFFER_CALC ),
+ m_bOverlayBuffer_Writer( DEFAULT_OVERLAYBUFFER_WRITER ),
+ m_bOverlayBuffer_DrawImpress( DEFAULT_OVERLAYBUFFER_DRAWIMPRESS ),
+
+ // #i74769#, #i75172#
+ m_bPaintBuffer_Calc( DEFAULT_PAINTBUFFER_CALC ),
+ m_bPaintBuffer_Writer( DEFAULT_PAINTBUFFER_WRITER ),
+ m_bPaintBuffer_DrawImpress( DEFAULT_PAINTBUFFER_DRAWIMPRESS ),
+
+ // #i4219#
+ m_nMaximumPaperWidth(DEFAULT_MAXIMUMPAPERWIDTH),
+ m_nMaximumPaperHeight(DEFAULT_MAXIMUMPAPERHEIGHT),
+ m_nMaximumPaperLeftMargin(DEFAULT_MAXIMUMPAPERLEFTMARGIN),
+ m_nMaximumPaperRightMargin(DEFAULT_MAXIMUMPAPERRIGHTMARGIN),
+ m_nMaximumPaperTopMargin(DEFAULT_MAXIMUMPAPERTOPMARGIN),
+ m_nMaximumPaperBottomMargin(DEFAULT_MAXIMUMPAPERBOTTOMMARGIN),
+
+ // primitives
+ m_bAntiAliasing(DEFAULT_ANTIALIASING),
+ m_bSnapHorVerLinesToDiscrete(DEFAULT_SNAPHORVERLINESTODISCRETE),
+ m_bSolidDragCreate(DEFAULT_SOLIDDRAGCREATE),
+ m_bRenderDecoratedTextDirect(DEFAULT_RENDERDECORATEDTEXTDIRECT),
+ m_bRenderSimpleTextDirect(DEFAULT_RENDERSIMPLETEXTDIRECT),
+ m_nQuadratic3DRenderLimit(DEFAULT_QUADRATIC3DRENDERLIMIT),
+ m_nQuadraticFormControlRenderLimit(DEFAULT_QUADRATICFORMCONTROLRENDERLIMIT),
+
+ // #i97672# selection settings
+ m_nTransparentSelectionPercent(DEFAULT_TRANSPARENTSELECTIONPERCENT),
+ m_nSelectionMaximumLuminancePercent(DEFAULT_SELECTIONMAXIMUMLUMINANCEPERCENT),
+ m_bTransparentSelection(DEFAULT_TRANSPARENTSELECTION),
+
+ // local values
+ m_bAllowAA(true),
+ m_bAllowAAChecked(false)
+{
+ Sequence< OUString > seqNames( impl_GetPropertyNames() );
+ Sequence< Any > seqValues = GetProperties( seqNames ) ;
+
+ DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nI miss some values of configuration keys!\n" );
+
+ // Copy values from list in right order to our internal member.
+ sal_Int32 nPropertyCount = seqValues.getLength();
+ for(sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
+ {
+ if (!seqValues[nProperty].hasValue())
+ continue;
+
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_OVERLAYBUFFER:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\OverlayBuffer\"?" );
+ seqValues[nProperty] >>= m_bOverlayBuffer;
+ }
+ break;
+
+ case PROPERTYHANDLE_PAINTBUFFER:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\PaintBuffer\"?" );
+ seqValues[nProperty] >>= m_bPaintBuffer;
+ }
+ break;
+
+ case PROPERTYHANDLE_STRIPE_COLOR_A:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_LONG), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\StripeColorA\"?" );
+ sal_Int32 nValue = 0;
+ seqValues[nProperty] >>= nValue;
+ m_bStripeColorA = Color(nValue);
+ }
+ break;
+
+ case PROPERTYHANDLE_STRIPE_COLOR_B:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_LONG), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\StripeColorB\"?" );
+ sal_Int32 nValue = 0;
+ seqValues[nProperty] >>= nValue;
+ m_bStripeColorB = Color(nValue);
+ }
+ break;
+
+ case PROPERTYHANDLE_STRIPE_LENGTH:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_SHORT), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\StripeLength\"?" );
+ seqValues[nProperty] >>= m_nStripeLength;
+ }
+ break;
+
+ // #i73602#
+ case PROPERTYHANDLE_OVERLAYBUFFER_CALC:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\OverlayBuffer_Calc\"?" );
+ seqValues[nProperty] >>= m_bOverlayBuffer_Calc;
+ }
+ break;
+
+ case PROPERTYHANDLE_OVERLAYBUFFER_WRITER:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\OverlayBuffer_Writer\"?" );
+ seqValues[nProperty] >>= m_bOverlayBuffer_Writer;
+ }
+ break;
+
+ case PROPERTYHANDLE_OVERLAYBUFFER_DRAWIMPRESS:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\OverlayBuffer_DrawImpress\"?" );
+ seqValues[nProperty] >>= m_bOverlayBuffer_DrawImpress;
+ }
+ break;
+
+ // #i74769#, #i75172#
+ case PROPERTYHANDLE_PAINTBUFFER_CALC:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\PaintBuffer_Calc\"?" );
+ seqValues[nProperty] >>= m_bPaintBuffer_Calc;
+ }
+ break;
+
+ case PROPERTYHANDLE_PAINTBUFFER_WRITER:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\PaintBuffer_Writer\"?" );
+ seqValues[nProperty] >>= m_bPaintBuffer_Writer;
+ }
+ break;
+
+ case PROPERTYHANDLE_PAINTBUFFER_DRAWIMPRESS:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\PaintBuffer_DrawImpress\"?" );
+ seqValues[nProperty] >>= m_bPaintBuffer_DrawImpress;
+ }
+ break;
+
+ // #i4219#
+ case PROPERTYHANDLE_MAXIMUMPAPERWIDTH:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_LONG), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\MaximumPaperWidth\"?" );
+ seqValues[nProperty] >>= m_nMaximumPaperWidth;
+ }
+ break;
+
+ case PROPERTYHANDLE_MAXIMUMPAPERHEIGHT:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_LONG), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\MaximumPaperHeight\"?" );
+ seqValues[nProperty] >>= m_nMaximumPaperHeight;
+ }
+ break;
+
+ case PROPERTYHANDLE_MAXIMUMPAPERLEFTMARGIN:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_LONG), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\MaximumPaperLeftMargin\"?" );
+ seqValues[nProperty] >>= m_nMaximumPaperLeftMargin;
+ }
+ break;
+
+ case PROPERTYHANDLE_MAXIMUMPAPERRIGHTMARGIN:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_LONG), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\MaximumPaperRightMargin\"?" );
+ seqValues[nProperty] >>= m_nMaximumPaperRightMargin;
+ }
+ break;
+
+ case PROPERTYHANDLE_MAXIMUMPAPERTOPMARGIN:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_LONG), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\MaximumPaperTopMargin\"?" );
+ seqValues[nProperty] >>= m_nMaximumPaperTopMargin;
+ }
+ break;
+
+ case PROPERTYHANDLE_MAXIMUMPAPERBOTTOMMARGIN:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_LONG), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\MaximumPaperBottomMargin\"?" );
+ seqValues[nProperty] >>= m_nMaximumPaperBottomMargin;
+ }
+ break;
+
+ // primitives
+ case PROPERTYHANDLE_ANTIALIASING:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\AntiAliasing\"?" );
+ seqValues[nProperty] >>= m_bAntiAliasing;
+ }
+ break;
+
+ // primitives
+ case PROPERTYHANDLE_SNAPHORVERLINESTODISCRETE:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\SnapHorVerLinesToDiscrete\"?" );
+ seqValues[nProperty] >>= m_bSnapHorVerLinesToDiscrete;
+ }
+ break;
+
+ case PROPERTYHANDLE_SOLIDDRAGCREATE:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\SolidDragCreate\"?" );
+ seqValues[nProperty] >>= m_bSolidDragCreate;
+ }
+ break;
+
+ case PROPERTYHANDLE_RENDERDECORATEDTEXTDIRECT:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\RenderDecoratedTextDirect\"?" );
+ seqValues[nProperty] >>= m_bRenderDecoratedTextDirect;
+ }
+ break;
+
+ case PROPERTYHANDLE_RENDERSIMPLETEXTDIRECT:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\RenderSimpleTextDirect\"?" );
+ seqValues[nProperty] >>= m_bRenderSimpleTextDirect;
+ }
+ break;
+
+ case PROPERTYHANDLE_QUADRATIC3DRENDERLIMIT:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_LONG), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\Quadratic3DRenderLimit\"?" );
+ seqValues[nProperty] >>= m_nQuadratic3DRenderLimit;
+ }
+ break;
+
+ case PROPERTYHANDLE_QUADRATICFORMCONTROLRENDERLIMIT:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_LONG), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\QuadraticFormControlRenderLimit\"?" );
+ seqValues[nProperty] >>= m_nQuadraticFormControlRenderLimit;
+ }
+ break;
+
+ // #i97672# selection settings
+ case PROPERTYHANDLE_TRANSPARENTSELECTION:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\TransparentSelection\"?" );
+ seqValues[nProperty] >>= m_bTransparentSelection;
+ }
+ break;
+
+ case PROPERTYHANDLE_TRANSPARENTSELECTIONPERCENT:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_SHORT), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\TransparentSelectionPercent\"?" );
+ seqValues[nProperty] >>= m_nTransparentSelectionPercent;
+ }
+ break;
+
+ case PROPERTYHANDLE_SELECTIONMAXIMUMLUMINANCEPERCENT:
+ {
+ DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_SHORT), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\SelectionMaximumLuminancePercent\"?" );
+ seqValues[nProperty] >>= m_nSelectionMaximumLuminancePercent;
+ }
+ break;
+ }
+ }
+}
+
+SvtOptionsDrawinglayer_Impl::~SvtOptionsDrawinglayer_Impl()
+{
+ if (IsModified())
+ Commit();
+}
+
+// Commit
+
+void SvtOptionsDrawinglayer_Impl::ImplCommit()
+{
+ Sequence< OUString > aSeqNames( impl_GetPropertyNames() );
+ Sequence< Any > aSeqValues( aSeqNames.getLength() );
+
+ for( sal_Int32 nProperty = 0, nCount = aSeqNames.getLength(); nProperty < nCount; ++nProperty )
+ {
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_OVERLAYBUFFER:
+ aSeqValues[nProperty] <<= m_bOverlayBuffer;
+ break;
+
+ case PROPERTYHANDLE_PAINTBUFFER:
+ aSeqValues[nProperty] <<= m_bPaintBuffer;
+ break;
+
+ case PROPERTYHANDLE_STRIPE_COLOR_A:
+ aSeqValues[nProperty] <<= m_bStripeColorA;
+ break;
+
+ case PROPERTYHANDLE_STRIPE_COLOR_B:
+ aSeqValues[nProperty] <<= m_bStripeColorB;
+ break;
+
+ case PROPERTYHANDLE_STRIPE_LENGTH:
+ aSeqValues[nProperty] <<= m_nStripeLength;
+ break;
+
+ // #i73602#
+ case PROPERTYHANDLE_OVERLAYBUFFER_CALC:
+ aSeqValues[nProperty] <<= m_bOverlayBuffer_Calc;
+ break;
+
+ case PROPERTYHANDLE_OVERLAYBUFFER_WRITER:
+ aSeqValues[nProperty] <<= m_bOverlayBuffer_Writer;
+ break;
+
+ case PROPERTYHANDLE_OVERLAYBUFFER_DRAWIMPRESS:
+ aSeqValues[nProperty] <<= m_bOverlayBuffer_DrawImpress;
+ break;
+
+ // #i74769#, #i75172#
+ case PROPERTYHANDLE_PAINTBUFFER_CALC:
+ aSeqValues[nProperty] <<= m_bPaintBuffer_Calc;
+ break;
+
+ case PROPERTYHANDLE_PAINTBUFFER_WRITER:
+ aSeqValues[nProperty] <<= m_bPaintBuffer_Writer;
+ break;
+
+ case PROPERTYHANDLE_PAINTBUFFER_DRAWIMPRESS:
+ aSeqValues[nProperty] <<= m_bPaintBuffer_DrawImpress;
+ break;
+
+ // #i4219#
+ case PROPERTYHANDLE_MAXIMUMPAPERWIDTH:
+ aSeqValues[nProperty] <<= m_nMaximumPaperWidth;
+ break;
+
+ case PROPERTYHANDLE_MAXIMUMPAPERHEIGHT:
+ aSeqValues[nProperty] <<= m_nMaximumPaperHeight;
+ break;
+
+ case PROPERTYHANDLE_MAXIMUMPAPERLEFTMARGIN:
+ aSeqValues[nProperty] <<= m_nMaximumPaperLeftMargin;
+ break;
+
+ case PROPERTYHANDLE_MAXIMUMPAPERRIGHTMARGIN:
+ aSeqValues[nProperty] <<= m_nMaximumPaperRightMargin;
+ break;
+
+ case PROPERTYHANDLE_MAXIMUMPAPERTOPMARGIN:
+ aSeqValues[nProperty] <<= m_nMaximumPaperTopMargin;
+ break;
+
+ case PROPERTYHANDLE_MAXIMUMPAPERBOTTOMMARGIN:
+ aSeqValues[nProperty] <<= m_nMaximumPaperBottomMargin;
+ break;
+
+ // primitives
+ case PROPERTYHANDLE_ANTIALIASING:
+ aSeqValues[nProperty] <<= m_bAntiAliasing;
+ break;
+
+ case PROPERTYHANDLE_SNAPHORVERLINESTODISCRETE:
+ aSeqValues[nProperty] <<= m_bSnapHorVerLinesToDiscrete;
+ break;
+
+ case PROPERTYHANDLE_SOLIDDRAGCREATE:
+ aSeqValues[nProperty] <<= m_bSolidDragCreate;
+ break;
+
+ case PROPERTYHANDLE_RENDERDECORATEDTEXTDIRECT:
+ aSeqValues[nProperty] <<= m_bRenderDecoratedTextDirect;
+ break;
+
+ case PROPERTYHANDLE_RENDERSIMPLETEXTDIRECT:
+ aSeqValues[nProperty] <<= m_bRenderSimpleTextDirect;
+ break;
+
+ case PROPERTYHANDLE_QUADRATIC3DRENDERLIMIT:
+ aSeqValues[nProperty] <<= m_nQuadratic3DRenderLimit;
+ break;
+
+ case PROPERTYHANDLE_QUADRATICFORMCONTROLRENDERLIMIT:
+ aSeqValues[nProperty] <<= m_nQuadraticFormControlRenderLimit;
+ break;
+
+ // #i97672# selection settings
+ case PROPERTYHANDLE_TRANSPARENTSELECTION:
+ aSeqValues[nProperty] <<= m_bTransparentSelection;
+ break;
+
+ case PROPERTYHANDLE_TRANSPARENTSELECTIONPERCENT:
+ aSeqValues[nProperty] <<= m_nTransparentSelectionPercent;
+ break;
+
+ case PROPERTYHANDLE_SELECTIONMAXIMUMLUMINANCEPERCENT:
+ aSeqValues[nProperty] <<= m_nSelectionMaximumLuminancePercent;
+ break;
+ }
+ }
+
+ PutProperties( aSeqNames, aSeqValues );
+}
+
+void SvtOptionsDrawinglayer_Impl::Notify( const css::uno::Sequence<OUString>& )
+{
+}
+// #i73602#
+
+// #i74769#, #i75172#
+
+// #i4219#
+
+// helper
+bool SvtOptionsDrawinglayer_Impl::IsAAPossibleOnThisSystem() const
+{
+ if(!m_bAllowAAChecked)
+ {
+ SvtOptionsDrawinglayer_Impl* pThat = const_cast< SvtOptionsDrawinglayer_Impl* >(this);
+ pThat->m_bAllowAAChecked = true;
+
+#ifdef _WIN32
+ // WIN32 uses GDIPlus with VCL for the first incarnation; this will be enhanced
+ // in the future to use canvases and the canvas renderer, thus an AA-abled
+ // canvas needs to be checked here in the future.
+ // Currently, just allow AA for WIN32
+#endif
+
+ // check XRenderExtension
+ if(m_bAllowAA && !Application::GetDefaultDevice()->SupportsOperation( OutDevSupportType::TransparentRect ))
+ {
+ pThat->m_bAllowAA = false;
+ }
+ }
+
+ return m_bAllowAA;
+}
+
+// primitives
+
+void SvtOptionsDrawinglayer_Impl::SetAntiAliasing( bool bState )
+{
+ if(m_bAntiAliasing != bState)
+ {
+ m_bAntiAliasing = bState;
+ SetModified();
+ }
+}
+
+// private method
+
+Sequence< OUString > SvtOptionsDrawinglayer_Impl::impl_GetPropertyNames()
+{
+ // Build list of configuration key names.
+ const OUString pProperties[] =
+ {
+ PROPERTYNAME_OVERLAYBUFFER ,
+ PROPERTYNAME_PAINTBUFFER ,
+ PROPERTYNAME_STRIPE_COLOR_A ,
+ PROPERTYNAME_STRIPE_COLOR_B ,
+ PROPERTYNAME_STRIPE_LENGTH ,
+
+ // #i73602#
+ PROPERTYNAME_OVERLAYBUFFER_CALC,
+ PROPERTYNAME_OVERLAYBUFFER_WRITER,
+ PROPERTYNAME_OVERLAYBUFFER_DRAWIMPRESS,
+
+ // #i74769#, #i75172#
+ PROPERTYNAME_PAINTBUFFER_CALC,
+ PROPERTYNAME_PAINTBUFFER_WRITER,
+ PROPERTYNAME_PAINTBUFFER_DRAWIMPRESS,
+
+ // #i4219#
+ PROPERTYNAME_MAXIMUMPAPERWIDTH,
+ PROPERTYNAME_MAXIMUMPAPERHEIGHT,
+ PROPERTYNAME_MAXIMUMPAPERLEFTMARGIN,
+ PROPERTYNAME_MAXIMUMPAPERRIGHTMARGIN,
+ PROPERTYNAME_MAXIMUMPAPERTOPMARGIN,
+ PROPERTYNAME_MAXIMUMPAPERBOTTOMMARGIN,
+
+ // primitives
+ PROPERTYNAME_ANTIALIASING,
+ PROPERTYNAME_SNAPHORVERLINESTODISCRETE,
+ PROPERTYNAME_SOLIDDRAGCREATE,
+ PROPERTYNAME_RENDERDECORATEDTEXTDIRECT,
+ PROPERTYNAME_RENDERSIMPLETEXTDIRECT,
+ PROPERTYNAME_QUADRATIC3DRENDERLIMIT,
+ PROPERTYNAME_QUADRATICFORMCONTROLRENDERLIMIT,
+
+ // #i97672# selection settings
+ PROPERTYNAME_TRANSPARENTSELECTION,
+ PROPERTYNAME_TRANSPARENTSELECTIONPERCENT,
+ PROPERTYNAME_SELECTIONMAXIMUMLUMINANCEPERCENT
+ };
+
+ // Initialize return sequence with these list ...
+ const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
+ // ... and return it.
+ return seqPropertyNames;
+}
+
+namespace {
+ //global
+ std::weak_ptr<SvtOptionsDrawinglayer_Impl> g_pOptionsDrawinglayer;
+}
+
+SvtOptionsDrawinglayer::SvtOptionsDrawinglayer()
+{
+ // Global access, must be guarded (multithreading!).
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ m_pImpl = g_pOptionsDrawinglayer.lock();
+ if( !m_pImpl )
+ {
+ m_pImpl = std::make_shared<SvtOptionsDrawinglayer_Impl>();
+ g_pOptionsDrawinglayer = m_pImpl;
+ }
+}
+
+SvtOptionsDrawinglayer::~SvtOptionsDrawinglayer()
+{
+ // Global access, must be guarded (multithreading!)
+ MutexGuard aGuard( GetOwnStaticMutex() );
+
+ m_pImpl.reset();
+}
+
+// public method
+
+bool SvtOptionsDrawinglayer::IsOverlayBuffer() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->IsOverlayBuffer();
+}
+
+// public method
+
+bool SvtOptionsDrawinglayer::IsPaintBuffer() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->IsPaintBuffer();
+}
+
+// public method
+
+Color SvtOptionsDrawinglayer::GetStripeColorA() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->GetStripeColorA();
+}
+
+// public method
+
+Color SvtOptionsDrawinglayer::GetStripeColorB() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->GetStripeColorB();
+}
+
+// public method
+
+sal_uInt16 SvtOptionsDrawinglayer::GetStripeLength() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->GetStripeLength();
+}
+
+// #i73602#
+bool SvtOptionsDrawinglayer::IsOverlayBuffer_Calc() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->IsOverlayBuffer_Calc();
+}
+
+bool SvtOptionsDrawinglayer::IsOverlayBuffer_Writer() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->IsOverlayBuffer_Writer();
+}
+
+bool SvtOptionsDrawinglayer::IsOverlayBuffer_DrawImpress() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->IsOverlayBuffer_DrawImpress();
+}
+
+// #i74769#, #i75172#
+bool SvtOptionsDrawinglayer::IsPaintBuffer_Calc() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->IsPaintBuffer_Calc();
+}
+
+bool SvtOptionsDrawinglayer::IsPaintBuffer_Writer() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->IsPaintBuffer_Writer();
+}
+
+bool SvtOptionsDrawinglayer::IsPaintBuffer_DrawImpress() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->IsPaintBuffer_DrawImpress();
+}
+
+// #i4219#
+sal_uInt32 SvtOptionsDrawinglayer::GetMaximumPaperWidth() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->GetMaximumPaperWidth();
+}
+
+sal_uInt32 SvtOptionsDrawinglayer::GetMaximumPaperHeight() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->GetMaximumPaperHeight();
+}
+
+sal_uInt32 SvtOptionsDrawinglayer::GetMaximumPaperLeftMargin() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->GetMaximumPaperLeftMargin();
+}
+
+sal_uInt32 SvtOptionsDrawinglayer::GetMaximumPaperRightMargin() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->GetMaximumPaperRightMargin();
+}
+
+sal_uInt32 SvtOptionsDrawinglayer::GetMaximumPaperTopMargin() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->GetMaximumPaperTopMargin();
+}
+
+sal_uInt32 SvtOptionsDrawinglayer::GetMaximumPaperBottomMargin() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->GetMaximumPaperBottomMargin();
+}
+
+// helper
+bool SvtOptionsDrawinglayer::IsAAPossibleOnThisSystem() const
+{
+ return m_pImpl->IsAAPossibleOnThisSystem();
+}
+
+// primitives
+bool SvtOptionsDrawinglayer::IsAntiAliasing() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->IsAntiAliasing() && IsAAPossibleOnThisSystem();
+}
+
+bool SvtOptionsDrawinglayer::IsSnapHorVerLinesToDiscrete() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->IsAntiAliasing() && m_pImpl->IsSnapHorVerLinesToDiscrete();
+}
+
+bool SvtOptionsDrawinglayer::IsSolidDragCreate() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->IsSolidDragCreate();
+}
+
+bool SvtOptionsDrawinglayer::IsRenderDecoratedTextDirect() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->IsRenderDecoratedTextDirect();
+}
+
+bool SvtOptionsDrawinglayer::IsRenderSimpleTextDirect() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->IsRenderSimpleTextDirect();
+}
+
+sal_uInt32 SvtOptionsDrawinglayer::GetQuadratic3DRenderLimit() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->GetQuadratic3DRenderLimit();
+}
+
+sal_uInt32 SvtOptionsDrawinglayer::GetQuadraticFormControlRenderLimit() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->GetQuadraticFormControlRenderLimit();
+}
+
+void SvtOptionsDrawinglayer::SetAntiAliasing( bool bState )
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ m_pImpl->SetAntiAliasing( bState );
+}
+
+// #i97672# selection settings
+bool SvtOptionsDrawinglayer::IsTransparentSelection() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return m_pImpl->IsTransparentSelection();
+}
+
+sal_uInt16 SvtOptionsDrawinglayer::GetTransparentSelectionPercent() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ sal_uInt16 aRetval(m_pImpl->GetTransparentSelectionPercent());
+
+ // crop to range [10% .. 90%]
+ if(aRetval < 10)
+ {
+ aRetval = 10;
+ }
+
+ if(aRetval > 90)
+ {
+ aRetval = 90;
+ }
+
+ return aRetval;
+}
+
+sal_uInt16 SvtOptionsDrawinglayer::GetSelectionMaximumLuminancePercent() const
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ sal_uInt16 aRetval(m_pImpl->GetSelectionMaximumLuminancePercent());
+
+ // crop to range [0% .. 100%]
+ if(aRetval > 90)
+ {
+ aRetval = 90;
+ }
+
+ return aRetval;
+}
+
+Color SvtOptionsDrawinglayer::getHilightColor() const
+{
+ Color aRetval(Application::GetSettings().GetStyleSettings().GetHighlightColor());
+ const basegfx::BColor aSelection(aRetval.getBColor());
+ const double fLuminance(aSelection.luminance());
+ const double fMaxLum(GetSelectionMaximumLuminancePercent() / 100.0);
+
+ if(fLuminance > fMaxLum)
+ {
+ const double fFactor(fMaxLum / fLuminance);
+ const basegfx::BColor aNewSelection(
+ aSelection.getRed() * fFactor,
+ aSelection.getGreen() * fFactor,
+ aSelection.getBlue() * fFactor);
+
+ aRetval = Color(aNewSelection);
+ }
+
+ return aRetval;
+}
+
+namespace
+{
+ class theOptionsDrawinglayerMutex : public rtl::Static<osl::Mutex, theOptionsDrawinglayerMutex>{};
+}
+
+// private method
+
+Mutex& SvtOptionsDrawinglayer::GetOwnStaticMutex()
+{
+ return theOptionsDrawinglayerMutex::get();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/config/printoptions.cxx b/svtools/source/config/printoptions.cxx
new file mode 100644
index 000000000..4a783863e
--- /dev/null
+++ b/svtools/source/config/printoptions.cxx
@@ -0,0 +1,510 @@
+/* -*- 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 <svtools/printoptions.hxx>
+#include <vcl/print.hxx>
+#include <com/sun/star/uno/Any.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+
+#include <comphelper/configurationhelper.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <officecfg/Office/Common.hxx>
+
+#include "itemholder2.hxx"
+
+#include <sal/macros.h>
+#include <tools/diagnose_ex.h>
+
+static const sal_uInt16 aDPIArray[] = { 72, 96, 150, 200, 300, 600 };
+
+#define DPI_COUNT (SAL_N_ELEMENTS(aDPIArray))
+
+#define ROOTNODE_START "Office.Common/Print/Option"
+#define ROOTNODE_PRINTOPTION "org.openoffice.Office.Common/Print/Option"
+
+#define PROPERTYNAME_REDUCETRANSPARENCY "ReduceTransparency"
+#define PROPERTYNAME_REDUCEDTRANSPARENCYMODE "ReducedTransparencyMode"
+#define PROPERTYNAME_REDUCEGRADIENTS "ReduceGradients"
+#define PROPERTYNAME_REDUCEDGRADIENTMODE "ReducedGradientMode"
+#define PROPERTYNAME_REDUCEDGRADIENTSTEPCOUNT "ReducedGradientStepCount"
+#define PROPERTYNAME_REDUCEBITMAPS "ReduceBitmaps"
+#define PROPERTYNAME_REDUCEDBITMAPMODE "ReducedBitmapMode"
+#define PROPERTYNAME_REDUCEDBITMAPRESOLUTION "ReducedBitmapResolution"
+#define PROPERTYNAME_REDUCEDBITMAPINCLUDESTRANSPARENCY "ReducedBitmapIncludesTransparency"
+#define PROPERTYNAME_CONVERTTOGREYSCALES "ConvertToGreyscales"
+#define PROPERTYNAME_PDFASSTANDARDPRINTJOBFORMAT "PDFAsStandardPrintJobFormat"
+
+using namespace ::utl;
+using namespace ::osl;
+using namespace ::com::sun::star::uno;
+
+static SvtPrintOptions_Impl* pPrinterOptionsDataContainer = nullptr;
+static SvtPrintOptions_Impl* pPrintFileOptionsDataContainer = nullptr;
+
+SvtPrintOptions_Impl* SvtPrinterOptions::m_pStaticDataContainer = nullptr;
+sal_Int32 SvtPrinterOptions::m_nRefCount = 0;
+
+SvtPrintOptions_Impl* SvtPrintFileOptions::m_pStaticDataContainer = nullptr;
+sal_Int32 SvtPrintFileOptions::m_nRefCount = 0;
+
+class SvtPrintOptions_Impl
+{
+public:
+ explicit SvtPrintOptions_Impl( const OUString& rConfigRoot );
+ ~SvtPrintOptions_Impl();
+
+ void SetReduceTransparency( bool bState ) ;
+ void SetReducedTransparencyMode( sal_Int16 nMode ) ;
+ void SetReduceGradients( bool bState ) ;
+ void SetReducedGradientMode( sal_Int16 nMode ) ;
+ void SetReducedGradientStepCount( sal_Int16 nStepCount ) ;
+ void SetReduceBitmaps( bool bState ) ;
+ void SetReducedBitmapMode( sal_Int16 nMode ) ;
+ void SetReducedBitmapResolution( sal_Int16 nResolution ) ;
+ void SetReducedBitmapIncludesTransparency( bool bState ) ;
+ void SetConvertToGreyscales( bool bState ) ;
+ void SetPDFAsStandardPrintJobFormat( bool bState ) ;
+
+
+// private API
+
+
+private:
+ void impl_setValue (const OUString& sProp, bool bNew );
+ void impl_setValue (const OUString& sProp, sal_Int16 nNew );
+
+
+// private member
+
+
+private:
+ css::uno::Reference< css::container::XNameAccess > m_xCfg;
+ css::uno::Reference< css::container::XNameAccess > m_xNode;
+};
+
+SvtPrintOptions_Impl::SvtPrintOptions_Impl(const OUString& rConfigRoot)
+{
+ try
+ {
+ m_xCfg.set(
+ ::comphelper::ConfigurationHelper::openConfig(
+ comphelper::getProcessComponentContext(),
+ ROOTNODE_PRINTOPTION,
+ ::comphelper::EConfigurationModes::Standard),
+ css::uno::UNO_QUERY);
+
+ if (m_xCfg.is())
+ {
+ m_xCfg->getByName(rConfigRoot.copy(rConfigRoot.lastIndexOf('/')+1)) >>= m_xNode;
+ }
+ }
+ catch (const css::uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("svtools.config");
+ m_xNode.clear();
+ m_xCfg.clear();
+ }
+}
+
+void SvtPrintOptions_Impl::SetReduceTransparency(bool bState)
+{
+ impl_setValue(PROPERTYNAME_REDUCETRANSPARENCY, bState);
+}
+
+void SvtPrintOptions_Impl::SetReducedTransparencyMode(sal_Int16 nMode)
+{
+ impl_setValue(PROPERTYNAME_REDUCEDTRANSPARENCYMODE, nMode);
+}
+
+void SvtPrintOptions_Impl::SetReduceGradients(bool bState)
+{
+ impl_setValue(PROPERTYNAME_REDUCEGRADIENTS, bState);
+}
+
+void SvtPrintOptions_Impl::SetReducedGradientMode(sal_Int16 nMode)
+{
+ impl_setValue(PROPERTYNAME_REDUCEDGRADIENTMODE, nMode);
+}
+
+void SvtPrintOptions_Impl::SetReducedGradientStepCount(sal_Int16 nStepCount )
+{
+ impl_setValue(PROPERTYNAME_REDUCEDGRADIENTSTEPCOUNT, nStepCount);
+}
+
+void SvtPrintOptions_Impl::SetReduceBitmaps(bool bState )
+{
+ impl_setValue(PROPERTYNAME_REDUCEBITMAPS, bState);
+}
+
+void SvtPrintOptions_Impl::SetReducedBitmapMode(sal_Int16 nMode )
+{
+ impl_setValue(PROPERTYNAME_REDUCEDBITMAPMODE, nMode);
+}
+
+void SvtPrintOptions_Impl::SetReducedBitmapResolution(sal_Int16 nResolution )
+{
+ impl_setValue(PROPERTYNAME_REDUCEDBITMAPRESOLUTION, nResolution);
+}
+
+void SvtPrintOptions_Impl::SetReducedBitmapIncludesTransparency(bool bState )
+{
+ impl_setValue(PROPERTYNAME_REDUCEDBITMAPINCLUDESTRANSPARENCY, bState);
+}
+
+void SvtPrintOptions_Impl::SetConvertToGreyscales(bool bState)
+{
+ impl_setValue(PROPERTYNAME_CONVERTTOGREYSCALES, bState);
+}
+
+void SvtPrintOptions_Impl::SetPDFAsStandardPrintJobFormat(bool bState)
+{
+ impl_setValue(PROPERTYNAME_PDFASSTANDARDPRINTJOBFORMAT, bState);
+}
+
+SvtPrintOptions_Impl::~SvtPrintOptions_Impl()
+{
+ m_xNode.clear();
+ m_xCfg.clear();
+}
+
+void SvtPrintOptions_Impl::impl_setValue (const OUString& sProp, bool bNew )
+{
+ try
+ {
+ if ( ! m_xNode.is())
+ return;
+
+ css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
+ if ( ! xSet.is())
+ return;
+
+ bool bOld = ! bNew;
+ if ( ! (xSet->getPropertyValue(sProp) >>= bOld))
+ return;
+
+ if (bOld != bNew)
+ {
+ xSet->setPropertyValue(sProp, css::uno::makeAny(bNew));
+ ::comphelper::ConfigurationHelper::flush(m_xCfg);
+ }
+ }
+ catch(const css::uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("svtools.config");
+ }
+}
+
+void SvtPrintOptions_Impl::impl_setValue (const OUString& sProp,
+ ::sal_Int16 nNew )
+{
+ try
+ {
+ if ( ! m_xNode.is())
+ return;
+
+ css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
+ if ( ! xSet.is())
+ return;
+
+ ::sal_Int16 nOld = nNew+1;
+ if ( ! (xSet->getPropertyValue(sProp) >>= nOld))
+ return;
+
+ if (nOld != nNew)
+ {
+ xSet->setPropertyValue(sProp, css::uno::makeAny(nNew));
+ ::comphelper::ConfigurationHelper::flush(m_xCfg);
+ }
+ }
+ catch(const css::uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("svtools.config");
+ }
+}
+
+SvtBasePrintOptions::SvtBasePrintOptions()
+ : m_pDataContainer(nullptr)
+{
+}
+
+SvtBasePrintOptions::~SvtBasePrintOptions()
+{
+}
+
+Mutex& SvtBasePrintOptions::GetOwnStaticMutex()
+{
+ static Mutex ourMutex;
+
+ return ourMutex;
+}
+
+bool SvtBasePrintOptions::IsReduceTransparency()
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return officecfg::Office::Common::Print::Option::Printer::ReduceTransparency::get();
+}
+
+sal_Int16 SvtBasePrintOptions::GetReducedTransparencyMode()
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return officecfg::Office::Common::Print::Option::Printer::ReducedTransparencyMode::get();
+}
+
+bool SvtBasePrintOptions::IsReduceGradients()
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return officecfg::Office::Common::Print::Option::Printer::ReduceGradients::get();
+}
+
+sal_Int16 SvtBasePrintOptions::GetReducedGradientMode()
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return officecfg::Office::Common::Print::Option::Printer::ReducedGradientMode::get();
+}
+
+sal_Int16 SvtBasePrintOptions::GetReducedGradientStepCount()
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return officecfg::Office::Common::Print::Option::Printer::ReducedGradientStepCount::get();
+}
+
+bool SvtBasePrintOptions::IsReduceBitmaps()
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return officecfg::Office::Common::Print::Option::Printer::ReduceBitmaps::get();
+}
+
+sal_Int16 SvtBasePrintOptions::GetReducedBitmapMode()
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return officecfg::Office::Common::Print::Option::Printer::ReducedBitmapMode::get();
+}
+
+sal_Int16 SvtBasePrintOptions::GetReducedBitmapResolution()
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return officecfg::Office::Common::Print::Option::Printer::ReducedBitmapResolution::get();
+}
+
+bool SvtBasePrintOptions::IsReducedBitmapIncludesTransparency()
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return officecfg::Office::Common::Print::Option::Printer::ReducedBitmapIncludesTransparency::get();
+}
+
+bool SvtBasePrintOptions::IsConvertToGreyscales()
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return officecfg::Office::Common::Print::Option::Printer::ConvertToGreyscales::get();
+}
+
+bool SvtBasePrintOptions::IsPDFAsStandardPrintJobFormat()
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ return officecfg::Office::Common::Print::Option::Printer::PDFAsStandardPrintJobFormat::get();
+}
+
+void SvtBasePrintOptions::SetReduceTransparency( bool bState )
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ m_pDataContainer->SetReduceTransparency( bState ) ;
+}
+
+void SvtBasePrintOptions::SetReducedTransparencyMode( sal_Int16 nMode )
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ m_pDataContainer->SetReducedTransparencyMode( nMode );
+}
+
+void SvtBasePrintOptions::SetReduceGradients( bool bState )
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ m_pDataContainer->SetReduceGradients( bState );
+}
+
+void SvtBasePrintOptions::SetReducedGradientMode( sal_Int16 nMode )
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ m_pDataContainer->SetReducedGradientMode( nMode );
+}
+
+void SvtBasePrintOptions::SetReducedGradientStepCount( sal_Int16 nStepCount )
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ m_pDataContainer->SetReducedGradientStepCount( nStepCount );
+}
+
+void SvtBasePrintOptions::SetReduceBitmaps( bool bState )
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ m_pDataContainer->SetReduceBitmaps( bState );
+}
+
+void SvtBasePrintOptions::SetReducedBitmapMode( sal_Int16 nMode )
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ m_pDataContainer->SetReducedBitmapMode( nMode );
+}
+
+void SvtBasePrintOptions::SetReducedBitmapResolution( sal_Int16 nResolution )
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ m_pDataContainer->SetReducedBitmapResolution( nResolution );
+}
+
+void SvtBasePrintOptions::SetReducedBitmapIncludesTransparency( bool bState )
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ m_pDataContainer->SetReducedBitmapIncludesTransparency( bState );
+}
+
+void SvtBasePrintOptions::SetConvertToGreyscales( bool bState )
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ m_pDataContainer->SetConvertToGreyscales( bState );
+}
+
+void SvtBasePrintOptions::SetPDFAsStandardPrintJobFormat( bool bState )
+{
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ m_pDataContainer->SetPDFAsStandardPrintJobFormat( bState );
+}
+
+void SvtBasePrintOptions::GetPrinterOptions( PrinterOptions& rOptions )
+{
+ rOptions.SetReduceTransparency( IsReduceTransparency() );
+ rOptions.SetReducedTransparencyMode( static_cast<PrinterTransparencyMode>(GetReducedTransparencyMode()) );
+ rOptions.SetReduceGradients( IsReduceGradients() );
+ rOptions.SetReducedGradientMode( static_cast<PrinterGradientMode>(GetReducedGradientMode()) );
+ rOptions.SetReducedGradientStepCount( GetReducedGradientStepCount() );
+ rOptions.SetReduceBitmaps( IsReduceBitmaps() );
+ rOptions.SetReducedBitmapMode( static_cast<PrinterBitmapMode>(GetReducedBitmapMode()) );
+ rOptions.SetReducedBitmapResolution( aDPIArray[ std::min( static_cast<sal_uInt16>(GetReducedBitmapResolution()), sal_uInt16( DPI_COUNT - 1 ) ) ] );
+ rOptions.SetReducedBitmapIncludesTransparency( IsReducedBitmapIncludesTransparency() );
+ rOptions.SetConvertToGreyscales( IsConvertToGreyscales() );
+ rOptions.SetPDFAsStandardPrintJobFormat( IsPDFAsStandardPrintJobFormat() );
+}
+
+void SvtBasePrintOptions::SetPrinterOptions( const PrinterOptions& rOptions )
+{
+ SetReduceTransparency( rOptions.IsReduceTransparency() );
+ SetReducedTransparencyMode(
+ sal::static_int_cast< sal_Int16 >(
+ rOptions.GetReducedTransparencyMode()) );
+ SetReduceGradients( rOptions.IsReduceGradients() );
+ SetReducedGradientMode(
+ sal::static_int_cast< sal_Int16 >(rOptions.GetReducedGradientMode()) );
+ SetReducedGradientStepCount( rOptions.GetReducedGradientStepCount() );
+ SetReduceBitmaps( rOptions.IsReduceBitmaps() );
+ SetReducedBitmapMode(
+ sal::static_int_cast< sal_Int16 >(rOptions.GetReducedBitmapMode()) );
+ SetReducedBitmapIncludesTransparency( rOptions.IsReducedBitmapIncludesTransparency() );
+ SetConvertToGreyscales( rOptions.IsConvertToGreyscales() );
+ SetPDFAsStandardPrintJobFormat( rOptions.IsPDFAsStandardPrintJobFormat() );
+
+ const sal_uInt16 nDPI = rOptions.GetReducedBitmapResolution();
+
+ if( nDPI < aDPIArray[ 0 ] )
+ SetReducedBitmapResolution( 0 );
+ else
+ {
+ for( long i = DPI_COUNT - 1; i >= 0; i-- )
+ {
+ if( nDPI >= aDPIArray[ i ] )
+ {
+ SetReducedBitmapResolution( static_cast<sal_Int16>(i) );
+ i = -1;
+ }
+ }
+ }
+}
+
+SvtPrinterOptions::SvtPrinterOptions()
+{
+ // Global access, must be guarded (multithreading!).
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Increase our refcount ...
+ ++m_nRefCount;
+ // ... and initialize our data container only if it not already!
+ if( m_pStaticDataContainer == nullptr )
+ {
+ OUString aRootPath = ROOTNODE_START "/Printer";
+ m_pStaticDataContainer = new SvtPrintOptions_Impl( aRootPath );
+ pPrinterOptionsDataContainer = m_pStaticDataContainer;
+ svtools::ItemHolder2::holdConfigItem(EItem::PrintOptions);
+ }
+
+ SetDataContainer( m_pStaticDataContainer );
+}
+
+SvtPrinterOptions::~SvtPrinterOptions()
+{
+ // Global access, must be guarded (multithreading!)
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Decrease our refcount.
+ --m_nRefCount;
+ // If last instance was deleted ...
+ // we must destroy our static data container!
+ if( m_nRefCount <= 0 )
+ {
+ delete m_pStaticDataContainer;
+ m_pStaticDataContainer = nullptr;
+ pPrinterOptionsDataContainer = nullptr;
+ }
+}
+
+SvtPrintFileOptions::SvtPrintFileOptions()
+{
+ // Global access, must be guarded (multithreading!).
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Increase our refcount ...
+ ++m_nRefCount;
+ // ... and initialize our data container only if it not already!
+ if( m_pStaticDataContainer == nullptr )
+ {
+ OUString aRootPath = ROOTNODE_START "/File";
+ m_pStaticDataContainer = new SvtPrintOptions_Impl( aRootPath );
+ pPrintFileOptionsDataContainer = m_pStaticDataContainer;
+
+ svtools::ItemHolder2::holdConfigItem(EItem::PrintFileOptions);
+ }
+
+ SetDataContainer( m_pStaticDataContainer );
+}
+
+SvtPrintFileOptions::~SvtPrintFileOptions()
+{
+ // Global access, must be guarded (multithreading!)
+ MutexGuard aGuard( GetOwnStaticMutex() );
+ // Decrease our refcount.
+ --m_nRefCount;
+ // If last instance was deleted ...
+ // we must destroy our static data container!
+ if( m_nRefCount <= 0 )
+ {
+ delete m_pStaticDataContainer;
+ m_pStaticDataContainer = nullptr;
+ pPrintFileOptionsDataContainer = nullptr;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/config/slidesorterbaropt.cxx b/svtools/source/config/slidesorterbaropt.cxx
new file mode 100644
index 000000000..770876048
--- /dev/null
+++ b/svtools/source/config/slidesorterbaropt.cxx
@@ -0,0 +1,431 @@
+/* -*- 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 <svtools/slidesorterbaropt.hxx>
+#include <unotools/configitem.hxx>
+#include <tools/debug.hxx>
+#include <osl/diagnose.h>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <comphelper/lok.hxx>
+#include <comphelper/sequence.hxx>
+#include <rtl/instance.hxx>
+
+using namespace ::utl;
+using namespace ::osl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star;
+
+#define ROOTNODE_SLIDESORTERBAR "Office.Impress/MultiPaneGUI/SlideSorterBar/Visible"
+
+#define PROPERTYNAME_VISIBLE_IMPRESSVIEW OUString("ImpressView")
+#define PROPERTYHANDLE_VISIBLE_IMPRESSVIEW 0
+#define PROPERTYNAME_VISIBLE_OUTLINEVIEW OUString("OutlineView")
+#define PROPERTYHANDLE_VISIBLE_OUTLINEVIEW 1
+#define PROPERTYNAME_VISIBLE_NOTESVIEW OUString("NotesView")
+#define PROPERTYHANDLE_VISIBLE_NOTESVIEW 2
+#define PROPERTYNAME_VISIBLE_HANDOUTVIEW OUString("HandoutView")
+#define PROPERTYHANDLE_VISIBLE_HANDOUTVIEW 3
+#define PROPERTYNAME_VISIBLE_SLIDESORTERVIEW OUString("SlideSorterView")
+#define PROPERTYHANDLE_VISIBLE_SLIDESORTERVIEW 4
+#define PROPERTYNAME_VISIBLE_DRAWVIEW OUString("DrawView")
+#define PROPERTYHANDLE_VISIBLE_DRAWVIEW 5
+
+class SvtSlideSorterBarOptions_Impl : public ConfigItem
+{
+ Sequence< OUString > m_seqPropertyNames;
+
+ public:
+
+ SvtSlideSorterBarOptions_Impl();
+ ~SvtSlideSorterBarOptions_Impl() override;
+
+ /** called for notify of configmanager
+
+ This method is called from the ConfigManager before the application ends or from the
+ PropertyChangeListener if the sub tree broadcasts changes. You must update your
+ internal values.
+
+ \sa baseclass ConfigItem
+ \param[in,out] seqPropertyNames is the list of properties which should be updated.
+ */
+ virtual void Notify( const Sequence< OUString >& seqPropertyNames ) override;
+
+ /**
+ loads required data from the configuration. It's called in the constructor to
+ read all entries and form ::Notify to re-read changed setting
+ */
+ void Load( const Sequence< OUString >& rPropertyNames );
+
+ // public interface
+ bool m_bVisibleImpressView;
+ bool m_bVisibleOutlineView;
+ bool m_bVisibleNotesView;
+ bool m_bVisibleHandoutView;
+ bool m_bVisibleSlideSorterView;
+ bool m_bVisibleDrawView;
+
+ private:
+ virtual void ImplCommit() final override;
+
+ /** return list of key names of our configuration management which represent our module tree
+
+ This method returns a static const list of key names. We need it to get needed values from
+ configuration management.
+
+ \return A list of needed configuration keys is returned.
+ */
+ static Sequence< OUString > GetPropertyNames();
+
+ void SetVisibleViewImpl( bool& bVisibleView, bool bVisible );
+
+ public:
+ void SetVisibleImpressView( bool bVisible)
+ { SetVisibleViewImpl( m_bVisibleImpressView, bVisible ); }
+
+ void SetVisibleOutlineView( bool bVisible)
+ { SetVisibleViewImpl( m_bVisibleOutlineView, bVisible ); }
+
+ void SetVisibleNotesView( bool bVisible)
+ { SetVisibleViewImpl( m_bVisibleNotesView, bVisible ); }
+
+ void SetVisibleHandoutView( bool bVisible)
+ { SetVisibleViewImpl( m_bVisibleHandoutView, bVisible ); }
+
+ void SetVisibleSlideSorterView( bool bVisible)
+ { SetVisibleViewImpl( m_bVisibleSlideSorterView, bVisible ); }
+
+ void SetVisibleDrawView( bool bVisible)
+ { SetVisibleViewImpl( m_bVisibleDrawView, bVisible ); }
+
+};
+
+SvtSlideSorterBarOptions_Impl::SvtSlideSorterBarOptions_Impl()
+ // Init baseclasses first
+ : ConfigItem( ROOTNODE_SLIDESORTERBAR )
+ , m_seqPropertyNames(GetPropertyNames())
+ , m_bVisibleImpressView( false )
+ , m_bVisibleOutlineView( false )
+ , m_bVisibleNotesView( false )
+ , m_bVisibleHandoutView( false )
+ , m_bVisibleSlideSorterView( false )
+ , m_bVisibleDrawView( false )
+
+{
+ // Use our static list of configuration keys to get his values.
+ Sequence< Any > seqValues = GetProperties( m_seqPropertyNames );
+
+ // Safe impossible cases.
+ // We need values from ALL configuration keys.
+ // Follow assignment use order of values in relation to our list of key names!
+ DBG_ASSERT( !(m_seqPropertyNames.getLength()!=seqValues.getLength()),
+ "SvtSlideSorterBarOptions_Impl::SvtSlideSorterBarOptions_Impl()\nI miss some values of configuration keys!\n" );
+
+ // Copy values from list in right order to our internal member.
+ for( sal_Int32 nProperty=0; nProperty<seqValues.getLength(); ++nProperty )
+ {
+ if (!seqValues[nProperty].hasValue())
+ continue;
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_VISIBLE_IMPRESSVIEW :
+ {
+ if( !(seqValues[nProperty] >>= m_bVisibleImpressView) )
+ OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleImpressView\"!" );
+ break;
+ }
+ case PROPERTYHANDLE_VISIBLE_OUTLINEVIEW :
+ {
+ if( !(seqValues[nProperty] >>= m_bVisibleOutlineView) )
+ OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleOutlineView\"!" );
+ break;
+ }
+ case PROPERTYHANDLE_VISIBLE_NOTESVIEW :
+ {
+ if( !(seqValues[nProperty] >>= m_bVisibleNotesView) )
+ OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleNotesView\"!" );
+ break;
+ }
+ case PROPERTYHANDLE_VISIBLE_HANDOUTVIEW :
+ {
+ if( !(seqValues[nProperty] >>= m_bVisibleHandoutView) )
+ OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleHandoutView\"!" );
+ break;
+ }
+ case PROPERTYHANDLE_VISIBLE_SLIDESORTERVIEW :
+ {
+ if( !(seqValues[nProperty] >>= m_bVisibleSlideSorterView) )
+ OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleSlideSorterView\"!" );
+ break;
+ }
+ case PROPERTYHANDLE_VISIBLE_DRAWVIEW :
+ {
+ if( !(seqValues[nProperty] >>= m_bVisibleDrawView) )
+ OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleDrawView\"!" );
+ break;
+ }
+ }
+ }
+
+ // Enable notification mechanism of our baseclass.
+ // We need it to get information about changes outside these class on our used configuration keys!
+ EnableNotification( m_seqPropertyNames );
+}
+
+SvtSlideSorterBarOptions_Impl::~SvtSlideSorterBarOptions_Impl()
+{
+ if (IsModified())
+ Commit();
+}
+
+void SvtSlideSorterBarOptions_Impl::Load( const Sequence< OUString >& rPropertyNames )
+{
+ const uno::Sequence< OUString> aInternalPropertyNames( GetPropertyNames());
+ Sequence< Any > seqValues = GetProperties( rPropertyNames );
+
+ // Safe impossible cases.
+ // We need values from ALL configuration keys.
+ // Follow assignment use order of values in relation to our list of key names!
+ DBG_ASSERT( !(rPropertyNames.getLength()!=seqValues.getLength()),
+ "SvtSlideSorterBarOptions_Impl::SvtSlideSorterBarOptions_Impl()\nI miss some values of configuration keys!\n" );
+
+ // Copy values from list in right order to our internal member.
+ for( sal_Int32 nProperty=0; nProperty<seqValues.getLength(); ++nProperty )
+ {
+ if (!seqValues[nProperty].hasValue())
+ continue;
+ switch( comphelper::findValue(aInternalPropertyNames, rPropertyNames[nProperty]) )
+ {
+ case PROPERTYHANDLE_VISIBLE_IMPRESSVIEW:
+ {
+ if( !(seqValues[nProperty] >>= m_bVisibleImpressView) )
+ OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleImpressView\"!" );
+ }
+ break;
+ case PROPERTYHANDLE_VISIBLE_OUTLINEVIEW :
+ {
+ if( !(seqValues[nProperty] >>= m_bVisibleOutlineView) )
+ OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleOutlineView\"!" );
+ }
+ break;
+ case PROPERTYHANDLE_VISIBLE_NOTESVIEW :
+ {
+ if( !(seqValues[nProperty] >>= m_bVisibleNotesView) )
+ OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleNotesView\"!" );
+ }
+ break;
+ case PROPERTYHANDLE_VISIBLE_HANDOUTVIEW :
+ {
+ if( !(seqValues[nProperty] >>= m_bVisibleHandoutView) )
+ OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleHandoutView\"!" );
+ }
+ break;
+ case PROPERTYHANDLE_VISIBLE_SLIDESORTERVIEW :
+ {
+ if( !(seqValues[nProperty] >>= m_bVisibleSlideSorterView) )
+ OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleSlideSorterView\"!" );
+ }
+ break;
+
+ case PROPERTYHANDLE_VISIBLE_DRAWVIEW :
+ {
+ if( !(seqValues[nProperty] >>= m_bVisibleDrawView) )
+ OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleDrawView\"!" );
+ }
+ break;
+ }
+ }
+}
+
+void SvtSlideSorterBarOptions_Impl::Notify( const Sequence< OUString >& rPropertyNames )
+{
+ Load( rPropertyNames );
+}
+
+void SvtSlideSorterBarOptions_Impl::ImplCommit()
+{
+ // Get names of supported properties, create a list for values and copy current values to it.
+ sal_Int32 nCount = m_seqPropertyNames.getLength();
+ Sequence< Any > seqValues ( nCount );
+ for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
+ {
+ switch( nProperty )
+ {
+ case PROPERTYHANDLE_VISIBLE_IMPRESSVIEW:
+ {
+ seqValues[nProperty] <<= m_bVisibleImpressView;
+ break;
+ }
+ case PROPERTYHANDLE_VISIBLE_OUTLINEVIEW:
+ {
+ seqValues[nProperty] <<= m_bVisibleOutlineView;
+ break;
+ }
+ case PROPERTYHANDLE_VISIBLE_NOTESVIEW:
+ {
+ seqValues[nProperty] <<= m_bVisibleNotesView;
+ break;
+ }
+ case PROPERTYHANDLE_VISIBLE_HANDOUTVIEW:
+ {
+ seqValues[nProperty] <<= m_bVisibleHandoutView;
+ break;
+ }
+ case PROPERTYHANDLE_VISIBLE_SLIDESORTERVIEW:
+ {
+ seqValues[nProperty] <<= m_bVisibleSlideSorterView;
+ break;
+ }
+ case PROPERTYHANDLE_VISIBLE_DRAWVIEW:
+ {
+ seqValues[nProperty] <<= m_bVisibleDrawView;
+ break;
+ }
+
+ }
+ }
+ // Set properties in configuration.
+ PutProperties( m_seqPropertyNames, seqValues );
+}
+
+Sequence< OUString > SvtSlideSorterBarOptions_Impl::GetPropertyNames()
+{
+ // Build list of configuration key names.
+ const OUString pProperties[] =
+ {
+ PROPERTYNAME_VISIBLE_IMPRESSVIEW,
+ PROPERTYNAME_VISIBLE_OUTLINEVIEW,
+ PROPERTYNAME_VISIBLE_NOTESVIEW,
+ PROPERTYNAME_VISIBLE_HANDOUTVIEW,
+ PROPERTYNAME_VISIBLE_SLIDESORTERVIEW,
+ PROPERTYNAME_VISIBLE_DRAWVIEW,
+ };
+
+ // Initialize return sequence with these list and run
+ return Sequence< OUString >( pProperties, SAL_N_ELEMENTS( pProperties ) );
+}
+
+void SvtSlideSorterBarOptions_Impl::SetVisibleViewImpl( bool& bVisibleView, bool bVisible )
+{
+ if( bVisibleView != bVisible )
+ {
+ bVisibleView = bVisible;
+ SetModified();
+ }
+}
+
+namespace {
+ std::weak_ptr<SvtSlideSorterBarOptions_Impl> g_pSlideSorterBarOptions;
+}
+
+SvtSlideSorterBarOptions::SvtSlideSorterBarOptions()
+{
+ // Global access, must be guarded (multithreading!).
+ MutexGuard aGuard( GetInitMutex() );
+
+ m_pImpl = g_pSlideSorterBarOptions.lock();
+ if( !m_pImpl )
+ {
+ m_pImpl = std::make_shared<SvtSlideSorterBarOptions_Impl>();
+ g_pSlideSorterBarOptions = m_pImpl;
+ }
+}
+
+SvtSlideSorterBarOptions::~SvtSlideSorterBarOptions()
+{
+ // Global access, must be guarded (multithreading!)
+ MutexGuard aGuard( GetInitMutex() );
+
+ m_pImpl.reset();
+}
+
+bool SvtSlideSorterBarOptions::GetVisibleImpressView() const
+{
+ static const bool bRunningUnitTest = getenv("LO_TESTNAME");
+ return m_pImpl->m_bVisibleImpressView && (!bRunningUnitTest || !comphelper::LibreOfficeKit::isActive());
+}
+
+void SvtSlideSorterBarOptions::SetVisibleImpressView(bool bVisible)
+{
+ m_pImpl->SetVisibleImpressView( bVisible );
+}
+
+bool SvtSlideSorterBarOptions::GetVisibleOutlineView() const
+{
+ return m_pImpl->m_bVisibleOutlineView;
+}
+
+void SvtSlideSorterBarOptions::SetVisibleOutlineView(bool bVisible)
+{
+ m_pImpl->SetVisibleOutlineView( bVisible );
+}
+
+bool SvtSlideSorterBarOptions::GetVisibleNotesView() const
+{
+ return m_pImpl->m_bVisibleNotesView;
+}
+
+void SvtSlideSorterBarOptions::SetVisibleNotesView(bool bVisible)
+{
+ m_pImpl->SetVisibleNotesView( bVisible );
+}
+
+bool SvtSlideSorterBarOptions::GetVisibleHandoutView() const
+{
+ return m_pImpl->m_bVisibleHandoutView;
+}
+
+void SvtSlideSorterBarOptions::SetVisibleHandoutView(bool bVisible)
+{
+ m_pImpl->SetVisibleHandoutView( bVisible );
+}
+
+bool SvtSlideSorterBarOptions::GetVisibleSlideSorterView() const
+{
+ return m_pImpl->m_bVisibleSlideSorterView && !comphelper::LibreOfficeKit::isActive();
+}
+
+void SvtSlideSorterBarOptions::SetVisibleSlideSorterView(bool bVisible)
+{
+ m_pImpl->SetVisibleSlideSorterView( bVisible );
+}
+
+bool SvtSlideSorterBarOptions::GetVisibleDrawView() const
+{
+ return m_pImpl->m_bVisibleDrawView;
+}
+
+void SvtSlideSorterBarOptions::SetVisibleDrawView(bool bVisible)
+{
+ m_pImpl->SetVisibleDrawView( bVisible );
+}
+
+namespace
+{
+ class theSvtSlideSorterBarOptionsMutex :
+ public rtl::Static< osl::Mutex, theSvtSlideSorterBarOptionsMutex > {};
+}
+
+Mutex & SvtSlideSorterBarOptions::GetInitMutex()
+{
+ return theSvtSlideSorterBarOptionsMutex::get();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/config/test/test.cxx b/svtools/source/config/test/test.cxx
new file mode 100644
index 000000000..c84d2ca9f
--- /dev/null
+++ b/svtools/source/config/test/test.cxx
@@ -0,0 +1,215 @@
+/* -*- 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 .
+ */
+
+
+// switches
+// use it to enable test scenarios
+
+
+#define TEST_DYNAMICMENUOPTIONS
+
+#include <unotools/dynamicmenuoptions.hxx>
+
+#include <cppuhelper/bootstrap.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+
+#include <cppuhelper/servicefactory.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/uno/Sequence.h>
+
+#include <rtl/ustring>
+#include <rtl/ustrbuf.hxx>
+#include <osl/diagnose.h>
+#include <sal/log.hxx>
+
+#include <vcl/event.hxx>
+#include <vcl/svapp.hxx>
+
+using namespace ::osl ;
+using namespace ::comphelper ;
+using namespace ::com::sun::star::uno ;
+using namespace ::com::sun::star::lang ;
+using namespace ::com::sun::star::beans ;
+using namespace ::com::sun::star::registry ;
+
+class TestApplication : public Application
+{
+
+ // interface
+
+ public:
+ void Main();
+
+
+ // test methods
+
+ private:
+ void impl_testDynamicMenuOptions();
+
+
+ // helper methods
+
+ private:
+ static Reference< XMultiServiceFactory > getUNOServiceManager();
+
+
+ // member
+
+ private:
+
+}; // class TestApplication
+
+
+// global variables
+
+
+TestApplication aTestApplication ;
+
+
+// main
+
+
+void TestApplication::Main()
+{
+ /**-***********************************************************************************************************
+ initialize program
+ **************************************************************************************************************/
+
+ // Init global servicemanager and set it for external services.
+ ::comphelper::setProcessServiceFactory( TestApplication::getUNOServiceManager() );
+ // Control success of operation.
+ OSL_ENSURE( !(::comphelper::getProcessServiceFactory()!=TestApplication::getUNOServiceManager()), "TestApplication::Main() Global servicemanager not right initialized." );
+
+ /**-***********************************************************************************************************
+ test area
+ **************************************************************************************************************/
+
+ #ifdef TEST_DYNAMICMENUOPTIONS
+ impl_testDynamicMenuOptions();
+ #endif
+
+// Execute();
+ OSL_FAIL( "Test was successful!" );
+}
+
+
+// test configuration of dynamic menus "New" and "Wizard"
+
+void TestApplication::impl_testDynamicMenuOptions()
+{
+ SvtDynamicMenuOptions aCFG;
+
+ // Test:
+ // read menus
+ // if( menus == empty )
+ // {
+ // fill it with samples
+ // read it again
+ // }
+ // output content
+
+ Sequence< Sequence< PropertyValue > > lNewMenu = aCFG.GetMenu( EDynamicMenuType::NewMenu );
+ Sequence< Sequence< PropertyValue > > lWizardMenu = aCFG.GetMenu( EDynamicMenuType::WizardMenu );
+
+ if( lNewMenu.getLength() < 1 )
+ {
+ aCFG.AppendItem( EDynamicMenuType::NewMenu, "private:factory/swriter", "new writer", "icon_writer", "_blank");
+ aCFG.AppendItem( EDynamicMenuType::NewMenu, "private:factory/scalc", "new calc", "icon_calc", "_blank");
+ aCFG.AppendItem( EDynamicMenuType::NewMenu, "private:factory/sdraw", "new draw", "icon_draw", "_blank");
+
+ lNewMenu = aCFG.GetMenu( EDynamicMenuType::NewMenu );
+ }
+
+ if( lWizardMenu.getLength() < 1 )
+ {
+ aCFG.AppendItem( EDynamicMenuType::WizardMenu, "file://a", "system file", "icon_file", "_self");
+ aCFG.AppendItem( EDynamicMenuType::WizardMenu, "ftp://b", "ftp host", "icon_ftp", "_self");
+ aCFG.AppendItem( EDynamicMenuType::WizardMenu, "http://c", "www", "icon_www", "_self");
+
+ lWizardMenu = aCFG.GetMenu( EDynamicMenuType::WizardMenu );
+ }
+
+ sal_uInt32 nItemCount ;
+ sal_uInt32 nItem ;
+ sal_uInt32 nPropertyCount;
+ sal_uInt32 nProperty ;
+ OUString sPropertyValue;
+ OUStringBuffer sOut( 5000 ) ;
+
+ nItemCount = lNewMenu.getLength();
+ for( nItem=0; nItem<nItemCount; ++nItem )
+ {
+ nPropertyCount = lNewMenu[nItem].getLength();
+ for( nProperty=0; nProperty<nPropertyCount; ++nProperty )
+ {
+ lNewMenu[nItem][nProperty].Value >>= sPropertyValue;
+
+ sOut.appendAscii ( "New/" );
+ sOut.append ( (sal_Int32)nItem );
+ sOut.appendAscii ( "/" );
+ sOut.append ( lNewMenu[nItem][nProperty].Name );
+ sOut.appendAscii ( " = " );
+ sOut.append ( sPropertyValue );
+ sOut.appendAscii ( "\n" );
+ }
+ }
+
+ sOut.appendAscii("\n--------------------------------------\n");
+
+ nItemCount = lWizardMenu.getLength();
+ for( nItem=0; nItem<nItemCount; ++nItem )
+ {
+ nPropertyCount = lNewMenu[nItem].getLength();
+ for( nProperty=0; nProperty<nPropertyCount; ++nProperty )
+ {
+ lWizardMenu[nItem][nProperty].Value >>= sPropertyValue;
+
+ sOut.appendAscii ( "Wizard/" );
+ sOut.append ( (sal_Int32)nItem );
+ sOut.appendAscii ( "/" );
+ sOut.append ( lNewMenu[nItem][nProperty].Name );
+ sOut.appendAscii ( " = " );
+ sOut.append ( sPropertyValue );
+ sOut.appendAscii ( "\n" );
+ }
+ }
+
+ SAL_WARN( "svtools", sOut );
+}
+
+
+// create new uno servicemanager by using normal applicat.rdb and user.rdb of an office installation!
+// Don't use this application at the same time like the office!
+
+Reference< XMultiServiceFactory > TestApplication::getUNOServiceManager()
+{
+ static Reference< XMultiServiceFactory > smgr;
+ if( ! smgr.is() )
+ {
+ Reference< XComponentContext > rCtx =
+ cppu::defaultBootstrap_InitialComponentContext();
+ smgr.set( rCtx->getServiceManager() , UNO_QUERY );
+ }
+ return smgr;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */