LCOV - code coverage report
Current view: top level - sc/source/filter/excel - xiformula.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 35 36 97.2 %
Date: 2012-08-25 Functions: 10 10 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 39 78 50.0 %

           Branch data     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 "xiformula.hxx"
      21                 :            : #include "rangelst.hxx"
      22                 :            : #include "xistream.hxx"
      23                 :            : 
      24                 :            : #include "excform.hxx"
      25                 :            : 
      26                 :            : // Formula compiler ===========================================================
      27                 :            : 
      28                 :            : /** Implementation class of the export formula compiler. */
      29         [ -  + ]:        110 : class XclImpFmlaCompImpl : protected XclImpRoot, protected XclTokenArrayHelper
      30                 :            : {
      31                 :            : public:
      32                 :            :     explicit            XclImpFmlaCompImpl( const XclImpRoot& rRoot );
      33                 :            : 
      34                 :            :     /** Creates a range list from the passed Excel token array. */
      35                 :            :     void                CreateRangeList(
      36                 :            :                             ScRangeList& rScRanges, XclFormulaType eType,
      37                 :            :                             const XclTokenArray& rXclTokArr, XclImpStream& rStrm );
      38                 :            : 
      39                 :            :     const ScTokenArray* CreateFormula( XclFormulaType eType, const XclTokenArray& rXclTokArr );
      40                 :            : 
      41                 :            :     // ------------------------------------------------------------------------
      42                 :            : private:
      43                 :            :     XclFunctionProvider maFuncProv;     /// Excel function data provider.
      44                 :            :     const XclBiff       meBiff;         /// Cached BIFF version to save GetBiff() calls.
      45                 :            : };
      46                 :            : 
      47                 :            : // ----------------------------------------------------------------------------
      48                 :            : 
      49                 :         55 : XclImpFmlaCompImpl::XclImpFmlaCompImpl( const XclImpRoot& rRoot ) :
      50                 :            :     XclImpRoot( rRoot ),
      51                 :            :     maFuncProv( rRoot ),
      52         [ +  - ]:         55 :     meBiff( rRoot.GetBiff() )
      53                 :            : {
      54                 :         55 : }
      55                 :            : 
      56                 :          3 : void XclImpFmlaCompImpl::CreateRangeList(
      57                 :            :         ScRangeList& rScRanges, XclFormulaType /*eType*/,
      58                 :            :         const XclTokenArray& rXclTokArr, XclImpStream& /*rStrm*/ )
      59                 :            : {
      60                 :          3 :     rScRanges.RemoveAll();
      61                 :            : 
      62                 :            :     //! evil hack, using old formula import :-)
      63         [ +  - ]:          3 :     if( !rXclTokArr.Empty() )
      64                 :            :     {
      65         [ +  - ]:          3 :         SvMemoryStream aMemStrm;
      66 [ +  - ][ +  - ]:          3 :         aMemStrm << EXC_ID_EOF << rXclTokArr.GetSize();
                 [ +  - ]
      67 [ +  - ][ +  - ]:          3 :         aMemStrm.Write( rXclTokArr.GetData(), rXclTokArr.GetSize() );
                 [ +  - ]
      68         [ +  - ]:          3 :         XclImpStream aFmlaStrm( aMemStrm, GetRoot() );
      69         [ +  - ]:          3 :         aFmlaStrm.StartNextRecord();
      70 [ +  - ][ +  - ]:          3 :         GetOldFmlaConverter().GetAbsRefs( rScRanges, aFmlaStrm, aFmlaStrm.GetRecSize() );
         [ +  - ][ +  - ]
                 [ +  - ]
      71                 :            :     }
      72                 :          3 : }
      73                 :            : 
      74                 :         18 : const ScTokenArray* XclImpFmlaCompImpl::CreateFormula(
      75                 :            :         XclFormulaType /*eType*/, const XclTokenArray& rXclTokArr )
      76                 :            : {
      77         [ -  + ]:         18 :     if (rXclTokArr.Empty())
      78                 :          0 :         return NULL;
      79                 :            : 
      80                 :            :     // evil hack!  are we trying to phase out the old style formula converter ?
      81         [ +  - ]:         18 :     SvMemoryStream aMemStrm;
      82 [ +  - ][ +  - ]:         18 :     aMemStrm << EXC_ID_EOF << rXclTokArr.GetSize();
                 [ +  - ]
      83 [ +  - ][ +  - ]:         18 :     aMemStrm.Write( rXclTokArr.GetData(), rXclTokArr.GetSize() );
                 [ +  - ]
      84         [ +  - ]:         18 :     XclImpStream aFmlaStrm( aMemStrm, GetRoot() );
      85         [ +  - ]:         18 :     aFmlaStrm.StartNextRecord();
      86                 :         18 :     const ScTokenArray* pArray = NULL;
      87 [ +  - ][ +  - ]:         18 :     GetOldFmlaConverter().Reset();
      88 [ +  - ][ +  - ]:         18 :     GetOldFmlaConverter().Convert(pArray, aFmlaStrm, aFmlaStrm.GetRecSize(), true);
                 [ +  - ]
      89 [ +  - ][ +  - ]:         18 :     return pArray;
      90                 :            : }
      91                 :            : 
      92                 :            : // ----------------------------------------------------------------------------
      93                 :            : 
      94                 :         55 : XclImpFormulaCompiler::XclImpFormulaCompiler( const XclImpRoot& rRoot ) :
      95                 :            :     XclImpRoot( rRoot ),
      96 [ +  - ][ +  - ]:         55 :     mxImpl( new XclImpFmlaCompImpl( rRoot ) )
                 [ +  - ]
      97                 :            : {
      98                 :         55 : }
      99                 :            : 
     100         [ +  - ]:         55 : XclImpFormulaCompiler::~XclImpFormulaCompiler()
     101                 :            : {
     102         [ -  + ]:        110 : }
     103                 :            : 
     104                 :          3 : void XclImpFormulaCompiler::CreateRangeList(
     105                 :            :         ScRangeList& rScRanges, XclFormulaType eType,
     106                 :            :         const XclTokenArray& rXclTokArr, XclImpStream& rStrm )
     107                 :            : {
     108                 :          3 :     mxImpl->CreateRangeList( rScRanges, eType, rXclTokArr, rStrm );
     109                 :          3 : }
     110                 :            : 
     111                 :         18 : const ScTokenArray* XclImpFormulaCompiler::CreateFormula(
     112                 :            :         XclFormulaType eType, const XclTokenArray& rXclTokArr )
     113                 :            : {
     114                 :         18 :     return mxImpl->CreateFormula(eType, rXclTokArr);
     115                 :            : }
     116                 :            : 
     117                 :            : // ============================================================================
     118                 :            : 
     119                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10