summaryrefslogtreecommitdiff
path: root/comphelper/source
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
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')
-rw-r--r--comphelper/source/container/embeddedobjectcontainer.cxx74
-rw-r--r--comphelper/source/misc/backupfilehelper.cxx488
-rw-r--r--comphelper/source/misc/namedvaluecollection.cxx40
-rw-r--r--comphelper/source/officeinstdir/officeinstallationdirectories.cxx40
4 files changed, 314 insertions, 328 deletions
diff --git a/comphelper/source/container/embeddedobjectcontainer.cxx b/comphelper/source/container/embeddedobjectcontainer.cxx
index ac85e9cfdc70..2d85b73f44ba 100644
--- a/comphelper/source/container/embeddedobjectcontainer.cxx
+++ b/comphelper/source/container/embeddedobjectcontainer.cxx
@@ -135,31 +135,31 @@ void EmbeddedObjectContainer::SwitchPersistence( const uno::Reference < embed::X
bool EmbeddedObjectContainer::CommitImageSubStorage()
{
- if ( pImpl->mxImageStorage.is() )
+ if ( !pImpl->mxImageStorage )
+ return true;
+
+ try
{
- try
+ bool bReadOnlyMode = true;
+ uno::Reference < beans::XPropertySet > xSet(pImpl->mxImageStorage,uno::UNO_QUERY);
+ if ( xSet.is() )
{
- bool bReadOnlyMode = true;
- uno::Reference < beans::XPropertySet > xSet(pImpl->mxImageStorage,uno::UNO_QUERY);
- if ( xSet.is() )
- {
- // get the open mode from the parent storage
- sal_Int32 nMode = 0;
- uno::Any aAny = xSet->getPropertyValue("OpenMode");
- if ( aAny >>= nMode )
- bReadOnlyMode = !(nMode & embed::ElementModes::WRITE );
- } // if ( xSet.is() )
- if ( !bReadOnlyMode )
- {
- uno::Reference< embed::XTransactedObject > xTransact( pImpl->mxImageStorage, uno::UNO_QUERY_THROW );
- xTransact->commit();
- }
- }
- catch (const uno::Exception&)
+ // get the open mode from the parent storage
+ sal_Int32 nMode = 0;
+ uno::Any aAny = xSet->getPropertyValue("OpenMode");
+ if ( aAny >>= nMode )
+ bReadOnlyMode = !(nMode & embed::ElementModes::WRITE );
+ } // if ( xSet.is() )
+ if ( !bReadOnlyMode )
{
- return false;
+ uno::Reference< embed::XTransactedObject > xTransact( pImpl->mxImageStorage, uno::UNO_QUERY_THROW );
+ xTransact->commit();
}
}
+ catch (const uno::Exception&)
+ {
+ return false;
+ }
return true;
}
@@ -969,26 +969,26 @@ bool EmbeddedObjectContainer::RemoveEmbeddedObject( const uno::Reference < embed
else
SAL_WARN( "comphelper.container", "Object not found for removal!" );
- if ( xPersist.is() && bKeepToTempStorage ) // #i119941#
- {
- // remove replacement image (if there is one)
- RemoveGraphicStream( aName );
+ if ( !xPersist || !bKeepToTempStorage ) // #i119941#
+ return true;
- // now it's time to remove the storage from the container storage
- try
- {
+ // remove replacement image (if there is one)
+ RemoveGraphicStream( aName );
+
+ // now it's time to remove the storage from the container storage
+ try
+ {
#if OSL_DEBUG_LEVEL > 1
- // if the object has a persistence and the object is not a link than it must have persistence entry in storage
- OSL_ENSURE( bIsNotEmbedded || pImpl->mxStorage->hasByName( aName ), "The object has no persistence entry in the storage!" );
+ // if the object has a persistence and the object is not a link than it must have persistence entry in storage
+ OSL_ENSURE( bIsNotEmbedded || pImpl->mxStorage->hasByName( aName ), "The object has no persistence entry in the storage!" );
#endif
- if ( xPersist.is() && pImpl->mxStorage->hasByName( aName ) )
- pImpl->mxStorage->removeElement( aName );
- }
- catch (const uno::Exception&)
- {
- SAL_WARN( "comphelper.container", "Failed to remove object from storage!" );
- return false;
- }
+ if ( xPersist.is() && pImpl->mxStorage->hasByName( aName ) )
+ pImpl->mxStorage->removeElement( aName );
+ }
+ catch (const uno::Exception&)
+ {
+ SAL_WARN( "comphelper.container", "Failed to remove object from storage!" );
+ return false;
}
return true;
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
diff --git a/comphelper/source/officeinstdir/officeinstallationdirectories.cxx b/comphelper/source/officeinstdir/officeinstallationdirectories.cxx
index 385f61680e1c..de6b284c5f68 100644
--- a/comphelper/source/officeinstdir/officeinstallationdirectories.cxx
+++ b/comphelper/source/officeinstdir/officeinstallationdirectories.cxx
@@ -44,30 +44,30 @@ static bool makeCanonicalFileURL( OUString & rURL )
if ( osl::FileBase::getAbsoluteFileURL( OUString(),
rURL,
aNormalizedURL )
+ != osl::DirectoryItem::E_None )
+ return false;
+
+ osl::DirectoryItem aDirItem;
+ if ( osl::DirectoryItem::get( aNormalizedURL, aDirItem )
+ != osl::DirectoryItem::E_None )
+ return false;
+
+ osl::FileStatus aFileStatus( osl_FileStatus_Mask_FileURL );
+
+ if ( aDirItem.getFileStatus( aFileStatus )
== osl::DirectoryItem::E_None )
{
- osl::DirectoryItem aDirItem;
- if ( osl::DirectoryItem::get( aNormalizedURL, aDirItem )
- == osl::DirectoryItem::E_None )
+ aNormalizedURL = aFileStatus.getFileURL();
+
+ if ( !aNormalizedURL.isEmpty() )
{
- osl::FileStatus aFileStatus( osl_FileStatus_Mask_FileURL );
+ if ( !aNormalizedURL.endsWith("/") )
+ rURL = aNormalizedURL;
+ else
+ rURL = aNormalizedURL
+ .copy( 0, aNormalizedURL.getLength() - 1 );
- if ( aDirItem.getFileStatus( aFileStatus )
- == osl::DirectoryItem::E_None )
- {
- aNormalizedURL = aFileStatus.getFileURL();
-
- if ( !aNormalizedURL.isEmpty() )
- {
- if ( !aNormalizedURL.endsWith("/") )
- rURL = aNormalizedURL;
- else
- rURL = aNormalizedURL
- .copy( 0, aNormalizedURL.getLength() - 1 );
-
- return true;
- }
- }
+ return true;
}
}
return false;