Kaydet (Commit) b411470b authored tarafından Michael Stahl's avatar Michael Stahl

vcl: replace dynamic lookups of Windows 7 APIs with static calls

Change-Id: I5d4c4bb98e271e69c45b8e7f989f9b21d287c0bb
üst 5158c16a
...@@ -100,10 +100,7 @@ ...@@ -100,10 +100,7 @@
#ifdef _WIN32 #ifdef _WIN32
// WinCrypt headers for PDF signing // WinCrypt headers for PDF signing
// Note: this uses Windows 7 APIs and requires the relevant data types; // Note: this uses Windows 7 APIs and requires the relevant data types
// the functions that don't exist in WinXP must be looked up at runtime!
#undef _WIN32_WINNT
#define _WIN32_WINNT _WIN32_WINNT_WIN7
#include <prewin.h> #include <prewin.h>
#include <wincrypt.h> #include <wincrypt.h>
#include <postwin.h> #include <postwin.h>
...@@ -6222,17 +6219,6 @@ NSSCMSMessage *CreateCMSMessage(PRTime* time, ...@@ -6222,17 +6219,6 @@ NSSCMSMessage *CreateCMSMessage(PRTime* time,
#ifdef _WIN32 #ifdef _WIN32
typedef BOOL (WINAPI *PointerTo_CryptRetrieveTimeStamp)(LPCWSTR wszUrl,
DWORD dwRetrievalFlags,
DWORD dwTimeout,
LPCSTR pszHashId,
const CRYPT_TIMESTAMP_PARA *pPara,
const BYTE *pbData,
DWORD cbData,
PCRYPT_TIMESTAMP_CONTEXT *ppTsContext,
PCCERT_CONTEXT *ppTsSigner,
HCERTSTORE phStore);
namespace namespace
{ {
...@@ -6958,15 +6944,6 @@ bool PDFWriter::Sign(PDFSignContext& rContext) ...@@ -6958,15 +6944,6 @@ bool PDFWriter::Sign(PDFSignContext& rContext)
if( !rContext.m_aSignTSA.isEmpty() ) if( !rContext.m_aSignTSA.isEmpty() )
{ {
PointerTo_CryptRetrieveTimeStamp crts = reinterpret_cast<PointerTo_CryptRetrieveTimeStamp>(GetProcAddress(LoadLibrary("crypt32.dll"), "CryptRetrieveTimeStamp"));
if (!crts)
{
SAL_WARN("vcl.pdfwriter", "Could not find the CryptRetrieveTimeStamp function in crypt32.dll: " << WindowsErrorString(GetLastError()));
CryptMsgClose(hMsg);
CertFreeCertificateContext(pCertContext);
return false;
}
HCRYPTMSG hDecodedMsg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING | X509_ASN_ENCODING, HCRYPTMSG hDecodedMsg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING | X509_ASN_ENCODING,
CMSG_DETACHED_FLAG, CMSG_DETACHED_FLAG,
CMSG_SIGNED, CMSG_SIGNED,
...@@ -7047,7 +7024,7 @@ bool PDFWriter::Sign(PDFSignContext& rContext) ...@@ -7047,7 +7024,7 @@ bool PDFWriter::Sign(PDFSignContext& rContext)
aTsPara.cExtension = 0; aTsPara.cExtension = 0;
aTsPara.rgExtension = nullptr; aTsPara.rgExtension = nullptr;
if (!(*crts)(SAL_W(rContext.m_aSignTSA.getStr()), if (!CryptRetrieveTimeStamp(SAL_W(rContext.m_aSignTSA.getStr()),
0, 0,
10000, 10000,
szOID_NIST_sha256, szOID_NIST_sha256,
......
...@@ -913,65 +913,47 @@ void WinSalInstance::AddToRecentDocumentList(const OUString& rFileUrl, const OUS ...@@ -913,65 +913,47 @@ void WinSalInstance::AddToRecentDocumentList(const OUString& rFileUrl, const OUS
{ {
if ( aSalShlData.mbW7 ) if ( aSalShlData.mbW7 )
{ {
typedef HRESULT ( WINAPI *SHCREATEITEMFROMPARSINGNAME )( PCWSTR, IBindCtx*, REFIID, void **ppv ); IShellItem* pShellItem = nullptr;
SHCREATEITEMFROMPARSINGNAME pSHCreateItemFromParsingName =
reinterpret_cast<SHCREATEITEMFROMPARSINGNAME>(GetProcAddress(
GetModuleHandleW (L"shell32.dll"), "SHCreateItemFromParsingName" ));
if( pSHCreateItemFromParsingName ) HRESULT hr = SHCreateItemFromParsingName(SAL_W(system_path.getStr()), nullptr, IID_PPV_ARGS(&pShellItem));
{
IShellItem* pShellItem = nullptr;
HRESULT hr = pSHCreateItemFromParsingName ( SAL_W(system_path.getStr()), nullptr, IID_PPV_ARGS(&pShellItem) );
if ( SUCCEEDED(hr) && 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 sApplicationName; OUString sApplicationID("TheDocumentFoundation.LibreOffice.");
sApplicationID += 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;
#if _WIN32_WINNT < _WIN32_WINNT_WIN7
// just define Windows 7 only constant locally...
#define SHARD_APPIDINFO 0x00000004
#endif
typedef struct {
IShellItem *psi;
PCWSTR pszAppID;
} DummyShardAppIDInfo;
DummyShardAppIDInfo info; SHARDAPPIDINFO info;
info.psi = pShellItem; info.psi = pShellItem;
info.pszAppID = SAL_W(sApplicationID.getStr()); info.pszAppID = SAL_W(sApplicationID.getStr());
SHAddToRecentDocs ( SHARD_APPIDINFO, &info ); SHAddToRecentDocs ( SHARD_APPIDINFO, &info );
return; return;
}
} }
} }
} }
......
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