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

Miklos Vajna vmiklos at collabora.co.uk
Fri Jun 13 12:29:56 PDT 2014


 oox/source/drawingml/shape.cxx                    |   16 ++++++++++
 oox/source/shape/WpsContext.cxx                   |    1 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   34 +++++++++++++++++++---
 3 files changed, 47 insertions(+), 4 deletions(-)

New commits:
commit 7b0eb08459f95986f2606c8ffd04ccab84d65fa0
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Jun 13 21:19:50 2014 +0200

    DOCX import: implement linking for shapes having textboxes
    
    Change-Id: I90deb68ab6a1029cf5df8170676638bf7e3cb469

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 6948f46..815887d 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -820,6 +820,22 @@ Reference< XShape > Shape::createAndInsert(
                 //aShapeProps.setProperty(PROP_TextBox, uno::makeAny(true));
             }
 
+            if (aServiceName != "com.sun.star.text.TextFrame" && isLinkedTxbx())
+            {
+                uno::Reference<beans::XPropertySet> propertySet (mxShape, uno::UNO_QUERY);
+                uno::Sequence<beans::PropertyValue> aGrabBag;
+                propertySet->getPropertyValue("InteropGrabBag") >>= 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("InteropGrabBag",uno::makeAny(aGrabBag));
+            }
+
             PropertySet( xSet ).setProperties( aShapeProps );
             if (mbLockedCanvas)
             {
diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index 63a5f7c..c17405e 100644
--- a/oox/source/shape/WpsContext.cxx
+++ b/oox/source/shape/WpsContext.cxx
@@ -149,6 +149,7 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken
         //for further processing.
         mpShape->getCustomShapeProperties()->setShapeTypeOverride(true);
         mpShape->setServiceName("com.sun.star.text.TextFrame");
+        mpShape->setTextBox(true);
         OptValue<OUString> id  = rAttribs.getString(XML_id);
         OptValue<OUString> seq = rAttribs.getString(XML_seq);
         if (id.has() && seq.has())
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 7748a33..b4b4dde 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1881,6 +1881,14 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape
                         xShapePropertySet->setPropertyValue(rPropNameSupplier.GetName( PROP_OPAQUE ), uno::makeAny( false ) );
                         checkZOredrStatus = true;
                     }
+                    else if ( aGrabBag[i].Name == "TxbxHasLink" )
+                    {
+                        //Chaining of textboxes will happen in ~DomainMapper_Impl
+                        //i.e when all the textboxes are read and all its attributes
+                        //have been set ( basically the Name/LinkedDisplayName )
+                        //which is set in Graphic Import.
+                        m_vTextFramesForChaining.push_back(xShape);
+                    }
                 }
             }
             if (!m_bInHeaderFooterImport && !checkZOredrStatus)
@@ -2324,8 +2332,17 @@ void DomainMapper_Impl::ChainTextFrames()
             uno::Reference<text::XTextContent>  xTextContent1(*outer_itr, uno::UNO_QUERY_THROW);
             uno::Reference<beans::XPropertySet> xPropertySet1(xTextContent1, uno::UNO_QUERY);
             uno::Sequence<beans::PropertyValue> aGrabBag1;
-            xPropertySet1->getPropertyValue("FrameInteropGrabBag") >>= aGrabBag1;
-            xPropertySet1->getPropertyValue("LinkDisplayName") >>= sName1;
+            uno::Reference<lang::XServiceInfo> xServiceInfo1(xPropertySet1, uno::UNO_QUERY);
+            if (xServiceInfo1->supportsService("com.sun.star.text.TextFrame"))
+            {
+                xPropertySet1->getPropertyValue("FrameInteropGrabBag") >>= aGrabBag1;
+                xPropertySet1->getPropertyValue("LinkDisplayName") >>= sName1;
+            }
+            else
+            {
+                xPropertySet1->getPropertyValue("InteropGrabBag") >>= aGrabBag1;
+                xPropertySet1->getPropertyValue("ChainName") >>= sName1;
+            }
 
             lcl_getGrabBagValue( aGrabBag1, "Txbx-Id")  >>= nTxbxId1;
             lcl_getGrabBagValue( aGrabBag1, "Txbx-Seq") >>= nTxbxSeq1;
@@ -2337,8 +2354,17 @@ void DomainMapper_Impl::ChainTextFrames()
                 uno::Reference<text::XTextContent>  xTextContent2(*inner_itr, uno::UNO_QUERY_THROW);
                 uno::Reference<beans::XPropertySet> xPropertySet2(xTextContent2, uno::UNO_QUERY);
                 uno::Sequence<beans::PropertyValue> aGrabBag2;
-                xPropertySet2->getPropertyValue("FrameInteropGrabBag") >>= aGrabBag2;
-                xPropertySet2->getPropertyValue("LinkDisplayName") >>= sName2;
+                uno::Reference<lang::XServiceInfo> xServiceInfo2(xPropertySet1, uno::UNO_QUERY);
+                if (xServiceInfo2->supportsService("com.sun.star.text.TextFrame"))
+                {
+                    xPropertySet2->getPropertyValue("FrameInteropGrabBag") >>= aGrabBag2;
+                    xPropertySet2->getPropertyValue("LinkDisplayName") >>= sName2;
+                }
+                else
+                {
+                    xPropertySet2->getPropertyValue("InteropGrabBag") >>= aGrabBag2;
+                    xPropertySet2->getPropertyValue("ChainName") >>= sName2;
+                }
 
                 lcl_getGrabBagValue( aGrabBag2, "Txbx-Id")  >>= nTxbxId2;
                 lcl_getGrabBagValue( aGrabBag2, "Txbx-Seq") >>= nTxbxSeq2;


More information about the Libreoffice-commits mailing list