Kaydet (Commit) 818619b0 authored tarafından Justin Luth's avatar Justin Luth Kaydeden (comit) Miklos Vajna

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/52171Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst e3718197
......@@ -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")
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment