Fix build
[LibreOffice.git] / sc / inc / tokenstringcontext.hxx
blob7421120dd2a6ecd17ad4197816375009d766f667
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 "compiler.hxx"
14 #include <unordered_map>
16 class ScDocument;
18 namespace sc
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.
26 struct SC_DLLPUBLIC TokenStringContext
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;
32 formula::FormulaGrammar::Grammar meGram;
33 formula::FormulaCompiler::OpCodeMapPtr mxOpCodeMap;
34 const ScCompiler::Convention* mpRefConv;
35 OUString maErrRef;
37 std::vector<OUString> maTabNames;
38 IndexNameMapType maGlobalRangeNames;
39 TabIndexMapType maSheetRangeNames;
40 IndexNameMapType maNamedDBs;
42 std::vector<OUString> maExternalFileNames;
43 IndexNamesMapType maExternalCachedTabNames;
45 TokenStringContext(const ScDocument& rDoc, formula::FormulaGrammar::Grammar eGram);
48 class SC_DLLPUBLIC CompileFormulaContext
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;
56 void updateTabNames();
58 public:
59 CompileFormulaContext(ScDocument& rDoc);
60 CompileFormulaContext(ScDocument& rDoc, formula::FormulaGrammar::Grammar eGram);
62 formula::FormulaGrammar::Grammar getGrammar() const { return meGram; }
63 void setGrammar(formula::FormulaGrammar::Grammar eGram);
65 void setODFSavingVersion(SvtSaveOptions::ODFSaneDefaultVersion eDefaultVersion)
67 m_oODFSavingVersion = eDefaultVersion;
69 std::optional<SvtSaveOptions::ODFSaneDefaultVersion> getODFSavingVersion()
71 return m_oODFSavingVersion;
74 const std::vector<OUString>& getTabNames() const { return maTabNames; }
76 ScDocument& getDoc() { return mrDoc; }
80 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */