diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2016-11-03 21:55:18 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2016-11-05 08:07:47 -0400 |
commit | fe7b4884a2c22e3089e2803824565fa6d1391e1b (patch) | |
tree | 420697f9fb98a1a1ad919a0746247bcbc7c6bef0 | |
parent | c7aa57bc6b35a27aba265ce548397f282541253f (diff) |
Dump the single cell vector reference info to the log.
Change-Id: If0ee6dca6642063501c728bec3b4e5d7b6401442
-rw-r--r-- | sc/inc/formulalogger.hxx | 11 | ||||
-rw-r--r-- | sc/source/core/data/formulacell.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/grouptokenconverter.cxx | 20 | ||||
-rw-r--r-- | sc/source/core/inc/grouptokenconverter.hxx | 3 | ||||
-rw-r--r-- | sc/source/core/tool/formulalogger.cxx | 47 |
5 files changed, 72 insertions, 11 deletions
diff --git a/sc/inc/formulalogger.hxx b/sc/inc/formulalogger.hxx index 0925d3056667..d63cf78b7ef1 100644 --- a/sc/inc/formulalogger.hxx +++ b/sc/inc/formulalogger.hxx @@ -16,6 +16,9 @@ class ScFormulaCell; class ScDocument; +class ScAddress; + +namespace formula { struct VectorRefArray; } namespace sc { @@ -74,6 +77,12 @@ public: void addMessage( const OUString& rMsg ); /** + * Add to the log a vector reference information for a single + * reference. + */ + void addRefMessage( const ScAddress& rPos, size_t nLen, const formula::VectorRefArray& rArray ); + + /** * Call this when the group calculation has finished successfullly. */ void setCalcComplete(); @@ -106,6 +115,8 @@ public: { public: void addMessage( const OUString& /*rMsg*/ ) { (void) this; /* loplugin:staticmethods */ } + void addRefMessage( const ScAddress& /*rPos*/, size_t /*nLen*/, const formula::VectorRefArray& /*rArray*/ ) + { (void) this; /* loplugin:staticmethods */ } void setCalcComplete() { (void) this; /* loplugin:staticmethods */ } }; diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 7f97e26531e0..6231bc6bdf57 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -4125,7 +4125,7 @@ bool ScFormulaCell::InterpretFormulaGroup() ScTokenArray aCode; ScGroupTokenConverter aConverter(aCode, *pDocument, *this, xGroup->mpTopCell->aPos); - if (!aConverter.convert(*pCode)) + if (!aConverter.convert(*pCode, aScope)) { SAL_INFO("sc.opencl", "conversion of group " << this << " failed, disabling"); mxGroup->meCalcState = sc::GroupCalcDisabled; diff --git a/sc/source/core/data/grouptokenconverter.cxx b/sc/source/core/data/grouptokenconverter.cxx index 22b89a6cb510..e866114c2ba3 100644 --- a/sc/source/core/data/grouptokenconverter.cxx +++ b/sc/source/core/data/grouptokenconverter.cxx @@ -7,12 +7,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <grouptokenconverter.hxx> +#include <compiler.hxx> + #include <formula/token.hxx> #include <formula/vectortoken.hxx> -#include "compiler.hxx" -#include "grouptokenconverter.hxx" - using namespace formula; bool ScGroupTokenConverter::isSelfReferenceRelative(const ScAddress& rRefPos, SCROW nRelRow) @@ -83,13 +83,16 @@ SCROW ScGroupTokenConverter::trimLength(SCTAB nTab, SCCOL nCol1, SCCOL nCol2, SC return nRowLen; } -ScGroupTokenConverter::ScGroupTokenConverter(ScTokenArray& rGroupTokens, ScDocument& rDoc, ScFormulaCell& rCell, const ScAddress& rPos) : - mrGroupTokens(rGroupTokens), mrDoc(rDoc), mrCell(rCell), mrPos(rPos) - +ScGroupTokenConverter::ScGroupTokenConverter( + ScTokenArray& rGroupTokens, ScDocument& rDoc, ScFormulaCell& rCell, const ScAddress& rPos) : + mrGroupTokens(rGroupTokens), + mrDoc(rDoc), + mrCell(rCell), + mrPos(rPos) { } -bool ScGroupTokenConverter::convert(ScTokenArray& rCode) +bool ScGroupTokenConverter::convert( ScTokenArray& rCode, sc::FormulaLogger::GroupScope& rScope ) { #if 0 { // debug to start with: @@ -135,6 +138,7 @@ bool ScGroupTokenConverter::convert(ScTokenArray& rCode) formula::SingleVectorRefToken aTok(aArray, nLen, nTrimLen); mrGroupTokens.AddToken(aTok); + rScope.addRefMessage(aRefPos, nLen, aArray); if (nTrimLen && !mxFormulaGroupContext) { @@ -250,7 +254,7 @@ bool ScGroupTokenConverter::convert(ScTokenArray& rCode) mrGroupTokens.AddOpCode(ocOpen); - if (!convert(*pNamedTokens)) + if (!convert(*pNamedTokens, rScope)) return false; mrGroupTokens.AddOpCode(ocClose); diff --git a/sc/source/core/inc/grouptokenconverter.hxx b/sc/source/core/inc/grouptokenconverter.hxx index 7b88004e9d5c..e9782d4ae665 100644 --- a/sc/source/core/inc/grouptokenconverter.hxx +++ b/sc/source/core/inc/grouptokenconverter.hxx @@ -15,6 +15,7 @@ #include "scdllapi.h" #include "tokenarray.hxx" #include "types.hxx" +#include <formulalogger.hxx> class SC_DLLPUBLIC ScGroupTokenConverter { @@ -31,7 +32,7 @@ class SC_DLLPUBLIC ScGroupTokenConverter public: ScGroupTokenConverter(ScTokenArray& rGroupTokens, ScDocument& rDoc, ScFormulaCell& rCell, const ScAddress& rPos); - bool convert(ScTokenArray& rCode); + bool convert( ScTokenArray& rCode, sc::FormulaLogger::GroupScope& rScope ); }; #endif // INCLUDED_SC_SOURCE_CORE_INC_GROUPTOKENCONVERTER_HXX diff --git a/sc/source/core/tool/formulalogger.cxx b/sc/source/core/tool/formulalogger.cxx index 7b5b916f9666..df7fc734b514 100644 --- a/sc/source/core/tool/formulalogger.cxx +++ b/sc/source/core/tool/formulalogger.cxx @@ -10,11 +10,14 @@ #include <tokenarray.hxx> #include <document.hxx> #include <tokenstringcontext.hxx> +#include <address.hxx> #include <o3tl/make_unique.hxx> #include <sfx2/objsh.hxx> #include <sfx2/docfile.hxx> #include <tools/urlobj.hxx> +#include <formula/vectortoken.hxx> +#include <rtl/ustrbuf.hxx> #include <cstdlib> @@ -48,6 +51,7 @@ FormulaLogger& FormulaLogger::get() struct FormulaLogger::GroupScope::Impl { FormulaLogger& mrLogger; + const ScDocument& mrDoc; OUString maPrefix; std::vector<OUString> maMessages; @@ -55,7 +59,7 @@ struct FormulaLogger::GroupScope::Impl bool mbCalcComplete = false; Impl( FormulaLogger& rLogger, const OUString& rPrefix, const ScDocument& rDoc, const ScFormulaCell& rCell ) : - mrLogger(rLogger), maPrefix(rPrefix) + mrLogger(rLogger), mrDoc(rDoc), maPrefix(rPrefix) { ++mrLogger.mnNestLevel; @@ -112,6 +116,47 @@ void FormulaLogger::GroupScope::addMessage( const OUString& rMsg ) mpImpl->maMessages.push_back(rMsg); } +void FormulaLogger::GroupScope::addRefMessage( + const ScAddress& rPos, size_t nLen, const formula::VectorRefArray& rArray ) +{ + OUStringBuffer aBuf; + + ScRange aRefRange(rPos); + aRefRange.aEnd.IncRow(nLen-1); + OUString aRangeStr = aRefRange.Format(ScRefFlags::VALID, &mpImpl->mrDoc); + aBuf.append(aRangeStr); + aBuf.appendAscii(": "); + + if (rArray.mpNumericArray) + { + if (rArray.mpStringArray) + { + // mixture of numeric and string cells. + aBuf.appendAscii("numeric and string"); + } + else + { + // numeric cells only. + aBuf.appendAscii("numeric only"); + } + } + else + { + if (rArray.mpStringArray) + { + // string cells only. + aBuf.appendAscii("string only"); + } + else + { + // empty cells. + aBuf.appendAscii("empty"); + } + } + + mpImpl->maMessages.push_back(aBuf.makeStringAndClear()); +} + void FormulaLogger::GroupScope::setCalcComplete() { mpImpl->mbCalcComplete = true; |