loplugin:flatten in comphelper

Change-Id: I1a8db4dbd744b87406d1db5609585495f01f4403
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92478
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2020-04-18 11:35:04 +02:00
parent ed0097845a
commit 8d4fd34183
16 changed files with 537 additions and 536 deletions

View File

@@ -98,21 +98,21 @@ namespace comphelper
void OContainerListenerAdapter::dispose() void OContainerListenerAdapter::dispose()
{ {
if (m_xContainer.is()) if (!m_xContainer.is())
return;
try
{ {
try Reference< XContainerListener > xPreventDelete(this);
{ m_xContainer->removeContainerListener(xPreventDelete);
Reference< XContainerListener > xPreventDelete(this); m_pListener->setAdapter(nullptr);
m_xContainer->removeContainerListener(xPreventDelete);
m_pListener->setAdapter(nullptr);
}
catch(const Exception&)
{
OSL_FAIL("Exception caught!");
}
m_xContainer = nullptr;
m_pListener = nullptr;
} }
catch(const Exception&)
{
OSL_FAIL("Exception caught!");
}
m_xContainer = nullptr;
m_pListener = nullptr;
} }

View File

@@ -423,42 +423,42 @@ void EmbeddedObjectContainer::AddEmbeddedObject( const css::uno::Reference < css
xChild->setParent( pImpl->m_xModel.get() ); xChild->setParent( pImpl->m_xModel.get() );
// look for object in temporary container // look for object in temporary container
if ( pImpl->mpTempObjectContainer ) if ( !pImpl->mpTempObjectContainer )
return;
auto& rObjectContainer = pImpl->mpTempObjectContainer->pImpl->maNameToObjectMap;
auto aIter = std::find_if(rObjectContainer.begin(), rObjectContainer.end(),
[&xObj](const EmbeddedObjectContainerNameMap::value_type& rEntry) { return rEntry.second == xObj; });
if (aIter == rObjectContainer.end())
return;
// copy replacement image from temporary container (if there is any)
OUString aTempName = aIter->first;
OUString aMediaType;
uno::Reference < io::XInputStream > xStream = pImpl->mpTempObjectContainer->GetGraphicStream( xObj, &aMediaType );
if ( xStream.is() )
{ {
auto& rObjectContainer = pImpl->mpTempObjectContainer->pImpl->maNameToObjectMap; InsertGraphicStream( xStream, rName, aMediaType );
auto aIter = std::find_if(rObjectContainer.begin(), rObjectContainer.end(), xStream = nullptr;
[&xObj](const EmbeddedObjectContainerNameMap::value_type& rEntry) { return rEntry.second == xObj; }); pImpl->mpTempObjectContainer->RemoveGraphicStream( aTempName );
if (aIter != rObjectContainer.end()) }
// remove object from storage of temporary container
uno::Reference < embed::XEmbedPersist > xPersist( xObj, uno::UNO_QUERY );
if ( xPersist.is() )
{
try
{
pImpl->mpTempObjectContainer->pImpl->mxStorage->removeElement( aTempName );
}
catch (const uno::Exception&)
{ {
// copy replacement image from temporary container (if there is any)
OUString aTempName = aIter->first;
OUString aMediaType;
uno::Reference < io::XInputStream > xStream = pImpl->mpTempObjectContainer->GetGraphicStream( xObj, &aMediaType );
if ( xStream.is() )
{
InsertGraphicStream( xStream, rName, aMediaType );
xStream = nullptr;
pImpl->mpTempObjectContainer->RemoveGraphicStream( aTempName );
}
// remove object from storage of temporary container
uno::Reference < embed::XEmbedPersist > xPersist( xObj, uno::UNO_QUERY );
if ( xPersist.is() )
{
try
{
pImpl->mpTempObjectContainer->pImpl->mxStorage->removeElement( aTempName );
}
catch (const uno::Exception&)
{
}
}
// temp. container needs to forget the object
pImpl->mpTempObjectContainer->pImpl->maObjectToNameMap.erase( aIter->second );
pImpl->mpTempObjectContainer->pImpl->maNameToObjectMap.erase( aIter );
} }
} }
// temp. container needs to forget the object
pImpl->mpTempObjectContainer->pImpl->maObjectToNameMap.erase( aIter->second );
pImpl->mpTempObjectContainer->pImpl->maNameToObjectMap.erase( aIter );
} }
bool EmbeddedObjectContainer::StoreEmbeddedObject( bool EmbeddedObjectContainer::StoreEmbeddedObject(
@@ -993,20 +993,20 @@ void EmbeddedObjectContainer::CloseEmbeddedObject( const uno::Reference < embed:
auto aIter = std::find_if(pImpl->maNameToObjectMap.begin(), pImpl->maNameToObjectMap.end(), auto aIter = std::find_if(pImpl->maNameToObjectMap.begin(), pImpl->maNameToObjectMap.end(),
[&xObj](const EmbeddedObjectContainerNameMap::value_type& rEntry) { return rEntry.second == xObj; }); [&xObj](const EmbeddedObjectContainerNameMap::value_type& rEntry) { return rEntry.second == xObj; });
if (aIter != pImpl->maNameToObjectMap.end()) if (aIter == pImpl->maNameToObjectMap.end())
{ return;
pImpl->maObjectToNameMap.erase( aIter->second );
pImpl->maNameToObjectMap.erase( aIter );
try pImpl->maObjectToNameMap.erase( aIter->second );
{ pImpl->maNameToObjectMap.erase( aIter );
xObj->close( true );
} try
catch (const uno::Exception&) {
{ xObj->close( true );
// it is no problem if the object is already closed }
// TODO/LATER: what if the object can not be closed? catch (const uno::Exception&)
} {
// it is no problem if the object is already closed
// TODO/LATER: what if the object can not be closed?
} }
} }

View File

@@ -594,26 +594,26 @@ void SAL_CALL ImplEventAttacherManager::detach(sal_Int32 nIndex, const Reference
std::deque< AttacherIndex_Impl >::iterator aCurrentPosition = aIndex.begin() + nIndex; std::deque< AttacherIndex_Impl >::iterator aCurrentPosition = aIndex.begin() + nIndex;
auto aObjIt = std::find_if(aCurrentPosition->aObjList.begin(), aCurrentPosition->aObjList.end(), auto aObjIt = std::find_if(aCurrentPosition->aObjList.begin(), aCurrentPosition->aObjList.end(),
[&xObject](const AttachedObject_Impl& rObj) { return rObj.xTarget == xObject; }); [&xObject](const AttachedObject_Impl& rObj) { return rObj.xTarget == xObject; });
if (aObjIt != aCurrentPosition->aObjList.end()) if (aObjIt == aCurrentPosition->aObjList.end())
return;
sal_Int32 i = 0;
for( const auto& rEvt : aCurrentPosition->aEventList )
{ {
sal_Int32 i = 0; if( aObjIt->aAttachedListenerSeq[i].is() )
for( const auto& rEvt : aCurrentPosition->aEventList )
{ {
if( aObjIt->aAttachedListenerSeq[i].is() ) try
{
xAttacher->removeListener( aObjIt->xTarget, rEvt.ListenerType,
rEvt.AddListenerParam, aObjIt->aAttachedListenerSeq[i] );
}
catch( Exception& )
{ {
try
{
xAttacher->removeListener( aObjIt->xTarget, rEvt.ListenerType,
rEvt.AddListenerParam, aObjIt->aAttachedListenerSeq[i] );
}
catch( Exception& )
{
}
} }
++i;
} }
aCurrentPosition->aObjList.erase( aObjIt ); ++i;
} }
aCurrentPosition->aObjList.erase( aObjIt );
} }
void SAL_CALL ImplEventAttacherManager::addScriptListener(const Reference< XScriptListener >& aListener) void SAL_CALL ImplEventAttacherManager::addScriptListener(const Reference< XScriptListener >& aListener)

View File

@@ -69,41 +69,41 @@ bool DirectoryHelper::dirExists(const OUString& rDirURL)
void DirectoryHelper::scanDirsAndFiles(const OUString& rDirURL, std::set<OUString>& rDirs, void DirectoryHelper::scanDirsAndFiles(const OUString& rDirURL, std::set<OUString>& rDirs,
std::set<std::pair<OUString, OUString>>& rFiles) std::set<std::pair<OUString, OUString>>& rFiles)
{ {
if (!rDirURL.isEmpty()) if (rDirURL.isEmpty())
return;
osl::Directory aDirectory(rDirURL);
if (osl::FileBase::E_None != aDirectory.open())
return;
osl::DirectoryItem aDirectoryItem;
while (osl::FileBase::E_None == aDirectory.getNextItem(aDirectoryItem))
{ {
osl::Directory aDirectory(rDirURL); osl::FileStatus aFileStatus(osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileURL
| osl_FileStatus_Mask_FileName);
if (osl::FileBase::E_None == aDirectory.open()) if (osl::FileBase::E_None == aDirectoryItem.getFileStatus(aFileStatus))
{ {
osl::DirectoryItem aDirectoryItem; if (aFileStatus.isDirectory())
while (osl::FileBase::E_None == aDirectory.getNextItem(aDirectoryItem))
{ {
osl::FileStatus aFileStatus(osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileURL const OUString aFileName(aFileStatus.getFileName());
| osl_FileStatus_Mask_FileName);
if (osl::FileBase::E_None == aDirectoryItem.getFileStatus(aFileStatus)) if (!aFileName.isEmpty())
{ {
if (aFileStatus.isDirectory()) rDirs.insert(aFileName);
{ }
const OUString aFileName(aFileStatus.getFileName()); }
else if (aFileStatus.isRegular())
{
OUString aFileName(aFileStatus.getFileName());
OUString aExtension;
aFileName = splitAtLastToken(aFileName, '.', aExtension);
if (!aFileName.isEmpty()) if (!aFileName.isEmpty())
{ {
rDirs.insert(aFileName); rFiles.insert(std::pair<OUString, OUString>(aFileName, aExtension));
}
}
else if (aFileStatus.isRegular())
{
OUString aFileName(aFileStatus.getFileName());
OUString aExtension;
aFileName = splitAtLastToken(aFileName, '.', aExtension);
if (!aFileName.isEmpty())
{
rFiles.insert(std::pair<OUString, OUString>(aFileName, aExtension));
}
}
} }
} }
} }

View File

@@ -124,18 +124,18 @@ namespace comphelper
if ( !isAlive() ) if ( !isAlive() )
return; return;
if ( _rxListener.is() && m_pImpl->getClientId() ) if ( !(_rxListener.is() && m_pImpl->getClientId()) )
return;
sal_Int32 nListenerCount = AccessibleEventNotifier::removeEventListener( m_pImpl->getClientId( ), _rxListener );
if ( !nListenerCount )
{ {
sal_Int32 nListenerCount = AccessibleEventNotifier::removeEventListener( m_pImpl->getClientId( ), _rxListener ); // no listeners anymore
if ( !nListenerCount ) // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
{ // and at least to us not firing any events anymore, in case somebody calls
// no listeners anymore // NotifyAccessibleEvent, again
// -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), AccessibleEventNotifier::revokeClient( m_pImpl->getClientId( ) );
// and at least to us not firing any events anymore, in case somebody calls m_pImpl->setClientId( 0 );
// NotifyAccessibleEvent, again
AccessibleEventNotifier::revokeClient( m_pImpl->getClientId( ) );
m_pImpl->setClientId( 0 );
}
} }
} }

View File

@@ -436,46 +436,46 @@ namespace
private: private:
void visitNodesXMLRead(const uno::Reference< xml::dom::XElement >& rElement) void visitNodesXMLRead(const uno::Reference< xml::dom::XElement >& rElement)
{ {
if (rElement.is()) if (!rElement.is())
return;
const OUString aTagName(rElement->getTagName());
if (aTagName == "extension")
{ {
const OUString aTagName(rElement->getTagName()); OUString aAttrUrl(rElement->getAttribute("url"));
const OUString aAttrRevoked(rElement->getAttribute("revoked"));
if (aTagName == "extension") if (!aAttrUrl.isEmpty())
{ {
OUString aAttrUrl(rElement->getAttribute("url")); const sal_Int32 nIndex(aAttrUrl.lastIndexOf('/'));
const OUString aAttrRevoked(rElement->getAttribute("revoked"));
if (!aAttrUrl.isEmpty()) if (nIndex > 0 && aAttrUrl.getLength() > nIndex + 1)
{ {
const sal_Int32 nIndex(aAttrUrl.lastIndexOf('/')); aAttrUrl = aAttrUrl.copy(nIndex + 1);
if (nIndex > 0 && aAttrUrl.getLength() > nIndex + 1)
{
aAttrUrl = aAttrUrl.copy(nIndex + 1);
}
const bool bEnabled(aAttrRevoked.isEmpty() || !aAttrRevoked.toBoolean());
maEntries.emplace_back(
OUStringToOString(aAttrUrl, RTL_TEXTENCODING_ASCII_US),
bEnabled);
} }
const bool bEnabled(aAttrRevoked.isEmpty() || !aAttrRevoked.toBoolean());
maEntries.emplace_back(
OUStringToOString(aAttrUrl, RTL_TEXTENCODING_ASCII_US),
bEnabled);
} }
else }
else
{
uno::Reference< xml::dom::XNodeList > aList = rElement->getChildNodes();
if (aList.is())
{ {
uno::Reference< xml::dom::XNodeList > aList = rElement->getChildNodes(); const sal_Int32 nLength(aList->getLength());
if (aList.is()) for (sal_Int32 a(0); a < nLength; a++)
{ {
const sal_Int32 nLength(aList->getLength()); const uno::Reference< xml::dom::XElement > aChild(aList->item(a), uno::UNO_QUERY);
for (sal_Int32 a(0); a < nLength; a++) if (aChild.is())
{ {
const uno::Reference< xml::dom::XElement > aChild(aList->item(a), uno::UNO_QUERY); visitNodesXMLRead(aChild);
if (aChild.is())
{
visitNodesXMLRead(aChild);
}
} }
} }
} }
@@ -605,58 +605,58 @@ namespace
const ExtensionInfoEntryVector& rToBeEnabled, const ExtensionInfoEntryVector& rToBeEnabled,
const ExtensionInfoEntryVector& rToBeDisabled) const ExtensionInfoEntryVector& rToBeDisabled)
{ {
if (!DirectoryHelper::fileExists(rUnoPackagReg))
return;
uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
uno::Reference< xml::dom::XDocumentBuilder > xBuilder = xml::dom::DocumentBuilder::create(xContext);
uno::Reference< xml::dom::XDocument > aDocument = xBuilder->parseURI(rUnoPackagReg);
if (!aDocument.is())
return;
if (!visitNodesXMLChange(
rTagToSearch,
aDocument->getDocumentElement(),
rToBeEnabled,
rToBeDisabled))
return;
// did change - write back
uno::Reference< xml::sax::XSAXSerializable > xSerializer(aDocument, uno::UNO_QUERY);
if (!xSerializer.is())
return;
// create a SAXWriter
uno::Reference< xml::sax::XWriter > const xSaxWriter = xml::sax::Writer::create(xContext);
uno::Reference< io::XStream > xTempFile = io::TempFile::create(xContext);
uno::Reference< io::XOutputStream > xOutStrm = xTempFile->getOutputStream();
// set output stream and do the serialization
xSaxWriter->setOutputStream(xOutStrm);
xSerializer->serialize(xSaxWriter, uno::Sequence< beans::StringPair >());
// get URL from temp file
uno::Reference < beans::XPropertySet > xTempFileProps(xTempFile, uno::UNO_QUERY);
uno::Any aUrl = xTempFileProps->getPropertyValue("Uri");
OUString aTempURL;
aUrl >>= aTempURL;
// copy back file
if (!(!aTempURL.isEmpty() && DirectoryHelper::fileExists(aTempURL)))
return;
if (DirectoryHelper::fileExists(rUnoPackagReg)) if (DirectoryHelper::fileExists(rUnoPackagReg))
{ {
uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); osl::File::remove(rUnoPackagReg);
uno::Reference< xml::dom::XDocumentBuilder > xBuilder = xml::dom::DocumentBuilder::create(xContext); }
uno::Reference< xml::dom::XDocument > aDocument = xBuilder->parseURI(rUnoPackagReg);
if (aDocument.is())
{
if (visitNodesXMLChange(
rTagToSearch,
aDocument->getDocumentElement(),
rToBeEnabled,
rToBeDisabled))
{
// did change - write back
uno::Reference< xml::sax::XSAXSerializable > xSerializer(aDocument, uno::UNO_QUERY);
if (xSerializer.is())
{
// create a SAXWriter
uno::Reference< xml::sax::XWriter > const xSaxWriter = xml::sax::Writer::create(xContext);
uno::Reference< io::XStream > xTempFile = io::TempFile::create(xContext);
uno::Reference< io::XOutputStream > xOutStrm = xTempFile->getOutputStream();
// set output stream and do the serialization
xSaxWriter->setOutputStream(xOutStrm);
xSerializer->serialize(xSaxWriter, uno::Sequence< beans::StringPair >());
// get URL from temp file
uno::Reference < beans::XPropertySet > xTempFileProps(xTempFile, uno::UNO_QUERY);
uno::Any aUrl = xTempFileProps->getPropertyValue("Uri");
OUString aTempURL;
aUrl >>= aTempURL;
// copy back file
if (!aTempURL.isEmpty() && DirectoryHelper::fileExists(aTempURL))
{
if (DirectoryHelper::fileExists(rUnoPackagReg))
{
osl::File::remove(rUnoPackagReg);
}
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
SAL_WARN_IF(osl::FileBase::E_None != osl::File::move(aTempURL, rUnoPackagReg), "comphelper.backupfilehelper", "could not copy back modified Extension configuration file"); SAL_WARN_IF(osl::FileBase::E_None != osl::File::move(aTempURL, rUnoPackagReg), "comphelper.backupfilehelper", "could not copy back modified Extension configuration file");
#else #else
osl::File::move(aTempURL, rUnoPackagReg); osl::File::move(aTempURL, rUnoPackagReg);
#endif #endif
}
}
}
}
}
} }
public: public:
@@ -1602,45 +1602,45 @@ namespace comphelper
// ensure existence of needed paths // ensure existence of needed paths
getInitialBaseURL(); getInitialBaseURL();
if (!maUserConfigBaseURL.isEmpty()) if (maUserConfigBaseURL.isEmpty())
return;
if (bSafeMode)
{ {
if (bSafeMode) if (!mbSafeModeDirExists)
{ {
if (!mbSafeModeDirExists) std::set< OUString > aExcludeList;
{
std::set< OUString > aExcludeList;
// do not move SafeMode directory itself // do not move SafeMode directory itself
aExcludeList.insert(getSafeModeName()); aExcludeList.insert(getSafeModeName());
// init SafeMode by creating the 'SafeMode' directory and moving // init SafeMode by creating the 'SafeMode' directory and moving
// all stuff there. All repairs will happen there. Both Dirs have to exist. // all stuff there. All repairs will happen there. Both Dirs have to exist.
// extend maUserConfigWorkURL as needed // extend maUserConfigWorkURL as needed
maUserConfigWorkURL = maUserConfigBaseURL + "/" + getSafeModeName(); maUserConfigWorkURL = maUserConfigBaseURL + "/" + getSafeModeName();
osl::Directory::createPath(maUserConfigWorkURL); osl::Directory::createPath(maUserConfigWorkURL);
DirectoryHelper::moveDirContent(maUserConfigBaseURL, maUserConfigWorkURL, aExcludeList); DirectoryHelper::moveDirContent(maUserConfigBaseURL, maUserConfigWorkURL, aExcludeList);
// switch local flag, maUserConfigWorkURL is already reset // switch local flag, maUserConfigWorkURL is already reset
mbSafeModeDirExists = true; mbSafeModeDirExists = true;
}
} }
else }
else
{
if (mbSafeModeDirExists)
{ {
if (mbSafeModeDirExists) // SafeMode has ended, return to normal mode by moving all content
{ // from 'SafeMode' directory back to UserDirectory and deleting it.
// SafeMode has ended, return to normal mode by moving all content // Both Dirs have to exist
// from 'SafeMode' directory back to UserDirectory and deleting it. std::set< OUString > aExcludeList;
// Both Dirs have to exist
std::set< OUString > aExcludeList;
DirectoryHelper::moveDirContent(maUserConfigWorkURL, maUserConfigBaseURL, aExcludeList); DirectoryHelper::moveDirContent(maUserConfigWorkURL, maUserConfigBaseURL, aExcludeList);
osl::Directory::remove(maUserConfigWorkURL); osl::Directory::remove(maUserConfigWorkURL);
// switch local flag and reset maUserConfigWorkURL // switch local flag and reset maUserConfigWorkURL
mbSafeModeDirExists = false; mbSafeModeDirExists = false;
maUserConfigWorkURL = maUserConfigBaseURL; maUserConfigWorkURL = maUserConfigBaseURL;
}
} }
} }
} }
@@ -1650,22 +1650,22 @@ namespace comphelper
// no push when SafeModeDir exists, it may be Office's exit after SafeMode // no push when SafeModeDir exists, it may be Office's exit after SafeMode
// where SafeMode flag is already deleted, but SafeModeDir cleanup is not // where SafeMode flag is already deleted, but SafeModeDir cleanup is not
// done yet (is done at next startup) // done yet (is done at next startup)
if (mbActive && !mbSafeModeDirExists) if (!(mbActive && !mbSafeModeDirExists))
return;
const OUString aPackURL(getPackURL());
// ensure dir and file vectors
fillDirFileInfo();
// process all files in question recursively
if (!maDirs.empty() || !maFiles.empty())
{ {
const OUString aPackURL(getPackURL()); tryPush_Files(
maDirs,
// ensure dir and file vectors maFiles,
fillDirFileInfo(); maUserConfigWorkURL,
aPackURL);
// process all files in question recursively
if (!maDirs.empty() || !maFiles.empty())
{
tryPush_Files(
maDirs,
maFiles,
maUserConfigWorkURL,
aPackURL);
}
} }
} }
@@ -1709,29 +1709,29 @@ namespace comphelper
void BackupFileHelper::tryPop() void BackupFileHelper::tryPop()
{ {
if (mbActive) if (!mbActive)
return;
bool bDidPop(false);
const OUString aPackURL(getPackURL());
// ensure dir and file vectors
fillDirFileInfo();
// process all files in question recursively
if (!maDirs.empty() || !maFiles.empty())
{ {
bool bDidPop(false); bDidPop = tryPop_files(
const OUString aPackURL(getPackURL()); maDirs,
maFiles,
maUserConfigWorkURL,
aPackURL);
}
// ensure dir and file vectors if (bDidPop)
fillDirFileInfo(); {
// try removal of evtl. empty directory
// process all files in question recursively osl::Directory::remove(aPackURL);
if (!maDirs.empty() || !maFiles.empty())
{
bDidPop = tryPop_files(
maDirs,
maFiles,
maUserConfigWorkURL,
aPackURL);
}
if (bDidPop)
{
// try removal of evtl. empty directory
osl::Directory::remove(aPackURL);
}
} }
} }
@@ -1751,18 +1751,18 @@ namespace comphelper
void BackupFileHelper::tryPopExtensionInfo() void BackupFileHelper::tryPopExtensionInfo()
{ {
if (mbActive && mbExtensions) if (!(mbActive && mbExtensions))
return;
bool bDidPop(false);
const OUString aPackURL(getPackURL());
bDidPop = tryPop_extensionInfo(aPackURL);
if (bDidPop)
{ {
bool bDidPop(false); // try removal of evtl. empty directory
const OUString aPackURL(getPackURL()); osl::Directory::remove(aPackURL);
bDidPop = tryPop_extensionInfo(aPackURL);
if (bDidPop)
{
// try removal of evtl. empty directory
osl::Directory::remove(aPackURL);
}
} }
} }

View File

@@ -256,11 +256,70 @@ void SAL_CALL OLockListener::disposing( const lang::EventObject& aEvent )
osl::ClearableMutexGuard aGuard( m_aMutex ); osl::ClearableMutexGuard aGuard( m_aMutex );
// object is disposed // object is disposed
if ( aEvent.Source == m_xInstance ) if ( aEvent.Source != m_xInstance )
{ return;
// the object does not listen for anything any more
m_nMode = 0;
// the object does not listen for anything any more
m_nMode = 0;
// dispose the wrapper;
uno::Reference< lang::XComponent > xComponent( m_xWrapper.get(), uno::UNO_QUERY );
aGuard.clear();
if ( xComponent.is() )
{
try { xComponent->dispose(); }
catch( uno::Exception& ){}
}
}
// XCloseListener
void SAL_CALL OLockListener::queryClosing( const lang::EventObject& aEvent, sal_Bool )
{
// GetsOwnership parameter is always ignored, the user of the service must close the object always
osl::ClearableMutexGuard aGuard( m_aMutex );
if ( !(!m_bDisposed && aEvent.Source == m_xInstance && ( m_nMode & embed::Actions::PREVENT_CLOSE )) )
return;
try
{
uno::Reference< embed::XActionsApproval > xApprove = m_xApproval;
// unlock the mutex here
aGuard.clear();
if ( xApprove.is() && xApprove->approveAction( embed::Actions::PREVENT_CLOSE ) )
throw util::CloseVetoException();
}
catch( util::CloseVetoException& )
{
// rethrow this exception
throw;
}
catch( uno::Exception& )
{
// no action should be done
}
}
void SAL_CALL OLockListener::notifyClosing( const lang::EventObject& aEvent )
{
osl::ClearableMutexGuard aGuard( m_aMutex );
// object is closed, no reason to listen
if ( aEvent.Source != m_xInstance )
return;
uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster( aEvent.Source, uno::UNO_QUERY );
if ( !xCloseBroadcaster.is() )
return;
xCloseBroadcaster->removeCloseListener( static_cast< util::XCloseListener* >( this ) );
m_nMode &= ~embed::Actions::PREVENT_CLOSE;
if ( !m_nMode )
{
// dispose the wrapper; // dispose the wrapper;
uno::Reference< lang::XComponent > xComponent( m_xWrapper.get(), uno::UNO_QUERY ); uno::Reference< lang::XComponent > xComponent( m_xWrapper.get(), uno::UNO_QUERY );
aGuard.clear(); aGuard.clear();
@@ -273,91 +332,32 @@ void SAL_CALL OLockListener::disposing( const lang::EventObject& aEvent )
} }
// XCloseListener
void SAL_CALL OLockListener::queryClosing( const lang::EventObject& aEvent, sal_Bool )
{
// GetsOwnership parameter is always ignored, the user of the service must close the object always
osl::ClearableMutexGuard aGuard( m_aMutex );
if ( !m_bDisposed && aEvent.Source == m_xInstance && ( m_nMode & embed::Actions::PREVENT_CLOSE ) )
{
try
{
uno::Reference< embed::XActionsApproval > xApprove = m_xApproval;
// unlock the mutex here
aGuard.clear();
if ( xApprove.is() && xApprove->approveAction( embed::Actions::PREVENT_CLOSE ) )
throw util::CloseVetoException();
}
catch( util::CloseVetoException& )
{
// rethrow this exception
throw;
}
catch( uno::Exception& )
{
// no action should be done
}
}
}
void SAL_CALL OLockListener::notifyClosing( const lang::EventObject& aEvent )
{
osl::ClearableMutexGuard aGuard( m_aMutex );
// object is closed, no reason to listen
if ( aEvent.Source == m_xInstance )
{
uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster( aEvent.Source, uno::UNO_QUERY );
if ( xCloseBroadcaster.is() )
{
xCloseBroadcaster->removeCloseListener( static_cast< util::XCloseListener* >( this ) );
m_nMode &= ~embed::Actions::PREVENT_CLOSE;
if ( !m_nMode )
{
// dispose the wrapper;
uno::Reference< lang::XComponent > xComponent( m_xWrapper.get(), uno::UNO_QUERY );
aGuard.clear();
if ( xComponent.is() )
{
try { xComponent->dispose(); }
catch( uno::Exception& ){}
}
}
}
}
}
// XTerminateListener // XTerminateListener
void SAL_CALL OLockListener::queryTermination( const lang::EventObject& aEvent ) void SAL_CALL OLockListener::queryTermination( const lang::EventObject& aEvent )
{ {
osl::ClearableMutexGuard aGuard( m_aMutex ); osl::ClearableMutexGuard aGuard( m_aMutex );
if ( aEvent.Source == m_xInstance && ( m_nMode & embed::Actions::PREVENT_TERMINATION ) ) if ( !(aEvent.Source == m_xInstance && ( m_nMode & embed::Actions::PREVENT_TERMINATION )) )
return;
try
{ {
try uno::Reference< embed::XActionsApproval > xApprove = m_xApproval;
{
uno::Reference< embed::XActionsApproval > xApprove = m_xApproval;
// unlock the mutex here // unlock the mutex here
aGuard.clear(); aGuard.clear();
if ( xApprove.is() && xApprove->approveAction( embed::Actions::PREVENT_TERMINATION ) ) if ( xApprove.is() && xApprove->approveAction( embed::Actions::PREVENT_TERMINATION ) )
throw frame::TerminationVetoException(); throw frame::TerminationVetoException();
} }
catch( frame::TerminationVetoException& ) catch( frame::TerminationVetoException& )
{ {
// rethrow this exception // rethrow this exception
throw; throw;
} }
catch( uno::Exception& ) catch( uno::Exception& )
{ {
// no action should be done // no action should be done
}
} }
} }
@@ -367,31 +367,31 @@ void SAL_CALL OLockListener::notifyTermination( const lang::EventObject& aEvent
osl::ClearableMutexGuard aGuard( m_aMutex ); osl::ClearableMutexGuard aGuard( m_aMutex );
// object is terminated, no reason to listen // object is terminated, no reason to listen
if ( aEvent.Source == m_xInstance ) if ( aEvent.Source != m_xInstance )
return;
uno::Reference< frame::XDesktop > xDesktop( aEvent.Source, uno::UNO_QUERY );
if ( !xDesktop.is() )
return;
try
{ {
uno::Reference< frame::XDesktop > xDesktop( aEvent.Source, uno::UNO_QUERY ); xDesktop->removeTerminateListener( static_cast< frame::XTerminateListener* >( this ) );
if ( xDesktop.is() ) m_nMode &= ~embed::Actions::PREVENT_TERMINATION;
if ( !m_nMode )
{ {
try // dispose the wrapper;
uno::Reference< lang::XComponent > xComponent( m_xWrapper.get(), uno::UNO_QUERY );
aGuard.clear();
if ( xComponent.is() )
{ {
xDesktop->removeTerminateListener( static_cast< frame::XTerminateListener* >( this ) ); try { xComponent->dispose(); }
m_nMode &= ~embed::Actions::PREVENT_TERMINATION; catch( uno::Exception& ){}
if ( !m_nMode )
{
// dispose the wrapper;
uno::Reference< lang::XComponent > xComponent( m_xWrapper.get(), uno::UNO_QUERY );
aGuard.clear();
if ( xComponent.is() )
{
try { xComponent->dispose(); }
catch( uno::Exception& ){}
}
}
} }
catch( uno::Exception& )
{}
} }
} }
catch( uno::Exception& )
{}
} }

View File

@@ -208,30 +208,30 @@ OfficeInstallationDirectories::getSupportedServiceNames()
void OfficeInstallationDirectories::initDirs() void OfficeInstallationDirectories::initDirs()
{ {
if ( !m_xOfficeBrandDir) if ( m_xOfficeBrandDir)
{ return;
osl::MutexGuard aGuard( m_aMutex );
if ( !m_xOfficeBrandDir )
{
uno::Reference< util::XMacroExpander > xExpander = util::theMacroExpander::get(m_xCtx);
m_xOfficeBrandDir = xExpander->expandMacros( "$BRAND_BASE_DIR" ); osl::MutexGuard aGuard( m_aMutex );
if ( m_xOfficeBrandDir )
return;
OSL_ENSURE( !m_xOfficeBrandDir->isEmpty(), uno::Reference< util::XMacroExpander > xExpander = util::theMacroExpander::get(m_xCtx);
"Unable to obtain office brand installation directory!" );
makeCanonicalFileURL( *m_xOfficeBrandDir ); m_xOfficeBrandDir = xExpander->expandMacros( "$BRAND_BASE_DIR" );
m_xUserDir = OSL_ENSURE( !m_xOfficeBrandDir->isEmpty(),
xExpander->expandMacros( "Unable to obtain office brand installation directory!" );
"${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE( "bootstrap" ) ":UserInstallation}" );
OSL_ENSURE( !m_xUserDir->isEmpty(), makeCanonicalFileURL( *m_xOfficeBrandDir );
"Unable to obtain office user data directory!" );
makeCanonicalFileURL( *m_xUserDir ); m_xUserDir =
} xExpander->expandMacros(
} "${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE( "bootstrap" ) ":UserInstallation}" );
OSL_ENSURE( !m_xUserDir->isEmpty(),
"Unable to obtain office user data directory!" );
makeCanonicalFileURL( *m_xUserDir );
} }
} }

View File

@@ -118,25 +118,25 @@ void SAL_CALL ChainablePropertySet::setPropertyValues(const Sequence< OUString >
if( nCount != rValues.getLength() ) if( nCount != rValues.getLength() )
throw IllegalArgumentException(); throw IllegalArgumentException();
if( nCount ) if( !nCount )
return;
_preSetValues();
const Any * pAny = rValues.getConstArray();
const OUString * pString = rPropertyNames.getConstArray();
PropertyInfoHash::const_iterator aEnd = mxInfo->maMap.end(), aIter;
for ( sal_Int32 i = 0; i < nCount; ++i, ++pString, ++pAny )
{ {
_preSetValues(); aIter = mxInfo->maMap.find ( *pString );
if ( aIter == aEnd )
throw RuntimeException( *pString, static_cast< XPropertySet* >( this ) );
const Any * pAny = rValues.getConstArray(); _setSingleValue ( *((*aIter).second), *pAny );
const OUString * pString = rPropertyNames.getConstArray();
PropertyInfoHash::const_iterator aEnd = mxInfo->maMap.end(), aIter;
for ( sal_Int32 i = 0; i < nCount; ++i, ++pString, ++pAny )
{
aIter = mxInfo->maMap.find ( *pString );
if ( aIter == aEnd )
throw RuntimeException( *pString, static_cast< XPropertySet* >( this ) );
_setSingleValue ( *((*aIter).second), *pAny );
}
_postSetValues();
} }
_postSetValues();
} }
Sequence< Any > SAL_CALL ChainablePropertySet::getPropertyValues(const Sequence< OUString >& rPropertyNames) Sequence< Any > SAL_CALL ChainablePropertySet::getPropertyValues(const Sequence< OUString >& rPropertyNames)

View File

@@ -189,53 +189,53 @@ void SAL_CALL MasterPropertySet::setPropertyValues( const Sequence< OUString >&
if( nCount != aValues.getLength() ) if( nCount != aValues.getLength() )
throw IllegalArgumentException(); throw IllegalArgumentException();
if( nCount ) if( !nCount )
return;
_preSetValues();
const Any * pAny = aValues.getConstArray();
const OUString * pString = aPropertyNames.getConstArray();
PropertyDataHash::const_iterator aEnd = mxInfo->maMap.end(), aIter;
//!! have a unique_ptr to an array of OGuards in order to have the
//!! allocated memory properly freed (exception safe!).
//!! Since the array itself has unique_ptrs as members we have to use a
//!! helper class 'AutoOGuardArray' in order to have
//!! the acquired locks properly released.
AutoOGuardArray aOGuardArray( nCount );
for ( sal_Int32 i = 0; i < nCount; ++i, ++pString, ++pAny )
{ {
_preSetValues(); aIter = mxInfo->maMap.find ( *pString );
if ( aIter == aEnd )
throw RuntimeException( *pString, static_cast< XPropertySet* >( this ) );
const Any * pAny = aValues.getConstArray(); if ( (*aIter).second->mnMapId == 0 ) // 0 means it's one of ours !
const OUString * pString = aPropertyNames.getConstArray(); _setSingleValue( *((*aIter).second->mpInfo), *pAny );
PropertyDataHash::const_iterator aEnd = mxInfo->maMap.end(), aIter; else
//!! have a unique_ptr to an array of OGuards in order to have the
//!! allocated memory properly freed (exception safe!).
//!! Since the array itself has unique_ptrs as members we have to use a
//!! helper class 'AutoOGuardArray' in order to have
//!! the acquired locks properly released.
AutoOGuardArray aOGuardArray( nCount );
for ( sal_Int32 i = 0; i < nCount; ++i, ++pString, ++pAny )
{ {
aIter = mxInfo->maMap.find ( *pString ); SlaveData * pSlave = maSlaveMap [ (*aIter).second->mnMapId ];
if ( aIter == aEnd ) if (!pSlave->IsInit())
throw RuntimeException( *pString, static_cast< XPropertySet* >( this ) );
if ( (*aIter).second->mnMapId == 0 ) // 0 means it's one of ours !
_setSingleValue( *((*aIter).second->mpInfo), *pAny );
else
{ {
SlaveData * pSlave = maSlaveMap [ (*aIter).second->mnMapId ]; // acquire mutex in c-tor and releases it in the d-tor (exception safe!).
if (!pSlave->IsInit()) if (pSlave->mxSlave->mpMutex)
{ aOGuardArray[i].reset( new osl::Guard< comphelper::SolarMutex >(pSlave->mxSlave->mpMutex) );
// acquire mutex in c-tor and releases it in the d-tor (exception safe!).
if (pSlave->mxSlave->mpMutex)
aOGuardArray[i].reset( new osl::Guard< comphelper::SolarMutex >(pSlave->mxSlave->mpMutex) );
pSlave->mxSlave->_preSetValues(); pSlave->mxSlave->_preSetValues();
pSlave->SetInit ( true ); pSlave->SetInit ( true );
}
pSlave->mxSlave->_setSingleValue( *((*aIter).second->mpInfo), *pAny );
} }
pSlave->mxSlave->_setSingleValue( *((*aIter).second->mpInfo), *pAny );
} }
}
_postSetValues(); _postSetValues();
for( const auto& rSlave : maSlaveMap ) for( const auto& rSlave : maSlaveMap )
{
if( rSlave.second->IsInit() )
{ {
if( rSlave.second->IsInit() ) rSlave.second->mxSlave->_postSetValues();
{ rSlave.second->SetInit( false );
rSlave.second->mxSlave->_postSetValues();
rSlave.second->SetInit( false );
}
} }
} }
} }

View File

@@ -99,23 +99,23 @@ GenericPropertySet::GenericPropertySet( PropertySetInfo* pInfo ) throw()
void SAL_CALL GenericPropertySet::addPropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& xListener ) void SAL_CALL GenericPropertySet::addPropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& xListener )
{ {
Reference < XPropertySetInfo > xInfo = getPropertySetInfo( ); Reference < XPropertySetInfo > xInfo = getPropertySetInfo( );
if ( xInfo.is() ) if ( !xInfo.is() )
return;
if ( aPropertyName.isEmpty() )
{ {
if ( aPropertyName.isEmpty() ) Sequence< Property> aSeq = xInfo->getProperties();
const Property* pIter = aSeq.getConstArray();
const Property* pEnd = pIter + aSeq.getLength();
for( ; pIter != pEnd ; ++pIter)
{ {
Sequence< Property> aSeq = xInfo->getProperties(); m_aListener.addInterface(pIter->Name,xListener);
const Property* pIter = aSeq.getConstArray();
const Property* pEnd = pIter + aSeq.getLength();
for( ; pIter != pEnd ; ++pIter)
{
m_aListener.addInterface(pIter->Name,xListener);
}
} }
else if ( xInfo->hasPropertyByName(aPropertyName) )
m_aListener.addInterface(aPropertyName,xListener);
else
throw UnknownPropertyException( aPropertyName, *this );
} }
else if ( xInfo->hasPropertyByName(aPropertyName) )
m_aListener.addInterface(aPropertyName,xListener);
else
throw UnknownPropertyException( aPropertyName, *this );
} }
void SAL_CALL GenericPropertySet::removePropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& xListener ) void SAL_CALL GenericPropertySet::removePropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& xListener )
@@ -123,23 +123,23 @@ void SAL_CALL GenericPropertySet::removePropertyChangeListener( const OUString&
ClearableMutexGuard aGuard( maMutex ); ClearableMutexGuard aGuard( maMutex );
Reference < XPropertySetInfo > xInfo = getPropertySetInfo( ); Reference < XPropertySetInfo > xInfo = getPropertySetInfo( );
aGuard.clear(); aGuard.clear();
if ( xInfo.is() ) if ( !xInfo.is() )
return;
if ( aPropertyName.isEmpty() )
{ {
if ( aPropertyName.isEmpty() ) Sequence< Property> aSeq = xInfo->getProperties();
const Property* pIter = aSeq.getConstArray();
const Property* pEnd = pIter + aSeq.getLength();
for( ; pIter != pEnd ; ++pIter)
{ {
Sequence< Property> aSeq = xInfo->getProperties(); m_aListener.removeInterface(pIter->Name,xListener);
const Property* pIter = aSeq.getConstArray();
const Property* pEnd = pIter + aSeq.getLength();
for( ; pIter != pEnd ; ++pIter)
{
m_aListener.removeInterface(pIter->Name,xListener);
}
} }
else if ( xInfo->hasPropertyByName(aPropertyName) )
m_aListener.removeInterface(aPropertyName,xListener);
else
throw UnknownPropertyException( aPropertyName, *this );
} }
else if ( xInfo->hasPropertyByName(aPropertyName) )
m_aListener.removeInterface(aPropertyName,xListener);
else
throw UnknownPropertyException( aPropertyName, *this );
} }
void GenericPropertySet::_setPropertyValues( const PropertyMapEntry** ppEntries, const Any* pValues ) void GenericPropertySet::_setPropertyValues( const PropertyMapEntry** ppEntries, const Any* pValues )

View File

@@ -144,19 +144,20 @@ namespace comphelper
::osl::MutexGuard aGuard( m_aMutex ); ::osl::MutexGuard aGuard( m_aMutex );
m_isModified = bModified; m_isModified = bModified;
} }
if (bModified) { if (!bModified)
try { return;
Reference<XInterface> xThis(*this);
EventObject event(xThis); try {
m_NotifyListeners.notifyEach( Reference<XInterface> xThis(*this);
&XModifyListener::modified, event); EventObject event(xThis);
} catch (RuntimeException &) { m_NotifyListeners.notifyEach(
if (!bIgnoreRuntimeExceptionsWhileFiring) { &XModifyListener::modified, event);
throw; } catch (RuntimeException &) {
} if (!bIgnoreRuntimeExceptionsWhileFiring) {
} catch (Exception &) { throw;
// ignore
} }
} catch (Exception &) {
// ignore
} }
} }

View File

@@ -298,28 +298,28 @@ namespace internal
void PropertyForwarder::doForward( sal_Int32 _nHandle, const Any& _rValue ) void PropertyForwarder::doForward( sal_Int32 _nHandle, const Any& _rValue )
{ {
OSL_ENSURE( m_rAggregationHelper.m_xAggregateSet.is(), "PropertyForwarder::doForward: no property set!" ); OSL_ENSURE( m_rAggregationHelper.m_xAggregateSet.is(), "PropertyForwarder::doForward: no property set!" );
if ( m_rAggregationHelper.m_xAggregateSet.is() ) if ( !m_rAggregationHelper.m_xAggregateSet.is() )
return;
m_rAggregationHelper.forwardingPropertyValue( _nHandle );
OSL_ENSURE( m_nCurrentlyForwarding == -1, "PropertyForwarder::doForward: reentrance?" );
m_nCurrentlyForwarding = _nHandle;
try
{ {
m_rAggregationHelper.forwardingPropertyValue( _nHandle ); m_rAggregationHelper.m_xAggregateSet->setPropertyValue( m_rAggregationHelper.getPropertyName( _nHandle ), _rValue );
// TODO: cache the property name? (it's a O(log n) search)
OSL_ENSURE( m_nCurrentlyForwarding == -1, "PropertyForwarder::doForward: reentrance?" );
m_nCurrentlyForwarding = _nHandle;
try
{
m_rAggregationHelper.m_xAggregateSet->setPropertyValue( m_rAggregationHelper.getPropertyName( _nHandle ), _rValue );
// TODO: cache the property name? (it's a O(log n) search)
}
catch( const Exception& )
{
m_rAggregationHelper.forwardedPropertyValue( _nHandle );
throw;
}
m_nCurrentlyForwarding = -1;
m_rAggregationHelper.forwardedPropertyValue( _nHandle );
} }
catch( const Exception& )
{
m_rAggregationHelper.forwardedPropertyValue( _nHandle );
throw;
}
m_nCurrentlyForwarding = -1;
m_rAggregationHelper.forwardedPropertyValue( _nHandle );
} }
} }

