sw/source/core/text/porrst.cxx | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-)
New commits: commit 5a97854375383efe2c506647eeef2e4ef6cd9b73 Author: László Németh <nem...@numbertext.org> AuthorDate: Tue Jan 28 02:29:16 2025 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Feb 6 15:20:52 2025 +0100 tdf#163309 sw: clean-up bookmark boundary mark labels Add white background to the labels for better visibility on colored page/background. Maximize the size of the label in 3 pt to support very narrow fixed line spacing of headings. Follow-up to commit 3393e52be0900ad63ceee0a43cd44d473ec8248a "tdf#163309 sw: show rdf:type as labels on bookmark boundary marks". Change-Id: I986b73892f2caca9ea0c97918db4c45577ada0eb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180810 Reviewed-by: László Németh <nem...@numbertext.org> Tested-by: Jenkins (cherry picked from commit a4af3948e9212ef46149f906e5880f77693cca4b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180828 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx index 0a8bab3d66ea..9331add1e58c 100644 --- a/sw/source/core/text/porrst.cxx +++ b/sw/source/core/text/porrst.cxx @@ -877,11 +877,6 @@ void SwBookmarkPortion::Paint( const SwTextPaintInfo &rInf ) const nTypePos = mnHalfCharWidth * 2; // start label after the opening bracket } - // vertical rdf:type label position for the opening and closing brackets - sal_Int32 fPos = std::get<0>(it) == SwScriptInfo::MarkKind::Start - ? -0.6 * nHeight - : 0.3 * nHeight; - // MarkKind::Point: drawn I-beam (e.g. U+2336) as overlapping ][ if ( std::get<0>(it) == SwScriptInfo::MarkKind::Point ) { @@ -908,34 +903,44 @@ void SwBookmarkPortion::Paint( const SwTextPaintInfo &rInf ) const auto origSize = aTmpSz; // calculate label size - aTmpSz.setHeight( ( 100 * aTmpSz.Height() ) / 250 ); - aTmpSz.setWidth( ( 100 * aTmpSz.Width() ) / 250 ); + aTmpSz.setHeight( std::min( tools::Long(60), 100 * aTmpSz.Height() / 250 ) ); + aTmpSz.setWidth( std::min( tools::Long(60), 100 * aTmpSz.Width() / 250 ) ); + + // vertical rdf:type label position for the opening and closing brackets + sal_Int32 fPos = std::get<0>(it) == SwScriptInfo::MarkKind::Start + ? -0.65 * nHeight + : aTmpSz.Height(); if ( aTmpSz.Width() || aTmpSz.Height() ) { aTmpFont.SetSize( aTmpSz, SwFontScript::Latin ); + auto aTextSize = rInf.GetTextSize(sType); aNewPos.AdjustY(fPos); if ( nDirection == -1 ) { if (bStart) { - nTypePos += rInf.GetTextSize( sType ).Width(); + nTypePos += aTextSize.Width(); bStart = false; } else - nTypePos += rInf.GetTextSize( sType + " " ).Width() + 2 * mnHalfCharWidth; + nTypePos += aTextSize.Width() + + rInf.GetTextSize( " " ).Width() + 2 * mnHalfCharWidth; } aNewPos.AdjustX( nDirection * nTypePos ); const_cast< SwTextPaintInfo& >( rInf ).SetPos( aNewPos ); - rInf.DrawText( sType, *this ); + SwRect aRect( rInf.GetPos(), Size(aTextSize.Width(), -aTextSize.Height() * 0.8) ); + rInf.DrawRect( aRect, true ); // white background + rInf.DrawText( sType, *this ); // label // restore original position aNewPos.AdjustX( -nDirection * nTypePos ); if ( nDirection == 1 ) - nTypePos += rInf.GetTextSize( sType + " " ).Width() - mnHalfCharWidth * 2; + nTypePos += aTextSize.Width() + + rInf.GetTextSize( " " ).Width() - mnHalfCharWidth * 2; aNewPos.AdjustY(-fPos); }