[Libreoffice-commits] core.git: desktop/win32 framework/source scp2/source vcl/inc vcl/Library_vcl.mk vcl/win

Jesús Corrius jcorrius at gmail.com
Sat Jul 20 14:01:26 PDT 2013


 desktop/win32/source/applauncher/launcher.cxx |   39 -------------
 framework/source/helper/titlebarupdate.cxx    |   32 ++++++++++-
 scp2/source/base/registryitem_base.scp        |    2 
 scp2/source/calc/registryitem_calc.scp        |    8 +-
 scp2/source/draw/registryitem_draw.scp        |    8 +-
 scp2/source/impress/registryitem_impress.scp  |    8 +-
 scp2/source/math/registryitem_math.scp        |    4 -
 scp2/source/writer/registryitem_writer.scp    |   14 ++--
 vcl/Library_vcl.mk                            |    1 
 vcl/inc/win/salframe.h                        |    7 +-
 vcl/win/source/window/salframe.cxx            |   75 +++++++++++++++++++++++++-
 11 files changed, 131 insertions(+), 67 deletions(-)

New commits:
commit 19f3d9310caef84fe2815eb89af448a81937bddd
Author: Jesús Corrius <jcorrius at gmail.com>
Date:   Sat Jul 20 17:10:43 2013 +0200

    fdo#35785 LibreOffice's support of recent documents in Windows 7 broken
    
    Change-Id: I916ba1335b0a0420f568ab9340632f273e3c9516
    Reviewed-on: https://gerrit.libreoffice.org/4997
    Reviewed-by: Fridrich Strba <fridrich at documentfoundation.org>
    Tested-by: Fridrich Strba <fridrich at documentfoundation.org>

diff --git a/desktop/win32/source/applauncher/launcher.cxx b/desktop/win32/source/applauncher/launcher.cxx
index c6a40d3..b0f031a 100644
--- a/desktop/win32/source/applauncher/launcher.cxx
+++ b/desktop/win32/source/applauncher/launcher.cxx
@@ -34,51 +34,12 @@
 #include <stdlib.h>
 #include <malloc.h>
 
-#define PACKVERSION(major,minor) MAKELONG(minor,major)
-#define APPUSERMODELID L"TheDocumentFoundation.LibreOffice"
-
-
 #ifdef __MINGW32__
 extern "C" int APIENTRY WinMain( HINSTANCE, HINSTANCE, LPSTR, int )
 #else
 extern "C" int APIENTRY _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
 #endif
 {
-    // Set an explicit Application User Model ID for the process
-
-    WCHAR szShell32[MAX_PATH];
-    GetSystemDirectoryW(szShell32, MAX_PATH);
-    wcscat(szShell32, L"\\Shell32.dll");
-
-    HINSTANCE hinstDll = LoadLibraryW(szShell32);
-
-    if(hinstDll)
-    {
-        DLLVERSIONINFO dvi;
-        ZeroMemory(&dvi, sizeof(dvi));
-        dvi.cbSize = sizeof(dvi);
-
-        DLLGETVERSIONPROC pDllGetVersion;
-        pDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(hinstDll, "DllGetVersion");
-        HRESULT hr = (*pDllGetVersion)(&dvi);
-
-        if(SUCCEEDED(hr))
-        {
-            DWORD dwVersion = PACKVERSION(dvi.dwMajorVersion, dvi.dwMinorVersion);
-            if(dwVersion >= PACKVERSION(6,1)) // Shell32 version in Windows 7
-            {
-                typedef HRESULT (WINAPI *SETCURRENTPROCESSEXPLICITAPPUSERMODELID)(PCWSTR);
-                SETCURRENTPROCESSEXPLICITAPPUSERMODELID pSetCurrentProcessExplicitAppUserModelID;
-                pSetCurrentProcessExplicitAppUserModelID =
-                    (SETCURRENTPROCESSEXPLICITAPPUSERMODELID)GetProcAddress(hinstDll, "SetCurrentProcessExplicitAppUserModelID");
-
-                if(pSetCurrentProcessExplicitAppUserModelID)
-                    (*pSetCurrentProcessExplicitAppUserModelID) (APPUSERMODELID);
-            }
-        }
-    }
-    FreeLibrary(hinstDll);
-
     // Retreive startup info
 
     STARTUPINFO aStartupInfo;
diff --git a/framework/source/helper/titlebarupdate.cxx b/framework/source/helper/titlebarupdate.cxx
index 6833933..f5506a1 100644
--- a/framework/source/helper/titlebarupdate.cxx
+++ b/framework/source/helper/titlebarupdate.cxx
@@ -172,7 +172,7 @@ void TitleBarUpdate::impl_updateApplicationID(const css::uno::Reference< css::fr
 
         OUString aModuleId = xModuleManager->identify(xFrame);
         OUString sDesktopName;
-
+#if defined(UNX) && !defined(MACOSX)
         if ( aModuleId.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.TextDocument")) ||
              aModuleId.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.GlobalDocument")) ||
              aModuleId.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.WebDocument")) ||
@@ -198,6 +198,34 @@ void TitleBarUpdate::impl_updateApplicationID(const css::uno::Reference< css::fr
         sApplicationID = utl::ConfigManager::getProductName().toAsciiLowerCase();
         sApplicationID += OUString(sal_Unicode('-'));
         sApplicationID += sDesktopName;
+#elif defined(WNT)
+        if ( aModuleId.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.TextDocument")) ||
+             aModuleId.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.GlobalDocument")) ||
+             aModuleId.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.WebDocument")) ||
+             aModuleId.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.xforms.XMLFormDocument")) )
+            sDesktopName = OUString("Writer");
+        else if ( aModuleId == "com.sun.star.sheet.SpreadsheetDocument" )
+            sDesktopName = OUString("Calc");
+        else if ( aModuleId == "com.sun.star.presentation.PresentationDocument" )
+            sDesktopName = OUString("Impress");
+        else if ( aModuleId == "com.sun.star.drawing.DrawingDocument" )
+            sDesktopName = OUString("Draw");
+        else if ( aModuleId == "com.sun.star.formula.FormulaProperties" )
+            sDesktopName = OUString("Math");
+        else if ( aModuleId.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.sdb.DatabaseDocument")) ||
+                  aModuleId.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.sdb.OfficeDatabaseDocument")) ||
+                  aModuleId.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.sdb.RelationDesign")) ||
+                  aModuleId.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.sdb.QueryDesign")) ||
+                  aModuleId.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.sdb.TableDesign")) ||
+                  aModuleId.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.sdb.DataSourceBrowser")) )
+            sDesktopName = OUString("Base");
+        else
+            sDesktopName = OUString("Startcenter");
+
+        // We use a hardcoded product name matching the registry keys so applications can be associated with file types
+        sApplicationID = "TheDocumentFoundation.LibreOffice.";
+        sApplicationID += sDesktopName;
+#endif
     }
     catch(const css::uno::Exception&)
     {
@@ -274,7 +302,7 @@ void TitleBarUpdate::impl_forceUpdate()
 
     impl_updateIcon  (xFrame);
     impl_updateTitle (xFrame);
-#if defined(UNX) && !defined(MACOSX)
+#if !defined(MACOSX)
     impl_updateApplicationID (xFrame);
 #endif
 }
diff --git a/scp2/source/base/registryitem_base.scp b/scp2/source/base/registryitem_base.scp
index 020c665..69bf1d0 100644
--- a/scp2/source/base/registryitem_base.scp
+++ b/scp2/source/base/registryitem_base.scp
@@ -84,7 +84,7 @@ RegistryItem gid_Regitem_Openoffice_Databasedocument_1_AppUserModelID
     ComponentCondition = "VersionNT >= 601";
     Subkey = "LibreOffice.DatabaseDocument.1";
     Name = "AppUserModelID";
-    Value = "TheDocumentFoundation.LibreOffice";
+    Value = "TheDocumentFoundation.LibreOffice.Base";
 End
 
 RegistryItem gid_Regitem_Openoffice_Databasedocument_1_FriendlyTypeName
diff --git a/scp2/source/calc/registryitem_calc.scp b/scp2/source/calc/registryitem_calc.scp
index 3ed1167..a99a3f6 100644
--- a/scp2/source/calc/registryitem_calc.scp
+++ b/scp2/source/calc/registryitem_calc.scp
@@ -283,7 +283,7 @@ RegistryItem gid_Regitem_Soffice_Starcalcdocument_6_AppUserModelID
     ComponentCondition = "VersionNT >= 601";
     Subkey = "soffice.StarCalcDocument.6";
     Name = "AppUserModelID";
-    Value = "TheDocumentFoundation.LibreOffice";
+    Value = "TheDocumentFoundation.LibreOffice.Calc";
 End
 
 RegistryItem gid_Regitem_Soffice_Starcalcdocument_6_FriendlyTypeName
@@ -397,7 +397,7 @@ RegistryItem gid_Regitem_Soffice_Starcalctemplate_6_AppUserModelID
     ComponentCondition = "VersionNT >= 601";
     Subkey = "soffice.StarCalcTemplate.6";
     Name = "AppUserModelID";
-    Value = "TheDocumentFoundation.LibreOffice";
+    Value = "TheDocumentFoundation.LibreOffice.Calc";
 End
 
 RegistryItem gid_Regitem_Soffice_Starcalctemplate_6_FriendlyTypeName
@@ -704,7 +704,7 @@ RegistryItem gid_Regitem_Openoffice_Calcdocument_1_AppUserModelID
     ComponentCondition = "VersionNT >= 601";
     Subkey = "LibreOffice.CalcDocument.1";
     Name = "AppUserModelID";
-    Value = "TheDocumentFoundation.LibreOffice";
+    Value = "TheDocumentFoundation.LibreOffice.Calc";
 End
 
 RegistryItem gid_Regitem_Openoffice_Calcdocument_1_FriendlyTypeName
@@ -910,7 +910,7 @@ RegistryItem gid_Regitem_Openoffice_Calctemplate_1_AppUserModelID
     ComponentCondition = "VersionNT >= 601";
     Subkey = "LibreOffice.CalcTemplate.1";
     Name = "AppUserModelID";
-    Value = "TheDocumentFoundation.LibreOffice";
+    Value = "TheDocumentFoundation.LibreOffice.Calc";
 End
 
 RegistryItem gid_Regitem_Openoffice_Calctemplate_1_FriendlyTypeName
diff --git a/scp2/source/draw/registryitem_draw.scp b/scp2/source/draw/registryitem_draw.scp
index 4c9c766..9c78232 100644
--- a/scp2/source/draw/registryitem_draw.scp
+++ b/scp2/source/draw/registryitem_draw.scp
@@ -283,7 +283,7 @@ RegistryItem gid_Regitem_Soffice_Stardrawdocument_6_AppUserModelID
     ComponentCondition = "VersionNT >= 601";
     Subkey = "soffice.StarDrawDocument.6";
     Name = "AppUserModelID";
-    Value = "TheDocumentFoundation.LibreOffice";
+    Value = "TheDocumentFoundation.LibreOffice.Draw";
 End
 
 RegistryItem gid_Regitem_Soffice_Stardrawdocument_6_FriendlyTypeName
@@ -397,7 +397,7 @@ RegistryItem gid_Regitem_Soffice_Stardrawtemplate_6_AppUserModelID
     ComponentCondition = "VersionNT >= 601";
     Subkey = "soffice.StarDrawTemplate.6";
     Name = "AppUserModelID";
-    Value = "TheDocumentFoundation.LibreOffice";
+    Value = "TheDocumentFoundation.LibreOffice.Draw";
 End
 
 RegistryItem gid_Regitem_Soffice_Stardrawtemplate_6_FriendlyTypeName
@@ -704,7 +704,7 @@ RegistryItem gid_Regitem_Openoffice_Drawdocument_1_AppUserModelID
     ComponentCondition = "VersionNT >= 601";
     Subkey = "LibreOffice.DrawDocument.1";
     Name = "AppUserModelID";
-    Value = "TheDocumentFoundation.LibreOffice";
+    Value = "TheDocumentFoundation.LibreOffice.Draw";
 End
 
 RegistryItem gid_Regitem_Openoffice_Drawdocument_1_FriendlyTypeName
@@ -910,7 +910,7 @@ RegistryItem gid_Regitem_Openoffice_Drawtemplate_1_AppUserModelID
     ComponentCondition = "VersionNT >= 601";
     Subkey = "LibreOffice.DrawTemplate.1";
     Name = "AppUserModelID";
-    Value = "TheDocumentFoundation.LibreOffice";
+    Value = "TheDocumentFoundation.LibreOffice.Draw";
 End
 
 RegistryItem gid_Regitem_Openoffice_Drawtemplate_1_FriendlyTypeName
diff --git a/scp2/source/impress/registryitem_impress.scp b/scp2/source/impress/registryitem_impress.scp
index 3d24721..92962c7 100644
--- a/scp2/source/impress/registryitem_impress.scp
+++ b/scp2/source/impress/registryitem_impress.scp
@@ -283,7 +283,7 @@ RegistryItem gid_Regitem_Soffice_Starimpressdocument_6_AppUserModelID
     ComponentCondition = "VersionNT >= 601";
     Subkey = "soffice.StarImpressDocument.6";
     Name = "AppUserModelID";
-    Value = "TheDocumentFoundation.LibreOffice";
+    Value = "TheDocumentFoundation.LibreOffice.Impress";
 End
 
 RegistryItem gid_Regitem_Soffice_Starimpressdocument_6_FriendlyTypeName
@@ -411,7 +411,7 @@ RegistryItem gid_Regitem_Soffice_Starimpresstemplate_6_AppUserModelID
     ComponentCondition = "VersionNT >= 601";
     Subkey = "soffice.StarImpressTemplate.6";
     Name = "AppUserModelID";
-    Value = "TheDocumentFoundation.LibreOffice";
+    Value = "TheDocumentFoundation.LibreOffice.Impress";
 End
 
 RegistryItem gid_Regitem_Soffice_Starimpresstemplate_6_FriendlyTypeName
@@ -719,7 +719,7 @@ RegistryItem gid_Regitem_Openoffice_Impressdocument_1_AppUserModelID
     ComponentCondition = "VersionNT >= 601";
     Subkey = "LibreOffice.ImpressDocument.1";
     Name = "AppUserModelID";
-    Value = "TheDocumentFoundation.LibreOffice";
+    Value = "TheDocumentFoundation.LibreOffice.Impress";
 End
 
 RegistryItem gid_Regitem_Openoffice_Impressdocument_1_FriendlyTypeName
@@ -939,7 +939,7 @@ RegistryItem gid_Regitem_Openoffice_Impresstemplate_1_AppUserModelID
     ComponentCondition = "VersionNT >= 601";
     Subkey = "LibreOffice.ImpressTemplate.1";
     Name = "AppUserModelID";
-    Value = "TheDocumentFoundation.LibreOffice";
+    Value = "TheDocumentFoundation.LibreOffice.Impress";
 End
 
 RegistryItem gid_Regitem_Openoffice_Impresstemplate_1_FriendlyTypeName
diff --git a/scp2/source/math/registryitem_math.scp b/scp2/source/math/registryitem_math.scp
index 6d6514f..aa39a03 100644
--- a/scp2/source/math/registryitem_math.scp
+++ b/scp2/source/math/registryitem_math.scp
@@ -282,7 +282,7 @@ RegistryItem gid_Regitem_Soffice_Starmathdocument_6_AppUserModelID
     ComponentCondition = "VersionNT >= 601";
     Subkey = "soffice.StarMathDocument.6";
     Name = "AppUserModelID";
-    Value = "TheDocumentFoundation.LibreOffice";
+    Value = "TheDocumentFoundation.LibreOffice.Math";
 End
 
 RegistryItem gid_Regitem_Soffice_Starmathdocument_6_FriendlyTypeName
@@ -560,7 +560,7 @@ RegistryItem gid_Regitem_Openoffice_Mathdocument_1_AppUserModelID
     ComponentCondition = "VersionNT >= 601";
     Subkey = "LibreOffice.MathDocument.1";
     Name = "AppUserModelID";
-    Value = "TheDocumentFoundation.LibreOffice";
+    Value = "TheDocumentFoundation.LibreOffice.Math";
 End
 
 RegistryItem gid_Regitem_Openoffice_Mathdocument_1_FriendlyTypeName
diff --git a/scp2/source/writer/registryitem_writer.scp b/scp2/source/writer/registryitem_writer.scp
index 1e490ad..3120af8 100644
--- a/scp2/source/writer/registryitem_writer.scp
+++ b/scp2/source/writer/registryitem_writer.scp
@@ -283,7 +283,7 @@ RegistryItem gid_Regitem_Soffice_Starwriterdocument_6_AppUserModelID
     ComponentCondition = "VersionNT >= 601";
     Subkey = "soffice.StarWriterDocument.6";
     Name = "AppUserModelID";
-    Value = "TheDocumentFoundation.LibreOffice";
+    Value = "TheDocumentFoundation.LibreOffice.Writer";
 End
 
 RegistryItem gid_Regitem_Soffice_Starwriterdocument_6_FriendlyTypeName
@@ -404,7 +404,7 @@ RegistryItem gid_Regitem_Soffice_Starwriterglobaldocument_6_AppUserModelID
     ComponentCondition = "VersionNT >= 601";
     Subkey = "soffice.StarWriterGlobalDocument.6";
     Name = "AppUserModelID";
-    Value = "TheDocumentFoundation.LibreOffice";
+    Value = "TheDocumentFoundation.LibreOffice.Writer";
 End
 
 RegistryItem gid_Regitem_Soffice_Starwriterglobaldocument_6_FriendlyTypeName
@@ -491,7 +491,7 @@ RegistryItem gid_Regitem_Soffice_Starwritertemplate_6_AppUserModelID
     ComponentCondition = "VersionNT >= 601";
     Subkey = "soffice.StarWriterTemplate.6";
     Name = "AppUserModelID";
-    Value = "TheDocumentFoundation.LibreOffice";
+    Value = "TheDocumentFoundation.LibreOffice.Writer";
 End
 
 RegistryItem gid_Regitem_Soffice_Starwritertemplate_6_FriendlyTypeName
@@ -854,7 +854,7 @@ RegistryItem gid_Regitem_Openoffice_Writerdocument_1_AppUserModelID
     ComponentCondition = "VersionNT >= 601";
     Subkey = "LibreOffice.WriterDocument.1";
     Name = "AppUserModelID";
-    Value = "TheDocumentFoundation.LibreOffice";
+    Value = "TheDocumentFoundation.LibreOffice.Writer";
 End
 
 RegistryItem gid_Regitem_Openoffice_Writerdocument_1_FriendlyTypeName
@@ -1083,7 +1083,7 @@ RegistryItem gid_Regitem_Openoffice_Writertemplate_1_AppUserModelID
     ComponentCondition = "VersionNT >= 601";
     Subkey = "LibreOffice.WriterTemplate.1";
     Name = "AppUserModelID";
-    Value = "TheDocumentFoundation.LibreOffice";
+    Value = "TheDocumentFoundation.LibreOffice.Writer";
 End
 
 RegistryItem gid_Regitem_Openoffice_Writertemplate_1_FriendlyTypeName
@@ -1235,7 +1235,7 @@ RegistryItem gid_Regitem_Openoffice_Writerglobaldocument_1_AppUserModelID
     ComponentCondition = "VersionNT >= 601";
     Subkey = "LibreOffice.WriterGlobalDocument.1";
     Name = "AppUserModelID";
-    Value = "TheDocumentFoundation.LibreOffice";
+    Value = "TheDocumentFoundation.LibreOffice.Writer";
 End
 
 RegistryItem gid_Regitem_Openoffice_Writerglobaldocument_1_FriendlyTypeName
@@ -1387,7 +1387,7 @@ RegistryItem gid_Regitem_Openoffice_WriterWebTemplate_1_AppUserModelID
     ComponentCondition = "VersionNT >= 601";
     Subkey = "LibreOffice.WriterWebTemplate.1";
     Name = "AppUserModelID";
-    Value = "TheDocumentFoundation.LibreOffice";
+    Value = "TheDocumentFoundation.LibreOffice.Writer";
 End
 
 RegistryItem gid_Regitem_Openoffice_WriterWebTemplate_1_FriendlyTypeName
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 3c56c44..dd0f0e0 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -635,6 +635,7 @@ $(eval $(call gb_Library_use_system_win32_libs,vcl,\
 	uuid \
 	version \
 	winspool \
+	shlwapi \
 ))
 
 $(eval $(call gb_Library_add_nativeres,vcl,vcl/salsrc))
diff --git a/vcl/inc/win/salframe.h b/vcl/inc/win/salframe.h
index 4076d61..cdde4b9 100644
--- a/vcl/inc/win/salframe.h
+++ b/vcl/inc/win/salframe.h
@@ -77,10 +77,11 @@ public:
     sal_Bool                    mbCandidateMode;        // TRUE: Wir befinden uns im Candidate-Modus
     static sal_Bool             mbInReparent;           // TRUE: ignore focus lost and gain due to reparenting
 
-    RGNDATA*                mpClipRgnData;
-    RECT*                   mpNextClipRect;
+    RGNDATA*                    mpClipRgnData;
+    RECT*                       mpNextClipRect;
     sal_Bool                    mbFirstClipRect;
-    sal_Int32               mnDisplay;              // Display used for Fullscreen, 0 is primary monitor
+    sal_Int32                   mnDisplay;              // Display used for Fullscreen, 0 is primary monitor
+    sal_Bool                    mbPropertiesStored;     // has values stored in the window property store
 
     void updateScreenNumber();
 public:
diff --git a/vcl/win/source/window/salframe.cxx b/vcl/win/source/window/salframe.cxx
index f3c9414..45f8424 100644
--- a/vcl/win/source/window/salframe.cxx
+++ b/vcl/win/source/window/salframe.cxx
@@ -90,6 +90,12 @@ using ::std::max;
 #include <sehandler.hxx>
 #endif
 
+#include <windows.h>
+#include <shobjidl.h>
+#include <propkey.h>
+#include <propvarutil.h>
+#include <shellapi.h>
+
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::lang;
@@ -881,6 +887,7 @@ WinSalFrame::WinSalFrame()
     mbFirstClipRect     = TRUE;
     mpNextClipRect      = NULL;
     mnDisplay           = 0;
+    mbPropertiesStored  = FALSE;
 
     memset( &maState, 0, sizeof( SalFrameState ) );
     maSysData.nSize     = sizeof( SystemEnvData );
@@ -971,6 +978,10 @@ WinSalFrame::~WinSalFrame()
             }
         }
 
+        // remove windows properties
+        if ( mbPropertiesStored )
+            SetApplicationID( OUString() );
+
         // destroy system frame
         if ( !DestroyWindow( mhWnd ) )
             SetWindowPtr( mhWnd, 0 );
@@ -1892,8 +1903,70 @@ void WinSalFrame::SetScreenNumber( unsigned int nNewScreen )
     }
 }
 
-void WinSalFrame::SetApplicationID( const OUString &/*rApplicationID*/ )
+void WinSalFrame::SetApplicationID( const OUString &rApplicationID )
 {
+    if( aSalShlData.maVersionInfo.dwMajorVersion >= 6 )
+    {
+        // http://msdn.microsoft.com/en-us/library/windows/desktop/dd378430(v=vs.85).aspx
+        // A window's properties must be removed before the window is closed.
+
+        WCHAR szShell32[MAX_PATH];
+        GetSystemDirectoryW( szShell32, MAX_PATH );
+        wcscat( szShell32, L"\\Shell32.dll" );
+
+        HINSTANCE hinstDll = LoadLibraryW( szShell32 );
+
+        if( hinstDll )
+        {
+            DLLVERSIONINFO dvi;
+            ZeroMemory(&dvi, sizeof(dvi));
+            dvi.cbSize = sizeof(dvi);
+
+            DLLGETVERSIONPROC pDllGetVersion;
+            pDllGetVersion = ( DLLGETVERSIONPROC )GetProcAddress( hinstDll, "DllGetVersion" );
+            HRESULT hr = (*pDllGetVersion)(&dvi);
+
+            if( SUCCEEDED(hr) )
+            {
+                #define PACKVERSION(major,minor) MAKELONG(minor,major)
+                DWORD dwVersion = PACKVERSION( dvi.dwMajorVersion, dvi.dwMinorVersion );
+                // shell32 in Windows 7 is version 6.1.
+                if( dwVersion >= PACKVERSION(6,1) )
+                {
+                    typedef HRESULT ( WINAPI *SHGETPROPERTYSTOREFORWINDOW )( HWND, REFIID, void ** );
+                    SHGETPROPERTYSTOREFORWINDOW pSHGetPropertyStoreForWindow;
+                    pSHGetPropertyStoreForWindow =
+                        ( SHGETPROPERTYSTOREFORWINDOW ) GetProcAddress( hinstDll, "SHGetPropertyStoreForWindow" );
+
+                    if( pSHGetPropertyStoreForWindow )
+                    {
+                        IPropertyStore *pps;
+                        HRESULT hr = ( *pSHGetPropertyStoreForWindow ) ( mhWnd, IID_PPV_ARGS(&pps) );
+                        if ( SUCCEEDED(hr) )
+                        {
+                            PROPVARIANT pv;
+                            if ( !rApplicationID.isEmpty() )
+                            {
+                                hr = InitPropVariantFromString( rApplicationID.getStr(), &pv );
+                                mbPropertiesStored = TRUE;
+                            }
+                            else
+                                // if rApplicationID we remove the property from the window, if present
+                                PropVariantInit( &pv );
+
+                            if ( SUCCEEDED(hr) )
+                            {
+                                hr = pps->SetValue( PKEY_AppUserModel_ID, pv );
+                                PropVariantClear( &pv );
+                            }
+                            pps->Release();
+                        }
+                    }
+                }
+            }
+        }
+        FreeLibrary( hinstDll );
+    }
 }
 
 // -----------------------------------------------------------------------


More information about the Libreoffice-commits mailing list