[Libreoffice-commits] core.git: svx/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Wed Aug 4 13:06:06 UTC 2021


 svx/source/fmcomp/gridcell.cxx |   24 +++++++++---------------
 svx/source/inc/gridcell.hxx    |   14 +++++++-------
 2 files changed, 16 insertions(+), 22 deletions(-)

New commits:
commit 5a925ea8bb0cb305ac05a4f39113465295d1c600
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Aug 4 12:52:19 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Aug 4 15:05:30 2021 +0200

    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>

diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
index cb5129e89326..9b28ac4043a7 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -801,16 +801,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 )
@@ -1920,7 +1916,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);
 }
@@ -2040,7 +2036,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);
 }
@@ -2123,7 +2119,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 )
@@ -2249,7 +2245,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);
 }
@@ -2762,9 +2758,7 @@ 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);
+    m_pWindow->SetEditableReadOnly(false);
 }
 
 CellControllerRef DbFilterField::CreateController() const
diff --git a/svx/source/inc/gridcell.hxx b/svx/source/inc/gridcell.hxx
index 8a0ecc5b52fa..2135f78d0d9a 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
@@ -542,7 +542,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
@@ -562,7 +562,7 @@ private:
     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
@@ -585,7 +585,7 @@ private:
     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
@@ -608,7 +608,7 @@ private:
     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
@@ -632,7 +632,7 @@ private:
     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


More information about the Libreoffice-commits mailing list