LCOV - code coverage report
Current view: top level - sc/source/core/inc - jumpmatrix.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 13 13 100.0 %
Date: 2015-06-13 12:38:46 Functions: 3 3 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             : #ifndef INCLUDED_SC_SOURCE_CORE_INC_JUMPMATRIX_HXX
      21             : #define INCLUDED_SC_SOURCE_CORE_INC_JUMPMATRIX_HXX
      22             : 
      23             : #include <formula/token.hxx>
      24             : #include <formula/errorcodes.hxx>
      25             : #include <vector>
      26             : #include "types.hxx"
      27             : #include "address.hxx"
      28             : 
      29             : typedef ::std::vector< formula::FormulaToken*> ScTokenVec;
      30             : 
      31             : struct ScJumpMatrixEntry
      32             : {
      33             :     double  fBool;      // 0:= false  1:= true   also if no-path
      34             :                         // other values may contain error conditions like NAN and INF
      35             :     short   nStart;     // start of path (actually start-1, see formula::FormulaTokenIterator)
      36             :     short   nNext;      // next after path
      37             :                         // jump path exists if nStart != nNext, else no path
      38             :     short   nStop;      // optional stop of path (nPC < nStop)
      39             : 
      40          29 :     void    SetJump( double fBoolP, short nStartP, short nNextP, short nStopP )
      41             :                 {
      42          29 :                     fBool = fBoolP;
      43          29 :                     nStart = nStartP;
      44          29 :                     nNext = nNextP;
      45          29 :                     nStop = nStopP;
      46          29 :                 }
      47          28 :     void    GetJump( double& rBool, short& rStart, short& rNext, short& rStop )
      48             :                 {
      49          28 :                     rBool = fBool;
      50          28 :                     rStart = nStart;
      51          28 :                     rNext = nNext;
      52          28 :                     rStop = nStop;
      53          28 :                 }
      54             : };
      55             : 
      56             : class ScJumpMatrix
      57             : {
      58             :     ScJumpMatrixEntry*  pJump;      // the jumps
      59             :     ScMatrixRef         pMat;       // the results
      60             :     ScTokenVec*         pParams;    // parameter stack
      61             :     SCSIZE              nCols;
      62             :     SCSIZE              nRows;
      63             :     SCSIZE              nCurCol;
      64             :     SCSIZE              nCurRow;
      65             :     SCSIZE              nResMatCols;
      66             :     SCSIZE              nResMatRows;
      67             :     bool                bStarted;
      68             : 
      69             :     // Buffer result ranges to be able to set a range of identically typed
      70             :     // values at the result matrix in order to avoid multiple shrinks and
      71             :     // growths of multi_type_vector segments, which is a major performance
      72             :     // bottleneck, see fdo#72929
      73             :     ::std::vector< svl::SharedString >  mvBufferStrings;
      74             :     ::std::vector< double >             mvBufferDoubles;
      75             :     SCSIZE                              mnBufferCol;
      76             :     SCSIZE                              mnBufferRowStart;
      77             :     SCSIZE                              mnBufferEmptyCount;
      78             :     SCSIZE                              mnBufferEmptyPathCount;
      79             : 
      80             :     enum BufferType
      81             :     {
      82             :         BUFFER_NONE,
      83             :         BUFFER_DOUBLE,
      84             :         BUFFER_STRING,
      85             :         BUFFER_EMPTY,
      86             :         BUFFER_EMPTYPATH
      87             :     };
      88             : 
      89             :     /** Flush different types or non-consecutive buffers. */
      90             :     void FlushBufferOtherThan( BufferType eType, SCSIZE nC, SCSIZE nR );
      91             : 
      92             :     ScJumpMatrix( const ScJumpMatrix& ) SAL_DELETED_FUNCTION;
      93             :     ScJumpMatrix& operator=( const ScJumpMatrix& ) SAL_DELETED_FUNCTION;
      94             : 
      95             : public:
      96             :     ScJumpMatrix( SCSIZE nColsP, SCSIZE nRowsP );
      97             :     ~ScJumpMatrix();
      98             :     void GetDimensions( SCSIZE& rCols, SCSIZE& rRows ) const;
      99             :     void SetJump( SCSIZE nCol, SCSIZE nRow, double fBool, short nStart, short nNext, short nStop = SHRT_MAX );
     100             :     void GetJump( SCSIZE nCol, SCSIZE nRow, double& rBool, short& rStart, short& rNext, short& rStop ) const;
     101             :     void SetAllJumps( double fBool, short nStart, short nNext, short nStop = SHRT_MAX );
     102             :     void SetJumpParameters( ScTokenVec* p );
     103          25 :     const ScTokenVec* GetJumpParameters() const { return pParams;}
     104             :     bool HasResultMatrix() const;
     105             :     ScMatrix* GetResultMatrix();        ///< also applies pending buffered values
     106             :     void GetPos( SCSIZE& rCol, SCSIZE& rRow ) const;
     107             :     bool Next( SCSIZE& rCol, SCSIZE& rRow );
     108             :     void GetResMatDimensions( SCSIZE& rCols, SCSIZE& rRows );
     109             :     void SetNewResMat( SCSIZE nNewCols, SCSIZE nNewRows );
     110             : 
     111             :     void PutResultDouble( double fVal, SCSIZE nC, SCSIZE nR );
     112             :     void PutResultString( const svl::SharedString& rStr, SCSIZE nC, SCSIZE nR );
     113             :     void PutResultEmpty( SCSIZE nC, SCSIZE nR );
     114             :     void PutResultEmptyPath( SCSIZE nC, SCSIZE nR );
     115             : };
     116             : 
     117             : #endif // INCLUDED_SC_SOURCE_CORE_INC_JUMPMATRIX_HXX
     118             : 
     119             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11