LCOV - code coverage report
Current view: top level - svtools/source/config - apearcfg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 57 92 62.0 %
Date: 2012-08-25 Functions: 4 10 40.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 47 115 40.9 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <svtools/apearcfg.hxx>
      31                 :            : #include "com/sun/star/uno/Any.hxx"
      32                 :            : 
      33                 :            : #include "tools/debug.hxx"
      34                 :            : #include "vcl/settings.hxx"
      35                 :            : #include "vcl/svapp.hxx"
      36                 :            : #include <rtl/logfile.hxx>
      37                 :            : #include <sal/macros.h>
      38                 :            : 
      39                 :            : #define DEFAULT_DRAGMODE    2
      40                 :            : #define DEFAULT_SNAPMODE    0
      41                 :            : #define DEFAULT_SCALEFACTOR 100
      42                 :            : #define DEFAULT_AAMINHEIGHT 8
      43                 :            : 
      44                 :            : using namespace ::rtl;
      45                 :            : using namespace ::com::sun::star::uno;
      46                 :            : 
      47                 :            : sal_Bool SvtTabAppearanceCfg::bInitialized = sal_False;
      48                 :            : 
      49                 :        474 : SvtTabAppearanceCfg::SvtTabAppearanceCfg()
      50                 :            :     :ConfigItem(OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/View")))
      51                 :            :     ,nDragMode          ( DEFAULT_DRAGMODE )
      52                 :            :     ,nScaleFactor       ( DEFAULT_SCALEFACTOR )
      53                 :            :     ,nSnapMode          ( DEFAULT_SNAPMODE )
      54                 :            :     ,nMiddleMouse       ( MOUSE_MIDDLE_AUTOSCROLL )
      55                 :            : #if defined( UNX )
      56                 :            :     ,nAAMinPixelHeight  ( DEFAULT_AAMINHEIGHT )
      57                 :            : #endif
      58                 :            :     ,bMenuMouseFollow(sal_False)
      59                 :            : #if defined( UNX )
      60         [ +  - ]:        474 :     ,bFontAntialiasing  ( sal_True )
      61                 :            : #endif
      62                 :            : {
      63                 :            :     RTL_LOGFILE_CONTEXT(aLog, "svtools SvtTabAppearanceCfg::SvtTabAppearanceCfg()");
      64                 :            : 
      65         [ +  - ]:        474 :     const Sequence<OUString>& rNames = GetPropertyNames();
      66         [ +  - ]:        474 :     Sequence<Any> aValues = GetProperties(rNames);
      67                 :        474 :     const Any* pValues = aValues.getConstArray();
      68                 :            :     DBG_ASSERT(aValues.getLength() == rNames.getLength(), "GetProperties failed");
      69                 :            : 
      70         [ +  - ]:        474 :     if(aValues.getLength() == rNames.getLength())
      71                 :            :     {
      72         [ +  + ]:       3792 :         for(int nProp = 0; nProp < rNames.getLength(); ++nProp, ++pValues)
      73                 :            :         {
      74         [ +  - ]:       3318 :             if(pValues->hasValue())
      75                 :            :             {
      76   [ +  +  +  +  :       3318 :                 switch(nProp)
             +  +  +  - ]
      77                 :            :                 {
      78                 :        474 :                     case  0: *pValues >>= nScaleFactor; break; //"FontScaling",
      79                 :        474 :                     case  1: *pValues >>= nDragMode; break;   //"Window/Drag",
      80                 :        474 :                     case  2: bMenuMouseFollow = *(sal_Bool*)pValues->getValue(); break; //"Menu/FollowMouse",
      81                 :        474 :                     case  3: *pValues >>= nSnapMode; break; //"Dialog/MousePositioning",
      82                 :        474 :                     case  4: *pValues >>= nMiddleMouse; break; //"Dialog/MiddleMouseButton",
      83                 :            : #if defined( UNX )
      84                 :        474 :                     case  5: bFontAntialiasing = *(sal_Bool*)pValues->getValue(); break;    // "FontAntialising/Enabled",
      85                 :       3318 :                     case  6: *pValues >>= nAAMinPixelHeight; break;                         // "FontAntialising/MinPixelHeight",
      86                 :            : #endif
      87                 :            :                 }
      88                 :            :             }
      89                 :            :         }
      90         [ +  - ]:        474 :     }
      91                 :        474 : }
      92                 :            : 
      93                 :        474 : SvtTabAppearanceCfg::~SvtTabAppearanceCfg( )
      94                 :            : {
      95         [ -  + ]:        474 : }
      96                 :            : 
      97                 :        474 : const Sequence<OUString>& SvtTabAppearanceCfg::GetPropertyNames()
      98                 :            : {
      99 [ +  + ][ +  - ]:        474 :     static Sequence<OUString> aNames;
         [ +  - ][ #  # ]
     100         [ +  + ]:        474 :     if(!aNames.getLength())
     101                 :            :     {
     102                 :            :         static const sal_Char* aPropNames[] =
     103                 :            :         {
     104                 :            :              "FontScaling"                       //  0
     105                 :            :             ,"Window/Drag"                       //  1
     106                 :            :             ,"Menu/FollowMouse"                  //  2
     107                 :            :             ,"Dialog/MousePositioning"           //  3
     108                 :            :             ,"Dialog/MiddleMouseButton"          //  4
     109                 :            : #if defined( UNX )
     110                 :            :             ,"FontAntiAliasing/Enabled"         //  5
     111                 :            :             ,"FontAntiAliasing/MinPixelHeight"  //  6
     112                 :            : #endif
     113                 :            :         };
     114                 :        158 :         const int nCount = SAL_N_ELEMENTS( aPropNames );
     115                 :        158 :         aNames.realloc(nCount);
     116                 :            : 
     117                 :        158 :         const sal_Char** pAsciiNames = aPropNames;
     118                 :        158 :         OUString* pNames = aNames.getArray();
     119         [ +  + ]:       1264 :         for(int i = 0; i < nCount; ++i, ++pNames, ++pAsciiNames)
     120                 :       1106 :             *pNames = OUString::createFromAscii( *pAsciiNames );
     121                 :            :     }
     122                 :        474 :     return aNames;
     123                 :            : }
     124                 :            : 
     125                 :          0 : void  SvtTabAppearanceCfg::Commit()
     126                 :            : {
     127         [ #  # ]:          0 :     const Sequence<OUString>& rNames = GetPropertyNames();
     128         [ #  # ]:          0 :     Sequence<Any> aValues(rNames.getLength());
     129         [ #  # ]:          0 :     Any* pValues = aValues.getArray();
     130                 :            : 
     131         [ #  # ]:          0 :     const Type& rType = ::getBooleanCppuType();
     132         [ #  # ]:          0 :     for(int nProp = 0; nProp < rNames.getLength(); nProp++)
     133                 :            :     {
     134   [ #  #  #  #  :          0 :         switch(nProp)
             #  #  #  # ]
     135                 :            :         {
     136         [ #  # ]:          0 :             case  0: pValues[nProp] <<= nScaleFactor; break;            // "FontScaling",
     137         [ #  # ]:          0 :             case  1: pValues[nProp] <<= nDragMode; break;               //"Window/Drag",
     138                 :          0 :             case  2: pValues[nProp].setValue(&bMenuMouseFollow, rType); break; //"Menu/FollowMouse",
     139         [ #  # ]:          0 :             case  3: pValues[nProp] <<= nSnapMode; break;               //"Dialog/MousePositioning",
     140         [ #  # ]:          0 :             case  4: pValues[nProp] <<= nMiddleMouse; break;               //"Dialog/MiddleMouseButton",
     141                 :            : #if defined( UNX )
     142                 :          0 :             case  5: pValues[nProp].setValue(&bFontAntialiasing, rType); break; // "FontAntialising/Enabled",
     143         [ #  # ]:          0 :             case  6: pValues[nProp] <<= nAAMinPixelHeight; break;               // "FontAntialising/MinPixelHeight",
     144                 :            : #endif
     145                 :            :         }
     146                 :            :     }
     147 [ #  # ][ #  # ]:          0 :     PutProperties(rNames, aValues);
     148                 :          0 : }
     149                 :            : 
     150                 :          0 : void SvtTabAppearanceCfg::Notify( const com::sun::star::uno::Sequence< rtl::OUString >& )
     151                 :            : {
     152                 :          0 : }
     153                 :            : 
     154                 :          0 : void SvtTabAppearanceCfg::SetScaleFactor ( sal_uInt16 nSet )
     155                 :            : {
     156                 :          0 :     nScaleFactor = nSet;
     157                 :          0 :     SetModified();
     158                 :          0 : }
     159                 :            : 
     160                 :          0 : void SvtTabAppearanceCfg::SetSnapMode ( sal_uInt16 nSet )
     161                 :            : {
     162                 :          0 :     nSnapMode = nSet;
     163                 :          0 :     SetModified();
     164                 :          0 : }
     165                 :            : 
     166                 :          0 : void SvtTabAppearanceCfg::SetMiddleMouseButton ( sal_uInt16 nSet )
     167                 :            : {
     168                 :          0 :     nMiddleMouse = nSet;
     169                 :          0 :     SetModified();
     170                 :          0 : }
     171                 :            : 
     172                 :        158 : void SvtTabAppearanceCfg::SetApplicationDefaults ( Application* pApp )
     173                 :            : {
     174 [ +  - ][ +  - ]:        158 :     AllSettings   hAppSettings = pApp->GetSettings();
     175         [ +  - ]:        158 :     StyleSettings hAppStyle    = hAppSettings.GetStyleSettings();
     176                 :            : 
     177                 :            :     // Look & Feel
     178                 :            : 
     179                 :            :     // SetStandard...Styles() resets the UseSystemUIFonts flag,
     180                 :            :     // but we don't want to change it now, so save the flag before ...
     181                 :        158 :     sal_Bool bUseSystemUIFonts = hAppStyle.GetUseSystemUIFonts();
     182         [ +  - ]:        158 :     hAppStyle.SetStandardStyles();
     183                 :            :     // and set it here
     184         [ +  - ]:        158 :     hAppStyle.SetUseSystemUIFonts( bUseSystemUIFonts );
     185                 :            : 
     186                 :            :     // Screen and ScreenFont Scaling
     187                 :            : 
     188         [ +  - ]:        158 :     hAppStyle.SetScreenZoom( nScaleFactor );
     189         [ +  - ]:        158 :     hAppStyle.SetScreenFontZoom( nScaleFactor );
     190                 :            : 
     191                 :            : #if defined( UNX )
     192                 :            :     // font anti aliasing
     193         [ +  - ]:        158 :     hAppStyle.SetAntialiasingMinPixelHeight( nAAMinPixelHeight );
     194         [ +  - ]:        158 :     hAppStyle.SetDisplayOptions( bFontAntialiasing ? 0 : DISPLAY_OPTION_AA_DISABLE );
     195                 :            : #endif
     196                 :            : 
     197                 :            :     // Mouse Snap
     198                 :            : 
     199         [ +  - ]:        158 :     MouseSettings hMouseSettings = hAppSettings.GetMouseSettings();
     200                 :        158 :     sal_uLong         nMouseOptions  = hMouseSettings.GetOptions();
     201                 :            : 
     202                 :        158 :     nMouseOptions &=  ! (MOUSE_OPTION_AUTOCENTERPOS | MOUSE_OPTION_AUTODEFBTNPOS);
     203                 :            : 
     204      [ -  -  + ]:        158 :     switch ( nSnapMode )
     205                 :            :     {
     206                 :            :     case SnapToButton:
     207                 :          0 :         nMouseOptions |= MOUSE_OPTION_AUTODEFBTNPOS;
     208                 :          0 :         break;
     209                 :            :     case SnapToMiddle:
     210                 :          0 :         nMouseOptions |= MOUSE_OPTION_AUTOCENTERPOS;
     211                 :          0 :         break;
     212                 :            :     case NoSnap:
     213                 :            :     default:
     214                 :        158 :         break;
     215                 :            :     }
     216         [ +  - ]:        158 :     hMouseSettings.SetOptions(nMouseOptions);
     217         [ +  - ]:        158 :     hMouseSettings.SetMiddleButtonAction(nMiddleMouse);
     218                 :            : 
     219                 :            :     // Merge and Publish Settings
     220                 :            : 
     221                 :        158 :     sal_uLong nFollow = hMouseSettings.GetFollow();
     222         [ +  - ]:        158 :     if(bMenuMouseFollow)
     223                 :        158 :         nFollow |= MOUSE_FOLLOW_MENU;
     224                 :            :     else
     225                 :          0 :         nFollow &= ~MOUSE_FOLLOW_MENU;
     226         [ +  - ]:        158 :     hMouseSettings.SetFollow( nFollow );
     227                 :            : 
     228         [ +  - ]:        158 :     hAppSettings.SetMouseSettings( hMouseSettings );
     229                 :            : 
     230         [ +  - ]:        158 :     hAppSettings.SetStyleSettings( hAppStyle );
     231         [ +  - ]:        158 :     pApp->MergeSystemSettings    ( hAppSettings );      // Allow system-settings to apply
     232         [ +  - ]:        158 :     pApp->SystemSettingsChanging ( hAppSettings, NULL );// Allow overruling of system-settings
     233                 :            :                                                         //is concerned with window drag
     234                 :            : 
     235 [ +  - ][ +  - ]:        158 :     pApp->SetSettings ( hAppSettings );
         [ +  - ][ +  - ]
     236                 :        158 : }
     237                 :            : 
     238                 :            : 
     239                 :            : 
     240                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10