summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2017-05-30 16:45:32 +0200
committerMichael Stahl <mstahl@redhat.com>2017-05-30 20:19:21 +0200
commitb411470bb818b6be17d0da982deb74d31b1b3dfc (patch)
treeff0f1f843a377b1469f625157163a288abe6d121
parent5158c16a9ef23ab610940eb51e2fead13a7b0456 (diff)
vcl: replace dynamic lookups of Windows 7 APIs with static calls
Change-Id: I5d4c4bb98e271e69c45b8e7f989f9b21d287c0bb
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx27
-rw-r--r--vcl/win/app/salinst.cxx90
2 files changed, 38 insertions, 79 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 5384204e4dc5..815892859b99 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -100,10 +100,7 @@
#ifdef _WIN32
// WinCrypt headers for PDF signing
-// 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
+// Note: this uses Windows 7 APIs and requires the relevant data types
#include <prewin.h>
#include <wincrypt.h>
#include <postwin.h>
@@ -6222,17 +6219,6 @@ NSSCMSMessage *CreateCMSMessage(PRTime* time,
#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
{
@@ -6958,15 +6944,6 @@ bool PDFWriter::Sign(PDFSignContext& rContext)
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,
CMSG_DETACHED_FLAG,
CMSG_SIGNED,
@@ -7047,7 +7024,7 @@ bool PDFWriter::Sign(PDFSignContext& rContext)
aTsPara.cExtension = 0;
aTsPara.rgExtension = nullptr;
- if (!(*crts)(SAL_W(rContext.m_aSignTSA.getStr()),
+ if (!CryptRetrieveTimeStamp(SAL_W(rContext.m_aSignTSA.getStr()),
0,
10000,
szOID_NIST_sha256,
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index e087b4d1d99b..78147ae67608 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -913,65 +913,47 @@ void WinSalInstance::AddToRecentDocumentList(const OUString& rFileUrl, const OUS
{
if ( aSalShlData.mbW7 )
{
- typedef HRESULT ( WINAPI *SHCREATEITEMFROMPARSINGNAME )( PCWSTR, IBindCtx*, REFIID, void **ppv );
- SHCREATEITEMFROMPARSINGNAME pSHCreateItemFromParsingName =
- reinterpret_cast<SHCREATEITEMFROMPARSINGNAME>(GetProcAddress(
- GetModuleHandleW (L"shell32.dll"), "SHCreateItemFromParsingName" ));
+ IShellItem* pShellItem = nullptr;
- if( pSHCreateItemFromParsingName )
- {
- IShellItem* pShellItem = nullptr;
-
- HRESULT hr = pSHCreateItemFromParsingName ( SAL_W(system_path.getStr()), nullptr, IID_PPV_ARGS(&pShellItem) );
+ HRESULT hr = SHCreateItemFromParsingName(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;
-
- 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;
+ OUString sApplicationID("TheDocumentFoundation.LibreOffice.");
+ sApplicationID += sApplicationName;
- DummyShardAppIDInfo info;
- info.psi = pShellItem;
- info.pszAppID = SAL_W(sApplicationID.getStr());
+ SHARDAPPIDINFO info;
+ info.psi = pShellItem;
+ info.pszAppID = SAL_W(sApplicationID.getStr());
- SHAddToRecentDocs ( SHARD_APPIDINFO, &info );
- return;
- }
+ SHAddToRecentDocs ( SHARD_APPIDINFO, &info );
+ return;
}
}
}