View File

@@ -129,26 +129,26 @@ void SAL_CALL PropertySetHelper::setPropertyValues( const Sequence< OUString >&
if( nCount != rValues.getLength() ) if( nCount != rValues.getLength() )
throw IllegalArgumentException(); throw IllegalArgumentException();
if( nCount ) if( !nCount )
return;
std::unique_ptr<PropertyMapEntry const *[]> pEntries(new PropertyMapEntry const *[nCount+1]);
pEntries[nCount] = nullptr;
const OUString* pNames = rPropertyNames.getConstArray();
bool bUnknown = false;
sal_Int32 n;
for( n = 0; !bUnknown && ( n < nCount ); n++, pNames++ )
{ {
std::unique_ptr<PropertyMapEntry const *[]> pEntries(new PropertyMapEntry const *[nCount+1]); pEntries[n] = mpImpl->find( *pNames );
pEntries[nCount] = nullptr; bUnknown = nullptr == pEntries[n];
const OUString* pNames = rPropertyNames.getConstArray();
bool bUnknown = false;
sal_Int32 n;
for( n = 0; !bUnknown && ( n < nCount ); n++, pNames++ )
{
pEntries[n] = mpImpl->find( *pNames );
bUnknown = nullptr == pEntries[n];
}
if( !bUnknown )
_setPropertyValues( pEntries.get(), rValues.getConstArray() );
if( bUnknown )
throw RuntimeException( *pNames, static_cast< XPropertySet* >( this ) );
} }
if( !bUnknown )
_setPropertyValues( pEntries.get(), rValues.getConstArray() );
if( bUnknown )
throw RuntimeException( *pNames, static_cast< XPropertySet* >( this ) );
} }
Sequence< Any > SAL_CALL PropertySetHelper::getPropertyValues(const Sequence< OUString >& rPropertyNames) Sequence< Any > SAL_CALL PropertySetHelper::getPropertyValues(const Sequence< OUString >& rPropertyNames)

View File

@@ -89,21 +89,21 @@ void OPropertyChangeMultiplexer::unlock()
void OPropertyChangeMultiplexer::dispose() void OPropertyChangeMultiplexer::dispose()
{ {
if (m_bListening) if (!m_bListening)
{ return;
Reference< XPropertyChangeListener> xPreventDelete(this);
for (const OUString& rProp : m_aProperties) Reference< XPropertyChangeListener> xPreventDelete(this);
m_xSet->removePropertyChangeListener(rProp, static_cast< XPropertyChangeListener*>(this));
m_pListener->setAdapter(nullptr); for (const OUString& rProp : m_aProperties)
m_xSet->removePropertyChangeListener(rProp, static_cast< XPropertyChangeListener*>(this));
m_pListener = nullptr; m_pListener->setAdapter(nullptr);
m_bListening = false;
if (m_bAutoSetRelease) m_pListener = nullptr;
m_xSet = nullptr; m_bListening = false;
}
if (m_bAutoSetRelease)
m_xSet = nullptr;
} }
// XEventListener // XEventListener

View File

@@ -191,24 +191,24 @@ sal_Int64 SAL_CALL UNOMemoryStream::getLength()
void SAL_CALL UNOMemoryStream::writeBytes( const Sequence< sal_Int8 >& aData ) void SAL_CALL UNOMemoryStream::writeBytes( const Sequence< sal_Int8 >& aData )
{ {
const sal_Int32 nBytesToWrite( aData.getLength() ); const sal_Int32 nBytesToWrite( aData.getLength() );
if( nBytesToWrite ) if( !nBytesToWrite )
return;
sal_Int64 nNewSize = static_cast<sal_Int64>(mnCursor) + nBytesToWrite;
if( nNewSize > SAL_MAX_INT32 )
{ {
sal_Int64 nNewSize = static_cast<sal_Int64>(mnCursor) + nBytesToWrite; OSL_ASSERT(false);
if( nNewSize > SAL_MAX_INT32 ) throw IOException("this implementation does not support more than 2GB!", static_cast<OWeakObject*>(this) );
{
OSL_ASSERT(false);
throw IOException("this implementation does not support more than 2GB!", static_cast<OWeakObject*>(this) );
}
if( static_cast< sal_Int32 >( nNewSize ) > static_cast< sal_Int32 >( maData.size() ) )
maData.resize( nNewSize );
sal_Int8* pData = &(*maData.begin());
sal_Int8* pCursor = &(pData[mnCursor]);
memcpy( pCursor, aData.getConstArray(), nBytesToWrite );
mnCursor += nBytesToWrite;
} }
if( static_cast< sal_Int32 >( nNewSize ) > static_cast< sal_Int32 >( maData.size() ) )
maData.resize( nNewSize );
sal_Int8* pData = &(*maData.begin());
sal_Int8* pCursor = &(pData[mnCursor]);
memcpy( pCursor, aData.getConstArray(), nBytesToWrite );
mnCursor += nBytesToWrite;
} }
void SAL_CALL UNOMemoryStream::flush() void SAL_CALL UNOMemoryStream::flush()