diff options
Diffstat (limited to 'sc')
-rw-r--r-- | sc/CppunitTest_sc_jumbosheets_test.mk | 58 | ||||
-rw-r--r-- | sc/Module_sc.mk | 1 | ||||
-rw-r--r-- | sc/inc/scmod.hxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/data/xlsx/tdf134392.xlsx | bin | 0 -> 11961 bytes | |||
-rw-r--r-- | sc/qa/unit/jumbosheets-test.cxx | 108 |
5 files changed, 168 insertions, 1 deletions
diff --git a/sc/CppunitTest_sc_jumbosheets_test.mk b/sc/CppunitTest_sc_jumbosheets_test.mk new file mode 100644 index 000000000000..3f8b0c99fbe8 --- /dev/null +++ b/sc/CppunitTest_sc_jumbosheets_test.mk @@ -0,0 +1,58 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# 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/. +# + +$(eval $(call gb_CppunitTest_CppunitTest,sc_jumbosheets_test)) + +$(eval $(call gb_CppunitTest_use_externals,sc_jumbosheets_test, \ + boost_headers \ + mdds_headers \ +)) + +$(eval $(call gb_CppunitTest_use_common_precompiled_header,sc_jumbosheets_test)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sc_jumbosheets_test, \ + sc/qa/unit/jumbosheets-test \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sc_jumbosheets_test, \ + basegfx \ + comphelper \ + cppu \ + cppuhelper \ + sal \ + salhelper \ + sax \ + sc \ + scqahelper \ + sfx \ + test \ + unotest \ + vcl \ +)) + +$(eval $(call gb_CppunitTest_set_include,sc_jumbosheets_test,\ + -I$(SRCDIR)/sc/source/ui/inc \ + -I$(SRCDIR)/sc/inc \ + -I$(SRCDIR)/sc/source/filter/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_api,sc_jumbosheets_test,\ + udkapi \ + offapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,sc_jumbosheets_test)) +$(eval $(call gb_CppunitTest_use_vcl,sc_jumbosheets_test)) + +$(eval $(call gb_CppunitTest_use_rdb,sc_jumbosheets_test,services)) + +$(eval $(call gb_CppunitTest_use_configuration,sc_jumbosheets_test)) + +# vim: set noet sw=4 ts=4: diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk index 730023c476a6..4c8ba1e49eb2 100644 --- a/sc/Module_sc.mk +++ b/sc/Module_sc.mk @@ -174,6 +174,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\ CppunitTest_sc_indexenumeration_tablerowsenumeration \ CppunitTest_sc_indexenumeration_textfieldenumeration \ CppunitTest_sc_importdescriptorbaseobj \ + CppunitTest_sc_jumbosheets_test \ CppunitTest_sc_labelrangeobj \ CppunitTest_sc_labelrangesobj \ CppunitTest_sc_macros_test \ diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx index 73bc1ac61619..c8af1d424d9b 100644 --- a/sc/inc/scmod.hxx +++ b/sc/inc/scmod.hxx @@ -174,7 +174,7 @@ public: void SetViewOptions ( const ScViewOptions& rOpt ); SC_DLLPUBLIC void SetDocOptions ( const ScDocOptions& rOpt ); SC_DLLPUBLIC void SetAppOptions ( const ScAppOptions& rOpt ); - void SetDefaultsOptions ( const ScDefaultsOptions& rOpt ); + SC_DLLPUBLIC void SetDefaultsOptions ( const ScDefaultsOptions& rOpt ); SC_DLLPUBLIC void SetFormulaOptions ( const ScFormulaOptions& rOpt ); SC_DLLPUBLIC void SetInputOptions ( const ScInputOptions& rOpt ); void SetPrintOptions ( const ScPrintOptions& rOpt ); diff --git a/sc/qa/unit/data/xlsx/tdf134392.xlsx b/sc/qa/unit/data/xlsx/tdf134392.xlsx Binary files differnew file mode 100644 index 000000000000..c5bb4150498a --- /dev/null +++ b/sc/qa/unit/data/xlsx/tdf134392.xlsx 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: */ |