From fdc8590032b292dcb8152b328401e591fea642a4 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 18 Sep 2020 11:47:56 +0200 Subject: tdf#136620 tdf#136708 filter,oox,sw: fix export of 2 different wraps This reverts commit 2cb90a5c87fe46737c8d840967d8836284f92ffd. Revert the change to EscherPropertyContainer, which was completely bogus, based on pre-existing bogus code in VMLExport::Commit(). The problem is that ESCHER_Wrap values are for wrapping text *inside* a text box, which is "mso-wrap-style" in VML, whereas VML's w10:wrap element defines how text wraps *around* a shape, doesn't exist as an ESCHER property and is specific to Word formats. Instead, export the w10:wrap element in VMLExport::EndShape(). This has 2 callers, WriteActiveXControl() and writeVMLDrawing(). Furthermore the value "none" wasn't written for WrapTextMode_THROUGH, which caused the wrap element to be omitted in that case. Change-Id: Id4a01fcb2ea73fa9bef4ee8769b5e0680e059f15 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103009 Tested-by: Jenkins Reviewed-by: Michael Stahl --- filter/source/msfilter/escherex.cxx | 20 ------ include/oox/export/vmlexport.hxx | 7 ++- oox/source/export/vmlexport.cxx | 22 +++++-- sc/source/filter/xcl97/xcl97rec.cxx | 2 + sw/source/filter/ww8/docxattributeoutput.cxx | 91 ++++++++++++++++++---------- sw/source/filter/ww8/docxattributeoutput.hxx | 6 ++ sw/source/filter/ww8/docxsdrexport.cxx | 6 +- 7 files changed, 94 insertions(+), 60 deletions(-) diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx index b05e013f8082..24dcabe0277e 100644 --- a/filter/source/msfilter/escherex.cxx +++ b/filter/source/msfilter/escherex.cxx @@ -61,7 +61,6 @@ #include #include #include -#include #include #include #include @@ -692,10 +691,6 @@ void EscherPropertyContainer::CreateTextProperties( bool bWordWrap ( false ); bool bAutoGrowSize ( false ); - uno::Any aTextWrap; - - (void)EscherPropertyValueHelper::GetPropertyValue(aTextWrap, rXPropSet, "TextWrap", true); - if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, "TextWritingMode", true ) ) aAny >>= eWM; if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, "TextVerticalAdjust", true ) ) @@ -834,21 +829,6 @@ void EscherPropertyContainer::CreateTextProperties( nTextAttr |= 0x20002; } } - - if (aTextWrap.hasValue()) - { // explicit text wrap overrides whatever was inferred previously - switch (aTextWrap.get()) - { - case text::WrapTextMode_THROUGH: - eWrapMode = ESCHER_WrapNone; - break; - // in theory there are 3 more Escher_Wrap, but [MS-ODRAW] says they are useless - default: - eWrapMode = ESCHER_WrapSquare; - break; - } - } - AddOpt( ESCHER_Prop_dxTextLeft, nLeft * 360 ); AddOpt( ESCHER_Prop_dxTextRight, nRight * 360 ); AddOpt( ESCHER_Prop_dyTextTop, nTop * 360 ); diff --git a/include/oox/export/vmlexport.hxx b/include/oox/export/vmlexport.hxx index 94aeb8601f1a..67c5fc88f113 100644 --- a/include/oox/export/vmlexport.hxx +++ b/include/oox/export/vmlexport.hxx @@ -77,8 +77,9 @@ class OOX_DLLPUBLIC VMLExport : public EscherEx /// Parent exporter, used for text callback. VMLTextExport* m_pTextExport; - /// Anchoring. + /// Anchoring - Writer specific properties sal_Int16 m_eHOri, m_eVOri, m_eHRel, m_eVRel; + std::unique_ptr m_pWrapAttrList; bool m_bInline; // css::text::TextContentAnchorType_AS_CHARACTER /// The object we're exporting. @@ -136,7 +137,9 @@ public: /// 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, - sal_Int16 eVRel = -1, const bool bOOxmlExport = false ); + sal_Int16 eVRel = -1, + std::unique_ptr m_pWrapAttrList = nullptr, + const bool bOOxmlExport = false ); OString const & AddInlineSdrObject( const SdrObject& rObj, const bool bOOxmlExport ); virtual void AddSdrObjectVMLObject( const SdrObject& rObj) override; static bool IsWaterMarkShape(const OUString& rStr); diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx index dea03c552cee..b5cc2152acda 100644 --- a/oox/source/export/vmlexport.cxx +++ b/oox/source/export/vmlexport.cxx @@ -421,11 +421,15 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, const tools::Rectangle& case ESCHER_WrapSquare: case ESCHER_WrapByPoints: pWrapType = "square"; break; // these two are equivalent according to the docu case ESCHER_WrapNone: pWrapType = "none"; break; - case ESCHER_WrapTopBottom: pWrapType = "topAndBottom"; break; - case ESCHER_WrapThrough: pWrapType = "through"; break; + case ESCHER_WrapTopBottom: + case ESCHER_WrapThrough: + break; // last two are *undefined* in MS-ODRAW, don't exist in VML } if ( pWrapType ) - m_pSerializer->singleElementNS(XML_w10, XML_wrap, XML_type, pWrapType); + { + m_ShapeStyle.append(";mso-wrap-style:"); + m_ShapeStyle.append(pWrapType); + } } bAlreadyWritten[ ESCHER_Prop_WrapText ] = true; break; @@ -1484,17 +1488,26 @@ void VMLExport::EndShape( sal_Int32 nShapeElement ) m_pSerializer->endElementNS(XML_v, XML_textbox); } + if (m_pWrapAttrList) + { + sax_fastparser::XFastAttributeListRef const pWrapAttrList(m_pWrapAttrList.release()); + m_pSerializer->singleElementNS(XML_w10, XML_wrap, pWrapAttrList); + } + // end of the shape m_pSerializer->endElementNS( XML_v, nShapeElement ); } -OString const & VMLExport::AddSdrObject( const SdrObject& rObj, sal_Int16 eHOri, sal_Int16 eVOri, sal_Int16 eHRel, sal_Int16 eVRel, const bool bOOxmlExport ) +OString const & VMLExport::AddSdrObject( const SdrObject& rObj, sal_Int16 eHOri, sal_Int16 eVOri, sal_Int16 eHRel, sal_Int16 eVRel, + std::unique_ptr pWrapAttrList, + const bool bOOxmlExport ) { m_pSdrObject = &rObj; m_eHOri = eHOri; m_eVOri = eVOri; m_eHRel = eHRel; m_eVRel = eVRel; + m_pWrapAttrList = std::move(pWrapAttrList); m_bInline = false; EscherEx::AddSdrObject(rObj, bOOxmlExport); return m_sShapeId; @@ -1507,6 +1520,7 @@ OString const & VMLExport::AddInlineSdrObject( const SdrObject& rObj, const bool m_eVOri = -1; m_eHRel = -1; m_eVRel = -1; + m_pWrapAttrList.reset(); m_bInline = true; EscherEx::AddSdrObject(rObj, bOOxmlExport); return m_sShapeId; diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx index 6ffdd64e3c26..80a7df04c489 100644 --- a/sc/source/filter/xcl97/xcl97rec.cxx +++ b/sc/source/filter/xcl97/xcl97rec.cxx @@ -60,6 +60,8 @@ #include #include #include + +#include #include #include #include diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index caaaf440ddc3..59c75c6fa635 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -5446,10 +5446,14 @@ void DocxAttributeOutput::WriteActiveXControl(const SdrObject* pObject, const Sw { 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, rHoriOri.GetHoriOrient(), rVertOri.GetVertOrient(), rHoriOri.GetRelationOrient(), - rVertOri.GetRelationOrient(), true); + rVertOri.GetRelationOrient(), + std::move(pAttrList), + true); } // Restore default values m_rExport.VMLExporter().SetSkipwzName(false); @@ -8816,43 +8820,64 @@ void DocxAttributeOutput::FormatULSpace( const SvxULSpaceItem& rULSpace ) } } -void DocxAttributeOutput::FormatSurround( const SwFormatSurround& rSurround ) +namespace docx { + +std::unique_ptr SurroundToVMLWrap(SwFormatSurround const& rSurround) { - if (m_rExport.SdrExporter().getTextFrameSyntax()) + FastAttributeList * pAttrList(nullptr); + OString sType; + OString sSide; + switch (rSurround.GetSurround()) { - OString sType, sSide; - switch (rSurround.GetSurround()) + case css::text::WrapTextMode_NONE: + sType = "topAndBottom"; + break; + case css::text::WrapTextMode_PARALLEL: + sType = "square"; + break; + case css::text::WrapTextMode_DYNAMIC: + sType = "square"; + sSide = "largest"; + break; + case css::text::WrapTextMode_LEFT: + sType = "square"; + sSide = "left"; + break; + case css::text::WrapTextMode_RIGHT: + sType = "square"; + sSide = "right"; + break; + case css::text::WrapTextMode_THROUGH: + /* empty type and side means through */ + default: + sType = "none"; + break; + } + if (!sType.isEmpty() || !sSide.isEmpty()) + { + pAttrList = FastSerializerHelper::createAttrList(); + if (!sType.isEmpty()) { - case css::text::WrapTextMode_NONE: - sType = "topAndBottom"; - break; - case css::text::WrapTextMode_PARALLEL: - sType = "square"; - break; - case css::text::WrapTextMode_DYNAMIC: - sType = "square"; - sSide = "largest"; - break; - case css::text::WrapTextMode_LEFT: - sType = "square"; - sSide = "left"; - break; - case css::text::WrapTextMode_RIGHT: - sType = "square"; - sSide = "right"; - break; - case css::text::WrapTextMode_THROUGH: - /* empty type and side means through */ - default: - break; + pAttrList->add(XML_type, sType); + } + if (!sSide.isEmpty()) + { + pAttrList->add(XML_side, sSide); } - if (!sType.isEmpty() || !sSide.isEmpty()) + } + return std::unique_ptr(pAttrList); +} + +} // namespace docx + +void DocxAttributeOutput::FormatSurround( const SwFormatSurround& rSurround ) +{ + if (m_rExport.SdrExporter().getTextFrameSyntax()) + { + std::unique_ptr pAttrList(docx::SurroundToVMLWrap(rSurround)); + if (pAttrList) { - m_rExport.SdrExporter().setFlyWrapAttrList(FastSerializerHelper::createAttrList()); - if (!sType.isEmpty()) - m_rExport.SdrExporter().getFlyWrapAttrList()->add(XML_type, sType); - if (!sSide.isEmpty()) - m_rExport.SdrExporter().getFlyWrapAttrList()->add(XML_side, sSide); + m_rExport.SdrExporter().setFlyWrapAttrList(pAttrList.release()); } } else if (m_rExport.SdrExporter().getDMLTextFrameSyntax()) diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index e711d88d23a4..089914ea0b2b 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -1054,6 +1054,12 @@ struct DocxTableExportContext ~DocxTableExportContext() { m_rOutput.popFromTableExportContext(*this); } }; +namespace docx { + +std::unique_ptr SurroundToVMLWrap(SwFormatSurround const& rSurround); + +} + #endif // INCLUDED_SW_SOURCE_FILTER_WW8_DOCXATTRIBUTEOUTPUT_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index cdae55937a4e..30d08a8cb2e5 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -846,9 +846,13 @@ void DocxSdrExport::writeVMLDrawing(const SdrObject* sdrObj, const SwFrameFormat const SwFormatHoriOrient& rHoriOri = rFrameFormat.GetHoriOrient(); const SwFormatVertOrient& rVertOri = rFrameFormat.GetVertOrient(); + SwFormatSurround const& rSurround(rFrameFormat.GetSurround()); + + std::unique_ptr pAttrList( + docx::SurroundToVMLWrap(rSurround)); m_pImpl->getExport().VMLExporter().AddSdrObject( *sdrObj, rHoriOri.GetHoriOrient(), rVertOri.GetVertOrient(), rHoriOri.GetRelationOrient(), - rVertOri.GetRelationOrient(), true); + rVertOri.GetRelationOrient(), std::move(pAttrList), true); m_pImpl->getSerializer()->endElementNS(XML_w, XML_pict); } -- cgit v1.2.3