diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-06-19 20:55:55 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-06-20 09:58:14 +0200 |
commit | b520005b1d42ce80296cbbc6b4fc3cc5e5d8cae0 (patch) | |
tree | 0a887b6c3d9feaf6fa8e7afcc14f02104453b16e /editeng | |
parent | 71a7e17dd7a6425a3df3c5dca25a3dac24ef6fa7 (diff) |
fix crash with non-window outputdevice better
Change-Id: I93511574f8ab7d564baf1f031d54ca0e72ca345e
Reviewed-on: https://gerrit.libreoffice.org/74380
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/impedit.cxx | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx index 9618c1fb604d..215af72daaed 100644 --- a/editeng/source/editeng/impedit.cxx +++ b/editeng/source/editeng/impedit.cxx @@ -1144,13 +1144,12 @@ Pair ImpEditView::Scroll( long ndX, long ndY, ScrollRangeCheck nRangeCheck ) if ( !ndX && !ndY ) return Pair( 0, 0 ); - if (!pOutWin) - return Pair( 0, 0 ); + const OutputDevice& rOutDev = getEditViewCallbacks() ? getEditViewCallbacks()->EditViewOutputDevice() : *GetWindow(); #ifdef DBG_UTIL tools::Rectangle aR( aOutArea ); - aR = pOutWin->LogicToPixel( aR ); - aR = pOutWin->PixelToLogic( aR ); + aR = rOutDev.LogicToPixel( aR ); + aR = rOutDev.PixelToLogic( aR ); SAL_WARN_IF( aR != aOutArea, "editeng", "OutArea before Scroll not aligned" ); #endif @@ -1216,8 +1215,8 @@ Pair ImpEditView::Scroll( long ndX, long ndY, ScrollRangeCheck nRangeCheck ) long nDiffY = !IsVertical() ? ( GetVisDocTop() - aNewVisArea.Top() ) : (IsTopToBottom() ? (GetVisDocLeft() - aNewVisArea.Left()) : -(GetVisDocTop() - aNewVisArea.Top())); Size aDiffs( nDiffX, nDiffY ); - aDiffs = pOutWin->LogicToPixel( aDiffs ); - aDiffs = pOutWin->PixelToLogic( aDiffs ); + aDiffs = rOutDev.LogicToPixel( aDiffs ); + aDiffs = rOutDev.PixelToLogic( aDiffs ); long nRealDiffX = aDiffs.Width(); long nRealDiffY = aDiffs.Height(); @@ -1228,7 +1227,8 @@ Pair ImpEditView::Scroll( long ndX, long ndY, ScrollRangeCheck nRangeCheck ) vcl::Cursor* pCrsr = GetCursor(); bool bVisCursor = pCrsr->IsVisible(); pCrsr->Hide(); - pOutWin->Update(); + if (pOutWin) + pOutWin->Update(); if ( !IsVertical() ) aVisDocStartPos.Move( -nRealDiffX, -nRealDiffY ); else @@ -1240,18 +1240,23 @@ Pair ImpEditView::Scroll( long ndX, long ndY, ScrollRangeCheck nRangeCheck ) } // Move by aligned value does not necessarily result in aligned // rectangle ... - aVisDocStartPos = pOutWin->LogicToPixel( aVisDocStartPos ); - aVisDocStartPos = pOutWin->PixelToLogic( aVisDocStartPos ); + aVisDocStartPos = rOutDev.LogicToPixel( aVisDocStartPos ); + aVisDocStartPos = rOutDev.PixelToLogic( aVisDocStartPos ); tools::Rectangle aRect( aOutArea ); - pOutWin->Scroll( nRealDiffX, nRealDiffY, aRect, ScrollFlags::Clip ); - if (comphelper::LibreOfficeKit::isActive()) + if (pOutWin) + { + pOutWin->Scroll( nRealDiffX, nRealDiffY, aRect, ScrollFlags::Clip ); + } + + if (comphelper::LibreOfficeKit::isActive() || getEditViewCallbacks()) { // Need to invalidate the window, otherwise no tile will be re-painted. pEditView->Invalidate(); } - pOutWin->Update(); + if (pOutWin) + pOutWin->Update(); pCrsr->SetPos( pCrsr->GetPos() + Point( nRealDiffX, nRealDiffY ) ); if ( bVisCursor ) { |