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

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: 's avatarJustin Luth <justin_luth@sil.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst 5ccf8264
......@@ -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")
......
......@@ -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")
......
......@@ -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 );
......
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