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

Eike Rathke erack at redhat.com
Thu May 7 06:56:38 PDT 2015


 sc/inc/refupdatecontext.hxx              |    9 +++++---
 sc/source/core/data/documen2.cxx         |    4 +--
 sc/source/core/data/document.cxx         |    8 +++----
 sc/source/core/data/refupdatecontext.cxx |   12 +++++------
 sc/source/core/tool/token.cxx            |   32 ++++++++++++++++++++++---------
 5 files changed, 41 insertions(+), 24 deletions(-)

New commits:
commit b6697facb33f3149673e683921aeb069a2fa4e96
Author: Eike Rathke <erack at redhat.com>
Date:   Wed May 6 17:15:12 2015 +0200

    Resolves: tdf#91078 check also DBData modified, not only named expressions
    
    This adds ScDocument& to all RefUpdate...Context; another approach could
    had been to add an UpdatedDBData similar to UpdatedRangeNames and gather
    those in the ScDBData::Update...() methods, but as long as
    ScDBData::IsModified() works that isn't necessary.
    
    (cherry picked from commit 848dc76e76c1c4a9040be4a0088c4d4527af6f40)
    
    Conflicts:
    	sc/source/core/tool/token.cxx
    
    assume modified if an index has no corresponding ScDBData (anymore)
    
    (cherry picked from commit 4a53021f0662e08b56fd076f78ac182634fcec4c)
    
    16cbc7d772f39c8778b8ba21a629ced6b0dbedeb
    
    Change-Id: Iae3ec6c8b8356cbd8acb2445489e91e7d6922fb3
    Reviewed-on: https://gerrit.libreoffice.org/15654
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/inc/refupdatecontext.hxx b/sc/inc/refupdatecontext.hxx
index 393a855..3b4db92 100644
--- a/sc/inc/refupdatecontext.hxx
+++ b/sc/inc/refupdatecontext.hxx
@@ -103,29 +103,32 @@ struct RefUpdateResult
 
 struct RefUpdateInsertTabContext
 {
+    ScDocument& mrDoc;
     SCTAB mnInsertPos;
     SCTAB mnSheets;
     UpdatedRangeNames maUpdatedNames;
 
-    RefUpdateInsertTabContext(SCTAB nInsertPos, SCTAB nSheets);
+    RefUpdateInsertTabContext(ScDocument& rDoc, SCTAB nInsertPos, SCTAB nSheets);
 };
 
 struct RefUpdateDeleteTabContext
 {
+    ScDocument& mrDoc;
     SCTAB mnDeletePos;
     SCTAB mnSheets;
     UpdatedRangeNames maUpdatedNames;
 
-    RefUpdateDeleteTabContext(SCTAB nInsertPos, SCTAB nSheets);
+    RefUpdateDeleteTabContext(ScDocument& rDoc, SCTAB nInsertPos, SCTAB nSheets);
 };
 
 struct RefUpdateMoveTabContext
 {
+    ScDocument& mrDoc;
     SCTAB mnOldPos;
     SCTAB mnNewPos;
     UpdatedRangeNames maUpdatedNames;
 
-    RefUpdateMoveTabContext(SCTAB nOldPos, SCTAB nNewPos);
+    RefUpdateMoveTabContext(ScDocument& rDoc, SCTAB nOldPos, SCTAB nNewPos);
 
     SCTAB getNewTab(SCTAB nOldTab) const;
 };
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 02e1992..0c5f212 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -731,7 +731,7 @@ bool ScDocument::MoveTab( SCTAB nOldPos, SCTAB nNewPos, ScProgress* pProgress )
             // Update Reference
             // TODO: combine with UpdateReference!
 
-            sc::RefUpdateMoveTabContext aCxt(nOldPos, nNewPos);
+            sc::RefUpdateMoveTabContext aCxt( *this, nOldPos, nNewPos);
 
             SCsTAB nDz = ((SCsTAB)nNewPos) - (SCsTAB)nOldPos;
             ScRange aSourceRange( 0,0,nOldPos, MAXCOL,MAXROW,nOldPos );
@@ -804,7 +804,7 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM
         bValid = !GetTable( aName, nDummy );
 
     sc::AutoCalcSwitch aACSwitch(*this, false);
