diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-05-11 00:15:32 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-05-11 01:20:02 +0200 |
commit | 3b992e247eba57ed3ebc08861e0cd85b52144e94 (patch) | |
tree | 1b7747c7e003eaeda5cb2a77cf4f7ad8b1f14892 | |
parent | a1b1c1ebbfab5883c707b31dbfbbbbe338ed4833 (diff) |
repaint color scale range if min/max changed
Change-Id: Id9a8479d286e50756c41fbd948d738a0c8d8c883
-rw-r--r-- | sc/inc/colorscale.hxx | 5 | ||||
-rw-r--r-- | sc/source/core/data/colorscale.cxx | 37 | ||||
-rw-r--r-- | sc/source/core/data/documen7.cxx | 12 |
3 files changed, 54 insertions, 0 deletions
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx index b71c38b87845..4f61f57de6f4 100644 --- a/sc/inc/colorscale.hxx +++ b/sc/inc/colorscale.hxx @@ -70,6 +70,7 @@ private: double GetMaxValue() const; void calcMinMax(double& nMin, double& nMax) const; + bool CheckEntriesForRel(const ScRange& rRange) const; public: ScColorScaleFormat(ScDocument* pDoc); @@ -77,6 +78,8 @@ public: void AddEntry(ScColorScaleEntry* pEntry); void SetRange(const ScRangeList& rList); + void DataChanged(const ScRange& rRange); + typedef ColorScaleEntries::iterator iterator; typedef ColorScaleEntries::const_iterator const_iterator; iterator begin(); @@ -99,6 +102,8 @@ public: ScColorScaleFormat* GetFormat(sal_uInt32 nFormat); void AddFormat( ScColorScaleFormat* pFormat ); + void DataChanged(const ScRange& rRange); + iterator begin(); const_iterator begin() const; iterator end(); diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 42b7f3cfbb05..4e5d963cc912 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -311,6 +311,35 @@ Color* ScColorScaleFormat::GetColor( const ScAddress& rAddr ) const return new Color(aColor); } +bool ScColorScaleFormat::CheckEntriesForRel(const ScRange& rRange) const +{ + bool bNeedUpdate = false; + for(const_iterator itr = begin(); itr != end(); ++itr) + { + if(itr->GetMin() || itr->GetMax()) + bNeedUpdate = true; + } + + // TODO: check also if the changed value is the new min/max + // or has been the old min/max value + bNeedUpdate = bNeedUpdate && maRanges.Intersects(rRange); + return bNeedUpdate; +} + +void ScColorScaleFormat::DataChanged(const ScRange& rRange) +{ + bool bNeedUpdate = CheckEntriesForRel(rRange); + if(bNeedUpdate) + { + size_t n = maRanges.size(); + for(size_t i = 0; i < n; ++i) + { + ScRange* pRange = maRanges[i]; + mpDoc->RepaintRange(*pRange); + } + } +} + ScColorScaleFormat::iterator ScColorScaleFormat::begin() { return maColorScales.begin(); @@ -370,4 +399,12 @@ size_t ScColorScaleFormatList::size() const return maColorScaleFormats.size(); } +void ScColorScaleFormatList::DataChanged(const ScRange& rRange) +{ + for(iterator itr = begin(); itr != end(); ++itr) + { + itr->DataChanged(rRange); + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx index 0826ea6e0cba..3d2815211d51 100644 --- a/sc/source/core/data/documen7.cxx +++ b/sc/source/core/data/documen7.cxx @@ -44,6 +44,7 @@ #include "scmod.hxx" // SC_MOD #include "inputopt.hxx" // GetExpandRefs #include "conditio.hxx" +#include "colorscale.hxx" #include "sheetevents.hxx" #include <tools/shl.hxx> @@ -111,6 +112,9 @@ void ScDocument::Broadcast( const ScHint& rHint ) if ( pCondFormList && rHint.GetAddress() != BCA_BRDCST_ALWAYS ) pCondFormList->SourceChanged( rHint.GetAddress() ); + if( mpColorScaleList && rHint.GetAddress() != BCA_BRDCST_ALWAYS ) + mpColorScaleList->DataChanged( rHint.GetAddress() ); + if ( rHint.GetAddress() != BCA_BRDCST_ALWAYS ) { SCTAB nTab = rHint.GetAddress().Tab(); @@ -134,6 +138,9 @@ void ScDocument::AreaBroadcast( const ScHint& rHint ) // Repaint fuer bedingte Formate mit relativen Referenzen: if ( pCondFormList && rHint.GetAddress() != BCA_BRDCST_ALWAYS ) pCondFormList->SourceChanged( rHint.GetAddress() ); + + if( mpColorScaleList && rHint.GetAddress() != BCA_BRDCST_ALWAYS ) + mpColorScaleList->DataChanged( rHint.GetAddress() ); } @@ -177,6 +184,11 @@ void ScDocument::AreaBroadcastInRange( const ScRange& rRange, const ScHint& rHin } } } + + if(mpColorScaleList) + { + mpColorScaleList->DataChanged(rRange); + } } |