[Libreoffice-commits] core.git: sc/inc sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Jul 13 23:58:31 UTC 2018
sc/inc/colorscale.hxx | 2
sc/inc/conditio.hxx | 5 ++
sc/source/core/data/colorscale.cxx | 72 ++++++++++++++++++++++++++++-----
sc/source/core/data/conditio.cxx | 5 ++
sc/source/filter/xml/xmlcondformat.cxx | 6 ++
sc/source/filter/xml/xmlcondformat.hxx | 2
6 files changed, 81 insertions(+), 11 deletions(-)
New commits:
commit 17722541e906cf64dcdd7169194aad72ec14bb10
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
AuthorDate: Tue Jul 10 00:16:00 2018 +0200
Commit: Markus Mohrhard <markus.mohrhard at googlemail.com>
CommitDate: Sat Jul 14 01:58:06 2018 +0200
tdf#117809, listen to the actual conditional format range if necessary
Change-Id: Ib83cf22e40f5e0338a3c85f631d30f00b80d8655
Reviewed-on: https://gerrit.libreoffice.org/57406
Tested-by: Jenkins
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index deab394229ea..13328ccf76b6 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -49,6 +49,8 @@ private:
ScColorScaleEntryType meType;
ScConditionalFormat* mpFormat;
+ void setListener();
+
public:
ScColorScaleEntry(double nVal, const Color& rCol);
ScColorScaleEntry();
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index 21a670053c11..31ca3531bf20 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -187,10 +187,12 @@ private:
std::function<void()> maCallbackFunction;
void startListening(const ScTokenArray* pTokens, const ScRange& rPos);
+ void startListening(const ScRangeList& rPos);
public:
explicit ScFormulaListener(ScFormulaCell* pCell);
explicit ScFormulaListener(ScDocument* pDoc);
+ explicit ScFormulaListener(ScDocument* pDoc, const ScRangeList& rRange);
virtual ~ScFormulaListener() override;
void Notify( const SfxHint& rHint ) override;
@@ -200,6 +202,7 @@ public:
void addTokenArray(const ScTokenArray* pTokens, const ScRange& rRange);
void stopListening();
void setCallback(const std::function<void()>& aCallbackFunction);
+
};
class ScConditionalFormat;
@@ -551,6 +554,8 @@ public:
bool IsEmpty() const;
size_t size() const;
+ ScDocument* GetDocument();
+
void CompileAll();
void CompileXML();
void UpdateReference( sc::RefUpdateContext& rCxt, bool bCopyAsMove = false );
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
index 4ea3606e48b8..e35083b639fe 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -36,6 +36,13 @@ ScFormulaListener::ScFormulaListener(ScDocument* pDoc):
{
}
+ScFormulaListener::ScFormulaListener(ScDocument* pDoc, const ScRangeList& rRange):
+ mbDirty(false),
+ mpDoc(pDoc)
+{
+ startListening(rRange);
+}
+
void ScFormulaListener::startListening(const ScTokenArray* pArr, const ScRange& rRange)
{
if (!pArr || mpDoc->IsClipOrUndo())
@@ -88,6 +95,19 @@ void ScFormulaListener::startListening(const ScTokenArray* pArr, const ScRange&
}
}
+void ScFormulaListener::startListening(const ScRangeList& rRange)
+{
+ if (mpDoc->IsClipOrUndo())
+ return;
+
+ size_t nLength = rRange.size();
+ for (size_t i = 0; i < nLength; ++i)
+ {
+ const ScRange& aRange = rRange[i];
+ mpDoc->StartListeningArea(aRange, false, this);
+ }
+}
+
void ScFormulaListener::addTokenArray(const ScTokenArray* pArray, const ScRange& rRange)
{
startListening(pArray, rRange);
@@ -150,6 +170,7 @@ ScColorScaleEntry::ScColorScaleEntry(const ScColorScaleEntry& rEntry):
meType(rEntry.meType),
mpFormat(rEntry.mpFormat)
{
+ setListener();
if(rEntry.mpCell)
{
mpCell.reset(new ScFormulaCell(*rEntry.mpCell, *rEntry.mpCell->GetDocument(), rEntry.mpCell->aPos, ScCloneFlags::NoMakeAbsExternal));
@@ -165,6 +186,7 @@ ScColorScaleEntry::ScColorScaleEntry(ScDocument* pDoc, const ScColorScaleEntry&
meType(rEntry.meType),
mpFormat(rEntry.mpFormat)
{
+ setListener();
if(rEntry.mpCell)
{
mpCell.reset(new ScFormulaCell(*rEntry.mpCell, *rEntry.mpCell->GetDocument(), rEntry.mpCell->aPos, ScCloneFlags::NoMakeAbsExternal));
@@ -229,12 +251,16 @@ void ScColorScaleEntry::SetValue(double nValue)
{
mnVal = nValue;
mpCell.reset();
+ setListener();
}
void ScColorScaleEntry::UpdateReference( const sc::RefUpdateContext& rCxt )
{
if (!mpCell)
+ {
+ setListener();
return;
+ }
mpCell->UpdateReference(rCxt);
mpListener.reset(new ScFormulaListener(mpCell.get()));
@@ -244,7 +270,10 @@ void ScColorScaleEntry::UpdateReference( const sc::RefUpdateContext& rCxt )
void ScColorScaleEntry::UpdateInsertTab( const sc::RefUpdateInsertTabContext& rCxt )
{
if (!mpCell)
+ {
+ setListener();
return;
+ }
mpCell->UpdateInsertTab(rCxt);
mpListener.reset(new ScFormulaListener(mpCell.get()));
@@ -254,7 +283,10 @@ void ScColorScaleEntry::UpdateInsertTab( const sc::RefUpdateInsertTabContext& rC
void ScColorScaleEntry::UpdateDeleteTab( const sc::RefUpdateDeleteTabContext& rCxt )
{
if (!mpCell)
+ {
+ setListener();
return;
+ }
mpCell->UpdateDeleteTab(rCxt);
mpListener.reset(new ScFormulaListener(mpCell.get()));
@@ -264,7 +296,10 @@ void ScColorScaleEntry::UpdateDeleteTab( const sc::RefUpdateDeleteTabContext& rC
void ScColorScaleEntry::UpdateMoveTab( const sc::RefUpdateMoveTabContext& rCxt )
{
if (!mpCell)
+ {
+ setListener();
return;
+ }
SCTAB nTabNo = rCxt.getNewTab(mpCell->aPos.Tab());
mpCell->UpdateMoveTab(rCxt, nTabNo);
@@ -280,10 +315,37 @@ void ScColorScaleEntry::SetColor(const Color& rColor)
void ScColorScaleEntry::SetRepaintCallback(ScConditionalFormat* pFormat)
{
mpFormat = pFormat;
+ setListener();
if (mpFormat && mpListener)
mpListener->setCallback([&]() { mpFormat->DoRepaint();});
}
+void ScColorScaleEntry::SetType( ScColorScaleEntryType eType )
+{
+ meType = eType;
+ if(eType != COLORSCALE_FORMULA)
+ {
+ mpCell.reset();
+ mpListener.reset();
+ }
+
+ setListener();
+}
+
+void ScColorScaleEntry::setListener()
+{
+ if (!mpFormat)
+ return;
+
+ if (meType == COLORSCALE_PERCENT || meType == COLORSCALE_PERCENTILE
+ || meType == COLORSCALE_MIN || meType == COLORSCALE_MAX
+ || meType == COLORSCALE_AUTO)
+ {
+ mpListener.reset(new ScFormulaListener(mpFormat->GetDocument(), mpFormat->GetRange()));
+ mpListener->setCallback([&]() { mpFormat->DoRepaint();});
+ }
+}
+
ScColorFormat::ScColorFormat(ScDocument* pDoc)
: ScFormatEntry(pDoc)
, mpParent(nullptr)
@@ -337,16 +399,6 @@ void ScColorScaleFormat::AddEntry( ScColorScaleEntry* pEntry )
maColorScales.back()->SetRepaintCallback(mpParent);
}
-void ScColorScaleEntry::SetType( ScColorScaleEntryType eType )
-{
- meType = eType;
- if(eType != COLORSCALE_FORMULA)
- {
- mpCell.reset();
- mpListener.reset();
- }
-}
-
double ScColorScaleFormat::GetMinValue() const
{
ScColorScaleEntries::const_iterator itr = maColorScales.begin();
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 4e93415542cf..018d9757c058 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -1778,6 +1778,11 @@ size_t ScConditionalFormat::size() const
return maEntries.size();
}
+ScDocument* ScConditionalFormat::GetDocument()
+{
+ return pDoc;
+}
+
ScConditionalFormat::~ScConditionalFormat()
{
}
diff --git a/sc/source/filter/xml/xmlcondformat.cxx b/sc/source/filter/xml/xmlcondformat.cxx
index deb34ec4e596..10ff5eda5de7 100644
--- a/sc/source/filter/xml/xmlcondformat.cxx
+++ b/sc/source/filter/xml/xmlcondformat.cxx
@@ -398,6 +398,7 @@ ScXMLDataBarFormatContext::ScXMLDataBarFormatContext( ScXMLImport& rImport,
ScConditionalFormat* pFormat):
ScXMLImportContext( rImport ),
mpFormatData(nullptr),
+ mpParent(pFormat),
mnIndex(0)
{
OUString sPositiveColor;
@@ -521,6 +522,7 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL ScXMLDataBarF
{
ScColorScaleEntry* pEntry(nullptr);
pContext = new ScXMLFormattingEntryContext( GetScImport(), pAttribList, pEntry );
+ pEntry->SetRepaintCallback(mpParent);
if(mnIndex == 0)
{
mpFormatData->mpLowerLimit.reset(pEntry);
@@ -547,7 +549,8 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL ScXMLDataBarF
ScXMLIconSetFormatContext::ScXMLIconSetFormatContext(ScXMLImport& rImport,
const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
ScConditionalFormat* pFormat):
- ScXMLImportContext( rImport )
+ ScXMLImportContext( rImport ),
+ mpParent(pFormat)
{
OUString aIconSetType, sShowValue;
if ( rAttrList.is() )
@@ -611,6 +614,7 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL ScXMLIconSetF
ScColorScaleEntry* pEntry(nullptr);
pContext = new ScXMLFormattingEntryContext( GetScImport(), pAttribList, pEntry );
mpFormatData->m_Entries.push_back(std::unique_ptr<ScColorScaleEntry>(pEntry));
+ pEntry->SetRepaintCallback(mpParent);
}
break;
default:
diff --git a/sc/source/filter/xml/xmlcondformat.hxx b/sc/source/filter/xml/xmlcondformat.hxx
index 35d9c9ef8518..3281ac7ae3f3 100644
--- a/sc/source/filter/xml/xmlcondformat.hxx
+++ b/sc/source/filter/xml/xmlcondformat.hxx
@@ -102,6 +102,7 @@ public:
private:
ScDataBarFormatData* mpFormatData;
+ ScConditionalFormat* mpParent;
sal_Int32 mnIndex;
};
@@ -109,6 +110,7 @@ private:
class ScXMLIconSetFormatContext : public ScXMLImportContext
{
ScIconSetFormatData* mpFormatData;
+ ScConditionalFormat* mpParent;
public:
ScXMLIconSetFormatContext( ScXMLImport& rImport,
More information about the Libreoffice-commits
mailing list