26#include <document.hxx>
29#include <com/sun/star/chart/XChartDataChangeEventListener.hpp>
40 uno::Reference< chart::XChartDataChangeEventListener >
xListener;
41 uno::Reference< chart::XChartData >
xSource;
45 uno::Reference< chart::XChartData > xS ) :
60 if (!m_pDoc || m_pDoc->IsInDtorClear())
65 m_pDoc->GetExternalRefManager()->removeLinkListener(
this);
74 if (maFileIds.count(nFileId))
81 removeFileId(nFileId);
91 maFileIds.insert(nFileId);
96 maFileIds.erase(nFileId);
110 maTokens(
std::move(aTokens)),
128 const std::unordered_set<sal_uInt16>& rFileIds =
mpExtRefListener->getAllFileIds();
129 for (
const auto& rFileId : rFileIds)
135 const uno::Reference< chart::XChartDataChangeEventListener >& rListener,
136 const uno::Reference< chart::XChartData >& rSource )
145 return uno::Reference< chart::XChartDataChangeEventListener >();
152 return uno::Reference< chart::XChartData >();
157 if (rHint.
GetId() == SfxHintId::ScDataChanged)
175 chart::ChartDataChangeType_ALL,
195 vector<ScTokenRef> aTokens;
202class StartEndListening
206 mrDoc(rDoc),
mrParent(rParent), mbStart(bStart) {}
216 sal_uInt16 nFileId = pToken->GetIndex();
235 startListening(aRange);
237 endListening(aRange);
241 void startListening(
const ScRange& rRange)
244 mrDoc.StartListeningCell(rRange.
aStart, &mrParent);
246 mrDoc.StartListeningArea(rRange,
false, &mrParent);
249 void endListening(
const ScRange& rRange)
252 mrDoc.EndListeningCell(rRange.
aStart, &mrParent);
254 mrDoc.EndListeningArea(rRange,
false, &mrParent);
355 meModifiedDuringUpdate( SC_CLCUPDATE_NONE ),
356 aIdle(
"sc::ScChartListenerCollection aIdle" ),
364 meModifiedDuringUpdate( SC_CLCUPDATE_NONE ),
365 aIdle(
"sc::ScChartListenerCollection aIdle" ),
384 it.second->StartListeningTo();
393 return m_Listeners.insert(std::make_pair(
aName, std::unique_ptr<ScChartListener>(pListener))).second;
405 ListenersType::iterator
const it =
m_Listeners.find(rName);
406 return it ==
m_Listeners.end() ? nullptr : it->second.get();
411 ListenersType::const_iterator
const it =
m_Listeners.find(rName);
412 return it ==
m_Listeners.end() ? nullptr : it->second.get();
422 for (sal_Int32 nNum = 1; nNum < 10000; ++nNum)
424 OUString aTestName = rPrefix + OUString::number(nNum);
461 aUsed.insert(std::make_pair(pair.first, std::move(pair.second)));
468 aUsed.insert(std::make_pair(pair.first, std::move(pair.second)));
476 const uno::Reference< chart::XChartData >& rSource )
484 if (
p->IsUno() &&
p->GetUnoListener() == rListener &&
p->GetUnoSource() == rSource)
532 it.second->SetDirty(
true);
547 if (!pCLCmp || *pCL != *pCLCmp)
549 if ( bSetChartRangeLists )
555 bool b1 = rList1.
is();
556 bool b2 = rList2.
is();
557 if ( b1 != b2 || (b1 && b2 && (*rList1 != *rList2)) )
578 if ( rList.
is() && rList->Intersects( rRange ) )
590 if (rHiddenRange.Intersects(rRange))
602 it.second->UpdateChartIntersecting(aRange);
614 [](
const ListenersType::value_type& lhs,
const ListenersType::value_type& rhs) {
615 return (lhs.first == rhs.first) && (*lhs.second == *rhs.second);
BaseContainerNodeSharedPtr & mrParent
IMPL_LINK_NOARG(ScChartListenerCollection, TimerHdl, Timer *, void)
static bool AnyInput(VclInputFlags nType=VCL_INPUT_ANY)
virtual void Start(bool bStartTimer=true) override
ScChartHiddenRangeListener()
virtual ~ScChartHiddenRangeListener()
void EndListeningHiddenRange(ScChartHiddenRangeListener *pListener)
Remove all ranges associated with passed listener instance from the list of hidden range listeners.
ScChartListener * findByName(const OUString &rName)
void SetDiffDirty(const ScChartListenerCollection &, bool bSetChartRangeLists)
bool insert(ScChartListener *pListener)
void SetRangeDirty(const ScRange &rRange)
void StartListeningHiddenRange(const ScRange &rRange, ScChartHiddenRangeListener *pListener)
Start listening on hide/show change within specified cell range.
bool hasListeners() const
~ScChartListenerCollection()
void UpdateChartsContainingTab(SCTAB nTab)
std::map< OUString, std::unique_ptr< ScChartListener > > ListenersType
OUString getUniqueName(std::u16string_view rPrefix) const
Create a unique name that's not taken by any existing chart listener objects.
ListenersType m_Listeners
ScChartListenerCollection(ScDocument &rDoc)
void FreeUno(const css::uno::Reference< css::chart::XChartDataChangeEventListener > &rListener, const css::uno::Reference< css::chart::XChartData > &rSource)
enum ScChartListenerCollection::UpdateStatus meModifiedDuringUpdate
void removeByName(const OUString &rName)
bool operator==(const ScChartListenerCollection &r) const
void ChangeListening(const OUString &rName, const ScRangeListRef &rRangeListRef)
std::unordered_multimap< ScChartHiddenRangeListener *, ScRange > maHiddenListeners
virtual void notify(sal_uInt16 nFileId, ScExternalRefManager::LinkUpdateType eType) override
virtual ~ExternalRefListener() override
void addFileId(sal_uInt16 nFileId)
ExternalRefListener(ScChartListener &rParent, ScDocument &rDoc)
void removeFileId(sal_uInt16 nFileId)
void SetRangeList(const ScRangeListRef &rNew)
bool operator!=(const ScChartListener &r) const
std::vector< ScTokenRef > maTokens
void SetUno(const css::uno::Reference< css::chart::XChartDataChangeEventListener > &rListener, const css::uno::Reference< css::chart::XChartData > &rSource)
std::unique_ptr< ScChartUnoData > pUnoData
ScChartListener(OUString aName, ScDocument &rDoc, const ScRangeListRef &rRangeListRef)
css::uno::Reference< css::chart::XChartDataChangeEventListener > GetUnoListener() const
std::unique_ptr< ExternalRefListener > mpExtRefListener
virtual ~ScChartListener() override
void UpdateChartIntersecting(const ScRange &rRange)
virtual void Notify(const SfxHint &rHint) override
void ChangeListening(const ScRangeListRef &rRangeListRef, bool bDirty)
css::uno::Reference< css::chart::XChartData > GetUnoSource() const
bool operator==(const ScChartListener &) const
const OUString & GetName() const
ExternalRefListener * GetExtRefListener()
ScRangeListRef GetRangeList() const
uno::Reference< chart::XChartData > xSource
const uno::Reference< chart::XChartDataChangeEventListener > & GetListener() const
ScChartUnoData(uno::Reference< chart::XChartDataChangeEventListener > xL, uno::Reference< chart::XChartData > xS)
const uno::Reference< chart::XChartData > & GetSource() const
uno::Reference< chart::XChartDataChangeEventListener > xListener
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC SCROW MaxRow() const
SC_DLLPUBLIC ScChartListenerCollection * GetChartListenerCollection() const
SC_DLLPUBLIC ScExternalRefManager * GetExternalRefManager() const
SC_DLLPUBLIC bool GetAutoCalc() const
bool IsInInterpreter() const
void UpdateChart(const OUString &rName)
void SetChartRangeList(std::u16string_view rChartName, const ScRangeListRef &rNewRangeListRef)
only assigns the new RangeList, no ChartListener or the like
bool IsImportingXML() const
void addLinkListener(sal_uInt16 nFileId, LinkListener *pListener)
Register a new link listener to a specified external document.
void removeLinkListener(sal_uInt16 nFileId, LinkListener *pListener)
Remove an existing link listener.
@ OH_NO_WE_ARE_GOING_TO_DIE
bool HasBroadcaster() const
void SetPriority(TaskPriority ePriority)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
#define LINK(Instance, Class, Member)
bool SC_DLLPUBLIC isRef(const ScTokenRef &pToken)
void getRangeListFromTokens(const ScDocument *pDoc, ScRangeList &rRangeList, const ::std::vector< ScTokenRef > &pTokens, const ScAddress &rPos)
void getTokensFromRangeList(const ScDocument *pDoc, ::std::vector< ScTokenRef > &pTokens, const ScRangeList &rRanges)
bool getRangeFromToken(const ScDocument *pDoc, ScRange &rRange, const ScTokenRef &pToken, const ScAddress &rPos, bool bExternal=false)
bool SC_DLLPUBLIC intersects(const ScDocument *pDoc, const ::std::vector< ScTokenRef > &rTokens, const ScTokenRef &pToken, const ScAddress &rPos)
void getTokenFromRange(const ScDocument *pDoc, ScTokenRef &pToken, const ScRange &rRange)
Create a double reference token from a range object.
bool SC_DLLPUBLIC isExternalRef(const ScTokenRef &pToken)
::boost::intrusive_ptr< formula::FormulaToken > ScTokenRef