[Libreoffice-commits] core.git: 4 commits - sc/inc sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Sat Nov 5 12:09:56 UTC 2016


 sc/inc/formulalogger.hxx                    |   46 ++++++++++++++
 sc/source/core/data/formulacell.cxx         |    2 
 sc/source/core/data/grouptokenconverter.cxx |   22 ++++---
 sc/source/core/inc/grouptokenconverter.hxx  |    3 
 sc/source/core/tool/formulalogger.cxx       |   88 +++++++++++++++++++++++++++-
 5 files changed, 150 insertions(+), 11 deletions(-)

New commits:
commit 60762db52515cba74450bcbe9c474416dbcf9c73
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Nov 4 21:17:54 2016 -0400

    Log cell range references.
    
    Change-Id: Id6402a35ced37aff7215a46d23b4103a64bf669b

diff --git a/sc/inc/formulalogger.hxx b/sc/inc/formulalogger.hxx
index 83a8e6bb..1df49cc 100644
--- a/sc/inc/formulalogger.hxx
+++ b/sc/inc/formulalogger.hxx
@@ -88,6 +88,13 @@ public:
         void addRefMessage( const ScAddress& rPos, size_t nLen, const formula::VectorRefArray& rArray );
 
         /**
+         * Add to the log a vector reference information for a range
+         * reference.
+         */
+        void addRefMessage(
+            const ScAddress& rPos, size_t nLen, const std::vector<formula::VectorRefArray>& rArrays );
+
+        /**
          * Add to the log a single cell reference information.
          */
         void addRefMessage( const ScAddress& rPos, const formula::FormulaToken& rToken );
@@ -125,10 +132,26 @@ 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 addRefMessage(
+            const ScAddress& /*rPos*/, size_t /*nLen*/,
+            const formula::VectorRefArray& /*rArray*/ )
+        {
+            (void) this; /* loplugin:staticmethods */
+        }
+
+        void addRefMessage(
+            const ScAddress& /*rPos*/, size_t /*nLen*/,
+            const std::vector<formula::VectorRefArray>& /*rArrays*/ )
+        {
+            (void) this; /* loplugin:staticmethods */
+        }
+
         void addRefMessage( const ScAddress& /*rPos*/, const formula::FormulaToken& /*rToken*/ )
-        { (void) this; /* loplugin:staticmethods */ }
+        {
+            (void) this; /* loplugin:staticmethods */
+        }
+
         void setCalcComplete() { (void) this; /* loplugin:staticmethods */ }
     };
 
