summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2020-09-18 11:47:56 +0200
committerMichael Stahl <michael.stahl@cib.de>2020-09-21 11:02:20 +0200
commitfdc8590032b292dcb8152b328401e591fea642a4 (patch)
treec3951fc48c92f69c4c38e3dc2291904d9d4ff94d
parent54bd2266d6e0c8926ecaf0fbb2dbb5ee9d1a802d (diff)
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 <michael.stahl@cib.de>
-rw-r--r--filter/source/msfilter/escherex.cxx20
-rw-r--r--include/oox/export/vmlexport.hxx7
-rw-r--r--oox/source/export/vmlexport.cxx22
-rw-r--r--sc/source/filter/xcl97/xcl97rec.cxx2
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx91
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx6
-rw-r--r--sw/source/filter/ww8/docxsdrexport.cxx6
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 <com/sun/star/drawing/FlagSequence.hpp>
#include <com/sun/star/drawing/PolygonFlags.hpp>
#include <com/sun/star/text/WritingMode.hpp>
-#include <com/sun/star/text/WrapTextMode.hpp>
#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
#include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
#include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
@@ -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<text::WrapTextMode>())
- {
- 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<sax_fastparser::FastAttributeList> 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<sax_fastparser::FastAttributeList> 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<FastAttributeList> 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 <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
#include <com/sun/star/chart2/XChartTypeContainer.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
+
+#include <sax/fastattribs.hxx>
#include <oox/token/tokens.hxx>
#include <oox/token/namespaces.hxx>
#include <oox/token/relationship.hxx>
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<sax_fastparser::FastAttributeList> 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<FastAttributeList> 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<FastAttributeList>(pAttrList);
+}
+
+} // namespace docx
+
+void DocxAttributeOutput::FormatSurround( const SwFormatSurround& rSurround )
+{
+ if (m_rExport.SdrExporter().getTextFrameSyntax())
+ {
+ std::unique_ptr<FastAttributeList> 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<sax_fastparser::FastAttributeList> 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<sax_fastparser::FastAttributeList> 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);
}