diff options
-rw-r--r-- | sd/qa/unit/misc-tests.cxx | 52 | ||||
-rw-r--r-- | xmloff/source/table/XMLTableExport.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/table/XMLTableImport.cxx | 2 |
3 files changed, 55 insertions, 3 deletions
diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx index bc741c6ac2fe..ee03008dfb47 100644 --- a/sd/qa/unit/misc-tests.cxx +++ b/sd/qa/unit/misc-tests.cxx @@ -24,6 +24,7 @@ #include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/table/XTable.hpp> #include <com/sun/star/table/XMergeableCellRange.hpp> +#include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <DrawDocShell.hxx> #include <drawdoc.hxx> @@ -80,6 +81,7 @@ public: void testTdf131033(); void testTdf129898LayerDrawnInSlideshow(); void testTdf136956(); + void testEncodedTableStyles(); CPPUNIT_TEST_SUITE(SdMiscTest); CPPUNIT_TEST(testTdf99396); @@ -101,6 +103,7 @@ public: CPPUNIT_TEST(testTdf131033); CPPUNIT_TEST(testTdf129898LayerDrawnInSlideshow); CPPUNIT_TEST(testTdf136956); + CPPUNIT_TEST(testEncodedTableStyles); CPPUNIT_TEST_SUITE_END(); virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override @@ -891,6 +894,55 @@ void SdMiscTest::testTdf136956() CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable->getRowCount()); } +void SdMiscTest::testEncodedTableStyles() +{ + // Silence unrelated failure: + // Error: element "table:table-template" is missing "first-row-start-column" attribute + skipValidation(); + + createSdDrawDoc(); + + { + uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent, + uno::UNO_QUERY_THROW); + uno::Reference<css::lang::XSingleServiceFactory> xTableStyleFamily( + xStyleFamiliesSupplier->getStyleFamilies()->getByName("table"), uno::UNO_QUERY_THROW); + uno::Reference<css::lang::XSingleServiceFactory> xCellStyleFamily( + xStyleFamiliesSupplier->getStyleFamilies()->getByName("cell"), uno::UNO_QUERY_THROW); + + uno::Reference<style::XStyle> xTableStyle(xTableStyleFamily->createInstance(), + uno::UNO_QUERY_THROW); + uno::Reference<style::XStyle> xCellStyle(xCellStyleFamily->createInstance(), + uno::UNO_QUERY_THROW); + + uno::Reference<container::XNameContainer>(xTableStyleFamily, uno::UNO_QUERY_THROW) + ->insertByName("table_1", uno::Any(xTableStyle)); + uno::Reference<container::XNameContainer>(xCellStyleFamily, uno::UNO_QUERY_THROW) + ->insertByName("table-body_1", uno::Any(xCellStyle)); + uno::Reference<container::XNameReplace>(xTableStyle, uno::UNO_QUERY_THROW) + ->replaceByName("body", uno::Any(xCellStyle)); + } + + saveAndReload("draw8"); + + { + uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent, + uno::UNO_QUERY_THROW); + uno::Reference<container::XNameAccess> xTableStyleFamily( + xStyleFamiliesSupplier->getStyleFamilies()->getByName("table"), uno::UNO_QUERY_THROW); + // Such style used to be exported as "table_5f_1" instead. + CPPUNIT_ASSERT(xTableStyleFamily->hasByName("table_1")); + + uno::Reference<container::XNameAccess> xTableStyle(xTableStyleFamily->getByName("table_1"), + uno::UNO_QUERY_THROW); + uno::Reference<style::XStyle> xCellStyle(xTableStyle->getByName("body"), uno::UNO_QUERY); + // Such style used to not be found by the table style, as it was + // searching for "table-body_5f_1" instead of "table-body_1". + CPPUNIT_ASSERT(xCellStyle.is()); + CPPUNIT_ASSERT_EQUAL(OUString("table-body_1"), xCellStyle->getName()); + } +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdMiscTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/xmloff/source/table/XMLTableExport.cxx b/xmloff/source/table/XMLTableExport.cxx index f415bb171af9..0b8fd95aadda 100644 --- a/xmloff/source/table/XMLTableExport.cxx +++ b/xmloff/source/table/XMLTableExport.cxx @@ -640,9 +640,9 @@ void XMLTableExport::exportTableTemplates() // tdf#106780 historically this wrong attribute was used // for the name; write it if extended because LO < 5.3 can // read only text:style-name, not the correct table:name - mrExport.AddAttribute(XML_NAMESPACE_TEXT, XML_STYLE_NAME, GetExport().EncodeStyleName( xTableStyle->getName() ) ); + mrExport.AddAttribute(XML_NAMESPACE_TEXT, XML_STYLE_NAME, xTableStyle->getName()); } - mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, GetExport().EncodeStyleName(xTableStyle->getName())); + mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, xTableStyle->getName()); } SvXMLElementExport tableTemplate( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_TEMPLATE, true, true ); diff --git a/xmloff/source/table/XMLTableImport.cxx b/xmloff/source/table/XMLTableImport.cxx index afc86cf4000c..65b6be09d2ff 100644 --- a/xmloff/source/table/XMLTableImport.cxx +++ b/xmloff/source/table/XMLTableImport.cxx @@ -376,7 +376,7 @@ void XMLTableImport::finishStyles() for( const auto& rStyle : *xT ) try { const OUString sPropName( rStyle.first ); - const OUString sStyleName( rStyle.second ); + const OUString sStyleName( mrImport.GetStyleDisplayName(XmlStyleFamily::TABLE_CELL, rStyle.second) ); xTemplate->replaceByName( sPropName, xCellFamily->getByName( sStyleName ) ); } catch( Exception& ) |