summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2021-03-28 18:21:04 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2021-11-01 12:15:26 +0100
commit0ec2f94100cf1b8c24642e79e60810a79ff075c3 (patch)
tree4d7fe8d78ff7051f48715ea1c67fa3fe13ab335a /xmloff
parent149df697ec2f4db0be891becef217312ded3ab88 (diff)
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 <rb.henschel@t-online.de> (cherry picked from commit 773465fb95c1be48f8fdf406d2d39caa142050db) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124198 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/CppunitTest_xmloff_draw.mk1
-rw-r--r--xmloff/qa/unit/data/tdf141301_Extrusion_Skew.odgbin0 -> 9838 bytes
-rw-r--r--xmloff/qa/unit/draw.cxx38
-rw-r--r--xmloff/source/draw/shapeexport.cxx8
4 files changed, 46 insertions, 1 deletions
diff --git a/xmloff/CppunitTest_xmloff_draw.mk b/xmloff/CppunitTest_xmloff_draw.mk
index 4ebac5c27a3b..46188eb0c438 100644
--- a/xmloff/CppunitTest_xmloff_draw.mk
+++ b/xmloff/CppunitTest_xmloff_draw.mk
@@ -13,6 +13,7 @@ $(eval $(call gb_CppunitTest_CppunitTest,xmloff_draw))
$(eval $(call gb_CppunitTest_use_externals,xmloff_draw,\
boost_headers \
+ libxml2 \
))
$(eval $(call gb_CppunitTest_add_exception_objects,xmloff_draw, \
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
--- /dev/null
+++ b/xmloff/qa/unit/data/tdf141301_Extrusion_Skew.odg
Binary files 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 <test/bootstrapfixture.hxx>
#include <unotest/macros_test.hxx>
+#include <test/xmltesttools.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/packages/zip/ZipFileAccess.hpp>
#include <unotools/mediadescriptor.hxx>
#include <unotools/tempfile.hxx>
+#include <unotools/ucbstreamhelper.hxx>
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<lang::XComponent> mxComponent;
@@ -31,6 +36,7 @@ private:
public:
void setUp() override;
void tearDown() override;
+ void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) override;
uno::Reference<lang::XComponent>& 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<frame::XStorable> 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<packages::zip::XZipFileAccess2> xNameAccess
+ = packages::zip::ZipFileAccess::createWithURL(mxComponentContext, aTempFile.GetURL());
+ uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName("content.xml"),
+ uno::UNO_QUERY);
+ std::unique_ptr<SvStream> 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: */
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
index 93a340fe3473..cd76dcde65d3 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -4258,6 +4258,7 @@ static void ImpExportEnhancedGeometry( SvXMLExport& rExport, const uno::Referenc
uno::Sequence< beans::PropertyValue > aExtrusionPropSeq;
if ( rGeoProp.Value >>= aExtrusionPropSeq )
{
+ bool bSkewValuesProvided = false;
for ( const beans::PropertyValue& rProp : std::as_const(aExtrusionPropSeq) )
{
switch( EASGet( rProp.Name ) )
@@ -4489,6 +4490,7 @@ static void ImpExportEnhancedGeometry( SvXMLExport& rExport, const uno::Referenc
css::drawing::EnhancedCustomShapeParameterPair aSkewParaPair;
if ( rProp.Value >>= aSkewParaPair )
{
+ bSkewValuesProvided = true;
ExportParameter( aStrBuffer, aSkewParaPair.First );
ExportParameter( aStrBuffer, aSkewParaPair.Second );
aStr = aStrBuffer.makeStringAndClear();
@@ -4558,6 +4560,12 @@ static void ImpExportEnhancedGeometry( SvXMLExport& rExport, const uno::Referenc
break;
}
}
+ // tdf#141301: no specific skew values provided
+ if (!bSkewValuesProvided)
+ {
+ // so we need to export default values explicitely
+ rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_SKEW, "50 -135");
+ }
}
}
break;