From 1c6bea8e677861d201e9b21b5f0e356f77dabaaf Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 15 Oct 2018 21:11:24 +0200 Subject: tdf#112520 RTF export: write ZOrder only for toplevel shapes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RTF export at the moment exports children of group shapes as a flat shape list. This means that the order inside the group shape is not relevant for the toplevel ZOrder, so just don't write it. (cherry picked from commit 2b920bdc12f3bf3a196ec0d6d59043a68e663e33) Change-Id: I870707cb28c2f177c0e5d9cf5328260e76b661f3 Reviewed-on: https://gerrit.libreoffice.org/61904 Tested-by: Xisco Faulí Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sw/qa/extras/rtfexport/data/tdf112520.docx | Bin 0 -> 13279 bytes sw/qa/extras/rtfexport/rtfexport3.cxx | 21 +++++++++++++++++++++ sw/source/filter/ww8/rtfsdrexport.cxx | 12 +++++++++--- sw/source/filter/ww8/rtfsdrexport.hxx | 2 ++ 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 sw/qa/extras/rtfexport/data/tdf112520.docx diff --git a/sw/qa/extras/rtfexport/data/tdf112520.docx b/sw/qa/extras/rtfexport/data/tdf112520.docx new file mode 100644 index 000000000000..31c5a0afc21e Binary files /dev/null and b/sw/qa/extras/rtfexport/data/tdf112520.docx differ diff --git a/sw/qa/extras/rtfexport/rtfexport3.cxx b/sw/qa/extras/rtfexport/rtfexport3.cxx index 45be1c450cb4..26bbc8121372 100644 --- a/sw/qa/extras/rtfexport/rtfexport3.cxx +++ b/sw/qa/extras/rtfexport/rtfexport3.cxx @@ -16,6 +16,7 @@ #include #include #include +#include class Test : public SwModelTestBase { @@ -172,6 +173,26 @@ DECLARE_RTFEXPORT_TEST(testTdf117505, "tdf117505.odt") getProperty(xFirstPage, "HeaderHeight")); } +DECLARE_RTFEXPORT_TEST(testTdf112520, "tdf112520.docx") +{ + if (!mbExported) + return; + + // Assert that the white shape is on top of the yellow one. + CPPUNIT_ASSERT_EQUAL(static_cast(0xffff00), + getProperty(getShape(2), "FillColor")); + CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, + getProperty(getShape(2), "AnchorType")); + CPPUNIT_ASSERT_EQUAL(static_cast(0xffffff), + getProperty(getShape(3), "FillColor")); + // Without the accompanying fix in place, this test would have failed with + // 'expected: 4, actual: 2'. + // This means the draw page was 0/at-char/white, 1/at-char/yellow, 2/at-page/white, + // instead of the good 0/at-page/white, 1/at-char/yellow, 2/at-char/white. + CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, + getProperty(getShape(3), "AnchorType")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/rtfsdrexport.cxx b/sw/source/filter/ww8/rtfsdrexport.cxx index 209e3a9d993c..c1b835194784 100644 --- a/sw/source/filter/ww8/rtfsdrexport.cxx +++ b/sw/source/filter/ww8/rtfsdrexport.cxx @@ -89,10 +89,11 @@ void RtfSdrExport::CloseContainer() sal_uInt32 RtfSdrExport::EnterGroup(const OUString& /*rShapeName*/, const tools::Rectangle* /*pRect*/) { + m_bInGroup = true; return GenerateShapeId(); } -void RtfSdrExport::LeaveGroup() { /* noop */} +void RtfSdrExport::LeaveGroup() { m_bInGroup = false; } void RtfSdrExport::AddShape(sal_uInt32 nShapeType, ShapeFlag nShapeFlags, sal_uInt32 /*nShapeId*/) { @@ -562,8 +563,13 @@ sal_Int32 RtfSdrExport::StartShape() m_rAttrOutput.RunText().append(OOO_STRING_SVTOOLS_RTF_SHPBYIGNORE); // Write ZOrder. - m_rAttrOutput.RunText().append(OOO_STRING_SVTOOLS_RTF_SHPZ); - m_rAttrOutput.RunText().append(OString::number(m_pSdrObject->GetOrdNum())); + if (!m_bInGroup) + { + // Order inside the group shape is not relevant for the flat shape list + // we write. + m_rAttrOutput.RunText().append(OOO_STRING_SVTOOLS_RTF_SHPZ); + m_rAttrOutput.RunText().append(OString::number(m_pSdrObject->GetOrdNum())); + } for (auto it = m_aShapeProps.rbegin(); it != m_aShapeProps.rend(); ++it) lcl_AppendSP(m_rAttrOutput.RunText(), (*it).first.getStr(), (*it).second); diff --git a/sw/source/filter/ww8/rtfsdrexport.hxx b/sw/source/filter/ww8/rtfsdrexport.hxx index c2c33de4aca2..b0c9f151e790 100644 --- a/sw/source/filter/ww8/rtfsdrexport.hxx +++ b/sw/source/filter/ww8/rtfsdrexport.hxx @@ -56,6 +56,8 @@ class RtfSdrExport final : public EscherEx /// Remember which shape types we had already written. std::unique_ptr m_pShapeTypeWritten; + bool m_bInGroup = false; + public: explicit RtfSdrExport(RtfExport& rExport); ~RtfSdrExport() override; -- cgit v1.2.3