[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - include/svtools reportdesign/source svtools/source svx/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Aug 10 18:26:31 UTC 2021


 include/svtools/brwbox.hxx                   |    1 
 include/svtools/editbrowsebox.hxx            |   26 ++++++
 reportdesign/source/ui/dlg/GroupsSorting.cxx |    4 -
 reportdesign/source/ui/inc/GroupsSorting.hxx |    2 
 svtools/source/brwbox/brwbox2.cxx            |    4 +
 svtools/source/brwbox/ebbcontrols.cxx        |   24 ++++++
 svtools/source/brwbox/editbrowsebox.cxx      |   11 +-
 svx/source/fmcomp/gridcell.cxx               |  103 ++++++++++-----------------
 svx/source/inc/gridcell.hxx                  |   23 +++---
 9 files changed, 114 insertions(+), 84 deletions(-)

New commits:
commit d48afb9ae5d78d40ad826b4f1ed047b0fb93e1e4
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Feb 18 17:22:31 2021 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Aug 10 20:25:49 2021 +0200

    Resolves: tdf#143023 explicitly connect to ControlBase focus-[in/out]
    
    instead of listening to the generic vcl::Window/Control focus events.
    The thing which really gets/loses focus is now a Widget hosted inside
    the ControlBase.
    
    also contains...
    
    fix comment
    
    Change-Id: Ia1783aff3fded7fd73de2b04b9aced647771a92c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119998
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    
    establish that DbCellControl Window member is always a ControlBase
    
    and remove resulting known redundant dynamic_casting
    
    Change-Id: I5f098ef1adee3ad5d2a2bc5fcd30523f980df2f9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119999
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    
    EventWindow is always a svt::ControlBase
    
    update DataBrowser has-focus when child widget loses focus
    
    similar to tdf#135641 case, focus-out becomes an issue with
    the bibliography editor if focus-in is seen on clicking in a cell,
    then click in a GtkEntry and tab around in a circle. Without this
    lose-focus support focus will be grabbed back to the cell of the
    initial click on a circuit of the focus-cycle
    
    Change-Id: I36288ed21dc4357c077f8dee55b55abf2457c2a6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111157
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit 422a8c3218b484817a8723b57fe9845d6abb83f4)
    
    reportdesigner focus out handler clobbering the preexisting handler
    
    set by the databrowser, so chain one after the other
    
    Change-Id: I5aa16635031be425b9354e5a2d6b891a81d54e55
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111384
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit 731f08e5a84817dbc3c6be6e670025d51f39cd61)
    
    Change-Id: I012d0bea687aa6d5965a4e2f6ce3899bfc629f1b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120006
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at allotropia.de>

diff --git a/include/svtools/brwbox.hxx b/include/svtools/brwbox.hxx
index b865b0957129..c14ecdb84a07 100644
--- a/include/svtools/brwbox.hxx
+++ b/include/svtools/brwbox.hxx
@@ -588,6 +588,7 @@ public:
     tools::Rectangle       GetControlArea() const;
     virtual bool    ProcessKey(const KeyEvent& rEvt);
     virtual void    ChildFocusIn();
+    virtual void    ChildFocusOut();
     void            Dispatch( sal_uInt16 nId );
     void            SetMode( BrowserMode nMode );
     BrowserMode     GetMode( ) const { return m_nCurrentMode; }
diff --git a/include/svtools/editbrowsebox.hxx b/include/svtools/editbrowsebox.hxx
index 34696522bd78..a1badb8cce80 100644
--- a/include/svtools/editbrowsebox.hxx
+++ b/include/svtools/editbrowsebox.hxx
@@ -171,9 +171,26 @@ namespace svt
         virtual void SetEditableReadOnly(bool bReadOnly);
 
         virtual bool ProcessKey(const KeyEvent& rKEvt);
+
+        // chain after the FocusInHdl
+        void SetFocusInHdl(const Link<LinkParamNone*,void>& rHdl)
+        {
+            m_aFocusInHdl = rHdl;
+        }
+
+        // chain after the FocusOutHdl
+        void SetFocusOutHdl(const Link<LinkParamNone*,void>& rHdl)
+        {
+            m_aFocusOutHdl = rHdl;
+        }
+
     protected:
         DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
         DECL_LINK(FocusInHdl, weld::Widget&, void);
+        DECL_LINK(FocusOutHdl, weld::Widget&, void);
+    private:
+        Link<LinkParamNone*,void> m_aFocusInHdl;
+        Link<LinkParamNone*,void> m_aFocusOutHdl;
     };
 
     class SVT_DLLPUBLIC EditControlBase : public ControlBase
@@ -191,6 +208,7 @@ namespace svt
         weld::Entry& get_widget() { return *m_pEntry; }
 
         virtual void connect_changed(const Link<weld::Entry&, void>& rLink) = 0;
+        virtual void connect_focus_out(const Link<weld::Widget&, void>& rLink) = 0;
 
     protected:
         void InitEditControlBase(weld::Entry* pEntry);
@@ -211,6 +229,11 @@ namespace svt
             m_xWidget->connect_changed(rLink);
         }
 
+        virtual void connect_focus_out(const Link<weld::Widget&, void>& rLink) override
+        {
+            m_xWidget->connect_focus_out(rLink);
+        }
+
     protected:
         std::unique_ptr<weld::Entry> m_xWidget;
     };
@@ -696,6 +719,7 @@ namespace svt
         virtual void dispose() override;
 
         virtual void connect_changed(const Link<weld::Entry&, void>& rLink) override;
+        virtual void connect_focus_out(const Link<weld::Widget&, void>& rLink) override;
 
         weld::EntryFormatter& get_formatter();
 
@@ -762,6 +786,7 @@ namespace svt
         weld::PatternFormatter& get_formatter() { return *m_xEntryFormatter; }
 
         virtual void connect_changed(const Link<weld::Entry&, void>& rLink) override;
+        virtual void connect_focus_out(const Link<weld::Widget&, void>& rLink) override;
 
         virtual void dispose() override;
     private:
@@ -995,6 +1020,7 @@ namespace svt
         virtual bool ProcessKey(const KeyEvent& rEvt) override;
 
         virtual void ChildFocusIn() override;
+        virtual void ChildFocusOut() override;
 
         css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleCheckBoxCell(sal_Int32 _nRow, sal_uInt16 _nColumnPos,const TriState& eState);
         bool ControlHasFocus() const;
diff --git a/reportdesign/source/ui/dlg/GroupsSorting.cxx b/reportdesign/source/ui/dlg/GroupsSorting.cxx
index 2aca2085fad5..21fa9e794c06 100644
--- a/reportdesign/source/ui/dlg/GroupsSorting.cxx
+++ b/reportdesign/source/ui/dlg/GroupsSorting.cxx
@@ -374,7 +374,7 @@ void OFieldExpressionControl::lateInit()
         rComboBox.connect_changed(LINK(this,OFieldExpressionControl,CBChangeHdl));
         m_pComboCell->SetHelpId(HID_RPT_FIELDEXPRESSION);
 
-        rComboBox.connect_focus_in(LINK(m_pParent, OGroupsSortingDialog, OnControlFocusGot));
+        m_pComboCell->SetFocusInHdl(LINK(m_pParent, OGroupsSortingDialog, OnControlFocusGot));
 
 
         // set browse mode
@@ -927,7 +927,7 @@ sal_Int32 OGroupsSortingDialog::getColumnDataType(const OUString& _sColumnName)
     return nDataType;
 }
 
-IMPL_LINK_NOARG(OGroupsSortingDialog, OnControlFocusGot, weld::Widget&, void )
+IMPL_LINK_NOARG(OGroupsSortingDialog, OnControlFocusGot, LinkParamNone*, void )
 {
     m_xHelpWindow->set_label(RptResId(STR_RPT_HELP_FIELD));
 }
diff --git a/reportdesign/source/ui/inc/GroupsSorting.hxx b/reportdesign/source/ui/inc/GroupsSorting.hxx
index cd038e6164c4..7b465a5a2034 100644
--- a/reportdesign/source/ui/inc/GroupsSorting.hxx
+++ b/reportdesign/source/ui/inc/GroupsSorting.hxx
@@ -74,7 +74,7 @@ private:
     DECL_LINK( OnWidgetFocusLost, weld::Widget&, void );
     DECL_LINK( OnWidgetFocusGot, weld::Widget&, void );
 
