check IFrame "FrameURL" target
[LibreOffice.git] / sc / inc / formulagroup.hxx
blob88e54820ed3f2dddd6753e40d22153c0713d900a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #pragma once
12 #include <config_feature_opencl.h>
14 #include "address.hxx"
15 #include "calcconfig.hxx"
16 #include "types.hxx"
17 #include "stlalgorithm.hxx"
19 #if HAVE_FEATURE_OPENCL
20 #include <opencl/platforminfo.hxx>
21 #endif
23 #include <memory>
24 #include <unordered_map>
25 #include <vector>
27 class ScDocument;
28 class ScTokenArray;
29 class ScFormulaCell;
31 namespace sc {
33 struct FormulaGroupEntry
35 union
37 ScFormulaCell* mpCell; // non-shared formula cell
38 ScFormulaCell** mpCells; // pointer to the top formula cell in a shared group.
41 size_t mnRow;
42 size_t mnLength;
43 bool mbShared;
45 FormulaGroupEntry( ScFormulaCell** pCells, size_t nRow, size_t nLength );
47 FormulaGroupEntry( ScFormulaCell* pCell, size_t nRow );
50 // Despite the name, this is actually a cache of cell values, used by OpenCL
51 // code ... I think. And obviously it's not really a struct either.
52 struct FormulaGroupContext
54 typedef AlignedAllocator<double,256> DoubleAllocType;
55 typedef std::vector<double, DoubleAllocType> NumArrayType;
56 typedef std::vector<rtl_uString*> StrArrayType;
57 typedef std::vector<std::unique_ptr<NumArrayType>> NumArrayStoreType;
58 typedef std::vector<std::unique_ptr<StrArrayType>> StrArrayStoreType;
60 struct ColKey
62 SCTAB mnTab;
63 SCCOL mnCol;
65 struct Hash
67 size_t operator() ( const ColKey& rKey ) const;
70 ColKey( SCTAB nTab, SCCOL nCol );
72 bool operator== ( const ColKey& r ) const;
75 struct ColArray
77 NumArrayType* mpNumArray;
78 StrArrayType* mpStrArray;
79 size_t mnSize;
81 ColArray( NumArrayType* pNumArray, StrArrayType* pStrArray );
84 typedef std::unordered_map<ColKey, ColArray, ColKey::Hash> ColArraysType;
86 NumArrayStoreType m_NumArrays; /// manage life cycle of numeric arrays.
87 StrArrayStoreType m_StrArrays; /// manage life cycle of string arrays.
89 ColArraysType maColArrays; /// keep track of longest array for each column.
91 ColArray* getCachedColArray( SCTAB nTab, SCCOL nCol, size_t nSize );
93 ColArray* setCachedColArray(
94 SCTAB nTab, SCCOL nCol, NumArrayType* pNumArray, StrArrayType* pStrArray );
96 void discardCachedColArray(SCTAB nTab, SCCOL nCol);
98 void ensureStrArray( ColArray& rColArray, size_t nArrayLen );
99 void ensureNumArray( ColArray& rColArray, size_t nArrayLen );
101 FormulaGroupContext();
102 FormulaGroupContext(const FormulaGroupContext&) = delete;
103 const FormulaGroupContext& operator=(const FormulaGroupContext&) = delete;
104 ~FormulaGroupContext();
108 * Abstract base class for a "compiled" formula
110 class CompiledFormula
112 public:
113 CompiledFormula();
114 virtual ~CompiledFormula();
118 * Abstract base class for vectorised formula group interpreters,
119 * plus a global instance factory.
121 class SC_DLLPUBLIC FormulaGroupInterpreter
123 static FormulaGroupInterpreter *msInstance;
125 protected:
126 ScCalcConfig maCalcConfig;
128 FormulaGroupInterpreter() {}
129 virtual ~FormulaGroupInterpreter() {}
131 /// Merge global and document specific settings.
132 void MergeCalcConfig(const ScDocument& rDoc);
134 public:
135 static FormulaGroupInterpreter *getStatic();
136 #if HAVE_FEATURE_OPENCL
137 static void fillOpenCLInfo(std::vector<OpenCLPlatformInfo>& rPlatforms);
138 static bool switchOpenCLDevice(const OUString& rDeviceId, bool bAutoSelect, bool bForceEvaluation = false);
139 // This is intended to be called from opencl-test.cxx only
140 static void enableOpenCL_UnitTestsOnly();
141 static void disableOpenCL_UnitTestsOnly();
142 static void getOpenCLDeviceInfo(sal_Int32& rDeviceId, sal_Int32& rPlatformId);
143 #endif
144 virtual ScMatrixRef inverseMatrix(const ScMatrix& rMat) = 0;
145 virtual bool interpret(ScDocument& rDoc, const ScAddress& rTopPos, ScFormulaCellGroupRef& xGroup, ScTokenArray& rCode) = 0;
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */