From 20ce7306d2761652d36ec16e971e30b5a937121f Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 22 Feb 2021 14:11:05 +0100 Subject: oox: VML export: write o:allowincell attribute on shapes Apparently the default is "t", which causes a fly that is anchored at-page with the first content on the page being a table to be wrongly positioned. Change-Id: Iba1b961c6e884b2a55928952937187732ef73a5a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111336 Tested-by: Jenkins Reviewed-by: Michael Stahl (cherry picked from commit 60b61fdaf85cecea0f972fc435530ee5d7492c98) --- include/oox/export/vmlexport.hxx | 6 +- oox/source/export/vmlexport.cxx | 8 +- .../ooxmlexport/data/shape-atpage-in-table.fodt | 185 +++++++++++++++++++++ sw/qa/extras/ooxmlexport/ooxmlexport15.cxx | 13 ++ sw/source/filter/ww8/docxattributeoutput.cxx | 3 + sw/source/filter/ww8/docxsdrexport.cxx | 6 +- 6 files changed, 216 insertions(+), 5 deletions(-) create mode 100644 sw/qa/extras/ooxmlexport/data/shape-atpage-in-table.fodt diff --git a/include/oox/export/vmlexport.hxx b/include/oox/export/vmlexport.hxx index 3736420756a6..f64f0cd04c65 100644 --- a/include/oox/export/vmlexport.hxx +++ b/include/oox/export/vmlexport.hxx @@ -84,6 +84,7 @@ class OOX_DLLPUBLIC VMLExport : public EscherEx sal_Int16 m_eHOri, m_eVOri, m_eHRel, m_eVRel; std::unique_ptr m_pWrapAttrList; bool m_bInline; // css::text::TextContentAnchorType_AS_CHARACTER + bool m_IsFollowingTextFlow = false; /// The object we're exporting. const SdrObject* m_pSdrObject; @@ -138,8 +139,9 @@ public: /// Export the sdr object as VML. /// /// Call this when you need to export the object as VML. - OString const & AddSdrObject( const SdrObject& rObj, sal_Int16 eHOri = -1, - sal_Int16 eVOri = -1, sal_Int16 eHRel = -1, + OString const & AddSdrObject( const SdrObject& rObj, + bool const bIsFollowingTextFlow = false, + sal_Int16 eHOri = -1, sal_Int16 eVOri = -1, sal_Int16 eHRel = -1, sal_Int16 eVRel = -1, std::unique_ptr m_pWrapAttrList = nullptr, const bool bOOxmlExport = false ); diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx index deea12e04330..99a591add354 100644 --- a/oox/source/export/vmlexport.cxx +++ b/oox/source/export/vmlexport.cxx @@ -1392,6 +1392,8 @@ sal_Int32 VMLExport::StartShape() break; } + m_pShapeAttrList->addNS(XML_o, XML_allowincell, m_IsFollowingTextFlow ? "t" : "f"); + // add style m_pShapeAttrList->add( XML_style, m_ShapeStyle.makeStringAndClear() ); @@ -1492,7 +1494,9 @@ void VMLExport::EndShape( sal_Int32 nShapeElement ) } } -OString const & VMLExport::AddSdrObject( const SdrObject& rObj, sal_Int16 eHOri, sal_Int16 eVOri, sal_Int16 eHRel, sal_Int16 eVRel, +OString const & VMLExport::AddSdrObject( const SdrObject& rObj, + bool const bIsFollowingTextFlow, + sal_Int16 eHOri, sal_Int16 eVOri, sal_Int16 eHRel, sal_Int16 eVRel, std::unique_ptr pWrapAttrList, const bool bOOxmlExport ) { @@ -1503,6 +1507,7 @@ OString const & VMLExport::AddSdrObject( const SdrObject& rObj, sal_Int16 eHOri, m_eVRel = eVRel; m_pWrapAttrList = std::move(pWrapAttrList); m_bInline = false; + m_IsFollowingTextFlow = bIsFollowingTextFlow; EscherEx::AddSdrObject(rObj, bOOxmlExport); return m_sShapeId; } @@ -1516,6 +1521,7 @@ OString const & VMLExport::AddInlineSdrObject( const SdrObject& rObj, const bool m_eVRel = -1; m_pWrapAttrList.reset(); m_bInline = true; + m_IsFollowingTextFlow = true; EscherEx::AddSdrObject(rObj, bOOxmlExport); return m_sShapeId; } diff --git a/sw/qa/extras/ooxmlexport/data/shape-atpage-in-table.fodt b/sw/qa/extras/ooxmlexport/data/shape-atpage-in-table.fodt new file mode 100644 index 000000000000..42c9c7790509 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/shape-atpage-in-table.fodt @@ -0,0 +1,185 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ABC DEF GHI + + + + + + + + + + + + + + + + diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx index d5e067b98f07..6912379369d5 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx @@ -146,6 +146,19 @@ DECLARE_OOXMLEXPORT_TEST(testTdf135973, "tdf135973.odt") } } +DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testVMLallowincell, "shape-atpage-in-table.fodt") +{ + xmlDocPtr pXmlDocument = parseExport("word/document.xml"); + + // VML o:allowincell, apparently the default is "t" + assertXPath(pXmlDocument, "/w:document/w:body/w:tbl[1]/w:tr[1]/w:tc[1]/w:p[1]/w:r/w:pict/v:shape", "allowincell", "f"); + +#if 0 + // DML layoutInCell + assertXPath(pXmlDocument, "/w:document/w:body/w:tbl[1]/w:tr[1]/w:tc[1]/w:p[1]/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor", "layoutInCell", "0"); +#endif +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index e9c09f206d01..0eb2a733ac33 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -5345,11 +5346,13 @@ void DocxAttributeOutput::WriteActiveXControl(const SdrObject* pObject, const Sw } else { + SwFormatFollowTextFlow const& rFlow(rFrameFormat.GetFollowTextFlow()); const SwFormatHoriOrient& rHoriOri = rFrameFormat.GetHoriOrient(); const SwFormatVertOrient& rVertOri = rFrameFormat.GetVertOrient(); SwFormatSurround const& rSurround(rFrameFormat.GetSurround()); std::unique_ptr pAttrList(docx::SurroundToVMLWrap(rSurround)); sShapeId = m_rExport.VMLExporter().AddSdrObject(*pObject, + rFlow.GetValue(), rHoriOri.GetHoriOrient(), rVertOri.GetVertOrient(), rHoriOri.GetRelationOrient(), rVertOri.GetRelationOrient(), diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index a1f8b7b2f5be..57fa2d708126 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include "docxattributeoutput.hxx" @@ -825,6 +826,7 @@ void DocxSdrExport::writeVMLDrawing(const SdrObject* sdrObj, const SwFrameFormat m_pImpl->getDrawingML()->SetFS(m_pImpl->getSerializer()); // See WinwordAnchoring::SetAnchoring(), these are not part of the SdrObject, have to be passed around manually. + SwFormatFollowTextFlow const& rFlow(rFrameFormat.GetFollowTextFlow()); const SwFormatHoriOrient& rHoriOri = rFrameFormat.GetHoriOrient(); const SwFormatVertOrient& rVertOri = rFrameFormat.GetVertOrient(); SwFormatSurround const& rSurround(rFrameFormat.GetSurround()); @@ -832,8 +834,8 @@ void DocxSdrExport::writeVMLDrawing(const SdrObject* sdrObj, const SwFrameFormat std::unique_ptr pAttrList( docx::SurroundToVMLWrap(rSurround)); m_pImpl->getExport().VMLExporter().AddSdrObject( - *sdrObj, rHoriOri.GetHoriOrient(), rVertOri.GetVertOrient(), rHoriOri.GetRelationOrient(), - rVertOri.GetRelationOrient(), std::move(pAttrList), true); + *sdrObj, rFlow.GetValue(), rHoriOri.GetHoriOrient(), rVertOri.GetVertOrient(), + rHoriOri.GetRelationOrient(), rVertOri.GetRelationOrient(), std::move(pAttrList), true); m_pImpl->getSerializer()->endElementNS(XML_w, XML_pict); } -- cgit