include/sfx2/charwin.hxx | 2 +- sfx2/source/control/charmapcontainer.cxx | 4 ++-- sfx2/source/control/charwin.cxx | 6 ++++-- svx/source/dialog/cuicharmap.cxx | 13 ++++++++----- 4 files changed, 15 insertions(+), 10 deletions(-)
New commits: commit cb5e9c8a2f76134cafdcd12ef2748fa9d538b076 Author: Michael Weghorn <[email protected]> AuthorDate: Fri Dec 19 16:45:26 2025 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Fri Dec 19 22:52:33 2025 +0100 tdf#168594 Only care about SvxCharView font family name For the SvxCharView::maFont attributes, only the family name is ever explicitly set from outside, see SvxCharView::UpdateFont. So from a semantic perspective, the widget holds a character's text and font family. Everything else are more or less internal implementation details of how the widget displays a character itself. Therefore, replace SvxCharWin::GetFont by a getter for the font family, SvxCharWin::GetFontFamilyName. Most of the callers of SvxCharview::GetFont also only retrieve the font family from the font. SvxCharacterMap::CharClickHdl is the only exception, but there seems to be no reason for being interested in anything else beyond the font family. Adjust it to only explicitly set the same font family for the other widgets in the "Special Characters" dialog as well. No obvious difference in behavior to before was noticed with this commit in place when clicking on one of the recent or favorite characters in the "Insert" -> "Special Characters..." dialog. This is one more step to prepare porting SfxCharmapCtrl away from using SvxCharView in an upcoming commit. Change-Id: I6189b7c1b78687994d09ee64e99d6c97eb4047ca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195931 Reviewed-by: Michael Weghorn <[email protected]> Tested-by: Jenkins diff --git a/include/sfx2/charwin.hxx b/include/sfx2/charwin.hxx index acf9afb2d9a3..710adf8f615a 100644 --- a/include/sfx2/charwin.hxx +++ b/include/sfx2/charwin.hxx @@ -68,7 +68,7 @@ public: SFX2_DLLPUBLIC virtual ~SvxCharView() override; void UpdateFont(const OUString& rFontFamilyName); - vcl::Font const & GetFont() const { return maFont; } + OUString GetFontFamilyName() const { return maFont.GetFamilyName(); } void SetText( const OUString& rText ); OUString const & GetText() const { return m_sText; } CharAndFont GetCharAndFont() const; diff --git a/sfx2/source/control/charmapcontainer.cxx b/sfx2/source/control/charmapcontainer.cxx index bc5cbfa360dd..16198aba9162 100644 --- a/sfx2/source/control/charmapcontainer.cxx +++ b/sfx2/source/control/charmapcontainer.cxx @@ -349,7 +349,7 @@ IMPL_LINK(SfxCharmapContainer, FavContextMenuHdl, const CommandEvent&, rCmdEvent IMPL_LINK(SfxCharmapContainer, RecentClearClickHdl, SvxCharView&, rView, void) { const OUString& sTitle = rView.GetText(); - OUString sFont = rView.GetFont().GetFamilyName(); + OUString sFont = rView.GetFontFamilyName(); // if recent char to be added is already in list, remove it auto itChar = std::ranges::find(m_aRecentChars, CharAndFont(sTitle, sFont)); @@ -389,7 +389,7 @@ IMPL_LINK_NOARG(SfxCharmapContainer, RecentClearAllClickHdl, SvxCharView&, void) IMPL_LINK(SfxCharmapContainer, FavClearClickHdl, SvxCharView&, rView, void) { - deleteFavCharacterFromList(rView.GetText(), rView.GetFont().GetFamilyName()); + deleteFavCharacterFromList(rView.GetText(), rView.GetFontFamilyName()); updateFavCharControl(); } diff --git a/sfx2/source/control/charwin.cxx b/sfx2/source/control/charwin.cxx index 30b5456e45fc..6c6259939b37 100644 --- a/sfx2/source/control/charwin.cxx +++ b/sfx2/source/control/charwin.cxx @@ -55,7 +55,7 @@ void SvxCharView::GetFocus() { Invalidate(); if (maFocusInHdl.IsSet()) - maFocusInHdl.Call(CharAndFont(GetText(), GetFont().GetFamilyName())); + maFocusInHdl.Call(CharAndFont(GetText(), GetFontFamilyName())); } void SvxCharView::LoseFocus() { Invalidate(); } @@ -251,7 +251,7 @@ void SvxCharView::SetText(const OUString& rText) CharAndFont SvxCharView::GetCharAndFont() const { - return CharAndFont(GetText(), GetFont().GetFamilyName()); + return CharAndFont(GetText(), GetFontFamilyName()); } void SvxCharView::SetHasInsert(bool bInsert) { maHasInsert = bInsert; } diff --git a/svx/source/dialog/cuicharmap.cxx b/svx/source/dialog/cuicharmap.cxx index c040370d87ea..cae8cedbc6bd 100644 --- a/svx/source/dialog/cuicharmap.cxx +++ b/svx/source/dialog/cuicharmap.cxx @@ -526,12 +526,18 @@ IMPL_LINK_NOARG(SvxCharacterMap, SearchUpdateHdl, weld::Entry&, void) IMPL_LINK(SvxCharacterMap, CharClickHdl, SvxCharView&, rView, void) { - SetCharFont(rView.GetFont()); + const OUString sFontFamily = rView.GetFontFamilyName(); + vcl::Font aCharFont = GetCharFont(); + aCharFont.SetFamilyName(sFontFamily); + SetCharFont(aCharFont); + m_aShowChar.SetText(rView.GetText()); - m_aShowChar.SetFont(rView.GetFont()); + vcl::Font aShowCharFont = m_aShowChar.GetFont(); + aShowCharFont.SetFamilyName(sFontFamily); + m_aShowChar.SetFont(aShowCharFont); m_aShowChar.Invalidate(); - setFavButtonState(rView.GetText(), rView.GetFont().GetFamilyName()); //check state + setFavButtonState(rView.GetText(), sFontFamily); //check state // Get the hexadecimal code OUString charValue = rView.GetText(); commit c06cb736e5d573bfa4d3a9e7578e090efeb7a4e9 Author: Michael Weghorn <[email protected]> AuthorDate: Fri Dec 19 16:37:25 2025 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Fri Dec 19 22:52:26 2025 +0100 tdf#168594 Let SvxCharView implement basic mouse click logic If the SvxCharView gets clicked, let itself take focus and trigger a repaint. This is basic logic for widgets, so nothing that the dialog containing the widget should have to take care of. Change-Id: Ia8cd874a414ae7767207709c3a4d3056864f7262 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195930 Reviewed-by: Michael Weghorn <[email protected]> Tested-by: Jenkins diff --git a/sfx2/source/control/charwin.cxx b/sfx2/source/control/charwin.cxx index 9cb1101b23cd..30b5456e45fc 100644 --- a/sfx2/source/control/charwin.cxx +++ b/sfx2/source/control/charwin.cxx @@ -76,6 +76,8 @@ bool SvxCharView::MouseButtonDown(const MouseEvent& rMEvt) InsertCharToDoc(); } + GrabFocus(); + Invalidate(); maMouseClickHdl.Call(*this); return true; } diff --git a/svx/source/dialog/cuicharmap.cxx b/svx/source/dialog/cuicharmap.cxx index cc11ee93f608..c040370d87ea 100644 --- a/svx/source/dialog/cuicharmap.cxx +++ b/svx/source/dialog/cuicharmap.cxx @@ -526,8 +526,6 @@ IMPL_LINK_NOARG(SvxCharacterMap, SearchUpdateHdl, weld::Entry&, void) IMPL_LINK(SvxCharacterMap, CharClickHdl, SvxCharView&, rView, void) { - rView.GrabFocus(); - SetCharFont(rView.GetFont()); m_aShowChar.SetText(rView.GetText()); m_aShowChar.SetFont(rView.GetFont()); @@ -547,7 +545,6 @@ IMPL_LINK(SvxCharacterMap, CharClickHdl, SvxCharView&, rView, void) m_xDecimalCodeText->set_text(aDecimalText); setCharName(cChar); - rView.Invalidate(); m_xOKBtn->set_sensitive(true); }
