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.cxx102
1 files changed, 51 insertions, 51 deletions
diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
index ed6ed79fd256..7e8bb6a455eb 100644
--- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
+++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
@@ -35,16 +35,19 @@
#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>
#include <vcl/settings.hxx>
+#include <vcl/weldutils.hxx>
#include <algorithm>
-#define USER_PACKAGE_MANAGER "user"
-#define SHARED_PACKAGE_MANAGER "shared"
+constexpr OUStringLiteral USER_PACKAGE_MANAGER = u"user";
+constexpr OUStringLiteral SHARED_PACKAGE_MANAGER = u"shared";
using namespace ::com::sun::star;
@@ -56,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);
};
@@ -145,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();
@@ -217,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()
@@ -230,7 +233,7 @@ ExtensionBox_Impl::~ExtensionBox_Impl()
for (auto const& entry : m_vEntries)
{
- entry->m_xPackage->removeEventListener( m_xRemoveListener.get() );
+ entry->m_xPackage->removeEventListener( m_xRemoveListener );
}
m_vEntries.clear();
@@ -238,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
@@ -353,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;
@@ -422,8 +425,7 @@ void ExtensionBox_Impl::DrawRow(vcl::RenderContext& rRenderContext, const tools:
// Setup fonts
// expand the point size of the desired font to the equivalent pixel size
- if (vcl::Window* pDefaultDevice = dynamic_cast<vcl::Window*>(Application::GetDefaultDevice()))
- pDefaultDevice->SetPointFont(rRenderContext, GetDrawingArea()->get_font());
+ weld::SetPointFont(rRenderContext, GetDrawingArea()->get_font());
vcl::Font aStdFont(rRenderContext.GetFont());
vcl::Font aBoldFont(aStdFont);
aBoldFont.SetWeight(WEIGHT_BOLD);
@@ -504,7 +506,7 @@ void ExtensionBox_Impl::DrawRow(vcl::RenderContext& rRenderContext, const tools:
{
aPos = rRect.TopLeft() + Point( ICON_OFFSET + nMaxTitleWidth + (2*SPACE_BETWEEN), TOP_OFFSET );
- rRenderContext.Push(PushFlags::FONT | PushFlags::TEXTCOLOR | PushFlags::TEXTFILLCOLOR);
+ rRenderContext.Push(vcl::PushFlags::FONT | vcl::PushFlags::TEXTCOLOR | vcl::PushFlags::TEXTFILLCOLOR);
rRenderContext.SetTextColor(rStyleSettings.GetLinkColor());
rRenderContext.SetTextFillColor(rStyleSettings.GetFieldColor());
vcl::Font aFont = rRenderContext.GetFont();
@@ -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,10 +734,10 @@ 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.IsInside(rMEvt.GetPosPixel());
+ bOverHyperlink = !rEntry->m_sPublisher.isEmpty() && rEntry->m_aLinkRect.Contains(rMEvt.GetPosPixel());
}
if (bOverHyperlink)
@@ -749,10 +751,10 @@ 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.IsInside(rRect);
+ bool bOverHyperlink = !rEntry->m_sPublisher.isEmpty() && rEntry->m_aLinkRect.Contains(rRect);
if (bOverHyperlink)
{
rRect = rEntry->m_aLinkRect;
@@ -765,39 +767,37 @@ OUString ExtensionBox_Impl::RequestHelp(tools::Rectangle& rRect)
bool ExtensionBox_Impl::MouseButtonDown( const MouseEvent& rMEvt )
{
- if ( rMEvt.IsLeft() )
+ if ( !rMEvt.IsLeft() )
+ return false;
+
+ if (rMEvt.IsMod1() && m_bHasActive)
+ selectEntry(ExtensionBox_Impl::ENTRY_NOTFOUND); // Selecting a not existing entry will deselect the current one
+ else
{
- if (rMEvt.IsMod1() && m_bHasActive)
- selectEntry(ExtensionBox_Impl::ENTRY_NOTFOUND); // Selecting a not existing entry will deselect the current one
- else
- {
- auto nPos = PointToPos( rMEvt.GetPosPixel() );
+ 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()))
{
- const auto& rEntry = m_vEntries[nPos];
- if (!rEntry->m_sPublisher.isEmpty() && rEntry->m_aLinkRect.IsInside(rMEvt.GetPosPixel()))
+ try
+ {
+ css::uno::Reference<css::system::XSystemShellExecute> xSystemShellExecute(
+ css::system::SystemShellExecute::create(comphelper::getProcessComponentContext()));
+ //throws css::lang::IllegalArgumentException, css::system::SystemShellExecuteException
+ xSystemShellExecute->execute(rEntry->m_sPublisherURL, OUString(), css::system::SystemShellExecuteFlags::URIS_ONLY);
+ }
+ catch (...)
{
- try
- {
- css::uno::Reference<css::system::XSystemShellExecute> xSystemShellExecute(
- css::system::SystemShellExecute::create(comphelper::getProcessComponentContext()));
- //throws css::lang::IllegalArgumentException, css::system::SystemShellExecuteException
- xSystemShellExecute->execute(rEntry->m_sPublisherURL, OUString(), css::system::SystemShellExecuteFlags::URIS_ONLY);
- }
- catch (...)
- {
- }
- return true;
}
+ return true;
}
-
- selectEntry( nPos );
}
- return true;
- }
- return false;
+ selectEntry( nPos );
+ }
+ return true;
}
bool ExtensionBox_Impl::KeyInput(const KeyEvent& rKEvt)
@@ -826,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 )
@@ -847,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 );
@@ -868,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(
@@ -884,7 +883,7 @@ void ExtensionBox_Impl::addEventListenerOnce(
if ( std::none_of(m_vListenerAdded.begin(), m_vListenerAdded.end(),
FindWeakRef(extension)) )
{
- extension->addEventListener( m_xRemoveListener.get() );
+ extension->addEventListener( m_xRemoveListener );
m_vListenerAdded.emplace_back(extension);
}
}
@@ -996,7 +995,7 @@ void ExtensionBox_Impl::removeEntry( const uno::Reference< deployment::XPackage
// the entry will be moved into the m_vRemovedEntries list which will be
// cleared on the next paint event
m_vRemovedEntries.push_back( *iIndex );
- (*iIndex)->m_xPackage->removeEventListener(m_xRemoveListener.get());
+ (*iIndex)->m_xPackage->removeEventListener(m_xRemoveListener);
m_vEntries.erase( iIndex );
m_bNeedsRecalc = true;
@@ -1108,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);
}
}