diff options
author | Andreas Heinisch <andreas.heinisch@yahoo.de> | 2020-09-28 22:09:04 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2020-11-15 19:15:20 +0100 |
commit | 7f43c1d203b3513462bb36eaea7bf7b41956c7b6 (patch) | |
tree | ddcd4d2fa84796cf7b7f929917acb0147e65fec5 /sc | |
parent | 7a83d0a268a348a86dd31acbac94872eab82f75b (diff) |
tdf#71271 - add code names regardless of VBA compatibility mode
During the save process of a document, save code names of calc sheets
regardless of the VBA compatibility mode. Loading of documents with
changed code names already work without checking the VBA mode.
Change-Id: Ieb5297ac3b671fd39a200c34409ba2ffdad4e1f7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103589
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/extras/macros-test.cxx | 35 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlexprt.cxx | 8 |
2 files changed, 40 insertions, 3 deletions
diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx index 5e6aa3d263fc..cf7d46ace3bb 100644 --- a/sc/qa/extras/macros-test.cxx +++ b/sc/qa/extras/macros-test.cxx @@ -19,6 +19,8 @@ #include <attrib.hxx> #include <scitems.hxx> +#include <com/sun/star/sheet/XSpreadsheet.hpp> + #include <com/sun/star/script/XLibraryContainerPassword.hpp> #include <com/sun/star/drawing/XDrawPageSupplier.hpp> @@ -48,6 +50,7 @@ public: void testTdf131296_legacy(); void testTdf131296_new(); void testTdf128218(); + void testTdf71271(); CPPUNIT_TEST_SUITE(ScMacrosTest); CPPUNIT_TEST(testStarBasic); @@ -64,6 +67,7 @@ public: CPPUNIT_TEST(testTdf131296_legacy); CPPUNIT_TEST(testTdf131296_new); CPPUNIT_TEST(testTdf128218); + CPPUNIT_TEST(testTdf71271); CPPUNIT_TEST_SUITE_END(); }; @@ -803,6 +807,37 @@ void ScMacrosTest::testTdf128218() xCloseable->close(true); } +void ScMacrosTest::testTdf71271() +{ + uno::Reference<lang::XComponent> xComponent = loadFromDesktop("private:factory/scalc"); + CPPUNIT_ASSERT(xComponent); + + { + uno::Reference<sheet::XSpreadsheetDocument> xDoc(xComponent, uno::UNO_QUERY_THROW); + uno::Reference<container::XIndexAccess> xIndex(xDoc->getSheets(), uno::UNO_QUERY_THROW); + uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xProps(xSheet, uno::UNO_QUERY_THROW); + xProps->setPropertyValue("CodeName", uno::Any(OUString("NewCodeName"))); + } + + saveAndReload(xComponent, ""); + CPPUNIT_ASSERT(xComponent); + + { + uno::Reference<sheet::XSpreadsheetDocument> xDoc(xComponent, uno::UNO_QUERY_THROW); + uno::Reference<container::XIndexAccess> xIndex(xDoc->getSheets(), uno::UNO_QUERY_THROW); + uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), uno::UNO_QUERY_THROW); + OUString sCodeName; + uno::Reference<beans::XPropertySet> xProps(xSheet, uno::UNO_QUERY_THROW); + // Without the fix in place the codename would not have been saved + xProps->getPropertyValue("CodeName") >>= sCodeName; + CPPUNIT_ASSERT_EQUAL(OUString("NewCodeName"), sCodeName); + } + + css::uno::Reference<css::util::XCloseable> xCloseable(xComponent, css::uno::UNO_QUERY_THROW); + xCloseable->close(true); +} + ScMacrosTest::ScMacrosTest() : UnoApiTest("/sc/qa/extras/testdocuments") { diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 41896b264955..0acd2d6708d5 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -5157,11 +5157,13 @@ void ScXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>& bool bVBACompat = false; uno::Reference <container::XNameAccess> xCodeNameAccess; OSL_ENSURE( pDoc, "ScXMLExport::GetConfigurationSettings - no ScDocument!" ); - if( pDoc && pDoc->IsInVBAMode() ) + // tdf#71271 - add code names regardless of VBA compatibility mode + if (pDoc) { // VBA compatibility mode - bVBACompat = true; - ++nPropsToAdd; + if (bVBACompat = pDoc->IsInVBAMode(); bVBACompat) + ++nPropsToAdd; + // code names xCodeNameAccess = new XMLCodeNameProvider( pDoc ); if( xCodeNameAccess->hasElements() ) |