diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2023-03-17 14:54:30 +0200 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2023-03-23 08:54:06 +0000 |
commit | b1393fd5ce847f40abab49f57c67929bb0087fae (patch) | |
tree | 6b185b3daf215c67171bd78c20b63d878084d933 /sc/qa | |
parent | 5d88965e7cca19205f5ef5ebd10ae8a8459ecb49 (diff) |
sc drawstyles: ODF import and export
Change-Id: Id92088a7d70c550682fe707d81e94157edc7caa8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149330
Tested-by: Jenkins
Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/subsequent_export_test4.cxx | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/sc/qa/unit/subsequent_export_test4.cxx b/sc/qa/unit/subsequent_export_test4.cxx index 024019e89c1e..3033ff4fef85 100644 --- a/sc/qa/unit/subsequent_export_test4.cxx +++ b/sc/qa/unit/subsequent_export_test4.cxx @@ -39,6 +39,7 @@ #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> #include <com/sun/star/packages/zip/ZipFileAccess.hpp> #include <com/sun/star/sheet/GlobalSheetSettings.hpp> +#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/text/XTextColumns.hpp> using namespace ::com::sun::star; @@ -1456,6 +1457,66 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testAutofilterHiddenButton) } } +CPPUNIT_TEST_FIXTURE(ScExportTest4, testShapeStyles) +{ + createScDoc(); + + { + uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, uno::UNO_QUERY_THROW); + uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent, + uno::UNO_QUERY_THROW); + uno::Reference<container::XNameContainer> xGraphicStyles( + xStyleFamiliesSupplier->getStyleFamilies()->getByName("GraphicStyles"), + uno::UNO_QUERY_THROW); + + // create styles + uno::Reference<style::XStyle> xStyle( + xMSF->createInstance("com.sun.star.style.GraphicStyle"), uno::UNO_QUERY_THROW); + xGraphicStyles->insertByName("MyStyle1", Any(xStyle)); + uno::Reference<beans::XPropertySet>(xStyle, uno::UNO_QUERY_THROW) + ->setPropertyValue("FillColor", Any(COL_RED)); + + xStyle.set(xMSF->createInstance("com.sun.star.style.GraphicStyle"), uno::UNO_QUERY_THROW); + xGraphicStyles->insertByName("MyStyle2", Any(xStyle)); + xStyle->setParentStyle("MyStyle1"); + + xStyle.set(xMSF->createInstance("com.sun.star.style.GraphicStyle"), uno::UNO_QUERY_THROW); + xGraphicStyles->insertByName("MyStyle3", Any(xStyle)); + xStyle->setParentStyle("MyStyle2"); + + // create shape + uno::Reference<drawing::XShape> xShape( + xMSF->createInstance("com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY_THROW); + + uno::Reference<drawing::XDrawPagesSupplier> xDPS(mxComponent, uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShapes> xShapes(xDPS->getDrawPages()->getByIndex(0), + uno::UNO_QUERY_THROW); + xShapes->add(xShape); + uno::Reference<beans::XPropertySet>(xShape, uno::UNO_QUERY_THROW) + ->setPropertyValue("Style", Any(xStyle)); + } + + saveAndReload("calc8"); + + { + uno::Reference<drawing::XDrawPagesSupplier> xDPS(mxComponent, uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShapes> xShapes(xDPS->getDrawPages()->getByIndex(0), + uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xShape(xShapes->getByIndex(0), uno::UNO_QUERY_THROW); + + // check style hierarchy + uno::Reference<style::XStyle> xStyle(xShape->getPropertyValue("Style"), + uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(OUString("MyStyle3"), xStyle->getName()); + CPPUNIT_ASSERT_EQUAL(OUString("MyStyle2"), xStyle->getParentStyle()); + + // check that styles have effect on shapes + Color nColor; + xShape->getPropertyValue("FillColor") >>= nColor; + CPPUNIT_ASSERT_EQUAL(COL_RED, nColor); + } +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |