LCOV - code coverage report
Current view: top level - sc/source/ui/unoobj - optuno.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 73 105 69.5 %
Date: 2012-08-25 Functions: 2 8 25.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 51 128 39.8 %

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

Generated by: LCOV version 1.10