[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - xmlsecurity/Library_xmlsecurity.mk xmlsecurity/source

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Thu Aug 29 08:25:29 UTC 2019


 xmlsecurity/Library_xmlsecurity.mk                     |    2 +
 xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx |   23 +++++++++++++++--
 2 files changed, 23 insertions(+), 2 deletions(-)

New commits:
commit 482a97009a729e6198a4eae07869913f90a90c3c
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Wed Aug 14 12:58:49 2019 +0300
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Thu Aug 29 10:24:53 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.kaganski at collabora.com>
    (cherry picked from commit 9c8854b7d6e5c9debc7eeae57c0d51a3f151a03e)
    Reviewed-on: https://gerrit.libreoffice.org/77535
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>

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 93f988649490..b893a593944c 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 )


More information about the Libreoffice-commits mailing list