[Libreoffice-commits] core.git: include/formula sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Jul 13 23:55:41 UTC 2018


 include/formula/tokenarray.hxx         |    8 ++++++--
 sc/source/filter/oox/formulabuffer.cxx |   26 ++++++++++++++++++++------
 2 files changed, 26 insertions(+), 8 deletions(-)

New commits:
commit 771149ac99a57c641caebdfc7dd6fac25c292682
Author:     Eike Rathke <erack at redhat.com>
AuthorDate: Fri Jul 13 22:30:24 2018 +0200
Commit:     Eike Rathke <erack at redhat.com>
CommitDate: Sat Jul 14 01:55:16 2018 +0200

    Resolves: tdf#94925 do not unset dirty if formula cell must be recalculated
    
    Change-Id: If70860b8babf1cce7fda2ae63412659e72dbb4c3
    Reviewed-on: https://gerrit.libreoffice.org/57404
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Jenkins

diff --git a/include/formula/tokenarray.hxx b/include/formula/tokenarray.hxx
index d4111f798d5c..2c422d94faf8 100644
--- a/include/formula/tokenarray.hxx
+++ b/include/formula/tokenarray.hxx
@@ -58,8 +58,8 @@ enum class ScRecalcMode : sal_uInt8
 {
     ALWAYS         = 0x01,  // exclusive, always
     ONLOAD_MUST    = 0x02,  // exclusive, always after load
-    ONLOAD_LENIENT = 0x04,  // exclusive, lenient after load (eg. macros not always, aliens, ...)
-    ONLOAD_ONCE    = 0x08,  // exclusive, once after load, import filter
+    ONLOAD_ONCE    = 0x04,  // exclusive, once after load, import filter
+    ONLOAD_LENIENT = 0x08,  // exclusive, lenient after load (eg. macros not always, aliens, ...)
     NORMAL         = 0x10,  // exclusive
     FORCED         = 0x20,  // combined, also if cell isn't visible, for macros with side effects
     ONREFMOVE      = 0x40,  // combined, if reference was moved
@@ -416,6 +416,10 @@ public:
                                 { return bool(nMode & ScRecalcMode::FORCED); }
     bool            IsRecalcModeOnRefMove() const
                                 { return bool(nMode & ScRecalcMode::ONREFMOVE); }
+                    /** Whether recalculation must happen after import, for
+                        example OOXML. */
+    bool            IsRecalcModeMustAfterImport() const
+                                { return (nMode & ScRecalcMode::EMask) <= ScRecalcMode::ONLOAD_ONCE; }
 
                             /** Get OpCode of the most outer function */
     inline OpCode           GetOuterFuncOpCode();
diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx
index 9bec5335a599..53172729ac85 100644
--- a/sc/source/filter/oox/formulabuffer.cxx
+++ b/sc/source/filter/oox/formulabuffer.cxx
@@ -159,6 +159,11 @@ void applySharedFormulas(
                 case XML_n:
                     // numeric value.
                     pCell->SetResultDouble(rDesc.maCellValue.toDouble());
+                    /* TODO: is it on purpose that we never reset dirty here
+                     * and thus recalculate anyway if cell was dirty? Or is it
+                     * never dirty and therefor set dirty below otherwise? This
+                     * is different from the non-shared case in
+                     * applyCellFormulaValues(). */
                 break;
                 case XML_str:
                     if (bGeneratorKnownGood)
@@ -168,8 +173,11 @@ void applySharedFormulas(
                         pCell->SetResultToken(new formula::FormulaStringToken(aSS));
                         // If we don't reset dirty, then e.g. disabling macros makes all cells
                         // that use macro functions to show #VALUE!
-                        pCell->ResetDirty();
-                        pCell->SetChanged(false);
+                        if (!pCell->GetCode()->IsRecalcModeMustAfterImport())
+                        {
+                            pCell->ResetDirty();
+                            pCell->SetChanged(false);
+                        }
                         break;
                     }
                     SAL_FALLTHROUGH;
@@ -270,8 +278,11 @@ void applyCellFormulaValues(
             case XML_n:
             {
                 pCell->SetResultDouble(rValueStr.toDouble());
-                pCell->ResetDirty();
-                pCell->SetChanged(false);
+                if (!pCell->GetCode()->IsRecalcModeMustAfterImport())
+                {
+                    pCell->ResetDirty();
+                    pCell->SetChanged(false);
+                }
             }
             break;
             case XML_str:
@@ -289,8 +300,11 @@ void applyCellFormulaValues(
                 {
                     svl::SharedString aSS = rStrPool.intern(rValueStr);
                     pCell->SetResultToken(new formula::FormulaStringToken(aSS));
-                    pCell->ResetDirty();
-                    pCell->SetChanged(false);
+                    if (!pCell->GetCode()->IsRecalcModeMustAfterImport())
+                    {
+                        pCell->ResetDirty();
+                        pCell->SetChanged(false);
+                    }
                 }
             break;
             default:


More information about the Libreoffice-commits mailing list