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_JUMPMATRIX_HXX
21 : #define SC_JUMPMATRIX_HXX
22 :
23 : #include "formula/token.hxx"
24 : #include "formula/errorcodes.hxx"
25 : #include <tools/solar.h>
26 : #include <vector>
27 : #include "types.hxx"
28 : #include "address.hxx"
29 :
30 : typedef ::std::vector< formula::FormulaToken*> ScTokenVec;
31 :
32 : struct ScJumpMatrixEntry
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 3 : void SetJump( double fBoolP, short nStartP, short nNextP, short nStopP )
42 : {
43 3 : fBool = fBoolP;
44 3 : nStart = nStartP;
45 3 : nNext = nNextP;
46 3 : nStop = nStopP;
47 3 : }
48 2 : void GetJump( double& rBool, short& rStart, short& rNext, short& rStop )
49 : {
50 2 : rBool = fBool;
51 2 : rStart = nStart;
52 2 : rNext = nNext;
53 2 : rStop = nStop;
54 2 : }
55 : };
56 :
57 : class ScJumpMatrix
58 : {
59 : ScJumpMatrixEntry* pJump; // the jumps
60 : ScMatrixRef pMat; // the results
61 : ScTokenVec* pParams; // parameter stack
62 : SCSIZE nCols;
63 : SCSIZE nRows;
64 : SCSIZE nCurCol;
65 : SCSIZE nCurRow;
66 : SCSIZE nResMatCols;
67 : SCSIZE nResMatRows;
68 : bool bStarted;
69 :
70 : // not implemented, prevent usage
71 : ScJumpMatrix( const ScJumpMatrix& );
72 : ScJumpMatrix& operator=( const ScJumpMatrix& );
73 :
74 : public:
75 : ScJumpMatrix( SCSIZE nColsP, SCSIZE nRowsP );
76 : ~ScJumpMatrix();
77 : void GetDimensions( SCSIZE& rCols, SCSIZE& rRows ) const;
78 : void SetJump( SCSIZE nCol, SCSIZE nRow, double fBool, short nStart, short nNext, short nStop = SHRT_MAX );
79 : void GetJump( SCSIZE nCol, SCSIZE nRow, double& rBool, short& rStart, short& rNext, short& rStop ) const;
80 : void SetAllJumps( double fBool, short nStart, short nNext, short nStop = SHRT_MAX );
81 : void SetJumpParameters( ScTokenVec* p );
82 : const ScTokenVec* GetJumpParameters() const;
83 : ScMatrix* GetResultMatrix() const;
84 : void GetPos( SCSIZE& rCol, SCSIZE& rRow ) const;
85 : bool Next( SCSIZE& rCol, SCSIZE& rRow );
86 : void GetResMatDimensions( SCSIZE& rCols, SCSIZE& rRows );
87 : void SetNewResMat( SCSIZE nNewCols, SCSIZE nNewRows );
88 : };
89 :
90 : #endif // SC_JUMPMATRIX_HXX
91 :
92 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|