-    DECL_LINK( OnControlFocusGot, weld::Widget&, void );
+    DECL_LINK( OnControlFocusGot, LinkParamNone*, void );
 
     DECL_LINK( LBChangeHdl, weld::ComboBox&, void );
     DECL_LINK( OnFormatAction, const OString&, void );
diff --git a/svtools/source/brwbox/brwbox2.cxx b/svtools/source/brwbox/brwbox2.cxx
index 5424edfb0cf2..f5c9bc618508 100644
--- a/svtools/source/brwbox/brwbox2.cxx
+++ b/svtools/source/brwbox/brwbox2.cxx
@@ -1691,6 +1691,10 @@ void BrowseBox::ChildFocusIn()
 {
 }
 
+void BrowseBox::ChildFocusOut()
+{
+}
+
 void BrowseBox::Dispatch( sal_uInt16 nId )
 {
 
diff --git a/svtools/source/brwbox/ebbcontrols.cxx b/svtools/source/brwbox/ebbcontrols.cxx
index 32c29784ce7b..3989f6d17c7c 100644
--- a/svtools/source/brwbox/ebbcontrols.cxx
+++ b/svtools/source/brwbox/ebbcontrols.cxx
@@ -32,6 +32,7 @@ namespace svt
         m_xWidget->connect_changed(LINK(this, ComboBoxControl, SelectHdl));
         m_xWidget->connect_key_press(LINK(this, ControlBase, KeyInputHdl));
         m_xWidget->connect_focus_in(LINK(this, ControlBase, FocusInHdl));
+        m_xWidget->connect_focus_out(LINK(this, ControlBase, FocusOutHdl));
     }
 
     void ComboBoxControl::dispose()
@@ -118,6 +119,7 @@ namespace svt
         m_xWidget->connect_changed(LINK(this, ListBoxControl, SelectHdl));
         m_xWidget->connect_key_press(LINK(this, ControlBase, KeyInputHdl));
         m_xWidget->connect_focus_in(LINK(this, ControlBase, FocusInHdl));
+        m_xWidget->connect_focus_out(LINK(this, ControlBase, FocusOutHdl));
     }
 
     void ListBoxControl::dispose()
@@ -187,6 +189,7 @@ namespace svt
         InitControlBase(m_xBox.get());
         m_xBox->connect_key_press(LINK(this, ControlBase, KeyInputHdl));
         m_xBox->connect_focus_in(LINK(this, ControlBase, FocusInHdl));
+        m_xBox->connect_focus_out(LINK(this, ControlBase, FocusOutHdl));
         m_xBox->connect_toggled(LINK(this, CheckBoxControl, OnToggle));
     }
 
@@ -339,6 +342,7 @@ namespace svt
         m_pEntry->set_width_chars(1); // so a smaller than default width can be used
         m_pEntry->connect_key_press(LINK(this, ControlBase, KeyInputHdl));
         m_pEntry->connect_focus_in(LINK(this, ControlBase, FocusInHdl));
+        connect_focus_out(LINK(this, ControlBase, FocusOutHdl));
     }
 
     bool ControlBase::ProcessKey(const KeyEvent& rKEvt)
@@ -353,7 +357,14 @@ namespace svt
 
     IMPL_LINK_NOARG(ControlBase, FocusInHdl, weld::Widget&, void)
     {
-        return static_cast<BrowserDataWin*>(GetParent())->GetParent()->ChildFocusIn();
+        m_aFocusInHdl.Call(nullptr);
+        static_cast<BrowserDataWin*>(GetParent())->GetParent()->ChildFocusIn();
+    }
+
+    IMPL_LINK_NOARG(ControlBase, FocusOutHdl, weld::Widget&, void)
+    {
+        m_aFocusOutHdl.Call(nullptr);
+        static_cast<BrowserDataWin*>(GetParent())->GetParent()->ChildFocusOut();
     }
 
     void EditControlBase::dispose()
@@ -393,6 +404,11 @@ namespace svt
         get_formatter().connect_changed(rLink);
     }
 
+    void FormattedControlBase::connect_focus_out(const Link<weld::Widget&, void>& rLink)
+    {
+        get_formatter().connect_focus_out(rLink);
+    }
+
     weld::EntryFormatter& FormattedControlBase::get_formatter()
     {
         return *m_xEntryFormatter;
@@ -531,6 +547,11 @@ namespace svt
         m_xEntryFormatter->connect_changed(rLink);
     }
 
