diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-10-14 16:56:42 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-10-16 14:19:19 +0000 |
commit | 5eab3e5eec67ad97f39f792852e88003fea89d1c (patch) | |
tree | 464308340f1ba6a803b3173e4a20d2320ae4c3a7 /embeddedobj | |
parent | 3b658759c945a5e2da7b2c6acfdecc9c3d9c6a34 (diff) |
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>
Diffstat (limited to 'embeddedobj')
-rw-r--r-- | embeddedobj/source/inc/oleembobj.hxx | 24 | ||||
-rw-r--r-- | embeddedobj/source/msole/advisesink.cxx | 12 | ||||
-rw-r--r-- | embeddedobj/source/msole/advisesink.hxx | 18 | ||||
-rw-r--r-- | embeddedobj/source/msole/graphconvert.cxx | 17 | ||||
-rw-r--r-- | embeddedobj/source/msole/graphconvert.hxx | 38 | ||||
-rw-r--r-- | embeddedobj/source/msole/mtnotification.hxx | 4 | ||||
-rw-r--r-- | embeddedobj/source/msole/olecomponent.cxx | 315 | ||||
-rw-r--r-- | embeddedobj/source/msole/olecomponent.hxx | 52 | ||||
-rw-r--r-- | embeddedobj/source/msole/oleembed.cxx | 18 | ||||
-rw-r--r-- | embeddedobj/source/msole/olemisc.cxx | 46 | ||||
-rw-r--r-- | embeddedobj/source/msole/olepersist.cxx | 58 | ||||
-rw-r--r-- | embeddedobj/source/msole/olepersist.hxx | 2 | ||||
-rw-r--r-- | embeddedobj/source/msole/oleregister.cxx | 2 | ||||
-rw-r--r-- | embeddedobj/source/msole/olevisual.cxx | 16 | ||||
-rw-r--r-- | embeddedobj/source/msole/olewrapclient.cxx | 20 | ||||
-rw-r--r-- | embeddedobj/source/msole/olewrapclient.hxx | 20 | ||||
-rw-r--r-- | embeddedobj/source/msole/xdialogcreator.cxx | 28 | ||||
-rw-r--r-- | embeddedobj/source/msole/xdialogcreator.hxx | 10 |
18 files changed, 356 insertions, 344 deletions
diff --git a/embeddedobj/source/inc/oleembobj.hxx b/embeddedobj/source/inc/oleembobj.hxx index d30b17cea6bf..4e41552d1a94 100644 --- a/embeddedobj/source/inc/oleembobj.hxx +++ b/embeddedobj/source/inc/oleembobj.hxx @@ -55,7 +55,7 @@ class VerbExecutionController bool m_bWasEverActive; bool m_bVerbExecutionInProgress; oslThreadIdentifier m_nVerbExecutionThreadIdentifier; - sal_Bool m_bChangedOnVerbExecution; + bool m_bChangedOnVerbExecution; #endif public: @@ -66,13 +66,13 @@ public: , m_bWasEverActive( false ) , m_bVerbExecutionInProgress( false ) , m_nVerbExecutionThreadIdentifier( 0 ) - , m_bChangedOnVerbExecution( sal_False ) + , m_bChangedOnVerbExecution( false ) #endif {} #ifdef _WIN32 void StartControlExecution(); - sal_Bool EndControlExecution_WasModified(); + bool EndControlExecution_WasModified(); void ModificationNotificationIsDone(); // no need to lock anything to check the value of the numeric members bool CanDoNotification() { return ( !m_bVerbExecutionInProgress && !m_bWasEverActive && !m_nNotificationLock ); } @@ -211,13 +211,13 @@ protected: #endif void MakeEventListenerNotification_Impl( const OUString& aEventName ); #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::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 ); #endif @@ -241,7 +241,7 @@ protected: bool bSaveAs ) throw ( css::uno::Exception ); #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 ); #endif void InsertVisualCache_Impl( @@ -264,11 +264,11 @@ protected: bool bAllowRepair50 = false ) throw (); #ifdef _WIN32 - sal_Bool SaveObject_Impl(); - sal_Bool OnShowWindow_Impl( sal_Bool bShow ); - void CreateOleComponent_Impl( OleComponent* pOleComponent = NULL ); - void CreateOleComponentAndLoad_Impl( OleComponent* pOleComponent = NULL ); - void CreateOleComponentFromClipboard_Impl( OleComponent* pOleComponent = NULL ); + bool SaveObject_Impl(); + bool OnShowWindow_Impl( bool bShow ); + void CreateOleComponent_Impl( OleComponent* pOleComponent = nullptr ); + void CreateOleComponentAndLoad_Impl( OleComponent* pOleComponent = nullptr ); + void CreateOleComponentFromClipboard_Impl( OleComponent* pOleComponent = nullptr ); OUString CreateTempURLEmpty_Impl(); OUString GetTempURL_Impl(); void SetObjectIsLink_Impl( bool bIsLink ) { m_bIsLink = bIsLink; } @@ -298,7 +298,7 @@ public: virtual ~OleEmbeddedObject() override; #ifdef _WIN32 - void OnIconChanged_Impl(); + static void OnIconChanged_Impl(); void OnViewChanged_Impl(); void OnClosed_Impl(); #endif diff --git a/embeddedobj/source/msole/advisesink.cxx b/embeddedobj/source/msole/advisesink.cxx index f759758ec6f6..fddf462d8963 100644 --- a/embeddedobj/source/msole/advisesink.cxx +++ b/embeddedobj/source/msole/advisesink.cxx @@ -36,17 +36,17 @@ OleWrapperAdviseSink::~OleWrapperAdviseSink() STDMETHODIMP OleWrapperAdviseSink::QueryInterface( REFIID riid , void** ppv ) { - *ppv=NULL; + *ppv=nullptr; if ( riid == IID_IUnknown ) - *ppv = (IUnknown*)this; + *ppv = static_cast<IUnknown*>(this); 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; } @@ -71,7 +71,7 @@ void OleWrapperAdviseSink::disconnectOleComponent() { // must not be called from the descructor of OleComponent!!! osl::MutexGuard aGuard( m_aMutex ); - m_pOleComp = NULL; + m_pOleComp = nullptr; } STDMETHODIMP_(void) OleWrapperAdviseSink::OnDataChange(LPFORMATETC, LPSTGMEDIUM) diff --git a/embeddedobj/source/msole/advisesink.hxx b/embeddedobj/source/msole/advisesink.hxx index bfd5f19b7921..cecdc171ddb5 100644 --- a/embeddedobj/source/msole/advisesink.hxx +++ b/embeddedobj/source/msole/advisesink.hxx @@ -38,15 +38,15 @@ public: virtual ~OleWrapperAdviseSink(); void disconnectOleComponent(); - STDMETHODIMP QueryInterface(REFIID, void**); - STDMETHODIMP_(ULONG) AddRef(); - STDMETHODIMP_(ULONG) Release(); - - STDMETHODIMP_(void) OnDataChange(LPFORMATETC, LPSTGMEDIUM); - STDMETHODIMP_(void) OnViewChange(DWORD, LONG); - STDMETHODIMP_(void) OnRename(LPMONIKER); - STDMETHODIMP_(void) OnSave(); - STDMETHODIMP_(void) OnClose(); + STDMETHODIMP QueryInterface(REFIID, void**) override; + STDMETHODIMP_(ULONG) AddRef() override; + STDMETHODIMP_(ULONG) Release() override; + + STDMETHODIMP_(void) OnDataChange(LPFORMATETC, LPSTGMEDIUM) override; + STDMETHODIMP_(void) OnViewChange(DWORD, LONG) override; + STDMETHODIMP_(void) OnRename(LPMONIKER) override; + STDMETHODIMP_(void) OnSave() override; + STDMETHODIMP_(void) OnClose() override; }; #endif diff --git a/embeddedobj/source/msole/graphconvert.cxx b/embeddedobj/source/msole/graphconvert.cxx index d6c93eb45e28..e7d4848c4823 100644 --- a/embeddedobj/source/msole/graphconvert.cxx +++ b/embeddedobj/source/msole/graphconvert.cxx @@ -34,6 +34,7 @@ #include <tools/stream.hxx> #include <vcl/graphicfilter.hxx> +#include <graphconvert.hxx> #include "mtnotification.hxx" #include "oleembobj.hxx" @@ -41,7 +42,7 @@ using namespace ::com::sun::star; -sal_Bool ConvertBufferToFormat( void* pBuf, +bool ConvertBufferToFormat( void* pBuf, sal_uInt32 nBufSize, const OUString& aMimeType, uno::Any& aResult ) @@ -56,11 +57,11 @@ sal_Bool ConvertBufferToFormat( void* pBuf, if (rFilter.CanImportGraphic(OUString(), aMemoryStream, GRFILTER_FORMAT_DONTKNOW, &nRetFormat) == GRFILTER_OK && rFilter.GetImportFormatMediaType(nRetFormat) == aMimeType) { - aResult <<= uno::Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aMemoryStream.GetData() ), aMemoryStream.Seek( STREAM_SEEK_TO_END ) ); - return sal_True; + aResult <<= uno::Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aMemoryStream.GetData() ), aMemoryStream.Seek( STREAM_SEEK_TO_END ) ); + 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 ); try { @@ -80,15 +81,15 @@ sal_Bool ConvertBufferToFormat( void* pBuf, aOutMediaProperties[1].Value <<= aMimeType; xGraphicProvider->storeGraphic( xGraphic, aOutMediaProperties ); - aResult <<= uno::Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aNewStream.GetData() ), aNewStream.Seek( STREAM_SEEK_TO_END ) ); - return sal_True; + aResult <<= uno::Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aNewStream.GetData() ), aNewStream.Seek( STREAM_SEEK_TO_END ) ); + return true; } } 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 ) m_pObject->OnViewChanged_Impl(); else if ( m_nAspect == embed::Aspects::MSOLE_ICON ) - m_pObject->OnIconChanged_Impl(); + OleEmbeddedObject::OnIconChanged_Impl(); } } catch( const uno::Exception& ) diff --git a/embeddedobj/source/msole/graphconvert.hxx b/embeddedobj/source/msole/graphconvert.hxx new file mode 100644 index 000000000000..b86c8e840ea5 --- /dev/null +++ b/embeddedobj/source/msole/graphconvert.hxx @@ -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: */ diff --git a/embeddedobj/source/msole/mtnotification.hxx b/embeddedobj/source/msole/mtnotification.hxx index 1e797d4f4528..99f4feb7295e 100644 --- a/embeddedobj/source/msole/mtnotification.hxx +++ b/embeddedobj/source/msole/mtnotification.hxx @@ -42,9 +42,9 @@ class MainThreadNotificationRequest : public cppu::WeakImplHelper< css::awt::XC public: 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(); + ~MainThreadNotificationRequest() override; }; #endif diff --git a/embeddedobj/source/msole/olecomponent.cxx b/embeddedobj/source/msole/olecomponent.cxx index 2f59f357ed58..dd06e6c0d7c1 100644 --- a/embeddedobj/source/msole/olecomponent.cxx +++ b/embeddedobj/source/msole/olecomponent.cxx @@ -35,7 +35,9 @@ #include <osl/file.hxx> #include <rtl/ref.hxx> +#include <graphconvert.hxx> #include <olecomponent.hxx> +#include <olepersist.hxx> #include <olewrapclient.hxx> #include <advisesink.hxx> #include <oleembobj.hxx> @@ -59,14 +61,14 @@ template< class T > class ComSmart if ( m_pInterface ) { T* pInterface = m_pInterface; - m_pInterface = NULL; + m_pInterface = nullptr; pInterface->Release(); } } public: ComSmart() - : m_pInterface( NULL ) + : m_pInterface( nullptr ) {} ComSmart( const ComSmart<T>& rObj ) @@ -126,7 +128,7 @@ public: { OwnRelease(); - m_pInterface = NULL; + m_pInterface = nullptr; return &m_pInterface; } @@ -161,19 +163,12 @@ public: // ============ 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; FORMATETC pFormatTemplates[FORMATS_NUM] = { - { CF_ENHMETAFILE, NULL, 0, -1, TYMED_ENHMF }, - { CF_METAFILEPICT, NULL, 0, -1, TYMED_MFPICT }, - { CF_BITMAP, NULL, 0, -1, TYMED_GDI } }; + { CF_ENHMETAFILE, nullptr, 0, -1, TYMED_ENHMF }, + { CF_METAFILEPICT, nullptr, 0, -1, TYMED_MFPICT }, + { CF_BITMAP, nullptr, 0, -1, TYMED_GDI } }; struct OleComponentNative_Impl { @@ -215,15 +210,11 @@ struct OleComponentNative_Impl { cppu::UnoType<uno::Sequence< sal_Int8 >>::get() ); } - void AddSupportedFormat( const FORMATETC& aFormatEtc ); - - FORMATETC* GetSupportedFormatForAspect( sal_uInt32 nRequestedAspect ); - - sal_Bool ConvertDataForFlavor( const STGMEDIUM& aMedium, + bool ConvertDataForFlavor( const STGMEDIUM& aMedium, const datatransfer::DataFlavor& aFlavor, uno::Any& aResult ); - sal_Bool GraphicalFlavor( const datatransfer::DataFlavor& aFlavor ); + bool GraphicalFlavor( const datatransfer::DataFlavor& aFlavor ); 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 return StgOpenStorage( reinterpret_cast<LPCWSTR>(aFilePath.getStr()), - NULL, + nullptr, STGM_READWRITE | STGM_TRANSACTED, // | STGM_DELETEONRELEASE, - NULL, + nullptr, 0, ppIStorage ); } -sal_Bool OleComponentNative_Impl::ConvertDataForFlavor( const STGMEDIUM& aMedium, +bool OleComponentNative_Impl::ConvertDataForFlavor( const STGMEDIUM& aMedium, const datatransfer::DataFlavor& aFlavor, uno::Any& aResult ) { - sal_Bool bAnyIsReady = sal_False; + bool bAnyIsReady = false; // try to convert data from Medium format to specified Flavor format if ( aFlavor.DataType == cppu::UnoType<uno::Sequence< sal_Int8 >>::get() ) { // first the GDI-metafile must be generated - std::unique_ptr<unsigned char[]> pBuf; + std::unique_ptr<sal_Int8[]> pBuf; sal_uInt32 nBufSize = 0; OUString aFormat; if ( aMedium.tymed == TYMED_MFPICT ) // Win Metafile { aFormat = "image/x-wmf"; - METAFILEPICT* pMF = ( METAFILEPICT* )GlobalLock( aMedium.hMetaFilePict ); + METAFILEPICT* pMF = static_cast<METAFILEPICT*>(GlobalLock( aMedium.hMetaFilePict )); if ( pMF ) { - nBufSize = GetMetaFileBitsEx( pMF->hMF, 0, NULL ) + 22; - pBuf.reset(new unsigned char[nBufSize]); + nBufSize = GetMetaFileBitsEx( pMF->hMF, 0, nullptr ) + 22; + pBuf.reset(new sal_Int8[nBufSize]); // TODO/LATER: the unit size must be calculated correctly - *( (long* )pBuf.get() ) = 0x9ac6cdd7L; - *( (short* )( pBuf.get()+6 )) = ( SHORT ) 0; - *( (short* )( pBuf.get()+8 )) = ( SHORT ) 0; - *( (short* )( pBuf.get()+10 )) = ( SHORT ) pMF->xExt; - *( (short* )( pBuf.get()+12 )) = ( SHORT ) pMF->yExt; - *( (short* )( pBuf.get()+14 )) = ( USHORT ) 2540; + *reinterpret_cast<long*>( pBuf.get() ) = 0x9ac6cdd7L; + *reinterpret_cast<short*>( pBuf.get()+6 ) = ( SHORT ) 0; + *reinterpret_cast<short*>( pBuf.get()+8 ) = ( SHORT ) 0; + *reinterpret_cast<short*>( pBuf.get()+10 ) = ( SHORT ) pMF->xExt; + *reinterpret_cast<short*>( pBuf.get()+12 ) = ( SHORT ) pMF->yExt; + *reinterpret_cast<short*>( pBuf.get()+14 ) = ( USHORT ) 2540; if ( nBufSize && nBufSize == GetMetaFileBitsEx( pMF->hMF, nBufSize - 22, pBuf.get() + 22 ) ) { if ( aFlavor.MimeType.matchAsciiL( "application/x-openoffice-wmf;windows_formatname=\"Image WMF\"", 57 ) ) { - aResult <<= uno::Sequence< sal_Int8 >( ( sal_Int8* )pBuf.get(), nBufSize ); - bAnyIsReady = sal_True; + aResult <<= uno::Sequence< sal_Int8 >( pBuf.get(), nBufSize ); + bAnyIsReady = true; } } @@ -325,28 +316,28 @@ sal_Bool OleComponentNative_Impl::ConvertDataForFlavor( const STGMEDIUM& aMedium else if ( aMedium.tymed == TYMED_ENHMF ) // Enh Metafile { aFormat = "image/x-emf"; - nBufSize = GetEnhMetaFileBits( aMedium.hEnhMetaFile, 0, NULL ); - pBuf.reset(new unsigned char[nBufSize]); - if ( nBufSize && nBufSize == GetEnhMetaFileBits( aMedium.hEnhMetaFile, nBufSize, pBuf.get() ) ) + nBufSize = GetEnhMetaFileBits( aMedium.hEnhMetaFile, 0, nullptr ); + pBuf.reset(new sal_Int8[nBufSize]); + 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 ) ) { - aResult <<= uno::Sequence< sal_Int8 >( ( sal_Int8* )pBuf.get(), nBufSize ); - bAnyIsReady = sal_True; + aResult <<= uno::Sequence< sal_Int8 >( pBuf.get(), nBufSize ); + bAnyIsReady = true; } } } else if ( aMedium.tymed == TYMED_GDI ) // Bitmap { aFormat = "image/x-MS-bmp"; - nBufSize = GetBitmapBits( aMedium.hBitmap, 0, NULL ); - pBuf.reset(new unsigned char[nBufSize]); + nBufSize = GetBitmapBits( aMedium.hBitmap, 0, nullptr ); + pBuf.reset(new sal_Int8[nBufSize]); 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 ) ) { - aResult <<= uno::Sequence< sal_Int8 >( ( sal_Int8* )pBuf.get(), nBufSize ); - bAnyIsReady = sal_True; + aResult <<= uno::Sequence< sal_Int8 >( pBuf.get(), nBufSize ); + bAnyIsReady = true; } } } @@ -358,7 +349,7 @@ sal_Bool OleComponentNative_Impl::ConvertDataForFlavor( const STGMEDIUM& aMedium && aFlavor.DataType == m_aSupportedGraphFormats[nInd].DataType && 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; } } @@ -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 for ( sal_Int32 nInd = 0; nInd < m_aSupportedGraphFormats.getLength(); nInd++ ) if ( aFlavor.MimeType.match( m_aSupportedGraphFormats[nInd].MimeType ) && 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 ) { @@ -390,10 +381,10 @@ sal_Bool GetClassIDFromSequence_Impl( uno::Sequence< sal_Int8 > aSeq, CLSID& aRe for( int nInd = 0; nInd < 8; nInd++ ) 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 ) -: m_pInterfaceContainer( NULL ) -, m_bDisposed( sal_False ) -, m_bModified( sal_False ) +: m_pInterfaceContainer( nullptr ) +, m_bDisposed( false ) +, m_bModified( false ) , m_pNativeImpl( new OleComponentNative_Impl() ) , m_pUnoOleObject( pUnoOleObject ) -, m_pOleWrapClientSite( NULL ) -, m_pImplAdviseSink( NULL ) +, m_pOleWrapClientSite( nullptr ) +, m_pImplAdviseSink( nullptr ) , m_nOLEMiscFlags( 0 ) , m_nAdvConn( 0 ) , m_xFactory( xFactory ) -, m_bOleInitialized( sal_False ) -, m_bWorkaroundActive( sal_False ) +, m_bOleInitialized( false ) +, m_bWorkaroundActive( false ) { 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" ); 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_pImplAdviseSink = new OleWrapperAdviseSink( ( OleComponent* )this ); + m_pImplAdviseSink = new OleWrapperAdviseSink( this ); m_pImplAdviseSink->AddRef(); } @@ -471,33 +462,13 @@ OleComponent::~OleComponent() ++aIter ) { delete (*aIter); - (*aIter) = NULL; + (*aIter) = nullptr; } m_pNativeImpl->m_aFormatsList.clear(); 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() { // the mutex must be locked before this method is called @@ -510,14 +481,14 @@ void OleComponent::Dispose() { m_pOleWrapClientSite->disconnectOleComponent(); m_pOleWrapClientSite->Release(); - m_pOleWrapClientSite = NULL; + m_pOleWrapClientSite = nullptr; } if ( m_pImplAdviseSink ) { m_pImplAdviseSink->disconnectOleComponent(); m_pImplAdviseSink->Release(); - m_pImplAdviseSink = NULL; + m_pImplAdviseSink = nullptr; } if ( m_pInterfaceContainer ) @@ -526,7 +497,7 @@ void OleComponent::Dispose() m_pInterfaceContainer->disposeAndClear( aEvent ); delete m_pInterfaceContainer; - m_pInterfaceContainer = NULL; + m_pInterfaceContainer = nullptr; } if ( m_bOleInitialized ) @@ -535,10 +506,10 @@ void OleComponent::Dispose() // the deinitialization might lead to a disaster, SO7 does not deinitialize OLE at all // so currently the same approach is selected as workaround // 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!!! osl::MutexGuard aGuard( m_aMutex ); - m_pUnoOleObject = NULL; + m_pUnoOleObject = nullptr; } @@ -608,7 +579,7 @@ void OleComponent::RetrieveObjectDataFlavors_Impl() if ( !m_aDataFlavors.getLength() ) { 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 ) { 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! { if ( !m_pNativeImpl->m_pObj ) - return sal_False; + return false; // the linked object will be detected here 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!" ); 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 ) - return sal_False; + return false; // remove all the caches - IOleCache* pIOleCache = NULL; - if ( SUCCEEDED( m_pNativeImpl->m_pObj->QueryInterface( IID_IOleCache, (void**)&pIOleCache ) ) && pIOleCache ) + IOleCache* pIOleCache = nullptr; + 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 ); if ( SUCCEEDED( hr2 ) && pEnumSD ) @@ -688,18 +659,18 @@ sal_Bool OleComponent::InitializeObject_Impl() // No IDataObject implementation, caching must be used instead 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 ); 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 ) - 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 // the object should have drawable aspect even in case it supports only iconic representation // if ( m_nOLEMiscFlags & OLEMISC_ONLYICONIC ) @@ -707,12 +678,12 @@ sal_Bool OleComponent::InitializeObject_Impl() m_pNativeImpl->m_pOleObject->SetClientSite( m_pOleWrapClientSite ); // 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 ); OleSetContainedObject( m_pNativeImpl->m_pOleObject, TRUE ); - return sal_True; + return true; } namespace @@ -721,7 +692,7 @@ namespace { HRESULT hr = E_FAIL; __try { - hr = OleLoad(pIStorage, IID_IUnknown, NULL, ppObj); + hr = OleLoad(pIStorage, IID_IUnknown, nullptr, ppObj); } __except( EXCEPTION_EXECUTE_HANDLER ) { return E_FAIL; } @@ -743,7 +714,7 @@ void OleComponent::LoadEmbeddedObject( const OUString& aTempURL ) if ( FAILED( hr ) || !m_pNativeImpl->m_pIStorage ) 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 ) { throw uno::RuntimeException(); @@ -763,7 +734,7 @@ void OleComponent::CreateObjectFromClipboard() if ( !m_pNativeImpl->m_pIStorage ) throw uno::RuntimeException(); // TODO - IDataObject * pDO = NULL; + IDataObject * pDO = nullptr; HRESULT hr = OleGetClipboard( &pDO ); if( SUCCEEDED( hr ) && pDO ) { @@ -773,10 +744,10 @@ void OleComponent::CreateObjectFromClipboard() hr = OleCreateFromData( pDO, IID_IUnknown, OLERENDER_DRAW, // OLERENDER_FORMAT - NULL, // &aFormat, - NULL, + nullptr, // &aFormat, + nullptr, m_pNativeImpl->m_pIStorage, - (void**)&m_pNativeImpl->m_pObj ); + reinterpret_cast<void**>(&m_pNativeImpl->m_pObj) ); } else { @@ -812,10 +783,10 @@ void OleComponent::CreateNewEmbeddedObject( const uno::Sequence< sal_Int8 >& aSe HRESULT hr = OleCreate( aClsID, IID_IUnknown, OLERENDER_DRAW, // OLERENDER_FORMAT - NULL, // &aFormat, - NULL, + nullptr, // &aFormat, + nullptr, m_pNativeImpl->m_pIStorage, - (void**)&m_pNativeImpl->m_pObj ); + reinterpret_cast<void**>(&m_pNativeImpl->m_pObj) ); if ( FAILED( hr ) || !m_pNativeImpl->m_pObj ) throw uno::RuntimeException(); // TODO @@ -855,10 +826,10 @@ void OleComponent::CreateObjectFromFile( const OUString& aFileURL ) reinterpret_cast<LPCWSTR>(aFilePath.getStr()), IID_IUnknown, OLERENDER_DRAW, // OLERENDER_FORMAT - NULL, - NULL, + nullptr, + nullptr, m_pNativeImpl->m_pIStorage, - (void**)&m_pNativeImpl->m_pObj ); + reinterpret_cast<void**>(&m_pNativeImpl->m_pObj) ); if ( FAILED( hr ) || !m_pNativeImpl->m_pObj ) throw uno::RuntimeException(); // TODO @@ -884,10 +855,10 @@ void OleComponent::CreateLinkFromFile( const OUString& aFileURL ) HRESULT hr = OleCreateLinkToFile( reinterpret_cast<LPCWSTR>(aFilePath.getStr()), IID_IUnknown, OLERENDER_DRAW, // OLERENDER_FORMAT - NULL, - NULL, + nullptr, + nullptr, m_pNativeImpl->m_pIStorage, - (void**)&m_pNativeImpl->m_pObj ); + reinterpret_cast<void**>(&m_pNativeImpl->m_pObj) ); if ( FAILED( hr ) || !m_pNativeImpl->m_pObj ) throw uno::RuntimeException(); // TODO @@ -906,7 +877,7 @@ void OleComponent::InitEmbeddedCopyOfLink( OleComponent* pOleLinkComponent ) throw io::IOException(); // TODO:the object is already initialized 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 ) ) ) { // the object must be already disconnected from the temporary URL @@ -917,16 +888,16 @@ void OleComponent::InitEmbeddedCopyOfLink( OleComponent* pOleLinkComponent ) hr = OleCreateFromData( pDataObject, IID_IUnknown, OLERENDER_DRAW, - NULL, - NULL, + nullptr, + nullptr, m_pNativeImpl->m_pIStorage, - (void**)&m_pNativeImpl->m_pObj ); + reinterpret_cast<void**>(&m_pNativeImpl->m_pObj) ); } if ( !m_pNativeImpl->m_pObj ) { 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 ) 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 OSL_ENSURE( pMalloc, "CoGetMalloc() failed!" ); - LPOLESTR pOleStr = NULL; + LPOLESTR pOleStr = nullptr; hr = pOleLink->GetSourceDisplayName( &pOleStr ); if ( SUCCEEDED( hr ) && pOleStr ) { - OUString aFilePath( ( sal_Unicode* )pOleStr ); + OUString aFilePath( pOleStr ); if ( pMalloc ) - pMalloc->Free( ( void* )pOleStr ); + pMalloc->Free( pOleStr ); hr = OleCreateFromFile( CLSID_NULL, reinterpret_cast<LPCWSTR>(aFilePath.getStr()), IID_IUnknown, OLERENDER_DRAW, // OLERENDER_FORMAT - NULL, - NULL, + nullptr, + nullptr, 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 ) { ComSmart< IBindCtx > pBindCtx; - hr = CreateBindCtx( 0, ( LPBC FAR* )&pBindCtx ); + hr = CreateBindCtx( 0, &pBindCtx ); if ( SUCCEEDED( hr ) && pBindCtx ) { 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 ) { - hr = pObjectStorage->CopyTo( 0, NULL, NULL, m_pNativeImpl->m_pIStorage ); + hr = pObjectStorage->CopyTo( 0, nullptr, nullptr, m_pNativeImpl->m_pIStorage ); 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 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 ) ) 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 awt::Size aSize; - sal_Bool bGotSize = sal_False; + bool bGotSize = false; if ( nMSAspect == DVASPECT_CONTENT ) { // Try to get the size from the replacement image first 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 ) { STGMEDIUM aMedium; @@ -1153,7 +1124,7 @@ awt::Size OleComponent::GetExtent( sal_Int64 nAspect ) hr = pDataObject->GetData( &aFormat, &aMedium ); 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 ) { // 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.Height = ( sal_Int32 )nY; - bGotSize = sal_True; + bGotSize = true; } else 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 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 ) ) { @@ -1258,8 +1229,8 @@ sal_Int64 OleComponent::GetMiscStatus( sal_Int64 nAspect ) if ( !m_pNativeImpl->m_pOleObject ) throw embed::WrongStateException(); // TODO: the object is in wrong state - sal_uInt32 nResult; - m_pNativeImpl->m_pOleObject->GetMiscStatus( ( DWORD )nAspect, ( DWORD* )&nResult ); + DWORD nResult; + m_pNativeImpl->m_pOleObject->GetMiscStatus( ( DWORD )nAspect, &nResult ); 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 ) throw embed::WrongStateException(); // TODO: the object is in wrong state if ( IsWorkaroundActive() ) - return sal_True; + return true; 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 ) throw io::IOException(); // TODO @@ -1306,7 +1277,7 @@ void OleComponent::StoreOwnTmpIfNecessary() throw embed::WrongStateException(); // TODO: the object is in wrong state 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 ) 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 // 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 ); if ( FAILED( hr ) ) throw io::IOException(); // TODO - hr = pPersistStorage->SaveCompleted( NULL ); + hr = pPersistStorage->SaveCompleted( nullptr ); if ( FAILED( hr ) && hr != E_UNEXPECTED ) 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; - OleEmbeddedObject* pLockObject = NULL; + bool bResult = false; + OleEmbeddedObject* pLockObject = nullptr; { 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; - OleEmbeddedObject* pLockObject = NULL; + bool bResult = false; + OleEmbeddedObject* pLockObject = nullptr; { osl::MutexGuard aGuard( m_aMutex ); @@ -1452,14 +1423,14 @@ void SAL_CALL OleComponent::close( sal_Bool bDeliverOwnership ) { ::cppu::OInterfaceContainerHelper* pContainer = m_pInterfaceContainer->getContainer( cppu::UnoType<util::XCloseListener>::get()); - if ( pContainer != NULL ) + if ( pContainer != nullptr ) { ::cppu::OInterfaceIteratorHelper pIterator( *pContainer ); while ( pIterator.hasMoreElements() ) { try { - ( (util::XCloseListener* )pIterator.next() )->queryClosing( aSource, bDeliverOwnership ); + static_cast<util::XCloseListener*>( pIterator.next() )->queryClosing( aSource, bDeliverOwnership ); } catch( const uno::RuntimeException& ) { @@ -1470,14 +1441,14 @@ void SAL_CALL OleComponent::close( sal_Bool bDeliverOwnership ) pContainer = m_pInterfaceContainer->getContainer( cppu::UnoType<util::XCloseListener>::get()); - if ( pContainer != NULL ) + if ( pContainer != nullptr ) { ::cppu::OInterfaceIteratorHelper pCloseIterator( *pContainer ); while ( pCloseIterator.hasMoreElements() ) { try { - ( (util::XCloseListener* )pCloseIterator.next() )->notifyClosing( aSource ); + static_cast<util::XCloseListener*>( pCloseIterator.next() )->notifyClosing( aSource ); } 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 uno::Any aResult; - sal_Bool bSupportedFlavor = sal_False; + bool bSupportedFlavor = false; 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 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 ) 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" ) { // allow to retrieve stream-representation of the object persistence - bSupportedFlavor = sal_True; + bSupportedFlavor = true; uno::Reference < io::XStream > xTempFileStream( io::TempFile::create(comphelper::getComponentContext(m_xFactory)), uno::UNO_QUERY_THROW ); @@ -1602,7 +1573,7 @@ uno::Any SAL_CALL OleComponent::getTransferData( const datatransfer::DataFlavor& { OSL_ENSURE( m_pUnoOleObject, "Unexpected object absence!" ); if ( !m_pUnoOleObject ) - throw uno::RuntimeException(); + throw uno::RuntimeException(); 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++ ) 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) { try { - close( sal_True ); + close( true ); } 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(); 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) 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[1] == aCLSID[2] && 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& ) @@ -1744,15 +1715,15 @@ void SAL_CALL OleComponent::setModified( sal_Bool bModified ) { ::cppu::OInterfaceContainerHelper* pContainer = m_pInterfaceContainer->getContainer( cppu::UnoType<util::XModifyListener>::get()); - if ( pContainer != NULL ) + if ( pContainer != nullptr ) { ::cppu::OInterfaceIteratorHelper pIterator( *pContainer ); while ( pIterator.hasMoreElements() ) { try { - lang::EventObject aEvent( (util::XModifiable*) this ); - ((util::XModifyListener*)pIterator.next())->modified( aEvent ); + lang::EventObject aEvent( static_cast<util::XModifiable*>(this) ); + static_cast<util::XModifyListener*>(pIterator.next())->modified( aEvent ); } catch( const uno::RuntimeException& ) { diff --git a/embeddedobj/source/msole/olecomponent.hxx b/embeddedobj/source/msole/olecomponent.hxx index 2d5e35a000e6..5b3dc68805fe 100644 --- a/embeddedobj/source/msole/olecomponent.hxx +++ b/embeddedobj/source/msole/olecomponent.hxx @@ -59,8 +59,8 @@ class OleComponent : public ::cppu::WeakImplHelper< css::util::XCloseable, css:: ::osl::Mutex m_aMutex; ::cppu::OMultiTypeInterfaceContainerHelper* m_pInterfaceContainer; - sal_Bool m_bDisposed; - sal_Bool m_bModified; + bool m_bDisposed; + bool m_bModified; OleComponentNative_Impl* m_pNativeImpl; OleEmbeddedObject* m_pUnoOleObject; @@ -75,13 +75,13 @@ class OleComponent : public ::cppu::WeakImplHelper< css::util::XCloseable, css:: 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 ) // 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 RetrieveObjectDataFlavors_Impl(); @@ -92,7 +92,7 @@ public: OleComponent( const css::uno::Reference< css::lang::XMultiServiceFactory >& m_xFactory, OleEmbeddedObject* pOleObj ); - virtual ~OleComponent(); + virtual ~OleComponent() override; OleComponent* createEmbeddedCopyOfLink(); @@ -102,13 +102,13 @@ public: const css::awt::Size& aMultiplier, 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 ================================================== void LoadEmbeddedObject( const OUString& aTempURL ); void CreateObjectFromClipboard(); void CreateNewEmbeddedObject( const css::uno::Sequence< sal_Int8 >& aSeqCLSID ); - void CreateObjectFromData( + static void CreateObjectFromData( const css::uno::Reference< css::datatransfer::XTransferable >& xTransfer ); void CreateObjectFromFile( const OUString& aFileName ); void CreateLinkFromFile( const OUString& aFileName ); @@ -132,40 +132,40 @@ public: css::uno::Sequence< sal_Int8 > GetCLSID(); - sal_Bool IsWorkaroundActive() { return m_bWorkaroundActive; } - sal_Bool IsDirty(); + bool IsWorkaroundActive() { return m_bWorkaroundActive; } + bool IsDirty(); void StoreOwnTmpIfNecessary(); - sal_Bool SaveObject_Impl(); - sal_Bool OnShowWindow_Impl( bool bShow ); + bool SaveObject_Impl(); + bool OnShowWindow_Impl( bool bShow ); void OnViewChange_Impl( sal_uInt32 dwAspect ); void OnClose_Impl(); // XCloseable - virtual void SAL_CALL close( sal_Bool DeliverOwnership ) throw (css::util::CloseVetoException, css::uno::RuntimeException); - virtual void SAL_CALL addCloseListener( 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); + 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) override; + virtual void SAL_CALL removeCloseListener( const css::uno::Reference< css::util::XCloseListener >& Listener ) throw (css::uno::RuntimeException) override; // 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::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( ) throw (css::uno::RuntimeException); - virtual sal_Bool SAL_CALL isDataFlavorSupported( const css::datatransfer::DataFlavor& aFlavor ) throw (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) override; + virtual sal_Bool SAL_CALL isDataFlavorSupported( const css::datatransfer::DataFlavor& aFlavor ) throw (css::uno::RuntimeException) override; // XComponent - virtual void SAL_CALL dispose() throw (css::uno::RuntimeException); - virtual void SAL_CALL addEventListener(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); + 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) override; + virtual void SAL_CALL removeEventListener(const css::uno::Reference < css::lang::XEventListener >& aListener) throw (css::uno::RuntimeException) override; // 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 - 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 ) - throw (css::beans::PropertyVetoException, css::uno::RuntimeException); - virtual void SAL_CALL addModifyListener( 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); + 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) override; + virtual void SAL_CALL removeModifyListener( const css::uno::Reference < css::util::XModifyListener >& xListener) throw(css::uno::RuntimeException) override; }; #endif diff --git a/embeddedobj/source/msole/oleembed.cxx b/embeddedobj/source/msole/oleembed.cxx index 801e568ab9af..91bc27c0ec78 100644 --- a/embeddedobj/source/msole/oleembed.cxx +++ b/embeddedobj/source/msole/oleembed.cxx @@ -484,7 +484,7 @@ void SAL_CALL OleEmbeddedObject::changeState( sal_Int32 nNewState ) sal_Int32 nOldState = m_nObjectState; aGuard.clear(); - StateChangeNotification_Impl( sal_True, nOldState, nNewState ); + StateChangeNotification_Impl( true, nOldState, nNewState ); aGuard.reset(); try @@ -506,7 +506,7 @@ void SAL_CALL OleEmbeddedObject::changeState( sal_Int32 nNewState ) } aGuard.clear(); - StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState ); + StateChangeNotification_Impl( false, nOldState, m_nObjectState ); aGuard.reset(); } else if ( nNewState == embed::EmbedStates::RUNNING || nNewState == embed::EmbedStates::ACTIVE ) @@ -523,7 +523,7 @@ void SAL_CALL OleEmbeddedObject::changeState( sal_Int32 nNewState ) SwitchComponentToRunningState_Impl(); m_nObjectState = embed::EmbedStates::RUNNING; aGuard.clear(); - StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState ); + StateChangeNotification_Impl( false, nOldState, m_nObjectState ); aGuard.reset(); if ( m_pOleComponent && m_bHasSizeToSet ) @@ -531,7 +531,7 @@ void SAL_CALL OleEmbeddedObject::changeState( sal_Int32 nNewState ) aGuard.clear(); try { m_pOleComponent->SetExtent( m_aSizeToSet, m_nAspectToSet ); - m_bHasSizeToSet = sal_False; + m_bHasSizeToSet = false; } catch( const uno::Exception& ) {} aGuard.reset(); @@ -556,7 +556,7 @@ void SAL_CALL OleEmbeddedObject::changeState( sal_Int32 nNewState ) aGuard.clear(); try { m_pOleComponent->SetExtent( m_aSizeToSet, m_nAspectToSet ); - m_bHasSizeToSet = sal_False; + m_bHasSizeToSet = false; } catch( uno::Exception& ) {} aGuard.reset(); @@ -583,7 +583,7 @@ void SAL_CALL OleEmbeddedObject::changeState( sal_Int32 nNewState ) catch( uno::Exception& ) { aGuard.clear(); - StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState ); + StateChangeNotification_Impl( false, nOldState, m_nObjectState ); throw; } } @@ -803,7 +803,7 @@ void SAL_CALL OleEmbeddedObject::doVerb( sal_Int32 nVerbID ) m_pOleComponent->ExecuteVerb( nVerbID ); // ==== the STAMPIT related solution ============================= - sal_Bool bModifiedOnExecution = m_aVerbExecutionController.EndControlExecution_WasModified(); + bool bModifiedOnExecution = m_aVerbExecutionController.EndControlExecution_WasModified(); // this workaround is implemented for STAMPIT object // 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(); - StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState ); + StateChangeNotification_Impl( false, nOldState, m_nObjectState ); throw; } @@ -1081,7 +1081,7 @@ sal_Int64 SAL_CALL OleEmbeddedObject::getStatus( sal_Int64 m_nStatus = m_pOleComponent->GetMiscStatus( nAspect ); m_nStatusAspect = nAspect; - m_bGotStatus = sal_True; + m_bGotStatus = true; nResult = m_nStatus; } #endif diff --git a/embeddedobj/source/msole/olemisc.cxx b/embeddedobj/source/msole/olemisc.cxx index 31d6f9ca399c..843e3b3fbb31 100644 --- a/embeddedobj/source/msole/olemisc.cxx +++ b/embeddedobj/source/msole/olemisc.cxx @@ -108,31 +108,31 @@ OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< lang::XMultiServiceF // this constructor let object be initialized from clipboard OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< lang::XMultiServiceFactory >& xFactory ) -: m_pOleComponent( NULL ) -, m_pInterfaceContainer( NULL ) -, m_bReadOnly( sal_False ) +: m_pOleComponent( nullptr ) +, m_pInterfaceContainer( nullptr ) +, m_bReadOnly( false ) , m_bDisposed( false ) , m_nObjectState( -1 ) , m_nTargetState( -1 ) , m_nUpdateMode( embed::EmbedUpdateModes::ALWAYS_UPDATE ) , m_xFactory( xFactory ) -, m_bWaitSaveCompleted( sal_False ) -, m_bNewVisReplInStream( sal_True ) -, m_bStoreLoaded( sal_False ) -, m_bVisReplInitialized( sal_False ) -, m_bVisReplInStream( sal_False ) -, m_bStoreVisRepl( sal_False ) -, m_bIsLink( sal_False ) -, m_bHasCachedSize( sal_False ) +, m_bWaitSaveCompleted( false ) +, m_bNewVisReplInStream( true ) +, m_bStoreLoaded( false ) +, m_bVisReplInitialized( false ) +, m_bVisReplInStream( false ) +, m_bStoreVisRepl( false ) +, m_bIsLink( false ) +, m_bHasCachedSize( false ) , m_nCachedAspect( 0 ) -, m_bHasSizeToSet( sal_False ) +, m_bHasSizeToSet( false ) , m_nAspectToSet( 0 ) -, m_bGotStatus( sal_False ) +, m_bGotStatus( false ) , m_nStatus( 0 ) , m_nStatusAspect( 0 ) -, m_pOwnView( NULL ) -, m_bFromClipboard( sal_True ) -, m_bTriedConversion( sal_False ) +, m_pOwnView( nullptr ) +, m_bFromClipboard( true ) +, m_bTriedConversion( false ) { } #endif @@ -185,13 +185,13 @@ void OleEmbeddedObject::MakeEventListenerNotification_Impl( const OUString& aEve } #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 ) { ::cppu::OInterfaceContainerHelper* pContainer = m_pInterfaceContainer->getContainer( cppu::UnoType<embed::XStateChangeListener>::get()); - if ( pContainer != NULL ) + if ( pContainer != nullptr ) { lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) ); ::cppu::OInterfaceIteratorHelper pIterator(*pContainer); @@ -202,7 +202,7 @@ void OleEmbeddedObject::StateChangeNotification_Impl( sal_Bool bBeforeChange, sa { try { - ((embed::XStateChangeListener*)pIterator.next())->changingState( aSource, nOldState, nNewState ); + static_cast<embed::XStateChangeListener*>(pIterator.next())->changingState( aSource, nOldState, nNewState ); } catch( const uno::Exception& ) { @@ -213,7 +213,7 @@ void OleEmbeddedObject::StateChangeNotification_Impl( sal_Bool bBeforeChange, sa { try { - ((embed::XStateChangeListener*)pIterator.next())->stateChanged( aSource, nOldState, nNewState ); + static_cast<embed::XStateChangeListener*>(pIterator.next())->stateChanged( aSource, nOldState, nNewState ); } catch( const uno::Exception& ) { @@ -237,7 +237,7 @@ void OleEmbeddedObject::GetRidOfComponent() m_pOleComponent->removeCloseListener( m_xClosePreventer ); try { - m_pOleComponent->close( sal_False ); + m_pOleComponent->close( false ); } catch( const uno::Exception& ) { @@ -249,7 +249,7 @@ void OleEmbeddedObject::GetRidOfComponent() m_pOleComponent->disconnectEmbeddedObject(); m_pOleComponent->release(); - m_pOleComponent = NULL; + m_pOleComponent = nullptr; } #endif } @@ -386,7 +386,7 @@ uno::Reference< util::XCloseable > SAL_CALL OleEmbeddedObject::getComponent() } #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 ); } diff --git a/embeddedobj/source/msole/olepersist.cxx b/embeddedobj/source/msole/olepersist.cxx index f713f97ea54a..eb5737db4944 100644 --- a/embeddedobj/source/msole/olepersist.cxx +++ b/embeddedobj/source/msole/olepersist.cxx @@ -169,7 +169,7 @@ OUString GetNewFilledTempFile_Impl( const uno::Reference< embed::XOptimizedStora xParentStorage->copyStreamElementData( aEntryName, xTempStream ); - xTempFile->setPropertyValue("RemoveFile", uno::makeAny( sal_False ) ); + xTempFile->setPropertyValue("RemoveFile", uno::makeAny( false ) ); uno::Any aUrl = xTempFile->getPropertyValue("Uri"); aUrl >>= aResult; } @@ -216,22 +216,22 @@ void VerbExecutionController::StartControlExecution() // the class is used to detect STAMPIT object, that can never be active if ( !m_bVerbExecutionInProgress && !m_bWasEverActive ) { - m_bVerbExecutionInProgress = sal_True; + m_bVerbExecutionInProgress = true; 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 ); - sal_Bool bResult = sal_False; + bool bResult = false; if ( m_bVerbExecutionInProgress && m_nVerbExecutionThreadIdentifier == osl::Thread::getCurrentIdentifier() ) { bResult = m_bChangedOnVerbExecution; - m_bVerbExecutionInProgress = sal_False; + m_bVerbExecutionInProgress = false; } return bResult; @@ -243,7 +243,7 @@ void VerbExecutionController::ModificationNotificationIsDone() osl::MutexGuard aGuard( m_aVerbExecutionMutex ); if ( m_bVerbExecutionInProgress && osl::Thread::getCurrentIdentifier() == m_nVerbExecutionThreadIdentifier ) - m_bChangedOnVerbExecution = sal_True; + m_bChangedOnVerbExecution = true; } #endif @@ -736,7 +736,7 @@ uno::Reference< io::XStream > OleEmbeddedObject::TryToRetrieveCachedVisualRepres try { - CreateOleComponentAndLoad_Impl( NULL ); + CreateOleComponentAndLoad_Impl(); m_aClassID = m_pOleComponent->GetCLSID(); // was not set during consruction } catch( const uno::Exception& ) @@ -803,16 +803,16 @@ void OleEmbeddedObject::SwitchOwnPersistence( const uno::Reference< embed::XStor #ifdef _WIN32 -sal_Bool OleEmbeddedObject::SaveObject_Impl() +bool OleEmbeddedObject::SaveObject_Impl() { - sal_Bool bResult = sal_False; + bool bResult = false; if ( m_xClientSite.is() ) { try { m_xClientSite->saveObject(); - bResult = sal_True; + bResult = true; } 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 ); - 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 == embed::EmbedStates::LOADED, "embeddedobj.ole", "The object get OnShowWindow in loaded state!" ); if ( m_nObjectState == -1 || m_nObjectState == embed::EmbedStates::LOADED ) - return sal_False; + return false; // the object is either activated or deactivated sal_Int32 nOldState = m_nObjectState; @@ -842,13 +842,13 @@ sal_Bool OleEmbeddedObject::OnShowWindow_Impl( sal_Bool bShow ) m_aVerbExecutionController.ObjectIsActive(); aGuard.clear(); - StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState ); + StateChangeNotification_Impl( false, nOldState, m_nObjectState ); } else if ( !bShow && m_nObjectState == embed::EmbedStates::ACTIVE ) { m_nObjectState = embed::EmbedStates::RUNNING; aGuard.clear(); - StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState ); + StateChangeNotification_Impl( false, nOldState, m_nObjectState ); } if ( m_xClientSite.is() ) @@ -856,7 +856,7 @@ sal_Bool OleEmbeddedObject::OnShowWindow_Impl( sal_Bool bShow ) try { m_xClientSite->visibilityChanged( bShow ); - bResult = sal_True; + bResult = true; } 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 m_xCachedVisualRepresentation.clear(); SaveObject_Impl(); - MakeEventListenerNotification_Impl( OUString( "OnVisAreaChanged" ) ); + MakeEventListenerNotification_Impl( "OnVisAreaChanged" ); } } @@ -914,7 +914,7 @@ void OleEmbeddedObject::OnClosed_Impl() { sal_Int32 nOldState = m_nObjectState; 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 ) { // this method should be used only on windows @@ -1167,13 +1167,13 @@ void OleEmbeddedObject::StoreToLocation_Impl( if ( !xTargetStream.is() ) 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(); if ( !xOutStream.is() ) throw io::IOException(); //TODO: access denied StoreObjectToStream( xOutStream ); - bVisReplIsStored = sal_True; + bVisReplIsStored = true; if ( bSaveAs ) { @@ -1188,7 +1188,7 @@ void OleEmbeddedObject::StoreToLocation_Impl( if ( xTmpCVRepresentation.is() ) { xCachedVisualRepresentation = xTmpCVRepresentation; - bNeedLocalCache = sal_False; + bNeedLocalCache = false; } } } @@ -1375,7 +1375,7 @@ void SAL_CALL OleEmbeddedObject::setPersistentEntry( { // the object should be initialized from clipboard // inpossibility to initialize the object means error here - CreateOleComponentFromClipboard_Impl( NULL ); + CreateOleComponentFromClipboard_Impl(); m_aClassID = m_pOleComponent->GetCLSID(); // was not set during consruction m_pOleComponent->RunObject(); m_nObjectState = embed::EmbedStates::RUNNING; @@ -1387,7 +1387,7 @@ void SAL_CALL OleEmbeddedObject::setPersistentEntry( // will be detected by olecomponent try { - CreateOleComponentAndLoad_Impl( NULL ); + CreateOleComponentAndLoad_Impl(); m_aClassID = m_pOleComponent->GetCLSID(); // was not set during consruction } catch( const uno::Exception& ) @@ -1759,14 +1759,14 @@ void SAL_CALL OleEmbeddedObject::storeOwn() #ifdef _WIN32 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" ); if ( !m_xObjectStream.is() ) 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(); if ( !xOutStream.is() ) 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 if ( !m_pOleComponent->IsWorkaroundActive() ) m_xCachedVisualRepresentation.clear(); - SetVisReplInStream( sal_True ); + SetVisReplInStream( true ); } #endif @@ -2015,7 +2015,7 @@ void SAL_CALL OleEmbeddedObject::breakLink( const uno::Reference< embed::XStorag m_nObjectState = nTargetState; } - m_bIsLink = sal_False; + m_bIsLink = false; m_aLinkURL.clear(); } else diff --git a/embeddedobj/source/msole/olepersist.hxx b/embeddedobj/source/msole/olepersist.hxx index 2248a2bf458e..09975a61f4f5 100644 --- a/embeddedobj/source/msole/olepersist.hxx +++ b/embeddedobj/source/msole/olepersist.hxx @@ -32,6 +32,8 @@ namespace com { namespace sun { namespace star { namespace lang { class XMultiServiceFactory; } } } } +OUString GetNewTempFileURL_Impl( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ); + OUString GetNewFilledTempFile_Impl( css::uno::Reference<css::io::XInputStream > const & xInStream, css::uno::Reference<css::lang::XMultiServiceFactory> const & xFactory) diff --git a/embeddedobj/source/msole/oleregister.cxx b/embeddedobj/source/msole/oleregister.cxx index 2261015fb224..5cb0ae690507 100644 --- a/embeddedobj/source/msole/oleregister.cxx +++ b/embeddedobj/source/msole/oleregister.cxx @@ -54,7 +54,7 @@ SAL_DLLPUBLIC_EXPORT void * SAL_CALL emboleobj_component_getFactory( // the following service makes sense only on windows 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_staticCreateSelfInstance, MSOLEDialogObjectCreator::impl_staticGetSupportedServiceNames() ); diff --git a/embeddedobj/source/msole/olevisual.cxx b/embeddedobj/source/msole/olevisual.cxx index 6d4d4673936a..1acb87706386 100644 --- a/embeddedobj/source/msole/olevisual.cxx +++ b/embeddedobj/source/msole/olevisual.cxx @@ -112,7 +112,7 @@ void SAL_CALL OleEmbeddedObject::setVisualAreaSize( sal_Int64 nAspect, const awt // SetExtent() is called only for objects that require it, // 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 - sal_Bool bAllowToSetExtent = + bool bAllowToSetExtent = ( ( getStatus( nAspect ) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE ) && !MimeConfigurationHelper::ClassIDsEqual(m_aClassID, MimeConfigurationHelper::GetSequenceClassID(MSO_WW8_CLASSID)) && m_bHasCachedSize ); @@ -136,12 +136,12 @@ void SAL_CALL OleEmbeddedObject::setVisualAreaSize( sal_Int64 nAspect, const awt aGuard.clear(); try { m_pOleComponent->SetExtent( aSizeToSet, nAspect ); // will throw an exception in case of failure - m_bHasSizeToSet = sal_False; + m_bHasSizeToSet = false; } catch( const uno::Exception& ) { // some objects do not allow to set the size even in running state - m_bHasSizeToSet = sal_True; + m_bHasSizeToSet = true; m_aSizeToSet = aSizeToSet; m_nAspectToSet = nAspect; } @@ -205,7 +205,7 @@ awt::Size SAL_CALL OleEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect ) bool bBackToLoaded = false; - sal_Bool bSuccess = sal_False; + bool bSuccess = false; if ( getCurrentState() == embed::EmbedStates::LOADED ) { 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 aSize = m_pOleComponent->GetExtent( nAspect ); // will throw an exception in case of failure - bSuccess = sal_True; + bSuccess = true; } catch( const uno::Exception& ) { @@ -255,7 +255,7 @@ awt::Size SAL_CALL OleEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect ) { // second try the cached replacement image aSize = m_pOleComponent->GetCachedExtent( nAspect ); // will throw an exception in case of failure - bSuccess = sal_True; + bSuccess = true; } 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 aSize = m_pOleComponent->GetReccomendedExtent( nAspect ); // will throw an exception in case of failure - bSuccess = sal_True; + bSuccess = true; } catch( const uno::Exception& ) { @@ -284,7 +284,7 @@ awt::Size SAL_CALL OleEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect ) m_aCachedSize = aSize; m_nCachedAspect = nAspect; - m_bHasCachedSize = sal_True; + m_bHasCachedSize = true; aResult = m_aCachedSize; } diff --git a/embeddedobj/source/msole/olewrapclient.cxx b/embeddedobj/source/msole/olewrapclient.cxx index 7c8755cdc05a..571a6914d716 100644 --- a/embeddedobj/source/msole/olewrapclient.cxx +++ b/embeddedobj/source/msole/olewrapclient.cxx @@ -37,17 +37,17 @@ OleWrapperClientSite::~OleWrapperClientSite() STDMETHODIMP OleWrapperClientSite::QueryInterface( REFIID riid , void** ppv ) { - *ppv=NULL; + *ppv=nullptr; if ( riid == IID_IUnknown ) - *ppv = (IUnknown*)this; + *ppv = static_cast<IUnknown*>(this); 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; } @@ -72,12 +72,12 @@ void OleWrapperClientSite::disconnectOleComponent() { // must not be called from the descructor of OleComponent!!! osl::MutexGuard aGuard( m_aMutex ); - m_pOleComp = NULL; + m_pOleComp = nullptr; } STDMETHODIMP OleWrapperClientSite::SaveObject() { - OleComponent* pLockComponent = NULL; + OleComponent* pLockComponent = nullptr; HRESULT hResult = E_FAIL; { @@ -102,13 +102,13 @@ STDMETHODIMP OleWrapperClientSite::SaveObject() STDMETHODIMP OleWrapperClientSite::GetMoniker( DWORD, DWORD, LPMONIKER *ppmk ) { - *ppmk = NULL; + *ppmk = nullptr; return E_NOTIMPL; } STDMETHODIMP OleWrapperClientSite::GetContainer( LPOLECONTAINER* ppContainer ) { - *ppContainer = NULL; + *ppContainer = nullptr; return E_NOTIMPL; } @@ -119,7 +119,7 @@ STDMETHODIMP OleWrapperClientSite::ShowObject() 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 { diff --git a/embeddedobj/source/msole/olewrapclient.hxx b/embeddedobj/source/msole/olewrapclient.hxx index 8064f79d8025..be64ab340586 100644 --- a/embeddedobj/source/msole/olewrapclient.hxx +++ b/embeddedobj/source/msole/olewrapclient.hxx @@ -37,16 +37,16 @@ public: void disconnectOleComponent(); - STDMETHODIMP QueryInterface(REFIID, void**); - STDMETHODIMP_(ULONG) AddRef(); - STDMETHODIMP_(ULONG) Release(); - - STDMETHODIMP SaveObject(); - STDMETHODIMP GetMoniker(DWORD, DWORD, LPMONIKER *); - STDMETHODIMP GetContainer(LPOLECONTAINER *); - STDMETHODIMP ShowObject(); - STDMETHODIMP OnShowWindow(BOOL); - STDMETHODIMP RequestNewObjectLayout(); + STDMETHODIMP QueryInterface(REFIID, void**) override; + STDMETHODIMP_(ULONG) AddRef() override; + STDMETHODIMP_(ULONG) Release() override; + + STDMETHODIMP SaveObject() override; + STDMETHODIMP GetMoniker(DWORD, DWORD, LPMONIKER *) override; + STDMETHODIMP GetContainer(LPOLECONTAINER *) override; + STDMETHODIMP ShowObject() override; + STDMETHODIMP OnShowWindow(BOOL) override; + STDMETHODIMP RequestNewObjectLayout() override; }; #endif diff --git a/embeddedobj/source/msole/xdialogcreator.cxx b/embeddedobj/source/msole/xdialogcreator.cxx index d92b8e72ca9b..2b46d2f1099a 100644 --- a/embeddedobj/source/msole/xdialogcreator.cxx +++ b/embeddedobj/source/msole/xdialogcreator.cxx @@ -48,7 +48,7 @@ class InitializedOleGuard public: InitializedOleGuard() { - if ( !SUCCEEDED( OleInitialize( NULL ) ) ) + if ( !SUCCEEDED( OleInitialize( nullptr ) ) ) throw css::uno::RuntimeException(); } @@ -169,11 +169,11 @@ embed::InsertedObjectInfo SAL_CALL MSOLEDialogObjectCreator::createInstanceByDia ::osl::Module aOleDlgLib; - if( !aOleDlgLib.load( OUString( "oledlg" ) )) + if( !aOleDlgLib.load( "oledlg" )) throw uno::RuntimeException(); - OleUIInsertObjectA_Type * pInsertFct = (OleUIInsertObjectA_Type *) - aOleDlgLib.getSymbol( OUString( "OleUIInsertObjectA" )); + OleUIInsertObjectA_Type * pInsertFct = reinterpret_cast<OleUIInsertObjectA_Type *>( + aOleDlgLib.getSymbol( "OleUIInsertObjectA" )); if( !pInsertFct ) throw uno::RuntimeException(); @@ -231,20 +231,20 @@ embed::InsertedObjectInfo SAL_CALL MSOLEDialogObjectCreator::createInstanceByDia 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 ) { - sal_uInt32 nBufSize = GetMetaFileBitsEx( pMF->hMF, 0, NULL ); + sal_uInt32 nBufSize = GetMetaFileBitsEx( pMF->hMF, 0, nullptr ); uno::Sequence< sal_Int8 > aMetafile( nBufSize + 22 ); - sal_uInt8* pBuf = (sal_uInt8*)( aMetafile.getArray() ); - *( (long* )pBuf ) = 0x9ac6cdd7L; - *( (short* )( pBuf+6 )) = ( SHORT ) 0; - *( (short* )( pBuf+8 )) = ( SHORT ) 0; - *( (short* )( pBuf+10 )) = ( SHORT ) pMF->xExt; - *( (short* )( pBuf+12 )) = ( SHORT ) pMF->yExt; - *( (short* )( pBuf+14 )) = ( USHORT ) 2540; + sal_Int8* pBuf = aMetafile.getArray(); + *reinterpret_cast<long*>( pBuf ) = 0x9ac6cdd7L; + *reinterpret_cast<short*>( pBuf+6 ) = ( SHORT ) 0; + *reinterpret_cast<short*>( pBuf+8 ) = ( SHORT ) 0; + *reinterpret_cast<short*>( pBuf+10 ) = ( SHORT ) pMF->xExt; + *reinterpret_cast<short*>( pBuf+12 ) = ( SHORT ) pMF->yExt; + *reinterpret_cast<short*>( pBuf+14 ) = ( USHORT ) 2540; if ( nBufSize && nBufSize == GetMetaFileBitsEx( pMF->hMF, nBufSize, pBuf+22 ) ) { diff --git a/embeddedobj/source/msole/xdialogcreator.hxx b/embeddedobj/source/msole/xdialogcreator.hxx index c047273b3e7b..714afeb1ddf1 100644 --- a/embeddedobj/source/msole/xdialogcreator.hxx +++ b/embeddedobj/source/msole/xdialogcreator.hxx @@ -52,15 +52,15 @@ public: // 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 - 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 - virtual OUString SAL_CALL getImplementationName() throw (css::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (css::uno::RuntimeException); - virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() 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) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (css::uno::RuntimeException) override; }; |