[Libreoffice-commits] core.git: include/svtools svtools/source svx/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jul 29 19:28:49 UTC 2020
include/svtools/editbrowsebox.hxx | 21 +++++++++++++++++++--
svtools/source/brwbox/ebbcontrols.cxx | 5 +++++
svx/source/fmcomp/gridcell.cxx | 10 +++++-----
3 files changed, 29 insertions(+), 7 deletions(-)
New commits:
commit 28a278e8029ed5d589a948f68abc2ba29c616c1f
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Jul 29 15:56:37 2020 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Jul 29 21:28:01 2020 +0200
move SetReadOnly into ControlBase as SetEditableReadOnly
and cast to that instead of "Edit" and override the Editable controls impls to
do something suitable when called
Change-Id: I24cc02b603e9551df4e3eb39f6cb4839883db777
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99709
Tested-by: Caolán McNamara <caolanm at redhat.com>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/svtools/editbrowsebox.hxx b/include/svtools/editbrowsebox.hxx
index 4e718bc708de..130dae510486 100644
--- a/include/svtools/editbrowsebox.hxx
+++ b/include/svtools/editbrowsebox.hxx
@@ -169,6 +169,8 @@ namespace svt
public:
ControlBase(BrowserDataWin* pParent, const OUString& rUIXMLDescription, const OString& rID);
+ virtual void SetEditableReadOnly(bool bReadOnly);
+
virtual bool ProcessKey(const KeyEvent& rKEvt);
protected:
DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
@@ -179,6 +181,11 @@ namespace svt
public:
EditControlBase(BrowserDataWin* pParent);
+ virtual void SetEditableReadOnly(bool bReadOnly) override
+ {
+ m_pEntry->set_editable(!bReadOnly);
+ }
+
virtual void dispose() override;
weld::Entry& get_widget() { return *m_pEntry; }
@@ -245,7 +252,7 @@ namespace svt
virtual void SetReadOnly( bool bReadOnly ) override
{
- m_rEdit.get_widget().set_editable(!bReadOnly);
+ m_rEdit.SetEditableReadOnly(bReadOnly);
}
virtual sal_Int32 GetMaxTextLen() const override
@@ -332,6 +339,11 @@ namespace svt
public:
MultiLineTextCell(BrowserDataWin* pParent);
+ virtual void SetEditableReadOnly(bool bReadOnly) override
+ {
+ m_xWidget->set_editable(!bReadOnly);
+ }
+
virtual void GetFocus() override;
virtual void dispose() override;
@@ -382,7 +394,7 @@ namespace svt
virtual void SetReadOnly( bool bReadOnly ) override
{
- m_rEdit.get_widget().set_editable(!bReadOnly);
+ m_rEdit.SetEditableReadOnly(bReadOnly);
}
virtual sal_Int32 GetMaxTextLen() const override
@@ -556,6 +568,11 @@ namespace svt
public:
ComboBoxControl(BrowserDataWin* pParent);
+ virtual void SetEditableReadOnly(bool bReadOnly) override
+ {
+ m_xWidget->set_entry_editable(!bReadOnly);
+ }
+
weld::ComboBox& get_widget() { return *m_xWidget; }
virtual void dispose() override;
diff --git a/svtools/source/brwbox/ebbcontrols.cxx b/svtools/source/brwbox/ebbcontrols.cxx
index 96b802bcf2e4..6958a1f63fab 100644
--- a/svtools/source/brwbox/ebbcontrols.cxx
+++ b/svtools/source/brwbox/ebbcontrols.cxx
@@ -303,6 +303,11 @@ namespace svt
{
}
+ void ControlBase::SetEditableReadOnly(bool /*bReadOnly*/)
+ {
+ // expected to be overridden for Entry, TextView or the editable entry part of a ComboBox
+ }
+
EditControlBase::EditControlBase(BrowserDataWin* pParent)
: ControlBase(pParent, "svt/ui/thineditcontrol.ui", "EditControl") // *thin*editcontrol has no frame/border
, m_pEntry(nullptr) // inheritors are expected to call InitEditControlBase
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
index 585abcdc124d..a920477e9f49 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -805,7 +805,7 @@ void DbCellControl::implAdjustReadOnly( const Reference< XPropertySet >& _rxMode
DBG_ASSERT( _rxModel.is(), "DbCellControl::implAdjustReadOnly: invalid model!" );
if ( m_pWindow && _rxModel.is() )
{
- Edit* pEditWindow = dynamic_cast< Edit* >( m_pWindow.get() );
+ ControlBase* pEditWindow = dynamic_cast<ControlBase*>(m_pWindow.get());
if ( pEditWindow )
{
bool bReadOnly = m_rColumn.IsReadOnly();
@@ -813,7 +813,7 @@ void DbCellControl::implAdjustReadOnly( const Reference< XPropertySet >& _rxMode
{
_rxModel->getPropertyValue( i_bReadOnly ? OUString(FM_PROP_READONLY) : OUString(FM_PROP_ISREADONLY)) >>= bReadOnly;
}
- pEditWindow->SetReadOnly(bReadOnly);
+ pEditWindow->SetEditableReadOnly(bReadOnly);
}
}
}
@@ -2748,9 +2748,9 @@ void DbFilterField::Init(BrowserDataWin& rParent, const Reference< XRowSet >& xC
DbCellControl::Init( rParent, xCursor );
// filter cells are never readonly
- Edit* pAsEdit = dynamic_cast< Edit* >( m_pWindow.get() );
- if ( pAsEdit )
- pAsEdit->SetReadOnly( false );
+ ControlBase* pAsEdit = dynamic_cast<ControlBase*>(m_pWindow.get());
+ if (pAsEdit)
+ pAsEdit->SetEditableReadOnly(false);
}
CellControllerRef DbFilterField::CreateController() const
More information about the Libreoffice-commits
mailing list