diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-03-16 22:43:43 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-06-28 04:33:10 +0200 |
commit | 49922897d68835ae4e5c850b3c55107157fe7548 (patch) | |
tree | f42918f443d9ccfe6d711e88c89ecd10f19de127 /sc/source/core/data/colorscale.cxx | |
parent | 669c12d59b6131f44945f166c77ae98df52ebb9e (diff) |
repaint whole range for range based cond formats, tdf#105696
The range based cond formats need to be repainted across the whole
range. This ensures that a change in condition which affects all cells
causes a repaint.
Change-Id: Ie6dd10088a1c11c1bafd1faa9c429a35a6469ff2
Reviewed-on: https://gerrit.libreoffice.org/35302
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sc/source/core/data/colorscale.cxx')
-rw-r--r-- | sc/source/core/data/colorscale.cxx | 65 |
1 files changed, 60 insertions, 5 deletions
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 25a029024e28..4bc29e669006 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -155,21 +155,24 @@ bool ScFormulaListener::NeedsRepaint() const ScColorScaleEntry::ScColorScaleEntry(): mnVal(0), - meType(COLORSCALE_VALUE) + meType(COLORSCALE_VALUE), + mpFormat(nullptr) { } ScColorScaleEntry::ScColorScaleEntry(double nVal, const Color& rCol): mnVal(nVal), maColor(rCol), - meType(COLORSCALE_VALUE) + meType(COLORSCALE_VALUE), + mpFormat(nullptr) { } ScColorScaleEntry::ScColorScaleEntry(const ScColorScaleEntry& rEntry): mnVal(rEntry.mnVal), maColor(rEntry.maColor), - meType(rEntry.meType) + meType(rEntry.meType), + mpFormat(rEntry.mpFormat) { if(rEntry.mpCell) { @@ -183,13 +186,16 @@ ScColorScaleEntry::ScColorScaleEntry(ScDocument* pDoc, const ScColorScaleEntry& mnVal(rEntry.mnVal), maColor(rEntry.maColor), mpCell(), - meType(rEntry.meType) + meType(rEntry.meType), + mpFormat(rEntry.mpFormat) { if(rEntry.mpCell) { mpCell.reset(new ScFormulaCell(*rEntry.mpCell, *rEntry.mpCell->GetDocument(), rEntry.mpCell->aPos, ScCloneFlags::NoMakeAbsExternal)); mpCell->StartListeningTo( pDoc ); mpListener.reset(new ScFormulaListener(mpCell.get())); + if (mpFormat) + mpListener->setCallback([&]() { mpFormat->DoRepaint();}); } } @@ -204,6 +210,8 @@ void ScColorScaleEntry::SetFormula( const OUString& rFormula, ScDocument* pDoc, mpCell.reset(new ScFormulaCell( pDoc, rAddr, rFormula, eGrammar )); mpCell->StartListeningTo( pDoc ); mpListener.reset(new ScFormulaListener(mpCell.get())); + if (mpFormat) + mpListener->setCallback([&]() { mpFormat->DoRepaint();}); } const ScTokenArray* ScColorScaleEntry::GetFormula() const @@ -254,6 +262,7 @@ void ScColorScaleEntry::UpdateReference( sc::RefUpdateContext& rCxt ) mpCell->UpdateReference(rCxt); mpListener.reset(new ScFormulaListener(mpCell.get())); + SetRepaintCallback(mpFormat); } void ScColorScaleEntry::UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt ) @@ -263,6 +272,7 @@ void ScColorScaleEntry::UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt ) mpCell->UpdateInsertTab(rCxt); mpListener.reset(new ScFormulaListener(mpCell.get())); + SetRepaintCallback(mpFormat); } void ScColorScaleEntry::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) @@ -272,6 +282,7 @@ void ScColorScaleEntry::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) mpCell->UpdateDeleteTab(rCxt); mpListener.reset(new ScFormulaListener(mpCell.get())); + SetRepaintCallback(mpFormat); } void ScColorScaleEntry::UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt ) @@ -282,6 +293,7 @@ void ScColorScaleEntry::UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt ) SCTAB nTabNo = rCxt.getNewTab(mpCell->aPos.Tab()); mpCell->UpdateMoveTab(rCxt, nTabNo); mpListener.reset(new ScFormulaListener(mpCell.get())); + SetRepaintCallback(mpFormat); } void ScColorScaleEntry::SetColor(const Color& rColor) @@ -289,6 +301,13 @@ void ScColorScaleEntry::SetColor(const Color& rColor) maColor = rColor; } +void ScColorScaleEntry::SetRepaintCallback(ScConditionalFormat* pFormat) +{ + mpFormat = pFormat; + if (mpFormat && mpListener) + mpListener->setCallback([&]() { mpFormat->DoRepaint();}); +} + ScColorFormat::ScColorFormat(ScDocument* pDoc) : ScFormatEntry(pDoc) , mpParent(nullptr) @@ -327,9 +346,19 @@ ScColorScaleFormat::~ScColorScaleFormat() { } +void ScColorScaleFormat::SetParent(ScConditionalFormat* pFormat) +{ + for (auto itr = begin(), itrEnd = end(); itr != itrEnd; ++itr) + { + (*itr)->SetRepaintCallback(pFormat); + } + ScColorFormat::SetParent(pFormat); +} + void ScColorScaleFormat::AddEntry( ScColorScaleEntry* pEntry ) { maColorScales.push_back(std::unique_ptr<ScColorScaleEntry>( pEntry )); + maColorScales.back()->SetRepaintCallback(mpParent); } void ScColorScaleEntry::SetType( ScColorScaleEntryType eType ) @@ -644,7 +673,8 @@ void ScColorScaleFormat::EnsureSize() } ScDataBarFormat::ScDataBarFormat(ScDocument* pDoc): - ScColorFormat(pDoc) + ScColorFormat(pDoc), + mpFormatData(new ScDataBarFormatData()) { } @@ -657,6 +687,11 @@ ScDataBarFormat::ScDataBarFormat(ScDocument* pDoc, const ScDataBarFormat& rForma void ScDataBarFormat::SetDataBarData( ScDataBarFormatData* pData ) { mpFormatData.reset(pData); + if (mpParent) + { + mpFormatData->mpUpperLimit->SetRepaintCallback(mpParent); + mpFormatData->mpLowerLimit->SetRepaintCallback(mpParent); + } } ScDataBarFormatData* ScDataBarFormat::GetDataBarData() @@ -674,6 +709,16 @@ ScColorFormat* ScDataBarFormat::Clone(ScDocument* pDoc) const return new ScDataBarFormat(pDoc, *this); } +void ScDataBarFormat::SetParent(ScConditionalFormat* pFormat) +{ + if (mpFormatData) + { + mpFormatData->mpUpperLimit->SetRepaintCallback(pFormat); + mpFormatData->mpLowerLimit->SetRepaintCallback(pFormat); + } + ScColorFormat::SetParent(pFormat); +} + condformat::ScFormatEntryType ScDataBarFormat::GetType() const { return condformat::DATABAR; @@ -920,9 +965,19 @@ ScColorFormat* ScIconSetFormat::Clone( ScDocument* pDoc ) const return new ScIconSetFormat(pDoc, *this); } +void ScIconSetFormat::SetParent(ScConditionalFormat* pFormat) +{ + for(iterator itr = begin(); itr != end(); ++itr) + { + (*itr)->SetRepaintCallback(pFormat); + } + ScColorFormat::SetParent(pFormat); +} + void ScIconSetFormat::SetIconSetData( ScIconSetFormatData* pFormatData ) { mpFormatData.reset( pFormatData ); + SetParent(mpParent); } ScIconSetFormatData* ScIconSetFormat::GetIconSetData() |