clang-cl loplugin: embeddedobj

Change-Id: Id8359ff2bc2ae177837f5c58f949d40b818a8684
Reviewed-on: https://gerrit.libreoffice.org/29869
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
Stephan Bergmann
2016-10-14 16:56:42 +02:00
parent 3b658759c9
commit 5eab3e5eec
18 changed files with 354 additions and 342 deletions

View File

@@ -55,7 +55,7 @@ class VerbExecutionController
bool m_bWasEverActive; bool m_bWasEverActive;
bool m_bVerbExecutionInProgress; bool m_bVerbExecutionInProgress;
oslThreadIdentifier m_nVerbExecutionThreadIdentifier; oslThreadIdentifier m_nVerbExecutionThreadIdentifier;
sal_Bool m_bChangedOnVerbExecution; bool m_bChangedOnVerbExecution;
#endif #endif
public: public:
@@ -66,13 +66,13 @@ public:
, m_bWasEverActive( false ) , m_bWasEverActive( false )
, m_bVerbExecutionInProgress( false ) , m_bVerbExecutionInProgress( false )
, m_nVerbExecutionThreadIdentifier( 0 ) , m_nVerbExecutionThreadIdentifier( 0 )
, m_bChangedOnVerbExecution( sal_False ) , m_bChangedOnVerbExecution( false )
#endif #endif
{} {}
#ifdef _WIN32 #ifdef _WIN32
void StartControlExecution(); void StartControlExecution();
sal_Bool EndControlExecution_WasModified(); bool EndControlExecution_WasModified();
void ModificationNotificationIsDone(); void ModificationNotificationIsDone();
// no need to lock anything to check the value of the numeric members // no need to lock anything to check the value of the numeric members
bool CanDoNotification() { return ( !m_bVerbExecutionInProgress && !m_bWasEverActive && !m_nNotificationLock ); } bool CanDoNotification() { return ( !m_bVerbExecutionInProgress && !m_bWasEverActive && !m_nNotificationLock ); }
@@ -211,13 +211,13 @@ protected:
#endif #endif
void MakeEventListenerNotification_Impl( const OUString& aEventName ); void MakeEventListenerNotification_Impl( const OUString& aEventName );
#ifdef _WIN32 #ifdef _WIN32
void StateChangeNotification_Impl( sal_Bool bBeforeChange, sal_Int32 nOldState, sal_Int32 nNewState ); void StateChangeNotification_Impl( bool bBeforeChange, sal_Int32 nOldState, sal_Int32 nNewState );
css::uno::Reference< css::io::XOutputStream > GetStreamForSaving(); css::uno::Reference< css::io::XOutputStream > GetStreamForSaving();
css::uno::Sequence< sal_Int32 > GetIntermediateVerbsSequence_Impl( sal_Int32 nNewState ); css::uno::Sequence< sal_Int32 > GetIntermediateVerbsSequence_Impl( sal_Int32 nNewState );
css::uno::Sequence< sal_Int32 > GetReachableStatesList_Impl( static css::uno::Sequence< sal_Int32 > GetReachableStatesList_Impl(
const css::uno::Sequence< css::embed::VerbDescriptor >& aVerbList ); const css::uno::Sequence< css::embed::VerbDescriptor >& aVerbList );
#endif #endif
@@ -241,7 +241,7 @@ protected:
bool bSaveAs ) bool bSaveAs )
throw ( css::uno::Exception ); throw ( css::uno::Exception );
#ifdef _WIN32 #ifdef _WIN32
void StoreObjectToStream( css::uno::Reference< css::io::XOutputStream > xOutStream ) void StoreObjectToStream( css::uno::Reference< css::io::XOutputStream > const & xOutStream )
throw ( css::uno::Exception ); throw ( css::uno::Exception );
#endif #endif
void InsertVisualCache_Impl( void InsertVisualCache_Impl(
@@ -264,11 +264,11 @@ protected:
bool bAllowRepair50 = false ) bool bAllowRepair50 = false )
throw (); throw ();
#ifdef _WIN32 #ifdef _WIN32
sal_Bool SaveObject_Impl(); bool SaveObject_Impl();
sal_Bool OnShowWindow_Impl( sal_Bool bShow ); bool OnShowWindow_Impl( bool bShow );
void CreateOleComponent_Impl( OleComponent* pOleComponent = NULL ); void CreateOleComponent_Impl( OleComponent* pOleComponent = nullptr );
void CreateOleComponentAndLoad_Impl( OleComponent* pOleComponent = NULL ); void CreateOleComponentAndLoad_Impl( OleComponent* pOleComponent = nullptr );
void CreateOleComponentFromClipboard_Impl( OleComponent* pOleComponent = NULL ); void CreateOleComponentFromClipboard_Impl( OleComponent* pOleComponent = nullptr );
OUString CreateTempURLEmpty_Impl(); OUString CreateTempURLEmpty_Impl();
OUString GetTempURL_Impl(); OUString GetTempURL_Impl();
void SetObjectIsLink_Impl( bool bIsLink ) { m_bIsLink = bIsLink; } void SetObjectIsLink_Impl( bool bIsLink ) { m_bIsLink = bIsLink; }
@@ -298,7 +298,7 @@ public:
virtual ~OleEmbeddedObject() override; virtual ~OleEmbeddedObject() override;
#ifdef _WIN32 #ifdef _WIN32
void OnIconChanged_Impl(); static void OnIconChanged_Impl();
void OnViewChanged_Impl(); void OnViewChanged_Impl();
void OnClosed_Impl(); void OnClosed_Impl();
#endif #endif

View File

@@ -36,17 +36,17 @@ OleWrapperAdviseSink::~OleWrapperAdviseSink()
STDMETHODIMP OleWrapperAdviseSink::QueryInterface( REFIID riid , void** ppv ) STDMETHODIMP OleWrapperAdviseSink::QueryInterface( REFIID riid , void** ppv )
{ {
*ppv=NULL; *ppv=nullptr;
if ( riid == IID_IUnknown ) if ( riid == IID_IUnknown )
*ppv = (IUnknown*)this; *ppv = static_cast<IUnknown*>(this);
if ( riid == IID_IAdviseSink ) if ( riid == IID_IAdviseSink )
*ppv = (IAdviseSink*)this; *ppv = static_cast<IAdviseSink*>(this);
if ( *ppv != NULL ) if ( *ppv != nullptr )
{ {
((IUnknown*)*ppv)->AddRef(); static_cast<IUnknown*>(*ppv)->AddRef();
return S_OK; return S_OK;
} }
@@ -71,7 +71,7 @@ void OleWrapperAdviseSink::disconnectOleComponent()
{ {
// must not be called from the descructor of OleComponent!!! // must not be called from the descructor of OleComponent!!!
osl::MutexGuard aGuard( m_aMutex ); osl::MutexGuard aGuard( m_aMutex );
m_pOleComp = NULL; m_pOleComp = nullptr;
} }
STDMETHODIMP_(void) OleWrapperAdviseSink::OnDataChange(LPFORMATETC, LPSTGMEDIUM) STDMETHODIMP_(void) OleWrapperAdviseSink::OnDataChange(LPFORMATETC, LPSTGMEDIUM)

View File

@@ -38,15 +38,15 @@ public:
virtual ~OleWrapperAdviseSink(); virtual ~OleWrapperAdviseSink();
void disconnectOleComponent(); void disconnectOleComponent();
STDMETHODIMP QueryInterface(REFIID, void**); STDMETHODIMP QueryInterface(REFIID, void**) override;
STDMETHODIMP_(ULONG) AddRef(); STDMETHODIMP_(ULONG) AddRef() override;
STDMETHODIMP_(ULONG) Release(); STDMETHODIMP_(ULONG) Release() override;
STDMETHODIMP_(void) OnDataChange(LPFORMATETC, LPSTGMEDIUM); STDMETHODIMP_(void) OnDataChange(LPFORMATETC, LPSTGMEDIUM) override;
STDMETHODIMP_(void) OnViewChange(DWORD, LONG); STDMETHODIMP_(void) OnViewChange(DWORD, LONG) override;
STDMETHODIMP_(void) OnRename(LPMONIKER); STDMETHODIMP_(void) OnRename(LPMONIKER) override;
STDMETHODIMP_(void) OnSave(); STDMETHODIMP_(void) OnSave() override;
STDMETHODIMP_(void) OnClose(); STDMETHODIMP_(void) OnClose() override;
}; };
#endif #endif

View File

@@ -34,6 +34,7 @@
#include <tools/stream.hxx> #include <tools/stream.hxx>
#include <vcl/graphicfilter.hxx> #include <vcl/graphicfilter.hxx>
#include <graphconvert.hxx>
#include "mtnotification.hxx" #include "mtnotification.hxx"
#include "oleembobj.hxx" #include "oleembobj.hxx"
@@ -41,7 +42,7 @@
using namespace ::com::sun::star; using namespace ::com::sun::star;
sal_Bool ConvertBufferToFormat( void* pBuf, bool ConvertBufferToFormat( void* pBuf,
sal_uInt32 nBufSize, sal_uInt32 nBufSize,
const OUString& aMimeType, const OUString& aMimeType,
uno::Any& aResult ) uno::Any& aResult )
@@ -56,11 +57,11 @@ sal_Bool ConvertBufferToFormat( void* pBuf,
if (rFilter.CanImportGraphic(OUString(), aMemoryStream, GRFILTER_FORMAT_DONTKNOW, &nRetFormat) == GRFILTER_OK && if (rFilter.CanImportGraphic(OUString(), aMemoryStream, GRFILTER_FORMAT_DONTKNOW, &nRetFormat) == GRFILTER_OK &&
rFilter.GetImportFormatMediaType(nRetFormat) == aMimeType) rFilter.GetImportFormatMediaType(nRetFormat) == aMimeType)
{ {
aResult <<= uno::Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aMemoryStream.GetData() ), aMemoryStream.Seek( STREAM_SEEK_TO_END ) ); aResult <<= uno::Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aMemoryStream.GetData() ), aMemoryStream.Seek( STREAM_SEEK_TO_END ) );
return sal_True; return true;
} }
uno::Sequence < sal_Int8 > aData( (sal_Int8*)pBuf, nBufSize ); uno::Sequence < sal_Int8 > aData( static_cast<sal_Int8*>(pBuf), nBufSize );
uno::Reference < io::XInputStream > xIn = new comphelper::SequenceInputStream( aData ); uno::Reference < io::XInputStream > xIn = new comphelper::SequenceInputStream( aData );
try try
{ {
@@ -80,15 +81,15 @@ sal_Bool ConvertBufferToFormat( void* pBuf,
aOutMediaProperties[1].Value <<= aMimeType; aOutMediaProperties[1].Value <<= aMimeType;
xGraphicProvider->storeGraphic( xGraphic, aOutMediaProperties ); xGraphicProvider->storeGraphic( xGraphic, aOutMediaProperties );
aResult <<= uno::Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aNewStream.GetData() ), aNewStream.Seek( STREAM_SEEK_TO_END ) ); aResult <<= uno::Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aNewStream.GetData() ), aNewStream.Seek( STREAM_SEEK_TO_END ) );
return sal_True; return true;
} }
} }
catch (const uno::Exception&) catch (const uno::Exception&)
{} {}
} }
return sal_False; return false;
} }
@@ -116,7 +117,7 @@ void SAL_CALL MainThreadNotificationRequest::notify (const uno::Any& ) throw (un
else if ( m_nAspect == embed::Aspects::MSOLE_CONTENT ) else if ( m_nAspect == embed::Aspects::MSOLE_CONTENT )
m_pObject->OnViewChanged_Impl(); m_pObject->OnViewChanged_Impl();
else if ( m_nAspect == embed::Aspects::MSOLE_ICON ) else if ( m_nAspect == embed::Aspects::MSOLE_ICON )
m_pObject->OnIconChanged_Impl(); OleEmbeddedObject::OnIconChanged_Impl();
} }
} }
catch( const uno::Exception& ) catch( const uno::Exception& )

View File

@@ -0,0 +1,38 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_EMBEDDEDOBJ_SOURCE_MSOLE_GRAPHCONVERT_HXX
#define INCLUDED_EMBEDDEDOBJ_SOURCE_MSOLE_GRAPHCONVERT_HXX
#include <sal/config.h>
#include <rtl/ustring.hxx>
#include <sal/types.h>
namespace com { namespace sun { namespace star { namespace uno {
class Any;
} } } }
bool ConvertBufferToFormat(
void * pBuf, sal_uInt32 nBufSize, OUString const & aFormatShortName,
css::uno::Any & aResult);
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -42,9 +42,9 @@ class MainThreadNotificationRequest : public cppu::WeakImplHelper< css::awt::XC
public: public:
virtual void SAL_CALL notify (const css::uno::Any& rUserData) virtual void SAL_CALL notify (const css::uno::Any& rUserData)
throw (css::uno::RuntimeException); throw (css::uno::RuntimeException) override;
MainThreadNotificationRequest( const ::rtl::Reference< OleEmbeddedObject >& xObj, sal_uInt16 nNotificationType, sal_uInt32 nAspect = 0 ); MainThreadNotificationRequest( const ::rtl::Reference< OleEmbeddedObject >& xObj, sal_uInt16 nNotificationType, sal_uInt32 nAspect = 0 );
~MainThreadNotificationRequest(); ~MainThreadNotificationRequest() override;
}; };
#endif #endif

View File

