summaryrefslogtreecommitdiff
path: root/vcl
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
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')
-rw-r--r--vcl/Library_vcl.mk1
-rw-r--r--vcl/inc/win/salframe.h7
-rw-r--r--vcl/win/source/window/salframe.cxx75
3 files changed, 79 insertions, 4 deletions
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 3c56c4495423..dd0f0e0a05d0 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 4076d61451d3..cdde4b9a7a68 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 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 );
+ }
}
// -----------------------------------------------------------------------