diff options
author | Regina Henschel <rb.henschel@t-online.de> | 2022-10-30 00:35:31 +0200 |
---|---|---|
committer | Regina Henschel <rb.henschel@t-online.de> | 2022-10-30 13:30:21 +0100 |
commit | 4d15adebcc492112ca88e36aa7e8799b62d86466 (patch) | |
tree | 32b6cb25d79f69c4ae45d7d8a05c98b696732749 /sc/qa | |
parent | 347fa47507fce9758b60d9126a1beed04c45dc35 (diff) |
tdf#151818 xlsx SmartArt import, apply theme text color
Similar as patch 2406ba67 for tdf#54095 but now for import of
SmartArt objects in xlsx files.
Change-Id: I12ca8c476fb9d141cef991e8e98ad13b53c70613
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142027
Tested-by: Jenkins
Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/data/xlsx/tdf151818_SmartartThemeFontColor.xlsx | bin | 0 -> 22678 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_filters_test2.cxx | 58 |
2 files changed, 58 insertions, 0 deletions
diff --git a/sc/qa/unit/data/xlsx/tdf151818_SmartartThemeFontColor.xlsx b/sc/qa/unit/data/xlsx/tdf151818_SmartartThemeFontColor.xlsx Binary files differnew file mode 100644 index 000000000000..c1851ca3791d --- /dev/null +++ b/sc/qa/unit/data/xlsx/tdf151818_SmartartThemeFontColor.xlsx diff --git a/sc/qa/unit/subsequent_filters_test2.cxx b/sc/qa/unit/subsequent_filters_test2.cxx index 8ae23af8048c..293c7300d7fb 100644 --- a/sc/qa/unit/subsequent_filters_test2.cxx +++ b/sc/qa/unit/subsequent_filters_test2.cxx @@ -55,6 +55,7 @@ #include <com/sun/star/sheet/XSpreadsheetDocument.hpp> #include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/text/WritingMode2.hpp> +#include <com/sun/star/text/XTextRange.hpp> #include <comphelper/scopeguard.hxx> #include <tools/UnitConversion.hxx> @@ -188,6 +189,7 @@ public: void testTooManyColsRows(); void testTdf83671_SmartArt_import(); void testTdf83671_SmartArt_import2(); + void testTdf151818_SmartArtFontColor(); CPPUNIT_TEST_SUITE(ScFiltersTest2); @@ -306,6 +308,7 @@ public: CPPUNIT_TEST(testTooManyColsRows); CPPUNIT_TEST(testTdf83671_SmartArt_import); CPPUNIT_TEST(testTdf83671_SmartArt_import2); + CPPUNIT_TEST(testTdf151818_SmartArtFontColor); CPPUNIT_TEST_SUITE_END(); }; @@ -3137,6 +3140,61 @@ void ScFiltersTest2::testTdf83671_SmartArt_import2() xDocSh->DoClose(); } +void ScFiltersTest2::testTdf151818_SmartArtFontColor() +{ + // The document contains a SmartArt where the color for the texts in the shapes is given by + // the theme. + // Error was, that the theme was not considered and therefore the text was white. + + // Make sure it is not loaded as metafile but with single shapes. + bool bUseGroup = officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::get(); + if (!bUseGroup) + { + std::shared_ptr<comphelper::ConfigurationChanges> pChange( + comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::set(true, pChange); + pChange->commit(); + } + + // Get document and shape in SmartArt object + ScDocShellRef xDocSh = loadDoc(u"tdf151818_SmartartThemeFontColor.", FORMAT_XLSX); + uno::Reference<drawing::XDrawPagesSupplier> xDoc(xDocSh->GetModel(), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XDrawPage> xPage(xDoc->getDrawPages()->getByIndex(0), + uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShapes> xSmartArt(xPage->getByIndex(0), uno::UNO_QUERY_THROW); + // shape 0 is the background shape without text + uno::Reference<text::XTextRange> xShape(xSmartArt->getByIndex(1), uno::UNO_QUERY); + + // text color + uno::Reference<container::XEnumerationAccess> xText(xShape->getText(), uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xPara(xText->createEnumeration()->nextElement(), + uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPortion(xPara->createEnumeration()->nextElement(), + uno::UNO_QUERY); + sal_Int32 nActualColor{ 0 }; + xPortion->getPropertyValue("CharColor") >>= nActualColor; + // Without fix the test would have failed with: + // - Expected: 4478058 (0x44546A) + // - Actual : 16777215 (0xFFFFFF), that is text was white + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x44546A), nActualColor); + + // clrScheme. For map between name in xlsx and index from CharColorTheme see + // oox::drawingml::Color::getSchemeColorIndex() + // Without fix the color scheme was "lt1" (1) but should be "dk2" (2). + CPPUNIT_ASSERT_EQUAL(sal_Int16(2), + xPortion->getPropertyValue("CharColorTheme").get<sal_Int16>()); + + if (!bUseGroup) + { + std::shared_ptr<comphelper::ConfigurationChanges> pChange( + comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::set(false, pChange); + pChange->commit(); + } + + xDocSh->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(ScFiltersTest2); CPPUNIT_PLUGIN_IMPLEMENT(); |