[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source sw/source

Dennis Francis dennis.francis at collabora.co.uk
Wed Jan 24 06:55:16 UTC 2018


 sc/qa/unit/parallelism.cxx           |   23 +++++++++++++++++++++++
 sc/source/core/tool/formulagroup.cxx |   16 +++++++++++++---
 sw/source/uibase/dochdl/swdtflvr.cxx |    2 +-
 3 files changed, 37 insertions(+), 4 deletions(-)

New commits:
commit ff166845fa5ed178a97b54bb2deef4beb0cf3bdf
Author: Dennis Francis <dennis.francis at collabora.co.uk>
Date:   Tue Jan 23 19:53:19 2018 +0530

    tdf#115093 : Do not reuse singleref tokens...
    
    ...in formula group computation if the formula contains
    only a single reference besides any ocOpen/ocClose pairs
    wrapping it as the sole content.
    
    In such a case the "result" formula token
    returned by ScInterpreter::GetResultToken() is the same
    as the original singleref token, so for each row of the
    formulagroup, we need to use a separate singleref token.
    
    Also added a unit test in sc/qa/unit/parallelism.cxx
    
    Change-Id: I6032efc5be9b51ca1e9daf9bdd19997a949d2f43
    Reviewed-on: https://gerrit.libreoffice.org/48449
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/sc/qa/unit/parallelism.cxx b/sc/qa/unit/parallelism.cxx
index 428d65a20bec..896b7c1d8382 100644
--- a/sc/qa/unit/parallelism.cxx
+++ b/sc/qa/unit/parallelism.cxx
@@ -46,12 +46,14 @@ public:
     void testDivision();
     void testVLOOKUP();
     void testVLOOKUPSUM();
+    void testSingleRef();
 
     CPPUNIT_TEST_SUITE(ScParallelismTest);
     CPPUNIT_TEST(testSUMIFS);
     CPPUNIT_TEST(testDivision);
     CPPUNIT_TEST(testVLOOKUP);
     CPPUNIT_TEST(testVLOOKUPSUM);
+    CPPUNIT_TEST(testSingleRef);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -296,6 +298,27 @@ void ScParallelismTest::testVLOOKUPSUM()
     m_pDoc->DeleteTab(0);
 }
 
+void ScParallelismTest::testSingleRef()
+{
+    m_pDoc->InsertTab(0, "1");
+
+    const size_t nNumRows = 200;
+    for (size_t i = 0; i < nNumRows; ++i)
+    {
+        m_pDoc->SetValue(0, i, 0, static_cast<double>(i));
+        m_pDoc->SetFormula(ScAddress(1, i, 0), "=A" + OUString::number(i+1), formula::FormulaGrammar::GRAM_NATIVE_UI);
+    }
+
+    m_xDocShell->DoHardRecalc();
+
+    for (size_t i = 0; i < nNumRows; ++i)
+    {
+        OString aMsg = "At row " + OString::number(i);
+        CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsg.getStr(), i, static_cast<size_t>(m_pDoc->GetValue(1, i, 0)));
+    }
+    m_pDoc->DeleteTab(0);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScParallelismTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index 57ad65d2b114..b494d25d1146 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -177,6 +177,7 @@ public:
         ScTokenArray aCode2;
 
         ScInterpreterContext aContext(mrDoc, mpFormatter);
+        sal_uInt16 nNumNonOpenClose = mrCode.GetLen();
 
         for (SCROW i = mnIdx; i <= mnLastIdx; ++i, maBatchTopPos.IncRow())
         {
@@ -212,7 +213,7 @@ public:
                                 aCode2.AddString(rPool.intern(OUString(pStr)));
                             else
                             {
-                                if ( pTargetTok->GetType() == formula::svString )
+                                if ( ( pTargetTok->GetType() == formula::svString ) && ( nNumNonOpenClose > 1 ) )
                                     pTargetTok->SetString(rPool.intern(OUString(pStr)));
                                 else
                                 {
@@ -226,7 +227,7 @@ public:
                             // Value of NaN represents an empty cell.
                             if ( !pTargetTok )
                                 aCode2.AddToken(ScEmptyCellToken(false, false));
-                            else if ( pTargetTok->GetType() != formula::svEmptyCell )
+                            else if ( ( pTargetTok->GetType() != formula::svEmptyCell ) || ( nNumNonOpenClose == 1 ) )
                             {
                                 ScEmptyCellToken* pEmptyTok = new ScEmptyCellToken(false, false);
                                 aCode2.ReplaceToken(nTokIdx, pEmptyTok, formula::FormulaTokenArray::CODE_ONLY);
@@ -239,7 +240,7 @@ public:
                                 aCode2.AddDouble(fVal);
                             else
                             {
-                                if ( pTargetTok->GetType() == formula::svDouble )
+                                if ( ( pTargetTok->GetType() == formula::svDouble ) && ( nNumNonOpenClose > 1 ) )
                                     pTargetTok->GetDoubleAsReference() = fVal;
                                 else
                                 {
@@ -291,7 +292,16 @@ public:
                     break;
                     default:
                         if ( !pTargetTok )
+                        {
+                            if ( p->GetType() == formula::svSep )
+                            {
+                                OpCode eOp = p->GetOpCode();
+                                if ( eOp == ocOpen || eOp == ocClose )
+                                    --nNumNonOpenClose;
+                            }
+
                             aCode2.AddToken(*p);
+                        }
                 } // end of switch statement
             } // end of formula token for loop
 
commit f8aca037896ce7085f0be0ab524b524bae57d38c
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Jan 23 16:44:16 2018 +0100

    USHRT_MAX -> SAL_MAX_UINT16
    
    ...presumably forgotten when changing SwEditShell::InsertDDETable parameters
    from USHORT to sal_uInt16 in 7f33ed417b2e29e5470724ea76967f64699a2662
    "removetooltypes01: #i112600# Remove tools types from sw"
    
    Change-Id: I28ad46bdfb6c95a7d2e0bcbf2ef8eef29217baa5
    Reviewed-on: https://gerrit.libreoffice.org/48436
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index ad4c27719948..8157dfd71f81 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -2148,7 +2148,7 @@ bool SwTransferable::PasteDDE( TransferableDataHelper& rData,
                 sal_Int32 nCols = comphelper::string::getTokenCount(sTmp, '\t');
 
                 // don't try to insert tables that are too large for writer
-                if (nRows > USHRT_MAX || nCols > USHRT_MAX)
+                if (nRows > SAL_MAX_UINT16 || nCols > SAL_MAX_UINT16)
                 {
                     if( bMsg )
                         ScopedVclPtrInstance<MessageDialog>(nullptr, SwResId(STR_TABLE_TOO_LARGE), VclMessageType::Info)->Execute();


More information about the Libreoffice-commits mailing list