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

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: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst 771149ac
......@@ -49,6 +49,8 @@ private:
ScColorScaleEntryType meType;
ScConditionalFormat* mpFormat;
void setListener();
public:
ScColorScaleEntry(double nVal, const Color& rCol);
ScColorScaleEntry();
......
......@@ -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 );
......
......@@ -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();
......
......@@ -1778,6 +1778,11 @@ size_t ScConditionalFormat::size() const
return maEntries.size();
}
ScDocument* ScConditionalFormat::GetDocument()
{
return pDoc;
}
ScConditionalFormat::~ScConditionalFormat()
{
}
......
......@@ -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:
......
......@@ -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,
......
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