[Libreoffice-commits] core.git: sw/qa sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Aug 10 10:19:05 UTC 2018
sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 5 +++++
sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 5 +++++
sw/source/filter/ww8/docxattributeoutput.cxx | 20 +++++++++++++++++---
3 files changed, 27 insertions(+), 3 deletions(-)
New commits:
commit ae74abcd85dc529aeab9e710f18b3089fdf2906f
Author: Justin Luth <justin_luth at sil.org>
AuthorDate: Thu Aug 9 19:44:26 2018 +0300
Commit: Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Fri Aug 10 12:18:39 2018 +0200
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 at sil.org>
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
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 );
More information about the Libreoffice-commits
mailing list