From 36750bc977b3210b23b7822abd395b30a78af6f5 Mon Sep 17 00:00:00 2001 From: Tamás Zolnai Date: Tue, 20 Dec 2016 17:14:58 +0000 Subject: tdf#96218: MSO DOCX image incorrectly placed when using Alignment Position MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit layoutInCell attribute should be ignored when we are not in a table. Change-Id: Ieed29c690f8516f63d0956a4f0495500908a0d27 Reviewed-on: https://gerrit.libreoffice.org/32253 Reviewed-by: Tamás Zolnai Tested-by: Tamás Zolnai --- sw/qa/extras/ooxmlimport/data/tdf96218.docx | Bin 0 -> 41900 bytes sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 6 ++++++ writerfilter/source/dmapper/DomainMapper.cxx | 5 +++++ writerfilter/source/dmapper/DomainMapper.hxx | 1 + writerfilter/source/dmapper/GraphicImport.cxx | 2 +- 5 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 sw/qa/extras/ooxmlimport/data/tdf96218.docx diff --git a/sw/qa/extras/ooxmlimport/data/tdf96218.docx b/sw/qa/extras/ooxmlimport/data/tdf96218.docx new file mode 100644 index 000000000000..a6a269f82be5 Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf96218.docx differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 4fd658d98ba5..14be1f844911 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -1274,6 +1274,12 @@ DECLARE_OOXMLIMPORT_TEST(testTdf82824, "tdf82824.docx") CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, getProperty(getShape(1), "AnchorType")); } +DECLARE_OOXMLIMPORT_TEST(testTdf96218, "tdf96218.docx") +{ + // Image had a bad position because layoutInCell attribute was not ignored + CPPUNIT_ASSERT(!getProperty(getShape(1), "IsFollowingTextFlow")); +} + // tests should only be added to ooxmlIMPORT *if* they fail round-tripping in ooxmlEXPORT CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 8d47e9801103..45f2764aa664 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -3680,6 +3680,11 @@ bool DomainMapper::IsInHeaderFooter() const return m_pImpl->IsInHeaderFooter(); } +bool DomainMapper::IsInTable() const +{ + return m_pImpl->hasTableManager() && m_pImpl->getTableManager().isInCell(); +} + bool DomainMapper::IsStyleSheetImport() const { return m_pImpl->IsStyleSheetImport(); diff --git a/writerfilter/source/dmapper/DomainMapper.hxx b/writerfilter/source/dmapper/DomainMapper.hxx index d1b36229eef8..4f05118b1190 100644 --- a/writerfilter/source/dmapper/DomainMapper.hxx +++ b/writerfilter/source/dmapper/DomainMapper.hxx @@ -108,6 +108,7 @@ public: css::uno::Reference PopPendingShape(); bool IsInHeaderFooter() const; + bool IsInTable() const; bool IsStyleSheetImport() const; /** @see DomainMapper_Impl::processDeferredCharacterProperties() diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index 3531093abb24..41c1166e129c 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -1266,7 +1266,7 @@ uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const b } xGraphicObjectProperties->setPropertyValue(getPropertyName( PROP_SURROUND ), uno::makeAny(m_pImpl->nWrap)); - if( m_pImpl->bLayoutInCell && m_pImpl->nWrap != text::WrapTextMode_THROUGHT ) + if( m_pImpl->rDomainMapper.IsInTable() && m_pImpl->bLayoutInCell && m_pImpl->nWrap != text::WrapTextMode_THROUGHT ) xGraphicObjectProperties->setPropertyValue(getPropertyName( PROP_FOLLOW_TEXT_FLOW ), uno::makeAny(true)); -- cgit