[Libreoffice-commits] core.git: sc/source
Eike Rathke (via logerrit)
logerrit at kemper.freedesktop.org
Wed Aug 18 23:20:10 UTC 2021
sc/source/ui/inc/gridwin.hxx | 8 ++--
sc/source/ui/view/gridwin4.cxx | 73 ++++++++++++++++++++++++-----------------
sc/source/ui/view/tabview5.cxx | 5 ++
3 files changed, 52 insertions(+), 34 deletions(-)
New commits:
commit f58f35b2c8ca1efbacec642a8f3de5b0c499bc6b
Author: Eike Rathke <erack at redhat.com>
AuthorDate: Wed Aug 18 23:42:45 2021 +0200
Commit: Eike Rathke <erack at redhat.com>
CommitDate: Thu Aug 19 01:19:32 2021 +0200
Do not count pages for initial page breaks, tdf#124983 follow-up
Use a loaded page size or leave it. Otherwise the previous
implementation could had lead to tremendous waiting time blocking
everything on large data without. See source code comment.
Also trigger updating page breaks only for one grid window, not
multiple repeating everything all over.
Remove bSetup parameter that does nothing but either doing something or
nothing, check in caller instead.
Move member variables to where they belong.
Change-Id: I5efc321e5bc5af075a77631aa9d94b0c50ae6b6b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120689
Reviewed-by: Eike Rathke <erack at redhat.com>
Tested-by: Jenkins
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 10d9fc68557a..50109106aa5d 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -200,6 +200,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
@@ -210,6 +212,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, weld::Popover&, void );
DECL_LINK( PopupSpellingHdl, SpellCallbackInfo&, void );
@@ -309,10 +312,9 @@ class SAL_DLLPUBLIC_RTTI ScGridWindow : public vcl::Window, public DropTargetHel
void InvalidateLOKViewCursor(const tools::Rectangle& rCursorRect,
const Fraction aScaleX, const Fraction aScaleY);
- Timer maShowPageBreaksTimer;
- bool bInitialPageBreaks;
- void SetupInitialPageBreaks(const ScDocument& rDoc, SCTAB nTab, bool bSetup);
+ void SetupInitialPageBreaks(const ScDocument& rDoc, SCTAB nTab);
DECL_LINK(InitiatePageBreaksTimer, Timer*, void);
+
protected:
virtual void PrePaint(vcl::RenderContext& rRenderContext) override;
virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index eecf6a4d814b..f810efbb8c19 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1271,29 +1271,27 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
if (mpNoteMarker)
mpNoteMarker->Draw(); // Above the cursor, in drawing map mode
- SetupInitialPageBreaks(rDoc, nTab, bPage&& bInitialPageBreaks);
+ if (bPage && bInitialPageBreaks)
+ SetupInitialPageBreaks(rDoc, nTab);
}
-void ScGridWindow::SetupInitialPageBreaks(const ScDocument& rDoc, SCTAB nTab, bool bSetup)
+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.
- if (bSetup)
- {
- 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;
- }
+ 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
@@ -2353,27 +2351,42 @@ IMPL_LINK(ScGridWindow, InitiatePageBreaksTimer, Timer*, pTimer, void)
{
if (pTimer == &maShowPageBreaksTimer)
{
- ScDocument& rDoc = mrViewData.GetDocument();
const ScViewOptions& rOpts = mrViewData.GetOptions();
- bool bPage = rOpts.GetOption(VOPT_PAGEBREAKS);
- ScDocShell* pDocSh = mrViewData.GetDocShell();
- bool bModified = pDocSh->IsModified();
- // 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.
+ 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)
{
- SCTAB nCurrentTab = mrViewData.GetTabNo();
- Size pagesize = rDoc.GetPageSize(nCurrentTab);
- if (pagesize.IsEmpty())
+ const SCTAB nCurrentTab = mrViewData.GetTabNo();
+ ScDocument& rDoc = mrViewData.GetDocument();
+ const Size aPageSize = rDoc.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.IsEmpty())
{
- ScPrintFunc(pDocSh, pDocSh->GetPrinter(), nCurrentTab);
- rDoc.SetPageSize(nCurrentTab, rDoc.GetPageSize(nCurrentTab));
+ ScDocShell* pDocSh = mrViewData.GetDocShell();
+ const bool bModified = pDocSh->IsModified();
+ // Even setting the same size sets page size valid, so
+ // UpdatePageBreaks() actually does something.
+ rDoc.SetPageSize( nCurrentTab, aPageSize);
+ rDoc.UpdatePageBreaks(nCurrentTab);
+ pDocSh->PostPaint(0, 0, nCurrentTab, rDoc.MaxCol(), rDoc.MaxRow(), nCurrentTab, PaintPartFlags::Grid);
+ pDocSh->SetModified(bModified);
}
- rDoc.UpdatePageBreaks(nCurrentTab);
- pDocSh->PostPaint(0, 0, nCurrentTab, rDoc.MaxCol(), rDoc.MaxRow(), nCurrentTab, PaintPartFlags::Grid);
- pDocSh->SetModified(bModified);
}
}
}
diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx
index f0b6ed6c4f18..bfb2f6c82ed1 100644
--- a/sc/source/ui/view/tabview5.cxx
+++ b/sc/source/ui/view/tabview5.cxx
@@ -321,11 +321,14 @@ 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())
return;
More information about the Libreoffice-commits
mailing list