From 0016757efef898205452a586ba5927e5d11fdabe Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Fri, 8 Jun 2012 19:31:32 +0200 Subject: attempt to anchor vml shapes properly as they should be This is a mess. Shapes from oox/vml are added to Writer by calling SwXDrawPage::add(), which forces the shapes to be AT_PAGE, because the pDoc->GetCurrentLayout() there is NULL. After that writerfilter in DomainMapper_Impl::PushShapeContext() tries to do further tricks with the anchoring. Such as the fix for bnc#764005 (0a412cc13edf0904524ee2cf1e38ccc36b713065) that broke inline shapes because of the AT_PAGE above. So try to set the proper anchoring already in oox, although I'm not entirely sure I got it right. Ideally writerfilter should not touch it, but when I simply removed it another testcase breaks, so hopefully this all can be cleaned up somewhen later when we have enough testcases for all the possibilities. Change-Id: I7dd95d87bd027ce0f129f76b3377f3d1445c34d1 --- oox/source/vml/vmlshape.cxx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index b66546ba0aba..d0984aba53c0 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -611,11 +611,20 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes aPropSet.setProperty(PROP_HoriOrientPosition, rShapeRect.X); aPropSet.setProperty(PROP_VertOrientPosition, rShapeRect.Y); aPropSet.setProperty(PROP_Opaque, sal_False); + // I'm not sure if AT_PAGE is always correct here (not sure what the parent that + // the spec talks about can be), but with Writer SwXDrawPage::add() + // always in practice uses this because of pDoc->GetCurrentLayout() being NULL at this point. + aPropSet.setProperty(PROP_AnchorType, text::TextContentAnchorType_AT_PAGE); } - else if( maTypeModel.maPosition == "static" || maTypeModel.maPosition.isEmpty()) - { // static position (the default) means anchored inline - aPropSet.setProperty(PROP_AnchorType, makeAny(text::TextContentAnchorType_AS_CHARACTER)); + else if( maTypeModel.maPosition == "relative" ) + { // I'm not very sure this is correct either. + aPropSet.setProperty(PROP_AnchorType, text::TextContentAnchorType_AT_PARAGRAPH); } + else // static (is the default) means anchored inline + { + aPropSet.setProperty(PROP_AnchorType, text::TextContentAnchorType_AS_CHARACTER); + } + if ( maTypeModel.maPositionVerticalRelative == "page" ) { aPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::PAGE_FRAME); -- cgit