[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - vcl/inc vcl/win

Jesús Corrius jcorrius at gmail.com
Mon Jul 29 01:25:25 PDT 2013


 vcl/inc/win/saldata.hxx            |    1 
 vcl/win/source/app/salinst.cxx     |   64 ++++++++++++++++++++++++++++++++++++-
 vcl/win/source/window/salframe.cxx |    3 -
 3 files changed, 65 insertions(+), 3 deletions(-)

New commits:
commit d915d7252c1997729892ab5f62680beeefe861aa
Author: Jesús Corrius <jcorrius at gmail.com>
Date:   Mon Jul 29 01:26:24 2013 +0200

    Use the Win7 semantics of SHAddToRecentDocs when possible
    
    Change-Id: I7cf0dfaec408800f3c682b3ef56799818b805881
    (cherry picked from commit e62fec4075e55fd62a3f0d25b230498e5705dd26)
    Reviewed-on: https://gerrit.libreoffice.org/5163
    Reviewed-by: Luboš Luňák <l.lunak at suse.cz>
    Tested-by: Luboš Luňák <l.lunak at suse.cz>

diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index fdf2faf..ea60b69 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 f5deb45..99356ba 100644
--- a/vcl/win/source/app/salinst.cxx
+++ b/vcl/win/source/app/salinst.cxx
@@ -480,6 +480,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 ) )
@@ -488,6 +489,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();
@@ -1017,7 +1022,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);
@@ -1025,7 +1030,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 f32f9fe..bc7dc27 100644
--- a/vcl/win/source/window/salframe.cxx
+++ b/vcl/win/source/window/salframe.cxx
@@ -1909,7 +1909,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.
@@ -1919,7 +1919,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;


More information about the Libreoffice-commits mailing list