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

Miklos Vajna vmiklos at collabora.co.uk
Tue Sep 23 02:07:47 PDT 2014


 sw/qa/extras/ooxmlexport/data/sdt-run-picture.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx           |   12 +++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx       |    9 +++++++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx  |   26 +++++++++++++++------
 4 files changed, 40 insertions(+), 7 deletions(-)

New commits:
commit 56b647b3a384db53bc55c56b2ae70e08c20e148b
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 23 10:27:10 2014 +0200

    DOCX filter: roundtrip SDT properties on Frame TextPortions
    
    Change-Id: Icb3dc9595a025c4386577d858c8ca96e2f9bbef7

diff --git a/sw/qa/extras/ooxmlexport/data/sdt-run-picture.docx b/sw/qa/extras/ooxmlexport/data/sdt-run-picture.docx
new file mode 100644
index 0000000..fa2d57c
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/sdt-run-picture.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 0bb68e8..dd458e9 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -251,6 +251,18 @@ DECLARE_OOXMLEXPORT_TEST(testSdtIgnoredFooter, "sdt-ignored-footer.docx")
     }
 }
 
+DECLARE_OOXMLEXPORT_TEST(testSdtRunPicture, "sdt-run-picture.docx")
+{
+    // SDT around run was exported as SDT around paragraph
+    if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
+    {
+        // This was 1: there was an SDT around w:p.
+        assertXPath(pXmlDoc, "//w:body/w:sdt", 0);
+        // This was 0: there were no SDT around w:r.
+        assertXPath(pXmlDoc, "//w:body/w:p/w:sdt", 1);
+    }
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index a4b11f4..4bdb9db 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -4132,6 +4132,15 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size
         nImageType = XML_embed;
     }
 
+    // In case there are any grab-bag items on the graphic frame, emit them now.
+    // These are always character grab-bags, as graphics are at-char or as-char in Word.
+    const SfxPoolItem* pItem = 0;
+    if (pFrmFmt->GetAttrSet().HasItem(RES_FRMATR_GRABBAG, &pItem))
+    {
+        const SfxGrabBagItem* pGrabBag = static_cast<const SfxGrabBagItem*>(pItem);
+        CharGrabBag(*pGrabBag);
+    }
+
     m_rExport.SdrExporter().startDMLAnchorInline(pFrmFmt, rSize);
 
     // picture description (used for pic:cNvPr later too)
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 7e68473..bf5a748 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -4455,6 +4455,22 @@ void  DomainMapper_Impl::ImportGraphic(writerfilter::Reference< Properties >::Po
     uno::Reference<text::XTextContent> xTextContent
         (m_pGraphicImport->GetGraphicObject());
 
+    // In case the SDT starts with the text portion of the graphic, then set the SDT properties here.
+    bool bHasGrabBag = false;
+    uno::Reference<beans::XPropertySet> xPropertySet(xTextContent, uno::UNO_QUERY);
+    if (xPropertySet.is())
+    {
+        uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo();
+        bHasGrabBag = xPropertySetInfo->hasPropertyByName("FrameInteropGrabBag");
+        // In case we're outside a paragraph, then the SDT properties are stored in the paragraph grab-bag, not the frame one.
+        if (!m_pSdtHelper->isInteropGrabBagEmpty() && bHasGrabBag && !m_pSdtHelper->isOutsideAParagraph())
+        {
+            comphelper::SequenceAsHashMap aFrameGrabBag(xPropertySet->getPropertyValue("FrameInteropGrabBag"));
+            aFrameGrabBag["SdtPr"] = uno::makeAny(m_pSdtHelper->getInteropGrabBagAndClear());
+            xPropertySet->setPropertyValue("FrameInteropGrabBag", uno::makeAny(aFrameGrabBag.getAsConstPropertyValueList()));
+        }
+    }
+
     /* Set "SdtEndBefore" property on Drawing.
      * It is required in a case when Drawing appears immediately after first run i.e.
      * there is no text/space/tab in between two runs.
@@ -4462,20 +4478,16 @@ void  DomainMapper_Impl::ImportGraphic(writerfilter::Reference< Properties >::Po
      */
     if(IsSdtEndBefore())
     {
-        uno::Reference< beans::XPropertySet > xGraphicObjectProperties(xTextContent,
-                    uno::UNO_QUERY_THROW);
-        uno::Reference< beans::XPropertySetInfo > xPropSetInfo;
-        if(xGraphicObjectProperties.is())
+        if(xPropertySet.is())
         {
-            xPropSetInfo = xGraphicObjectProperties->getPropertySetInfo();
-            if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("FrameInteropGrabBag"))
+            if (bHasGrabBag)
             {
                 uno::Sequence<beans::PropertyValue> aFrameGrabBag(1);
                 beans::PropertyValue aRet;
                 aRet.Name = "SdtEndBefore";
                 aRet.Value <<= uno::makeAny(true);
                 aFrameGrabBag[0] = aRet;
-                xGraphicObjectProperties->setPropertyValue("FrameInteropGrabBag",uno::makeAny(aFrameGrabBag));
+                xPropertySet->setPropertyValue("FrameInteropGrabBag",uno::makeAny(aFrameGrabBag));
             }
         }
     }


More information about the Libreoffice-commits mailing list