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