sc/qa/uitest/calc_tests9/tdf126541_GridVisibilityImportXlsx.py | 30 ++++++++++ sc/qa/uitest/data/tdf126541_GridOff.xlsx |binary sc/qa/uitest/data/tdf126541_GridOffGlobally.ods |binary sc/qa/unit/subsequent_export-test2.cxx | 14 ++-- sc/source/filter/oox/viewsettings.cxx | 18 +++++- 5 files changed, 55 insertions(+), 7 deletions(-)
New commits: commit c3dd27d24dec0c581ed731acf8ff3504a4068b03 Author: Attila Szűcs <szucs.atti...@nisz.hu> AuthorDate: Thu Jul 8 08:45:00 2021 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Wed Jul 21 23:50:46 2021 +0200 tdf#142854 XLSX import: fix grid visibility in headless mode Fix regression from commit 759103fd65f82fc131679eba0de05f2ddc7294c8 (tdf#126541 XLSX import: fix View grid lines). Sheet based grid visibility shouldn't overwrite the global grid visibility, except for headless mode (i.e. for command line batch mode, see --convert-to in ./soffice --help, otherwise we could get a regression here: The sheet based grid visibility (bShowGrid) is stored in view settings. Headless mode means not to export view setting, including sheet based grid visibility. As the old workaround, use global visibility to keep the losing sheet visibility. FIXME: headless mode only works correctly if all sheets have the same grid visibility. The sheet based bShowGrid should be moved to another location, which is supported by the headless mode, too. Note: now the modified tdf#126541 unit test checks the fix for the regression of the headless mode, and the new Python UI test checks the (now improved) fix for tdf#126541 on the desktop. Co-authored-by: Tibor Nagy (NISZ) Change-Id: I93551d22cc5d858dc64f93a46cd8aa202b4b2df5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118599 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119314 Tested-by: Jenkins diff --git a/sc/qa/uitest/calc_tests9/tdf126541_GridVisibilityImportXlsx.py b/sc/qa/uitest/calc_tests9/tdf126541_GridVisibilityImportXlsx.py new file mode 100644 index 000000000000..0e916ad38ea1 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf126541_GridVisibilityImportXlsx.py @@ -0,0 +1,30 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file + +class tdf126541(UITestCase): + + def test_tdf126541_GridVisibilityImportXlsx(self): + # Import an ods file with 'Hide' global grid visibility setting. + self.ui_test.load_file(get_url_for_data_file("tdf126541_GridOffGlobally.ods")) + document = self.ui_test.get_component() + controller = document.getCurrentController() + grid = controller.ShowGrid + self.assertEqual(grid, False) + self.ui_test.close_doc() + + # Importing xlsx file should set the global grid visibility setting to 'Show' + # Sheet based grid line visibility setting should not overwrite the global setting. + self.ui_test.load_file(get_url_for_data_file("tdf126541_GridOff.xlsx")) + document = self.ui_test.get_component() + controller = document.getCurrentController() + grid = controller.ShowGrid + self.assertEqual(grid, True) + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/data/tdf126541_GridOff.xlsx b/sc/qa/uitest/data/tdf126541_GridOff.xlsx new file mode 100644 index 000000000000..e27089b01603 Binary files /dev/null and b/sc/qa/uitest/data/tdf126541_GridOff.xlsx differ diff --git a/sc/qa/uitest/data/tdf126541_GridOffGlobally.ods b/sc/qa/uitest/data/tdf126541_GridOffGlobally.ods new file mode 100644 index 000000000000..389fe347d493 Binary files /dev/null and b/sc/qa/uitest/data/tdf126541_GridOffGlobally.ods differ diff --git a/sc/qa/unit/subsequent_export-test2.cxx b/sc/qa/unit/subsequent_export-test2.cxx index 2b1dda267fed..6cc0ece437d6 100644 --- a/sc/qa/unit/subsequent_export-test2.cxx +++ b/sc/qa/unit/subsequent_export-test2.cxx @@ -187,7 +187,7 @@ public: void testTdf84874(); void testTdf136721_paper_size(); void testTdf139258_rotated_image(); - void testTdf126541_SheetVisibilityImportXlsx(); + void testTdf142854_GridVisibilityImportXlsxInHeadlessMode(); void testTdf140431(); void testTdf142929_filterLessThanXLSX(); @@ -285,7 +285,7 @@ public: CPPUNIT_TEST(testTdf84874); CPPUNIT_TEST(testTdf136721_paper_size); CPPUNIT_TEST(testTdf139258_rotated_image); - CPPUNIT_TEST(testTdf126541_SheetVisibilityImportXlsx); + CPPUNIT_TEST(testTdf142854_GridVisibilityImportXlsxInHeadlessMode); CPPUNIT_TEST(testTdf140431); CPPUNIT_TEST(testTdf142929_filterLessThanXLSX); @@ -2308,17 +2308,19 @@ ScDocShellRef ScExportTest2::loadDocAndSetupModelViewController(std::u16string_v return xDocSh; } -void ScExportTest2::testTdf126541_SheetVisibilityImportXlsx() +void ScExportTest2::testTdf142854_GridVisibilityImportXlsxInHeadlessMode() { + // Tests are running in Headless mode // 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. + // To avoid regression, in headless mode leave the bug tdf126541 + // It means Sheet based grid line visibility setting will overwrite the global setting. + // If there is only 1 sheet in the document, it will not result visible problems. xShell = loadDocAndSetupModelViewController(u"tdf126541_GridOff.", FORMAT_XLSX, true); - CPPUNIT_ASSERT(xShell->GetDocument().GetViewOptions().GetOption(VOPT_GRID)); + CPPUNIT_ASSERT(!xShell->GetDocument().GetViewOptions().GetOption(VOPT_GRID)); } void ScExportTest2::testTdf140431() diff --git a/sc/source/filter/oox/viewsettings.cxx b/sc/source/filter/oox/viewsettings.cxx index dcf07a6e97e1..926289134d16 100644 --- a/sc/source/filter/oox/viewsettings.cxx +++ b/sc/source/filter/oox/viewsettings.cxx @@ -41,6 +41,7 @@ #include <addressconverter.hxx> #include <workbooksettings.hxx> #include <worksheetbuffer.hxx> +#include <vcl/svapp.hxx> namespace com::sun::star::container { class XNameContainer; } @@ -578,7 +579,22 @@ 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, true); + if (!Application::IsHeadlessModeEnabled()) + { + // tdf#126541 sheet based grid visibility shouldn't overwrite the global grid visibility + aPropMap.setProperty(PROP_ShowGrid, true); + } + else + { + // tdf#142854 except for headless mode, otherwise we could get a regression here: + // The sheet based grid visibility (bShowGrid) is stored in view settings. Headless + // mode means not to export view setting, including sheet based grid visibility. + // As the old workaround, use global visibility to keep the losing sheet visibility. + // FIXME: this only works correctly if all sheets have the same grid visibility. + // The sheet based bShowGrid should be moved to another location, which is supported + // by the headless mode, too. + aPropMap.setProperty(PROP_ShowGrid, rxActiveSheetView->mbShowGrid); + } 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