From 091fe76b6329b4bb974987554369cbfadd8f2401 Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Tue, 30 Jun 2015 12:55:18 +0300 Subject: tdf#87348 implement mso-next-textbox vml-style textbox chaining import Change-Id: Ic62769cf5bb1589dd4de3a66b3d7dd896e5b5711 Reviewed-on: https://gerrit.libreoffice.org/16366 Reviewed-by: Justin Luth Tested-by: Jenkins Reviewed-by: Miklos Vajna --- oox/source/vml/vmlshape.cxx | 77 +++++++++++++++++++++++++++++++++--- oox/source/vml/vmlshapecontext.cxx | 1 + oox/source/vml/vmltextboxcontext.cxx | 2 + 3 files changed, 75 insertions(+), 5 deletions(-) (limited to 'oox') diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index 55b17d99a741..2c2f6eb4a685 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -312,21 +312,64 @@ Reference< XShape > ShapeBase::convertAndInsert( const Reference< XShapes >& rxS if( aShapeProp.hasProperty( PROP_Name ) ) aShapeProp.setProperty( PROP_Name, getShapeName() ); uno::Reference< lang::XServiceInfo > xSInfo( xShape, uno::UNO_QUERY_THROW ); + + OUString sLinkChainName = getTypeModel().maLegacyId; + sal_Int32 id = 0; + sal_Int32 idPos = sLinkChainName.indexOf("_x"); + sal_Int32 seq = 0; + sal_Int32 seqPos = sLinkChainName.indexOf("_s",idPos); + if( idPos >= 0 && idPos < seqPos ) + { + id = sLinkChainName.copy(idPos+2,seqPos-idPos+2).toInt32(); + seq = sLinkChainName.copy(seqPos+2).toInt32(); + } + + OUString s_mso_next_textbox; + if( getTextBox() ) + s_mso_next_textbox = getTextBox()->msNextTextbox; + if( s_mso_next_textbox.startsWith("#") ) + s_mso_next_textbox = s_mso_next_textbox.copy(1); + if (xSInfo->supportsService("com.sun.star.text.TextFrame")) { uno::Sequence aGrabBag; uno::Reference propertySet (xShape, uno::UNO_QUERY); propertySet->getPropertyValue("FrameInteropGrabBag") >>= aGrabBag; - sal_Int32 length = aGrabBag.getLength(); + sal_Int32 length; + length = aGrabBag.getLength(); aGrabBag.realloc( length+1 ); aGrabBag[length].Name = "VML-Z-ORDER"; aGrabBag[length].Value = uno::makeAny( maTypeModel.maZIndex.toInt32() ); + + if( !s_mso_next_textbox.isEmpty() ) + { + length = aGrabBag.getLength(); + aGrabBag.realloc( length+1 ); + aGrabBag[length].Name = "mso-next-textbox"; + aGrabBag[length].Value = uno::makeAny( s_mso_next_textbox ); + } + + if( !sLinkChainName.isEmpty() ) + { + length = aGrabBag.getLength(); + aGrabBag.realloc( length+4 ); + aGrabBag[length].Name = "TxbxHasLink"; + aGrabBag[length].Value = uno::makeAny( true ); + aGrabBag[length+1].Name = "Txbx-Id"; + aGrabBag[length+1].Value = uno::makeAny( id ); + aGrabBag[length+2].Name = "Txbx-Seq"; + aGrabBag[length+2].Value = uno::makeAny( seq ); + aGrabBag[length+3].Name = "LinkChainName"; + aGrabBag[length+3].Value = uno::makeAny( sLinkChainName ); + } + if(!(maTypeModel.maRotation).isEmpty()) { - aGrabBag.realloc( length+2 ); - aGrabBag[length+1].Name = "mso-rotation-angle"; - aGrabBag[length+1].Value = uno::makeAny(sal_Int32(NormAngle360((maTypeModel.maRotation.toInt32()) * -100))); + length = aGrabBag.getLength(); + aGrabBag.realloc( length+1 ); + aGrabBag[length].Name = "mso-rotation-angle"; + aGrabBag[length].Value = uno::makeAny(sal_Int32(NormAngle360((maTypeModel.maRotation.toInt32()) * -100))); } propertySet->setPropertyValue( "FrameInteropGrabBag", uno::makeAny(aGrabBag) ); sal_Int32 backColorTransparency = 0; @@ -346,10 +389,34 @@ Reference< XShape > ShapeBase::convertAndInsert( const Reference< XShapes >& rxS uno::Sequence aGrabBag; uno::Reference propertySet (xShape, uno::UNO_QUERY); propertySet->getPropertyValue("InteropGrabBag") >>= aGrabBag; - sal_Int32 length = aGrabBag.getLength(); + sal_Int32 length; + + length = aGrabBag.getLength(); aGrabBag.realloc( length+1 ); aGrabBag[length].Name = "VML-Z-ORDER"; aGrabBag[length].Value = uno::makeAny( maTypeModel.maZIndex.toInt32() ); + + if( !s_mso_next_textbox.isEmpty() ) + { + length = aGrabBag.getLength(); + aGrabBag.realloc( length+1 ); + aGrabBag[length].Name = "mso-next-textbox"; + aGrabBag[length].Value = uno::makeAny( s_mso_next_textbox ); + } + + if( !sLinkChainName.isEmpty() ) + { + length = aGrabBag.getLength(); + aGrabBag.realloc( length+4 ); + aGrabBag[length].Name = "TxbxHasLink"; + aGrabBag[length].Value = uno::makeAny( true ); + aGrabBag[length+1].Name = "Txbx-Id"; + aGrabBag[length+1].Value = uno::makeAny( id ); + aGrabBag[length+2].Name = "Txbx-Seq"; + aGrabBag[length+2].Value = uno::makeAny( seq ); + aGrabBag[length+3].Name = "LinkChainName"; + aGrabBag[length+3].Value = uno::makeAny( sLinkChainName ); + } propertySet->setPropertyValue( "InteropGrabBag", uno::makeAny(aGrabBag) ); } } diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx index 2f69efe3e7f2..4ea10e87bd98 100644 --- a/oox/source/vml/vmlshapecontext.cxx +++ b/oox/source/vml/vmlshapecontext.cxx @@ -269,6 +269,7 @@ ShapeTypeContext::ShapeTypeContext( ContextHandler2Helper& rParent, ShapeType& r // shape identifier and shape name bool bHasOspid = rAttribs.hasAttribute( O_TOKEN( spid ) ); mrTypeModel.maShapeId = rAttribs.getXString( bHasOspid ? O_TOKEN( spid ) : XML_id, OUString() ); + mrTypeModel.maLegacyId = rAttribs.getString( XML_id, OUString() ); OSL_ENSURE( !mrTypeModel.maShapeId.isEmpty(), "ShapeTypeContext::ShapeTypeContext - missing shape identifier" ); // if the o:spid attribute exists, the id attribute contains the user-defined shape name if( bHasOspid ) diff --git a/oox/source/vml/vmltextboxcontext.cxx b/oox/source/vml/vmltextboxcontext.cxx index 8a1d5fb3077c..d1a8b1256d74 100644 --- a/oox/source/vml/vmltextboxcontext.cxx +++ b/oox/source/vml/vmltextboxcontext.cxx @@ -212,6 +212,8 @@ TextBoxContext::TextBoxContext( ContextHandler2Helper& rParent, TextBox& rTextBo rTextBox.mrTypeModel.mbAutoHeight = true; else if (aName == "mso-layout-flow-alt") rTextBox.mrTypeModel.maLayoutFlowAlt = aValue; + else if (aName == "mso-next-textbox") + rTextBox.msNextTextbox = aValue; else SAL_WARN("oox", "unhandled style property: " << aName); } -- cgit