From 773465fb95c1be48f8fdf406d2d39caa142050db Mon Sep 17 00:00:00 2001 From: Julien Nabet Date: Sun, 28 Mar 2021 18:21:04 +0200 Subject: tdf#141301: extrusion-skew angle value -135 is not written to file... whereas it should since not default value (Regina) Hopefully in some years missing values are unlikely and bug tdf#141127 can be fixed. (Regina) I have added a unit test to Julien's patch. Change-Id: Ia2aabd8e724e3c3db9ae8a87cb27707aa7040fb9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113257 Tested-by: Jenkins Reviewed-by: Regina Henschel --- xmloff/qa/unit/data/tdf141301_Extrusion_Skew.odg | Bin 0 -> 9838 bytes xmloff/qa/unit/draw.cxx | 38 ++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 xmloff/qa/unit/data/tdf141301_Extrusion_Skew.odg (limited to 'xmloff/qa/unit') diff --git a/xmloff/qa/unit/data/tdf141301_Extrusion_Skew.odg b/xmloff/qa/unit/data/tdf141301_Extrusion_Skew.odg new file mode 100644 index 000000000000..757289d43849 Binary files /dev/null and b/xmloff/qa/unit/data/tdf141301_Extrusion_Skew.odg differ diff --git a/xmloff/qa/unit/draw.cxx b/xmloff/qa/unit/draw.cxx index d386e92a2da6..3b0cda0f0383 100644 --- a/xmloff/qa/unit/draw.cxx +++ b/xmloff/qa/unit/draw.cxx @@ -9,21 +9,26 @@ #include #include +#include #include #include #include #include +#include #include #include +#include using namespace ::com::sun::star; constexpr OUStringLiteral DATA_DIRECTORY = u"/xmloff/qa/unit/data/"; /// Covers xmloff/source/draw/ fixes. -class XmloffDrawTest : public test::BootstrapFixture, public unotest::MacrosTest +class XmloffDrawTest : public test::BootstrapFixture, + public unotest::MacrosTest, + public XmlTestTools { private: uno::Reference mxComponent; @@ -31,6 +36,7 @@ private: public: void setUp() override; void tearDown() override; + void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) override; uno::Reference& getComponent() { return mxComponent; } }; @@ -49,6 +55,11 @@ void XmloffDrawTest::tearDown() test::BootstrapFixture::tearDown(); } +void XmloffDrawTest::registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) +{ + XmlTestTools::registerODFNamespaces(pXmlXpathCtx); +} + CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTextBoxLoss) { // Load a document that has a shape with a textbox in it. Save it to ODF and reload. @@ -75,6 +86,31 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTextBoxLoss) CPPUNIT_ASSERT(bTextBox); } +CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTdf141301_Extrusion_Angle) +{ + // Load a document that has a custom shape with extrusion direction as set by LO as its default. + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf141301_Extrusion_Skew.odg"; + getComponent() = loadFromDesktop(aURL, "com.sun.star.comp.drawing.DrawingDocument"); + + // Prepare use of XPath + uno::Reference xStorable(getComponent(), uno::UNO_QUERY); + utl::TempFile aTempFile; + aTempFile.EnableKillingFile(); + utl::MediaDescriptor aMediaDescriptor; + aMediaDescriptor["FilterName"] <<= OUString("draw8"); + xStorable->storeAsURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); + uno::Reference xNameAccess + = packages::zip::ZipFileAccess::createWithURL(mxComponentContext, aTempFile.GetURL()); + uno::Reference xInputStream(xNameAccess->getByName("content.xml"), + uno::UNO_QUERY); + std::unique_ptr pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true)); + xmlDocUniquePtr pXmlDoc = parseXmlStream(pStream.get()); + + // Without fix draw:extrusion-skew="50 -135" was not written to file although "50 -135" is not + // default in ODF, but only default inside LO. + assertXPath(pXmlDoc, "//draw:enhanced-geometry", "extrusion-skew", "50 -135"); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit