From 7e92a996d1588bdf2ff1e2df10220a0f57686cfb Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Fri, 23 Mar 2018 12:40:14 +0300 Subject: tdf#116570 ww8 export: skip sectionbreak for footnotes An extra CR was added at the start of each footnote. I'm guessing these documents started life as "end of document" footnotes in Word. SectionBreaksAndFrames is only used by .doc, so this will not affect .docx and .rtf (which are both fine anyway). I forgot that I recently fixed the same problem for endnotes in tdf#108448. Nice to have found example footnote documents also. Change-Id: Ib496e02d9ff46dbc2337a6d3dfe164a625b09a83 Reviewed-on: https://gerrit.libreoffice.org/51771 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- sw/qa/extras/inc/swmodeltestbase.hxx | 18 +++++++++++++----- .../ww8export/data/tdf116570_exportFootnote.odt | Bin 0 -> 16416 bytes sw/qa/extras/ww8export/ww8export2.cxx | 20 +++++++++++--------- sw/source/filter/ww8/wrtww8.cxx | 2 +- 4 files changed, 25 insertions(+), 15 deletions(-) create mode 100644 sw/qa/extras/ww8export/data/tdf116570_exportFootnote.odt diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx index b4b39aad7f27..de9db84162f5 100644 --- a/sw/qa/extras/inc/swmodeltestbase.hxx +++ b/sw/qa/extras/inc/swmodeltestbase.hxx @@ -498,13 +498,14 @@ protected: return aValue; } - /// Get number of paragraphs of the document. - int getParagraphs() + int getParagraphs( uno::Reference const & xText ) { - uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); - uno::Reference xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); - uno::Reference xParaEnum = xParaEnumAccess->createEnumeration(); int nRet = 0; + if ( ! xText.is() ) + return nRet; + + uno::Reference xParaEnumAccess(xText->getText(), uno::UNO_QUERY); + uno::Reference xParaEnum = xParaEnumAccess->createEnumeration(); while (xParaEnum->hasMoreElements()) { xParaEnum->nextElement(); @@ -513,6 +514,13 @@ protected: return nRet; } + /// Get number of paragraphs of the document. + int getParagraphs() + { + uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); + return getParagraphs( xTextDocument->getText() ); + } + uno::Reference getParagraphOrTable(int number, uno::Reference const & xText = uno::Reference()) const { assert(number != 0); // this thing is 1-based diff --git a/sw/qa/extras/ww8export/data/tdf116570_exportFootnote.odt b/sw/qa/extras/ww8export/data/tdf116570_exportFootnote.odt new file mode 100644 index 000000000000..c1598eb71c9f Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf116570_exportFootnote.odt differ diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx index ab640d848931..bca0d6b745fb 100644 --- a/sw/qa/extras/ww8export/ww8export2.cxx +++ b/sw/qa/extras/ww8export/ww8export2.cxx @@ -206,15 +206,17 @@ DECLARE_WW8EXPORT_TEST(testTdf108448_endNote, "tdf108448_endNote.odt") uno::Reference xEndnote; xEndnotes->getByIndex(0) >>= xEndnote; - uno::Reference xParaEnumAccess(xEndnote->getText(), uno::UNO_QUERY); - uno::Reference xParaEnum = xParaEnumAccess->createEnumeration(); - int nRet = 0; - while (xParaEnum->hasMoreElements()) - { - xParaEnum->nextElement(); - nRet++; - } - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of paragraphs in Endnote i", 1, nRet ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of paragraphs in Endnote i", 1, getParagraphs(xEndnote) ); +} + +DECLARE_WW8EXPORT_TEST(testTdf116570_exportFootnote, "tdf116570_exportFootnote.odt") +{ + uno::Reference xFootnotesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY); + uno::Reference xFootnoteText; + xFootnotes->getByIndex(0) >>= xFootnoteText; + + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of paragraphs in first footnote", 2, getParagraphs(xFootnoteText) ); } DECLARE_WW8EXPORT_TEST(testTdf112074_RTLtableJustification, "tdf112074_RTLtableJustification.doc") diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index e4553b6217f3..ce893b951085 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -2706,7 +2706,7 @@ void MSWordExportBase::WriteText() SwNode& rNd = m_pCurPam->GetNode(); // no section breaks exported for Endnotes - if ( rNd.IsTextNode() && m_nTextTyp != TXT_EDN ) + if ( rNd.IsTextNode() && m_nTextTyp != TXT_EDN && m_nTextTyp != TXT_FTN ) { SwSoftPageBreakList breakList; // if paragraph need to be split than handle section break somewhere -- cgit v1.2.3