@@ -35,7 +35,9 @@
#include <osl/file.hxx> #include <osl/file.hxx>
#include <rtl/ref.hxx> #include <rtl/ref.hxx>
#include <graphconvert.hxx>
#include <olecomponent.hxx> #include <olecomponent.hxx>
#include <olepersist.hxx>
#include <olewrapclient.hxx> #include <olewrapclient.hxx>
#include <advisesink.hxx> #include <advisesink.hxx>
#include <oleembobj.hxx> #include <oleembobj.hxx>
@@ -59,14 +61,14 @@ template< class T > class ComSmart
if ( m_pInterface ) if ( m_pInterface )
{ {
T* pInterface = m_pInterface; T* pInterface = m_pInterface;
m_pInterface = NULL; m_pInterface = nullptr;
pInterface->Release(); pInterface->Release();
} }
} }
public: public:
ComSmart() ComSmart()
: m_pInterface( NULL ) : m_pInterface( nullptr )
{} {}
ComSmart( const ComSmart<T>& rObj ) ComSmart( const ComSmart<T>& rObj )
@@ -126,7 +128,7 @@ public:
{ {
OwnRelease(); OwnRelease();
m_pInterface = NULL; m_pInterface = nullptr;
return &m_pInterface; return &m_pInterface;
} }
@@ -161,19 +163,12 @@ public:
// ============ class ComSmart ===================== // ============ class ComSmart =====================
sal_Bool ConvertBufferToFormat( void* pBuf,
sal_uInt32 nBufSize,
const OUString& aFormatShortName,
uno::Any& aResult );
OUString GetNewTempFileURL_Impl( const uno::Reference< lang::XMultiServiceFactory >& xFactory ) throw( io::IOException );
typedef ::std::vector< FORMATETC* > FormatEtcList; typedef ::std::vector< FORMATETC* > FormatEtcList;
FORMATETC pFormatTemplates[FORMATS_NUM] = { FORMATETC pFormatTemplates[FORMATS_NUM] = {
{ CF_ENHMETAFILE, NULL, 0, -1, TYMED_ENHMF }, { CF_ENHMETAFILE, nullptr, 0, -1, TYMED_ENHMF },
{ CF_METAFILEPICT, NULL, 0, -1, TYMED_MFPICT }, { CF_METAFILEPICT, nullptr, 0, -1, TYMED_MFPICT },
{ CF_BITMAP, NULL, 0, -1, TYMED_GDI } }; { CF_BITMAP, nullptr, 0, -1, TYMED_GDI } };
struct OleComponentNative_Impl { struct OleComponentNative_Impl {
@@ -215,15 +210,11 @@ struct OleComponentNative_Impl {
cppu::UnoType<uno::Sequence< sal_Int8 >>::get() ); cppu::UnoType<uno::Sequence< sal_Int8 >>::get() );
} }
void AddSupportedFormat( const FORMATETC& aFormatEtc ); bool ConvertDataForFlavor( const STGMEDIUM& aMedium,
FORMATETC* GetSupportedFormatForAspect( sal_uInt32 nRequestedAspect );
sal_Bool ConvertDataForFlavor( const STGMEDIUM& aMedium,
const datatransfer::DataFlavor& aFlavor, const datatransfer::DataFlavor& aFlavor,
uno::Any& aResult ); uno::Any& aResult );
sal_Bool GraphicalFlavor( const datatransfer::DataFlavor& aFlavor ); bool GraphicalFlavor( const datatransfer::DataFlavor& aFlavor );
uno::Sequence< datatransfer::DataFlavor > GetFlavorsForAspects( sal_uInt32 nSupportedAspects ); uno::Sequence< datatransfer::DataFlavor > GetFlavorsForAspects( sal_uInt32 nSupportedAspects );
}; };
@@ -268,54 +259,54 @@ HRESULT OpenIStorageFromURL_Impl( const OUString& aURL, IStorage** ppIStorage )
throw uno::RuntimeException(); // TODO: something dangerous happened throw uno::RuntimeException(); // TODO: something dangerous happened
return StgOpenStorage( reinterpret_cast<LPCWSTR>(aFilePath.getStr()), return StgOpenStorage( reinterpret_cast<LPCWSTR>(aFilePath.getStr()),
NULL, nullptr,
STGM_READWRITE | STGM_TRANSACTED, // | STGM_DELETEONRELEASE, STGM_READWRITE | STGM_TRANSACTED, // | STGM_DELETEONRELEASE,
NULL, nullptr,
0, 0,
ppIStorage ); ppIStorage );
} }
sal_Bool OleComponentNative_Impl::ConvertDataForFlavor( const STGMEDIUM& aMedium, bool OleComponentNative_Impl::ConvertDataForFlavor( const STGMEDIUM& aMedium,
const datatransfer::DataFlavor& aFlavor, const datatransfer::DataFlavor& aFlavor,
uno::Any& aResult ) uno::Any& aResult )
{ {
sal_Bool bAnyIsReady = sal_False; bool bAnyIsReady = false;
// try to convert data from Medium format to specified Flavor format // try to convert data from Medium format to specified Flavor format
if ( aFlavor.DataType == cppu::UnoType<uno::Sequence< sal_Int8 >>::get() ) if ( aFlavor.DataType == cppu::UnoType<uno::Sequence< sal_Int8 >>::get() )
{ {
// first the GDI-metafile must be generated // first the GDI-metafile must be generated
std::unique_ptr<unsigned char[]> pBuf; std::unique_ptr<sal_Int8[]> pBuf;
sal_uInt32 nBufSize = 0; sal_uInt32 nBufSize = 0;
OUString aFormat; OUString aFormat;
if ( aMedium.tymed == TYMED_MFPICT ) // Win Metafile if ( aMedium.tymed == TYMED_MFPICT ) // Win Metafile
{ {
aFormat = "image/x-wmf"; aFormat = "image/x-wmf";
METAFILEPICT* pMF = ( METAFILEPICT* )GlobalLock( aMedium.hMetaFilePict ); METAFILEPICT* pMF = static_cast<METAFILEPICT*>(GlobalLock( aMedium.hMetaFilePict ));
if ( pMF ) if ( pMF )
{ {
nBufSize = GetMetaFileBitsEx( pMF->hMF, 0, NULL ) + 22; nBufSize = GetMetaFileBitsEx( pMF->hMF, 0, nullptr ) + 22;
pBuf.reset(new unsigned char[nBufSize]); pBuf.reset(new sal_Int8[nBufSize]);
// TODO/LATER: the unit size must be calculated correctly // TODO/LATER: the unit size must be calculated correctly
*( (long* )pBuf.get() ) = 0x9ac6cdd7L; *reinterpret_cast<long*>( pBuf.get() ) = 0x9ac6cdd7L;
*( (short* )( pBuf.get()+6 )) = ( SHORT ) 0; *reinterpret_cast<short*>( pBuf.get()+6 ) = ( SHORT ) 0;
*( (short* )( pBuf.get()+8 )) = ( SHORT ) 0; *reinterpret_cast<short*>( pBuf.get()+8 ) = ( SHORT ) 0;
*( (short* )( pBuf.get()+10 )) = ( SHORT ) pMF->xExt; *reinterpret_cast<short*>( pBuf.get()+10 ) = ( SHORT ) pMF->xExt;
*( (short* )( pBuf.get()+12 )) = ( SHORT ) pMF->yExt; *reinterpret_cast<short*>( pBuf.get()+12 ) = ( SHORT ) pMF->yExt;
*( (short* )( pBuf.get()+14 )) = ( USHORT ) 2540; *reinterpret_cast<short*>( pBuf.get()+14 ) = ( USHORT ) 2540;
if ( nBufSize && nBufSize == GetMetaFileBitsEx( pMF->hMF, nBufSize - 22, pBuf.get() + 22 ) ) if ( nBufSize && nBufSize == GetMetaFileBitsEx( pMF->hMF, nBufSize - 22, pBuf.get() + 22 ) )
{ {
if ( aFlavor.MimeType.matchAsciiL( "application/x-openoffice-wmf;windows_formatname=\"Image WMF\"", 57 ) ) if ( aFlavor.MimeType.matchAsciiL( "application/x-openoffice-wmf;windows_formatname=\"Image WMF\"", 57 ) )
{ {
aResult <<= uno::Sequence< sal_Int8 >( ( sal_Int8* )pBuf.get(), nBufSize ); aResult <<= uno::Sequence< sal_Int8 >( pBuf.get(), nBufSize );
bAnyIsReady = sal_True; bAnyIsReady = true;
} }
} }
@@ -325,28 +316,28 @@ sal_Bool OleComponentNative_Impl::ConvertDataForFlavor( const STGMEDIUM& aMedium
else if ( aMedium.tymed == TYMED_ENHMF ) // Enh Metafile else if ( aMedium.tymed == TYMED_ENHMF ) // Enh Metafile
{ {
aFormat = "image/x-emf"; aFormat = "image/x-emf";
nBufSize = GetEnhMetaFileBits( aMedium.hEnhMetaFile, 0, NULL ); nBufSize = GetEnhMetaFileBits( aMedium.hEnhMetaFile, 0, nullptr );
pBuf.reset(new unsigned char[nBufSize]); pBuf.reset(new sal_Int8[nBufSize]);
if ( nBufSize && nBufSize == GetEnhMetaFileBits( aMedium.hEnhMetaFile, nBufSize, pBuf.get() ) ) if ( nBufSize && nBufSize == GetEnhMetaFileBits( aMedium.hEnhMetaFile, nBufSize, reinterpret_cast<LPBYTE>(pBuf.get()) ) )
{ {
if ( aFlavor.MimeType.matchAsciiL( "application/x-openoffice-emf;windows_formatname=\"Image EMF\"", 57 ) ) if ( aFlavor.MimeType.matchAsciiL( "application/x-openoffice-emf;windows_formatname=\"Image EMF\"", 57 ) )
{ {
aResult <<= uno::Sequence< sal_Int8 >( ( sal_Int8* )pBuf.get(), nBufSize ); aResult <<= uno::Sequence< sal_Int8 >( pBuf.get(), nBufSize );
bAnyIsReady = sal_True; bAnyIsReady = true;
} }
} }
} }
else if ( aMedium.tymed == TYMED_GDI ) // Bitmap else if ( aMedium.tymed == TYMED_GDI ) // Bitmap
{ {
aFormat = "image/x-MS-bmp"; aFormat = "image/x-MS-bmp";
nBufSize = GetBitmapBits( aMedium.hBitmap, 0, NULL ); nBufSize = GetBitmapBits( aMedium.hBitmap, 0, nullptr );
pBuf.reset(new unsigned char[nBufSize]); pBuf.reset(new sal_Int8[nBufSize]);
if ( nBufSize && nBufSize == sal::static_int_cast< ULONG >( GetBitmapBits( aMedium.hBitmap, nBufSize, pBuf.get() ) ) ) if ( nBufSize && nBufSize == sal::static_int_cast< ULONG >( GetBitmapBits( aMedium.hBitmap, nBufSize, pBuf.get() ) ) )
{ {
if ( aFlavor.MimeType.matchAsciiL( "application/x-openoffice-bitmap;windows_formatname=\"Bitmap\"", 54 ) ) if ( aFlavor.MimeType.matchAsciiL( "application/x-openoffice-bitmap;windows_formatname=\"Bitmap\"", 54 ) )
{ {
aResult <<= uno::Sequence< sal_Int8 >( ( sal_Int8* )pBuf.get(), nBufSize ); aResult <<= uno::Sequence< sal_Int8 >( pBuf.get(), nBufSize );
bAnyIsReady = sal_True; bAnyIsReady = true;
} }
} }
} }
@@ -358,7 +349,7 @@ sal_Bool OleComponentNative_Impl::ConvertDataForFlavor( const STGMEDIUM& aMedium
&& aFlavor.DataType == m_aSupportedGraphFormats[nInd].DataType && aFlavor.DataType == m_aSupportedGraphFormats[nInd].DataType
&& aFlavor.DataType == cppu::UnoType<uno::Sequence< sal_Int8 >>::get() ) && aFlavor.DataType == cppu::UnoType<uno::Sequence< sal_Int8 >>::get() )
{ {
bAnyIsReady = ConvertBufferToFormat( ( void* )pBuf.get(), nBufSize, aFormat, aResult ); bAnyIsReady = ConvertBufferToFormat( pBuf.get(), nBufSize, aFormat, aResult );
break; break;
} }
} }
@@ -368,19 +359,19 @@ sal_Bool OleComponentNative_Impl::ConvertDataForFlavor( const STGMEDIUM& aMedium
} }
sal_Bool OleComponentNative_Impl::GraphicalFlavor( const datatransfer::DataFlavor& aFlavor ) bool OleComponentNative_Impl::GraphicalFlavor( const datatransfer::DataFlavor& aFlavor )
{ {
// Actually all the required graphical formats must be supported // Actually all the required graphical formats must be supported
for ( sal_Int32 nInd = 0; nInd < m_aSupportedGraphFormats.getLength(); nInd++ ) for ( sal_Int32 nInd = 0; nInd < m_aSupportedGraphFormats.getLength(); nInd++ )
if ( aFlavor.MimeType.match( m_aSupportedGraphFormats[nInd].MimeType ) if ( aFlavor.MimeType.match( m_aSupportedGraphFormats[nInd].MimeType )
&& aFlavor.DataType == m_aSupportedGraphFormats[nInd].DataType ) && aFlavor.DataType == m_aSupportedGraphFormats[nInd].DataType )
return sal_True; return true;
return sal_False; return false;
} }
sal_Bool GetClassIDFromSequence_Impl( uno::Sequence< sal_Int8 > aSeq, CLSID& aResult ) bool GetClassIDFromSequence_Impl( uno::Sequence< sal_Int8 > const & aSeq, CLSID& aResult )
{ {
if ( aSeq.getLength() == 16 ) if ( aSeq.getLength() == 16 )
{ {
@@ -390,10 +381,10 @@ sal_Bool GetClassIDFromSequence_Impl( uno::Sequence< sal_Int8 > aSeq, CLSID& aRe
for( int nInd = 0; nInd < 8; nInd++ ) for( int nInd = 0; nInd < 8; nInd++ )
aResult.Data4[nInd] = ( sal_uInt8 )aSeq[nInd+8]; aResult.Data4[nInd] = ( sal_uInt8 )aSeq[nInd+8];
return sal_True; return true;
} }
return sal_False; return false;
} }
@@ -423,30 +414,30 @@ OUString WinAccToVcl_Impl( const sal_Unicode* pStr )
OleComponent::OleComponent( const uno::Reference< lang::XMultiServiceFactory >& xFactory, OleEmbeddedObject* pUnoOleObject ) OleComponent::OleComponent( const uno::Reference< lang::XMultiServiceFactory >& xFactory, OleEmbeddedObject* pUnoOleObject )
: m_pInterfaceContainer( NULL ) : m_pInterfaceContainer( nullptr )
, m_bDisposed( sal_False ) , m_bDisposed( false )
, m_bModified( sal_False ) , m_bModified( false )
, m_pNativeImpl( new OleComponentNative_Impl() ) , m_pNativeImpl( new OleComponentNative_Impl() )
, m_pUnoOleObject( pUnoOleObject ) , m_pUnoOleObject( pUnoOleObject )
, m_pOleWrapClientSite( NULL ) , m_pOleWrapClientSite( nullptr )
, m_pImplAdviseSink( NULL ) , m_pImplAdviseSink( nullptr )
, m_nOLEMiscFlags( 0 ) , m_nOLEMiscFlags( 0 )
, m_nAdvConn( 0 ) , m_nAdvConn( 0 )
, m_xFactory( xFactory ) , m_xFactory( xFactory )
, m_bOleInitialized( sal_False ) , m_bOleInitialized( false )
, m_bWorkaroundActive( sal_False ) , m_bWorkaroundActive( false )
{ {
OSL_ENSURE( m_pUnoOleObject, "No owner object is provided!" ); OSL_ENSURE( m_pUnoOleObject, "No owner object is provided!" );
HRESULT hr = OleInitialize( NULL ); HRESULT hr = OleInitialize( nullptr );
OSL_ENSURE( hr == S_OK || hr == S_FALSE, "The ole can not be successfully initialized\n" ); OSL_ENSURE( hr == S_OK || hr == S_FALSE, "The ole can not be successfully initialized\n" );
if ( hr == S_OK || hr == S_FALSE ) if ( hr == S_OK || hr == S_FALSE )
m_bOleInitialized = sal_True; m_bOleInitialized = true;
m_pOleWrapClientSite = new OleWrapperClientSite( ( OleComponent* )this ); m_pOleWrapClientSite = new OleWrapperClientSite( this );
m_pOleWrapClientSite->AddRef(); m_pOleWrapClientSite->AddRef();
m_pImplAdviseSink = new OleWrapperAdviseSink( ( OleComponent* )this ); m_pImplAdviseSink = new OleWrapperAdviseSink( this );
m_pImplAdviseSink->AddRef(); m_pImplAdviseSink->AddRef();
} }
@@ -471,33 +462,13 @@ OleComponent::~OleComponent()
++aIter ) ++aIter )
{ {
delete (*aIter); delete (*aIter);
(*aIter) = NULL; (*aIter) = nullptr;
} }
m_pNativeImpl->m_aFormatsList.clear(); m_pNativeImpl->m_aFormatsList.clear();
delete m_pNativeImpl; delete m_pNativeImpl;
} }
void OleComponentNative_Impl::AddSupportedFormat( const FORMATETC& aFormatEtc )
{
FORMATETC* pFormatToInsert = new FORMATETC( aFormatEtc );
m_aFormatsList.push_back( pFormatToInsert );
}
FORMATETC* OleComponentNative_Impl::GetSupportedFormatForAspect( sal_uInt32 nRequestedAspect )
{
for ( FormatEtcList::iterator aIter = m_aFormatsList.begin();
aIter != m_aFormatsList.end();
++aIter )
if ( (*aIter) && (*aIter)->dwAspect == nRequestedAspect )
return (*aIter);
return NULL;
}
void OleComponent::Dispose() void OleComponent::Dispose()
{ {
// the mutex must be locked before this method is called // the mutex must be locked before this method is called
@@ -510,14 +481,14 @@ void OleComponent::Dispose()
{ {
m_pOleWrapClientSite->disconnectOleComponent(); m_pOleWrapClientSite->disconnectOleComponent();
m_pOleWrapClientSite->Release(); m_pOleWrapClientSite->Release();
m_pOleWrapClientSite = NULL; m_pOleWrapClientSite = nullptr;
} }
if ( m_pImplAdviseSink ) if ( m_pImplAdviseSink )
{ {
m_pImplAdviseSink->disconnectOleComponent(); m_pImplAdviseSink->disconnectOleComponent();
m_pImplAdviseSink->Release(); m_pImplAdviseSink->Release();
m_pImplAdviseSink = NULL; m_pImplAdviseSink = nullptr;
} }
if ( m_pInterfaceContainer ) if ( m_pInterfaceContainer )
@@ -526,7 +497,7 @@ void OleComponent::Dispose()
m_pInterfaceContainer->disposeAndClear( aEvent ); m_pInterfaceContainer->disposeAndClear( aEvent );
delete m_pInterfaceContainer; delete m_pInterfaceContainer;
m_pInterfaceContainer = NULL; m_pInterfaceContainer = nullptr;
} }
if ( m_bOleInitialized ) if ( m_bOleInitialized )
@@ -535,10 +506,10 @@ void OleComponent::Dispose()
// the deinitialization might lead to a disaster, SO7 does not deinitialize OLE at all // the deinitialization might lead to a disaster, SO7 does not deinitialize OLE at all
// so currently the same approach is selected as workaround // so currently the same approach is selected as workaround
// OleUninitialize(); // OleUninitialize();
m_bOleInitialized = sal_False; m_bOleInitialized = false;
} }
m_bDisposed = sal_True; m_bDisposed = true;
} }
@@ -546,7 +517,7 @@ void OleComponent::disconnectEmbeddedObject()
{ {
// must not be called from destructor of UNO OLE object!!! // must not be called from destructor of UNO OLE object!!!
osl::MutexGuard aGuard( m_aMutex ); osl::MutexGuard aGuard( m_aMutex );
m_pUnoOleObject = NULL; m_pUnoOleObject = nullptr;
} }
@@ -608,7 +579,7 @@ void OleComponent::RetrieveObjectDataFlavors_Impl()
if ( !m_aDataFlavors.getLength() ) if ( !m_aDataFlavors.getLength() )
{ {
ComSmart< IDataObject > pDataObject; ComSmart< IDataObject > pDataObject;
HRESULT hr = m_pNativeImpl->m_pObj->QueryInterface( IID_IDataObject, (void**)&pDataObject ); HRESULT hr = m_pNativeImpl->m_pObj->QueryInterface( IID_IDataObject, reinterpret_cast<void**>(&pDataObject) );
if ( SUCCEEDED( hr ) && pDataObject ) if ( SUCCEEDED( hr ) && pDataObject )
{ {
ComSmart< IEnumFORMATETC > pFormatEnum; ComSmart< IEnumFORMATETC > pFormatEnum;
@@ -652,29 +623,29 @@ void OleComponent::RetrieveObjectDataFlavors_Impl()
} }
sal_Bool OleComponent::InitializeObject_Impl() bool OleComponent::InitializeObject_Impl()
// There will be no static objects! // There will be no static objects!
{ {
if ( !m_pNativeImpl->m_pObj ) if ( !m_pNativeImpl->m_pObj )
return sal_False; return false;
// the linked object will be detected here // the linked object will be detected here
ComSmart< IOleLink > pOleLink; ComSmart< IOleLink > pOleLink;
HRESULT hr = m_pNativeImpl->m_pObj->QueryInterface( IID_IOleLink, (void**)&pOleLink ); HRESULT hr = m_pNativeImpl->m_pObj->QueryInterface( IID_IOleLink, reinterpret_cast<void**>(&pOleLink) );
OSL_ENSURE( m_pUnoOleObject, "Unexpected object absence!" ); OSL_ENSURE( m_pUnoOleObject, "Unexpected object absence!" );
if ( m_pUnoOleObject ) if ( m_pUnoOleObject )
m_pUnoOleObject->SetObjectIsLink_Impl( sal_Bool( pOleLink != NULL ) ); m_pUnoOleObject->SetObjectIsLink_Impl( bool( pOleLink != nullptr ) );
hr = m_pNativeImpl->m_pObj->QueryInterface( IID_IViewObject2, (void**)&m_pNativeImpl->m_pViewObject2 ); hr = m_pNativeImpl->m_pObj->QueryInterface( IID_IViewObject2, reinterpret_cast<void**>(&m_pNativeImpl->m_pViewObject2) );
if ( FAILED( hr ) || !m_pNativeImpl->m_pViewObject2 ) if ( FAILED( hr ) || !m_pNativeImpl->m_pViewObject2 )
return sal_False; return false;
// remove all the caches // remove all the caches
IOleCache* pIOleCache = NULL; IOleCache* pIOleCache = nullptr;
if ( SUCCEEDED( m_pNativeImpl->m_pObj->QueryInterface( IID_IOleCache, (void**)&pIOleCache ) ) && pIOleCache ) if ( SUCCEEDED( m_pNativeImpl->m_pObj->QueryInterface( IID_IOleCache, reinterpret_cast<void**>(&pIOleCache) ) ) && pIOleCache )
{ {
IEnumSTATDATA* pEnumSD = NULL; IEnumSTATDATA* pEnumSD = nullptr;
HRESULT hr2 = pIOleCache->EnumCache( &pEnumSD ); HRESULT hr2 = pIOleCache->EnumCache( &pEnumSD );
if ( SUCCEEDED( hr2 ) && pEnumSD ) if ( SUCCEEDED( hr2 ) && pEnumSD )
@@ -688,18 +659,18 @@ sal_Bool OleComponent::InitializeObject_Impl()
// No IDataObject implementation, caching must be used instead // No IDataObject implementation, caching must be used instead
DWORD nConn; DWORD nConn;
FORMATETC aFormat = { 0, 0, DVASPECT_CONTENT, -1, TYMED_MFPICT }; FORMATETC aFormat = { 0, nullptr, DVASPECT_CONTENT, -1, TYMED_MFPICT };
hr2 = pIOleCache->Cache( &aFormat, ADVFCACHE_ONSAVE, &nConn ); hr2 = pIOleCache->Cache( &aFormat, ADVFCACHE_ONSAVE, &nConn );
pIOleCache->Release(); pIOleCache->Release();
pIOleCache = NULL; pIOleCache = nullptr;
} }
hr = m_pNativeImpl->m_pObj->QueryInterface( IID_IOleObject, (void**)&m_pNativeImpl->m_pOleObject ); hr = m_pNativeImpl->m_pObj->QueryInterface( IID_IOleObject, reinterpret_cast<void**>(&m_pNativeImpl->m_pOleObject) );
if ( FAILED( hr ) || !m_pNativeImpl->m_pOleObject ) if ( FAILED( hr ) || !m_pNativeImpl->m_pOleObject )
return sal_False; // Static objects are not supported, they should be inserted as graphics return false; // Static objects are not supported, they should be inserted as graphics
m_pNativeImpl->m_pOleObject->GetMiscStatus( DVASPECT_CONTENT, ( DWORD* )&m_nOLEMiscFlags ); m_pNativeImpl->m_pOleObject->GetMiscStatus( DVASPECT_CONTENT, reinterpret_cast<DWORD*>(&m_nOLEMiscFlags) );
// TODO: use other misc flags also // TODO: use other misc flags also
// the object should have drawable aspect even in case it supports only iconic representation // the object should have drawable aspect even in case it supports only iconic representation
// if ( m_nOLEMiscFlags & OLEMISC_ONLYICONIC ) // if ( m_nOLEMiscFlags & OLEMISC_ONLYICONIC )
@@ -707,12 +678,12 @@ sal_Bool OleComponent::InitializeObject_Impl()
m_pNativeImpl->m_pOleObject->SetClientSite( m_pOleWrapClientSite ); m_pNativeImpl->m_pOleObject->SetClientSite( m_pOleWrapClientSite );
// the only need in this registration is workaround for close notification // the only need in this registration is workaround for close notification
m_pNativeImpl->m_pOleObject->Advise( m_pImplAdviseSink, ( DWORD* )&m_nAdvConn ); m_pNativeImpl->m_pOleObject->Advise( m_pImplAdviseSink, reinterpret_cast<DWORD*>(&m_nAdvConn) );
m_pNativeImpl->m_pViewObject2->SetAdvise( DVASPECT_CONTENT, 0, m_pImplAdviseSink ); m_pNativeImpl->m_pViewObject2->SetAdvise( DVASPECT_CONTENT, 0, m_pImplAdviseSink );
OleSetContainedObject( m_pNativeImpl->m_pOleObject, TRUE ); OleSetContainedObject( m_pNativeImpl->m_pOleObject, TRUE );
return sal_True; return true;
} }
namespace namespace
@@ -721,7 +692,7 @@ namespace
{ {
HRESULT hr = E_FAIL; HRESULT hr = E_FAIL;
__try { __try {
hr = OleLoad(pIStorage, IID_IUnknown, NULL, ppObj); hr = OleLoad(pIStorage, IID_IUnknown, nullptr, ppObj);
} __except( EXCEPTION_EXECUTE_HANDLER ) { } __except( EXCEPTION_EXECUTE_HANDLER ) {
return E_FAIL; return E_FAIL;
} }
@@ -743,7 +714,7 @@ void OleComponent::LoadEmbeddedObject( const OUString& aTempURL )
if ( FAILED( hr ) || !m_pNativeImpl->m_pIStorage ) if ( FAILED( hr ) || !m_pNativeImpl->m_pIStorage )
throw io::IOException(); // TODO: transport error code? throw io::IOException(); // TODO: transport error code?
hr = OleLoadSeh(m_pNativeImpl->m_pIStorage, (void**)&m_pNativeImpl->m_pObj); hr = OleLoadSeh(m_pNativeImpl->m_pIStorage, reinterpret_cast<void**>(&m_pNativeImpl->m_pObj));
if ( FAILED( hr ) || !m_pNativeImpl->m_pObj ) if ( FAILED( hr ) || !m_pNativeImpl->m_pObj )
{ {
throw uno::RuntimeException(); throw uno::RuntimeException();
@@ -763,7 +734,7 @@ void OleComponent::CreateObjectFromClipboard()
if ( !m_pNativeImpl->m_pIStorage ) if ( !m_pNativeImpl->m_pIStorage )
throw uno::RuntimeException(); // TODO throw uno::RuntimeException(); // TODO
IDataObject * pDO = NULL; IDataObject * pDO = nullptr;
HRESULT hr = OleGetClipboard( &pDO ); HRESULT hr = OleGetClipboard( &pDO );
if( SUCCEEDED( hr ) && pDO ) if( SUCCEEDED( hr ) && pDO )
{ {
@@ -773,10 +744,10 @@ void OleComponent::CreateObjectFromClipboard()
hr = OleCreateFromData( pDO, hr = OleCreateFromData( pDO,
IID_IUnknown, IID_IUnknown,
OLERENDER_DRAW, // OLERENDER_FORMAT OLERENDER_DRAW, // OLERENDER_FORMAT
NULL, // &aFormat, nullptr, // &aFormat,
NULL, nullptr,
m_pNativeImpl->m_pIStorage, m_pNativeImpl->m_pIStorage,
(void**)&m_pNativeImpl->m_pObj ); reinterpret_cast<void**>(&m_pNativeImpl->m_pObj) );
} }
else else
{ {
@@ -812,10 +783,10 @@ void OleComponent::CreateNewEmbeddedObject( const uno::Sequence< sal_Int8 >& aSe
HRESULT hr = OleCreate( aClsID, HRESULT hr = OleCreate( aClsID,
IID_IUnknown, IID_IUnknown,
OLERENDER_DRAW, // OLERENDER_FORMAT OLERENDER_DRAW, // OLERENDER_FORMAT
NULL, // &aFormat, nullptr, // &aFormat,
NULL, nullptr,
m_pNativeImpl->m_pIStorage, m_pNativeImpl->m_pIStorage,
(void**)&m_pNativeImpl->m_pObj ); reinterpret_cast<void**>(&m_pNativeImpl->m_pObj) );
if ( FAILED( hr ) || !m_pNativeImpl->m_pObj ) if ( FAILED( hr ) || !m_pNativeImpl->m_pObj )
throw uno::RuntimeException(); // TODO throw uno::RuntimeException(); // TODO
@@ -855,10 +826,10 @@ void OleComponent::CreateObjectFromFile( const OUString& aFileURL )
reinterpret_cast<LPCWSTR>(aFilePath.getStr()), reinterpret_cast<LPCWSTR>(aFilePath.getStr()),
IID_IUnknown, IID_IUnknown,
OLERENDER_DRAW, // OLERENDER_FORMAT OLERENDER_DRAW, // OLERENDER_FORMAT
NULL, nullptr,
NULL, nullptr,
m_pNativeImpl->m_pIStorage, m_pNativeImpl->m_pIStorage,
(void**)&m_pNativeImpl->m_pObj ); reinterpret_cast<void**>(&m_pNativeImpl->m_pObj) );
if ( FAILED( hr ) || !m_pNativeImpl->m_pObj ) if ( FAILED( hr ) || !m_pNativeImpl->m_pObj )
throw uno::RuntimeException(); // TODO throw uno::RuntimeException(); // TODO
@@ -884,10 +855,10 @@ void OleComponent::CreateLinkFromFile( const OUString& aFileURL )
HRESULT hr = OleCreateLinkToFile( reinterpret_cast<LPCWSTR>(aFilePath.getStr()), HRESULT hr = OleCreateLinkToFile( reinterpret_cast<LPCWSTR>(aFilePath.getStr()),
IID_IUnknown, IID_IUnknown,
OLERENDER_DRAW, // OLERENDER_FORMAT OLERENDER_DRAW, // OLERENDER_FORMAT
NULL, nullptr,
NULL, nullptr,
m_pNativeImpl->m_pIStorage, m_pNativeImpl->m_pIStorage,
(void**)&m_pNativeImpl->m_pObj ); reinterpret_cast<void**>(&m_pNativeImpl->m_pObj) );
if ( FAILED( hr ) || !m_pNativeImpl->m_pObj ) if ( FAILED( hr ) || !m_pNativeImpl->m_pObj )
throw uno::RuntimeException(); // TODO throw uno::RuntimeException(); // TODO
@@ -906,7 +877,7 @@ void OleComponent::InitEmbeddedCopyOfLink( OleComponent* pOleLinkComponent )
throw io::IOException(); // TODO:the object is already initialized throw io::IOException(); // TODO:the object is already initialized
ComSmart< IDataObject > pDataObject; ComSmart< IDataObject > pDataObject;
HRESULT hr = pOleLinkComponent->m_pNativeImpl->m_pObj->QueryInterface( IID_IDataObject, (void**)&pDataObject ); HRESULT hr = pOleLinkComponent->m_pNativeImpl->m_pObj->QueryInterface( IID_IDataObject, reinterpret_cast<void**>(&pDataObject) );
if ( SUCCEEDED( hr ) && pDataObject && SUCCEEDED( OleQueryCreateFromData( pDataObject ) ) ) if ( SUCCEEDED( hr ) && pDataObject && SUCCEEDED( OleQueryCreateFromData( pDataObject ) ) )
{ {
// the object must be already disconnected from the temporary URL // the object must be already disconnected from the temporary URL
@@ -917,16 +888,16 @@ void OleComponent::InitEmbeddedCopyOfLink( OleComponent* pOleLinkComponent )
hr = OleCreateFromData( pDataObject, hr = OleCreateFromData( pDataObject,
IID_IUnknown, IID_IUnknown,
OLERENDER_DRAW, OLERENDER_DRAW,
NULL, nullptr,
NULL, nullptr,
m_pNativeImpl->m_pIStorage, m_pNativeImpl->m_pIStorage,
(void**)&m_pNativeImpl->m_pObj ); reinterpret_cast<void**>(&m_pNativeImpl->m_pObj) );
} }
if ( !m_pNativeImpl->m_pObj ) if ( !m_pNativeImpl->m_pObj )
{ {
ComSmart< IOleLink > pOleLink; ComSmart< IOleLink > pOleLink;
hr = pOleLinkComponent->m_pNativeImpl->m_pObj->QueryInterface( IID_IOleLink, (void**)&pOleLink ); hr = pOleLinkComponent->m_pNativeImpl->m_pObj->QueryInterface( IID_IOleLink, reinterpret_cast<void**>(&pOleLink) );
if ( FAILED( hr ) || !pOleLink ) if ( FAILED( hr ) || !pOleLink )
throw io::IOException(); // TODO: the object doesn't support IOleLink throw io::IOException(); // TODO: the object doesn't support IOleLink
@@ -944,22 +915,22 @@ void OleComponent::InitEmbeddedCopyOfLink( OleComponent* pOleLinkComponent )
CoGetMalloc( 1, &pMalloc ); // if fails there will be a memory leak CoGetMalloc( 1, &pMalloc ); // if fails there will be a memory leak
OSL_ENSURE( pMalloc, "CoGetMalloc() failed!" ); OSL_ENSURE( pMalloc, "CoGetMalloc() failed!" );
LPOLESTR pOleStr = NULL; LPOLESTR pOleStr = nullptr;
hr = pOleLink->GetSourceDisplayName( &pOleStr ); hr = pOleLink->GetSourceDisplayName( &pOleStr );
if ( SUCCEEDED( hr ) && pOleStr ) if ( SUCCEEDED( hr ) && pOleStr )
{ {
OUString aFilePath( ( sal_Unicode* )pOleStr ); OUString aFilePath( pOleStr );
if ( pMalloc ) if ( pMalloc )
pMalloc->Free( ( void* )pOleStr ); pMalloc->Free( pOleStr );
hr = OleCreateFromFile( CLSID_NULL, hr = OleCreateFromFile( CLSID_NULL,
reinterpret_cast<LPCWSTR>(aFilePath.getStr()), reinterpret_cast<LPCWSTR>(aFilePath.getStr()),
IID_IUnknown, IID_IUnknown,
OLERENDER_DRAW, // OLERENDER_FORMAT OLERENDER_DRAW, // OLERENDER_FORMAT
NULL, nullptr,
NULL, nullptr,
m_pNativeImpl->m_pIStorage, m_pNativeImpl->m_pIStorage,
(void**)&m_pNativeImpl->m_pObj ); reinterpret_cast<void**>(&m_pNativeImpl->m_pObj) );
} }
} }
@@ -967,16 +938,16 @@ void OleComponent::InitEmbeddedCopyOfLink( OleComponent* pOleLinkComponent )
if ( !m_pNativeImpl->m_pObj ) if ( !m_pNativeImpl->m_pObj )
{ {
ComSmart< IBindCtx > pBindCtx; ComSmart< IBindCtx > pBindCtx;
hr = CreateBindCtx( 0, ( LPBC FAR* )&pBindCtx ); hr = CreateBindCtx( 0, &pBindCtx );
if ( SUCCEEDED( hr ) && pBindCtx ) if ( SUCCEEDED( hr ) && pBindCtx )
{ {
ComSmart< IStorage > pObjectStorage; ComSmart< IStorage > pObjectStorage;
hr = pMoniker->BindToStorage( pBindCtx, NULL, IID_IStorage, (void**)&pObjectStorage ); hr = pMoniker->BindToStorage( pBindCtx, nullptr, IID_IStorage, reinterpret_cast<void**>(&pObjectStorage) );
if ( SUCCEEDED( hr ) && pObjectStorage ) if ( SUCCEEDED( hr ) && pObjectStorage )
{ {
hr = pObjectStorage->CopyTo( 0, NULL, NULL, m_pNativeImpl->m_pIStorage ); hr = pObjectStorage->CopyTo( 0, nullptr, nullptr, m_pNativeImpl->m_pIStorage );
if ( SUCCEEDED( hr ) ) if ( SUCCEEDED( hr ) )
hr = OleLoadSeh(m_pNativeImpl->m_pIStorage, (void**)&m_pNativeImpl->m_pObj); hr = OleLoadSeh(m_pNativeImpl->m_pIStorage, reinterpret_cast<void**>(&m_pNativeImpl->m_pObj));
} }
} }
} }
@@ -1088,7 +1059,7 @@ void OleComponent::ExecuteVerb( sal_Int32 nVerbID )
// TODO: probably extents should be set here and stored in aRect // TODO: probably extents should be set here and stored in aRect
// TODO: probably the parent window also should be set // TODO: probably the parent window also should be set
hr = m_pNativeImpl->m_pOleObject->DoVerb( nVerbID, NULL, m_pOleWrapClientSite, 0, NULL, NULL ); hr = m_pNativeImpl->m_pOleObject->DoVerb( nVerbID, nullptr, m_pOleWrapClientSite, 0, nullptr, nullptr );
if ( FAILED( hr ) ) if ( FAILED( hr ) )
throw io::IOException(); // TODO throw io::IOException(); // TODO
@@ -1137,13 +1108,13 @@ awt::Size OleComponent::GetExtent( sal_Int64 nAspect )
DWORD nMSAspect = ( DWORD )nAspect; // first 32 bits are for MS aspects DWORD nMSAspect = ( DWORD )nAspect; // first 32 bits are for MS aspects
awt::Size aSize; awt::Size aSize;
sal_Bool bGotSize = sal_False; bool bGotSize = false;
if ( nMSAspect == DVASPECT_CONTENT ) if ( nMSAspect == DVASPECT_CONTENT )
{ {
// Try to get the size from the replacement image first // Try to get the size from the replacement image first
ComSmart< IDataObject > pDataObject; ComSmart< IDataObject > pDataObject;
HRESULT hr = m_pNativeImpl->m_pObj->QueryInterface( IID_IDataObject, (void**)&pDataObject ); HRESULT hr = m_pNativeImpl->m_pObj->QueryInterface( IID_IDataObject, reinterpret_cast<void**>(&pDataObject) );
if ( SUCCEEDED( hr ) || pDataObject ) if ( SUCCEEDED( hr ) || pDataObject )
{ {
STGMEDIUM aMedium; STGMEDIUM aMedium;
@@ -1153,7 +1124,7 @@ awt::Size OleComponent::GetExtent( sal_Int64 nAspect )
hr = pDataObject->GetData( &aFormat, &aMedium ); hr = pDataObject->GetData( &aFormat, &aMedium );
if ( SUCCEEDED( hr ) && aMedium.tymed == TYMED_MFPICT ) // Win Metafile if ( SUCCEEDED( hr ) && aMedium.tymed == TYMED_MFPICT ) // Win Metafile
{ {
METAFILEPICT* pMF = ( METAFILEPICT* )GlobalLock( aMedium.hMetaFilePict ); METAFILEPICT* pMF = static_cast<METAFILEPICT*>(GlobalLock( aMedium.hMetaFilePict ));
if ( pMF ) if ( pMF )
{ {
// the object uses 0.01 mm as unit, so the metafile size should be converted to object unit // the object uses 0.01 mm as unit, so the metafile size should be converted to object unit
@@ -1193,7 +1164,7 @@ awt::Size OleComponent::GetExtent( sal_Int64 nAspect )
{ {
aSize.Width = ( sal_Int32 )nX; aSize.Width = ( sal_Int32 )nX;
aSize.Height = ( sal_Int32 )nY; aSize.Height = ( sal_Int32 )nY;
bGotSize = sal_True; bGotSize = true;
} }
else else
OSL_FAIL( "Unexpected size is provided!" ); OSL_FAIL( "Unexpected size is provided!" );
@@ -1220,7 +1191,7 @@ awt::Size OleComponent::GetCachedExtent( sal_Int64 nAspect )
DWORD nMSAspect = ( DWORD )nAspect; // first 32 bits are for MS aspects DWORD nMSAspect = ( DWORD )nAspect; // first 32 bits are for MS aspects
SIZEL aSize; SIZEL aSize;
HRESULT hr = m_pNativeImpl->m_pViewObject2->GetExtent( nMSAspect, -1, NULL, &aSize ); HRESULT hr = m_pNativeImpl->m_pViewObject2->GetExtent( nMSAspect, -1, nullptr, &aSize );
if ( FAILED( hr ) ) if ( FAILED( hr ) )
{ {
@@ -1258,8 +1229,8 @@ sal_Int64 OleComponent::GetMiscStatus( sal_Int64 nAspect )
if ( !m_pNativeImpl->m_pOleObject ) if ( !m_pNativeImpl->m_pOleObject )
throw embed::WrongStateException(); // TODO: the object is in wrong state throw embed::WrongStateException(); // TODO: the object is in wrong state
sal_uInt32 nResult; DWORD nResult;
m_pNativeImpl->m_pOleObject->GetMiscStatus( ( DWORD )nAspect, ( DWORD* )&nResult ); m_pNativeImpl->m_pOleObject->GetMiscStatus( ( DWORD )nAspect, &nResult );
return ( sal_Int64 )nResult; // first 32 bits are for MS flags return ( sal_Int64 )nResult; // first 32 bits are for MS flags
} }
@@ -1282,16 +1253,16 @@ uno::Sequence< sal_Int8 > OleComponent::GetCLSID()
} }
sal_Bool OleComponent::IsDirty() bool OleComponent::IsDirty()
{ {
if ( !m_pNativeImpl->m_pOleObject ) if ( !m_pNativeImpl->m_pOleObject )
throw embed::WrongStateException(); // TODO: the object is in wrong state throw embed::WrongStateException(); // TODO: the object is in wrong state
if ( IsWorkaroundActive() ) if ( IsWorkaroundActive() )
return sal_True; return true;
ComSmart< IPersistStorage > pPersistStorage; ComSmart< IPersistStorage > pPersistStorage;
HRESULT hr = m_pNativeImpl->m_pObj->QueryInterface( IID_IPersistStorage, (void**)&pPersistStorage ); HRESULT hr = m_pNativeImpl->m_pObj->QueryInterface( IID_IPersistStorage, reinterpret_cast<void**>(&pPersistStorage) );
if ( FAILED( hr ) || !pPersistStorage ) if ( FAILED( hr ) || !pPersistStorage )
throw io::IOException(); // TODO throw io::IOException(); // TODO
@@ -1306,7 +1277,7 @@ void OleComponent::StoreOwnTmpIfNecessary()
throw embed::WrongStateException(); // TODO: the object is in wrong state throw embed::WrongStateException(); // TODO: the object is in wrong state
ComSmart< IPersistStorage > pPersistStorage; ComSmart< IPersistStorage > pPersistStorage;
HRESULT hr = m_pNativeImpl->m_pObj->QueryInterface( IID_IPersistStorage, (void**)&pPersistStorage ); HRESULT hr = m_pNativeImpl->m_pObj->QueryInterface( IID_IPersistStorage, reinterpret_cast<void**>(&pPersistStorage) );
if ( FAILED( hr ) || !pPersistStorage ) if ( FAILED( hr ) || !pPersistStorage )
throw io::IOException(); // TODO throw io::IOException(); // TODO
@@ -1331,14 +1302,14 @@ void OleComponent::StoreOwnTmpIfNecessary()
// another workaround for AcrobatReader7.0.8 object, this object might think that it is not changed // another workaround for AcrobatReader7.0.8 object, this object might think that it is not changed
// when it has been created from file, although it must be saved // when it has been created from file, although it must be saved
m_bWorkaroundActive = sal_True; m_bWorkaroundActive = true;
} }
hr = m_pNativeImpl->m_pIStorage->Commit( STGC_DEFAULT ); hr = m_pNativeImpl->m_pIStorage->Commit( STGC_DEFAULT );
if ( FAILED( hr ) ) if ( FAILED( hr ) )
throw io::IOException(); // TODO throw io::IOException(); // TODO
hr = pPersistStorage->SaveCompleted( NULL ); hr = pPersistStorage->SaveCompleted( nullptr );
if ( FAILED( hr ) && hr != E_UNEXPECTED ) if ( FAILED( hr ) && hr != E_UNEXPECTED )
throw io::IOException(); // TODO throw io::IOException(); // TODO
@@ -1346,10 +1317,10 @@ void OleComponent::StoreOwnTmpIfNecessary()
} }
sal_Bool OleComponent::SaveObject_Impl() bool OleComponent::SaveObject_Impl()
{ {
sal_Bool bResult = sal_False; bool bResult = false;
OleEmbeddedObject* pLockObject = NULL; OleEmbeddedObject* pLockObject = nullptr;
{ {
osl::MutexGuard aGuard( m_aMutex ); osl::MutexGuard aGuard( m_aMutex );
@@ -1370,10 +1341,10 @@ sal_Bool OleComponent::SaveObject_Impl()
} }
sal_Bool OleComponent::OnShowWindow_Impl( bool bShow ) bool OleComponent::OnShowWindow_Impl( bool bShow )
{ {
sal_Bool bResult = sal_False; bool bResult = false;
OleEmbeddedObject* pLockObject = NULL; OleEmbeddedObject* pLockObject = nullptr;
{ {
osl::MutexGuard aGuard( m_aMutex ); osl::MutexGuard aGuard( m_aMutex );
@@ -1452,14 +1423,14 @@ void SAL_CALL OleComponent::close( sal_Bool bDeliverOwnership )
{ {
::cppu::OInterfaceContainerHelper* pContainer = ::cppu::OInterfaceContainerHelper* pContainer =
m_pInterfaceContainer->getContainer( cppu::UnoType<util::XCloseListener>::get()); m_pInterfaceContainer->getContainer( cppu::UnoType<util::XCloseListener>::get());
if ( pContainer != NULL ) if ( pContainer != nullptr )
{ {
::cppu::OInterfaceIteratorHelper pIterator( *pContainer ); ::cppu::OInterfaceIteratorHelper pIterator( *pContainer );
while ( pIterator.hasMoreElements() ) while ( pIterator.hasMoreElements() )
{ {
try try
{ {
( (util::XCloseListener* )pIterator.next() )->queryClosing( aSource, bDeliverOwnership ); static_cast<util::XCloseListener*>( pIterator.next() )->queryClosing( aSource, bDeliverOwnership );
} }
catch( const uno::RuntimeException& ) catch( const uno::RuntimeException& )
{ {
@@ -1470,14 +1441,14 @@ void SAL_CALL OleComponent::close( sal_Bool bDeliverOwnership )
pContainer = m_pInterfaceContainer->getContainer( pContainer = m_pInterfaceContainer->getContainer(
cppu::UnoType<util::XCloseListener>::get()); cppu::UnoType<util::XCloseListener>::get());
if ( pContainer != NULL ) if ( pContainer != nullptr )
{ {
::cppu::OInterfaceIteratorHelper pCloseIterator( *pContainer ); ::cppu::OInterfaceIteratorHelper pCloseIterator( *pContainer );
while ( pCloseIterator.hasMoreElements() ) while ( pCloseIterator.hasMoreElements() )
{ {
try try
{ {
( (util::XCloseListener* )pCloseIterator.next() )->notifyClosing( aSource ); static_cast<util::XCloseListener*>( pCloseIterator.next() )->notifyClosing( aSource );
} }
catch( const uno::RuntimeException& ) catch( const uno::RuntimeException& )
{ {
@@ -1532,7 +1503,7 @@ uno::Any SAL_CALL OleComponent::getTransferData( const datatransfer::DataFlavor&
throw embed::WrongStateException(); // TODO: the object is in wrong state throw embed::WrongStateException(); // TODO: the object is in wrong state
uno::Any aResult; uno::Any aResult;
sal_Bool bSupportedFlavor = sal_False; bool bSupportedFlavor = false;
if ( m_pNativeImpl->GraphicalFlavor( aFlavor ) ) if ( m_pNativeImpl->GraphicalFlavor( aFlavor ) )
{ {
@@ -1540,7 +1511,7 @@ uno::Any SAL_CALL OleComponent::getTransferData( const datatransfer::DataFlavor&
// if own icon is set and icon aspect is requested the own icon can be returned directly // if own icon is set and icon aspect is requested the own icon can be returned directly
ComSmart< IDataObject > pDataObject; ComSmart< IDataObject > pDataObject;
HRESULT hr = m_pNativeImpl->m_pObj->QueryInterface( IID_IDataObject, (void**)&pDataObject ); HRESULT hr = m_pNativeImpl->m_pObj->QueryInterface( IID_IDataObject, reinterpret_cast<void**>(&pDataObject) );
if ( FAILED( hr ) || !pDataObject ) if ( FAILED( hr ) || !pDataObject )
throw io::IOException(); // TODO: transport error code throw io::IOException(); // TODO: transport error code
@@ -1591,7 +1562,7 @@ uno::Any SAL_CALL OleComponent::getTransferData( const datatransfer::DataFlavor&
&& aFlavor.MimeType == "application/x-openoffice-contentstream" ) && aFlavor.MimeType == "application/x-openoffice-contentstream" )
{ {
// allow to retrieve stream-representation of the object persistence // allow to retrieve stream-representation of the object persistence
bSupportedFlavor = sal_True; bSupportedFlavor = true;
uno::Reference < io::XStream > xTempFileStream( uno::Reference < io::XStream > xTempFileStream(
io::TempFile::create(comphelper::getComponentContext(m_xFactory)), io::TempFile::create(comphelper::getComponentContext(m_xFactory)),
uno::UNO_QUERY_THROW ); uno::UNO_QUERY_THROW );
@@ -1602,7 +1573,7 @@ uno::Any SAL_CALL OleComponent::getTransferData( const datatransfer::DataFlavor&
{ {
OSL_ENSURE( m_pUnoOleObject, "Unexpected object absence!" ); OSL_ENSURE( m_pUnoOleObject, "Unexpected object absence!" );
if ( !m_pUnoOleObject ) if ( !m_pUnoOleObject )
throw uno::RuntimeException(); throw uno::RuntimeException();
m_pUnoOleObject->StoreObjectToStream( xTempOutStream ); m_pUnoOleObject->StoreObjectToStream( xTempOutStream );
@@ -1655,16 +1626,16 @@ sal_Bool SAL_CALL OleComponent::isDataFlavorSupported( const datatransfer::DataF
for ( sal_Int32 nInd = 0; nInd < m_aDataFlavors.getLength(); nInd++ ) for ( sal_Int32 nInd = 0; nInd < m_aDataFlavors.getLength(); nInd++ )
if ( m_aDataFlavors[nInd].MimeType.equals( aFlavor.MimeType ) && m_aDataFlavors[nInd].DataType == aFlavor.DataType ) if ( m_aDataFlavors[nInd].MimeType.equals( aFlavor.MimeType ) && m_aDataFlavors[nInd].DataType == aFlavor.DataType )
return sal_True; return true;
return sal_False; return false;
} }
void SAL_CALL OleComponent::dispose() throw (css::uno::RuntimeException) void SAL_CALL OleComponent::dispose() throw (css::uno::RuntimeException)
{ {
try try
{ {
close( sal_True ); close( true );
} }
catch ( const uno::Exception& ) catch ( const uno::Exception& )
{ {
@@ -1703,7 +1674,7 @@ sal_Int64 SAL_CALL OleComponent::getSomething( const css::uno::Sequence< sal_Int
{ {
uno::Sequence < sal_Int8 > aCLSID = GetCLSID(); uno::Sequence < sal_Int8 > aCLSID = GetCLSID();
if ( MimeConfigurationHelper::ClassIDsEqual( aIdentifier, aCLSID ) ) if ( MimeConfigurationHelper::ClassIDsEqual( aIdentifier, aCLSID ) )
return (sal_Int64) (IUnknown*) m_pNativeImpl->m_pObj; return reinterpret_cast<sal_Int64>(static_cast<IUnknown*>(m_pNativeImpl->m_pObj));
// compatibility hack for old versions: CLSID was used in wrong order (SvGlobalName order) // compatibility hack for old versions: CLSID was used in wrong order (SvGlobalName order)
sal_Int32 nLength = aIdentifier.getLength(); sal_Int32 nLength = aIdentifier.getLength();
@@ -1720,7 +1691,7 @@ sal_Int64 SAL_CALL OleComponent::getSomething( const css::uno::Sequence< sal_Int
aIdentifier[2] == aCLSID[1] && aIdentifier[2] == aCLSID[1] &&
aIdentifier[1] == aCLSID[2] && aIdentifier[1] == aCLSID[2] &&
aIdentifier[0] == aCLSID[3] ) aIdentifier[0] == aCLSID[3] )
return (sal_Int64) (IUnknown*) m_pNativeImpl->m_pObj; return reinterpret_cast<sal_Int64>(static_cast<IUnknown*>(m_pNativeImpl->m_pObj));
} }
} }
catch ( const uno::Exception& ) catch ( const uno::Exception& )
@@ -1744,15 +1715,15 @@ void SAL_CALL OleComponent::setModified( sal_Bool bModified )
{ {
::cppu::OInterfaceContainerHelper* pContainer = ::cppu::OInterfaceContainerHelper* pContainer =
m_pInterfaceContainer->getContainer( cppu::UnoType<util::XModifyListener>::get()); m_pInterfaceContainer->getContainer( cppu::UnoType<util::XModifyListener>::get());
if ( pContainer != NULL ) if ( pContainer != nullptr )
{ {
::cppu::OInterfaceIteratorHelper pIterator( *pContainer ); ::cppu::OInterfaceIteratorHelper pIterator( *pContainer );
while ( pIterator.hasMoreElements() ) while ( pIterator.hasMoreElements() )
{ {
try try
{ {
lang::EventObject aEvent( (util::XModifiable*) this ); lang::EventObject aEvent( static_cast<util::XModifiable*>(this) );
((util::XModifyListener*)pIterator.next())->modified( aEvent ); static_cast<util::XModifyListener*>(pIterator.next())->modified( aEvent );
} }
catch( const uno::RuntimeException& ) catch( const uno::RuntimeException& )
{ {

View File

@@ -59,8 +59,8 @@ class OleComponent : public ::cppu::WeakImplHelper< css::util::XCloseable, css::
::osl::Mutex m_aMutex; ::osl::Mutex m_aMutex;
::cppu::OMultiTypeInterfaceContainerHelper* m_pInterfaceContainer; ::cppu::OMultiTypeInterfaceContainerHelper* m_pInterfaceContainer;
sal_Bool m_bDisposed; bool m_bDisposed;
sal_Bool m_bModified; bool m_bModified;
OleComponentNative_Impl* m_pNativeImpl; OleComponentNative_Impl* m_pNativeImpl;
OleEmbeddedObject* m_pUnoOleObject; OleEmbeddedObject* m_pUnoOleObject;
@@ -75,13 +75,13 @@ class OleComponent : public ::cppu::WeakImplHelper< css::util::XCloseable, css::
css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory;
sal_Bool m_bOleInitialized; bool m_bOleInitialized;
// specifies whether the workaround for some rare embedded objects is activated ( f.e. AcrobatReader 7.0.8 object ) // specifies whether the workaround for some rare embedded objects is activated ( f.e. AcrobatReader 7.0.8 object )
// such objects report the dirty state wrongly sometimes and do not allow to store them any time // such objects report the dirty state wrongly sometimes and do not allow to store them any time
sal_Bool m_bWorkaroundActive; bool m_bWorkaroundActive;
sal_Bool InitializeObject_Impl(); bool InitializeObject_Impl();
void CreateNewIStorage_Impl(); void CreateNewIStorage_Impl();
void RetrieveObjectDataFlavors_Impl(); void RetrieveObjectDataFlavors_Impl();
@@ -92,7 +92,7 @@ public:
OleComponent( const css::uno::Reference< css::lang::XMultiServiceFactory >& m_xFactory, OleComponent( const css::uno::Reference< css::lang::XMultiServiceFactory >& m_xFactory,
OleEmbeddedObject* pOleObj ); OleEmbeddedObject* pOleObj );
virtual ~OleComponent(); virtual ~OleComponent() override;
OleComponent* createEmbeddedCopyOfLink(); OleComponent* createEmbeddedCopyOfLink();
@@ -102,13 +102,13 @@ public:
const css::awt::Size& aMultiplier, const css::awt::Size& aMultiplier,
const css::awt::Size& aDivisor ); const css::awt::Size& aDivisor );
css::awt::Size CalculateTheRealSize( const css::awt::Size& aContSize, sal_Bool bUpdate ); css::awt::Size CalculateTheRealSize( const css::awt::Size& aContSize, bool bUpdate );
// ==== Initialization ================================================== // ==== Initialization ==================================================
void LoadEmbeddedObject( const OUString& aTempURL ); void LoadEmbeddedObject( const OUString& aTempURL );
void CreateObjectFromClipboard(); void CreateObjectFromClipboard();
void CreateNewEmbeddedObject( const css::uno::Sequence< sal_Int8 >& aSeqCLSID ); void CreateNewEmbeddedObject( const css::uno::Sequence< sal_Int8 >& aSeqCLSID );
void CreateObjectFromData( static void CreateObjectFromData(
const css::uno::Reference< css::datatransfer::XTransferable >& xTransfer ); const css::uno::Reference< css::datatransfer::XTransferable >& xTransfer );
void CreateObjectFromFile( const OUString& aFileName ); void CreateObjectFromFile( const OUString& aFileName );
void CreateLinkFromFile( const OUString& aFileName ); void CreateLinkFromFile( const OUString& aFileName );
@@ -132,40 +132,40 @@ public:
css::uno::Sequence< sal_Int8 > GetCLSID(); css::uno::Sequence< sal_Int8 > GetCLSID();
sal_Bool IsWorkaroundActive() { return m_bWorkaroundActive; } bool IsWorkaroundActive() { return m_bWorkaroundActive; }
sal_Bool IsDirty(); bool IsDirty();
void StoreOwnTmpIfNecessary(); void StoreOwnTmpIfNecessary();
sal_Bool SaveObject_Impl(); bool SaveObject_Impl();
sal_Bool OnShowWindow_Impl( bool bShow ); bool OnShowWindow_Impl( bool bShow );
void OnViewChange_Impl( sal_uInt32 dwAspect ); void OnViewChange_Impl( sal_uInt32 dwAspect );
void OnClose_Impl(); void OnClose_Impl();
// XCloseable // XCloseable
virtual void SAL_CALL close( sal_Bool DeliverOwnership ) throw (css::util::CloseVetoException, css::uno::RuntimeException); virtual void SAL_CALL close( sal_Bool DeliverOwnership ) throw (css::util::CloseVetoException, css::uno::RuntimeException) override;
virtual void SAL_CALL addCloseListener( const css::uno::Reference< css::util::XCloseListener >& Listener ) throw (css::uno::RuntimeException); virtual void SAL_CALL addCloseListener( const css::uno::Reference< css::util::XCloseListener >& Listener ) throw (css::uno::RuntimeException) override;
virtual void SAL_CALL removeCloseListener( const css::uno::Reference< css::util::XCloseListener >& Listener ) throw (css::uno::RuntimeException); virtual void SAL_CALL removeCloseListener( const css::uno::Reference< css::util::XCloseListener >& Listener ) throw (css::uno::RuntimeException) override;
// XTransferable // XTransferable
virtual css::uno::Any SAL_CALL getTransferData( const css::datatransfer::DataFlavor& aFlavor ) throw (css::datatransfer::UnsupportedFlavorException, css::io::IOException, css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getTransferData( const css::datatransfer::DataFlavor& aFlavor ) throw (css::datatransfer::UnsupportedFlavorException, css::io::IOException, css::uno::RuntimeException) override;
virtual css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( ) throw (css::uno::RuntimeException); virtual css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( ) throw (css::uno::RuntimeException) override;
virtual sal_Bool SAL_CALL isDataFlavorSupported( const css::datatransfer::DataFlavor& aFlavor ) throw (css::uno::RuntimeException); virtual sal_Bool SAL_CALL isDataFlavorSupported( const css::datatransfer::DataFlavor& aFlavor ) throw (css::uno::RuntimeException) override;
// XComponent // XComponent
virtual void SAL_CALL dispose() throw (css::uno::RuntimeException); virtual void SAL_CALL dispose() throw (css::uno::RuntimeException) override;
virtual void SAL_CALL addEventListener(const css::uno::Reference < css::lang::XEventListener >& aListener) throw (css::uno::RuntimeException); virtual void SAL_CALL addEventListener(const css::uno::Reference < css::lang::XEventListener >& aListener) throw (css::uno::RuntimeException) override;
virtual void SAL_CALL removeEventListener(const css::uno::Reference < css::lang::XEventListener >& aListener) throw (css::uno::RuntimeException); virtual void SAL_CALL removeEventListener(const css::uno::Reference < css::lang::XEventListener >& aListener) throw (css::uno::RuntimeException) override;
// XUnoTunnel // XUnoTunnel
virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) throw(css::uno::RuntimeException) ; virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) throw(css::uno::RuntimeException) override;
// XModifiable // XModifiable
virtual sal_Bool SAL_CALL isModified() throw (css::uno::RuntimeException); virtual sal_Bool SAL_CALL isModified() throw (css::uno::RuntimeException) override;
virtual void SAL_CALL setModified( sal_Bool bModified ) virtual void SAL_CALL setModified( sal_Bool bModified )
throw (css::beans::PropertyVetoException, css::uno::RuntimeException); throw (css::beans::PropertyVetoException, css::uno::RuntimeException) override;
virtual void SAL_CALL addModifyListener( const css::uno::Reference < css::util::XModifyListener >& xListener ) throw(css::uno::RuntimeException); virtual void SAL_CALL addModifyListener( const css::uno::Reference < css::util::XModifyListener >& xListener ) throw(css::uno::RuntimeException) override;
virtual void SAL_CALL removeModifyListener( const css::uno::Reference < css::util::XModifyListener >& xListener) throw(css::uno::RuntimeException); virtual void SAL_CALL removeModifyListener( const css::uno::Reference < css::util::XModifyListener >& xListener) throw(css::uno::RuntimeException) override;
}; };
#endif #endif

View File

@@ -484,7 +484,7 @@ void SAL_CALL OleEmbeddedObject::changeState( sal_Int32 nNewState )
sal_Int32 nOldState = m_nObjectState; sal_Int32 nOldState = m_nObjectState;
aGuard.clear(); aGuard.clear();
StateChangeNotification_Impl( sal_True, nOldState, nNewState ); StateChangeNotification_Impl( true, nOldState, nNewState );
aGuard.reset(); aGuard.reset();
try try
@@ -506,7 +506,7 @@ void SAL_CALL OleEmbeddedObject::changeState( sal_Int32 nNewState )
} }
aGuard.clear(); aGuard.clear();
StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState ); StateChangeNotification_Impl( false, nOldState, m_nObjectState );
aGuard.reset(); aGuard.reset();
} }
else if ( nNewState == embed::EmbedStates::RUNNING || nNewState == embed::EmbedStates::ACTIVE ) else if ( nNewState == embed::EmbedStates::RUNNING || nNewState == embed::EmbedStates::ACTIVE )
@@ -523,7 +523,7 @@ void SAL_CALL OleEmbeddedObject::changeState( sal_Int32 nNewState )
SwitchComponentToRunningState_Impl(); SwitchComponentToRunningState_Impl();
m_nObjectState = embed::EmbedStates::RUNNING; m_nObjectState = embed::EmbedStates::RUNNING;
aGuard.clear(); aGuard.clear();
StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState ); StateChangeNotification_Impl( false, nOldState, m_nObjectState );
aGuard.reset(); aGuard.reset();
if ( m_pOleComponent && m_bHasSizeToSet ) if ( m_pOleComponent && m_bHasSizeToSet )
@@ -531,7 +531,7 @@ void SAL_CALL OleEmbeddedObject::changeState( sal_Int32 nNewState )
aGuard.clear(); aGuard.clear();
try { try {
m_pOleComponent->SetExtent( m_aSizeToSet, m_nAspectToSet ); m_pOleComponent->SetExtent( m_aSizeToSet, m_nAspectToSet );
m_bHasSizeToSet = sal_False; m_bHasSizeToSet = false;
} }
catch( const uno::Exception& ) {} catch( const uno::Exception& ) {}
aGuard.reset(); aGuard.reset();
@@ -556,7 +556,7 @@ void SAL_CALL OleEmbeddedObject::changeState( sal_Int32 nNewState )
aGuard.clear(); aGuard.clear();
try { try {
m_pOleComponent->SetExtent( m_aSizeToSet, m_nAspectToSet ); m_pOleComponent->SetExtent( m_aSizeToSet, m_nAspectToSet );
m_bHasSizeToSet = sal_False; m_bHasSizeToSet = false;
} }
catch( uno::Exception& ) {} catch( uno::Exception& ) {}
aGuard.reset(); aGuard.reset();
@@ -583,7 +583,7 @@ void SAL_CALL OleEmbeddedObject::changeState( sal_Int32 nNewState )
catch( uno::Exception& ) catch( uno::Exception& )
{ {
aGuard.clear(); aGuard.clear();
StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState ); StateChangeNotification_Impl( false, nOldState, m_nObjectState );
throw; throw;
} }
} }
@@ -803,7 +803,7 @@ void SAL_CALL OleEmbeddedObject::doVerb( sal_Int32 nVerbID )
m_pOleComponent->ExecuteVerb( nVerbID ); m_pOleComponent->ExecuteVerb( nVerbID );
// ==== the STAMPIT related solution ============================= // ==== the STAMPIT related solution =============================
sal_Bool bModifiedOnExecution = m_aVerbExecutionController.EndControlExecution_WasModified(); bool bModifiedOnExecution = m_aVerbExecutionController.EndControlExecution_WasModified();
// this workaround is implemented for STAMPIT object // this workaround is implemented for STAMPIT object
// if object was modified during verb execution it is saved here // if object was modified during verb execution it is saved here
@@ -818,7 +818,7 @@ void SAL_CALL OleEmbeddedObject::doVerb( sal_Int32 nVerbID )
aGuard.clear(); aGuard.clear();
StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState ); StateChangeNotification_Impl( false, nOldState, m_nObjectState );
throw; throw;
} }
@@ -1081,7 +1081,7 @@ sal_Int64 SAL_CALL OleEmbeddedObject::getStatus( sal_Int64
m_nStatus = m_pOleComponent->GetMiscStatus( nAspect ); m_nStatus = m_pOleComponent->GetMiscStatus( nAspect );
m_nStatusAspect = nAspect; m_nStatusAspect = nAspect;
m_bGotStatus = sal_True; m_bGotStatus = true;
nResult = m_nStatus; nResult = m_nStatus;
} }
#endif #endif

View File

@@ -108,31 +108,31 @@ OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< lang::XMultiServiceF
// this constructor let object be initialized from clipboard // this constructor let object be initialized from clipboard
OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< lang::XMultiServiceFactory >& xFactory ) OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< lang::XMultiServiceFactory >& xFactory )
: m_pOleComponent( NULL ) : m_pOleComponent( nullptr )
, m_pInterfaceContainer( NULL ) , m_pInterfaceContainer( nullptr )
, m_bReadOnly( sal_False ) , m_bReadOnly( false )
, m_bDisposed( false ) , m_bDisposed( false )
, m_nObjectState( -1 ) , m_nObjectState( -1 )
, m_nTargetState( -1 ) , m_nTargetState( -1 )
, m_nUpdateMode( embed::EmbedUpdateModes::ALWAYS_UPDATE ) , m_nUpdateMode( embed::EmbedUpdateModes::ALWAYS_UPDATE )
, m_xFactory( xFactory ) , m_xFactory( xFactory )
, m_bWaitSaveCompleted( sal_False ) , m_bWaitSaveCompleted( false )
, m_bNewVisReplInStream( sal_True ) , m_bNewVisReplInStream( true )
, m_bStoreLoaded( sal_False ) , m_bStoreLoaded( false )
, m_bVisReplInitialized( sal_False ) , m_bVisReplInitialized( false )
, m_bVisReplInStream( sal_False ) , m_bVisReplInStream( false )
, m_bStoreVisRepl( sal_False ) , m_bStoreVisRepl( false )
, m_bIsLink( sal_False ) , m_bIsLink( false )
, m_bHasCachedSize( sal_False ) , m_bHasCachedSize( false )
, m_nCachedAspect( 0 ) , m_nCachedAspect( 0 )
, m_bHasSizeToSet( sal_False ) , m_bHasSizeToSet( false )
, m_nAspectToSet( 0 ) , m_nAspectToSet( 0 )
, m_bGotStatus( sal_False ) , m_bGotStatus( false )
, m_nStatus( 0 ) , m_nStatus( 0 )
, m_nStatusAspect( 0 ) , m_nStatusAspect( 0 )
, m_pOwnView( NULL ) , m_pOwnView( nullptr )
, m_bFromClipboard( sal_True ) , m_bFromClipboard( true )
, m_bTriedConversion( sal_False ) , m_bTriedConversion( false )
{ {
} }
#endif #endif
@@ -185,13 +185,13 @@ void OleEmbeddedObject::MakeEventListenerNotification_Impl( const OUString& aEve
} }
#ifdef _WIN32 #ifdef _WIN32
void OleEmbeddedObject::StateChangeNotification_Impl( sal_Bool bBeforeChange, sal_Int32 nOldState, sal_Int32 nNewState ) void OleEmbeddedObject::StateChangeNotification_Impl( bool bBeforeChange, sal_Int32 nOldState, sal_Int32 nNewState )
{ {
if ( m_pInterfaceContainer ) if ( m_pInterfaceContainer )
{ {
::cppu::OInterfaceContainerHelper* pContainer = m_pInterfaceContainer->getContainer( ::cppu::OInterfaceContainerHelper* pContainer = m_pInterfaceContainer->getContainer(
cppu::UnoType<embed::XStateChangeListener>::get()); cppu::UnoType<embed::XStateChangeListener>::get());
if ( pContainer != NULL ) if ( pContainer != nullptr )
{ {
lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) ); lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) );
::cppu::OInterfaceIteratorHelper pIterator(*pContainer); ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
@@ -202,7 +202,7 @@ void OleEmbeddedObject::StateChangeNotification_Impl( sal_Bool bBeforeChange, sa
{ {
try try
{ {
((embed::XStateChangeListener*)pIterator.next())->changingState( aSource, nOldState, nNewState ); static_cast<embed::XStateChangeListener*>(pIterator.next())->changingState( aSource, nOldState, nNewState );
} }
catch( const uno::Exception& ) catch( const uno::Exception& )
{ {
@@ -213,7 +213,7 @@ void OleEmbeddedObject::StateChangeNotification_Impl( sal_Bool bBeforeChange, sa
{ {
try try
{ {
((embed::XStateChangeListener*)pIterator.next())->stateChanged( aSource, nOldState, nNewState ); static_cast<embed::XStateChangeListener*>(pIterator.next())->stateChanged( aSource, nOldState, nNewState );
} }
catch( const uno::Exception& ) catch( const uno::Exception& )
{ {
@@ -237,7 +237,7 @@ void OleEmbeddedObject::GetRidOfComponent()
m_pOleComponent->removeCloseListener( m_xClosePreventer ); m_pOleComponent->removeCloseListener( m_xClosePreventer );
try try
{ {
m_pOleComponent->close( sal_False ); m_pOleComponent->close( false );
} }
catch( const uno::Exception& ) catch( const uno::Exception& )
{ {
@@ -249,7 +249,7 @@ void OleEmbeddedObject::GetRidOfComponent()
m_pOleComponent->disconnectEmbeddedObject(); m_pOleComponent->disconnectEmbeddedObject();
m_pOleComponent->release(); m_pOleComponent->release();
m_pOleComponent = NULL; m_pOleComponent = nullptr;
} }
#endif #endif
} }
@@ -386,7 +386,7 @@ uno::Reference< util::XCloseable > SAL_CALL OleEmbeddedObject::getComponent()
} }
#if defined(_WIN32) #if defined(_WIN32)
if (m_pOleComponent != 0) if (m_pOleComponent != nullptr)
{ {
return uno::Reference< util::XCloseable >( static_cast< ::cppu::OWeakObject* >( m_pOleComponent ), uno::UNO_QUERY ); return uno::Reference< util::XCloseable >( static_cast< ::cppu::OWeakObject* >( m_pOleComponent ), uno::UNO_QUERY );
} }

View File

@@ -169,7 +169,7 @@ OUString GetNewFilledTempFile_Impl( const uno::Reference< embed::XOptimizedStora
xParentStorage->copyStreamElementData( aEntryName, xTempStream ); xParentStorage->copyStreamElementData( aEntryName, xTempStream );
xTempFile->setPropertyValue("RemoveFile", uno::makeAny( sal_False ) ); xTempFile->setPropertyValue("RemoveFile", uno::makeAny( false ) );
uno::Any aUrl = xTempFile->getPropertyValue("Uri"); uno::Any aUrl = xTempFile->getPropertyValue("Uri");
aUrl >>= aResult; aUrl >>= aResult;
} }
@@ -216,22 +216,22 @@ void VerbExecutionController::StartControlExecution()
// the class is used to detect STAMPIT object, that can never be active // the class is used to detect STAMPIT object, that can never be active
if ( !m_bVerbExecutionInProgress && !m_bWasEverActive ) if ( !m_bVerbExecutionInProgress && !m_bWasEverActive )
{ {
m_bVerbExecutionInProgress = sal_True; m_bVerbExecutionInProgress = true;
m_nVerbExecutionThreadIdentifier = osl::Thread::getCurrentIdentifier(); m_nVerbExecutionThreadIdentifier = osl::Thread::getCurrentIdentifier();
m_bChangedOnVerbExecution = sal_False; m_bChangedOnVerbExecution = false;
} }
} }
sal_Bool VerbExecutionController::EndControlExecution_WasModified() bool VerbExecutionController::EndControlExecution_WasModified()
{ {
osl::MutexGuard aGuard( m_aVerbExecutionMutex ); osl::MutexGuard aGuard( m_aVerbExecutionMutex );
sal_Bool bResult = sal_False; bool bResult = false;
if ( m_bVerbExecutionInProgress && m_nVerbExecutionThreadIdentifier == osl::Thread::getCurrentIdentifier() ) if ( m_bVerbExecutionInProgress && m_nVerbExecutionThreadIdentifier == osl::Thread::getCurrentIdentifier() )
{ {
bResult = m_bChangedOnVerbExecution; bResult = m_bChangedOnVerbExecution;
m_bVerbExecutionInProgress = sal_False; m_bVerbExecutionInProgress = false;
} }
return bResult; return bResult;
@@ -243,7 +243,7 @@ void VerbExecutionController::ModificationNotificationIsDone()
osl::MutexGuard aGuard( m_aVerbExecutionMutex ); osl::MutexGuard aGuard( m_aVerbExecutionMutex );
if ( m_bVerbExecutionInProgress && osl::Thread::getCurrentIdentifier() == m_nVerbExecutionThreadIdentifier ) if ( m_bVerbExecutionInProgress && osl::Thread::getCurrentIdentifier() == m_nVerbExecutionThreadIdentifier )
m_bChangedOnVerbExecution = sal_True; m_bChangedOnVerbExecution = true;
} }
#endif #endif
@@ -736,7 +736,7 @@ uno::Reference< io::XStream > OleEmbeddedObject::TryToRetrieveCachedVisualRepres
try try
{ {
CreateOleComponentAndLoad_Impl( NULL ); CreateOleComponentAndLoad_Impl();
m_aClassID = m_pOleComponent->GetCLSID(); // was not set during consruction m_aClassID = m_pOleComponent->GetCLSID(); // was not set during consruction
} }
catch( const uno::Exception& ) catch( const uno::Exception& )
@@ -803,16 +803,16 @@ void OleEmbeddedObject::SwitchOwnPersistence( const uno::Reference< embed::XStor
#ifdef _WIN32 #ifdef _WIN32
sal_Bool OleEmbeddedObject::SaveObject_Impl() bool OleEmbeddedObject::SaveObject_Impl()
{ {
sal_Bool bResult = sal_False; bool bResult = false;
if ( m_xClientSite.is() ) if ( m_xClientSite.is() )
{ {
try try
{ {
m_xClientSite->saveObject(); m_xClientSite->saveObject();
bResult = sal_True; bResult = true;
} }
catch( const uno::Exception& ) catch( const uno::Exception& )
{ {
@@ -823,16 +823,16 @@ sal_Bool OleEmbeddedObject::SaveObject_Impl()
} }
sal_Bool OleEmbeddedObject::OnShowWindow_Impl( sal_Bool bShow ) bool OleEmbeddedObject::OnShowWindow_Impl( bool bShow )
{ {
::osl::ResettableMutexGuard aGuard( m_aMutex ); ::osl::ResettableMutexGuard aGuard( m_aMutex );
sal_Bool bResult = sal_False; bool bResult = false;
SAL_WARN_IF( m_nObjectState == -1, "embeddedobj.ole", "The object has no persistence!" ); SAL_WARN_IF( m_nObjectState == -1, "embeddedobj.ole", "The object has no persistence!" );
SAL_WARN_IF( m_nObjectState == embed::EmbedStates::LOADED, "embeddedobj.ole", "The object get OnShowWindow in loaded state!" ); SAL_WARN_IF( m_nObjectState == embed::EmbedStates::LOADED, "embeddedobj.ole", "The object get OnShowWindow in loaded state!" );
if ( m_nObjectState == -1 || m_nObjectState == embed::EmbedStates::LOADED ) if ( m_nObjectState == -1 || m_nObjectState == embed::EmbedStates::LOADED )
return sal_False; return false;
// the object is either activated or deactivated // the object is either activated or deactivated
sal_Int32 nOldState = m_nObjectState; sal_Int32 nOldState = m_nObjectState;
@@ -842,13 +842,13 @@ sal_Bool OleEmbeddedObject::OnShowWindow_Impl( sal_Bool bShow )
m_aVerbExecutionController.ObjectIsActive(); m_aVerbExecutionController.ObjectIsActive();
aGuard.clear(); aGuard.clear();
StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState ); StateChangeNotification_Impl( false, nOldState, m_nObjectState );
} }
else if ( !bShow && m_nObjectState == embed::EmbedStates::ACTIVE ) else if ( !bShow && m_nObjectState == embed::EmbedStates::ACTIVE )
{ {
m_nObjectState = embed::EmbedStates::RUNNING; m_nObjectState = embed::EmbedStates::RUNNING;
aGuard.clear(); aGuard.clear();
StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState ); StateChangeNotification_Impl( false, nOldState, m_nObjectState );
} }
if ( m_xClientSite.is() ) if ( m_xClientSite.is() )
@@ -856,7 +856,7 @@ sal_Bool OleEmbeddedObject::OnShowWindow_Impl( sal_Bool bShow )
try try
{ {
m_xClientSite->visibilityChanged( bShow ); m_xClientSite->visibilityChanged( bShow );
bResult = sal_True; bResult = true;
} }
catch( const uno::Exception& ) catch( const uno::Exception& )
{ {
@@ -899,7 +899,7 @@ void OleEmbeddedObject::OnViewChanged_Impl()
// The view is changed while the object is in running state, save the new object // The view is changed while the object is in running state, save the new object
m_xCachedVisualRepresentation.clear(); m_xCachedVisualRepresentation.clear();
SaveObject_Impl(); SaveObject_Impl();
MakeEventListenerNotification_Impl( OUString( "OnVisAreaChanged" ) ); MakeEventListenerNotification_Impl( "OnVisAreaChanged" );
} }
} }
@@ -914,7 +914,7 @@ void OleEmbeddedObject::OnClosed_Impl()
{ {
sal_Int32 nOldState = m_nObjectState; sal_Int32 nOldState = m_nObjectState;
m_nObjectState = embed::EmbedStates::LOADED; m_nObjectState = embed::EmbedStates::LOADED;
StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState ); StateChangeNotification_Impl( false, nOldState, m_nObjectState );
} }
} }
@@ -1027,7 +1027,7 @@ uno::Reference< io::XOutputStream > OleEmbeddedObject::GetStreamForSaving()
} }
void OleEmbeddedObject::StoreObjectToStream( uno::Reference< io::XOutputStream > xOutStream ) void OleEmbeddedObject::StoreObjectToStream( uno::Reference< io::XOutputStream > const & xOutStream )
throw ( uno::Exception ) throw ( uno::Exception )
{ {
// this method should be used only on windows // this method should be used only on windows
@@ -1167,13 +1167,13 @@ void OleEmbeddedObject::StoreToLocation_Impl(
if ( !xTargetStream.is() ) if ( !xTargetStream.is() )
throw io::IOException(); //TODO: access denied throw io::IOException(); //TODO: access denied
SetStreamMediaType_Impl( xTargetStream, OUString( "application/vnd.sun.star.oleobject" )); SetStreamMediaType_Impl( xTargetStream, "application/vnd.sun.star.oleobject" );
uno::Reference< io::XOutputStream > xOutStream = xTargetStream->getOutputStream(); uno::Reference< io::XOutputStream > xOutStream = xTargetStream->getOutputStream();
if ( !xOutStream.is() ) if ( !xOutStream.is() )
throw io::IOException(); //TODO: access denied throw io::IOException(); //TODO: access denied
StoreObjectToStream( xOutStream ); StoreObjectToStream( xOutStream );
bVisReplIsStored = sal_True; bVisReplIsStored = true;
if ( bSaveAs ) if ( bSaveAs )
{ {
@@ -1188,7 +1188,7 @@ void OleEmbeddedObject::StoreToLocation_Impl(
if ( xTmpCVRepresentation.is() ) if ( xTmpCVRepresentation.is() )
{ {
xCachedVisualRepresentation = xTmpCVRepresentation; xCachedVisualRepresentation = xTmpCVRepresentation;
bNeedLocalCache = sal_False; bNeedLocalCache = false;
} }
} }
} }
@@ -1375,7 +1375,7 @@ void SAL_CALL OleEmbeddedObject::setPersistentEntry(
{ {
// the object should be initialized from clipboard // the object should be initialized from clipboard
// inpossibility to initialize the object means error here // inpossibility to initialize the object means error here
CreateOleComponentFromClipboard_Impl( NULL ); CreateOleComponentFromClipboard_Impl();
m_aClassID = m_pOleComponent->GetCLSID(); // was not set during consruction m_aClassID = m_pOleComponent->GetCLSID(); // was not set during consruction
m_pOleComponent->RunObject(); m_pOleComponent->RunObject();
m_nObjectState = embed::EmbedStates::RUNNING; m_nObjectState = embed::EmbedStates::RUNNING;
@@ -1387,7 +1387,7 @@ void SAL_CALL OleEmbeddedObject::setPersistentEntry(
// will be detected by olecomponent // will be detected by olecomponent
try try
{ {
CreateOleComponentAndLoad_Impl( NULL ); CreateOleComponentAndLoad_Impl();
m_aClassID = m_pOleComponent->GetCLSID(); // was not set during consruction m_aClassID = m_pOleComponent->GetCLSID(); // was not set during consruction
} }
catch( const uno::Exception& ) catch( const uno::Exception& )
@@ -1759,14 +1759,14 @@ void SAL_CALL OleEmbeddedObject::storeOwn()
#ifdef _WIN32 #ifdef _WIN32
if ( m_nObjectState != embed::EmbedStates::LOADED && m_pOleComponent && m_pOleComponent->IsDirty() ) if ( m_nObjectState != embed::EmbedStates::LOADED && m_pOleComponent && m_pOleComponent->IsDirty() )
{ {
bStoreLoaded = sal_False; bStoreLoaded = false;
OSL_ENSURE( m_xParentStorage.is() && m_xObjectStream.is(), "The object has no valid persistence!\n" ); OSL_ENSURE( m_xParentStorage.is() && m_xObjectStream.is(), "The object has no valid persistence!\n" );
if ( !m_xObjectStream.is() ) if ( !m_xObjectStream.is() )
throw io::IOException(); //TODO: access denied throw io::IOException(); //TODO: access denied
SetStreamMediaType_Impl( m_xObjectStream, OUString( "application/vnd.sun.star.oleobject" )); SetStreamMediaType_Impl( m_xObjectStream, "application/vnd.sun.star.oleobject" );
uno::Reference< io::XOutputStream > xOutStream = m_xObjectStream->getOutputStream(); uno::Reference< io::XOutputStream > xOutStream = m_xObjectStream->getOutputStream();
if ( !xOutStream.is() ) if ( !xOutStream.is() )
throw io::IOException(); //TODO: access denied throw io::IOException(); //TODO: access denied
@@ -1777,7 +1777,7 @@ void SAL_CALL OleEmbeddedObject::storeOwn()
// the replacement is changed probably, and it must be in the object stream // the replacement is changed probably, and it must be in the object stream
if ( !m_pOleComponent->IsWorkaroundActive() ) if ( !m_pOleComponent->IsWorkaroundActive() )
m_xCachedVisualRepresentation.clear(); m_xCachedVisualRepresentation.clear();
SetVisReplInStream( sal_True ); SetVisReplInStream( true );
} }
#endif #endif
@@ -2015,7 +2015,7 @@ void SAL_CALL OleEmbeddedObject::breakLink( const uno::Reference< embed::XStorag
m_nObjectState = nTargetState; m_nObjectState = nTargetState;
} }
m_bIsLink = sal_False; m_bIsLink = false;
m_aLinkURL.clear(); m_aLinkURL.clear();
} }
else else

View File

@@ -32,6 +32,8 @@ namespace com { namespace sun { namespace star {
namespace lang { class XMultiServiceFactory; } namespace lang { class XMultiServiceFactory; }
} } } } } }
OUString GetNewTempFileURL_Impl( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory );
OUString GetNewFilledTempFile_Impl( OUString GetNewFilledTempFile_Impl(
css::uno::Reference<css::io::XInputStream > const & xInStream, css::uno::Reference<css::io::XInputStream > const & xInStream,
css::uno::Reference<css::lang::XMultiServiceFactory> const & xFactory) css::uno::Reference<css::lang::XMultiServiceFactory> const & xFactory)

View File

@@ -54,7 +54,7 @@ SAL_DLLPUBLIC_EXPORT void * SAL_CALL emboleobj_component_getFactory(
// the following service makes sense only on windows // the following service makes sense only on windows
else if ( aImplName.equals( MSOLEDialogObjectCreator::impl_staticGetImplementationName() ) ) else if ( aImplName.equals( MSOLEDialogObjectCreator::impl_staticGetImplementationName() ) )
{ {
xFactory= ::cppu::createOneInstanceFactory( reinterpret_cast< lang::XMultiServiceFactory*>( pServiceManager ), xFactory= ::cppu::createOneInstanceFactory( static_cast< lang::XMultiServiceFactory*>( pServiceManager ),
MSOLEDialogObjectCreator::impl_staticGetImplementationName(), MSOLEDialogObjectCreator::impl_staticGetImplementationName(),
MSOLEDialogObjectCreator::impl_staticCreateSelfInstance, MSOLEDialogObjectCreator::impl_staticCreateSelfInstance,
MSOLEDialogObjectCreator::impl_staticGetSupportedServiceNames() ); MSOLEDialogObjectCreator::impl_staticGetSupportedServiceNames() );

View File

@@ -112,7 +112,7 @@ void SAL_CALL OleEmbeddedObject::setVisualAreaSize( sal_Int64 nAspect, const awt
// SetExtent() is called only for objects that require it, // SetExtent() is called only for objects that require it,
// it should not be called for MSWord documents to workaround problem i49369 // it should not be called for MSWord documents to workaround problem i49369
// If cached size is not set, that means that this is the size initialization, so there is no need to set the real size // If cached size is not set, that means that this is the size initialization, so there is no need to set the real size
sal_Bool bAllowToSetExtent = bool bAllowToSetExtent =
( ( getStatus( nAspect ) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE ) ( ( getStatus( nAspect ) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE )
&& !MimeConfigurationHelper::ClassIDsEqual(m_aClassID, MimeConfigurationHelper::GetSequenceClassID(MSO_WW8_CLASSID)) && !MimeConfigurationHelper::ClassIDsEqual(m_aClassID, MimeConfigurationHelper::GetSequenceClassID(MSO_WW8_CLASSID))
&& m_bHasCachedSize ); && m_bHasCachedSize );
@@ -136,12 +136,12 @@ void SAL_CALL OleEmbeddedObject::setVisualAreaSize( sal_Int64 nAspect, const awt
aGuard.clear(); aGuard.clear();
try { try {
m_pOleComponent->SetExtent( aSizeToSet, nAspect ); // will throw an exception in case of failure m_pOleComponent->SetExtent( aSizeToSet, nAspect ); // will throw an exception in case of failure
m_bHasSizeToSet = sal_False; m_bHasSizeToSet = false;
} }
catch( const uno::Exception& ) catch( const uno::Exception& )
{ {
// some objects do not allow to set the size even in running state // some objects do not allow to set the size even in running state
m_bHasSizeToSet = sal_True; m_bHasSizeToSet = true;
m_aSizeToSet = aSizeToSet; m_aSizeToSet = aSizeToSet;
m_nAspectToSet = nAspect; m_nAspectToSet = nAspect;
} }
@@ -205,7 +205,7 @@ awt::Size SAL_CALL OleEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect )
bool bBackToLoaded = false; bool bBackToLoaded = false;
sal_Bool bSuccess = sal_False; bool bSuccess = false;
if ( getCurrentState() == embed::EmbedStates::LOADED ) if ( getCurrentState() == embed::EmbedStates::LOADED )
{ {
SAL_WARN( "embeddedobj.ole", "Loaded object has no cached size!" ); SAL_WARN( "embeddedobj.ole", "Loaded object has no cached size!" );
@@ -229,7 +229,7 @@ awt::Size SAL_CALL OleEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect )
{ {
// first try to get size using replacement image // first try to get size using replacement image
aSize = m_pOleComponent->GetExtent( nAspect ); // will throw an exception in case of failure aSize = m_pOleComponent->GetExtent( nAspect ); // will throw an exception in case of failure
bSuccess = sal_True; bSuccess = true;
} }
catch( const uno::Exception& ) catch( const uno::Exception& )
{ {
@@ -255,7 +255,7 @@ awt::Size SAL_CALL OleEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect )
{ {
// second try the cached replacement image // second try the cached replacement image
aSize = m_pOleComponent->GetCachedExtent( nAspect ); // will throw an exception in case of failure aSize = m_pOleComponent->GetCachedExtent( nAspect ); // will throw an exception in case of failure
bSuccess = sal_True; bSuccess = true;
} }
catch( const uno::Exception& ) catch( const uno::Exception& )
{ {
@@ -268,7 +268,7 @@ awt::Size SAL_CALL OleEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect )
{ {
// third try the size reported by the object // third try the size reported by the object
aSize = m_pOleComponent->GetReccomendedExtent( nAspect ); // will throw an exception in case of failure aSize = m_pOleComponent->GetReccomendedExtent( nAspect ); // will throw an exception in case of failure
bSuccess = sal_True; bSuccess = true;
} }
catch( const uno::Exception& ) catch( const uno::Exception& )
{ {
@@ -284,7 +284,7 @@ awt::Size SAL_CALL OleEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect )
m_aCachedSize = aSize; m_aCachedSize = aSize;
m_nCachedAspect = nAspect; m_nCachedAspect = nAspect;
m_bHasCachedSize = sal_True; m_bHasCachedSize = true;
aResult = m_aCachedSize; aResult = m_aCachedSize;
} }

View File

@@ -37,17 +37,17 @@ OleWrapperClientSite::~OleWrapperClientSite()
STDMETHODIMP OleWrapperClientSite::QueryInterface( REFIID riid , void** ppv ) STDMETHODIMP OleWrapperClientSite::QueryInterface( REFIID riid , void** ppv )
{ {
*ppv=NULL; *ppv=nullptr;
if ( riid == IID_IUnknown ) if ( riid == IID_IUnknown )
*ppv = (IUnknown*)this; *ppv = static_cast<IUnknown*>(this);
if ( riid == IID_IOleClientSite ) if ( riid == IID_IOleClientSite )
*ppv = (IOleClientSite*)this; *ppv = static_cast<IOleClientSite*>(this);
if ( *ppv != NULL ) if ( *ppv != nullptr )
{ {
((IUnknown*)*ppv)->AddRef(); static_cast<IUnknown*>(*ppv)->AddRef();
return S_OK; return S_OK;
} }
@@ -72,12 +72,12 @@ void OleWrapperClientSite::disconnectOleComponent()
{ {
// must not be called from the descructor of OleComponent!!! // must not be called from the descructor of OleComponent!!!
osl::MutexGuard aGuard( m_aMutex ); osl::MutexGuard aGuard( m_aMutex );
m_pOleComp = NULL; m_pOleComp = nullptr;
} }
STDMETHODIMP OleWrapperClientSite::SaveObject() STDMETHODIMP OleWrapperClientSite::SaveObject()
{ {
OleComponent* pLockComponent = NULL; OleComponent* pLockComponent = nullptr;
HRESULT hResult = E_FAIL; HRESULT hResult = E_FAIL;
{ {
@@ -102,13 +102,13 @@ STDMETHODIMP OleWrapperClientSite::SaveObject()
STDMETHODIMP OleWrapperClientSite::GetMoniker( DWORD, DWORD, LPMONIKER *ppmk ) STDMETHODIMP OleWrapperClientSite::GetMoniker( DWORD, DWORD, LPMONIKER *ppmk )
{ {
*ppmk = NULL; *ppmk = nullptr;
return E_NOTIMPL; return E_NOTIMPL;
} }
STDMETHODIMP OleWrapperClientSite::GetContainer( LPOLECONTAINER* ppContainer ) STDMETHODIMP OleWrapperClientSite::GetContainer( LPOLECONTAINER* ppContainer )
{ {
*ppContainer = NULL; *ppContainer = nullptr;
return E_NOTIMPL; return E_NOTIMPL;
} }
@@ -119,7 +119,7 @@ STDMETHODIMP OleWrapperClientSite::ShowObject()
STDMETHODIMP OleWrapperClientSite::OnShowWindow( BOOL bShow ) STDMETHODIMP OleWrapperClientSite::OnShowWindow( BOOL bShow )
{ {
OleComponent* pLockComponent = NULL; OleComponent* pLockComponent = nullptr;
// TODO/LATER: redirect the notification to the main thread so that SolarMutex can be locked // TODO/LATER: redirect the notification to the main thread so that SolarMutex can be locked
{ {

View File

@@ -37,16 +37,16 @@ public:
void disconnectOleComponent(); void disconnectOleComponent();
STDMETHODIMP QueryInterface(REFIID, void**); STDMETHODIMP QueryInterface(REFIID, void**) override;
STDMETHODIMP_(ULONG) AddRef(); STDMETHODIMP_(ULONG) AddRef() override;
STDMETHODIMP_(ULONG) Release(); STDMETHODIMP_(ULONG) Release() override;
STDMETHODIMP SaveObject(); STDMETHODIMP SaveObject() override;
STDMETHODIMP GetMoniker(DWORD, DWORD, LPMONIKER *); STDMETHODIMP GetMoniker(DWORD, DWORD, LPMONIKER *) override;
STDMETHODIMP GetContainer(LPOLECONTAINER *); STDMETHODIMP GetContainer(LPOLECONTAINER *) override;
STDMETHODIMP ShowObject(); STDMETHODIMP ShowObject() override;
STDMETHODIMP OnShowWindow(BOOL); STDMETHODIMP OnShowWindow(BOOL) override;
STDMETHODIMP RequestNewObjectLayout(); STDMETHODIMP RequestNewObjectLayout() override;
}; };
#endif #endif

View File

@@ -48,7 +48,7 @@ class InitializedOleGuard
public: public:
InitializedOleGuard() InitializedOleGuard()
{ {
if ( !SUCCEEDED( OleInitialize( NULL ) ) ) if ( !SUCCEEDED( OleInitialize( nullptr ) ) )
throw css::uno::RuntimeException(); throw css::uno::RuntimeException();
} }
@@ -169,11 +169,11 @@ embed::InsertedObjectInfo SAL_CALL MSOLEDialogObjectCreator::createInstanceByDia
::osl::Module aOleDlgLib; ::osl::Module aOleDlgLib;
if( !aOleDlgLib.load( OUString( "oledlg" ) )) if( !aOleDlgLib.load( "oledlg" ))
throw uno::RuntimeException(); throw uno::RuntimeException();
OleUIInsertObjectA_Type * pInsertFct = (OleUIInsertObjectA_Type *) OleUIInsertObjectA_Type * pInsertFct = reinterpret_cast<OleUIInsertObjectA_Type *>(
aOleDlgLib.getSymbol( OUString( "OleUIInsertObjectA" )); aOleDlgLib.getSymbol( "OleUIInsertObjectA" ));
if( !pInsertFct ) if( !pInsertFct )
throw uno::RuntimeException(); throw uno::RuntimeException();
@@ -231,20 +231,20 @@ embed::InsertedObjectInfo SAL_CALL MSOLEDialogObjectCreator::createInstanceByDia
uno::UNO_QUERY ); uno::UNO_QUERY );
} }
if ( ( io.dwFlags & IOF_CHECKDISPLAYASICON) && io.hMetaPict != NULL ) if ( ( io.dwFlags & IOF_CHECKDISPLAYASICON) && io.hMetaPict != nullptr )
{ {
METAFILEPICT* pMF = ( METAFILEPICT* )GlobalLock( io.hMetaPict ); METAFILEPICT* pMF = static_cast<METAFILEPICT*>(GlobalLock( io.hMetaPict ));
if ( pMF ) if ( pMF )
{ {
sal_uInt32 nBufSize = GetMetaFileBitsEx( pMF->hMF, 0, NULL ); sal_uInt32 nBufSize = GetMetaFileBitsEx( pMF->hMF, 0, nullptr );
uno::Sequence< sal_Int8 > aMetafile( nBufSize + 22 ); uno::Sequence< sal_Int8 > aMetafile( nBufSize + 22 );
sal_uInt8* pBuf = (sal_uInt8*)( aMetafile.getArray() ); sal_Int8* pBuf = aMetafile.getArray();
*( (long* )pBuf ) = 0x9ac6cdd7L; *reinterpret_cast<long*>( pBuf ) = 0x9ac6cdd7L;
*( (short* )( pBuf+6 )) = ( SHORT ) 0; *reinterpret_cast<short*>( pBuf+6 ) = ( SHORT ) 0;
*( (short* )( pBuf+8 )) = ( SHORT ) 0; *reinterpret_cast<short*>( pBuf+8 ) = ( SHORT ) 0;
*( (short* )( pBuf+10 )) = ( SHORT ) pMF->xExt; *reinterpret_cast<short*>( pBuf+10 ) = ( SHORT ) pMF->xExt;
*( (short* )( pBuf+12 )) = ( SHORT ) pMF->yExt; *reinterpret_cast<short*>( pBuf+12 ) = ( SHORT ) pMF->yExt;
*( (short* )( pBuf+14 )) = ( USHORT ) 2540; *reinterpret_cast<short*>( pBuf+14 ) = ( USHORT ) 2540;
if ( nBufSize && nBufSize == GetMetaFileBitsEx( pMF->hMF, nBufSize, pBuf+22 ) ) if ( nBufSize && nBufSize == GetMetaFileBitsEx( pMF->hMF, nBufSize, pBuf+22 ) )
{ {

View File

@@ -52,15 +52,15 @@ public:
// XInsertObjectDialog // XInsertObjectDialog
virtual css::embed::InsertedObjectInfo SAL_CALL createInstanceByDialog( const css::uno::Reference< css::embed::XStorage >& xStorage, const OUString& sEntName, const css::uno::Sequence< css::beans::PropertyValue >& lObjArgs ) throw (css::lang::IllegalArgumentException, css::io::IOException, css::uno::Exception, css::uno::RuntimeException); virtual css::embed::InsertedObjectInfo SAL_CALL createInstanceByDialog( const css::uno::Reference< css::embed::XStorage >& xStorage, const OUString& sEntName, const css::uno::Sequence< css::beans::PropertyValue >& lObjArgs ) throw (css::lang::IllegalArgumentException, css::io::IOException, css::uno::Exception, css::uno::RuntimeException) override;
// XEmbedObjectClipboardCreator // XEmbedObjectClipboardCreator
virtual css::embed::InsertedObjectInfo SAL_CALL createInstanceInitFromClipboard( const css::uno::Reference< css::embed::XStorage >& xStorage, const OUString& sEntryName, const css::uno::Sequence< css::beans::PropertyValue >& aObjectArgs ) throw (css::lang::IllegalArgumentException, css::io::IOException, css::uno::Exception, css::uno::RuntimeException); virtual css::embed::InsertedObjectInfo SAL_CALL createInstanceInitFromClipboard( const css::uno::Reference< css::embed::XStorage >& xStorage, const OUString& sEntryName, const css::uno::Sequence< css::beans::PropertyValue >& aObjectArgs ) throw (css::lang::IllegalArgumentException, css::io::IOException, css::uno::Exception, css::uno::RuntimeException) override;
// XServiceInfo // XServiceInfo
virtual OUString SAL_CALL getImplementationName() throw (css::uno::RuntimeException); virtual OUString SAL_CALL getImplementationName() throw (css::uno::RuntimeException) override;
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (css::uno::RuntimeException); virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (css::uno::RuntimeException) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (css::uno::RuntimeException); virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (css::uno::RuntimeException) override;
}; };