From 2d1fe7fb67ec1ff1b96912c0945d17d54aecb12e Mon Sep 17 00:00:00 2001 From: Tamás Zolnai Date: Tue, 22 Aug 2017 02:02:07 +0200 Subject: Fix two issues in ActiveX DOCX import / export code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Inline anchored VML shape had wrong vertical position ** In MSO inline shapes are positioned to the top of the baseline * During export all shape ids were the same (shape_0) ** VML shapes used to be exported only as fallback, I guess that's why it did not cause any issue before. ** Override the shapeid generator with a new one, which actually generates unique shapeids. Change-Id: I752f39d092d0b61d91824141655dae662dbeafbc Reviewed-on: https://gerrit.libreoffice.org/41319 Reviewed-by: Tamás Zolnai Tested-by: Tamás Zolnai --- oox/source/export/vmlexport.cxx | 27 ++++++++++++++++++++++++++- oox/source/vml/vmlshape.cxx | 2 ++ 2 files changed, 28 insertions(+), 1 deletion(-) (limited to 'oox') diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx index a401c3c44465..f45edde6cc86 100644 --- a/oox/source/export/vmlexport.cxx +++ b/oox/source/export/vmlexport.cxx @@ -68,6 +68,8 @@ VMLExport::VMLExport( ::sax_fastparser::FSHelperPtr const & pSerializer, VMLText , m_aShapeTypeWritten( ESCHER_ShpInst_COUNT ) , m_bSkipwzName( false ) , m_bUseHashMarkForType( false ) + , m_bOverrideShapeIdGeneration( false ) + , m_nShapeIDCounter( 0 ) { mnGroupLevel = 1; } @@ -208,6 +210,18 @@ bool VMLExport::IsWaterMarkShape(const OUString& rStr) return rStr.match("PowerPlusWaterMarkObject") || rStr.match("WordPictureWatermark"); } +void VMLExport::OverrideShapeIDGen(bool bOverrideShapeIdGen, const OString sShapeIDPrefix) +{ + m_bOverrideShapeIdGeneration = bOverrideShapeIdGen; + if(bOverrideShapeIdGen) + { + assert(!sShapeIDPrefix.isEmpty()); + m_sShapeIDPrefix = sShapeIDPrefix; + } + else + m_sShapeIDPrefix.clear(); +} + static void impl_AddArrowHead( sax_fastparser::FastAttributeList *pAttrList, sal_Int32 nElement, sal_uInt32 nValue ) { if ( !pAttrList ) @@ -884,7 +898,10 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, const tools::Rectangle& OString VMLExport::ShapeIdString( sal_uInt32 nId ) { - return "shape_" + OString::number( nId ); + if(m_bOverrideShapeIdGeneration) + return m_sShapeIDPrefix + OString::number( nId ); + else + return "shape_" + OString::number( nId ); } void VMLExport::AddFlipXY( ) @@ -1025,6 +1042,14 @@ OUString lcl_getAnchorIdFromGrabBag(const SdrObject* pSdrObject) return aResult; } +sal_uInt32 VMLExport::GenerateShapeId() +{ + if(!m_bOverrideShapeIdGeneration) + return EscherEx::GenerateShapeId(); + else + return m_nShapeIDCounter++; +} + sal_Int32 VMLExport::StartShape() { if ( m_nShapeType == ESCHER_ShpInst_Nil ) diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index b51a9020393f..e1d0cf6d9a41 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -616,6 +616,8 @@ void lcl_SetAnchorType(PropertySet& rPropSet, const ShapeTypeModel& rTypeModel, else // static (is the default) means anchored inline { rPropSet.setProperty(PROP_AnchorType, text::TextContentAnchorType_AS_CHARACTER); + // Use top orientation, this one seems similar to what MSO uses as inline + rPropSet.setAnyProperty(PROP_VertOrient, makeAny(text::VertOrientation::TOP)); } lcl_setSurround( rPropSet, rTypeModel, rGraphicHelper ); } -- cgit