summaryrefslogtreecommitdiff
path: root/sc/qa/unit/subsequent_export-test.cxx
diff options
context:
space:
mode:
authorAttila Szűcs <szucs.attila3@nisz.hu>2021-05-25 10:28:05 +0200
committerLászló Németh <nemeth@numbertext.org>2021-05-26 20:50:26 +0200
commit759103fd65f82fc131679eba0de05f2ddc7294c8 (patch)
tree1ecf0862c318ac627bfe9433abfe6a76f012c50d /sc/qa/unit/subsequent_export-test.cxx
parentb5af95a4d5c59094aa9fbdf35e49962f605f8dee (diff)
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 <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sc/qa/unit/subsequent_export-test.cxx')
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx46
1 files changed, 46 insertions, 0 deletions
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();