Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sc / inc / formulalogger.hxx
blob879418eab0b44ff3c82c3b6d0d7fdb1bf67a3c16
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 */
8 #ifndef INCLUDED_SC_INC_FORMULALOGGER_HXX
9 #define INCLUDED_SC_INC_FORMULALOGGER_HXX
11 #include <rtl/ustring.hxx>
13 #include <memory>
14 #include <vector>
16 #include <config_options_calc.h>
18 class ScFormulaCell;
19 class ScDocument;
20 class ScAddress;
21 struct ScFormulaCellGroup;
23 namespace formula {
25 class FormulaToken;
26 struct VectorRefArray;
30 namespace osl { class File; }
32 namespace sc {
34 #if ENABLE_FORMULA_LOGGER
36 /**
37 * Outputs formula calculation log outputs to specified file.
39 class FormulaLogger
41 std::unique_ptr<osl::File> mpLogFile;
42 std::vector<OUString> maMessages;
44 sal_Int32 mnNestLevel = 0;
45 const ScFormulaCellGroup* mpLastGroup = nullptr;
47 void writeAscii( const char* s );
48 void writeAscii( const char* s, size_t n );
49 void write( const OUString& ou );
50 void write( sal_Int32 n );
52 void sync();
54 void writeNestLevel();
56 public:
58 static FormulaLogger& get();
60 /**
61 * This class is only moveable.
63 class GroupScope
65 friend class FormulaLogger;
67 struct Impl;
68 std::unique_ptr<Impl> mpImpl;
70 public:
71 GroupScope() = delete;
72 GroupScope( const GroupScope& ) = delete;
73 GroupScope& operator= ( const GroupScope& ) = delete;
75 private:
76 GroupScope(
77 FormulaLogger& rLogger, const OUString& rPrefix,
78 const ScDocument& rDoc, const ScFormulaCell& rCell,
79 bool bOutputEnabled );
81 public:
82 GroupScope( GroupScope&& r );
83 ~GroupScope();
85 /**
86 * Add an arbitrary message to dump to the log.
88 void addMessage( const OUString& rMsg );
90 /**
91 * Add to the log a vector reference information for a single
92 * reference.
94 void addRefMessage(
95 const ScAddress& rCellPos, const ScAddress& rRefPos, size_t nLen,
96 const formula::VectorRefArray& rArray );
98 /**
99 * Add to the log a vector reference information for a range
100 * reference.
102 void addRefMessage(
103 const ScAddress& rCellPos, const ScAddress& rRefPos, size_t nLen,
104 const std::vector<formula::VectorRefArray>& rArrays );
107 * Add to the log a single cell reference information.
109 void addRefMessage(
110 const ScAddress& rCellPos, const ScAddress& rRefPos,
111 const formula::FormulaToken& rToken );
113 void addGroupSizeThresholdMessage( const ScFormulaCell& rCell );
116 * Call this when the group calculation has finished successfully.
118 void setCalcComplete();
121 FormulaLogger( const FormulaLogger& ) = delete;
122 FormulaLogger& operator= ( const FormulaLogger& ) = delete;
124 FormulaLogger();
125 ~FormulaLogger();
127 GroupScope enterGroup( const ScDocument& rDoc, const ScFormulaCell& rCell );
130 #else
133 * Dummy class with all empty inline methods.
135 class FormulaLogger
137 public:
139 static FormulaLogger get()
141 return FormulaLogger();
144 class GroupScope
146 public:
147 void addMessage( const OUString& /*rMsg*/ ) { (void) this; /* loplugin:staticmethods */ }
149 void addRefMessage(
150 const ScAddress& /*rCellPos*/, const ScAddress& /*rRefPos*/, size_t /*nLen*/,
151 const formula::VectorRefArray& /*rArray*/ )
153 (void) this; /* loplugin:staticmethods */
156 void addRefMessage(
157 const ScAddress& /*rCellPos*/, const ScAddress& /*rRefPos*/, size_t /*nLen*/,
158 const std::vector<formula::VectorRefArray>& /*rArrays*/ )
160 (void) this; /* loplugin:staticmethods */
163 void addRefMessage(
164 const ScAddress& /*rCellPos*/, const ScAddress& /*rRefPos*/,
165 const formula::FormulaToken& /*rToken*/ )
167 (void) this; /* loplugin:staticmethods */
170 void addGroupSizeThresholdMessage( const ScFormulaCell& /*rCell*/ )
172 (void) this; /* loplugin:staticmethods */
175 void setCalcComplete() { (void) this; /* loplugin:staticmethods */ }
178 GroupScope enterGroup( const ScDocument& /*rDoc*/, const ScFormulaCell& /*rCell*/ )
180 (void) this; /* loplugin:staticmethods */
181 return GroupScope();
185 #endif // ENABLE_FORMULA_LOGGER
189 #endif
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */