LibreOffice Module sc (master)  1
formulalogger.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 Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6  */
7 
8 #ifndef INCLUDED_SC_INC_FORMULALOGGER_HXX
9 #define INCLUDED_SC_INC_FORMULALOGGER_HXX
10 
11 #include <rtl/ustring.hxx>
12 
13 #include <memory>
14 #include <string_view>
15 #include <vector>
16 
17 #include <config_options_calc.h>
18 
19 class ScFormulaCell;
20 class ScDocument;
21 class ScAddress;
22 struct ScFormulaCellGroup;
23 
24 namespace formula {
25 
26 class FormulaToken;
27 struct VectorRefArray;
28 
29 }
30 
31 namespace osl { class File; }
32 
33 namespace sc {
34 
35 #if ENABLE_FORMULA_LOGGER
36 
40 class FormulaLogger
41 {
42  std::unique_ptr<osl::File> mpLogFile;
43 
44  sal_Int32 mnNestLevel = 0;
45  const ScFormulaCellGroup* mpLastGroup = nullptr;
46 
47  void writeAscii( const char* s );
48  void writeAscii( const char* s, size_t n );
49  void write( std::u16string_view ou );
50  void write( sal_Int32 n );
51 
52  void sync();
53 
54  void writeNestLevel();
55 
56 public:
57 
58  static FormulaLogger& get();
59 
63  class GroupScope
64  {
65  friend class FormulaLogger;
66 
67  struct Impl;
68  std::unique_ptr<Impl> mpImpl;
69 
70  public:
71  GroupScope() = delete;
72  GroupScope( const GroupScope& ) = delete;
73  GroupScope& operator= ( const GroupScope& ) = delete;
74 
75  private:
76  GroupScope(
77  FormulaLogger& rLogger, const OUString& rPrefix,
78  const ScDocument& rDoc, const ScFormulaCell& rCell,
79  bool bOutputEnabled );
80 
81  public:
82  GroupScope(GroupScope&& r) noexcept;
83  ~GroupScope();
84 
88  void addMessage( const OUString& rMsg );
89 
94  void addRefMessage(
95  const ScAddress& rCellPos, const ScAddress& rRefPos, size_t nLen,
96  const formula::VectorRefArray& rArray );
97 
102  void addRefMessage(
103  const ScAddress& rCellPos, const ScAddress& rRefPos, size_t nLen,
104  const std::vector<formula::VectorRefArray>& rArrays );
105 
109  void addRefMessage(
110  const ScAddress& rCellPos, const ScAddress& rRefPos,
111  const formula::FormulaToken& rToken );
112 
113  void addGroupSizeThresholdMessage( const ScFormulaCell& rCell );
114 
118  void setCalcComplete();
119  };
120 
121  FormulaLogger( const FormulaLogger& ) = delete;
122  FormulaLogger& operator= ( const FormulaLogger& ) = delete;
123 
124  FormulaLogger();
125  ~FormulaLogger();
126 
127  GroupScope enterGroup( const ScDocument& rDoc, const ScFormulaCell& rCell );
128 };
129 
130 #else
131 
136 {
137 public:
138 
139  static FormulaLogger get()
140  {
141  return FormulaLogger();
142  }
143 
145  {
146  public:
147  void addMessage( [[maybe_unused]] const OUString& /*rMsg*/ ) { (void) this; /* loplugin:staticmethods */ }
148 
150  const ScAddress& /*rCellPos*/, const ScAddress& /*rRefPos*/, size_t /*nLen*/,
151  const formula::VectorRefArray& /*rArray*/ )
152  {
153  (void) this; /* loplugin:staticmethods */
154  }
155 
157  const ScAddress& /*rCellPos*/, const ScAddress& /*rRefPos*/, size_t /*nLen*/,
158  const std::vector<formula::VectorRefArray>& /*rArrays*/ )
159  {
160  (void) this; /* loplugin:staticmethods */
161  }
162 
164  const ScAddress& /*rCellPos*/, const ScAddress& /*rRefPos*/,
165  const formula::FormulaToken& /*rToken*/ )
166  {
167  (void) this; /* loplugin:staticmethods */
168  }
169 
171  {
172  (void) this; /* loplugin:staticmethods */
173  }
174 
175  void setCalcComplete() { (void) this; /* loplugin:staticmethods */ }
176  };
177 
178  GroupScope enterGroup( const ScDocument& /*rDoc*/, const ScFormulaCell& /*rCell*/ )
179  {
180  (void) this; /* loplugin:staticmethods */
181  return GroupScope();
182  }
183 };
184 
185 #endif // ENABLE_FORMULA_LOGGER
186 
187 }
188 
189 #endif
190 
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void addRefMessage(const ScAddress &, const ScAddress &, size_t, const std::vector< formula::VectorRefArray > &)
void addRefMessage(const ScAddress &, const ScAddress &, const formula::FormulaToken &)
GroupScope enterGroup(const ScDocument &, const ScFormulaCell &)
void addMessage([[maybe_unused]] const OUString &)
void addGroupSizeThresholdMessage(const ScFormulaCell &)
void addRefMessage(const ScAddress &, const ScAddress &, size_t, const formula::VectorRefArray &)
Dummy class with all empty inline methods.
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo