[Libreoffice-commits] core.git: sw/qa sw/source
Justin Luth
justin_luth at sil.org
Wed Jul 11 08:47:53 UTC 2018
sw/qa/extras/ooxmlexport/data/tdf63561_clearTabs.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 8 +++
sw/source/filter/ww8/docxattributeoutput.cxx | 42 ++++++++----------
3 files changed, 28 insertions(+), 22 deletions(-)
New commits:
commit 859a0389b5639397e9c46cd4828a35793bd194f8
Author: Justin Luth <justin_luth at sil.org>
Date: Wed Jul 11 08:18:22 2018 +0300
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 at sil.org>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf63561_clearTabs.docx b/sw/qa/extras/ooxmlexport/data/tdf63561_clearTabs.docx
new file mode 100644
index 000000000000..228b9b5478ba
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf63561_clearTabs.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 1b979bb79cb0..70e46790c5a0 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -56,6 +56,14 @@ DECLARE_OOXMLEXPORT_TEST(testTdf46938_clearTabStop, "tdf46938_clearTabStop.docx"
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty< uno::Sequence<style::TabStop> >(getParagraph(1), "ParaTabStops").getLength());
}
+DECLARE_OOXMLEXPORT_TEST(testTdf63561_clearTabs, "tdf63561_clearTabs.docx")
+{
+ // MSO2013 gives 5,7, and 4 respectively
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty< uno::Sequence<style::TabStop> >(getParagraph(1), "ParaTabStops").getLength());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(3), getProperty< uno::Sequence<style::TabStop> >(getParagraph(3), "ParaTabStops").getLength());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(4), getProperty< uno::Sequence<style::TabStop> >(getParagraph(4), "ParaTabStops").getLength());
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf82065_Ind_start_strict, "tdf82065_Ind_start_strict.docx")
{
uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 1709cd036739..2de8e1b68d04 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -7707,31 +7707,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());
@@ -7740,6 +7722,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 )
More information about the Libreoffice-commits
mailing list