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

Generated by: LCOV version 1.10