[Libreoffice-commits] .: 3 commits - sc/inc sc/source
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Thu May 10 16:23:10 PDT 2012
sc/inc/colorscale.hxx | 7 +++
sc/source/core/data/colorscale.cxx | 80 ++++++++++++++++++++++++++++++++++++-
sc/source/core/data/documen2.cxx | 2
sc/source/core/data/documen7.cxx | 12 +++++
4 files changed, 99 insertions(+), 2 deletions(-)
New commits:
commit 2d74e6c122c4d07d86873e3a8d69d0fdc2361e31
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri May 11 01:17:56 2012 +0200
update the color scales when moving tabs
Change-Id: Iabeeae6d2c31f983ea04652dce81e448a7623472
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index 4f61f57..a34c50c 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 4e5d963..c14251d 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 a64162e..605f9cd 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 )
commit 3b992e247eba57ed3ebc08861e0cd85b52144e94
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri May 11 00:15:32 2012 +0200
repaint color scale range if min/max changed
Change-Id: Id9a8479d286e50756c41fbd948d738a0c8d8c883
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index b71c38b..4f61f57 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 42b7f3c..4e5d963 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 0826ea6..3d28152 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);
+ }
}
commit a1b1c1ebbfab5883c707b31dbfbbbbe338ed4833
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu May 10 21:29:48 2012 +0200
calculate color for color scales with more than 2 entries correctly
Change-Id: I5b62644df8742939551c1aaeaae1ebeda9b97f63
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
index 3cc0e5a..42b7f3c 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -297,13 +297,12 @@ Color* ScColorScaleFormat::GetColor( const ScAddress& rAddr ) const
Color rColMax = itr->GetColor();
++itr;
- while(itr != end() && nVal > nValMin)
+ while(itr != end() && nVal > nValMax)
{
rColMin = rColMax;
nValMin = nValMax;
rColMax = itr->GetColor();
nValMax = CalcValue(nMin, nMax, itr);
- nValMax = itr->GetValue();
++itr;
}
More information about the Libreoffice-commits
mailing list