summaryrefslogtreecommitdiff
path: root/embedserv
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2017-10-05 06:19:56 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2017-10-05 16:02:52 +0200
commit1944e3ddc0b2247de3138d2a441cd6999e21fd9a (patch)
treeb59f213e245e151ee792ca424fd06b5a11c88857 /embedserv
parent81d404803f477eb71b74eb9c7a67bba6b1af95d1 (diff)
Rename and move SAL_U/W to o3tl::toU/W
Previosly (since commit 9ac98e6e3488e434bf4864ecfb13a121784f640b) it was expected to gradually remove SAL_U/W usage in Windows code by replacing with reinterpret_cast or changing to some bettertypes. But as it's useful to make use of fact that LibreOffice and Windows use compatible representation of strings, this commit puts these functions to a better-suited o3tl, and recommends that the functions be consistently used throughout Windows-specific code to reflect the compatibility and keep the casts safe. Change-Id: I2f7c65606d0e2d0c01a00f08812bb4ab7659c5f6 Reviewed-on: https://gerrit.libreoffice.org/43150 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'embedserv')
-rw-r--r--embedserv/source/embed/ed_ioleobject.cxx7
-rw-r--r--embedserv/source/embed/ed_ipersiststr.cxx39
2 files changed, 24 insertions, 22 deletions
diff --git a/embedserv/source/embed/ed_ioleobject.cxx b/embedserv/source/embed/ed_ioleobject.cxx
index 8e068ba3555d..140efc12fd3f 100644
--- a/embedserv/source/embed/ed_ioleobject.cxx
+++ b/embedserv/source/embed/ed_ioleobject.cxx
@@ -19,6 +19,7 @@
#include "embeddoc.hxx"
#include <osl/diagnose.h>
+#include <o3tl/char16_t2wchar_t.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
@@ -44,8 +45,8 @@ STDMETHODIMP EmbedDocument_Impl::SetHostNames( LPCOLESTR szContainerApp, LPCOLES
// the code should be ignored for links
if ( !m_aFileName.getLength() )
{
- m_pDocHolder->setTitle(SAL_U(szContainerObj));
- m_pDocHolder->setContainerName(SAL_U(szContainerApp));
+ m_pDocHolder->setTitle(o3tl::toU(szContainerObj));
+ m_pDocHolder->setContainerName(o3tl::toU(szContainerApp));
}
return S_OK;
@@ -417,7 +418,7 @@ HRESULT EmbedDocument_Impl::SaveObject()
// in case of links the containers does not provide client site sometimes
hr = Save( static_cast<LPCOLESTR>(nullptr), FALSE ); // triggers saving to the link location
- SaveCompleted(SAL_W(aPreservFileName.getStr()));
+ SaveCompleted(o3tl::toW(aPreservFileName.getStr()));
}
notify( false );
diff --git a/embedserv/source/embed/ed_ipersiststr.cxx b/embedserv/source/embed/ed_ipersiststr.cxx
index bba4d2d59bc6..db14f3fb4893 100644
--- a/embedserv/source/embed/ed_ipersiststr.cxx
+++ b/embedserv/source/embed/ed_ipersiststr.cxx
@@ -36,6 +36,7 @@
#include <com/sun/star/util/XURLTransformer.hpp>
#include <comphelper/processfactory.hxx>
+#include <o3tl/char16_t2wchar_t.hxx>
#include <o3tl/string_view.hxx>
#include <osl/mutex.hxx>
#include <osl/diagnose.h>
@@ -220,7 +221,7 @@ uno::Sequence< beans::PropertyValue > EmbedDocument_Impl::fillArgsForLoading_Imp
uno::Reference< util::XURLTransformer > aTransformer( util::URLTransformer::create(comphelper::getComponentContext(m_xFactory)) );
util::URL aURL;
- aURL.Complete = SAL_U(pFilePath);
+ aURL.Complete = o3tl::toU(pFilePath);
if ( aTransformer->parseSmart( aURL, OUString() ) )
sDocUrl = aURL.Complete;
@@ -429,7 +430,7 @@ STDMETHODIMP EmbedDocument_Impl::InitNew( IStorage *pStg )
if ( hr == S_OK )
{
- hr = pStg->CreateStream( SAL_W(aOfficeEmbedStreamName.getStr()),
+ hr = pStg->CreateStream( o3tl::toW(aOfficeEmbedStreamName.getStr()),
STGM_CREATE | ( nStreamMode & 0x73 ),
0,
0,
@@ -437,7 +438,7 @@ STDMETHODIMP EmbedDocument_Impl::InitNew( IStorage *pStg )
if ( hr == S_OK && m_pOwnStream )
{
- hr = pStg->CreateStream( SAL_W(aExtentStreamName.getStr()),
+ hr = pStg->CreateStream( o3tl::toW(aExtentStreamName.getStr()),
STGM_CREATE | ( nStreamMode & 0x73 ),
0,
0,
@@ -483,7 +484,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( IStorage *pStg )
if ( FAILED( hr ) ) return E_FAIL;
DWORD nStreamMode = aStat.grfMode;
- hr = pStg->OpenStream( SAL_W(aOfficeEmbedStreamName.getStr()),
+ hr = pStg->OpenStream( o3tl::toW(aOfficeEmbedStreamName.getStr()),
nullptr,
nStreamMode & 0x73,
0,
@@ -492,7 +493,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( IStorage *pStg )
if ( SUCCEEDED( hr ) )
{
- hr = pStg->OpenStream( SAL_W(aExtentStreamName.getStr()),
+ hr = pStg->OpenStream( o3tl::toW(aExtentStreamName.getStr()),
nullptr,
nStreamMode & 0x73,
0,
@@ -565,8 +566,8 @@ STDMETHODIMP EmbedDocument_Impl::Load( IStorage *pStg )
{
m_pOwnStream = CComPtr< IStream >();
m_pExtStream = CComPtr< IStream >();
- hr = pStg->DestroyElement( SAL_W(aOfficeEmbedStreamName.getStr()) );
- hr = pStg->DestroyElement( SAL_W(aExtentStreamName.getStr()) );
+ hr = pStg->DestroyElement( o3tl::toW(aOfficeEmbedStreamName.getStr()) );
+ hr = pStg->DestroyElement( o3tl::toW(aExtentStreamName.getStr()) );
OSL_ENSURE( SUCCEEDED( hr ), "Can not destroy created stream!" );
if ( FAILED( hr ) )
@@ -595,14 +596,14 @@ STDMETHODIMP EmbedDocument_Impl::Save( IStorage *pStgSave, BOOL fSameAsLoad )
if ( FAILED( hr ) ) return E_FAIL;
DWORD nStreamMode = aStat.grfMode;
- hr = pStgSave->CreateStream( SAL_W(aOfficeEmbedStreamName.getStr()),
+ hr = pStgSave->CreateStream( o3tl::toW(aOfficeEmbedStreamName.getStr()),
STGM_CREATE | ( nStreamMode & 0x73 ),
0,
0,
&pTargetStream );
if ( FAILED( hr ) || !pTargetStream ) return E_FAIL;
- hr = pStgSave->CreateStream( SAL_W(aExtentStreamName.getStr()),
+ hr = pStgSave->CreateStream( o3tl::toW(aExtentStreamName.getStr()),
STGM_CREATE | ( nStreamMode & 0x73 ),
0,
0,
@@ -690,14 +691,14 @@ STDMETHODIMP EmbedDocument_Impl::SaveCompleted( IStorage *pStgNew )
if ( FAILED( hr ) ) return E_OUTOFMEMORY;
DWORD nStreamMode = aStat.grfMode;
- hr = m_pMasterStorage->OpenStream( SAL_W(aOfficeEmbedStreamName.getStr()),
+ hr = m_pMasterStorage->OpenStream( o3tl::toW(aOfficeEmbedStreamName.getStr()),
nullptr,
nStreamMode & 0x73,
0,
&m_pOwnStream );
if ( FAILED( hr ) || !m_pOwnStream ) return E_OUTOFMEMORY;
- hr = m_pMasterStorage->OpenStream( SAL_W(aExtentStreamName.getStr()),
+ hr = m_pMasterStorage->OpenStream( o3tl::toW(aExtentStreamName.getStr()),
nullptr,
nStreamMode & 0x73,
0,
@@ -753,20 +754,20 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ )
CLIPFORMAT cf = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" );
hr = WriteFmtUserTypeStg( m_pMasterStorage,
cf, // ???
- const_cast<LPOLESTR>( SAL_W(aCurType.data())) );
+ const_cast<LPOLESTR>( o3tl::toW(aCurType.data())) );
if ( FAILED( hr ) ) return E_FAIL;
hr = m_pMasterStorage->SetClass( m_guid );
if ( FAILED( hr ) ) return E_FAIL;
- hr = m_pMasterStorage->CreateStream( SAL_W(aOfficeEmbedStreamName.getStr()),
+ hr = m_pMasterStorage->CreateStream( o3tl::toW(aOfficeEmbedStreamName.getStr()),
STGM_CREATE | ( nStreamMode & 0x73 ),
0,
0,
&m_pOwnStream );
if ( FAILED( hr ) || !m_pOwnStream ) return E_FAIL;
- hr = m_pMasterStorage->CreateStream( SAL_W(aExtentStreamName.getStr()),
+ hr = m_pMasterStorage->CreateStream( o3tl::toW(aExtentStreamName.getStr()),
STGM_CREATE | ( nStreamMode & 0x73 ),
0,
0,
@@ -791,7 +792,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ )
pszFileName ) );
hr = S_OK;
- m_aFileName = SAL_U(pszFileName);
+ m_aFileName = o3tl::toU(pszFileName);
}
catch( const uno::Exception& )
{
@@ -804,7 +805,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ )
cf = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" );
hr = WriteFmtUserTypeStg( m_pMasterStorage,
cf, // ???
- const_cast<LPOLESTR>( SAL_W(aCurType.data())) );
+ const_cast<LPOLESTR>( o3tl::toW(aCurType.data())) );
if ( SUCCEEDED( hr ) )
{
@@ -863,7 +864,7 @@ STDMETHODIMP EmbedDocument_Impl::Save( LPCOLESTR pszFileName, BOOL fRemember )
else
{
util::URL aURL;
- aURL.Complete = SAL_U( pszFileName );
+ aURL.Complete = o3tl::toU( pszFileName );
uno::Reference< util::XURLTransformer > aTransformer( util::URLTransformer::create(comphelper::getComponentContext(m_xFactory)) );
@@ -891,7 +892,7 @@ STDMETHODIMP EmbedDocument_Impl::Save( LPCOLESTR pszFileName, BOOL fRemember )
STDMETHODIMP EmbedDocument_Impl::SaveCompleted( LPCOLESTR pszFileName )
{
// the different file name would mean error here
- m_aFileName = SAL_U(pszFileName);
+ m_aFileName = o3tl::toU(pszFileName);
return S_OK;
}
@@ -903,7 +904,7 @@ STDMETHODIMP EmbedDocument_Impl::GetCurFile( LPOLESTR *ppszFileName )
if ( FAILED( hr ) || !pMalloc ) return E_FAIL;
*ppszFileName = static_cast<LPOLESTR>( pMalloc->Alloc( sizeof( sal_Unicode ) * ( m_aFileName.getLength() + 1 ) ) );
- wcsncpy( *ppszFileName, SAL_W(m_aFileName.getStr()), m_aFileName.getLength() + 1 );
+ wcsncpy( *ppszFileName, o3tl::toW(m_aFileName.getStr()), m_aFileName.getLength() + 1 );
return m_aFileName.getLength() ? S_OK : S_FALSE;
}