summaryrefslogtreecommitdiff
path: root/svx/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-05-20 15:22:56 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-05-21 13:25:38 +0200
commit0677d46bcc56c1f6c27b9331662990b38fd452d6 (patch)
treee10c8fb1bc934a3d0868ae4e144ad3631b8c0938 /svx/source
parent119b6876c92e4cdae44583c4b1b1419d3533e3ee (diff)
FmXListBoxCell doesn't need to implement css::awt::XListBox
FmXListBoxCell implements css::awt::XListBox but none of that functionality is needed locally where it is used to pick a value in a cell when edited interactively. As an XInterface a FmXListBoxCell does fall into the script::XEventAttacherManager attach/detach sink-hole so its very difficult to determine if it (and any of its siblings) really need to implement the amount of uno interfaces they actually implement, so this is a little speculative. See https://ask.libreoffice.org/en/question/152691/how-to-populate-combo-box-within-table-control-in-form/ for an example of the ComboBox interaction case which is similar to this ListBox case. The exotic "multiselection" option definitely isn't shown as an option in the property browser for a listbox column in the table control. Change-Id: I7bdc351e615c9df708a30e4396f6f352fabaed36 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94584 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx/source')
-rw-r--r--svx/source/fmcomp/gridcell.cxx255
-rw-r--r--svx/source/inc/gridcell.hxx32
2 files changed, 2 insertions, 285 deletions
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
index 2eef5e666941..0700e03e435c 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -3967,8 +3967,6 @@ FmXListBoxCell::FmXListBoxCell(DbGridColumn* pColumn, std::unique_ptr<DbCellCont
, m_aItemListeners(m_aMutex)
, m_aActionListeners(m_aMutex)
, m_pBox(&static_cast<svt::ListBoxControl&>(m_pCellControl->GetWindow()).get_widget())
- , m_nLines(Application::GetSettings().GetStyleSettings().GetListBoxMaximumLineCount())
- , m_bMulti(false)
{
m_pBox->connect_changed(LINK(this, FmXListBoxCell, ChangedHdl));
}
@@ -3995,257 +3993,8 @@ void FmXListBoxCell::disposing()
FmXTextCell::disposing();
}
-Any SAL_CALL FmXListBoxCell::queryAggregation( const css::uno::Type& _rType )
-{
- Any aReturn = FmXTextCell::queryAggregation(_rType);
-
- if ( !aReturn.hasValue() )
- aReturn = FmXListBoxCell_Base::queryInterface( _rType );
-
- return aReturn;
-}
-
-Sequence< css::uno::Type > SAL_CALL FmXListBoxCell::getTypes( )
-{
- return ::comphelper::concatSequences(
- FmXTextCell::getTypes(),
- FmXListBoxCell_Base::getTypes()
- );
-}
-
IMPLEMENT_GET_IMPLEMENTATION_ID( FmXListBoxCell )
-void SAL_CALL FmXListBoxCell::addItemListener(const Reference< css::awt::XItemListener >& l)
-{
- m_aItemListeners.addInterface( l );
-}
-
-
-void SAL_CALL FmXListBoxCell::removeItemListener(const Reference< css::awt::XItemListener >& l)
-{
- m_aItemListeners.removeInterface( l );
-}
-
-
-void SAL_CALL FmXListBoxCell::addActionListener(const Reference< css::awt::XActionListener >& l)
-{
- m_aActionListeners.addInterface( l );
-}
-
-
-void SAL_CALL FmXListBoxCell::removeActionListener(const Reference< css::awt::XActionListener >& l)
-{
- m_aActionListeners.removeInterface( l );
-}
-
-void SAL_CALL FmXListBoxCell::addItem(const OUString& aItem, sal_Int16 nPos)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
- if (m_pBox)
- m_pBox->insert_text(nPos, aItem);
-}
-
-void SAL_CALL FmXListBoxCell::addItems(const css::uno::Sequence<OUString>& aItems, sal_Int16 nPos)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
- if (m_pBox)
- {
- sal_uInt16 nP = nPos;
- for ( const auto& rItem : aItems )
- {
- m_pBox->insert_text(nP, rItem);
- if ( nPos != -1 ) // Not if 0xFFFF, because LIST_APPEND
- nP++;
- }
- }
-}
-
-void SAL_CALL FmXListBoxCell::removeItems(sal_Int16 nPos, sal_Int16 nCount)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
- if ( m_pBox )
- {
- for ( sal_uInt16 n = nCount; n; )
- m_pBox->remove( nPos + (--n) );
- }
-}
-
-sal_Int16 SAL_CALL FmXListBoxCell::getItemCount()
-{
- ::osl::MutexGuard aGuard( m_aMutex );
- return m_pBox ? m_pBox->get_count() : 0;
-}
-
-OUString SAL_CALL FmXListBoxCell::getItem(sal_Int16 nPos)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
- return m_pBox ? m_pBox->get_text(nPos) : OUString();
-}
-
-css::uno::Sequence<OUString> SAL_CALL FmXListBoxCell::getItems()
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- css::uno::Sequence<OUString> aSeq;
- if (m_pBox)
- {
- const sal_Int32 nEntries = m_pBox->get_count();
- aSeq = css::uno::Sequence<OUString>( nEntries );
- for ( sal_Int32 n = nEntries; n; )
- {
- --n;
- aSeq.getArray()[n] = m_pBox->get_text( n );
- }
- }
- return aSeq;
-}
-
-sal_Int16 SAL_CALL FmXListBoxCell::getSelectedItemPos()
-{
- ::osl::MutexGuard aGuard( m_aMutex );
- if (m_pBox)
- {
- UpdateFromColumn();
- sal_Int32 nPos = m_pBox->get_active();
- if (nPos > SHRT_MAX || nPos < SHRT_MIN)
- throw std::out_of_range("awt::XListBox::getSelectedItemPos can only return a short");
- return nPos;
- }
- return 0;
-}
-
-Sequence< sal_Int16 > SAL_CALL FmXListBoxCell::getSelectedItemsPos()
-{
- ::osl::MutexGuard aGuard( m_aMutex );
- Sequence<sal_Int16> aSeq;
-
- if (m_pBox)
- {
- UpdateFromColumn();
- auto aSelected = m_pBox->get_selected_rows();
- size_t nSelEntries = aSelected.size();
- aSeq = Sequence<sal_Int16>( nSelEntries );
- for (size_t n = 0; n < nSelEntries; ++n)
- aSeq.getArray()[n] = aSelected[n];
- }
- return aSeq;
-}
-
-OUString SAL_CALL FmXListBoxCell::getSelectedItem()
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- OUString aItem;
-
- if (m_pBox)
- {
- UpdateFromColumn();
- aItem = m_pBox->get_active_text();
- }
-
- return aItem;
-}
-
-css::uno::Sequence<OUString> SAL_CALL FmXListBoxCell::getSelectedItems()
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- css::uno::Sequence<OUString> aSeq;
-
- if (m_pBox)
- {
- UpdateFromColumn();
- auto aSelected = m_pBox->get_selected_rows();
- const size_t nSelEntries = aSelected.size();
- aSeq = css::uno::Sequence<OUString>( nSelEntries );
- for (size_t n = 0; n < nSelEntries; ++n)
- aSeq.getArray()[n] = m_pBox->get_text(aSelected[n]);
- }
- return aSeq;
-}
-
-void SAL_CALL FmXListBoxCell::selectItemPos(sal_Int16 nPos, sal_Bool bSelect)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if (m_pBox)
- {
- if (bSelect)
- m_pBox->select(nPos);
- else
- m_pBox->unselect(nPos);
- }
-}
-
-void SAL_CALL FmXListBoxCell::selectItemsPos(const Sequence< sal_Int16 >& aPositions, sal_Bool bSelect)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if (m_pBox)
- {
- for ( sal_uInt16 n = static_cast<sal_uInt16>(aPositions.getLength()); n; )
- {
- auto nPos = static_cast<sal_uInt16>(aPositions.getConstArray()[--n]);
- if (bSelect)
- m_pBox->select(nPos);
- else
- m_pBox->unselect(nPos);
- }
- }
-}
-
-void SAL_CALL FmXListBoxCell::selectItem(const OUString& aItem, sal_Bool bSelect)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if (m_pBox)
- {
- auto nPos = m_pBox->find_text(aItem);
- if (bSelect)
- m_pBox->select(nPos);
- else
- m_pBox->unselect(nPos);
- }
-}
-
-sal_Bool SAL_CALL FmXListBoxCell::isMutipleMode()
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- return m_bMulti;
-}
-
-void SAL_CALL FmXListBoxCell::setMultipleMode(sal_Bool bMulti)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- m_bMulti = bMulti;
-
- if (m_pBox)
- m_pBox->set_selection_mode(bMulti ? SelectionMode::Multiple : SelectionMode::Single);
-}
-
-sal_Int16 SAL_CALL FmXListBoxCell::getDropDownLineCount()
-{
- ::osl::MutexGuard aGuard( m_aMutex );
- return m_nLines;
-}
-
-void SAL_CALL FmXListBoxCell::setDropDownLineCount(sal_Int16 nLines)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- m_nLines = nLines; // just store it to return it
-}
-
-void SAL_CALL FmXListBoxCell::makeVisible(sal_Int16 nEntry)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if (m_pBox)
- m_pBox->scroll_to_row(nEntry);
-}
-
IMPL_LINK_NOARG(FmXListBoxCell, ChangedHdl, weld::ComboBox&, void)
{
if (!m_pBox || !m_pBox->changed_by_direct_pick())
@@ -4258,8 +4007,8 @@ IMPL_LINK_NOARG(FmXListBoxCell, ChangedHdl, weld::ComboBox&, void)
aEvent.Highlighted = 0;
// with multiple selection 0xFFFF, otherwise the ID
- aEvent.Selected = (m_pBox->get_selected_rows().size() == 1 )
- ? m_pBox->get_active() : 0xFFFF;
+ aEvent.Selected = (m_pBox->get_active() != -1 )
+ ? m_pBox->get_active() : 0xFFFF;
m_aItemListeners.notifyEach( &awt::XItemListener::itemStateChanged, aEvent );
return;
diff --git a/svx/source/inc/gridcell.hxx b/svx/source/inc/gridcell.hxx
index 360e6d83da8a..2e43144fcb1d 100644
--- a/svx/source/inc/gridcell.hxx
+++ b/svx/source/inc/gridcell.hxx
@@ -952,46 +952,16 @@ protected:
};
-typedef ::cppu::ImplHelper1 < css::awt::XListBox
- > FmXListBoxCell_Base;
class FmXListBoxCell final :public FmXTextCell
- ,public FmXListBoxCell_Base
{
public:
FmXListBoxCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl );
- DECLARE_UNO3_AGG_DEFAULTS(FmXListBoxCell, FmXTextCell)
- virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& _rType ) override;
- virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
// OComponentHelper
virtual void SAL_CALL disposing() override;
-// css::awt::XListBox
- virtual void SAL_CALL addItemListener(const css::uno::Reference< css::awt::XItemListener >& l) override;
- virtual void SAL_CALL removeItemListener(const css::uno::Reference< css::awt::XItemListener >& l) override;
- virtual void SAL_CALL addActionListener(const css::uno::Reference< css::awt::XActionListener >& l) override;
- virtual void SAL_CALL removeActionListener(const css::uno::Reference< css::awt::XActionListener >& l) override;
- virtual void SAL_CALL addItem(const OUString& aItem, sal_Int16 nPos) override;
- virtual void SAL_CALL addItems(const css::uno::Sequence< OUString >& aItems, sal_Int16 nPos) override;
- virtual void SAL_CALL removeItems(sal_Int16 nPos, sal_Int16 nCount) override;
- virtual sal_Int16 SAL_CALL getItemCount() override;
- virtual OUString SAL_CALL getItem(sal_Int16 nPos) override;
- virtual css::uno::Sequence< OUString > SAL_CALL getItems() override;
- virtual sal_Int16 SAL_CALL getSelectedItemPos() override;
- virtual css::uno::Sequence< sal_Int16 > SAL_CALL getSelectedItemsPos() override;
- virtual OUString SAL_CALL getSelectedItem() override;
- virtual css::uno::Sequence< OUString > SAL_CALL getSelectedItems() override;
- virtual void SAL_CALL selectItemPos(sal_Int16 nPos, sal_Bool bSelect) override;
- virtual void SAL_CALL selectItemsPos(const css::uno::Sequence< sal_Int16 >& aPositions, sal_Bool bSelect) override;
- virtual void SAL_CALL selectItem(const OUString& aItem, sal_Bool bSelect) override;
- virtual sal_Bool SAL_CALL isMutipleMode() override;
- virtual void SAL_CALL setMultipleMode(sal_Bool bMulti) override;
- virtual sal_Int16 SAL_CALL getDropDownLineCount() override;
- virtual void SAL_CALL setDropDownLineCount(sal_Int16 nLines) override;
- virtual void SAL_CALL makeVisible(sal_Int16 nEntry) override;
-
private:
virtual ~FmXListBoxCell() override;
@@ -1002,8 +972,6 @@ private:
::comphelper::OInterfaceContainerHelper2 m_aItemListeners,
m_aActionListeners;
weld::ComboBox* m_pBox;
- sal_uInt16 m_nLines;
- bool m_bMulti;
};