23#include <com/sun/star/lang/XServiceInfo.hpp>
24#include <com/sun/star/document/XDocumentEventListener.hpp>
25#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
26#include <com/sun/star/beans/XPropertySet.hpp>
27#include <com/sun/star/frame/theGlobalEventBroadcaster.hpp>
28#include <com/sun/star/graphic/GraphicProvider.hpp>
29#include <com/sun/star/graphic/XGraphicProvider.hpp>
30#include <com/sun/star/task/XJob.hpp>
38#include <sfx2/strings.hrc>
40#include <bitmaps.hlst>
55class UpdateCheckUI :
public ::cppu::WeakImplHelper
56 < lang::XServiceInfo, document::XDocumentEventListener, beans::XPropertySet >
58 uno::Reference< uno::XComponentContext >
m_xContext;
59 uno::Reference< task::XJob > mrJob;
60 OUString maBubbleImageURL;
62 std::locale maSfxLocale;
67 Image GetBubbleImage( OUString
const &rURL );
70 explicit UpdateCheckUI(
const uno::Reference<uno::XComponentContext>&);
78 virtual void SAL_CALL documentEventOccured(
const document::DocumentEvent& Event)
override;
79 virtual void SAL_CALL disposing(
const lang::EventObject& Event)
override;
82 virtual uno::Reference< beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
override;
85 virtual void SAL_CALL addPropertyChangeListener(
const OUString& PropertyName,
86 const uno::Reference< beans::XPropertyChangeListener > & aListener)
override;
87 virtual void SAL_CALL removePropertyChangeListener(
const OUString& PropertyName,
88 const uno::Reference< beans::XPropertyChangeListener > & aListener)
override;
89 virtual void SAL_CALL addVetoableChangeListener(
const OUString& PropertyName,
90 const uno::Reference< beans::XVetoableChangeListener > & aListener)
override;
91 virtual void SAL_CALL removeVetoableChangeListener(
const OUString& PropertyName,
92 const uno::Reference< beans::XVetoableChangeListener > & aListener)
override;
95UpdateCheckUI::UpdateCheckUI(
const uno::Reference<uno::XComponentContext>& xContext)
100 uno::Reference< document::XDocumentEventBroadcaster > xBroadcaster( frame::theGlobalEventBroadcaster::get(
m_xContext) );
101 xBroadcaster->addDocumentEventListener(
this );
105 maBubbleManager.SetBubbleImage(GetBubbleImage(maBubbleImageURL));
106 maBubbleManager.SetClickHdl(
LINK(
this, UpdateCheckUI, ClickHdl));
110UpdateCheckUI::getImplementationName()
112 return "vnd.sun.UpdateCheckUI";
115uno::Sequence< OUString > SAL_CALL
116UpdateCheckUI::getSupportedServiceNames()
118 return {
"com.sun.star.setup.UpdateCheckUI" };
122UpdateCheckUI::supportsService( OUString
const & serviceName )
127Image UpdateCheckUI::GetBubbleImage( OUString
const &rURL )
131 if ( !maBubbleImageURL.isEmpty() )
133 uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
136 throw uno::RuntimeException(
137 "UpdateCheckUI: unable to obtain service manager from component context" );
141 uno::Reference< graphic::XGraphicProvider > xGraphProvider(graphic::GraphicProvider::create(xContext));
144 uno::Reference< graphic::XGraphic > xGraphic = xGraphProvider->queryGraphic( aMediaProps );
147 aImage =
Image( xGraphic );
150 catch(
const uno::Exception& )
156 aImage =
Image(StockImage::Yes, SV_RESID_BITMAP_INFOBOX);
161void SAL_CALL UpdateCheckUI::documentEventOccured(
const document::DocumentEvent& rEvent)
165 if( rEvent.EventName ==
"OnPrepareViewClosing" )
166 maBubbleManager.RemoveBubbleWindow();
169void SAL_CALL UpdateCheckUI::disposing(
const lang::EventObject&)
173uno::Reference< beans::XPropertySetInfo > UpdateCheckUI::getPropertySetInfo()
178void UpdateCheckUI::setPropertyValue(
const OUString& rPropertyName,
187 maBubbleManager.SetBubbleTitle(aString);
191 maBubbleManager.SetBubbleText(aString);
195 if ( aString != maBubbleImageURL ) {
196 maBubbleImageURL = aString;
197 maBubbleManager.SetBubbleImage(GetBubbleImage(maBubbleImageURL));
201 bool bShowBubble=
false;
202 rValue >>= bShowBubble;
203 maBubbleManager.SetShowBubble(bShowBubble);
206 uno::Reference< task::XJob > aJob;
209 throw lang::IllegalArgumentException();
213 bool bShowMenuIcon =
false;
214 rValue >>= bShowMenuIcon;
215 maBubbleManager.SetShowMenuIcon(bShowMenuIcon);
218 throw beans::UnknownPropertyException(rPropertyName);
221uno::Any UpdateCheckUI::getPropertyValue(
const OUString& rPropertyName)
228 aRet <<= maBubbleManager.GetBubbleTitle();
230 aRet <<= maBubbleManager.GetBubbleText();
232 aRet <<= maBubbleManager.GetShowBubble();
234 aRet <<= maBubbleImageURL;
238 aRet <<= maBubbleManager.GetShowMenuIcon();
240 throw beans::UnknownPropertyException(rPropertyName);
246void UpdateCheckUI::addPropertyChangeListener(
const OUString& ,
247 const uno::Reference< beans::XPropertyChangeListener > & )
253void UpdateCheckUI::removePropertyChangeListener(
const OUString& ,
254 const uno::Reference< beans::XPropertyChangeListener > & )
259void UpdateCheckUI::addVetoableChangeListener(
const OUString& ,
260 const uno::Reference< beans::XVetoableChangeListener > & )
265void UpdateCheckUI::removeVetoableChangeListener(
const OUString& ,
266 const uno::Reference< beans::XVetoableChangeListener > & )
278 uno::Sequence<beans::NamedValue> aEmpty;
279 mrJob->execute( aEmpty );
281 catch(
const uno::Exception&) {
283 VclMessageType::Warning, VclButtonsType::Ok,
293extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
295 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const&)
298 return cppu::acquire(
new UpdateCheckUI(context));
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
Size GetSizePixel() const
constexpr tools::Long Width() const
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
Reference< XComponentContext > m_xContext
#define LINK(Instance, Class, Member)
std::locale Create(std::string_view aPrefixName, const LanguageTag &rLocale)
OUString get(TranslateId sContextAndId, const std::locale &loc)
IMPL_LINK_NOARG(FinalPage, OnEntryNameModified, weld::Entry &, void)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
VBAHELPER_DLLPUBLIC bool setPropertyValue(css::uno::Sequence< css::beans::PropertyValue > &aProp, const OUString &aName, const css::uno::Any &aValue)
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
constexpr OUStringLiteral PROPERTY_TITLE
constexpr OUStringLiteral PROPERTY_IMAGE
constexpr OUStringLiteral PROPERTY_TEXT
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * extensions_update_UpdateCheckUI_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
constexpr OUStringLiteral PROPERTY_CLICK_HDL
constexpr OUStringLiteral PROPERTY_SHOW_BUBBLE
constexpr OUStringLiteral PROPERTY_SHOW_MENUICON