summaryrefslogtreecommitdiff
path: root/vcl/win
diff options
context:
space:
mode:
authorJesús Corrius <jcorrius@gmail.com>2013-07-20 17:10:43 +0200
committerFridrich Strba <fridrich@documentfoundation.org>2013-07-20 21:01:01 +0000
commit19f3d9310caef84fe2815eb89af448a81937bddd (patch)
tree8784aea768d9355497f56cd1f3dfad4e55563014 /vcl/win
parent822577f412214f282588b627fd6addb489f6a9f0 (diff)
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@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
Diffstat (limited to 'vcl/win')
-rw-r--r--vcl/win/source/window/salframe.cxx75
1 files changed, 74 insertions, 1 deletions
diff --git a/vcl/win/source/window/salframe.cxx b/vcl/win/source/window/salframe.cxx
index f3c94140d65b..45f842468b06 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 );
+ }
}
// -----------------------------------------------------------------------