embeddedobj/source/msole/olecomponent.cxx | 4 - embedserv/source/embed/tracker.cxx | 2 extensions/source/ole/olethread.cxx | 4 - extensions/source/ole/servprov.cxx | 2 extensions/source/ole/unoobjw.cxx | 6 - include/comphelper/windowserrorstring.hxx | 6 - sal/osl/w32/socket.cxx | 2 sal/osl/w32/thread.cxx | 2 sfx2/source/appl/shutdowniconw32.cxx | 2 shell/source/win32/spsupp/spsuppHelper.cxx | 2 svl/source/crypto/cryptosign.cxx | 40 +++++----- vcl/skia/win/gdiimpl.cxx | 8 +- vcl/source/opengl/win/context.cxx | 12 +-- vcl/win/app/salinst.cxx | 2 vcl/win/dtrans/MtaOleClipb.cxx | 2 vcl/win/dtrans/target.cxx | 2 vcl/win/gdi/DWriteTextRenderer.cxx | 2 vcl/win/gdi/salfont.cxx | 2 vcl/win/gdi/salgdi.cxx | 4 - vcl/win/gdi/salvd.cxx | 6 - vcl/win/gdi/winlayout.cxx | 1 vcl/win/window/salframe.cxx | 14 +-- vcl/win/window/salobj.cxx | 2 xmlsecurity/source/xmlsec/errorcallback.cxx | 2 xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx | 2 xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx | 8 +- 26 files changed, 70 insertions(+), 71 deletions(-)
New commits: commit 2a20616d09709427e8cf2474d4721836bce66b8e Author: varshneydevansh <varshney.devansh...@gmail.com> AuthorDate: Wed Mar 26 14:33:08 2025 +0530 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Wed Mar 26 15:11:33 2025 +0100 Move Windows error helpers to comphelper namespace Previously, WindowsErrorString and WindowsErrorStringFromHRESULT were defined in an anonymous namespace in windowserrorstring.hxx, which: 1. Made them unavailable to other translation units 2. Violate ODR by creating separate copies in each TU 3. Require workarounds to access them Changes: - Move functions to proper comphelper namespace - Keep implementations inline as they're simple utilities - Preserve all existing functionality - Update all call sites to use comphelper:: prefix This change enables proper use of these utilities across LibreOffice while maintaining current behavior and performance characteristics. Introduced in this commit: commit 94cdcaa4d8db8f03ac9a84dac54357efff3eb123 Author: Tor Lillqvist <t...@collabora.com> Date: Thu Aug 13 13:22:28 2015 +0300 Add a globally usable WindowsErrorString function Change-Id: I34df1c2b1f30c6204f107ca4792131d692203880 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183332 Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Tested-by: Jenkins diff --git a/embeddedobj/source/msole/olecomponent.cxx b/embeddedobj/source/msole/olecomponent.cxx index 9cc03b751865..1d4fa24e8e4f 100644 --- a/embeddedobj/source/msole/olecomponent.cxx +++ b/embeddedobj/source/msole/olecomponent.cxx @@ -412,7 +412,7 @@ OleComponent::OleComponent( const uno::Reference< uno::XComponentContext >& xCon { SAL_WARN("embeddedobj.ole", "OleComponent ctor: OleInitialize() failed with 0x" << OUString::number(static_cast<sal_uInt32>(hr), 16) << ": " - << WindowsErrorStringFromHRESULT(hr)); + << comphelper::WindowsErrorStringFromHRESULT(hr)); } m_pOleWrapClientSite = new OleWrapperClientSite( this ); @@ -945,7 +945,7 @@ void OleComponent::RunObject() if ( FAILED( hr ) ) { - OUString error = WindowsErrorStringFromHRESULT(hr); + OUString error = comphelper::WindowsErrorStringFromHRESULT(hr); if ( hr == REGDB_E_CLASSNOTREG ) { if (auto pOleObj diff --git a/embedserv/source/embed/tracker.cxx b/embedserv/source/embed/tracker.cxx index fb331dfa1478..f9e70aa7e1e7 100644 --- a/embedserv/source/embed/tracker.cxx +++ b/embedserv/source/embed/tracker.cxx @@ -399,7 +399,7 @@ BOOL Tracker::TrackHandle(int nHandle,HWND hWnd,POINT point,HWND hWndClipTo) { MSG msg; int const bRet = GetMessageW(&msg, nullptr, 0, 0); - SAL_WARN_IF(-1 == bRet, "embedserv", "GetMessageW failed: " << WindowsErrorString(GetLastError())); + SAL_WARN_IF(-1 == bRet, "embedserv", "GetMessageW failed: " << comphelper::WindowsErrorString(GetLastError())); if (-1 == bRet || 0 == bRet) break; diff --git a/extensions/source/ole/olethread.cxx b/extensions/source/ole/olethread.cxx index 503f8bc096c1..e3957187755e 100644 --- a/extensions/source/ole/olethread.cxx +++ b/extensions/source/ole/olethread.cxx @@ -36,10 +36,10 @@ void o2u_attachCurrentThread() // Let's find out explicitly what apartment mode we are in. if (hr == RPC_E_CHANGED_MODE) SAL_INFO("extensions.olebridge", "CoInitializeEx failed (expectedly): " - << WindowsErrorStringFromHRESULT(hr)); + << comphelper::WindowsErrorStringFromHRESULT(hr)); else SAL_WARN("extensions.olebridge", - "CoInitializeEx failed: " << WindowsErrorStringFromHRESULT(hr)); + "CoInitializeEx failed: " << comphelper::WindowsErrorStringFromHRESULT(hr)); APTTYPE nAptType; APTTYPEQUALIFIER nAptTypeQualifier; if (SUCCEEDED(CoGetApartmentType(&nAptType, &nAptTypeQualifier))) diff --git a/extensions/source/ole/servprov.cxx b/extensions/source/ole/servprov.cxx index a37703eb012d..13a2fbc10bba 100644 --- a/extensions/source/ole/servprov.cxx +++ b/extensions/source/ole/servprov.cxx @@ -92,7 +92,7 @@ bool OneInstanceOleWrapper::registerClass(GUID const * pGuid) REGCLS_MULTIPLEUSE, &m_factoryHandle); - SAL_INFO("extensions.olebridge", "CoRegisterClassObject(" << *pGuid << "): " << WindowsErrorStringFromHRESULT(hresult)); + SAL_INFO("extensions.olebridge", "CoRegisterClassObject(" << *pGuid << "): " << comphelper::WindowsErrorStringFromHRESULT(hresult)); return (hresult == NOERROR); } diff --git a/extensions/source/ole/unoobjw.cxx b/extensions/source/ole/unoobjw.cxx index eada13aa6386..6e3cca6446cb 100644 --- a/extensions/source/ole/unoobjw.cxx +++ b/extensions/source/ole/unoobjw.cxx @@ -2311,7 +2311,7 @@ Sink::Call( const OUString& Method, Sequence< Any >& Arguments ) HRESULT nResult = mpUnkSink->QueryInterface(IID_IDispatch, reinterpret_cast<void **>(&pDispatch)); if (!SUCCEEDED(nResult)) { - SAL_WARN("extensions.olebridge", "Sink::Call: Not IDispatch: " << WindowsErrorStringFromHRESULT(nResult)); + SAL_WARN("extensions.olebridge", "Sink::Call: Not IDispatch: " << comphelper::WindowsErrorStringFromHRESULT(nResult)); return; } @@ -2404,7 +2404,7 @@ Sink::Call( const OUString& Method, Sequence< Any >& Arguments ) nResult = pDispatch->Invoke(nMemId, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &aDispParams, &aVarResult, nullptr, &uArgErr); SAL_INFO("extensions.olebridge", "Sink::Call(" << Method << "): Invoke() returned"); - SAL_WARN_IF(!SUCCEEDED(nResult), "extensions.olebridge", "Call to " << Method << " failed: " << WindowsErrorStringFromHRESULT(nResult)); + SAL_WARN_IF(!SUCCEEDED(nResult), "extensions.olebridge", "Call to " << Method << " failed: " << comphelper::WindowsErrorStringFromHRESULT(nResult)); // Undo VT_BYREF magic done above. Copy out parameters back to the Anys in Arguments for (unsigned j = 0; j < aDispParams.cArgs; j++) @@ -2708,7 +2708,7 @@ public: nResult = CComObject<CXEnumConnections>::CreateInstance(&pEnumConnections); if (FAILED(nResult)) { - SAL_INFO("extensions.olebridge", "..." << this << "@CXConnectionPoint::EnumConnections: " << WindowsErrorStringFromHRESULT(nResult)); + SAL_INFO("extensions.olebridge", "..." << this << "@CXConnectionPoint::EnumConnections: " << comphelper::WindowsErrorStringFromHRESULT(nResult)); return nResult; } diff --git a/include/comphelper/windowserrorstring.hxx b/include/comphelper/windowserrorstring.hxx index 7b6bdb6db8b1..a007da4632d9 100644 --- a/include/comphelper/windowserrorstring.hxx +++ b/include/comphelper/windowserrorstring.hxx @@ -15,8 +15,8 @@ #include <rtl/ustring.hxx> #include <o3tl/char16_t2wchar_t.hxx> -namespace { - +namespace comphelper +{ inline OUString WindowsErrorString(DWORD nErrorCode) { LPWSTR pMsgBuf; @@ -61,7 +61,7 @@ inline OUString WindowsErrorStringFromHRESULT(HRESULT hr) return WindowsErrorString(nErrorCode); } -} // anonymous namespace +} // namespace comphelper #endif diff --git a/sal/osl/w32/socket.cxx b/sal/osl/w32/socket.cxx index bc5a50dfd99b..354ce2db5942 100644 --- a/sal/osl/w32/socket.cxx +++ b/sal/osl/w32/socket.cxx @@ -788,7 +788,7 @@ oslSocket SAL_CALL osl_createSocket( if(pSocket->m_Socket == OSL_INVALID_SOCKET) { int nErrno = WSAGetLastError(); - SAL_WARN("sal.osl", "socket creation failed: (" << nErrno << "): " << WindowsErrorString(nErrno)); + SAL_WARN("sal.osl", "socket creation failed: (" << nErrno << "): " << comphelper::WindowsErrorString(nErrno)); destroySocketImpl(pSocket); pSocket = nullptr; diff --git a/sal/osl/w32/thread.cxx b/sal/osl/w32/thread.cxx index 690431972516..36ff83d49f4c 100644 --- a/sal/osl/w32/thread.cxx +++ b/sal/osl/w32/thread.cxx @@ -99,7 +99,7 @@ static oslThread oslCreateThread(oslWorkerFunction pWorker, if(pThreadImpl->m_hThread == nullptr) { - SAL_WARN("sal.osl", "CreateThread failed:" << WindowsErrorString(GetLastError())); + SAL_WARN("sal.osl", "CreateThread failed:" << comphelper::WindowsErrorString(GetLastError())); /* create failed */ free(pThreadImpl); diff --git a/sfx2/source/appl/shutdowniconw32.cxx b/sfx2/source/appl/shutdowniconw32.cxx index 9bbbac69c094..60a836b05dcb 100644 --- a/sfx2/source/appl/shutdowniconw32.cxx +++ b/sfx2/source/appl/shutdowniconw32.cxx @@ -457,7 +457,7 @@ static unsigned __stdcall SystrayThread(void* /*lpParam*/) } if (-1 == bRet) { - SAL_WARN("sfx.appl", "GetMessageW failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("sfx.appl", "GetMessageW failed: " << comphelper::WindowsErrorString(GetLastError())); return 1; } TranslateMessage( &msg ); diff --git a/shell/source/win32/spsupp/spsuppHelper.cxx b/shell/source/win32/spsupp/spsuppHelper.cxx index 88d2ccf19485..49b5c40bb16b 100644 --- a/shell/source/win32/spsupp/spsuppHelper.cxx +++ b/shell/source/win32/spsupp/spsuppHelper.cxx @@ -133,7 +133,7 @@ DWORD LOStart(const wchar_t* sModeArg, const wchar_t* sFilePath) DWORD dwError = GetLastError(); const OUString sErrorMsg = "Could not start LibreOffice. Error is 0x" + OUString::number(dwError, 16) + ": " - + WindowsErrorString(dwError); + + comphelper::WindowsErrorString(dwError); // Report the error to user and return error MessageBoxW(nullptr, o3tl::toW(sErrorMsg.getStr()), nullptr, MB_ICONERROR); diff --git a/svl/source/crypto/cryptosign.cxx b/svl/source/crypto/cryptosign.cxx index df9ce919b1a8..11bda7de4e17 100644 --- a/svl/source/crypto/cryptosign.cxx +++ b/svl/source/crypto/cryptosign.cxx @@ -1355,7 +1355,7 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer) PCCERT_CONTEXT pCertContext = CertCreateCertificateContext(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, reinterpret_cast<const BYTE*>(aDerEncoded.getArray()), aDerEncoded.getLength()); if (pCertContext == nullptr) { - SAL_WARN("svl.crypto", "CertCreateCertificateContext failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("svl.crypto", "CertCreateCertificateContext failed: " << comphelper::WindowsErrorString(GetLastError())); return false; } @@ -1381,7 +1381,7 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer) &nKeySpec, &bFreeNeeded)) { - SAL_WARN("svl.crypto", "CryptAcquireCertificatePrivateKey failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("svl.crypto", "CryptAcquireCertificatePrivateKey failed: " << comphelper::WindowsErrorString(GetLastError())); CertFreeCertificateContext(pCertContext); return false; } @@ -1438,7 +1438,7 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer) nullptr); if (!hMsg) { - SAL_WARN("svl.crypto", "CryptMsgOpenToEncode failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("svl.crypto", "CryptMsgOpenToEncode failed: " << comphelper::WindowsErrorString(GetLastError())); CertFreeCertificateContext(pCertContext); return false; } @@ -1448,7 +1448,7 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer) const bool last = (i == m_dataBlocks.size() - 1); if (!CryptMsgUpdate(hMsg, static_cast<const BYTE *>(m_dataBlocks[i].first), m_dataBlocks[i].second, last)) { - SAL_WARN("svl.crypto", "CryptMsgUpdate failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("svl.crypto", "CryptMsgUpdate failed: " << comphelper::WindowsErrorString(GetLastError())); CryptMsgClose(hMsg); CertFreeCertificateContext(pCertContext); return false; @@ -1467,7 +1467,7 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer) nullptr); if (!hDecodedMsg) { - SAL_WARN("svl.crypto", "CryptMsgOpenToDecode failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("svl.crypto", "CryptMsgOpenToDecode failed: " << comphelper::WindowsErrorString(GetLastError())); CryptMsgClose(hMsg); CertFreeCertificateContext(pCertContext); return false; @@ -1477,7 +1477,7 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer) if (!CryptMsgGetParam(hMsg, CMSG_BARE_CONTENT_PARAM, 0, nullptr, &nTsSigLen)) { - SAL_WARN("svl.crypto", "CryptMsgGetParam(CMSG_BARE_CONTENT_PARAM) failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("svl.crypto", "CryptMsgGetParam(CMSG_BARE_CONTENT_PARAM) failed: " << comphelper::WindowsErrorString(GetLastError())); CryptMsgClose(hDecodedMsg); CryptMsgClose(hMsg); CertFreeCertificateContext(pCertContext); @@ -1490,7 +1490,7 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer) if (!CryptMsgGetParam(hMsg, CMSG_BARE_CONTENT_PARAM, 0, pTsSig.get(), &nTsSigLen)) { - SAL_WARN("svl.crypto", "CryptMsgGetParam(CMSG_BARE_CONTENT_PARAM) failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("svl.crypto", "CryptMsgGetParam(CMSG_BARE_CONTENT_PARAM) failed: " << comphelper::WindowsErrorString(GetLastError())); CryptMsgClose(hDecodedMsg); CryptMsgClose(hMsg); CertFreeCertificateContext(pCertContext); @@ -1499,7 +1499,7 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer) if (!CryptMsgUpdate(hDecodedMsg, pTsSig.get(), nTsSigLen, TRUE)) { - SAL_WARN("svl.crypto", "CryptMsgUpdate failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("svl.crypto", "CryptMsgUpdate failed: " << comphelper::WindowsErrorString(GetLastError())); CryptMsgClose(hDecodedMsg); CryptMsgClose(hMsg); CertFreeCertificateContext(pCertContext); @@ -1509,7 +1509,7 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer) DWORD nDecodedSignerInfoLen = 0; if (!CryptMsgGetParam(hDecodedMsg, CMSG_SIGNER_INFO_PARAM, 0, nullptr, &nDecodedSignerInfoLen)) { - SAL_WARN("svl.crypto", "CryptMsgGetParam(CMSG_SIGNER_INFO_PARAM) failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("svl.crypto", "CryptMsgGetParam(CMSG_SIGNER_INFO_PARAM) failed: " << comphelper::WindowsErrorString(GetLastError())); CryptMsgClose(hDecodedMsg); CryptMsgClose(hMsg); CertFreeCertificateContext(pCertContext); @@ -1520,7 +1520,7 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer) if (!CryptMsgGetParam(hDecodedMsg, CMSG_SIGNER_INFO_PARAM, 0, pDecodedSignerInfoBuf.get(), &nDecodedSignerInfoLen)) { - SAL_WARN("svl.crypto", "CryptMsgGetParam(CMSG_SIGNER_INFO_PARAM) failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("svl.crypto", "CryptMsgGetParam(CMSG_SIGNER_INFO_PARAM) failed: " << comphelper::WindowsErrorString(GetLastError())); CryptMsgClose(hDecodedMsg); CryptMsgClose(hMsg); CertFreeCertificateContext(pCertContext); @@ -1550,7 +1550,7 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer) nullptr, nullptr)) { - SAL_WARN("svl.crypto", "CryptRetrieveTimeStamp failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("svl.crypto", "CryptRetrieveTimeStamp failed: " << comphelper::WindowsErrorString(GetLastError())); CryptMsgClose(hDecodedMsg); CryptMsgClose(hMsg); CertFreeCertificateContext(pCertContext); @@ -1593,7 +1593,7 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer) if (!hMsg || !CryptMsgUpdate(hMsg, static_cast<const BYTE *>(m_dataBlocks[i].first), m_dataBlocks[i].second, last)) { - SAL_WARN("svl.crypto", "Re-creating the message failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("svl.crypto", "Re-creating the message failed: " << comphelper::WindowsErrorString(GetLastError())); CryptMemFree(pTsContext); CryptMsgClose(hDecodedMsg); CryptMsgClose(hMsg); @@ -1609,7 +1609,7 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer) if (!CryptMsgGetParam(hMsg, CMSG_CONTENT_PARAM, 0, nullptr, &nSigLen)) { - SAL_WARN("svl.crypto", "CryptMsgGetParam(CMSG_CONTENT_PARAM) failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("svl.crypto", "CryptMsgGetParam(CMSG_CONTENT_PARAM) failed: " << comphelper::WindowsErrorString(GetLastError())); if (pTsContext) CryptMemFree(pTsContext); CryptMsgClose(hMsg); @@ -1632,7 +1632,7 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer) if (!CryptMsgGetParam(hMsg, CMSG_CONTENT_PARAM, 0, pSig.get(), &nSigLen)) { - SAL_WARN("svl.crypto", "CryptMsgGetParam(CMSG_CONTENT_PARAM) failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("svl.crypto", "CryptMsgGetParam(CMSG_CONTENT_PARAM) failed: " << comphelper::WindowsErrorString(GetLastError())); if (pTsContext) CryptMemFree(pTsContext); CryptMsgClose(hMsg); @@ -2148,7 +2148,7 @@ bool Signing::Verify(const std::vector<unsigned char>& aData, // Update the message with the encoded header blob. if (!CryptMsgUpdate(hMsg, aSignature.data(), aSignature.size(), TRUE)) { - SAL_WARN("svl.crypto", "ValidateSignature, CryptMsgUpdate() for the header failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("svl.crypto", "ValidateSignature, CryptMsgUpdate() for the header failed: " << comphelper::WindowsErrorString(GetLastError())); return false; } @@ -2157,13 +2157,13 @@ bool Signing::Verify(const std::vector<unsigned char>& aData, // Update the message with the content blob. if (!CryptMsgUpdate(hMsg, aData.data(), aData.size(), FALSE)) { - SAL_WARN("svl.crypto", "ValidateSignature, CryptMsgUpdate() for the content failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("svl.crypto", "ValidateSignature, CryptMsgUpdate() for the content failed: " << comphelper::WindowsErrorString(GetLastError())); return false; } if (!CryptMsgUpdate(hMsg, nullptr, 0, TRUE)) { - SAL_WARN("svl.crypto", "ValidateSignature, CryptMsgUpdate() for the last content failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("svl.crypto", "ValidateSignature, CryptMsgUpdate() for the last content failed: " << comphelper::WindowsErrorString(GetLastError())); return false; } } @@ -2171,13 +2171,13 @@ bool Signing::Verify(const std::vector<unsigned char>& aData, DWORD nDigestID = 0; if (!CryptMsgGetParam(hMsg, CMSG_SIGNER_HASH_ALGORITHM_PARAM, 0, nullptr, &nDigestID)) { - SAL_WARN("svl.crypto", "ValidateSignature: CryptMsgGetParam() failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("svl.crypto", "ValidateSignature: CryptMsgGetParam() failed: " << comphelper::WindowsErrorString(GetLastError())); return false; } std::unique_ptr<BYTE[]> pDigestBytes(new BYTE[nDigestID]); if (!CryptMsgGetParam(hMsg, CMSG_SIGNER_HASH_ALGORITHM_PARAM, 0, pDigestBytes.get(), &nDigestID)) { - SAL_WARN("svl.crypto", "ValidateSignature: CryptMsgGetParam() failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("svl.crypto", "ValidateSignature: CryptMsgGetParam() failed: " << comphelper::WindowsErrorString(GetLastError())); return false; } auto pDigestID = reinterpret_cast<CRYPT_ALGORITHM_IDENTIFIER*>(pDigestBytes.get()); @@ -2316,7 +2316,7 @@ bool Signing::Verify(const std::vector<unsigned char>& aData, PCRYPT_TIMESTAMP_CONTEXT pTsContext; if (!CryptVerifyTimeStampSignature(rAttr.rgValue->pbData, rAttr.rgValue->cbData, nullptr, 0, nullptr, &pTsContext, nullptr, nullptr)) { - SAL_WARN("svl.crypto", "CryptMsgUpdate failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("svl.crypto", "CryptMsgUpdate failed: " << comphelper::WindowsErrorString(GetLastError())); break; } diff --git a/vcl/skia/win/gdiimpl.cxx b/vcl/skia/win/gdiimpl.cxx index 8ce4c33e57d0..e315eb0f7234 100644 --- a/vcl/skia/win/gdiimpl.cxx +++ b/vcl/skia/win/gdiimpl.cxx @@ -224,10 +224,10 @@ WinSkiaSalGraphicsImpl::createDirectWriteTypeface(const WinFontInstance* pWinFon } catch (const sal::systools::ComError& e) { - SAL_DETAIL_LOG_STREAM(SAL_DETAIL_ENABLE_LOG_INFO, ::SAL_DETAIL_LOG_LEVEL_INFO, "vcl.skia", - e.what(), - "HRESULT 0x" << OUString::number(e.GetHresult(), 16) << ": " - << WindowsErrorStringFromHRESULT(e.GetHresult())); + SAL_DETAIL_LOG_STREAM( + SAL_DETAIL_ENABLE_LOG_INFO, ::SAL_DETAIL_LOG_LEVEL_INFO, "vcl.skia", e.what(), + "HRESULT 0x" << OUString::number(e.GetHresult(), 16) << ": " + << comphelper::WindowsErrorStringFromHRESULT(e.GetHresult())); return nullptr; } diff --git a/vcl/source/opengl/win/context.cxx b/vcl/source/opengl/win/context.cxx index d9e7dc11b17f..98ced2d1cf26 100644 --- a/vcl/source/opengl/win/context.cxx +++ b/vcl/source/opengl/win/context.cxx @@ -127,7 +127,7 @@ void WinOpenGLContext::makeCurrent() g_bAnyCurrent = false; DWORD nLastError = GetLastError(); if (nLastError != ERROR_SUCCESS) - SAL_WARN("vcl.opengl", "wglMakeCurrent failed: " << WindowsErrorString(nLastError)); + SAL_WARN("vcl.opengl", "wglMakeCurrent failed: " << comphelper::WindowsErrorString(nLastError)); return; } @@ -530,21 +530,21 @@ bool WinOpenGLContext::ImplInit() if (!SetPixelFormat(m_aGLWin.hDC, WindowPix, &PixelFormatFront)) { - SAL_WARN("vcl.opengl", "SetPixelFormat failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("vcl.opengl", "SetPixelFormat failed: " << comphelper::WindowsErrorString(GetLastError())); return false; } HGLRC hTempRC = wglCreateContext(m_aGLWin.hDC); if (hTempRC == nullptr) { - SAL_WARN("vcl.opengl", "wglCreateContext failed: "<< WindowsErrorString(GetLastError())); + SAL_WARN("vcl.opengl", "wglCreateContext failed: "<< comphelper::WindowsErrorString(GetLastError())); return false; } if (!wglMakeCurrent(m_aGLWin.hDC, hTempRC)) { g_bAnyCurrent = false; - SAL_WARN("vcl.opengl", "wglMakeCurrent failed: "<< WindowsErrorString(GetLastError())); + SAL_WARN("vcl.opengl", "wglMakeCurrent failed: "<< comphelper::WindowsErrorString(GetLastError())); return false; } @@ -582,7 +582,7 @@ bool WinOpenGLContext::ImplInit() m_aGLWin.hRC = wglCreateContextAttribsARB(m_aGLWin.hDC, hSharedCtx, attribs); if (m_aGLWin.hRC == nullptr) { - SAL_WARN("vcl.opengl", "wglCreateContextAttribsARB failed: "<< WindowsErrorString(GetLastError())); + SAL_WARN("vcl.opengl", "wglCreateContextAttribsARB failed: "<< comphelper::WindowsErrorString(GetLastError())); wglMakeCurrent(nullptr, nullptr); g_bAnyCurrent = false; wglDeleteContext(hTempRC); @@ -604,7 +604,7 @@ bool WinOpenGLContext::ImplInit() if (!wglMakeCurrent(m_aGLWin.hDC, m_aGLWin.hRC)) { g_bAnyCurrent = false; - SAL_WARN("vcl.opengl", "wglMakeCurrent failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("vcl.opengl", "wglMakeCurrent failed: " << comphelper::WindowsErrorString(GetLastError())); return false; } diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx index ccbbefa89ad6..c5d6477b23e6 100644 --- a/vcl/win/app/salinst.cxx +++ b/vcl/win/app/salinst.cxx @@ -499,7 +499,7 @@ bool ImplSalYield(const bool bWait, const bool bHandleAllCurrentEvents) switch (GetMessageW(&aMsg, nullptr, 0, 0)) { case -1: - SAL_WARN("vcl.schedule", "GetMessageW failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("vcl.schedule", "GetMessageW failed: " << comphelper::WindowsErrorString(GetLastError())); // should we std::abort() / SalAbort here? break; case 0: diff --git a/vcl/win/dtrans/MtaOleClipb.cxx b/vcl/win/dtrans/MtaOleClipb.cxx index 3ea0a98f540a..1c4564fbb78f 100644 --- a/vcl/win/dtrans/MtaOleClipb.cxx +++ b/vcl/win/dtrans/MtaOleClipb.cxx @@ -593,7 +593,7 @@ unsigned int CMtaOleClipboard::run( ) } if (-1 == bRet) { - SAL_WARN("vcl.win.dtrans", "GetMessageW failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("vcl.win.dtrans", "GetMessageW failed: " << comphelper::WindowsErrorString(GetLastError())); nRet = ~0U; break; } diff --git a/vcl/win/dtrans/target.cxx b/vcl/win/dtrans/target.cxx index abe53379eab4..399ffd9d063d 100644 --- a/vcl/win/dtrans/target.cxx +++ b/vcl/win/dtrans/target.cxx @@ -217,7 +217,7 @@ unsigned __stdcall DndTargetOleSTAFunc(void* pParams) } if (-1 == bRet) { - SAL_WARN("vcl.win.dtrans", "GetMessageW failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("vcl.win.dtrans", "GetMessageW failed: " << comphelper::WindowsErrorString(GetLastError())); break; } if( msg.message == WM_REGISTERDRAGDROP) diff --git a/vcl/win/gdi/DWriteTextRenderer.cxx b/vcl/win/gdi/DWriteTextRenderer.cxx index 15441a8389e1..b4f9d50c4088 100644 --- a/vcl/win/gdi/DWriteTextRenderer.cxx +++ b/vcl/win/gdi/DWriteTextRenderer.cxx @@ -71,7 +71,7 @@ HRESULT checkResult(HRESULT hr, const char* location) { SAL_DETAIL_LOG_STREAM(SAL_DETAIL_ENABLE_LOG_WARN && FAILED(hr), ::SAL_DETAIL_LOG_LEVEL_WARN, "vcl.gdi", location, - "HRESULT failed with: 0x" << OUString::number(hr, 16) << ": " << WindowsErrorStringFromHRESULT(hr)); + "HRESULT failed with: 0x" << OUString::number(hr, 16) << ": " << comphelper::WindowsErrorStringFromHRESULT(hr)); return hr; } diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index 518b7136aa1d..d3c181af17fa 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -1327,7 +1327,7 @@ IDWriteFontFace* WinFontInstance::GetDWFontFace() const if (FAILED(hr)) { SAL_WARN("vcl.fonts", "HRESULT 0x" << OUString::number(hr, 16) << ": " - << WindowsErrorStringFromHRESULT(hr)); + << comphelper::WindowsErrorStringFromHRESULT(hr)); mxDWFontFace = nullptr; } } diff --git a/vcl/win/gdi/salgdi.cxx b/vcl/win/gdi/salgdi.cxx index 634bbb078e38..31993e7e5957 100644 --- a/vcl/win/gdi/salgdi.cxx +++ b/vcl/win/gdi/salgdi.cxx @@ -416,7 +416,7 @@ IDWriteFactory* WinSalGraphics::getDWriteFactory() if (FAILED(hr)) { SAL_WARN("vcl.fonts", "HRESULT 0x" << OUString::number(hr, 16) << ": " - << WindowsErrorStringFromHRESULT(hr)); + << comphelper::WindowsErrorStringFromHRESULT(hr)); abort(); } return pResult; @@ -435,7 +435,7 @@ IDWriteGdiInterop* WinSalGraphics::getDWriteGdiInterop() if (FAILED(hr)) { SAL_WARN("vcl.fonts", "HRESULT 0x" << OUString::number(hr, 16) << ": " - << WindowsErrorStringFromHRESULT(hr)); + << comphelper::WindowsErrorStringFromHRESULT(hr)); abort(); } return pResult; diff --git a/vcl/win/gdi/salvd.cxx b/vcl/win/gdi/salvd.cxx index d4c9421f44f3..c31228d23118 100644 --- a/vcl/win/gdi/salvd.cxx +++ b/vcl/win/gdi/salvd.cxx @@ -38,7 +38,7 @@ HBITMAP WinSalVirtualDevice::ImplCreateVirDevBitmap(HDC hDC, tools::Long nDX, to if ( nBitCount == 1 ) { hBitmap = CreateBitmap( static_cast<int>(nDX), static_cast<int>(nDY), 1, 1, nullptr ); - SAL_WARN_IF( !hBitmap, "vcl", "CreateBitmap failed: " << WindowsErrorString( GetLastError() ) ); + SAL_WARN_IF( !hBitmap, "vcl", "CreateBitmap failed: " << comphelper::WindowsErrorString( GetLastError() ) ); ppData = nullptr; } else @@ -65,7 +65,7 @@ HBITMAP WinSalVirtualDevice::ImplCreateVirDevBitmap(HDC hDC, tools::Long nDX, to hBitmap = CreateDIBSection( hDC, &aBitmapInfo, DIB_RGB_COLORS, ppData, nullptr, 0 ); - SAL_WARN_IF( !hBitmap, "vcl", "CreateDIBSection failed: " << WindowsErrorString( GetLastError() ) ); + SAL_WARN_IF( !hBitmap, "vcl", "CreateDIBSection failed: " << comphelper::WindowsErrorString( GetLastError() ) ); } return hBitmap; @@ -78,7 +78,7 @@ std::unique_ptr<SalVirtualDevice> WinSalInstance::CreateVirtualDevice( SalGraphi WinSalGraphics& rGraphics = static_cast<WinSalGraphics&>(rSGraphics); HDC hDC = CreateCompatibleDC( rGraphics.getHDC() ); - SAL_WARN_IF( !hDC, "vcl", "CreateCompatibleDC failed: " << WindowsErrorString( GetLastError() ) ); + SAL_WARN_IF( !hDC, "vcl", "CreateCompatibleDC failed: " << comphelper::WindowsErrorString( GetLastError() ) ); if (!hDC) return nullptr; diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx index d5bbc048da43..23d97a4acf87 100644 --- a/vcl/win/gdi/winlayout.cxx +++ b/vcl/win/gdi/winlayout.cxx @@ -27,7 +27,6 @@ #include <osl/file.h> #include <sal/log.hxx> -#include <comphelper/windowserrorstring.hxx> #include <comphelper/scopeguard.hxx> #include <win/salgdi.h> diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx index 7c130ea6d3da..5528807bee6a 100644 --- a/vcl/win/window/salframe.cxx +++ b/vcl/win/window/salframe.cxx @@ -465,7 +465,7 @@ SalFrame* ImplSalCreateFrame( WinSalInstance* pInst, hWnd = CreateWindowExW( nExSysStyle, pClassName, L"", nSysStyle, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, hWndParent, nullptr, pInst->mhInst, pFrame ); - SAL_WARN_IF(!hWnd, "vcl", "CreateWindowExW failed: " << WindowsErrorString(GetLastError())); + SAL_WARN_IF(!hWnd, "vcl", "CreateWindowExW failed: " << comphelper::WindowsErrorString(GetLastError())); #if OSL_DEBUG_LEVEL > 1 // set transparency value @@ -4546,7 +4546,7 @@ static WinSalMenuItem* ImplGetSalMenuItem( HMENU hMenu, UINT nPos, bool bByPosit mi.cbSize = sizeof( mi ); mi.fMask = MIIM_DATA; if( !GetMenuItemInfoW( hMenu, nPos, bByPosition, &mi) ) - SAL_WARN("vcl", "GetMenuItemInfoW failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("vcl", "GetMenuItemInfoW failed: " << comphelper::WindowsErrorString(GetLastError())); return reinterpret_cast<WinSalMenuItem *>(mi.dwItemData); } @@ -4563,7 +4563,7 @@ static int ImplGetSelectedIndex( HMENU hMenu ) for(int i=0; i<n; i++ ) { if( !GetMenuItemInfoW( hMenu, i, TRUE, &mi) ) - SAL_WARN( "vcl", "GetMenuItemInfoW failed: " << WindowsErrorString( GetLastError() ) ); + SAL_WARN( "vcl", "GetMenuItemInfoW failed: " << comphelper::WindowsErrorString( GetLastError() ) ); else { if( mi.fState & MFS_HILITE ) @@ -4703,7 +4703,7 @@ static LRESULT ImplDrawItem(HWND, WPARAM wParam, LPARAM lParam ) // Fill background if(!PatBlt( pDI->hDC, aRect.left, aRect.top, aRect.right-aRect.left, aRect.bottom-aRect.top, PATCOPY )) - SAL_WARN("vcl", "PatBlt failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("vcl", "PatBlt failed: " << comphelper::WindowsErrorString(GetLastError())); int lineHeight = aRect.bottom-aRect.top; @@ -4787,7 +4787,7 @@ static LRESULT ImplDrawItem(HWND, WPARAM wParam, LPARAM lParam ) reinterpret_cast<LPARAM>(aStr.getStr()), WPARAM(0), aRect.left, aRect.top + (lineHeight - strSize.cy)/2, 0, 0, DST_PREFIXTEXT | (fDisabled && !fSelected ? DSS_DISABLED : DSS_NORMAL) ) ) - SAL_WARN("vcl", "DrawStateW failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("vcl", "DrawStateW failed: " << comphelper::WindowsErrorString(GetLastError())); if( pSalMenuItem->mAccelText.getLength() ) { @@ -4804,7 +4804,7 @@ static LRESULT ImplDrawItem(HWND, WPARAM wParam, LPARAM lParam ) reinterpret_cast<LPARAM>(aStr.getStr()), WPARAM(0), aRect.right-strSizeA.cx-tm.tmMaxCharWidth, aRect.top + (lineHeight - strSizeA.cy)/2, 0, 0, DST_TEXT | (fDisabled && !fSelected ? DSS_DISABLED : DSS_NORMAL) ) ) - SAL_WARN("vcl", "DrawStateW failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("vcl", "DrawStateW failed: " << comphelper::WindowsErrorString(GetLastError())); } // Restore the original font and colors. @@ -5778,7 +5778,7 @@ static LRESULT CALLBACK SalFrameWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LP UINT uiGcs = 3; if (!SetGestureConfig(hWnd, 0, uiGcs, gc, sizeof(GESTURECONFIG))) { - SAL_WARN("vcl", "SetGestureConfig failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("vcl", "SetGestureConfig failed: " << comphelper::WindowsErrorString(GetLastError())); } } return 0; diff --git a/vcl/win/window/salobj.cxx b/vcl/win/window/salobj.cxx index 70b49a8f5b4b..5778c264a793 100644 --- a/vcl/win/window/salobj.cxx +++ b/vcl/win/window/salobj.cxx @@ -477,7 +477,7 @@ SalObject* ImplSalCreateObject( WinSalInstance* pInst, WinSalFrame* pParent ) if ( !hWndChild ) { - SAL_WARN("vcl", "CreateWindowExW failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("vcl", "CreateWindowExW failed: " << comphelper::WindowsErrorString(GetLastError())); delete pObject; return nullptr; diff --git a/xmlsecurity/source/xmlsec/errorcallback.cxx b/xmlsecurity/source/xmlsec/errorcallback.cxx index a2c429462e81..7f45413657e4 100644 --- a/xmlsecurity/source/xmlsec/errorcallback.cxx +++ b/xmlsecurity/source/xmlsec/errorcallback.cxx @@ -48,7 +48,7 @@ static void errorCallback(const char* file, OUString systemErrorString; #ifdef _WIN32 - systemErrorString = " " + WindowsErrorString(GetLastError()); + systemErrorString = " " + comphelper::WindowsErrorString(GetLastError()); #endif SAL_WARN("xmlsecurity.xmlsec", file << ":" << line << ": " << func << "() '" << pErrorObject << "' '" << pErrorSubject << "' " << reason << " '" << pMsg << "'" << systemErrorString); diff --git a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx index a6258f92ad76..8f5b46ad09ce 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx @@ -283,7 +283,7 @@ static BOOL WINAPI cert_enum_system_store_callback(const void *pvSystemStore, if (!(ERROR_FILE_NOT_FOUND == dwErr || ERROR_NOT_SUPPORTED == dwErr)) { - SAL_WARN("xmlsecurity.xmlsec", "CertEnumPhysicalStore failed:" << WindowsErrorString(GetLastError())); + SAL_WARN("xmlsecurity.xmlsec", "CertEnumPhysicalStore failed:" << comphelper::WindowsErrorString(GetLastError())); } } return TRUE; diff --git a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx index bd4ef701e6ed..05881195312e 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx @@ -612,7 +612,7 @@ sal_Int32 SAL_CALL X509Certificate_MSCryptImpl::getCertificateUsage( ) &length); if (!rc) - SAL_WARN("xmlsecurity.xmlsec", "CryptDecodeObject failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("xmlsecurity.xmlsec", "CryptDecodeObject failed: " << comphelper::WindowsErrorString(GetLastError())); else { std::vector<char>buffer(length); @@ -628,7 +628,7 @@ sal_Int32 SAL_CALL X509Certificate_MSCryptImpl::getCertificateUsage( ) CRYPT_BIT_BLOB *blob = reinterpret_cast<CRYPT_BIT_BLOB*>(buffer.data()); if (!rc) - SAL_WARN("xmlsecurity.xmlsec", "CryptDecodeObject failed: " << WindowsErrorString(GetLastError())); + SAL_WARN("xmlsecurity.xmlsec", "CryptDecodeObject failed: " << comphelper::WindowsErrorString(GetLastError())); else if (blob->cbData == 1) usage = blob->pbData[0]; else @@ -727,7 +727,7 @@ static bool EncodeDistinguishedName(std::u16string_view const rName, CERT_NAME_B reinterpret_cast<LPCWSTR>(rName.data()), CERT_X500_NAME_STR, nullptr, nullptr, &rBlob.cbData, &pszError)) { - SAL_INFO("xmlsecurity.xmlsec", "CertStrToNameW failed: " << WindowsErrorString(GetLastError()) << "; " << OUString(o3tl::toU(pszError))); + SAL_INFO("xmlsecurity.xmlsec", "CertStrToNameW failed: " << comphelper::WindowsErrorString(GetLastError()) << "; " << OUString(o3tl::toU(pszError))); return false; } rBlob.pbData = new BYTE[rBlob.cbData]; @@ -735,7 +735,7 @@ static bool EncodeDistinguishedName(std::u16string_view const rName, CERT_NAME_B reinterpret_cast<LPCWSTR>(rName.data()), CERT_X500_NAME_STR, nullptr, rBlob.pbData, &rBlob.cbData, &pszError)) { - SAL_INFO("xmlsecurity.xmlsec", "CertStrToNameW failed: " << WindowsErrorString(GetLastError()) << "; " << OUString(o3tl::toU(pszError))); + SAL_INFO("xmlsecurity.xmlsec", "CertStrToNameW failed: " << comphelper::WindowsErrorString(GetLastError()) << "; " << OUString(o3tl::toU(pszError))); return false; } return true;