diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-05-18 17:09:26 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-05-18 17:36:46 +0200 |
commit | 726051277d90d0dfe384111d03b97835517bb69c (patch) | |
tree | 2f0275892a6d13d6d06280b50485a96d6ffbc248 /sc | |
parent | a78ee84360cd3bb9c806ceb8a5fc0794971334d4 (diff) |
update data bars correctly
Change-Id: Icddd688dbf5da8154dd470539b03b6a2d02ca755
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/colorscale.cxx | 65 |
1 files changed, 58 insertions, 7 deletions
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 975e6e9a92de..f9adede55ecb 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -416,15 +416,17 @@ Color* ScColorScaleFormat::GetColor( const ScAddress& rAddr ) const return new Color(aColor); } -void ScColorScaleFormat::UpdateMoveTab(SCTAB nOldTab, SCTAB nNewTab) +namespace { + +SCTAB UpdateMoveTabRangeList( ScRangeList& rList, SCTAB nOldTab, SCTAB nNewTab ) { - size_t n = maRanges.size(); + size_t n = rList.size(); SCTAB nMinTab = std::min<SCTAB>(nOldTab, nNewTab); SCTAB nMaxTab = std::max<SCTAB>(nOldTab, nNewTab); SCTAB nThisTab = -1; for(size_t i = 0; i < n; ++i) { - ScRange* pRange = maRanges[i]; + ScRange* pRange = rList[i]; SCTAB nTab = pRange->aStart.Tab(); if(nTab < nMinTab || nTab > nMaxTab) { @@ -456,6 +458,15 @@ void ScColorScaleFormat::UpdateMoveTab(SCTAB nOldTab, SCTAB nNewTab) if(nThisTab == -1) nThisTab = 0; + + return nThisTab; +} + +} + +void ScColorScaleFormat::UpdateMoveTab(SCTAB nOldTab, SCTAB nNewTab) +{ + SCTAB nThisTab = UpdateMoveTabRangeList(maRanges, nOldTab, nNewTab); for(iterator itr = begin(); itr != end(); ++itr) { itr->UpdateMoveTab(nOldTab, nNewTab, nThisTab); @@ -558,18 +569,58 @@ ScColorFormatType ScDataBarFormat::GetType() const return DATABAR; } -void ScDataBarFormat::UpdateReference( UpdateRefMode , - const ScRange& , SCsCOL , SCsROW , SCsTAB ) +void ScDataBarFormat::UpdateReference( UpdateRefMode eRefMode, + const ScRange& rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz ) +{ + maRanges.UpdateReference( eRefMode, mpDoc, rRange, nDx, nDy, nDz ); + + mpFormatData->mpUpperLimit->UpdateReference( eRefMode, rRange, nDx, nDy, nDz ); + mpFormatData->mpLowerLimit->UpdateReference( eRefMode, rRange, nDx, nDy, nDz ); +} + +namespace { + +bool NeedUpdate(ScColorScaleEntry* pEntry) { + if(pEntry->GetMin()) + return true; + + if(pEntry->GetMax()) + return true; + + if(pEntry->GetFormula()) + return true; + + return false; +} + } -void ScDataBarFormat::DataChanged(const ScRange& ) +void ScDataBarFormat::DataChanged(const ScRange& rRange) { + bool bNeedUpdate = false; + + bNeedUpdate = NeedUpdate(mpFormatData->mpUpperLimit.get()); + bNeedUpdate &= NeedUpdate(mpFormatData->mpLowerLimit.get()); + bNeedUpdate &= maRanges.Intersects(rRange); + + if(bNeedUpdate) + { + size_t n = maRanges.size(); + for(size_t i = 0; i < n; ++i) + { + ScRange* pRange = maRanges[i]; + mpDoc->RepaintRange(*pRange); + } + } } -void ScDataBarFormat::UpdateMoveTab(SCTAB , SCTAB ) +void ScDataBarFormat::UpdateMoveTab(SCTAB nOldTab, SCTAB nNewTab) { + SCTAB nThisTab = UpdateMoveTabRangeList(maRanges, nOldTab, nNewTab); + mpFormatData->mpUpperLimit->UpdateMoveTab(nOldTab, nNewTab, nThisTab); + mpFormatData->mpLowerLimit->UpdateMoveTab(nOldTab, nNewTab, nThisTab); } ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const |