LCOV - code coverage report
Current view: top level - sc/source/ui/vba - vbaformatcondition.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 68 0.0 %
Date: 2015-06-13 12:38:46 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 "unonames.hxx"
      22             : #include <ooo/vba/excel/XlFormatConditionType.hpp>
      23             : 
      24             : using namespace ::ooo::vba;
      25             : using namespace ::com::sun::star;
      26             : 
      27             : static ScVbaFormatConditions*
      28           0 : lcl_getScVbaFormatConditionsPtr( const uno::Reference< excel::XFormatConditions >& xFormatConditions ) throw ( script::BasicErrorException )
      29             : {
      30           0 :     ScVbaFormatConditions* pFormatConditions = static_cast< ScVbaFormatConditions* >( xFormatConditions.get() );
      31           0 :     if ( !pFormatConditions )
      32           0 :         DebugHelper::basicexception(SbERR_METHOD_FAILED, OUString() );
      33           0 :     return pFormatConditions;
      34             : }
      35             : 
      36           0 : ScVbaFormatCondition::ScVbaFormatCondition( const uno::Reference< XHelperInterface >& xParent,
      37             :                                             const uno::Reference< uno::XComponentContext > & xContext,
      38             :                                             const uno::Reference< sheet::XSheetConditionalEntry >& _xSheetConditionalEntry,
      39             :                                             const uno::Reference< excel::XStyle >& _xStyle,
      40             :                                             const uno::Reference< excel::XFormatConditions >& _xFormatConditions,
      41             :                                             const uno::Reference< css::beans::XPropertySet >& _xPropertySet ) throw ( css::uno::RuntimeException, css::script::BasicErrorException )
      42             :     : ScVbaFormatCondition_BASE( xParent, xContext,
      43             :                                  uno::Reference< sheet::XSheetCondition >( _xSheetConditionalEntry, css::uno::UNO_QUERY_THROW ) ),
      44           0 :                                  moFormatConditions( _xFormatConditions ), mxStyle( _xStyle ), mxParentRangePropertySet( _xPropertySet )
      45             : {
      46           0 :         mxSheetConditionalEntries = lcl_getScVbaFormatConditionsPtr( moFormatConditions )->getSheetConditionalEntries();
      47             : 
      48           0 :         mxSheetConditionalEntry = _xSheetConditionalEntry;
      49           0 :         msStyleName = mxStyle->getName();
      50           0 : }
      51             : 
      52             : void SAL_CALL
      53           0 : ScVbaFormatCondition::Delete(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
      54             : {
      55           0 :     ScVbaFormatConditions* pFormatConditions = lcl_getScVbaFormatConditionsPtr( moFormatConditions );
      56           0 :     pFormatConditions->removeFormatCondition(msStyleName, 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, std::exception)
      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 (const uno::Exception&)
      70             :     {
      71           0 :         DebugHelper::basicexception(SbERR_METHOD_FAILED, OUString() );
      72             :     }
      73           0 : }
      74             : 
      75             : uno::Reference< excel::XInterior > SAL_CALL
      76           0 : ScVbaFormatCondition::Interior(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
      77             : {
      78           0 :     return mxStyle->Interior();
      79             : }
      80             : 
      81             : uno::Reference< excel::XFont > SAL_CALL
      82           0 : ScVbaFormatCondition::Font(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
      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, std::exception)
      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::basicexception(SbERR_METHOD_FAILED, 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( ScVbaFormatConditions::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( ScVbaFormatConditions::getA1Formula(_aFormula2)) );
     122           0 : }
     123             : 
     124             : ::sal_Int32 SAL_CALL
     125           0 : ScVbaFormatCondition::Type(  ) throw ( script::BasicErrorException, uno::RuntimeException, std::exception )
     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             : ::sal_Int32
     136           0 : ScVbaFormatCondition::Operator( bool bVal ) throw (script::BasicErrorException )
     137             : {
     138           0 :     return ScVbaFormatCondition_BASE::Operator( bVal );
     139             : }
     140             : ::sal_Int32 SAL_CALL
     141           0 : ScVbaFormatCondition::Operator(  ) throw (script::BasicErrorException, uno::RuntimeException)
     142             : {
     143           0 :     return ScVbaFormatCondition_BASE::Operator( true );
     144             : }
     145             : 
     146             : void
     147           0 : ScVbaFormatCondition::notifyRange() throw ( script::BasicErrorException )
     148             : {
     149             :     try
     150             :     {
     151           0 :         mxParentRangePropertySet->setPropertyValue(SC_UNONAME_CONDFMT, uno::makeAny( mxSheetConditionalEntries));
     152             :     }
     153           0 :     catch (uno::Exception& )
     154             :     {
     155           0 :         DebugHelper::basicexception(SbERR_METHOD_FAILED, OUString() );
     156             :     }
     157           0 : }
     158             : 
     159             : OUString
     160           0 : ScVbaFormatCondition::getServiceImplName()
     161             : {
     162           0 :     return OUString("ScVbaFormatCondition");
     163             : }
     164             : 
     165             : uno::Sequence< OUString >
     166           0 : ScVbaFormatCondition::getServiceNames()
     167             : {
     168           0 :     static uno::Sequence< OUString > aServiceNames;
     169           0 :     if ( aServiceNames.getLength() == 0 )
     170             :     {
     171           0 :         aServiceNames.realloc( 1 );
     172           0 :         aServiceNames[ 0 ] = "ooo.vba.excel.FormatCondition";
     173             :     }
     174           0 :     return aServiceNames;
     175             : }
     176             : 
     177             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11