xref: /AOO42X/main/svtools/source/config/accessibilityoptions.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_svtools.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <svtools/accessibilityoptions.hxx>
32*cdf0e10cSrcweir #include "configitems/accessibilityoptions_const.hxx"
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include <unotools/configmgr.hxx>
35*cdf0e10cSrcweir #include <tools/debug.hxx>
36*cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
37*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
40*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
41*cdf0e10cSrcweir #endif
42*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
43*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
44*cdf0e10cSrcweir #endif
45*cdf0e10cSrcweir #ifndef _COMPHELPER_CONFIGURATIONHELPER_HXX_
46*cdf0e10cSrcweir #include <comphelper/configurationhelper.hxx>
47*cdf0e10cSrcweir #endif
48*cdf0e10cSrcweir #ifndef _UNOTOOLS_PROCESSFACTORY_HXX_
49*cdf0e10cSrcweir #include <unotools/processfactory.hxx>
50*cdf0e10cSrcweir #endif
51*cdf0e10cSrcweir #ifndef _SVT_LOGHELPER_HXX_
52*cdf0e10cSrcweir #include <unotools/loghelper.hxx>
53*cdf0e10cSrcweir #endif
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir #include <svl/smplhint.hxx>
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir #include <vcl/settings.hxx>
58*cdf0e10cSrcweir #include <vcl/svapp.hxx>
59*cdf0e10cSrcweir #include <rtl/instance.hxx>
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir #include <itemholder2.hxx>
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir using namespace utl;
64*cdf0e10cSrcweir using namespace rtl;
65*cdf0e10cSrcweir using namespace com::sun::star::uno;
66*cdf0e10cSrcweir namespace css = com::sun::star;
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir #define HELP_TIP_TIMEOUT 0xffff     // max. timeout setting to pretend a non-timeout
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir // class SvtAccessibilityOptions_Impl ---------------------------------------------
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir class SvtAccessibilityOptions_Impl
74*cdf0e10cSrcweir {
75*cdf0e10cSrcweir private:
76*cdf0e10cSrcweir     css::uno::Reference< css::container::XNameAccess > m_xCfg;
77*cdf0e10cSrcweir     sal_Bool                                           bIsModified;
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir public:
80*cdf0e10cSrcweir     SvtAccessibilityOptions_Impl();
81*cdf0e10cSrcweir     ~SvtAccessibilityOptions_Impl();
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir     void        SetVCLSettings();
84*cdf0e10cSrcweir     sal_Bool    GetAutoDetectSystemHC();
85*cdf0e10cSrcweir     sal_Bool    GetIsForPagePreviews() const;
86*cdf0e10cSrcweir     sal_Bool    GetIsHelpTipsDisappear() const;
87*cdf0e10cSrcweir     sal_Bool    GetIsAllowAnimatedGraphics() const;
88*cdf0e10cSrcweir     sal_Bool    GetIsAllowAnimatedText() const;
89*cdf0e10cSrcweir     sal_Bool    GetIsAutomaticFontColor() const;
90*cdf0e10cSrcweir     sal_Bool    GetIsSystemFont() const;
91*cdf0e10cSrcweir     sal_Int16   GetHelpTipSeconds() const;
92*cdf0e10cSrcweir     sal_Bool    IsSelectionInReadonly() const;
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir     void        SetAutoDetectSystemHC(sal_Bool bSet);
95*cdf0e10cSrcweir     void        SetIsForPagePreviews(sal_Bool bSet);
96*cdf0e10cSrcweir     void        SetIsHelpTipsDisappear(sal_Bool bSet);
97*cdf0e10cSrcweir     void        SetIsAllowAnimatedGraphics(sal_Bool bSet);
98*cdf0e10cSrcweir     void        SetIsAllowAnimatedText(sal_Bool bSet);
99*cdf0e10cSrcweir     void        SetIsAutomaticFontColor(sal_Bool bSet);
100*cdf0e10cSrcweir     void        SetIsSystemFont(sal_Bool bSet);
101*cdf0e10cSrcweir     void        SetHelpTipSeconds(sal_Int16 nSet);
102*cdf0e10cSrcweir     void        SetSelectionInReadonly(sal_Bool bSet);
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir     sal_Bool    IsModified() const { return bIsModified; };
105*cdf0e10cSrcweir };
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir // initialization of static members --------------------------------------
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir SvtAccessibilityOptions_Impl* volatile  SvtAccessibilityOptions::sm_pSingleImplConfig =NULL;
110*cdf0e10cSrcweir sal_Int32                     volatile  SvtAccessibilityOptions::sm_nAccessibilityRefCount(0);
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir namespace
113*cdf0e10cSrcweir {
114*cdf0e10cSrcweir     struct SingletonMutex
115*cdf0e10cSrcweir         : public rtl::Static< ::osl::Mutex, SingletonMutex > {};
116*cdf0e10cSrcweir }
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir // -----------------------------------------------------------------------
119*cdf0e10cSrcweir // class SvtAccessibilityOptions_Impl ---------------------------------------------
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir SvtAccessibilityOptions_Impl::SvtAccessibilityOptions_Impl()
122*cdf0e10cSrcweir {
123*cdf0e10cSrcweir     try
124*cdf0e10cSrcweir     {
125*cdf0e10cSrcweir         m_xCfg = css::uno::Reference< css::container::XNameAccess >(
126*cdf0e10cSrcweir             ::comphelper::ConfigurationHelper::openConfig(
127*cdf0e10cSrcweir             utl::getProcessServiceFactory(),
128*cdf0e10cSrcweir             s_sAccessibility,
129*cdf0e10cSrcweir             ::comphelper::ConfigurationHelper::E_STANDARD),
130*cdf0e10cSrcweir             css::uno::UNO_QUERY);
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir         bIsModified = sal_False;
133*cdf0e10cSrcweir     }
134*cdf0e10cSrcweir     catch(const css::uno::Exception& ex)
135*cdf0e10cSrcweir     {
136*cdf0e10cSrcweir         m_xCfg.clear();
137*cdf0e10cSrcweir         LogHelper::logIt(ex);
138*cdf0e10cSrcweir     }
139*cdf0e10cSrcweir }
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir SvtAccessibilityOptions_Impl::~SvtAccessibilityOptions_Impl()
142*cdf0e10cSrcweir {
143*cdf0e10cSrcweir }
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir // -----------------------------------------------------------------------
146*cdf0e10cSrcweir sal_Bool SvtAccessibilityOptions_Impl::GetAutoDetectSystemHC()
147*cdf0e10cSrcweir {
148*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
149*cdf0e10cSrcweir     sal_Bool                                        bRet = sal_True;
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir     try
152*cdf0e10cSrcweir     {
153*cdf0e10cSrcweir         if(xNode.is())
154*cdf0e10cSrcweir             xNode->getPropertyValue(s_sAutoDetectSystemHC) >>= bRet;
155*cdf0e10cSrcweir     }
156*cdf0e10cSrcweir     catch(const css::uno::Exception& ex)
157*cdf0e10cSrcweir     {
158*cdf0e10cSrcweir         LogHelper::logIt(ex);
159*cdf0e10cSrcweir     }
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir     return bRet;
162*cdf0e10cSrcweir }
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir sal_Bool SvtAccessibilityOptions_Impl::GetIsForPagePreviews() const
165*cdf0e10cSrcweir {
166*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
167*cdf0e10cSrcweir     sal_Bool                                        bRet = sal_True;
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir     try
170*cdf0e10cSrcweir     {
171*cdf0e10cSrcweir         if(xNode.is())
172*cdf0e10cSrcweir             xNode->getPropertyValue(s_sIsForPagePreviews) >>= bRet;
173*cdf0e10cSrcweir     }
174*cdf0e10cSrcweir     catch(const css::uno::Exception& ex)
175*cdf0e10cSrcweir     {
176*cdf0e10cSrcweir         LogHelper::logIt(ex);
177*cdf0e10cSrcweir     }
178*cdf0e10cSrcweir     return bRet;
179*cdf0e10cSrcweir }
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir sal_Bool SvtAccessibilityOptions_Impl::GetIsHelpTipsDisappear() const
182*cdf0e10cSrcweir {
183*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
184*cdf0e10cSrcweir     sal_Bool                                        bRet = sal_True;
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir     try
187*cdf0e10cSrcweir     {
188*cdf0e10cSrcweir         if(xNode.is())
189*cdf0e10cSrcweir             xNode->getPropertyValue(s_sIsHelpTipsDisappear) >>= bRet;
190*cdf0e10cSrcweir     }
191*cdf0e10cSrcweir     catch(const css::uno::Exception& ex)
192*cdf0e10cSrcweir     {
193*cdf0e10cSrcweir         LogHelper::logIt(ex);
194*cdf0e10cSrcweir     }
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir     return bRet;
197*cdf0e10cSrcweir }
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir sal_Bool SvtAccessibilityOptions_Impl::GetIsAllowAnimatedGraphics() const
200*cdf0e10cSrcweir {
201*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
202*cdf0e10cSrcweir     sal_Bool                                        bRet = sal_True;
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir     try
205*cdf0e10cSrcweir     {
206*cdf0e10cSrcweir         if(xNode.is())
207*cdf0e10cSrcweir             xNode->getPropertyValue(s_sIsAllowAnimatedGraphics) >>= bRet;
208*cdf0e10cSrcweir     }
209*cdf0e10cSrcweir     catch(const css::uno::Exception& ex)
210*cdf0e10cSrcweir     {
211*cdf0e10cSrcweir         LogHelper::logIt(ex);
212*cdf0e10cSrcweir     }
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir     return bRet;
215*cdf0e10cSrcweir }
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir sal_Bool SvtAccessibilityOptions_Impl::GetIsAllowAnimatedText() const
218*cdf0e10cSrcweir {
219*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
220*cdf0e10cSrcweir     sal_Bool                                        bRet = sal_True;
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir     try
223*cdf0e10cSrcweir     {
224*cdf0e10cSrcweir         if(xNode.is())
225*cdf0e10cSrcweir             xNode->getPropertyValue(s_sIsAllowAnimatedText) >>= bRet;
226*cdf0e10cSrcweir     }
227*cdf0e10cSrcweir     catch(const css::uno::Exception& ex)
228*cdf0e10cSrcweir     {
229*cdf0e10cSrcweir         LogHelper::logIt(ex);
230*cdf0e10cSrcweir     }
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir     return bRet;
233*cdf0e10cSrcweir }
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir sal_Bool SvtAccessibilityOptions_Impl::GetIsAutomaticFontColor() const
236*cdf0e10cSrcweir {
237*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
238*cdf0e10cSrcweir     sal_Bool                                        bRet = sal_False;
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir     try
241*cdf0e10cSrcweir     {
242*cdf0e10cSrcweir         if(xNode.is())
243*cdf0e10cSrcweir             xNode->getPropertyValue(s_sIsAutomaticFontColor) >>= bRet;
244*cdf0e10cSrcweir     }
245*cdf0e10cSrcweir     catch(const css::uno::Exception& ex)
246*cdf0e10cSrcweir     {
247*cdf0e10cSrcweir         LogHelper::logIt(ex);
248*cdf0e10cSrcweir     }
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir     return bRet;
251*cdf0e10cSrcweir }
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir sal_Bool SvtAccessibilityOptions_Impl::GetIsSystemFont() const
254*cdf0e10cSrcweir {
255*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
256*cdf0e10cSrcweir     sal_Bool                                        bRet = sal_True;
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir     try
259*cdf0e10cSrcweir     {
260*cdf0e10cSrcweir         if(xNode.is())
261*cdf0e10cSrcweir             xNode->getPropertyValue(s_sIsSystemFont) >>= bRet;
262*cdf0e10cSrcweir     }
263*cdf0e10cSrcweir     catch(const css::uno::Exception& ex)
264*cdf0e10cSrcweir     {
265*cdf0e10cSrcweir         LogHelper::logIt(ex);
266*cdf0e10cSrcweir     }
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir     return bRet;
269*cdf0e10cSrcweir }
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir sal_Int16 SvtAccessibilityOptions_Impl::GetHelpTipSeconds() const
272*cdf0e10cSrcweir {
273*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
274*cdf0e10cSrcweir     sal_Int16                                       nRet = 4;
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir     try
277*cdf0e10cSrcweir     {
278*cdf0e10cSrcweir         if(xNode.is())
279*cdf0e10cSrcweir             xNode->getPropertyValue(s_sHelpTipSeconds) >>= nRet;
280*cdf0e10cSrcweir     }
281*cdf0e10cSrcweir     catch(const css::uno::Exception& ex)
282*cdf0e10cSrcweir     {
283*cdf0e10cSrcweir         LogHelper::logIt(ex);
284*cdf0e10cSrcweir     }
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir     return nRet;
287*cdf0e10cSrcweir }
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir sal_Bool SvtAccessibilityOptions_Impl::IsSelectionInReadonly() const
290*cdf0e10cSrcweir {
291*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
292*cdf0e10cSrcweir     sal_Bool                                        bRet = sal_False;
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir     try
295*cdf0e10cSrcweir     {
296*cdf0e10cSrcweir         if(xNode.is())
297*cdf0e10cSrcweir             xNode->getPropertyValue(s_sIsSelectionInReadonly) >>= bRet;
298*cdf0e10cSrcweir     }
299*cdf0e10cSrcweir     catch(const css::uno::Exception& ex)
300*cdf0e10cSrcweir     {
301*cdf0e10cSrcweir         LogHelper::logIt(ex);
302*cdf0e10cSrcweir     }
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir     return bRet;
305*cdf0e10cSrcweir }
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir void SvtAccessibilityOptions_Impl::SetAutoDetectSystemHC(sal_Bool bSet)
308*cdf0e10cSrcweir {
309*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir     try
312*cdf0e10cSrcweir     {
313*cdf0e10cSrcweir         if(xNode.is() && xNode->getPropertyValue(s_sAutoDetectSystemHC)!=bSet)
314*cdf0e10cSrcweir         {
315*cdf0e10cSrcweir             xNode->setPropertyValue(s_sAutoDetectSystemHC, css::uno::makeAny(bSet));
316*cdf0e10cSrcweir             ::comphelper::ConfigurationHelper::flush(m_xCfg);
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir             bIsModified = sal_True;
319*cdf0e10cSrcweir         }
320*cdf0e10cSrcweir     }
321*cdf0e10cSrcweir     catch(const css::uno::Exception& ex)
322*cdf0e10cSrcweir     {
323*cdf0e10cSrcweir         LogHelper::logIt(ex);
324*cdf0e10cSrcweir     }
325*cdf0e10cSrcweir }
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir void SvtAccessibilityOptions_Impl::SetIsForPagePreviews(sal_Bool bSet)
328*cdf0e10cSrcweir {
329*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir     try
332*cdf0e10cSrcweir     {
333*cdf0e10cSrcweir         if(xNode.is() && xNode->getPropertyValue(s_sIsForPagePreviews)!=bSet)
334*cdf0e10cSrcweir         {
335*cdf0e10cSrcweir             xNode->setPropertyValue(s_sIsForPagePreviews, css::uno::makeAny(bSet));
336*cdf0e10cSrcweir             ::comphelper::ConfigurationHelper::flush(m_xCfg);
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir             bIsModified = sal_True;
339*cdf0e10cSrcweir         }
340*cdf0e10cSrcweir     }
341*cdf0e10cSrcweir     catch(const css::uno::Exception& ex)
342*cdf0e10cSrcweir     {
343*cdf0e10cSrcweir         LogHelper::logIt(ex);
344*cdf0e10cSrcweir     }
345*cdf0e10cSrcweir }
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir void SvtAccessibilityOptions_Impl::SetIsHelpTipsDisappear(sal_Bool bSet)
348*cdf0e10cSrcweir {
349*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir     try
352*cdf0e10cSrcweir     {
353*cdf0e10cSrcweir         if(xNode.is() && xNode->getPropertyValue(s_sIsHelpTipsDisappear)!=bSet)
354*cdf0e10cSrcweir         {
355*cdf0e10cSrcweir             xNode->setPropertyValue(s_sIsHelpTipsDisappear, css::uno::makeAny(bSet));
356*cdf0e10cSrcweir             ::comphelper::ConfigurationHelper::flush(m_xCfg);
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir             bIsModified = sal_True;
359*cdf0e10cSrcweir         }
360*cdf0e10cSrcweir     }
361*cdf0e10cSrcweir     catch(const css::uno::Exception& ex)
362*cdf0e10cSrcweir     {
363*cdf0e10cSrcweir         LogHelper::logIt(ex);
364*cdf0e10cSrcweir     }
365*cdf0e10cSrcweir }
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir void SvtAccessibilityOptions_Impl::SetIsAllowAnimatedGraphics(sal_Bool bSet)
368*cdf0e10cSrcweir {
369*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir     try
372*cdf0e10cSrcweir     {
373*cdf0e10cSrcweir         if(xNode.is() && xNode->getPropertyValue(s_sIsAllowAnimatedGraphics)!=bSet)
374*cdf0e10cSrcweir         {
375*cdf0e10cSrcweir             xNode->setPropertyValue(s_sIsAllowAnimatedGraphics, css::uno::makeAny(bSet));
376*cdf0e10cSrcweir             ::comphelper::ConfigurationHelper::flush(m_xCfg);
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir             bIsModified = sal_True;
379*cdf0e10cSrcweir         }
380*cdf0e10cSrcweir     }
381*cdf0e10cSrcweir     catch(const css::uno::Exception& ex)
382*cdf0e10cSrcweir     {
383*cdf0e10cSrcweir         LogHelper::logIt(ex);
384*cdf0e10cSrcweir     }
385*cdf0e10cSrcweir }
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir void SvtAccessibilityOptions_Impl::SetIsAllowAnimatedText(sal_Bool bSet)
388*cdf0e10cSrcweir {
389*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
390*cdf0e10cSrcweir 
391*cdf0e10cSrcweir     try
392*cdf0e10cSrcweir     {
393*cdf0e10cSrcweir         if(xNode.is() && xNode->getPropertyValue(s_sIsAllowAnimatedText)!=bSet)
394*cdf0e10cSrcweir         {
395*cdf0e10cSrcweir             xNode->setPropertyValue(s_sIsAllowAnimatedText, css::uno::makeAny(bSet));
396*cdf0e10cSrcweir             ::comphelper::ConfigurationHelper::flush(m_xCfg);
397*cdf0e10cSrcweir 
398*cdf0e10cSrcweir             bIsModified = sal_True;
399*cdf0e10cSrcweir         }
400*cdf0e10cSrcweir     }
401*cdf0e10cSrcweir     catch(const css::uno::Exception& ex)
402*cdf0e10cSrcweir     {
403*cdf0e10cSrcweir         LogHelper::logIt(ex);
404*cdf0e10cSrcweir     }
405*cdf0e10cSrcweir }
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir void SvtAccessibilityOptions_Impl::SetIsAutomaticFontColor(sal_Bool bSet)
408*cdf0e10cSrcweir {
409*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir     try
412*cdf0e10cSrcweir     {
413*cdf0e10cSrcweir         if(xNode.is() && xNode->getPropertyValue(s_sIsAutomaticFontColor)!=bSet)
414*cdf0e10cSrcweir         {
415*cdf0e10cSrcweir             xNode->setPropertyValue(s_sIsAutomaticFontColor, css::uno::makeAny(bSet));
416*cdf0e10cSrcweir             ::comphelper::ConfigurationHelper::flush(m_xCfg);
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir             bIsModified = sal_True;
419*cdf0e10cSrcweir         }
420*cdf0e10cSrcweir     }
421*cdf0e10cSrcweir     catch(const css::uno::Exception& ex)
422*cdf0e10cSrcweir     {
423*cdf0e10cSrcweir         LogHelper::logIt(ex);
424*cdf0e10cSrcweir     }
425*cdf0e10cSrcweir }
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir void SvtAccessibilityOptions_Impl::SetIsSystemFont(sal_Bool bSet)
428*cdf0e10cSrcweir {
429*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir     try
432*cdf0e10cSrcweir     {
433*cdf0e10cSrcweir         if(xNode.is() && xNode->getPropertyValue(s_sIsSystemFont)!=bSet)
434*cdf0e10cSrcweir         {
435*cdf0e10cSrcweir             xNode->setPropertyValue(s_sIsSystemFont, css::uno::makeAny(bSet));
436*cdf0e10cSrcweir             ::comphelper::ConfigurationHelper::flush(m_xCfg);
437*cdf0e10cSrcweir 
438*cdf0e10cSrcweir             bIsModified = sal_True;
439*cdf0e10cSrcweir         }
440*cdf0e10cSrcweir     }
441*cdf0e10cSrcweir     catch(const css::uno::Exception& ex)
442*cdf0e10cSrcweir     {
443*cdf0e10cSrcweir         LogHelper::logIt(ex);
444*cdf0e10cSrcweir     }
445*cdf0e10cSrcweir }
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir void SvtAccessibilityOptions_Impl::SetHelpTipSeconds(sal_Int16 nSet)
448*cdf0e10cSrcweir {
449*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
450*cdf0e10cSrcweir 
451*cdf0e10cSrcweir     try
452*cdf0e10cSrcweir     {
453*cdf0e10cSrcweir         if(xNode.is() && xNode->getPropertyValue(s_sHelpTipSeconds)!=nSet)
454*cdf0e10cSrcweir         {
455*cdf0e10cSrcweir             xNode->setPropertyValue(s_sHelpTipSeconds, css::uno::makeAny(nSet));
456*cdf0e10cSrcweir             ::comphelper::ConfigurationHelper::flush(m_xCfg);
457*cdf0e10cSrcweir 
458*cdf0e10cSrcweir             bIsModified = sal_True;
459*cdf0e10cSrcweir         }
460*cdf0e10cSrcweir     }
461*cdf0e10cSrcweir     catch(const css::uno::Exception& ex)
462*cdf0e10cSrcweir     {
463*cdf0e10cSrcweir         LogHelper::logIt(ex);
464*cdf0e10cSrcweir     }
465*cdf0e10cSrcweir }
466*cdf0e10cSrcweir 
467*cdf0e10cSrcweir void SvtAccessibilityOptions_Impl::SetSelectionInReadonly(sal_Bool bSet)
468*cdf0e10cSrcweir {
469*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir     try
472*cdf0e10cSrcweir     {
473*cdf0e10cSrcweir         if(xNode.is() && xNode->getPropertyValue(s_sIsSelectionInReadonly)!=bSet)
474*cdf0e10cSrcweir         {
475*cdf0e10cSrcweir             xNode->setPropertyValue(s_sIsSelectionInReadonly, css::uno::makeAny(bSet));
476*cdf0e10cSrcweir             ::comphelper::ConfigurationHelper::flush(m_xCfg);
477*cdf0e10cSrcweir 
478*cdf0e10cSrcweir             bIsModified = sal_True;
479*cdf0e10cSrcweir         }
480*cdf0e10cSrcweir     }
481*cdf0e10cSrcweir     catch(const css::uno::Exception& ex)
482*cdf0e10cSrcweir     {
483*cdf0e10cSrcweir         LogHelper::logIt(ex);
484*cdf0e10cSrcweir     }
485*cdf0e10cSrcweir }
486*cdf0e10cSrcweir 
487*cdf0e10cSrcweir void SvtAccessibilityOptions_Impl::SetVCLSettings()
488*cdf0e10cSrcweir {
489*cdf0e10cSrcweir     AllSettings aAllSettings = Application::GetSettings();
490*cdf0e10cSrcweir     HelpSettings aHelpSettings = aAllSettings.GetHelpSettings();
491*cdf0e10cSrcweir     aHelpSettings.SetTipTimeout( GetIsHelpTipsDisappear() ? GetHelpTipSeconds() * 1000 : HELP_TIP_TIMEOUT);
492*cdf0e10cSrcweir     aAllSettings.SetHelpSettings(aHelpSettings);
493*cdf0e10cSrcweir     if(aAllSettings.GetStyleSettings().GetUseSystemUIFonts() != GetIsSystemFont() )
494*cdf0e10cSrcweir     {
495*cdf0e10cSrcweir         StyleSettings aStyleSettings = aAllSettings.GetStyleSettings();
496*cdf0e10cSrcweir         aStyleSettings.SetUseSystemUIFonts( GetIsSystemFont()  );
497*cdf0e10cSrcweir         aAllSettings.SetStyleSettings(aStyleSettings);
498*cdf0e10cSrcweir         Application::MergeSystemSettings( aAllSettings );
499*cdf0e10cSrcweir     }
500*cdf0e10cSrcweir 
501*cdf0e10cSrcweir     Application::SetSettings(aAllSettings);
502*cdf0e10cSrcweir }
503*cdf0e10cSrcweir 
504*cdf0e10cSrcweir // -----------------------------------------------------------------------
505*cdf0e10cSrcweir // class SvtAccessibilityOptions --------------------------------------------------
506*cdf0e10cSrcweir 
507*cdf0e10cSrcweir SvtAccessibilityOptions::SvtAccessibilityOptions()
508*cdf0e10cSrcweir {
509*cdf0e10cSrcweir     {
510*cdf0e10cSrcweir         ::osl::MutexGuard aGuard( SingletonMutex::get() );
511*cdf0e10cSrcweir         if(!sm_pSingleImplConfig)
512*cdf0e10cSrcweir         {
513*cdf0e10cSrcweir             sm_pSingleImplConfig = new SvtAccessibilityOptions_Impl;
514*cdf0e10cSrcweir             ItemHolder2::holdConfigItem(E_ACCESSIBILITYOPTIONS);
515*cdf0e10cSrcweir         }
516*cdf0e10cSrcweir         ++sm_nAccessibilityRefCount;
517*cdf0e10cSrcweir     }
518*cdf0e10cSrcweir     //StartListening( *sm_pSingleImplConfig, sal_True );
519*cdf0e10cSrcweir }
520*cdf0e10cSrcweir 
521*cdf0e10cSrcweir // -----------------------------------------------------------------------
522*cdf0e10cSrcweir 
523*cdf0e10cSrcweir SvtAccessibilityOptions::~SvtAccessibilityOptions()
524*cdf0e10cSrcweir {
525*cdf0e10cSrcweir     //EndListening( *sm_pSingleImplConfig, sal_True );
526*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( SingletonMutex::get() );
527*cdf0e10cSrcweir     if( !--sm_nAccessibilityRefCount )
528*cdf0e10cSrcweir     {
529*cdf0e10cSrcweir         //if( sm_pSingleImplConfig->IsModified() )
530*cdf0e10cSrcweir         //  sm_pSingleImplConfig->Commit();
531*cdf0e10cSrcweir         DELETEZ( sm_pSingleImplConfig );
532*cdf0e10cSrcweir     }
533*cdf0e10cSrcweir }
534*cdf0e10cSrcweir 
535*cdf0e10cSrcweir // -----------------------------------------------------------------------
536*cdf0e10cSrcweir 
537*cdf0e10cSrcweir void SvtAccessibilityOptions::Notify( SfxBroadcaster&, const SfxHint& rHint )
538*cdf0e10cSrcweir {
539*cdf0e10cSrcweir     NotifyListeners(0);
540*cdf0e10cSrcweir     if ( rHint.IsA(TYPE(SfxSimpleHint)) )
541*cdf0e10cSrcweir     {
542*cdf0e10cSrcweir         if ( ((SfxSimpleHint&)rHint).GetId()  == SFX_HINT_ACCESSIBILITY_CHANGED )
543*cdf0e10cSrcweir             SetVCLSettings();
544*cdf0e10cSrcweir     }
545*cdf0e10cSrcweir }
546*cdf0e10cSrcweir 
547*cdf0e10cSrcweir // -----------------------------------------------------------------------
548*cdf0e10cSrcweir 
549*cdf0e10cSrcweir sal_Bool SvtAccessibilityOptions::IsModified() const
550*cdf0e10cSrcweir {
551*cdf0e10cSrcweir     return sm_pSingleImplConfig->IsModified();
552*cdf0e10cSrcweir }
553*cdf0e10cSrcweir void SvtAccessibilityOptions::Commit()
554*cdf0e10cSrcweir {
555*cdf0e10cSrcweir     //sm_pSingleImplConfig->Commit();
556*cdf0e10cSrcweir }
557*cdf0e10cSrcweir 
558*cdf0e10cSrcweir // -----------------------------------------------------------------------
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir sal_Bool SvtAccessibilityOptions::GetIsForDrawings() const
561*cdf0e10cSrcweir {
562*cdf0e10cSrcweir     DBG_ERROR( "SvtAccessibilityOptions::GetIsForDrawings: is obsolete!" );
563*cdf0e10cSrcweir     return sal_False;
564*cdf0e10cSrcweir }
565*cdf0e10cSrcweir sal_Bool SvtAccessibilityOptions::GetIsForBorders() const
566*cdf0e10cSrcweir {
567*cdf0e10cSrcweir     DBG_ERROR( "SvtAccessibilityOptions::GetIsForBorders: is obsolete!" );
568*cdf0e10cSrcweir     return sal_False;
569*cdf0e10cSrcweir }
570*cdf0e10cSrcweir sal_Bool SvtAccessibilityOptions::GetAutoDetectSystemHC() const
571*cdf0e10cSrcweir {
572*cdf0e10cSrcweir     return sm_pSingleImplConfig->GetAutoDetectSystemHC();
573*cdf0e10cSrcweir }
574*cdf0e10cSrcweir sal_Bool SvtAccessibilityOptions::GetIsForPagePreviews() const
575*cdf0e10cSrcweir {
576*cdf0e10cSrcweir     return sm_pSingleImplConfig->GetIsForPagePreviews();
577*cdf0e10cSrcweir }
578*cdf0e10cSrcweir sal_Bool SvtAccessibilityOptions::GetIsHelpTipsDisappear() const
579*cdf0e10cSrcweir {
580*cdf0e10cSrcweir     return sm_pSingleImplConfig->GetIsHelpTipsDisappear();
581*cdf0e10cSrcweir }
582*cdf0e10cSrcweir sal_Bool SvtAccessibilityOptions::GetIsAllowAnimatedGraphics() const
583*cdf0e10cSrcweir {
584*cdf0e10cSrcweir     return sm_pSingleImplConfig->GetIsAllowAnimatedGraphics();
585*cdf0e10cSrcweir }
586*cdf0e10cSrcweir sal_Bool SvtAccessibilityOptions::GetIsAllowAnimatedText() const
587*cdf0e10cSrcweir {
588*cdf0e10cSrcweir     return sm_pSingleImplConfig->GetIsAllowAnimatedText();
589*cdf0e10cSrcweir }
590*cdf0e10cSrcweir sal_Bool SvtAccessibilityOptions::GetIsAutomaticFontColor() const
591*cdf0e10cSrcweir {
592*cdf0e10cSrcweir     return sm_pSingleImplConfig->GetIsAutomaticFontColor();
593*cdf0e10cSrcweir }
594*cdf0e10cSrcweir sal_Bool SvtAccessibilityOptions::GetIsSystemFont() const
595*cdf0e10cSrcweir {
596*cdf0e10cSrcweir     return sm_pSingleImplConfig->GetIsSystemFont();
597*cdf0e10cSrcweir }
598*cdf0e10cSrcweir sal_Int16 SvtAccessibilityOptions::GetHelpTipSeconds() const
599*cdf0e10cSrcweir {
600*cdf0e10cSrcweir     return sm_pSingleImplConfig->GetHelpTipSeconds();
601*cdf0e10cSrcweir }
602*cdf0e10cSrcweir sal_Bool SvtAccessibilityOptions::IsSelectionInReadonly() const
603*cdf0e10cSrcweir {
604*cdf0e10cSrcweir     return sm_pSingleImplConfig->IsSelectionInReadonly();
605*cdf0e10cSrcweir }
606*cdf0e10cSrcweir 
607*cdf0e10cSrcweir // -----------------------------------------------------------------------
608*cdf0e10cSrcweir void SvtAccessibilityOptions::SetAutoDetectSystemHC(sal_Bool bSet)
609*cdf0e10cSrcweir {
610*cdf0e10cSrcweir     sm_pSingleImplConfig->SetAutoDetectSystemHC(bSet);
611*cdf0e10cSrcweir }
612*cdf0e10cSrcweir void SvtAccessibilityOptions::SetIsForPagePreviews(sal_Bool bSet)
613*cdf0e10cSrcweir {
614*cdf0e10cSrcweir     sm_pSingleImplConfig->SetIsForPagePreviews(bSet);
615*cdf0e10cSrcweir }
616*cdf0e10cSrcweir void SvtAccessibilityOptions::SetIsHelpTipsDisappear(sal_Bool bSet)
617*cdf0e10cSrcweir {
618*cdf0e10cSrcweir     sm_pSingleImplConfig->SetIsHelpTipsDisappear(bSet);
619*cdf0e10cSrcweir }
620*cdf0e10cSrcweir void SvtAccessibilityOptions::SetIsAllowAnimatedGraphics(sal_Bool bSet)
621*cdf0e10cSrcweir {
622*cdf0e10cSrcweir     sm_pSingleImplConfig->SetIsAllowAnimatedGraphics(bSet);
623*cdf0e10cSrcweir }
624*cdf0e10cSrcweir void SvtAccessibilityOptions::SetIsAllowAnimatedText(sal_Bool bSet)
625*cdf0e10cSrcweir {
626*cdf0e10cSrcweir     sm_pSingleImplConfig->SetIsAllowAnimatedText(bSet);
627*cdf0e10cSrcweir }
628*cdf0e10cSrcweir void SvtAccessibilityOptions::SetIsAutomaticFontColor(sal_Bool bSet)
629*cdf0e10cSrcweir {
630*cdf0e10cSrcweir     sm_pSingleImplConfig->SetIsAutomaticFontColor(bSet);
631*cdf0e10cSrcweir }
632*cdf0e10cSrcweir void SvtAccessibilityOptions::SetIsSystemFont(sal_Bool bSet)
633*cdf0e10cSrcweir {
634*cdf0e10cSrcweir     sm_pSingleImplConfig->SetIsSystemFont(bSet);
635*cdf0e10cSrcweir }
636*cdf0e10cSrcweir void SvtAccessibilityOptions::SetHelpTipSeconds(sal_Int16 nSet)
637*cdf0e10cSrcweir {
638*cdf0e10cSrcweir     sm_pSingleImplConfig->SetHelpTipSeconds(nSet);
639*cdf0e10cSrcweir }
640*cdf0e10cSrcweir void SvtAccessibilityOptions::SetSelectionInReadonly(sal_Bool bSet)
641*cdf0e10cSrcweir {
642*cdf0e10cSrcweir     sm_pSingleImplConfig->SetSelectionInReadonly(bSet);
643*cdf0e10cSrcweir }
644*cdf0e10cSrcweir 
645*cdf0e10cSrcweir void SvtAccessibilityOptions::SetVCLSettings()
646*cdf0e10cSrcweir {
647*cdf0e10cSrcweir     sm_pSingleImplConfig->SetVCLSettings();
648*cdf0e10cSrcweir }
649*cdf0e10cSrcweir // -----------------------------------------------------------------------
650