LCOV - code coverage report
Current view: top level - svtools/source/config - apearcfg.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 92 0.0 %
Date: 2014-04-14 Functions: 0 10 0.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/apearcfg.hxx>
      22             : #include "com/sun/star/uno/Any.hxx"
      23             : 
      24             : #include "tools/debug.hxx"
      25             : #include "vcl/settings.hxx"
      26             : #include "vcl/svapp.hxx"
      27             : #include <sal/macros.h>
      28             : 
      29             : #define DEFAULT_DRAGMODE    2
      30             : #define DEFAULT_SNAPMODE    0
      31             : #define DEFAULT_SCALEFACTOR 100
      32             : #if defined UNX
      33             : #define DEFAULT_AAMINHEIGHT 8
      34             : #endif
      35             : 
      36             : using namespace ::rtl;
      37             : using namespace ::com::sun::star::uno;
      38             : 
      39             : bool SvtTabAppearanceCfg::bInitialized = false;
      40             : 
      41           0 : SvtTabAppearanceCfg::SvtTabAppearanceCfg()
      42             :     :ConfigItem(OUString("Office.Common/View"))
      43             :     ,nDragMode          ( DEFAULT_DRAGMODE )
      44             :     ,nScaleFactor       ( DEFAULT_SCALEFACTOR )
      45             :     ,nSnapMode          ( DEFAULT_SNAPMODE )
      46             :     ,nMiddleMouse       ( MOUSE_MIDDLE_AUTOSCROLL )
      47             : #if defined( UNX )
      48             :     ,nAAMinPixelHeight  ( DEFAULT_AAMINHEIGHT )
      49             : #endif
      50             :     ,bMenuMouseFollow   ( false )
      51             : #if defined( UNX )
      52           0 :     ,bFontAntialiasing  ( true )
      53             : #endif
      54             : {
      55           0 :     const Sequence<OUString>& rNames = GetPropertyNames();
      56           0 :     Sequence<Any> aValues = GetProperties(rNames);
      57           0 :     const Any* pValues = aValues.getConstArray();
      58             :     DBG_ASSERT(aValues.getLength() == rNames.getLength(), "GetProperties failed");
      59             : 
      60           0 :     if(aValues.getLength() == rNames.getLength())
      61             :     {
      62           0 :         for(int nProp = 0; nProp < rNames.getLength(); ++nProp, ++pValues)
      63             :         {
      64           0 :             if(pValues->hasValue())
      65             :             {
      66           0 :                 switch(nProp)
      67             :                 {
      68           0 :                     case  0: *pValues >>= nScaleFactor; break; //"FontScaling",
      69           0 :                     case  1: *pValues >>= nDragMode; break;   //"Window/Drag",
      70           0 :                     case  2: bMenuMouseFollow = *(sal_Bool*)pValues->getValue(); break; //"Menu/FollowMouse",
      71           0 :                     case  3: *pValues >>= nSnapMode; break; //"Dialog/MousePositioning",
      72           0 :                     case  4: *pValues >>= nMiddleMouse; break; //"Dialog/MiddleMouseButton",
      73             : #if defined( UNX )
      74           0 :                     case  5: bFontAntialiasing = *(sal_Bool*)pValues->getValue(); break;    // "FontAntialising/Enabled",
      75           0 :                     case  6: *pValues >>= nAAMinPixelHeight; break;                         // "FontAntialising/MinPixelHeight",
      76             : #endif
      77             :                 }
      78             :             }
      79             :         }
      80           0 :     }
      81           0 : }
      82             : 
      83           0 : SvtTabAppearanceCfg::~SvtTabAppearanceCfg( )
      84             : {
      85           0 : }
      86             : 
      87           0 : const Sequence<OUString>& SvtTabAppearanceCfg::GetPropertyNames()
      88             : {
      89           0 :     static Sequence<OUString> aNames;
      90           0 :     if(!aNames.getLength())
      91             :     {
      92             :         static const sal_Char* aPropNames[] =
      93             :         {
      94             :              "FontScaling"                       //  0
      95             :             ,"Window/Drag"                       //  1
      96             :             ,"Menu/FollowMouse"                  //  2
      97             :             ,"Dialog/MousePositioning"           //  3
      98             :             ,"Dialog/MiddleMouseButton"          //  4
      99             : #if defined( UNX )
     100             :             ,"FontAntiAliasing/Enabled"         //  5
     101             :             ,"FontAntiAliasing/MinPixelHeight"  //  6
     102             : #endif
     103             :         };
     104           0 :         const int nCount = SAL_N_ELEMENTS( aPropNames );
     105           0 :         aNames.realloc(nCount);
     106             : 
     107           0 :         const sal_Char** pAsciiNames = aPropNames;
     108           0 :         OUString* pNames = aNames.getArray();
     109           0 :         for(int i = 0; i < nCount; ++i, ++pNames, ++pAsciiNames)
     110           0 :             *pNames = OUString::createFromAscii( *pAsciiNames );
     111             :     }
     112           0 :     return aNames;
     113             : }
     114             : 
     115           0 : void  SvtTabAppearanceCfg::Commit()
     116             : {
     117           0 :     const Sequence<OUString>& rNames = GetPropertyNames();
     118           0 :     Sequence<Any> aValues(rNames.getLength());
     119           0 :     Any* pValues = aValues.getArray();
     120             : 
     121           0 :     const Type& rType = ::getBooleanCppuType();
     122           0 :     for(int nProp = 0; nProp < rNames.getLength(); nProp++)
     123             :     {
     124           0 :         switch(nProp)
     125             :         {
     126           0 :             case  0: pValues[nProp] <<= nScaleFactor; break;            // "FontScaling",
     127           0 :             case  1: pValues[nProp] <<= nDragMode; break;               //"Window/Drag",
     128           0 :             case  2: pValues[nProp].setValue(&bMenuMouseFollow, rType); break; //"Menu/FollowMouse",
     129           0 :             case  3: pValues[nProp] <<= nSnapMode; break;               //"Dialog/MousePositioning",
     130           0 :             case  4: pValues[nProp] <<= nMiddleMouse; break;               //"Dialog/MiddleMouseButton",
     131             : #if defined( UNX )
     132           0 :             case  5: pValues[nProp].setValue(&bFontAntialiasing, rType); break; // "FontAntialising/Enabled",
     133           0 :             case  6: pValues[nProp] <<= nAAMinPixelHeight; break;               // "FontAntialising/MinPixelHeight",
     134             : #endif
     135             :         }
     136             :     }
     137           0 :     PutProperties(rNames, aValues);
     138           0 : }
     139             : 
     140           0 : void SvtTabAppearanceCfg::Notify( const com::sun::star::uno::Sequence< OUString >& )
     141             : {
     142           0 : }
     143             : 
     144           0 : void SvtTabAppearanceCfg::SetScaleFactor ( sal_uInt16 nSet )
     145             : {
     146           0 :     nScaleFactor = nSet;
     147           0 :     SetModified();
     148           0 : }
     149             : 
     150           0 : void SvtTabAppearanceCfg::SetSnapMode ( sal_uInt16 nSet )
     151             : {
     152           0 :     nSnapMode = nSet;
     153           0 :     SetModified();
     154           0 : }
     155             : 
     156           0 : void SvtTabAppearanceCfg::SetMiddleMouseButton ( sal_uInt16 nSet )
     157             : {
     158           0 :     nMiddleMouse = nSet;
     159           0 :     SetModified();
     160           0 : }
     161             : 
     162           0 : void SvtTabAppearanceCfg::SetApplicationDefaults ( Application* pApp )
     163             : {
     164           0 :     AllSettings   hAppSettings = pApp->GetSettings();
     165           0 :     StyleSettings hAppStyle    = hAppSettings.GetStyleSettings();
     166             : 
     167             :     // Look & Feel
     168             : 
     169             :     // SetStandard...Styles() resets the UseSystemUIFonts flag,
     170             :     // but we don't want to change it now, so save the flag before ...
     171           0 :     sal_Bool bUseSystemUIFonts = hAppStyle.GetUseSystemUIFonts();
     172           0 :     hAppStyle.SetStandardStyles();
     173             :     // and set it here
     174           0 :     hAppStyle.SetUseSystemUIFonts( bUseSystemUIFonts );
     175             : 
     176             :     // Screen and ScreenFont Scaling
     177             : 
     178           0 :     hAppStyle.SetScreenZoom( nScaleFactor );
     179           0 :     hAppStyle.SetScreenFontZoom( nScaleFactor );
     180             : 
     181             : #if defined( UNX )
     182             :     // font anti aliasing
     183           0 :     hAppStyle.SetAntialiasingMinPixelHeight( nAAMinPixelHeight );
     184           0 :     hAppStyle.SetDisplayOptions( bFontAntialiasing ? 0 : DISPLAY_OPTION_AA_DISABLE );
     185             : #endif
     186             : 
     187             :     // Mouse Snap
     188             : 
     189           0 :     MouseSettings hMouseSettings = hAppSettings.GetMouseSettings();
     190           0 :     sal_uLong         nMouseOptions  = hMouseSettings.GetOptions();
     191             : 
     192           0 :     nMouseOptions &=  ~ (MOUSE_OPTION_AUTOCENTERPOS | MOUSE_OPTION_AUTODEFBTNPOS);
     193             : 
     194           0 :     switch ( nSnapMode )
     195             :     {
     196             :     case SnapToButton:
     197           0 :         nMouseOptions |= MOUSE_OPTION_AUTODEFBTNPOS;
     198           0 :         break;
     199             :     case SnapToMiddle:
     200           0 :         nMouseOptions |= MOUSE_OPTION_AUTOCENTERPOS;
     201           0 :         break;
     202             :     case NoSnap:
     203             :     default:
     204           0 :         break;
     205             :     }
     206           0 :     hMouseSettings.SetOptions(nMouseOptions);
     207           0 :     hMouseSettings.SetMiddleButtonAction(nMiddleMouse);
     208             : 
     209             :     // Merge and Publish Settings
     210             : 
     211           0 :     sal_uLong nFollow = hMouseSettings.GetFollow();
     212           0 :     if(bMenuMouseFollow)
     213           0 :         nFollow |= MOUSE_FOLLOW_MENU;
     214             :     else
     215           0 :         nFollow &= ~MOUSE_FOLLOW_MENU;
     216           0 :     hMouseSettings.SetFollow( nFollow );
     217             : 
     218           0 :     hAppSettings.SetMouseSettings( hMouseSettings );
     219             : 
     220           0 :     hAppSettings.SetStyleSettings( hAppStyle );
     221           0 :     pApp->MergeSystemSettings    ( hAppSettings );      // Allow system-settings to apply
     222           0 :     pApp->OverrideSystemSettings ( hAppSettings );
     223             : 
     224           0 :     pApp->SetSettings ( hAppSettings );
     225           0 : }
     226             : 
     227             : 
     228             : 
     229             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10