summaryrefslogtreecommitdiff
path: root/comphelper/source/misc
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-12-21 13:42:35 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-12-21 15:55:46 +0100
commit25298930bc86d1a449a7e5b139d65e49f695f8c1 (patch)
treeb3f28ef6b18b12347694a637b6785ecb5eedc1fe /comphelper/source/misc
parent1edaee2f03bce0efa409c592919458658d0aa751 (diff)
loplugin:flatten in canvas..cui
Change-Id: I208767eaa60d913fe2882403f1f9351eb08256f7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127224 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper/source/misc')
-rw-r--r--comphelper/source/misc/backupfilehelper.cxx488
-rw-r--r--comphelper/source/misc/namedvaluecollection.cxx40
2 files changed, 257 insertions, 271 deletions
diff --git a/comphelper/source/misc/backupfilehelper.cxx b/comphelper/source/misc/backupfilehelper.cxx
index d03662381939..c091ee7ab06b 100644
--- a/comphelper/source/misc/backupfilehelper.cxx
+++ b/comphelper/source/misc/backupfilehelper.cxx
@@ -806,197 +806,191 @@ namespace
bool copy_content_straight(oslFileHandle& rTargetHandle)
{
- if (maFile && osl::File::E_None == maFile->open(osl_File_OpenFlag_Read))
- {
- sal_uInt8 aArray[BACKUP_FILE_HELPER_BLOCK_SIZE];
- sal_uInt64 nBytesTransfer(0);
- sal_uInt64 nSize(getPackFileSize());
+ if (!maFile || osl::File::E_None != maFile->open(osl_File_OpenFlag_Read))
+ return false;
- // set offset in source file - when this is zero, a new file is to be added
- if (osl::File::E_None == maFile->setPos(osl_Pos_Absolut, sal_Int64(getOffset())))
- {
- while (nSize != 0)
- {
- const sal_uInt64 nToTransfer(std::min(nSize, sal_uInt64(BACKUP_FILE_HELPER_BLOCK_SIZE)));
+ sal_uInt8 aArray[BACKUP_FILE_HELPER_BLOCK_SIZE];
+ sal_uInt64 nBytesTransfer(0);
+ sal_uInt64 nSize(getPackFileSize());
- if (osl::File::E_None != maFile->read(static_cast<void*>(aArray), nToTransfer, nBytesTransfer) || nBytesTransfer != nToTransfer)
- {
- break;
- }
+ // set offset in source file - when this is zero, a new file is to be added
+ if (osl::File::E_None == maFile->setPos(osl_Pos_Absolut, sal_Int64(getOffset())))
+ {
+ while (nSize != 0)
+ {
+ const sal_uInt64 nToTransfer(std::min(nSize, sal_uInt64(BACKUP_FILE_HELPER_BLOCK_SIZE)));
- if (osl_File_E_None != osl_writeFile(rTargetHandle, static_cast<const void*>(aArray), nToTransfer, &nBytesTransfer) || nBytesTransfer != nToTransfer)
- {
- break;
- }
+ if (osl::File::E_None != maFile->read(static_cast<void*>(aArray), nToTransfer, nBytesTransfer) || nBytesTransfer != nToTransfer)
+ {
+ break;
+ }
- nSize -= nToTransfer;
+ if (osl_File_E_None != osl_writeFile(rTargetHandle, static_cast<const void*>(aArray), nToTransfer, &nBytesTransfer) || nBytesTransfer != nToTransfer)
+ {
+ break;
}
- }
- maFile->close();
- return (0 == nSize);
+ nSize -= nToTransfer;
+ }
}
- return false;
+ maFile->close();
+ return (0 == nSize);
}
bool copy_content_compress(oslFileHandle& rTargetHandle)
{
- if (maFile && osl::File::E_None == maFile->open(osl_File_OpenFlag_Read))
- {
- sal_uInt8 aArray[BACKUP_FILE_HELPER_BLOCK_SIZE];
- sal_uInt8 aBuffer[BACKUP_FILE_HELPER_BLOCK_SIZE];
- sal_uInt64 nBytesTransfer(0);
- sal_uInt64 nSize(getPackFileSize());
- z_stream zstream;
- memset(&zstream, 0, sizeof(zstream));
+ if (!maFile || osl::File::E_None != maFile->open(osl_File_OpenFlag_Read))
+ return false;
- if (Z_OK == deflateInit(&zstream, Z_BEST_COMPRESSION))
+ sal_uInt8 aArray[BACKUP_FILE_HELPER_BLOCK_SIZE];
+ sal_uInt8 aBuffer[BACKUP_FILE_HELPER_BLOCK_SIZE];
+ sal_uInt64 nBytesTransfer(0);
+ sal_uInt64 nSize(getPackFileSize());
+ z_stream zstream;
+ memset(&zstream, 0, sizeof(zstream));
+
+ if (Z_OK == deflateInit(&zstream, Z_BEST_COMPRESSION))
+ {
+ // set offset in source file - when this is zero, a new file is to be added
+ if (osl::File::E_None == maFile->setPos(osl_Pos_Absolut, sal_Int64(getOffset())))
{
- // set offset in source file - when this is zero, a new file is to be added
- if (osl::File::E_None == maFile->setPos(osl_Pos_Absolut, sal_Int64(getOffset())))
+ bool bOkay(true);
+
+ while (bOkay && nSize != 0)
{
- bool bOkay(true);
+ const sal_uInt64 nToTransfer(std::min(nSize, sal_uInt64(BACKUP_FILE_HELPER_BLOCK_SIZE)));
- while (bOkay && nSize != 0)
+ if (osl::File::E_None != maFile->read(static_cast<void*>(aArray), nToTransfer, nBytesTransfer) || nBytesTransfer != nToTransfer)
{
- const sal_uInt64 nToTransfer(std::min(nSize, sal_uInt64(BACKUP_FILE_HELPER_BLOCK_SIZE)));
-
- if (osl::File::E_None != maFile->read(static_cast<void*>(aArray), nToTransfer, nBytesTransfer) || nBytesTransfer != nToTransfer)
- {
- break;
- }
+ break;
+ }
- zstream.avail_in = nToTransfer;
- zstream.next_in = reinterpret_cast<unsigned char*>(aArray);
+ zstream.avail_in = nToTransfer;
+ zstream.next_in = reinterpret_cast<unsigned char*>(aArray);
- do {
- zstream.avail_out = BACKUP_FILE_HELPER_BLOCK_SIZE;
- zstream.next_out = reinterpret_cast<unsigned char*>(aBuffer);
+ do {
+ zstream.avail_out = BACKUP_FILE_HELPER_BLOCK_SIZE;
+ zstream.next_out = reinterpret_cast<unsigned char*>(aBuffer);
#if !defined Z_PREFIX
- const sal_Int64 nRetval(deflate(&zstream, nSize == nToTransfer ? Z_FINISH : Z_NO_FLUSH));
+ const sal_Int64 nRetval(deflate(&zstream, nSize == nToTransfer ? Z_FINISH : Z_NO_FLUSH));
#else
- const sal_Int64 nRetval(z_deflate(&zstream, nSize == nToTransfer ? Z_FINISH : Z_NO_FLUSH));
+ const sal_Int64 nRetval(z_deflate(&zstream, nSize == nToTransfer ? Z_FINISH : Z_NO_FLUSH));
#endif
- if (Z_STREAM_ERROR == nRetval)
+ if (Z_STREAM_ERROR == nRetval)
+ {
+ bOkay = false;
+ }
+ else
+ {
+ const sal_uInt64 nAvailable(BACKUP_FILE_HELPER_BLOCK_SIZE - zstream.avail_out);
+
+ if (osl_File_E_None != osl_writeFile(rTargetHandle, static_cast<const void*>(aBuffer), nAvailable, &nBytesTransfer) || nBytesTransfer != nAvailable)
{
bOkay = false;
}
- else
- {
- const sal_uInt64 nAvailable(BACKUP_FILE_HELPER_BLOCK_SIZE - zstream.avail_out);
-
- if (osl_File_E_None != osl_writeFile(rTargetHandle, static_cast<const void*>(aBuffer), nAvailable, &nBytesTransfer) || nBytesTransfer != nAvailable)
- {
- bOkay = false;
- }
- }
- } while (bOkay && 0 == zstream.avail_out);
-
- if (!bOkay)
- {
- break;
}
+ } while (bOkay && 0 == zstream.avail_out);
- nSize -= nToTransfer;
+ if (!bOkay)
+ {
+ break;
}
+ nSize -= nToTransfer;
+ }
+
#if !defined Z_PREFIX
- deflateEnd(&zstream);
+ deflateEnd(&zstream);
#else
- z_deflateEnd(&zstream);
+ z_deflateEnd(&zstream);
#endif
- }
}
+ }
- maFile->close();
+ maFile->close();
- // get compressed size and add to entry
- if (mnFullFileSize == mnPackFileSize && mnFullFileSize == zstream.total_in)
- {
- mnPackFileSize = zstream.total_out;
- }
-
- return (0 == nSize);
+ // get compressed size and add to entry
+ if (mnFullFileSize == mnPackFileSize && mnFullFileSize == zstream.total_in)
+ {
+ mnPackFileSize = zstream.total_out;
}
- return false;
+ return (0 == nSize);
}
bool copy_content_uncompress(oslFileHandle& rTargetHandle)
{
- if (maFile && osl::File::E_None == maFile->open(osl_File_OpenFlag_Read))
- {
- sal_uInt8 aArray[BACKUP_FILE_HELPER_BLOCK_SIZE];
- sal_uInt8 aBuffer[BACKUP_FILE_HELPER_BLOCK_SIZE];
- sal_uInt64 nBytesTransfer(0);
- sal_uInt64 nSize(getPackFileSize());
- z_stream zstream;
- memset(&zstream, 0, sizeof(zstream));
+ if (!maFile || osl::File::E_None != maFile->open(osl_File_OpenFlag_Read))
+ return false;
- if (Z_OK == inflateInit(&zstream))
+ sal_uInt8 aArray[BACKUP_FILE_HELPER_BLOCK_SIZE];
+ sal_uInt8 aBuffer[BACKUP_FILE_HELPER_BLOCK_SIZE];
+ sal_uInt64 nBytesTransfer(0);
+ sal_uInt64 nSize(getPackFileSize());
+ z_stream zstream;
+ memset(&zstream, 0, sizeof(zstream));
+
+ if (Z_OK == inflateInit(&zstream))
+ {
+ // set offset in source file - when this is zero, a new file is to be added
+ if (osl::File::E_None == maFile->setPos(osl_Pos_Absolut, sal_Int64(getOffset())))
{
- // set offset in source file - when this is zero, a new file is to be added
- if (osl::File::E_None == maFile->setPos(osl_Pos_Absolut, sal_Int64(getOffset())))
+ bool bOkay(true);
+
+ while (bOkay && nSize != 0)
{
- bool bOkay(true);
+ const sal_uInt64 nToTransfer(std::min(nSize, sal_uInt64(BACKUP_FILE_HELPER_BLOCK_SIZE)));
- while (bOkay && nSize != 0)
+ if (osl::File::E_None != maFile->read(static_cast<void*>(aArray), nToTransfer, nBytesTransfer) || nBytesTransfer != nToTransfer)
{
- const sal_uInt64 nToTransfer(std::min(nSize, sal_uInt64(BACKUP_FILE_HELPER_BLOCK_SIZE)));
-
- if (osl::File::E_None != maFile->read(static_cast<void*>(aArray), nToTransfer, nBytesTransfer) || nBytesTransfer != nToTransfer)
- {
- break;
- }
+ break;
+ }
- zstream.avail_in = nToTransfer;
- zstream.next_in = reinterpret_cast<unsigned char*>(aArray);
+ zstream.avail_in = nToTransfer;
+ zstream.next_in = reinterpret_cast<unsigned char*>(aArray);
- do {
- zstream.avail_out = BACKUP_FILE_HELPER_BLOCK_SIZE;
- zstream.next_out = reinterpret_cast<unsigned char*>(aBuffer);
+ do {
+ zstream.avail_out = BACKUP_FILE_HELPER_BLOCK_SIZE;
+ zstream.next_out = reinterpret_cast<unsigned char*>(aBuffer);
#if !defined Z_PREFIX
- const sal_Int64 nRetval(inflate(&zstream, Z_NO_FLUSH));
+ const sal_Int64 nRetval(inflate(&zstream, Z_NO_FLUSH));
#else
- const sal_Int64 nRetval(z_inflate(&zstream, Z_NO_FLUSH));
+ const sal_Int64 nRetval(z_inflate(&zstream, Z_NO_FLUSH));
#endif
- if (Z_STREAM_ERROR == nRetval)
+ if (Z_STREAM_ERROR == nRetval)
+ {
+ bOkay = false;
+ }
+ else
+ {
+ const sal_uInt64 nAvailable(BACKUP_FILE_HELPER_BLOCK_SIZE - zstream.avail_out);
+
+ if (osl_File_E_None != osl_writeFile(rTargetHandle, static_cast<const void*>(aBuffer), nAvailable, &nBytesTransfer) || nBytesTransfer != nAvailable)
{
bOkay = false;
}
- else
- {
- const sal_uInt64 nAvailable(BACKUP_FILE_HELPER_BLOCK_SIZE - zstream.avail_out);
-
- if (osl_File_E_None != osl_writeFile(rTargetHandle, static_cast<const void*>(aBuffer), nAvailable, &nBytesTransfer) || nBytesTransfer != nAvailable)
- {
- bOkay = false;
- }
- }
- } while (bOkay && 0 == zstream.avail_out);
-
- if (!bOkay)
- {
- break;
}
+ } while (bOkay && 0 == zstream.avail_out);
- nSize -= nToTransfer;
+ if (!bOkay)
+ {
+ break;
}
+ nSize -= nToTransfer;
+ }
+
#if !defined Z_PREFIX
- deflateEnd(&zstream);
+ deflateEnd(&zstream);
#else
- z_deflateEnd(&zstream);
+ z_deflateEnd(&zstream);
#endif
- }
}
-
- maFile->close();
- return (0 == nSize);
}
- return false;
+ maFile->close();
+ return (0 == nSize);
}
@@ -1421,26 +1415,24 @@ namespace
bool tryPop(oslFileHandle& rHandle)
{
- if (!maPackedFileEntryVector.empty())
- {
- // already backups there, check if different from last entry
- PackedFileEntry& aLastEntry = maPackedFileEntryVector.back();
+ if (maPackedFileEntryVector.empty())
+ return false;
- // here the uncompress flag has to be determined, true
- // means to add the file compressed, false means to add it
- // uncompressed
- bool bRetval = aLastEntry.copy_content(rHandle, true);
+ // already backups there, check if different from last entry
+ PackedFileEntry& aLastEntry = maPackedFileEntryVector.back();
- if (bRetval)
- {
- maPackedFileEntryVector.pop_back();
- mbChanged = true;
- }
+ // here the uncompress flag has to be determined, true
+ // means to add the file compressed, false means to add it
+ // uncompressed
+ bool bRetval = aLastEntry.copy_content(rHandle, true);
- return bRetval;
+ if (bRetval)
+ {
+ maPackedFileEntryVector.pop_back();
+ mbChanged = true;
}
- return false;
+ return bRetval;
}
void tryReduceToNumBackups(sal_uInt16 nNumBackups)
@@ -2227,46 +2219,44 @@ namespace comphelper
{
const OUString aFileURL(createFileURL(rSourceURL, rName, rExt));
- if (DirectoryHelper::fileExists(aFileURL))
- {
- // try Pop for base file
- const OUString aPackURL(createPackURL(rTargetURL, rName));
- PackedFile aPackedFile(aPackURL);
+ if (!DirectoryHelper::fileExists(aFileURL))
+ return false;
- if (!aPackedFile.empty())
- {
- oslFileHandle aHandle;
- OUString aTempURL;
+ // try Pop for base file
+ const OUString aPackURL(createPackURL(rTargetURL, rName));
+ PackedFile aPackedFile(aPackURL);
- // open target temp file - it exists until deleted
- if (osl::File::E_None == osl::FileBase::createTempFile(nullptr, &aHandle, &aTempURL))
- {
- bool bRetval(aPackedFile.tryPop(aHandle));
+ if (aPackedFile.empty())
+ return false;
- // close temp file (in all cases) - it exists until deleted
- osl_closeFile(aHandle);
+ oslFileHandle aHandle;
+ OUString aTempURL;
- if (bRetval)
- {
- // copy over existing file by first deleting original
- // and moving the temp file to old original
- osl::File::remove(aFileURL);
- osl::File::move(aTempURL, aFileURL);
-
- // reduce to allowed number and flush
- aPackedFile.tryReduceToNumBackups(mnNumBackups);
- aPackedFile.flush();
- }
+ // open target temp file - it exists until deleted
+ if (osl::File::E_None != osl::FileBase::createTempFile(nullptr, &aHandle, &aTempURL))
+ return false;
- // delete temp file (in all cases - it may be moved already)
- osl::File::remove(aTempURL);
+ bool bRetval(aPackedFile.tryPop(aHandle));
- return bRetval;
- }
- }
+ // close temp file (in all cases) - it exists until deleted
+ osl_closeFile(aHandle);
+
+ if (bRetval)
+ {
+ // copy over existing file by first deleting original
+ // and moving the temp file to old original
+ osl::File::remove(aFileURL);
+ osl::File::move(aTempURL, aFileURL);
+
+ // reduce to allowed number and flush
+ aPackedFile.tryReduceToNumBackups(mnNumBackups);
+ aPackedFile.flush();
}
- return false;
+ // delete temp file (in all cases - it may be moved already)
+ osl::File::remove(aTempURL);
+
+ return bRetval;
}
/////////////////// ExtensionInfo helpers ///////////////////////
@@ -2319,103 +2309,101 @@ namespace comphelper
const OUString aPackURL(createPackURL(rTargetURL, u"ExtensionInfo"));
PackedFile aPackedFile(aPackURL);
- if (!aPackedFile.empty())
- {
- oslFileHandle aHandle;
- OUString aTempURL;
+ if (aPackedFile.empty())
+ return false;
- // open target temp file - it exists until deleted
- if (osl::File::E_None == osl::FileBase::createTempFile(nullptr, &aHandle, &aTempURL))
- {
- bool bRetval(aPackedFile.tryPop(aHandle));
+ oslFileHandle aHandle;
+ OUString aTempURL;
- // close temp file (in all cases) - it exists until deleted
- osl_closeFile(aHandle);
+ // open target temp file - it exists until deleted
+ if (osl::File::E_None != osl::FileBase::createTempFile(nullptr, &aHandle, &aTempURL))
+ return false;
- if (bRetval)
- {
- // last config is in temp file, load it to ExtensionInfo
- ExtensionInfo aLoadedExtensionInfo;
- FileSharedPtr aBaseFile = std::make_shared<osl::File>(aTempURL);
+ bool bRetval(aPackedFile.tryPop(aHandle));
- if (osl::File::E_None == aBaseFile->open(osl_File_OpenFlag_Read))
- {
- if (aLoadedExtensionInfo.read_entries(aBaseFile))
- {
- // get current extension info, but from XML config files
- ExtensionInfo aCurrentExtensionInfo;
+ // close temp file (in all cases) - it exists until deleted
+ osl_closeFile(aHandle);
- aCurrentExtensionInfo.createUserExtensionRegistryEntriesFromXML(maUserConfigWorkURL);
+ if (bRetval)
+ {
+ // last config is in temp file, load it to ExtensionInfo
+ ExtensionInfo aLoadedExtensionInfo;
+ FileSharedPtr aBaseFile = std::make_shared<osl::File>(aTempURL);
- // now we have loaded last_working (aLoadedExtensionInfo) and
- // current (aCurrentExtensionInfo) ExtensionInfo and may react on
- // differences by de/activating these as needed
- const ExtensionInfoEntryVector& aUserEntries = aCurrentExtensionInfo.getExtensionInfoEntryVector();
- const ExtensionInfoEntryVector& rLoadedVector = aLoadedExtensionInfo.getExtensionInfoEntryVector();
- ExtensionInfoEntryVector aToBeDisabled;
- ExtensionInfoEntryVector aToBeEnabled;
+ if (osl::File::E_None == aBaseFile->open(osl_File_OpenFlag_Read))
+ {
+ if (aLoadedExtensionInfo.read_entries(aBaseFile))
+ {
+ // get current extension info, but from XML config files
+ ExtensionInfo aCurrentExtensionInfo;
- for (const auto& rCurrentInfo : aUserEntries)
- {
- const ExtensionInfoEntry* pLoadedInfo = nullptr;
+ aCurrentExtensionInfo.createUserExtensionRegistryEntriesFromXML(maUserConfigWorkURL);
- for (const auto& rLoadedInfo : rLoadedVector)
- {
- if (rCurrentInfo.isSameExtension(rLoadedInfo))
- {
- pLoadedInfo = &rLoadedInfo;
- break;
- }
- }
+ // now we have loaded last_working (aLoadedExtensionInfo) and
+ // current (aCurrentExtensionInfo) ExtensionInfo and may react on
+ // differences by de/activating these as needed
+ const ExtensionInfoEntryVector& aUserEntries = aCurrentExtensionInfo.getExtensionInfoEntryVector();
+ const ExtensionInfoEntryVector& rLoadedVector = aLoadedExtensionInfo.getExtensionInfoEntryVector();
+ ExtensionInfoEntryVector aToBeDisabled;
+ ExtensionInfoEntryVector aToBeEnabled;
- if (nullptr != pLoadedInfo)
- {
- // loaded info contains information about the Extension rCurrentInfo
- const bool bCurrentEnabled(rCurrentInfo.isEnabled());
- const bool bLoadedEnabled(pLoadedInfo->isEnabled());
+ for (const auto& rCurrentInfo : aUserEntries)
+ {
+ const ExtensionInfoEntry* pLoadedInfo = nullptr;
- if (bCurrentEnabled && !bLoadedEnabled)
- {
- aToBeDisabled.push_back(rCurrentInfo);
- }
- else if (!bCurrentEnabled && bLoadedEnabled)
- {
- aToBeEnabled.push_back(rCurrentInfo);
- }
- }
- else
- {
- // There is no loaded info about the Extension rCurrentInfo.
- // It needs to be disabled
- if (rCurrentInfo.isEnabled())
- {
- aToBeDisabled.push_back(rCurrentInfo);
- }
- }
+ for (const auto& rLoadedInfo : rLoadedVector)
+ {
+ if (rCurrentInfo.isSameExtension(rLoadedInfo))
+ {
+ pLoadedInfo = &rLoadedInfo;
+ break;
}
+ }
- if (!aToBeDisabled.empty() || !aToBeEnabled.empty())
+ if (nullptr != pLoadedInfo)
+ {
+ // loaded info contains information about the Extension rCurrentInfo
+ const bool bCurrentEnabled(rCurrentInfo.isEnabled());
+ const bool bLoadedEnabled(pLoadedInfo->isEnabled());
+
+ if (bCurrentEnabled && !bLoadedEnabled)
{
- ExtensionInfo::changeEnableDisableStateInXML(maUserConfigWorkURL, aToBeEnabled, aToBeDisabled);
+ aToBeDisabled.push_back(rCurrentInfo);
+ }
+ else if (!bCurrentEnabled && bLoadedEnabled)
+ {
+ aToBeEnabled.push_back(rCurrentInfo);
+ }
+ }
+ else
+ {
+ // There is no loaded info about the Extension rCurrentInfo.
+ // It needs to be disabled
+ if (rCurrentInfo.isEnabled())
+ {
+ aToBeDisabled.push_back(rCurrentInfo);
}
-
- bRetval = true;
}
}
- // reduce to allowed number and flush
- aPackedFile.tryReduceToNumBackups(mnNumBackups);
- aPackedFile.flush();
- }
-
- // delete temp file (in all cases - it may be moved already)
- osl::File::remove(aTempURL);
+ if (!aToBeDisabled.empty() || !aToBeEnabled.empty())
+ {
+ ExtensionInfo::changeEnableDisableStateInXML(maUserConfigWorkURL, aToBeEnabled, aToBeDisabled);
+ }
- return bRetval;
+ bRetval = true;
+ }
}
+
+ // reduce to allowed number and flush
+ aPackedFile.tryReduceToNumBackups(mnNumBackups);
+ aPackedFile.flush();
}
- return false;
+ // delete temp file (in all cases - it may be moved already)
+ osl::File::remove(aTempURL);
+
+ return bRetval;
}
/////////////////// FileDirInfo helpers ///////////////////////
diff --git a/comphelper/source/misc/namedvaluecollection.cxx b/comphelper/source/misc/namedvaluecollection.cxx
index c56e6979a3a0..574f8e0a1898 100644
--- a/comphelper/source/misc/namedvaluecollection.cxx
+++ b/comphelper/source/misc/namedvaluecollection.cxx
@@ -179,28 +179,26 @@ namespace comphelper
bool NamedValueCollection::get_ensureType( const OUString& _rValueName, void* _pValueLocation, const Type& _rExpectedValueType ) const
{
auto pos = maValues.find( _rValueName );
- if ( pos != maValues.end() )
- {
- if ( uno_type_assignData(
- _pValueLocation, _rExpectedValueType.getTypeLibType(),
- const_cast< void* >( pos->second.getValue() ), pos->second.getValueType().getTypeLibType(),
- reinterpret_cast< uno_QueryInterfaceFunc >( cpp_queryInterface ),
- reinterpret_cast< uno_AcquireFunc >( cpp_acquire ),
- reinterpret_cast< uno_ReleaseFunc >( cpp_release )
- ) )
- // argument exists, and could be extracted
- return true;
-
- // argument exists, but is of wrong type
- throw IllegalArgumentException(
- "Invalid value type for '" + _rValueName
- + "'.\nExpected: " + _rExpectedValueType.getTypeName()
- + "\nFound: " + pos->second.getValueType().getTypeName(),
- nullptr, 0 );
- }
+ if ( pos == maValues.end() )
+ // argument does not exist
+ return false;
- // argument does not exist
- return false;
+ if ( uno_type_assignData(
+ _pValueLocation, _rExpectedValueType.getTypeLibType(),
+ const_cast< void* >( pos->second.getValue() ), pos->second.getValueType().getTypeLibType(),
+ reinterpret_cast< uno_QueryInterfaceFunc >( cpp_queryInterface ),
+ reinterpret_cast< uno_AcquireFunc >( cpp_acquire ),
+ reinterpret_cast< uno_ReleaseFunc >( cpp_release )
+ ) )
+ // argument exists, and could be extracted
+ return true;
+
+ // argument exists, but is of wrong type
+ throw IllegalArgumentException(
+ "Invalid value type for '" + _rValueName
+ + "'.\nExpected: " + _rExpectedValueType.getTypeName()
+ + "\nFound: " + pos->second.getValueType().getTypeName(),
+ nullptr, 0 );
}
const Any& NamedValueCollection::impl_get( const OUString& _rValueName ) const