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

Justin Luth justin_luth at sil.org
Sat Apr 28 04:15:44 UTC 2018


 sw/qa/extras/ww8export/data/tdf106062_nonHangingFootnote.odt |binary
 sw/qa/extras/ww8export/ww8export2.cxx                        |    9 +++++++
 sw/source/filter/ww8/ww8par2.cxx                             |   14 +++++++++--
 3 files changed, 21 insertions(+), 2 deletions(-)

New commits:
commit a3783c0af4bd21eb9c001aadc60c660c06a47779
Author: Justin Luth <justin_luth at sil.org>
Date:   Fri Mar 30 21:36:42 2018 +0300

    tdf#106062 ww8import: skip fake tab only on hanging indent
    
    Export has changed, so that it only exports a tab when the
    footnote paragraph has a hanging indent. Adjusting the import
    code to match that change.
    
    Please test with MSO before flagging this patch as a regression.
    Certainly there will be some documents previously saved by LO
    which will now, in LO, show an extra tab character after the footnote.
    Any previously saved document without a hanging indent will display
    this extra tab. However, MSO has always seen that extra tab, so
    these patches are enhancing compatibility.
    
    Change-Id: Id074ca0f3246eaee9807b907757cbeb6f1bbe7b4
    Reviewed-on: https://gerrit.libreoffice.org/52173
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Justin Luth <justin_luth at sil.org>

diff --git a/sw/qa/extras/ww8export/data/tdf106062_nonHangingFootnote.odt b/sw/qa/extras/ww8export/data/tdf106062_nonHangingFootnote.odt
new file mode 100644
index 000000000000..af5e225ea08c
Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf106062_nonHangingFootnote.odt differ
diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx
index bca0d6b745fb..bc9a104740bb 100644
--- a/sw/qa/extras/ww8export/ww8export2.cxx
+++ b/sw/qa/extras/ww8export/ww8export2.cxx
@@ -209,6 +209,15 @@ DECLARE_WW8EXPORT_TEST(testTdf108448_endNote, "tdf108448_endNote.odt")
     CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of paragraphs in Endnote i", 1, getParagraphs(xEndnote) );
 }
 
+DECLARE_WW8EXPORT_TEST(testTdf106062_nonHangingFootnote, "tdf106062_nonHangingFootnote.odt")
+{
+    uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
+    uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY);
+    // This failed, tab between the footnote number and the footnote content was lost on import.
+    CPPUNIT_ASSERT_MESSAGE( "Footnote starts with a tab", xTextRange->getString().startsWith("\t") );
+}
+
 DECLARE_WW8EXPORT_TEST(testTdf116570_exportFootnote, "tdf116570_exportFootnote.odt")
 {
     uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index 56c45f4d5ba5..cb68c03c438d 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -245,10 +245,20 @@ sal_uInt16 SwWW8ImplReader::End_Footnote()
             const OUString &rText = pTNd->GetText();
             if (rText[0] == sChar[0])
             {
+                // Allow MSO to emulate LO footnote text starting at left margin - only meaningful with hanging indent
+                sal_Int32 nFirstLineIndent=0;
+                SfxItemSet aSet( m_rDoc.GetAttrPool(), svl::Items<RES_LR_SPACE, RES_LR_SPACE>{} );
+                if ( pTNd->GetAttr(aSet) )
+                {
+                    const SvxLRSpaceItem* pLRSpace = aSet.GetItem<SvxLRSpaceItem>(RES_LR_SPACE);
+                    if ( pLRSpace )
+                        nFirstLineIndent = pLRSpace->GetTextFirstLineOfst();
+                }
+
                 m_pPaM->GetPoint()->nContent.Assign( pTNd, 0 );
                 m_pPaM->SetMark();
-                // Strip out tabs we may have inserted on export #i24762#
-                if (rText.getLength() > 1 && rText[1] == 0x09)
+                // Strip out aesthetic tabs we may have inserted on export #i24762#
+                if (nFirstLineIndent < 0 && rText.getLength() > 1 && rText[1] == 0x09)
                     ++m_pPaM->GetMark()->nContent;
                 ++m_pPaM->GetMark()->nContent;
                 m_xReffingStck->Delete(*m_pPaM);


More information about the Libreoffice-commits mailing list