sw/source/core/text/porexp.cxx | 53 +++++++++++++++++++--------------------- sw/source/core/text/porrst.cxx | 3 +- sw/source/core/text/txthyph.cxx | 15 ++++++++++- 3 files changed, 42 insertions(+), 29 deletions(-)
New commits: commit 1e9a5ee8671f9a48894849d3cba4d65afa181554 Author: Heiko Tietze <tietze.he...@gmail.com> AuthorDate: Thu May 23 14:58:46 2024 +0200 Commit: Heiko Tietze <heiko.tie...@documentfoundation.org> CommitDate: Fri May 24 16:30:31 2024 +0200 Resolves tdf161196 - Visibility of formatting marks * Special indicators such as "°" for no-break space but also "," for zero width space are hidden if non-printable chars are disabled * Special indicators use the same color (NON_PRINTING_CHARACTER_COLOR) * Hard hyphen becomes blueish with non-printable chars on * Hard blank as well as hard hyphen are controlled by Formatting Aids > Non-breaking spaces; and both highlighting and indicator are hidden with non-printable chars off Change-Id: Ifa29371587ba44d825e04368c5f5c5bf7ed94c7f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167987 Tested-by: Jenkins Reviewed-by: Heiko Tietze <heiko.tie...@documentfoundation.org> diff --git a/sw/source/core/text/porexp.cxx b/sw/source/core/text/porexp.cxx index 0884db6fce76..377af4671f2b 100644 --- a/sw/source/core/text/porexp.cxx +++ b/sw/source/core/text/porexp.cxx @@ -213,35 +213,34 @@ void SwBlankPortion::Paint( const SwTextPaintInfo &rInf ) const rInf.DrawViewOpt(*this, PortionType::Blank); SwExpandPortion::Paint(rInf); - if (m_cChar == CHAR_HARDBLANK) + if (rInf.GetOpt().IsViewMetaChars() && rInf.GetOpt().IsHardBlank()) { - if (rInf.GetOpt().IsBlank()) - { - // Draw tilde or degree sign - OUString aMarker = (rInf.GetTextFrame()->GetDoc().getIDocumentSettingAccess() + // Draw tilde or degree sign + OUString aMarker = (m_cChar == CHAR_HARDBLANK ? + rInf.GetTextFrame()->GetDoc().getIDocumentSettingAccess() .get(DocumentSettingId::USE_VARIABLE_WIDTH_NBSP) - ? u"~"_ustr - : u"°"_ustr); - - SwPosSize aMarkerSize(rInf.GetTextSize(aMarker)); - Point aPos(rInf.GetPos()); - - std::shared_ptr<SwRect> pPortionRect = std::make_shared<SwRect>(); - rInf.CalcRect(*this, pPortionRect.get()); - aPos.AdjustX((pPortionRect->Width() / 2) - (aMarkerSize.Width() / 2)); - - SwTextPaintInfo aInf(rInf, &aMarker); - aInf.SetPos(aPos); - SwTextPortion aMarkerPor; - aMarkerPor.Width(aMarkerSize.Width()); - aMarkerPor.Height(aMarkerSize.Height()); - aMarkerPor.SetAscent(GetAscent()); - - Color colorBackup = aInf.GetFont()->GetColor(); - aInf.GetFont()->SetColor(NON_PRINTING_CHARACTER_COLOR); - aInf.DrawText(aMarkerPor, TextFrameIndex(aMarker.getLength()), true); - aInf.GetFont()->SetColor(colorBackup); - } + ? u"~"_ustr + : u"°"_ustr + : u"-"_ustr); //CHAR_HARDHYPHEN + + SwPosSize aMarkerSize(rInf.GetTextSize(aMarker)); + Point aPos(rInf.GetPos()); + + std::shared_ptr<SwRect> pPortionRect = std::make_shared<SwRect>(); + rInf.CalcRect(*this, pPortionRect.get()); + aPos.AdjustX((pPortionRect->Width() / 2) - (aMarkerSize.Width() / 2)); + + SwTextPaintInfo aInf(rInf, &aMarker); + aInf.SetPos(aPos); + SwTextPortion aMarkerPor; + aMarkerPor.Width(aMarkerSize.Width()); + aMarkerPor.Height(aMarkerSize.Height()); + aMarkerPor.SetAscent(GetAscent()); + + Color colorBackup = aInf.GetFont()->GetColor(); + aInf.GetFont()->SetColor(NON_PRINTING_CHARACTER_COLOR); + aInf.DrawText(aMarkerPor, TextFrameIndex(aMarker.getLength()), true); + aInf.GetFont()->SetColor(colorBackup); } } diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx index ff1e029ae141..8f0b89852450 100644 --- a/sw/source/core/text/porrst.cxx +++ b/sw/source/core/text/porrst.cxx @@ -677,7 +677,7 @@ bool SwHiddenTextPortion::Format( SwTextFormatInfo &rInf ) bool SwControlCharPortion::DoPaint(SwTextPaintInfo const& rTextPaintInfo, OUString & rOutString, SwFont & rTmpFont, int &) const { - if (mcChar == CHAR_WJ || !rTextPaintInfo.GetOpt().IsFieldShadings()) + if (mcChar == CHAR_WJ || !rTextPaintInfo.GetOpt().IsViewMetaChars()) { return false; } @@ -696,6 +696,7 @@ bool SwControlCharPortion::DoPaint(SwTextPaintInfo const& rTextPaintInfo, } rTmpFont.SetEscapement( CHAR_ZWSP == mcChar ? DFLT_ESC_AUTO_SUB : -25 ); + rTmpFont.SetColor( NON_PRINTING_CHARACTER_COLOR ); const sal_uInt16 nProp = 40; rTmpFont.SetProportion( nProp ); // a smaller font diff --git a/sw/source/core/text/txthyph.cxx b/sw/source/core/text/txthyph.cxx index a718296e8a2e..98bfc9480c01 100644 --- a/sw/source/core/text/txthyph.cxx +++ b/sw/source/core/text/txthyph.cxx @@ -431,10 +431,23 @@ sal_uInt16 SwSoftHyphPortion::GetViewWidth( const SwTextSizeInfo &rInf ) const */ void SwSoftHyphPortion::Paint( const SwTextPaintInfo &rInf ) const { - if( Width() ) + if ( Width() && rInf.GetOpt().IsViewMetaChars()) { rInf.DrawViewOpt( *this, PortionType::SoftHyphen ); SwExpandPortion::Paint( rInf ); + + OUString aMarker = u"-"_ustr; + SwTextPaintInfo aInf(rInf, &aMarker); + SwTextPortion aMarkerPor; + SwPosSize aMarkerSize(rInf.GetTextSize(aMarker)); + aMarkerPor.Width(aMarkerSize.Width()); + aMarkerPor.Height(aMarkerSize.Height()); + aMarkerPor.SetAscent(GetAscent()); + + Color colorBackup = aInf.GetFont()->GetColor(); + aInf.GetFont()->SetColor(NON_PRINTING_CHARACTER_COLOR); + aInf.DrawText(aMarkerPor, TextFrameIndex(aMarker.getLength()), true); + aInf.GetFont()->SetColor(colorBackup); } }