sw/qa/extras/ooxmlexport/data/FDO76248.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx    |    8 +
 sw/source/filter/ww8/docxsdrexport.cxx      |  159 ++++++++++++++--------------
 3 files changed, 89 insertions(+), 78 deletions(-)

New commits:
commit 3e92847d75e8703d0537d5411d1f98bd1cd0402a
Author: Miklos Vajna <vmik...@collabora.co.uk>
Date:   Wed Mar 19 14:09:51 2014 +0100

    fdo#76248 make the test fail without the fix
    
    Change-Id: I26d27bfaafb83ee3ae74ce64bf72146b157ed7db

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 6a50def..ee6c511 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2880,11 +2880,11 @@ DECLARE_OOXMLEXPORT_TEST(testSimpleSdts, 
"simple-sdts.docx")
 
 DECLARE_OOXMLEXPORT_TEST(testFDO76248, "FDO76248.docx")
 {
-    uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
-    uno::Reference<text::XTextViewCursorSupplier> 
xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
-    uno::Reference<text::XPageCursor> 
xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
-    xCursor->jumpToLastPage();
-    CPPUNIT_ASSERT_EQUAL(sal_Int16(3), xCursor->getPage());
+    xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+    if (!pXmlDoc)
+       return;
+    // In two cases the a:graphicData elements had no children, which is 
invalid.
+    assertXPath(pXmlDoc, "//a:graphicData[not(*)]", 0);
 }
 
 #endif
commit 79747314d368ab253e171877209d7172fd993c74
Author: Rohit Deshmukh <rohit.deshm...@synerzip.com>
Date:   Mon Mar 17 15:08:04 2014 +0530

    fdo#76248: Fix for file corruption which contains Polyline shape.
    
    Reviewed on:
        https://gerrit.libreoffice.org/8623
    
    Change-Id: I042eeb0829c55d6a0fd5d85c1712c7b1cddc8c96

diff --git a/sw/qa/extras/ooxmlexport/data/FDO76248.docx 
b/sw/qa/extras/ooxmlexport/data/FDO76248.docx
new file mode 100644
index 0000000..c7b868e
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/FDO76248.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 0a77ab5..6a50def 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2878,6 +2878,14 @@ DECLARE_OOXMLEXPORT_TEST(testSimpleSdts, 
"simple-sdts.docx")
 
 }
 
