sw/source/uibase/uiview/view.cxx |   32 ++++++--------------------------
 1 file changed, 6 insertions(+), 26 deletions(-)

New commits:
commit 9426e90c2c339b16487c48cd885a3e4586e1e1f3
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Thu Jul 21 09:29:32 2022 +0200
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Thu Jul 21 12:10:56 2022 +0200

    Cleanup restoring last position
    
    The checks of valid bottom were introduced in commit
    f50ec0bda2a4a6d55217bbc8e82e1a9ab3daaa9f
      Author Martin Gallwey <m...@openoffice.org>
      Date   Wed May 16 16:08:38 2001 +0000
        #86580#, #86953#, #86294#, make ReadUserDataSequence bullet-proof
    
    Possibly initially, bBrowse passed to SwView::ReadUserData was
    sometimes false; but at some point it became always true, making
    the code using right and bottom (stored in aVis) unreachable. That
    became evident after commit db93b92d78714ed193b3cbe52b18e3cfd9da99b8
      Author Noel Grandin <n...@peralex.com>
      Date   Thu Mar 17 11:21:56 2016 +0200
        loplugin:constantparam in sfx2
    
    So just drop the unused pieces, that for large documents often resulted
    in last position not being restored, because the code exited early at
    nBottom > (m_pWrtShell->GetDocSize().Height()+nAdd) check.
    
    Change-Id: If9b4e6faa2754b94cb1298a7221e70736c94f27e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137186
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 4159b8714a7c..5b270da21dfc 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -1313,8 +1313,6 @@ void SwView::ReadUserDataSequence ( const uno::Sequence < 
beans::PropertyValue >
     const SwViewOption* pVOpt = m_pWrtShell->GetViewOptions();
 
     sal_Int64 nX = rRect.Left(), nY = rRect.Top(), nLeft = rVis.Left(), nTop = 
rVis.Top();
-    sal_Int64 nRight = nLeft;
-    sal_Int64 nBottom = LONG_MIN;
     sal_Int16 nZoomType = static_cast< sal_Int16 >(pVOpt->GetZoomType());
     sal_Int16 nZoomFactor = static_cast < sal_Int16 > (pVOpt->GetZoom());
     bool bViewLayoutBookMode = pVOpt->IsViewLayoutBookMode();
@@ -1323,8 +1321,8 @@ void SwView::ReadUserDataSequence ( const uno::Sequence < 
beans::PropertyValue >
 
     bool bSelectedFrame = ( m_pWrtShell->GetSelFrameType() != 
FrameTypeFlags::NONE ),
              bGotVisibleLeft = false,
-             bGotVisibleTop = false, bGotVisibleRight = false,
-             bGotVisibleBottom = false, bGotZoomType = false,
+             bGotVisibleTop = false,
+             bGotZoomType = false,
              bGotZoomFactor = false, bGotIsSelectedFrame = false,
              bGotViewLayoutColumns = false, bGotViewLayoutBookMode = false,
              bGotHideWhitespace = false,
@@ -1356,18 +1354,6 @@ void SwView::ReadUserDataSequence ( const uno::Sequence 
< beans::PropertyValue >
            nTop = o3tl::toTwips(nTop, o3tl::Length::mm100);
            bGotVisibleTop = true;
         }
-        else if ( rValue.Name == "VisibleRight" )
-        {
-           rValue.Value >>= nRight;
-           nRight = o3tl::toTwips(nRight, o3tl::Length::mm100);
-           bGotVisibleRight = true;
-        }
-        else if ( rValue.Name == "VisibleBottom" )
-        {
-           rValue.Value >>= nBottom;
-           nBottom = o3tl::toTwips(nBottom, o3tl::Length::mm100);
-           bGotVisibleBottom = true;
-        }
         else if ( rValue.Name == "ZoomType" )
         {
            rValue.Value >>= nZoomType;
@@ -1420,16 +1406,9 @@ void SwView::ReadUserDataSequence ( const uno::Sequence 
< beans::PropertyValue >
 
     SelectShell();
 
-    if (!bGotVisibleBottom)
-        return;
-
     Point aCursorPos( nX, nY );
-    const tools::Long nAdd = m_pWrtShell->GetViewOptions()->getBrowseMode() ? 
DOCUMENTBORDER : DOCUMENTBORDER*2;
-    if (nBottom > (m_pWrtShell->GetDocSize().Height()+nAdd) )
-        return;
 
     m_pWrtShell->EnableSmooth( false );
-    const tools::Rectangle aVis( nLeft, nTop, nRight, nBottom );
 
     SvxZoomType eZoom;
     if ( !m_pWrtShell->GetViewOptions()->getBrowseMode() )
@@ -1536,7 +1515,7 @@ void SwView::ReadUserDataSequence ( const uno::Sequence < 
beans::PropertyValue >
     {
         if ( bGotVisibleLeft && bGotVisibleTop )
         {
-            Point aTopLeft(aVis.TopLeft());
+            Point aTopLeft(nLeft, nTop);
             // make sure the document is still centered
             const SwTwips lBorder = IsDocumentBorder() ? DOCUMENTBORDER : 2 * 
DOCUMENTBORDER;
             SwTwips nEditWidth = 
GetEditWin().GetOutDev()->GetOutputSize().Width();
@@ -1551,8 +1530,6 @@ void SwView::ReadUserDataSequence ( const uno::Sequence < 
beans::PropertyValue >
             }
             SetVisArea( aTopLeft );
         }
-        else if (bGotVisibleLeft && bGotVisibleTop && bGotVisibleRight && 
bGotVisibleBottom )
-            SetVisArea( aVis );
     }
 
     m_pWrtShell->LockView( true );
@@ -1582,6 +1559,9 @@ void SwView::WriteUserDataSequence ( uno::Sequence < 
beans::PropertyValue >& rSe
     auto visibleTop = convertTwipToMm100 ( rVis.Top() );
     aVector.push_back(comphelper::makePropertyValue("VisibleTop", visibleTop));
 
+    // We don't read VisibleRight and VisibleBottom anymore, but write them,
+    // because older versions rely on their presense to restore position
+
     auto visibleRight = rVis.IsWidthEmpty() ? visibleLeft : convertTwipToMm100 
( rVis.Right() );
     aVector.push_back(comphelper::makePropertyValue("VisibleRight", 
visibleRight));
 

Reply via email to