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 <vector>
18 
20 {
21 private:
22  OUString mTemplate;
24  bool mbUse3D;
25 
26  typedef std::map<OUString, ScRange> RangeReplacementMap;
27  typedef std::map<OUString, ScAddress> AddressReplacementMap;
28 
29  AddressReplacementMap mAddressReplacementMap;
30  RangeReplacementMap mRangeReplacementMap;
31 
32 public:
34 
35  void setTemplate(const OUString& aTemplate);
36  void setTemplate(const char* aTemplate);
37  const OUString& getTemplate();
38 
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; }
42 
43  void applyRange(const OUString& aVariable, const ScRange& aRange, bool b3D = true);
44  void applyRangeList(const OUString& aVariable, const ScRangeList& aRangeList, sal_Unicode cDelimiter );
45  void applyAddress(const OUString& aVariable, const ScAddress& aAddress, bool b3D = true);
46  void applyString(const OUString& aVariable, const OUString& aValue);
47  void applyNumber(const OUString& aVariable, sal_Int32 aValue);
48 };
49 
51 {
52 public:
53  std::vector<ScAddress> mAddressStack;
54 
58 
59  AddressWalker(const ScAddress& aInitialAddress);
60 
61  ScAddress current(SCCOL aRelativeCol = 0, SCROW aRelativeRow = 0, SCTAB aRelativeTab = 0);
62 
63  void reset();
64  void resetColumn();
65  void resetRow();
66  void nextColumn();
67  void nextRow();
68  void newLine();
69  void push(SCCOL aRelativeCol = 0, SCROW aRelativeRow = 0, SCTAB aRelativeTab = 0);
70 };
71 
73 {
74 public:
78 
79  AddressWalkerWriter(const ScAddress& aInitialAddress, ScDocShell* pDocShell, ScDocument* pDocument,
81 
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);
89 };
90 
91 class DataCellIterator final
92 {
93 private:
95  bool mByColumn;
98 
99 public:
100  DataCellIterator(const ScRange& aInputRange, bool aByColumn);
102 
103  bool hasNext() const;
104  ScAddress get();
105  void next();
106  ScAddress getRelative(int aDelta);
107 };
108 
110 {
111 protected:
113  sal_Int32 mIndex;
114 
115 public:
116  DataRangeIterator(const ScRange& aInputRange);
117  virtual ~DataRangeIterator();
118 
119  virtual bool hasNext() = 0;
120  virtual ScRange get() = 0;
121  virtual size_t size() = 0;
122  virtual void next() = 0;
123  virtual void reset() = 0;
124 
125  sal_Int32 index();
126 
127  virtual DataCellIterator iterateCells() = 0;
128 };
129 
131 {
133 
134 public:
135  DataRangeByColumnIterator(const ScRange& aInputRange);
136 
137  virtual bool hasNext() override;
138  virtual void next() override;
139  virtual ScRange get() override;
140  virtual size_t size() override;
141  virtual void reset() override;
142  virtual DataCellIterator iterateCells() override;
143 };
144 
146 {
148 
149 public:
150  DataRangeByRowIterator(const ScRange& aInputRange);
151 
152  virtual bool hasNext() override;
153  virtual void next() override;
154  virtual ScRange get() override;
155  virtual size_t size() override;
156  virtual void reset() override;
157  virtual DataCellIterator iterateCells() override;
158 };
159 
160 #endif
161 
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::map< OUString, ScRange > RangeReplacementMap
void applyNumber(const OUString &aVariable, sal_Int32 aValue)
virtual void next()=0
void writeFormula(const OUString &aFormula)
ScAddress getRelative(int aDelta)
std::vector< ScAddress > mAddressStack
void writeString(const OUString &aString)
const sal_Unicode cDelimiter
Definition: tpusrlst.cxx:44
RangeReplacementMap mRangeReplacementMap
virtual DataCellIterator iterateCells()=0
AddressWalkerWriter(const ScAddress &aInitialAddress, ScDocShell *pDocShell, ScDocument *pDocument, formula::FormulaGrammar::Grammar eGrammar)
void applyRangeList(const OUString &aVariable, const ScRangeList &aRangeList, sal_Unicode cDelimiter)
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
void applyAddress(const OUString &aVariable, const ScAddress &aAddress, bool b3D=true)
DataRangeIterator(const ScRange &aInputRange)
void applyRange(const OUString &aVariable, const ScRange &aRange, bool b3D=true)
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)
virtual DataCellIterator iterateCells() override
void applyString(const OUString &aVariable, const OUString &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)