From 255194801e9eb8e3aaede56837450af35f8313e0 Mon Sep 17 00:00:00 2001 From: umeshkadam Date: Fri, 18 Apr 2014 13:12:53 +0530 Subject: fod#77122 DOCX filter: link between textboxes is not being preserved Added support for linked textboxes for docx interoperability. Reviewed on: https://gerrit.libreoffice.org/9092 Change-Id: I7db4f5a1783afff53c64908d182788b262f5e863 --- oox/source/drawingml/shape.cxx | 19 +++++++++++++++++++ oox/source/shape/WpsContext.cxx | 35 ++++++++++++++++++++++++++++++++++- oox/source/token/tokens.txt | 1 + 3 files changed, 54 insertions(+), 1 deletion(-) (limited to 'oox') diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index f7150db048d1..1d0d4525801f 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -139,6 +139,8 @@ Shape::Shape( const ShapePtr& pSourceShape ) , mbHiddenMasterShape( pSourceShape->mbHiddenMasterShape ) , mbLockedCanvas( pSourceShape->mbLockedCanvas ) , mbWps( pSourceShape->mbWps ) +, maLinkedTxbxAttr() +, mbHasLinkedTxbx(false) , maDiagramDoms( pSourceShape->maDiagramDoms ) {} @@ -677,6 +679,23 @@ Reference< XShape > Shape::createAndInsert( aGrabBag[length].Value = uno::makeAny(mpCustomShapePropertiesPtr->getShapePresetTypeName()); propertySet->setPropertyValue("FrameInteropGrabBag",uno::makeAny(aGrabBag)); } + //If the text box has links then save the link information so that + //it can be accessed in DomainMapper_Impl.cxx while chaining the text frames. + if (this->isLinkedTxbx()) + { + uno::Reference propertySet (mxShape, uno::UNO_QUERY); + uno::Sequence aGrabBag; + propertySet->getPropertyValue("FrameInteropGrabBag") >>= aGrabBag; + sal_Int32 length = aGrabBag.getLength(); + aGrabBag.realloc( length + 3 ); + aGrabBag[length].Name = "TxbxHasLink"; + aGrabBag[length].Value = uno::makeAny(this->isLinkedTxbx()); + aGrabBag[length + 1 ].Name = "Txbx-Id"; + aGrabBag[length + 1 ].Value = uno::makeAny(this->getLinkedTxbxAttributes().id); + aGrabBag[length + 2 ].Name = "Txbx-Seq"; + aGrabBag[length + 2 ].Value = uno::makeAny(this->getLinkedTxbxAttributes().seq); + propertySet->setPropertyValue("FrameInteropGrabBag",uno::makeAny(aGrabBag)); + } // TextFrames have BackColor, not FillColor if (aShapeProps.hasProperty(PROP_FillColor)) diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx index c30992d316ac..57237095c5e6 100644 --- a/oox/source/shape/WpsContext.cxx +++ b/oox/source/shape/WpsContext.cxx @@ -109,9 +109,42 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken } break; case XML_txbx: + { mpShape->getCustomShapeProperties()->setShapeTypeOverride(true); mpShape->setServiceName("com.sun.star.text.TextFrame"); - break; + //in case if the textbox is linked, save the attributes + //for further processing. + if (rAttribs.hasAttribute(XML_id)) + { + OptValue id = rAttribs.getString(XML_id); + if (id.has()) + { + oox::drawingml::LinkedTxbxAttr linkedTxtBoxAttr ; + linkedTxtBoxAttr.id = id.get().toInt32(); + mpShape->setTxbxHasLinkedTxtBox(true); + mpShape->setLinkedTxbxAttributes(linkedTxtBoxAttr); + } + } + } + break; + case XML_linkedTxbx: + { + //in case if the textbox is linked, save the attributes + //for further processing. + mpShape->getCustomShapeProperties()->setShapeTypeOverride(true); + mpShape->setServiceName("com.sun.star.text.TextFrame"); + OptValue id = rAttribs.getString(XML_id); + OptValue seq = rAttribs.getString(XML_seq); + if (id.has() && seq.has()) + { + oox::drawingml::LinkedTxbxAttr linkedTxtBoxAttr ; + linkedTxtBoxAttr.id = id.get().toInt32(); + linkedTxtBoxAttr.seq = seq.get().toInt32(); + mpShape->setTxbxHasLinkedTxtBox(true); + mpShape->setLinkedTxbxAttributes(linkedTxtBoxAttr); + } + } + break; default: SAL_WARN("oox", "WpsContext::createFastChildContext: unhandled element: " << getBaseToken(nElementToken)); break; diff --git a/oox/source/token/tokens.txt b/oox/source/token/tokens.txt index e2740015a9b6..bab7cf1dc859 100644 --- a/oox/source/token/tokens.txt +++ b/oox/source/token/tokens.txt @@ -3074,6 +3074,7 @@ lines linesAndChars linestyle link +linkedTxbx linkStyles linkTarget linkToQuery -- cgit