+DECLARE_OOXMLEXPORT_TEST(testFDO76248, "FDO76248.docx")
+{
+    uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+    uno::Reference<text::XTextViewCursorSupplier> 
xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
+    uno::Reference<text::XPageCursor> 
xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
+    xCursor->jumpToLastPage();
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(3), xCursor->getPage());
+}
 
 #endif
 
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx 
b/sw/source/filter/ww8/docxsdrexport.cxx
index be0baa1..0e62973 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -536,95 +536,98 @@ void DocxSdrExport::writeVMLDrawing(const SdrObject* 
sdrObj, const SwFrmFmt& rFr
 
 void DocxSdrExport::writeDMLDrawing(const SdrObject* pSdrObject, const 
SwFrmFmt* pFrmFmt, int nAnchorId)
 {
-    sax_fastparser::FSHelperPtr pFS = m_pImpl->m_pSerializer;
-    Size aSize(pSdrObject->GetLogicRect().GetWidth(), 
pSdrObject->GetLogicRect().GetHeight());
-    startDMLAnchorInline(pFrmFmt, aSize);
-
-    sax_fastparser::FastAttributeList* pDocPrAttrList = pFS->createAttrList();
-    pDocPrAttrList->add(XML_id, OString::number(nAnchorId).getStr());
-    pDocPrAttrList->add(XML_name, OUStringToOString(pSdrObject->GetName(), 
RTL_TEXTENCODING_UTF8));
-    if (!pSdrObject->GetTitle().isEmpty())
-        pDocPrAttrList->add(XML_title, 
OUStringToOString(pSdrObject->GetTitle(), RTL_TEXTENCODING_UTF8));
-    if (!pSdrObject->GetDescription().isEmpty())
-        pDocPrAttrList->add(XML_descr, 
OUStringToOString(pSdrObject->GetDescription(), RTL_TEXTENCODING_UTF8));
-    sax_fastparser::XFastAttributeListRef xDocPrAttrListRef(pDocPrAttrList);
-    pFS->singleElementNS(XML_wp, XML_docPr, xDocPrAttrListRef);
-
     uno::Reference<drawing::XShape> 
xShape(const_cast<SdrObject*>(pSdrObject)->getUnoShape(), uno::UNO_QUERY_THROW);
-    uno::Reference<lang::XServiceInfo> xServiceInfo(xShape, 
uno::UNO_QUERY_THROW);
-    uno::Reference< beans::XPropertySet > xPropertySet(xShape, uno::UNO_QUERY);
-    uno::Reference< beans::XPropertySetInfo > xPropSetInfo;
-    if (xPropertySet.is())
-        xPropSetInfo = xPropertySet->getPropertySetInfo();
-
-    bool bLockedCanvas = false;
-    if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("InteropGrabBag"))
+    if (m_pImpl->isSupportedDMLShape(xShape))
     {
-        uno::Sequence< beans::PropertyValue > propList;
-        xPropertySet->getPropertyValue("InteropGrabBag") >>= propList;
-        for (sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp)
+        sax_fastparser::FSHelperPtr pFS = m_pImpl->m_pSerializer;
+        Size aSize(pSdrObject->GetLogicRect().GetWidth(), 
pSdrObject->GetLogicRect().GetHeight());
+        startDMLAnchorInline(pFrmFmt, aSize);
+
+        sax_fastparser::FastAttributeList* pDocPrAttrList = 
pFS->createAttrList();
+        pDocPrAttrList->add(XML_id, OString::number(nAnchorId).getStr());
+        pDocPrAttrList->add(XML_name, OUStringToOString(pSdrObject->GetName(), 
RTL_TEXTENCODING_UTF8));
+        if (!pSdrObject->GetTitle().isEmpty())
+            pDocPrAttrList->add(XML_title, 
OUStringToOString(pSdrObject->GetTitle(), RTL_TEXTENCODING_UTF8));
+        if (!pSdrObject->GetDescription().isEmpty())
+            pDocPrAttrList->add(XML_descr, 
OUStringToOString(pSdrObject->GetDescription(), RTL_TEXTENCODING_UTF8));
+        sax_fastparser::XFastAttributeListRef 
xDocPrAttrListRef(pDocPrAttrList);
+        pFS->singleElementNS(XML_wp, XML_docPr, xDocPrAttrListRef);
+
+        uno::Reference<lang::XServiceInfo> xServiceInfo(xShape, 
uno::UNO_QUERY_THROW);
+        uno::Reference< beans::XPropertySet > xPropertySet(xShape, 
uno::UNO_QUERY);
+        uno::Reference< beans::XPropertySetInfo > xPropSetInfo;
+        if (xPropertySet.is())
+            xPropSetInfo = xPropertySet->getPropertySetInfo();
+
+        bool bLockedCanvas = false;
+        if (xPropSetInfo.is() && 
xPropSetInfo->hasPropertyByName("InteropGrabBag"))
         {
-            OUString propName = propList[nProp].Name;
-            if (propName == "LockedCanvas")
+            uno::Sequence< beans::PropertyValue > propList;
+            xPropertySet->getPropertyValue("InteropGrabBag") >>= propList;
+            for (sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp)
             {
-                /*
-                 * Export as Locked Canvas only if the drawing
-                 * was originally a Locked Canvas and is now inside a Text 
Frame.
-                 */
+                OUString propName = propList[nProp].Name;
+                if (propName == "LockedCanvas")
+                {
+                    /*
+                     * Export as Locked Canvas only if the drawing
+                     * was originally a Locked Canvas and is now inside a Text 
Frame.
+                     */
 
-                bLockedCanvas = m_pImpl->m_bIsInDMLTextFrame;
-                break;
+                    bLockedCanvas = m_pImpl->m_bIsInDMLTextFrame;
+                    break;
+                }
             }
         }
-    }
-    const char* pNamespace = 
"http://schemas.microsoft.com/office/word/2010/wordprocessingShape";;
-    if (xServiceInfo->supportsService("com.sun.star.drawing.GroupShape"))
-        pNamespace = 
"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup";;
-    else if 
(xServiceInfo->supportsService("com.sun.star.drawing.GraphicObjectShape"))
-        pNamespace = 
"http://schemas.openxmlformats.org/drawingml/2006/picture";;
-    pFS->startElementNS(XML_a, XML_graphic,
-                        FSNS(XML_xmlns, XML_a), 
"http://schemas.openxmlformats.org/drawingml/2006/main";,
-                        FSEND);
-    pFS->startElementNS(XML_a, XML_graphicData,
-                        XML_uri, pNamespace,
-                        FSEND);
-
-    if (bLockedCanvas)
-        pFS->startElementNS(XML_lc, XML_lockedCanvas,
-                            FSNS(XML_xmlns, XML_lc), 
"http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas";,
+        const char* pNamespace = 
"http://schemas.microsoft.com/office/word/2010/wordprocessingShape";;
+        if (xServiceInfo->supportsService("com.sun.star.drawing.GroupShape"))
+            pNamespace = 
"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup";;
+        else if 
(xServiceInfo->supportsService("com.sun.star.drawing.GraphicObjectShape"))
+            pNamespace = 
"http://schemas.openxmlformats.org/drawingml/2006/picture";;
+        pFS->startElementNS(XML_a, XML_graphic,
+                            FSNS(XML_xmlns, XML_a), 
"http://schemas.openxmlformats.org/drawingml/2006/main";,
+                            FSEND);
+        pFS->startElementNS(XML_a, XML_graphicData,
+                            XML_uri, pNamespace,
                             FSEND);
 
-    m_pImpl->m_rExport.OutputDML(xShape);
+        if (bLockedCanvas)
+            pFS->startElementNS(XML_lc, XML_lockedCanvas,
+                                FSNS(XML_xmlns, XML_lc), 
"http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas";,
+                                FSEND);
 
-    if (bLockedCanvas)
-        pFS->endElementNS(XML_lc, XML_lockedCanvas);
-    pFS->endElementNS(XML_a, XML_graphicData);
-    pFS->endElementNS(XML_a, XML_graphic);
+        m_pImpl->m_rExport.OutputDML(xShape);
 
-    // Relative size of the drawing.
-    if (pSdrObject->GetRelativeWidth())
-    {
-        // At the moment drawinglayer objects are always relative from page.
-        pFS->startElementNS(XML_wp14, XML_sizeRelH,
-                            XML_relativeFrom, 
(pSdrObject->GetRelativeWidthRelation() == text::RelOrientation::FRAME ? 
"margin" : "page"),
-                            FSEND);
-        pFS->startElementNS(XML_wp14, XML_pctWidth, FSEND);
-        pFS->writeEscaped(OUString::number(*pSdrObject->GetRelativeWidth() * 
100 * oox::drawingml::PER_PERCENT));
-        pFS->endElementNS(XML_wp14, XML_pctWidth);
-        pFS->endElementNS(XML_wp14, XML_sizeRelH);
-    }
-    if (pSdrObject->GetRelativeHeight())
-    {
-        pFS->startElementNS(XML_wp14, XML_sizeRelV,
-                            XML_relativeFrom, 
(pSdrObject->GetRelativeHeightRelation() == text::RelOrientation::FRAME ? 
"margin" : "page"),
-                            FSEND);
-        pFS->startElementNS(XML_wp14, XML_pctHeight, FSEND);
-        pFS->writeEscaped(OUString::number(*pSdrObject->GetRelativeHeight() * 
100 * oox::drawingml::PER_PERCENT));
-        pFS->endElementNS(XML_wp14, XML_pctHeight);
-        pFS->endElementNS(XML_wp14, XML_sizeRelV);
-    }
+        if (bLockedCanvas)
+            pFS->endElementNS(XML_lc, XML_lockedCanvas);
+        pFS->endElementNS(XML_a, XML_graphicData);
+        pFS->endElementNS(XML_a, XML_graphic);
 
-    endDMLAnchorInline(pFrmFmt);
+        // Relative size of the drawing.
+        if (pSdrObject->GetRelativeWidth())
+        {
+            // At the moment drawinglayer objects are always relative from 
page.
+            pFS->startElementNS(XML_wp14, XML_sizeRelH,
+                                XML_relativeFrom, 
(pSdrObject->GetRelativeWidthRelation() == text::RelOrientation::FRAME ? 
"margin" : "page"),
+                                FSEND);
+            pFS->startElementNS(XML_wp14, XML_pctWidth, FSEND);
+            pFS->writeEscaped(OUString::number(*pSdrObject->GetRelativeWidth() 
* 100 * oox::drawingml::PER_PERCENT));
+            pFS->endElementNS(XML_wp14, XML_pctWidth);
+            pFS->endElementNS(XML_wp14, XML_sizeRelH);
+        }
+        if (pSdrObject->GetRelativeHeight())
+        {
+            pFS->startElementNS(XML_wp14, XML_sizeRelV,
+                                XML_relativeFrom, 
(pSdrObject->GetRelativeHeightRelation() == text::RelOrientation::FRAME ? 
"margin" : "page"),
+                                FSEND);
+            pFS->startElementNS(XML_wp14, XML_pctHeight, FSEND);
+            
pFS->writeEscaped(OUString::number(*pSdrObject->GetRelativeHeight() * 100 * 
oox::drawingml::PER_PERCENT));
+            pFS->endElementNS(XML_wp14, XML_pctHeight);
+            pFS->endElementNS(XML_wp14, XML_sizeRelV);
+        }
+
+        endDMLAnchorInline(pFrmFmt);
+    }
 }
 
 void DocxSdrExport::Impl::textFrameShadow(const SwFrmFmt& rFrmFmt)
@@ -669,7 +672,7 @@ bool 
DocxSdrExport::Impl::isSupportedDMLShape(uno::Reference<drawing::XShape> xS
     bool supported = true;
 
     uno::Reference<lang::XServiceInfo> xServiceInfo(xShape, 
uno::UNO_QUERY_THROW);
-    if (xServiceInfo->supportsService("com.sun.star.drawing.PolyPolygonShape"))
+    if (xServiceInfo->supportsService("com.sun.star.drawing.PolyPolygonShape") 
|| xServiceInfo->supportsService("com.sun.star.drawing.PolyLineShape"))
         supported = false;
 
     return supported;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to