sc/source/ui/inc/gridwin.hxx | 7 +++ sc/source/ui/view/gridwin.cxx | 6 +++ sc/source/ui/view/gridwin4.cxx | 73 +++++++++++++++++++++++++++++++++++++++++ sc/source/ui/view/tabview5.cxx | 11 ++++++ 4 files changed, 97 insertions(+)
New commits: commit df5aeb624e328fb191996632f2874618b618e94c Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue Apr 5 13:40:23 2022 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Tue Apr 5 15:30:12 2022 +0200 Revert "trac#34262 Revert "Do not count pages for initial page breaks, tdf#124983 follow-up"" The actual root cause of the WollMux mail merge issue (too little Java heap space) has been identified in the meantime. In addition, when reverting, I was confused by the fact that the commit msg was only that of the follow-up commit commit 129c680f02564c8bee93930dec9f2ad80980cc1c Author: Eike Rathke <er...@redhat.com> Date: Wed Aug 18 23:42:45 2021 +0200 Do not count pages for initial page breaks, tdf#124983 follow-up but the second version of the underlying fix commit 86e300df241312f6152da1cfa3cb2b8c668d1df5 Author: Ilhan Yesil <ilhanye...@gmx.de> Date: Fri Mar 6 13:40:59 2020 +0100 tdf#124983 In calc make printable page borders initially visible as well as a cherry-pick of the follow-up commit 3d7007ef8784e92bb56a91c40e7bdff812251677 Author: Eike Rathke <er...@redhat.com> Date: Tue Jun 29 14:31:19 2021 +0200 maShowPageBreaksTimer.Stop() in ScGridWindow::dispose(), tdf#124983 follow-up were actually all already contained in that single commit as well, without being mentioned explicitly. This reverts commit 1f966bb3e38a028c82cee40f6c5a17fe9619b53c. Change-Id: Ib42a2612843bd78ecb9aa538ab64f2a953a3c093 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132572 Tested-by: Michael Weghorn <m.wegh...@posteo.de> Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx index 5ebb26241d10..e9363a1f96d2 100644 --- a/sc/source/ui/inc/gridwin.hxx +++ b/sc/source/ui/inc/gridwin.hxx @@ -190,6 +190,8 @@ class SAL_DLLPUBLIC_RTTI ScGridWindow : public vcl::Window, public DropTargetHel RfCorner aRFSelectedCorned; + Timer maShowPageBreaksTimer; + bool bEEMouse:1; // Edit Engine has mouse bool bDPMouse:1; // DataPilot D&D (new Pivot table) bool bRFMouse:1; // RangeFinder drag @@ -200,6 +202,7 @@ class SAL_DLLPUBLIC_RTTI ScGridWindow : public vcl::Window, public DropTargetHel bool bNeedsRepaint:1; bool bAutoMarkVisible:1; bool bListValButton:1; + bool bInitialPageBreaks:1; DECL_LINK( PopupModeEndHdl, FloatingWindow*, void ); DECL_LINK( PopupSpellingHdl, SpellCallbackInfo&, void ); @@ -288,6 +291,8 @@ class SAL_DLLPUBLIC_RTTI ScGridWindow : public vcl::Window, public DropTargetHel void GetSelectionRects( ::std::vector< tools::Rectangle >& rPixelRects ); + void SetupInitialPageBreaks(const ScDocument& rDoc, SCTAB nTab); + DECL_LINK(InitiatePageBreaksTimer, Timer*, void); protected: virtual void PrePaint(vcl::RenderContext& rRenderContext) override; @@ -462,6 +467,8 @@ public: void updateLOKValListButton(bool bVisible, const ScAddress& rPos) const; + void initiatePageBreaks(); + protected: void ImpCreateOverlayObjects(); void ImpDestroyOverlayObjects(); diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 0ed015bb31da..aa540b5d5134 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -482,6 +482,10 @@ ScGridWindow::ScGridWindow( vcl::Window* pParent, ScViewData* pData, ScSplitPos SetDigitLanguage( SC_MOD()->GetOptDigitLanguage() ); EnableRTL( false ); + + bInitialPageBreaks = true; + maShowPageBreaksTimer.SetInvokeHandler(LINK(this, ScGridWindow, InitiatePageBreaksTimer)); + maShowPageBreaksTimer.SetTimeout(1); } ScGridWindow::~ScGridWindow() @@ -491,6 +495,8 @@ ScGridWindow::~ScGridWindow() void ScGridWindow::dispose() { + maShowPageBreaksTimer.Stop(); + ImpDestroyOverlayObjects(); mpFilterBox.disposeAndClear(); diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 9426c8842bf0..aa7ad1312acc 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -1055,6 +1055,28 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI if (mpNoteMarker) mpNoteMarker->Draw(); // Above the cursor, in drawing map mode + + if (bPage && bInitialPageBreaks) + SetupInitialPageBreaks(rDoc, nTab); +} + + +void ScGridWindow::SetupInitialPageBreaks(const ScDocument& rDoc, SCTAB nTab) +{ + // tdf#124983, if option LibreOfficeDev Calc/View/Visual Aids/Page breaks + // is enabled, breaks should be visible. If the document is opened the first + // time, the breaks are not calculated yet, so for this initialization + // a timer will be triggered here. + std::set<SCCOL> aColBreaks; + std::set<SCROW> aRowBreaks; + rDoc.GetAllColBreaks(aColBreaks, nTab, true, false); + rDoc.GetAllRowBreaks(aRowBreaks, nTab, true, false); + if (aColBreaks.size() == 0 || aRowBreaks.size() == 0) + { + maShowPageBreaksTimer.SetPriority(TaskPriority::DEFAULT_IDLE); + maShowPageBreaksTimer.Start(); + } + bInitialPageBreaks = false; } namespace @@ -2005,4 +2027,55 @@ void ScGridWindow::DataChanged( const DataChangedEvent& rDCEvt ) } } +void ScGridWindow::initiatePageBreaks() +{ + bInitialPageBreaks = true; +} + +IMPL_LINK(ScGridWindow, InitiatePageBreaksTimer, Timer*, pTimer, void) +{ + if (pTimer == &maShowPageBreaksTimer) + { + const ScViewOptions& rOpts = pViewData->GetOptions(); + const bool bPage = rOpts.GetOption(VOPT_PAGEBREAKS); + // tdf#124983, if option LibreOfficeDev Calc/View/Visual Aids/Page + // breaks is enabled, breaks should be visible. If the document is + // opened the first time or a tab is activated the first time, the + // breaks are not calculated yet, so this initialization is done here. + if (bPage) + { + const SCTAB nCurrentTab = pViewData->GetTabNo(); + ScDocument* pDoc = pViewData->GetDocument(); + const Size aPageSize = pDoc->GetPageSize(nCurrentTab); + // Do not attempt to calculate a page size here if it is empty if + // that involves counting pages. + // An earlier implementation did + // ScPrintFunc(pDocSh, pDocSh->GetPrinter(), nCurrentTab); + // rDoc.SetPageSize(nCurrentTab, rDoc.GetPageSize(nCurrentTab)); + // which resulted in tremendous waiting times after having loaded + // larger documents i.e. imported from CSV, in which UI is entirely + // blocked. All time is spent under ScPrintFunc::CountPages() in + // ScTable::ExtendPrintArea() in the loop that calls + // MaybeAddExtraColumn() to do stuff for each text string content + // cell (each row in each column). Maybe that can be optimized, or + // obtaining page size without that overhead would be possible, but + // as is calling that from here is a no-no so this is a quick + // disable things. + if (aPageSize.Width()>0&&aPageSize.Height()) + { + ScDocShell* pDocSh = pViewData->GetDocShell(); + const bool bModified = pDocSh->IsModified(); + // Even setting the same size sets page size valid, so + // UpdatePageBreaks() actually does something. + pDoc->SetPageSize( nCurrentTab, aPageSize); + pDoc->UpdatePageBreaks(nCurrentTab); + pDocSh->PostPaint(0, 0, nCurrentTab, pDoc->MaxCol(), pDoc->MaxRow(), nCurrentTab, PaintPartFlags::Grid); + pDocSh->SetModified(bModified); + } + } + + Invalidate(); + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx index b075b748f0e3..635b40e97ab5 100644 --- a/sc/source/ui/view/tabview5.cxx +++ b/sc/source/ui/view/tabview5.cxx @@ -315,6 +315,17 @@ void ScTabView::TabChanged( bool bSameTabButMoved ) } } + for (int i = 0; i < 4; i++) + { + if (pGridWin[i]) + { + pGridWin[i]->initiatePageBreaks(); + // Trigger calculating page breaks only once. + break; + } + } + + if (comphelper::LibreOfficeKit::isActive()) { ScDocShell* pDocSh = GetViewData().GetDocShell();