[Libreoffice-commits] core.git: include/vcl toolkit/source vcl/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Tue Nov 26 20:13:55 UTC 2019
include/vcl/lstbox.hxx | 1 +
toolkit/source/awt/vclxwindows.cxx | 7 ++++++-
vcl/source/control/listbox.cxx | 30 ++++++++++++++++++++++++++++++
3 files changed, 37 insertions(+), 1 deletion(-)
New commits:
commit c8afb4000f178badaf63c2f38fd3fbc12ec832f3
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Nov 26 14:05:56 2019 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Nov 26 21:11:48 2019 +0100
tdf#129037 add a way to select multiple entries of a ListBox together
Change-Id: I362a9e9e644e15f0dd3aeb691973a0979d17eeb0
Reviewed-on: https://gerrit.libreoffice.org/83771
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/vcl/lstbox.hxx b/include/vcl/lstbox.hxx
index 4ff5cf071790..9c519b6919dc 100644
--- a/include/vcl/lstbox.hxx
+++ b/include/vcl/lstbox.hxx
@@ -164,6 +164,7 @@ public:
void SelectEntry( const OUString& rStr, bool bSelect = true );
void SelectEntryPos( sal_Int32 nPos, bool bSelect = true );
+ void SelectEntriesPos( const std::vector<sal_Int32>& rPositions, bool bSelect = true );
sal_Int32 GetSelectedEntryCount() const;
OUString GetSelectedEntry( sal_Int32 nSelIndex = 0 ) const;
diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx
index 5645bf099288..50071403d6e5 100644
--- a/toolkit/source/awt/vclxwindows.cxx
+++ b/toolkit/source/awt/vclxwindows.cxx
@@ -1716,19 +1716,24 @@ void VCLXListBox::selectItemsPos( const css::uno::Sequence<sal_Int16>& aPosition
VclPtr< ListBox > pBox = GetAs< ListBox >();
if ( pBox )
{
+ std::vector<sal_Int32> aPositionVec;
+ aPositionVec.reserve(aPositions.getLength());
+
bool bChanged = false;
for ( auto n = aPositions.getLength(); n; )
{
const auto nPos = aPositions.getConstArray()[--n];
if ( pBox->IsEntryPosSelected( nPos ) != bool(bSelect) )
{
- pBox->SelectEntryPos( nPos, bSelect );
+ aPositionVec.push_back(nPos);
bChanged = true;
}
}
if ( bChanged )
{
+ pBox->SelectEntriesPos(aPositionVec, bSelect);
+
// VCL doesn't call select handler after API call.
// ImplCallItemListeners();
diff --git a/vcl/source/control/listbox.cxx b/vcl/source/control/listbox.cxx
index 2de9f387011a..a93a9e52dde4 100644
--- a/vcl/source/control/listbox.cxx
+++ b/vcl/source/control/listbox.cxx
@@ -1071,6 +1071,36 @@ void ListBox::SelectEntryPos( sal_Int32 nPos, bool bSelect )
}
}
+void ListBox::SelectEntriesPos( const std::vector<sal_Int32>& rPositions, bool bSelect )
+{
+ if (!mpImplLB)
+ return;
+
+ bool bCallListeners = false;
+
+ const sal_Int32 nCurrentPos = mpImplLB->GetCurrentPos();
+ const auto nEntryCount = mpImplLB->GetEntryList()->GetEntryCount();
+ const auto nMRUCount = mpImplLB->GetEntryList()->GetMRUCount();
+
+ for (auto nPos : rPositions)
+ {
+ if (0 <= nPos && nPos < nEntryCount)
+ {
+ mpImplLB->SelectEntry(nPos + nMRUCount, bSelect);
+ if (nCurrentPos != nPos && bSelect)
+ bCallListeners = true;
+ }
+ }
+
+ //Only when bSelect == true, send both Selection & Focus events
+ if (bCallListeners)
+ {
+ CallEventListeners(VclEventId::ListboxSelect);
+ if (HasFocus())
+ CallEventListeners(VclEventId::ListboxFocus);
+ }
+}
+
void ListBox::SetEntryData( sal_Int32 nPos, void* pNewData )
{
mpImplLB->SetEntryData( nPos + mpImplLB->GetEntryList()->GetMRUCount(), pNewData );
More information about the Libreoffice-commits
mailing list