1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
8 #ifndef INCLUDED_SC_INC_FORMULALOGGER_HXX
9 #define INCLUDED_SC_INC_FORMULALOGGER_HXX
11 #include <rtl/ustring.hxx>
16 #include <config_options_calc.h>
21 struct ScFormulaCellGroup
;
26 struct VectorRefArray
;
30 namespace osl
{ class File
; }
34 #if ENABLE_FORMULA_LOGGER
37 * Outputs formula calculation log outputs to specified file.
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
);
54 void writeNestLevel();
58 static FormulaLogger
& get();
61 * This class is only moveable.
65 friend class FormulaLogger
;
68 std::unique_ptr
<Impl
> mpImpl
;
71 GroupScope() = delete;
72 GroupScope( const GroupScope
& ) = delete;
73 GroupScope
& operator= ( const GroupScope
& ) = delete;
77 FormulaLogger
& rLogger
, const OUString
& rPrefix
,
78 const ScDocument
& rDoc
, const ScFormulaCell
& rCell
,
79 bool bOutputEnabled
);
82 GroupScope( GroupScope
&& r
);
86 * Add an arbitrary message to dump to the log.
88 void addMessage( const OUString
& rMsg
);
91 * Add to the log a vector reference information for a single
95 const ScAddress
& rCellPos
, const ScAddress
& rRefPos
, size_t nLen
,
96 const formula::VectorRefArray
& rArray
);
99 * Add to the log a vector reference information for a range
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.
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;
127 GroupScope
enterGroup( const ScDocument
& rDoc
, const ScFormulaCell
& rCell
);
133 * Dummy class with all empty inline methods.
139 static FormulaLogger
get()
141 return FormulaLogger();
147 void addMessage( const OUString
& /*rMsg*/ ) { (void) this; /* loplugin:staticmethods */ }
150 const ScAddress
& /*rCellPos*/, const ScAddress
& /*rRefPos*/, size_t /*nLen*/,
151 const formula::VectorRefArray
& /*rArray*/ )
153 (void) this; /* loplugin:staticmethods */
157 const ScAddress
& /*rCellPos*/, const ScAddress
& /*rRefPos*/, size_t /*nLen*/,
158 const std::vector
<formula::VectorRefArray
>& /*rArrays*/ )
160 (void) this; /* loplugin:staticmethods */
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 */
185 #endif // ENABLE_FORMULA_LOGGER
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */