LCOV - code coverage report
Current view: top level - sc/source/ui/unoobj - optuno.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 73 105 69.5 %
Date: 2014-04-11 Functions: 2 9 22.2 %
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 <svl/itemprop.hxx>
      21             : 
      22             : #include <com/sun/star/util/Date.hpp>
      23             : 
      24             : #include "optuno.hxx"
      25             : #include "miscuno.hxx"
      26             : #include "unonames.hxx"
      27             : #include "docoptio.hxx"
      28             : 
      29             : using namespace com::sun::star;
      30             : 
      31             : 
      32           0 : const SfxItemPropertyMapEntry* ScDocOptionsHelper::GetPropertyMap()
      33             : {
      34             :     static const SfxItemPropertyMapEntry aMap[] =
      35             :     {
      36           0 :         {OUString(SC_UNO_CALCASSHOWN),  PROP_UNO_CALCASSHOWN ,  getBooleanCppuType(),          0, 0},
      37           0 :         {OUString(SC_UNO_DEFTABSTOP),   PROP_UNO_DEFTABSTOP  ,  getCppuType((sal_Int16*)0),    0, 0},
      38           0 :         {OUString(SC_UNO_IGNORECASE),   PROP_UNO_IGNORECASE  ,  getBooleanCppuType(),          0, 0},
      39           0 :         {OUString(SC_UNO_ITERENABLED),  PROP_UNO_ITERENABLED ,  getBooleanCppuType(),          0, 0},
      40           0 :         {OUString(SC_UNO_ITERCOUNT),    PROP_UNO_ITERCOUNT   ,  getCppuType((sal_Int32*)0),    0, 0},
      41           0 :         {OUString(SC_UNO_ITEREPSILON),  PROP_UNO_ITEREPSILON ,  getCppuType((double*)0),       0, 0},
      42           0 :         {OUString(SC_UNO_LOOKUPLABELS), PROP_UNO_LOOKUPLABELS,  getBooleanCppuType(),          0, 0},
      43           0 :         {OUString(SC_UNO_MATCHWHOLE),   PROP_UNO_MATCHWHOLE  ,  getBooleanCppuType(),          0, 0},
      44           0 :         {OUString(SC_UNO_NULLDATE),     PROP_UNO_NULLDATE    ,  getCppuType((util::Date*)0),   0, 0},
      45           0 :         {OUString(SC_UNO_SPELLONLINE),  PROP_UNO_SPELLONLINE ,  getBooleanCppuType(),          0, 0},
      46           0 :         {OUString(SC_UNO_STANDARDDEC),  PROP_UNO_STANDARDDEC ,  getCppuType((sal_Int16*)0),    0, 0},
      47           0 :         {OUString(SC_UNO_REGEXENABLED), PROP_UNO_REGEXENABLED,  getBooleanCppuType(),          0, 0},
      48             :         { OUString(), 0, css::uno::Type(), 0, 0 }
      49           0 :     };
      50           0 :     return aMap;
      51             : }
      52             : 
      53        1819 : bool ScDocOptionsHelper::setPropertyValue( ScDocOptions& rOptions,
      54             :                 const SfxItemPropertyMap& rPropMap,
      55             :                 const OUString& aPropertyName, const uno::Any& aValue )
      56             : {
      57             :     //! use map (with new identifiers)
      58             : 
      59        1819 :     const SfxItemPropertySimpleEntry* pEntry = rPropMap.getByName(aPropertyName );
      60        1819 :     if( !pEntry || !pEntry->nWID )
      61         432 :         return false;
      62        1387 :     switch( pEntry->nWID )
      63             :     {
      64             :         case PROP_UNO_CALCASSHOWN :
      65         157 :             rOptions.SetCalcAsShown( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
      66         157 :         break;
      67             :         case PROP_UNO_DEFTABSTOP  :
      68             :         {
      69           6 :             sal_Int16 nIntVal = 0;
      70           6 :             if ( aValue >>= nIntVal )
      71           6 :                 rOptions.SetTabDistance( nIntVal );
      72             :         }
      73           6 :         break;
      74             :         case PROP_UNO_IGNORECASE  :
      75         157 :             rOptions.SetIgnoreCase( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
      76         157 :         break;
      77             :         case PROP_UNO_ITERENABLED:
      78         157 :             rOptions.SetIter( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
      79         157 :         break;
      80             :         case PROP_UNO_ITERCOUNT   :
      81             :         {
      82         157 :             sal_Int32 nIntVal = 0;
      83         157 :             if ( aValue >>= nIntVal )
      84         157 :                 rOptions.SetIterCount( (sal_uInt16)nIntVal );
      85             :         }
      86         157 :         break;
      87             :         case PROP_UNO_ITEREPSILON :
      88             :         {
      89         157 :             double fDoubleVal = 0;
      90         157 :             if ( aValue >>= fDoubleVal )
      91         157 :                 rOptions.SetIterEps( fDoubleVal );
      92             :         }
      93         157 :         break;
      94             :         case PROP_UNO_LOOKUPLABELS :
      95         157 :             rOptions.SetLookUpColRowNames( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
      96         157 :         break;
      97             :         case PROP_UNO_MATCHWHOLE  :
      98         113 :             rOptions.SetMatchWholeCell( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
      99         113 :         break;
     100             :         case PROP_UNO_NULLDATE:
     101             :         {
     102         157 :             util::Date aDate;
     103         157 :             if ( aValue >>= aDate )
     104         157 :                 rOptions.SetDate( aDate.Day, aDate.Month, aDate.Year );
     105             :         }
     106         157 :         break;
     107             :         case PROP_UNO_SPELLONLINE:
     108           6 :             rOptions.SetAutoSpell( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     109           6 :         break;
     110             :         case PROP_UNO_STANDARDDEC:
     111             :         {
     112           6 :             sal_Int16 nIntVal = 0;
     113           6 :             if ( aValue >>= nIntVal )
     114           6 :                 rOptions.SetStdPrecision( nIntVal );
     115             :         }
     116           6 :         break;
     117             :         case PROP_UNO_REGEXENABLED:
     118         157 :             rOptions.SetFormulaRegexEnabled( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     119         157 :         break;
     120             :         default:;
     121             :     }
     122        1387 :     return true;
     123             : }
     124             : 
     125        4006 : uno::Any ScDocOptionsHelper::getPropertyValue(
     126             :                 const ScDocOptions& rOptions,
     127             :                 const SfxItemPropertyMap& rPropMap,
     128             :                 const OUString& aPropertyName )
     129             : {
     130        4006 :     uno::Any aRet;
     131        4006 :     const SfxItemPropertySimpleEntry* pEntry = rPropMap.getByName( aPropertyName );
     132        4006 :     if( !pEntry || !pEntry->nWID )
     133        3612 :         return aRet;
     134         394 :     switch( pEntry->nWID )
     135             :     {
     136             :         case PROP_UNO_CALCASSHOWN :
     137          32 :             ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsCalcAsShown() );
     138          32 :         break;
     139             :         case PROP_UNO_DEFTABSTOP :
     140          14 :             aRet <<= (sal_Int16)( rOptions.GetTabDistance() );
     141          14 :         break;
     142             :         case PROP_UNO_IGNORECASE :
     143          32 :             ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsIgnoreCase() );
     144          32 :         break;
     145             :         case PROP_UNO_ITERENABLED:
     146          32 :         ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsIter() );
     147          32 :         break;
     148             :         case PROP_UNO_ITERCOUNT:
     149          32 :             aRet <<= (sal_Int32)( rOptions.GetIterCount() );
     150          32 :         break;
     151             :         case PROP_UNO_ITEREPSILON:
     152          32 :             aRet <<= (double)( rOptions.GetIterEps() );
     153          32 :         break;
     154             :         case PROP_UNO_LOOKUPLABELS:
     155          32 :             ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsLookUpColRowNames() );
     156          32 :         break;
     157             :         case PROP_UNO_MATCHWHOLE:
     158          32 :             ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsMatchWholeCell() );
     159          32 :         break;
     160             :         case PROP_UNO_NULLDATE:
     161             :         {
     162             :             sal_uInt16 nD, nM, nY;
     163          96 :             rOptions.GetDate( nD, nM, nY );
     164          96 :             util::Date aDate( nD, nM, nY );
     165          96 :             aRet <<= aDate;
     166             :         }
     167          96 :         break;
     168             :         case PROP_UNO_SPELLONLINE:
     169          14 :             ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsAutoSpell() );
     170          14 :         break;
     171             :         case PROP_UNO_STANDARDDEC :
     172          14 :             aRet <<= (sal_Int16)( rOptions.GetStdPrecision() );
     173          14 :         break;
     174             :         case PROP_UNO_REGEXENABLED:
     175          32 :             ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsFormulaRegexEnabled() );
     176          32 :         break;
     177             :         default:;
     178             :     }
     179         394 :     return aRet;
     180             : }
     181             : 
     182           0 : ScDocOptionsObj::ScDocOptionsObj( const ScDocOptions& rOpt ) :
     183             :     ScModelObj( NULL ),
     184           0 :     aOptions( rOpt )
     185             : {
     186           0 : }
     187             : 
     188           0 : ScDocOptionsObj::~ScDocOptionsObj()
     189             : {
     190           0 : }
     191             : 
     192           0 : void SAL_CALL ScDocOptionsObj::setPropertyValue(
     193             :                         const OUString& aPropertyName, const uno::Any& aValue )
     194             :                 throw(beans::UnknownPropertyException, beans::PropertyVetoException,
     195             :                         lang::IllegalArgumentException, lang::WrappedTargetException,
     196             :                         uno::RuntimeException, std::exception)
     197             : {
     198           0 :     SolarMutexGuard aGuard;
     199             : 
     200           0 :     sal_Bool bDone = ScDocOptionsHelper::setPropertyValue( aOptions, GetPropertySet().getPropertyMap(), aPropertyName, aValue );
     201             : 
     202           0 :     if (!bDone)
     203           0 :         ScModelObj::setPropertyValue( aPropertyName, aValue );
     204           0 : }
     205             : 
     206           0 : uno::Any SAL_CALL ScDocOptionsObj::getPropertyValue( const OUString& aPropertyName )
     207             :                 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
     208             :                         uno::RuntimeException, std::exception)
     209             : {
     210           0 :     SolarMutexGuard aGuard;
     211             : 
     212           0 :     uno::Any aRet(ScDocOptionsHelper::getPropertyValue( aOptions, GetPropertySet().getPropertyMap(), aPropertyName ));
     213           0 :     if ( !aRet.hasValue() )
     214           0 :         aRet =  ScModelObj::getPropertyValue( aPropertyName );
     215             : 
     216           0 :     return aRet;
     217             : }
     218             : 
     219             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10