+    void PatternControl::connect_focus_out(const Link<weld::Widget&, void>& rLink)
+    {
+        m_xEntryFormatter->connect_focus_out(rLink);
+    }
+
     void PatternControl::dispose()
     {
         m_xEntryFormatter.reset();
@@ -619,6 +640,7 @@ namespace svt
         InitControlBase(m_xWidget.get());
         m_xWidget->connect_key_press(LINK(this, ControlBase, KeyInputHdl));
         m_xWidget->connect_focus_in(LINK(this, ControlBase, FocusInHdl));
+        m_xWidget->connect_focus_out(LINK(this, ControlBase, FocusOutHdl));
         // so any the natural size doesn't have an effect
         m_xWidget->set_size_request(1, 1);
     }
diff --git a/svtools/source/brwbox/editbrowsebox.cxx b/svtools/source/brwbox/editbrowsebox.cxx
index 71126b5a3f4b..236897d0d96e 100644
--- a/svtools/source/brwbox/editbrowsebox.cxx
+++ b/svtools/source/brwbox/editbrowsebox.cxx
@@ -160,7 +160,6 @@ namespace svt
         nEditCol = 0;
     }
 
-
     VclPtr<BrowserHeader> EditBrowseBox::CreateHeaderBar(BrowseBox* pParent)
     {
         pHeader = imp_CreateHeaderBar(pParent);
@@ -169,20 +168,17 @@ namespace svt
         return pHeader;
     }
 
-
     VclPtr<BrowserHeader> EditBrowseBox::imp_CreateHeaderBar(BrowseBox* pParent)
     {
         return VclPtr<EditBrowserHeader>::Create(pParent);
     }
 
-
     void EditBrowseBox::LoseFocus()
     {
         BrowseBox::LoseFocus();
         DetermineFocus();
     }
 
-
     void EditBrowseBox::GetFocus()
     {
         BrowseBox::GetFocus();
@@ -195,14 +191,12 @@ namespace svt
         DetermineFocus(getRealGetFocusFlags(this));
     }
 
-
     bool EditBrowseBox::SeekRow(sal_Int32 nRow)
     {
         nPaintRow = nRow;
         return true;
     }
 
-
     IMPL_LINK_NOARG(EditBrowseBox, StartEditHdl, void*, void)
     {
         nStartEvent = nullptr;
@@ -418,6 +412,11 @@ namespace svt
         DetermineFocus(getRealGetFocusFlags(this));
     }
 
+    void EditBrowseBox::ChildFocusOut()
+    {
+        DetermineFocus();
+    }
+
     void EditBrowseBox::MouseButtonDown(const BrowserMouseEvent& rEvt)
     {
         // absorb double clicks
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
index 5d508a0fdedf..08ca07962939 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -802,16 +802,12 @@ void DbCellControl::implAdjustReadOnly( const Reference< XPropertySet >& _rxMode
     if ( !(m_pWindow && _rxModel.is()) )
         return;
 
-    ControlBase* pEditWindow = dynamic_cast<ControlBase*>(m_pWindow.get());
-    if ( pEditWindow )
+    bool bReadOnly = m_rColumn.IsReadOnly();
+    if ( !bReadOnly )
     {
-        bool bReadOnly = m_rColumn.IsReadOnly();
-        if ( !bReadOnly )
-        {
-            _rxModel->getPropertyValue( i_bReadOnly ? OUString(FM_PROP_READONLY) : OUString(FM_PROP_ISREADONLY)) >>= bReadOnly;
-        }
-        pEditWindow->SetEditableReadOnly(bReadOnly);
+        _rxModel->getPropertyValue( i_bReadOnly ? OUString(FM_PROP_READONLY) : OUString(FM_PROP_ISREADONLY)) >>= bReadOnly;
     }
+    m_pWindow->SetEditableReadOnly(bReadOnly);
 }
 
 void DbCellControl::implAdjustEnabled( const Reference< XPropertySet >& _rxModel )
@@ -1921,7 +1917,7 @@ void DbNumericField::implAdjustGenericFieldSetting( const Reference< XPropertySe
     rPaintFormatter.SetFormat( sFormatString, aAppLanguage );
 }
 
-VclPtr<Control> DbNumericField::createField(BrowserDataWin* pParent, bool bSpinButton, const Reference<XPropertySet>& /*rxModel*/)
+VclPtr<svt::ControlBase> DbNumericField::createField(BrowserDataWin* pParent, bool bSpinButton, const Reference<XPropertySet>& /*rxModel*/)
 {
     return VclPtr<DoubleNumericControl>::Create(pParent, bSpinButton);
 }
@@ -2041,7 +2037,7 @@ void DbCurrencyField::implAdjustGenericFieldSetting( const Reference< XPropertyS
     rPaintCurrencyFormatter.SetCurrencySymbol(aStr);
 }
 
-VclPtr<Control> DbCurrencyField::createField(BrowserDataWin* pParent, bool bSpinButton, const Reference< XPropertySet >& /*rxModel*/)
+VclPtr<svt::ControlBase> DbCurrencyField::createField(BrowserDataWin* pParent, bool bSpinButton, const Reference< XPropertySet >& /*rxModel*/)
 {
     return VclPtr<LongCurrencyControl>::Create(pParent, bSpinButton);
 }
@@ -2124,7 +2120,7 @@ DbDateField::DbDateField( DbGridColumn& _rColumn )
     doPropertyListening( FM_PROP_DATE_SHOW_CENTURY );
 }
 
