sc/source/core/data/conditio.cxx          |    6 ++++++
 sc/source/core/data/documen8.cxx          |   17 +++++++++++++++--
 sc/source/filter/excel/xicontent.cxx      |    6 ++++++
 sc/source/filter/oox/condformatbuffer.cxx |    2 ++
 4 files changed, 29 insertions(+), 2 deletions(-)

New commits:
commit dc44111ad5965bf4179fc654b677e1e445dea2f0
Author: Eike Rathke <er...@redhat.com>
Date:   Thu Jan 25 13:20:27 2018 +0100

    CheckLinkFormulaNeedingCheck() for conditional format expressions
    
     This is a combination of 4 commits.
    
    Prepare CheckLinkFormulaNeedingCheck() to use either RPN or tokenized code
    
    Conditional format formulas aren't finally compiled until needed
    so the check will have to operate on the tokenized expression
    instead of RPN code.
    
    (cherry picked from commit faa0305ba3d0dc698fce4915d4f3a1fb52422380)
    
    CheckLinkFormulaNeedingCheck() for .ods conditional format expressions
    
    (cherry picked from commit 2930ba2ac5d9423f2848b968edcd8ddc71966186)
    
    CheckLinkFormulaNeedingCheck() for .xlsx conditional format expressions
    
    (cherry picked from commit fef24d9f999ee54d7936900485d97ff26656f517)
    
    CheckLinkFormulaNeedingCheck() for .xls conditional format expressions
    
    (cherry picked from commit af2a2a0c72db312902e466c36697b5c198041e82)
    
    45eb1ab5efa0ec9da2663f20427d2474ce300826
    31ede1a23223a798141a0891deeabd8cf88fff58
    afa112cc591b411d80ead48bf726788d361f6eb3
    
    Change-Id: I68837e9bd33f125ab47b10b1a6fa18175abd1627
    Reviewed-on: https://gerrit.libreoffice.org/48719
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Tested-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 502d0b1e0623..db4bd1f4b8fa 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -522,6 +522,12 @@ void ScConditionEntry::CompileXML()
     Compile( GetExpression(aSrcPos, 0, 0, eTempGrammar1),
              GetExpression(aSrcPos, 1, 0, eTempGrammar2),
              aStrNmsp1, aStrNmsp2, eTempGrammar1, eTempGrammar2, true );
+
+    // Importing ocDde/ocWebservice?
+    if (pFormula1)
+        mpDoc->CheckLinkFormulaNeedingCheck(*pFormula1);
+    if (pFormula2)
+        mpDoc->CheckLinkFormulaNeedingCheck(*pFormula2);
 }
 
 void ScConditionEntry::SetSrcString( const OUString& rNew )
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 9cf09ddb4c70..ca8227058d5a 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -1157,8 +1157,21 @@ void ScDocument::CheckLinkFormulaNeedingCheck( const 
ScTokenArray& rCode )
     if (HasLinkFormulaNeedingCheck())
         return;
 
-    if (rCode.HasOpCodeRPN(ocDde) || rCode.HasOpCodeRPN(ocWebservice))
-        SetLinkFormulaNeedingCheck(true);
+    // Prefer RPN over tokenized formula if available.
+    if (rCode.GetCodeLen())
+    {
+        if (rCode.HasOpCodeRPN(ocDde) || rCode.HasOpCodeRPN(ocWebservice))
+            SetLinkFormulaNeedingCheck(true);
+    }
+    else if (rCode.GetLen())
+    {
+        if (rCode.HasOpCode(ocDde) || rCode.HasOpCode(ocWebservice))
+            SetLinkFormulaNeedingCheck(true);
+    }
+    else
+    {
+        assert(!"called with empty ScTokenArray");
+    }
 }
 
 // TimerDelays etc.
diff --git a/sc/source/filter/excel/xicontent.cxx 
b/sc/source/filter/excel/xicontent.cxx
index 14c2ad9d0a3f..89ebcfaada63 100644
--- a/sc/source/filter/excel/xicontent.cxx
+++ b/sc/source/filter/excel/xicontent.cxx
@@ -662,7 +662,10 @@ void XclImpCondFormat::ReadCF( XclImpStream& rStrm )
         rFmlaConv.Convert( pTokArr, rStrm, nFmlaSize1, false, FT_CondFormat );
         // formula converter owns pTokArr -> create a copy of the token array
         if( pTokArr )
+        {
             xTokArr1.reset( pTokArr->Clone() );
+            GetDocRef().CheckLinkFormulaNeedingCheck( *xTokArr1);
+        }
     }
 
     ::std::unique_ptr< ScTokenArray > pTokArr2;
@@ -673,7 +676,10 @@ void XclImpCondFormat::ReadCF( XclImpStream& rStrm )
         rFmlaConv.Convert( pTokArr, rStrm, nFmlaSize2, false, FT_CondFormat );
         // formula converter owns pTokArr -> create a copy of the token array
         if( pTokArr )
+        {
             pTokArr2.reset( pTokArr->Clone() );
+            GetDocRef().CheckLinkFormulaNeedingCheck( *pTokArr2);
+        }
     }
 
     // *** create the Calc conditional formatting ***
diff --git a/sc/source/filter/oox/condformatbuffer.cxx 
b/sc/source/filter/oox/condformatbuffer.cxx
index 677ddb98af26..274f062b999d 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -868,11 +868,13 @@ void CondFormatRule::finalizeImport()
         {
             pTokenArray2.reset(new ScTokenArray());
             ScTokenConversion::ConvertToTokenArray( rDoc, *pTokenArray2.get(), 
maModel.maFormulas[ 1 ] );
+            rDoc.CheckLinkFormulaNeedingCheck( *pTokenArray2.get());
         }
 
         ScTokenArray aTokenArray;
         OUString aStyleName = getStyles().createDxfStyle( maModel.mnDxfId );
         ScTokenConversion::ConvertToTokenArray( rDoc, aTokenArray, 
maModel.maFormulas[ 0 ] );
+        rDoc.CheckLinkFormulaNeedingCheck( aTokenArray);
         ScCondFormatEntry* pNewEntry = new ScCondFormatEntry(eOperator,
                                             &aTokenArray, pTokenArray2.get(), 
&rDoc, aPos, aStyleName);
         mpFormat->AddEntry(pNewEntry);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to