summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2021-12-16 15:36:59 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2021-12-20 14:13:53 +0100
commitf314a882c96cc0e951fecb83be73a03ef3f33da1 (patch)
treec172e338a019d6006f395aad2b6d7bcd7fe1f6bf
parent68fdfc6013126526f5ba3908c5ad762f18f463cf (diff)
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 <jluth@mail.com> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127000
-rw-r--r--sw/source/core/docnode/ndtbl1.cxx34
1 files changed, 22 insertions, 12 deletions
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 );
}