// the name "default" is reserved for internal use
OUString aName = xClipboard->getName(); if ( m_aDefaultName == aName ) throw IllegalArgumentException("name reserved", static_cast < XClipboardManager * > (this), 1);
// try to add new clipboard to the list
std::unique_lock aGuard(m_aMutex); if (!m_bDisposed)
{
std::pair< const OUString, Reference< XClipboard > > value (
aName.getLength() ? aName : m_aDefaultName,
xClipboard );
std::pair< ClipboardMap::iterator, bool > p = m_aClipboardMap.insert(value);
aGuard.unlock();
// insert failed, element must exist already if (!p.second) throw ElementExistException(aName, static_cast < XClipboardManager * > (this));
// removeClipboard is still allowed here, so make a copy of the // list (to ensure integrity) and clear the original.
rGuard.lock();
ClipboardMap aCopy;
std::swap(aCopy, m_aClipboardMap);
rGuard.unlock();
// dispose all clipboards still in list for (autoconst& elem : aCopy)
{
Reference< XComponent > xComponent(elem.second, UNO_QUERY); if (xComponent.is())
{ try
{
xComponent->removeEventListener(static_cast < XEventListener * > (this));
xComponent->dispose();
} catch (const Exception&)
{ // exceptions can be safely ignored here.
}
}
}
}
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.