diff options
-rw-r--r-- | sc/source/ui/inc/gridwin.hxx | 6 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin4.cxx | 62 | ||||
-rw-r--r-- | sc/source/ui/view/tabview5.cxx | 7 |
4 files changed, 79 insertions, 0 deletions
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx index 09e46d7a4e21..daf6c35b652c 100644 --- a/sc/source/ui/inc/gridwin.hxx +++ b/sc/source/ui/inc/gridwin.hxx @@ -309,6 +309,10 @@ 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(ScDocument& rDoc, SCTAB nTab, bool bSetup); + DECL_LINK(InitiatePageBreaksTimer, Timer*, void); protected: virtual void PrePaint(vcl::RenderContext& rRenderContext) override; virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; @@ -490,6 +494,8 @@ public: void updateLOKValListButton(bool bVisible, const ScAddress& rPos) const; void updateLOKInputHelp(const OUString& title, const OUString& content) 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 b6412ae36fbb..c2c115c4371c 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -424,6 +424,10 @@ ScGridWindow::ScGridWindow( vcl::Window* pParent, ScViewData& rData, ScSplitPos GetOutDev()->SetDigitLanguage( SC_MOD()->GetOptDigitLanguage() ); EnableRTL( false ); + + bInitialPageBreaks = true; + maShowPageBreaksTimer.SetInvokeHandler(LINK(this, ScGridWindow, InitiatePageBreaksTimer)); + maShowPageBreaksTimer.SetTimeout(1); } ScGridWindow::~ScGridWindow() diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 9c1ff475449a..f1e53ed61cb8 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -76,6 +76,9 @@ #include <vcl/virdev.hxx> #include <svx/sdrpaintwindow.hxx> #include <drwlayer.hxx> +#include <columnspanset.hxx> +#include <docfunc.hxx> +#include <printfun.hxx> static void lcl_LimitRect( tools::Rectangle& rRect, const tools::Rectangle& rVisible ) { @@ -1267,6 +1270,30 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI if (mpNoteMarker) mpNoteMarker->Draw(); // Above the cursor, in drawing map mode + + SetupInitialPageBreaks(rDoc, nTab, bPage&& bInitialPageBreaks); +} + + +void ScGridWindow::SetupInitialPageBreaks(ScDocument& rDoc, SCTAB nTab, bool bSetup) +{ + // 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; + } + } } namespace @@ -2316,4 +2343,39 @@ void ScGridWindow::DataChanged( const DataChangedEvent& rDCEvt ) Invalidate(); } +void ScGridWindow::initiatePageBreaks() +{ + bInitialPageBreaks = true; +} + +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. + if (bPage) + { + SCTAB nCurrentTab = mrViewData.GetTabNo(); + Size pagesize = rDoc.GetPageSize(nCurrentTab); + if (pagesize.IsEmpty()) + { + ScPrintFunc(pDocSh, pDocSh->GetPrinter(), nCurrentTab); + rDoc.SetPageSize(nCurrentTab, rDoc.GetPageSize(nCurrentTab)); + } + rDoc.UpdatePageBreaks(nCurrentTab); + pDocSh->PostPaint(0, 0, nCurrentTab, rDoc.MaxCol(), rDoc.MaxRow(), nCurrentTab, PaintPartFlags::Grid); + pDocSh->SetModified(bModified); + } + } +} + + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx index 3de36af347d2..f0b6ed6c4f18 100644 --- a/sc/source/ui/view/tabview5.cxx +++ b/sc/source/ui/view/tabview5.cxx @@ -320,6 +320,13 @@ void ScTabView::TabChanged( bool bSameTabButMoved ) } } + for (int i = 0; i < 4; i++) + if (pGridWin[i]) + { + pGridWin[i]->initiatePageBreaks(); + } + + if (!comphelper::LibreOfficeKit::isActive()) return; |