diff --git a/sc/source/core/data/grouptokenconverter.cxx b/sc/source/core/data/grouptokenconverter.cxx
index fd69b4c..e4eecfb 100644
--- a/sc/source/core/data/grouptokenconverter.cxx
+++ b/sc/source/core/data/grouptokenconverter.cxx
@@ -224,6 +224,7 @@ bool ScGroupTokenConverter::convert( ScTokenArray& rCode, sc::FormulaLogger::Gro
 
                 formula::DoubleVectorRefToken aTok(aArrays, nRequestedLength, nArrayLength, nRefRowSize, bAbsFirst, bAbsLast);
                 mrGroupTokens.AddToken(aTok);
+                rScope.addRefMessage(aRefPos, nRequestedLength, aArrays);
 
                 if (nArrayLength && !aArrays.empty() && !mxFormulaGroupContext)
                 {
diff --git a/sc/source/core/tool/formulalogger.cxx b/sc/source/core/tool/formulalogger.cxx
index e8f720c..a5337bf 100644
--- a/sc/source/core/tool/formulalogger.cxx
+++ b/sc/source/core/tool/formulalogger.cxx
@@ -158,6 +158,17 @@ void FormulaLogger::GroupScope::addRefMessage(
 }
 
 void FormulaLogger::GroupScope::addRefMessage(
+    const ScAddress& rPos, size_t nLen, const std::vector<formula::VectorRefArray>& rArrays )
+{
+    ScAddress aPos(rPos); // copy
+    for (const formula::VectorRefArray& rArray : rArrays)
+    {
+        addRefMessage(aPos, nLen, rArray);
+        aPos.IncCol();
+    }
+}
+
+void FormulaLogger::GroupScope::addRefMessage(
     const ScAddress& rPos, const formula::FormulaToken& rToken )
 {
     OUStringBuffer aBuf;
commit 34c49d3f87eafcbb2c57f764e8972178b3804344
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Nov 4 18:41:59 2016 -0400

    Log single cell references.
    
    Change-Id: If711c44a3be7ae02d1354bb36ed7db6b5a86ef6b

diff --git a/sc/inc/formulalogger.hxx b/sc/inc/formulalogger.hxx
index d63cf78..83a8e6bb 100644
--- a/sc/inc/formulalogger.hxx
+++ b/sc/inc/formulalogger.hxx
@@ -18,7 +18,12 @@ class ScFormulaCell;
 class ScDocument;
 class ScAddress;
 
-namespace formula { struct VectorRefArray; }
+namespace formula {
+
+class FormulaToken;
+struct VectorRefArray;
+
+}
 
 namespace sc {
 
@@ -83,6 +88,11 @@ public:
         void addRefMessage( const ScAddress& rPos, size_t nLen, const formula::VectorRefArray& rArray );
 
         /**
+         * Add to the log a single cell reference information.
+         */
+        void addRefMessage( const ScAddress& rPos, const formula::FormulaToken& rToken );
+
+        /**
          * Call this when the group calculation has finished successfullly.
          */
         void setCalcComplete();
@@ -117,6 +127,8 @@ 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 addRefMessage( const ScAddress& /*rPos*/, const formula::FormulaToken& /*rToken*/ )
+        { (void) this; /* loplugin:staticmethods */ }
         void setCalcComplete() { (void) this; /* loplugin:staticmethods */ }
     };
 
diff --git a/sc/source/core/data/grouptokenconverter.cxx b/sc/source/core/data/grouptokenconverter.cxx
index e866114..fd69b4c 100644
--- a/sc/source/core/data/grouptokenconverter.cxx
+++ b/sc/source/core/data/grouptokenconverter.cxx
@@ -160,6 +160,7 @@ bool ScGroupTokenConverter::convert( ScTokenArray& rCode, sc::FormulaLogger::Gro
                         return false;
 
                     mrGroupTokens.AddToken(*pNewToken);
+                    rScope.addRefMessage(aRefPos, *pNewToken);
                 }
             }
             break;
diff --git a/sc/source/core/tool/formulalogger.cxx b/sc/source/core/tool/formulalogger.cxx
index df7fc73..e8f720c 100644
--- a/sc/source/core/tool/formulalogger.cxx
+++ b/sc/source/core/tool/formulalogger.cxx
@@ -157,6 +157,29 @@ void FormulaLogger::GroupScope::addRefMessage(
     mpImpl->maMessages.push_back(aBuf.makeStringAndClear());
 }
 
+void FormulaLogger::GroupScope::addRefMessage(
+    const ScAddress& rPos, const formula::FormulaToken& rToken )
+{
+    OUStringBuffer aBuf;
+    OUString aPosStr = rPos.Format(ScRefFlags::VALID, &mpImpl->mrDoc);
+    aBuf.append(aPosStr);
+    aBuf.appendAscii(": ");
+
+    switch (rToken.GetType())
+    {
+        case formula::svDouble:
+            aBuf.appendAscii("numeric value");
+            break;
+        case formula::svString:
+            aBuf.appendAscii("string value");
+            break;
+        default:
+            aBuf.appendAscii("unknown value");
+    }
+
+    mpImpl->maMessages.push_back(aBuf.makeStringAndClear());
+}
+
 void FormulaLogger::GroupScope::setCalcComplete()
 {
     mpImpl->mbCalcComplete = true;
commit fe7b4884a2c22e3089e2803824565fa6d1391e1b
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Thu Nov 3 21:55:18 2016 -0400

    Dump the single cell vector reference info to the log.
    
    Change-Id: If0ee6dca6642063501c728bec3b4e5d7b6401442

diff --git a/sc/inc/formulalogger.hxx b/sc/inc/formulalogger.hxx
index 0925d30..d63cf78 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 7f97e26..6231bc6 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 22b89a6..e866114 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 7b88004..e9782d4 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 7b5b916f..df7fc73 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;
commit c7aa57bc6b35a27aba265ce548397f282541253f
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Thu Nov 3 19:42:22 2016 -0400

    Output the header information to the formula log.
    
    The header information for now contains relevant formula calculation
    configuration settings.
    
    Change-Id: Ia6f8b84a3a6fa448708b9a78957002481c3a1c67

diff --git a/sc/source/core/tool/formulalogger.cxx b/sc/source/core/tool/formulalogger.cxx
index c7ae53b..7b5b916f 100644
--- a/sc/source/core/tool/formulalogger.cxx
+++ b/sc/source/core/tool/formulalogger.cxx
@@ -152,7 +152,14 @@ FormulaLogger::FormulaLogger()
         return;
     }
 
+    // Output the header information.
     writeAscii("---\n");
+    writeAscii("OpenCL: ");
+    writeAscii(ScCalcConfig::isOpenCLEnabled() ? "enabled\n" : "disabled\n");
+    writeAscii("Software Interpreter: ");
+    writeAscii(ScCalcConfig::isSwInterpreterEnabled() ? "enabled\n" : "disabled\n");
+    writeAscii("---\n");
+
     sync();
 }
 


More information about the Libreoffice-commits mailing list