sw/source/core/docnode/ndtbl1.cxx | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-)
New commits: commit f314a882c96cc0e951fecb83be73a03ef3f33da1 Author: Justin Luth <justin_l...@sil.org> AuthorDate: Thu Dec 16 15:36:59 2021 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Dec 20 14:13:53 2021 +0100 related tdf#90805 sw table: ensure border when setting border color When using uno:FrameLineColor to set a table's border color, add hairline borders if there are none at all. Change-Id: Ib2b2f8aff0052dc32b38486c98670ebff3bd6a4d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126923 Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127000 diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx index 964b2cb610f2..d7f3c5419590 100644 --- a/sw/source/core/docnode/ndtbl1.cxx +++ b/sw/source/core/docnode/ndtbl1.cxx @@ -928,6 +928,8 @@ void SwDoc::SetTabLineStyle( const SwCursor& rCursor, GetIDocumentUndoRedo().AppendUndo(std::make_unique<SwUndoAttrTable>(*pTableNd)); } + const SvxBorderLine aHairlineBorder(pColor, SvxBorderLineWidth::Hairline); + for( auto &rU : aUnions ) { SwSelUnion *pUnion = &rU; @@ -946,24 +948,32 @@ void SwDoc::SetTabLineStyle( const SwCursor& rCursor, SwFrameFormat *pFormat = pCell->GetFormat(); std::unique_ptr<SvxBoxItem> aBox(pFormat->GetBox().Clone()); + SvxBorderLine* pTop = const_cast<SvxBorderLine*>(aBox->GetTop()); + SvxBorderLine* pBot = const_cast<SvxBorderLine*>(aBox->GetBottom()); + SvxBorderLine* pLeft = const_cast<SvxBorderLine*>(aBox->GetLeft()); + SvxBorderLine* pRight = const_cast<SvxBorderLine*>(aBox->GetRight()); + if ( !pBorderLine && bSetLine ) { aBox.reset(::GetDfltAttr(RES_BOX)->Clone()); } + else if (pColor && !pBorderLine && !pTop && !pBot && !pLeft && !pRight) + { + aBox->SetLine(&aHairlineBorder, SvxBoxItemLine::TOP); + aBox->SetLine(&aHairlineBorder, SvxBoxItemLine::BOTTOM); + aBox->SetLine(&aHairlineBorder, SvxBoxItemLine::LEFT); + aBox->SetLine(&aHairlineBorder, SvxBoxItemLine::RIGHT); + } else { - if ( aBox->GetTop() ) - ::lcl_SetLineStyle( const_cast<SvxBorderLine*>(aBox->GetTop()), - pColor, pBorderLine ); - if ( aBox->GetBottom() ) - ::lcl_SetLineStyle( const_cast<SvxBorderLine*>(aBox->GetBottom()), - pColor, pBorderLine ); - if ( aBox->GetLeft() ) - ::lcl_SetLineStyle( const_cast<SvxBorderLine*>(aBox->GetLeft()), - pColor, pBorderLine ); - if ( aBox->GetRight() ) - ::lcl_SetLineStyle( const_cast<SvxBorderLine*>(aBox->GetRight()), - pColor, pBorderLine ); + if (pTop) + ::lcl_SetLineStyle(pTop, pColor, pBorderLine); + if (pBot) + ::lcl_SetLineStyle(pBot, pColor, pBorderLine); + if (pLeft) + ::lcl_SetLineStyle(pLeft, pColor, pBorderLine); + if (pRight) + ::lcl_SetLineStyle(pRight, pColor, pBorderLine); } pFormat->SetFormatAttr( *aBox ); }