/src/libreoffice/sc/inc/tokenstringcontext.hxx
Line | Count | Source |
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 | | |
10 | | #pragma once |
11 | | |
12 | | #include "compiler.hxx" |
13 | | |
14 | | #include <unordered_map> |
15 | | |
16 | | class ScDocument; |
17 | | |
18 | | namespace sc |
19 | | { |
20 | | /** |
21 | | * Context for creating string from an array of formula tokens, used in |
22 | | * ScTokenArray::CreateString(). You can re-use the same string context |
23 | | * between multiple CreateString() calls as long as the document content is |
24 | | * unmodified. |
25 | | */ |
26 | | struct SC_DLLPUBLIC TokenStringContext |
27 | | { |
28 | | typedef std::unordered_map<sal_uInt16, OUString> IndexNameMapType; |
29 | | typedef std::unordered_map<size_t, std::vector<OUString>> IndexNamesMapType; |
30 | | typedef std::unordered_map<SCTAB, IndexNameMapType> TabIndexMapType; |
31 | | |
32 | | formula::FormulaGrammar::Grammar meGram; |
33 | | formula::FormulaCompiler::OpCodeMapPtr mxOpCodeMap; |
34 | | const ScCompiler::Convention* mpRefConv; |
35 | | OUString maErrRef; |
36 | | |
37 | | std::vector<OUString> maTabNames; |
38 | | IndexNameMapType maGlobalRangeNames; |
39 | | TabIndexMapType maSheetRangeNames; |
40 | | IndexNameMapType maNamedDBs; |
41 | | |
42 | | std::vector<OUString> maExternalFileNames; |
43 | | IndexNamesMapType maExternalCachedTabNames; |
44 | | |
45 | | TokenStringContext(const ScDocument& rDoc, formula::FormulaGrammar::Grammar eGram); |
46 | | }; |
47 | | |
48 | | class SC_DLLPUBLIC CompileFormulaContext |
49 | | { |
50 | | ScDocument& mrDoc; |
51 | | formula::FormulaGrammar::Grammar meGram; |
52 | | std::vector<OUString> maTabNames; |
53 | | // Used in FormulaCompiler::CreateStringFromToken(), set by ScXMLExport::WriteCell() |
54 | | std::optional<SvtSaveOptions::ODFSaneDefaultVersion> m_oODFSavingVersion; |
55 | | |
56 | | void updateTabNames(); |
57 | | |
58 | | public: |
59 | | CompileFormulaContext(ScDocument& rDoc); |
60 | | CompileFormulaContext(ScDocument& rDoc, formula::FormulaGrammar::Grammar eGram); |
61 | | |
62 | 289k | formula::FormulaGrammar::Grammar getGrammar() const { return meGram; } |
63 | | void setGrammar(formula::FormulaGrammar::Grammar eGram); |
64 | | |
65 | | void setODFSavingVersion(SvtSaveOptions::ODFSaneDefaultVersion eDefaultVersion) |
66 | 0 | { |
67 | 0 | m_oODFSavingVersion = eDefaultVersion; |
68 | 0 | } |
69 | | const std::optional<SvtSaveOptions::ODFSaneDefaultVersion>& getODFSavingVersion() const |
70 | 289k | { |
71 | 289k | return m_oODFSavingVersion; |
72 | 289k | } |
73 | | |
74 | 289k | const std::vector<OUString>& getTabNames() const { return maTabNames; } |
75 | | |
76 | 289k | ScDocument& getDoc() { return mrDoc; } |
77 | | }; |
78 | | } |
79 | | |
80 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |