cui/source/options/optgdlg.cxx          |    6 ++++++
 include/systools/win32/winstoreutil.hxx |   32 ++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)

New commits:
commit bc9e978a5df5f2ee84b32d1a4a67d5e6eadb4e86
Author:     Mike Kaganski <[email protected]>
AuthorDate: Sun Feb 26 11:24:30 2023 +0300
Commit:     Mike Kaganski <[email protected]>
CommitDate: Sun Feb 26 11:19:46 2023 +0000

    Hide Quickstarter from General options in Windows store apps
    
    In that environment, the shell:Startup shortcut created by us points to the
    quickstart.exe under Program 
Files\WindowsApps\<StoreSpecificAppDir>\program.
    The resulting shortcut can't launch, because of an inaccessible part in the
    path (the protected WindowsApps directory). So the feature does not work in
    the dialog.
    
    Windows store apps should advertise the Windows startup task in the 
manifest.
    Let's just hide the dialog entry in this case. A possible TODO would be to
    provide a button instead, which would open the Startup Apps system applet,
    similar to what we do for Default apps for file associations.
    
    Change-Id: Ieafdf6d23ced96506b01c6b3cf9fb12904696df1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147735
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx
index 02801e9537c3..1037cdd7ed1f 100644
--- a/cui/source/options/optgdlg.cxx
+++ b/cui/source/options/optgdlg.cxx
@@ -88,6 +88,7 @@
 #include <svtools/imgdef.hxx>
 
 #if defined(_WIN32)
+#include <systools/win32/winstoreutil.hxx>
 #include <vcl/fileregistration.hxx>
 #endif
 using namespace ::com::sun::star::uno;
@@ -192,6 +193,11 @@ OfaMiscTabPage::OfaMiscTabPage(weld::Container* pPage, 
weld::DialogController* p
     m_xQuickStarterFrame->hide();
     //Hide frame label in case of no content
     m_xHelpImproveLabel->hide();
+#else
+    // Store-packaged apps (located under the protected Program 
Files\WindowsApps) can't use normal
+    // shell shortcuts to their exe; hide. TODO: show a button to open 
"Startup Apps" system applet?
+    if (sal::systools::IsStorePackagedApp())
+        m_xQuickStarterFrame->hide();
 #endif
 
 #if defined(_WIN32)
diff --git a/include/systools/win32/winstoreutil.hxx 
b/include/systools/win32/winstoreutil.hxx
new file mode 100644
index 000000000000..aa0a70e64423
--- /dev/null
+++ b/include/systools/win32/winstoreutil.hxx
@@ -0,0 +1,32 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include <sal/config.h>
+
+#include <prewin.h>
+#include <postwin.h>
+
+namespace sal::systools
+{
+// Returns true if the current process is run as a Windows store app, which 
has some specifics
+inline bool IsStorePackagedApp()
+{
+    // GetCurrentPackageFullName is only available since Windows 8
+    HMODULE hDll = GetModuleHandleW(L"kernel32.dll");
+    using Func_t = LONG WINAPI(UINT32*, PWSTR);
+    if (auto pFunc = reinterpret_cast<Func_t*>(GetProcAddress(hDll, 
"GetCurrentPackageFullName")))
+        if (UINT32 size = 0; pFunc(&size, nullptr) == 
ERROR_INSUFFICIENT_BUFFER)
+            return true;
+    return false;
+}
+} // sal::systools
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */

Reply via email to