LibreOffice Module sc (master)  1
TableFillingAndNavigationTools.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  */
10 
11 #ifndef INCLUDED_SC_SOURCE_UI_INC_TABLEFILLINGANDNAVIGATIONTOOLS_HXX
12 #define INCLUDED_SC_SOURCE_UI_INC_TABLEFILLINGANDNAVIGATIONTOOLS_HXX
13 
14 #include <address.hxx>
15 #include <rangelst.hxx>
16 
17 #include <map>
18 #include <vector>
19 
21 {
22 private:
23  OUString mTemplate;
25  bool mbUse3D;
26 
27  typedef std::map<OUString, ScRange> RangeReplacementMap;
28  typedef std::map<OUString, ScAddress> AddressReplacementMap;
29 
30  AddressReplacementMap mAddressReplacementMap;
31  RangeReplacementMap mRangeReplacementMap;
32 
33 public:
35 
36  void setTemplate(const OUString& aTemplate);
37  void setTemplate(const char* aTemplate);
38  const OUString& getTemplate();
39 
40  void autoReplaceRange(const OUString& aVariable, const ScRange& rRange);
41  void autoReplaceAddress(const OUString& aVariable, ScAddress const & aAddress);
42  void autoReplaceUses3D(bool bUse3D) { mbUse3D = bUse3D; }
43 
44  void applyRange(std::u16string_view aVariable, const ScRange& aRange, bool b3D = true);
45  void applyRangeList(std::u16string_view aVariable, const ScRangeList& aRangeList, sal_Unicode cDelimiter );
46  void applyAddress(std::u16string_view aVariable, const ScAddress& aAddress, bool b3D = true);
47  void applyString(std::u16string_view aVariable, std::u16string_view aValue);
48  void applyNumber(std::u16string_view aVariable, sal_Int32 aValue);
49 };
50 
52 {
53 public:
54  std::vector<ScAddress> mAddressStack;
55 
59 
60  AddressWalker(const ScAddress& aInitialAddress);
61 
62  ScAddress current(SCCOL aRelativeCol = 0, SCROW aRelativeRow = 0, SCTAB aRelativeTab = 0);
63 
64  void reset();
65  void resetColumn();
66  void resetRow();
67  void nextColumn();
68  void nextRow();
69  void newLine();
70  void push(SCCOL aRelativeCol = 0, SCROW aRelativeRow = 0, SCTAB aRelativeTab = 0);
71 };
72 
74 {
75 public:
79 
80  AddressWalkerWriter(const ScAddress& aInitialAddress, ScDocShell* pDocShell, ScDocument& rDocument,
82 
83  void writeFormula(const OUString& aFormula);
84  void writeFormulas(const std::vector<OUString>& rFormulas);
85  void writeMatrixFormula(const OUString& aFormula, SCCOL nCols = 1, SCROW nRows = 1);
86  void writeString(const OUString& aString);
87  void writeString(const char* aCharArray);
88  void writeBoldString(const OUString& aString);
89  void writeValue(double aValue);
90 };
91 
92 class DataCellIterator final
93 {
94 private:
96  bool mByColumn;
99 
100 public:
101  DataCellIterator(const ScRange& aInputRange, bool aByColumn);
103 
104  bool hasNext() const;
105  ScAddress get();
106  void next();
107  ScAddress getRelative(int aDelta);
108 };
109 
111 {
112 protected:
114  sal_Int32 mIndex;
115 
116 public:
117  DataRangeIterator(const ScRange& aInputRange);
118  virtual ~DataRangeIterator();
119 
120  virtual bool hasNext() = 0;
121  virtual ScRange get() = 0;
122  virtual size_t size() = 0;
123  virtual void next() = 0;
124  virtual void reset() = 0;
125 
126  sal_Int32 index();
127 
128  virtual DataCellIterator iterateCells() = 0;
129 };
130 
132 {
134 
135 public:
136  DataRangeByColumnIterator(const ScRange& aInputRange);
137 
138  virtual bool hasNext() override;
139  virtual void next() override;
140  virtual ScRange get() override;
141  virtual size_t size() override;
142  virtual void reset() override;
143  virtual DataCellIterator iterateCells() override;
144 };
145 
147 {
149 
150 public:
151  DataRangeByRowIterator(const ScRange& aInputRange);
152 
153  virtual bool hasNext() override;
154  virtual void next() override;
155  virtual ScRange get() override;
156  virtual size_t size() override;
157  virtual void reset() override;
158  virtual DataCellIterator iterateCells() override;
159 };
160 
161 #endif
162 
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::map< OUString, ScRange > RangeReplacementMap
void applyAddress(std::u16string_view aVariable, const ScAddress &aAddress, bool b3D=true)
virtual void next()=0
void writeFormula(const OUString &aFormula)
ScAddress getRelative(int aDelta)
std::vector< ScAddress > mAddressStack
void writeString(const OUString &aString)
void applyRange(std::u16string_view aVariable, const ScRange &aRange, bool b3D=true)
const sal_Unicode cDelimiter
Definition: tpusrlst.cxx:44
RangeReplacementMap mRangeReplacementMap
virtual DataCellIterator iterateCells()=0
AddressWalkerWriter(const ScAddress &aInitialAddress, ScDocShell *pDocShell, ScDocument &rDocument, formula::FormulaGrammar::Grammar eGrammar)
void push(SCCOL aRelativeCol=0, SCROW aRelativeRow=0, SCTAB aRelativeTab=0)
virtual DataCellIterator iterateCells() override
DataRangeByRowIterator(const ScRange &aInputRange)
virtual void reset()=0
sal_uInt16 sal_Unicode
void writeBoldString(const OUString &aString)
virtual size_t size()=0
void writeMatrixFormula(const OUString &aFormula, SCCOL nCols=1, SCROW nRows=1)
virtual bool hasNext()=0
formula::FormulaGrammar::Grammar meGrammar
ScAddress current(SCCOL aRelativeCol=0, SCROW aRelativeRow=0, SCTAB aRelativeTab=0)
sal_Int16 SCCOL
Definition: types.hxx:22
DataRangeIterator(const ScRange &aInputRange)
void applyRangeList(std::u16string_view aVariable, const ScRangeList &aRangeList, sal_Unicode cDelimiter)
std::map< OUString, ScAddress > AddressReplacementMap
void autoReplaceRange(const OUString &aVariable, const ScRange &rRange)
AddressWalker(const ScAddress &aInitialAddress)
sal_Int32 SCROW
Definition: types.hxx:18
void autoReplaceAddress(const OUString &aVariable, ScAddress const &aAddress)
void applyNumber(std::u16string_view aVariable, sal_Int32 aValue)
virtual DataCellIterator iterateCells() override
void applyString(std::u16string_view aVariable, std::u16string_view aValue)
AddressReplacementMap mAddressReplacementMap
void setTemplate(const OUString &aTemplate)
DataRangeByColumnIterator(const ScRange &aInputRange)
sal_Int16 SCTAB
Definition: types.hxx:23
DataCellIterator(const ScRange &aInputRange, bool aByColumn)
void writeFormulas(const std::vector< OUString > &rFormulas)