Kaydet (Commit) 19f3d931 authored tarafından Jesús Corrius's avatar Jesús Corrius Kaydeden (comit) Fridrich Strba

fdo#35785 LibreOffice's support of recent documents in Windows 7 broken

Change-Id: I916ba1335b0a0420f568ab9340632f273e3c9516
Reviewed-on: https://gerrit.libreoffice.org/4997Reviewed-by: 's avatarFridrich Strba <fridrich@documentfoundation.org>
Tested-by: 's avatarFridrich Strba <fridrich@documentfoundation.org>
üst 822577f4
......@@ -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;
......
......@@ -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
}
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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))
......
......@@ -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:
......
......@@ -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 );
}
}
// -----------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment