10#include <tokenarray.hxx>
11#include <document.hxx>
16#include <osl/file.hxx>
21#include <rtl/ustrbuf.hxx>
30std::unique_ptr<osl::File> initFile()
32 const char* pPath = std::getenv(
"LIBO_FORMULA_LOG_FILE");
37 OUString aPath = OUString::createFromAscii(pPath);
39 aURL.SetSmartURL(aPath);
42 return std::make_unique<osl::File>(aPath);
48 if (rCellPos.
Tab() != rRefPos.
Tab())
57 static FormulaLogger aLogger;
88 mrLogger.writeAscii(
"-- enter (formula='");
112 mrLogger.writeAscii(
"calculation complete");
114 mrLogger.writeAscii(
"without calculation");
125FormulaLogger::GroupScope::GroupScope(
128 mpImpl(
std::make_unique<Impl>(rLogger, rPrefix, rDoc, rCell, bOutputEnabled)) {}
130FormulaLogger::GroupScope::GroupScope(GroupScope&& r) noexcept : mpImpl(std::move(r.mpImpl)) {}
132FormulaLogger::GroupScope::~GroupScope() {}
136 mpImpl->maMessages.push_back(rMsg);
144 aRefRange.aEnd.IncRow(nLen-1);
145 OUString aRangeStr = aRefRange.Format(mpImpl->mrDoc, getRefFlags(rCellPos, rRefPos));
147 std::u16string_view aMsg;
153 aMsg =
u"numeric and string";
158 aMsg =
u"numeric only";
166 aMsg =
u"string only";
175 mpImpl->maMessages.push_back(aRangeStr +
": " + aMsg);
180 const std::vector<formula::VectorRefArray>& rArrays )
194 OUString aPosStr = rRefPos.
Format(getRefFlags(rCellPos, rRefPos), &mpImpl->mrDoc);
195 std::u16string_view aMsg;
199 aMsg =
u"numeric value";
202 aMsg =
u"string value";
205 aMsg =
u"unknown value";
208 mpImpl->maMessages.push_back(aPosStr +
": " + aMsg);
213 OUString
aBuf =
"group length below minimum threshold ("
218 mpImpl->maMessages.push_back(aBuf);
223 mpImpl->mbCalcComplete =
true;
227FormulaLogger::FormulaLogger()
229 mpLogFile = initFile();
234 osl::FileBase::RC eRC = mpLogFile->open(osl_File_OpenFlag_Write | osl_File_OpenFlag_Create);
236 if (eRC == osl::FileBase::E_EXIST)
238 eRC = mpLogFile->open(osl_File_OpenFlag_Write);
240 if (eRC != osl::FileBase::E_None)
247 if (mpLogFile->setPos(osl_Pos_End, 0) != osl::FileBase::E_None)
254 else if (eRC != osl::FileBase::E_None)
263 writeAscii(
"OpenCL: ");
270FormulaLogger::~FormulaLogger()
276void FormulaLogger::writeAscii(
const char* s )
282 mpLogFile->write(s, strlen(s), nBytes);
285void FormulaLogger::writeAscii(
const char* s,
size_t n )
291 mpLogFile->write(s, n, nBytes);
294void FormulaLogger::write( std::u16string_view ou )
297 writeAscii(s.getStr(), s.getLength());
300void FormulaLogger::write( sal_Int32 n )
302 OString s = OString::number(n);
303 writeAscii(s.getStr(), s.getLength());
306void FormulaLogger::sync()
314void FormulaLogger::writeNestLevel()
318 if (mnNestLevel < 10)
324 for (sal_Int32 i = 1;
i < mnNestLevel; ++
i)
340 OUString aGroupPrefix =
aName +
": formula-group: " +
343 bool bOutputEnabled = mpLastGroup != rCell.
GetCellGroup().get();
346 return GroupScope(*
this, aGroupPrefix, rDoc, rCell, bOutputEnabled);
OUString GetLastName(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
SC_DLLPUBLIC void Format(OStringBuffer &r, ScRefFlags nFlags, const ScDocument *pDocument=nullptr, const Details &rDetails=detailsOOOa1) const
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const
SfxObjectShell * GetDocumentShell() const
static const ScCalcConfig & GetGlobalConfig()
OUString CreateString(sc::TokenStringContext &rCxt, const ScAddress &rPos) const
Create a string representation of formula token array without modifying the internal state of the tok...
const INetURLObject & GetURLObject() const
SfxMedium * GetMedium() const
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
CAUTION! The following defines must be in the same namespace as the respective type.
static bool isOpenCLEnabled()
Context for creating string from an array of formula tokens, used in ScTokenArray::CreateString().