LCOV - code coverage report
Current view: top level - libreoffice/cui/source/options - optaccessibility.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 85 1.2 %
Date: 2012-12-27 Functions: 2 14 14.3 %
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             : #include <optaccessibility.hxx>
      21             : #include <optaccessibility.hrc>
      22             : #include <dialmgr.hxx>
      23             : #include <cuires.hrc>
      24             : #include <svtools/accessibilityoptions.hxx>
      25             : #include <vcl/settings.hxx>
      26             : #include <vcl/svapp.hxx>
      27             : 
      28           0 : static void MovePosY( Window& _rWin, long _nDelta )
      29             : {
      30           0 :     Point   aPoint = _rWin.GetPosPixel();
      31           0 :     aPoint.Y() += _nDelta;
      32             : 
      33           0 :     _rWin.SetPosPixel( aPoint );
      34           0 : }
      35             : 
      36           0 : struct SvxAccessibilityOptionsTabPage_Impl
      37             : {
      38             :     SvtAccessibilityOptions     m_aConfig;
      39           0 :     SvxAccessibilityOptionsTabPage_Impl()
      40           0 :             : m_aConfig(){}
      41             : };
      42             : 
      43           0 : SvxAccessibilityOptionsTabPage::SvxAccessibilityOptionsTabPage( Window* pParent, const SfxItemSet& rSet )
      44           0 :     :SfxTabPage(pParent, CUI_RES( RID_SVXPAGE_ACCESSIBILITYCONFIG ), rSet)
      45           0 :     ,m_aMiscellaneousLabel      (this, CUI_RES(FL_MISCELLANEOUS     ))
      46           0 :     ,m_aAccessibilityTool       (this, CUI_RES(CB_ACCESSIBILITY_TOOL    ))
      47           0 :     ,m_aTextSelectionInReadonly (this, CUI_RES(CB_TEXTSELECTION     ))
      48           0 :     ,m_aAnimatedGraphics        (this, CUI_RES(CB_ANIMATED_GRAPHICS ))
      49           0 :     ,m_aAnimatedTexts           (this, CUI_RES(CB_ANIMATED_TEXTS        ))
      50           0 :     ,m_aTipHelpCB               (this, CUI_RES(CB_TIPHELP               ))
      51           0 :     ,m_aTipHelpNF               (this, CUI_RES(NF_TIPHELP               ))
      52           0 :     ,m_aTipHelpFT               (this, CUI_RES(FT_TIPHELP               ))
      53           0 :     ,m_aHCOptionsLabel          (this, CUI_RES(FL_HC_OPTIONS            ))
      54           0 :     ,m_aAutoDetectHC            (this, CUI_RES(CB_AUTO_DETECT_HC        ))
      55           0 :     ,m_aAutomaticFontColor      (this, CUI_RES(CB_AUTOMATIC_FONT_COLOR))
      56           0 :     ,m_aPagePreviews            (this, CUI_RES(CB_PAGE_PREVIEWS       ))
      57           0 :     ,m_pImpl(new SvxAccessibilityOptionsTabPage_Impl)
      58             : {
      59           0 :     FreeResource();
      60           0 :     m_aTipHelpCB.SetClickHdl(LINK(this, SvxAccessibilityOptionsTabPage, TipHelpHdl));
      61             : 
      62           0 :     long nHeightDelta = 0;      // to correct positions _under_ m_aAccessibilityTool
      63             : 
      64             : #ifdef UNX
      65             :     {
      66             :         // UNIX: read the gconf2 setting instead to use the checkbox
      67           0 :         m_aAccessibilityTool.Hide();
      68           0 :         nHeightDelta = -( ROWA_2 - ROWA_1 );
      69             :     }
      70             : #else
      71             :     // calculate the height of the checkbox. Do we need two (default in resource) or only one line
      72             :     String aText = m_aAccessibilityTool.GetText();
      73             :     long nWidth = m_aAccessibilityTool.GetTextWidth( aText );
      74             :     long nCtrlWidth = m_aAccessibilityTool.GetSizePixel().Width() - ( COL2 - COL1 );
      75             :     if ( nWidth > nCtrlWidth )
      76             :     {
      77             :         long nDelta = 2 * RSC_CD_FIXEDLINE_HEIGHT + LINESPACE - RSC_CD_CHECKBOX_HEIGHT;
      78             :         nHeightDelta = nDelta;
      79             :         Size aSize = m_aAccessibilityTool.LogicToPixel( Size( 0, nDelta ), MAP_APPFONT );
      80             :         nDelta = aSize.Height();
      81             :         aSize = m_aAccessibilityTool.GetSizePixel();
      82             :         aSize.Height() += nDelta;
      83             :         m_aAccessibilityTool.SetSizePixel( aSize );
      84             :     }
      85             : #endif
      86             : 
      87           0 :     if( nHeightDelta )
      88             :     {   //adjust positions of controls under m_aAccessibilityTool
      89           0 :         Size aSize = m_aAccessibilityTool.LogicToPixel( Size( 0, nHeightDelta ), MAP_APPFONT );
      90           0 :         nHeightDelta = aSize.Height();
      91             : 
      92           0 :         MovePosY( m_aTextSelectionInReadonly, nHeightDelta );
      93           0 :         MovePosY( m_aAnimatedGraphics, nHeightDelta );
      94           0 :         MovePosY( m_aAnimatedTexts, nHeightDelta );
      95           0 :         MovePosY( m_aTipHelpCB, nHeightDelta );
      96           0 :         MovePosY( m_aTipHelpNF, nHeightDelta );
      97           0 :         MovePosY( m_aTipHelpFT, nHeightDelta );
      98           0 :         MovePosY( m_aHCOptionsLabel, nHeightDelta );
      99           0 :         MovePosY( m_aAutoDetectHC, nHeightDelta );
     100           0 :         MovePosY( m_aAutomaticFontColor, nHeightDelta );
     101           0 :         MovePosY( m_aPagePreviews, nHeightDelta );
     102             :     }
     103           0 : }
     104             : 
     105           0 : SvxAccessibilityOptionsTabPage::~SvxAccessibilityOptionsTabPage()
     106             : {
     107           0 :     delete m_pImpl;
     108           0 : }
     109             : 
     110           0 : SfxTabPage* SvxAccessibilityOptionsTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
     111             : {
     112           0 :     return new SvxAccessibilityOptionsTabPage(pParent, rAttrSet);
     113             : }
     114             : 
     115           0 : sal_Bool SvxAccessibilityOptionsTabPage::FillItemSet( SfxItemSet& )
     116             : {
     117             :     //aConfig.Set... from controls
     118             : 
     119           0 :     m_pImpl->m_aConfig.SetIsForPagePreviews( m_aPagePreviews.IsChecked() );
     120           0 :     m_pImpl->m_aConfig.SetIsHelpTipsDisappear( m_aTipHelpCB.IsChecked() );
     121           0 :     m_pImpl->m_aConfig.SetHelpTipSeconds( (short)m_aTipHelpNF.GetValue() );
     122           0 :     m_pImpl->m_aConfig.SetIsAllowAnimatedGraphics( m_aAnimatedGraphics.IsChecked() );
     123           0 :     m_pImpl->m_aConfig.SetIsAllowAnimatedText( m_aAnimatedTexts.IsChecked() );
     124           0 :     m_pImpl->m_aConfig.SetIsAutomaticFontColor( m_aAutomaticFontColor.IsChecked() );
     125           0 :     m_pImpl->m_aConfig.SetSelectionInReadonly( m_aTextSelectionInReadonly.IsChecked());
     126           0 :     m_pImpl->m_aConfig.SetAutoDetectSystemHC( m_aAutoDetectHC.IsChecked());
     127             : 
     128           0 :     if(m_pImpl->m_aConfig.IsModified())
     129           0 :         m_pImpl->m_aConfig.Commit();
     130             : 
     131           0 :     AllSettings aAllSettings = Application::GetSettings();
     132           0 :     MiscSettings aMiscSettings = aAllSettings.GetMiscSettings();
     133             : #ifndef UNX
     134             :     aMiscSettings.SetEnableATToolSupport( m_aAccessibilityTool.IsChecked() );
     135             : #endif
     136           0 :     aAllSettings.SetMiscSettings(aMiscSettings);
     137           0 :     Application::MergeSystemSettings( aAllSettings );
     138           0 :     Application::SetSettings(aAllSettings);
     139             : 
     140           0 :     return sal_False;
     141             : }
     142             : 
     143           0 : void SvxAccessibilityOptionsTabPage::Reset( const SfxItemSet& )
     144             : {
     145             :     //set controls from aConfig.Get...
     146             : 
     147           0 :     m_aPagePreviews.Check(            m_pImpl->m_aConfig.GetIsForPagePreviews() );
     148           0 :     EnableTipHelp(                    m_pImpl->m_aConfig.GetIsHelpTipsDisappear() );
     149           0 :     m_aTipHelpNF.SetValue(            m_pImpl->m_aConfig.GetHelpTipSeconds() );
     150           0 :     m_aAnimatedGraphics.Check(        m_pImpl->m_aConfig.GetIsAllowAnimatedGraphics() );
     151           0 :     m_aAnimatedTexts.Check(           m_pImpl->m_aConfig.GetIsAllowAnimatedText() );
     152           0 :     m_aAutomaticFontColor.Check(      m_pImpl->m_aConfig.GetIsAutomaticFontColor() );
     153           0 :     m_aTextSelectionInReadonly.Check( m_pImpl->m_aConfig.IsSelectionInReadonly() );
     154           0 :     m_aAutoDetectHC.Check(            m_pImpl->m_aConfig.GetAutoDetectSystemHC() );
     155             : 
     156             : 
     157           0 :     AllSettings aAllSettings = Application::GetSettings();
     158           0 :     MiscSettings aMiscSettings = aAllSettings.GetMiscSettings();
     159           0 :     m_aAccessibilityTool.Check( aMiscSettings.GetEnableATToolSupport() );
     160           0 : }
     161             : 
     162           0 : IMPL_LINK(SvxAccessibilityOptionsTabPage, TipHelpHdl, CheckBox*, pBox)
     163             : {
     164           0 :     sal_Bool bChecked = pBox->IsChecked();
     165           0 :     m_aTipHelpNF.Enable(bChecked);
     166           0 :     return 0;
     167             : }
     168             : 
     169           0 : void SvxAccessibilityOptionsTabPage::EnableTipHelp(sal_Bool bCheck)
     170             : {
     171           0 :     m_aTipHelpCB.Check(bCheck);
     172           0 :     m_aTipHelpNF.Enable(bCheck);
     173           3 : }
     174             : 
     175             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10