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

Generated by: LCOV version 1.11