summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesús Corrius <jcorrius@gmail.com>2013-07-29 01:26:24 +0200
committerFridrich Štrba <fridrich.strba@bluewin.ch>2013-07-29 01:34:29 +0200
commite62fec4075e55fd62a3f0d25b230498e5705dd26 (patch)
tree5cc49ff9280352d6330909b3c9d94a12161d3918
parentaf079c886f9643d539a16065dc4e96d70fac422b (diff)
Use the Win7 semantics of SHAddToRecentDocs when possible
Change-Id: I7cf0dfaec408800f3c682b3ef56799818b805881
-rw-r--r--vcl/inc/win/saldata.hxx1
-rw-r--r--vcl/win/source/app/salinst.cxx64
-rw-r--r--vcl/win/source/window/salframe.cxx3
3 files changed, 65 insertions, 3 deletions
diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index fdf2fafc0351..ea60b6977900 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -136,6 +136,7 @@ struct SalShlData
UINT mnWheelScrollChars; // WheelScrollChars
UINT mnWheelMsgId; // Wheel-Message-Id fuer W95
BOOL mbWXP; // Windows XP
+ BOOL mbW7; // Windows 7
OSVERSIONINFO maVersionInfo;
};
diff --git a/vcl/win/source/app/salinst.cxx b/vcl/win/source/app/salinst.cxx
index da0ad46c8696..4401bb703a42 100644
--- a/vcl/win/source/app/salinst.cxx
+++ b/vcl/win/source/app/salinst.cxx
@@ -493,6 +493,7 @@ SalInstance* CreateSalInstance()
// determine the windows version
aSalShlData.mbWXP = 0;
+ aSalShlData.mbW7 = 0;
memset( &aSalShlData.maVersionInfo, 0, sizeof(aSalShlData.maVersionInfo) );
aSalShlData.maVersionInfo.dwOSVersionInfoSize = sizeof( aSalShlData.maVersionInfo );
if ( GetVersionEx( &aSalShlData.maVersionInfo ) )
@@ -501,6 +502,10 @@ SalInstance* CreateSalInstance()
if ( aSalShlData.maVersionInfo.dwMajorVersion > 5 ||
( aSalShlData.maVersionInfo.dwMajorVersion == 5 && aSalShlData.maVersionInfo.dwMinorVersion >= 1 ) )
aSalShlData.mbWXP = 1;
+ // Windows 7 ?
+ if ( aSalShlData.maVersionInfo.dwMajorVersion > 6 ||
+ ( aSalShlData.maVersionInfo.dwMajorVersion == 6 && aSalShlData.maVersionInfo.dwMinorVersion >= 1 ) )
+ aSalShlData.mbW7 = 1;
}
pSalData->mnAppThreadId = GetCurrentThreadId();
@@ -1030,7 +1035,7 @@ void* WinSalInstance::GetConnectionIdentifier( ConnectionIdentifierType& rReturn
@param aFileUrl
The file url of the document.
*/
-void WinSalInstance::AddToRecentDocumentList(const OUString& rFileUrl, const OUString& /*rMimeType*/, const OUString& /* rDocumentService */)
+void WinSalInstance::AddToRecentDocumentList(const OUString& rFileUrl, const OUString& /*rMimeType*/, const OUString& rDocumentService)
{
OUString system_path;
osl::FileBase::RC rc = osl::FileBase::getSystemPathFromFileURL(rFileUrl, system_path);
@@ -1038,7 +1043,64 @@ void WinSalInstance::AddToRecentDocumentList(const OUString& rFileUrl, const OUS
OSL_ENSURE(osl::FileBase::E_None == rc, "Invalid file url");
if (osl::FileBase::E_None == rc)
+ {
+ if ( aSalShlData.mbW7 )
+ {
+ typedef HRESULT ( WINAPI *SHCREATEITEMFROMPARSINGNAME )( PCWSTR, IBindCtx*, REFIID, void **ppv );
+ SHCREATEITEMFROMPARSINGNAME pSHCreateItemFromParsingName =
+ ( SHCREATEITEMFROMPARSINGNAME )GetProcAddress(
+ GetModuleHandleW (L"shell32.dll"), "SHCreateItemFromParsingName" );
+
+ if( pSHCreateItemFromParsingName )
+ {
+ IShellItem* pShellItem = NULL;
+
+ HRESULT hr = pSHCreateItemFromParsingName ( system_path.getStr(), NULL, IID_PPV_ARGS(&pShellItem) );
+
+ if ( SUCCEEDED(hr) && pShellItem )
+ {
+ OUString sApplicationName;
+
+ if ( rDocumentService == "com.sun.star.text.TextDocument" ||
+ rDocumentService == "com.sun.star.text.GlobalDocument" ||
+ rDocumentService == "com.sun.star.text.WebDocument" ||
+ rDocumentService == "com.sun.star.xforms.XMLFormDocument" )
+ sApplicationName = "Writer";
+ else if ( rDocumentService == "com.sun.star.sheet.SpreadsheetDocument" ||
+ rDocumentService == "com.sun.star.chart2.ChartDocument" )
+ sApplicationName = "Calc";
+ else if ( rDocumentService == "com.sun.star.presentation.PresentationDocument" )
+ sApplicationName = "Impress";
+ else if ( rDocumentService == "com.sun.star.drawing.DrawingDocument" )
+ sApplicationName = "Draw";
+ else if ( rDocumentService == "com.sun.star.formula.FormulaProperties" )
+ sApplicationName = "Math";
+ else if ( rDocumentService == "com.sun.star.sdb.DatabaseDocument" ||
+ rDocumentService == "com.sun.star.sdb.OfficeDatabaseDocument" ||
+ rDocumentService == "com.sun.star.sdb.RelationDesign" ||
+ rDocumentService == "com.sun.star.sdb.QueryDesign" ||
+ rDocumentService == "com.sun.star.sdb.TableDesign" ||
+ rDocumentService == "com.sun.star.sdb.DataSourceBrowser" )
+ sApplicationName = "Base";
+
+ if ( !sApplicationName.isEmpty() )
+ {
+ OUString sApplicationID("TheDocumentFoundation.LibreOffice.");
+ sApplicationID += sApplicationName;
+
+ SHARDAPPIDINFO info;
+ info.psi = pShellItem;
+ info.pszAppID = sApplicationID.getStr();
+
+ SHAddToRecentDocs ( SHARD_APPIDINFO, &info );
+ return;
+ }
+ }
+ }
+ }
+ // For whatever reason, we could not use the SHARD_APPIDNFO semantics
SHAddToRecentDocs(SHARD_PATHW, system_path.getStr());
+ }
}
// -----------------------------------------------------------------------
diff --git a/vcl/win/source/window/salframe.cxx b/vcl/win/source/window/salframe.cxx
index 63454c2e5fba..91a34a9e290d 100644
--- a/vcl/win/source/window/salframe.cxx
+++ b/vcl/win/source/window/salframe.cxx
@@ -1905,7 +1905,7 @@ void WinSalFrame::SetScreenNumber( unsigned int nNewScreen )
void WinSalFrame::SetApplicationID( const OUString &rApplicationID )
{
- if( aSalShlData.maVersionInfo.dwMajorVersion >= 6 )
+ if ( aSalShlData.mbW7 )
{
// 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.
@@ -1915,7 +1915,6 @@ void WinSalFrame::SetApplicationID( const OUString &rApplicationID )
pSHGetPropertyStoreForWindow = ( SHGETPROPERTYSTOREFORWINDOW )GetProcAddress(
GetModuleHandleW (L"shell32.dll"), "SHGetPropertyStoreForWindow" );
- // A mere presence of the symbol means we are at least on Windows 7 or Windows Server 2008 R2
if( pSHGetPropertyStoreForWindow )
{
IPropertyStore *pps;