LCOV - code coverage report
Current view: top level - sc/source/filter/excel - xiformula.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 36 0.0 %
Date: 2014-04-14 Functions: 0 10 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 "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           0 : 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           0 : XclImpFmlaCompImpl::XclImpFmlaCompImpl( const XclImpRoot& rRoot ) :
      48             :     XclImpRoot( rRoot ),
      49             :     maFuncProv( rRoot ),
      50           0 :     meBiff( rRoot.GetBiff() )
      51             : {
      52           0 : }
      53             : 
      54           0 : void XclImpFmlaCompImpl::CreateRangeList(
      55             :         ScRangeList& rScRanges, XclFormulaType /*eType*/,
      56             :         const XclTokenArray& rXclTokArr, XclImpStream& /*rStrm*/ )
      57             : {
      58           0 :     rScRanges.RemoveAll();
      59             : 
      60             :     //! evil hack, using old formula import :-)
      61           0 :     if( !rXclTokArr.Empty() )
      62             :     {
      63           0 :         SvMemoryStream aMemStrm;
      64           0 :         aMemStrm.WriteUInt16( EXC_ID_EOF ).WriteUInt16( rXclTokArr.GetSize() );
      65           0 :         aMemStrm.Write( rXclTokArr.GetData(), rXclTokArr.GetSize() );
      66           0 :         XclImpStream aFmlaStrm( aMemStrm, GetRoot() );
      67           0 :         aFmlaStrm.StartNextRecord();
      68           0 :         GetOldFmlaConverter().GetAbsRefs( rScRanges, aFmlaStrm, aFmlaStrm.GetRecSize() );
      69             :     }
      70           0 : }
      71             : 
      72           0 : const ScTokenArray* XclImpFmlaCompImpl::CreateFormula(
      73             :         XclFormulaType /*eType*/, const XclTokenArray& rXclTokArr )
      74             : {
      75           0 :     if (rXclTokArr.Empty())
      76           0 :         return NULL;
      77             : 
      78             :     // evil hack!  are we trying to phase out the old style formula converter ?
      79           0 :     SvMemoryStream aMemStrm;
      80           0 :     aMemStrm.WriteUInt16( EXC_ID_EOF ).WriteUInt16( rXclTokArr.GetSize() );
      81           0 :     aMemStrm.Write( rXclTokArr.GetData(), rXclTokArr.GetSize() );
      82           0 :     XclImpStream aFmlaStrm( aMemStrm, GetRoot() );
      83           0 :     aFmlaStrm.StartNextRecord();
      84           0 :     const ScTokenArray* pArray = NULL;
      85           0 :     GetOldFmlaConverter().Reset();
      86           0 :     GetOldFmlaConverter().Convert(pArray, aFmlaStrm, aFmlaStrm.GetRecSize(), true);
      87           0 :     return pArray;
      88             : }
      89             : 
      90           0 : XclImpFormulaCompiler::XclImpFormulaCompiler( const XclImpRoot& rRoot ) :
      91             :     XclImpRoot( rRoot ),
      92           0 :     mxImpl( new XclImpFmlaCompImpl( rRoot ) )
      93             : {
      94           0 : }
      95             : 
      96           0 : XclImpFormulaCompiler::~XclImpFormulaCompiler()
      97             : {
      98           0 : }
      99             : 
     100           0 : void XclImpFormulaCompiler::CreateRangeList(
     101             :         ScRangeList& rScRanges, XclFormulaType eType,
     102             :         const XclTokenArray& rXclTokArr, XclImpStream& rStrm )
     103             : {
     104           0 :     mxImpl->CreateRangeList( rScRanges, eType, rXclTokArr, rStrm );
     105           0 : }
     106             : 
     107           0 : const ScTokenArray* XclImpFormulaCompiler::CreateFormula(
     108             :         XclFormulaType eType, const XclTokenArray& rXclTokArr )
     109             : {
     110           0 :     return mxImpl->CreateFormula(eType, rXclTokArr);
     111             : }
     112             : 
     113             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10