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/embed | |
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/embed')
-rw-r--r-- | embedserv/source/embed/docholder.cxx | 217 | ||||
-rw-r--r-- | embedserv/source/embed/ed_idataobj.cxx | 20 | ||||
-rw-r--r-- | embedserv/source/embed/ed_iinplace.cxx | 2 | ||||
-rw-r--r-- | embedserv/source/embed/ed_ioleobject.cxx | 16 | ||||
-rw-r--r-- | embedserv/source/embed/ed_ipersiststr.cxx | 126 | ||||
-rw-r--r-- | embedserv/source/embed/esdll.cxx | 2 | ||||
-rw-r--r-- | embedserv/source/embed/guid.cxx | 2 | ||||
-rw-r--r-- | embedserv/source/embed/guid.hxx | 37 | ||||
-rw-r--r-- | embedserv/source/embed/iipaobj.cxx | 6 | ||||
-rw-r--r-- | embedserv/source/embed/intercept.cxx | 78 | ||||
-rw-r--r-- | embedserv/source/embed/register.cxx | 4 | ||||
-rw-r--r-- | embedserv/source/embed/servprov.cxx | 26 | ||||
-rw-r--r-- | embedserv/source/embed/syswinwrapper.cxx | 40 | ||||
-rw-r--r-- | embedserv/source/embed/tracker.cxx | 181 |
14 files changed, 388 insertions, 369 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; } } |