Kaydet (Commit) 1c76531b authored tarafından Miklos Vajna's avatar Miklos Vajna Kaydeden (comit) Andras Timar

tdf#112520 RTF export: write ZOrder only for toplevel shapes

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 2b920bdc)

Reviewed-on: https://gerrit.libreoffice.org/61904Tested-by: 's avatarXisco Faulí <xiscofauli@libreoffice.org>
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
(cherry picked from commit 1c6bea8e)

Change-Id: I870707cb28c2f177c0e5d9cf5328260e76b661f3
üst 78ce62fd
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <com/sun/star/text/XPageCursor.hpp> #include <com/sun/star/text/XPageCursor.hpp>
#include <com/sun/star/text/XTextViewCursorSupplier.hpp> #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
#include <com/sun/star/text/XTextColumns.hpp> #include <com/sun/star/text/XTextColumns.hpp>
#include <com/sun/star/text/TextContentAnchorType.hpp>
#include <com/sun/star/text/XTextRangeCompare.hpp> #include <com/sun/star/text/XTextRangeCompare.hpp>
class Test : public SwModelTestBase class Test : public SwModelTestBase
...@@ -152,6 +153,26 @@ DECLARE_RTFEXPORT_TEST(testTdf117505, "tdf117505.odt") ...@@ -152,6 +153,26 @@ DECLARE_RTFEXPORT_TEST(testTdf117505, "tdf117505.odt")
getProperty<sal_Int32>(xFirstPage, "HeaderHeight")); getProperty<sal_Int32>(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<sal_Int32>(0xffff00),
getProperty<sal_Int32>(getShape(2), "FillColor"));
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER,
getProperty<text::TextContentAnchorType>(getShape(2), "AnchorType"));
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xffffff),
getProperty<sal_Int32>(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<text::TextContentAnchorType>(getShape(3), "AnchorType"));
}
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -87,10 +87,11 @@ void RtfSdrExport::CloseContainer() ...@@ -87,10 +87,11 @@ void RtfSdrExport::CloseContainer()
sal_uInt32 RtfSdrExport::EnterGroup(const OUString& /*rShapeName*/, sal_uInt32 RtfSdrExport::EnterGroup(const OUString& /*rShapeName*/,
const tools::Rectangle* /*pRect*/) const tools::Rectangle* /*pRect*/)
{ {
m_bInGroup = true;
return GenerateShapeId(); return GenerateShapeId();
} }
void RtfSdrExport::LeaveGroup() { /* noop */} void RtfSdrExport::LeaveGroup() { m_bInGroup = false; }
void RtfSdrExport::AddShape(sal_uInt32 nShapeType, ShapeFlag nShapeFlags, sal_uInt32 /*nShapeId*/) void RtfSdrExport::AddShape(sal_uInt32 nShapeType, ShapeFlag nShapeFlags, sal_uInt32 /*nShapeId*/)
{ {
...@@ -556,8 +557,13 @@ sal_Int32 RtfSdrExport::StartShape() ...@@ -556,8 +557,13 @@ sal_Int32 RtfSdrExport::StartShape()
m_rAttrOutput.RunText().append(OOO_STRING_SVTOOLS_RTF_SHPBYIGNORE); m_rAttrOutput.RunText().append(OOO_STRING_SVTOOLS_RTF_SHPBYIGNORE);
// Write ZOrder. // Write ZOrder.
m_rAttrOutput.RunText().append(OOO_STRING_SVTOOLS_RTF_SHPZ); if (!m_bInGroup)
m_rAttrOutput.RunText().append(OString::number(m_pSdrObject->GetOrdNum())); {
// 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) for (auto it = m_aShapeProps.rbegin(); it != m_aShapeProps.rend(); ++it)
lcl_AppendSP(m_rAttrOutput.RunText(), (*it).first.getStr(), (*it).second); lcl_AppendSP(m_rAttrOutput.RunText(), (*it).first.getStr(), (*it).second);
......
...@@ -57,6 +57,8 @@ class RtfSdrExport final : public EscherEx ...@@ -57,6 +57,8 @@ class RtfSdrExport final : public EscherEx
/// Remember which shape types we had already written. /// Remember which shape types we had already written.
std::unique_ptr<bool[]> m_pShapeTypeWritten; std::unique_ptr<bool[]> m_pShapeTypeWritten;
bool m_bInGroup = false;
public: public:
explicit RtfSdrExport(RtfExport& rExport); explicit RtfSdrExport(RtfExport& rExport);
~RtfSdrExport() override; ~RtfSdrExport() override;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment