tdf#124983 In calc make printable page borders also initially visible

If option "LibreOfficeDev Calc/View/Page breaks"
is enabled, breaks should be visible. But if the document
is opened the first time, the breaks are not calculated yet
and therefore not visible.

Change-Id: I651e4df4a9c292aa953888498a5c9d0fb5b8c8d2
Reviewed-on: https://gerrit.libreoffice.org/75355
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack@redhat.com>
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 4893b31..94796121 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -69,6 +69,7 @@
#include <vcl/virdev.hxx>
#include <svx/sdrpaintwindow.hxx>
#include <drwlayer.hxx>
#include <printfun.hxx>

static void lcl_LimitRect( tools::Rectangle& rRect, const tools::Rectangle& rVisible )
{
@@ -560,6 +561,23 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
    bool bGridFirst = !rOpts.GetOption( VOPT_GRID_ONTOP );

    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, the breaks are not calculated yet, so this initialization is
    // done here.
    if (bPage)
    {
        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)
        {
            ScDocShell* pDocSh = pViewData->GetDocShell();
            ScPrintFunc aPrintFunc(pDocSh, pDocSh->GetPrinter(), nTab);
            aPrintFunc.UpdatePages();
        }
    }

    bool bPageMode = pViewData->IsPagebreakMode();
    if (bPageMode)                                      // after FindChanged