LibreOffice Module sc (master)  1
jumpmatrix.hxx
Go to the documentation of this file.
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 <limits.h>
24 #include <vector>
25 #include <types.hxx>
26 #include <address.hxx>
27 #include <token.hxx>
28 
29 namespace formula { class FormulaToken; }
30 
31 typedef ::std::vector< const formula::FormulaToken*> ScTokenVec;
32 
34 {
35  double fBool; // 0:= false 1:= true also if no-path
36  // other values may contain error conditions like NAN and INF
37  short nStart; // start of path (actually start-1, see formula::FormulaTokenIterator)
38  short nNext; // next after path
39  // jump path exists if nStart != nNext, else no path
40  short nStop; // optional stop of path (nPC < nStop)
41 
42  void SetJump( double fBoolP, short nStartP, short nNextP, short nStopP )
43  {
44  fBool = fBoolP;
45  nStart = nStartP;
46  nNext = nNextP;
47  nStop = nStopP;
48  }
49  void GetJump( double& rBool, short& rStart, short& rNext, short& rStop ) const
50  {
51  rBool = fBool;
52  rStart = nStart;
53  rNext = nNext;
54  rStop = nStop;
55  }
56 };
57 
59 {
60  std::vector<ScJumpMatrixEntry> mvJump; // the jumps
61  ScMatrixRef pMat; // the results
62  ScRefList mvRefList; // array of references result, if any
63  ScTokenVec mvParams; // parameter stack
71  bool bStarted;
72 
73  // Buffer result ranges to be able to set a range of identically typed
74  // values at the result matrix in order to avoid multiple shrinks and
75  // growths of multi_type_vector segments, which is a major performance
76  // bottleneck, see fdo#72929
77  ::std::vector< svl::SharedString > mvBufferStrings;
78  ::std::vector< double > mvBufferDoubles;
83 
85  {
91  };
92 
94  void FlushBufferOtherThan( BufferType eType, SCSIZE nC, SCSIZE nR );
95 
96  ScJumpMatrix( const ScJumpMatrix& ) = delete;
97  ScJumpMatrix& operator=( const ScJumpMatrix& ) = delete;
98 
99 public:
100  ScJumpMatrix( OpCode eOp, SCSIZE nColsP, SCSIZE nRowsP );
101  ~ScJumpMatrix();
102  void GetDimensions( SCSIZE& rCols, SCSIZE& rRows ) const;
103  void SetJump( SCSIZE nCol, SCSIZE nRow, double fBool, short nStart, short nNext );
104  void GetJump( SCSIZE nCol, SCSIZE nRow, double& rBool, short& rStart, short& rNext, short& rStop ) const;
105  void SetAllJumps( double fBool, short nStart, short nNext, short nStop = SHRT_MAX );
106  void SetJumpParameters( ScTokenVec&& p );
107  const ScTokenVec & GetJumpParameters() const { return mvParams;}
108  bool HasResultMatrix() const;
110  void GetPos( SCSIZE& rCol, SCSIZE& rRow ) const;
111  bool Next( SCSIZE& rCol, SCSIZE& rRow );
112  void GetResMatDimensions( SCSIZE& rCols, SCSIZE& rRows );
113  void SetNewResMat( SCSIZE nNewCols, SCSIZE nNewRows );
115  OpCode GetOpCode() const { return meOp; }
116 
117  void PutResultDouble( double fVal, SCSIZE nC, SCSIZE nR );
118  void PutResultString( const svl::SharedString& rStr, SCSIZE nC, SCSIZE nR );
119  void PutResultEmpty( SCSIZE nC, SCSIZE nR );
120  void PutResultEmptyPath( SCSIZE nC, SCSIZE nR );
121 };
122 
123 #endif // INCLUDED_SC_SOURCE_CORE_INC_JUMPMATRIX_HXX
124 
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Matrix data type that can store values of mixed types.
Definition: scmatrix.hxx:113
std::vector< ScJumpMatrixEntry > mvJump
Definition: jumpmatrix.hxx:60
SCSIZE mnBufferRowStart
Definition: jumpmatrix.hxx:80
ScMatrixRef pMat
Definition: jumpmatrix.hxx:61
void SetNewResMat(SCSIZE nNewCols, SCSIZE nNewRows)
Definition: jumpmatrix.cxx:135
ScJumpMatrix & operator=(const ScJumpMatrix &)=delete
SCSIZE nCols
Definition: jumpmatrix.hxx:64
void SetJump(SCSIZE nCol, SCSIZE nRow, double fBool, short nStart, short nNext)
Definition: jumpmatrix.cxx:63
::std::vector< svl::SharedString > mvBufferStrings
Definition: jumpmatrix.hxx:77
ScTokenVec mvParams
Definition: jumpmatrix.hxx:63
void PutResultEmpty(SCSIZE nC, SCSIZE nR)
Definition: jumpmatrix.cxx:241
void GetJump(SCSIZE nCol, SCSIZE nRow, double &rBool, short &rStart, short &rNext, short &rStop) const
Definition: jumpmatrix.cxx:69
SCSIZE nResMatCols
Definition: jumpmatrix.hxx:68
void GetDimensions(SCSIZE &rCols, SCSIZE &rRows) const
Definition: jumpmatrix.cxx:57
SCSIZE nCurCol
Definition: jumpmatrix.hxx:66
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
Definition: address.hxx:45
OpCode
::boost::intrusive_ptr< ScMatrix > ScMatrixRef
Definition: types.hxx:26
SCSIZE mnBufferEmptyCount
Definition: jumpmatrix.hxx:81
bool Next(SCSIZE &rCol, SCSIZE &rRow)
Definition: jumpmatrix.cxx:110
void SetJump(double fBoolP, short nStartP, short nNextP, short nStopP)
Definition: jumpmatrix.hxx:42
void PutResultEmptyPath(SCSIZE nC, SCSIZE nR)
Definition: jumpmatrix.cxx:257
void SetJumpParameters(ScTokenVec &&p)
Definition: jumpmatrix.cxx:99
bool HasResultMatrix() const
Definition: jumpmatrix.cxx:163
SCSIZE mnBufferCol
Definition: jumpmatrix.hxx:79
ScMatrix * GetResultMatrix()
also applies pending buffered values
Definition: jumpmatrix.cxx:202
ScRefList mvRefList
Definition: jumpmatrix.hxx:62
::std::vector< const formula::FormulaToken * > ScTokenVec
Definition: jumpmatrix.hxx:31
void GetPos(SCSIZE &rCol, SCSIZE &rRow) const
Definition: jumpmatrix.cxx:104
void GetResMatDimensions(SCSIZE &rCols, SCSIZE &rRows)
Definition: jumpmatrix.cxx:129
void SetAllJumps(double fBool, short nStart, short nNext, short nStop=SHRT_MAX)
Definition: jumpmatrix.cxx:89
SCSIZE mnBufferEmptyPathCount
Definition: jumpmatrix.hxx:82
void FlushBufferOtherThan(BufferType eType, SCSIZE nC, SCSIZE nR)
Flush different types or non-consecutive buffers.
Definition: jumpmatrix.cxx:174
void GetJump(double &rBool, short &rStart, short &rNext, short &rStop) const
Definition: jumpmatrix.hxx:49
ScJumpMatrix(const ScJumpMatrix &)=delete
SCSIZE nResMatRows
Definition: jumpmatrix.hxx:69
SCSIZE nRows
Definition: jumpmatrix.hxx:65
void PutResultDouble(double fVal, SCSIZE nC, SCSIZE nR)
Definition: jumpmatrix.cxx:209
void PutResultString(const svl::SharedString &rStr, SCSIZE nC, SCSIZE nR)
Definition: jumpmatrix.cxx:225
SCSIZE nCurRow
Definition: jumpmatrix.hxx:67
ScRefList & GetRefList()
Definition: jumpmatrix.cxx:169
::std::vector< ScComplexRefData > ScRefList
Definition: token.hxx:38
::std::vector< double > mvBufferDoubles
Definition: jumpmatrix.hxx:78
OpCode GetOpCode() const
Definition: jumpmatrix.hxx:115
const ScTokenVec & GetJumpParameters() const
Definition: jumpmatrix.hxx:107