[Libreoffice-commits] core.git: comphelper/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Sat Apr 18 19:47:13 UTC 2020
comphelper/source/container/containermultiplexer.cxx | 26
comphelper/source/container/embeddedobjectcontainer.cxx | 90 +--
comphelper/source/eventattachermgr/eventattachermgr.cxx | 28
comphelper/source/misc/DirectoryHelper.cxx | 56 -
comphelper/source/misc/accessiblecontexthelper.cxx | 22
comphelper/source/misc/backupfilehelper.cxx | 294 +++++-----
comphelper/source/misc/instancelocker.cxx | 166 ++---
comphelper/source/officeinstdir/officeinstallationdirectories.cxx | 36 -
comphelper/source/property/ChainablePropertySet.cxx | 28
comphelper/source/property/MasterPropertySet.cxx | 74 +-
comphelper/source/property/genericpropertyset.cxx | 52 -
comphelper/source/property/opropertybag.cxx | 25
comphelper/source/property/propagg.cxx | 34 -
comphelper/source/property/propertysethelper.cxx | 34 -
comphelper/source/property/propmultiplex.cxx | 22
comphelper/source/streaming/memorystream.cxx | 28
16 files changed, 508 insertions(+), 507 deletions(-)
New commits:
commit 8d4fd3418322f3f6852054c44be2cd74b0db76ee
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Sat Apr 18 11:35:04 2020 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Apr 18 21:46:33 2020 +0200
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 at collabora.co.uk>
diff --git a/comphelper/source/container/containermultiplexer.cxx b/comphelper/source/container/containermultiplexer.cxx
index 0d23c0e04d0a..c687e72793ad 100644
--- a/comphelper/source/container/containermultiplexer.cxx
+++ b/comphelper/source/container/containermultiplexer.cxx
@@ -98,21 +98,21 @@ namespace comphelper
void OContainerListenerAdapter::dispose()
{
- if (m_xContainer.is())
+ if (!m_xContainer.is())
+ return;
+
+ try
{
- try
- {
- Reference< XContainerListener > xPreventDelete(this);
- m_xContainer->removeContainerListener(xPreventDelete);
- m_pListener->setAdapter(nullptr);
- }
- catch(const Exception&)
- {
- OSL_FAIL("Exception caught!");
- }
- m_xContainer = nullptr;
- m_pListener = nullptr;
+ Reference< XContainerListener > xPreventDelete(this);
+ m_xContainer->removeContainerListener(xPreventDelete);
+ m_pListener->setAdapter(nullptr);
}
+ catch(const Exception&)
+ {
+ OSL_FAIL("Exception caught!");
+ }
+ m_xContainer = nullptr;
+ m_pListener = nullptr;
}
diff --git a/comphelper/source/container/embeddedobjectcontainer.cxx b/comphelper/source/container/embeddedobjectcontainer.cxx
index aa818d78ce5e..0b35e929ba15 100644
--- a/comphelper/source/container/embeddedobjectcontainer.cxx
+++ b/comphelper/source/container/embeddedobjectcontainer.cxx
@@ -423,42 +423,42 @@ void EmbeddedObjectContainer::AddEmbeddedObject( const css::uno::Reference < css
xChild->setParent( pImpl->m_xModel.get() );
// look for object in temporary container
- if ( pImpl->mpTempObjectContainer )
- {
- 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())
- {
- // 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 );
- }
+ if ( !pImpl->mpTempObjectContainer )
+ return;
- // 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&)
- {
- }
- }
+ 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() )
+ {
+ InsertGraphicStream( xStream, rName, aMediaType );
+ xStream = nullptr;
+ pImpl->mpTempObjectContainer->RemoveGraphicStream( aTempName );
+ }
- // temp. container needs to forget the object
- pImpl->mpTempObjectContainer->pImpl->maObjectToNameMap.erase( aIter->second );
- pImpl->mpTempObjectContainer->pImpl->maNameToObjectMap.erase( aIter );
+ // 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 );
}
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(),
[&xObj](const EmbeddedObjectContainerNameMap::value_type& rEntry) { return rEntry.second == xObj; });
- if (aIter != pImpl->maNameToObjectMap.end())
- {
- pImpl->maObjectToNameMap.erase( aIter->second );
- pImpl->maNameToObjectMap.erase( aIter );
+ if (aIter == pImpl->maNameToObjectMap.end())
+ return;
- try
- {
- xObj->close( true );
- }
- catch (const uno::Exception&)
- {
- // it is no problem if the object is already closed
- // TODO/LATER: what if the object can not be closed?
- }
+ pImpl->maObjectToNameMap.erase( aIter->second );
+ pImpl->maNameToObjectMap.erase( aIter );
+
+ try
+ {
+ xObj->close( true );
+ }
+ catch (const uno::Exception&)
+ {
+ // it is no problem if the object is already closed
+ // TODO/LATER: what if the object can not be closed?
}
}
diff --git a/comphelper/source/eventattachermgr/eventattachermgr.cxx b/comphelper/source/eventattachermgr/eventattachermgr.cxx
index 9d7561fc9ef9..e92b7fc70e1a 100644
--- a/comphelper/source/eventattachermgr/eventattachermgr.cxx
+++ b/comphelper/source/eventattachermgr/eventattachermgr.cxx
@@ -594,26 +594,26 @@ void SAL_CALL ImplEventAttacherManager::detach(sal_Int32 nIndex, const Reference
std::deque< AttacherIndex_Impl >::iterator aCurrentPosition = aIndex.begin() + nIndex;
auto aObjIt = std::find_if(aCurrentPosition->aObjList.begin(), aCurrentPosition->aObjList.end(),
[&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;
- for( const auto& rEvt : aCurrentPosition->aEventList )
+ if( aObjIt->aAttachedListenerSeq[i].is() )
{
- 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)
diff --git a/comphelper/source/misc/DirectoryHelper.cxx b/comphelper/source/misc/DirectoryHelper.cxx
index fa5380d425dd..5b0ffbf68465 100644
--- a/comphelper/source/misc/DirectoryHelper.cxx
+++ b/comphelper/source/misc/DirectoryHelper.cxx
@@ -69,41 +69,41 @@ bool DirectoryHelper::dirExists(const OUString& rDirURL)
void DirectoryHelper::scanDirsAndFiles(const OUString& rDirURL, std::set<OUString>& rDirs,
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())
+ {
+ const OUString aFileName(aFileStatus.getFileName());
- while (osl::FileBase::E_None == aDirectory.getNextItem(aDirectoryItem))
+ if (!aFileName.isEmpty())
+ {
+ rDirs.insert(aFileName);
+ }
+ }
+ else if (aFileStatus.isRegular())
{
- osl::FileStatus aFileStatus(osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileURL
- | osl_FileStatus_Mask_FileName);
+ OUString aFileName(aFileStatus.getFileName());
+ OUString aExtension;
+ aFileName = splitAtLastToken(aFileName, '.', aExtension);
- if (osl::FileBase::E_None == aDirectoryItem.getFileStatus(aFileStatus))
+ if (!aFileName.isEmpty())
{
- if (aFileStatus.isDirectory())
- {
- const OUString aFileName(aFileStatus.getFileName());
-
- if (!aFileName.isEmpty())
- {
- rDirs.insert(aFileName);
- }
- }
- 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));
- }
- }
+ rFiles.insert(std::pair<OUString, OUString>(aFileName, aExtension));
}
}
}
diff --git a/comphelper/source/misc/accessiblecontexthelper.cxx b/comphelper/source/misc/accessiblecontexthelper.cxx
index 463c9735f228..a4d11cb59c1a 100644
--- a/comphelper/source/misc/accessiblecontexthelper.cxx
+++ b/comphelper/source/misc/accessiblecontexthelper.cxx
@@ -124,18 +124,18 @@ namespace comphelper
if ( !isAlive() )
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 );
- if ( !nListenerCount )
- {
- // no listeners anymore
- // -> 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
- // NotifyAccessibleEvent, again
- AccessibleEventNotifier::revokeClient( m_pImpl->getClientId( ) );
- m_pImpl->setClientId( 0 );
- }
+ // no listeners anymore
+ // -> 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
+ // NotifyAccessibleEvent, again
+ AccessibleEventNotifier::revokeClient( m_pImpl->getClientId( ) );
+ m_pImpl->setClientId( 0 );
}
}
diff --git a/comphelper/source/misc/backupfilehelper.cxx b/comphelper/source/misc/backupfilehelper.cxx
index e58fe768f15b..e443c384d85b 100644
--- a/comphelper/source/misc/backupfilehelper.cxx
+++ b/comphelper/source/misc/backupfilehelper.cxx
@@ -436,46 +436,46 @@ namespace
private:
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 OUString aAttrRevoked(rElement->getAttribute("revoked"));
+ const sal_Int32 nIndex(aAttrUrl.lastIndexOf('/'));
- if (!aAttrUrl.isEmpty())
+ if (nIndex > 0 && aAttrUrl.getLength() > nIndex + 1)
{
- const sal_Int32 nIndex(aAttrUrl.lastIndexOf('/'));
-
- 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);
+ aAttrUrl = aAttrUrl.copy(nIndex + 1);
}
+
+ 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);
-
- if (aChild.is())
- {
- visitNodesXMLRead(aChild);
- }
+ visitNodesXMLRead(aChild);
}
}
}
@@ -605,58 +605,58 @@ namespace
const ExtensionInfoEntryVector& rToBeEnabled,
const ExtensionInfoEntryVector& rToBeDisabled)
{
- if (DirectoryHelper::fileExists(rUnoPackagReg))
- {
- 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 (!DirectoryHelper::fileExists(rUnoPackagReg))
+ return;
- if (aDocument.is())
- {
- if (visitNodesXMLChange(
- rTagToSearch,
- aDocument->getDocumentElement(),
- rToBeEnabled,
- rToBeDisabled))
- {
- // did change - write back
- uno::Reference< xml::sax::XSAXSerializable > xSerializer(aDocument, uno::UNO_QUERY);
+ 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 (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 (!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))
+ {
+ osl::File::remove(rUnoPackagReg);
+ }
#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
- osl::File::move(aTempURL, rUnoPackagReg);
+ osl::File::move(aTempURL, rUnoPackagReg);
#endif
- }
- }
- }
- }
- }
}
public:
@@ -1602,45 +1602,45 @@ namespace comphelper
// ensure existence of needed paths
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
- aExcludeList.insert(getSafeModeName());
+ // do not move SafeMode directory itself
+ aExcludeList.insert(getSafeModeName());
- // init SafeMode by creating the 'SafeMode' directory and moving
- // all stuff there. All repairs will happen there. Both Dirs have to exist.
- // extend maUserConfigWorkURL as needed
- maUserConfigWorkURL = maUserConfigBaseURL + "/" + getSafeModeName();
+ // init SafeMode by creating the 'SafeMode' directory and moving
+ // all stuff there. All repairs will happen there. Both Dirs have to exist.
+ // extend maUserConfigWorkURL as needed
+ maUserConfigWorkURL = maUserConfigBaseURL + "/" + getSafeModeName();
- osl::Directory::createPath(maUserConfigWorkURL);
- DirectoryHelper::moveDirContent(maUserConfigBaseURL, maUserConfigWorkURL, aExcludeList);
+ osl::Directory::createPath(maUserConfigWorkURL);
+ DirectoryHelper::moveDirContent(maUserConfigBaseURL, maUserConfigWorkURL, aExcludeList);
- // switch local flag, maUserConfigWorkURL is already reset
- mbSafeModeDirExists = true;
- }
+ // switch local flag, maUserConfigWorkURL is already reset
+ 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.
- // Both Dirs have to exist
- std::set< OUString > aExcludeList;
+ // SafeMode has ended, return to normal mode by moving all content
+ // from 'SafeMode' directory back to UserDirectory and deleting it.
+ // Both Dirs have to exist
+ std::set< OUString > aExcludeList;
- DirectoryHelper::moveDirContent(maUserConfigWorkURL, maUserConfigBaseURL, aExcludeList);
- osl::Directory::remove(maUserConfigWorkURL);
+ DirectoryHelper::moveDirContent(maUserConfigWorkURL, maUserConfigBaseURL, aExcludeList);
+ osl::Directory::remove(maUserConfigWorkURL);
- // switch local flag and reset maUserConfigWorkURL
- mbSafeModeDirExists = false;
- maUserConfigWorkURL = maUserConfigBaseURL;
- }
+ // switch local flag and reset maUserConfigWorkURL
+ mbSafeModeDirExists = false;
+ maUserConfigWorkURL = maUserConfigBaseURL;
}
}
}
@@ -1650,22 +1650,22 @@ namespace comphelper
// no push when SafeModeDir exists, it may be Office's exit after SafeMode
// where SafeMode flag is already deleted, but SafeModeDir cleanup is not
// done yet (is done at next startup)
- if (mbActive && !mbSafeModeDirExists)
- {
- const OUString aPackURL(getPackURL());
+ if (!(mbActive && !mbSafeModeDirExists))
+ return;
- // ensure dir and file vectors
- fillDirFileInfo();
+ const OUString aPackURL(getPackURL());
- // process all files in question recursively
- if (!maDirs.empty() || !maFiles.empty())
- {
- tryPush_Files(
- maDirs,
- maFiles,
- maUserConfigWorkURL,
- aPackURL);
- }
+ // ensure dir and file vectors
+ fillDirFileInfo();
+
+ // 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()
{
- if (mbActive)
- {
- bool bDidPop(false);
- const OUString aPackURL(getPackURL());
+ if (!mbActive)
+ return;
- // ensure dir and file vectors
- fillDirFileInfo();
+ bool bDidPop(false);
+ const OUString aPackURL(getPackURL());
- // process all files in question recursively
- if (!maDirs.empty() || !maFiles.empty())
- {
- bDidPop = tryPop_files(
- maDirs,
- maFiles,
- maUserConfigWorkURL,
- aPackURL);
- }
+ // ensure dir and file vectors
+ fillDirFileInfo();
- if (bDidPop)
- {
- // try removal of evtl. empty directory
- osl::Directory::remove(aPackURL);
- }
+ // process all files in question recursively
+ 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()
{
- if (mbActive && mbExtensions)
- {
- bool bDidPop(false);
- const OUString aPackURL(getPackURL());
+ if (!(mbActive && mbExtensions))
+ return;
- bDidPop = tryPop_extensionInfo(aPackURL);
+ bool bDidPop(false);
+ const OUString aPackURL(getPackURL());
- if (bDidPop)
- {
- // try removal of evtl. empty directory
- osl::Directory::remove(aPackURL);
- }
+ bDidPop = tryPop_extensionInfo(aPackURL);
+
+ if (bDidPop)
+ {
+ // try removal of evtl. empty directory
+ osl::Directory::remove(aPackURL);
}
}
diff --git a/comphelper/source/misc/instancelocker.cxx b/comphelper/source/misc/instancelocker.cxx
index ad581840d01d..c32747e26514 100644
--- a/comphelper/source/misc/instancelocker.cxx
+++ b/comphelper/source/misc/instancelocker.cxx
@@ -256,19 +256,19 @@ void SAL_CALL OLockListener::disposing( const lang::EventObject& aEvent )
osl::ClearableMutexGuard aGuard( m_aMutex );
// object is disposed
- if ( aEvent.Source == m_xInstance )
- {
- // the object does not listen for anything any more
- m_nMode = 0;
+ if ( aEvent.Source != m_xInstance )
+ return;
- // 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& ){}
- }
+ // 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& ){}
}
}
@@ -279,27 +279,27 @@ void SAL_CALL OLockListener::queryClosing( const lang::EventObject& aEvent, sal_
{
// 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 ) )
+ if ( !(!m_bDisposed && aEvent.Source == m_xInstance && ( m_nMode & embed::Actions::PREVENT_CLOSE )) )
+ return;
+
+ try
{
- try
- {
- uno::Reference< embed::XActionsApproval > xApprove = m_xApproval;
+ uno::Reference< embed::XActionsApproval > xApprove = m_xApproval;
- // unlock the mutex here
- aGuard.clear();
+ // 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
- }
+ 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
}
}
@@ -309,24 +309,24 @@ 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 )
+ 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 )
{
- uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster( aEvent.Source, uno::UNO_QUERY );
- if ( xCloseBroadcaster.is() )
+ // dispose the wrapper;
+ uno::Reference< lang::XComponent > xComponent( m_xWrapper.get(), uno::UNO_QUERY );
+ aGuard.clear();
+ if ( xComponent.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& ){}
- }
- }
+ try { xComponent->dispose(); }
+ catch( uno::Exception& ){}
}
}
}
@@ -337,27 +337,27 @@ void SAL_CALL OLockListener::notifyClosing( const lang::EventObject& aEvent )
void SAL_CALL OLockListener::queryTermination( const lang::EventObject& aEvent )
{
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
- aGuard.clear();
+ // unlock the mutex here
+ aGuard.clear();
- if ( xApprove.is() && xApprove->approveAction( embed::Actions::PREVENT_TERMINATION ) )
- throw frame::TerminationVetoException();
- }
- catch( frame::TerminationVetoException& )
- {
- // rethrow this exception
- throw;
- }
- catch( uno::Exception& )
- {
- // no action should be done
- }
+ if ( xApprove.is() && xApprove->approveAction( embed::Actions::PREVENT_TERMINATION ) )
+ throw frame::TerminationVetoException();
+ }
+ catch( frame::TerminationVetoException& )
+ {
+ // rethrow this exception
+ throw;
+ }
+ catch( uno::Exception& )
+ {
+ // no action should be done
}
}
@@ -367,31 +367,31 @@ void SAL_CALL OLockListener::notifyTermination( const lang::EventObject& aEvent
osl::ClearableMutexGuard aGuard( m_aMutex );
// 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 );
- if ( xDesktop.is() )
+ xDesktop->removeTerminateListener( static_cast< frame::XTerminateListener* >( this ) );
+ 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 ) );
- m_nMode &= ~embed::Actions::PREVENT_TERMINATION;
- 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& ){}
- }
- }
+ try { xComponent->dispose(); }
+ catch( uno::Exception& ){}
}
- catch( uno::Exception& )
- {}
}
}
+ catch( uno::Exception& )
+ {}
}
diff --git a/comphelper/source/officeinstdir/officeinstallationdirectories.cxx b/comphelper/source/officeinstdir/officeinstallationdirectories.cxx
index dec66895e940..b255fd3b9d44 100644
--- a/comphelper/source/officeinstdir/officeinstallationdirectories.cxx
+++ b/comphelper/source/officeinstdir/officeinstallationdirectories.cxx
@@ -208,30 +208,30 @@ OfficeInstallationDirectories::getSupportedServiceNames()
void OfficeInstallationDirectories::initDirs()
{
- if ( !m_xOfficeBrandDir)
- {
- osl::MutexGuard aGuard( m_aMutex );
- if ( !m_xOfficeBrandDir )
- {
- uno::Reference< util::XMacroExpander > xExpander = util::theMacroExpander::get(m_xCtx);
+ if ( m_xOfficeBrandDir)
+ return;
- m_xOfficeBrandDir = xExpander->expandMacros( "$BRAND_BASE_DIR" );
+ osl::MutexGuard aGuard( m_aMutex );
+ if ( m_xOfficeBrandDir )
+ return;
- OSL_ENSURE( !m_xOfficeBrandDir->isEmpty(),
- "Unable to obtain office brand installation directory!" );
+ uno::Reference< util::XMacroExpander > xExpander = util::theMacroExpander::get(m_xCtx);
- makeCanonicalFileURL( *m_xOfficeBrandDir );
+ m_xOfficeBrandDir = xExpander->expandMacros( "$BRAND_BASE_DIR" );
- m_xUserDir =
- xExpander->expandMacros(
- "${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE( "bootstrap" ) ":UserInstallation}" );
+ OSL_ENSURE( !m_xOfficeBrandDir->isEmpty(),
+ "Unable to obtain office brand installation directory!" );
- OSL_ENSURE( !m_xUserDir->isEmpty(),
- "Unable to obtain office user data directory!" );
+ makeCanonicalFileURL( *m_xOfficeBrandDir );
- 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 );
}
}
diff --git a/comphelper/source/property/ChainablePropertySet.cxx b/comphelper/source/property/ChainablePropertySet.cxx
index 258b6dad0495..c4f0d018641d 100644
--- a/comphelper/source/property/ChainablePropertySet.cxx
+++ b/comphelper/source/property/ChainablePropertySet.cxx
@@ -118,25 +118,25 @@ void SAL_CALL ChainablePropertySet::setPropertyValues(const Sequence< OUString >
if( nCount != rValues.getLength() )
throw IllegalArgumentException();
- if( nCount )
- {
- _preSetValues();
+ if( !nCount )
+ return;
- const Any * pAny = rValues.getConstArray();
- const OUString * pString = rPropertyNames.getConstArray();
- PropertyInfoHash::const_iterator aEnd = mxInfo->maMap.end(), aIter;
+ _preSetValues();
- 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 ) );
+ const Any * pAny = rValues.getConstArray();
+ const OUString * pString = rPropertyNames.getConstArray();
+ PropertyInfoHash::const_iterator aEnd = mxInfo->maMap.end(), aIter;
- _setSingleValue ( *((*aIter).second), *pAny );
- }
+ 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 ) );
- _postSetValues();
+ _setSingleValue ( *((*aIter).second), *pAny );
}
+
+ _postSetValues();
}
Sequence< Any > SAL_CALL ChainablePropertySet::getPropertyValues(const Sequence< OUString >& rPropertyNames)
diff --git a/comphelper/source/property/MasterPropertySet.cxx b/comphelper/source/property/MasterPropertySet.cxx
index 82f9d85d7525..e5e94b5ad46f 100644
--- a/comphelper/source/property/MasterPropertySet.cxx
+++ b/comphelper/source/property/MasterPropertySet.cxx
@@ -189,53 +189,53 @@ void SAL_CALL MasterPropertySet::setPropertyValues( const Sequence< OUString >&
if( nCount != aValues.getLength() )
throw IllegalArgumentException();
- if( nCount )
- {
- _preSetValues();
+ if( !nCount )
+ return;
- const Any * pAny = aValues.getConstArray();
- const OUString * pString = aPropertyNames.getConstArray();
- PropertyDataHash::const_iterator aEnd = mxInfo->maMap.end(), aIter;
+ _preSetValues();
- //!! 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 );
+ const Any * pAny = aValues.getConstArray();
+ const OUString * pString = aPropertyNames.getConstArray();
+ PropertyDataHash::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 ) );
+ //!! 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 );
- if ( (*aIter).second->mnMapId == 0 ) // 0 means it's one of ours !
- _setSingleValue( *((*aIter).second->mpInfo), *pAny );
- else
+ 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 ) );
+
+ if ( (*aIter).second->mnMapId == 0 ) // 0 means it's one of ours !
+ _setSingleValue( *((*aIter).second->mpInfo), *pAny );
+ else
+ {
+ SlaveData * pSlave = maSlaveMap [ (*aIter).second->mnMapId ];
+ if (!pSlave->IsInit())
{
- SlaveData * pSlave = maSlaveMap [ (*aIter).second->mnMapId ];
- if (!pSlave->IsInit())
- {
- // 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) );
+ // 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->SetInit ( true );
- }
- pSlave->mxSlave->_setSingleValue( *((*aIter).second->mpInfo), *pAny );
+ pSlave->mxSlave->_preSetValues();
+ pSlave->SetInit ( true );
}
+ pSlave->mxSlave->_setSingleValue( *((*aIter).second->mpInfo), *pAny );
}
+ }
- _postSetValues();
- for( const auto& rSlave : maSlaveMap )
+ _postSetValues();
+ 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 );
}
}
}
diff --git a/comphelper/source/property/genericpropertyset.cxx b/comphelper/source/property/genericpropertyset.cxx
index 298cb53b9c73..fd591774cdeb 100644
--- a/comphelper/source/property/genericpropertyset.cxx
+++ b/comphelper/source/property/genericpropertyset.cxx
@@ -99,23 +99,23 @@ GenericPropertySet::GenericPropertySet( PropertySetInfo* pInfo ) throw()
void SAL_CALL GenericPropertySet::addPropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& xListener )
{
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();
- const Property* pIter = aSeq.getConstArray();
- const Property* pEnd = pIter + aSeq.getLength();
- for( ; pIter != pEnd ; ++pIter)
- {
- m_aListener.addInterface(pIter->Name,xListener);
- }
+ 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 )
@@ -123,23 +123,23 @@ void SAL_CALL GenericPropertySet::removePropertyChangeListener( const OUString&
ClearableMutexGuard aGuard( maMutex );
Reference < XPropertySetInfo > xInfo = getPropertySetInfo( );
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();
- const Property* pIter = aSeq.getConstArray();
- const Property* pEnd = pIter + aSeq.getLength();
- for( ; pIter != pEnd ; ++pIter)
- {
- m_aListener.removeInterface(pIter->Name,xListener);
- }
+ 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 )
diff --git a/comphelper/source/property/opropertybag.cxx b/comphelper/source/property/opropertybag.cxx
index 5c6cd013d70c..1018413befb6 100644
--- a/comphelper/source/property/opropertybag.cxx
+++ b/comphelper/source/property/opropertybag.cxx
@@ -144,19 +144,20 @@ namespace comphelper
::osl::MutexGuard aGuard( m_aMutex );
m_isModified = bModified;
}
- if (bModified) {
- try {
- Reference<XInterface> xThis(*this);
- EventObject event(xThis);
- m_NotifyListeners.notifyEach(
- &XModifyListener::modified, event);
- } catch (RuntimeException &) {
- if (!bIgnoreRuntimeExceptionsWhileFiring) {
- throw;
- }
- } catch (Exception &) {
- // ignore
+ if (!bModified)
+ return;
+
+ try {
+ Reference<XInterface> xThis(*this);
+ EventObject event(xThis);
+ m_NotifyListeners.notifyEach(
+ &XModifyListener::modified, event);
+ } catch (RuntimeException &) {
+ if (!bIgnoreRuntimeExceptionsWhileFiring) {
+ throw;
}
+ } catch (Exception &) {
+ // ignore
}
}
diff --git a/comphelper/source/property/propagg.cxx b/comphelper/source/property/propagg.cxx
index 282405c63069..af1092c9748b 100644
--- a/comphelper/source/property/propagg.cxx
+++ b/comphelper/source/property/propagg.cxx
@@ -298,28 +298,28 @@ namespace internal
void PropertyForwarder::doForward( sal_Int32 _nHandle, const Any& _rValue )
{
OSL_ENSURE( m_rAggregationHelper.m_xAggregateSet.is(), "PropertyForwarder::doForward: no property set!" );
- if ( m_rAggregationHelper.m_xAggregateSet.is() )
- {
- m_rAggregationHelper.forwardingPropertyValue( _nHandle );
+ if ( !m_rAggregationHelper.m_xAggregateSet.is() )
+ return;
- OSL_ENSURE( m_nCurrentlyForwarding == -1, "PropertyForwarder::doForward: reentrance?" );
- m_nCurrentlyForwarding = _nHandle;
+ m_rAggregationHelper.forwardingPropertyValue( _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;
+ 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 );
}
}
diff --git a/comphelper/source/property/propertysethelper.cxx b/comphelper/source/property/propertysethelper.cxx
index 1f456c2c00b3..f397cdc13925 100644
--- a/comphelper/source/property/propertysethelper.cxx
+++ b/comphelper/source/property/propertysethelper.cxx
@@ -129,26 +129,26 @@ void SAL_CALL PropertySetHelper::setPropertyValues( const Sequence< OUString >&
if( nCount != rValues.getLength() )
throw IllegalArgumentException();
- if( nCount )
- {
- std::unique_ptr<PropertyMapEntry const *[]> pEntries(new PropertyMapEntry const *[nCount+1]);
- pEntries[nCount] = nullptr;
- const OUString* pNames = rPropertyNames.getConstArray();
+ if( !nCount )
+ return;
- bool bUnknown = false;
- sal_Int32 n;
- for( n = 0; !bUnknown && ( n < nCount ); n++, pNames++ )
- {
- pEntries[n] = mpImpl->find( *pNames );
- bUnknown = nullptr == pEntries[n];
- }
+ std::unique_ptr<PropertyMapEntry const *[]> pEntries(new PropertyMapEntry const *[nCount+1]);
+ pEntries[nCount] = nullptr;
+ const OUString* pNames = rPropertyNames.getConstArray();
- if( !bUnknown )
- _setPropertyValues( pEntries.get(), rValues.getConstArray() );
-
- if( bUnknown )
- throw RuntimeException( *pNames, static_cast< XPropertySet* >( this ) );
+ 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 ) );
}
Sequence< Any > SAL_CALL PropertySetHelper::getPropertyValues(const Sequence< OUString >& rPropertyNames)
diff --git a/comphelper/source/property/propmultiplex.cxx b/comphelper/source/property/propmultiplex.cxx
index 5feaa7b5db09..66a1545f852e 100644
--- a/comphelper/source/property/propmultiplex.cxx
+++ b/comphelper/source/property/propmultiplex.cxx
@@ -89,21 +89,21 @@ void OPropertyChangeMultiplexer::unlock()
void OPropertyChangeMultiplexer::dispose()
{
- if (m_bListening)
- {
- Reference< XPropertyChangeListener> xPreventDelete(this);
+ if (!m_bListening)
+ return;
- for (const OUString& rProp : m_aProperties)
- m_xSet->removePropertyChangeListener(rProp, static_cast< XPropertyChangeListener*>(this));
+ Reference< XPropertyChangeListener> xPreventDelete(this);
- m_pListener->setAdapter(nullptr);
+ for (const OUString& rProp : m_aProperties)
+ m_xSet->removePropertyChangeListener(rProp, static_cast< XPropertyChangeListener*>(this));
- m_pListener = nullptr;
- m_bListening = false;
+ m_pListener->setAdapter(nullptr);
- if (m_bAutoSetRelease)
- m_xSet = nullptr;
- }
+ m_pListener = nullptr;
+ m_bListening = false;
+
+ if (m_bAutoSetRelease)
+ m_xSet = nullptr;
}
// XEventListener
diff --git a/comphelper/source/streaming/memorystream.cxx b/comphelper/source/streaming/memorystream.cxx
index 4e5beee9d032..b275ac34b06e 100644
--- a/comphelper/source/streaming/memorystream.cxx
+++ b/comphelper/source/streaming/memorystream.cxx
@@ -191,24 +191,24 @@ sal_Int64 SAL_CALL UNOMemoryStream::getLength()
void SAL_CALL UNOMemoryStream::writeBytes( const Sequence< sal_Int8 >& aData )
{
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;
- if( nNewSize > SAL_MAX_INT32 )
- {
- OSL_ASSERT(false);
- 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 );
+ 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 );
+ sal_Int8* pData = &(*maData.begin());
+ sal_Int8* pCursor = &(pData[mnCursor]);
+ memcpy( pCursor, aData.getConstArray(), nBytesToWrite );
- mnCursor += nBytesToWrite;
- }
+ mnCursor += nBytesToWrite;
}
void SAL_CALL UNOMemoryStream::flush()
More information about the Libreoffice-commits
mailing list