LCOV - code coverage report
Current view: top level - sc/source/ui/unoobj - optuno.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 105 0.0 %
Date: 2014-04-14 Functions: 0 9 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 <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           0 : 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           0 :     const SfxItemPropertySimpleEntry* pEntry = rPropMap.getByName(aPropertyName );
      60           0 :     if( !pEntry || !pEntry->nWID )
      61           0 :         return false;
      62           0 :     switch( pEntry->nWID )
      63             :     {
      64             :         case PROP_UNO_CALCASSHOWN :
      65           0 :             rOptions.SetCalcAsShown( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
      66           0 :         break;
      67             :         case PROP_UNO_DEFTABSTOP  :
      68             :         {
      69           0 :             sal_Int16 nIntVal = 0;
      70           0 :             if ( aValue >>= nIntVal )
      71           0 :                 rOptions.SetTabDistance( nIntVal );
      72             :         }
      73           0 :         break;
      74             :         case PROP_UNO_IGNORECASE  :
      75           0 :             rOptions.SetIgnoreCase( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
      76           0 :         break;
      77             :         case PROP_UNO_ITERENABLED:
      78           0 :             rOptions.SetIter( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
      79           0 :         break;
      80             :         case PROP_UNO_ITERCOUNT   :
      81             :         {
      82           0 :             sal_Int32 nIntVal = 0;
      83           0 :             if ( aValue >>= nIntVal )
      84           0 :                 rOptions.SetIterCount( (sal_uInt16)nIntVal );
      85             :         }
      86           0 :         break;
      87             :         case PROP_UNO_ITEREPSILON :
      88             :         {
      89           0 :             double fDoubleVal = 0;
      90           0 :             if ( aValue >>= fDoubleVal )
      91           0 :                 rOptions.SetIterEps( fDoubleVal );
      92             :         }
      93           0 :         break;
      94             :         case PROP_UNO_LOOKUPLABELS :
      95           0 :             rOptions.SetLookUpColRowNames( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
      96           0 :         break;
      97             :         case PROP_UNO_MATCHWHOLE  :
      98           0 :             rOptions.SetMatchWholeCell( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
      99           0 :         break;
     100             :         case PROP_UNO_NULLDATE:
     101             :         {
     102           0 :             util::Date aDate;
     103           0 :             if ( aValue >>= aDate )
     104           0 :                 rOptions.SetDate( aDate.Day, aDate.Month, aDate.Year );
     105             :         }
     106           0 :         break;
     107             :         case PROP_UNO_SPELLONLINE:
     108           0 :             rOptions.SetAutoSpell( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     109           0 :         break;
     110             :         case PROP_UNO_STANDARDDEC:
     111             :         {
     112           0 :             sal_Int16 nIntVal = 0;
     113           0 :             if ( aValue >>= nIntVal )
     114           0 :                 rOptions.SetStdPrecision( nIntVal );
     115             :         }
     116           0 :         break;
     117             :         case PROP_UNO_REGEXENABLED:
     118           0 :             rOptions.SetFormulaRegexEnabled( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     119           0 :         break;
     120             :         default:;
     121             :     }
     122           0 :     return true;
     123             : }
     124             : 
     125           0 : uno::Any ScDocOptionsHelper::getPropertyValue(
     126             :                 const ScDocOptions& rOptions,
     127             :                 const SfxItemPropertyMap& rPropMap,
     128             :                 const OUString& aPropertyName )
     129             : {
     130           0 :     uno::Any aRet;
     131           0 :     const SfxItemPropertySimpleEntry* pEntry = rPropMap.getByName( aPropertyName );
     132           0 :     if( !pEntry || !pEntry->nWID )
     133           0 :         return aRet;
     134           0 :     switch( pEntry->nWID )
     135             :     {
     136             :         case PROP_UNO_CALCASSHOWN :
     137           0 :             ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsCalcAsShown() );
     138           0 :         break;
     139             :         case PROP_UNO_DEFTABSTOP :
     140           0 :             aRet <<= (sal_Int16)( rOptions.GetTabDistance() );
     141           0 :         break;
     142             :         case PROP_UNO_IGNORECASE :
     143           0 :             ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsIgnoreCase() );
     144           0 :         break;
     145             :         case PROP_UNO_ITERENABLED:
     146           0 :         ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsIter() );
     147           0 :         break;
     148             :         case PROP_UNO_ITERCOUNT:
     149           0 :             aRet <<= (sal_Int32)( rOptions.GetIterCount() );
     150           0 :         break;
     151             :         case PROP_UNO_ITEREPSILON:
     152           0 :             aRet <<= (double)( rOptions.GetIterEps() );
     153           0 :         break;
     154             :         case PROP_UNO_LOOKUPLABELS:
     155           0 :             ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsLookUpColRowNames() );
     156           0 :         break;
     157             :         case PROP_UNO_MATCHWHOLE:
     158           0 :             ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsMatchWholeCell() );
     159           0 :         break;
     160             :         case PROP_UNO_NULLDATE:
     161             :         {
     162             :             sal_uInt16 nD, nM, nY;
     163           0 :             rOptions.GetDate( nD, nM, nY );
     164           0 :             util::Date aDate( nD, nM, nY );
     165           0 :             aRet <<= aDate;
     166             :         }
     167           0 :         break;
     168             :         case PROP_UNO_SPELLONLINE:
     169           0 :             ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsAutoSpell() );
     170           0 :         break;
     171             :         case PROP_UNO_STANDARDDEC :
     172           0 :             aRet <<= (sal_Int16)( rOptions.GetStdPrecision() );
     173           0 :         break;
     174             :         case PROP_UNO_REGEXENABLED:
     175           0 :             ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsFormulaRegexEnabled() );
     176           0 :         break;
     177             :         default:;
     178             :     }
     179           0 :     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