diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-06-17 15:37:47 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-06-17 17:41:01 +0200 |
commit | 5df0bfdddb65742e437d7bfe2df2979f445aea8f (patch) | |
tree | 942620d6b6fd1f31dc7a85061348f7da5aa11fd4 | |
parent | 503facc9c423ef307799bbc89f7a786853b7dc29 (diff) |
DOCX filter: preserve AnchorId on shapes having a textbox
CppunitTest_sw_ooxmlsdrexport's testAnchorIdForWP14AndW14 would fail
without this, when "shape with text" is imported as "shape with
textbox".
Change-Id: I8705aee16270aa68416f0c830c429880fc76d85d
-rw-r--r-- | oox/source/export/vmlexport.cxx | 19 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxsdrexport.cxx | 9 | ||||
-rw-r--r-- | writerfilter/source/dmapper/GraphicImport.cxx | 7 |
3 files changed, 32 insertions, 3 deletions
diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx index b0d712eb7b27..ad24db2fa5e0 100644 --- a/oox/source/export/vmlexport.cxx +++ b/oox/source/export/vmlexport.cxx @@ -971,6 +971,21 @@ bool lcl_isTextBox(const SdrObject* pSdrObject) return false; } +OUString lcl_getAnchorIdFromGrabBag(const SdrObject* pSdrObject) +{ + OUString aResult; + + uno::Reference<beans::XPropertySet> xShape(const_cast<SdrObject*>(pSdrObject)->getUnoShape(), uno::UNO_QUERY); + if (xShape->getPropertySetInfo()->hasPropertyByName("InteropGrabBag")) + { + comphelper::SequenceAsHashMap aInteropGrabBag(xShape->getPropertyValue("InteropGrabBag")); + if (aInteropGrabBag.find("AnchorId") != aInteropGrabBag.end()) + aInteropGrabBag["AnchorId"] >>= aResult; + } + + return aResult; +} + sal_Int32 VMLExport::StartShape() { if ( m_nShapeType == ESCHER_ShpInst_Nil ) @@ -1087,6 +1102,10 @@ sal_Int32 VMLExport::StartShape() // add style m_pShapeAttrList->add( XML_style, m_pShapeStyle->makeStringAndClear() ); + OUString sAnchorId = lcl_getAnchorIdFromGrabBag(m_pSdrObject); + if (!sAnchorId.isEmpty()) + m_pShapeAttrList->addNS(XML_wp14, XML_anchorId, OUStringToOString(sAnchorId, RTL_TEXTENCODING_UTF8)); + if ( nShapeElement >= 0 && !m_pShapeAttrList->hasAttribute( XML_type ) ) { if ( bReferToShapeType ) diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index bd580a0af37b..7646e00dfd76 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -75,8 +75,13 @@ OUString lclGetAnchorIdFromGrabBag(const SdrObject* pObj) { OUString aResult; uno::Reference<drawing::XShape> xShape(const_cast<SdrObject*>(pObj)->getUnoShape(), uno::UNO_QUERY); - uno::Sequence< beans::PropertyValue > propList = - lclGetProperty(xShape, "FrameInteropGrabBag"); + OUString aGrabBagName; + uno::Reference<lang::XServiceInfo> xServiceInfo(xShape, uno::UNO_QUERY); + if (xServiceInfo->supportsService("com.sun.star.text.TextFrame")) + aGrabBagName = "FrameInteropGrabBag"; + else + aGrabBagName = "InteropGrabBag"; + uno::Sequence< beans::PropertyValue > propList = lclGetProperty(xShape, aGrabBagName); for (sal_Int32 nProp = 0; nProp < propList.getLength(); ++nProp) { OUString aPropName = propList[nProp].Name; diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index 2487408faad6..e796d217fc87 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -468,7 +468,12 @@ void GraphicImport::putPropertyToFrameGrabBag( const OUString& sPropertyName, co if (!xSetInfo.is()) return; - const OUString aGrabBagPropName("FrameInteropGrabBag"); + OUString aGrabBagPropName; + uno::Reference<lang::XServiceInfo> xServiceInfo(m_xShape, uno::UNO_QUERY_THROW); + if (xServiceInfo->supportsService("com.sun.star.text.TextFrame")) + aGrabBagPropName = "FrameInteropGrabBag"; + else + aGrabBagPropName = "InteropGrabBag"; if (xSetInfo->hasPropertyByName(aGrabBagPropName)) { |