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

umeshkadam umesh.kadam at synerzip.com
Sun Apr 27 11:15:27 PDT 2014


 sw/qa/extras/ooxmlexport/data/fdo77718.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx    |   34 +++++++++++++++++++++++++++-
 sw/source/filter/ww8/docxsdrexport.cxx      |   10 ++++----
 sw/source/filter/ww8/docxsdrexport.hxx      |    3 +-
 4 files changed, 41 insertions(+), 6 deletions(-)

New commits:
commit 825265f093a844f952d0dd64e5b4de9a1aba3185
Author: umeshkadam <umesh.kadam at synerzip.com>
Date:   Mon Apr 21 19:46:00 2014 +0530

    fdo#77718: Picture inside SmartArt changes after RT
    
    - The image data stream for the targets of relId's were getting overwritten,
     therefore the data was getting loss.
    - Added anchor id as part of computing a unique name for images.
    - Added UT for the same.
    
    Change-Id: I999ba1b3701ef357641dd0365403a5d7ad8d18aa
    Reviewed-on: https://gerrit.libreoffice.org/9121
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/ooxmlexport/data/fdo77718.docx b/sw/qa/extras/ooxmlexport/data/fdo77718.docx
new file mode 100644
index 0000000..7a22485
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo77718.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 631f415..31fd36b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2748,11 +2748,43 @@ DECLARE_OOXMLEXPORT_TEST(testFdo74792, "fdo74792.docx")
                          comphelper::getComponentContext(m_xSFactory), m_aTempFile.GetURL());
 
     //check that images are also saved
-    OUString sImageFile( "word/media/OOXDiagramDataRels0.jpeg" );
+    OUString sImageFile( "word/media/OOXDiagramDataRels1_0.jpeg" ); //added anchor id to form a uniqe name
     uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName( sImageFile ), uno::UNO_QUERY);
     CPPUNIT_ASSERT( xInputStream.is() );
 }
 
+DECLARE_OOXMLEXPORT_TEST(testFdo77718, "fdo77718.docx")
+{
+    //in case of multiple smart arts the names for images were getting
+    //repeated and thereby causing a data loss as the binary stream was
+    //getting over written. This test case ensures that unique names are
+    //given for images in different smart arts.
+    xmlDocPtr pXmlDataRels1 = parseExport("word/diagrams/_rels/data1.xml.rels");
+    if( !pXmlDataRels1 )
+        return;
+
+    xmlDocPtr pXmlDataRels2 = parseExport("word/diagrams/_rels/data2.xml.rels");
+    if( !pXmlDataRels2 )
+        return;
+
+    //ensure that the rels file is present.
+    assertXPath(pXmlDataRels1,"/rels:Relationships/rels:Relationship", 4);
+    assertXPath(pXmlDataRels2,"/rels:Relationships/rels:Relationship", 4);
+
+    uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(
+                         comphelper::getComponentContext(m_xSFactory), m_aTempFile.GetURL());
+
+    //check that images are also saved
+    OUString sImageFile1( "word/media/OOXDiagramDataRels1_0.jpeg" ); //added anchor id to form a uniqe name
+    uno::Reference<io::XInputStream> xInputStream1(xNameAccess->getByName( sImageFile1 ), uno::UNO_QUERY);
+    CPPUNIT_ASSERT( xInputStream1.is() );
+
+    //check that images are saved for other smart-arts as well.
+    OUString sImageFile2( "word/media/OOXDiagramDataRels2_0.jpeg" ); //added anchor id to form a uniqe name
+    uno::Reference<io::XInputStream> xInputStream2(xNameAccess->getByName( sImageFile2 ), uno::UNO_QUERY);
+    CPPUNIT_ASSERT( xInputStream2.is() );
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTableCurruption, "tableCurrupt.docx")
 {
     xmlDocPtr pXmlDoc = parseExport("word/header4.xml");
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index da3c9e9..5c5d5a2 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -807,7 +807,8 @@ void DocxSdrExport::writeDMLEffectLst(const SwFrmFmt& rFrmFmt)
 
 void DocxSdrExport::writeDiagramRels(uno::Reference<xml::dom::XDocument> xDom,
                                      uno::Sequence< uno::Sequence< uno::Any > > xRelSeq,
-                                     uno::Reference< io::XOutputStream > xOutStream, const OUString& sGrabBagProperyName)
+                                     uno::Reference< io::XOutputStream > xOutStream, const OUString& sGrabBagProperyName,
+                                     int nAnchorId)
 {
     // add image relationships of OOXData, OOXDiagram
     OUString sType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image");
@@ -838,7 +839,8 @@ void DocxSdrExport::writeDiagramRels(uno::Reference<xml::dom::XDocument> xDom,
         uno::Reference<io::XInputStream> dataImagebin(new ::comphelper::SequenceInputStream(dataSeq));
 
         OUString sFragment("../media/");
-        sFragment += sGrabBagProperyName + OUString::number(j) + sExtension;
+        //nAnchorId is used to make the name unique irrespective of the number of smart arts.
+        sFragment += sGrabBagProperyName + OUString::number(nAnchorId) + "_" + OUString::number(j) + sExtension;
 
         PropertySet aProps(xOutStream);
         aProps.setAnyProperty(PROP_RelId, uno::makeAny(sal_Int32(sRelId.toInt32())));
@@ -1021,7 +1023,7 @@ void DocxSdrExport::writeDiagram(const SdrObject* sdrObject, const SwFrmFmt& rFr
                           uno::Sequence< beans::StringPair >());
 
     // write the associated Images and rels for data file
-    writeDiagramRels(dataDom, xDataRelSeq, xDataOutputStream, OUString("OOXDiagramDataRels"));
+    writeDiagramRels(dataDom, xDataRelSeq, xDataOutputStream, OUString("OOXDiagramDataRels"), nAnchorId);
 
     // write layout file
     serializer.set(layoutDom, uno::UNO_QUERY);
@@ -1058,7 +1060,7 @@ void DocxSdrExport::writeDiagram(const SdrObject* sdrObject, const SwFrmFmt& rFr
         // write the associated Images and rels for drawing file
         uno::Sequence< uno::Sequence< uno::Any > > xDrawingRelSeq;
         diagramDrawing[1] >>= xDrawingRelSeq;
-        writeDiagramRels(drawingDom, xDrawingRelSeq, xDrawingOutputStream, OUString("OOXDiagramDrawingRels"));
+        writeDiagramRels(drawingDom, xDrawingRelSeq, xDrawingOutputStream, OUString("OOXDiagramDrawingRels"), nAnchorId);
     }
 }
 
diff --git a/sw/source/filter/ww8/docxsdrexport.hxx b/sw/source/filter/ww8/docxsdrexport.hxx
index dced28c..32a5644 100644
--- a/sw/source/filter/ww8/docxsdrexport.hxx
+++ b/sw/source/filter/ww8/docxsdrexport.hxx
@@ -87,7 +87,8 @@ public:
     void writeDiagram(const SdrObject* sdrObject, const SwFrmFmt& rFrmFmt, int nAnchorId);
     void writeDiagramRels(com::sun::star::uno::Reference< com::sun::star::xml::dom::XDocument> xDom,
                           com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< com::sun::star::uno::Any > > xRelSeq,
-                          com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > xOutStream, const OUString& sGrabBagProperyName);
+                          com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > xOutStream, const OUString& sGrabBagProperyName,
+                          int nAnchorId);
     /// Writes text frame in DML format.
     void writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId);
     /// Writes text frame in VML format.


More information about the Libreoffice-commits mailing list