sc/inc/document.hxx                       |    2 ++
 sc/source/core/data/conditio.cxx          |    6 ++++++
 sc/source/core/data/documen8.cxx          |   23 +++++++++++++++++++++++
 sc/source/core/data/formulacell.cxx       |    3 +--
 sc/source/core/tool/rangenam.cxx          |    8 +++++++-
 sc/source/filter/excel/excform.cxx        |    1 +
 sc/source/filter/excel/excform8.cxx       |    1 +
 sc/source/filter/excel/impop.cxx          |    1 +
 sc/source/filter/excel/xicontent.cxx      |    6 ++++++
 sc/source/filter/excel/xiname.cxx         |    3 +++
 sc/source/filter/oox/condformatbuffer.cxx |    2 ++
 sc/source/filter/oox/defnamesbuffer.cxx   |    2 ++
 sc/source/filter/oox/formulabuffer.cxx    |    4 ++++
 13 files changed, 59 insertions(+), 3 deletions(-)

New commits:
commit 4e014900dac59685d47adfb732c58575770ddc83
Author: Eike Rathke <er...@redhat.com>
Date:   Mon Jan 29 18:19:33 2018 +0100

    CheckLinkFormulaNeedingCheck() for named expressions
    
     This is a combination of 3 commits.
    
    CheckLinkFormulaNeedingCheck() for .ods named expressions
    
    This is specifically necessary for named expressions that are used
    in conditional format formulas, for which RPN is generated at a
    later stage, not during import.
    
    (cherry picked from commit eae9648e99be53ba441d9d8207aac6f3ce211ef2)
    
    CheckLinkFormulaNeedingCheck() for .xls named expressions
    
    (cherry picked from commit 8512f13c42ae3fbb287a555616fe10ff04295616)
    
    CheckLinkFormulaNeedingCheck() for .xlsx named expressions
    
    (cherry picked from commit a1f933ee2b9e23a505d937035821e9571cf4119c)
    
     Conflicts:
            sc/source/filter/oox/defnamesbuffer.cxx
    
    e03cb5767c34f8157a492a6d6c3b0700d065052d
    217c89822ab477a6c383d170ae739e44efd10fa3
    
    Change-Id: I54ab8dc14f81d6b18b0d17f448187d19d8e396fc
    Reviewed-on: https://gerrit.libreoffice.org/48858
    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/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index 0377890b2326..463f5b731d23 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -64,9 +64,14 @@ ScRangeData::ScRangeData( ScDocument* pDok,
                 mnMaxCol    (-1)
 {
     if (!rSymbol.isEmpty())
-        CompileRangeData( rSymbol, pDoc->IsImportingXML());
+    {
         // Let the compiler set an error on unknown names for a subsequent
         // CompileUnresolvedXML().
+        const bool bImporting = pDoc->IsImportingXML();
+        CompileRangeData( rSymbol, bImporting);
+        if (bImporting)
+            pDoc->CheckLinkFormulaNeedingCheck( *pCode);
+    }
     else
     {
         // #i63513#/#i65690# don't leave pCode as NULL.
@@ -199,6 +204,7 @@ void ScRangeData::CompileUnresolvedXML( 
sc::CompileFormulaContext& rCxt )
         // Don't let the compiler set an error for unknown names on final
         // compile, errors are handled by the interpreter thereafter.
         CompileRangeData( aSymbol, false);
+        rCxt.getDoc()->CheckLinkFormulaNeedingCheck( *pCode);
     }
 }
 
diff --git a/sc/source/filter/excel/xiname.cxx 
b/sc/source/filter/excel/xiname.cxx
index d09661503c6b..8decfc00e8e0 100644
--- a/sc/source/filter/excel/xiname.cxx
+++ b/sc/source/filter/excel/xiname.cxx
@@ -265,7 +265,10 @@ void XclImpName::InsertName(const ScTokenArray* pArray)
         }
     }
     if (pData)
+    {
+        GetDoc().CheckLinkFormulaNeedingCheck( *pData->GetCode());
         mpScData = pData;               // cache for later use
+    }
 }
 
 XclImpNameManager::XclImpNameManager( const XclImpRoot& rRoot ) :
