summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2018-08-09 19:44:26 +0300
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-08-10 12:18:39 +0200
commitae74abcd85dc529aeab9e710f18b3089fdf2906f (patch)
treee7cd80084fe2341dcace9cc0e8930490d6e8df03
parent5ccf82642b19728e1cfe8fa11f654e90712c5757 (diff)
tdf#116549 docx export: write "nil" to uninherit a border
If styles would provide a border, then non-borders need to be explicitly written out. Unit tests prove this out for both styles and pragraphs. Change-Id: I4195d38622adc09831f6dad64840a92a42c494b5 Reviewed-on: https://gerrit.libreoffice.org/58803 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport4.cxx5
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport9.cxx5
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx20
3 files changed, 27 insertions, 3 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index ddba448248d4..04f393309ee0 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -660,6 +660,11 @@ DECLARE_OOXMLEXPORT_TEST(testTableCurruption, "tableCurrupt.docx")
return;
CPPUNIT_ASSERT(pXmlDoc) ;
assertXPath(pXmlDoc, "/w:hdr/w:tbl[1]/w:tr[1]/w:tc[1]",1);
+
+ // tdf#116549: header paragraph should not have a bottom border.
+ uno::Reference<text::XText> xHeaderText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName("First Page"), "HeaderText");
+ table::BorderLine2 aHeaderBottomBorder = getProperty<table::BorderLine2>( getParagraphOfText( 1, xHeaderText ), "BottomBorder");
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), aHeaderBottomBorder.LineWidth);
}
DECLARE_OOXMLEXPORT_TEST(testDateControl, "date-control.docx")
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index fca3263616b9..57955e46e7f1 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -767,6 +767,11 @@ DECLARE_OOXMLEXPORT_TEST(testTdf103976, "tdf103976.docx")
uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
// This was 0, table style inheritance went wrong and w:afterLines had priority over w:after.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(convertTwipToMm100(60)), getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), "ParaBottomMargin"));
+
+ // tdf#116549: heading 2 style should not have a bottom border.
+ uno::Reference<beans::XPropertySet> xStyle(getStyles("ParagraphStyles")->getByName("Heading 2"), uno::UNO_QUERY);
+ table::BorderLine2 aBottomBorder = getProperty<table::BorderLine2>(xStyle, "BottomBorder");
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), aBottomBorder.LineWidth);
}
DECLARE_OOXMLEXPORT_TEST(testTdf106001, "tdf106001.docx")
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 9ea5388cbc4b..f97ffe2645a6 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2971,7 +2971,7 @@ static void impl_borderLine( FSHelperPtr const & pSerializer, sal_Int32 elementT
break;
}
}
- else if( rStyleProps == nullptr )
+ else if ( !rStyleProps || !rStyleProps->LineWidth )
// no line, and no line set by the style either:
// there is no need to write the property
return;
@@ -8528,8 +8528,22 @@ void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox )
// Open the paragraph's borders tag
m_pSerializer->startElementNS( XML_w, XML_pBdr, FSEND );
- std::map<SvxBoxItemLine, css::table::BorderLine2> aEmptyMap; // empty styles map
- impl_borders( m_pSerializer, rBox, aOutputBorderOptions, aEmptyMap );
+ std::map<SvxBoxItemLine, css::table::BorderLine2> aStyleBorders;
+ const SvxBoxItem* pInherited = nullptr;
+ if ( GetExport().m_pStyAttr )
+ pInherited = GetExport().m_pStyAttr->GetItem<SvxBoxItem>(RES_BOX);
+ else if ( GetExport().m_pCurrentStyle && GetExport().m_pCurrentStyle->DerivedFrom() )
+ pInherited = GetExport().m_pCurrentStyle->DerivedFrom()->GetAttrSet().GetItem<SvxBoxItem>(RES_BOX);
+
+ if ( pInherited )
+ {
+ aStyleBorders[ SvxBoxItemLine::TOP ] = SvxBoxItem::SvxLineToLine(pInherited->GetTop(), /*bConvert=*/false);
+ aStyleBorders[ SvxBoxItemLine::BOTTOM ] = SvxBoxItem::SvxLineToLine(pInherited->GetBottom(), false);
+ aStyleBorders[ SvxBoxItemLine::LEFT ] = SvxBoxItem::SvxLineToLine(pInherited->GetLeft(), false);
+ aStyleBorders[ SvxBoxItemLine::RIGHT ] = SvxBoxItem::SvxLineToLine(pInherited->GetRight(), false);
+ }
+
+ impl_borders( m_pSerializer, rBox, aOutputBorderOptions, aStyleBorders );
// Close the paragraph's borders tag
m_pSerializer->endElementNS( XML_w, XML_pBdr );