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

Generated by: LCOV version 1.10