LCOV - code coverage report
Current view: top level - libreoffice/sc/source/filter/inc - formel.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 13 25 52.0 %
Date: 2012-12-27 Functions: 4 7 57.1 %
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             : #ifndef SC_FORMEL_HXX
      21             : #define SC_FORMEL_HXX
      22             : 
      23             : #include <tools/solar.h>
      24             : 
      25             : #include <compiler.hxx>
      26             : #include <global.hxx>
      27             : 
      28             : #include "root.hxx"
      29             : #include "tokstack.hxx"
      30             : 
      31             : #include <boost/ptr_container/ptr_map.hpp>
      32             : #include <vector>
      33             : 
      34             : class XclImpStream;
      35             : class ScTokenArray;
      36             : struct ScSingleRefData;
      37             : struct ScComplexRefData;
      38             : 
      39             : enum ConvErr
      40             : {
      41             :     ConvOK = 0,
      42             :     ConvErrNi,      // unimplemented/unknown opcode occurred
      43             :     ConvErrNoMem,   // alloc error
      44             :     ConvErrExternal,// excel add-ins are not converted
      45             :     ConvErrCount    // did not get all bytes of formula
      46             : };
      47             : 
      48             : enum FORMULA_TYPE
      49             : {
      50             :     FT_CellFormula,
      51             :     FT_RangeName,
      52             :     FT_SharedFormula,
      53             :     FT_CondFormat
      54             : };
      55             : 
      56             : class _ScRangeListTabs
      57             : {
      58             :     typedef ::std::vector<ScRange> RangeListType;
      59             :     typedef ::boost::ptr_map<SCTAB, RangeListType> TabRangeType;
      60             :     TabRangeType maTabRanges;
      61             :     RangeListType::const_iterator maItrCur;
      62             :     RangeListType::const_iterator maItrCurEnd;
      63             : 
      64             : public:
      65             :     _ScRangeListTabs ();
      66             :     ~_ScRangeListTabs();
      67             : 
      68             :     void Append( ScSingleRefData aSRD, SCTAB nTab, bool bLimit = true );
      69             :     void Append( ScComplexRefData aCRD, SCTAB nTab, bool bLimit = true );
      70             : 
      71             :     const ScRange* First ( SCTAB nTab = 0 );
      72             :     const ScRange* Next ();
      73             : 
      74          40 :     bool HasRanges () const { return !maTabRanges.empty(); }
      75             : };
      76             : 
      77             : class ConverterBase
      78             : {
      79             : protected:
      80             :     TokenPool           aPool;          // user token + predefined token
      81             :     TokenStack          aStack;
      82             :     ScAddress           aEingPos;
      83             :     ConvErr             eStatus;
      84             :     sal_Char*           pBuffer;        // universal buffer
      85             :     sal_uInt16              nBufferSize;    // ...and its size
      86             : 
      87             :                         ConverterBase( sal_uInt16 nNewBuffer );
      88             :     virtual             ~ConverterBase();
      89             : 
      90             :     void                Reset();
      91             : };
      92             : 
      93             : 
      94             : 
      95             : class ExcelConverterBase : public ConverterBase
      96             : {
      97             : protected:
      98             :                         ExcelConverterBase( sal_uInt16 nNewBuffer );
      99             :     virtual             ~ExcelConverterBase();
     100             : 
     101             : public:
     102             :     void                Reset();
     103             :     void                Reset( const ScAddress& rEingPos );
     104             : 
     105             :     virtual ConvErr     Convert( const ScTokenArray*& rpErg, XclImpStream& rStrm, sal_Size nFormulaLen,
     106             :                                  bool bAllowArrays, const FORMULA_TYPE eFT = FT_CellFormula ) = 0;
     107             :     virtual ConvErr     Convert( _ScRangeListTabs&, XclImpStream& rStrm, sal_Size nFormulaLen, SCsTAB nTab,
     108             :                                     const FORMULA_TYPE eFT = FT_CellFormula ) = 0;
     109             : };
     110             : 
     111             : 
     112             : 
     113             : class LotusConverterBase : public ConverterBase
     114             : {
     115             : protected:
     116             :     SvStream&           aIn;
     117             :     sal_Int32               nBytesLeft;
     118             : 
     119             :     inline void         Ignore( const long nSeekRel );
     120             :     inline void         Read( sal_Char& nByte );
     121             :     inline void         Read( sal_uInt8& nByte );
     122             :     inline void         Read( sal_uInt16& nUINT16 );
     123             :     inline void         Read( sal_Int16& nINT16 );
     124             :     inline void         Read( double& fDouble );
     125             :         inline void                     Read( sal_uInt32& nUINT32 );
     126             : 
     127             :                         LotusConverterBase( SvStream& rStr, sal_uInt16 nNewBuffer );
     128             :     virtual             ~LotusConverterBase();
     129             : 
     130             : public:
     131             :     void                Reset( const ScAddress& rEingPos );
     132             : 
     133             :     virtual ConvErr     Convert( const ScTokenArray*& rpErg, sal_Int32& nRest,
     134             :                                     const FORMULA_TYPE eFT = FT_CellFormula ) = 0;
     135             : 
     136             : protected:
     137             :     using               ConverterBase::Reset;
     138             : };
     139             : 
     140             : 
     141           0 : inline void LotusConverterBase::Ignore( const long nSeekRel )
     142             : {
     143           0 :     aIn.SeekRel( nSeekRel );
     144           0 :     nBytesLeft -= nSeekRel;
     145           0 : }
     146             : 
     147             : inline void LotusConverterBase::Read( sal_Char& nByte )
     148             : {
     149             :     aIn >> nByte;
     150             :     nBytesLeft--;
     151             : }
     152             : 
     153          22 : inline void LotusConverterBase::Read( sal_uInt8& nByte )
     154             : {
     155          22 :     aIn >> nByte;
     156          22 :     nBytesLeft--;
     157          22 : }
     158             : 
     159           2 : inline void LotusConverterBase::Read( sal_uInt16& nUINT16 )
     160             : {
     161           2 :     aIn >> nUINT16;
     162           2 :     nBytesLeft -= 2;
     163           2 : }
     164             : 
     165           0 : inline void LotusConverterBase::Read( sal_Int16& nINT16 )
     166             : {
     167           0 :     aIn >> nINT16;
     168           0 :     nBytesLeft -= 2;
     169           0 : }
     170             : 
     171           0 : inline void LotusConverterBase::Read( double& fDouble )
     172             : {
     173           0 :     aIn >> fDouble;
     174           0 :     nBytesLeft -= 8;
     175           0 : }
     176             : 
     177           6 : inline void LotusConverterBase::Read( sal_uInt32& nUINT32 )
     178             : {
     179           6 :     aIn >> nUINT32;
     180           6 :     nBytesLeft -= 4;
     181           6 : }
     182             : 
     183             : #endif
     184             : 
     185             : 
     186             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10