1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
13 #include <address.hxx>
14 #include <rangelst.hxx>
26 typedef std::map
<OUString
, ScRange
> RangeReplacementMap
;
27 typedef std::map
<OUString
, ScAddress
> AddressReplacementMap
;
29 AddressReplacementMap mAddressReplacementMap
;
30 RangeReplacementMap mRangeReplacementMap
;
33 FormulaTemplate(ScDocument
* pDoc
);
35 void setTemplate(const OUString
& aTemplate
);
36 void setTemplate(const char* aTemplate
);
37 const OUString
& getTemplate();
39 void autoReplaceRange(const OUString
& aVariable
, const ScRange
& rRange
);
40 void autoReplaceAddress(const OUString
& aVariable
, ScAddress
const & aAddress
);
41 void autoReplaceUses3D(bool bUse3D
) { mbUse3D
= bUse3D
; }
43 void applyRange(std::u16string_view aVariable
, const ScRange
& aRange
, bool b3D
= true);
44 void applyRangeList(std::u16string_view aVariable
, const ScRangeList
& aRangeList
, sal_Unicode cDelimiter
);
45 void applyAddress(std::u16string_view aVariable
, const ScAddress
& aAddress
, bool b3D
= true);
46 void applyString(std::u16string_view aVariable
, std::u16string_view aValue
);
47 void applyNumber(std::u16string_view aVariable
, sal_Int32 aValue
);
53 std::vector
<ScAddress
> mAddressStack
;
55 ScAddress mCurrentAddress
;
56 ScAddress mMinimumAddress
;
57 ScAddress mMaximumAddress
;
59 AddressWalker(const ScAddress
& aInitialAddress
);
61 ScAddress
current(SCCOL aRelativeCol
= 0, SCROW aRelativeRow
= 0, SCTAB aRelativeTab
= 0);
69 void push(SCCOL aRelativeCol
= 0, SCROW aRelativeRow
= 0, SCTAB aRelativeTab
= 0);
72 class AddressWalkerWriter
: public AddressWalker
74 ScDocShell
* mpDocShell
;
75 ScDocument
& mrDocument
;
76 formula::FormulaGrammar::Grammar meGrammar
;
79 AddressWalkerWriter(const ScAddress
& aInitialAddress
, ScDocShell
* pDocShell
, ScDocument
& rDocument
,
80 formula::FormulaGrammar::Grammar eGrammar
);
82 void writeFormula(const OUString
& aFormula
);
83 void writeFormulas(const std::vector
<OUString
>& rFormulas
);
84 void writeMatrixFormula(const OUString
& aFormula
, SCCOL nCols
= 1, SCROW nRows
= 1);
85 void writeString(const OUString
& aString
);
86 void writeString(const char* aCharArray
);
87 void writeBoldString(const OUString
& aString
);
88 void writeValue(double aValue
);
91 class DataCellIterator final
100 DataCellIterator(const ScRange
& aInputRange
, bool aByColumn
);
102 bool hasNext() const;
105 ScAddress
getRelative(int aDelta
);
108 class DataRangeIterator
115 DataRangeIterator(const ScRange
& aInputRange
);
116 virtual ~DataRangeIterator();
118 virtual bool hasNext() = 0;
119 virtual ScRange
get() = 0;
120 virtual size_t size() = 0;
121 virtual void next() = 0;
122 virtual void reset() = 0;
126 virtual DataCellIterator
iterateCells() = 0;
129 class DataRangeByColumnIterator final
: public DataRangeIterator
134 DataRangeByColumnIterator(const ScRange
& aInputRange
);
136 virtual bool hasNext() override
;
137 virtual void next() override
;
138 virtual ScRange
get() override
;
139 virtual size_t size() override
;
140 virtual void reset() override
;
141 virtual DataCellIterator
iterateCells() override
;
144 class DataRangeByRowIterator final
: public DataRangeIterator
149 DataRangeByRowIterator(const ScRange
& aInputRange
);
151 virtual bool hasNext() override
;
152 virtual void next() override
;
153 virtual ScRange
get() override
;
154 virtual size_t size() override
;
155 virtual void reset() override
;
156 virtual DataCellIterator
iterateCells() override
;
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */