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);
146 aRefRange.aEnd.IncRow(nLen-1);
147 OUString aRangeStr = aRefRange.Format(mpImpl->mrDoc, getRefFlags(rCellPos, rRefPos));
148 aBuf.append(aRangeStr);
156 aBuf.append(
"numeric and string");
161 aBuf.append(
"numeric only");
169 aBuf.append(
"string only");
174 aBuf.append(
"empty");
178 mpImpl->maMessages.push_back(
aBuf.makeStringAndClear());
183 const std::vector<formula::VectorRefArray>& rArrays )
198 OUString aPosStr = rRefPos.
Format(getRefFlags(rCellPos, rRefPos), &mpImpl->mrDoc);
199 aBuf.append(aPosStr);
205 aBuf.append(
"numeric value");
208 aBuf.append(
"string value");
211 aBuf.append(
"unknown value");
214 mpImpl->maMessages.push_back(
aBuf.makeStringAndClear());
220 aBuf.append(
"group length below minimum threshold (");
225 mpImpl->maMessages.push_back(
aBuf.makeStringAndClear());
230 mpImpl->mbCalcComplete =
true;
234FormulaLogger::FormulaLogger()
236 mpLogFile = initFile();
241 osl::FileBase::RC eRC = mpLogFile->open(osl_File_OpenFlag_Write | osl_File_OpenFlag_Create);
243 if (eRC == osl::FileBase::E_EXIST)
245 eRC = mpLogFile->open(osl_File_OpenFlag_Write);
247 if (eRC != osl::FileBase::E_None)
254 if (mpLogFile->setPos(osl_Pos_End, 0) != osl::FileBase::E_None)
261 else if (eRC != osl::FileBase::E_None)
270 writeAscii(
"OpenCL: ");
277FormulaLogger::~FormulaLogger()
283void FormulaLogger::writeAscii(
const char* s )
289 mpLogFile->write(s, strlen(s), nBytes);
292void FormulaLogger::writeAscii(
const char* s,
size_t n )
298 mpLogFile->write(s, n, nBytes);
301void FormulaLogger::write( std::u16string_view ou )
304 writeAscii(s.getStr(), s.getLength());
307void FormulaLogger::write( sal_Int32 n )
309 OString s = OString::number(n);
310 writeAscii(s.getStr(), s.getLength());
313void FormulaLogger::sync()
321void FormulaLogger::writeNestLevel()
325 if (mnNestLevel < 10)
331 for (sal_Int32 i = 1;
i < mnNestLevel; ++
i)
347 OUString aGroupPrefix =
aName +
": formula-group: " +
350 bool bOutputEnabled = mpLastGroup != rCell.
GetCellGroup().get();
353 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().