From caea6281967bacd38a9296e6acefe9e5baefc3a4 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 22 Sep 2017 08:54:58 +0200 Subject: Better not modify const RECTs passed in ...through IOleInPlaceObject::SetObjectRects, via EmbedDocument_Impl::SetObjectRects Change-Id: Ia2533822795776d18132a457dc41f80fadb7c809 Reviewed-on: https://gerrit.libreoffice.org/42615 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- embedserv/source/embed/docholder.cxx | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/embedserv/source/embed/docholder.cxx b/embedserv/source/embed/docholder.cxx index 2998395279c4..929e8d252350 100644 --- a/embedserv/source/embed/docholder.cxx +++ b/embedserv/source/embed/docholder.cxx @@ -1176,24 +1176,26 @@ HRESULT DocumentHolder::SetContRects(LPCRECT aRect) HRESULT DocumentHolder::SetObjectRects(LPCRECT aRect, LPCRECT aClip) { - const_cast(aRect)->left -= m_aBorder.left; - const_cast(aRect)->right += m_aBorder.right; - const_cast(aRect)->top -= m_aBorder.top; - const_cast(aRect)->bottom += m_aBorder.bottom; - const_cast(aClip)->left -= m_aBorder.left; - const_cast(aClip)->right += m_aBorder.right; - const_cast(aClip)->top -= m_aBorder.top; - const_cast(aClip)->bottom += m_aBorder.bottom; + auto rect = *aRect; + rect.left -= m_aBorder.left; + rect.right += m_aBorder.right; + rect.top -= m_aBorder.top; + rect.bottom += m_aBorder.bottom; + auto clip = *aClip; + clip.left -= m_aBorder.left; + clip.right += m_aBorder.right; + clip.top -= m_aBorder.top; + clip.bottom += m_aBorder.bottom; if(m_pCHatchWin) - m_pCHatchWin->RectsSet(const_cast(aRect), const_cast(aClip)); + m_pCHatchWin->RectsSet(&rect, &clip); if(m_xEditWindow.is()) { m_xEditWindow->setVisible(false); m_xEditWindow->setPosSize( m_pCHatchWin ? HATCHWIN_BORDERWIDTHDEFAULT : 0, m_pCHatchWin ? HATCHWIN_BORDERWIDTHDEFAULT : 0, - aRect->right - aRect->left, - aRect->bottom - aRect->top, + rect.right - rect.left, + rect.bottom - rect.top, awt::PosSize::POSSIZE); m_xEditWindow->setVisible(true); } -- cgit