LibreOffice Module sc (master) 1
tokenarray.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <formula/token.hxx>
23#include <rtl/ref.hxx>
24#include "document.hxx"
25#include "scdllapi.h"
26#include "types.hxx"
27#include "calcmacros.hxx"
28#include "address.hxx"
29#include "global.hxx"
31
32namespace sc {
33
34struct RefUpdateContext;
35struct RefUpdateInsertTabContext;
36struct RefUpdateDeleteTabContext;
37struct RefUpdateMoveTabContext;
38struct RefUpdateResult;
39struct TokenStringContext;
40class ColRowReorderMapType;
41
42}
43
44struct ScRawToken;
45struct ScSingleRefData;
46struct ScComplexRefData;
47
49{
50 friend class ScCompiler;
51
52 bool ImplGetReference( ScRange& rRange, const ScAddress& rPos, bool bValidOnly ) const;
53
54 // hold a reference to the limits because sometimes our lifetime exceeds the lifetime of the associated ScDocument
60
61 void CheckForThreading( const formula::FormulaToken& r );
62
63public:
68 ScTokenArray( const ScTokenArray& ) = default;
69 ScTokenArray( ScTokenArray&& ) = default;
70 virtual ~ScTokenArray() override;
71
72 bool EqualTokens( const ScTokenArray* pArr2 ) const;
73
74 virtual void Clear() override;
75 std::unique_ptr<ScTokenArray> Clone() const;
76 ScTokenArray CloneValue() const;
77
78 void GenHash();
79 size_t GetHash() const { return mnHashValue;}
80
81 ScFormulaVectorState GetVectorState() const { return meVectorState;}
82 void ResetVectorState();
83 bool IsFormulaVectorDisabled() const;
84
89 bool IsInvariant() const;
90
92 bool IsReference( ScRange& rRange, const ScAddress& rPos ) const;
94 bool IsValidReference( ScRange& rRange, const ScAddress& rPos ) const;
95
99 bool GetAdjacentExtendOfOuterFuncRefs(
100 SCCOLROW& nExtend,
101 const ScAddress& rPos, ScDirection );
102
103 formula::FormulaToken* AddRawToken( const ScRawToken& );
104 virtual bool AddFormulaToken(
105 const css::sheet::FormulaToken& rToken,
106 svl::SharedStringPool& rSPool,
107 formula::ExternalReferenceHelper* _pRef) override;
108 virtual void CheckToken( const formula::FormulaToken& r ) override;
109 virtual formula::FormulaToken* AddOpCode( OpCode eCode ) override;
111 formula::FormulaToken* AddSingleReference( const ScSingleRefData& rRef );
113 formula::FormulaToken* AddMatrixSingleReference( const ScSingleRefData& rRef );
114 formula::FormulaToken* AddDoubleReference( const ScComplexRefData& rRef );
115 void AddRangeName( sal_uInt16 n, sal_Int16 nSheet );
116 formula::FormulaToken* AddDBRange( sal_uInt16 n );
117 formula::FormulaToken* AddExternalName( sal_uInt16 nFileId, const svl::SharedString& rName );
118 void AddExternalSingleReference( sal_uInt16 nFileId, const svl::SharedString& rTabName, const ScSingleRefData& rRef );
119 formula::FormulaToken* AddExternalDoubleReference( sal_uInt16 nFileId, const svl::SharedString& rTabName, const ScComplexRefData& rRef );
120 formula::FormulaToken* AddMatrix( const ScMatrixRef& p );
122 formula::FormulaToken* AddColRowName( const ScSingleRefData& rRef );
123 virtual formula::FormulaToken* MergeArray( ) override;
124
127 void MergeRangeReference( const ScAddress & rPos );
128
130 void AssignXMLString( const OUString &rText, const OUString &rFormulaNmsp );
131
136
145 void ReadjustAbsolute3DReferences( const ScDocument& rOldDoc, ScDocument& rNewDoc, const ScAddress& rPos, bool bRangeName = false );
146
151 void AdjustAbsoluteRefs( const ScDocument& rOldDoc, const ScAddress& rOldPos, const ScAddress& rNewPos, bool bCheckCopyArea );
152
156 void AdjustSheetLocalNameReferences( SCTAB nOldTab, SCTAB nNewTab );
157
161 bool ReferencesSheet( SCTAB nTab, SCTAB nPosTab ) const;
162
170 sc::RefUpdateResult AdjustReferenceOnShift( const sc::RefUpdateContext& rCxt, const ScAddress& rOldPos );
171
172 sc::RefUpdateResult AdjustReferenceOnMove(
173 const sc::RefUpdateContext& rCxt, const ScAddress& rOldPos, const ScAddress& rNewPos );
174
185 void MoveReferenceColReorder(
186 const ScAddress& rPos, SCTAB nTab, SCROW nRow1, SCROW nRow2,
187 const sc::ColRowReorderMapType& rColMap );
188
189 void MoveReferenceRowReorder(
190 const ScAddress& rPos, SCTAB nTab, SCCOL nCol1, SCCOL nCol2,
191 const sc::ColRowReorderMapType& rRowMap );
192
201 sc::RefUpdateResult AdjustReferenceInName( const sc::RefUpdateContext& rCxt, const ScAddress& rPos );
202
203 sc::RefUpdateResult AdjustReferenceInMovedName( const sc::RefUpdateContext& rCxt, const ScAddress& rPos );
204
214 sc::RefUpdateResult AdjustReferenceOnDeletedTab( const sc::RefUpdateDeleteTabContext& rCxt, const ScAddress& rOldPos );
215
216 sc::RefUpdateResult AdjustReferenceOnInsertedTab( const sc::RefUpdateInsertTabContext& rCxt, const ScAddress& rOldPos );
217
218 sc::RefUpdateResult AdjustReferenceOnMovedTab( const sc::RefUpdateMoveTabContext& rCxt, const ScAddress& rOldPos );
219
223 void AdjustReferenceOnMovedOrigin( const ScAddress& rOldPos, const ScAddress& rNewPos );
224
229 void AdjustReferenceOnMovedOriginIfOtherSheet( const ScAddress& rOldPos, const ScAddress& rNewPos );
230
235 void AdjustReferenceOnCopy( const ScAddress& rNewPos );
236
247 void ClearTabDeleted( const ScAddress& rPos, SCTAB nStartTab, SCTAB nEndTab );
248
249 void CheckRelativeReferenceBounds(
250 const sc::RefUpdateContext& rCxt, const ScAddress& rPos, SCROW nGroupLen, std::vector<SCROW>& rBounds ) const;
251
252 void CheckRelativeReferenceBounds(
253 const ScAddress& rPos, SCROW nGroupLen, const ScRange& rRange, std::vector<SCROW>& rBounds ) const;
254
255 void CheckExpandReferenceBounds(
256 const sc::RefUpdateContext& rCxt, const ScAddress& rPos, SCROW nGroupLen, std::vector<SCROW>& rBounds ) const;
257
262 OUString CreateString( sc::TokenStringContext& rCxt, const ScAddress& rPos ) const;
263
264 void WrapReference( const ScAddress& rPos, SCCOL nMaxCol, SCROW nMaxRow );
265
266 sal_Int32 GetWeight() const;
267
268 bool IsEnabledForOpenCL() const { return mbOpenCLEnabled; }
269 bool IsEnabledForThreading() const { return mbThreadingEnabled; }
270
271#if DEBUG_FORMULA_COMPILER
272 void Dump() const;
273#endif
274};
275
276/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScDocument & rDoc
Definition: compiler.hxx:274
bool mbThreadingEnabled
Definition: tokenarray.hxx:59
ScTokenArray(const ScTokenArray &)=default
Assignment with incrementing references of FormulaToken entries (not copied!)
size_t GetHash() const
Definition: tokenarray.hxx:79
bool IsEnabledForThreading() const
Definition: tokenarray.hxx:269
ScFormulaVectorState GetVectorState() const
Definition: tokenarray.hxx:81
bool IsEnabledForOpenCL() const
Definition: tokenarray.hxx:268
size_t mnHashValue
Definition: tokenarray.hxx:56
bool mbOpenCLEnabled
Definition: tokenarray.hxx:58
rtl::Reference< ScSheetLimits > mxSheetLimits
Definition: tokenarray.hxx:55
ScTokenArray(ScTokenArray &&)=default
ScFormulaVectorState meVectorState
Definition: tokenarray.hxx:57
bool MergeRangeReference(FormulaToken **const pCode1, FormulaToken *const *const pCode2)
virtual FormulaToken * MergeArray()
virtual void CheckToken(const FormulaToken &t)
virtual FormulaToken * AddOpCode(OpCode e)
FormulaTokenArray & operator=(const FormulaTokenArray &)
virtual bool AddFormulaToken(const css::sheet::FormulaToken &rToken, svl::SharedStringPool &rSPool, ExternalReferenceHelper *pExtRef)
ScDirection
Definition: global.hxx:343
CAUTION! The following defines must be in the same namespace as the respective type.
Definition: broadcast.cxx:15
css::uno::Reference< css::animations::XAnimationNode > Clone(const css::uno::Reference< css::animations::XAnimationNode > &xSourceNode, const SdPage *pSource=nullptr, const SdPage *pTarget=nullptr)
OpCode
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
Complex reference (a range) into the sheet.
Definition: refdata.hxx:123
Single reference (one address) into the sheet.
Definition: refdata.hxx:30
Context for reference update during shifting, moving or copying of cell ranges.
Context for creating string from an array of formula tokens, used in ScTokenArray::CreateString().
#define SAL_WARN_UNUSED
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:23
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
::boost::intrusive_ptr< ScMatrix > ScMatrixRef
Definition: types.hxx:25
ScFormulaVectorState
When vectorization is enabled, we could potentially mass-calculate a series of formula token arrays i...
Definition: types.hxx:52
sal_Int32 SCROW
Definition: types.hxx:17