-    sc::RefUpdateInsertTabContext aCxt(nNewPos, 1);
+    sc::RefUpdateInsertTabContext aCxt( *this, nNewPos, 1);
     sc::StartListeningContext aSLCxt(*this);
 
     if (bValid)
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 5a21587..5889916 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -491,7 +491,7 @@ bool ScDocument::InsertTab(
         {
             if (ValidTab(nPos) && (nPos < nTabCount))
             {
-                sc::RefUpdateInsertTabContext aCxt(nPos, 1);
+                sc::RefUpdateInsertTabContext aCxt( *this, nPos, 1);
 
                 ScRange aRange( 0,0,nPos, MAXCOL,MAXROW,MAXTAB );
                 xColNameRanges->UpdateReference( URM_INSDEL, this, aRange, 0,0,1 );
@@ -582,7 +582,7 @@ bool ScDocument::InsertTabs( SCTAB nPos, const std::vector<OUString>& rNames,
         {
             if (ValidTab(nPos) && (nPos < nTabCount))
             {
-                sc::RefUpdateInsertTabContext aCxt(nPos, nNewSheets);
+                sc::RefUpdateInsertTabContext aCxt( *this, nPos, nNewSheets);
                 ScRange aRange( 0,0,nPos, MAXCOL,MAXROW,MAXTAB );
                 xColNameRanges->UpdateReference( URM_INSDEL, this, aRange, 0,0,nNewSheets );
                 xRowNameRanges->UpdateReference( URM_INSDEL, this, aRange, 0,0,nNewSheets );
@@ -657,7 +657,7 @@ bool ScDocument::DeleteTab( SCTAB nTab )
             if (nTabCount > 1)
             {
                 sc::AutoCalcSwitch aACSwitch(*this, false);
-                sc::RefUpdateDeleteTabContext aCxt(nTab, 1);
+                sc::RefUpdateDeleteTabContext aCxt( *this, nTab, 1);
 
                 ScRange aRange( 0, 0, nTab, MAXCOL, MAXROW, nTab );
                 DelBroadcastAreasInRange( aRange );
@@ -739,7 +739,7 @@ bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets )
             if (nTabCount > nSheets)
             {
                 sc::AutoCalcSwitch aACSwitch(*this, false);
-                sc::RefUpdateDeleteTabContext aCxt(nTab, nSheets);
+                sc::RefUpdateDeleteTabContext aCxt( *this, nTab, nSheets);
 
                 for (SCTAB aTab = 0; aTab < nSheets; ++aTab)
                 {
diff --git a/sc/source/core/data/refupdatecontext.cxx b/sc/source/core/data/refupdatecontext.cxx
index d63c745..b5f5391 100644
--- a/sc/source/core/data/refupdatecontext.cxx
+++ b/sc/source/core/data/refupdatecontext.cxx
@@ -61,14 +61,14 @@ RefUpdateResult::RefUpdateResult(const RefUpdateResult& r) :
     mbReferenceModified(r.mbReferenceModified),
     mbNameModified(r.mbNameModified) {}
 
-RefUpdateInsertTabContext::RefUpdateInsertTabContext(SCTAB nInsertPos, SCTAB nSheets) :
-    mnInsertPos(nInsertPos), mnSheets(nSheets) {}
+RefUpdateInsertTabContext::RefUpdateInsertTabContext(ScDocument& rDoc, SCTAB nInsertPos, SCTAB nSheets) :
+    mrDoc(rDoc), mnInsertPos(nInsertPos), mnSheets(nSheets) {}
 
-RefUpdateDeleteTabContext::RefUpdateDeleteTabContext(SCTAB nDeletePos, SCTAB nSheets) :
-    mnDeletePos(nDeletePos), mnSheets(nSheets) {}
+RefUpdateDeleteTabContext::RefUpdateDeleteTabContext(ScDocument& rDoc, SCTAB nDeletePos, SCTAB nSheets) :
+    mrDoc(rDoc), mnDeletePos(nDeletePos), mnSheets(nSheets) {}
 
-RefUpdateMoveTabContext::RefUpdateMoveTabContext(SCTAB nOldPos, SCTAB nNewPos) :
-    mnOldPos(nOldPos), mnNewPos(nNewPos) {}
+RefUpdateMoveTabContext::RefUpdateMoveTabContext(ScDocument& rDoc, SCTAB nOldPos, SCTAB nNewPos) :
+    mrDoc(rDoc), mnOldPos(nOldPos), mnNewPos(nNewPos) {}
 
 SCTAB RefUpdateMoveTabContext::getNewTab(SCTAB nOldTab) const
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 1d2a0a6..9500a28 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -43,6 +43,7 @@
 #include "types.hxx"
 #include "globstr.hrc"
 #include "addincol.hxx"
+#include "dbdata.hxx"
 #include <svl/sharedstring.hxx>
 
 using ::std::vector;
@@ -2588,9 +2589,6 @@ bool expandRangeByEdge( const sc::RefUpdateContext& rCxt, ScRange& rRefRange, co
 
 bool isNameModified( const sc::UpdatedRangeNames& rUpdatedNames, SCTAB nOldTab, const formula::FormulaToken& rToken )
 {
-    if (rToken.GetOpCode() != ocName)
-        return false;
-
     SCTAB nTab = -1;
     if (!rToken.IsGlobal())
         nTab = nOldTab;
@@ -2599,6 +2597,16 @@ bool isNameModified( const sc::UpdatedRangeNames& rUpdatedNames, SCTAB nOldTab,
     return rUpdatedNames.isNameUpdated(nTab, rToken.GetIndex());
 }
 
+bool isDBDataModified( const ScDocument& rDoc, const formula::FormulaToken& rToken )
+{
+    // Check if this DBData has been modified.
+    const ScDBData* pDBData = rDoc.GetDBCollection()->getNamedDBs().findByIndex( rToken.GetIndex());
+    if (!pDBData)
+        return true;
+
+    return pDBData->IsModified();
+}
+
 }
 
 sc::RefUpdateResult ScTokenArray::AdjustReferenceOnShift( const sc::RefUpdateContext& rCxt, const ScAddress& rOldPos )
@@ -2737,7 +2745,8 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnShift( const sc::RefUpdateCon
             break;
             case svIndex:
             {
-                if (isNameModified(rCxt.maUpdatedNames, rOldPos.Tab(), **p))
+                if (((*p)->GetOpCode() == ocName && isNameModified(rCxt.maUpdatedNames, rOldPos.Tab(), **p)) ||
+                        ((*p)->GetOpCode() == ocDBArea && isDBDataModified(rCxt.mrDoc, **p)))
                     aRes.mbNameModified = true;
             }
             break;
@@ -2805,7 +2814,8 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMove(
             break;
             case svIndex:
             {
-                if (isNameModified(rCxt.maUpdatedNames, rOldPos.Tab(), **p))
+                if (((*p)->GetOpCode() == ocName && isNameModified(rCxt.maUpdatedNames, rOldPos.Tab(), **p)) ||
+                        ((*p)->GetOpCode() == ocDBArea && isDBDataModified(rCxt.mrDoc, **p)))
                     aRes.mbNameModified = true;
             }
             break;
@@ -2860,7 +2870,8 @@ sc::RefUpdateResult ScTokenArray::MoveReference( const ScAddress& rPos, const sc
             break;
             case svIndex:
             {
-                if (isNameModified(rCxt.maUpdatedNames, aOldRange.aStart.Tab(), **p))
+                if (((*p)->GetOpCode() == ocName && isNameModified(rCxt.maUpdatedNames, aOldRange.aStart.Tab(), **p)) ||
+                        ((*p)->GetOpCode() == ocDBArea && isDBDataModified(rCxt.mrDoc, **p)))
                     aRes.mbNameModified = true;
             }
             break;
@@ -3344,7 +3355,8 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnDeletedTab( sc::RefUpdateDele
             break;
             case svIndex:
             {
-                if (isNameModified(rCxt.maUpdatedNames, rOldPos.Tab(), **p))
+                if (((*p)->GetOpCode() == ocName && isNameModified(rCxt.maUpdatedNames, rOldPos.Tab(), **p)) ||
+                        ((*p)->GetOpCode() == ocDBArea && isDBDataModified(rCxt.mrDoc, **p)))
                     aRes.mbNameModified = true;
             }
             break;
@@ -3388,7 +3400,8 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnInsertedTab( sc::RefUpdateIns
             break;
             case svIndex:
             {
-                if (isNameModified(rCxt.maUpdatedNames, rOldPos.Tab(), **p))
+                if (((*p)->GetOpCode() == ocName && isNameModified(rCxt.maUpdatedNames, rOldPos.Tab(), **p)) ||
+                        ((*p)->GetOpCode() == ocDBArea && isDBDataModified(rCxt.mrDoc, **p)))
                     aRes.mbNameModified = true;
             }
             break;
@@ -3453,7 +3466,8 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMovedTab( sc::RefUpdateMoveTa
             break;
             case svIndex:
             {
-                if (isNameModified(rCxt.maUpdatedNames, rOldPos.Tab(), **p))
+                if (((*p)->GetOpCode() == ocName && isNameModified(rCxt.maUpdatedNames, rOldPos.Tab(), **p)) ||
+                        ((*p)->GetOpCode() == ocDBArea && isDBDataModified(rCxt.mrDoc, **p)))
                     aRes.mbNameModified = true;
             }
             break;


More information about the Libreoffice-commits mailing list