xmlsecurity/Library_xmlsecurity.mk | 2 + xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx | 23 +++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-)
New commits: commit 9c8854b7d6e5c9debc7eeae57c0d51a3f151a03e Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Wed Aug 14 12:58:49 2019 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Wed Aug 14 13:26:02 2019 +0200 Don't hardcode "C:\\Program Files (x86)" path on Windows It might be simple "Program Files" on 32-bit system; or localized (see https://www.samlogic.net/articles/program-files-folder-different-languages.htm), or on a different drive (if system isn't on C:), etc. Change-Id: Id0f28b4c4920fcda53a58fbff9f42bcfde6668f6 Reviewed-on: https://gerrit.libreoffice.org/77448 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/xmlsecurity/Library_xmlsecurity.mk b/xmlsecurity/Library_xmlsecurity.mk index 9a65dd2152a9..5a80e6e17591 100644 --- a/xmlsecurity/Library_xmlsecurity.mk +++ b/xmlsecurity/Library_xmlsecurity.mk @@ -83,6 +83,8 @@ $(eval $(call gb_Library_add_defs,xmlsecurity,\ )) $(eval $(call gb_Library_use_system_win32_libs,xmlsecurity,\ crypt32 \ + Ole32 \ + Shell32 \ )) else ifneq (,$(filter DESKTOP,$(BUILD_TYPE))$(filter ANDROID,$(OS))) diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx index 032171928c88..67545e3bb561 100644 --- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx +++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx @@ -59,6 +59,12 @@ #include <vcl/svapp.hxx> #include <unotools/configitem.hxx> +#ifdef _WIN32 +#include <o3tl/char16_t2wchar_t.hxx> +#include <prewin.h> +#include <Shlobj.h> +#endif + using namespace comphelper; using namespace css::security; using namespace css::uno; @@ -457,15 +463,28 @@ IMPL_LINK_NOARG(DigitalSignaturesDialog, CertMgrButtonHdl, weld::Button&, void) OUString("GNU\\GnuPG\\bin\\kleopatra.exe"), OUString("GNU\\GnuPG\\bin\\launch-gpa.exe"), OUString("GNU\\GnuPG\\bin\\gpa.exe") }; - const char* const cPath = "C:\\Program Files (x86)"; + static const OUString aPath = [] { + OUString sRet; + PWSTR sPath = nullptr; + HRESULT hr + = SHGetKnownFolderPath(FOLDERID_ProgramFilesX86, KF_FLAG_DEFAULT, nullptr, &sPath); + if (SUCCEEDED(hr)) + { + sRet = o3tl::toU(sPath); + CoTaskMemFree(sPath); + } + return sRet; + }(); + if (aPath.isEmpty()) + return; #else const OUString aGUIServers[] = { OUString("kleopatra"), OUString("seahorse"), OUString("gpa"), OUString("kgpg") }; const char* cPath = getenv("PATH"); if (!cPath) return; + OUString aPath(cPath, strlen(cPath), osl_getThreadTextEncoding()); #endif - OUString aPath(cPath, strlen(cPath), osl_getThreadTextEncoding()); OUString sFoundGUIServer, sExecutable; for ( auto const &rServer : aGUIServers ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits