Fix build
[LibreOffice.git] / sc / inc / formulalogger.hxx
blob9e8da1f681b08f233feb54f79eb7dee5f41860b3
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 #pragma once
10 #include <rtl/ustring.hxx>
12 #include <memory>
13 #include <string_view>
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;
43 sal_Int32 mnNestLevel = 0;
44 const ScFormulaCellGroup* mpLastGroup = nullptr;
46 void writeAscii( const char* s );
47 void writeAscii( const char* s, size_t n );
48 void write( std::u16string_view ou );
49 void write( sal_Int32 n );
51 void sync();
53 void writeNestLevel();
55 public:
57 static FormulaLogger& get();
59 /**
60 * This class is only moveable.
62 class GroupScope
64 friend class FormulaLogger;
66 struct Impl;
67 std::unique_ptr<Impl> mpImpl;
69 public:
70 GroupScope() = delete;
71 GroupScope( const GroupScope& ) = delete;
72 GroupScope& operator= ( const GroupScope& ) = delete;
74 private:
75 GroupScope(
76 FormulaLogger& rLogger, const OUString& rPrefix,
77 const ScDocument& rDoc, const ScFormulaCell& rCell,
78 bool bOutputEnabled );
80 public:
81 GroupScope(GroupScope&& r) noexcept;
82 ~GroupScope();
84 /**
85 * Add an arbitrary message to dump to the log.
87 void addMessage( const OUString& rMsg );
89 /**
90 * Add to the log a vector reference information for a single
91 * reference.
93 void addRefMessage(
94 const ScAddress& rCellPos, const ScAddress& rRefPos, size_t nLen,
95 const formula::VectorRefArray& rArray );
97 /**
98 * Add to the log a vector reference information for a range
99 * reference.
101 void addRefMessage(
102 const ScAddress& rCellPos, const ScAddress& rRefPos, size_t nLen,
103 const std::vector<formula::VectorRefArray>& rArrays );
106 * Add to the log a single cell reference information.
108 void addRefMessage(
109 const ScAddress& rCellPos, const ScAddress& rRefPos,
110 const formula::FormulaToken& rToken );
112 void addGroupSizeThresholdMessage( const ScFormulaCell& rCell );
115 * Call this when the group calculation has finished successfully.
117 void setCalcComplete();
120 FormulaLogger( const FormulaLogger& ) = delete;
121 FormulaLogger& operator= ( const FormulaLogger& ) = delete;
123 FormulaLogger();
124 ~FormulaLogger();
126 GroupScope enterGroup( const ScDocument& rDoc, const ScFormulaCell& rCell );
129 #else
132 * Dummy class with all empty inline methods.
134 class FormulaLogger
136 public:
138 static FormulaLogger get()
140 return FormulaLogger();
143 class GroupScope
145 public:
146 void addMessage( [[maybe_unused]] const OUString& /*rMsg*/ ) { (void) this; /* loplugin:staticmethods */ }
148 void addRefMessage(
149 const ScAddress& /*rCellPos*/, const ScAddress& /*rRefPos*/, size_t /*nLen*/,
150 const formula::VectorRefArray& /*rArray*/ )
152 (void) this; /* loplugin:staticmethods */
155 void addRefMessage(
156 const ScAddress& /*rCellPos*/, const ScAddress& /*rRefPos*/, size_t /*nLen*/,
157 const std::vector<formula::VectorRefArray>& /*rArrays*/ )
159 (void) this; /* loplugin:staticmethods */
162 void addRefMessage(
163 const ScAddress& /*rCellPos*/, const ScAddress& /*rRefPos*/,
164 const formula::FormulaToken& /*rToken*/ )
166 (void) this; /* loplugin:staticmethods */
169 void addGroupSizeThresholdMessage( const ScFormulaCell& /*rCell*/ )
171 (void) this; /* loplugin:staticmethods */
174 void setCalcComplete() { (void) this; /* loplugin:staticmethods */ }
177 GroupScope enterGroup( const ScDocument& /*rDoc*/, const ScFormulaCell& /*rCell*/ )
179 (void) this; /* loplugin:staticmethods */
180 return GroupScope();
184 #endif // ENABLE_FORMULA_LOGGER
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */