diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-10-14 16:56:18 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-10-16 14:19:18 +0000 |
commit | 3b658759c945a5e2da7b2c6acfdecc9c3d9c6a34 (patch) | |
tree | ed79ef1d1dd3683e371b02d0b402aa45f654590a /embedserv/source | |
parent | d11ac6045926d4c6e392b3797939fbb7c7d37b27 (diff) |
clang-cl loplugin: embedserv
Change-Id: I9901dac882a74453015881ded2355ff0a51b50d5
Reviewed-on: https://gerrit.libreoffice.org/29868
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'embedserv/source')
27 files changed, 798 insertions, 814 deletions
diff --git a/embedserv/source/embed/docholder.cxx b/embedserv/source/embed/docholder.cxx index d4a6a4168a1b..538cd5a24ad5 100644 --- a/embedserv/source/embed/docholder.cxx +++ b/embedserv/source/embed/docholder.cxx @@ -62,13 +62,12 @@ #include <com/sun/star/util/XCloseable.hpp> #include <com/sun/star/util/XModifyBroadcaster.hpp> #include <comphelper/processfactory.hxx> +#include <o3tl/any.hxx> #include <osl/diagnose.h> #include <rtl/process.h> using namespace ::com::sun::star; -extern OUString getFilterNameFromGUID_Impl( GUID* ); - // add mutex locking ??? DocumentHolder::DocumentHolder( @@ -76,24 +75,24 @@ DocumentHolder::DocumentHolder( const ::rtl::Reference< EmbeddedDocumentInstanceAccess_Impl >& xOleAccess ) : m_bAllowInPlace(true), - m_pIOleIPSite(0), - m_pIOleIPFrame(0), - m_pIOleIPUIWindow(0), - m_pCHatchWin(0), + m_pIOleIPSite(nullptr), + m_pIOleIPFrame(nullptr), + m_pIOleIPUIWindow(nullptr), + m_pCHatchWin(nullptr), m_xOleAccess( xOleAccess ), - m_pInterceptor(0), + m_pInterceptor(nullptr), m_xFactory( xFactory ), m_bOnDeactivate(false), - m_hWndxWinParent(NULL), - m_hWndxWinCont(NULL), - m_nMenuHandle(NULL), - m_nMenuShared(NULL), - m_nOLEMenu(NULL), + m_hWndxWinParent(nullptr), + m_hWndxWinCont(nullptr), + m_nMenuHandle(nullptr), + m_nMenuShared(nullptr), + m_nOLEMenu(nullptr), m_nMacroExecMode( document::MacroExecMode::USE_CONFIG ), - m_bLink( sal_False ) + m_bLink( false ) { uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create(comphelper::getComponentContext(m_xFactory)); - xDesktop->addTerminateListener( (frame::XTerminateListener*)this ); + xDesktop->addTerminateListener( static_cast<frame::XTerminateListener*>(this) ); } @@ -105,14 +104,14 @@ DocumentHolder::~DocumentHolder() } -void DocumentHolder::LoadDocInFrame( sal_Bool bPluginMode ) +void DocumentHolder::LoadDocInFrame( bool bPluginMode ) { uno::Reference<frame::XComponentLoader> xComponentLoader( m_xFrame,uno::UNO_QUERY); if( xComponentLoader.is() && m_xDocument.is() ) { uno::Reference< task::XInteractionHandler2 > xHandler( - task::InteractionHandler::createWithParent(comphelper::getComponentContext(m_xFactory), 0) ); + task::InteractionHandler::createWithParent(comphelper::getComponentContext(m_xFactory), nullptr) ); sal_Int32 nLen = 3; uno::Sequence<beans::PropertyValue> aSeq( nLen ); @@ -159,8 +158,8 @@ void DocumentHolder::LoadDocInFrame( sal_Bool bPluginMode ) beans::PropertyState_DIRECT_VALUE); xComponentLoader->loadComponentFromURL( - OUString("private:object"), - OUString("_self"), + "private:object", + "_self", 0, aSeq); @@ -192,7 +191,7 @@ void DocumentHolder::DisableInplaceActivation(BOOL b) BOOL DocumentHolder::isActive() const { - return m_pIOleIPSite != 0; + return m_pIOleIPSite != nullptr; } HRESULT DocumentHolder::InPlaceActivate( @@ -210,10 +209,10 @@ HRESULT DocumentHolder::InPlaceActivate( RECT rcClip; OLEINPLACEFRAMEINFO frameInfo; - if (NULL==pActiveSite) + if (nullptr==pActiveSite) return ResultFromScode(E_INVALIDARG); - if (NULL!=m_pIOleIPSite) + if (nullptr!=m_pIOleIPSite) { if (fIncludeUI) UIActivate(); @@ -227,7 +226,7 @@ HRESULT DocumentHolder::InPlaceActivate( //1. Initialization, obtaining interfaces, OnInPlaceActivate. hr=pActiveSite->QueryInterface( IID_IOleInPlaceSite, - (void**) &m_pIOleIPSite); + reinterpret_cast<void**>(&m_pIOleIPSite)); if (FAILED(hr)) return hr; @@ -236,7 +235,8 @@ HRESULT DocumentHolder::InPlaceActivate( if (NOERROR!=hr) { - m_pIOleIPSite->Release(), m_pIOleIPSite=NULL; + m_pIOleIPSite->Release(); + m_pIOleIPSite=nullptr; return ResultFromScode(E_FAIL); } @@ -255,13 +255,13 @@ HRESULT DocumentHolder::InPlaceActivate( // initialize the office as, with hwnd as parentwindow uno::Any aAny; uno::Sequence<sal_Int8> aProcessIdent(16); - rtl_getGlobalProcessId((sal_uInt8*)aProcessIdent.getArray()); + rtl_getGlobalProcessId(reinterpret_cast<sal_uInt8*>(aProcessIdent.getArray())); try { if(!m_xEditWindow.is()) { // determine XWindow and window handle of parent - HWND hWndxWinParent(0); + HWND hWndxWinParent(nullptr); uno::Reference<awt::XWindow> xWin; uno::Reference<awt::XToolkit2> xToolkit = @@ -272,14 +272,15 @@ HRESULT DocumentHolder::InPlaceActivate( m_pCHatchWin = new winwrap::CHatchWin( m_hInstance,this); - if(m_pCHatchWin->Init(hWndSite,/*ID_HATCHWINDOW*/2000, NULL)) { + if(m_pCHatchWin->Init(hWndSite,/*ID_HATCHWINDOW*/2000, nullptr)) { m_pCHatchWin->RectsSet(&rcPos,&rcClip); //set visible area hWndxWinParent = m_pCHatchWin->Window(); ShowWindow(hWndxWinParent,SW_SHOW); //Make visible. } else { // no success initializing hatch window - delete m_pCHatchWin, m_pCHatchWin = 0; + delete m_pCHatchWin; + m_pCHatchWin = nullptr; hWndxWinParent = hWndSite; } @@ -297,7 +298,7 @@ HRESULT DocumentHolder::InPlaceActivate( rcPos.right-rcPos.left, rcPos.bottom - rcPos.top, awt::PosSize::POSSIZE); - xWin->setVisible(sal_True); + xWin->setVisible(true); m_xEditWindow = xWin; m_hWndxWinParent = hWndxWinParent; @@ -320,7 +321,7 @@ HRESULT DocumentHolder::InPlaceActivate( 0, 0, awt::PosSize::POSSIZE); - m_xEditWindow->setVisible(sal_True); + m_xEditWindow->setVisible(true); } if(m_xContainerWindow.is()) { @@ -350,7 +351,7 @@ HRESULT DocumentHolder::InPlaceActivate( m_xLayoutManager->setDockingAreaAcceptor(this); // load the model into the frame - LoadDocInFrame( sal_True ); + LoadDocInFrame( true ); uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create(comphelper::getComponentContext(m_xFactory)); xDesktop->getFrames()->append(m_xFrame); @@ -359,8 +360,7 @@ HRESULT DocumentHolder::InPlaceActivate( if(m_xLayoutManager.is()) { uno::Reference< css::ui::XUIElement > xUIEl( m_xLayoutManager->getElement( - OUString( - "private:resource/menubar/menubar"))); + "private:resource/menubar/menubar")); OSL_ENSURE(xUIEl.is(),"no menubar"); uno::Reference<awt::XSystemDependentMenuPeer> xSDMP( xUIEl->getRealInterface(), @@ -371,8 +371,7 @@ HRESULT DocumentHolder::InPlaceActivate( if( aAny >>= tmp ) m_nMenuHandle = HMENU(tmp); m_xLayoutManager->hideElement( - OUString( - "private:resource/menubar/menubar" )); + "private:resource/menubar/menubar" ); } } @@ -419,13 +418,13 @@ void DocumentHolder::InPlaceDeactivate() if(m_xEditWindow.is()) { m_xEditWindow->setVisible(false); ShowWindow(m_hWndxWinParent,SW_HIDE); - SetParent(m_hWndxWinParent,0); + SetParent(m_hWndxWinParent,nullptr); } if(m_xContainerWindow.is()) { m_xContainerWindow->setVisible(false); ShowWindow(m_hWndxWinCont,SW_HIDE); - SetParent(m_hWndxWinCont,0); + SetParent(m_hWndxWinCont,nullptr); } // TODO/cd: Workaround for status indicator bug. It always makes the @@ -435,12 +434,12 @@ void DocumentHolder::InPlaceDeactivate() if (m_xLayoutManager.is()) m_xLayoutManager->setVisible(false); - if (NULL!=m_pIOleIPSite) + if (nullptr!=m_pIOleIPSite) m_pIOleIPSite->OnInPlaceDeactivate(); - if(m_pIOleIPFrame) m_pIOleIPFrame->Release(); m_pIOleIPFrame = 0; - if(m_pIOleIPUIWindow) m_pIOleIPUIWindow->Release(); m_pIOleIPUIWindow = 0; - if(m_pIOleIPSite) m_pIOleIPSite->Release(); m_pIOleIPSite = 0; + if(m_pIOleIPFrame) m_pIOleIPFrame->Release(); m_pIOleIPFrame = nullptr; + if(m_pIOleIPUIWindow) m_pIOleIPUIWindow->Release(); m_pIOleIPUIWindow = nullptr; + if(m_pIOleIPSite) m_pIOleIPSite->Release(); m_pIOleIPSite = nullptr; if ( m_xOleAccess.is() ) { @@ -458,7 +457,7 @@ void DocumentHolder::InPlaceDeactivate() HRESULT DocumentHolder::UIActivate() { // 1. Call IOleInPlaceSite::UIActivate - if (NULL!=m_pIOleIPSite) + if (nullptr!=m_pIOleIPSite) m_pIOleIPSite->OnUIActivate(); //2. Critical for accelerators to work initially. @@ -470,11 +469,11 @@ HRESULT DocumentHolder::UIActivate() OLECHAR starOffice[] = {'S','t','a','r','O','f','f','i','c','e',0}; CComPtr< IOleInPlaceActiveObject > pObj = new CIIAObj( this ); - if (NULL!=m_pIOleIPFrame) + if (nullptr!=m_pIOleIPFrame) m_pIOleIPFrame->SetActiveObject( pObj, starOffice ); - if (NULL!=m_pIOleIPUIWindow) + if (nullptr!=m_pIOleIPUIWindow) m_pIOleIPUIWindow->SetActiveObject( pObj, starOffice ); @@ -489,14 +488,14 @@ void DocumentHolder::UIDeactivate() //1. Remove the shared menu. InPlaceMenuDestroy(); - if (NULL!=m_pIOleIPFrame) - m_pIOleIPFrame->SetActiveObject(NULL, NULL); + if (nullptr!=m_pIOleIPFrame) + m_pIOleIPFrame->SetActiveObject(nullptr, nullptr); - if (NULL!=m_pIOleIPUIWindow) - m_pIOleIPUIWindow->SetActiveObject(NULL, NULL); + if (nullptr!=m_pIOleIPUIWindow) + m_pIOleIPUIWindow->SetActiveObject(nullptr, nullptr); //3. Call IOleInPlaceSite::OnUIDeactivate - if (NULL!=m_pIOleIPSite) + if (nullptr!=m_pIOleIPSite) m_pIOleIPSite->OnUIDeactivate(FALSE); return; @@ -504,7 +503,7 @@ void DocumentHolder::UIDeactivate() void CopyToOLEMenu(HMENU hOrig,WORD origPos,HMENU hDest,WORD destPos) { - HMENU subMenu(NULL); + HMENU subMenu(nullptr); UINT uTemp = MF_BYPOSITION | MF_POPUP; char buffer[256]; @@ -561,11 +560,11 @@ BOOL DocumentHolder::InPlaceMenuCreate() uno::Reference<awt::XSystemDependentWindowPeer> xSysDepWin(m_xContainerWindow,uno::UNO_QUERY); if(xSysDepWin.is()) { uno::Sequence<sal_Int8> aProcessIdent(16); - rtl_getGlobalProcessId((sal_uInt8*)aProcessIdent.getArray()); + rtl_getGlobalProcessId(reinterpret_cast<sal_uInt8*>(aProcessIdent.getArray())); uno::Any aAny = xSysDepWin->getWindowHandle(aProcessIdent,lang::SystemDependent::SYSTEM_WIN32); sal_Int64 tmp; aAny >>= tmp; - HWND aHwnd = (HWND) tmp; + HWND aHwnd = reinterpret_cast<HWND>(tmp); m_pIOleIPFrame->SetMenu( m_nMenuShared,m_nOLEMenu,aHwnd); } @@ -577,12 +576,13 @@ BOOL DocumentHolder::InPlaceMenuCreate() BOOL DocumentHolder::InPlaceMenuDestroy() { - if( NULL == m_nMenuShared ) + if( nullptr == m_nMenuShared ) return TRUE; - m_pIOleIPFrame->SetMenu(NULL,NULL,NULL); + m_pIOleIPFrame->SetMenu(nullptr,nullptr,nullptr); - OleDestroyMenuDescriptor(m_nOLEMenu),m_nOLEMenu = NULL; + OleDestroyMenuDescriptor(m_nOLEMenu); + m_nOLEMenu = nullptr; return TRUE; } @@ -602,15 +602,15 @@ void DocumentHolder::FreeOffice() { uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create(comphelper::getComponentContext(m_xFactory)); xDesktop->removeTerminateListener( - (frame::XTerminateListener*)this ); + static_cast<frame::XTerminateListener*>(this) ); } -void DocumentHolder::DisconnectFrameDocument( sal_Bool bComplete ) +void DocumentHolder::DisconnectFrameDocument( bool bComplete ) { try { uno::Reference< util::XModifyBroadcaster > xModifiable( m_xDocument, uno::UNO_QUERY_THROW ); - xModifiable->removeModifyListener( (util::XModifyListener*)this ); + xModifiable->removeModifyListener( static_cast<util::XModifyListener*>(this) ); } catch( const uno::Exception& ) {} @@ -619,7 +619,7 @@ void DocumentHolder::DisconnectFrameDocument( sal_Bool bComplete ) { uno::Reference< util::XCloseBroadcaster > xBroadcaster( m_xDocument, uno::UNO_QUERY_THROW ); - xBroadcaster->removeCloseListener( (util::XCloseListener*)this ); + xBroadcaster->removeCloseListener( static_cast<util::XCloseListener*>(this) ); } catch( const uno::Exception& ) {} @@ -628,7 +628,7 @@ void DocumentHolder::DisconnectFrameDocument( sal_Bool bComplete ) { uno::Reference< util::XCloseBroadcaster > xBroadcaster( m_xFrame, uno::UNO_QUERY_THROW ); - xBroadcaster->removeCloseListener( (util::XCloseListener*)this ); + xBroadcaster->removeCloseListener( static_cast<util::XCloseListener*>(this) ); } catch( const uno::Exception& ) {} @@ -636,7 +636,7 @@ void DocumentHolder::DisconnectFrameDocument( sal_Bool bComplete ) if ( bComplete ) { m_xFrame.clear(); - m_pIDispatch = NULL; + m_pIDispatch = nullptr; m_xDocument.clear(); } } @@ -652,13 +652,13 @@ void DocumentHolder::CloseDocument() { try { - xCloseable->close( sal_True ); + xCloseable->close( true ); } catch( const uno::Exception& ) {} } - m_pIDispatch = NULL; + m_pIDispatch = nullptr; m_xDocument.clear(); } @@ -669,7 +669,7 @@ void DocumentHolder::CloseFrame() { uno::Reference< util::XCloseBroadcaster > xBroadcaster( m_xFrame, uno::UNO_QUERY_THROW ); - xBroadcaster->removeCloseListener( (util::XCloseListener*)this ); + xBroadcaster->removeCloseListener( static_cast<util::XCloseListener*>(this) ); } catch( const uno::Exception& ) {} @@ -678,7 +678,7 @@ void DocumentHolder::CloseFrame() m_xFrame,uno::UNO_QUERY); if(xCloseable.is()) try { - xCloseable->close(sal_True); + xCloseable->close(true); } catch( const uno::Exception& ) { } @@ -691,7 +691,7 @@ void DocumentHolder::CloseFrame() m_xFrame.clear(); } -void DocumentHolder::SetDocument( const uno::Reference< frame::XModel >& xDoc, sal_Bool bLink ) +void DocumentHolder::SetDocument( const uno::Reference< frame::XModel >& xDoc, bool bLink ) { if ( m_xDocument.is() ) CloseDocument(); @@ -703,19 +703,19 @@ void DocumentHolder::SetDocument( const uno::Reference< frame::XModel >& xDoc, s m_xDocument, uno::UNO_QUERY ); if ( xBroadcaster.is() ) - xBroadcaster->addCloseListener( (util::XCloseListener*)this ); + xBroadcaster->addCloseListener( static_cast<util::XCloseListener*>(this) ); if ( m_xDocument.is() && !m_bLink ) { // set the document mode to embedded uno::Sequence< beans::PropertyValue > aSeq(1); aSeq[0].Name = "SetEmbedded"; - aSeq[0].Value <<= sal_True; + aSeq[0].Value <<= true; m_xDocument->attachResource(OUString(),aSeq); } } -sal_Bool DocumentHolder::ExecuteSuspendCloseFrame() +bool DocumentHolder::ExecuteSuspendCloseFrame() { if ( m_xFrame.is() && m_xFactory.is() ) { @@ -724,15 +724,15 @@ sal_Bool DocumentHolder::ExecuteSuspendCloseFrame() uno::Reference< frame::XController > xController = m_xFrame->getController(); if ( xController.is() ) { - if ( !xController->suspend( sal_True ) ) - return sal_False; + if ( !xController->suspend( true ) ) + return false; FreeOffice(); try { uno::Reference<util::XCloseable> xCloseable( m_xFrame, uno::UNO_QUERY ); if ( xCloseable.is() ) - xCloseable->close(sal_True); + xCloseable->close(true); else { m_xFrame->dispose(); @@ -741,7 +741,7 @@ sal_Bool DocumentHolder::ExecuteSuspendCloseFrame() catch( const util::CloseVetoException& ) { // should be called if the frame could not be closed - xController->suspend( sal_False ); + xController->suspend( false ); } } } @@ -752,7 +752,7 @@ sal_Bool DocumentHolder::ExecuteSuspendCloseFrame() m_xFrame.clear(); } - return sal_True; + return true; } uno::Reference< frame::XFrame2 > DocumentHolder::DocumentFrame() @@ -767,14 +767,14 @@ uno::Reference< frame::XFrame2 > DocumentHolder::DocumentFrame() // is loaded into the frame in ::show() method the terminate listener will be removed // this is so only for outplace activation if( xFrame.is() ) - m_xFrame.set( xFrame->findFrame( OUString("_blank"), 0 ), uno::UNO_QUERY ); + m_xFrame.set( xFrame->findFrame( "_blank", 0 ), uno::UNO_QUERY ); uno::Reference< util::XCloseBroadcaster > xBroadcaster( m_xFrame, uno::UNO_QUERY ); if ( xBroadcaster.is() ) { - xBroadcaster->addCloseListener( (util::XCloseListener*)this ); + xBroadcaster->addCloseListener( static_cast<util::XCloseListener*>(this) ); FreeOffice(); // the frame is part of the desktop } } @@ -808,14 +808,14 @@ void DocumentHolder::ClearInterceptorInternally() m_pInterceptor->DisconnectDocHolder(); m_xInterceptorLocker.clear(); - m_pInterceptor = 0; + m_pInterceptor = nullptr; } void DocumentHolder::ClearInterceptor() { ::osl::MutexGuard aGuard( m_aMutex ); m_xInterceptorLocker.clear(); - m_pInterceptor = 0; + m_pInterceptor = nullptr; } @@ -833,7 +833,7 @@ void DocumentHolder::show() } else if( DocumentFrame().is() ) { - LoadDocInFrame( sal_False ); + LoadDocInFrame( false ); // get rid of second closer if it is there uno::Reference< beans::XPropertySet > xLMProps( m_xFrame->getLayoutManager(), uno::UNO_QUERY ); @@ -848,7 +848,7 @@ void DocumentHolder::show() try { uno::Reference< util::XModifyBroadcaster > xModifiable( m_xDocument, uno::UNO_QUERY_THROW ); - xModifiable->addModifyListener( (util::XModifyListener*)this ); + xModifiable->addModifyListener( static_cast<util::XModifyListener*>(this) ); } catch( const uno::Exception& ) {} @@ -888,7 +888,7 @@ void DocumentHolder::resizeWin( const SIZEL& rNewSize ) if ( aOldSize.cx != rNewSize.cx || aOldSize.cy != rNewSize.cy ) { - HDC hdc = GetDC( NULL ); + HDC hdc = GetDC( nullptr ); SetMapMode( hdc, MM_HIMETRIC ); POINT aOldOffset; @@ -901,7 +901,7 @@ void DocumentHolder::resizeWin( const SIZEL& rNewSize ) aNewOffset.y = rNewSize.cy; bIsOk = LPtoDP( hdc, &aNewOffset, 1 ); - ReleaseDC( NULL, hdc ); + ReleaseDC( nullptr, hdc ); awt::Rectangle aWinRect = xWindow->getPosSize(); @@ -952,7 +952,7 @@ void DocumentHolder::setTitle(const OUString& aDocumentName) { for(sal_Int32 j = 0; j < aSeq.getLength(); ++j) if(aSeq[j].Name == - OUString("UIName")) + "UIName") { aSeq[j].Value >>= m_aFilterName; break; @@ -985,7 +985,7 @@ void DocumentHolder::setTitle(const OUString& aDocumentName) { ::osl::ClearableMutexGuard aGuard( m_aMutex ); - Interceptor* pTmpInter = NULL; + Interceptor* pTmpInter = nullptr; uno::Reference< frame::XDispatchProviderInterceptor > xLock( m_xInterceptorLocker ); if ( xLock.is() && m_pInterceptor ) pTmpInter = m_pInterceptor; @@ -1025,7 +1025,7 @@ IDispatch* DocumentHolder::GetIDispatch() if ( xSupplier.is() ) { uno::Sequence< sal_Int8 > aProcId( 16 ); - rtl_getGlobalProcessId( (sal_uInt8*)aProcId.getArray() ); + rtl_getGlobalProcessId( reinterpret_cast<sal_uInt8*>(aProcId.getArray()) ); try { uno::Any anyResult = xSupplier->createBridge( @@ -1034,10 +1034,9 @@ IDispatch* DocumentHolder::GetIDispatch() bridge::ModelDependent::UNO, bridge::ModelDependent::OLE ); - if ( anyResult.getValueTypeClass() == - cppu::UnoType<sal_uIntPtr>::get().getTypeClass() ) + if ( auto var = o3tl::tryAccess<sal_uIntPtr>(anyResult) ) { - VARIANT* pVariant = *(VARIANT**)anyResult.getValue(); + VARIANT* pVariant = reinterpret_cast<VARIANT*>(*var); if ( pVariant->vt == VT_DISPATCH ) m_pIDispatch = pVariant->pdispVal; @@ -1154,7 +1153,7 @@ HRESULT DocumentHolder::SetContRects(LPCRECT aRect) RECT wi; memset(&wi,0,sizeof(wi)); if(m_pIOleIPFrame) { - m_pIOleIPFrame->GetBorder((LPRECT)&wi); + m_pIOleIPFrame->GetBorder(&wi); m_xContainerWindow->setPosSize( 0,0, wi.right - wi.left, @@ -1177,17 +1176,17 @@ HRESULT DocumentHolder::SetContRects(LPCRECT aRect) HRESULT DocumentHolder::SetObjectRects(LPCRECT aRect, LPCRECT aClip) { - ((LPRECT)aRect)->left -= m_aBorder.left; - ((LPRECT)aRect)->right += m_aBorder.right; - ((LPRECT)aRect)->top -= m_aBorder.top; - ((LPRECT)aRect)->bottom += m_aBorder.bottom; - ((LPRECT)aClip)->left -= m_aBorder.left; - ((LPRECT)aClip)->right += m_aBorder.right; - ((LPRECT)aClip)->top -= m_aBorder.top; - ((LPRECT)aClip)->bottom += m_aBorder.bottom; + const_cast<LPRECT>(aRect)->left -= m_aBorder.left; + const_cast<LPRECT>(aRect)->right += m_aBorder.right; + const_cast<LPRECT>(aRect)->top -= m_aBorder.top; + const_cast<LPRECT>(aRect)->bottom += m_aBorder.bottom; + const_cast<LPRECT>(aClip)->left -= m_aBorder.left; + const_cast<LPRECT>(aClip)->right += m_aBorder.right; + const_cast<LPRECT>(aClip)->top -= m_aBorder.top; + const_cast<LPRECT>(aClip)->bottom += m_aBorder.bottom; if(m_pCHatchWin) - m_pCHatchWin->RectsSet((LPRECT)aRect, (LPRECT)aClip); + m_pCHatchWin->RectsSet(const_cast<LPRECT>(aRect), const_cast<LPRECT>(aClip)); if(m_xEditWindow.is()) { m_xEditWindow->setVisible(false); m_xEditWindow->setPosSize( @@ -1210,7 +1209,7 @@ css::uno::Reference< css::awt::XWindow> SAL_CALL DocumentHolder::getContainerWin if(m_xContainerWindow.is()) return m_xContainerWindow; - uno::Reference<awt::XWindow> xWin(0); + uno::Reference<awt::XWindow> xWin(nullptr); uno::Reference<awt::XToolkit2> xToolkit = awt::Toolkit::create( comphelper::getComponentContext(m_xFactory) ); @@ -1219,7 +1218,7 @@ css::uno::Reference< css::awt::XWindow> SAL_CALL DocumentHolder::getContainerWin m_pIOleIPFrame->GetWindow(&hWnd); uno::Sequence<sal_Int8> aProcessIdent(16); - rtl_getGlobalProcessId((sal_uInt8*)aProcessIdent.getArray()); + rtl_getGlobalProcessId(reinterpret_cast<sal_uInt8*>(aProcessIdent.getArray())); xWin.set( xToolkit->createSystemChild( @@ -1230,7 +1229,7 @@ css::uno::Reference< css::awt::XWindow> SAL_CALL DocumentHolder::getContainerWin RECT wi; memset(&wi,0,sizeof(wi)); - if(xWin.is() && m_pIOleIPFrame->GetBorder((LPRECT)&wi) == NOERROR) { + if(xWin.is() && m_pIOleIPFrame->GetBorder(&wi) == NOERROR) { xWin->setVisible(true); xWin->setPosSize( 0,0, @@ -1245,7 +1244,7 @@ css::uno::Reference< css::awt::XWindow> SAL_CALL DocumentHolder::getContainerWin aProcessIdent,lang::SystemDependent::SYSTEM_WIN32); sal_Int64 tmp; if( aAny >>= tmp ) - SetContainerWindowHandle((HWND) tmp); + SetContainerWindowHandle(reinterpret_cast<HWND>(tmp)); } } } @@ -1261,16 +1260,16 @@ sal_Bool SAL_CALL DocumentHolder::requestDockingAreaSpace( const css::awt::Recta ) { if(m_bOnDeactivate) - return sal_True; + return true; BORDERWIDTHS bw; - SetRect((LPRECT)&bw, + SetRect(&bw, RequestedSpace.X,RequestedSpace.Y, RequestedSpace.Width,RequestedSpace.Height); if( m_pIOleIPFrame ) return m_pIOleIPFrame->RequestBorderSpace(&bw) == NOERROR ; else - return sal_Bool(false); + return false; } @@ -1283,7 +1282,7 @@ void SAL_CALL DocumentHolder::setDockingAreaSpace( const css::awt::Rectangle& Bo return; BORDERWIDTHS bw; - SetRect((LPRECT)&bw, + SetRect(&bw, BorderSpace.X,BorderSpace.Y, BorderSpace.Width,BorderSpace.Height); if( m_pIOleIPFrame ) { @@ -1314,7 +1313,7 @@ void SAL_CALL DocumentHolder::disposing( const css::lang::EventObject& aSource ) { if ( m_xDocument.is() && m_xDocument == aSource.Source ) { - m_pIDispatch = NULL; + m_pIDispatch = nullptr; m_xDocument.clear(); } @@ -1348,7 +1347,7 @@ DocumentHolder::notifyClosing( { uno::Reference< util::XCloseBroadcaster > xEventBroadcaster( aSource.Source, uno::UNO_QUERY_THROW ); - xEventBroadcaster->removeCloseListener( (util::XCloseListener*)this ); + xEventBroadcaster->removeCloseListener( static_cast<util::XCloseListener*>(this) ); } catch( const uno::Exception& ) {} @@ -1356,7 +1355,7 @@ DocumentHolder::notifyClosing( if ( m_xDocument.is() && m_xDocument == aSource.Source ) { // can happen only in case of links - m_pIDispatch = NULL; + m_pIDispatch = nullptr; m_xDocument.clear(); m_xFrame.clear(); @@ -1391,7 +1390,7 @@ DocumentHolder::notifyTermination( aSource.Source, uno::UNO_QUERY ); if ( xDesktop.is() ) - xDesktop->removeTerminateListener( (frame::XTerminateListener*)this ); + xDesktop->removeTerminateListener( static_cast<frame::XTerminateListener*>(this) ); } diff --git a/embedserv/source/embed/ed_idataobj.cxx b/embedserv/source/embed/ed_idataobj.cxx index c51327c35c7d..f682254e1f9d 100644 --- a/embedserv/source/embed/ed_idataobj.cxx +++ b/embedserv/source/embed/ed_idataobj.cxx @@ -35,7 +35,7 @@ using namespace ::com::sun::star; // EmbedDocument_Impl -sal_uInt64 EmbedDocument_Impl::getMetaFileHandle_Impl( sal_Bool isEnhMeta ) +sal_uInt64 EmbedDocument_Impl::getMetaFileHandle_Impl( bool isEnhMeta ) { sal_uInt64 pResult = NULL; @@ -85,13 +85,13 @@ STDMETHODIMP EmbedDocument_Impl::GetData( FORMATETC * pFormatetc, STGMEDIUM * pM if ( !( pFormatetc->tymed & TYMED_ENHMF ) ) return DV_E_TYMED; - HENHMETAFILE hMeta = reinterpret_cast<HENHMETAFILE>( getMetaFileHandle_Impl( sal_True ) ); + HENHMETAFILE hMeta = reinterpret_cast<HENHMETAFILE>( getMetaFileHandle_Impl( true ) ); if ( hMeta ) { pMedium->tymed = TYMED_ENHMF; pMedium->hEnhMetaFile = hMeta; - pMedium->pUnkForRelease = NULL; + pMedium->pUnkForRelease = nullptr; return S_OK; } @@ -103,13 +103,13 @@ STDMETHODIMP EmbedDocument_Impl::GetData( FORMATETC * pFormatetc, STGMEDIUM * pM if ( !( pFormatetc->tymed & TYMED_MFPICT ) ) return DV_E_TYMED; - HGLOBAL hMeta = reinterpret_cast<HGLOBAL>( getMetaFileHandle_Impl( sal_False ) ); + HGLOBAL hMeta = reinterpret_cast<HGLOBAL>( getMetaFileHandle_Impl( false ) ); if ( hMeta ) { pMedium->tymed = TYMED_MFPICT; pMedium->hMetaFilePict = hMeta; - pMedium->pUnkForRelease = NULL; + pMedium->pUnkForRelease = nullptr; return S_OK; } @@ -126,7 +126,7 @@ STDMETHODIMP EmbedDocument_Impl::GetData( FORMATETC * pFormatetc, STGMEDIUM * pM return DV_E_TYMED; CComPtr< IStorage > pNewStg; - HRESULT hr = StgCreateDocfile( NULL, STGM_CREATE | STGM_READWRITE | STGM_DELETEONRELEASE, 0, &pNewStg ); + HRESULT hr = StgCreateDocfile( nullptr, STGM_CREATE | STGM_READWRITE | STGM_DELETEONRELEASE, 0, &pNewStg ); if ( FAILED( hr ) || !pNewStg ) return STG_E_MEDIUMFULL; hr = SaveTo_Impl( pNewStg ); @@ -135,7 +135,7 @@ STDMETHODIMP EmbedDocument_Impl::GetData( FORMATETC * pFormatetc, STGMEDIUM * pM pMedium->tymed = TYMED_ISTORAGE; pMedium->pstg = pNewStg; pMedium->pstg->AddRef(); - pMedium->pUnkForRelease = ( IUnknown* )pNewStg; + pMedium->pUnkForRelease = static_cast<IUnknown*>(pNewStg); return S_OK; } @@ -171,7 +171,7 @@ STDMETHODIMP EmbedDocument_Impl::GetDataHere( FORMATETC * pFormatetc, STGMEDIUM if ( FAILED( hr ) ) return STG_E_MEDIUMFULL; pMedium->tymed = TYMED_ISTORAGE; - pMedium->pUnkForRelease = NULL; + pMedium->pUnkForRelease = nullptr; return S_OK; } @@ -225,7 +225,7 @@ STDMETHODIMP EmbedDocument_Impl::GetCanonicalFormatEtc( FORMATETC * pFormatetcIn if ( !pFormatetcIn || !pFormatetcOut ) return DV_E_FORMATETC; - pFormatetcOut->ptd = NULL; + pFormatetcOut->ptd = nullptr; pFormatetcOut->cfFormat = pFormatetcIn->cfFormat; pFormatetcOut->dwAspect = DVASPECT_CONTENT; @@ -272,7 +272,7 @@ STDMETHODIMP EmbedDocument_Impl::DAdvise( FORMATETC * pFormatetc, DWORD advf, IA if ( !SUCCEEDED( CreateDataAdviseHolder( &m_pDAdviseHolder ) ) || !m_pDAdviseHolder ) return E_OUTOFMEMORY; - return m_pDAdviseHolder->Advise( (IDataObject*)this, pFormatetc, advf, pAdvSink, pdwConnection ); + return m_pDAdviseHolder->Advise( static_cast<IDataObject*>(this), pFormatetc, advf, pAdvSink, pdwConnection ); } STDMETHODIMP EmbedDocument_Impl::DUnadvise( DWORD dwConnection ) diff --git a/embedserv/source/embed/ed_iinplace.cxx b/embedserv/source/embed/ed_iinplace.cxx index 1ea81f2d73bb..d013fee3fd15 100644 --- a/embedserv/source/embed/ed_iinplace.cxx +++ b/embedserv/source/embed/ed_iinplace.cxx @@ -26,7 +26,7 @@ STDMETHODIMP EmbedDocument_Impl::GetWindow(HWND *hWnd) OSL_ENSURE(m_pDocHolder,"no document for inplace activation"); *hWnd = m_pDocHolder->GetTopMostWinHandle(); - if(*hWnd != NULL) + if(*hWnd != nullptr) return NOERROR; else return ERROR; diff --git a/embedserv/source/embed/ed_ioleobject.cxx b/embedserv/source/embed/ed_ioleobject.cxx index 3a79799231df..35557d25ff2b 100644 --- a/embedserv/source/embed/ed_ioleobject.cxx +++ b/embedserv/source/embed/ed_ioleobject.cxx @@ -25,10 +25,6 @@ using namespace ::com::sun::star; - -extern OUString getFilterNameFromGUID_Impl( GUID* ); - - // IOleObject @@ -51,10 +47,10 @@ STDMETHODIMP EmbedDocument_Impl::SetHostNames( LPCOLESTR szContainerApp, LPCOLES { m_pDocHolder->setTitle( OUString( - (sal_Unicode*)szContainerObj)); + szContainerObj)); m_pDocHolder->setContainerName( OUString( - (sal_Unicode*)szContainerApp)); + szContainerApp)); } return S_OK; @@ -149,7 +145,7 @@ STDMETHODIMP EmbedDocument_Impl::DoVerb( return OLEOBJ_S_CANNOT_DOVERB_NOW; // an object can not handle any Verbs in Hands off mode - if ( m_pMasterStorage == NULL || m_pOwnStream == NULL ) + if ( m_pMasterStorage == nullptr || m_pOwnStream == nullptr ) return OLE_E_CANT_BINDTOSOURCE; @@ -427,8 +423,8 @@ HRESULT EmbedDocument_Impl::SaveObject() OUString aPreservFileName = m_aFileName; // in case of links the containers does not provide client site sometimes - hr = Save( (LPCOLESTR)NULL, FALSE ); // triggers saving to the link location - SaveCompleted( (LPCOLESTR)aPreservFileName.getStr() ); + hr = Save( static_cast<LPCOLESTR>(nullptr), FALSE ); // triggers saving to the link location + SaveCompleted( aPreservFileName.getStr() ); } notify( false ); @@ -458,7 +454,7 @@ void EmbedDocument_Impl::notify( bool bDataChanged ) iAdvise->second->OnViewChange( DVASPECT_CONTENT, -1 ); if ( m_pDAdviseHolder && bDataChanged ) - m_pDAdviseHolder->SendOnDataChange( (IDataObject*)this, 0, 0 ); + m_pDAdviseHolder->SendOnDataChange( static_cast<IDataObject*>(this), 0, 0 ); } void EmbedDocument_Impl::Deactivate() diff --git a/embedserv/source/embed/ed_ipersiststr.cxx b/embedserv/source/embed/ed_ipersiststr.cxx index 9679c4a1908f..86a2d93f6a8d 100644 --- a/embedserv/source/embed/ed_ipersiststr.cxx +++ b/embedserv/source/embed/ed_ipersiststr.cxx @@ -41,9 +41,11 @@ #include <osl/diagnose.h> #include <sal/types.h> +#include <guid.hxx> + #include <string.h> -#define EXT_STREAM_LENGTH 16 +#define EXT_STREAM_LENGTH 4 namespace { @@ -53,15 +55,11 @@ const sal_Int32 nConstBufferSize = 32000; using namespace ::com::sun::star; -extern OUString getStorageTypeFromGUID_Impl( GUID* guid ); -extern OUString getServiceNameFromGUID_Impl( GUID* ); -extern OUString getFilterNameFromGUID_Impl( GUID* ); - const OUString aOfficeEmbedStreamName( "package_stream" ); const OUString aExtentStreamName( "properties_stream" ); uno::Reference< io::XInputStream > createTempXInStreamFromIStream( - uno::Reference< lang::XMultiServiceFactory > xFactory, + uno::Reference< lang::XMultiServiceFactory > const & xFactory, IStream *pStream ) { uno::Reference< io::XInputStream > xResult; @@ -88,7 +86,7 @@ uno::Reference< io::XInputStream > createTempXInStreamFromIStream( sal_uInt32 nRead = 0; do { - pStream->Read( (void*)aBuffer.getArray(), nConstBufferSize, &nRead ); + pStream->Read( aBuffer.getArray(), nConstBufferSize, &nRead ); if ( nRead < nConstBufferSize ) aBuffer.realloc( nRead ); @@ -114,7 +112,7 @@ uno::Reference< io::XInputStream > createTempXInStreamFromIStream( return xResult; } -HRESULT copyXTempOutToIStream( uno::Reference< io::XOutputStream > xTempOut, IStream* pStream ) +HRESULT copyXTempOutToIStream( uno::Reference< io::XOutputStream > const & xTempOut, IStream* pStream ) { if ( !xTempOut.is() || !pStream ) return E_FAIL; @@ -152,7 +150,7 @@ HRESULT copyXTempOutToIStream( uno::Reference< io::XOutputStream > xTempOut, ISt } sal_uInt32 nWritten = 0; - hr = pStream->Write( (void*)aBuffer.getArray(), nReadBytes, &nWritten ); + hr = pStream->Write( aBuffer.getArray(), nReadBytes, &nWritten ); if ( !SUCCEEDED( hr ) || nWritten != nReadBytes ) return E_FAIL; @@ -169,9 +167,9 @@ EmbedDocument_Impl::EmbedDocument_Impl( const uno::Reference< lang::XMultiServic : m_refCount( 0L ) , m_xFactory( xFactory ) , m_guid( *guid ) -, m_bIsDirty( sal_False ) +, m_bIsDirty( false ) , m_nAdviseNum( 0 ) -, m_bIsInVerbHandling( sal_False ) +, m_bIsInVerbHandling( false ) //, m_bLoadedFromFile( sal_False ) { m_xOwnAccess = new EmbeddedDocumentInstanceAccess_Impl( this ); @@ -186,7 +184,7 @@ EmbedDocument_Impl::~EmbedDocument_Impl() if ( m_pDocHolder->HasFrame() && m_pDocHolder->IsLink() ) { // a link with frame should be only disconnected, not closed - m_pDocHolder->DisconnectFrameDocument( sal_True ); + m_pDocHolder->DisconnectFrameDocument( true ); } else { @@ -197,7 +195,7 @@ EmbedDocument_Impl::~EmbedDocument_Impl() m_pDocHolder->release(); } -uno::Sequence< beans::PropertyValue > EmbedDocument_Impl::fillArgsForLoading_Impl( uno::Reference< io::XInputStream > xStream, DWORD /*nStreamMode*/, LPCOLESTR pFilePath ) +uno::Sequence< beans::PropertyValue > EmbedDocument_Impl::fillArgsForLoading_Impl( uno::Reference< io::XInputStream > const & xStream, DWORD /*nStreamMode*/, LPCOLESTR pFilePath ) { uno::Sequence< beans::PropertyValue > aArgs( 3 ); @@ -239,7 +237,7 @@ uno::Sequence< beans::PropertyValue > EmbedDocument_Impl::fillArgsForLoading_Imp return aArgs; } -uno::Sequence< beans::PropertyValue > EmbedDocument_Impl::fillArgsForStoring_Impl( uno::Reference< io::XOutputStream > xStream) +uno::Sequence< beans::PropertyValue > EmbedDocument_Impl::fillArgsForStoring_Impl( uno::Reference< io::XOutputStream > const & xStream) { uno::Sequence< beans::PropertyValue > aArgs( xStream.is() ? 2 : 1 ); @@ -264,7 +262,7 @@ HRESULT EmbedDocument_Impl::SaveTo_Impl( IStorage* pStg ) // should not enter NoScribble mode CComPtr< IStream > pOrigOwn = m_pOwnStream; CComPtr< IStream > pOrigExt = m_pExtStream; - HRESULT hr = Save( pStg, sal_False ); + HRESULT hr = Save( pStg, false ); pStg->Commit( STGC_ONLYIFCURRENT ); m_pOwnStream = pOrigOwn; m_pExtStream = pOrigExt; @@ -280,65 +278,65 @@ STDMETHODIMP EmbedDocument_Impl::QueryInterface( REFIID riid, void FAR* FAR* ppv if(IsEqualIID(riid, IID_IUnknown)) { AddRef(); - *ppv = (IUnknown*) (IPersistStorage*) this; + *ppv = static_cast<IUnknown*>(static_cast<IPersistStorage*>(this)); return S_OK; } else if (IsEqualIID(riid, IID_IPersist)) { AddRef(); - *ppv = (IPersist*) (IPersistStorage*) this; + *ppv = static_cast<IPersist*>(static_cast<IPersistStorage*>(this)); return S_OK; } else if (IsEqualIID(riid, IID_IExternalConnection)) { AddRef(); - *ppv = (IExternalConnection*) this; + *ppv = static_cast<IExternalConnection*>(this); return S_OK; } else if (IsEqualIID(riid, IID_IPersistStorage)) { AddRef(); - *ppv = (IPersistStorage*) this; + *ppv = static_cast<IPersistStorage*>(this); return S_OK; } else if (IsEqualIID(riid, IID_IDataObject)) { AddRef(); - *ppv = (IDataObject*) this; + *ppv = static_cast<IDataObject*>(this); return S_OK; } else if (IsEqualIID(riid, IID_IOleObject)) { AddRef(); - *ppv = (IOleObject*) this; + *ppv = static_cast<IOleObject*>(this); return S_OK; } else if (IsEqualIID(riid, IID_IOleWindow)) { AddRef(); - *ppv = (IOleWindow*) this; + *ppv = static_cast<IOleWindow*>(this); return S_OK; } else if (IsEqualIID(riid, IID_IOleInPlaceObject)) { AddRef(); - *ppv = (IOleInPlaceObject*) this; + *ppv = static_cast<IOleInPlaceObject*>(this); return S_OK; } else if (IsEqualIID(riid, IID_IPersistFile)) { AddRef(); - *ppv = (IPersistFile*) this; + *ppv = static_cast<IPersistFile*>(this); return S_OK; } else if (IsEqualIID(riid, IID_IDispatch)) { AddRef(); - *ppv = (IDispatch*) this; + *ppv = static_cast<IDispatch*>(this); return S_OK; } - *ppv = NULL; + *ppv = nullptr; return ResultFromScode(E_NOINTERFACE); } @@ -427,7 +425,7 @@ STDMETHODIMP EmbedDocument_Impl::InitNew( IStorage *pStg ) CLIPFORMAT cf = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" ); hr = WriteFmtUserTypeStg( pStg, cf, // ??? - reinterpret_cast<LPWSTR>(( sal_Unicode* )aCurType.getStr()) ); + const_cast<sal_Unicode *>(aCurType.getStr()) ); if ( hr == S_OK ) { @@ -449,7 +447,7 @@ STDMETHODIMP EmbedDocument_Impl::InitNew( IStorage *pStg ) { m_pMasterStorage = pStg; - m_bIsDirty = sal_True; + m_bIsDirty = true; } else hr = E_FAIL; @@ -486,7 +484,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( IStorage *pStg ) DWORD nStreamMode = aStat.grfMode; hr = pStg->OpenStream( reinterpret_cast<LPCWSTR>(aOfficeEmbedStreamName.getStr()), - 0, + nullptr, nStreamMode & 0x73, 0, &m_pOwnStream ); @@ -495,7 +493,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( IStorage *pStg ) if ( SUCCEEDED( hr ) ) { hr = pStg->OpenStream( reinterpret_cast<LPCWSTR>(aExtentStreamName.getStr()), - 0, + nullptr, nStreamMode & 0x73, 0, &m_pExtStream ); @@ -512,9 +510,9 @@ STDMETHODIMP EmbedDocument_Impl::Load( IStorage *pStg ) if ( SUCCEEDED( hr ) ) { sal_uInt32 nRead; - sal_Int8 aInf[EXT_STREAM_LENGTH]; - hr = m_pExtStream->Read( (void*)aInf, EXT_STREAM_LENGTH, &nRead ); - if ( nRead != EXT_STREAM_LENGTH ) hr = E_FAIL; + sal_Int32 aInf[EXT_STREAM_LENGTH]; + hr = m_pExtStream->Read( aInf, sizeof aInf, &nRead ); + if ( nRead != sizeof aInf ) hr = E_FAIL; if ( SUCCEEDED( hr ) ) { @@ -522,8 +520,8 @@ STDMETHODIMP EmbedDocument_Impl::Load( IStorage *pStg ) // aRectToSet.top = *((sal_Int32*)&aInf[4]); // aRectToSet.right = *((sal_Int32*)&aInf[8]); // aRectToSet.bottom = *((sal_Int32*)&aInf[12]); - aSizeToSet.cx = *((sal_Int32*)&aInf[8]) - *((sal_Int32*)aInf); - aSizeToSet.cy = *((sal_Int32*)&aInf[12]) - *((sal_Int32*)&aInf[4]); + aSizeToSet.cx = aInf[2] - aInf[0]; + aSizeToSet.cy = aInf[3] - aInf[1]; } } } @@ -589,7 +587,7 @@ STDMETHODIMP EmbedDocument_Impl::Save( IStorage *pStgSave, BOOL fSameAsLoad ) if ( !fSameAsLoad && pStgSave != m_pMasterStorage ) { OSL_ENSURE( m_pMasterStorage, "How could the document be initialized without storage!??\n" ); - HRESULT hr = m_pMasterStorage->CopyTo( NULL, NULL, NULL, pStgSave ); + HRESULT hr = m_pMasterStorage->CopyTo( NULL, nullptr, nullptr, pStgSave ); if ( FAILED( hr ) ) return E_FAIL; STATSTG aStat; @@ -627,7 +625,7 @@ STDMETHODIMP EmbedDocument_Impl::Save( IStorage *pStgSave, BOOL fSameAsLoad ) { try { - xStorable->storeToURL( OUString( "private:stream" ), + xStorable->storeToURL( "private:stream", fillArgsForStoring_Impl( xTempOut ) ); hr = copyXTempOutToIStream( xTempOut, pTargetStream ); if ( SUCCEEDED( hr ) ) @@ -644,14 +642,10 @@ STDMETHODIMP EmbedDocument_Impl::Save( IStorage *pStgSave, BOOL fSameAsLoad ) if ( SUCCEEDED( hr ) ) { sal_uInt32 nWritten; - sal_Int8 aInf[EXT_STREAM_LENGTH]; - *((sal_Int32*)aInf) = 0; - *((sal_Int32*)&aInf[4]) = 0; - *((sal_Int32*)&aInf[8]) = aSize.cx; - *((sal_Int32*)&aInf[12]) = aSize.cy; + sal_Int32 aInf[EXT_STREAM_LENGTH] = {0, 0, aSize.cx, aSize.cy}; - hr = pNewExtStream->Write( (void*)aInf, EXT_STREAM_LENGTH, &nWritten ); - if ( nWritten != EXT_STREAM_LENGTH ) hr = E_FAIL; + hr = pNewExtStream->Write( aInf, sizeof aInf, &nWritten ); + if ( nWritten != sizeof aInf ) hr = E_FAIL; if ( SUCCEEDED( hr ) ) { @@ -661,8 +655,8 @@ STDMETHODIMP EmbedDocument_Impl::Save( IStorage *pStgSave, BOOL fSameAsLoad ) { uno::Reference< util::XModifiable > xMod( m_pDocHolder->GetDocument(), uno::UNO_QUERY ); if ( xMod.is() ) - xMod->setModified( sal_False ); - m_bIsDirty = sal_False; + xMod->setModified( false ); + m_bIsDirty = false; } } } @@ -697,20 +691,20 @@ STDMETHODIMP EmbedDocument_Impl::SaveCompleted( IStorage *pStgNew ) DWORD nStreamMode = aStat.grfMode; hr = m_pMasterStorage->OpenStream( reinterpret_cast<LPCWSTR>(aOfficeEmbedStreamName.getStr()), - 0, + nullptr, nStreamMode & 0x73, 0, &m_pOwnStream ); if ( FAILED( hr ) || !m_pOwnStream ) return E_OUTOFMEMORY; hr = m_pMasterStorage->OpenStream( reinterpret_cast<LPCWSTR>(aExtentStreamName.getStr()), - 0, + nullptr, nStreamMode & 0x73, 0, &m_pExtStream ); if ( FAILED( hr ) || !m_pExtStream ) return E_OUTOFMEMORY; - sal_Bool bModified = sal_False; + bool bModified = false; uno::Reference< util::XModifiable > xMod( m_pDocHolder->GetDocument(), uno::UNO_QUERY ); if ( xMod.is() ) bModified = xMod->isModified(); @@ -748,7 +742,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ ) return E_FAIL; DWORD nStreamMode = STGM_CREATE | STGM_READWRITE | STGM_DELETEONRELEASE | STGM_SHARE_EXCLUSIVE; - HRESULT hr = StgCreateDocfile( NULL, + HRESULT hr = StgCreateDocfile( nullptr, nStreamMode , 0, &m_pMasterStorage ); @@ -759,7 +753,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ ) CLIPFORMAT cf = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" ); hr = WriteFmtUserTypeStg( m_pMasterStorage, cf, // ??? - reinterpret_cast<LPWSTR>(( sal_Unicode* )aCurType.getStr()) ); + const_cast<sal_Unicode *>(aCurType.getStr()) ); if ( FAILED( hr ) ) return E_FAIL; hr = m_pMasterStorage->SetClass( m_guid ); @@ -785,7 +779,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ ) uno::UNO_QUERY ); if ( aDocument.is() ) { - m_pDocHolder->SetDocument( aDocument, sal_True ); + m_pDocHolder->SetDocument( aDocument, true ); uno::Reference< frame::XLoadable > xLoadable( m_pDocHolder->GetDocument(), uno::UNO_QUERY ); if( xLoadable.is() ) @@ -810,7 +804,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ ) cf = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" ); hr = WriteFmtUserTypeStg( m_pMasterStorage, cf, // ??? - reinterpret_cast<LPWSTR>(( sal_Unicode* )aCurType.getStr()) ); + const_cast<sal_Unicode *>(aCurType.getStr()) ); if ( SUCCEEDED( hr ) ) { @@ -826,20 +820,16 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ ) if ( SUCCEEDED( hr ) ) { sal_uInt32 nWritten; - sal_Int8 aInf[EXT_STREAM_LENGTH]; - *((sal_Int32*)aInf) = 0; - *((sal_Int32*)&aInf[4]) = 0; - *((sal_Int32*)&aInf[8]) = aSize.cx; - *((sal_Int32*)&aInf[12]) = aSize.cy; - - hr = m_pExtStream->Write( (void*)aInf, EXT_STREAM_LENGTH, &nWritten ); - if ( nWritten != EXT_STREAM_LENGTH ) hr = E_FAIL; + sal_Int32 aInf[EXT_STREAM_LENGTH] = {0, 0, aSize.cx, aSize.cy}; + + hr = m_pExtStream->Write( aInf, sizeof aInf, &nWritten ); + if ( nWritten != sizeof aInf ) hr = E_FAIL; } } } if ( SUCCEEDED( hr ) ) - m_bIsDirty = sal_True; + m_bIsDirty = true; else hr = E_FAIL; } @@ -847,9 +837,9 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ ) if ( FAILED( hr ) ) { m_pDocHolder->CloseDocument(); - m_pOwnStream = NULL; - m_pExtStream = NULL; - m_pMasterStorage = NULL; + m_pOwnStream = nullptr; + m_pExtStream = nullptr; + m_pMasterStorage = nullptr; } } @@ -912,7 +902,7 @@ STDMETHODIMP EmbedDocument_Impl::GetCurFile( LPOLESTR *ppszFileName ) HRESULT hr = CoGetMalloc( 1, &pMalloc ); if ( FAILED( hr ) || !pMalloc ) return E_FAIL; - *ppszFileName = (LPOLESTR)( pMalloc->Alloc( sizeof( sal_Unicode ) * ( m_aFileName.getLength() + 1 ) ) ); + *ppszFileName = static_cast<LPOLESTR>( pMalloc->Alloc( sizeof( sal_Unicode ) * ( m_aFileName.getLength() + 1 ) ) ); wcsncpy( *ppszFileName, reinterpret_cast<LPCWSTR>(m_aFileName.getStr()), m_aFileName.getLength() + 1 ); return m_aFileName.getLength() ? S_OK : S_FALSE; @@ -928,12 +918,12 @@ LockedEmbedDocument_Impl EmbeddedDocumentInstanceAccess_Impl::GetEmbedDocument() void EmbeddedDocumentInstanceAccess_Impl::ClearEmbedDocument() { ::osl::MutexGuard aGuard( m_aMutex ); - m_pEmbedDocument = NULL; + m_pEmbedDocument = nullptr; } LockedEmbedDocument_Impl::LockedEmbedDocument_Impl() -: m_pEmbedDocument( NULL ) +: m_pEmbedDocument( nullptr ) {} LockedEmbedDocument_Impl::LockedEmbedDocument_Impl( EmbedDocument_Impl* pEmbedDocument ) diff --git a/embedserv/source/embed/esdll.cxx b/embedserv/source/embed/esdll.cxx index 1c70d78327f6..d998f0134297 100644 --- a/embedserv/source/embed/esdll.cxx +++ b/embedserv/source/embed/esdll.cxx @@ -67,7 +67,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) if (dwReason == DLL_PROCESS_ATTACH) { - _Module.Init(ObjectMap, hInstance, NULL); + _Module.Init(ObjectMap, hInstance); DisableThreadLibraryCalls(hInstance); } else if (dwReason == DLL_PROCESS_DETACH) diff --git a/embedserv/source/embed/guid.cxx b/embedserv/source/embed/guid.cxx index bdbb015a0e40..882408f57869 100644 --- a/embedserv/source/embed/guid.cxx +++ b/embedserv/source/embed/guid.cxx @@ -24,6 +24,8 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/container/XNameAccess.hpp> +#include <guid.hxx> + OUString getStorageTypeFromGUID_Impl( GUID* guid ) { if ( *guid == OID_WriterTextServer ) diff --git a/embedserv/source/embed/guid.hxx b/embedserv/source/embed/guid.hxx new file mode 100644 index 000000000000..a970fb4fb8e4 --- /dev/null +++ b/embedserv/source/embed/guid.hxx @@ -0,0 +1,37 @@ +/* -*- 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_EMBEDSERV_SOURCE_EMBED_GUID_HXX +#define INCLUDED_EMBEDSERV_SOURCE_EMBED_GUID_HXX + +#include <sal/config.h> + +#include <rtl/ustring.hxx> + +#include <common.h> + +OUString getFilterNameFromGUID_Impl( GUID* ); + +OUString getServiceNameFromGUID_Impl( GUID* ); + +OUString getStorageTypeFromGUID_Impl( GUID* guid ); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/embedserv/source/embed/iipaobj.cxx b/embedserv/source/embed/iipaobj.cxx index 081a6c301eb9..528d4bf35068 100644 --- a/embedserv/source/embed/iipaobj.cxx +++ b/embedserv/source/embed/iipaobj.cxx @@ -37,7 +37,7 @@ CIIAObj::~CIIAObj() STDMETHODIMP CIIAObj::QueryInterface(REFIID riid, LPVOID FAR *ppv) { - *ppv=NULL; + *ppv=nullptr; if(IID_IUnknown==riid || IID_IOleWindow==riid || @@ -45,9 +45,9 @@ STDMETHODIMP CIIAObj::QueryInterface(REFIID riid, LPVOID FAR *ppv) *ppv=this; //AddRef any interface we'll return. - if (NULL!=*ppv) + if (nullptr!=*ppv) { - ((LPUNKNOWN)*ppv)->AddRef(); + static_cast<LPUNKNOWN>(*ppv)->AddRef(); return NOERROR; } diff --git a/embedserv/source/embed/intercept.cxx b/embedserv/source/embed/intercept.cxx index 2f412d338db2..3bde41481447 100644 --- a/embedserv/source/embed/intercept.cxx +++ b/embedserv/source/embed/intercept.cxx @@ -83,20 +83,20 @@ void SAL_CALL Interceptor::dispose() if(m_pStatCL) m_pStatCL->disposeAndClear( aEvt ); - m_xSlaveDispatchProvider = 0; - m_xMasterDispatchProvider = 0; + m_xSlaveDispatchProvider = nullptr; + m_xMasterDispatchProvider = nullptr; } Interceptor::Interceptor( const ::rtl::Reference< EmbeddedDocumentInstanceAccess_Impl >& xOleAccess, DocumentHolder* pDocH, - sal_Bool bLink ) + bool bLink ) : m_xOleAccess( xOleAccess ), m_xDocHLocker( static_cast< ::cppu::OWeakObject* >( pDocH ) ), m_pDocH(pDocH), - m_pDisposeEventListeners(0), - m_pStatCL(0), + m_pDisposeEventListeners(nullptr), + m_pStatCL(nullptr), m_bLink( bLink ) { m_aInterceptedURL[0] = ".uno:Save"; @@ -113,7 +113,7 @@ Interceptor::~Interceptor() delete m_pDisposeEventListeners; delete m_pStatCL; - DocumentHolder* pTmpDocH = NULL; + DocumentHolder* pTmpDocH = nullptr; uno::Reference< uno::XInterface > xLock; { osl::MutexGuard aGuard(m_aMutex); @@ -130,8 +130,8 @@ void Interceptor::DisconnectDocHolder() { osl::MutexGuard aGuard(m_aMutex); m_xDocHLocker.clear(); - m_pDocH = NULL; - m_xOleAccess = NULL; + m_pDocH = nullptr; + m_xOleAccess = nullptr; } //XDispatch @@ -169,7 +169,7 @@ Interceptor::dispatch( { if ( aNewArgs[nInd].Name == "SaveTo" ) { - aNewArgs[nInd].Value <<= sal_True; + aNewArgs[nInd].Value <<= true; break; } nInd++; @@ -179,11 +179,11 @@ Interceptor::dispatch( { aNewArgs.realloc( nInd + 1 ); aNewArgs[nInd].Name = "SaveTo"; - aNewArgs[nInd].Value <<= sal_True; + aNewArgs[nInd].Value <<= true; } uno::Reference< frame::XDispatch > xDispatch = m_xSlaveDispatchProvider->queryDispatch( - URL, OUString( "_self" ), 0 ); + URL, "_self", 0 ); if ( xDispatch.is() ) xDispatch->dispatch( URL, aNewArgs ); } @@ -196,7 +196,7 @@ void Interceptor::generateFeatureStateEvent() { if( m_pStatCL ) { - DocumentHolder* pTmpDocH = NULL; + DocumentHolder* pTmpDocH = nullptr; uno::Reference< uno::XInterface > xLock; { osl::MutexGuard aGuard(m_aMutex); @@ -223,14 +223,14 @@ void Interceptor::generateFeatureStateEvent() continue; frame::FeatureStateEvent aStateEvent; - aStateEvent.IsEnabled = sal_True; - aStateEvent.Requery = sal_False; + aStateEvent.IsEnabled = true; + aStateEvent.Requery = false; if(i == 0) { aStateEvent.FeatureURL.Complete = m_aInterceptedURL[0]; aStateEvent.FeatureDescriptor = "Update"; - aStateEvent.State <<= (OUString("($1) ") + aTitle); + aStateEvent.State <<= ("($1) " + aTitle); } else if ( i == 5 ) @@ -243,7 +243,7 @@ void Interceptor::generateFeatureStateEvent() { aStateEvent.FeatureURL.Complete = m_aInterceptedURL[i]; aStateEvent.FeatureDescriptor = "Close and Return"; - aStateEvent.State <<= (OUString("($2) ") + aTitle); + aStateEvent.State <<= ("($2) " + aTitle); } @@ -274,7 +274,7 @@ Interceptor::addStatusListener( if( !m_bLink && URL.Complete == m_aInterceptedURL[0] ) { // Save - DocumentHolder* pTmpDocH = NULL; + DocumentHolder* pTmpDocH = nullptr; uno::Reference< uno::XInterface > xLock; { osl::MutexGuard aGuard(m_aMutex); @@ -290,9 +290,9 @@ Interceptor::addStatusListener( frame::FeatureStateEvent aStateEvent; aStateEvent.FeatureURL.Complete = m_aInterceptedURL[0]; aStateEvent.FeatureDescriptor = "Update"; - aStateEvent.IsEnabled = sal_True; - aStateEvent.Requery = sal_False; - aStateEvent.State <<= (OUString("($1) ") + aTitle ); + aStateEvent.IsEnabled = true; + aStateEvent.Requery = false; + aStateEvent.State <<= ("($1) " + aTitle ); Control->statusChanged(aStateEvent); { @@ -312,7 +312,7 @@ Interceptor::addStatusListener( URL.Complete == m_aInterceptedURL[++i] || URL.Complete == m_aInterceptedURL[++i] ) ) { // Close and return - DocumentHolder* pTmpDocH = NULL; + DocumentHolder* pTmpDocH = nullptr; uno::Reference< uno::XInterface > xLock; { osl::MutexGuard aGuard(m_aMutex); @@ -328,9 +328,9 @@ Interceptor::addStatusListener( frame::FeatureStateEvent aStateEvent; aStateEvent.FeatureURL.Complete = m_aInterceptedURL[i]; aStateEvent.FeatureDescriptor = "Close and Return"; - aStateEvent.IsEnabled = sal_True; - aStateEvent.Requery = sal_False; - aStateEvent.State <<= (OUString("($2) ") + aTitle ); + aStateEvent.IsEnabled = true; + aStateEvent.Requery = false; + aStateEvent.State <<= ("($2) " + aTitle ); Control->statusChanged(aStateEvent); @@ -350,8 +350,8 @@ Interceptor::addStatusListener( frame::FeatureStateEvent aStateEvent; aStateEvent.FeatureURL.Complete = m_aInterceptedURL[5]; aStateEvent.FeatureDescriptor = "SaveCopyTo"; - aStateEvent.IsEnabled = sal_True; - aStateEvent.Requery = sal_False; + aStateEvent.IsEnabled = true; + aStateEvent.Requery = false; aStateEvent.State <<= (OUString("($3)")); Control->statusChanged(aStateEvent); @@ -422,23 +422,23 @@ Interceptor::queryDispatch( { osl::MutexGuard aGuard(m_aMutex); if( !m_bLink && URL.Complete == m_aInterceptedURL[0] ) - return (frame::XDispatch*)this; + return static_cast<frame::XDispatch*>(this); else if(URL.Complete == m_aInterceptedURL[1]) - return (frame::XDispatch*)0 ; + return nullptr; else if( !m_bLink && URL.Complete == m_aInterceptedURL[2] ) - return (frame::XDispatch*)this; + return static_cast<frame::XDispatch*>(this); else if( !m_bLink && URL.Complete == m_aInterceptedURL[3] ) - return (frame::XDispatch*)this; + return static_cast<frame::XDispatch*>(this); else if( !m_bLink && URL.Complete == m_aInterceptedURL[4] ) - return (frame::XDispatch*)this; + return static_cast<frame::XDispatch*>(this); else if(URL.Complete == m_aInterceptedURL[5]) - return (frame::XDispatch*)this; + return static_cast<frame::XDispatch*>(this); else { if(m_xSlaveDispatchProvider.is()) return m_xSlaveDispatchProvider->queryDispatch( URL,TargetFrameName,SearchFlags); else - return uno::Reference<frame::XDispatch>(0); + return uno::Reference<frame::XDispatch>(nullptr); } } @@ -458,17 +458,17 @@ Interceptor::queryDispatches( for(sal_Int32 i = 0; i < Requests.getLength(); ++i) if ( !m_bLink && m_aInterceptedURL[0] == Requests[i].FeatureURL.Complete ) - aRet[i] = (frame::XDispatch*) this; + aRet[i] = static_cast<frame::XDispatch*>(this); else if(m_aInterceptedURL[1] == Requests[i].FeatureURL.Complete) - aRet[i] = (frame::XDispatch*) 0; + aRet[i] = nullptr; else if( !m_bLink && m_aInterceptedURL[2] == Requests[i].FeatureURL.Complete ) - aRet[i] = (frame::XDispatch*) this; + aRet[i] = static_cast<frame::XDispatch*>(this); else if( !m_bLink && m_aInterceptedURL[3] == Requests[i].FeatureURL.Complete ) - aRet[i] = (frame::XDispatch*) this; + aRet[i] = static_cast<frame::XDispatch*>(this); else if( !m_bLink && m_aInterceptedURL[4] == Requests[i].FeatureURL.Complete ) - aRet[i] = (frame::XDispatch*) this; + aRet[i] = static_cast<frame::XDispatch*>(this); else if(m_aInterceptedURL[5] == Requests[i].FeatureURL.Complete) - aRet[i] = (frame::XDispatch*) this; + aRet[i] = static_cast<frame::XDispatch*>(this); return aRet; } diff --git a/embedserv/source/embed/register.cxx b/embedserv/source/embed/register.cxx index cd28a61d5470..f6d10d564a46 100644 --- a/embedserv/source/embed/register.cxx +++ b/embedserv/source/embed/register.cxx @@ -59,14 +59,14 @@ extern "C" { SAL_DLLPUBLIC_EXPORT void * SAL_CALL emser_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ ) { - void * pRet = 0; + void * pRet = nullptr; OUString aImplName( OUString::createFromAscii( pImplName ) ); uno::Reference< lang::XSingleServiceFactory > xFactory; if(pServiceManager && aImplName.equals( EmbedServer_getImplementationName() ) ) { - xFactory= ::cppu::createOneInstanceFactory( reinterpret_cast< lang::XMultiServiceFactory*>(pServiceManager), + xFactory= ::cppu::createOneInstanceFactory( static_cast< lang::XMultiServiceFactory*>(pServiceManager), EmbedServer_getImplementationName(), EmbedServer_createInstance, EmbedServer_getSupportedServiceNames() ); diff --git a/embedserv/source/embed/servprov.cxx b/embedserv/source/embed/servprov.cxx index 209163d1dad2..b380e4cad860 100644 --- a/embedserv/source/embed/servprov.cxx +++ b/embedserv/source/embed/servprov.cxx @@ -50,7 +50,7 @@ class CurThreadData CurThreadData(); virtual ~CurThreadData(); - sal_Bool SAL_CALL setData(void *pData); + bool SAL_CALL setData(void *pData); void* SAL_CALL getData(); @@ -60,7 +60,7 @@ class CurThreadData CurThreadData::CurThreadData() { - m_hKey = osl_createThreadKey( (oslThreadKeyCallbackFunction)NULL ); + m_hKey = osl_createThreadKey( nullptr ); } CurThreadData::~CurThreadData() @@ -68,7 +68,7 @@ CurThreadData::~CurThreadData() osl_destroyThreadKey(m_hKey); } -sal_Bool CurThreadData::setData(void *pData) +bool CurThreadData::setData(void *pData) { OSL_ENSURE( m_hKey, "No thread key!\n" ); return (osl_setThreadKeyData(m_hKey, pData)); @@ -84,16 +84,16 @@ void o2u_attachCurrentThread() { static CurThreadData oleThreadData; - if ( oleThreadData.getData() != 0 ) + if ( oleThreadData.getData() != nullptr ) { - HRESULT hr = CoInitializeEx(0, COINIT_MULTITHREADED); + HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED); if (!SUCCEEDED(hr)) { // FIXME: is it a problem that this ends up in STA currently? assert(RPC_E_CHANGED_MODE == hr); SAL_INFO("embedserv.ole", "CoInitializeEx fail: probably thread is in STA already?"); } - oleThreadData.setData((void*)sal_True); + oleThreadData.setData(reinterpret_cast<void*>(true)); } } @@ -151,7 +151,7 @@ EmbedProviderFactory_Impl::~EmbedProviderFactory_Impl() { } -sal_Bool EmbedProviderFactory_Impl::registerClass() +bool EmbedProviderFactory_Impl::registerClass() { HRESULT hresult; @@ -167,7 +167,7 @@ sal_Bool EmbedProviderFactory_Impl::registerClass() return (hresult == NOERROR); } -sal_Bool EmbedProviderFactory_Impl::deregisterClass() +bool EmbedProviderFactory_Impl::deregisterClass() { HRESULT hresult = CoRevokeClassObject( m_factoryHandle ); @@ -179,17 +179,17 @@ STDMETHODIMP EmbedProviderFactory_Impl::QueryInterface(REFIID riid, void FAR* FA if(IsEqualIID(riid, IID_IUnknown)) { AddRef(); - *ppv = (IUnknown*) (IClassFactory*) this; + *ppv = static_cast<IUnknown*>(static_cast<IClassFactory*>(this)); return NOERROR; } else if (IsEqualIID(riid, IID_IClassFactory)) { AddRef(); - *ppv = (IClassFactory*) this; + *ppv = static_cast<IClassFactory*>(this); return NOERROR; } - *ppv = NULL; + *ppv = nullptr; return ResultFromScode(E_NOINTERFACE); } @@ -214,9 +214,9 @@ STDMETHODIMP EmbedProviderFactory_Impl::CreateInstance(IUnknown FAR* punkOuter, REFIID riid, void FAR* FAR* ppv) { - punkOuter = NULL; + punkOuter = nullptr; - IUnknown* pEmbedDocument = (IUnknown*)(IPersistStorage*)( new EmbedDocument_Impl( m_xFactory, &m_guid ) ); + IUnknown* pEmbedDocument = static_cast<IUnknown*>(static_cast<IPersistStorage*>( new EmbedDocument_Impl( m_xFactory, &m_guid ) )); return pEmbedDocument->QueryInterface( riid, ppv ); } diff --git a/embedserv/source/embed/syswinwrapper.cxx b/embedserv/source/embed/syswinwrapper.cxx index e079d6c73344..b6d9f4247b67 100644 --- a/embedserv/source/embed/syswinwrapper.cxx +++ b/embedserv/source/embed/syswinwrapper.cxx @@ -44,14 +44,10 @@ using namespace winwrap; typedef CHatchWin *PCHatchWin; - -void DrawShading(LPRECT prc, HDC hDC, UINT cWidth); - - winwrap::CWindow::CWindow(HINSTANCE hInst) { m_hInst=hInst; - m_hWnd=NULL; + m_hWnd=nullptr; return; } @@ -118,10 +114,10 @@ BOOL winwrap::HatchWindowRegister(HINSTANCE hInst) wc.cbClsExtra = 0; wc.lpfnWndProc = HatchWndProc; wc.cbWndExtra = CBHATCHWNDEXTRA; - wc.hIcon = NULL; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); - wc.lpszMenuName = NULL; + wc.hIcon = nullptr; + wc.hCursor = LoadCursor(nullptr, IDC_ARROW); + wc.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW+1); + wc.lpszMenuName = nullptr; wc.lpszClassName = SZCLASSHATCHWIN; return RegisterClass(&wc); @@ -140,9 +136,9 @@ CHatchWin::CHatchWin(HINSTANCE hInst,const DocumentHolder* pDocHolder) : CWindow(hInst), m_aTracker() { - m_hWnd=NULL; - m_hWndKid=NULL; - m_hWndAssociate=NULL; + m_hWnd=nullptr; + m_hWndKid=nullptr; + m_hWndAssociate=nullptr; m_uID=0; m_dBorderOrg=GetProfileInt(TEXT("windows") @@ -164,7 +160,7 @@ CHatchWin::~CHatchWin() * Chances are this was already destroyed when a document * was destroyed. */ - if (NULL!=m_hWnd && IsWindow(m_hWnd)) + if (nullptr!=m_hWnd && IsWindow(m_hWnd)) DestroyWindow(m_hWnd); return; @@ -200,7 +196,7 @@ BOOL CHatchWin::Init(HWND hWndParent, WORD uID, HWND hWndAssoc) m_uID=uID; m_hWndAssociate=hWndAssoc; - return (NULL!=m_hWnd); + return (nullptr!=m_hWnd); } @@ -274,7 +270,7 @@ void CHatchWin::RectsSet(LPRECT prcPos, LPRECT prcClip) InflateRect(&rcPos, m_dBorder, m_dBorder); IntersectRect(&rc, &rcPos, prcClip); - SetWindowPos(m_hWnd, NULL, rc.left, rc.top, rc.right-rc.left + SetWindowPos(m_hWnd, nullptr, rc.left, rc.top, rc.right-rc.left , rc.bottom-rc.top, SWP_NOZORDER | SWP_NOACTIVATE); /* @@ -316,7 +312,7 @@ void CHatchWin::ChildSet(HWND hWndKid) { m_hWndKid=hWndKid; - if (NULL!=hWndKid) + if (nullptr!=hWndKid) { SetParent(hWndKid, m_hWnd); @@ -374,14 +370,14 @@ LRESULT APIENTRY winwrap::HatchWndProc( HDC hDC; PAINTSTRUCT ps; - phw=(PCHatchWin)GetWindowLongPtr(hWnd, HWWL_STRUCTURE); + phw=reinterpret_cast<PCHatchWin>(GetWindowLongPtr(hWnd, HWWL_STRUCTURE)); POINT ptMouse; switch (iMsg) { case WM_CREATE: - phw=(PCHatchWin)((LPCREATESTRUCT)lParam)->lpCreateParams; - SetWindowLongPtr(hWnd, HWWL_STRUCTURE, (LONG_PTR)phw); + phw=static_cast<PCHatchWin>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams); + SetWindowLongPtr(hWnd, HWWL_STRUCTURE, reinterpret_cast<LONG_PTR>(phw)); break; case WM_PAINT: hDC=BeginPaint(hWnd,&ps); @@ -409,7 +405,7 @@ LRESULT APIENTRY winwrap::HatchWndProc( break; case WM_SETFOCUS: //We need this since the container will SetFocus to us. - if (NULL!=phw->m_hWndKid) + if (nullptr!=phw->m_hWndKid) SetFocus(phw->m_hWndKid); break; @@ -423,12 +419,12 @@ LRESULT APIENTRY winwrap::HatchWndProc( * message when the mouse is on the border. So we can * just send the notification. */ - if (NULL!=phw->m_hWndAssociate) + if (nullptr!=phw->m_hWndAssociate) { SendMessage( phw->m_hWndAssociate, WM_COMMAND, MAKEWPARAM(phw->m_uID, HWN_BORDERDOUBLECLICKED), - (LPARAM) hWnd); + reinterpret_cast<LPARAM>(hWnd)); } break; diff --git a/embedserv/source/embed/tracker.cxx b/embedserv/source/embed/tracker.cxx index f0e3954d2e29..acd0e32b7d9c 100644 --- a/embedserv/source/embed/tracker.cxx +++ b/embedserv/source/embed/tracker.cxx @@ -30,8 +30,8 @@ #include "syswinwrapper.hxx" -HCURSOR _afxCursors[10] = { 0, }; -HBRUSH _afxHalftoneBrush = 0; +HCURSOR afxCursors[10] = { nullptr, }; +HBRUSH afxHalftoneBrush = nullptr; // the struct below is used to determine the qualities of a particular handle @@ -48,7 +48,7 @@ struct AFX_HANDLEINFO }; // this array describes all 8 handles (clock-wise) -const AFX_HANDLEINFO _afxHandleInfo[] = +const AFX_HANDLEINFO afxHandleInfo[] = { // corner handles (top-left, top-right, bottom-right, bottom-left { offsetof(RECT, left), offsetof(RECT, top), 0, 0, 0, 0, 1, 3 }, @@ -72,7 +72,7 @@ struct AFX_RECTINFO }; // this array is indexed by the offset of the RECT member / sizeof(int) -const AFX_RECTINFO _afxRectInfo[] = +const AFX_RECTINFO afxRectInfo[] = { { offsetof(RECT, right), +1 }, { offsetof(RECT, bottom), +1 }, @@ -83,26 +83,26 @@ const AFX_RECTINFO _afxRectInfo[] = HBRUSH HalftoneBrush() { - if (_afxHalftoneBrush == NULL) + if (afxHalftoneBrush == nullptr) { WORD grayPattern[8]; for (int i = 0; i < 8; i++) grayPattern[i] = (WORD)(0x5555 << (i & 1)); HBITMAP grayBitmap = CreateBitmap(8, 8, 1, 1, &grayPattern); - if (grayBitmap != NULL) + if (grayBitmap != nullptr) { - _afxHalftoneBrush = CreatePatternBrush(grayBitmap); + afxHalftoneBrush = CreatePatternBrush(grayBitmap); DeleteObject(grayBitmap); } } - return _afxHalftoneBrush; + return afxHalftoneBrush; } void DrawDragRect( HDC hDC,LPRECT lpRect,SIZE size, LPRECT lpRectLast,SIZE sizeLast, - HBRUSH hBrush = NULL,HBRUSH hBrushLast = NULL) + HBRUSH hBrush = nullptr,HBRUSH hBrushLast = nullptr) { // first, determine the update region and select it HRGN rgnNew; @@ -115,15 +115,15 @@ void DrawDragRect( rgnNew = CreateRectRgn(0, 0, 0, 0); CombineRgn(rgnNew,rgnOutside,rgnInside,RGN_XOR); - HBRUSH hBrushOld = NULL; - if (hBrush == NULL) + HBRUSH hBrushOld = nullptr; + if (hBrush == nullptr) hBrush = HalftoneBrush(); - if (hBrushLast == NULL) + if (hBrushLast == nullptr) hBrushLast = hBrush; - HRGN rgnLast(NULL); - HRGN rgnUpdate(NULL); - if (lpRectLast != NULL) + HRGN rgnLast(nullptr); + HRGN rgnUpdate(nullptr); + if (lpRectLast != nullptr) { // find difference between new region and old region rgnLast = CreateRectRgn(0, 0, 0, 0); @@ -146,29 +146,29 @@ void DrawDragRect( CombineRgn(rgnUpdate,rgnLast,rgnNew, RGN_XOR); } } - if (hBrush != hBrushLast && lpRectLast != NULL) + if (hBrush != hBrushLast && lpRectLast != nullptr) { // brushes are different -- erase old region first SelectClipRgn(hDC,rgnLast); GetClipBox(hDC,&rect); - hBrushOld = (HBRUSH)SelectObject(hDC,(HGDIOBJ)hBrushLast); + hBrushOld = static_cast<HBRUSH>(SelectObject(hDC,static_cast<HGDIOBJ>(hBrushLast))); PatBlt(hDC,rect.left,rect.top,(rect.right-rect.left),(rect.bottom-rect.top),PATINVERT); - SelectObject(hDC,(HGDIOBJ)hBrushOld); - hBrushOld = NULL; + SelectObject(hDC,static_cast<HGDIOBJ>(hBrushOld)); + hBrushOld = nullptr; } // draw into the update/new region SelectClipRgn(hDC,rgnUpdate); GetClipBox(hDC,&rect); - hBrushOld = (HBRUSH) SelectObject(hDC,(HGDIOBJ) hBrush); + hBrushOld = static_cast<HBRUSH>(SelectObject(hDC, static_cast<HGDIOBJ>(hBrush))); PatBlt(hDC,rect.left, rect.top,(rect.right-rect.left),(rect.bottom-rect.top), PATINVERT); // cleanup DC - if (hBrushOld != NULL) - SelectObject(hDC,(HGDIOBJ)hBrushOld); - SelectClipRgn(hDC,NULL); + if (hBrushOld != nullptr) + SelectObject(hDC, static_cast<HGDIOBJ>(hBrushOld)); + SelectClipRgn(hDC,nullptr); } @@ -218,9 +218,9 @@ Tracker::Tracker(LPCRECT lpSrcRect, UINT nStyle) m_nStyle = nStyle; } -HBRUSH _afxHatchBrush = 0; -HPEN _afxBlackDottedPen = 0; -int _afxHandleSize = 0; +HBRUSH afxHatchBrush = nullptr; +HPEN afxBlackDottedPen = nullptr; +int afxHandleSize = 0; void Tracker::Construct() @@ -228,7 +228,7 @@ void Tracker::Construct() static BOOL bInitialized = false; if (!bInitialized) { - if (_afxHatchBrush == NULL) + if (afxHatchBrush == nullptr) { // create the hatch pattern + bitmap WORD hatchPattern[8]; @@ -242,32 +242,32 @@ void Tracker::Construct() HBITMAP hatchBitmap = CreateBitmap(8, 8, 1, 1,&hatchPattern); // create black hatched brush - _afxHatchBrush = CreatePatternBrush(hatchBitmap); + afxHatchBrush = CreatePatternBrush(hatchBitmap); DeleteObject(hatchBitmap); } - if (_afxBlackDottedPen == NULL) + if (afxBlackDottedPen == nullptr) { // create black dotted pen - _afxBlackDottedPen = CreatePen(PS_DOT, 0, RGB(0, 0, 0)); + afxBlackDottedPen = CreatePen(PS_DOT, 0, RGB(0, 0, 0)); } // get default handle size from Windows profile setting static const TCHAR szWindows[] = TEXT("windows"); static const TCHAR szInplaceBorderWidth[] = TEXT("oleinplaceborderwidth"); - _afxHandleSize = GetProfileInt(szWindows, szInplaceBorderWidth, 4); + afxHandleSize = GetProfileInt(szWindows, szInplaceBorderWidth, 4); bInitialized = TRUE; - _afxCursors[0] = _afxCursors[2] = LoadCursor(0,IDC_SIZENWSE); - _afxCursors[4] = _afxCursors[6] = LoadCursor(0,IDC_SIZENS); - _afxCursors[1] = _afxCursors[3] = LoadCursor(0,IDC_SIZENESW); - _afxCursors[5] = _afxCursors[7] = LoadCursor(0,IDC_SIZEWE); - _afxCursors[8] = LoadCursor(0,IDC_SIZEALL); + afxCursors[0] = afxCursors[2] = LoadCursor(nullptr,IDC_SIZENWSE); + afxCursors[4] = afxCursors[6] = LoadCursor(nullptr,IDC_SIZENS); + afxCursors[1] = afxCursors[3] = LoadCursor(nullptr,IDC_SIZENESW); + afxCursors[5] = afxCursors[7] = LoadCursor(nullptr,IDC_SIZEWE); + afxCursors[8] = LoadCursor(nullptr,IDC_SIZEALL); } m_nStyle = 0; - m_nHandleSize = _afxHandleSize; + m_nHandleSize = afxHandleSize; m_sizeMin.cy = m_sizeMin.cx = m_nHandleSize*2; SetRectEmpty(&m_rectLast); @@ -327,7 +327,7 @@ BOOL Tracker::SetCursor(HWND pWnd, UINT nHitTest) const nHandle = (TrackerHit)9; } - ::SetCursor(_afxCursors[nHandle]); + ::SetCursor(afxCursors[nHandle]); return TRUE; } @@ -353,7 +353,7 @@ BOOL Tracker::Track(HWND hWnd,POINT point,BOOL bAllowInvert, BOOL Tracker::TrackHandle(int nHandle,HWND hWnd,POINT point,HWND hWndClipTo) { // don't handle if capture already set - if (GetCapture() != NULL) + if (GetCapture() != nullptr) return FALSE; // save original width & height in pixels @@ -363,7 +363,7 @@ BOOL Tracker::TrackHandle(int nHandle,HWND hWnd,POINT point,HWND hWndClipTo) // set capture to the window which received this message SetCapture(hWnd); UpdateWindow(hWnd); - if (hWndClipTo != NULL) + if (hWndClipTo != nullptr) UpdateWindow(hWndClipTo); RECT rectSave = m_rect; @@ -376,10 +376,10 @@ BOOL Tracker::TrackHandle(int nHandle,HWND hWnd,POINT point,HWND hWndClipTo) // get DC for drawing HDC hDrawDC; - if (hWndClipTo != NULL) + if (hWndClipTo != nullptr) { // clip to arbitrary window by using adjusted Window DC - hDrawDC = GetDCEx(hWndClipTo,NULL, DCX_CACHE); + hDrawDC = GetDCEx(hWndClipTo,nullptr, DCX_CACHE); } else { @@ -394,7 +394,7 @@ BOOL Tracker::TrackHandle(int nHandle,HWND hWnd,POINT point,HWND hWndClipTo) for (;;) { MSG msg; - GetMessage(&msg, NULL, 0, 0); + GetMessage(&msg, nullptr, 0, 0); if (GetCapture() != hWnd) break; @@ -406,9 +406,9 @@ BOOL Tracker::TrackHandle(int nHandle,HWND hWnd,POINT point,HWND hWndClipTo) case WM_MOUSEMOVE: rectOld = m_rect; // handle resize cases (and part of move) - if (px != NULL) + if (px != nullptr) *px = (int)(short)LOWORD(msg.lParam) - xDiff; - if (py != NULL) + if (py != nullptr) *py = (int)(short)HIWORD(msg.lParam) - yDiff; // handle move case @@ -465,7 +465,7 @@ BOOL Tracker::TrackHandle(int nHandle,HWND hWnd,POINT point,HWND hWndClipTo) } ExitLoop: - if (hWndClipTo != NULL) + if (hWndClipTo != nullptr) ReleaseDC(hWndClipTo,hDrawDC); else ReleaseDC(hWnd,hDrawDC); @@ -494,29 +494,29 @@ void Tracker::AdjustRect(int nHandle, LPRECT) // convert the handle into locations within m_rect int *px, *py; - GetModifyPointers(nHandle, &px, &py, NULL, NULL); + GetModifyPointers(nHandle, &px, &py, nullptr, nullptr); // enforce minimum width int nNewWidth = m_rect.right - m_rect.left; int nAbsWidth = m_bAllowInvert ? abs(nNewWidth) : nNewWidth; - if (px != NULL && nAbsWidth < m_sizeMin.cx) + if (px != nullptr && nAbsWidth < m_sizeMin.cx) { nNewWidth = nAbsWidth != 0 ? nNewWidth / nAbsWidth : 1; const AFX_RECTINFO* pRectInfo = - &_afxRectInfo[(int*)px - (int*)&m_rect]; - *px = *(int*)((BYTE*)&m_rect + pRectInfo->nOffsetAcross) + + &afxRectInfo[px - reinterpret_cast<int*>(&m_rect)]; + *px = *reinterpret_cast<int*>(reinterpret_cast<BYTE*>(&m_rect) + pRectInfo->nOffsetAcross) + nNewWidth * m_sizeMin.cx * -pRectInfo->nSignAcross; } // enforce minimum height int nNewHeight = m_rect.bottom - m_rect.top; int nAbsHeight = m_bAllowInvert ? abs(nNewHeight) : nNewHeight; - if (py != NULL && nAbsHeight < m_sizeMin.cy) + if (py != nullptr && nAbsHeight < m_sizeMin.cy) { nNewHeight = nAbsHeight != 0 ? nNewHeight / nAbsHeight : 1; const AFX_RECTINFO* pRectInfo = - &_afxRectInfo[(int*)py - (int*)&m_rect]; - *py = *(int*)((BYTE*)&m_rect + pRectInfo->nOffsetAcross) + + &afxRectInfo[py - reinterpret_cast<int*>(&m_rect)]; + *py = *reinterpret_cast<int*>(reinterpret_cast<BYTE*>(&m_rect) + pRectInfo->nOffsetAcross) + nNewHeight * m_sizeMin.cy * -pRectInfo->nSignAcross; } } @@ -530,7 +530,7 @@ void Tracker::DrawTrackerRect( NormalizeRect(&rect); // convert to client coordinates - if (pWndClipTo != NULL) + if (pWndClipTo != nullptr) TransformRect(&rect,pWnd,pWndClipTo); SIZE size; @@ -564,15 +564,15 @@ void Tracker::Draw(HDC hDC) const { // set initial DC state SetMapMode(hDC,MM_TEXT); - SetViewportOrgEx(hDC,0, 0,NULL); - SetWindowOrgEx(hDC,0, 0,NULL); + SetViewportOrgEx(hDC,0, 0,nullptr); + SetWindowOrgEx(hDC,0, 0,nullptr); // get normalized rectangle RECT rect = m_rect; NormalizeRect(&rect); - HPEN pOldPen = NULL; - HBRUSH pOldBrush = NULL; + HPEN pOldPen = nullptr; + HBRUSH pOldBrush = nullptr; HGDIOBJ pTemp; int nOldROP; @@ -580,10 +580,10 @@ void Tracker::Draw(HDC hDC) const if ((m_nStyle & (dottedLine|solidLine)) != 0) { if (m_nStyle & dottedLine) - pOldPen = (HPEN)SelectObject(hDC,_afxBlackDottedPen); + pOldPen = static_cast<HPEN>(SelectObject(hDC,afxBlackDottedPen)); else - pOldPen = (HPEN)SelectObject(hDC,(HGDIOBJ)BLACK_PEN); - pOldBrush = (HBRUSH)SelectObject(hDC,(HGDIOBJ)NULL_BRUSH); + pOldPen = static_cast<HPEN>(SelectObject(hDC,reinterpret_cast<HGDIOBJ>(BLACK_PEN))); + pOldBrush = static_cast<HBRUSH>(SelectObject(hDC,reinterpret_cast<HGDIOBJ>(NULL_BRUSH))); nOldROP = SetROP2(hDC,R2_COPYPEN); InflateRect(&rect,+1, +1); // borders are one pixel outside Rectangle(hDC,rect.left, rect.top, rect.right, rect.bottom); @@ -592,17 +592,17 @@ void Tracker::Draw(HDC hDC) const // if hatchBrush is going to be used, need to unrealize it if ((m_nStyle & (hatchInside|hatchedBorder)) != 0) - UnrealizeObject((HGDIOBJ)_afxHatchBrush); + UnrealizeObject(static_cast<HGDIOBJ>(afxHatchBrush)); // hatch inside if ((m_nStyle & hatchInside) != 0) { - pTemp = SelectObject(hDC,(HGDIOBJ)NULL_PEN); - if (pOldPen == NULL) - pOldPen = (HPEN)pTemp; - pTemp = SelectObject(hDC,(HGDIOBJ)_afxHatchBrush); - if (pOldBrush == NULL) - pOldBrush = (HBRUSH)pTemp; + pTemp = SelectObject(hDC,reinterpret_cast<HGDIOBJ>(NULL_PEN)); + if (pOldPen == nullptr) + pOldPen = static_cast<HPEN>(pTemp); + pTemp = SelectObject(hDC,static_cast<HGDIOBJ>(afxHatchBrush)); + if (pOldBrush == nullptr) + pOldBrush = static_cast<HBRUSH>(pTemp); SetBkMode(hDC,TRANSPARENT); nOldROP = SetROP2(hDC,R2_MASKNOTPEN); Rectangle(hDC,rect.left+1, rect.top+1, rect.right, rect.bottom); @@ -612,9 +612,9 @@ void Tracker::Draw(HDC hDC) const // draw hatched border if ((m_nStyle & hatchedBorder) != 0) { - pTemp = SelectObject(hDC,(HGDIOBJ)_afxHatchBrush); - if (pOldBrush == NULL) - pOldBrush = (HBRUSH)pTemp; + pTemp = SelectObject(hDC,static_cast<HGDIOBJ>(afxHatchBrush)); + if (pOldBrush == nullptr) + pOldBrush = static_cast<HBRUSH>(pTemp); SetBkMode(hDC,OPAQUE); RECT rectTrue; GetTrueRect(&rectTrue); @@ -647,9 +647,9 @@ void Tracker::Draw(HDC hDC) const } // cleanup pDC state - if (pOldPen != NULL) + if (pOldPen != nullptr) SelectObject(hDC,pOldPen); - if (pOldBrush != NULL) + if (pOldBrush != nullptr) SelectObject(hDC,pOldBrush); RestoreDC(hDC,-1); } @@ -676,9 +676,9 @@ void Tracker::GetHandleRect(int nHandle,RECT* pHandleRect) const int nWidth = rectT.right - rectT.left; int nHeight = rectT.bottom - rectT.top; RECT rect; - const AFX_HANDLEINFO* pHandleInfo = &_afxHandleInfo[nHandle]; - rect.left = *(int*)((BYTE*)&rectT + pHandleInfo->nOffsetX); - rect.top = *(int*)((BYTE*)&rectT + pHandleInfo->nOffsetY); + const AFX_HANDLEINFO* pHandleInfo = &afxHandleInfo[nHandle]; + rect.left = *reinterpret_cast<int*>(reinterpret_cast<BYTE*>(&rectT) + pHandleInfo->nOffsetX); + rect.top = *reinterpret_cast<int*>(reinterpret_cast<BYTE*>(&rectT) + pHandleInfo->nOffsetY); rect.left += size * pHandleInfo->nHandleX; rect.top += size * pHandleInfo->nHandleY; rect.left += pHandleInfo->nCenterX * (nWidth - size) / 2; @@ -692,15 +692,14 @@ void Tracker::GetHandleRect(int nHandle,RECT* pHandleRect) const int Tracker::GetHandleSize(LPRECT lpRect) const { - if (lpRect == NULL) - lpRect = (LPRECT)&m_rect; + LPCRECT rect = lpRect == nullptr ? &m_rect : lpRect; int size = m_nHandleSize; if (!(m_nStyle & resizeOutside)) { // make sure size is small enough for the size of the rect - int sizeMax = min(abs(lpRect->right - lpRect->left), - abs(lpRect->bottom - lpRect->top)); + int sizeMax = min(abs(rect->right - rect->left), + abs(rect->bottom - rect->top)); if (size * 2 > sizeMax) size = sizeMax / 2; } @@ -738,11 +737,11 @@ int Tracker::NormalizeHit(int nHandle) const { if (nHandle == hitMiddle || nHandle == hitNothing) return nHandle; - const AFX_HANDLEINFO* pHandleInfo = &_afxHandleInfo[nHandle]; + const AFX_HANDLEINFO* pHandleInfo = &afxHandleInfo[nHandle]; if (m_rect.right - m_rect.left < 0) { nHandle = (TrackerHit)pHandleInfo->nInvertX; - pHandleInfo = &_afxHandleInfo[nHandle]; + pHandleInfo = &afxHandleInfo[nHandle]; } if (m_rect.bottom - m_rect.top < 0) nHandle = (TrackerHit)pHandleInfo->nInvertY; @@ -791,36 +790,36 @@ void Tracker::GetModifyPointers( if (nHandle == hitMiddle) nHandle = hitTopLeft; // same as hitting top-left - *ppx = NULL; - *ppy = NULL; + *ppx = nullptr; + *ppy = nullptr; // fill in the part of the rect that this handle modifies // (Note: handles that map to themselves along a given axis when that // axis is inverted don't modify the value on that axis) - const AFX_HANDLEINFO* pHandleInfo = &_afxHandleInfo[nHandle]; + const AFX_HANDLEINFO* pHandleInfo = &afxHandleInfo[nHandle]; if (pHandleInfo->nInvertX != nHandle) { - *ppx = (int*)((BYTE*)&m_rect + pHandleInfo->nOffsetX); - if (px != NULL) + *ppx = reinterpret_cast<int*>(reinterpret_cast<BYTE*>(&m_rect) + pHandleInfo->nOffsetX); + if (px != nullptr) *px = **ppx; } else { // middle handle on X axis - if (px != NULL) + if (px != nullptr) *px = m_rect.left + (m_rect.left-m_rect.right) / 2; } if (pHandleInfo->nInvertY != nHandle) { - *ppy = (int*)((BYTE*)&m_rect + pHandleInfo->nOffsetY); - if (py != NULL) + *ppy = reinterpret_cast<int*>(reinterpret_cast<BYTE*>(&m_rect) + pHandleInfo->nOffsetY); + if (py != nullptr) *py = **ppy; } else { // middle handle on Y axis - if (py != NULL) + if (py != nullptr) *py = m_rect.top + (m_rect.top-m_rect.bottom) / 2; } } diff --git a/embedserv/source/inc/docholder.hxx b/embedserv/source/inc/docholder.hxx index 9daab2220c59..e350b434d337 100644 --- a/embedserv/source/inc/docholder.hxx +++ b/embedserv/source/inc/docholder.hxx @@ -90,7 +90,7 @@ private: CComPtr< IDispatch > m_pIDispatch; - sal_Bool m_bLink; + bool m_bLink; css::uno::Reference< css::frame::XFrame2 > DocumentFrame(); @@ -101,7 +101,7 @@ private: void ClearInterceptorInternally(); - void LoadDocInFrame( sal_Bool bPluginMode ); + void LoadDocInFrame( bool bPluginMode ); public: @@ -122,7 +122,7 @@ public: const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory, const ::rtl::Reference< EmbeddedDocumentInstanceAccess_Impl >& xOleAccess ); - ~DocumentHolder(); + ~DocumentHolder() override; // Methods for inplace activation @@ -136,19 +136,19 @@ public: BOOL InPlaceMenuCreate(); BOOL InPlaceMenuDestroy(); - void OpenIntoWindow(); - BOOL Undo(); + static void OpenIntoWindow(); + static BOOL Undo(); // further methods void SetDocument( const css::uno::Reference< css::frame::XModel >& xDoc, - sal_Bool bLink = sal_False + bool bLink = false ); - sal_Bool ExecuteSuspendCloseFrame(); + bool ExecuteSuspendCloseFrame(); - void DisconnectFrameDocument( sal_Bool bComplete = sal_False ); + void DisconnectFrameDocument( bool bComplete = false ); void CloseDocument(); void CloseFrame(); void ClearInterceptor(); @@ -164,8 +164,8 @@ public: void OnPosRectChanged(LPRECT lpRect) const; void show(); - sal_Bool HasFrame() { return m_xFrame.is(); } - sal_Bool IsLink() { return m_bLink; } + bool HasFrame() { return m_xFrame.is(); } + bool IsLink() { return m_bLink; } /** hides the document window, even in case of an external container * side managed window. @@ -198,7 +198,7 @@ public: // XEventListener virtual void SAL_CALL disposing( const css::lang::EventObject& aSource ) - throw( css::uno::RuntimeException ); + throw( css::uno::RuntimeException ) override; // XCloseListener virtual void SAL_CALL @@ -208,13 +208,13 @@ public: ) throw( css::util::CloseVetoException - ); + ) override; virtual void SAL_CALL notifyClosing( const css::lang::EventObject& aSource ) - throw( css::uno::RuntimeException ); + throw( css::uno::RuntimeException ) override; // XTerminateListener virtual void SAL_CALL @@ -223,13 +223,13 @@ public: ) throw( css::frame::TerminationVetoException - ); + ) override; virtual void SAL_CALL notifyTermination( const css::lang::EventObject& aSource ) - throw( css::uno::RuntimeException ); + throw( css::uno::RuntimeException ) override; // XModifyListener @@ -239,7 +239,7 @@ public: ) throw ( css::uno::RuntimeException - ); + ) override; // XDockingAreaAcceptor @@ -249,7 +249,7 @@ public: ) throw ( css::uno::RuntimeException - ); + ) override; virtual sal_Bool SAL_CALL requestDockingAreaSpace( @@ -257,7 +257,7 @@ public: ) throw( css::uno::RuntimeException - ); + ) override; virtual void SAL_CALL setDockingAreaSpace( @@ -265,7 +265,7 @@ public: ) throw ( css::uno::RuntimeException - ); + ) override; }; #endif diff --git a/embedserv/source/inc/embeddoc.hxx b/embedserv/source/inc/embeddoc.hxx index 1c8e4606fbf5..ce3e70f02101 100644 --- a/embedserv/source/inc/embeddoc.hxx +++ b/embedserv/source/inc/embeddoc.hxx @@ -51,15 +51,15 @@ class EmbedDocument_Impl { protected: css::uno::Sequence< css::beans::PropertyValue > - fillArgsForLoading_Impl( css::uno::Reference< css::io::XInputStream > xStream, + fillArgsForLoading_Impl( css::uno::Reference< css::io::XInputStream > const & xStream, DWORD nStreamMode, - LPCOLESTR pFilePath = NULL ); + LPCOLESTR pFilePath = nullptr ); css::uno::Sequence< css::beans::PropertyValue > - fillArgsForStoring_Impl( css::uno::Reference< css::io::XOutputStream > xStream ); + fillArgsForStoring_Impl( css::uno::Reference< css::io::XOutputStream > const & xStream ); HRESULT SaveTo_Impl( IStorage* pStg ); - sal_uInt64 getMetaFileHandle_Impl( sal_Bool isEnhMeta ); + sal_uInt64 getMetaFileHandle_Impl( bool isEnhMeta ); public: EmbedDocument_Impl( const css::uno::Reference< css::lang::XMultiServiceFactory >& smgr, @@ -67,78 +67,78 @@ public: virtual ~EmbedDocument_Impl(); /* IUnknown methods */ - STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj); - STDMETHOD_(ULONG, AddRef)(); - STDMETHOD_(ULONG, Release)(); + STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj) override; + STDMETHOD_(ULONG, AddRef)() override; + STDMETHOD_(ULONG, Release)() override; /* IPersistMethod */ - STDMETHOD(GetClassID)(CLSID *pClassID); + STDMETHOD(GetClassID)(CLSID *pClassID) override; /* IPersistStorage methods */ - STDMETHOD(IsDirty) (); - STDMETHOD(InitNew) ( IStorage *pStg ); - STDMETHOD(Load) ( IStorage* pStr ); - STDMETHOD(Save) ( IStorage *pStgSave, BOOL fSameAsLoad ); - STDMETHOD(SaveCompleted) ( IStorage *pStgNew ); - STDMETHOD(HandsOffStorage) (void); + STDMETHOD(IsDirty) () override; + STDMETHOD(InitNew) ( IStorage *pStg ) override; + STDMETHOD(Load) ( IStorage* pStr ) override; + STDMETHOD(Save) ( IStorage *pStgSave, BOOL fSameAsLoad ) override; + STDMETHOD(SaveCompleted) ( IStorage *pStgNew ) override; + STDMETHOD(HandsOffStorage) (void) override; /* IDataObject methods */ - STDMETHOD(GetData) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium ); - STDMETHOD(GetDataHere) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium ); - STDMETHOD(QueryGetData) ( FORMATETC * pFormatetc ); - STDMETHOD(GetCanonicalFormatEtc) ( FORMATETC * pFormatetcIn, FORMATETC * pFormatetcOut ); - STDMETHOD(SetData) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium, BOOL fRelease ); - STDMETHOD(EnumFormatEtc) ( DWORD dwDirection, IEnumFORMATETC ** ppFormatetc ); - STDMETHOD(DAdvise) ( FORMATETC * pFormatetc, DWORD advf, IAdviseSink * pAdvSink, DWORD * pdwConnection ); - STDMETHOD(DUnadvise) ( DWORD dwConnection ); - STDMETHOD(EnumDAdvise) ( IEnumSTATDATA ** ppenumAdvise ); + STDMETHOD(GetData) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium ) override; + STDMETHOD(GetDataHere) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium ) override; + STDMETHOD(QueryGetData) ( FORMATETC * pFormatetc ) override; + STDMETHOD(GetCanonicalFormatEtc) ( FORMATETC * pFormatetcIn, FORMATETC * pFormatetcOut ) override; + STDMETHOD(SetData) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium, BOOL fRelease ) override; + STDMETHOD(EnumFormatEtc) ( DWORD dwDirection, IEnumFORMATETC ** ppFormatetc ) override; + STDMETHOD(DAdvise) ( FORMATETC * pFormatetc, DWORD advf, IAdviseSink * pAdvSink, DWORD * pdwConnection ) override; + STDMETHOD(DUnadvise) ( DWORD dwConnection ) override; + STDMETHOD(EnumDAdvise) ( IEnumSTATDATA ** ppenumAdvise ) override; /* IOleObject methods */ - STDMETHOD(SetClientSite) ( IOleClientSite* pSite ); - STDMETHOD(GetClientSite) ( IOleClientSite** pSite ); - STDMETHOD(SetHostNames) ( LPCOLESTR szContainerApp, LPCOLESTR szContainerObj ); - STDMETHOD(Close) ( DWORD dwSaveOption); - STDMETHOD(SetMoniker) ( DWORD dwWhichMoniker, IMoniker *pmk ); - STDMETHOD(GetMoniker) ( DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk ); - STDMETHOD(InitFromData) ( IDataObject *pDataObject, BOOL fCreation, DWORD dwReserved ); - STDMETHOD(GetClipboardData) ( DWORD dwReserved, IDataObject **ppDataObject ); - STDMETHOD(DoVerb) ( LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect ); - STDMETHOD(EnumVerbs) ( IEnumOLEVERB **ppEnumOleVerb ); - STDMETHOD(Update) (); - STDMETHOD(IsUpToDate) (); - STDMETHOD(GetUserClassID) ( CLSID *pClsid ); - STDMETHOD(GetUserType) ( DWORD dwFormOfType, LPOLESTR *pszUserType ); - STDMETHOD(SetExtent) ( DWORD dwDrawAspect, SIZEL *psizel ); - STDMETHOD(GetExtent) ( DWORD dwDrawAspect, SIZEL *psizel ); - STDMETHOD(Advise) ( IAdviseSink *pAdvSink, DWORD *pdwConnection ); - STDMETHOD(Unadvise) ( DWORD dwConnection ); - STDMETHOD(EnumAdvise) ( IEnumSTATDATA **ppenumAdvise ); - STDMETHOD(GetMiscStatus) ( DWORD dwAspect, DWORD *pdwStatus ); - STDMETHOD(SetColorScheme) ( LOGPALETTE *pLogpal ); + STDMETHOD(SetClientSite) ( IOleClientSite* pSite ) override; + STDMETHOD(GetClientSite) ( IOleClientSite** pSite ) override; + STDMETHOD(SetHostNames) ( LPCOLESTR szContainerApp, LPCOLESTR szContainerObj ) override; + STDMETHOD(Close) ( DWORD dwSaveOption) override; + STDMETHOD(SetMoniker) ( DWORD dwWhichMoniker, IMoniker *pmk ) override; + STDMETHOD(GetMoniker) ( DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk ) override; + STDMETHOD(InitFromData) ( IDataObject *pDataObject, BOOL fCreation, DWORD dwReserved ) override; + STDMETHOD(GetClipboardData) ( DWORD dwReserved, IDataObject **ppDataObject ) override; + STDMETHOD(DoVerb) ( LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect ) override; + STDMETHOD(EnumVerbs) ( IEnumOLEVERB **ppEnumOleVerb ) override; + STDMETHOD(Update) () override; + STDMETHOD(IsUpToDate) () override; + STDMETHOD(GetUserClassID) ( CLSID *pClsid ) override; + STDMETHOD(GetUserType) ( DWORD dwFormOfType, LPOLESTR *pszUserType ) override; + STDMETHOD(SetExtent) ( DWORD dwDrawAspect, SIZEL *psizel ) override; + STDMETHOD(GetExtent) ( DWORD dwDrawAspect, SIZEL *psizel ) override; + STDMETHOD(Advise) ( IAdviseSink *pAdvSink, DWORD *pdwConnection ) override; + STDMETHOD(Unadvise) ( DWORD dwConnection ) override; + STDMETHOD(EnumAdvise) ( IEnumSTATDATA **ppenumAdvise ) override; + STDMETHOD(GetMiscStatus) ( DWORD dwAspect, DWORD *pdwStatus ) override; + STDMETHOD(SetColorScheme) ( LOGPALETTE *pLogpal ) override; /* IOleInPlaceObject methods */ - STDMETHOD(GetWindow)(HWND *); - STDMETHOD(ContextSensitiveHelp)(BOOL); - STDMETHOD(InPlaceDeactivate)(); - STDMETHOD(UIDeactivate)(); - STDMETHOD(SetObjectRects)(LPCRECT, LPCRECT); - STDMETHOD(ReactivateAndUndo)(); + STDMETHOD(GetWindow)(HWND *) override; + STDMETHOD(ContextSensitiveHelp)(BOOL) override; + STDMETHOD(InPlaceDeactivate)() override; + STDMETHOD(UIDeactivate)() override; + STDMETHOD(SetObjectRects)(LPCRECT, LPCRECT) override; + STDMETHOD(ReactivateAndUndo)() override; /* IPersistFile methods */ - STDMETHOD(Load) ( LPCOLESTR pszFileName, DWORD dwMode ); - STDMETHOD(Save) ( LPCOLESTR pszFileName, BOOL fRemember ); - STDMETHOD(SaveCompleted) ( LPCOLESTR pszFileName ); - STDMETHOD(GetCurFile) ( LPOLESTR *ppszFileName ); + STDMETHOD(Load) ( LPCOLESTR pszFileName, DWORD dwMode ) override; + STDMETHOD(Save) ( LPCOLESTR pszFileName, BOOL fRemember ) override; + STDMETHOD(SaveCompleted) ( LPCOLESTR pszFileName ) override; + STDMETHOD(GetCurFile) ( LPOLESTR *ppszFileName ) override; /* IDispatch methods */ - STDMETHOD(GetTypeInfoCount) ( unsigned int FAR* pctinfo ); - STDMETHOD(GetTypeInfo) ( unsigned int iTInfo, LCID lcid, ITypeInfo FAR* FAR* ppTInfo ); - STDMETHOD(GetIDsOfNames) ( REFIID riid, OLECHAR FAR* FAR* rgszNames, unsigned int cNames, LCID lcid, DISPID FAR* rgDispId ); - STDMETHOD(Invoke) ( DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR* pDispParams, VARIANT FAR* pVarResult, EXCEPINFO FAR* pExcepInfo, unsigned int FAR* puArgErr ); + STDMETHOD(GetTypeInfoCount) ( unsigned int FAR* pctinfo ) override; + STDMETHOD(GetTypeInfo) ( unsigned int iTInfo, LCID lcid, ITypeInfo FAR* FAR* ppTInfo ) override; + STDMETHOD(GetIDsOfNames) ( REFIID riid, OLECHAR FAR* FAR* rgszNames, unsigned int cNames, LCID lcid, DISPID FAR* rgDispId ) override; + STDMETHOD(Invoke) ( DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR* pDispParams, VARIANT FAR* pVarResult, EXCEPINFO FAR* pExcepInfo, unsigned int FAR* puArgErr ) override; /* IExternalConnection methods */ - virtual DWORD STDMETHODCALLTYPE AddConnection( DWORD extconn, DWORD reserved); - virtual DWORD STDMETHODCALLTYPE ReleaseConnection( DWORD extconn, DWORD reserved, BOOL fLastReleaseCloses); + virtual DWORD STDMETHODCALLTYPE AddConnection( DWORD extconn, DWORD reserved) override; + virtual DWORD STDMETHODCALLTYPE ReleaseConnection( DWORD extconn, DWORD reserved, BOOL fLastReleaseCloses) override; // c++ - methods @@ -164,7 +164,7 @@ protected: CComPtr< IStream > m_pExtStream; GUID m_guid; - sal_Bool m_bIsDirty; + bool m_bIsDirty; CComPtr< IOleClientSite > m_pClientSite; CComPtr< IDataAdviseHolder > m_pDAdviseHolder; @@ -174,23 +174,23 @@ protected: ::rtl::Reference< EmbeddedDocumentInstanceAccess_Impl > m_xOwnAccess; - sal_Bool m_bIsInVerbHandling; + bool m_bIsInVerbHandling; }; class BooleanGuard_Impl { - sal_Bool& m_bValue; + bool& m_bValue; public: - BooleanGuard_Impl( sal_Bool& bValue ) + BooleanGuard_Impl( bool& bValue ) : m_bValue( bValue ) { - m_bValue = sal_True; + m_bValue = true; } ~BooleanGuard_Impl() { - m_bValue = sal_False; + m_bValue = false; } }; diff --git a/embedserv/source/inc/iipaobj.hxx b/embedserv/source/inc/iipaobj.hxx index ba0e476c574d..7ae08932fdd5 100644 --- a/embedserv/source/inc/iipaobj.hxx +++ b/embedserv/source/inc/iipaobj.hxx @@ -41,19 +41,19 @@ public: virtual ~CIIAObj(); /* IUnknown methods */ - STDMETHODIMP QueryInterface(REFIID, LPVOID FAR * ppvObj); - STDMETHODIMP_(ULONG) AddRef(); - STDMETHODIMP_(ULONG) Release(); + STDMETHODIMP QueryInterface(REFIID, LPVOID FAR * ppvObj) override; + STDMETHODIMP_(ULONG) AddRef() override; + STDMETHODIMP_(ULONG) Release() override; /* IOleInPlaceActiveObject methods */ - STDMETHODIMP GetWindow(HWND *); - STDMETHODIMP ContextSensitiveHelp(BOOL); + STDMETHODIMP GetWindow(HWND *) override; + STDMETHODIMP ContextSensitiveHelp(BOOL) override; STDMETHODIMP TranslateAccelerator(LPMSG); - STDMETHODIMP OnFrameWindowActivate(BOOL); - STDMETHODIMP OnDocWindowActivate(BOOL); + STDMETHODIMP OnFrameWindowActivate(BOOL) override; + STDMETHODIMP OnDocWindowActivate(BOOL) override; STDMETHODIMP ResizeBorder(LPCRECT, LPOLEINPLACEUIWINDOW - , BOOL); - STDMETHODIMP EnableModeless(BOOL); + , BOOL) override; + STDMETHODIMP EnableModeless(BOOL) override; private: diff --git a/embedserv/source/inc/intercept.hxx b/embedserv/source/inc/intercept.hxx index 3dc08c790efa..739c9ae6320c 100644 --- a/embedserv/source/inc/intercept.hxx +++ b/embedserv/source/inc/intercept.hxx @@ -46,9 +46,9 @@ public: Interceptor( const ::rtl::Reference< EmbeddedDocumentInstanceAccess_Impl >& xOleAccess, DocumentHolder* pDocH, - sal_Bool bLink ); + bool bLink ); - ~Interceptor(); + ~Interceptor() override; void DisconnectDocHolder(); @@ -76,7 +76,7 @@ public: dispatch( const css::util::URL& URL, const css::uno::Sequence< css::beans::PropertyValue >& Arguments ) - throw (css::uno::RuntimeException); + throw (css::uno::RuntimeException) override; virtual void SAL_CALL addStatusListener( @@ -84,7 +84,7 @@ public: const css::util::URL& URL ) throw ( css::uno::RuntimeException - ); + ) override; virtual void SAL_CALL removeStatusListener( @@ -92,14 +92,14 @@ public: const css::util::URL& URL ) throw ( css::uno::RuntimeException - ); + ) override; //XInterceptorInfo virtual css::uno::Sequence< OUString > SAL_CALL getInterceptedURLs( ) throw ( css::uno::RuntimeException - ); + ) override; //XDispatchProvider ( inherited by XDispatchProviderInterceptor ) @@ -111,7 +111,7 @@ public: sal_Int32 SearchFlags ) throw ( css::uno::RuntimeException - ); + ) override; virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( @@ -119,7 +119,7 @@ public: css::frame::DispatchDescriptor >& Requests ) throw ( css::uno::RuntimeException - ); + ) override; //XDispatchProviderInterceptor @@ -127,27 +127,27 @@ public: getSlaveDispatchProvider( ) throw ( css::uno::RuntimeException - ); + ) override; virtual void SAL_CALL setSlaveDispatchProvider( const css::uno::Reference< css::frame::XDispatchProvider >& NewDispatchProvider ) throw ( css::uno::RuntimeException - ); + ) override; virtual css::uno::Reference< css::frame::XDispatchProvider > SAL_CALL getMasterDispatchProvider( ) throw ( css::uno::RuntimeException - ); + ) override; virtual void SAL_CALL setMasterDispatchProvider( const css::uno::Reference< css::frame::XDispatchProvider >& NewSupplier ) throw ( css::uno::RuntimeException - ); + ) override; private: @@ -168,7 +168,7 @@ private: comphelper::OInterfaceContainerHelper2* m_pDisposeEventListeners; StatusChangeListenerContainer* m_pStatCL; - sal_Bool m_bLink; + bool m_bLink; }; #endif diff --git a/embedserv/source/inc/servprov.hxx b/embedserv/source/inc/servprov.hxx index a775303021ba..ab0c78d843ef 100644 --- a/embedserv/source/inc/servprov.hxx +++ b/embedserv/source/inc/servprov.hxx @@ -35,7 +35,7 @@ class EmbedServer_Impl: public cppu::WeakImplHelper<css::lang::XServiceInfo> { public: EmbedServer_Impl( const css::uno::Reference< css::lang::XMultiServiceFactory > &xFactory ); - virtual ~EmbedServer_Impl(); + virtual ~EmbedServer_Impl() override; OUString SAL_CALL getImplementationName() throw (css::uno::RuntimeException, std::exception) override; @@ -59,17 +59,17 @@ public: EmbedProviderFactory_Impl( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory, const GUID* pGuid); virtual ~EmbedProviderFactory_Impl(); - sal_Bool registerClass(); - sal_Bool deregisterClass(); + bool registerClass(); + bool deregisterClass(); /* IUnknown methods */ - STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj); - STDMETHOD_(ULONG, AddRef)(); - STDMETHOD_(ULONG, Release)(); + STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj) override; + STDMETHOD_(ULONG, AddRef)() override; + STDMETHOD_(ULONG, Release)() override; /* IClassFactory methods */ - STDMETHOD(CreateInstance)(IUnknown FAR* punkOuter, REFIID riid, void FAR* FAR* ppv); - STDMETHOD(LockServer)(int fLock); + STDMETHOD(CreateInstance)(IUnknown FAR* punkOuter, REFIID riid, void FAR* FAR* ppv) override; + STDMETHOD(LockServer)(int fLock) override; protected: diff --git a/embedserv/source/inc/syswinwrapper.hxx b/embedserv/source/inc/syswinwrapper.hxx index 52bf7d03d19c..fde21349095b 100644 --- a/embedserv/source/inc/syswinwrapper.hxx +++ b/embedserv/source/inc/syswinwrapper.hxx @@ -94,7 +94,7 @@ namespace winwrap { void GetTrueRect(LPRECT lpTrueRect) const; BOOL SetCursor(HWND hWnd,UINT nHitTest) const; BOOL Track(HWND hWnd,POINT point,BOOL bAllowInvert = FALSE, - HWND hWndClipTo = NULL); + HWND hWndClipTo = nullptr); // BOOL TrackRubberBand(HWND hWnd,POINT point,BOOL bAllowInvert = TRUE); int HitTest(POINT point) const; int NormalizeHit(int nHandle) const; @@ -123,7 +123,7 @@ protected: void GetHandleRect(int nHandle,RECT* pHandleRect) const; void GetModifyPointers( int nHandle,int**ppx, int**ppy, int* px, int*py); - virtual int GetHandleSize(LPRECT lpRect = NULL) const; + virtual int GetHandleSize(LPRECT lpRect = nullptr) const; BOOL TrackHandle(int nHandle,HWND hWnd,POINT point,HWND hWndClipTo); void Construct(); }; diff --git a/embedserv/source/inc/xwin.hxx b/embedserv/source/inc/xwin.hxx index b3952114101d..48834299c721 100644 --- a/embedserv/source/inc/xwin.hxx +++ b/embedserv/source/inc/xwin.hxx @@ -38,7 +38,7 @@ public: ContainerWindowWrapper(HWND aHwnd); - ~ ContainerWindowWrapper(); + ~ ContainerWindowWrapper() override; // XComponent @@ -48,7 +48,7 @@ public: ) throw ( css::uno::RuntimeException - ); + ) override; virtual void SAL_CALL addEventListener( @@ -56,7 +56,7 @@ public: ) throw ( css::uno::RuntimeException - ); + ) override; virtual void SAL_CALL removeEventListener( @@ -64,7 +64,7 @@ public: ) throw ( css::uno::RuntimeException - ); + ) override; // XSystemDependentWindowPeer @@ -76,7 +76,7 @@ public: ) throw ( css::uno::RuntimeException - ); + ) override; // XWindow @@ -89,14 +89,14 @@ public: sal_Int16 Flags ) throw ( - css::uno::RuntimeException); + css::uno::RuntimeException) override; virtual css::awt::Rectangle SAL_CALL getPosSize( ) throw ( css::uno::RuntimeException - ); + ) override; virtual void SAL_CALL setVisible( @@ -104,7 +104,7 @@ public: ) throw ( css::uno::RuntimeException - ); + ) override; virtual void SAL_CALL setEnable( @@ -112,14 +112,14 @@ public: ) throw ( css::uno::RuntimeException - ); + ) override; virtual void SAL_CALL setFocus( ) throw ( css::uno::RuntimeException - ); + ) override; virtual void SAL_CALL addWindowListener( @@ -127,7 +127,7 @@ public: ) throw ( css::uno::RuntimeException - ); + ) override; virtual void SAL_CALL removeWindowListener( @@ -135,7 +135,7 @@ public: ) throw ( css::uno::RuntimeException - ); + ) override; virtual void SAL_CALL addFocusListener( @@ -143,7 +143,7 @@ public: ) throw ( css::uno::RuntimeException - ); + ) override; virtual void SAL_CALL removeFocusListener( @@ -151,7 +151,7 @@ public: ) throw ( css::uno::RuntimeException - ); + ) override; virtual void SAL_CALL addKeyListener( @@ -160,7 +160,7 @@ public: ) throw ( css::uno::RuntimeException - ); + ) override; virtual void SAL_CALL removeKeyListener( @@ -168,7 +168,7 @@ public: ) throw ( css::uno::RuntimeException - ); + ) override; virtual void SAL_CALL addMouseListener( @@ -176,7 +176,7 @@ public: ) throw ( css::uno::RuntimeException - ); + ) override; virtual void SAL_CALL removeMouseListener( @@ -185,7 +185,7 @@ public: ) throw ( css::uno::RuntimeException - ); + ) override; virtual void SAL_CALL addMouseMotionListener( @@ -194,7 +194,7 @@ public: ) throw ( css::uno::RuntimeException - ); + ) override; virtual void SAL_CALL removeMouseMotionListener( @@ -202,7 +202,7 @@ public: ) throw ( css::uno::RuntimeException - ); + ) override; virtual void SAL_CALL addPaintListener( @@ -210,7 +210,7 @@ public: ) throw ( css::uno::RuntimeException - ); + ) override; virtual void SAL_CALL removePaintListener( @@ -218,7 +218,7 @@ public: ) throw ( css::uno::RuntimeException - ); + ) override; private: diff --git a/embedserv/source/inprocserv/advisesink.cxx b/embedserv/source/inprocserv/advisesink.cxx index eb6488c91c58..e036e30850b3 100644 --- a/embedserv/source/inprocserv/advisesink.cxx +++ b/embedserv/source/inprocserv/advisesink.cxx @@ -28,7 +28,7 @@ namespace inprocserv OleWrapperAdviseSink::OleWrapperAdviseSink() : m_nRefCount( 0 ) -, m_pFormatEtc( NULL ) +, m_pFormatEtc( nullptr ) , m_nAspect( DVASPECT_CONTENT ) , m_nRegID( 0 ) , m_bObjectAdvise( TRUE ) @@ -42,7 +42,7 @@ OleWrapperAdviseSink::OleWrapperAdviseSink() OleWrapperAdviseSink::OleWrapperAdviseSink( const ComSmart< IAdviseSink >& pListener ) : m_nRefCount( 0 ) , m_pListener( pListener ) -, m_pFormatEtc( NULL ) +, m_pFormatEtc( nullptr ) , m_nAspect( DVASPECT_CONTENT ) , m_nRegID( 0 ) , m_bObjectAdvise( TRUE ) @@ -56,7 +56,7 @@ OleWrapperAdviseSink::OleWrapperAdviseSink( const ComSmart< IAdviseSink >& pList OleWrapperAdviseSink::OleWrapperAdviseSink( const ComSmart< IAdviseSink >& pListener, FORMATETC* pFormatEtc, DWORD nDataRegFlag ) : m_nRefCount( 0 ) , m_pListener( pListener ) -, m_pFormatEtc( NULL ) +, m_pFormatEtc( nullptr ) , m_nAspect( DVASPECT_CONTENT ) , m_nRegID( 0 ) , m_bObjectAdvise( FALSE ) @@ -69,7 +69,7 @@ OleWrapperAdviseSink::OleWrapperAdviseSink( const ComSmart< IAdviseSink >& pList { m_pFormatEtc = new FORMATETC; m_pFormatEtc->cfFormat = pFormatEtc->cfFormat; - m_pFormatEtc->ptd = NULL; + m_pFormatEtc->ptd = nullptr; m_pFormatEtc->dwAspect = pFormatEtc->dwAspect; m_pFormatEtc->lindex = pFormatEtc->lindex; m_pFormatEtc->tymed = pFormatEtc->tymed; @@ -79,7 +79,7 @@ OleWrapperAdviseSink::OleWrapperAdviseSink( const ComSmart< IAdviseSink >& pList OleWrapperAdviseSink::OleWrapperAdviseSink( const ComSmart< IAdviseSink >& pListener, DWORD nAspect, DWORD nViewRegFlag ) : m_nRefCount( 0 ) , m_pListener( pListener ) -, m_pFormatEtc( NULL ) +, m_pFormatEtc( nullptr ) , m_nAspect( nAspect ) , m_nRegID( 0 ) , m_bObjectAdvise( TRUE ) @@ -97,17 +97,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; } diff --git a/embedserv/source/inprocserv/advisesink.hxx b/embedserv/source/inprocserv/advisesink.hxx index 6a496bad912c..af07cde789d1 100644 --- a/embedserv/source/inprocserv/advisesink.hxx +++ b/embedserv/source/inprocserv/advisesink.hxx @@ -69,21 +69,21 @@ public: FORMATETC* GetFormatEtc() { return m_pFormatEtc; } DWORD GetAspect() { return m_nAspect; } ComSmart< IAdviseSink >& GetOrigAdvise() { return m_pListener; } - void DisconnectOrigAdvise() { m_pListener = NULL; } + void DisconnectOrigAdvise() { m_pListener = nullptr; } void SetClosed() { m_bClosed = TRUE; } void UnsetClosed() { m_bClosed = FALSE; } BOOL IsClosed() { return m_bClosed; } - STDMETHODIMP QueryInterface(REFIID, void**); - STDMETHODIMP_(ULONG) AddRef(); - STDMETHODIMP_(ULONG) Release(); + STDMETHODIMP QueryInterface(REFIID, void**) override; + STDMETHODIMP_(ULONG) AddRef() override; + STDMETHODIMP_(ULONG) Release() override; - STDMETHODIMP_(void) OnDataChange(LPFORMATETC, LPSTGMEDIUM); - STDMETHODIMP_(void) OnViewChange(DWORD, LONG); - STDMETHODIMP_(void) OnRename(LPMONIKER); - STDMETHODIMP_(void) OnSave(); - STDMETHODIMP_(void) OnClose(); + 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; }; }; // namespace advisesink diff --git a/embedserv/source/inprocserv/dllentry.cxx b/embedserv/source/inprocserv/dllentry.cxx index 4c7baf0afbb8..58bc9a3a5c32 100644 --- a/embedserv/source/inprocserv/dllentry.cxx +++ b/embedserv/source/inprocserv/dllentry.cxx @@ -42,7 +42,7 @@ static const GUID* guidList[ SUPPORTED_FACTORIES_NUM ] = { &OID_MathOASISServer }; -static HINSTANCE g_hInstance = NULL; +static HINSTANCE g_hInstance = nullptr; static ULONG g_nObj = 0; static ULONG g_nLock = 0; @@ -93,7 +93,7 @@ namespace { HRESULT hRes = E_FAIL; if ( pLibrary && nLen ) { - HKEY hKey = NULL; + HKEY hKey = nullptr; hRes = S_OK; for ( int nInd = 0; nInd < SUPPORTED_FACTORIES_NUM; nInd++ ) @@ -109,14 +109,14 @@ namespace { { if ( ERROR_SUCCESS == RegOpenKey( HKEY_LOCAL_MACHINE, pSubKey, &hKey ) ) { - if ( ERROR_SUCCESS == RegSetValueEx( hKey, "", 0, REG_SZ, (const BYTE*)pLibrary, nLen ) ) + if ( ERROR_SUCCESS == RegSetValueEx( hKey, "", 0, REG_SZ, reinterpret_cast<const BYTE*>(pLibrary), nLen ) ) bLocalSuccess = TRUE; } if ( hKey ) { RegCloseKey( hKey ); - hKey = NULL; + hKey = nullptr; } } @@ -144,13 +144,13 @@ public: virtual ~InprocEmbedProvider_Impl(); /* IUnknown methods */ - STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj); - STDMETHOD_(ULONG, AddRef)(); - STDMETHOD_(ULONG, Release)(); + STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj) override; + STDMETHOD_(ULONG, AddRef)() override; + STDMETHOD_(ULONG, Release)() override; /* IClassFactory methods */ - STDMETHOD(CreateInstance)(IUnknown FAR* punkOuter, REFIID riid, void FAR* FAR* ppv); - STDMETHOD(LockServer)(int fLock); + STDMETHOD(CreateInstance)(IUnknown FAR* punkOuter, REFIID riid, void FAR* FAR* ppv) override; + STDMETHOD(LockServer)(int fLock) override; protected: @@ -186,7 +186,7 @@ STDAPI INPROC_DLLPUBLIC DllGetClassObject( REFCLSID rclsid, REFIID riid, LPVOID* return E_NOINTERFACE; *ppv = new inprocserv::InprocEmbedProvider_Impl( rclsid ); - ((LPUNKNOWN)*ppv)->AddRef(); + static_cast<LPUNKNOWN>(*ppv)->AddRef(); return S_OK; } @@ -270,17 +270,17 @@ STDMETHODIMP InprocEmbedProvider_Impl::QueryInterface( REFIID riid, void FAR* FA if(IsEqualIID(riid, IID_IUnknown)) { AddRef(); - *ppv = (IUnknown*) this; + *ppv = static_cast<IUnknown*>(this); return S_OK; } else if (IsEqualIID(riid, IID_IClassFactory)) { AddRef(); - *ppv = (IClassFactory*) this; + *ppv = static_cast<IClassFactory*>(this); return S_OK; } - *ppv = NULL; + *ppv = nullptr; return E_NOINTERFACE; } @@ -307,18 +307,16 @@ STDMETHODIMP InprocEmbedProvider_Impl::CreateInstance(IUnknown FAR* punkOuter, // TODO/LATER: should the aggregation be supported? // if ( punkOuter != NULL && riid != IID_IUnknown ) // return E_NOINTERFACE; - if ( punkOuter != NULL ) + if ( punkOuter != nullptr ) return CLASS_E_NOAGGREGATION; InprocEmbedDocument_Impl* pEmbedDocument = new InprocEmbedDocument_Impl( m_guid ); pEmbedDocument->AddRef(); - HRESULT hr = pEmbedDocument->Init(); - if ( SUCCEEDED( hr ) ) - hr = pEmbedDocument->QueryInterface( riid, ppv ); + HRESULT hr = pEmbedDocument->QueryInterface( riid, ppv ); pEmbedDocument->Release(); if ( !SUCCEEDED( hr ) ) - *ppv = NULL; + *ppv = nullptr; return hr; } diff --git a/embedserv/source/inprocserv/inprocembobj.cxx b/embedserv/source/inprocserv/inprocembobj.cxx index c2fc1dc71947..d71e9960d4bf 100644 --- a/embedserv/source/inprocserv/inprocembobj.cxx +++ b/embedserv/source/inprocserv/inprocembobj.cxx @@ -25,36 +25,9 @@ namespace inprocserv { +namespace { -BOOL StringsEqual( LPCOLESTR pszNameFromOutside, wchar_t* pOwnName ) -{ - BOOL bResult = TRUE; - - if ( pszNameFromOutside && pOwnName ) - { - for ( int nInd = 0; pszNameFromOutside[nInd] != 0 || pOwnName[nInd] != 0; nInd++ ) - { - if ( pszNameFromOutside[nInd] != pOwnName[nInd] ) - { - bResult = FALSE; - break; - } - } - } - else if ( pszNameFromOutside || pOwnName ) - bResult = FALSE; - - return bResult; -} - - -HRESULT InprocEmbedDocument_Impl::Init() -{ - return S_OK; -} - - -void InprocEmbedDocument_Impl::SetName( LPCOLESTR pszNameFromOutside, wchar_t*& pOwnName ) +void SetName( LPCOLESTR pszNameFromOutside, wchar_t*& pOwnName ) { if ( !pszNameFromOutside ) return; @@ -67,7 +40,7 @@ void InprocEmbedDocument_Impl::SetName( LPCOLESTR pszNameFromOutside, wchar_t*& if ( pOwnName ) { delete[] pOwnName; - pOwnName = NULL; + pOwnName = nullptr; } pOwnName = new wchar_t[nLen+1]; @@ -76,11 +49,36 @@ void InprocEmbedDocument_Impl::SetName( LPCOLESTR pszNameFromOutside, wchar_t*& pOwnName[nLen] = 0; } +DWORD InsertAdviseLinkToList( const ComSmart<OleWrapperAdviseSink>& pOwnAdvise, ComSmart< OleWrapperAdviseSink > pAdvises[] ) +{ + // the result should start from 1 in case of success, the element 0 can be used for own needs + DWORD nResult = 0; + + if ( pOwnAdvise ) + { + for ( DWORD nInd = 1; nInd < DEFAULT_ARRAY_LEN && nResult == 0; nInd++ ) + { + if ( pAdvises[nInd] == pOwnAdvise ) + { + nResult = nInd; + } + else if ( pAdvises[nInd] == nullptr ) + { + pAdvises[nInd] = pOwnAdvise; + nResult = nInd; + } + } + } + + return nResult; +} + +} BOOL InprocEmbedDocument_Impl::CheckDefHandler() { // set the own listener - if ( m_pOleAdvises[0] == NULL ) + if ( m_pOleAdvises[0] == nullptr ) { m_pOleAdvises[0] = new OleWrapperAdviseSink(); } @@ -93,7 +91,7 @@ BOOL InprocEmbedDocument_Impl::CheckDefHandler() // deregister all the listeners ComSmart< IOleObject > pOleObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, reinterpret_cast<void**>(&pOleObject) ); if ( SUCCEEDED( hr ) && pOleObject ) { for ( DWORD nInd = 0; nInd < DEFAULT_ARRAY_LEN; nInd++ ) @@ -104,11 +102,11 @@ BOOL InprocEmbedDocument_Impl::CheckDefHandler() m_pOleAdvises[nInd]->SetRegID( 0 ); } - pOleObject->SetClientSite( NULL ); + pOleObject->SetClientSite( nullptr ); } ComSmart< IDataObject > pIDataObject; - hr = m_pDefHandler->QueryInterface( IID_IDataObject, (void**)&pIDataObject ); + hr = m_pDefHandler->QueryInterface( IID_IDataObject, reinterpret_cast<void**>(&pIDataObject) ); if ( SUCCEEDED( hr ) && pIDataObject ) { for ( DWORD nInd = 0; nInd < DEFAULT_ARRAY_LEN; nInd++ ) @@ -121,22 +119,22 @@ BOOL InprocEmbedDocument_Impl::CheckDefHandler() } ComSmart< IViewObject > pIViewObject; - hr = m_pDefHandler->QueryInterface( IID_IViewObject, (void**)&pIViewObject ); + hr = m_pDefHandler->QueryInterface( IID_IViewObject, reinterpret_cast<void**>(&pIViewObject) ); if ( SUCCEEDED( hr ) && pIViewObject ) { if ( m_pViewAdvise ) - pIViewObject->SetAdvise( m_pViewAdvise->GetAspect(), m_pViewAdvise->GetViewAdviseFlag(), NULL ); + pIViewObject->SetAdvise( m_pViewAdvise->GetAspect(), m_pViewAdvise->GetViewAdviseFlag(), nullptr ); } ComSmart< IPersistStorage > pPersist; - hr = m_pDefHandler->QueryInterface( IID_IPersistStorage, (void**)&pPersist ); + hr = m_pDefHandler->QueryInterface( IID_IPersistStorage, reinterpret_cast<void**>(&pPersist) ); if ( SUCCEEDED( hr ) && pPersist ) { // disconnect the old wrapper from the storage pPersist->HandsOffStorage(); } - m_pDefHandler = NULL; + m_pDefHandler = nullptr; } m_pOleAdvises[0]->UnsetClosed(); @@ -149,14 +147,14 @@ BOOL InprocEmbedDocument_Impl::CheckDefHandler() if ( !m_pDefHandler ) { // create a new default inprocess handler - HRESULT hr = OleCreateDefaultHandler( m_guid, NULL, IID_IUnknown, (void**)&m_pDefHandler ); + HRESULT hr = OleCreateDefaultHandler( m_guid, nullptr, IID_IUnknown, reinterpret_cast<void**>(&m_pDefHandler) ); if ( SUCCEEDED( hr ) ) { { if ( m_nInitMode == INIT_FROM_STORAGE ) { ComSmart< IPersistStorage > pPersist; - hr = m_pDefHandler->QueryInterface( IID_IPersistStorage, (void**)&pPersist ); + hr = m_pDefHandler->QueryInterface( IID_IPersistStorage, reinterpret_cast<void**>(&pPersist) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pPersist && m_pStorage ) @@ -165,7 +163,7 @@ BOOL InprocEmbedDocument_Impl::CheckDefHandler() else if ( m_nInitMode == LOAD_FROM_STORAGE ) { ComSmart< IPersistStorage > pPersist; - hr = m_pDefHandler->QueryInterface( IID_IPersistStorage, (void**)&pPersist ); + hr = m_pDefHandler->QueryInterface( IID_IPersistStorage, reinterpret_cast<void**>(&pPersist) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pPersist && m_pStorage ) @@ -174,7 +172,7 @@ BOOL InprocEmbedDocument_Impl::CheckDefHandler() else if ( m_nInitMode == LOAD_FROM_FILE ) { ComSmart< IPersistFile > pPersistFile; - hr = m_pDefHandler->QueryInterface( IID_IPersistFile, (void**)&pPersistFile ); + hr = m_pDefHandler->QueryInterface( IID_IPersistFile, reinterpret_cast<void**>(&pPersistFile) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pPersistFile && m_pFileName ) @@ -185,14 +183,14 @@ BOOL InprocEmbedDocument_Impl::CheckDefHandler() if ( !SUCCEEDED( hr ) || !m_pDefHandler ) { - m_pDefHandler = NULL; + m_pDefHandler = nullptr; return FALSE; } // register all the listeners new ComSmart< IOleObject > pOleObject; - hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); + hr = m_pDefHandler->QueryInterface( IID_IOleObject, reinterpret_cast<void**>(&pOleObject) ); if ( SUCCEEDED( hr ) && pOleObject ) { if ( m_pClientSite ) @@ -208,7 +206,7 @@ BOOL InprocEmbedDocument_Impl::CheckDefHandler() } ComSmart< IDataObject > pIDataObject; - hr = m_pDefHandler->QueryInterface( IID_IDataObject, (void**)&pIDataObject ); + hr = m_pDefHandler->QueryInterface( IID_IDataObject, reinterpret_cast<void**>(&pIDataObject) ); if ( SUCCEEDED( hr ) && pIDataObject ) { for ( DWORD nInd = 0; nInd < DEFAULT_ARRAY_LEN; nInd++ ) @@ -221,7 +219,7 @@ BOOL InprocEmbedDocument_Impl::CheckDefHandler() } ComSmart< IViewObject > pIViewObject; - hr = m_pDefHandler->QueryInterface( IID_IViewObject, (void**)&pIViewObject ); + hr = m_pDefHandler->QueryInterface( IID_IViewObject, reinterpret_cast<void**>(&pIViewObject) ); if ( SUCCEEDED( hr ) && pIViewObject ) { if ( m_pViewAdvise ) @@ -233,35 +231,9 @@ BOOL InprocEmbedDocument_Impl::CheckDefHandler() return TRUE; } - -DWORD InprocEmbedDocument_Impl::InsertAdviseLinkToList( const ComSmart<OleWrapperAdviseSink>& pOwnAdvise, ComSmart< OleWrapperAdviseSink > pAdvises[] ) -{ - // the result should start from 1 in case of success, the element 0 can be used for own needs - DWORD nResult = 0; - - if ( pOwnAdvise ) - { - for ( DWORD nInd = 1; nInd < DEFAULT_ARRAY_LEN && nResult == 0; nInd++ ) - { - if ( pAdvises[nInd] == pOwnAdvise ) - { - nResult = nInd; - } - else if ( pAdvises[nInd] == NULL ) - { - pAdvises[nInd] = pOwnAdvise; - nResult = nInd; - } - } - } - - return nResult; -} - - void InprocEmbedDocument_Impl::Clean() { - m_pDefHandler = (IUnknown*)NULL; + m_pDefHandler = nullptr; // no DisconnectOrigAdvise() call here, since it is no explicit disconnection for ( DWORD nInd = 0; nInd < DEFAULT_ARRAY_LEN; nInd++ ) @@ -269,34 +241,34 @@ void InprocEmbedDocument_Impl::Clean() if ( m_pOleAdvises[nInd] ) { ComSmart< OleWrapperAdviseSink > pAdvise = m_pOleAdvises[nInd]; - m_pOleAdvises[nInd] = NULL; + m_pOleAdvises[nInd] = nullptr; } if ( m_pDataAdvises[nInd] ) { ComSmart< OleWrapperAdviseSink > pAdvise = m_pDataAdvises[nInd]; - m_pDataAdvises[nInd] = NULL; + m_pDataAdvises[nInd] = nullptr; } } - m_pViewAdvise = NULL; + m_pViewAdvise = nullptr; m_nInitMode = NOINIT; - m_pStorage = NULL; + m_pStorage = nullptr; if ( m_pOleContainer ) { m_pOleContainer->LockContainer( FALSE ); - m_pOleContainer = NULL; + m_pOleContainer = nullptr; } - m_pClientSite = NULL; + m_pClientSite = nullptr; m_nFileOpenMode = 0; if ( m_pFileName ) { delete m_pFileName; - m_pFileName = NULL; + m_pFileName = nullptr; } } @@ -307,89 +279,89 @@ STDMETHODIMP InprocEmbedDocument_Impl::QueryInterface( REFIID riid, void FAR* FA if(IsEqualIID(riid, IID_IUnknown)) { AddRef(); - *ppv = (IUnknown*) (IPersistStorage*) this; + *ppv = static_cast<IUnknown*>(static_cast<IPersistStorage*>(this)); return S_OK; } else if (IsEqualIID(riid, IID_IPersist)) { AddRef(); - *ppv = (IPersist*) (IPersistStorage*) this; + *ppv = static_cast<IPersist*>(static_cast<IPersistStorage*>(this)); return S_OK; } else if (IsEqualIID(riid, IID_IPersistStorage)) { AddRef(); - *ppv = (IPersistStorage*) this; + *ppv = static_cast<IPersistStorage*>(this); return S_OK; } else if (IsEqualIID(riid, IID_IDataObject)) { AddRef(); - *ppv = (IDataObject*) this; + *ppv = static_cast<IDataObject*>(this); return S_OK; } else if (IsEqualIID(riid, IID_IOleObject)) { AddRef(); - *ppv = (IOleObject*) this; + *ppv = static_cast<IOleObject*>(this); return S_OK; } else if (IsEqualIID(riid, IID_IPersistFile)) { AddRef(); - *ppv = (IPersistFile*) this; + *ppv = static_cast<IPersistFile*>(this); return S_OK; } else if (IsEqualIID(riid, IID_IRunnableObject)) { AddRef(); - *ppv = (IRunnableObject*) this; + *ppv = static_cast<IRunnableObject*>(this); return S_OK; } else if (IsEqualIID(riid, IID_IViewObject)) { AddRef(); - *ppv = (IViewObject*) this; + *ppv = static_cast<IViewObject*>(this); return S_OK; } else if (IsEqualIID(riid, IID_IViewObject2)) { AddRef(); - *ppv = (IViewObject2*) this; + *ppv = static_cast<IViewObject2*>(this); return S_OK; } else if (IsEqualIID(riid, IID_IOleCache)) { AddRef(); - *ppv = (IOleCache*) &m_aInternalCache; + *ppv = static_cast<IOleCache*>(&m_aInternalCache); return S_OK; } else if (IsEqualIID(riid, IID_IOleCache2)) { AddRef(); - *ppv = (IOleCache2*) &m_aInternalCache; + *ppv = static_cast<IOleCache2*>(&m_aInternalCache); return S_OK; } else if (IsEqualIID(riid, IID_IOleWindow)) { AddRef(); - *ppv = (IOleWindow*) this; + *ppv = static_cast<IOleWindow*>(this); return S_OK; } else if (IsEqualIID(riid, IID_IOleInPlaceObject)) { AddRef(); - *ppv = (IOleInPlaceObject*) this; + *ppv = static_cast<IOleInPlaceObject*>(this); return S_OK; } else if (IsEqualIID(riid, IID_IDispatch)) { AddRef(); - *ppv = (IDispatch*) this; + *ppv = static_cast<IDispatch*>(this); return S_OK; } - *ppv = NULL; + *ppv = nullptr; return ResultFromScode(E_NOINTERFACE); } @@ -427,13 +399,13 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetClassID( CLSID* pClassId ) STDMETHODIMP InprocEmbedDocument_Impl::IsDirty() { - if ( m_pDefHandler == NULL || m_pOleAdvises[0] == NULL || m_pOleAdvises[0]->IsClosed() ) + if ( m_pDefHandler == nullptr || m_pOleAdvises[0] == nullptr || m_pOleAdvises[0]->IsClosed() ) return S_FALSE; if ( CheckDefHandler() ) { ComSmart< IPersistStorage > pPersist; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IPersistStorage, (void**)&pPersist ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IPersistStorage, reinterpret_cast<void**>(&pPersist) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pPersist ) @@ -449,7 +421,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::InitNew( IStorage *pStg ) if ( CheckDefHandler() ) { ComSmart< IPersistStorage > pPersist; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IPersistStorage, (void**)&pPersist ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IPersistStorage, reinterpret_cast<void**>(&pPersist) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pPersist ) @@ -464,7 +436,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::InitNew( IStorage *pStg ) if ( m_pFileName ) { delete[] m_pFileName; - m_pFileName = NULL; + m_pFileName = nullptr; } } @@ -481,7 +453,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::Load( IStorage *pStg ) if ( CheckDefHandler() ) { ComSmart< IPersistStorage > pPersist; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IPersistStorage, (void**)&pPersist ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IPersistStorage, reinterpret_cast<void**>(&pPersist) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pPersist ) @@ -496,7 +468,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::Load( IStorage *pStg ) if ( m_pFileName ) { delete[] m_pFileName; - m_pFileName = NULL; + m_pFileName = nullptr; } } @@ -510,13 +482,13 @@ STDMETHODIMP InprocEmbedDocument_Impl::Load( IStorage *pStg ) STDMETHODIMP InprocEmbedDocument_Impl::Save( IStorage *pStgSave, BOOL fSameAsLoad ) { - if ( fSameAsLoad && ( m_pDefHandler == NULL || m_pOleAdvises[0] == NULL || m_pOleAdvises[0]->IsClosed() ) ) + if ( fSameAsLoad && ( m_pDefHandler == nullptr || m_pOleAdvises[0] == nullptr || m_pOleAdvises[0]->IsClosed() ) ) return S_OK; if ( CheckDefHandler() ) { ComSmart< IPersistStorage > pPersist; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IPersistStorage, (void**)&pPersist ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IPersistStorage, reinterpret_cast<void**>(&pPersist) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pPersist ) @@ -529,7 +501,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::Save( IStorage *pStgSave, BOOL fSameAsLoa STDMETHODIMP InprocEmbedDocument_Impl::SaveCompleted( IStorage *pStgNew ) { - if ( m_pDefHandler == NULL || m_pOleAdvises[0] == NULL || m_pOleAdvises[0]->IsClosed() ) + if ( m_pDefHandler == nullptr || m_pOleAdvises[0] == nullptr || m_pOleAdvises[0]->IsClosed() ) { if ( pStgNew ) m_pStorage = pStgNew; @@ -540,7 +512,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::SaveCompleted( IStorage *pStgNew ) if ( CheckDefHandler() ) { ComSmart< IPersistStorage > pPersist; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IPersistStorage, (void**)&pPersist ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IPersistStorage, reinterpret_cast<void**>(&pPersist) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pPersist ) @@ -558,7 +530,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::SaveCompleted( IStorage *pStgNew ) if ( m_pFileName ) { delete[] m_pFileName; - m_pFileName = NULL; + m_pFileName = nullptr; } } @@ -575,7 +547,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::HandsOffStorage() if ( CheckDefHandler() ) { ComSmart< IPersistStorage > pPersist; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IPersistStorage, (void**)&pPersist ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IPersistStorage, reinterpret_cast<void**>(&pPersist) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pPersist ) @@ -583,7 +555,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::HandsOffStorage() hr = pPersist->HandsOffStorage(); if ( SUCCEEDED( hr ) ) { - m_pStorage = NULL; + m_pStorage = nullptr; } return hr; @@ -600,7 +572,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD dwMode if ( CheckDefHandler() && pszFileName ) { ComSmart< IPersistFile > pPersist; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IPersistFile, (void**)&pPersist ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IPersistFile, reinterpret_cast<void**>(&pPersist) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pPersist ) @@ -610,7 +582,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD dwMode { m_nInitMode = LOAD_FROM_FILE; if ( m_pStorage ) - m_pStorage = NULL; + m_pStorage = nullptr; m_nFileOpenMode = dwMode; // copy the string @@ -630,7 +602,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::Save( LPCOLESTR pszFileName, BOOL fRememb if ( CheckDefHandler() ) { ComSmart< IPersistFile > pPersist; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IPersistFile, (void**)&pPersist ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IPersistFile, reinterpret_cast<void**>(&pPersist) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pPersist ) @@ -646,7 +618,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::SaveCompleted( LPCOLESTR pszFileName ) if ( CheckDefHandler() ) { ComSmart< IPersistFile > pPersist; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IPersistFile, (void**)&pPersist ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IPersistFile, reinterpret_cast<void**>(&pPersist) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pPersist ) @@ -656,7 +628,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::SaveCompleted( LPCOLESTR pszFileName ) { m_nInitMode = LOAD_FROM_STORAGE; if ( m_pStorage ) - m_pStorage = NULL; + m_pStorage = nullptr; m_nFileOpenMode = STGM_READWRITE; // was just written // copy the string @@ -675,7 +647,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetCurFile( LPOLESTR *ppszFileName ) if ( CheckDefHandler() ) { ComSmart< IPersistFile > pPersist; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IPersistFile, (void**)&pPersist ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IPersistFile, reinterpret_cast<void**>(&pPersist) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pPersist ) @@ -694,18 +666,18 @@ STDMETHODIMP InprocEmbedDocument_Impl::SetClientSite( IOleClientSite* pSite ) if ( !pSite ) { - m_pClientSite = NULL; + m_pClientSite = nullptr; if ( m_pOleContainer ) { m_pOleContainer->LockContainer( FALSE ); - m_pOleContainer = NULL; + m_pOleContainer = nullptr; } } if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, reinterpret_cast<void**>(&pOleObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pOleObject ) @@ -718,7 +690,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::SetClientSite( IOleClientSite* pSite ) if ( m_pOleContainer ) { m_pOleContainer->LockContainer( FALSE ); - m_pOleContainer = NULL; + m_pOleContainer = nullptr; } m_pClientSite->GetContainer( &m_pOleContainer ); @@ -739,7 +711,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetClientSite( IOleClientSite** pSite ) if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, reinterpret_cast<void**>(&pOleObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pOleObject ) @@ -756,7 +728,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::SetHostNames( LPCOLESTR szContainerApp, L if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, reinterpret_cast<void**>(&pOleObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pOleObject ) @@ -776,7 +748,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::Close( DWORD dwSaveOption ) { // no need to close if there is no default handler. ComSmart< IOleObject > pOleObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, reinterpret_cast<void**>(&pOleObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pOleObject ) @@ -784,7 +756,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::Close( DWORD dwSaveOption ) hr = pOleObject->Close( dwSaveOption ); if (!SUCCEEDED(hr)) ret = hr; - hr = CoDisconnectObject( (IUnknown*)(IPersistStorage*)this, 0 ); + hr = CoDisconnectObject( static_cast<IUnknown*>(static_cast<IPersistStorage*>(this)), 0 ); if (!SUCCEEDED(hr) && SUCCEEDED(ret)) ret = hr; } @@ -802,7 +774,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::SetMoniker( DWORD dwWhichMoniker, IMonike if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, reinterpret_cast<void**>(&pOleObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pOleObject ) @@ -818,7 +790,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetMoniker( DWORD dwAssign, DWORD dwWhich if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, reinterpret_cast<void**>(&pOleObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pOleObject ) @@ -834,7 +806,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::InitFromData( IDataObject * pDataObject, if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, reinterpret_cast<void**>(&pOleObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pOleObject ) @@ -850,7 +822,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetClipboardData( DWORD dwReserved, IData if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, reinterpret_cast<void**>(&pOleObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pOleObject ) @@ -872,7 +844,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::DoVerb( if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, reinterpret_cast<void**>(&pOleObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pOleObject ) @@ -896,7 +868,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::EnumVerbs( IEnumOLEVERB ** ppEnumOleVerb if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, reinterpret_cast<void**>(&pOleObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pOleObject ) @@ -913,7 +885,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::Update() if ( m_pDefHandler && CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, reinterpret_cast<void**>(&pOleObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pOleObject ) @@ -929,7 +901,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::IsUpToDate() if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, reinterpret_cast<void**>(&pOleObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pOleObject ) @@ -954,7 +926,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetUserType( DWORD dwFormOfType, LPOLESTR if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, reinterpret_cast<void**>(&pOleObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pOleObject ) @@ -970,7 +942,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::SetExtent( DWORD dwDrawAspect, SIZEL *psi if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, reinterpret_cast<void**>(&pOleObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pOleObject ) @@ -986,7 +958,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetExtent( DWORD dwDrawAspect, SIZEL * ps if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, reinterpret_cast<void**>(&pOleObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pOleObject ) @@ -1007,13 +979,13 @@ STDMETHODIMP InprocEmbedDocument_Impl::Advise( IAdviseSink *pAdvSink, DWORD *pdw if ( DEFAULT_ARRAY_LEN > *pdwConnection && *pdwConnection > 0 && m_pOleAdvises[*pdwConnection] ) { m_pOleAdvises[*pdwConnection]->DisconnectOrigAdvise(); - m_pOleAdvises[*pdwConnection] = NULL; + m_pOleAdvises[*pdwConnection] = nullptr; } if ( pAdvSink && CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, reinterpret_cast<void**>(&pOleObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pOleObject ) @@ -1046,7 +1018,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::Unadvise( DWORD dwConnection ) if ( m_pDefHandler ) { ComSmart< IOleObject > pOleObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, reinterpret_cast<void**>(&pOleObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pOleObject ) @@ -1057,7 +1029,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::Unadvise( DWORD dwConnection ) } m_pOleAdvises[dwConnection]->DisconnectOrigAdvise(); - m_pOleAdvises[dwConnection] = NULL; + m_pOleAdvises[dwConnection] = nullptr; return S_OK; } @@ -1077,7 +1049,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetMiscStatus( DWORD dwAspect, DWORD * pd if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, reinterpret_cast<void**>(&pOleObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pOleObject ) @@ -1093,7 +1065,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::SetColorScheme( LOGPALETTE * pLogpal ) if ( CheckDefHandler() ) { ComSmart< IOleObject > pOleObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, (void**)&pOleObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleObject, reinterpret_cast<void**>(&pOleObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pOleObject ) @@ -1110,7 +1082,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetData( FORMATETC * pFormatetc, STGMEDIU if ( CheckDefHandler() ) { ComSmart< IDataObject > pIDataObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IDataObject, (void**)&pIDataObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IDataObject, reinterpret_cast<void**>(&pIDataObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIDataObject ) @@ -1126,7 +1098,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetDataHere( FORMATETC * pFormatetc, STGM if ( CheckDefHandler() ) { ComSmart< IDataObject > pIDataObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IDataObject, (void**)&pIDataObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IDataObject, reinterpret_cast<void**>(&pIDataObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIDataObject ) @@ -1142,7 +1114,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::QueryGetData( FORMATETC * pFormatetc ) if ( CheckDefHandler() ) { ComSmart< IDataObject > pIDataObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IDataObject, (void**)&pIDataObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IDataObject, reinterpret_cast<void**>(&pIDataObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIDataObject ) @@ -1158,7 +1130,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetCanonicalFormatEtc( FORMATETC * pForma if ( CheckDefHandler() ) { ComSmart< IDataObject > pIDataObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IDataObject, (void**)&pIDataObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IDataObject, reinterpret_cast<void**>(&pIDataObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIDataObject ) @@ -1174,7 +1146,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::SetData( FORMATETC * pFormatetc, STGMEDIU if ( CheckDefHandler() ) { ComSmart< IDataObject > pIDataObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IDataObject, (void**)&pIDataObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IDataObject, reinterpret_cast<void**>(&pIDataObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIDataObject ) @@ -1190,7 +1162,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::EnumFormatEtc( DWORD dwDirection, IEnumFO if ( CheckDefHandler() ) { ComSmart< IDataObject > pIDataObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IDataObject, (void**)&pIDataObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IDataObject, reinterpret_cast<void**>(&pIDataObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIDataObject ) @@ -1211,13 +1183,13 @@ STDMETHODIMP InprocEmbedDocument_Impl::DAdvise( FORMATETC * pFormatetc, DWORD ad if ( m_pDefHandler && DEFAULT_ARRAY_LEN > *pdwConnection && *pdwConnection > 0 && m_pDataAdvises[*pdwConnection] ) { m_pDataAdvises[*pdwConnection]->DisconnectOrigAdvise(); - m_pDataAdvises[*pdwConnection] = NULL; + m_pDataAdvises[*pdwConnection] = nullptr; } if ( pAdvSink && CheckDefHandler() ) { ComSmart< IDataObject > pIDataObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IDataObject, (void**)&pIDataObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IDataObject, reinterpret_cast<void**>(&pIDataObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIDataObject ) @@ -1249,7 +1221,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::DUnadvise( DWORD dwConnection ) if ( CheckDefHandler() ) { ComSmart< IDataObject > pIDataObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IDataObject, (void**)&pIDataObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IDataObject, reinterpret_cast<void**>(&pIDataObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIDataObject ) @@ -1260,7 +1232,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::DUnadvise( DWORD dwConnection ) } m_pDataAdvises[dwConnection]->DisconnectOrigAdvise(); - m_pDataAdvises[dwConnection] = NULL; + m_pDataAdvises[dwConnection] = nullptr; return S_OK; } @@ -1274,7 +1246,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::EnumDAdvise( IEnumSTATDATA ** ppenumAdvis if ( CheckDefHandler() ) { ComSmart< IDataObject > pIDataObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IDataObject, (void**)&pIDataObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IDataObject, reinterpret_cast<void**>(&pIDataObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIDataObject ) @@ -1291,7 +1263,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetRunningClass( LPCLSID lpClsid ) if ( CheckDefHandler() ) { ComSmart< IRunnableObject > pIRunObj; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IRunnableObject, (void**)&pIRunObj ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IRunnableObject, reinterpret_cast<void**>(&pIRunObj) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIRunObj ) @@ -1307,7 +1279,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::Run( LPBINDCTX pbc ) if ( CheckDefHandler() ) { ComSmart< IRunnableObject > pIRunObj; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IRunnableObject, (void**)&pIRunObj ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IRunnableObject, reinterpret_cast<void**>(&pIRunObj) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIRunObj ) @@ -1323,7 +1295,7 @@ BOOL STDMETHODCALLTYPE InprocEmbedDocument_Impl::IsRunning() if ( CheckDefHandler() ) { ComSmart< IRunnableObject > pIRunObj; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IRunnableObject, (void**)&pIRunObj ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IRunnableObject, reinterpret_cast<void**>(&pIRunObj) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIRunObj ) @@ -1340,7 +1312,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::LockRunning( BOOL fLock, BOOL fLastUnlock if ( CheckDefHandler() ) { ComSmart< IRunnableObject > pIRunObj; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IRunnableObject, (void**)&pIRunObj ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IRunnableObject, reinterpret_cast<void**>(&pIRunObj) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIRunObj ) @@ -1356,7 +1328,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::SetContainedObject( BOOL fContained) if ( CheckDefHandler() ) { ComSmart< IRunnableObject > pIRunObj; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IRunnableObject, (void**)&pIRunObj ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IRunnableObject, reinterpret_cast<void**>(&pIRunObj) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIRunObj ) @@ -1374,7 +1346,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::Draw( DWORD dwDrawAspect, LONG lindex, vo if ( CheckDefHandler() ) { ComSmart< IViewObject > pIViewObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IViewObject, (void**)&pIViewObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IViewObject, reinterpret_cast<void**>(&pIViewObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIViewObject ) @@ -1390,7 +1362,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetColorSet( DWORD dwDrawAspect, LONG lin if ( CheckDefHandler() ) { ComSmart< IViewObject > pIViewObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IViewObject, (void**)&pIViewObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IViewObject, reinterpret_cast<void**>(&pIViewObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIViewObject ) @@ -1406,7 +1378,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::Freeze( DWORD dwDrawAspect, LONG lindex, if ( CheckDefHandler() ) { ComSmart< IViewObject > pIViewObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IViewObject, (void**)&pIViewObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IViewObject, reinterpret_cast<void**>(&pIViewObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIViewObject ) @@ -1422,7 +1394,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::Unfreeze( DWORD dwFreeze ) if ( CheckDefHandler() ) { ComSmart< IViewObject > pIViewObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IViewObject, (void**)&pIViewObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IViewObject, reinterpret_cast<void**>(&pIViewObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIViewObject ) @@ -1440,13 +1412,13 @@ STDMETHODIMP InprocEmbedDocument_Impl::SetAdvise( DWORD aspects, DWORD advf, IAd if ( m_pViewAdvise ) { m_pViewAdvise->DisconnectOrigAdvise(); - m_pViewAdvise = NULL; + m_pViewAdvise = nullptr; } if ( pAdvSink && CheckDefHandler() ) { ComSmart< IViewObject > pIViewObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IViewObject, (void**)&pIViewObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IViewObject, reinterpret_cast<void**>(&pIViewObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIViewObject ) @@ -1484,7 +1456,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetAdvise( DWORD *pAspects, DWORD *pAdvf, (*ppAdvSink)->AddRef(); } else - *ppAdvSink = NULL; + *ppAdvSink = nullptr; return S_OK; } @@ -1496,7 +1468,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetExtent( DWORD dwDrawAspect, LONG linde if ( CheckDefHandler() ) { ComSmart< IViewObject2 > pIViewObject2; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IViewObject2, (void**)&pIViewObject2 ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IViewObject2, reinterpret_cast<void**>(&pIViewObject2) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIViewObject2 ) @@ -1514,7 +1486,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetWindow( HWND *phwnd ) if ( CheckDefHandler() ) { ComSmart< IOleWindow > pIOleWindow; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleWindow, (void**)&pIOleWindow ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleWindow, reinterpret_cast<void**>(&pIOleWindow) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIOleWindow ) @@ -1530,7 +1502,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::ContextSensitiveHelp( BOOL fEnterMode ) if ( CheckDefHandler() ) { ComSmart< IOleWindow > pIOleWindow; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleWindow, (void**)&pIOleWindow ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleWindow, reinterpret_cast<void**>(&pIOleWindow) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIOleWindow ) @@ -1548,7 +1520,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::InPlaceDeactivate() if ( CheckDefHandler() ) { ComSmart< IOleInPlaceObject > pIOleInPlaceObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleInPlaceObject, (void**)&pIOleInPlaceObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleInPlaceObject, reinterpret_cast<void**>(&pIOleInPlaceObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIOleInPlaceObject ) @@ -1564,7 +1536,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::UIDeactivate() if ( CheckDefHandler() ) { ComSmart< IOleInPlaceObject > pIOleInPlaceObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleInPlaceObject, (void**)&pIOleInPlaceObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleInPlaceObject, reinterpret_cast<void**>(&pIOleInPlaceObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIOleInPlaceObject ) @@ -1580,7 +1552,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::SetObjectRects( LPCRECT lprcPosRect, LPCR if ( CheckDefHandler() ) { ComSmart< IOleInPlaceObject > pIOleInPlaceObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleInPlaceObject, (void**)&pIOleInPlaceObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleInPlaceObject, reinterpret_cast<void**>(&pIOleInPlaceObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIOleInPlaceObject ) @@ -1596,7 +1568,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::ReactivateAndUndo() if ( CheckDefHandler() ) { ComSmart< IOleInPlaceObject > pIOleInPlaceObject; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleInPlaceObject, (void**)&pIOleInPlaceObject ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IOleInPlaceObject, reinterpret_cast<void**>(&pIOleInPlaceObject) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIOleInPlaceObject ) @@ -1614,7 +1586,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetTypeInfoCount( UINT *pctinfo ) if ( CheckDefHandler() ) { ComSmart< IDispatch > pIDispatch; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IDispatch, (void**)&pIDispatch ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IDispatch, reinterpret_cast<void**>(&pIDispatch) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIDispatch ) @@ -1630,7 +1602,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetTypeInfo( UINT iTInfo, LCID lcid, ITyp if ( CheckDefHandler() ) { ComSmart< IDispatch > pIDispatch; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IDispatch, (void**)&pIDispatch ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IDispatch, reinterpret_cast<void**>(&pIDispatch) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIDispatch ) @@ -1646,7 +1618,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::GetIDsOfNames( REFIID riid, LPOLESTR *rgs if ( CheckDefHandler() ) { ComSmart< IDispatch > pIDispatch; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IDispatch, (void**)&pIDispatch ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IDispatch, reinterpret_cast<void**>(&pIDispatch) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIDispatch ) @@ -1662,7 +1634,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::Invoke( DISPID dispIdMember, REFIID riid, if ( CheckDefHandler() ) { ComSmart< IDispatch > pIDispatch; - HRESULT hr = m_pDefHandler->QueryInterface( IID_IDispatch, (void**)&pIDispatch ); + HRESULT hr = m_pDefHandler->QueryInterface( IID_IDispatch, reinterpret_cast<void**>(&pIDispatch) ); ULONGGuard aGuard( &m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIDispatch ) @@ -1702,7 +1674,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::InternalCacheWrapper::Cache( FORMATETC *p if ( m_rOwnDocument.CheckDefHandler() ) { ComSmart< IOleCache > pIOleCache; - HRESULT hr = m_rOwnDocument.GetDefHandler()->QueryInterface( IID_IOleCache, (void**)&pIOleCache ); + HRESULT hr = m_rOwnDocument.GetDefHandler()->QueryInterface( IID_IOleCache, reinterpret_cast<void**>(&pIOleCache) ); ULONGGuard aGuard( &m_rOwnDocument.m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIOleCache ) @@ -1718,7 +1690,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::InternalCacheWrapper::Uncache( DWORD dwCo if ( m_rOwnDocument.CheckDefHandler() ) { ComSmart< IOleCache > pIOleCache; - HRESULT hr = m_rOwnDocument.GetDefHandler()->QueryInterface( IID_IOleCache, (void**)&pIOleCache ); + HRESULT hr = m_rOwnDocument.GetDefHandler()->QueryInterface( IID_IOleCache, reinterpret_cast<void**>(&pIOleCache) ); ULONGGuard aGuard( &m_rOwnDocument.m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIOleCache ) @@ -1734,7 +1706,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::InternalCacheWrapper::EnumCache( IEnumSTA if ( m_rOwnDocument.CheckDefHandler() ) { ComSmart< IOleCache > pIOleCache; - HRESULT hr = m_rOwnDocument.GetDefHandler()->QueryInterface( IID_IOleCache, (void**)&pIOleCache ); + HRESULT hr = m_rOwnDocument.GetDefHandler()->QueryInterface( IID_IOleCache, reinterpret_cast<void**>(&pIOleCache) ); ULONGGuard aGuard( &m_rOwnDocument.m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIOleCache ) @@ -1750,7 +1722,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::InternalCacheWrapper::InitCache( IDataObj if ( m_rOwnDocument.CheckDefHandler() ) { ComSmart< IOleCache > pIOleCache; - HRESULT hr = m_rOwnDocument.GetDefHandler()->QueryInterface( IID_IOleCache, (void**)&pIOleCache ); + HRESULT hr = m_rOwnDocument.GetDefHandler()->QueryInterface( IID_IOleCache, reinterpret_cast<void**>(&pIOleCache) ); ULONGGuard aGuard( &m_rOwnDocument.m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIOleCache ) @@ -1766,7 +1738,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::InternalCacheWrapper::SetData( FORMATETC if ( m_rOwnDocument.CheckDefHandler() ) { ComSmart< IOleCache > pIOleCache; - HRESULT hr = m_rOwnDocument.GetDefHandler()->QueryInterface( IID_IOleCache, (void**)&pIOleCache ); + HRESULT hr = m_rOwnDocument.GetDefHandler()->QueryInterface( IID_IOleCache, reinterpret_cast<void**>(&pIOleCache) ); ULONGGuard aGuard( &m_rOwnDocument.m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIOleCache ) @@ -1783,7 +1755,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::InternalCacheWrapper::UpdateCache( LPDATA if ( m_rOwnDocument.CheckDefHandler() ) { ComSmart< IOleCache2 > pIOleCache2; - HRESULT hr = m_rOwnDocument.GetDefHandler()->QueryInterface( IID_IOleCache2, (void**)&pIOleCache2 ); + HRESULT hr = m_rOwnDocument.GetDefHandler()->QueryInterface( IID_IOleCache2, reinterpret_cast<void**>(&pIOleCache2) ); ULONGGuard aGuard( &m_rOwnDocument.m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIOleCache2 ) @@ -1799,7 +1771,7 @@ STDMETHODIMP InprocEmbedDocument_Impl::InternalCacheWrapper::DiscardCache( DWORD if ( m_rOwnDocument.CheckDefHandler() ) { ComSmart< IOleCache2 > pIOleCache2; - HRESULT hr = m_rOwnDocument.GetDefHandler()->QueryInterface( IID_IOleCache2, (void**)&pIOleCache2 ); + HRESULT hr = m_rOwnDocument.GetDefHandler()->QueryInterface( IID_IOleCache2, reinterpret_cast<void**>(&pIOleCache2) ); ULONGGuard aGuard( &m_rOwnDocument.m_nCallsOnStack ); // avoid reentrance problem if ( SUCCEEDED( hr ) && pIOleCache2 ) diff --git a/embedserv/source/inprocserv/inprocembobj.h b/embedserv/source/inprocserv/inprocembobj.h index 25ee78f5f5c5..a900a61598f1 100644 --- a/embedserv/source/inprocserv/inprocembobj.h +++ b/embedserv/source/inprocserv/inprocembobj.h @@ -101,22 +101,20 @@ class InprocEmbedDocument_Impl : public InprocCountedObject_Impl virtual ~InternalCacheWrapper() {} /* IUnknown methods */ - STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj); - STDMETHOD_(ULONG, AddRef)(); - STDMETHOD_(ULONG, Release)(); + STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj) override; + STDMETHOD_(ULONG, AddRef)() override; + STDMETHOD_(ULONG, Release)() override; /* IOleCache2 methods */ - STDMETHOD(Cache)( FORMATETC *pformatetc, DWORD advf, DWORD *pdwConnection); - STDMETHOD(Uncache)( DWORD dwConnection); - STDMETHOD(EnumCache)( IEnumSTATDATA **ppenumSTATDATA); - STDMETHOD(InitCache)( IDataObject *pDataObject); - STDMETHOD(SetData)( FORMATETC *pformatetc, STGMEDIUM *pmedium, BOOL fRelease); - STDMETHOD(UpdateCache)( LPDATAOBJECT pDataObject, DWORD grfUpdf, LPVOID pReserved); - STDMETHOD(DiscardCache)( DWORD dwDiscardOptions); + STDMETHOD(Cache)( FORMATETC *pformatetc, DWORD advf, DWORD *pdwConnection) override; + STDMETHOD(Uncache)( DWORD dwConnection) override; + STDMETHOD(EnumCache)( IEnumSTATDATA **ppenumSTATDATA) override; + STDMETHOD(InitCache)( IDataObject *pDataObject) override; + STDMETHOD(SetData)( FORMATETC *pformatetc, STGMEDIUM *pmedium, BOOL fRelease) override; + STDMETHOD(UpdateCache)( LPDATAOBJECT pDataObject, DWORD grfUpdf, LPVOID pReserved) override; + STDMETHOD(DiscardCache)( DWORD dwDiscardOptions) override; } m_aInternalCache; - - DWORD InsertAdviseLinkToList( const ComSmart<OleWrapperAdviseSink>& pOwnAdvise, ComSmart< OleWrapperAdviseSink > pAdvises[] ); void Clean(); @@ -128,7 +126,7 @@ public: , m_guid( guid ) , m_nInitMode( NOINIT ) , m_nFileOpenMode( 0 ) - , m_pFileName( NULL ) + , m_pFileName( nullptr ) , m_nCallsOnStack( 0 ) , m_aInternalCache( *this ) {} @@ -136,99 +134,96 @@ public: virtual ~InprocEmbedDocument_Impl() {} - HRESULT Init(); - void SetName( LPCOLESTR pszNameFromOutside, wchar_t*& pOwnName ); - BOOL CheckDefHandler(); ComSmart< IUnknown >& GetDefHandler() { return m_pDefHandler; } /* IUnknown methods */ - STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj); - STDMETHOD_(ULONG, AddRef)(); - STDMETHOD_(ULONG, Release)(); + STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj) override; + STDMETHOD_(ULONG, AddRef)() override; + STDMETHOD_(ULONG, Release)() override; /* IOleObject methods */ - STDMETHOD(SetClientSite) ( IOleClientSite* pSite ); - STDMETHOD(GetClientSite) ( IOleClientSite** pSite ); - STDMETHOD(SetHostNames) ( LPCOLESTR szContainerApp, LPCOLESTR szContainerObj ); - STDMETHOD(Close) ( DWORD dwSaveOption); - STDMETHOD(SetMoniker) ( DWORD dwWhichMoniker, IMoniker *pmk ); - STDMETHOD(GetMoniker) ( DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk ); - STDMETHOD(InitFromData) ( IDataObject *pDataObject, BOOL fCreation, DWORD dwReserved ); - STDMETHOD(GetClipboardData) ( DWORD dwReserved, IDataObject **ppDataObject ); - STDMETHOD(DoVerb) ( LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect ); - STDMETHOD(EnumVerbs) ( IEnumOLEVERB **ppEnumOleVerb ); - STDMETHOD(Update) (); - STDMETHOD(IsUpToDate) (); - STDMETHOD(GetUserClassID) ( CLSID *pClsid ); - STDMETHOD(GetUserType) ( DWORD dwFormOfType, LPOLESTR *pszUserType ); - STDMETHOD(SetExtent) ( DWORD dwDrawAspect, SIZEL *psizel ); - STDMETHOD(GetExtent) ( DWORD dwDrawAspect, SIZEL *psizel ); - STDMETHOD(Advise) ( IAdviseSink *pAdvSink, DWORD *pdwConnection ); - STDMETHOD(Unadvise) ( DWORD dwConnection ); - STDMETHOD(EnumAdvise) ( IEnumSTATDATA **ppenumAdvise ); - STDMETHOD(GetMiscStatus) ( DWORD dwAspect, DWORD *pdwStatus ); - STDMETHOD(SetColorScheme) ( LOGPALETTE *pLogpal ); + STDMETHOD(SetClientSite) ( IOleClientSite* pSite ) override; + STDMETHOD(GetClientSite) ( IOleClientSite** pSite ) override; + STDMETHOD(SetHostNames) ( LPCOLESTR szContainerApp, LPCOLESTR szContainerObj ) override; + STDMETHOD(Close) ( DWORD dwSaveOption) override; + STDMETHOD(SetMoniker) ( DWORD dwWhichMoniker, IMoniker *pmk ) override; + STDMETHOD(GetMoniker) ( DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk ) override; + STDMETHOD(InitFromData) ( IDataObject *pDataObject, BOOL fCreation, DWORD dwReserved ) override; + STDMETHOD(GetClipboardData) ( DWORD dwReserved, IDataObject **ppDataObject ) override; + STDMETHOD(DoVerb) ( LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect ) override; + STDMETHOD(EnumVerbs) ( IEnumOLEVERB **ppEnumOleVerb ) override; + STDMETHOD(Update) () override; + STDMETHOD(IsUpToDate) () override; + STDMETHOD(GetUserClassID) ( CLSID *pClsid ) override; + STDMETHOD(GetUserType) ( DWORD dwFormOfType, LPOLESTR *pszUserType ) override; + STDMETHOD(SetExtent) ( DWORD dwDrawAspect, SIZEL *psizel ) override; + STDMETHOD(GetExtent) ( DWORD dwDrawAspect, SIZEL *psizel ) override; + STDMETHOD(Advise) ( IAdviseSink *pAdvSink, DWORD *pdwConnection ) override; + STDMETHOD(Unadvise) ( DWORD dwConnection ) override; + STDMETHOD(EnumAdvise) ( IEnumSTATDATA **ppenumAdvise ) override; + STDMETHOD(GetMiscStatus) ( DWORD dwAspect, DWORD *pdwStatus ) override; + STDMETHOD(SetColorScheme) ( LOGPALETTE *pLogpal ) override; /* IDataObject methods */ - STDMETHOD(GetData) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium ); - STDMETHOD(GetDataHere) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium ); - STDMETHOD(QueryGetData) ( FORMATETC * pFormatetc ); - STDMETHOD(GetCanonicalFormatEtc) ( FORMATETC * pFormatetcIn, FORMATETC * pFormatetcOut ); - STDMETHOD(SetData) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium, BOOL fRelease ); - STDMETHOD(EnumFormatEtc) ( DWORD dwDirection, IEnumFORMATETC ** ppFormatetc ); - STDMETHOD(DAdvise) ( FORMATETC * pFormatetc, DWORD advf, IAdviseSink * pAdvSink, DWORD * pdwConnection ); - STDMETHOD(DUnadvise) ( DWORD dwConnection ); - STDMETHOD(EnumDAdvise) ( IEnumSTATDATA ** ppenumAdvise ); + STDMETHOD(GetData) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium ) override; + STDMETHOD(GetDataHere) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium ) override; + STDMETHOD(QueryGetData) ( FORMATETC * pFormatetc ) override; + STDMETHOD(GetCanonicalFormatEtc) ( FORMATETC * pFormatetcIn, FORMATETC * pFormatetcOut ) override; + STDMETHOD(SetData) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium, BOOL fRelease ) override; + STDMETHOD(EnumFormatEtc) ( DWORD dwDirection, IEnumFORMATETC ** ppFormatetc ) override; + STDMETHOD(DAdvise) ( FORMATETC * pFormatetc, DWORD advf, IAdviseSink * pAdvSink, DWORD * pdwConnection ) override; + STDMETHOD(DUnadvise) ( DWORD dwConnection ) override; + STDMETHOD(EnumDAdvise) ( IEnumSTATDATA ** ppenumAdvise ) override; /* IPersistMethod */ - STDMETHOD(GetClassID)(CLSID *pClassID); + STDMETHOD(GetClassID)(CLSID *pClassID) override; /* IPersistStorage methods */ - STDMETHOD(IsDirty) (); - STDMETHOD(InitNew) ( IStorage *pStg ); - STDMETHOD(Load) ( IStorage* pStr ); - STDMETHOD(Save) ( IStorage *pStgSave, BOOL fSameAsLoad ); - STDMETHOD(SaveCompleted) ( IStorage *pStgNew ); - STDMETHOD(HandsOffStorage) (void); + STDMETHOD(IsDirty) () override; + STDMETHOD(InitNew) ( IStorage *pStg ) override; + STDMETHOD(Load) ( IStorage* pStr ) override; + STDMETHOD(Save) ( IStorage *pStgSave, BOOL fSameAsLoad ) override; + STDMETHOD(SaveCompleted) ( IStorage *pStgNew ) override; + STDMETHOD(HandsOffStorage) (void) override; /* IPersistFile methods */ - STDMETHOD(Load) ( LPCOLESTR pszFileName, DWORD dwMode ); - STDMETHOD(Save) ( LPCOLESTR pszFileName, BOOL fRemember ); - STDMETHOD(SaveCompleted) ( LPCOLESTR pszFileName ); - STDMETHOD(GetCurFile) ( LPOLESTR *ppszFileName ); + STDMETHOD(Load) ( LPCOLESTR pszFileName, DWORD dwMode ) override; + STDMETHOD(Save) ( LPCOLESTR pszFileName, BOOL fRemember ) override; + STDMETHOD(SaveCompleted) ( LPCOLESTR pszFileName ) override; + STDMETHOD(GetCurFile) ( LPOLESTR *ppszFileName ) override; /* IRunnableObject methods */ - STDMETHOD(GetRunningClass) ( LPCLSID lpClsid); - STDMETHOD(Run) ( LPBINDCTX pbc); - virtual BOOL STDMETHODCALLTYPE IsRunning( void); - STDMETHOD(LockRunning) ( BOOL fLock, BOOL fLastUnlockCloses ); - STDMETHOD(SetContainedObject) ( BOOL fContained); + STDMETHOD(GetRunningClass) ( LPCLSID lpClsid) override; + STDMETHOD(Run) ( LPBINDCTX pbc) override; + virtual BOOL STDMETHODCALLTYPE IsRunning( void) override; + STDMETHOD(LockRunning) ( BOOL fLock, BOOL fLastUnlockCloses ) override; + STDMETHOD(SetContainedObject) ( BOOL fContained) override; /* IViewObject2 methods */ - STDMETHOD(Draw)( DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds, BOOL ( STDMETHODCALLTYPE *pfnContinue )( ULONG_PTR dwContinue ), ULONG_PTR dwContinue); - STDMETHOD(GetColorSet)( DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet); - STDMETHOD(Freeze)( DWORD dwDrawAspect, LONG lindex, void *pvAspect, DWORD *pdwFreeze); - STDMETHOD(Unfreeze)( DWORD dwFreeze); - STDMETHOD(SetAdvise)( DWORD aspects, DWORD advf, IAdviseSink *pAdvSink); - STDMETHOD(GetAdvise)( DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink); - STDMETHOD(GetExtent)( DWORD dwDrawAspect, LONG lindex, DVTARGETDEVICE *ptd, LPSIZEL lpsizel); + STDMETHOD(Draw)( DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds, BOOL ( STDMETHODCALLTYPE *pfnContinue )( ULONG_PTR dwContinue ), ULONG_PTR dwContinue) override; + STDMETHOD(GetColorSet)( DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet) override; + STDMETHOD(Freeze)( DWORD dwDrawAspect, LONG lindex, void *pvAspect, DWORD *pdwFreeze) override; + STDMETHOD(Unfreeze)( DWORD dwFreeze) override; + STDMETHOD(SetAdvise)( DWORD aspects, DWORD advf, IAdviseSink *pAdvSink) override; + STDMETHOD(GetAdvise)( DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink) override; + STDMETHOD(GetExtent)( DWORD dwDrawAspect, LONG lindex, DVTARGETDEVICE *ptd, LPSIZEL lpsizel) override; /* IOleWindow methods */ - STDMETHOD(GetWindow)( HWND *phwnd); - STDMETHOD(ContextSensitiveHelp)( BOOL fEnterMode); + STDMETHOD(GetWindow)( HWND *phwnd) override; + STDMETHOD(ContextSensitiveHelp)( BOOL fEnterMode) override; /* IOleInPlaceObject methods */ - STDMETHOD(InPlaceDeactivate)( void); - STDMETHOD(UIDeactivate)( void); - STDMETHOD(SetObjectRects)( LPCRECT lprcPosRect, LPCRECT lprcClipRect); - STDMETHOD(ReactivateAndUndo)( void); + STDMETHOD(InPlaceDeactivate)( void) override; + STDMETHOD(UIDeactivate)( void) override; + STDMETHOD(SetObjectRects)( LPCRECT lprcPosRect, LPCRECT lprcClipRect) override; + STDMETHOD(ReactivateAndUndo)( void) override; /*IDispatch methods*/ - STDMETHOD(GetTypeInfoCount)( UINT *pctinfo); - STDMETHOD(GetTypeInfo)( UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo); - STDMETHOD(GetIDsOfNames)( REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId); - STDMETHOD(Invoke)( DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr); + STDMETHOD(GetTypeInfoCount)( UINT *pctinfo) override; + STDMETHOD(GetTypeInfo)( UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) override; + STDMETHOD(GetIDsOfNames)( REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) override; + STDMETHOD(Invoke)( DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) override; }; diff --git a/embedserv/source/inprocserv/smartpointer.hxx b/embedserv/source/inprocserv/smartpointer.hxx index dab46ada769a..2cd19610762c 100644 --- a/embedserv/source/inprocserv/smartpointer.hxx +++ b/embedserv/source/inprocserv/smartpointer.hxx @@ -33,27 +33,27 @@ 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 ) : m_pInterface( rObj.m_pInterface ) { - if ( m_pInterface != NULL ) + if ( m_pInterface != nullptr ) m_pInterface->AddRef(); } explicit ComSmart( T* pInterface ) : m_pInterface( pInterface ) { - if ( m_pInterface != NULL ) + if ( m_pInterface != nullptr ) m_pInterface->AddRef(); } @@ -68,7 +68,7 @@ public: m_pInterface = rObj.m_pInterface; - if ( m_pInterface != NULL ) + if ( m_pInterface != nullptr ) m_pInterface->AddRef(); return *this; @@ -80,7 +80,7 @@ public: m_pInterface = pInterface; - if ( m_pInterface != NULL ) + if ( m_pInterface != nullptr ) m_pInterface->AddRef(); return *this; @@ -100,7 +100,7 @@ public: { OwnRelease(); - m_pInterface = NULL; + m_pInterface = nullptr; return &m_pInterface; } |