tdf#96218: MSO DOCX image incorrectly placed when using Alignment Position

layoutInCell attribute should be ignored when we are not
in a table.

Reviewed-on: https://gerrit.libreoffice.org/32253
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai@collabora.com>
(cherry picked from commit 36750bc977b3210b23b7822abd395b30a78af6f5)

Conflicts:
	sw/qa/extras/ooxmlimport/ooxmlimport.cxx

Change-Id: Ieed29c690f8516f63d0956a4f0495500908a0d27
Reviewed-on: https://gerrit.libreoffice.org/32266
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
diff --git a/sw/qa/extras/ooxmlimport/data/tdf96218.docx b/sw/qa/extras/ooxmlimport/data/tdf96218.docx
new file mode 100644
index 0000000..a6a269f
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/tdf96218.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 39ffc52..36e34cb 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -3275,6 +3275,14 @@ DECLARE_OOXMLIMPORT_TEST(testTdf82824, "tdf82824.docx")
    // This was text::TextContentAnchorType_AS_CHARACTER, <wp:anchor> wasn't handled on import for the chart.
    CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
}

DECLARE_OOXMLIMPORT_TEST(testTdf96218, "tdf96218.docx")
{
    // Image had a bad position because layoutInCell attribute was not ignored
    CPPUNIT_ASSERT(!getProperty<bool>(getShape(1), "IsFollowingTextFlow"));
}


CPPUNIT_PLUGIN_IMPLEMENT();

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index a46c6f6..789aebe 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3650,6 +3650,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 2abaf123..10220b9 100644
--- a/writerfilter/source/dmapper/DomainMapper.hxx
+++ b/writerfilter/source/dmapper/DomainMapper.hxx
@@ -114,6 +114,7 @@ public:
    css::uno::Reference<css::drawing::XShape> 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 79b46c7..dedda68 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -1262,7 +1262,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));