LibreOffice Module desktop (master)  1
dp_gui_dialog2.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <config_extensions.h>
21 
22 #include <strings.hrc>
23 #include <helpids.h>
24 
25 #include "dp_gui.h"
26 #include "dp_gui_dialog2.hxx"
27 #include "dp_gui_extlistbox.hxx"
28 #include <dp_shared.hxx>
29 #include "dp_gui_theextmgr.hxx"
31 #include <dp_misc.h>
32 #include <dp_update.hxx>
33 #include <dp_identifier.hxx>
34 
35 #include <fpicker/strings.hrc>
36 
37 #include <vcl/commandevent.hxx>
38 #include <vcl/svapp.hxx>
39 
40 #include <osl/mutex.hxx>
41 #include <sal/log.hxx>
42 #include <rtl/ustrbuf.hxx>
43 
45 
46 #include <sfx2/filedlghelper.hxx>
47 #include <sfx2/sfxdlg.hxx>
48 
50 #include <cppuhelper/exc_hlp.hxx>
52 
54 #include <tools/diagnose_ex.h>
55 #include <unotools/configmgr.hxx>
56 
57 #include <com/sun/star/deployment/DeploymentException.hpp>
58 #include <com/sun/star/lang/IllegalArgumentException.hpp>
59 #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
60 #include <com/sun/star/system/SystemShellExecute.hpp>
61 
62 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
63 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
64 #include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
65 
66 #include <officecfg/Office/ExtensionManager.hxx>
67 
68 #include <map>
69 #include <memory>
70 #include <vector>
71 
72 using namespace ::com::sun::star;
73 using namespace ::com::sun::star::system;
74 
75 
76 namespace dp_gui {
77 
78 constexpr OUStringLiteral USER_PACKAGE_MANAGER = u"user";
79 constexpr OUStringLiteral SHARED_PACKAGE_MANAGER = u"shared";
80 constexpr OUStringLiteral BUNDLED_PACKAGE_MANAGER = u"bundled";
81 
82 // ExtBoxWithBtns_Impl
84 {
86 
88 
89  void SetButtonStatus( const TEntry_Impl& rEntry );
90  OString ShowPopupMenu( const Point &rPos, const tools::Long nPos );
91 
92 public:
93  explicit ExtBoxWithBtns_Impl(std::unique_ptr<weld::ScrolledWindow> xScroll);
94 
95  void InitFromDialog(ExtMgrDialog *pParentDialog);
96 
97  virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override;
98  virtual bool Command( const CommandEvent& rCEvt ) override;
99 
100  virtual void RecalcAll() override;
101  virtual void selectEntry( const tools::Long nPos ) override;
102 
103  void enableButtons( bool bEnable );
104 };
105 
106 ExtBoxWithBtns_Impl::ExtBoxWithBtns_Impl(std::unique_ptr<weld::ScrolledWindow> xScroll)
107  : ExtensionBox_Impl(std::move(xScroll))
108  , m_bInterfaceLocked(false)
109  , m_pParent(nullptr)
110 {
111 }
112 
114 {
115  setExtensionManager(pParentDialog->getExtensionManager());
116 
117  m_pParent = pParentDialog;
118 }
119 
121 {
122  const sal_Int32 nActive = getSelIndex();
123 
124  if ( nActive != ExtensionBox_Impl::ENTRY_NOTFOUND )
125  {
126  SetButtonStatus( GetEntryData( nActive) );
127  }
128  else
129  {
130  m_pParent->enableOptionsButton( false );
131  m_pParent->enableRemoveButton( false );
132  m_pParent->enableEnableButton( false );
133  }
134 
136 }
137 
138 
139 //This function may be called with nPos < 0
141 {
142  if ( HasActive() && ( nPos == getSelIndex() ) )
143  return;
144 
146 }
147 
149 {
150  bool bShowOptionBtn = true;
151 
152  rEntry->m_bHasButtons = false;
153  if ( ( rEntry->m_eState == REGISTERED ) || ( rEntry->m_eState == NOT_AVAILABLE ) )
154  {
156  }
157  else
158  {
160  bShowOptionBtn = false;
161  }
162 
163  if ( ( !rEntry->m_bUser || ( rEntry->m_eState == NOT_AVAILABLE ) || rEntry->m_bMissingDeps )
164  && !rEntry->m_bMissingLic )
165  {
166  m_pParent->enableEnableButton( false );
167  }
168  else
169  {
170  m_pParent->enableEnableButton( !rEntry->m_bLocked );
171  rEntry->m_bHasButtons = true;
172  }
173 
174  if ( rEntry->m_bHasOptions && bShowOptionBtn )
175  {
177  rEntry->m_bHasButtons = true;
178  }
179  else
180  {
181  m_pParent->enableOptionsButton( false );
182  }
183 
184  if ( rEntry->m_bUser || rEntry->m_bShared )
185  {
186  m_pParent->enableRemoveButton( !rEntry->m_bLocked );
187  rEntry->m_bHasButtons = true;
188  }
189  else
190  {
191  m_pParent->enableRemoveButton( false );
192  }
193 }
194 
196 {
197  if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
198  return ExtensionBox_Impl::Command(rCEvt);
199 
200  const Point aMousePos(rCEvt.GetMousePosPixel());
201  const auto nPos = PointToPos(aMousePos);
202  OString sCommand = ShowPopupMenu(aMousePos, nPos);
203 
204  if (sCommand == "CMD_ENABLE")
205  m_pParent->enablePackage( GetEntryData( nPos )->m_xPackage, true );
206  else if (sCommand == "CMD_DISABLE")
207  m_pParent->enablePackage( GetEntryData( nPos )->m_xPackage, false );
208  else if (sCommand == "CMD_UPDATE")
210  else if (sCommand == "CMD_REMOVE")
212  else if (sCommand == "CMD_SHOW_LICENSE")
213  {
214  m_pParent->incBusy();
215  ShowLicenseDialog aLicenseDlg(m_pParent->getDialog(), GetEntryData(nPos)->m_xPackage);
216  aLicenseDlg.run();
217  m_pParent->decBusy();
218  }
219 
220  return true;
221 }
222 
223 OString ExtBoxWithBtns_Impl::ShowPopupMenu( const Point & rPos, const tools::Long nPos )
224 {
225  if ( nPos >= static_cast<tools::Long>(getItemCount()) )
226  return "CMD_NONE";
227 
228  std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(nullptr, "desktop/ui/extensionmenu.ui"));
229  std::unique_ptr<weld::Menu> xPopup(xBuilder->weld_menu("menu"));
230 
231 #if ENABLE_EXTENSION_UPDATE
232  xPopup->append("CMD_UPDATE", DpResId( RID_CTX_ITEM_CHECK_UPDATE ) );
233 #endif
234 
235  if ( ! GetEntryData( nPos )->m_bLocked )
236  {
237  if ( GetEntryData( nPos )->m_bUser )
238  {
239  if ( GetEntryData( nPos )->m_eState == REGISTERED )
240  xPopup->append("CMD_DISABLE", DpResId(RID_CTX_ITEM_DISABLE));
241  else if ( GetEntryData( nPos )->m_eState != NOT_AVAILABLE )
242  xPopup->append("CMD_ENABLE", DpResId(RID_CTX_ITEM_ENABLE));
243  }
244  if (!officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionRemoval::get())
245  {
246  xPopup->append("CMD_REMOVE", DpResId(RID_CTX_ITEM_REMOVE));
247  }
248  }
249 
250  if ( !GetEntryData( nPos )->m_sLicenseText.isEmpty() )
251  xPopup->append("CMD_SHOW_LICENSE", DpResId(RID_STR_SHOW_LICENSE_CMD));
252 
253  return xPopup->popup_at_rect(GetDrawingArea(), tools::Rectangle(rPos, Size(1, 1)));
254 }
255 
257 {
258  if (m_bInterfaceLocked)
259  return false;
261 }
262 
264 {
265  m_bInterfaceLocked = ! bEnable;
266 
267  if ( bEnable )
268  {
269  sal_Int32 nIndex = getSelIndex();
270  if ( nIndex != ExtensionBox_Impl::ENTRY_NOTFOUND )
271  SetButtonStatus( GetEntryData( nIndex ) );
272  }
273  else
274  {
275  m_pParent->enableEnableButton( false );
276  m_pParent->enableOptionsButton( false );
277  m_pParent->enableRemoveButton( false );
278  }
279 }
280 
281 // DialogHelper
282 
283 DialogHelper::DialogHelper(const uno::Reference< uno::XComponentContext > &xContext,
284  weld::Window* pWindow)
285  : m_pWindow(pWindow)
286  , m_nEventID(nullptr)
287 {
289 }
290 
292 {
293  if ( m_nEventID )
295 }
296 
297 
298 bool DialogHelper::IsSharedPkgMgr( const uno::Reference< deployment::XPackage > &xPackage )
299 {
300  return xPackage->getRepositoryName() == SHARED_PACKAGE_MANAGER;
301 }
302 
303 bool DialogHelper::continueOnSharedExtension( const uno::Reference< deployment::XPackage > &xPackage,
304  weld::Widget* pParent,
305  TranslateId pResID,
306  bool &bHadWarning )
307 {
308  if ( !bHadWarning && IsSharedPkgMgr( xPackage ) )
309  {
310  const SolarMutexGuard guard;
311  incBusy();
312  std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent,
313  VclMessageType::Warning, VclButtonsType::OkCancel, DpResId(pResID)));
314  bHadWarning = true;
315 
316  bool bRet = RET_OK == xBox->run();
317  xBox.reset();
318  decBusy();
319  return bRet;
320  }
321  else
322  return true;
323 }
324 
325 void DialogHelper::openWebBrowser(const OUString& sURL, const OUString& sTitle)
326 {
327  if ( sURL.isEmpty() ) // Nothing to do, when the URL is empty
328  return;
329 
330  try
331  {
332  uno::Reference< XSystemShellExecute > xSystemShellExecute(
334  //throws css::lang::IllegalArgumentException, css::system::SystemShellExecuteException
335  xSystemShellExecute->execute( sURL, OUString(), SystemShellExecuteFlags::URIS_ONLY );
336  }
337  catch ( const uno::Exception& )
338  {
340  OUString msg( ::comphelper::anyToString( exc ) );
341  const SolarMutexGuard guard;
342  incBusy();
343  std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(getFrameWeld(),
344  VclMessageType::Warning, VclButtonsType::Ok, msg));
345  xErrorBox->set_title(sTitle);
346  xErrorBox->run();
347  xErrorBox.reset();
348  decBusy();
349  }
350 }
351 
352 bool DialogHelper::installExtensionWarn(std::u16string_view rExtensionName)
353 {
354  const SolarMutexGuard guard;
355 
356  // Check if extension installation is disabled in the expert configurations
357  if (officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionInstallation::get())
358  {
359  incBusy();
360  std::unique_ptr<weld::MessageDialog> xWarnBox(Application::CreateMessageDialog(getFrameWeld(),
361  VclMessageType::Warning, VclButtonsType::Ok,
362  DpResId(RID_STR_WARNING_INSTALL_EXTENSION_DISABLED)));
363  xWarnBox->run();
364  xWarnBox.reset();
365  decBusy();
366 
367  return false;
368  }
369 
370  incBusy();
371  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(getFrameWeld(),
372  VclMessageType::Warning, VclButtonsType::OkCancel,
373  DpResId(RID_STR_WARNING_INSTALL_EXTENSION)));
374  OUString sText(xInfoBox->get_primary_text());
375  sText = sText.replaceAll("%NAME", rExtensionName);
376  xInfoBox->set_primary_text(sText);
377 
378  bool bRet = RET_OK == xInfoBox->run();
379  xInfoBox.reset();
380  decBusy();
381  return bRet;
382 }
383 
384 bool DialogHelper::installForAllUsers(bool &bInstallForAll)
385 {
386  const SolarMutexGuard guard;
387  incBusy();
388  std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(getFrameWeld(), "desktop/ui/installforalldialog.ui"));
389  std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog("InstallForAllDialog"));
390  short nRet = xQuery->run();
391  xQuery.reset();
392  decBusy();
393  if (nRet == RET_CANCEL)
394  return false;
395 
396  bInstallForAll = ( nRet == RET_NO );
397  return true;
398 }
399 
400 void DialogHelper::PostUserEvent( const Link<void*,void>& rLink, void* pCaller )
401 {
402  if ( m_nEventID )
404 
405  m_nEventID = Application::PostUserEvent(rLink, pCaller);
406 }
407 
408 // ExtMgrDialog
410  : GenericDialogController(pParent, "desktop/ui/extensionmanager.ui", "ExtensionManagerDialog")
411  , DialogHelper(pManager->getContext(), m_xDialog.get())
412  , m_sAddPackages(DpResId(RID_STR_ADD_PACKAGES))
413  , m_bHasProgress(false)
414  , m_bProgressChanged(false)
415  , m_bStartProgress(false)
416  , m_bStopProgress(false)
417  , m_bEnableWarning(false)
418  , m_bDisableWarning(false)
419  , m_bDeleteWarning(false)
420  , m_bClosed(false)
421  , m_nProgress(0)
422  , m_pManager(pManager)
423  , m_xExtensionBox(new ExtBoxWithBtns_Impl(m_xBuilder->weld_scrolled_window("scroll", true)))
424  , m_xExtensionBoxWnd(new weld::CustomWeld(*m_xBuilder, "extensions", *m_xExtensionBox))
425  , m_xOptionsBtn(m_xBuilder->weld_button("optionsbtn"))
426  , m_xAddBtn(m_xBuilder->weld_button("addbtn"))
427  , m_xRemoveBtn(m_xBuilder->weld_button("removebtn"))
428  , m_xEnableBtn(m_xBuilder->weld_button("enablebtn"))
429  , m_xUpdateBtn(m_xBuilder->weld_button("updatebtn"))
430  , m_xCloseBtn(m_xBuilder->weld_button("close"))
431  , m_xBundledCbx(m_xBuilder->weld_check_button("bundled"))
432  , m_xSharedCbx(m_xBuilder->weld_check_button("shared"))
433  , m_xUserCbx(m_xBuilder->weld_check_button("user"))
434  , m_xGetExtensions(m_xBuilder->weld_link_button("getextensions"))
435  , m_xProgressText(m_xBuilder->weld_label("progressft"))
436  , m_xProgressBar(m_xBuilder->weld_progress_bar("progressbar"))
437  , m_xCancelBtn(m_xBuilder->weld_button("cancel"))
438 {
439  m_xExtensionBox->InitFromDialog(this);
440 
442 
443  m_xOptionsBtn->connect_clicked( LINK( this, ExtMgrDialog, HandleOptionsBtn ) );
444  m_xAddBtn->connect_clicked( LINK( this, ExtMgrDialog, HandleAddBtn ) );
445  m_xRemoveBtn->connect_clicked( LINK( this, ExtMgrDialog, HandleRemoveBtn ) );
446  m_xEnableBtn->connect_clicked( LINK( this, ExtMgrDialog, HandleEnableBtn ) );
447  m_xCloseBtn->connect_clicked( LINK( this, ExtMgrDialog, HandleCloseBtn ) );
448 
449  m_xCancelBtn->connect_clicked( LINK( this, ExtMgrDialog, HandleCancelBtn ) );
450 
451  m_xBundledCbx->connect_toggled( LINK( this, ExtMgrDialog, HandleExtTypeCbx ) );
452  m_xSharedCbx->connect_toggled( LINK( this, ExtMgrDialog, HandleExtTypeCbx ) );
453  m_xUserCbx->connect_toggled( LINK( this, ExtMgrDialog, HandleExtTypeCbx ) );
454 
455  m_xBundledCbx->set_active(true);
456  m_xSharedCbx->set_active(true);
457  m_xUserCbx->set_active(true);
458 
459  m_xProgressBar->hide();
460 
461 #if ENABLE_EXTENSION_UPDATE
462  m_xUpdateBtn->connect_clicked( LINK( this, ExtMgrDialog, HandleUpdateBtn ) );
463  m_xUpdateBtn->set_sensitive(false);
464 #else
465  m_xUpdateBtn->hide();
466 #endif
467 
468  if (officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionInstallation::get())
469  {
470  m_xAddBtn->set_sensitive(false);
471  m_xAddBtn->set_tooltip_text(DpResId(RID_STR_WARNING_INSTALL_EXTENSION_DISABLED));
472  }
473  if (officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionRemoval::get())
474  {
475  m_xRemoveBtn->set_sensitive(false);
476  m_xRemoveBtn->set_tooltip_text(DpResId(RID_STR_WARNING_REMOVE_EXTENSION_DISABLED));
477  }
478 
479  m_aIdle.SetPriority(TaskPriority::LOWEST);
480  m_aIdle.SetDebugName( "ExtMgrDialog m_aIdle TimeOutHdl" );
481  m_aIdle.SetInvokeHandler( LINK( this, ExtMgrDialog, TimeOutHdl ) );
482 }
483 
485 {
486  m_aIdle.Stop();
487 }
488 
489 void ExtMgrDialog::setGetExtensionsURL( const OUString &rURL )
490 {
491  m_xGetExtensions->set_uri( rURL );
492 }
493 
494 void ExtMgrDialog::addPackageToList( const uno::Reference< deployment::XPackage > &xPackage,
495  bool bLicenseMissing )
496 {
497  const SolarMutexGuard aGuard;
498  m_xUpdateBtn->set_sensitive(true);
499 
500  if (m_xBundledCbx->get_active() && (xPackage->getRepositoryName() == BUNDLED_PACKAGE_MANAGER) )
501  {
502  m_xExtensionBox->addEntry( xPackage, bLicenseMissing );
503  }
504  else if (m_xSharedCbx->get_active() && (xPackage->getRepositoryName() == SHARED_PACKAGE_MANAGER) )
505  {
506  m_xExtensionBox->addEntry( xPackage, bLicenseMissing );
507  }
508  else if (m_xUserCbx->get_active() && (xPackage->getRepositoryName() == USER_PACKAGE_MANAGER ))
509  {
510  m_xExtensionBox->addEntry( xPackage, bLicenseMissing );
511  }
512 }
513 
515 {
516  m_xExtensionBox->prepareChecking();
517 }
518 
520 {
521  const SolarMutexGuard guard;
522  m_xExtensionBox->checkEntries();
523 }
524 
525 bool ExtMgrDialog::removeExtensionWarn(std::u16string_view rExtensionName)
526 {
527  const SolarMutexGuard guard;
528  incBusy();
529  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(),
530  VclMessageType::Warning, VclButtonsType::OkCancel,
531  DpResId(RID_STR_WARNING_REMOVE_EXTENSION)));
532 
533  OUString sText(xInfoBox->get_primary_text());
534  sText = sText.replaceAll("%NAME", rExtensionName);
535  xInfoBox->set_primary_text(sText);
536 
537  bool bRet = RET_OK == xInfoBox->run();
538  xInfoBox.reset();
539  decBusy();
540 
541  return bRet;
542 }
543 
544 void ExtMgrDialog::enablePackage( const uno::Reference< deployment::XPackage > &xPackage,
545  bool bEnable )
546 {
547  if ( !xPackage.is() )
548  return;
549 
550  if ( bEnable )
551  {
552  if (!continueOnSharedExtension(xPackage, m_xDialog.get(), RID_STR_WARNING_ENABLE_SHARED_EXTENSION, m_bEnableWarning))
553  return;
554  }
555  else
556  {
557  if (!continueOnSharedExtension(xPackage, m_xDialog.get(), RID_STR_WARNING_DISABLE_SHARED_EXTENSION, m_bDisableWarning))
558  return;
559  }
560 
561  m_pManager->getCmdQueue()->enableExtension( xPackage, bEnable );
562 }
563 
564 
565 void ExtMgrDialog::removePackage( const uno::Reference< deployment::XPackage > &xPackage )
566 {
567  if ( !xPackage.is() )
568  return;
569 
570  if ( !IsSharedPkgMgr( xPackage ) || m_bDeleteWarning )
571  {
572  if ( ! removeExtensionWarn( xPackage->getDisplayName() ) )
573  return;
574  }
575 
576  if (!continueOnSharedExtension(xPackage, m_xDialog.get(), RID_STR_WARNING_REMOVE_SHARED_EXTENSION, m_bDeleteWarning))
577  return;
578 
579  m_pManager->getCmdQueue()->removeExtension( xPackage );
580 }
581 
582 
583 void ExtMgrDialog::updatePackage( const uno::Reference< deployment::XPackage > &xPackage )
584 {
585  if ( !xPackage.is() )
586  return;
587 
588  // get the extension with highest version
589  uno::Sequence<uno::Reference<deployment::XPackage> > seqExtensions =
590  m_pManager->getExtensionManager()->getExtensionsWithSameIdentifier(
591  dp_misc::getIdentifier(xPackage), xPackage->getName(), uno::Reference<ucb::XCommandEnvironment>());
592  uno::Reference<deployment::XPackage> extension =
594  OSL_ASSERT(extension.is());
595  std::vector< css::uno::Reference< css::deployment::XPackage > > vEntries;
596  vEntries.push_back(extension);
597 
598  m_pManager->getCmdQueue()->checkForUpdates( vEntries );
599 }
600 
601 
602 bool ExtMgrDialog::acceptLicense( const uno::Reference< deployment::XPackage > &xPackage )
603 {
604  if ( !xPackage.is() )
605  return false;
606 
607  m_pManager->getCmdQueue()->acceptLicense( xPackage );
608 
609  return true;
610 }
611 
612 
613 uno::Sequence< OUString > ExtMgrDialog::raiseAddPicker()
614 {
615  sfx2::FileDialogHelper aDlgHelper(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, m_xDialog.get());
617  const uno::Reference<ui::dialogs::XFilePicker3>& xFilePicker = aDlgHelper.GetFilePicker();
618  xFilePicker->setTitle( m_sAddPackages );
619 
620  // collect and set filter list:
621  typedef std::map< OUString, OUString > t_string2string;
622  t_string2string title2filter;
623  OUStringBuffer supportedFilters;
624 
625  const uno::Sequence< uno::Reference< deployment::XPackageTypeInfo > > packageTypes(
626  m_pManager->getExtensionManager()->getSupportedPackageTypes() );
627 
628  for ( uno::Reference< deployment::XPackageTypeInfo > const & xPackageType : packageTypes )
629  {
630  const OUString filter( xPackageType->getFileFilter() );
631  if (!filter.isEmpty())
632  {
633  const OUString title( xPackageType->getShortDescription() );
634  const std::pair< t_string2string::iterator, bool > insertion(
635  title2filter.emplace( title, filter ) );
636  if (!supportedFilters.isEmpty())
637  supportedFilters.append(';');
638  supportedFilters.append(filter);
639  if ( ! insertion.second )
640  { // already existing, append extensions:
641  insertion.first->second = insertion.first->second +
642  ";" + filter;
643  }
644  }
645  }
646 
647  static const OUString StrAllFiles = []()
648  {
649  const SolarMutexGuard guard;
650  std::locale loc = Translate::Create("fps");
651  return Translate::get(STR_FILTERNAME_ALL, loc);
652  }();
653 
654  // All files at top:
655  xFilePicker->appendFilter( StrAllFiles, "*.*" );
656  xFilePicker->appendFilter( DpResId(RID_STR_ALL_SUPPORTED), supportedFilters.makeStringAndClear() );
657  // then supported ones:
658  for (auto const& elem : title2filter)
659  {
660  try
661  {
662  xFilePicker->appendFilter( elem.first, elem.second );
663  }
664  catch (const lang::IllegalArgumentException &)
665  {
666  TOOLS_WARN_EXCEPTION( "desktop", "" );
667  }
668  }
669  xFilePicker->setCurrentFilter( DpResId(RID_STR_ALL_SUPPORTED) );
670 
671  if ( xFilePicker->execute() != ui::dialogs::ExecutableDialogResults::OK )
672  return uno::Sequence<OUString>(); // cancelled
673 
674  uno::Sequence< OUString > files( xFilePicker->getSelectedFiles() );
675  OSL_ASSERT( files.hasElements() );
676  return files;
677 }
678 
680 {
681  m_xOptionsBtn->set_sensitive( bEnable );
682 }
683 
685 {
686  m_xRemoveBtn->set_sensitive( bEnable && !officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionRemoval::get());
687 
688  if (officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionRemoval::get())
689  {
690  m_xRemoveBtn->set_tooltip_text(DpResId(RID_STR_WARNING_REMOVE_EXTENSION_DISABLED));
691  }
692  else
693  {
694  m_xRemoveBtn->set_tooltip_text("");
695  }
696 }
697 
699 {
700  m_xEnableBtn->set_sensitive( bEnable );
701 }
702 
704 {
705  if (bEnable)
706  {
707  m_xEnableBtn->set_label( DpResId( RID_CTX_ITEM_ENABLE ) );
709  }
710  else
711  {
712  m_xEnableBtn->set_label( DpResId( RID_CTX_ITEM_DISABLE ) );
714  }
715 }
716 
717 IMPL_LINK_NOARG(ExtMgrDialog, HandleCancelBtn, weld::Button&, void)
718 {
719  if ( m_xAbortChannel.is() )
720  {
721  try
722  {
723  m_xAbortChannel->sendAbort();
724  }
725  catch ( const uno::RuntimeException & )
726  {
727  TOOLS_WARN_EXCEPTION( "dbaccess", "" );
728  }
729  }
730 }
731 
732 IMPL_LINK_NOARG(ExtMgrDialog, HandleCloseBtn, weld::Button&, void)
733 {
734  bool bCallClose = true;
735 
736  //only suggest restart if modified and this is the first close attempt
737  if (!m_bClosed && m_pManager->isModified())
738  {
739  m_pManager->clearModified();
740 
741  //only suggest restart if we're actually running, e.g. not from standalone unopkg gui
743  {
744  SolarMutexGuard aGuard;
745  bCallClose = !::svtools::executeRestartDialog(comphelper::getProcessComponentContext(),
746  m_xDialog.get(),
748  }
749  }
750 
751  if (bCallClose)
752  m_xDialog->response(RET_CANCEL);
753 }
754 
755 IMPL_LINK( ExtMgrDialog, startProgress, void*, _bLockInterface, void )
756 {
757  ::osl::MutexGuard aGuard( m_aMutex );
758  bool bLockInterface = static_cast<bool>(_bLockInterface);
759 
760  if ( m_bStartProgress && !m_bHasProgress )
761  m_aIdle.Start();
762 
763  if ( m_bStopProgress )
764  {
765  if ( m_xProgressBar->get_visible() )
766  m_xProgressBar->set_percentage( 100 );
767  m_xAbortChannel.clear();
768 
769  SAL_INFO( "desktop.deployment", " startProgress handler: stop" );
770  }
771  else
772  {
773  SAL_INFO( "desktop.deployment", " startProgress handler: start" );
774  }
775 
776  m_xCancelBtn->set_sensitive( bLockInterface );
777  m_xAddBtn->set_sensitive( !bLockInterface && !officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionInstallation::get());
778  if (officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionInstallation::get())
779  {
780  m_xAddBtn->set_tooltip_text(DpResId(RID_STR_WARNING_INSTALL_EXTENSION_DISABLED));
781  }
782  else
783  {
784  m_xAddBtn->set_tooltip_text("");
785  }
786 
787  m_xUpdateBtn->set_sensitive( !bLockInterface && m_xExtensionBox->getItemCount() );
788  m_xExtensionBox->enableButtons( !bLockInterface );
789 
790  clearEventID();
791 }
792 
793 
794 void ExtMgrDialog::showProgress( bool _bStart )
795 {
796  ::osl::MutexGuard aGuard( m_aMutex );
797 
798  bool bStart = _bStart;
799 
800  if ( bStart )
801  {
802  m_nProgress = 0;
803  m_bStartProgress = true;
804  SAL_INFO( "desktop.deployment", "showProgress start" );
805  }
806  else
807  {
808  m_nProgress = 100;
809  m_bStopProgress = true;
810  SAL_INFO( "desktop.deployment", "showProgress stop!" );
811  }
812 
813  DialogHelper::PostUserEvent( LINK( this, ExtMgrDialog, startProgress ), reinterpret_cast<void*>(bStart) );
814  m_aIdle.Start();
815 }
816 
817 
819 {
820  if ( m_nProgress != nProgress )
821  {
822  ::osl::MutexGuard aGuard( m_aMutex );
823  m_nProgress = nProgress;
824  m_aIdle.Start();
825  }
826 }
827 
828 
829 void ExtMgrDialog::updateProgress( const OUString &rText,
830  const uno::Reference< task::XAbortChannel > &xAbortChannel)
831 {
832  ::osl::MutexGuard aGuard( m_aMutex );
833 
834  m_xAbortChannel = xAbortChannel;
835  m_sProgressText = rText;
836  m_bProgressChanged = true;
837  m_aIdle.Start();
838 }
839 
840 
841 void ExtMgrDialog::updatePackageInfo( const uno::Reference< deployment::XPackage > &xPackage )
842 {
843  const SolarMutexGuard aGuard;
844  m_xExtensionBox->updateEntry( xPackage );
845 }
846 
847 IMPL_LINK_NOARG(ExtMgrDialog, HandleOptionsBtn, weld::Button&, void)
848 {
849  const sal_Int32 nActive = m_xExtensionBox->getSelIndex();
850 
851  if ( nActive != ExtensionBox_Impl::ENTRY_NOTFOUND )
852  {
854 
855  OUString sExtensionId = m_xExtensionBox->GetEntryData( nActive )->m_xPackage->getIdentifier().Value;
856  ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateOptionsDialog(m_xDialog.get(), sExtensionId));
857 
858  pDlg->Execute();
859  }
860 }
861 
863 {
864  incBusy();
865 
866  uno::Sequence< OUString > aFileList = raiseAddPicker();
867 
868  if ( aFileList.hasElements() )
869  {
870  m_pManager->installPackage( aFileList[0] );
871  }
872 
873  decBusy();
874 }
875 
876 IMPL_LINK_NOARG(ExtMgrDialog, HandleRemoveBtn, weld::Button&, void)
877 {
878  const sal_Int32 nActive = m_xExtensionBox->getSelIndex();
879 
880  if ( nActive != ExtensionBox_Impl::ENTRY_NOTFOUND )
881  {
882  TEntry_Impl pEntry = m_xExtensionBox->GetEntryData( nActive );
883  removePackage( pEntry->m_xPackage );
884  }
885 }
886 
887 IMPL_LINK_NOARG(ExtMgrDialog, HandleEnableBtn, weld::Button&, void)
888 {
889  const sal_Int32 nActive = m_xExtensionBox->getSelIndex();
890 
891  if ( nActive != ExtensionBox_Impl::ENTRY_NOTFOUND )
892  {
893  TEntry_Impl pEntry = m_xExtensionBox->GetEntryData( nActive );
894 
895  if ( pEntry->m_bMissingLic )
896  acceptLicense( pEntry->m_xPackage );
897  else
898  {
899  const bool bEnable( pEntry->m_eState != REGISTERED );
900  enablePackage( pEntry->m_xPackage, bEnable );
901  }
902  }
903 }
904 
906 {
907  // re-creates the list of packages with addEntry selecting the packages
908  prepareChecking();
909  m_pManager->createPackageList();
910  checkEntries();
911 }
912 
913 IMPL_LINK_NOARG(ExtMgrDialog, HandleUpdateBtn, weld::Button&, void)
914 {
915 #if ENABLE_EXTENSION_UPDATE
916  m_pManager->checkUpdates();
917 #else
918  (void) this;
919 #endif
920 }
921 
922 IMPL_LINK_NOARG(ExtMgrDialog, TimeOutHdl, Timer *, void)
923 {
924  if ( m_bStopProgress )
925  {
926  m_bHasProgress = false;
927  m_bStopProgress = false;
928  m_xProgressText->hide();
929  m_xProgressBar->hide();
930  m_xCancelBtn->hide();
931  }
932  else
933  {
934  if ( m_bProgressChanged )
935  {
936  m_bProgressChanged = false;
937  m_xProgressText->set_label(m_sProgressText);
938  }
939 
940  if ( m_bStartProgress )
941  {
942  m_bStartProgress = false;
943  m_bHasProgress = true;
944  m_xProgressBar->show();
945  m_xProgressText->show();
946  m_xCancelBtn->set_sensitive(true);
947  m_xCancelBtn->show();
948  }
949 
950  if ( m_xProgressBar->get_visible() )
951  m_xProgressBar->set_percentage( static_cast<sal_uInt16>(m_nProgress) );
952  }
953 }
954 
956 {
958  m_bClosed = true;
959 }
960 
961 //UpdateRequiredDialog
963  : GenericDialogController(pParent, "desktop/ui/updaterequireddialog.ui", "UpdateRequiredDialog")
964  , DialogHelper(pManager->getContext(), m_xDialog.get())
965  , m_sCloseText(DpResId(RID_STR_CLOSE_BTN))
966  , m_bHasProgress(false)
967  , m_bProgressChanged(false)
968  , m_bStartProgress(false)
969  , m_bStopProgress(false)
970  , m_bHasLockedEntries(false)
971  , m_nProgress(0)
972  , m_pManager(pManager)
973  , m_xExtensionBox(new ExtensionBox_Impl(m_xBuilder->weld_scrolled_window("scroll", true)))
974  , m_xExtensionBoxWnd(new weld::CustomWeld(*m_xBuilder, "extensions", *m_xExtensionBox))
975  , m_xUpdateNeeded(m_xBuilder->weld_label("updatelabel"))
976  , m_xUpdateBtn(m_xBuilder->weld_button("ok"))
977  , m_xCloseBtn(m_xBuilder->weld_button("disable"))
978  , m_xCancelBtn(m_xBuilder->weld_button("cancel"))
979  , m_xProgressText(m_xBuilder->weld_label("progresslabel"))
980  , m_xProgressBar(m_xBuilder->weld_progress_bar("progress"))
981 {
982  m_xExtensionBox->setExtensionManager(pManager);
983 
984  m_xUpdateBtn->connect_clicked( LINK( this, UpdateRequiredDialog, HandleUpdateBtn ) );
985  m_xCloseBtn->connect_clicked( LINK( this, UpdateRequiredDialog, HandleCloseBtn ) );
986  m_xCancelBtn->connect_clicked( LINK( this, UpdateRequiredDialog, HandleCancelBtn ) );
987 
988  OUString aText = m_xUpdateNeeded->get_label();
989  aText = aText.replaceAll(
990  "%PRODUCTNAME", utl::ConfigManager::getProductName());
991  m_xUpdateNeeded->set_label(aText);
992 
993  m_xProgressBar->hide();
994  m_xUpdateBtn->set_sensitive( false );
995  m_xCloseBtn->grab_focus();
996 
997  m_aIdle.SetPriority( TaskPriority::LOWEST );
998  m_aIdle.SetDebugName( "UpdateRequiredDialog m_aIdle TimeOutHdl" );
999  m_aIdle.SetInvokeHandler( LINK( this, UpdateRequiredDialog, TimeOutHdl ) );
1000 }
1001 
1003 {
1004  m_aIdle.Stop();
1005 }
1006 
1007 void UpdateRequiredDialog::addPackageToList( const uno::Reference< deployment::XPackage > &xPackage,
1008  bool bLicenseMissing )
1009 {
1010  // We will only add entries to the list with unsatisfied dependencies
1011  if ( !bLicenseMissing && !checkDependencies( xPackage ) )
1012  {
1013  m_bHasLockedEntries |= m_pManager->isReadOnly( xPackage );
1014  const SolarMutexGuard aGuard;
1015  m_xUpdateBtn->set_sensitive(true);
1016  m_xExtensionBox->addEntry( xPackage );
1017  }
1018 }
1019 
1020 
1022 {
1023  m_xExtensionBox->prepareChecking();
1024 }
1025 
1026 
1028 {
1029  const SolarMutexGuard guard;
1030  m_xExtensionBox->checkEntries();
1031 
1032  if ( ! hasActiveEntries() )
1033  {
1034  m_xCloseBtn->set_label( m_sCloseText );
1035  m_xCloseBtn->grab_focus();
1036  }
1037 }
1038 
1039 
1041 {
1042  if ( m_xAbortChannel.is() )
1043  {
1044  try
1045  {
1046  m_xAbortChannel->sendAbort();
1047  }
1048  catch ( const uno::RuntimeException & )
1049  {
1050  TOOLS_WARN_EXCEPTION( "desktop", "" );
1051  }
1052  }
1053 }
1054 
1055 
1056 IMPL_LINK( UpdateRequiredDialog, startProgress, void*, _bLockInterface, void )
1057 {
1058  ::osl::MutexGuard aGuard( m_aMutex );
1059  bool bLockInterface = static_cast<bool>(_bLockInterface);
1060 
1061  if ( m_bStartProgress && !m_bHasProgress )
1062  m_aIdle.Start();
1063 
1064  if ( m_bStopProgress )
1065  {
1066  if ( m_xProgressBar->get_visible() )
1067  m_xProgressBar->set_percentage( 100 );
1068  m_xAbortChannel.clear();
1069  SAL_INFO( "desktop.deployment", " startProgress handler: stop" );
1070  }
1071  else
1072  {
1073  SAL_INFO( "desktop.deployment", " startProgress handler: start" );
1074  }
1075 
1076  m_xCancelBtn->set_sensitive( bLockInterface );
1077  m_xUpdateBtn->set_sensitive( false );
1078  clearEventID();
1079 }
1080 
1081 
1083 {
1084  ::osl::MutexGuard aGuard( m_aMutex );
1085 
1086  bool bStart = _bStart;
1087 
1088  if ( bStart )
1089  {
1090  m_nProgress = 0;
1091  m_bStartProgress = true;
1092  SAL_INFO( "desktop.deployment", "showProgress start" );
1093  }
1094  else
1095  {
1096  m_nProgress = 100;
1097  m_bStopProgress = true;
1098  SAL_INFO( "desktop.deployment", "showProgress stop!" );
1099  }
1100 
1101  DialogHelper::PostUserEvent( LINK( this, UpdateRequiredDialog, startProgress ), reinterpret_cast<void*>(bStart) );
1102  m_aIdle.Start();
1103 }
1104 
1105 
1107 {
1108  if ( m_nProgress != nProgress )
1109  {
1110  ::osl::MutexGuard aGuard( m_aMutex );
1111  m_nProgress = nProgress;
1112  m_aIdle.Start();
1113  }
1114 }
1115 
1116 
1117 void UpdateRequiredDialog::updateProgress( const OUString &rText,
1118  const uno::Reference< task::XAbortChannel > &xAbortChannel)
1119 {
1120  ::osl::MutexGuard aGuard( m_aMutex );
1121 
1122  m_xAbortChannel = xAbortChannel;
1123  m_sProgressText = rText;
1124  m_bProgressChanged = true;
1125  m_aIdle.Start();
1126 }
1127 
1128 
1129 void UpdateRequiredDialog::updatePackageInfo( const uno::Reference< deployment::XPackage > &xPackage )
1130 {
1131  // We will remove all updated packages with satisfied dependencies, but
1132  // we will show all disabled entries so the user sees the result
1133  // of the 'disable all' button
1134  const SolarMutexGuard aGuard;
1135  if ( isEnabled( xPackage ) && checkDependencies( xPackage ) )
1136  m_xExtensionBox->removeEntry( xPackage );
1137  else
1138  m_xExtensionBox->updateEntry( xPackage );
1139 
1140  if ( ! hasActiveEntries() )
1141  {
1142  m_xCloseBtn->set_label( m_sCloseText );
1143  m_xCloseBtn->grab_focus();
1144  }
1145 }
1146 
1147 
1149 {
1150  ::osl::ClearableMutexGuard aGuard( m_aMutex );
1151 
1152  std::vector< uno::Reference< deployment::XPackage > > vUpdateEntries;
1153  sal_Int32 nCount = m_xExtensionBox->GetEntryCount();
1154 
1155  for ( sal_Int32 i = 0; i < nCount; ++i )
1156  {
1157  TEntry_Impl pEntry = m_xExtensionBox->GetEntryData( i );
1158  vUpdateEntries.push_back( pEntry->m_xPackage );
1159  }
1160 
1161  aGuard.clear();
1162 
1163  m_pManager->getCmdQueue()->checkForUpdates( vUpdateEntries );
1164 }
1165 
1166 
1168 {
1169  ::osl::MutexGuard aGuard( m_aMutex );
1170 
1171  if ( !isBusy() )
1172  {
1173  if ( m_bHasLockedEntries )
1174  m_xDialog->response(-1);
1175  else if ( hasActiveEntries() )
1176  disableAllEntries();
1177  else
1178  m_xDialog->response(RET_CANCEL);
1179  }
1180 }
1181 
1182 
1184 {
1185  if ( m_bStopProgress )
1186  {
1187  m_bHasProgress = false;
1188  m_bStopProgress = false;
1189  m_xProgressText->hide();
1190  m_xProgressBar->hide();
1191  m_xCancelBtn->hide();
1192  }
1193  else
1194  {
1195  if ( m_bProgressChanged )
1196  {
1197  m_bProgressChanged = false;
1198  m_xProgressText->set_label( m_sProgressText );
1199  }
1200 
1201  if ( m_bStartProgress )
1202  {
1203  m_bStartProgress = false;
1204  m_bHasProgress = true;
1205  m_xProgressBar->show();
1206  m_xProgressText->show();
1207  m_xCancelBtn->set_sensitive(true);
1208  m_xCancelBtn->show();
1209  }
1210 
1211  if (m_xProgressBar->get_visible())
1212  m_xProgressBar->set_percentage(m_nProgress);
1213  }
1214 }
1215 
1216 // VCL::Dialog
1218 {
1219  //ToDo
1220  //I believe m_bHasLockedEntries was used to prevent showing extensions which cannot
1221  //be disabled because they are in a read only repository. However, disabling extensions
1222  //is now always possible because the registration data of all repositories
1223  //are in the user installation.
1224  //Therefore all extensions could be displayed and all the handling around m_bHasLockedEntries
1225  //could be removed.
1226  if ( m_bHasLockedEntries )
1227  {
1228  // Set other text, disable update btn, remove not shared entries from list;
1229  m_xUpdateNeeded->set_label( DpResId( RID_STR_NO_ADMIN_PRIVILEGE ) );
1230  m_xCloseBtn->set_label( DpResId( RID_STR_EXIT_BTN ) );
1231  m_xUpdateBtn->set_sensitive( false );
1232  m_xExtensionBox->RemoveUnlocked();
1233  }
1234 
1235  return GenericDialogController::run();
1236 }
1237 
1238 // Check dependencies of all packages
1239 
1240 bool UpdateRequiredDialog::isEnabled( const uno::Reference< deployment::XPackage > &xPackage )
1241 {
1242  bool bRegistered = false;
1243  try {
1244  beans::Optional< beans::Ambiguous< sal_Bool > > option( xPackage->isRegistered( uno::Reference< task::XAbortChannel >(),
1245  uno::Reference< ucb::XCommandEnvironment >() ) );
1246  if ( option.IsPresent )
1247  {
1248  ::beans::Ambiguous< sal_Bool > const & reg = option.Value;
1249  if ( reg.IsAmbiguous )
1250  bRegistered = false;
1251  else
1252  bRegistered = reg.Value;
1253  }
1254  else
1255  bRegistered = false;
1256  }
1257  catch ( const uno::RuntimeException & ) { throw; }
1258  catch (const uno::Exception & ) {
1259  TOOLS_WARN_EXCEPTION( "desktop", "" );
1260  bRegistered = false;
1261  }
1262 
1263  return bRegistered;
1264 }
1265 
1266 // Checks the dependencies no matter if the extension is enabled or disabled!
1267 bool UpdateRequiredDialog::checkDependencies( const uno::Reference< deployment::XPackage > &xPackage )
1268 {
1269  bool bDependenciesValid = false;
1270  try {
1271  bDependenciesValid = xPackage->checkDependencies( uno::Reference< ucb::XCommandEnvironment >() );
1272  }
1273  catch ( const deployment::DeploymentException & ) {}
1274  return bDependenciesValid;
1275 }
1276 
1277 
1279 {
1280  ::osl::MutexGuard aGuard( m_aMutex );
1281 
1282  bool bRet = false;
1283  tools::Long nCount = m_xExtensionBox->GetEntryCount();
1284  for ( tools::Long nIndex = 0; nIndex < nCount; nIndex++ )
1285  {
1286  TEntry_Impl pEntry = m_xExtensionBox->GetEntryData( nIndex );
1287 
1288  if ( isEnabled(pEntry->m_xPackage) && !checkDependencies( pEntry->m_xPackage ) )
1289  {
1290  bRet = true;
1291  break;
1292  }
1293  }
1294 
1295  return bRet;
1296 }
1297 
1298 
1300 {
1301  ::osl::MutexGuard aGuard( m_aMutex );
1302 
1303  incBusy();
1304 
1305  tools::Long nCount = m_xExtensionBox->GetEntryCount();
1306  for ( tools::Long nIndex = 0; nIndex < nCount; nIndex++ )
1307  {
1308  TEntry_Impl pEntry = m_xExtensionBox->GetEntryData( nIndex );
1309  m_pManager->getCmdQueue()->enableExtension( pEntry->m_xPackage, false );
1310  }
1311 
1312  decBusy();
1313 
1314  if ( ! hasActiveEntries() )
1315  m_xCloseBtn->set_label( m_sCloseText );
1316 }
1317 
1318 // ShowLicenseDialog
1320  const uno::Reference< deployment::XPackage> &xPackage)
1321  : GenericDialogController(pParent, "desktop/ui/showlicensedialog.ui", "ShowLicenseDialog")
1322  , m_xLicenseText(m_xBuilder->weld_text_view("textview"))
1323 {
1324  m_xLicenseText->set_size_request(m_xLicenseText->get_approximate_digit_width() * 72,
1325  m_xLicenseText->get_height_rows(21));
1326  m_xLicenseText->set_text(xPackage->getLicenseText());
1327 }
1328 
1330 {
1331 }
1332 
1333 // UpdateRequiredDialogService
1334 
1335 UpdateRequiredDialogService::UpdateRequiredDialogService( SAL_UNUSED_PARAMETER uno::Sequence< uno::Any > const&,
1336  uno::Reference< uno::XComponentContext > const& xComponentContext )
1337  : m_xComponentContext( xComponentContext )
1338 {
1339 }
1340 
1341 // XServiceInfo
1343 {
1344  return "com.sun.star.comp.deployment.ui.UpdateRequiredDialog";
1345 }
1346 
1348 {
1349  return cppu::supportsService(this, ServiceName);
1350 }
1351 
1353 {
1354  return { "com.sun.star.deployment.ui.UpdateRequiredDialog" };
1355 }
1356 
1357 
1358 // XExecutableDialog
1359 
1361 {
1362 }
1363 
1364 
1366 {
1369  xManager->createDialog( true );
1370  sal_Int16 nRet = xManager->execute();
1371 
1372  return nRet;
1373 }
1374 
1375 
1376 } //namespace dp_gui
1377 
1378 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
std::shared_ptr< weld::Dialog > m_xDialog
UpdateRequiredDialog(weld::Window *pParent, TheExtensionManager *pManager)
sal_Int32 nIndex
static weld::Builder * CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
virtual void addPackageToList(const css::uno::Reference< css::deployment::XPackage > &, bool bLicenseMissing=false) override
virtual void selectEntry(const tools::Long nPos)
virtual ~ShowLicenseDialog() override
void setGetExtensionsURL(const OUString &rURL)
css::uno::Sequence< OUString > raiseAddPicker()
static SfxAbstractDialogFactory * Create()
static bool isEnabled(const css::uno::Reference< css::deployment::XPackage > &xPackage)
virtual short run() override
css::uno::Reference< css::task::XAbortChannel > m_xAbortChannel
virtual void prepareChecking() override
virtual ~UpdateRequiredDialog() override
RESTART_REASON_EXTENSION_INSTALL
void setExtensionManager(TheExtensionManager *pManager)
DialogHelper(const css::uno::Reference< css::uno::XComponentContext > &, weld::Window *pWindow)
long Long
virtual void updateProgress(const OUString &rText, const css::uno::Reference< css::task::XAbortChannel > &xAbortChannel) override
const css::uno::Reference< css::deployment::XExtensionManager > & getExtensionManager() const
std::unique_ptr< weld::Button > m_xOptionsBtn
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
std::unique_ptr< weld::CheckButton > m_xSharedCbx
void PostUserEvent(const Link< void *, void > &rLink, void *pCaller)
bool office_is_running()
Definition: dp_misc.cxx:331
virtual ~ExtMgrDialog() override
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
std::unique_ptr< weld::ProgressBar > m_xProgressBar
ToolBarManager * m_pManager
virtual short Execute()=0
std::unique_ptr< weld::CheckButton > m_xUserCbx
std::unique_ptr< weld::Button > m_xUpdateBtn
virtual Dialog * getDialog() override
RET_CANCEL
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)
IMPL_LINK_NOARG(ExtMgrDialog, HandleCancelBtn, weld::Button &, void)
virtual bool Command(const CommandEvent &rCEvt) override
std::unique_ptr< weld::LinkButton > m_xGetExtensions
virtual VclPtr< VclAbstractDialog > CreateOptionsDialog(weld::Window *pParent, const OUString &rExtensionId)=0
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
std::unique_ptr< weld::Button > m_xEnableBtn
ShowLicenseDialog(weld::Window *pParent, const css::uno::Reference< css::deployment::XPackage > &xPackage)
virtual void updatePackageInfo(const css::uno::Reference< css::deployment::XPackage > &xPackage) override
RET_NO
static::rtl::Reference< TheExtensionManager > get(css::uno::Reference< css::uno::XComponentContext > const &xContext, css::uno::Reference< css::awt::XWindow > const &xParent=nullptr, OUString const &view=OUString())
virtual void selectEntry(const tools::Long nPos) override
virtual void showProgress(bool bStart) override
JCOPY_OPTION option
std::unique_ptr< weld::Label > m_xUpdateNeeded
void SetButtonStatus(const TEntry_Impl &rEntry)
css::uno::Reference< css::uno::XComponentContext > m_xContext
Any SAL_CALL getCaughtException()
void removePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage)
int nCount
void enablePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage, bool bEnable)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
constexpr OUStringLiteral USER_PACKAGE_MANAGER
std::mutex m_aMutex
css::uno::Reference< css::task::XAbortChannel > m_xAbortChannel
void removeExtension(const css::uno::Reference< css::deployment::XPackage > &rPackage)
constexpr OUStringLiteral SHARED_PACKAGE_MANAGER
std::unique_ptr< weld::Button > m_xUpdateBtn
void enableOptionsButton(bool bEnable)
ImplSVEvent * m_nEventID
void SetContext(Context _eNewContext)
void SetDebugName(const char *pDebugName)
std::locale Create(std::string_view aPrefixName, const LanguageTag &rLocale)
Reference< XComponentContext > const m_xComponentContext
virtual void updateProgress(const OUString &rText, const css::uno::Reference< css::task::XAbortChannel > &xAbortChannel) override
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
std::unique_ptr< weld::Button > m_xCloseBtn
std::unique_ptr< weld::ProgressBar > m_xProgressBar
TEntry_Impl const & GetEntryData(tools::Long nPos)
#define TOOLS_WARN_EXCEPTION(area, stream)
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
int i
static OUString getProductName()
bool acceptLicense(const css::uno::Reference< css::deployment::XPackage > &xPackage)
void checkForUpdates(const std::vector< css::uno::Reference< css::deployment::XPackage > > &vList)
bool isReadOnly(const css::uno::Reference< css::deployment::XPackage > &xPackage) const
std::unique_ptr< ExtensionBox_Impl > m_xExtensionBox
virtual void checkEntries() override
void openWebBrowser(const OUString &rURL, const OUString &rTitle)
void updatePackage(const css::uno::Reference< css::deployment::XPackage > &xPackage)
CommandEventId GetCommand() const
float u
unsigned char sal_Bool
static bool checkDependencies(const css::uno::Reference< css::deployment::XPackage > &xPackage)
ExtMgrDialog(weld::Window *pParent, TheExtensionManager *pManager)
OUString get(TranslateId sContextAndId, const std::locale &loc)
void enableEnableButton(bool bEnable)
bool continueOnSharedExtension(const css::uno::Reference< css::deployment::XPackage > &, weld::Widget *pParent, TranslateId pResID, bool &bHadWarning)
virtual void updatePackageInfo(const css::uno::Reference< css::deployment::XPackage > &xPackage) override
std::unique_ptr< weld::Button > m_xAddBtn
virtual sal_Int16 SAL_CALL execute() override
sal_Int32 getSelIndex() const
const Point & GetMousePosPixel() const
bool removeExtensionWarn(std::u16string_view rExtensionTitle)
static uno::Reference< css::uno::XComponentContext > xContext
Definition: init.cxx:2261
void enableButtontoEnable(bool bEnable)
bool installForAllUsers(bool &bInstallForAll)
void acceptLicense(const css::uno::Reference< css::deployment::XPackage > &rPackage)
weld::DrawingArea * GetDrawingArea() const
TheExtensionManager * m_pManager
sal_Int32 getItemCount() const
void Stop()
constexpr OUStringLiteral BUNDLED_PACKAGE_MANAGER
std::unique_ptr< weld::Button > m_xCancelBtn
void enableExtension(const css::uno::Reference< css::deployment::XPackage > &rPackage, const bool bEnable)
std::unique_ptr< weld::Button > m_xCancelBtn
OUString DpResId(TranslateId aId)
Definition: dp_shared.hxx:36
ExtBoxWithBtns_Impl(std::unique_ptr< weld::ScrolledWindow > xScroll)
#define HID_EXTENSION_MANAGER_LISTBOX_DISABLE
Definition: helpids.h:23
ExtensionCmdQueue * getCmdQueue() const
#define SAL_INFO(area, stream)
virtual void RecalcAll() override
tools::Long PointToPos(const Point &rPos)
std::unique_ptr< weld::Button > m_xCloseBtn
TheExtensionManager * getExtensionManager() const
RET_OK
std::unique_ptr< ExtBoxWithBtns_Impl > m_xExtensionBox
uno::Reference< deployment::XPackage > m_xPackage
TheExtensionManager * m_pManager
weld::Window * getFrameWeld() const
Reference< XExecutableDialog > m_xDialog
virtual short run()
std::unique_ptr< weld::Button > m_xRemoveBtn
OString ShowPopupMenu(const Point &rPos, const tools::Long nPos)
Reference< XComponentContext > getProcessComponentContext()
void SetInvokeHandler(const Link< Timer *, void > &rLink)
const OUString m_sAddPackages
void enableButtons(bool bEnable)
virtual void Start(bool bStartTimer=true) override
void SetPriority(TaskPriority ePriority)
virtual void checkEntries() override
UpdateRequiredDialogService(css::uno::Sequence< css::uno::Any > const &args, css::uno::Reference< css::uno::XComponentContext > const &xComponentContext)
bool installExtensionWarn(std::u16string_view rExtensionURL)
css::uno::Reference< css::uno::XComponentContext > const m_xComponentContext
virtual OUString SAL_CALL getImplementationName() override
Definition: dp_gui.h:22
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString getIdentifier(css::uno::Reference< css::deployment::XPackage > const &package)
Gets the identifier of a package.
virtual bool Command(const CommandEvent &)
std::unique_ptr< weld::CheckButton > m_xBundledCbx
void InitFromDialog(ExtMgrDialog *pParentDialog)
virtual void prepareChecking() override
std::unique_ptr< weld::TextView > m_xLicenseText
#define HID_EXTENSION_MANAGER_LISTBOX_ENABLE
Definition: helpids.h:22
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
void enableRemoveButton(bool bEnable)
virtual void SAL_CALL setTitle(OUString const &title) override
sal_uInt16 nPos
std::shared_ptr< Entry_Impl > TEntry_Impl
virtual void showProgress(bool bStart) override
OUString anyToString(uno::Any const &value)
IMPL_LINK(ExtMgrDialog, startProgress, void *, _bLockInterface, void)
static bool IsSharedPkgMgr(const css::uno::Reference< css::deployment::XPackage > &)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC css::uno::Reference< css::deployment::XPackage > getExtensionWithHighestVersion(css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > const &seqExtensionsWithSameId)
virtual void addPackageToList(const css::uno::Reference< css::deployment::XPackage > &, bool bLicenseMissing=false) override
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo