26#include <bitmaps.hlst>
29#include <com/sun/star/i18n/CollatorOptions.hpp>
30#include <com/sun/star/deployment/DependencyException.hpp>
31#include <com/sun/star/deployment/DeploymentException.hpp>
32#include <com/sun/star/deployment/ExtensionRemovedException.hpp>
33#include <com/sun/star/system/XSystemShellExecute.hpp>
34#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
35#include <com/sun/star/system/SystemShellExecute.hpp>
39#include <osl/diagnose.h>
40#include <rtl/ustrbuf.hxx>
80 m_bHasOptions( false ),
85 m_bMissingDeps( false ),
86 m_bHasButtons( false ),
87 m_bMissingLic( false ),
93 m_sTitle = xPackage->getDisplayName();
98 beans::StringPair aInfo(
m_xPackage->getPublisherInfo() );
112 catch (
const deployment::ExtensionRemovedException &) {}
113 catch (
const uno::RuntimeException &) {}
126 eCompare =
m_sVersion.compareTo( rEntry->m_sVersion );
129 sal_Int32 nCompare =
m_xPackage->getRepositoryName().compareTo( rEntry->m_xPackage->getRepositoryName() );
132 else if ( nCompare > 0 )
145 catch (
const deployment::DeploymentException &e )
147 deployment::DependencyException depExc;
148 if ( e.Cause >>= depExc )
150 OUStringBuffer aMissingDep(
DpResId( RID_STR_ERROR_MISSING_DEPENDENCIES ) );
151 for (
const auto&
i : std::as_const(depExc.UnsatisfiedDependencies) )
153 aMissingDep.append(
"\n"
156 aMissingDep.append(
"\n");
183 : m_bHasScrollBar( false )
184 , m_bHasActive( false )
185 , m_bNeedsRecalc( true )
186 , m_bInCheckMode( false )
187 , m_bAdjustActive( false )
188 , m_bInDelete( false )
192 , m_nActiveHeight( 0 )
198 , m_xScrollBar(
std::move(xScroll))
208 if ( nIconHeight < nTitleHeight )
223 m_oCollator.emplace( ::comphelper::getProcessComponentContext() );
224 m_oCollator->loadDefaultCollator( *
m_pLocale, i18n::CollatorOptions::CollatorOptions_IGNORE_CASE );
249 return static_cast< sal_Int32
>(
m_vEntries.size() );
258 return static_cast< sal_Int32
>(
m_nActive );
274 if ( nIconHeight < nTitleHeight )
275 aTextHeight = nTitleHeight;
277 aTextHeight = nIconHeight;
286 if ( !aText.isEmpty() )
291 DrawTextFlags::MultiLine | DrawTextFlags::WordBreak);
337 bool invalidate =
false;
390 if (rEntry->m_bActive)
397 if (rEntry->m_bActive)
407 rRenderContext.
Erase(rRect);
414 if (!rEntry->m_aIcon)
417 aImage = rEntry->m_aIcon;
432 rRenderContext.
SetFont(aBoldFont);
438 rRenderContext.
SetFont(aStdFont);
440 if (!rEntry->m_sPublisher.isEmpty())
442 nLinkWidth = rRenderContext.
GetTextWidth(rEntry->m_sPublisher);
449 rRenderContext.
SetFont(aBoldFont);
451 if (aTitleWidth > nMaxTitleWidth - aVersionWidth)
453 aTitleWidth = nMaxTitleWidth - aVersionWidth - (aTextHeight / 3);
454 OUString aShortTitle = rRenderContext.
GetEllipsisString(rEntry->m_sTitle, aTitleWidth);
455 rRenderContext.
DrawText(aPos, aShortTitle);
456 aTitleWidth += (aTextHeight / 3);
459 rRenderContext.
DrawText(aPos, rEntry->m_sTitle);
461 rRenderContext.
SetFont(aStdFont);
462 rRenderContext.
DrawText(
Point(aPos.
X() + aTitleWidth, aPos.
Y()), rEntry->m_sVersion);
466 if ( nIconHeight < nTitleHeight )
467 aTextHeight = nTitleHeight;
469 aTextHeight = nIconHeight;
472 OUString sDescription;
473 if (!rEntry->m_sErrorText.isEmpty())
475 if (rEntry->m_bActive)
476 sDescription = rEntry->m_sErrorText +
"\n" + rEntry->m_sDescription;
478 sDescription = rEntry->m_sErrorText;
481 sDescription = rEntry->m_sDescription;
484 if (rEntry->m_bActive)
488 if (rEntry->m_bHasButtons)
492 sDescription, DrawTextFlags::MultiLine | DrawTextFlags::WordBreak );
497 sDescription = sDescription.replace(0x000A,
' ');
499 if (nWidth > rRect.
GetWidth() - aPos.
X())
501 rRenderContext.
DrawText(aPos, sDescription);
505 if (!rEntry->m_sPublisher.isEmpty())
516 rRenderContext.
DrawText(aPos, rEntry->m_sPublisher);
518 rRenderContext.
Pop();
522 if (!rEntry->m_bUser)
525 if (rEntry->m_bLocked)
530 if ((rEntry->m_eState ==
AMBIGUOUS ) || rEntry->m_bMissingDeps || rEntry->m_bMissingLic)
557 if ( aEntryRect.
Top() < 0 )
560 aEntryRect.
Move( 0, -aEntryRect.
Top() );
580 aEntryRect.
Move( 0, nOffset );
611 else if ( nKeyCode ==
KEY_END )
654 DrawRow(rRenderContext, aEntryRect, entry);
677 const bool bNeedsScrollBar = ( nTotalHeight > aSize.
Height() );
679 if ( bNeedsScrollBar )
711 CustomWidgetController::SetDrawingArea(pDrawingArea);
734 bool bOverHyperlink =
false;
740 bOverHyperlink = !rEntry->m_sPublisher.isEmpty() && rEntry->m_aLinkRect.Contains(rMEvt.
GetPosPixel());
757 bool bOverHyperlink = !rEntry->m_sPublisher.isEmpty() && rEntry->m_aLinkRect.Contains(rRect);
760 rRect = rEntry->m_aLinkRect;
761 return rEntry->m_sPublisherURL;
782 if (!rEntry->m_sPublisher.isEmpty() && rEntry->m_aLinkRect.Contains(rMEvt.
GetPosPixel()))
786 css::uno::Reference<css::system::XSystemShellExecute> xSystemShellExecute(
789 xSystemShellExecute->execute(rEntry->m_sPublisherURL, OUString(), css::system::SystemShellExecuteFlags::URIS_ONLY);
809 sal_uInt16 nKeyCode = aKeyCode.
GetCode();
811 bool bHandled =
false;
827 if ( nStart == nEnd )
832 else if ( eCompare == 0 )
835 if (rEntry->m_xPackage !=
m_vEntries[nStart]->m_xPackage)
849 const tools::Long nMid = nStart + ( ( nEnd - nStart ) / 2 );
854 else if ( eCompare > 0 )
859 if (rEntry->m_xPackage !=
m_vEntries[nMid]->m_xPackage)
873 const uno::Reference<deployment::XPackage> hardRef(rxListener);
874 return !hardRef.is();
885 FindWeakRef(extension)) )
894 bool bLicenseMissing )
899 TEntry_Impl pEntry = std::make_shared<Entry_Impl>( xPackage, eState, bLocked );
902 if ( pEntry->m_sTitle.isEmpty() )
922 OSL_FAIL(
"ExtensionBox_Impl::addEntry(): Will not add duplicate entries");
930 pEntry->m_bMissingLic = bLicenseMissing;
933 pEntry->m_sErrorText =
DpResId(RID_STR_ERROR_MISSING_LICENSE);
950 if ( entry->m_xPackage == xPackage )
954 entry->m_eState = eState;
955 entry->m_sTitle = xPackage->getDisplayName();
956 entry->m_sVersion = xPackage->getVersion();
957 entry->m_sDescription = xPackage->getDescription();
960 entry->m_bMissingLic =
false;
963 entry->m_sErrorText =
DpResId( RID_STR_ERROR_UNKNOWN_STATUS );
964 else if ( ! entry->m_bMissingLic )
965 entry->m_sErrorText.clear();
984 bool invalidate =
false;
989 [&xPackage](
const TEntry_Impl& rxEntry) { return rxEntry->m_xPackage == xPackage; });
1033 bool bAllRemoved =
false;
1035 while ( ! bAllRemoved )
1043 if ( !entry->m_bLocked )
1045 bAllRemoved =
false;
1061 entry->m_bChecked =
false;
1062 entry->m_bNew =
false;
1072 bool bNeedsUpdate =
false;
1079 if (!(*iIndex)->m_bChecked)
1081 (*iIndex)->m_bChecked =
true;
1082 bNeedsUpdate =
true;
1084 if ((*iIndex)->m_bNew)
1098 if (
nPos < nChangedActivePos)
1100 --nChangedActivePos;
1106 nChangedActivePos =
nPos;
1122 if ( nNewPos != - 1)
1124 else if (nChangedActivePos != -1) {
1138 m_nTopIndex = rScrBar.vadjustment_get_value();
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
sal_Int32 compareString(const OUString &s1, const OUString &s2) const
Size GetSizePixel() const
const vcl::KeyCode & GetKeyCode() const
const Point & GetPosPixel() const
const vcl::Font & GetFont() const
void SetFont(const vcl::Font &rNewFont)
void DrawRect(const tools::Rectangle &rRect)
void DrawLine(const Point &rStartPt, const Point &rEndPt)
OUString GetEllipsisString(const OUString &rStr, tools::Long nMaxWidth, DrawTextFlags nStyle=DrawTextFlags::EndEllipsis) const
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
void SetTextColor(const Color &rColor)
void DrawImage(const Point &rPos, const Image &rImage, DrawImageFlags nStyle=DrawImageFlags::NONE)
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
tools::Rectangle GetTextRect(const tools::Rectangle &rRect, const OUString &rStr, DrawTextFlags nStyle=DrawTextFlags::WordBreak, TextRectInfo *pInfo=nullptr, const vcl::ITextLayout *_pTextLayout=nullptr) const
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
tools::Long GetTextHeight() const
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
const AllSettings & GetSettings() const
constexpr tools::Long Y() const
tools::Long AdjustY(tools::Long nVertMove)
constexpr tools::Long X() const
constexpr tools::Long Height() const
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
const Color & GetFieldTextColor() const
const Color & GetFieldColor() const
const Color & GetLinkColor() const
const Color & GetHighlightColor() const
const Color & GetHighlightTextColor() const
const Color & GetDisableColor() const
virtual void selectEntry(const tools::Long nPos)
std::vector< TEntry_Impl > m_vEntries
tools::Long PointToPos(const Point &rPos)
virtual ~ExtensionBox_Impl() override
bool FindEntryPos(const TEntry_Impl &rEntry, tools::Long nStart, tools::Long nEnd, tools::Long &nFound)
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
void updateEntry(const css::uno::Reference< css::deployment::XPackage > &xPackage)
tools::Long GetTotalHeight() const
tools::Rectangle GetEntryRect(const tools::Long nPos) const
void DrawRow(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect, const TEntry_Impl &rEntry)
std::vector< TEntry_Impl > m_vRemovedEntries
void addEventListenerOnce(css::uno::Reference< css::deployment::XPackage > const &extension)
std::optional< CollatorWrapper > m_oCollator
virtual void Resize() override
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rPaintRect) override
mutable::osl::Mutex m_entriesMutex
sal_Int32 getSelIndex() const
std::unique_ptr< css::lang::Locale > m_pLocale
void cleanVecListenerAdded()
rtl::Reference< ExtensionRemovedListener > m_xRemoveListener
std::vector< css::uno::WeakReference< css::deployment::XPackage > > m_vListenerAdded
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
void removeEntry(const css::uno::Reference< css::deployment::XPackage > &xPackage)
ExtensionBox_Impl(std::unique_ptr< weld::ScrolledWindow > xScroll)
std::unique_ptr< weld::ScrolledWindow > m_xScrollBar
virtual OUString RequestHelp(tools::Rectangle &rRect) override
sal_Int32 getItemCount() const
TheExtensionManager * m_pManager
tools::Long m_nActiveHeight
bool HandleCursorKey(sal_uInt16 nKeyCode)
virtual bool KeyInput(const KeyEvent &rKEvt) override
void CalcActiveHeight(const tools::Long nPos)
void addEntry(const css::uno::Reference< css::deployment::XPackage > &xPackage, bool bLicenseMissing=false)
virtual bool MouseMove(const MouseEvent &rMEvt) override
virtual void SAL_CALL disposing(css::lang::EventObject const &evt) override
virtual ~ExtensionRemovedListener() override
ExtensionBox_Impl * m_pParent
static PackageState getPackageState(const css::uno::Reference< css::deployment::XPackage > &xPackage)
bool isReadOnly(const css::uno::Reference< css::deployment::XPackage > &xPackage) const
bool supportsOptions(const css::uno::Reference< css::deployment::XPackage > &xPackage) const
void SetWeight(FontWeight)
void SetUnderline(FontLineStyle)
sal_uInt16 GetGroup() const
sal_uInt16 GetCode() const
virtual OutputDevice & get_ref_device()=0
constexpr ::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
uno::Reference< deployment::XPackage > m_xPackage
constexpr OUStringLiteral SHARED_PACKAGE_MANAGER
const uno::Reference< deployment::XPackage > m_extension
constexpr OUStringLiteral USER_PACKAGE_MANAGER
#define RIGHT_ICON_OFFSET
OUString DpResId(TranslateId aId)
constexpr sal_uInt16 KEY_HOME
constexpr sal_uInt16 KEY_LEFT
constexpr sal_uInt16 KEY_PAGEDOWN
constexpr sal_uInt16 KEY_TAB
constexpr sal_uInt16 KEY_UP
constexpr sal_uInt16 KEY_RIGHT
constexpr sal_uInt16 KEY_DOWN
constexpr sal_uInt16 KEY_PAGEUP
constexpr sal_uInt16 KEY_END
constexpr sal_uInt16 KEYGROUP_CURSOR
#define LINK(Instance, Class, Member)
const LanguageTag & getLocale()
Reference< XComponentContext > getProcessComponentContext()
constexpr OUStringLiteral SHARED_PACKAGE_MANAGER
IMPL_LINK(ExtMgrDialog, startProgress, void *, _bLockInterface, void)
constexpr OUStringLiteral USER_PACKAGE_MANAGER
std::shared_ptr< Entry_Impl > TEntry_Impl
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString getErrorText(css::uno::Reference< css::xml::dom::XElement > const &dependency)
Obtain the (human-readable) error message of a failed dependency.
css::uno::Reference< css::deployment::XPackageRegistry > create(css::uno::Reference< css::deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, css::uno::Reference< css::uno::XComponentContext > const &xComponentContext)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
void SetPointFont(OutputDevice &rDevice, const vcl::Font &rFont)
sal_Int32 CompareTo(const CollatorWrapper *pCollator, const TEntry_Impl &rEntry) const
Entry_Impl(const css::uno::Reference< css::deployment::XPackage > &xPackage, const PackageState eState, const bool bReadOnly)
css::uno::Reference< css::deployment::XPackage > m_xPackage