diff options
author | Juergen Funk <juergen.funk_ml@cib.de> | 2024-07-10 09:10:09 +0200 |
---|---|---|
committer | Oliver Specht <oliver.specht@cib.de> | 2024-07-11 10:58:06 +0200 |
commit | c92e4d1a944019dd5b14cdce3d85213d2a8d9e92 (patch) | |
tree | b17cc24f2c6fd5998b6d293f7a1086bbc0e85bcc | |
parent | 35e5abe8e569c67fbb0afe84afbd826373470a8c (diff) |
tdf#161538 fix empty page inserted into specific file
- the empty pages can be switch off with
"Print automatically inserted blank pages"
but when the switch is off, the view of the
"Print Prewiew" was wrong when scrolling,
this patch fix that
Change-Id: I62627b8d65db325e12818c91fee3e3c7c89c7751
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170278
Tested-by: Jenkins
Reviewed-by: Oliver Specht <oliver.specht@cib.de>
-rw-r--r-- | sw/inc/pagepreviewlayout.hxx | 6 | ||||
-rw-r--r-- | sw/source/core/view/pagepreviewlayout.cxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/uiview/pview.cxx | 45 |
3 files changed, 24 insertions, 30 deletions
diff --git a/sw/inc/pagepreviewlayout.hxx b/sw/inc/pagepreviewlayout.hxx index d2af5f846ea1..7a6bccc65555 100644 --- a/sw/inc/pagepreviewlayout.hxx +++ b/sw/inc/pagepreviewlayout.hxx @@ -296,6 +296,12 @@ public: mnSelectedPageNum = _nSelectedPageNum; } + /** get the maximal preview pages */ + sal_uInt16 GetMaxPreviewPages() const + { + return mnPages; + } + /** paint prepared preview @param _aOutRect diff --git a/sw/source/core/view/pagepreviewlayout.cxx b/sw/source/core/view/pagepreviewlayout.cxx index 95ae9cec3419..b363d1a42fa6 100644 --- a/sw/source/core/view/pagepreviewlayout.cxx +++ b/sw/source/core/view/pagepreviewlayout.cxx @@ -388,6 +388,9 @@ bool SwPagePreviewLayout::Prepare( const sal_uInt16 _nProposedStartPageNum, mnPaintPhyStartPageNum = mnPages; mbNoPageVisible = true; } + + mnPaintPhyStartPageNum = ConvertRelativeToAbsolutePageNum( + mnPaintPhyStartPageNum ); } // set starting column and starting row mnPaintStartCol = nColOfProposed; diff --git a/sw/source/uibase/uiview/pview.cxx b/sw/source/uibase/uiview/pview.cxx index 60d536bec43a..25694534a179 100644 --- a/sw/source/uibase/uiview/pview.cxx +++ b/sw/source/uibase/uiview/pview.cxx @@ -1445,16 +1445,17 @@ void SwPagePreview::EndScrollHdl(weld::Scrollbar& rScrollbar, bool bHori) { if ( Help::IsQuickHelpEnabled() ) Help::ShowQuickHelp(m_pVScrollbar, tools::Rectangle(), OUString()); - if ( GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow() ) + SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout(); + if (pPagePreviewLay->DoesPreviewLayoutRowsFitIntoWindow() ) { // Scroll how many pages ?? - const sal_uInt16 nThmbPos = o3tl::narrowing<sal_uInt16>(rScrollbar.adjustment_get_value()); + const sal_uInt16 nThmbPos = pPagePreviewLay->ConvertRelativeToAbsolutePageNum( + o3tl::narrowing<sal_uInt16>(rScrollbar.adjustment_get_value()) ); // adjust to new preview functionality if( nThmbPos != m_pViewWin->SelectedPage() ) { // consider case that page <nThmbPos> // is already visible - SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout(); if ( pPagePreviewLay->IsPageVisible( nThmbPos ) ) { pPagePreviewLay->MarkNewSelectedPage( nThmbPos ); @@ -1464,29 +1465,11 @@ void SwPagePreview::EndScrollHdl(weld::Scrollbar& rScrollbar, bool bHori) else { // consider whether layout columns - // fit or not. - if ( !pPagePreviewLay->DoesPreviewLayoutColsFitIntoWindow() ) - { - m_pViewWin->SetSttPage( nThmbPos ); - m_pViewWin->SetSelectedPage( nThmbPos ); - ChgPage( SwPagePreviewWin::MV_SCROLL, false ); - // update scrollbars - ScrollViewSzChg(); - } - else - { - // correct scroll amount - const sal_Int16 nPageDiff = nThmbPos - m_pViewWin->SelectedPage(); - const sal_uInt16 nVisPages = m_pViewWin->GetRow() * m_pViewWin->GetCol(); - sal_Int16 nWinPagesToScroll = nPageDiff / nVisPages; - if ( nPageDiff % nVisPages ) - { - // decrease/increase number of preview pages to scroll - nPageDiff < 0 ? --nWinPagesToScroll : ++nWinPagesToScroll; - } - m_pViewWin->SetSelectedPage( nThmbPos ); - m_pViewWin->Scroll( 0, pPagePreviewLay->GetWinPagesScrollAmount( nWinPagesToScroll ) ); - } + m_pViewWin->SetSttPage( nThmbPos ); + m_pViewWin->SetSelectedPage( nThmbPos ); + ChgPage( SwPagePreviewWin::MV_SCROLL, false ); + // update scrollbars + ScrollViewSzChg(); } // update accessibility GetViewShell()->ShowPreviewSelection( nThmbPos ); @@ -1570,23 +1553,25 @@ void SwPagePreview::ScrollViewSzChg() SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout(); if ( pPagePreviewLay->IsPageVisible( m_pViewWin->SelectedPage() ) ) { - m_pVScrollbar->SetThumbPos( m_pViewWin->SelectedPage() ); + m_pVScrollbar->SetThumbPos( + pPagePreviewLay->ConvertAbsoluteToRelativePageNum(m_pViewWin->SelectedPage()) ); } else { - m_pVScrollbar->SetThumbPos( m_pViewWin->GetSttPage() ); + m_pVScrollbar->SetThumbPos( + pPagePreviewLay->ConvertAbsoluteToRelativePageNum(m_pViewWin->GetSttPage()) ); } m_pVScrollbar->SetLineSize( m_pViewWin->GetCol() ); m_pVScrollbar->SetPageSize( nVisPages ); // calculate and set scrollbar range - Range aScrollbarRange( 1, mnPageCount ); + Range aScrollbarRange( 1, pPagePreviewLay->GetMaxPreviewPages() ); // increase range by one, because left-top-corner is left blank. ++aScrollbarRange.Max(); // increase range in order to access all pages aScrollbarRange.Max() += ( nVisPages - 1 ); m_pVScrollbar->SetRange( aScrollbarRange ); - bShowVScrollbar = nVisPages < mnPageCount; + bShowVScrollbar = nVisPages < pPagePreviewLay->GetMaxPreviewPages(); } else //vertical scrolling by pixel { |