LCOV - code coverage report
Current view: top level - sc/source/ui/vba - vbacondition.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 71 0.0 %
Date: 2014-04-14 Functions: 0 7 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 "vbacondition.hxx"
      21             : #include <ooo/vba/excel/XlFormatConditionOperator.hpp>
      22             : #include <ooo/vba/excel/XFormatCondition.hpp>
      23             : #include <com/sun/star/table/XCellRange.hpp>
      24             : #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
      25             : 
      26             : using namespace ::ooo::vba;
      27             : using namespace ::com::sun::star;
      28             : 
      29             : const sal_Int32 ISFORMULA = 98765432;
      30             : 
      31             : template< typename Ifc1 >
      32           0 : ScVbaCondition< Ifc1 >::ScVbaCondition(  const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< sheet::XSheetCondition >& _xSheetCondition ) : ScVbaCondition_BASE( xParent, xContext ), mxSheetCondition( _xSheetCondition )
      33             : {
      34           0 :     mxAddressable.set( xParent, uno::UNO_QUERY_THROW );
      35           0 : }
      36             : 
      37             : template< typename Ifc1 >
      38             : sheet::ConditionOperator
      39           0 : ScVbaCondition< Ifc1 >::retrieveAPIOperator( const uno::Any& _aOperator) throw ( script::BasicErrorException )
      40             : {
      41           0 :     sheet::ConditionOperator aRetAPIOperator = sheet::ConditionOperator_NONE;
      42           0 :     sal_Int32 nOperator = 0;
      43           0 :     if ( (_aOperator >>= nOperator ) )
      44             :     {
      45           0 :         switch(nOperator)
      46             :         {
      47             :             case excel::XlFormatConditionOperator::xlBetween:
      48           0 :                 aRetAPIOperator = sheet::ConditionOperator_BETWEEN;
      49           0 :                 break;
      50             :             case  excel::XlFormatConditionOperator::xlNotBetween:
      51           0 :                 aRetAPIOperator = sheet::ConditionOperator_NOT_BETWEEN;
      52           0 :                 break;
      53             :             case excel::XlFormatConditionOperator::xlEqual:
      54           0 :                 aRetAPIOperator = sheet::ConditionOperator_EQUAL;
      55           0 :                 break;
      56             :             case excel::XlFormatConditionOperator::xlNotEqual:
      57           0 :                 aRetAPIOperator = sheet::ConditionOperator_NOT_EQUAL;
      58           0 :                 break;
      59             :             case excel::XlFormatConditionOperator::xlGreater:
      60           0 :                 aRetAPIOperator = sheet::ConditionOperator_GREATER;
      61           0 :                 break;
      62             :             case excel::XlFormatConditionOperator::xlLess:
      63           0 :                 aRetAPIOperator = sheet::ConditionOperator_LESS;
      64           0 :                 break;
      65             :             case excel::XlFormatConditionOperator::xlGreaterEqual:
      66           0 :                 aRetAPIOperator = sheet::ConditionOperator_GREATER_EQUAL;
      67           0 :                 break;
      68             :             case excel::XlFormatConditionOperator::xlLessEqual:
      69           0 :                 aRetAPIOperator = sheet::ConditionOperator_LESS_EQUAL;
      70           0 :                 break;
      71             :             default:
      72           0 :                 aRetAPIOperator = sheet::ConditionOperator_NONE;
      73           0 :                 break;
      74             :         }
      75             :     }
      76           0 :     return aRetAPIOperator;
      77             : }
      78             : 
      79             : template< typename Ifc1 >
      80             : OUString
      81           0 : ScVbaCondition< Ifc1 >::Formula1( ) throw ( script::BasicErrorException, uno::RuntimeException )
      82             : {
      83           0 :      return mxSheetCondition->getFormula1();
      84             : }
      85             : 
      86             : template< typename Ifc1 >
      87             : OUString
      88           0 : ScVbaCondition< Ifc1 >::Formula2( ) throw ( script::BasicErrorException, uno::RuntimeException )
      89             : {
      90           0 :      return mxSheetCondition->getFormula2();
      91             : }
      92             : 
      93             : template< typename Ifc1 >
      94             : void
      95           0 : ScVbaCondition< Ifc1 >::setFormula1( const uno::Any& _aFormula1) throw ( script::BasicErrorException )
      96             : {
      97           0 :     OUString sFormula;
      98           0 :     if ( (_aFormula1 >>= sFormula ))
      99             :     {
     100           0 :         mxSheetCondition->setFormula1( sFormula );
     101           0 :         table::CellRangeAddress aCellRangeAddress = mxAddressable->getRangeAddress();
     102           0 :         table::CellAddress aCellAddress( aCellRangeAddress.Sheet, aCellRangeAddress.StartColumn,  aCellRangeAddress.StartRow );
     103           0 :         mxSheetCondition->setSourcePosition(aCellAddress);
     104           0 :     }
     105           0 : }
     106             : 
     107             : template< typename Ifc1 >
     108             : void
     109           0 : ScVbaCondition< Ifc1 >::setFormula2( const uno::Any& _aFormula2) throw ( script::BasicErrorException )
     110             : {
     111           0 :     OUString sFormula2;
     112             :     // #TODO surely this can't be right?
     113             :     // ( from helperapi/impl/.../calc/ConditionImpl.java
     114           0 :     if ( (_aFormula2 >>= sFormula2 ))
     115           0 :         mxSheetCondition->setFormula1(sFormula2);
     116           0 : }
     117             : 
     118             : template< typename Ifc1 >
     119             : sal_Int32
     120           0 : ScVbaCondition< Ifc1 >::Operator(sal_Bool _bIncludeFormulaValue) throw ( script::BasicErrorException )
     121             : {
     122           0 :     sal_Int32 retvalue = -1;
     123           0 :     sheet::ConditionOperator aConditionalOperator =  mxSheetCondition->getOperator();
     124           0 :     switch (aConditionalOperator)
     125             :     {
     126             :         case sheet::ConditionOperator_EQUAL:
     127           0 :             retvalue = excel::XlFormatConditionOperator::xlEqual;
     128           0 :             break;
     129             :         case sheet::ConditionOperator_NOT_EQUAL:
     130           0 :             retvalue = excel::XlFormatConditionOperator::xlNotEqual;
     131           0 :             break;
     132             :         case sheet::ConditionOperator_GREATER:
     133           0 :             retvalue = excel::XlFormatConditionOperator::xlGreater;
     134           0 :             break;
     135             :         case sheet::ConditionOperator_GREATER_EQUAL:
     136           0 :             retvalue = excel::XlFormatConditionOperator::xlGreaterEqual;
     137           0 :             break;
     138             :         case sheet::ConditionOperator_LESS:
     139           0 :             retvalue = excel::XlFormatConditionOperator::xlLess;
     140           0 :             break;
     141             :         case sheet::ConditionOperator_LESS_EQUAL:
     142           0 :             retvalue = excel::XlFormatConditionOperator::xlLessEqual;
     143           0 :             break;
     144             :         case sheet::ConditionOperator_BETWEEN:
     145           0 :             retvalue = excel::XlFormatConditionOperator::xlBetween;
     146           0 :             break;
     147             :         case sheet::ConditionOperator_NOT_BETWEEN:
     148           0 :             retvalue = excel::XlFormatConditionOperator::xlNotBetween;
     149           0 :             break;
     150             :         case sheet::ConditionOperator_FORMULA:
     151           0 :             if (_bIncludeFormulaValue)
     152             :             {
     153             :                 //#FIXME huh what's this all about
     154             :                 // from helperapi/impl/.../calc/ConditionImpl
     155           0 :                 retvalue = ISFORMULA;
     156           0 :                 break;
     157             :             }
     158             :         case sheet::ConditionOperator_NONE:
     159             :         default:
     160           0 :             DebugHelper::exception(SbERR_METHOD_FAILED, OUString("Operator not supported"));
     161           0 :         break;
     162             :     }
     163           0 :     return retvalue;
     164             : }
     165             : 
     166             : template class ScVbaCondition< excel::XFormatCondition >;
     167             : 
     168             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10