summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/inc/refupdatecontext.hxx9
-rw-r--r--sc/source/core/data/documen2.cxx4
-rw-r--r--sc/source/core/data/document.cxx8
-rw-r--r--sc/source/core/data/refupdatecontext.cxx12
-rw-r--r--sc/source/core/tool/token.cxx32
5 files changed, 41 insertions, 24 deletions
diff --git a/sc/inc/refupdatecontext.hxx b/sc/inc/refupdatecontext.hxx
index 1de44a612f02..bee194c457e8 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 01721b6b0616..eeec6efdfaef 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -729,7 +729,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 );
@@ -802,7 +802,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 f9c378483c6c..c445d63fcd62 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -492,7 +492,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 052ab74dd3f7..07cb0602e060 100644
--- a/sc/source/core/data/refupdatecontext.cxx
+++ b/sc/source/core/data/refupdatecontext.cxx
@@ -62,14 +62,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 964566351fd9..67d45da01c2d 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 <reordermap.hxx>
#include <svl/sharedstring.hxx>
@@ -2670,9 +2671,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;
@@ -2681,6 +2679,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 false;
+
+ return pDBData->IsModified();
+}
+
}
sc::RefUpdateResult ScTokenArray::AdjustReferenceOnShift( const sc::RefUpdateContext& rCxt, const ScAddress& rOldPos )
@@ -2819,7 +2827,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;
@@ -2887,7 +2896,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;
@@ -2942,7 +2952,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;
@@ -3458,7 +3469,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;
@@ -3502,7 +3514,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;
@@ -3567,7 +3580,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;