[Libreoffice-commits] core.git: vcl/win
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Thu Apr 1 09:57:22 UTC 2021
vcl/win/app/fileregistration.cxx | 34 +++++++++++++---------------------
1 file changed, 13 insertions(+), 21 deletions(-)
New commits:
commit 7a743920c7fd46b2709186be5a344ba81b54b19d
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Thu Apr 1 09:44:46 2021 +0300
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Thu Apr 1 11:56:36 2021 +0200
Simplify CheckFileExtRegistration
Change-Id: I49a01e9cae16a408c6be11fe0501f489c3db6e3a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113438
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/vcl/win/app/fileregistration.cxx b/vcl/win/app/fileregistration.cxx
index 7454f5e0c2f4..2555cede8d2d 100644
--- a/vcl/win/app/fileregistration.cxx
+++ b/vcl/win/app/fileregistration.cxx
@@ -23,7 +23,7 @@
#include <strings.hrc>
#include <svdata.hxx>
-#include <map>
+#include <utility>
#include <prewin.h>
#include <Shobjidl.h>
@@ -155,11 +155,11 @@ void CheckFileExtRegistration(weld::Window* pDialogParent)
if (bUninit)
CoUninitialize();
});
- sal::systools::COMReference<IApplicationAssociationRegistration> pAAR = nullptr;
+ sal::systools::COMReference<IApplicationAssociationRegistration> pAAR;
try
{
- pAAR = sal::systools::COMReference<IApplicationAssociationRegistration>().CoCreateInstance(
- CLSID_ApplicationAssociationRegistration, nullptr, CLSCTX_INPROC_SERVER);
+ pAAR.CoCreateInstance(CLSID_ApplicationAssociationRegistration, nullptr,
+ CLSCTX_INPROC_SERVER);
}
catch (...)
{
@@ -167,30 +167,22 @@ void CheckFileExtRegistration(weld::Window* pDialogParent)
return;
}
- std::map<OUString, OUString> formats = {
- { ".odp", "LibreOffice.ImpressDocument.1" },
- { ".odt", "LibreOffice.WriterDocument.1" },
- { ".ods", "LibreOffice.CalcDocument.1" },
+ static const std::pair<LPCWSTR, LPCWSTR> formats[] = {
+ { L".odp", L"LibreOffice.ImpressDocument.1" },
+ { L".odt", L"LibreOffice.WriterDocument.1" },
+ { L".ods", L"LibreOffice.CalcDocument.1" },
};
OUString aNonDefaults;
- bool isNotDefault = false;
- for (std::map<OUString, OUString>::iterator it = formats.begin(); it != formats.end(); it++)
+ for (const auto & [ szExt, szProgId ] : formats)
{
- if (IsPathDefaultForClass(pAAR, o3tl::toW(it->first.getStr()),
- o3tl::toW(it->second.getStr()))
- == S_FALSE)
- {
- isNotDefault = true;
- aNonDefaults += it->first;
- aNonDefaults += "\n";
- }
+ if (IsPathDefaultForClass(pAAR, szExt, szProgId) == S_FALSE)
+ aNonDefaults += OUString::Concat(o3tl::toU(szExt)) + "\n";
}
- if (isNotDefault)
+ if (!aNonDefaults.isEmpty())
{
- OUString aMsg(VclResId(STR_FILEEXT_NONDEFAULT_ASK_MSG));
- aMsg = aMsg.replaceFirst("$1", aNonDefaults);
+ OUString aMsg(VclResId(STR_FILEEXT_NONDEFAULT_ASK_MSG).replaceFirst("$1", aNonDefaults));
VclAbstractDialogFactory* pFact = VclAbstractDialogFactory::Create();
ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateFileExtCheckDialog(
More information about the Libreoffice-commits
mailing list