[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - shell/inc shell/source

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 28 02:29:54 UTC 2019


 shell/inc/spsupp/registrar.hpp           |   21 +++++++++---
 shell/source/win32/spsupp/registrar.cxx  |   51 ++++++++++++++++++++++++-------
 shell/source/win32/spsupp/spsuppServ.cxx |   20 ++++--------
 3 files changed, 64 insertions(+), 28 deletions(-)

New commits:
commit 0c7acc58bd11c1db724fce7314b3cc381359d3a3
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Thu Jun 27 14:46:36 2019 +1000
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Fri Jun 28 04:29:22 2019 +0200

    Register versions from 1 to 5 for SharePoint OpenDocuments object
    
    This is required fro two reasons:
    1. For our custom LOSPSupport.OpenDocuments, it allows SharePoint site's
    js code to properly find out the supported methods of the object.
    Previously we only registered v.1 for it, and that made SharePoint to
    assume that only older subset of methods is supported.
    2. For SharePoint.OpenDocuments, which is used to register MS component
    to point to our implementation, leaving out v.4 and v.5 made problems on
    systems with co-existing MS Office; leftover registration of v.4 and v.5
    resulted in mixed results: when opened from web view, documents used MS
    ActiveX, while for documents opened from list view in SharePoint, our
    ActiveX was used. Registering all versions produces consistent results.
    
    Change-Id: I7e8d4216cce1708e676c834a465654751f079c89
    Reviewed-on: https://gerrit.libreoffice.org/74776
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    (cherry picked from commit b8ecabc07a04537a1d1f317c83556e9d58abd318)
    Reviewed-on: https://gerrit.libreoffice.org/74780
    Tested-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/shell/inc/spsupp/registrar.hpp b/shell/inc/spsupp/registrar.hpp
index b055ac8b0d42..920e076de97c 100644
--- a/shell/inc/spsupp/registrar.hpp
+++ b/shell/inc/spsupp/registrar.hpp
@@ -10,6 +10,8 @@
 #ifndef INCLUDED_SHELL_INC_SPSUPP_REGISTRAR_H
 #define INCLUDED_SHELL_INC_SPSUPP_REGISTRAR_H
 
+#include <initializer_list>
+
 #if !defined WIN32_LEAN_AND_MEAN
 # define WIN32_LEAN_AND_MEAN
 #endif
@@ -18,16 +20,25 @@
 class Registrar {
 public:
     explicit Registrar(REFIID riidCLSID);
+    // First version in list becomes default
     HRESULT RegisterObject(REFIID riidTypeLib,
                            const wchar_t* sProgram,
                            const wchar_t* sComponent,
-                           int nVersion,
-                           const wchar_t* Path,
+                           std::initializer_list<int> aVersions,
+                           const wchar_t* Path);
+    HRESULT UnRegisterObject(const wchar_t* sProgram, const wchar_t* sComponent,
+                             std::initializer_list<int> aVersions);
+    // First version in list becomes the default
+    HRESULT RegisterProgIDs(const wchar_t* sProgram, const wchar_t* sComponent,
+                            std::initializer_list<int> aVersions);
+    HRESULT UnRegisterProgIDs(const wchar_t* sProgram, const wchar_t* sComponent,
+                              std::initializer_list<int> aVersions);
+
+private:
+    HRESULT RegisterProgID(const wchar_t* sProgram, const wchar_t* sComponent, int nVersion,
                            bool bSetDefault);
-    HRESULT UnRegisterObject(const wchar_t* sProgram, const wchar_t* sComponent, int nVersion);
-    HRESULT RegisterProgID(const wchar_t* sProgram, const wchar_t* sComponent, int nVersion, bool bSetDefault);
     HRESULT UnRegisterProgID(const wchar_t* sProgram, const wchar_t* sComponent, int nVersion);
-private:
+
     static const size_t nGUIDlen = 40;
     wchar_t m_sCLSID[nGUIDlen];
     HRESULT m_ConstructionResult;
diff --git a/shell/source/win32/spsupp/registrar.cxx b/shell/source/win32/spsupp/registrar.cxx
index 7c3bbb881612..008c2ac59c82 100644
--- a/shell/source/win32/spsupp/registrar.cxx
+++ b/shell/source/win32/spsupp/registrar.cxx
@@ -76,7 +76,7 @@ namespace {
         return HRESULT_FROM_WIN32(iRetVal);
     }
 
-}
+} // namespace
 
 // see http://stackoverflow.com/questions/284619
 // see https://msdn.microsoft.com/en-us/library/ms691424
