summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2020-09-17 20:01:38 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2020-09-21 07:52:00 +0200
commit40240877eed74e4a886c78ad86e163bdd8f6290c (patch)
tree7fe15efb6b7ad49d55cc9f3049107f9e4385ce36 /sc/qa
parent327091048c8cbcad0178dfd8e06813153e861e5e (diff)
tdf#134392: sc_jumbosheets_test: Add unittest
Change-Id: Id1a63d6b7fde3f911625573ffce1bed5d2b322df Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102971 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/unit/data/xlsx/tdf134392.xlsxbin0 -> 11961 bytes
-rw-r--r--sc/qa/unit/jumbosheets-test.cxx108
2 files changed, 108 insertions, 0 deletions
diff --git a/sc/qa/unit/data/xlsx/tdf134392.xlsx b/sc/qa/unit/data/xlsx/tdf134392.xlsx
new file mode 100644
index 000000000000..c5bb4150498a
--- /dev/null
+++ b/sc/qa/unit/data/xlsx/tdf134392.xlsx
Binary files differ
diff --git a/sc/qa/unit/jumbosheets-test.cxx b/sc/qa/unit/jumbosheets-test.cxx
new file mode 100644
index 000000000000..77bd231984c1
--- /dev/null
+++ b/sc/qa/unit/jumbosheets-test.cxx
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * 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/.
+ */
+
+#include <memory>
+#include <sal/config.h>
+#include <unotest/filters-test.hxx>
+#include <test/bootstrapfixture.hxx>
+
+#include <defaultsoptions.hxx>
+#include <scmod.hxx>
+
+#include "helper/qahelper.hxx"
+#include "helper/shared_test_impl.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+/* Implementation of Filters test */
+
+class ScFiltersTest : public test::FiltersTest, public ScBootstrapFixture
+{
+public:
+ ScFiltersTest();
+
+ virtual bool load(const OUString& rFilter, const OUString& rURL, const OUString& rUserData,
+ SfxFilterFlags nFilterFlags, SotClipboardFormatId nClipboardID,
+ unsigned int nFilterVersion) override;
+
+ virtual void setUp() override;
+ virtual void tearDown() override;
+
+ void testTdf134392();
+
+ CPPUNIT_TEST_SUITE(ScFiltersTest);
+
+ CPPUNIT_TEST(testTdf134392);
+
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+ uno::Reference<uno::XInterface> m_xCalcComponent;
+};
+
+bool ScFiltersTest::load(const OUString& rFilter, const OUString& rURL, const OUString& rUserData,
+ SfxFilterFlags nFilterFlags, SotClipboardFormatId nClipboardID,
+ unsigned int nFilterVersion)
+{
+ ScDocShellRef xDocShRef = ScBootstrapFixture::load(rURL, rFilter, rUserData, OUString(),
+ nFilterFlags, nClipboardID, nFilterVersion);
+ bool bLoaded = xDocShRef.is();
+ //reference counting of ScDocShellRef is very confused.
+ if (bLoaded)
+ xDocShRef->DoClose();
+ return bLoaded;
+}
+
+void ScFiltersTest::testTdf134392()
+{
+ // Without the fix in place, the file would have crashed
+ ScDocShellRef xDocSh = loadDoc("tdf134392.", FORMAT_XLSX);
+ CPPUNIT_ASSERT(xDocSh.is());
+
+ ScDocument& rDoc = xDocSh->GetDocument();
+ rDoc.CalcAll(); // perform hard re-calculation.
+ xDocSh->DoClose();
+}
+
+ScFiltersTest::ScFiltersTest()
+ : ScBootstrapFixture("sc/qa/unit/data")
+{
+}
+
+void ScFiltersTest::setUp()
+{
+ test::BootstrapFixture::setUp();
+
+ // This is a bit of a fudge, we do this to ensure that ScGlobals::ensure,
+ // which is a private symbol to us, gets called
+ m_xCalcComponent
+ = getMultiServiceFactory()->createInstance("com.sun.star.comp.Calc.SpreadsheetDocument");
+ CPPUNIT_ASSERT_MESSAGE("no calc component!", m_xCalcComponent.is());
+
+ ScDefaultsOptions aDefaultsOption = SC_MOD()->GetDefaultsOptions();
+ aDefaultsOption.SetInitJumboSheets(true);
+ SC_MOD()->SetDefaultsOptions(aDefaultsOption);
+}
+
+void ScFiltersTest::tearDown()
+{
+ uno::Reference<lang::XComponent>(m_xCalcComponent, UNO_QUERY_THROW)->dispose();
+ test::BootstrapFixture::tearDown();
+
+ ScDefaultsOptions aDefaultsOption = SC_MOD()->GetDefaultsOptions();
+ aDefaultsOption.SetInitJumboSheets(false);
+ SC_MOD()->SetDefaultsOptions(aDefaultsOption);
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScFiltersTest);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */