sc/CppunitTest_sc_subsequent_export_test.mk       |    1 
 sc/qa/unit/data/ods/tdf126541_GridOffGlobally.ods |binary
 sc/qa/unit/data/xlsx/tdf126541_GridOff.xlsx       |binary
 sc/qa/unit/subsequent_export-test.cxx             |   46 ++++++++++++++++++++++
 sc/source/filter/oox/viewsettings.cxx             |    2 
 5 files changed, 48 insertions(+), 1 deletion(-)

New commits:
commit 759103fd65f82fc131679eba0de05f2ddc7294c8
Author:     Attila Szűcs <szucs.atti...@nisz.hu>
AuthorDate: Tue May 25 10:28:05 2021 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Wed May 26 20:50:26 2021 +0200

    tdf#126541 XLSX import: fix View grid lines
    
    It was not possible to enable the disabled grid
    with View->View grid lines, as intended, because
    document-level grid visibility was set to the
    visibility of the actual sheet's grid (which already
    imported correctly) instead of keeping its default true
    value.
    
    Note: document-level or global grid visibility is
    unknown for XLSX, but handled by Writer/ODS, see
    Tools->Options->Calc->View->Grid lines.
    
    Co-authored-by: Tibor Nagy (NISZ)
    
    Change-Id: Iccab3e2b9f617cdcd678071f73c7c2d6db0bc161
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116096
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/sc/CppunitTest_sc_subsequent_export_test.mk 
b/sc/CppunitTest_sc_subsequent_export_test.mk
index 604dbabeadc8..9d5fb86cb56e 100644
--- a/sc/CppunitTest_sc_subsequent_export_test.mk
+++ b/sc/CppunitTest_sc_subsequent_export_test.mk
@@ -96,6 +96,7 @@ $(eval $(call 
gb_CppunitTest_use_components,sc_subsequent_export_test,\
     sfx2/util/sfx \
     sot/util/sot \
     svl/util/svl \
+    svl/source/fsstor/fsstorage \
     svtools/util/svt \
     toolkit/util/tk \
     ucb/source/core/ucb1 \
diff --git a/sc/qa/unit/data/ods/tdf126541_GridOffGlobally.ods 
b/sc/qa/unit/data/ods/tdf126541_GridOffGlobally.ods
new file mode 100644
index 000000000000..389fe347d493
Binary files /dev/null and b/sc/qa/unit/data/ods/tdf126541_GridOffGlobally.ods 
differ
diff --git a/sc/qa/unit/data/xlsx/tdf126541_GridOff.xlsx 
b/sc/qa/unit/data/xlsx/tdf126541_GridOff.xlsx
new file mode 100644
index 000000000000..e27089b01603
Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf126541_GridOff.xlsx differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index ee9f0ee110e5..2ef429e30a4f 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -43,6 +43,7 @@
 #include <dpcache.hxx>
 #include <dpobject.hxx>
 #include <clipparam.hxx>
+#include <viewopti.hxx>
 
 #include <svx/svdpage.hxx>
 #include <svx/svdograf.hxx>
@@ -295,6 +296,7 @@ public:
     void testTdf84874();
     void testTdf136721_paper_size();
     void testTdf139258_rotated_image();
+    void testTdf126541_SheetVisibilityImportXlsx();
 
     CPPUNIT_TEST_SUITE(ScExportTest);
     CPPUNIT_TEST(test);
@@ -486,10 +488,13 @@ public:
     CPPUNIT_TEST(testTdf84874);
     CPPUNIT_TEST(testTdf136721_paper_size);
     CPPUNIT_TEST(testTdf139258_rotated_image);
+    CPPUNIT_TEST(testTdf126541_SheetVisibilityImportXlsx);
 
     CPPUNIT_TEST_SUITE_END();
 
 private:
+
+    ScDocShellRef loadDocAndSetupModelViewController(std::u16string_view 
rFileName, sal_Int32 nFormat, bool bReadWrite);
     void testExcelCellBorders( sal_uLong nFormatType );
 
     uno::Reference<uno::XInterface> m_xCalcComponent;
@@ -6127,6 +6132,47 @@ void ScExportTest::testTdf139258_rotated_image()
     assertXPathContent(pDrawing, "/xdr:wsDr/xdr:twoCellAnchor/xdr:to/xdr:row", 
"25");
 }
 
+ScDocShellRef 
ScExportTest::loadDocAndSetupModelViewController(std::u16string_view rFileName, 
sal_Int32 nFormat, bool bReadWrite)
+{
+    uno::Reference< frame::XDesktop2 > xDesktop = 
frame::Desktop::create(::comphelper::getProcessComponentContext());
+    CPPUNIT_ASSERT(xDesktop.is());
+
+    // create a frame
+    Reference< frame::XFrame > xTargetFrame = xDesktop->findFrame("_blank", 0);
+    CPPUNIT_ASSERT(xTargetFrame.is());
+
+    // 1. Open the document
+    ScDocShellRef xDocSh = loadDoc(rFileName, nFormat, bReadWrite);
+    CPPUNIT_ASSERT_MESSAGE(OString("Failed to load " + 
OUStringToOString(rFileName, RTL_TEXTENCODING_UTF8)).getStr(), xDocSh.is());
+
+    uno::Reference< frame::XModel2 > xModel2 = xDocSh->GetModel();
+    CPPUNIT_ASSERT(xModel2.is());
+
+    Reference< frame::XController2 > xController = 
xModel2->createDefaultViewController(xTargetFrame);
+    CPPUNIT_ASSERT(xController.is());
+
+    // introduce model/view/controller to each other
+    xController->attachModel(xModel2);
+    xModel2->connectController(xController);
+    xTargetFrame->setComponent(xController->getComponentWindow(), xController);
+    xController->attachFrame(xTargetFrame);
+    xModel2->setCurrentController(xController);
+
+    return xDocSh;
+}
+
+void ScExportTest::testTdf126541_SheetVisibilityImportXlsx()
+{
+    // Import an ods file with 'Hide' global grid visibility setting.
+    ScDocShellRef xShell = 
loadDocAndSetupModelViewController(u"tdf126541_GridOffGlobally.", FORMAT_ODS, 
true);
+    
CPPUNIT_ASSERT(!xShell->GetDocument().GetViewOptions().GetOption(VOPT_GRID));
+
+    // Importing xlsx file should set the global grid visibility setting to 
'Show'
+    // Sheet based grid line visibility setting should not overwrite the 
global setting.
+    xShell = loadDocAndSetupModelViewController(u"tdf126541_GridOff.", 
FORMAT_XLSX, true);
+    
CPPUNIT_ASSERT(xShell->GetDocument().GetViewOptions().GetOption(VOPT_GRID));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/filter/oox/viewsettings.cxx 
b/sc/source/filter/oox/viewsettings.cxx
index 0e66409f725c..dcf07a6e97e1 100644
--- a/sc/source/filter/oox/viewsettings.cxx
+++ b/sc/source/filter/oox/viewsettings.cxx
@@ -578,7 +578,7 @@ void ViewSettings::finalizeImport()
         aPropMap.setProperty( PROP_GridColor, rxActiveSheetView->getGridColor( 
getBaseFilter() ));
         aPropMap.setProperty( PROP_ShowPageBreakPreview, 
rxActiveSheetView->isPageBreakPreview());
         aPropMap.setProperty( PROP_ShowFormulas, 
rxActiveSheetView->mbShowFormulas);
-        aPropMap.setProperty( PROP_ShowGrid, rxActiveSheetView->mbShowGrid);
+        aPropMap.setProperty( PROP_ShowGrid, true);
         aPropMap.setProperty( PROP_HasColumnRowHeaders, 
rxActiveSheetView->mbShowHeadings);
         aPropMap.setProperty( PROP_ShowZeroValues, 
rxActiveSheetView->mbShowZeros);
         aPropMap.setProperty( PROP_IsOutlineSymbolsSet, 
rxActiveSheetView->mbShowOutline);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to