-VclPtr<Control> DbDateField::createField(BrowserDataWin* pParent, bool bSpinButton, const Reference< XPropertySet >& rxModel)
+VclPtr<svt::ControlBase> DbDateField::createField(BrowserDataWin* pParent, bool bSpinButton, const Reference< XPropertySet >& rxModel)
 {
     // check if there is a DropDown property set to TRUE
     bool bDropDown =    !hasProperty( FM_PROP_DROPDOWN, rxModel )
@@ -2250,7 +2246,7 @@ DbTimeField::DbTimeField( DbGridColumn& _rColumn )
     doPropertyListening( FM_PROP_STRICTFORMAT );
 }
 
-VclPtr<Control> DbTimeField::createField(BrowserDataWin* pParent, bool bSpinButton, const Reference< XPropertySet >& /*rxModel*/ )
+VclPtr<svt::ControlBase> DbTimeField::createField(BrowserDataWin* pParent, bool bSpinButton, const Reference< XPropertySet >& /*rxModel*/ )
 {
     return VclPtr<TimeControl>::Create(pParent, bSpinButton);
 }
@@ -2763,9 +2759,8 @@ void DbFilterField::Init(BrowserDataWin& rParent, const Reference< XRowSet >& xC
     DbCellControl::Init( rParent, xCursor );
 
     // filter cells are never readonly
-    ControlBase* pAsEdit = dynamic_cast<ControlBase*>(m_pWindow.get());
-    if (pAsEdit)
-        pAsEdit->SetEditableReadOnly(false);
+    if (m_pWindow)
+        m_pWindow->SetEditableReadOnly(false);
 }
 
 CellControllerRef DbFilterField::CreateController() const
@@ -3089,7 +3084,6 @@ IMPL_LINK_NOARG(DbFilterField, OnClick, weld::Button&, void)
     }
 }
 
-
 FmXGridCell::FmXGridCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> _pControl )
             :OComponentHelper(m_aMutex)
             ,m_pColumn(pColumn)
@@ -3102,23 +3096,24 @@ FmXGridCell::FmXGridCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl>
 {
 }
 
-
 void FmXGridCell::init()
 {
-    vcl::Window* pEventWindow( getEventWindow() );
+    svt::ControlBase* pEventWindow( getEventWindow() );
     if ( pEventWindow )
+    {
         pEventWindow->AddEventListener( LINK( this, FmXGridCell, OnWindowEvent ) );
+        pEventWindow->SetFocusInHdl(LINK( this, FmXGridCell, OnFocusGained));
+        pEventWindow->SetFocusOutHdl(LINK( this, FmXGridCell, OnFocusLost));
+    }
 }
 
-
-vcl::Window* FmXGridCell::getEventWindow() const
+svt::ControlBase* FmXGridCell::getEventWindow() const
 {
     if ( m_pCellControl )
         return &m_pCellControl->GetWindow();
     return nullptr;
 }
 
-
 FmXGridCell::~FmXGridCell()
 {
     if (!OComponentHelper::rBHelper.bDisposed)
@@ -3129,14 +3124,12 @@ FmXGridCell::~FmXGridCell()
 
 }
 
