xmloff/CppunitTest_xmloff_draw.mk                |    1 
 xmloff/qa/unit/data/tdf141301_Extrusion_Skew.odg |binary
 xmloff/qa/unit/draw.cxx                          |   38 ++++++++++++++++++++++-
 xmloff/source/draw/shapeexport.cxx               |    8 ++++
 4 files changed, 46 insertions(+), 1 deletion(-)

New commits:
commit 773465fb95c1be48f8fdf406d2d39caa142050db
Author:     Julien Nabet <serval2...@yahoo.fr>
AuthorDate: Sun Mar 28 18:21:04 2021 +0200
Commit:     Regina Henschel <rb.hensc...@t-online.de>
CommitDate: Thu Oct 28 14:15:35 2021 +0200

    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.hensc...@t-online.de>

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
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 <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 f94fa160afd7..fd22a4dca5a2 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -4282,6 +4282,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 ) )
@@ -4513,6 +4514,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();
@@ -4582,6 +4584,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;

Reply via email to