diff options
author | Justin Luth <justin_luth@sil.org> | 2018-07-11 08:18:22 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-07-25 10:18:53 +0200 |
commit | 5fa898acb96fb344b526bd6e3892c4f4fae6e4f8 (patch) | |
tree | ea2dcec638c975fbeeaab422a3ae0aea78d725df /sw/source | |
parent | 84a0cdf166ea9ab5073b085193d0f10958897437 (diff) |
tdf#63561 docx export: "clear" unused inherited tabs
If a style contains tab definitions, then the paragraph inherits
these. They are added to any tabs defined at the paragraph
level. Unwanted inherited tabs must be explicitly removed.
(TODO: LO ought to be inheriting from ALL parents, so the same
logic ought to apply to a style's parent tabs, but currently
LO does not import that way. So the proof unit test looks
different in MSO compared to LO.)
Change-Id: Ida8ed2792482655d512c753fdff8d02062d895a8
Reviewed-on: https://gerrit.libreoffice.org/57255
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
(cherry picked from commit 859a0389b5639397e9c46cd4828a35793bd194f8)
Reviewed-on: https://gerrit.libreoffice.org/57267
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index b7373bfa5235..95de428c320c 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -7711,31 +7711,13 @@ static void impl_WriteTabElement( FSHelperPtr const & pSerializer, void DocxAttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStop ) { - sal_uInt16 nCount = rTabStop.Count(); + const SvxTabStopItem* pInheritedTabs = GetExport().m_pStyAttr ? GetExport().m_pStyAttr->GetItem<SvxTabStopItem>(RES_PARATR_TABSTOP) : nullptr; + const sal_uInt16 nInheritedTabCount = pInheritedTabs ? pInheritedTabs->Count() : 0; + const sal_uInt16 nCount = rTabStop.Count(); // <w:tabs> must contain at least one <w:tab>, so don't write it empty - if( nCount == 0 ) - { - // clear style tabs - otherwise style will override... - if( GetExport().m_pStyAttr ) - { - const SvxTabStopItem* pStyleTabs = GetExport().m_pStyAttr->GetItem<SvxTabStopItem>(RES_PARATR_TABSTOP); - if( pStyleTabs && pStyleTabs->Count() ) - { - m_pSerializer->startElementNS( XML_w, XML_tabs, FSEND ); - for( int i = 0; i < pStyleTabs->Count(); ++i ) - { - m_pSerializer->singleElementNS( XML_w, XML_tab, - FSNS( XML_w, XML_val ), OString("clear"), - FSNS( XML_w, XML_pos ), OString::number(pStyleTabs->At(i).GetTabPos()), - FSEND ); - } - m_pSerializer->endElementNS( XML_w, XML_tabs ); - } - } - + if ( !nCount && !nInheritedTabCount ) return; - } if( nCount == 1 && rTabStop[ 0 ].GetAdjustment() == SvxTabAdjust::Default ) { GetExport().setDefaultTabStop( rTabStop[ 0 ].GetTabPos()); @@ -7744,6 +7726,22 @@ void DocxAttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStop ) m_pSerializer->startElementNS( XML_w, XML_tabs, FSEND ); + // clear unused inherited tabs - otherwise the style will add them back in + sal_Int32 nCurrTab = 0; + for ( sal_uInt16 i = 0; i < nInheritedTabCount; ++i ) + { + while ( nCurrTab < nCount && rTabStop[nCurrTab] < pInheritedTabs->At(i) ) + ++nCurrTab; + + if ( nCurrTab == nCount || pInheritedTabs->At(i) < rTabStop[nCurrTab] ) + { + m_pSerializer->singleElementNS( XML_w, XML_tab, + FSNS( XML_w, XML_val ), OString("clear"), + FSNS( XML_w, XML_pos ), OString::number(pInheritedTabs->At(i).GetTabPos()), + FSEND ); + } + } + for (sal_uInt16 i = 0; i < nCount; i++ ) { if( rTabStop[i].GetAdjustment() != SvxTabAdjust::Default ) |