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

Pallavi Jadhav pallavi.jadhav at synerzip.com
Thu May 22 23:33:37 PDT 2014


 sw/qa/extras/ooxmlexport/data/fdo78882.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx     |   15 +++++++++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx |    3 ++-
 sw/source/filter/ww8/docxsdrexport.cxx       |   13 ++++++++++++-
 sw/source/filter/ww8/docxsdrexport.hxx       |    1 +
 5 files changed, 30 insertions(+), 2 deletions(-)

New commits:
commit 70f49dc6927f3321e764174bd8050acaff63be32
Author: Pallavi Jadhav <pallavi.jadhav at synerzip.com>
Date:   Thu May 22 13:31:48 2014 +0530

    fdo#78882: DOCX: File gets corrupt after Roundtrip
    
    	Issue :
    	- Document contains a Section break(Next Page) with a drawing.
    	- Section break is manullay adjusted before the drawing.
    	  Hence in original document.xml it wsectPr comes as
    	  a part of w:pPr of paragraph.
    	- But in RT in document.xml, section break is written
    	  by adding a dummy paragraph.
    	- This is because <w:drawing> also contains a paragraph
    	  and hence when encounters section property LO creates
    	  a dummy paragraph and writes it in between runs.
    	- This was causing the corruption.
    
    	Implementation :
    	- Added a member varaible m_bDMLAndVMLDrawingOpen.
    	- It is set to true when it writes drawing.
    	- It's value is checked in DocxAttributeOutput::EndParagraph()
    	  If m_bDMLAndVMLDrawingOpen is true Do Not make
    	  m_bParagraphOpened to false, as one more paragraph is still
    	  open.
    	- This will postpone the writing od Section property and will
    	  be written inside w:pPr and no dummy paragraph will get
    	  created.
    	- Added Export Unit test case.
    
    Change-Id: Ifa26fcaf8f02e62d020339670c8ba58ba92d9f40
    Reviewed-on: https://gerrit.libreoffice.org/9430
    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/fdo78882.docx b/sw/qa/extras/ooxmlexport/data/fdo78882.docx
new file mode 100644
index 0000000..da591f9
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo78882.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index e348ccd..a508a48 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -3466,6 +3466,21 @@ DECLARE_OOXMLEXPORT_TEST(testFdo78651, "fdo78651.docx")
     // ensure that there are only two tables
     assertXPath(pXmlDoc, "//w:tbl", 2);
 }
+
+DECLARE_OOXMLEXPORT_TEST(testfdo78882, "fdo78882.docx")
+{
+    xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+
+    if (!pXmlDoc)
+        return;
+
+    // Ensure that Section Break is getting written inside second paragraph
+    assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[2]/w:pPr[1]/w:sectPr[1]",1);
+
+    // Ensure that no dummy paragarph gets created inside second paragraph for Section Break
+    assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[2]/w:p[1]/w:pPr[1]/w:sectPr[1]",0);
+}
+
 DECLARE_OOXMLEXPORT_TEST(testWordArtWithinDraingtool, "testWordArtWithinDraingtool.docx")
 {
 /*   * Within a file, there is a 2007 wordArt enclosed in a drawing tool
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 25019ba..8a2ac9d 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -414,7 +414,8 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT
     // Check for end of cell, rows, tables here
     FinishTableRowCell( pTextNodeInfoInner );
 
-    m_bParagraphOpened = false;
+    if( !m_rExport.SdrExporter().IsDMLAndVMLDrawingOpen() )
+        m_bParagraphOpened = false;
 
 }
 
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index c2481c5..50bfb7d 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -152,6 +152,7 @@ struct DocxSdrExport::Impl
     sax_fastparser::FastAttributeList* m_pDashLineStyleAttr;
     sal_Int32 m_nId ;
     sal_Int32 m_nSeq ;
+    bool m_bDMLAndVMLDrawingOpen;
 
     Impl(DocxSdrExport& rSdrExport, DocxExport& rExport, sax_fastparser::FSHelperPtr pSerializer, oox::drawingml::DrawingML* pDrawingML)
         : m_rSdrExport(rSdrExport),
@@ -172,7 +173,8 @@ struct DocxSdrExport::Impl
           m_pBodyPrAttrList(0),
           m_pDashLineStyleAttr(0),
           m_nId(0),
-          m_nSeq(0)
+          m_nSeq(0),
+          m_bDMLAndVMLDrawingOpen(false)
     {
     }
 
@@ -247,6 +249,11 @@ bool DocxSdrExport::IsDrawingOpen()
     return m_pImpl->m_bDrawingOpen;
 }
 
+bool DocxSdrExport::IsDMLAndVMLDrawingOpen()
+{
+    return m_pImpl->m_bDMLAndVMLDrawingOpen;
+}
+
 bool DocxSdrExport::IsParagraphHasDrawing()
 {
     return m_pImpl->m_bParagraphHasDrawing;
@@ -795,6 +802,8 @@ bool DocxSdrExport::Impl::isSupportedDMLShape(uno::Reference<drawing::XShape> xS
 
 void DocxSdrExport::writeDMLAndVMLDrawing(const SdrObject* sdrObj, const SwFrmFmt& rFrmFmt,const Point& rNdTopLeft, int nAnchorId)
 {
+    m_pImpl->m_bDMLAndVMLDrawingOpen = true;
+
     // Depending on the shape type, we actually don't write the shape as DML.
     OUString sShapeType;
     sal_uInt32 nMirrorFlags = 0;
@@ -820,6 +829,8 @@ void DocxSdrExport::writeDMLAndVMLDrawing(const SdrObject* sdrObj, const SwFrmFm
     }
     else
         writeVMLDrawing(sdrObj, rFrmFmt, rNdTopLeft);
+
+    m_pImpl->m_bDMLAndVMLDrawingOpen = false;
 }
 
 // Converts ARGB transparency (0..255) to drawingml alpha (opposite, and 0..100000)
diff --git a/sw/source/filter/ww8/docxsdrexport.hxx b/sw/source/filter/ww8/docxsdrexport.hxx
index d88a204..8760a6b 100644
--- a/sw/source/filter/ww8/docxsdrexport.hxx
+++ b/sw/source/filter/ww8/docxsdrexport.hxx
@@ -65,6 +65,7 @@ public:
     bool getFrameBtLr();
 
     bool IsDrawingOpen();
+    bool IsDMLAndVMLDrawingOpen();
     bool IsParagraphHasDrawing();
     void setParagraphHasDrawing(bool bParagraphHasDrawing);
     sax_fastparser::FastAttributeList*& getFlyFillAttrList();


More information about the Libreoffice-commits mailing list