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

Generated by: LCOV version 1.10