summaryrefslogtreecommitdiff
path: root/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/source/deployment/gui/dp_gui_extlistbox.cxx')
-rw-r--r--desktop/source/deployment/gui/dp_gui_extlistbox.cxx36
1 files changed, 19 insertions, 17 deletions
diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
index f66c016ea6a7..7e8bb6a455eb 100644
--- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
+++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
@@ -35,8 +35,10 @@
#include <com/sun/star/system/SystemShellExecute.hpp>
#include <cppuhelper/weakref.hxx>
#include <i18nlangtag/languagetag.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <rtl/ustrbuf.hxx>
+#include <utility>
#include <vcl/event.hxx>
#include <vcl/ptrstyle.hxx>
#include <vcl/svapp.hxx>
@@ -57,7 +59,7 @@ struct FindWeakRef
{
const uno::Reference<deployment::XPackage> m_extension;
- explicit FindWeakRef( uno::Reference<deployment::XPackage> const & ext): m_extension(ext) {}
+ explicit FindWeakRef( uno::Reference<deployment::XPackage> ext): m_extension(std::move(ext)) {}
bool operator () (uno::WeakReference< deployment::XPackage > const & ref);
};
@@ -146,10 +148,10 @@ void Entry_Impl::checkDependencies()
if ( e.Cause >>= depExc )
{
OUStringBuffer aMissingDep( DpResId( RID_STR_ERROR_MISSING_DEPENDENCIES ) );
- for ( const auto& i : std::as_const(depExc.UnsatisfiedDependencies) )
+ for (const auto& i : depExc.UnsatisfiedDependencies)
{
- aMissingDep.append("\n");
- aMissingDep.append(dp_misc::Dependencies::getErrorText(i));
+ aMissingDep.append("\n"
+ + dp_misc::Dependencies::getErrorText(i));
}
aMissingDep.append("\n");
m_sErrorText = aMissingDep.makeStringAndClear();
@@ -218,8 +220,8 @@ void ExtensionBox_Impl::Init()
m_xRemoveListener = new ExtensionRemovedListener( this );
m_pLocale.reset( new lang::Locale( Application::GetSettings().GetLanguageTag().getLocale() ) );
- m_pCollator.reset( new CollatorWrapper( ::comphelper::getProcessComponentContext() ) );
- m_pCollator->loadDefaultCollator( *m_pLocale, i18n::CollatorOptions::CollatorOptions_IGNORE_CASE );
+ m_oCollator.emplace( ::comphelper::getProcessComponentContext() );
+ m_oCollator->loadDefaultCollator( *m_pLocale, i18n::CollatorOptions::CollatorOptions_IGNORE_CASE );
}
ExtensionBox_Impl::~ExtensionBox_Impl()
@@ -239,7 +241,7 @@ ExtensionBox_Impl::~ExtensionBox_Impl()
m_xRemoveListener.clear();
m_pLocale.reset();
- m_pCollator.reset();
+ m_oCollator.reset();
}
sal_Int32 ExtensionBox_Impl::getItemCount() const
@@ -354,7 +356,7 @@ void ExtensionBox_Impl::selectEntry( const tools::Long nPos )
m_vEntries[ m_nActive ]->m_bActive = false;
}
- if ( ( nPos >= 0 ) && ( nPos < static_cast<tools::Long>(m_vEntries.size()) ) )
+ if ( ( nPos >= 0 ) && ( o3tl::make_unsigned(nPos) < m_vEntries.size() ) )
{
m_bHasActive = true;
m_nActive = nPos;
@@ -623,7 +625,7 @@ bool ExtensionBox_Impl::HandleCursorKey( sal_uInt16 nKeyCode )
if ( nSelect < 0 )
nSelect = 0;
- if ( nSelect >= static_cast<tools::Long>(m_vEntries.size()) )
+ if ( o3tl::make_unsigned(nSelect) >= m_vEntries.size() )
nSelect = m_vEntries.size() - 1;
selectEntry( nSelect );
@@ -732,7 +734,7 @@ bool ExtensionBox_Impl::MouseMove( const MouseEvent& rMEvt )
bool bOverHyperlink = false;
auto nPos = PointToPos( rMEvt.GetPosPixel() );
- if ( ( nPos >= 0 ) && ( nPos < static_cast<tools::Long>(m_vEntries.size()) ) )
+ if ( ( nPos >= 0 ) && ( o3tl::make_unsigned(nPos) < m_vEntries.size() ) )
{
const auto& rEntry = m_vEntries[nPos];
bOverHyperlink = !rEntry->m_sPublisher.isEmpty() && rEntry->m_aLinkRect.Contains(rMEvt.GetPosPixel());
@@ -749,7 +751,7 @@ bool ExtensionBox_Impl::MouseMove( const MouseEvent& rMEvt )
OUString ExtensionBox_Impl::RequestHelp(tools::Rectangle& rRect)
{
auto nPos = PointToPos( rRect.TopLeft() );
- if ( ( nPos >= 0 ) && ( nPos < static_cast<tools::Long>(m_vEntries.size()) ) )
+ if ( ( nPos >= 0 ) && ( o3tl::make_unsigned(nPos) < m_vEntries.size() ) )
{
const auto& rEntry = m_vEntries[nPos];
bool bOverHyperlink = !rEntry->m_sPublisher.isEmpty() && rEntry->m_aLinkRect.Contains(rRect);
@@ -774,7 +776,7 @@ bool ExtensionBox_Impl::MouseButtonDown( const MouseEvent& rMEvt )
{
auto nPos = PointToPos( rMEvt.GetPosPixel() );
- if ( ( nPos >= 0 ) && ( nPos < static_cast<tools::Long>(m_vEntries.size()) ) )
+ if ( ( nPos >= 0 ) && ( o3tl::make_unsigned(nPos) < m_vEntries.size() ) )
{
const auto& rEntry = m_vEntries[nPos];
if (!rEntry->m_sPublisher.isEmpty() && rEntry->m_aLinkRect.Contains(rMEvt.GetPosPixel()))
@@ -824,7 +826,7 @@ bool ExtensionBox_Impl::FindEntryPos( const TEntry_Impl& rEntry, const tools::Lo
if ( nStart == nEnd )
{
- eCompare = rEntry->CompareTo( m_pCollator.get(), m_vEntries[ nStart ] );
+ eCompare = rEntry->CompareTo( &*m_oCollator, m_vEntries[ nStart ] );
if ( eCompare < 0 )
return false;
else if ( eCompare == 0 )
@@ -845,7 +847,7 @@ bool ExtensionBox_Impl::FindEntryPos( const TEntry_Impl& rEntry, const tools::Lo
}
const tools::Long nMid = nStart + ( ( nEnd - nStart ) / 2 );
- eCompare = rEntry->CompareTo( m_pCollator.get(), m_vEntries[ nMid ] );
+ eCompare = rEntry->CompareTo( &*m_oCollator, m_vEntries[ nMid ] );
if ( eCompare < 0 )
return FindEntryPos( rEntry, nStart, nMid-1, nPos );
@@ -866,12 +868,11 @@ bool ExtensionBox_Impl::FindEntryPos( const TEntry_Impl& rEntry, const tools::Lo
void ExtensionBox_Impl::cleanVecListenerAdded()
{
- m_vListenerAdded.erase(std::remove_if(m_vListenerAdded.begin(), m_vListenerAdded.end(),
+ std::erase_if(m_vListenerAdded,
[](const uno::WeakReference<deployment::XPackage>& rxListener) {
const uno::Reference<deployment::XPackage> hardRef(rxListener);
return !hardRef.is();
- }),
- m_vListenerAdded.end());
+ });
}
void ExtensionBox_Impl::addEventListenerOnce(
@@ -1106,6 +1107,7 @@ void ExtensionBox_Impl::checkEntries()
m_bHasActive = false;
}
m_vRemovedEntries.push_back(*iIndex);
+ (*iIndex)->m_xPackage->removeEventListener(m_xRemoveListener);
iIndex = m_vEntries.erase(iIndex);
}
}