diff --git a/sc/source/filter/oox/defnamesbuffer.cxx 
b/sc/source/filter/oox/defnamesbuffer.cxx
index b6c564d303dd..32c957efa4ba 100644
--- a/sc/source/filter/oox/defnamesbuffer.cxx
+++ b/sc/source/filter/oox/defnamesbuffer.cxx
@@ -38,6 +38,7 @@
 #include "tokenarray.hxx"
 #include "tokenuno.hxx"
 #include "compiler.hxx"
+#include "document.hxx"
 
 namespace oox {
 namespace xls {
@@ -338,6 +339,7 @@ std::unique_ptr<ScTokenArray> DefinedName::getScTokens(
     // after, a resulting error must be reset.
     sal_uInt16 nErr = pArray->GetCodeError();
     aCompiler.CompileTokenArray();
+    getScDocument().CheckLinkFormulaNeedingCheck( *pArray);
     pArray->DelRPN();
     pArray->SetCodeError(nErr);
 
commit 68a7e83f0e8dc34cf2b1eeba58a2cd8d3fe7b77d
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 c4b32cd813dd..2beedf0b1a54 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -472,6 +472,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 cc77c70a0b3a..9734ce650f5f 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -1159,8 +1159,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 8534f8a68832..73513ee17e81 100644
--- a/sc/source/filter/excel/xicontent.cxx
+++ b/sc/source/filter/excel/xicontent.cxx
@@ -657,7 +657,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;
@@ -668,7 +671,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 98f654f2610b..d1e230ecb58e 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -867,11 +867,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);
commit b5e114e440028fee0d165728dbabbff53c99c5d8
Author: Eike Rathke <er...@redhat.com>
Date:   Wed Jan 17 22:22:55 2018 +0100

    CheckLinkFormulaNeedingCheck() for .xls and .xlsx formula cells
    
     This is a combination of 3 commits.
    
    Move implementation to CheckLinkFormulaNeedingCheck() for further reuse
    
    (cherry picked from commit 55e484c7bcd3ef218e08d3fd93f97bf98fd8cb7f)
    
    CheckLinkFormulaNeedingCheck() for .xlsx cell formulas
    
    (cherry picked from commit f96dbc3dd9c33202f75e29ef49d962386595995d)
    
    CheckLinkFormulaNeedingCheck() for .xls cell formulas
    
    (cherry picked from commit 6bc48275558c3f76c4da25eb8af3c48583ac5599)
    
    a6dd195f7eb4d43483e87eeca59f651e7bf2dcb8
    2587fbc4fec39b6f2c8e733331815a2953dee308
    
    Change-Id: I541d2b6e12a88371c064b901b00e71206ee0c18e
    Reviewed-on: https://gerrit.libreoffice.org/48143
    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/inc/document.hxx b/sc/inc/document.hxx
index 450a3d581395..67b91d6ac536 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1812,6 +1812,8 @@ public:
 
     bool            HasLinkFormulaNeedingCheck() const      { return 
bLinkFormulaNeedingCheck; }
     void            SetLinkFormulaNeedingCheck(bool bSet)   { 
bLinkFormulaNeedingCheck = bSet; }
+    /** Check token array and set link check if ocDde/ocWebservice is 
contained. */
+    SC_DLLPUBLIC void CheckLinkFormulaNeedingCheck( const ScTokenArray& rCode 
);
 
     static bool     CheckMacroWarn();
 
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 15fbb88c2e64..cc77c70a0b3a 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -88,6 +88,7 @@
 #include "stringutil.hxx"
 #include <documentlinkmgr.hxx>
 #include <scopetools.hxx>
+#include <tokenarray.hxx>
 
 #include <memory>
 
@@ -1153,6 +1154,15 @@ void ScDocument::UpdateRefAreaLinks( UpdateRefMode 
eUpdateRefMode,
     }
 }
 
+void ScDocument::CheckLinkFormulaNeedingCheck( const ScTokenArray& rCode )
+{
+    if (HasLinkFormulaNeedingCheck())
+        return;
+
+    if (rCode.HasOpCodeRPN(ocDde) || rCode.HasOpCodeRPN(ocWebservice))
+        SetLinkFormulaNeedingCheck(true);
+}
+
 // TimerDelays etc.
 void ScDocument::KeyInput( const KeyEvent& )
 {
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 5458cb5335b4..53f89c869237 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -1414,8 +1414,7 @@ void ScFormulaCell::CompileXML( 
sc::CompileFormulaContext& rCxt, ScProgress& rPr
 
     //  After loading, it must be known if ocDde/ocWebservice is in any formula
     //  (for external links warning, CompileXML is called at the end of 
loading XML file)
-    if (!pDocument->HasLinkFormulaNeedingCheck() && 
(pCode->HasOpCodeRPN(ocDde) || pCode->HasOpCodeRPN(ocWebservice)))
-        pDocument->SetLinkFormulaNeedingCheck(true);
+    pDocument->CheckLinkFormulaNeedingCheck(*pCode);
 
     //volatile cells must be added here for import
     if( pCode->IsRecalcModeAlways() || pCode->IsRecalcModeForced() ||
diff --git a/sc/source/filter/excel/excform.cxx 
b/sc/source/filter/excel/excform.cxx
index c05f8adf3bec..bdc66c74077a 100644
--- a/sc/source/filter/excel/excform.cxx
+++ b/sc/source/filter/excel/excform.cxx
@@ -157,6 +157,7 @@ void ImportExcel::Formula(
     {
         pCell = new ScFormulaCell(&rDoc.getDoc(), aScPos, *pResult);
         pCell->GetCode()->WrapReference(aScPos, EXC_MAXCOL8, EXC_MAXROW8);
+        rDoc.getDoc().CheckLinkFormulaNeedingCheck( *pCell->GetCode());
         rDoc.getDoc().EnsureTable(aScPos.Tab());
         rDoc.setFormulaCell(aScPos, pCell);
         SetLastFormula(aScPos.Col(), aScPos.Row(), fCurVal, nXF, pCell);
diff --git a/sc/source/filter/excel/excform8.cxx 
b/sc/source/filter/excel/excform8.cxx
index 32e1932c6c22..c312b9a492ed 100644
--- a/sc/source/filter/excel/excform8.cxx
+++ b/sc/source/filter/excel/excform8.cxx
@@ -729,6 +729,7 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray*& 
rpTokArray, XclImpStream& aIn,
                                         << nMerk0 << ocClose;
                                 aPool >> aStack;
                                 pExtName->CreateDdeData( GetDoc(), aApplic, 
aTopic );
+                                GetDoc().SetLinkFormulaNeedingCheck(true);
                             }
                         }
                         break;
diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx
index 1d24749aca16..a07d9877d660 100644
--- a/sc/source/filter/excel/impop.cxx
+++ b/sc/source/filter/excel/impop.cxx
@@ -866,6 +866,7 @@ void ImportExcel::Shrfmla()
 
     ScFormulaCell* pCell = new ScFormulaCell(pD, aPos, *pErgebnis);
     pCell->GetCode()->WrapReference(aPos, EXC_MAXCOL8, EXC_MAXROW8);
+    rDoc.getDoc().CheckLinkFormulaNeedingCheck( *pCell->GetCode());
     rDoc.getDoc().EnsureTable(aPos.Tab());
     rDoc.setFormulaCell(aPos, pCell);
     pCell->SetNeedNumberFormat(false);
diff --git a/sc/source/filter/oox/formulabuffer.cxx 
b/sc/source/filter/oox/formulabuffer.cxx
index 0d276a602f9d..50b01668c818 100644
--- a/sc/source/filter/oox/formulabuffer.cxx
+++ b/sc/source/filter/oox/formulabuffer.cxx
@@ -229,6 +229,10 @@ void applyCellFormulas(
             continue;
 
         aCompiler.CompileTokenArray(); // Generate RPN tokens.
+
+        // Check if ocDde/ocWebservice is in any formula for external links 
warning.
+        rDoc.getDoc().CheckLinkFormulaNeedingCheck(*pCode);
+
         ScFormulaCell* pCell = new ScFormulaCell(&rDoc.getDoc(), aPos, pCode);
         rDoc.setFormulaCell(aPos, pCell);
         rCache.store(aPos, pCell);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to