tdf#126540 sc: toggling grid lines sets document as modified

View->View Grid Lines modifies a sheet-level option which must
be saved in the document.

Co-authored-by: Tibor Nagy (NISZ)

Change-Id: Ifcee59d27fbe0bb50b9fe99e16c70e2062a714f6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115711
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index aa5d8b5..d133876 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -1640,6 +1640,19 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf99913)
    CPPUNIT_ASSERT(pDoc->RowFiltered(2, 0));
}

CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf126540_GridToggleModifiesTheDocument)
{
    ScModelObj* pModelObj = createDoc("tdf99913.xlsx");
    ScDocument* pDoc = pModelObj->GetDocument();
    CPPUNIT_ASSERT(pDoc);

    // Toggling the grid of a sheet, must set the document modified state
    ScDocShell* pDocSh = ScDocShell::GetViewData()->GetDocShell();
    CPPUNIT_ASSERT(!pDocSh->IsModified());
    dispatchCommand(mxComponent, ".uno:ToggleSheetGrid", {});
    CPPUNIT_ASSERT(pDocSh->IsModified());
}

CPPUNIT_PLUGIN_IMPLEMENT();

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx
index 40f78b7..57b0bf6 100644
--- a/sc/source/ui/view/tabvwshf.cxx
+++ b/sc/source/ui/view/tabvwshf.cxx
@@ -735,6 +735,8 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
                rViewData.SetShowGrid(!bShowGrid);
                SfxBindings& rBindings = GetViewFrame()->GetBindings();
                rBindings.Invalidate( FID_TAB_TOGGLE_GRID );
                ScDocShellModificator aModificator(*rViewData.GetDocShell());
                aModificator.SetDocumentModified();
                PaintGrid();
                rReq.Done();
            }