@@ -88,12 +88,9 @@ Registrar::Registrar(REFIID riidCLSID)
         E_UNEXPECTED: S_OK;
 }
 
-HRESULT Registrar::RegisterObject(REFIID riidTypeLib,
-                       const wchar_t* sProgram,
-                       const wchar_t* sComponent,
-                       int nVersion,
-                       const wchar_t* Path,
-                       bool bSetDefault)
+HRESULT Registrar::RegisterObject(REFIID riidTypeLib, const wchar_t* sProgram,
+                                  const wchar_t* sComponent, std::initializer_list<int> aVersions,
+                                  const wchar_t* Path)
 {
     if (!wcslen(sComponent) || !wcslen(sProgram))
         return E_INVALIDARG;
@@ -167,15 +164,16 @@ HRESULT Registrar::RegisterObject(REFIID riidTypeLib,
     }
 
     // ProgID
-    return RegisterProgID(sProgram, sComponent, nVersion, bSetDefault);
+    return RegisterProgIDs(sProgram, sComponent, aVersions);
 }
 
-HRESULT Registrar::UnRegisterObject(const wchar_t* sProgram, const wchar_t* sComponent, int nVersion)
+HRESULT Registrar::UnRegisterObject(const wchar_t* sProgram, const wchar_t* sComponent,
+                                    std::initializer_list<int> aVersions)
 {
     if (FAILED(m_ConstructionResult))
         return m_ConstructionResult;
     // ProgID
-    UnRegisterProgID(sProgram, sComponent, nVersion);
+    UnRegisterProgIDs(sProgram, sComponent, aVersions);
     // CLSID
     wchar_t sBuf[MAX_PATH];
     swprintf(sBuf, MAX_PATH, L"CLSID\\%s\\InProcServer32", m_sCLSID);
@@ -187,7 +185,8 @@ HRESULT Registrar::UnRegisterObject(const wchar_t* sProgram, const wchar_t* sCom
     swprintf(sBuf, MAX_PATH, L"CLSID\\%s\\TypeLib", m_sCLSID);
     RegDel(HKEY_CLASSES_ROOT, sBuf);
     swprintf(sBuf, MAX_PATH, L"CLSID\\%s", m_sCLSID);
-    return RegDel(HKEY_CLASSES_ROOT, sBuf);
+    RegDel(HKEY_CLASSES_ROOT, sBuf);
+    return S_OK;
 }
 
 HRESULT Registrar::RegisterProgID(const wchar_t* sProgram, const wchar_t* sComponent, int nVersion, bool bSetDefault)
@@ -222,6 +221,22 @@ HRESULT Registrar::RegisterProgID(const wchar_t* sProgram, const wchar_t* sCompo
     return hr;
 }
 
+HRESULT Registrar::RegisterProgIDs(const wchar_t* sProgram, const wchar_t* sComponent,
+                                   std::initializer_list<int> aVersions)
+{
+    HRESULT hr = S_OK;
+    bool bDefaultRegistered = false;
+    for (int nVersion : aVersions)
+    {
+        if (SUCCEEDED(hr))
+        {
+            hr = RegisterProgID(sProgram, sComponent, nVersion, !bDefaultRegistered);
+            bDefaultRegistered = true;
+        }
+    }
+    return hr;
+}
+
 HRESULT Registrar::UnRegisterProgID(const wchar_t* sProgram, const wchar_t* sComponent, int nVersion)
 {
     if (FAILED(m_ConstructionResult))
@@ -258,4 +273,18 @@ HRESULT Registrar::UnRegisterProgID(const wchar_t* sProgram, const wchar_t* sCom
     return hr;
 }
 
+HRESULT Registrar::UnRegisterProgIDs(const wchar_t* sProgram, const wchar_t* sComponent,
+                                    std::initializer_list<int> aVersions)
+{
+    HRESULT hr = S_OK;
+    // Try all ProgIDs regardless of error, but make sure to return failure result if some failed
+    for (int nVersion : aVersions)
+    {
+        HRESULT hrLast = UnRegisterProgID(sProgram, sComponent, nVersion);
+        if (SUCCEEDED(hr))
+            hr = hrLast;
+    }
+    return hr;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/shell/source/win32/spsupp/spsuppServ.cxx b/shell/source/win32/spsupp/spsuppServ.cxx
index ae0b1de90bef..489fd85dae12 100644
--- a/shell/source/win32/spsupp/spsuppServ.cxx
+++ b/shell/source/win32/spsupp/spsuppServ.cxx
@@ -128,7 +128,9 @@ STDAPI DllRegisterServer(void)
     if (FAILED(hr))
         return hr;
 
-    return Registrar(CLSID_spsupp).RegisterObject(LIBID_spsupp, L"LOSPSupport", L"OpenDocuments", 1, szFile, true);
+    // Default is v.5
+    return Registrar(CLSID_spsupp)
+        .RegisterObject(LIBID_spsupp, L"LOSPSupport", L"OpenDocuments", { 5, 1, 2, 3, 4 }, szFile);
 }
 
 STDAPI DllUnregisterServer(void)
@@ -148,7 +150,8 @@ STDAPI DllUnregisterServer(void)
     if (FAILED(hr))
         return hr;
 
-    return Registrar(CLSID_spsupp).UnRegisterObject(L"LOSPSupport", L"OpenDocuments", 1);
+    return Registrar(CLSID_spsupp)
+        .UnRegisterObject(L"LOSPSupport", L"OpenDocuments", { 1, 2, 3, 4, 5 });
 }
 
 // This is called when regsvr32.exe is called with "/i" flag
@@ -162,19 +165,12 @@ STDAPI DllInstall(BOOL bInstall, _In_opt_ PCWSTR pszCmdLine)
         Registrar registrar(CLSID_spsupp);
         if (bInstall)
         {
-            hr = registrar.RegisterProgID(L"SharePoint", L"OpenDocuments", 3, true);
-            if (SUCCEEDED(hr))
-                hr = registrar.RegisterProgID(L"SharePoint", L"OpenDocuments", 2, false);
-            if (SUCCEEDED(hr))
-                hr = registrar.RegisterProgID(L"SharePoint", L"OpenDocuments", 1, false);
+            // Default is v.5
+            hr = registrar.RegisterProgIDs(L"SharePoint", L"OpenDocuments", { 5, 1, 2, 3, 4 });
         }
         else
         {
-            // Try all ProgIDs regardless of error, but make sure to return failure result if at least one failed
-            hr = registrar.UnRegisterProgID(L"SharePoint", L"OpenDocuments", 1);
-            HRESULT hrLast;
-            hr = SUCCEEDED(hrLast = registrar.UnRegisterProgID(L"SharePoint", L"OpenDocuments", 2)) ? hr : hrLast;
-            hr = SUCCEEDED(hrLast = registrar.UnRegisterProgID(L"SharePoint", L"OpenDocuments", 3)) ? hr : hrLast;
+            hr = registrar.UnRegisterProgIDs(L"SharePoint", L"OpenDocuments", { 1, 2, 3, 4, 5 });
         }
         return hr;
     }


More information about the Libreoffice-commits mailing list