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

Justin Luth justin_luth at sil.org
Sun Apr 8 13:19:54 UTC 2018


 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx |    7 +------
 sw/source/filter/ww8/wrtw8nds.cxx          |   13 ++++++++++++-
 2 files changed, 13 insertions(+), 7 deletions(-)

New commits:
commit 818619b0f2f7813decb26d0b14362dec76a8ff37
Author: Justin Luth <justin_luth at sil.org>
Date:   Fri Mar 30 18:06:17 2018 +0300

    tdf#106062 ooxmlexport: hanging indent ? aesthetic tab : no
    
    By default, LO footnote paragraph style has a hanging indent of .60cm.
    In LO footnotes, the footnote character starts at the hanging indent
    (position 0) and the footnote text "magically" starts at the left margin.
    
    MSO doesn't do any magical formatting so exporting emulates that by
    inserting a tab after the footnote character.
    
    However, that aethetic tab was being inserted after EVERY footnote character,
    regardless of whether the emulation was needed or not. That particularly
    caused problems when the document was originally authored by MSO, which
    typically has no margin or first line indent. In those cases, the
    document is altered by gaining undesirable extra space.
    
    Since the emulation is only of value with a hanging indent that is larger
    than the footnote character, only add the tab when a hanging indent exists.
    (Checking the size of the hanging indent could improve this even more,
    but measuring font size etc adds too much complexity.)
    
    The import code also knows about the fake tab and removes it.
    Follow-up patches will change the import to ONLY remove the fake tab
    if there is a hanging indent. (That is going to cause "regressions"
    because tabs from some previously saved documents will now
    show the "aesthetic tab" - just like MSO does.)
    
    Change-Id: I371da3f2b09f600f027377a36583f91b39425151
    Reviewed-on: https://gerrit.libreoffice.org/52171
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index fac212c3cfe9..fcfea4083551 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -983,12 +983,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf90810, "tdf90810short.docx")
     uno::Reference<text::XFootnote> xFootnote(xFootnoteIdxAcc->getByIndex(0), uno::UNO_QUERY);
     uno::Reference<text::XText> xFootnoteText(xFootnote, uno::UNO_QUERY);
     rtl::OUString sFootnoteText = xFootnoteText->getString();
-    // Original document doesn't have a leading tab in the footnote, but the
-    // export adds one unconditionally.
-    if (mbExported)
-        CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(90), sFootnoteText.getLength());
-    else
-        CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(89), sFootnoteText.getLength());
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(89), sFootnoteText.getLength());
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf89165, "tdf89165.docx")
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 143dd510ab2e..fb8454dd1b83 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -2433,8 +2433,19 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
                 OUString aSnippet( aAttrIter.GetSnippet( aStr, nAktPos + ofs, nLen ) );
                 if ( ( m_nTextTyp == TXT_EDN || m_nTextTyp == TXT_FTN ) && nAktPos == 0 && nLen > 0 )
                 {
+                    // Allow MSO to emulate LO footnote text starting at left margin - only meaningful with hanging indent
+                    sal_Int32 nFirstLineIndent=0;
+                    SfxItemSet aSet( m_pDoc->GetAttrPool(), svl::Items<RES_LR_SPACE, RES_LR_SPACE>{} );
+                    const SwTextNode* pTextNode( rNode.GetTextNode() );
+                    if ( pTextNode && pTextNode->GetAttr(aSet) )
+                    {
+                        const SvxLRSpaceItem* pLRSpace = aSet.GetItem<SvxLRSpaceItem>(RES_LR_SPACE);
+                        if ( pLRSpace )
+                            nFirstLineIndent = pLRSpace->GetTextFirstLineOfst();
+                    }
+
                     // Insert tab for aesthetic purposes #i24762#
-                    if ( m_bAddFootnoteTab && aSnippet[0] != 0x09 )
+                    if ( m_bAddFootnoteTab && nFirstLineIndent < 0 && aSnippet[0] != 0x09 )
                         aSnippet = "\x09" + aSnippet;
                     m_bAddFootnoteTab = false;
                 }


More information about the Libreoffice-commits mailing list