fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / core / tool / tokenstringcontext.cxx
blob44babecdc21f2760c4806e94c1d9069fa79ae866
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 #include "tokenstringcontext.hxx"
11 #include "compiler.hxx"
12 #include "document.hxx"
13 #include "dbdata.hxx"
14 #include "externalrefmgr.hxx"
16 using namespace com::sun::star;
18 namespace sc {
20 namespace {
22 void insertAllNames( TokenStringContext::IndexNameMapType& rMap, const ScRangeName& rNames )
24 ScRangeName::const_iterator it = rNames.begin(), itEnd = rNames.end();
25 for (; it != itEnd; ++it)
27 const ScRangeData* pData = it->second;
28 rMap.insert(
29 TokenStringContext::IndexNameMapType::value_type(pData->GetIndex(), pData->GetName()));
35 TokenStringContext::TokenStringContext( const ScDocument* pDoc, formula::FormulaGrammar::Grammar eGram ) :
36 meGram(eGram),
37 mpRefConv(ScCompiler::GetRefConvention(formula::FormulaGrammar::extractRefConvention(eGram)))
39 ScCompiler aComp(NULL, ScAddress());
40 mxOpCodeMap = aComp.GetOpCodeMap(formula::FormulaGrammar::extractFormulaLanguage(eGram));
41 if (mxOpCodeMap)
42 maErrRef = mxOpCodeMap->getSymbol(ocErrRef);
44 if (!pDoc)
45 return;
47 // Fetch all sheet names.
48 maTabNames = pDoc->GetAllTableNames();
50 std::vector<OUString>::iterator it = maTabNames.begin(), itEnd = maTabNames.end();
51 for (; it != itEnd; ++it)
52 ScCompiler::CheckTabQuotes(*it, formula::FormulaGrammar::extractRefConvention(eGram));
55 // Fetch all named range names.
56 const ScRangeName* pNames = pDoc->GetRangeName();
57 if (pNames)
58 // global names
59 insertAllNames(maGlobalRangeNames, *pNames);
62 ScRangeName::TabNameCopyMap aTabRangeNames;
63 pDoc->GetAllTabRangeNames(aTabRangeNames);
64 ScRangeName::TabNameCopyMap::const_iterator it = aTabRangeNames.begin(), itEnd = aTabRangeNames.end();
65 for (; it != itEnd; ++it)
67 const ScRangeName* pSheetNames = it->second;
68 if (!pSheetNames)
69 continue;
71 SCTAB nTab = it->first;
72 IndexNameMapType aNames;
73 insertAllNames(aNames, *pSheetNames);
74 maSheetRangeNames.insert(TabIndexMapType::value_type(nTab, aNames));
78 // Fetch all named database ranges names.
79 const ScDBCollection* pDBs = pDoc->GetDBCollection();
80 if (pDBs)
82 const ScDBCollection::NamedDBs& rNamedDBs = pDBs->getNamedDBs();
83 ScDBCollection::NamedDBs::const_iterator it = rNamedDBs.begin(), itEnd = rNamedDBs.end();
84 for (; it != itEnd; ++it)
86 const ScDBData& rData = *it;
87 maNamedDBs.insert(IndexNameMapType::value_type(rData.GetIndex(), rData.GetName()));
91 // Fetch all relevant bits for external references.
92 if (pDoc->HasExternalRefManager())
94 const ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
95 maExternalFileNames = pRefMgr->getAllCachedExternalFileNames();
96 for (size_t i = 0, n = maExternalFileNames.size(); i < n; ++i)
98 sal_uInt16 nFileId = static_cast<sal_uInt16>(i);
99 std::vector<OUString> aTabNames;
100 pRefMgr->getAllCachedTableNames(nFileId, aTabNames);
101 if (!aTabNames.empty())
102 maExternalCachedTabNames.insert(
103 IndexNamesMapType::value_type(nFileId, aTabNames));
108 CompileFormulaContext::CompileFormulaContext( ScDocument* pDoc ) :
109 mpDoc(pDoc), meGram(pDoc->GetGrammar())
111 updateTabNames();
114 CompileFormulaContext::CompileFormulaContext( ScDocument* pDoc, formula::FormulaGrammar::Grammar eGram ) :
115 mpDoc(pDoc), meGram(eGram)
117 updateTabNames();
120 void CompileFormulaContext::updateTabNames()
122 // Fetch all sheet names.
123 maTabNames = mpDoc->GetAllTableNames();
125 std::vector<OUString>::iterator it = maTabNames.begin(), itEnd = maTabNames.end();
126 for (; it != itEnd; ++it)
127 ScCompiler::CheckTabQuotes(*it, formula::FormulaGrammar::extractRefConvention(meGram));
131 void CompileFormulaContext::setGrammar( formula::FormulaGrammar::Grammar eGram )
133 bool bUpdate = (meGram != eGram);
134 meGram = eGram;
135 if (bUpdate)
136 updateTabNames();
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */