[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - sc/inc sc/source

Eike Rathke erack at redhat.com
Sat Jan 27 19:56:15 UTC 2018


 sc/inc/document.hxx                    |    2 ++
 sc/source/core/data/documen8.cxx       |   10 ++++++++++
 sc/source/core/data/formulacell.cxx    |    3 +--
 sc/source/filter/excel/excform.cxx     |    1 +
 sc/source/filter/excel/excform8.cxx    |    1 +
 sc/source/filter/excel/impop.cxx       |    1 +
 sc/source/filter/oox/formulabuffer.cxx |    4 ++++
 7 files changed, 20 insertions(+), 2 deletions(-)

New commits:
commit 540135c4aea282b441f6f3d41770d5f9d00c8245
Author: Eike Rathke <erack at 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/48137
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 6bce61522184..d6cd6fd79987 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1994,6 +1994,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 );
 
     void            SetRangeOverflowType(ErrCode nType)  { nRangeOverflowType = nType; }
     bool            HasRangeOverflow() const             { return nRangeOverflowType != ERRCODE_NONE; }
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 9f637eb53046..4a2b7b5a9f99 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -87,6 +87,7 @@
 #include <stringutil.hxx>
 #include <documentlinkmgr.hxx>
 #include <scopetools.hxx>
+#include <tokenarray.hxx>
 
 #include <memory>
 #include <utility>
@@ -1175,6 +1176,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()
 {
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index e7e4d09f5a47..5b8e6d1d36e9 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -1360,8 +1360,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 2a74af0c7463..8ef1555660f5 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 b441f729c4c1..1a95d3f01b16 100644
--- a/sc/source/filter/excel/excform8.cxx
+++ b/sc/source/filter/excel/excform8.cxx
@@ -730,6 +730,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 8f02b00dd0cf..f1b21b74ef43 100644
--- a/sc/source/filter/excel/impop.cxx
+++ b/sc/source/filter/excel/impop.cxx
@@ -861,6 +861,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 c750b45e97c1..cfa917330096 100644
--- a/sc/source/filter/oox/formulabuffer.cxx
+++ b/sc/source/filter/oox/formulabuffer.cxx
@@ -213,6 +213,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);


More information about the Libreoffice-commits mailing list