LCOV - code coverage report
Current view: top level - sc/source/ui/unoobj - optuno.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 74 106 69.8 %
Date: 2014-11-03 Functions: 4 11 36.4 %
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           0 : const SfxItemPropertyMapEntry* ScDocOptionsHelper::GetPropertyMap()
      32             : {
      33             :     static const SfxItemPropertyMapEntry aMap[] =
      34             :     {
      35           0 :         {OUString(SC_UNO_CALCASSHOWN),  PROP_UNO_CALCASSHOWN ,  getBooleanCppuType(),          0, 0},
      36           0 :         {OUString(SC_UNO_DEFTABSTOP),   PROP_UNO_DEFTABSTOP  ,  cppu::UnoType<sal_Int16>::get(),    0, 0},
      37           0 :         {OUString(SC_UNO_IGNORECASE),   PROP_UNO_IGNORECASE  ,  getBooleanCppuType(),          0, 0},
      38           0 :         {OUString(SC_UNO_ITERENABLED),  PROP_UNO_ITERENABLED ,  getBooleanCppuType(),          0, 0},
      39           0 :         {OUString(SC_UNO_ITERCOUNT),    PROP_UNO_ITERCOUNT   ,  cppu::UnoType<sal_Int32>::get(),    0, 0},
      40           0 :         {OUString(SC_UNO_ITEREPSILON),  PROP_UNO_ITEREPSILON ,  cppu::UnoType<double>::get(),       0, 0},
      41           0 :         {OUString(SC_UNO_LOOKUPLABELS), PROP_UNO_LOOKUPLABELS,  getBooleanCppuType(),          0, 0},
      42           0 :         {OUString(SC_UNO_MATCHWHOLE),   PROP_UNO_MATCHWHOLE  ,  getBooleanCppuType(),          0, 0},
      43           0 :         {OUString(SC_UNO_NULLDATE),     PROP_UNO_NULLDATE    ,  cppu::UnoType<util::Date>::get(),   0, 0},
      44           0 :         {OUString(SC_UNO_SPELLONLINE),  PROP_UNO_SPELLONLINE ,  getBooleanCppuType(),          0, 0},
      45           0 :         {OUString(SC_UNO_STANDARDDEC),  PROP_UNO_STANDARDDEC ,  cppu::UnoType<sal_Int16>::get(),    0, 0},
      46           0 :         {OUString(SC_UNO_REGEXENABLED), PROP_UNO_REGEXENABLED,  getBooleanCppuType(),          0, 0},
      47             :         { OUString(), 0, css::uno::Type(), 0, 0 }
      48           0 :     };
      49           0 :     return aMap;
      50             : }
      51             : 
      52        5136 : 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        5136 :     const SfxItemPropertySimpleEntry* pEntry = rPropMap.getByName(aPropertyName );
      59        5136 :     if( !pEntry || !pEntry->nWID )
      60        1070 :         return false;
      61        4066 :     switch( pEntry->nWID )
      62             :     {
      63             :         case PROP_UNO_CALCASSHOWN :
      64         462 :             rOptions.SetCalcAsShown( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
      65         462 :         break;
      66             :         case PROP_UNO_DEFTABSTOP  :
      67             :         {
      68          12 :             sal_Int16 nIntVal = 0;
      69          12 :             if ( aValue >>= nIntVal )
      70          12 :                 rOptions.SetTabDistance( nIntVal );
      71             :         }
      72          12 :         break;
      73             :         case PROP_UNO_IGNORECASE  :
      74         462 :             rOptions.SetIgnoreCase( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
      75         462 :         break;
      76             :         case PROP_UNO_ITERENABLED:
      77         462 :             rOptions.SetIter( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
      78         462 :         break;
      79             :         case PROP_UNO_ITERCOUNT   :
      80             :         {
      81         462 :             sal_Int32 nIntVal = 0;
      82         462 :             if ( aValue >>= nIntVal )
      83         462 :                 rOptions.SetIterCount( (sal_uInt16)nIntVal );
      84             :         }
      85         462 :         break;
      86             :         case PROP_UNO_ITEREPSILON :
      87             :         {
      88         462 :             double fDoubleVal = 0;
      89         462 :             if ( aValue >>= fDoubleVal )
      90         462 :                 rOptions.SetIterEps( fDoubleVal );
      91             :         }
      92         462 :         break;
      93             :         case PROP_UNO_LOOKUPLABELS :
      94         462 :             rOptions.SetLookUpColRowNames( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
      95         462 :         break;
      96             :         case PROP_UNO_MATCHWHOLE  :
      97         334 :             rOptions.SetMatchWholeCell( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
      98         334 :         break;
      99             :         case PROP_UNO_NULLDATE:
     100             :         {
     101         462 :             util::Date aDate;
     102         462 :             if ( aValue >>= aDate )
     103         462 :                 rOptions.SetDate( aDate.Day, aDate.Month, aDate.Year );
     104             :         }
     105         462 :         break;
     106             :         case PROP_UNO_SPELLONLINE:
     107          12 :             rOptions.SetAutoSpell( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     108          12 :         break;
     109             :         case PROP_UNO_STANDARDDEC:
     110             :         {
     111          12 :             sal_Int16 nIntVal = 0;
     112          12 :             if ( aValue >>= nIntVal )
     113          12 :                 rOptions.SetStdPrecision( nIntVal );
     114             :         }
     115          12 :         break;
     116             :         case PROP_UNO_REGEXENABLED:
     117         462 :             rOptions.SetFormulaRegexEnabled( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     118         462 :         break;
     119             :         default:;
     120             :     }
     121        4066 :     return true;
     122             : }
     123             : 
     124        9918 : uno::Any ScDocOptionsHelper::getPropertyValue(
     125             :                 const ScDocOptions& rOptions,
     126             :                 const SfxItemPropertyMap& rPropMap,
     127             :                 const OUString& aPropertyName )
     128             : {
     129        9918 :     uno::Any aRet;
     130        9918 :     const SfxItemPropertySimpleEntry* pEntry = rPropMap.getByName( aPropertyName );
     131        9918 :     if( !pEntry || !pEntry->nWID )
     132        8064 :         return aRet;
     133        1854 :     switch( pEntry->nWID )
     134             :     {
     135             :         case PROP_UNO_CALCASSHOWN :
     136          76 :             ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsCalcAsShown() );
     137          76 :         break;
     138             :         case PROP_UNO_DEFTABSTOP :
     139          28 :             aRet <<= (sal_Int16)( rOptions.GetTabDistance() );
     140          28 :         break;
     141             :         case PROP_UNO_IGNORECASE :
     142          76 :             ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsIgnoreCase() );
     143          76 :         break;
     144             :         case PROP_UNO_ITERENABLED:
     145          76 :         ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsIter() );
     146          76 :         break;
     147             :         case PROP_UNO_ITERCOUNT:
     148          76 :             aRet <<= (sal_Int32)( rOptions.GetIterCount() );
     149          76 :         break;
     150             :         case PROP_UNO_ITEREPSILON:
     151          76 :             aRet <<= (double)( rOptions.GetIterEps() );
     152          76 :         break;
     153             :         case PROP_UNO_LOOKUPLABELS:
     154          76 :             ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsLookUpColRowNames() );
     155          76 :         break;
     156             :         case PROP_UNO_MATCHWHOLE:
     157          76 :             ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsMatchWholeCell() );
     158          76 :         break;
     159             :         case PROP_UNO_NULLDATE:
     160             :         {
     161             :             sal_uInt16 nD, nM, nY;
     162        1162 :             rOptions.GetDate( nD, nM, nY );
     163        1162 :             util::Date aDate( nD, nM, nY );
     164        1162 :             aRet <<= aDate;
     165             :         }
     166        1162 :         break;
     167             :         case PROP_UNO_SPELLONLINE:
     168          28 :             ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsAutoSpell() );
     169          28 :         break;
     170             :         case PROP_UNO_STANDARDDEC :
     171          28 :             aRet <<= (sal_Int16)( rOptions.GetStdPrecision() );
     172          28 :         break;
     173             :         case PROP_UNO_REGEXENABLED:
     174          76 :             ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsFormulaRegexEnabled() );
     175          76 :         break;
     176             :         default:;
     177             :     }
     178        1854 :     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         228 : }
     217             : 
     218             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10