LCOV - code coverage report
Current view: top level - sc/source/ui/vba - vbaformatcondition.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 67 0.0 %
Date: 2012-08-25 Functions: 0 16 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 75 0.0 %

           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                 :            : #include "vbaformatcondition.hxx"
      29                 :            : #include "vbaformatconditions.hxx"
      30                 :            : #include <ooo/vba/excel/XlFormatConditionType.hpp>
      31                 :            : 
      32                 :            : using namespace ::ooo::vba;
      33                 :            : using namespace ::com::sun::star;
      34                 :            : 
      35                 :            : ScVbaFormatConditions*
      36                 :          0 : lcl_getScVbaFormatConditionsPtr( const uno::Reference< excel::XFormatConditions >& xFormatConditions ) throw ( script::BasicErrorException )
      37                 :            : {
      38         [ #  # ]:          0 :     ScVbaFormatConditions* pFormatConditions = static_cast< ScVbaFormatConditions* >( xFormatConditions.get() );
      39         [ #  # ]:          0 :     if ( !pFormatConditions )
      40         [ #  # ]:          0 :         DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
      41                 :          0 :     return pFormatConditions;
      42                 :            : }
      43         [ #  # ]:          0 : ScVbaFormatCondition::ScVbaFormatCondition(  const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< sheet::XSheetConditionalEntry >& _xSheetConditionalEntry, const uno::Reference< excel::XStyle >& _xStyle, const uno::Reference< excel::XFormatConditions >& _xFormatConditions, const uno::Reference< css::beans::XPropertySet >& _xPropertySet ) throw ( css::uno::RuntimeException ) : ScVbaFormatCondition_BASE( xParent, xContext, uno::Reference< sheet::XSheetCondition >( _xSheetConditionalEntry, css::uno::UNO_QUERY_THROW ) ), moFormatConditions( _xFormatConditions ), mxStyle( _xStyle ), mxParentRangePropertySet( _xPropertySet )
      44                 :            : {
      45 [ #  # ][ #  # ]:          0 :         mxSheetConditionalEntries = lcl_getScVbaFormatConditionsPtr( moFormatConditions )->getSheetConditionalEntries();
                 [ #  # ]
      46                 :            : 
      47         [ #  # ]:          0 :         mxSheetConditionalEntry = _xSheetConditionalEntry;
      48 [ #  # ][ #  # ]:          0 :         msStyleName = mxStyle->getName();
      49                 :          0 : }
      50                 :            : 
      51                 :            : 
      52                 :            : void SAL_CALL
      53                 :          0 : ScVbaFormatCondition::Delete(  ) throw (script::BasicErrorException, uno::RuntimeException)
      54                 :            : {
      55                 :          0 :     ScVbaFormatConditions* pFormatConditions = lcl_getScVbaFormatConditionsPtr( moFormatConditions );
      56                 :          0 :     pFormatConditions->removeFormatCondition(msStyleName, sal_True);
      57                 :          0 :         notifyRange();
      58                 :          0 : }
      59                 :            : 
      60                 :            : void SAL_CALL
      61                 :          0 : ScVbaFormatCondition::Modify( ::sal_Int32 _nType, const uno::Any& _aOperator, const uno::Any& _aFormula1, const uno::Any& _aFormula2 ) throw (script::BasicErrorException, uno::RuntimeException)
      62                 :            : {
      63                 :            :     try
      64                 :            :     {
      65         [ #  # ]:          0 :         ScVbaFormatConditions* pFormatConditions = lcl_getScVbaFormatConditionsPtr( moFormatConditions );
      66         [ #  # ]:          0 :         pFormatConditions->removeFormatCondition(msStyleName, false);
      67         [ #  # ]:          0 :         pFormatConditions->Add(_nType, _aOperator, _aFormula1, _aFormula2, mxStyle);
      68                 :            :     }
      69         [ #  # ]:          0 :     catch (uno::Exception& )
      70                 :            :     {
      71         [ #  # ]:          0 :         DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
      72                 :            :     }
      73                 :          0 : }
      74                 :            : 
      75                 :            : uno::Reference< excel::XInterior > SAL_CALL
      76                 :          0 : ScVbaFormatCondition::Interior(  ) throw (script::BasicErrorException, uno::RuntimeException)
      77                 :            : {
      78                 :          0 :     return mxStyle->Interior();
      79                 :            : }
      80                 :            : 
      81                 :            : uno::Reference< excel::XFont > SAL_CALL
      82                 :          0 : ScVbaFormatCondition::Font(  ) throw (script::BasicErrorException, uno::RuntimeException)
      83                 :            : {
      84                 :          0 :     return mxStyle->Font();
      85                 :            : }
      86                 :            : uno::Any SAL_CALL
      87                 :          0 : ScVbaFormatCondition::Borders( const uno::Any& Index ) throw (script::BasicErrorException, uno::RuntimeException)
      88                 :          0 : { return mxStyle->Borders( Index );
      89                 :            : }
      90                 :            : 
      91                 :            : sheet::ConditionOperator
      92                 :          0 : ScVbaFormatCondition::retrieveAPIType(sal_Int32 _nVBAType, const uno::Reference< sheet::XSheetCondition >& _xSheetCondition ) throw ( script::BasicErrorException )
      93                 :            : {
      94                 :          0 :     sheet::ConditionOperator aAPIType = sheet::ConditionOperator_NONE;
      95      [ #  #  # ]:          0 :     switch (_nVBAType)
      96                 :            :     {
      97                 :            :         case excel::XlFormatConditionType::xlExpression:
      98                 :          0 :             aAPIType = sheet::ConditionOperator_FORMULA;
      99                 :          0 :             break;
     100                 :            :         case excel::XlFormatConditionType::xlCellValue:
     101 [ #  # ][ #  # ]:          0 :             if ( _xSheetCondition.is() && (_xSheetCondition->getOperator() == sheet::ConditionOperator_FORMULA ) )
                 [ #  # ]
     102                 :          0 :                 aAPIType = sheet::ConditionOperator_NONE;
     103                 :          0 :             break;
     104                 :            :         default:
     105         [ #  # ]:          0 :             DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
     106                 :            :     }
     107                 :          0 :     return aAPIType;
     108                 :            : }
     109                 :            : 
     110                 :            : void
     111                 :          0 : ScVbaFormatCondition::setFormula1( const uno::Any& _aFormula1) throw ( script::BasicErrorException )
     112                 :            : {
     113                 :            :     // getA1Formula *SHOULD* detect whether the formula is r1c1 or A1 syntax
     114                 :            :     // and if R1C1 convert to A1
     115 [ #  # ][ #  # ]:          0 :     ScVbaFormatCondition_BASE::setFormula1( uno::makeAny( lcl_getScVbaFormatConditionsPtr( moFormatConditions )->getA1Formula(_aFormula1) ) );
     116                 :          0 : }
     117                 :            : 
     118                 :            : void
     119                 :          0 : ScVbaFormatCondition::setFormula2( const uno::Any& _aFormula2) throw ( script::BasicErrorException )
     120                 :            : {
     121 [ #  # ][ #  # ]:          0 :     ScVbaFormatCondition_BASE::setFormula1( uno::makeAny( lcl_getScVbaFormatConditionsPtr( moFormatConditions )->getA1Formula(_aFormula2)) );
     122                 :          0 : }
     123                 :            : 
     124                 :            : ::sal_Int32 SAL_CALL
     125                 :          0 : ScVbaFormatCondition::Type(  ) throw ( script::BasicErrorException, uno::RuntimeException )
     126                 :            : {
     127                 :          0 :     sal_Int32 nReturnType = 0;
     128         [ #  # ]:          0 :     if ( mxSheetCondition->getOperator() == sheet::ConditionOperator_FORMULA)
     129                 :          0 :         nReturnType = excel::XlFormatConditionType::xlExpression;
     130                 :            :     else
     131                 :          0 :         nReturnType = excel::XlFormatConditionType::xlCellValue;
     132                 :          0 :     return nReturnType;
     133                 :            : }
     134                 :            : 
     135                 :            : 
     136                 :            : ::sal_Int32
     137                 :          0 : ScVbaFormatCondition::Operator( sal_Bool bVal ) throw (script::BasicErrorException )
     138                 :            : {
     139                 :          0 :     return ScVbaFormatCondition_BASE::Operator( bVal );
     140                 :            : }
     141                 :            : ::sal_Int32 SAL_CALL
     142                 :          0 : ScVbaFormatCondition::Operator(  ) throw (script::BasicErrorException, uno::RuntimeException)
     143                 :            : {
     144                 :          0 :     return ScVbaFormatCondition_BASE::Operator( sal_True );
     145                 :            : }
     146                 :            : 
     147                 :            : void
     148                 :          0 : ScVbaFormatCondition::notifyRange() throw ( script::BasicErrorException )
     149                 :            : {
     150                 :            :     try
     151                 :            :     {
     152 [ #  # ][ #  # ]:          0 :         mxParentRangePropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ConditionalFormat") ), uno::makeAny( mxSheetConditionalEntries) );
         [ #  # ][ #  # ]
     153                 :            :     }
     154         [ #  # ]:          0 :     catch (uno::Exception& )
     155                 :            :     {
     156         [ #  # ]:          0 :         DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
     157                 :            :     }
     158                 :          0 : }
     159                 :            : 
     160                 :            : rtl::OUString
     161                 :          0 : ScVbaFormatCondition::getServiceImplName()
     162                 :            : {
     163                 :          0 :     return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScVbaFormatCondition"));
     164                 :            : }
     165                 :            : 
     166                 :            : uno::Sequence< rtl::OUString >
     167                 :          0 : ScVbaFormatCondition::getServiceNames()
     168                 :            : {
     169 [ #  # ][ #  # ]:          0 :     static uno::Sequence< rtl::OUString > aServiceNames;
         [ #  # ][ #  # ]
     170         [ #  # ]:          0 :     if ( aServiceNames.getLength() == 0 )
     171                 :            :     {
     172                 :          0 :         aServiceNames.realloc( 1 );
     173         [ #  # ]:          0 :         aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.FormatCondition" ) );
     174                 :            :     }
     175                 :          0 :     return aServiceNames;
     176                 :            : }
     177                 :            : 
     178                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10