1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef SC_JUMPMATRIX_HXX
21 #define SC_JUMPMATRIX_HXX
23 #include "formula/token.hxx"
24 #include "formula/errorcodes.hxx"
25 #include <tools/solar.h>
28 #include "address.hxx"
30 typedef ::std::vector
< formula::FormulaToken
*> ScTokenVec
;
32 struct ScJumpMatrixEntry
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)
41 void SetJump( double fBoolP
, short nStartP
, short nNextP
, short nStopP
)
48 void GetJump( double& rBool
, short& rStart
, short& rNext
, short& rStop
)
59 ScJumpMatrixEntry
* pJump
; // the jumps
60 ScMatrixRef pMat
; // the results
61 ScTokenVec
* pParams
; // parameter stack
70 // Buffer result ranges to be able to set a range of identically typed
71 // values at the result matrix in order to avoid multiple shrinks and
72 // growths of multi_type_vector segments, which is a major performance
73 // bottleneck, see fdo#72929
74 ::std::vector
< svl::SharedString
> mvBufferStrings
;
75 ::std::vector
< double > mvBufferDoubles
;
77 SCSIZE mnBufferRowStart
;
78 SCSIZE mnBufferEmptyCount
;
79 SCSIZE mnBufferEmptyPathCount
;
90 /** Flush different types or non-consecutive buffers. */
91 void FlushBufferOtherThan( BufferType eType
, SCSIZE nC
, SCSIZE nR
);
93 // not implemented, prevent usage
94 ScJumpMatrix( const ScJumpMatrix
& );
95 ScJumpMatrix
& operator=( const ScJumpMatrix
& );
98 ScJumpMatrix( SCSIZE nColsP
, SCSIZE nRowsP
);
100 void GetDimensions( SCSIZE
& rCols
, SCSIZE
& rRows
) const;
101 void SetJump( SCSIZE nCol
, SCSIZE nRow
, double fBool
, short nStart
, short nNext
, short nStop
= SHRT_MAX
);
102 void GetJump( SCSIZE nCol
, SCSIZE nRow
, double& rBool
, short& rStart
, short& rNext
, short& rStop
) const;
103 void SetAllJumps( double fBool
, short nStart
, short nNext
, short nStop
= SHRT_MAX
);
104 void SetJumpParameters( ScTokenVec
* p
);
105 const ScTokenVec
* GetJumpParameters() const;
106 bool HasResultMatrix() const;
107 ScMatrix
* GetResultMatrix(); ///< also applies pending buffered values
108 void GetPos( SCSIZE
& rCol
, SCSIZE
& rRow
) const;
109 bool Next( SCSIZE
& rCol
, SCSIZE
& rRow
);
110 void GetResMatDimensions( SCSIZE
& rCols
, SCSIZE
& rRows
);
111 void SetNewResMat( SCSIZE nNewCols
, SCSIZE nNewRows
);
113 void PutResultDouble( double fVal
, SCSIZE nC
, SCSIZE nR
);
114 void PutResultString( const svl::SharedString
& rStr
, SCSIZE nC
, SCSIZE nR
);
115 void PutResultEmpty( SCSIZE nC
, SCSIZE nR
);
116 void PutResultEmptyPath( SCSIZE nC
, SCSIZE nR
);
119 #endif // SC_JUMPMATRIX_HXX
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */