Kaydet (Commit) d74fd920 authored tarafından Eike Rathke's avatar Eike Rathke Kaydeden (comit) Andras Timar

introduce ScRefUpdateRes UR_STICKY

Some callers of ScRefUpdate::Update() rely on a return value
!=UR_NOTHING if rows or columns are inserted or deleted or moved, so
simply ignoring the entire columns/rows cases is not possible even if
the ranges actually don't change. Instead, return UR_STICKY that may
allow to further differentiate in future.

Change-Id: Iba6c1e5eb1a33d39ef677ef1de2f2d296bf504f1
(cherry picked from commit 9a21a20f)
üst 5f44bcaa
...@@ -1069,7 +1069,8 @@ void ScBroadcastAreaSlotMachine::UpdateBroadcastAreas( ...@@ -1069,7 +1069,8 @@ void ScBroadcastAreaSlotMachine::UpdateBroadcastAreas(
{ {
aRange = ScRange( theCol1,theRow1,theTab1, theCol2,theRow2,theTab2 ); aRange = ScRange( theCol1,theRow1,theTab1, theCol2,theRow2,theTab2 );
pArea->UpdateRange( aRange ); pArea->UpdateRange( aRange );
pArea->GetBroadcaster().Broadcast( ScAreaChangedHint( aRange ) ); // for DDE // For DDE and ScLookupCache
pArea->GetBroadcaster().Broadcast( ScAreaChangedHint( aRange ) );
} }
// insert to slots // insert to slots
......
...@@ -31,7 +31,12 @@ class ScRange; ...@@ -31,7 +31,12 @@ class ScRange;
enum ScRefUpdateRes { enum ScRefUpdateRes {
UR_NOTHING = 0, // keine Anpassungen UR_NOTHING = 0, // keine Anpassungen
UR_UPDATED = 1, // Anpassungen erfolgt UR_UPDATED = 1, // Anpassungen erfolgt
UR_INVALID = 2 // Referenz wurde ungueltig UR_INVALID = 2, // Referenz wurde ungueltig
UR_STICKY = 3 /**< Not updated because the reference is sticky,
but would had been updated if it wasn't. For
entire columns/rows. Essentially the same as
not UR_NOTHING for the caller but allows
differentiation. */
}; };
class ScRefUpdate class ScRefUpdate
......
...@@ -111,7 +111,7 @@ void ScLookupCache::Notify( const SfxHint& rHint ) ...@@ -111,7 +111,7 @@ void ScLookupCache::Notify( const SfxHint& rHint )
if (!mpDoc->IsInDtorClear()) if (!mpDoc->IsInDtorClear())
{ {
const ScHint* p = dynamic_cast<const ScHint*>(&rHint); const ScHint* p = dynamic_cast<const ScHint*>(&rHint);
if (p && (p->GetId() & SC_HINT_DATACHANGED)) if ((p && (p->GetId() & SC_HINT_DATACHANGED)) || dynamic_cast<const ScAreaChangedHint*>(&rHint))
{ {
mpDoc->RemoveLookupCache( *this); mpDoc->RemoveLookupCache( *this);
delete this; delete this;
......
...@@ -208,8 +208,7 @@ ScRefUpdateRes ScRefUpdate::Update( ScDocument* pDoc, UpdateRefMode eUpdateRefMo ...@@ -208,8 +208,7 @@ ScRefUpdateRes ScRefUpdate::Update( ScDocument* pDoc, UpdateRefMode eUpdateRefMo
{ {
bool bExpand = pDoc->IsExpandRefs(); bool bExpand = pDoc->IsExpandRefs();
if ( nDx && (theRow1 >= nRow1) && (theRow2 <= nRow2) && if ( nDx && (theRow1 >= nRow1) && (theRow2 <= nRow2) &&
(theTab1 >= nTab1) && (theTab2 <= nTab2) && (theTab1 >= nTab1) && (theTab2 <= nTab2))
!(theCol1 == 0 && theCol2 == MAXCOL) )
{ {
bool bExp = (bExpand && IsExpand( theCol1, theCol2, nCol1, nDx )); bool bExp = (bExpand && IsExpand( theCol1, theCol2, nCol1, nDx ));
bCut1 = lcl_MoveStart( theCol1, nCol1, nDx, MAXCOL ); bCut1 = lcl_MoveStart( theCol1, nCol1, nDx, MAXCOL );
...@@ -226,10 +225,15 @@ ScRefUpdateRes ScRefUpdate::Update( ScDocument* pDoc, UpdateRefMode eUpdateRefMo ...@@ -226,10 +225,15 @@ ScRefUpdateRes ScRefUpdate::Update( ScDocument* pDoc, UpdateRefMode eUpdateRefMo
Expand( theCol1, theCol2, nCol1, nDx ); Expand( theCol1, theCol2, nCol1, nDx );
eRet = UR_UPDATED; eRet = UR_UPDATED;
} }
if (eRet != UR_NOTHING && oldCol1 == 0 && oldCol2 == MAXCOL)
{
eRet = UR_STICKY;
theCol1 = oldCol1;
theCol2 = oldCol2;
}
} }
if ( nDy && (theCol1 >= nCol1) && (theCol2 <= nCol2) && if ( nDy && (theCol1 >= nCol1) && (theCol2 <= nCol2) &&
(theTab1 >= nTab1) && (theTab2 <= nTab2) && (theTab1 >= nTab1) && (theTab2 <= nTab2))
!(theRow1 == 0 && theRow2 == MAXROW) )
{ {
bool bExp = (bExpand && IsExpand( theRow1, theRow2, nRow1, nDy )); bool bExp = (bExpand && IsExpand( theRow1, theRow2, nRow1, nDy ));
bCut1 = lcl_MoveStart( theRow1, nRow1, nDy, MAXROW ); bCut1 = lcl_MoveStart( theRow1, nRow1, nDy, MAXROW );
...@@ -246,6 +250,12 @@ ScRefUpdateRes ScRefUpdate::Update( ScDocument* pDoc, UpdateRefMode eUpdateRefMo ...@@ -246,6 +250,12 @@ ScRefUpdateRes ScRefUpdate::Update( ScDocument* pDoc, UpdateRefMode eUpdateRefMo
Expand( theRow1, theRow2, nRow1, nDy ); Expand( theRow1, theRow2, nRow1, nDy );
eRet = UR_UPDATED; eRet = UR_UPDATED;
} }
if (eRet != UR_NOTHING && oldRow1 == 0 && oldRow2 == MAXROW)
{
eRet = UR_STICKY;
theRow1 = oldRow1;
theRow2 = oldRow2;
}
} }
if ( nDz && (theCol1 >= nCol1) && (theCol2 <= nCol2) && if ( nDz && (theCol1 >= nCol1) && (theCol2 <= nCol2) &&
(theRow1 >= nRow1) && (theRow2 <= nRow2) ) (theRow1 >= nRow1) && (theRow2 <= nRow2) )
...@@ -274,19 +284,31 @@ ScRefUpdateRes ScRefUpdate::Update( ScDocument* pDoc, UpdateRefMode eUpdateRefMo ...@@ -274,19 +284,31 @@ ScRefUpdateRes ScRefUpdate::Update( ScDocument* pDoc, UpdateRefMode eUpdateRefMo
if ((theCol1 >= nCol1-nDx) && (theRow1 >= nRow1-nDy) && (theTab1 >= nTab1-nDz) && if ((theCol1 >= nCol1-nDx) && (theRow1 >= nRow1-nDy) && (theTab1 >= nTab1-nDz) &&
(theCol2 <= nCol2-nDx) && (theRow2 <= nRow2-nDy) && (theTab2 <= nTab2-nDz)) (theCol2 <= nCol2-nDx) && (theRow2 <= nRow2-nDy) && (theTab2 <= nTab2-nDz))
{ {
if ( nDx && !(theCol1 == 0 && theCol2 == MAXCOL) ) if ( nDx )
{ {
bCut1 = lcl_MoveItCut( theCol1, nDx, MAXCOL ); bCut1 = lcl_MoveItCut( theCol1, nDx, MAXCOL );
bCut2 = lcl_MoveItCut( theCol2, nDx, MAXCOL ); bCut2 = lcl_MoveItCut( theCol2, nDx, MAXCOL );
if ( bCut1 || bCut2 ) if ( bCut1 || bCut2 )
eRet = UR_UPDATED; eRet = UR_UPDATED;
if (eRet != UR_NOTHING && oldCol1 == 0 && oldCol2 == MAXCOL)
{
eRet = UR_STICKY;
theCol1 = oldCol1;
theCol2 = oldCol2;
}
} }
if ( nDy && !(theRow1 == 0 && theRow2 == MAXROW) ) if ( nDy )
{ {
bCut1 = lcl_MoveItCut( theRow1, nDy, MAXROW ); bCut1 = lcl_MoveItCut( theRow1, nDy, MAXROW );
bCut2 = lcl_MoveItCut( theRow2, nDy, MAXROW ); bCut2 = lcl_MoveItCut( theRow2, nDy, MAXROW );
if ( bCut1 || bCut2 ) if ( bCut1 || bCut2 )
eRet = UR_UPDATED; eRet = UR_UPDATED;
if (eRet != UR_NOTHING && oldRow1 == 0 && oldRow2 == MAXROW)
{
eRet = UR_STICKY;
theRow1 = oldRow1;
theRow2 = oldRow2;
}
} }
if ( nDz ) if ( nDz )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment