21 #include <strings.hrc>
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>
38 #include <osl/diagnose.h>
39 #include <rtl/ustrbuf.hxx>
46 #define USER_PACKAGE_MANAGER "user"
47 #define SHARED_PACKAGE_MANAGER "shared"
59 explicit FindWeakRef( uno::Reference<deployment::XPackage>
const & ext): m_extension(ext) {}
60 bool operator () (uno::WeakReference< deployment::XPackage >
const & ref);
63 bool FindWeakRef::operator () (uno::WeakReference< deployment::XPackage >
const & ref)
65 const uno::Reference<deployment::XPackage> ext(ref);
76 m_bLocked( bReadOnly ),
77 m_bHasOptions( false ),
82 m_bMissingDeps( false ),
83 m_bHasButtons( false ),
84 m_bMissingLic( false ),
90 m_sTitle = xPackage->getDisplayName();
95 beans::StringPair aInfo(
m_xPackage->getPublisherInfo() );
100 uno::Reference< graphic::XGraphic >
xGraphic = xPackage->getIcon(
false );
109 catch (
const deployment::ExtensionRemovedException &) {}
110 catch (
const uno::RuntimeException &) {}
123 eCompare =
m_sVersion.compareTo( rEntry->m_sVersion );
126 sal_Int32 nCompare =
m_xPackage->getRepositoryName().compareTo( rEntry->m_xPackage->getRepositoryName() );
129 else if ( nCompare > 0 )
140 m_xPackage->checkDependencies( uno::Reference< ucb::XCommandEnvironment >() );
142 catch (
const deployment::DeploymentException &e )
144 deployment::DependencyException depExc;
145 if ( e.Cause >>= depExc )
147 OUStringBuffer aMissingDep(
DpResId( RID_STR_ERROR_MISSING_DEPENDENCIES ) );
148 for (
const auto&
i : std::as_const(depExc.UnsatisfiedDependencies) )
150 aMissingDep.append(
"\n");
153 aMissingDep.append(
"\n");
164 uno::Reference< deployment::XPackage > xPackage( rEvt.Source, uno::UNO_QUERY );
180 : m_bHasScrollBar( false )
181 , m_bHasActive( false )
182 , m_bNeedsRecalc( true )
183 , m_bInCheckMode( false )
184 , m_bAdjustActive( false )
185 , m_bInDelete( false )
189 , m_nActiveHeight( 0 )
194 , m_pManager( nullptr )
195 , m_xScrollBar(
std::move(xScroll))
205 if ( nIconHeight < nTitleHeight )
221 m_pCollator->loadDefaultCollator( *
m_pLocale, i18n::CollatorOptions::CollatorOptions_IGNORE_CASE );
246 return static_cast< sal_Int32
>(
m_vEntries.size() );
255 return static_cast< sal_Int32
>(
m_nActive );
271 if ( nIconHeight < nTitleHeight )
272 aTextHeight = nTitleHeight;
274 aTextHeight = nIconHeight;
282 OUString aText(
m_vEntries[ nPos ]->m_sErrorText );
283 if ( !aText.isEmpty() )
288 DrawTextFlags::MultiLine | DrawTextFlags::WordBreak);
334 bool invalidate =
false;
356 if ( ( nPos >= 0 ) && ( nPos < static_cast<tools::Long>(
m_vEntries.size()) ) )
387 if (rEntry->m_bActive)
394 if (rEntry->m_bActive)
404 rRenderContext.
Erase(rRect);
411 if (!rEntry->m_aIcon)
414 aImage = rEntry->m_aIcon;
426 pDefaultDevice->SetPointFont(rRenderContext,
GetDrawingArea()->get_font());
430 rRenderContext.
SetFont(aBoldFont);
436 rRenderContext.
SetFont(aStdFont);
438 if (!rEntry->m_sPublisher.isEmpty())
440 nLinkWidth = rRenderContext.
GetTextWidth(rEntry->m_sPublisher);
447 rRenderContext.
SetFont(aBoldFont);
449 if (aTitleWidth > nMaxTitleWidth - aVersionWidth)
451 aTitleWidth = nMaxTitleWidth - aVersionWidth - (aTextHeight / 3);
452 OUString aShortTitle = rRenderContext.
GetEllipsisString(rEntry->m_sTitle, aTitleWidth);
453 rRenderContext.
DrawText(aPos, aShortTitle);
454 aTitleWidth += (aTextHeight / 3);
457 rRenderContext.
DrawText(aPos, rEntry->m_sTitle);
459 rRenderContext.
SetFont(aStdFont);
460 rRenderContext.
DrawText(
Point(aPos.X() + aTitleWidth, aPos.Y()), rEntry->m_sVersion);
464 if ( nIconHeight < nTitleHeight )
465 aTextHeight = nTitleHeight;
467 aTextHeight = nIconHeight;
470 OUString sDescription;
471 if (!rEntry->m_sErrorText.isEmpty())
473 if (rEntry->m_bActive)
474 sDescription = rEntry->m_sErrorText +
"\n" + rEntry->m_sDescription;
476 sDescription = rEntry->m_sErrorText;
479 sDescription = rEntry->m_sDescription;
481 aPos.AdjustY(aTextHeight );
482 if (rEntry->m_bActive)
486 if (rEntry->m_bHasButtons)
490 sDescription, DrawTextFlags::MultiLine | DrawTextFlags::WordBreak );
495 sDescription = sDescription.replace(0x000A,
' ');
497 if (nWidth > rRect.
GetWidth() - aPos.X())
499 rRenderContext.
DrawText(aPos, sDescription);
503 if (!rEntry->m_sPublisher.isEmpty())
507 rRenderContext.
Push(PushFlags::FONT | PushFlags::TEXTCOLOR | PushFlags::TEXTFILLCOLOR);
514 rRenderContext.
DrawText(aPos, rEntry->m_sPublisher);
516 rRenderContext.
Pop();
520 if (!rEntry->m_bUser)
523 if (rEntry->m_bLocked)
528 if ((rEntry->m_eState ==
AMBIGUOUS ) || rEntry->m_bMissingDeps || rEntry->m_bMissingLic)
555 if ( aEntryRect.
Top() < 0 )
558 aEntryRect.
Move( 0, -aEntryRect.
Top() );
578 aEntryRect.
Move( 0, nOffset );
609 else if ( nKeyCode ==
KEY_END )
626 if ( nSelect >= static_cast<tools::Long>(
m_vEntries.size()) )
652 DrawRow(rRenderContext, aEntryRect, entry);
653 aStart.AdjustY(aSize.
Height() );
675 const bool bNeedsScrollBar = ( nTotalHeight > aSize.
Height() );
677 if ( bNeedsScrollBar )
709 CustomWidgetController::SetDrawingArea(pDrawingArea);
732 bool bOverHyperlink =
false;
735 if ( (
nPos >= 0 ) && ( nPos < static_cast<tools::Long>(
m_vEntries.size()) ) )
738 bOverHyperlink = !rEntry->m_sPublisher.isEmpty() && rEntry->m_aLinkRect.IsInside(rMEvt.
GetPosPixel());
752 if ( (
nPos >= 0 ) && ( nPos < static_cast<tools::Long>(
m_vEntries.size()) ) )
755 bool bOverHyperlink = !rEntry->m_sPublisher.isEmpty() && rEntry->m_aLinkRect.IsInside(rRect);
758 rRect = rEntry->m_aLinkRect;
759 return rEntry->m_sPublisherURL;
776 if ( (
nPos >= 0 ) && ( nPos < static_cast<tools::Long>(
m_vEntries.size()) ) )
779 if (!rEntry->m_sPublisher.isEmpty() && rEntry->m_aLinkRect.IsInside(rMEvt.
GetPosPixel()))
783 css::uno::Reference<css::system::XSystemShellExecute> xSystemShellExecute(
786 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)
872 [](
const uno::WeakReference<deployment::XPackage>& rxListener) {
873 const uno::Reference<deployment::XPackage> hardRef(rxListener);
874 return !hardRef.is();
880 uno::Reference<deployment::XPackage >
const & extension)
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; });
1012 ( nPos == static_cast<tools::Long>(
m_vEntries.size()) ) )
1033 bool bAllRemoved =
false;
1035 while ( ! bAllRemoved )
1043 if ( !entry->m_bLocked )
1045 bAllRemoved =
false;
1046 uno::Reference< deployment::XPackage> xPackage = entry->m_xPackage;
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;
1121 if ( nNewPos != - 1)
1123 else if (nChangedActivePos != -1) {
1137 m_nTopIndex = rScrBar.vadjustment_get_value();
#define LINK(Instance, Class, Member)
Size GetSizePixel() const
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, MetricVector *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
void addEntry(const css::uno::Reference< css::deployment::XPackage > &xPackage, bool bLicenseMissing=false)
void updateEntry(const css::uno::Reference< css::deployment::XPackage > &xPackage)
virtual void selectEntry(const tools::Long nPos)
sal_Int32 compareString(const OUString &s1, const OUString &s2) const
void DrawImage(const Point &rPos, const Image &rImage, DrawImageFlags nStyle=DrawImageFlags::NONE)
virtual void Resize() override
bool HandleCursorKey(sal_uInt16 nKeyCode)
const Color & GetHighlightTextColor() const
sal_Int32 CompareTo(const CollatorWrapper *pCollator, const TEntry_Impl &rEntry) const
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
Entry_Impl(const css::uno::Reference< css::deployment::XPackage > &xPackage, const PackageState eState, const bool bReadOnly)
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rPaintRect) override
sal_uInt16 GetGroup() const
sal_uInt16 GetCode() const
ExtensionBox_Impl * m_pParent
virtual ~ExtensionRemovedListener() override
constexpr::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
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)
const Color & GetFieldTextColor() const
constexpr sal_uInt16 KEY_UP
#define RIGHT_ICON_OFFSET
const Color & GetHighlightColor() const
constexpr sal_uInt16 KEY_END
static OutputDevice * GetDefaultDevice()
virtual bool MouseMove(const MouseEvent &rMEvt) override
tools::Rectangle GetTextRect(const tools::Rectangle &rRect, const OUString &rStr, DrawTextFlags nStyle=DrawTextFlags::WordBreak, TextRectInfo *pInfo=nullptr, const vcl::ITextLayout *_pTextLayout=nullptr) const
const vcl::Font & GetFont() const
OUString GetEllipsisString(const OUString &rStr, tools::Long nMaxWidth, DrawTextFlags nStyle=DrawTextFlags::EndEllipsis) const
constexpr sal_uInt16 KEY_PAGEUP
void DrawRow(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect, const TEntry_Impl &rEntry)
std::unique_ptr< weld::ScrolledWindow > m_xScrollBar
constexpr sal_uInt16 KEYGROUP_CURSOR
virtual ~ExtensionBox_Impl() override
void SetUnderline(FontLineStyle)
virtual OutputDevice & get_ref_device()=0
void DrawLine(const Point &rStartPt, const Point &rEndPt)
void DrawRect(const tools::Rectangle &rRect)
std::unique_ptr< css::lang::Locale > m_pLocale
tools::Long m_nActiveHeight
virtual bool KeyInput(const KeyEvent &rKEvt) override
constexpr sal_uInt16 KEY_DOWN
tools::Rectangle GetEntryRect(const tools::Long nPos) const
const Color & GetDisableColor() const
rtl::Reference< ExtensionRemovedListener > m_xRemoveListener
virtual void SAL_CALL disposing(css::lang::EventObject const &evt) override
constexpr sal_uInt16 KEY_HOME
TheExtensionManager * m_pManager
bool isReadOnly(const css::uno::Reference< css::deployment::XPackage > &xPackage) const
tools::Long Width() const
const Color & GetFieldColor() const
void SetTextColor(const Color &rColor)
#define SHARED_PACKAGE_MANAGER
constexpr sal_uInt16 KEY_PAGEDOWN
const uno::Reference< deployment::XPackage > m_extension
css::uno::Reference< css::deployment::XPackage > m_xPackage
const AllSettings & GetSettings() const
bool supportsOptions(const css::uno::Reference< css::deployment::XPackage > &xPackage) const
std::vector< TEntry_Impl > m_vEntries
const Color & GetLinkColor() const
tools::Long GetTotalHeight() const
sal_Int32 getSelIndex() const
constexpr sal_uInt16 KEY_RIGHT
Point LogicToPixel(const Point &rLogicPt) const
const LanguageTag & getLocale()
const vcl::KeyCode & GetKeyCode() const
#define USER_PACKAGE_MANAGER
sal_Int32 getItemCount() const
ExtensionBox_Impl(std::unique_ptr< weld::ScrolledWindow > xScroll)
void cleanVecListenerAdded()
std::vector< TEntry_Impl > m_vRemovedEntries
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
void SetFont(const vcl::Font &rNewFont)
tools::Long GetTextHeight() const
tools::Long PointToPos(const Point &rPos)
tools::Long AdjustWidth(tools::Long n)
uno::Reference< deployment::XPackage > m_xPackage
virtual OUString RequestHelp(tools::Rectangle &rRect) override
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
std::unique_ptr< CollatorWrapper > m_pCollator
tools::Long Height() const
Reference< XComponentContext > getProcessComponentContext()
static PackageState getPackageState(const css::uno::Reference< css::deployment::XPackage > &xPackage)
const Point & GetPosPixel() const
void setHeight(tools::Long nHeight)
void addEventListenerOnce(css::uno::Reference< css::deployment::XPackage > const &extension)
mutable::osl::Mutex m_entriesMutex
OUString DpResId(const char *pId)
void CalcActiveHeight(const tools::Long nPos)
constexpr sal_uInt16 KEY_LEFT
std::vector< css::uno::WeakReference< css::deployment::XPackage > > m_vListenerAdded
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString getErrorText(css::uno::Reference< css::xml::dom::XElement > const &dependency)
Obtain the (human-readable) error message of a failed dependency.
void Push(PushFlags nFlags=PushFlags::ALL)
Reference< XGraphic > xGraphic
bool FindEntryPos(const TEntry_Impl &rEntry, tools::Long nStart, tools::Long nEnd, tools::Long &nFound)
void removeEntry(const css::uno::Reference< css::deployment::XPackage > &xPackage)
constexpr sal_uInt16 KEY_TAB
std::shared_ptr< Entry_Impl > TEntry_Impl
IMPL_LINK(ExtMgrDialog, startProgress, void *, _bLockInterface, void)