Kaydet (Commit) 3b992e24 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

repaint color scale range if min/max changed

Change-Id: Id9a8479d286e50756c41fbd948d738a0c8d8c883
üst a1b1c1eb
......@@ -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();
......
......@@ -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: */
......@@ -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);
}
}
......
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