summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-05-11 01:17:56 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-05-11 01:20:02 +0200
commit2d74e6c122c4d07d86873e3a8d69d0fdc2361e31 (patch)
tree5ff971bbfbbcfae41bb9701f6e7dbfa30900118c
parent3b992e247eba57ed3ebc08861e0cd85b52144e94 (diff)
update the color scales when moving tabs
Change-Id: Iabeeae6d2c31f983ea04652dce81e448a7623472
-rw-r--r--sc/inc/colorscale.hxx2
-rw-r--r--sc/source/core/data/colorscale.cxx40
-rw-r--r--sc/source/core/data/documen2.cxx2
3 files changed, 44 insertions, 0 deletions
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index 4f61f57de6f4..a34c50cc5705 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -79,6 +79,7 @@ public:
void SetRange(const ScRangeList& rList);
void DataChanged(const ScRange& rRange);
+ void UpdateMoveTab(SCTAB nOldTab, SCTAB nNewTab);
typedef ColorScaleEntries::iterator iterator;
typedef ColorScaleEntries::const_iterator const_iterator;
@@ -103,6 +104,7 @@ public:
void AddFormat( ScColorScaleFormat* pFormat );
void DataChanged(const ScRange& rRange);
+ void UpdateMoveTab(SCTAB nOldTab, SCTAB nNewTab);
iterator begin();
const_iterator begin() const;
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
index 4e5d963cc912..c14251da585a 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -311,6 +311,38 @@ Color* ScColorScaleFormat::GetColor( const ScAddress& rAddr ) const
return new Color(aColor);
}
+void ScColorScaleFormat::UpdateMoveTab(SCTAB nOldTab, SCTAB nNewTab)
+{
+ size_t n = maRanges.size();
+ SCTAB nMinTab = std::min<SCTAB>(nOldTab, nNewTab);
+ SCTAB nMaxTab = std::max<SCTAB>(nOldTab, nNewTab);
+ for(size_t i = 0; i < n; ++i)
+ {
+ ScRange* pRange = maRanges[i];
+ SCTAB nTab = pRange->aStart.Tab();
+ if(nTab < nMinTab || nTab > nMaxTab)
+ continue;
+
+ if(nTab == nOldTab)
+ {
+ pRange->aStart.SetTab(nNewTab);
+ pRange->aEnd.SetTab(nNewTab);
+ continue;
+ }
+
+ if(nNewTab < nOldTab)
+ {
+ pRange->aStart.IncTab();
+ pRange->aEnd.IncTab();
+ }
+ else
+ {
+ pRange->aStart.IncTab(-1);
+ pRange->aEnd.IncTab(-1);
+ }
+ }
+}
+
bool ScColorScaleFormat::CheckEntriesForRel(const ScRange& rRange) const
{
bool bNeedUpdate = false;
@@ -407,4 +439,12 @@ void ScColorScaleFormatList::DataChanged(const ScRange& rRange)
}
}
+void ScColorScaleFormatList::UpdateMoveTab(SCTAB nOldTab, SCTAB nNewTab)
+{
+ for(iterator itr = begin(); itr != end(); ++itr)
+ {
+ itr->UpdateMoveTab(nOldTab, nNewTab);
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index a64162e9de68..605f9cd751c4 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -753,6 +753,8 @@ bool ScDocument::MoveTab( SCTAB nOldPos, SCTAB nNewPos, ScProgress* pProgress )
UpdateRefAreaLinks( URM_REORDER, aSourceRange, 0,0,nDz );
if ( pCondFormList )
pCondFormList->UpdateMoveTab( nOldPos, nNewPos );
+ if ( mpColorScaleList )
+ mpColorScaleList->UpdateMoveTab( nOldPos, nNewPos );
if ( pValidationList )
pValidationList->UpdateMoveTab( nOldPos, nNewPos );
if ( pUnoBroadcaster )