diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 4893b31c6b1b..947961218438 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -69,6 +69,7 @@ #include #include #include +#include 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 aColBreaks; + std::set 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