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 4cd05b29046cfa1a2e68bc49dd849c2651b93cd9 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:17:43 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. Change-Id: I147d23c43e679113c84c21fbfc0c8ac1ca9e51b6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136792 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins (cherry picked from commit 0203485a7f7dd85f8d3e04ce91579051aa89d26a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136760 diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx index b7f2f6f81905..2affe7edd844 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 b4c6865dabdb..45a2027b4e74 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; } @@ -108,6 +109,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; } + void dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText, TextFrameIndex& nOffset) const override; }; diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx index f935e8d8ab93..d9727deabeec 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;