include/sfx2/charmapcontainer.hxx        |   17 ++---------------
 include/sfx2/charwin.hxx                 |   22 +++++++++++++++++++---
 sfx2/inc/charmapcontrol.hxx              |    2 +-
 sfx2/source/control/charmapcontainer.cxx |   16 +++++++++++++++-
 sfx2/source/control/charmapcontrol.cxx   |    6 +++---
 sfx2/source/control/charwin.cxx          |   28 ++++++++++++----------------
 6 files changed, 52 insertions(+), 39 deletions(-)

New commits:
commit fdfb5b726e78f89c2637d164056a83cc6231378d
Author:     Michael Weghorn <[email protected]>
AuthorDate: Fri Dec 19 15:37:42 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Fri Dec 19 22:52:17 2025 +0100

    tdf#168594 Move InsertCharToDoc logic out of SvxCharView
    
    Move the logic into a static helper method in
    SfxCharmapContainer that takes a CharAndFont param.
    
    This is one more step to prepare porting SfxCharmapCtrl away
    from using SvxCharView in an upcoming commit.
    
    Change-Id: I1345be314ef033ef4aa9c9dfbb2b7e12b8103191
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195929
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/include/sfx2/charmapcontainer.hxx 
b/include/sfx2/charmapcontainer.hxx
index 88da6d358ee9..22b33790f05b 100644
--- a/include/sfx2/charmapcontainer.hxx
+++ b/include/sfx2/charmapcontainer.hxx
@@ -88,6 +88,7 @@ public:
     void GrabFocusToFirstFavorite();
 
     static OUString GetCharInfoText(std::u16string_view sCharText);
+    static void InsertCharToDoc(const CharAndFont& rChar);
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/include/sfx2/charwin.hxx b/include/sfx2/charwin.hxx
index 9e2c7a9807a3..acf9afb2d9a3 100644
--- a/include/sfx2/charwin.hxx
+++ b/include/sfx2/charwin.hxx
@@ -61,6 +61,8 @@ private:
     virtual bool Command(const CommandEvent&) override;
     virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
 
+    void InsertCharToDoc();
+
 public:
     SvxCharView(const VclPtr<VirtualDevice>& rVirDev);
     SFX2_DLLPUBLIC virtual ~SvxCharView() override;
@@ -69,9 +71,9 @@ public:
     vcl::Font const & GetFont() const { return maFont; }
     void            SetText( const OUString& rText );
     OUString const & GetText() const { return m_sText; }
+    CharAndFont GetCharAndFont() const;
     void SetToolTip(const OUString& rToolTip) { m_sToolTip = rToolTip; };
     void            SetHasInsert( bool bInsert );
-    void            InsertCharToDoc();
 
     Size            get_preferred_size() const { return 
GetDrawingArea()->get_preferred_size(); }
 
diff --git a/sfx2/source/control/charmapcontainer.cxx 
b/sfx2/source/control/charmapcontainer.cxx
index b02a8734ddca..bc5cbfa360dd 100644
--- a/sfx2/source/control/charmapcontainer.cxx
+++ b/sfx2/source/control/charmapcontainer.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <comphelper/dispatchcommand.hxx>
+#include <comphelper/propertyvalue.hxx>
 #include <officecfg/Office/Common.hxx>
 #include <charmapcontrol.hxx>
 #include <charmappopup.hxx>
@@ -449,4 +450,17 @@ OUString 
SfxCharmapContainer::GetCharInfoText(std::u16string_view sCharText)
     return OUString();
 }
 
+void SfxCharmapContainer::InsertCharToDoc(const CharAndFont& rChar)
+{
+    if (rChar.sChar.isEmpty())
+        return;
+
+    uno::Sequence<beans::PropertyValue> aArgs{
+        comphelper::makePropertyValue(u"Symbols"_ustr, rChar.sChar),
+        comphelper::makePropertyValue(u"FontName"_ustr, rChar.sFont)
+    };
+
+    comphelper::dispatchCommand(u".uno:InsertSymbol"_ustr, aArgs);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/sfx2/source/control/charmapcontrol.cxx 
b/sfx2/source/control/charmapcontrol.cxx
index 8ad2f89a8b2d..d3e520f53f3a 100644
--- a/sfx2/source/control/charmapcontrol.cxx
+++ b/sfx2/source/control/charmapcontrol.cxx
@@ -59,7 +59,7 @@ IMPL_LINK(SfxCharmapCtrl, CharClickHdl, SvxCharView&, rView, 
void)
 {
     m_xControl->EndPopupMode();
 
-    rView.InsertCharToDoc();
+    SfxCharmapContainer::InsertCharToDoc(rView.GetCharAndFont());
 }
 
 IMPL_LINK_NOARG(SfxCharmapCtrl, OpenDlgHdl, weld::Button&, void)
diff --git a/sfx2/source/control/charwin.cxx b/sfx2/source/control/charwin.cxx
index c650aa0bd8b6..9cb1101b23cd 100644
--- a/sfx2/source/control/charwin.cxx
+++ b/sfx2/source/control/charwin.cxx
@@ -24,8 +24,7 @@
 #include <vcl/svapp.hxx>
 #include <vcl/weld/weldutils.hxx>
 #include <sfx2/charwin.hxx>
-#include <comphelper/dispatchcommand.hxx>
-#include <comphelper/propertyvalue.hxx>
+#include <sfx2/charmapcontainer.hxx>
 
 #include <com/sun/star/beans/PropertyValue.hpp>
 
@@ -112,18 +111,7 @@ bool SvxCharView::Command(const CommandEvent& 
rCommandEvent)
     return weld::CustomWidgetController::Command(rCommandEvent);
 }
 
-void SvxCharView::InsertCharToDoc()
-{
-    if (GetText().isEmpty())
-        return;
-
-    uno::Sequence<beans::PropertyValue> aArgs{
-        comphelper::makePropertyValue(u"Symbols"_ustr, GetText()),
-        comphelper::makePropertyValue(u"FontName"_ustr, maFont.GetFamilyName())
-    };
-
-    comphelper::dispatchCommand(u".uno:InsertSymbol"_ustr, aArgs);
-}
+void SvxCharView::InsertCharToDoc() { 
SfxCharmapContainer::InsertCharToDoc(GetCharAndFont()); }
 
 void SvxCharView::Paint(vcl::RenderContext& rRenderContext, const 
tools::Rectangle&)
 {
@@ -259,6 +247,11 @@ void SvxCharView::SetText(const OUString& rText)
     Invalidate();
 }
 
+CharAndFont SvxCharView::GetCharAndFont() const
+{
+    return CharAndFont(GetText(), GetFont().GetFamilyName());
+}
+
 void SvxCharView::SetHasInsert(bool bInsert) { maHasInsert = bInsert; }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
commit bebdf3ff5ac53a6db916389f70b743efb3c08fc6
Author:     Michael Weghorn <[email protected]>
AuthorDate: Fri Dec 19 15:14:23 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Fri Dec 19 22:52:09 2025 +0100

    tdf#168594 Change SvxCharView focus callback param to CharAndFont
    
    What exact widget received focus is not of interest, but
    only what special character is newly focused.
    
    Therefore, switch the param of the handler from SvxCharView
    to CharAndFont (and move that struct into the charwin.hxx
    header, to be able to use it there).
    
    This is one more step to prepare porting SfxCharmapCtrl away
    from using SvxCharView in an upcoming commit.
    
    Change-Id: I4b582e7b3e8564253f9016d8813adf6f6e25b191
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195928
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/include/sfx2/charmapcontainer.hxx 
b/include/sfx2/charmapcontainer.hxx
index 77c9852296e3..88da6d358ee9 100644
--- a/include/sfx2/charmapcontainer.hxx
+++ b/include/sfx2/charmapcontainer.hxx
@@ -29,20 +29,6 @@
 
 class SFX2_DLLPUBLIC SfxCharmapContainer
 {
-    struct CharAndFont
-    {
-        OUString sChar;
-        OUString sFont;
-
-        CharAndFont(const OUString& rChar, const OUString& rFont)
-            : sChar(rChar)
-            , sFont(rFont)
-        {
-        }
-
-        bool operator==(const CharAndFont& rOther) const = default;
-    };
-
     std::deque<CharAndFont> m_aRecentChars;
     std::deque<CharAndFont> m_aFavChars;
 
@@ -82,7 +68,7 @@ public:
 
     void init(bool bHasInsert, const Link<SvxCharView&, void>& rMouseClickHdl,
               const Link<void*, void>& rUpdateFavHdl, const Link<void*, void>& 
rUpdateRecentHdl,
-              const Link<SvxCharView&, void>& rFocusInHdl = Link<SvxCharView&, 
void>());
+              const Link<const CharAndFont&, void>& rFocusInHdl = Link<const 
CharAndFont&, void>());
 
     void getFavCharacterList();
     void updateFavCharControl();
diff --git a/include/sfx2/charwin.hxx b/include/sfx2/charwin.hxx
index d5bbc70a9f5f..9e2c7a9807a3 100644
--- a/include/sfx2/charwin.hxx
+++ b/include/sfx2/charwin.hxx
@@ -24,6 +24,20 @@
 #include <vcl/weld/customweld.hxx>
 #include <vcl/weld/weld.hxx>
 
+struct CharAndFont
+{
+    OUString sChar;
+    OUString sFont;
+
+    CharAndFont(const OUString& rChar, const OUString& rFont)
+        : sChar(rChar)
+        , sFont(rFont)
+    {
+    }
+
+    bool operator==(const CharAndFont& rOther) const = default;
+};
+
 class SAL_DLLPUBLIC_RTTI SvxCharView final : public 
weld::CustomWidgetController
 {
 private:
@@ -33,7 +47,7 @@ private:
     OUString        m_sText;
     OUString        m_sToolTip;
 
-    Link<SvxCharView&, void> maFocusInHdl;
+    Link<const CharAndFont&, void> maFocusInHdl;
     Link<SvxCharView&, void> maMouseClickHdl;
     Link<const CommandEvent&, void> maContextMenuHdl;
 
@@ -61,7 +75,7 @@ public:
 
     Size            get_preferred_size() const { return 
GetDrawingArea()->get_preferred_size(); }
 
-    void setFocusInHdl(const Link<SvxCharView&, void>& rLink);
+    void setFocusInHdl(const Link<const CharAndFont&, void>& rLink);
     void setMouseClickHdl(const Link<SvxCharView&, void>& rLink);
     void setContextMenuHdl(const Link<const CommandEvent&, void>& rLink);
 };
diff --git a/sfx2/inc/charmapcontrol.hxx b/sfx2/inc/charmapcontrol.hxx
index d3e531a52afe..34a21374a142 100644
--- a/sfx2/inc/charmapcontrol.hxx
+++ b/sfx2/inc/charmapcontrol.hxx
@@ -44,7 +44,7 @@ private:
     std::unique_ptr<weld::Button> m_xDlgBtn;
     std::unique_ptr<weld::Label> m_xCharInfoLabel;
 
-    DECL_LINK(CharFocusInHdl, SvxCharView&, void);
+    DECL_LINK(CharFocusInHdl, const CharAndFont&, void);
     DECL_LINK(CharClickHdl, SvxCharView&, void);
     DECL_LINK(OpenDlgHdl, weld::Button&, void);
     DECL_LINK(DlgBtnFocusInHdl, weld::Widget&, void);
diff --git a/sfx2/source/control/charmapcontainer.cxx 
b/sfx2/source/control/charmapcontainer.cxx
index 2ebe854c3541..b02a8734ddca 100644
--- a/sfx2/source/control/charmapcontainer.cxx
+++ b/sfx2/source/control/charmapcontainer.cxx
@@ -112,7 +112,7 @@ SfxCharmapContainer::SfxCharmapContainer(weld::Builder& 
rBuilder, const VclPtr<V
 void SfxCharmapContainer::init(bool bHasInsert, const Link<SvxCharView&, 
void>& rMouseClickHdl,
                                const Link<void*, void>& rUpdateFavHdl,
                                const Link<void*, void>& rUpdateRecentHdl,
-                               const Link<SvxCharView&, void>& rFocusInHdl)
+                               const Link<const CharAndFont&, void>& 
rFocusInHdl)
 {
     m_aUpdateFavHdl = rUpdateFavHdl;
     m_aUpdateRecentHdl = rUpdateRecentHdl;
diff --git a/sfx2/source/control/charmapcontrol.cxx 
b/sfx2/source/control/charmapcontrol.cxx
index ae34823a7821..8ad2f89a8b2d 100644
--- a/sfx2/source/control/charmapcontrol.cxx
+++ b/sfx2/source/control/charmapcontrol.cxx
@@ -50,9 +50,9 @@ SfxCharmapCtrl::~SfxCharmapCtrl()
 {
 }
 
-IMPL_LINK(SfxCharmapCtrl, CharFocusInHdl, SvxCharView&, rView, void)
+IMPL_LINK(SfxCharmapCtrl, CharFocusInHdl, const CharAndFont&, rChar, void)
 {
-    
m_xCharInfoLabel->set_label(SfxCharmapContainer::GetCharInfoText(rView.GetText()));
+    
m_xCharInfoLabel->set_label(SfxCharmapContainer::GetCharInfoText(rChar.sChar));
 }
 
 IMPL_LINK(SfxCharmapCtrl, CharClickHdl, SvxCharView&, rView, void)
diff --git a/sfx2/source/control/charwin.cxx b/sfx2/source/control/charwin.cxx
index a89736df76ab..c650aa0bd8b6 100644
--- a/sfx2/source/control/charwin.cxx
+++ b/sfx2/source/control/charwin.cxx
@@ -56,7 +56,7 @@ void SvxCharView::GetFocus()
 {
     Invalidate();
     if (maFocusInHdl.IsSet())
-        maFocusInHdl.Call(*this);
+        maFocusInHdl.Call(CharAndFont(GetText(), GetFont().GetFamilyName()));
 }
 
 void SvxCharView::LoseFocus() { Invalidate(); }
@@ -220,7 +220,10 @@ void SvxCharView::Paint(vcl::RenderContext& 
rRenderContext, const tools::Rectang
         rRenderContext.SetFont(aOrigFont);
 }
 
-void SvxCharView::setFocusInHdl(const Link<SvxCharView&, void>& rLink) { 
maFocusInHdl = rLink; }
+void SvxCharView::setFocusInHdl(const Link<const CharAndFont&, void>& rLink)
+{
+    maFocusInHdl = rLink;
+}
 
 void SvxCharView::setMouseClickHdl(const Link<SvxCharView&, void>& rLink)
 {

Reply via email to