LibreOffice Module svtools (master) 1
accessibilityoptions.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20
22
24#include <com/sun/star/uno/Any.hxx>
25
26#include <com/sun/star/beans/XPropertySet.hpp>
27#include <com/sun/star/container/XNameAccess.hpp>
30
31#include <vcl/settings.hxx>
32#include <vcl/svapp.hxx>
34#include <officecfg/Office/Common.hxx>
35
36#include <mutex>
37
38#include "itemholder2.hxx"
39
40using namespace utl;
41using namespace com::sun::star::uno;
42
43#define HELP_TIP_TIMEOUT 0xffff // max. timeout setting to pretend a non-timeout
44
45// class SvtAccessibilityOptions_Impl ---------------------------------------------
46
48{
49private:
50 css::uno::Reference< css::container::XNameAccess > m_xCfg;
51 css::uno::Reference< css::beans::XPropertySet > m_xNode;
52
53public:
55};
56
57// initialization of static members --------------------------------------
58
61
62namespace
63{
64 std::mutex& SingletonMutex()
65 {
66 static std::mutex SINGLETON;
67 return SINGLETON;
68 }
69}
70
71
72// class SvtAccessibilityOptions_Impl ---------------------------------------------
73
75{
76 try
77 {
78 m_xCfg.set(
81 "org.openoffice.Office.Common/Accessibility",
83 css::uno::UNO_QUERY);
84 m_xNode.set(m_xCfg, css::uno::UNO_QUERY);
85 }
86 catch(const css::uno::Exception&)
87 {
88 DBG_UNHANDLED_EXCEPTION("svtools.config");
89 m_xCfg.clear();
90 }
91}
92
94{
96 StyleSettings aStyleSettings(aAllSettings.GetStyleSettings());
97 HelpSettings aHelpSettings(aAllSettings.GetHelpSettings());
98 bool StyleSettingsChanged(false);
99
100 bool bHelpTipsDisappear = officecfg::Office::Common::Accessibility::IsHelpTipsDisappear::get();
101 sal_Int16 nHelpTipSeconds = officecfg::Office::Common::Accessibility::HelpTipSeconds::get();
102 aHelpSettings.SetTipTimeout( bHelpTipsDisappear ? nHelpTipSeconds * 1000 : HELP_TIP_TIMEOUT);
103 aAllSettings.SetHelpSettings(aHelpSettings);
104
105 std::optional<sal_Int16> nEdgeBlendingCount(officecfg::Office::Common::Accessibility::EdgeBlending::get());
106 if (!nEdgeBlendingCount)
107 nEdgeBlendingCount = 35;
108 OSL_ENSURE(*nEdgeBlendingCount >= 0, "OOps, negative values for EdgeBlending are not allowed (!)");
109 if (*nEdgeBlendingCount < 0)
110 nEdgeBlendingCount = 0;
111
112 if(aStyleSettings.GetEdgeBlending() != *nEdgeBlendingCount)
113 {
114 aStyleSettings.SetEdgeBlending(*nEdgeBlendingCount);
115 StyleSettingsChanged = true;
116 }
117
118 std::optional<sal_Int16> nMaxLineCount(officecfg::Office::Common::Accessibility::ListBoxMaximumLineCount::get());
119 if (!nMaxLineCount)
120 nMaxLineCount = 25;
121 OSL_ENSURE(*nMaxLineCount >= 0, "OOps, negative values for ListBoxMaximumLineCount are not allowed (!)");
122 if (*nMaxLineCount < 0)
123 nMaxLineCount = 0;
124
125 if(aStyleSettings.GetListBoxMaximumLineCount() != *nMaxLineCount)
126 {
127 aStyleSettings.SetListBoxMaximumLineCount(*nMaxLineCount);
128 StyleSettingsChanged = true;
129 }
130
131#ifdef IOS
132 std::optional<sal_Int16> nMaxColumnCount = 4;
133#else
134 std::optional<sal_Int16> nMaxColumnCount(officecfg::Office::Common::Accessibility::ColorValueSetColumnCount::get());
135 if (!nMaxColumnCount)
136 nMaxColumnCount = 12;
137#endif
138
139 OSL_ENSURE(*nMaxColumnCount >= 0, "OOps, negative values for ColorValueSetColumnCount are not allowed (!)");
140 if (*nMaxColumnCount < 0)
141 nMaxColumnCount = 0;
142
143 if(aStyleSettings.GetColorValueSetColumnCount() != *nMaxColumnCount)
144 {
145 aStyleSettings.SetColorValueSetColumnCount(*nMaxColumnCount);
146 StyleSettingsChanged = true;
147 }
148
149 const bool bPreviewUsesCheckeredBackground(officecfg::Office::Common::Accessibility::PreviewUsesCheckeredBackground::get());
150
151 if(aStyleSettings.GetPreviewUsesCheckeredBackground() != bPreviewUsesCheckeredBackground)
152 {
153 aStyleSettings.SetPreviewUsesCheckeredBackground(bPreviewUsesCheckeredBackground);
154 StyleSettingsChanged = true;
155 }
156
157 if(StyleSettingsChanged)
158 {
159 aAllSettings.SetStyleSettings(aStyleSettings);
161 }
162
163 Application::SetSettings(aAllSettings);
164}
165
166// class SvtAccessibilityOptions --------------------------------------------------
167
169{
171 {
172 std::unique_lock aGuard( SingletonMutex() );
174 {
176 aGuard.unlock(); // because holdConfigItem will call this constructor
177 svtools::ItemHolder2::holdConfigItem(EItem::AccessibilityOptions);
178 }
180 }
181 //StartListening( *sm_pSingleImplConfig, sal_True );
182}
183
185{
186 //EndListening( *sm_pSingleImplConfig, sal_True );
187 std::unique_lock aGuard( SingletonMutex() );
189 {
190 //if( sm_pSingleImplConfig->IsModified() )
191 // sm_pSingleImplConfig->Commit();
193 sm_pSingleImplConfig = nullptr;
194 }
195}
197{
198 return officecfg::Office::Common::Accessibility::IsAllowAnimatedGraphics::get();
199}
201{
202 return officecfg::Office::Common::Accessibility::IsAllowAnimatedText::get();
203}
205{
206 return officecfg::Office::Common::Accessibility::IsAutomaticFontColor::get();
207}
209{
210 return officecfg::Office::Common::Accessibility::IsSelectionInReadonly::get();
211}
212
213
214/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define HELP_TIP_TIMEOUT
void SetHelpSettings(const HelpSettings &rSet)
const HelpSettings & GetHelpSettings() const
const StyleSettings & GetStyleSettings() const
void SetStyleSettings(const StyleSettings &rSet)
static void MergeSystemSettings(AllSettings &rSettings)
static const AllSettings & GetSettings()
static void SetSettings(const AllSettings &rSettings)
void SetTipTimeout(sal_Int32 nTipTimeout)
void SetPreviewUsesCheckeredBackground(bool bNew)
bool GetPreviewUsesCheckeredBackground() const
void SetEdgeBlending(sal_uInt16 nCount)
sal_uInt16 GetListBoxMaximumLineCount() const
void SetListBoxMaximumLineCount(sal_uInt16 nCount)
sal_uInt16 GetEdgeBlending() const
sal_uInt16 GetColorValueSetColumnCount() const
void SetColorValueSetColumnCount(sal_uInt16 nCount)
css::uno::Reference< css::beans::XPropertySet > m_xNode
css::uno::Reference< css::container::XNameAccess > m_xCfg
static sal_Int32 sm_nAccessibilityRefCount
static SvtAccessibilityOptions_Impl * sm_pSingleImplConfig
virtual ~SvtAccessibilityOptions() override
static css::uno::Reference< css::uno::XInterface > openConfig(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const OUString &sPackage, EConfigurationModes eMode)
static void holdConfigItem(EItem eItem)
Definition: itemholder2.cxx:73
static bool IsFuzzing()
#define DBG_UNHANDLED_EXCEPTION(...)
Reference< XComponentContext > getProcessComponentContext()