diff options
author | Pallavi Jadhav <pallavi.jadhav@synerzip.com> | 2014-05-22 13:31:48 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-05-23 01:33:13 -0500 |
commit | 70f49dc6927f3321e764174bd8050acaff63be32 (patch) | |
tree | 6edf90b17d076da3571fd55916237bb83bafe3c2 | |
parent | 40facc4ea878fb674214af697cc738cdf6573150 (diff) |
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@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/fdo78882.docx | bin | 0 -> 22429 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 15 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 3 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxsdrexport.cxx | 13 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxsdrexport.hxx | 1 |
5 files changed, 30 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fdo78882.docx b/sw/qa/extras/ooxmlexport/data/fdo78882.docx Binary files differnew file mode 100644 index 000000000000..da591f9e75f6 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/fdo78882.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index e348ccd0860c..a508a489423f 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 25019ba10f0a..8a2ac9d391ca 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 c2481c53edb3..50bfb7d82f99 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 d88a204de7c4..8760a6b1cb4e 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(); |