sw/source/core/text/porfld.cxx | 2 +- sw/source/core/text/porfld.hxx | 3 +++ sw/source/core/text/txtfld.cxx | 7 ++++++- 3 files changed, 10 insertions(+), 2 deletions(-)
New commits: commit 5abd089d601fb745735ad784c1be48a30bdb0a40 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon Jul 4 09:19:35 2022 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Mon Jul 4 13:05:06 2022 +0200 sw content controls, checkbox: reduce left vs right amount of shading mismatch This was a visual problem with all content controls, but most visible with short ones, like checkbox. A content control's layout starts with a field portion (shaded), followed by a content control portion (also shaded). The shading around the checkbox character is not balanced, the left side has more shading. Half of the additional shading is caused by shading for the field portion: avoid this in case we know where will be a content control portion after the field portion. The result is not perfect, but the left/right mismatch for the amount of shading around the checkbox is much better this way. (cherry picked from commit 0203485a7f7dd85f8d3e04ce91579051aa89d26a) Conflicts: sw/source/core/text/porfld.hxx Change-Id: I147d23c43e679113c84c21fbfc0c8ac1ca9e51b6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136795 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx index 6ef492c1b9d5..413e8e4d4171 100644 --- a/sw/source/core/text/porfld.cxx +++ b/sw/source/core/text/porfld.cxx @@ -441,7 +441,7 @@ void SwFieldPortion::Paint( const SwTextPaintInfo &rInf ) const SwFontSave aSave( rInf, m_pFont.get() ); // OSL_ENSURE(GetLen() <= TextFrameIndex(1), "SwFieldPortion::Paint: rest-portion pollution?"); - if( Width() && ( !m_bPlaceHolder || rInf.GetOpt().IsShowPlaceHolderFields() ) ) + if( Width() && ( !m_bPlaceHolder || rInf.GetOpt().IsShowPlaceHolderFields() ) && !m_bContentControl ) { // A very liberal use of the background rInf.DrawViewOpt( *this, PortionType::Field ); diff --git a/sw/source/core/text/porfld.hxx b/sw/source/core/text/porfld.hxx index 519e56f8f58c..ec4757d56ea9 100644 --- a/sw/source/core/text/porfld.hxx +++ b/sw/source/core/text/porfld.hxx @@ -52,6 +52,7 @@ protected: bool m_bReplace : 1; // Used by SwGrfNumPortion const bool m_bPlaceHolder : 1; bool m_bNoLength : 1; // HACK for meta suffix (no CH_TXTATR) + bool m_bContentControl = false; void SetFont( std::unique_ptr<SwFont> pNew ) { m_pFont = std::move(pNew); } bool IsNoLength() const { return m_bNoLength; } @@ -107,6 +108,8 @@ public: // Accessibility: pass information about this portion to the PortionHandler virtual void HandlePortion( SwPortionHandler& rPH ) const override; + + void SetContentControl(bool bContentControl) { m_bContentControl = bContentControl; } }; /** diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx index fc25dc4e9880..efb8d2926bc4 100644 --- a/sw/source/core/text/txtfld.cxx +++ b/sw/source/core/text/txtfld.cxx @@ -406,7 +406,12 @@ SwLinePortion *SwTextFormatter::NewExtraPortion( SwTextFormatInfo &rInf ) } if( !pRet ) { - pRet = new SwFieldPortion( "" ); + auto pFieldPortion = new SwFieldPortion( "" ); + if (pHint->Which() == RES_TXTATR_CONTENTCONTROL) + { + pFieldPortion->SetContentControl(true); + } + pRet = pFieldPortion; rInf.SetLen(TextFrameIndex(1)); } return pRet;