/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
ScChartListener::ExternalRefListener::~ExternalRefListener()
{ if (!m_pDoc || m_pDoc->IsInDtorClear()) // The document is being destroyed. Do nothing. return;
// Make sure to remove all pointers to this object.
m_pDoc->GetExternalRefManager()->removeLinkListener(this);
}
void ScChartListener::ExternalRefListener::notify(sal_uInt16 nFileId, ScExternalRefManager::LinkUpdateType eType)
{ switch (eType)
{ case ScExternalRefManager::LINK_MODIFIED:
{ if (maFileIds.count(nFileId)) // We are listening to this external document. Send an update // request to the chart.
mrParent.SetUpdateQueue();
} break; case ScExternalRefManager::LINK_BROKEN:
removeFileId(nFileId); break; case ScExternalRefManager::OH_NO_WE_ARE_GOING_TO_DIE:
m_pDoc = nullptr; break;
}
}
void ScChartListener::Update()
{ if ( mrDoc.IsInInterpreter() )
{ // If interpreting do nothing and restart timer so we don't // interfere with interpreter and don't produce an Err522 or similar. // This may happen if we are rescheduled via Basic function.
mrDoc.GetChartListenerCollection()->StartTimer(); return ;
} if ( pUnoData )
{
bDirty = false; // recognize some day what has changed inside the Chart
chart::ChartDataChangeEvent aEvent( pUnoData->GetSource(),
chart::ChartDataChangeType_ALL,
0, 0, 0, 0 );
pUnoData->GetListener()->chartDataChanged( aEvent );
} elseif ( mrDoc.GetAutoCalc() )
{
bDirty = false;
mrDoc.UpdateChart(GetName());
}
}
if (ScRefTokenHelper::intersects(&mrDoc, maTokens, pToken, ScAddress()))
{ // force update (chart has to be loaded), don't use ScChartListener::Update
mrDoc.UpdateChart(GetName());
}
}
ScChartListener::ExternalRefListener* ScChartListener::GetExtRefListener()
{ if (!mpExtRefListener)
mpExtRefListener.reset(new ExternalRefListener(*this, mrDoc));
ScChartListenerCollection::~ScChartListenerCollection()
{ // remove ChartListener objects before aIdle dtor is called, because // ScChartListener::EndListeningTo may cause ScChartListenerCollection::StartTimer // to be called if an empty ScNoteCell is deleted
m_Listeners.clear();
}
void ScChartListenerCollection::StartAllListeners()
{ for (autoconst& it : m_Listeners)
{
it.second->StartListeningTo();
}
}
void ScChartListenerCollection::FreeUnused()
{ if (meModifiedDuringUpdate == SC_CLCUPDATE_RUNNING)
meModifiedDuringUpdate = SC_CLCUPDATE_MODIFIED;
ListenersType aUsed;
for (auto & pair : m_Listeners)
{
ScChartListener* p = pair.second.get(); if (p->IsUno())
{ // We don't delete UNO charts; they are to be deleted separately via FreeUno().
aUsed.insert(std::make_pair(pair.first, std::move(pair.second))); continue;
}
if (p->IsUsed())
{
p->SetUsed(false);
aUsed.insert(std::make_pair(pair.first, std::move(pair.second)));
}
}
void ScChartListenerCollection::UpdateDirtyCharts()
{ // During ScChartListener::Update() the most nasty things can happen due to // UNO listeners, e.g. reentrant calls via BASIC to insert() and FreeUno() // and similar that modify m_Listeners and invalidate iterators.
meModifiedDuringUpdate = SC_CLCUPDATE_RUNNING;
for (autoconst& it : m_Listeners)
{
ScChartListener *const p = it.second.get(); if (p->IsDirty())
p->Update();
if (meModifiedDuringUpdate == SC_CLCUPDATE_MODIFIED) break; // iterator is invalid
if (aIdle.IsActive() && !rDoc.IsImportingXML()) break; // one interfered
}
meModifiedDuringUpdate = SC_CLCUPDATE_NONE;
}
void ScChartListenerCollection::SetDirty()
{ for (autoconst& it : m_Listeners)
{
it.second->SetDirty(true);
}
// New hidden range listener implementation for (auto& [pListener, rHiddenRange] : maHiddenListeners)
{ if (rHiddenRange.Intersects(rRange))
{
pListener->notify();
}
}
}
bool ScChartListenerCollection::operator==( const ScChartListenerCollection& r ) const
{ // Do not use ScStrCollection::operator==() here that uses IsEqual and Compare. // Use ScChartListener::operator==() instead. if (&rDoc != &r.rDoc) returnfalse;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.