sc/source/ui/inc/gridwin.hxx   |    6 +++
 sc/source/ui/view/gridwin.cxx  |    4 ++
 sc/source/ui/view/gridwin4.cxx |   62 +++++++++++++++++++++++++++++++++++++++++
 sc/source/ui/view/tabview5.cxx |    7 ++++
 4 files changed, 79 insertions(+)

New commits:
commit ff3f749cd08851ee4eb0991eabee0327ca081a45
Author:     Ilhan Yesil <ilhanye...@gmx.de>
AuthorDate: Fri Mar 6 13:40:59 2020 +0100
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Wed Jun 23 19:45:15 2021 +0200

    tdf#124983 In calc make printable page borders initially visible
    
    If option "LibreOfficeDev Calc/View/Page breaks"
    is enabled, breaks should be visible. But if the document
    is opened the first time or a tab is opened the first time,
    the breaks are not calculated yet and therefore not visible.
    To avoid calculations during the load of the document, a
    timer will be triggered to calculate the breaks after loading
    is finished.
    
    Change-Id: I87219c62e20882b19d36042692efd2e6a8d8190a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90101
    Tested-by: Jenkins
    Reviewed-by: Eike Rathke <er...@redhat.com>
    (cherry picked from commit 86e300df241312f6152da1cfa3cb2b8c668d1df5)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117718

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;
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to