tdf#150265: properly handle empty rectangle in SwView::CalcVisArea
Use PixelToLogic taking Rectangle for this job, that does everything
required in this case.
Before commit 9426e90c2c339b16487c48cd885a3e4586e1e1f3
Author Mike Kaganski <mike.kaganski@collabora.com>
Date Thu Jul 21 09:29:32 2022 +0200
Cleanup restoring last position
headless import always returned early from SwView::ReadUserDataSequence, because
either !bGotVisibleBottom, or nBottom > (m_pWrtShell->GetDocSize().Height()+nAdd)
was true. Thus, SetZoom wasn't called, and SwView::CalcVisArea wasn't called from
it.
After the change, in SetZoom, the empty rectangle created from passed zero Size
got converted from pixels to logic, using transformation loosing its empty state.
That resulted in some non-empty VisArea, and later in DOCX export of the table,
WW8TableInfo::processSwTableByLayout got garbage from aTableCellInfo.getRect.
Using proper Window::PixelToLogic overload allows to simplify and fix it all.
Change-Id: Ib5e6d5bda10bf0f8dcb93ff6a46ca6cb81ff5a3c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137807
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
diff --git a/sw/source/uibase/uiview/viewport.cxx b/sw/source/uibase/uiview/viewport.cxx
index e145e0e..e2fbefa 100644
--- a/sw/source/uibase/uiview/viewport.cxx
+++ b/sw/source/uibase/uiview/viewport.cxx
@@ -778,13 +778,7 @@ void SwView::CalcVisArea( const Size &rOutPixel )
{
Point aTopLeft;
tools::Rectangle aRect( aTopLeft, rOutPixel );
aTopLeft = GetEditWin().PixelToLogic( aTopLeft );
Point aBottomRight( GetEditWin().PixelToLogic( aRect.BottomRight() ) );
aRect.SetLeft( aTopLeft.X() );
aRect.SetTop( aTopLeft.Y() );
aRect.SetRight( aBottomRight.X() );
aRect.SetBottom( aBottomRight.Y() );
aRect = GetEditWin().PixelToLogic(aRect);
// The shifts to the right and/or below can now be incorrect
// (e.g. change zoom level, change view size).