From 7546a904265cc0d0a0e3795cdb411cbb945a39fe Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 21 Apr 2015 12:17:27 +0200 Subject: RTF import: handle d{x,y}WrapDist* picture properties Commit e789c7f0f15a6b571de95b81e77e3a323e9f540e (RTF import of d{x,y}WrapDist* shape properties, 2013-04-09) added support for wrap distance of shapes, but that was ignored for shapes, as dmapper later overwrote the set margins. Fix this by generating the expected tokens in case of pictures, then dmapper will take care of the rest. Also add testcases for the original shape wrap distance feature that was missing. Change-Id: I6f219ee6fef71328368409d142897dbae77a0f2f --- writerfilter/source/rtftok/rtfsdrimport.cxx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'writerfilter/source/rtftok/rtfsdrimport.cxx') diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index aad5c01b0758..400a26b017dc 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -45,6 +45,7 @@ RTFSdrImport::RTFSdrImport(RTFDocumentImpl& rDocument, uno::Reference const& xDstDoc) : m_rImport(rDocument) , m_bTextFrame(false) + , m_bTextGraphicObject(false) , m_bFakePict(false) { uno::Reference xDrawings(xDstDoc, uno::UNO_QUERY); @@ -257,6 +258,7 @@ int RTFSdrImport::initShape(uno::Reference& o_xShape, { case ESCHER_ShpInst_PictureFrame: createShape("com.sun.star.drawing.GraphicObjectShape", o_xShape, o_xPropSet); + m_bTextGraphicObject = true; break; case ESCHER_ShpInst_Line: createShape("com.sun.star.drawing.LineShape", o_xShape, o_xPropSet); @@ -293,6 +295,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap { bool bPib = false; m_bTextFrame = false; + m_bTextGraphicObject = false; uno::Reference xShape; uno::Reference xPropertySet; @@ -524,22 +527,30 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap } else if (i->first == "dxWrapDistLeft") { - if (xPropertySet.is()) + if (m_bTextGraphicObject) + rShape.aAnchorAttributes.set(NS_ooxml::LN_CT_Anchor_distL, std::make_shared(i->second.toInt32())); + else if (xPropertySet.is()) xPropertySet->setPropertyValue("LeftMargin", uno::makeAny(i->second.toInt32() / 360)); } else if (i->first == "dyWrapDistTop") { - if (xPropertySet.is()) + if (m_bTextGraphicObject) + rShape.aAnchorAttributes.set(NS_ooxml::LN_CT_Anchor_distT, std::make_shared(i->second.toInt32())); + else if (xPropertySet.is()) xPropertySet->setPropertyValue("TopMargin", uno::makeAny(i->second.toInt32() / 360)); } else if (i->first == "dxWrapDistRight") { - if (xPropertySet.is()) + if (m_bTextGraphicObject) + rShape.aAnchorAttributes.set(NS_ooxml::LN_CT_Anchor_distR, std::make_shared(i->second.toInt32())); + else if (xPropertySet.is()) xPropertySet->setPropertyValue("RightMargin", uno::makeAny(i->second.toInt32() / 360)); } else if (i->first == "dyWrapDistBottom") { - if (xPropertySet.is()) + if (m_bTextGraphicObject) + rShape.aAnchorAttributes.set(NS_ooxml::LN_CT_Anchor_distB, std::make_shared(i->second.toInt32())); + else if (xPropertySet.is()) xPropertySet->setPropertyValue("BottomMargin", uno::makeAny(i->second.toInt32() / 360)); } else if (i->first == "fillType") -- cgit