LCOV - code coverage report
Current view: top level - sc/source/core/tool - inputopt.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 115 0.0 %
Date: 2014-04-14 Functions: 0 11 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             : #include <com/sun/star/uno/Any.hxx>
      21             : #include <com/sun/star/uno/Sequence.hxx>
      22             : 
      23             : #include "cfgids.hxx"
      24             : #include "inputopt.hxx"
      25             : #include "rechead.hxx"
      26             : #include "scresid.hxx"
      27             : #include "global.hxx"
      28             : #include "sc.hrc"
      29             : #include "miscuno.hxx"
      30             : 
      31             : using namespace utl;
      32             : using namespace com::sun::star::uno;
      33             : 
      34             : // ScInputOptions - input options
      35             : 
      36           0 : ScInputOptions::ScInputOptions()
      37             : {
      38           0 :     SetDefaults();
      39           0 : }
      40             : 
      41           0 : ScInputOptions::ScInputOptions( const ScInputOptions& rCpy )
      42             : {
      43           0 :     *this = rCpy;
      44           0 : }
      45             : 
      46           0 : ScInputOptions::~ScInputOptions()
      47             : {
      48           0 : }
      49             : 
      50           0 : void ScInputOptions::SetDefaults()
      51             : {
      52           0 :     nMoveDir        = DIR_BOTTOM;
      53           0 :     bMoveSelection  = true;
      54           0 :     bEnterEdit      = false;
      55           0 :     bExtendFormat   = false;
      56           0 :     bRangeFinder    = true;
      57           0 :     bExpandRefs     = false;
      58           0 :     bMarkHeader     = true;
      59           0 :     bUseTabCol      = false;
      60           0 :     bTextWysiwyg    = false;
      61           0 :     bReplCellsWarn  = true;
      62           0 :     bLegacyCellSelection = false;
      63           0 : }
      64             : 
      65           0 : const ScInputOptions& ScInputOptions::operator=( const ScInputOptions& rCpy )
      66             : {
      67           0 :     nMoveDir        = rCpy.nMoveDir;
      68           0 :     bMoveSelection  = rCpy.bMoveSelection;
      69           0 :     bEnterEdit      = rCpy.bEnterEdit;
      70           0 :     bExtendFormat   = rCpy.bExtendFormat;
      71           0 :     bRangeFinder    = rCpy.bRangeFinder;
      72           0 :     bExpandRefs     = rCpy.bExpandRefs;
      73           0 :     bMarkHeader     = rCpy.bMarkHeader;
      74           0 :     bUseTabCol      = rCpy.bUseTabCol;
      75           0 :     bTextWysiwyg    = rCpy.bTextWysiwyg;
      76           0 :     bReplCellsWarn  = rCpy.bReplCellsWarn;
      77           0 :     bLegacyCellSelection = rCpy.bLegacyCellSelection;
      78             : 
      79           0 :     return *this;
      80             : }
      81             : 
      82             : //  Config Item containing input options
      83             : 
      84             : #define CFGPATH_INPUT           "Office.Calc/Input"
      85             : 
      86             : #define SCINPUTOPT_MOVEDIR                0
      87             : #define SCINPUTOPT_MOVESEL                1
      88             : #define SCINPUTOPT_EDTEREDIT              2
      89             : #define SCINPUTOPT_EXTENDFMT              3
      90             : #define SCINPUTOPT_RANGEFIND              4
      91             : #define SCINPUTOPT_EXPANDREFS             5
      92             : #define SCINPUTOPT_MARKHEADER             6
      93             : #define SCINPUTOPT_USETABCOL              7
      94             : #define SCINPUTOPT_TEXTWYSIWYG            8
      95             : #define SCINPUTOPT_REPLCELLSWARN          9
      96             : #define SCINPUTOPT_LEGACY_CELL_SELECTION 10
      97             : #define SCINPUTOPT_COUNT                 11
      98             : 
      99           0 : Sequence<OUString> ScInputCfg::GetPropertyNames()
     100             : {
     101             :     static const char* aPropNames[] =
     102             :     {
     103             :         "MoveSelectionDirection",   // SCINPUTOPT_MOVEDIR
     104             :         "MoveSelection",            // SCINPUTOPT_MOVESEL
     105             :         "SwitchToEditMode",         // SCINPUTOPT_EDTEREDIT
     106             :         "ExpandFormatting",         // SCINPUTOPT_EXTENDFMT
     107             :         "ShowReference",            // SCINPUTOPT_RANGEFIND
     108             :         "ExpandReference",          // SCINPUTOPT_EXPANDREFS
     109             :         "HighlightSelection",       // SCINPUTOPT_MARKHEADER
     110             :         "UseTabCol",                // SCINPUTOPT_USETABCOL
     111             :         "UsePrinterMetrics",        // SCINPUTOPT_TEXTWYSIWYG
     112             :         "ReplaceCellsWarning",      // SCINPUTOPT_REPLCELLSWARN
     113             :         "LegacyCellSelection"       // SCINPUTOPT_LEGACY_CELL_SELECTION
     114             :     };
     115           0 :     Sequence<OUString> aNames(SCINPUTOPT_COUNT);
     116           0 :     OUString* pNames = aNames.getArray();
     117           0 :     for(int i = 0; i < SCINPUTOPT_COUNT; i++)
     118           0 :         pNames[i] = OUString::createFromAscii(aPropNames[i]);
     119             : 
     120           0 :     return aNames;
     121             : }
     122             : 
     123           0 : ScInputCfg::ScInputCfg() :
     124           0 :     ConfigItem( OUString( CFGPATH_INPUT ) )
     125             : {
     126           0 :     Sequence<OUString> aNames = GetPropertyNames();
     127           0 :     Sequence<Any> aValues = GetProperties(aNames);
     128           0 :     EnableNotification(aNames);
     129           0 :     const Any* pValues = aValues.getConstArray();
     130             :     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
     131           0 :     if(aValues.getLength() == aNames.getLength())
     132             :     {
     133           0 :         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     134             :         {
     135             :             OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
     136           0 :             if(pValues[nProp].hasValue())
     137             :             {
     138           0 :                 sal_Int32 nIntVal = 0;
     139           0 :                 switch(nProp)
     140             :                 {
     141             :                     case SCINPUTOPT_MOVEDIR:
     142           0 :                         if ( pValues[nProp] >>= nIntVal )
     143           0 :                             SetMoveDir( (sal_uInt16)nIntVal );
     144           0 :                         break;
     145             :                     case SCINPUTOPT_MOVESEL:
     146           0 :                         SetMoveSelection( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     147           0 :                         break;
     148             :                     case SCINPUTOPT_EDTEREDIT:
     149           0 :                         SetEnterEdit( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     150           0 :                         break;
     151             :                     case SCINPUTOPT_EXTENDFMT:
     152           0 :                         SetExtendFormat( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     153           0 :                         break;
     154             :                     case SCINPUTOPT_RANGEFIND:
     155           0 :                         SetRangeFinder( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     156           0 :                         break;
     157             :                     case SCINPUTOPT_EXPANDREFS:
     158           0 :                         SetExpandRefs( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     159           0 :                         break;
     160             :                     case SCINPUTOPT_MARKHEADER:
     161           0 :                         SetMarkHeader( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     162           0 :                         break;
     163             :                     case SCINPUTOPT_USETABCOL:
     164           0 :                         SetUseTabCol( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     165           0 :                         break;
     166             :                     case SCINPUTOPT_TEXTWYSIWYG:
     167           0 :                         SetTextWysiwyg( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     168           0 :                         break;
     169             :                     case SCINPUTOPT_REPLCELLSWARN:
     170           0 :                         SetReplaceCellsWarn( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     171           0 :                         break;
     172             :                     case SCINPUTOPT_LEGACY_CELL_SELECTION:
     173           0 :                         SetLegacyCellSelection( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     174           0 :                         break;
     175             :                 }
     176             :             }
     177             :         }
     178           0 :     }
     179           0 : }
     180             : 
     181           0 : void ScInputCfg::Commit()
     182             : {
     183           0 :     Sequence<OUString> aNames = GetPropertyNames();
     184           0 :     Sequence<Any> aValues(aNames.getLength());
     185           0 :     Any* pValues = aValues.getArray();
     186             : 
     187           0 :     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     188             :     {
     189           0 :         switch(nProp)
     190             :         {
     191             :             case SCINPUTOPT_MOVEDIR:
     192           0 :                 pValues[nProp] <<= (sal_Int32) GetMoveDir();
     193           0 :                 break;
     194             :             case SCINPUTOPT_MOVESEL:
     195           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetMoveSelection() );
     196           0 :                 break;
     197             :             case SCINPUTOPT_EDTEREDIT:
     198           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetEnterEdit() );
     199           0 :                 break;
     200             :             case SCINPUTOPT_EXTENDFMT:
     201           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetExtendFormat() );
     202           0 :                 break;
     203             :             case SCINPUTOPT_RANGEFIND:
     204           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetRangeFinder() );
     205           0 :                 break;
     206             :             case SCINPUTOPT_EXPANDREFS:
     207           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetExpandRefs() );
     208           0 :                 break;
     209             :             case SCINPUTOPT_MARKHEADER:
     210           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetMarkHeader() );
     211           0 :                 break;
     212             :             case SCINPUTOPT_USETABCOL:
     213           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetUseTabCol() );
     214           0 :                 break;
     215             :             case SCINPUTOPT_TEXTWYSIWYG:
     216           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetTextWysiwyg() );
     217           0 :                 break;
     218             :             case SCINPUTOPT_REPLCELLSWARN:
     219           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetReplaceCellsWarn() );
     220           0 :                 break;
     221             :             case SCINPUTOPT_LEGACY_CELL_SELECTION:
     222           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetLegacyCellSelection() );
     223           0 :                 break;
     224             :         }
     225             :     }
     226           0 :     PutProperties(aNames, aValues);
     227           0 : }
     228             : 
     229           0 : void ScInputCfg::Notify( const Sequence<OUString>& /* aPropertyNames */ )
     230             : {
     231             :     OSL_FAIL("properties have been changed");
     232           0 : }
     233             : 
     234           0 : void ScInputCfg::SetOptions( const ScInputOptions& rNew )
     235             : {
     236           0 :     *(ScInputOptions*)this = rNew;
     237           0 :     SetModified();
     238           0 : }
     239             : 
     240           0 : void ScInputCfg::OptionsChanged()
     241             : {
     242           0 :     SetModified();
     243           0 : }
     244             : 
     245             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10