summaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2024-08-21 13:42:28 +0500
committerMike Kaganski <mike.kaganski@collabora.com>2024-08-21 12:15:36 +0200
commit02c0e5f970dee4d064fcb26b378cbfe6f3a1bc05 (patch)
treef5f01173f9b2e3fdc96d77bfaf0ce4a75a275475 /extensions
parent02e2870c86a00380549266f944c9218187a002ec (diff)
Simplify BSTR construction from OUString a bit
Use the known string length into account (and I definitely like to not rely on the undocumented implementation detail that OUString is null-terminated). Change-Id: I0e7478d25e802f8f8e31f02cf8d77613c1325bc9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172170 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'extensions')
-rw-r--r--extensions/source/ole/unoconversionutilities.hxx3
-rw-r--r--extensions/source/ole/unoobjw.cxx9
2 files changed, 7 insertions, 5 deletions
diff --git a/extensions/source/ole/unoconversionutilities.hxx b/extensions/source/ole/unoconversionutilities.hxx
index a73a714abe55..e2d68dbe5359 100644
--- a/extensions/source/ole/unoconversionutilities.hxx
+++ b/extensions/source/ole/unoconversionutilities.hxx
@@ -36,6 +36,7 @@
#include <o3tl/char16_t2wchar_t.hxx>
#include "ole2uno.hxx"
#include <cppuhelper/weakref.hxx>
+#include <systools/win32/oleauto.hxx>
#include "unotypewrapper.hxx"
#include <unordered_map>
@@ -849,7 +850,7 @@ void UnoConversionUtilities<T>::anyToVariant(VARIANT* pVariant, const Any& rAny)
if (rAny >>= value)
{
pVariant->vt = VT_BSTR;
- pVariant->bstrVal = SysAllocString(o3tl::toW(value.getStr()));
+ pVariant->bstrVal = sal::systools::BStr::newBSTR(value);
}
else
{
diff --git a/extensions/source/ole/unoobjw.cxx b/extensions/source/ole/unoobjw.cxx
index 5a3151d07b44..cd84c0c6b91b 100644
--- a/extensions/source/ole/unoobjw.cxx
+++ b/extensions/source/ole/unoobjw.cxx
@@ -87,6 +87,7 @@
#include <comphelper/windowserrorstring.hxx>
#include <o3tl/char16_t2wchar_t.hxx>
#include <o3tl/safeint.hxx>
+#include <systools/win32/oleauto.hxx>
#include "comifaces.hxx"
#include "jscriptclasses.hxx"
@@ -119,7 +120,7 @@ static void writeExcepinfo(EXCEPINFO * pInfo, const OUString& message)
{
pInfo->wCode = UNO_2_OLE_EXCEPTIONCODE;
pInfo->bstrSource = SysAllocString(L"[automation bridge] ");
- pInfo->bstrDescription = SysAllocString(o3tl::toW(message.getStr()));
+ pInfo->bstrDescription = sal::systools::BStr::newBSTR(message);
}
}
@@ -811,7 +812,7 @@ HRESULT STDMETHODCALLTYPE CXTypeInfo::GetNames(MEMBERID memid,
return E_INVALIDARG;
SAL_INFO("extensions.olebridge", "..." << this << "@CXTypeInfo::GetNames(" << memid << "): " << aMethods[memid + 2]->getName());
- rgBstrNames[0] = SysAllocString(reinterpret_cast<LPOLESTR>(aMethods[memid + 2]->getName().pData->buffer));
+ rgBstrNames[0] = sal::systools::BStr::newBSTR(aMethods[memid + 2]->getName());
*pcNames = 1;
return S_OK;
@@ -887,7 +888,7 @@ HRESULT STDMETHODCALLTYPE CXTypeInfo::GetDocumentation(MEMBERID memid,
{
if (memid == MEMBERID_NIL)
{
- *pBstrName = SysAllocString(o3tl::toW(msImplementationName.getStr()));
+ *pBstrName = sal::systools::BStr::newBSTR(msImplementationName);
}
else if (memid == DISPID_VALUE)
{
@@ -897,7 +898,7 @@ HRESULT STDMETHODCALLTYPE CXTypeInfo::GetDocumentation(MEMBERID memid,
else
{
// FIXME: Shouldn't we be able to know the names of the members of UNO interfaces?
- *pBstrName = SysAllocString(o3tl::toW(OUString("UnknownNameOfMember#" + OUString::number(memid)).getStr()));
+ *pBstrName = sal::systools::BStr::newBSTR(Concat2View("UnknownNameOfMember#" + OUString::number(memid)));
}
}
if (pBstrDocString)