-
 void FmXGridCell::SetTextLineColor()
 {
     if (m_pCellControl)
         m_pCellControl->SetTextLineColor();
 }
 
-
 void FmXGridCell::SetTextLineColor(const Color& _rColor)
 {
     if (m_pCellControl)
@@ -3332,78 +3325,62 @@ void SAL_CALL FmXGridCell::removeMouseMotionListener( const Reference< awt::XMou
     m_aMouseMotionListeners.removeInterface( _rxListener );
 }
 
-
 void SAL_CALL FmXGridCell::addPaintListener( const Reference< awt::XPaintListener >& )
 {
     OSL_FAIL( "FmXGridCell::addPaintListener: not implemented" );
 }
 
-
 void SAL_CALL FmXGridCell::removePaintListener( const Reference< awt::XPaintListener >& )
 {
     OSL_FAIL( "FmXGridCell::removePaintListener: not implemented" );
 }
 
-
 IMPL_LINK( FmXGridCell, OnWindowEvent, VclWindowEvent&, _rEvent, void )
 {
     ENSURE_OR_THROW( _rEvent.GetWindow(), "illegal window" );
-    onWindowEvent( _rEvent.GetId(), *_rEvent.GetWindow(), _rEvent.GetData() );
+    onWindowEvent(_rEvent.GetId(), _rEvent.GetData());
 }
 
-
 void FmXGridCell::onFocusGained( const awt::FocusEvent& _rEvent )
 {
     checkDisposed(OComponentHelper::rBHelper.bDisposed);
     m_aFocusListeners.notifyEach( &awt::XFocusListener::focusGained, _rEvent );
 }
 
-
 void FmXGridCell::onFocusLost( const awt::FocusEvent& _rEvent )
 {
     checkDisposed(OComponentHelper::rBHelper.bDisposed);
     m_aFocusListeners.notifyEach( &awt::XFocusListener::focusLost, _rEvent );
 }
 
+IMPL_LINK_NOARG(FmXGridCell, OnFocusGained, LinkParamNone*, void)
+{
+    if (!m_aFocusListeners.getLength())
+        return;
+
+    awt::FocusEvent aEvent;
+    aEvent.Source = *this;
+    aEvent.Temporary = false;
 
-void FmXGridCell::onWindowEvent( const VclEventId _nEventId, const vcl::Window& _rWindow, const void* _pEventData )
+    onFocusGained(aEvent);
+}
+
+IMPL_LINK_NOARG(FmXGridCell, OnFocusLost, LinkParamNone*, void)
 {
-    switch ( _nEventId )
-    {
-    case VclEventId::ControlGetFocus:
-    case VclEventId::WindowGetFocus:
-    case VclEventId::ControlLoseFocus:
-    case VclEventId::WindowLoseFocus:
-    {
-        if  (   (   _rWindow.IsCompoundControl()
-                &&  (   _nEventId == VclEventId::ControlGetFocus
-                    ||  _nEventId == VclEventId::ControlLoseFocus
-                    )
-                )
-            ||  (   !_rWindow.IsCompoundControl()
-                &&  (   _nEventId == VclEventId::WindowGetFocus
-                    ||  _nEventId == VclEventId::WindowLoseFocus
-                    )
-                )
-            )
-        {
-            if ( !m_aFocusListeners.getLength() )
-                break;
+    if (!m_aFocusListeners.getLength())
+        return;
 
-            bool bFocusGained = ( _nEventId == VclEventId::ControlGetFocus ) || ( _nEventId == VclEventId::WindowGetFocus );
+    awt::FocusEvent aEvent;
+    aEvent.Source = *this;
+    aEvent.Temporary = false;
 
-            awt::FocusEvent aEvent;
-            aEvent.Source = *this;
-            aEvent.FocusFlags = static_cast<sal_Int16>(_rWindow.GetGetFocusFlags());
-            aEvent.Temporary = false;
+    onFocusLost(aEvent);
+}
 
-            if ( bFocusGained )
-                onFocusGained( aEvent );
-            else
-                onFocusLost( aEvent );
-        }
-    }
-    break;
+void FmXGridCell::onWindowEvent(const VclEventId _nEventId, const void* _pEventData)
+{
+    switch ( _nEventId )
+    {
     case VclEventId::WindowMouseButtonDown:
     case VclEventId::WindowMouseButtonUp:
     {
diff --git a/svx/source/inc/gridcell.hxx b/svx/source/inc/gridcell.hxx
index 3966a4954a15..6aef3de3fde9 100644
--- a/svx/source/inc/gridcell.hxx
+++ b/svx/source/inc/gridcell.hxx
@@ -211,8 +211,8 @@ private:
 
 protected:
     DbGridColumn&               m_rColumn;
-    VclPtr<vcl::Window>         m_pPainter;
-    VclPtr<vcl::Window>         m_pWindow;
+    VclPtr<svt::ControlBase>    m_pPainter;
+    VclPtr<svt::ControlBase>    m_pWindow;
 
 protected:
     // attribute access
@@ -262,8 +262,7 @@ public:
     DbCellControl(DbGridColumn& _rColumn);
     virtual ~DbCellControl() override;
 
-
-    vcl::Window& GetWindow() const
+    svt::ControlBase& GetWindow() const
     {
         ENSURE_OR_THROW( m_pWindow, "no window" );
         return *m_pWindow;
@@ -545,7 +544,7 @@ public:
     virtual ::svt::CellControllerRef    CreateController() const override;
 
 protected:
-    virtual VclPtr<Control> createField(
+    virtual VclPtr<svt::ControlBase> createField(
                             BrowserDataWin* _pParent,
                             bool bSpinButton,
                             const css::uno::Reference< css::beans::XPropertySet >& _rxModel
@@ -565,7 +564,7 @@ protected:
     virtual void        updateFromModel( css::uno::Reference< css::beans::XPropertySet > _rxModel ) override;
 
     // DbSpinField
-    virtual VclPtr<Control> createField(
+    virtual VclPtr<svt::ControlBase> createField(
                             BrowserDataWin* _pParent,
                             bool bSpinButton,
                             const css::uno::Reference< css::beans::XPropertySet >& _rxModel
@@ -588,7 +587,7 @@ protected:
     virtual void        updateFromModel( css::uno::Reference< css::beans::XPropertySet > _rxModel ) override;
 
     // DbSpinField
-    virtual VclPtr<Control> createField(
+    virtual VclPtr<svt::ControlBase> createField(
                             BrowserDataWin* _pParent,
                             bool bSpinButton,
                             const css::uno::Reference< css::beans::XPropertySet >& _rxModel
@@ -611,7 +610,7 @@ protected:
     virtual void        updateFromModel( css::uno::Reference< css::beans::XPropertySet > _rxModel ) override;
 
     // DbSpinField
-    virtual VclPtr<Control> createField(
+    virtual VclPtr<svt::ControlBase> createField(
                             BrowserDataWin* _pParent,
                             bool bSpinButton,
                             const css::uno::Reference< css::beans::XPropertySet >& _rxModel
@@ -635,7 +634,7 @@ protected:
     virtual void        updateFromModel( css::uno::Reference< css::beans::XPropertySet > _rxModel ) override;
 
     // DbSpinField
-    virtual VclPtr<Control> createField(
+    virtual VclPtr<svt::ControlBase> createField(
                             BrowserDataWin* _pParent,
                             bool bSpinButton,
                             const css::uno::Reference< css::beans::XPropertySet >& _rxModel
@@ -776,14 +775,16 @@ public:
         { m_pCellControl->AlignControl(nAlignment);}
 
 protected:
-    void onWindowEvent( const VclEventId _nEventId, const vcl::Window& _rWindow, const void* _pEventData );
+    void onWindowEvent(const VclEventId _nEventId, const void* _pEventData);
 
     // default implementations call our focus listeners, don't forget to call them if you override this
     virtual void onFocusGained( const css::awt::FocusEvent& _rEvent );
     virtual void onFocusLost( const css::awt::FocusEvent& _rEvent );
 
 private:
-    vcl::Window* getEventWindow() const;
+    svt::ControlBase* getEventWindow() const;
+    DECL_LINK(OnFocusGained, LinkParamNone*, void);
+    DECL_LINK(OnFocusLost, LinkParamNone*, void);
     DECL_LINK( OnWindowEvent, VclWindowEvent&, void );
 };
 


More information about the Libreoffice-commits mailing list