[Libreoffice-commits] core.git: oox/source sw/source writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Jun 17 08:41:52 PDT 2014


 oox/source/export/vmlexport.cxx               |   19 +++++++++++++++++++
 sw/source/filter/ww8/docxsdrexport.cxx        |    9 +++++++--
 writerfilter/source/dmapper/GraphicImport.cxx |    7 ++++++-
 3 files changed, 32 insertions(+), 3 deletions(-)

New commits:
commit 5df0bfdddb65742e437d7bfe2df2979f445aea8f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Jun 17 15:37:47 2014 +0200

    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

diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index b0d712e..ad24db2 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 bd580a0..7646e00 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 2487408..e796d21 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))
     {


More information about the Libreoffice-commits mailing list