LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svtools/source/config - accessibilityoptions.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 134 343 39.1 %
Date: 2013-07-09 Functions: 26 65 40.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      21             : #include <svtools/accessibilityoptions.hxx>
      22             : 
      23             : #include <unotools/configmgr.hxx>
      24             : #include <com/sun/star/uno/Any.hxx>
      25             : #include <com/sun/star/uno/Sequence.hxx>
      26             : 
      27             : #include <com/sun/star/beans/XPropertySet.hpp>
      28             : #include <com/sun/star/container/XNameAccess.hpp>
      29             : #include <comphelper/configurationhelper.hxx>
      30             : #include <comphelper/processfactory.hxx>
      31             : 
      32             : #include <svl/smplhint.hxx>
      33             : 
      34             : #include <vcl/settings.hxx>
      35             : #include <vcl/svapp.hxx>
      36             : #include <rtl/instance.hxx>
      37             : 
      38             : #include <itemholder2.hxx>
      39             : 
      40             : using namespace utl;
      41             : using namespace com::sun::star::uno;
      42             : 
      43             : #define HELP_TIP_TIMEOUT 0xffff     // max. timeout setting to pretend a non-timeout
      44             : 
      45             : namespace
      46             : {
      47             :     const char s_sAccessibility[] = "org.openoffice.Office.Common/Accessibility";
      48             :     const char s_sAutoDetectSystemHC[] = "AutoDetectSystemHC";
      49             :     const char s_sIsForPagePreviews[] = "IsForPagePreviews";
      50             :     const char s_sIsHelpTipsDisappear[] = "IsHelpTipsDisappear";
      51             :     const char s_sHelpTipSeconds[] = "HelpTipSeconds";
      52             :     const char s_sIsAllowAnimatedGraphics[] = "IsAllowAnimatedGraphics";
      53             :     const char s_sIsAllowAnimatedText[] = "IsAllowAnimatedText";
      54             :     const char s_sIsAutomaticFontColor[] = "IsAutomaticFontColor";
      55             :     const char s_sIsSystemFont[] = "IsSystemFont";
      56             :     const char s_sIsSelectionInReadonly[] = "IsSelectionInReadonly";
      57             :     const char s_sColorValueSetMaximumRowCount[] = "ColorValueSetMaximumRowCount";
      58             :     const char s_sColorValueSetEntryEdgeLength[] = "ColorValueSetEntryEdgeLength";
      59             :     const char s_sColorValueSetColumnCount[] = "ColorValueSetColumnCount";
      60             :     const char s_sEdgeBlending[] = "EdgeBlending";
      61             :     const char s_sListBoxMaximumLineCount[] = "ListBoxMaximumLineCount";
      62             :     const char s_sPreviewUsesCheckeredBackground[]  = "PreviewUsesCheckeredBackground";
      63             : }
      64             : 
      65             : // class SvtAccessibilityOptions_Impl ---------------------------------------------
      66             : 
      67             : class SvtAccessibilityOptions_Impl
      68             : {
      69             : private:
      70             :     css::uno::Reference< css::container::XNameAccess > m_xCfg;
      71             :     sal_Bool                                           bIsModified;
      72             : 
      73             : public:
      74             :     SvtAccessibilityOptions_Impl();
      75             :     ~SvtAccessibilityOptions_Impl();
      76             : 
      77             :     void        SetVCLSettings();
      78             :     sal_Bool    GetAutoDetectSystemHC();
      79             :     sal_Bool    GetIsForPagePreviews() const;
      80             :     sal_Bool    GetIsHelpTipsDisappear() const;
      81             :     sal_Bool    GetIsAllowAnimatedGraphics() const;
      82             :     sal_Bool    GetIsAllowAnimatedText() const;
      83             :     sal_Bool    GetIsAutomaticFontColor() const;
      84             :     sal_Bool    GetIsSystemFont() const;
      85             :     sal_Int16   GetHelpTipSeconds() const;
      86             :     sal_Bool    IsSelectionInReadonly() const;
      87             :     sal_Int16   GetEdgeBlending() const;
      88             :     sal_Int16   GetListBoxMaximumLineCount() const;
      89             :     sal_Int16   GetColorValueSetColumnCount() const;
      90             :     sal_Bool    GetPreviewUsesCheckeredBackground() const;
      91             : 
      92             :     void        SetAutoDetectSystemHC(sal_Bool bSet);
      93             :     void        SetIsForPagePreviews(sal_Bool bSet);
      94             :     void        SetIsHelpTipsDisappear(sal_Bool bSet);
      95             :     void        SetIsAllowAnimatedGraphics(sal_Bool bSet);
      96             :     void        SetIsAllowAnimatedText(sal_Bool bSet);
      97             :     void        SetIsAutomaticFontColor(sal_Bool bSet);
      98             :     void        SetIsSystemFont(sal_Bool bSet);
      99             :     void        SetHelpTipSeconds(sal_Int16 nSet);
     100             :     void        SetSelectionInReadonly(sal_Bool bSet);
     101             :     void        SetEdgeBlending(sal_Int16 nSet);
     102             :     void        SetListBoxMaximumLineCount(sal_Int16 nSet);
     103             :     void        SetColorValueSetColumnCount(sal_Int16 nSet);
     104             :     void        SetPreviewUsesCheckeredBackground(sal_Bool bSet);
     105             : 
     106           0 :     sal_Bool    IsModified() const { return bIsModified; };
     107             : };
     108             : 
     109             : // initialization of static members --------------------------------------
     110             : 
     111             : SvtAccessibilityOptions_Impl* SvtAccessibilityOptions::sm_pSingleImplConfig =NULL;
     112             : sal_Int32                     SvtAccessibilityOptions::sm_nAccessibilityRefCount(0);
     113             : 
     114             : namespace
     115             : {
     116             :     struct SingletonMutex
     117             :         : public rtl::Static< ::osl::Mutex, SingletonMutex > {};
     118             : }
     119             : 
     120             : // -----------------------------------------------------------------------
     121             : // class SvtAccessibilityOptions_Impl ---------------------------------------------
     122             : 
     123         118 : SvtAccessibilityOptions_Impl::SvtAccessibilityOptions_Impl()
     124             : {
     125             :     try
     126             :     {
     127         236 :         m_xCfg = css::uno::Reference< css::container::XNameAccess >(
     128             :             ::comphelper::ConfigurationHelper::openConfig(
     129             :             comphelper::getProcessComponentContext(),
     130             :             s_sAccessibility,
     131             :             ::comphelper::ConfigurationHelper::E_STANDARD),
     132         118 :             css::uno::UNO_QUERY);
     133             : 
     134         118 :         bIsModified = sal_False;
     135             :     }
     136           0 :     catch(const css::uno::Exception& ex)
     137             :     {
     138           0 :         m_xCfg.clear();
     139             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     140             :     }
     141         118 : }
     142             : 
     143          87 : SvtAccessibilityOptions_Impl::~SvtAccessibilityOptions_Impl()
     144             : {
     145          87 : }
     146             : 
     147             : // -----------------------------------------------------------------------
     148           0 : sal_Bool SvtAccessibilityOptions_Impl::GetAutoDetectSystemHC()
     149             : {
     150           0 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     151           0 :     sal_Bool                                        bRet = sal_True;
     152             : 
     153             :     try
     154             :     {
     155           0 :         if(xNode.is())
     156           0 :             xNode->getPropertyValue(s_sAutoDetectSystemHC) >>= bRet;
     157             :     }
     158           0 :     catch(const css::uno::Exception& ex)
     159             :     {
     160             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     161             :     }
     162             : 
     163           0 :     return bRet;
     164             : }
     165             : 
     166          56 : sal_Bool SvtAccessibilityOptions_Impl::GetIsForPagePreviews() const
     167             : {
     168          56 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     169          56 :     sal_Bool                                        bRet = sal_True;
     170             : 
     171             :     try
     172             :     {
     173          56 :         if(xNode.is())
     174          56 :             xNode->getPropertyValue(s_sIsForPagePreviews) >>= bRet;
     175             :     }
     176           0 :     catch(const css::uno::Exception& ex)
     177             :     {
     178             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     179             :     }
     180          56 :     return bRet;
     181             : }
     182             : 
     183          83 : sal_Bool SvtAccessibilityOptions_Impl::GetIsHelpTipsDisappear() const
     184             : {
     185          83 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     186          83 :     sal_Bool                                        bRet = sal_True;
     187             : 
     188             :     try
     189             :     {
     190          83 :         if(xNode.is())
     191          83 :             xNode->getPropertyValue(s_sIsHelpTipsDisappear) >>= bRet;
     192             :     }
     193           0 :     catch(const css::uno::Exception& ex)
     194             :     {
     195             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     196             :     }
     197             : 
     198          83 :     return bRet;
     199             : }
     200             : 
     201       19033 : sal_Bool SvtAccessibilityOptions_Impl::GetIsAllowAnimatedGraphics() const
     202             : {
     203       19033 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     204       19033 :     sal_Bool                                        bRet = sal_True;
     205             : 
     206             :     try
     207             :     {
     208       19033 :         if(xNode.is())
     209       19033 :             xNode->getPropertyValue(s_sIsAllowAnimatedGraphics) >>= bRet;
     210             :     }
     211           0 :     catch(const css::uno::Exception& ex)
     212             :     {
     213             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     214             :     }
     215             : 
     216       19033 :     return bRet;
     217             : }
     218             : 
     219       19033 : sal_Bool SvtAccessibilityOptions_Impl::GetIsAllowAnimatedText() const
     220             : {
     221       19033 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     222       19033 :     sal_Bool                                        bRet = sal_True;
     223             : 
     224             :     try
     225             :     {
     226       19033 :         if(xNode.is())
     227       19033 :             xNode->getPropertyValue(s_sIsAllowAnimatedText) >>= bRet;
     228             :     }
     229           0 :     catch(const css::uno::Exception& ex)
     230             :     {
     231             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     232             :     }
     233             : 
     234       19033 :     return bRet;
     235             : }
     236             : 
     237       10237 : sal_Bool SvtAccessibilityOptions_Impl::GetIsAutomaticFontColor() const
     238             : {
     239       10237 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     240       10237 :     sal_Bool                                        bRet = sal_False;
     241             : 
     242             :     try
     243             :     {
     244       10237 :         if(xNode.is())
     245       10237 :             xNode->getPropertyValue(s_sIsAutomaticFontColor) >>= bRet;
     246             :     }
     247           0 :     catch(const css::uno::Exception& ex)
     248             :     {
     249             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     250             :     }
     251             : 
     252       10237 :     return bRet;
     253             : }
     254             : 
     255          83 : sal_Bool SvtAccessibilityOptions_Impl::GetIsSystemFont() const
     256             : {
     257          83 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     258          83 :     sal_Bool                                        bRet = sal_True;
     259             : 
     260             :     try
     261             :     {
     262          83 :         if(xNode.is())
     263          83 :             xNode->getPropertyValue(s_sIsSystemFont) >>= bRet;
     264             :     }
     265           0 :     catch(const css::uno::Exception& ex)
     266             :     {
     267             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     268             :     }
     269             : 
     270          83 :     return bRet;
     271             : }
     272             : 
     273          83 : sal_Int16 SvtAccessibilityOptions_Impl::GetHelpTipSeconds() const
     274             : {
     275          83 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     276          83 :     sal_Int16                                       nRet = 4;
     277             : 
     278             :     try
     279             :     {
     280          83 :         if(xNode.is())
     281          83 :             xNode->getPropertyValue(s_sHelpTipSeconds) >>= nRet;
     282             :     }
     283           0 :     catch(const css::uno::Exception& ex)
     284             :     {
     285             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     286             :     }
     287             : 
     288          83 :     return nRet;
     289             : }
     290             : 
     291        1635 : sal_Bool SvtAccessibilityOptions_Impl::IsSelectionInReadonly() const
     292             : {
     293        1635 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     294        1635 :     sal_Bool                                        bRet = sal_False;
     295             : 
     296             :     try
     297             :     {
     298        1635 :         if(xNode.is())
     299        1635 :             xNode->getPropertyValue(s_sIsSelectionInReadonly) >>= bRet;
     300             :     }
     301           0 :     catch(const css::uno::Exception& ex)
     302             :     {
     303             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     304             :     }
     305             : 
     306        1635 :     return bRet;
     307             : }
     308             : 
     309          83 : sal_Int16 SvtAccessibilityOptions_Impl::GetEdgeBlending() const
     310             : {
     311          83 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     312          83 :     sal_Int16 nRet = 35;
     313             : 
     314             :     try
     315             :     {
     316          83 :         if(xNode.is())
     317          83 :             xNode->getPropertyValue(s_sEdgeBlending) >>= nRet;
     318             :     }
     319           0 :     catch(const css::uno::Exception& ex)
     320             :     {
     321             :         SAL_WARN("svtools", "Caught unexpected: " << ex.Message);
     322             :     }
     323             : 
     324          83 :     return nRet;
     325             : }
     326             : 
     327          83 : sal_Int16 SvtAccessibilityOptions_Impl::GetListBoxMaximumLineCount() const
     328             : {
     329          83 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     330          83 :     sal_Int16 nRet = 25;
     331             : 
     332             :     try
     333             :     {
     334          83 :         if(xNode.is())
     335          83 :             xNode->getPropertyValue(s_sListBoxMaximumLineCount) >>= nRet;
     336             :     }
     337           0 :     catch(const css::uno::Exception& ex)
     338             :     {
     339             :         SAL_WARN("svtools", "Caught unexpected: " << ex.Message);
     340             :     }
     341             : 
     342          83 :     return nRet;
     343             : }
     344             : 
     345          83 : sal_Int16 SvtAccessibilityOptions_Impl::GetColorValueSetColumnCount() const
     346             : {
     347          83 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     348          83 :     sal_Int16 nRet = 12;
     349             : 
     350             :     try
     351             :     {
     352          83 :         if(xNode.is())
     353          83 :             xNode->getPropertyValue(s_sColorValueSetColumnCount) >>= nRet;
     354             :     }
     355           0 :     catch(const css::uno::Exception& ex)
     356             :     {
     357             :         SAL_WARN("svtools", "Caught unexpected: " << ex.Message);
     358             :     }
     359             : 
     360          83 :     return nRet;
     361             : }
     362             : 
     363          83 : sal_Bool SvtAccessibilityOptions_Impl::GetPreviewUsesCheckeredBackground() const
     364             : {
     365          83 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     366          83 :     sal_Bool bRet = sal_False;
     367             : 
     368             :     try
     369             :     {
     370          83 :         if(xNode.is())
     371          83 :             xNode->getPropertyValue(s_sPreviewUsesCheckeredBackground) >>= bRet;
     372             :     }
     373           0 :     catch(const css::uno::Exception& ex)
     374             :     {
     375             :         SAL_WARN("svtools", "Caught unexpected: " << ex.Message);
     376             :     }
     377             : 
     378          83 :     return bRet;
     379             : }
     380             : 
     381           0 : void SvtAccessibilityOptions_Impl::SetAutoDetectSystemHC(sal_Bool bSet)
     382             : {
     383           0 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     384             : 
     385             :     try
     386             :     {
     387           0 :         if(xNode.is() && xNode->getPropertyValue(s_sAutoDetectSystemHC)!=bSet)
     388             :         {
     389           0 :             xNode->setPropertyValue(s_sAutoDetectSystemHC, css::uno::makeAny(bSet));
     390           0 :             ::comphelper::ConfigurationHelper::flush(m_xCfg);
     391             : 
     392           0 :             bIsModified = sal_True;
     393             :         }
     394             :     }
     395           0 :     catch(const css::uno::Exception& ex)
     396             :     {
     397             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     398           0 :     }
     399           0 : }
     400             : 
     401           0 : void SvtAccessibilityOptions_Impl::SetIsForPagePreviews(sal_Bool bSet)
     402             : {
     403           0 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     404             : 
     405             :     try
     406             :     {
     407           0 :         if(xNode.is() && xNode->getPropertyValue(s_sIsForPagePreviews)!=bSet)
     408             :         {
     409           0 :             xNode->setPropertyValue(s_sIsForPagePreviews, css::uno::makeAny(bSet));
     410           0 :             ::comphelper::ConfigurationHelper::flush(m_xCfg);
     411             : 
     412           0 :             bIsModified = sal_True;
     413             :         }
     414             :     }
     415           0 :     catch(const css::uno::Exception& ex)
     416             :     {
     417             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     418           0 :     }
     419           0 : }
     420             : 
     421           0 : void SvtAccessibilityOptions_Impl::SetIsHelpTipsDisappear(sal_Bool bSet)
     422             : {
     423           0 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     424             : 
     425             :     try
     426             :     {
     427           0 :         if(xNode.is() && xNode->getPropertyValue(s_sIsHelpTipsDisappear)!=bSet)
     428             :         {
     429           0 :             xNode->setPropertyValue(s_sIsHelpTipsDisappear, css::uno::makeAny(bSet));
     430           0 :             ::comphelper::ConfigurationHelper::flush(m_xCfg);
     431             : 
     432           0 :             bIsModified = sal_True;
     433             :         }
     434             :     }
     435           0 :     catch(const css::uno::Exception& ex)
     436             :     {
     437             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     438           0 :     }
     439           0 : }
     440             : 
     441           0 : void SvtAccessibilityOptions_Impl::SetIsAllowAnimatedGraphics(sal_Bool bSet)
     442             : {
     443           0 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     444             : 
     445             :     try
     446             :     {
     447           0 :         if(xNode.is() && xNode->getPropertyValue(s_sIsAllowAnimatedGraphics)!=bSet)
     448             :         {
     449           0 :             xNode->setPropertyValue(s_sIsAllowAnimatedGraphics, css::uno::makeAny(bSet));
     450           0 :             ::comphelper::ConfigurationHelper::flush(m_xCfg);
     451             : 
     452           0 :             bIsModified = sal_True;
     453             :         }
     454             :     }
     455           0 :     catch(const css::uno::Exception& ex)
     456             :     {
     457             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     458           0 :     }
     459           0 : }
     460             : 
     461           0 : void SvtAccessibilityOptions_Impl::SetIsAllowAnimatedText(sal_Bool bSet)
     462             : {
     463           0 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     464             : 
     465             :     try
     466             :     {
     467           0 :         if(xNode.is() && xNode->getPropertyValue(s_sIsAllowAnimatedText)!=bSet)
     468             :         {
     469           0 :             xNode->setPropertyValue(s_sIsAllowAnimatedText, css::uno::makeAny(bSet));
     470           0 :             ::comphelper::ConfigurationHelper::flush(m_xCfg);
     471             : 
     472           0 :             bIsModified = sal_True;
     473             :         }
     474             :     }
     475           0 :     catch(const css::uno::Exception& ex)
     476             :     {
     477             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     478           0 :     }
     479           0 : }
     480             : 
     481           0 : void SvtAccessibilityOptions_Impl::SetIsAutomaticFontColor(sal_Bool bSet)
     482             : {
     483           0 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     484             : 
     485             :     try
     486             :     {
     487           0 :         if(xNode.is() && xNode->getPropertyValue(s_sIsAutomaticFontColor)!=bSet)
     488             :         {
     489           0 :             xNode->setPropertyValue(s_sIsAutomaticFontColor, css::uno::makeAny(bSet));
     490           0 :             ::comphelper::ConfigurationHelper::flush(m_xCfg);
     491             : 
     492           0 :             bIsModified = sal_True;
     493             :         }
     494             :     }
     495           0 :     catch(const css::uno::Exception& ex)
     496             :     {
     497             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     498           0 :     }
     499           0 : }
     500             : 
     501           0 : void SvtAccessibilityOptions_Impl::SetIsSystemFont(sal_Bool bSet)
     502             : {
     503           0 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     504             : 
     505             :     try
     506             :     {
     507           0 :         if(xNode.is() && xNode->getPropertyValue(s_sIsSystemFont)!=bSet)
     508             :         {
     509           0 :             xNode->setPropertyValue(s_sIsSystemFont, css::uno::makeAny(bSet));
     510           0 :             ::comphelper::ConfigurationHelper::flush(m_xCfg);
     511             : 
     512           0 :             bIsModified = sal_True;
     513             :         }
     514             :     }
     515           0 :     catch(const css::uno::Exception& ex)
     516             :     {
     517             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     518           0 :     }
     519           0 : }
     520             : 
     521           0 : void SvtAccessibilityOptions_Impl::SetHelpTipSeconds(sal_Int16 nSet)
     522             : {
     523           0 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     524             : 
     525             :     try
     526             :     {
     527           0 :         if(xNode.is() && xNode->getPropertyValue(s_sHelpTipSeconds)!=nSet)
     528             :         {
     529           0 :             xNode->setPropertyValue(s_sHelpTipSeconds, css::uno::makeAny(nSet));
     530           0 :             ::comphelper::ConfigurationHelper::flush(m_xCfg);
     531             : 
     532           0 :             bIsModified = sal_True;
     533             :         }
     534             :     }
     535           0 :     catch(const css::uno::Exception& ex)
     536             :     {
     537             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     538           0 :     }
     539           0 : }
     540             : 
     541           0 : void SvtAccessibilityOptions_Impl::SetSelectionInReadonly(sal_Bool bSet)
     542             : {
     543           0 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     544             : 
     545             :     try
     546             :     {
     547           0 :         if(xNode.is() && xNode->getPropertyValue(s_sIsSelectionInReadonly)!=bSet)
     548             :         {
     549           0 :             xNode->setPropertyValue(s_sIsSelectionInReadonly, css::uno::makeAny(bSet));
     550           0 :             ::comphelper::ConfigurationHelper::flush(m_xCfg);
     551             : 
     552           0 :             bIsModified = sal_True;
     553             :         }
     554             :     }
     555           0 :     catch(const css::uno::Exception& ex)
     556             :     {
     557             :         SAL_WARN("svtools.config", "Caught unexpected: " << ex.Message);
     558           0 :     }
     559           0 : }
     560             : 
     561          83 : void SvtAccessibilityOptions_Impl::SetVCLSettings()
     562             : {
     563          83 :     AllSettings aAllSettings(Application::GetSettings());
     564         166 :     StyleSettings aStyleSettings(aAllSettings.GetStyleSettings());
     565         166 :     HelpSettings aHelpSettings(aAllSettings.GetHelpSettings());
     566          83 :     bool StyleSettingsChanged(false);
     567             : 
     568          83 :     aHelpSettings.SetTipTimeout( GetIsHelpTipsDisappear() ? GetHelpTipSeconds() * 1000 : HELP_TIP_TIMEOUT);
     569          83 :     aAllSettings.SetHelpSettings(aHelpSettings);
     570             : 
     571          83 :     if(aStyleSettings.GetUseSystemUIFonts() != GetIsSystemFont())
     572             :     {
     573           0 :         aStyleSettings.SetUseSystemUIFonts(GetIsSystemFont());
     574           0 :         StyleSettingsChanged = true;
     575             :     }
     576             : 
     577          83 :     const sal_Int16 nEdgeBlendingCountA(GetEdgeBlending());
     578             :     OSL_ENSURE(nEdgeBlendingCountA >= 0, "OOps, negative values for EdgeBlending are not allowed (!)");
     579          83 :     const sal_uInt16 nEdgeBlendingCountB(static_cast< sal_uInt16 >(nEdgeBlendingCountA >= 0 ? nEdgeBlendingCountA : 0));
     580             : 
     581          83 :     if(aStyleSettings.GetEdgeBlending() != nEdgeBlendingCountB)
     582             :     {
     583           0 :         aStyleSettings.SetEdgeBlending(nEdgeBlendingCountB);
     584           0 :         StyleSettingsChanged = true;
     585             :     }
     586             : 
     587          83 :     const sal_Int16 nMaxLineCountA(GetListBoxMaximumLineCount());
     588             :     OSL_ENSURE(nMaxLineCountA >= 0, "OOps, negative values for ListBoxMaximumLineCount are not allowed (!)");
     589          83 :     const sal_uInt16 nMaxLineCountB(static_cast< sal_uInt16 >(nMaxLineCountA >= 0 ? nMaxLineCountA : 0));
     590             : 
     591          83 :     if(aStyleSettings.GetListBoxMaximumLineCount() != nMaxLineCountB)
     592             :     {
     593           0 :         aStyleSettings.SetListBoxMaximumLineCount(nMaxLineCountB);
     594           0 :         StyleSettingsChanged = true;
     595             :     }
     596             : 
     597          83 :     const sal_Int16 nMaxColumnCountA(GetColorValueSetColumnCount());
     598             :     OSL_ENSURE(nMaxColumnCountA >= 0, "OOps, negative values for ColorValueSetColumnCount are not allowed (!)");
     599          83 :     const sal_uInt16 nMaxColumnCountB(static_cast< sal_uInt16 >(nMaxColumnCountA >= 0 ? nMaxColumnCountA : 0));
     600             : 
     601          83 :     if(aStyleSettings.GetColorValueSetColumnCount() != nMaxColumnCountB)
     602             :     {
     603          83 :         aStyleSettings.SetColorValueSetColumnCount(nMaxColumnCountB);
     604          83 :         StyleSettingsChanged = true;
     605             :     }
     606             : 
     607          83 :     const bool bPreviewUsesCheckeredBackground(GetPreviewUsesCheckeredBackground());
     608             : 
     609          83 :     if(aStyleSettings.GetPreviewUsesCheckeredBackground() != bPreviewUsesCheckeredBackground)
     610             :     {
     611          83 :         aStyleSettings.SetPreviewUsesCheckeredBackground(bPreviewUsesCheckeredBackground);
     612          83 :         StyleSettingsChanged = true;
     613             :     }
     614             : 
     615          83 :     if(StyleSettingsChanged)
     616             :     {
     617          83 :         aAllSettings.SetStyleSettings(aStyleSettings);
     618          83 :         Application::MergeSystemSettings(aAllSettings);
     619             :     }
     620             : 
     621         166 :     Application::SetSettings(aAllSettings);
     622          83 : }
     623             : 
     624           0 : void SvtAccessibilityOptions_Impl::SetEdgeBlending(sal_Int16 nSet)
     625             : {
     626           0 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     627             : 
     628             :     try
     629             :     {
     630           0 :         if(xNode.is() && xNode->getPropertyValue(s_sEdgeBlending)!=nSet)
     631             :         {
     632           0 :             xNode->setPropertyValue(s_sEdgeBlending, css::uno::makeAny(nSet));
     633           0 :             ::comphelper::ConfigurationHelper::flush(m_xCfg);
     634             : 
     635           0 :             bIsModified = sal_True;
     636             :         }
     637             :     }
     638           0 :     catch(const css::uno::Exception& ex)
     639             :     {
     640             :         SAL_WARN("svtools", "Caught unexpected: " << ex.Message);
     641           0 :     }
     642           0 : }
     643             : 
     644           0 : void SvtAccessibilityOptions_Impl::SetListBoxMaximumLineCount(sal_Int16 nSet)
     645             : {
     646           0 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     647             : 
     648             :     try
     649             :     {
     650           0 :         if(xNode.is() && xNode->getPropertyValue(s_sListBoxMaximumLineCount)!=nSet)
     651             :         {
     652           0 :             xNode->setPropertyValue(s_sListBoxMaximumLineCount, css::uno::makeAny(nSet));
     653           0 :             ::comphelper::ConfigurationHelper::flush(m_xCfg);
     654             : 
     655           0 :             bIsModified = sal_True;
     656             :         }
     657             :     }
     658           0 :     catch(const css::uno::Exception& ex)
     659             :     {
     660             :         SAL_WARN("svtools", "Caught unexpected: " << ex.Message);
     661           0 :     }
     662           0 : }
     663             : 
     664           0 : void SvtAccessibilityOptions_Impl::SetColorValueSetColumnCount(sal_Int16 nSet)
     665             : {
     666           0 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     667             : 
     668             :     try
     669             :     {
     670           0 :         if(xNode.is() && xNode->getPropertyValue(s_sColorValueSetColumnCount)!=nSet)
     671             :         {
     672           0 :             xNode->setPropertyValue(s_sColorValueSetColumnCount, css::uno::makeAny(nSet));
     673           0 :             ::comphelper::ConfigurationHelper::flush(m_xCfg);
     674             : 
     675           0 :             bIsModified = sal_True;
     676             :         }
     677             :     }
     678           0 :     catch(const css::uno::Exception& ex)
     679             :     {
     680             :         SAL_WARN("svtools", "Caught unexpected: " << ex.Message);
     681           0 :     }
     682           0 : }
     683             : 
     684           0 : void SvtAccessibilityOptions_Impl::SetPreviewUsesCheckeredBackground(sal_Bool bSet)
     685             : {
     686           0 :     css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY);
     687             : 
     688             :     try
     689             :     {
     690           0 :         if(xNode.is() && xNode->getPropertyValue(s_sPreviewUsesCheckeredBackground)!=bSet)
     691             :         {
     692           0 :             xNode->setPropertyValue(s_sPreviewUsesCheckeredBackground, css::uno::makeAny(bSet));
     693           0 :             ::comphelper::ConfigurationHelper::flush(m_xCfg);
     694             : 
     695           0 :             bIsModified = sal_True;
     696             :         }
     697             :     }
     698           0 :     catch(const css::uno::Exception& ex)
     699             :     {
     700             :         SAL_WARN("svtools", "Caught unexpected: " << ex.Message);
     701           0 :     }
     702           0 : }
     703             : 
     704             : // -----------------------------------------------------------------------
     705             : // class SvtAccessibilityOptions --------------------------------------------------
     706             : 
     707        3207 : SvtAccessibilityOptions::SvtAccessibilityOptions()
     708             : {
     709             :     {
     710        3207 :         ::osl::MutexGuard aGuard( SingletonMutex::get() );
     711        3207 :         if(!sm_pSingleImplConfig)
     712             :         {
     713         118 :             sm_pSingleImplConfig = new SvtAccessibilityOptions_Impl;
     714         118 :             svtools::ItemHolder2::holdConfigItem(E_ACCESSIBILITYOPTIONS);
     715             :         }
     716        3207 :         ++sm_nAccessibilityRefCount;
     717             :     }
     718             :     //StartListening( *sm_pSingleImplConfig, sal_True );
     719        3207 : }
     720             : 
     721             : // -----------------------------------------------------------------------
     722             : 
     723        6456 : SvtAccessibilityOptions::~SvtAccessibilityOptions()
     724             : {
     725             :     //EndListening( *sm_pSingleImplConfig, sal_True );
     726        3155 :     ::osl::MutexGuard aGuard( SingletonMutex::get() );
     727        3155 :     if( !--sm_nAccessibilityRefCount )
     728             :     {
     729             :         //if( sm_pSingleImplConfig->IsModified() )
     730             :         //  sm_pSingleImplConfig->Commit();
     731          87 :         DELETEZ( sm_pSingleImplConfig );
     732        3155 :     }
     733        3301 : }
     734             : 
     735             : // -----------------------------------------------------------------------
     736             : 
     737           0 : void SvtAccessibilityOptions::Notify( SfxBroadcaster&, const SfxHint& rHint )
     738             : {
     739           0 :     NotifyListeners(0);
     740           0 :     if ( rHint.IsA(TYPE(SfxSimpleHint)) )
     741             :     {
     742           0 :         if ( ((SfxSimpleHint&)rHint).GetId()  == SFX_HINT_ACCESSIBILITY_CHANGED )
     743           0 :             SetVCLSettings();
     744             :     }
     745           0 : }
     746             : 
     747             : // -----------------------------------------------------------------------
     748             : 
     749           0 : sal_Bool SvtAccessibilityOptions::IsModified() const
     750             : {
     751           0 :     return sm_pSingleImplConfig->IsModified();
     752             : }
     753           0 : void SvtAccessibilityOptions::Commit()
     754             : {
     755             :     //sm_pSingleImplConfig->Commit();
     756           0 : }
     757             : 
     758             : // -----------------------------------------------------------------------
     759             : 
     760           0 : sal_Bool SvtAccessibilityOptions::GetAutoDetectSystemHC() const
     761             : {
     762           0 :     return sm_pSingleImplConfig->GetAutoDetectSystemHC();
     763             : }
     764          56 : sal_Bool SvtAccessibilityOptions::GetIsForPagePreviews() const
     765             : {
     766          56 :     return sm_pSingleImplConfig->GetIsForPagePreviews();
     767             : }
     768           0 : sal_Bool SvtAccessibilityOptions::GetIsHelpTipsDisappear() const
     769             : {
     770           0 :     return sm_pSingleImplConfig->GetIsHelpTipsDisappear();
     771             : }
     772       19033 : sal_Bool SvtAccessibilityOptions::GetIsAllowAnimatedGraphics() const
     773             : {
     774       19033 :     return sm_pSingleImplConfig->GetIsAllowAnimatedGraphics();
     775             : }
     776       19033 : sal_Bool SvtAccessibilityOptions::GetIsAllowAnimatedText() const
     777             : {
     778       19033 :     return sm_pSingleImplConfig->GetIsAllowAnimatedText();
     779             : }
     780       10237 : sal_Bool SvtAccessibilityOptions::GetIsAutomaticFontColor() const
     781             : {
     782       10237 :     return sm_pSingleImplConfig->GetIsAutomaticFontColor();
     783             : }
     784           0 : sal_Bool SvtAccessibilityOptions::GetIsSystemFont() const
     785             : {
     786           0 :     return sm_pSingleImplConfig->GetIsSystemFont();
     787             : }
     788           0 : sal_Int16 SvtAccessibilityOptions::GetHelpTipSeconds() const
     789             : {
     790           0 :     return sm_pSingleImplConfig->GetHelpTipSeconds();
     791             : }
     792        1635 : sal_Bool SvtAccessibilityOptions::IsSelectionInReadonly() const
     793             : {
     794        1635 :     return sm_pSingleImplConfig->IsSelectionInReadonly();
     795             : }
     796           0 : sal_Int16 SvtAccessibilityOptions::GetEdgeBlending() const
     797             : {
     798           0 :     return sm_pSingleImplConfig->GetEdgeBlending();
     799             : }
     800           0 : sal_Int16 SvtAccessibilityOptions::GetListBoxMaximumLineCount() const
     801             : {
     802           0 :     return sm_pSingleImplConfig->GetListBoxMaximumLineCount();
     803             : }
     804           0 : sal_Int16 SvtAccessibilityOptions::GetColorValueSetColumnCount() const
     805             : {
     806           0 :     return sm_pSingleImplConfig->GetColorValueSetColumnCount();
     807             : }
     808           0 : sal_Bool SvtAccessibilityOptions::GetPreviewUsesCheckeredBackground() const
     809             : {
     810           0 :     return sm_pSingleImplConfig->GetPreviewUsesCheckeredBackground();
     811             : }
     812             : 
     813             : // -----------------------------------------------------------------------
     814           0 : void SvtAccessibilityOptions::SetAutoDetectSystemHC(sal_Bool bSet)
     815             : {
     816           0 :     sm_pSingleImplConfig->SetAutoDetectSystemHC(bSet);
     817           0 : }
     818           0 : void SvtAccessibilityOptions::SetIsForPagePreviews(sal_Bool bSet)
     819             : {
     820           0 :     sm_pSingleImplConfig->SetIsForPagePreviews(bSet);
     821           0 : }
     822           0 : void SvtAccessibilityOptions::SetIsHelpTipsDisappear(sal_Bool bSet)
     823             : {
     824           0 :     sm_pSingleImplConfig->SetIsHelpTipsDisappear(bSet);
     825           0 : }
     826           0 : void SvtAccessibilityOptions::SetIsAllowAnimatedGraphics(sal_Bool bSet)
     827             : {
     828           0 :     sm_pSingleImplConfig->SetIsAllowAnimatedGraphics(bSet);
     829           0 : }
     830           0 : void SvtAccessibilityOptions::SetIsAllowAnimatedText(sal_Bool bSet)
     831             : {
     832           0 :     sm_pSingleImplConfig->SetIsAllowAnimatedText(bSet);
     833           0 : }
     834           0 : void SvtAccessibilityOptions::SetIsAutomaticFontColor(sal_Bool bSet)
     835             : {
     836           0 :     sm_pSingleImplConfig->SetIsAutomaticFontColor(bSet);
     837           0 : }
     838           0 : void SvtAccessibilityOptions::SetIsSystemFont(sal_Bool bSet)
     839             : {
     840           0 :     sm_pSingleImplConfig->SetIsSystemFont(bSet);
     841           0 : }
     842           0 : void SvtAccessibilityOptions::SetHelpTipSeconds(sal_Int16 nSet)
     843             : {
     844           0 :     sm_pSingleImplConfig->SetHelpTipSeconds(nSet);
     845           0 : }
     846           0 : void SvtAccessibilityOptions::SetSelectionInReadonly(sal_Bool bSet)
     847             : {
     848           0 :     sm_pSingleImplConfig->SetSelectionInReadonly(bSet);
     849           0 : }
     850          83 : void SvtAccessibilityOptions::SetVCLSettings()
     851             : {
     852          83 :     sm_pSingleImplConfig->SetVCLSettings();
     853          83 : }
     854           0 : void SvtAccessibilityOptions::SetEdgeBlending(sal_Int16 nSet)
     855             : {
     856           0 :     sm_pSingleImplConfig->SetEdgeBlending(nSet);
     857           0 : }
     858           0 : void SvtAccessibilityOptions::SetListBoxMaximumLineCount(sal_Int16 nSet)
     859             : {
     860           0 :     sm_pSingleImplConfig->SetListBoxMaximumLineCount(nSet);
     861           0 : }
     862           0 : void SvtAccessibilityOptions::SetColorValueSetColumnCount(sal_Int16 nSet)
     863             : {
     864           0 :     sm_pSingleImplConfig->SetColorValueSetColumnCount(nSet);
     865           0 : }
     866           0 : void SvtAccessibilityOptions::SetPreviewUsesCheckeredBackground(sal_Bool bSet)
     867             : {
     868           0 :     sm_pSingleImplConfig->SetPreviewUsesCheckeredBackground(bSet);
     869         465 : }
     870             : 
     871             : // -----------------------------------------------------------------------
     872             : 
     873             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10