24#include <sfx2/strings.hrc>
27#include <com/sun/star/task/InteractionHandler.hpp>
28#include <com/sun/star/frame/Desktop.hpp>
29#include <com/sun/star/frame/TerminationVetoException.hpp>
30#include <com/sun/star/frame/XDispatchResultListener.hpp>
31#include <com/sun/star/frame/XNotifyingDispatch.hpp>
32#include <com/sun/star/frame/XFramesSupplier.hpp>
33#include <com/sun/star/frame/XFrame.hpp>
34#include <com/sun/star/util/URLTransformer.hpp>
35#include <com/sun/star/util/XURLTransformer.hpp>
36#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
37#include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
38#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
39#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
40#include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
41#include <com/sun/star/ui/dialogs/ControlActions.hpp>
42#include <com/sun/star/document/MacroExecMode.hpp>
43#include <com/sun/star/document/UpdateDocMode.hpp>
52#include <officecfg/Office/Common.hxx>
55#include <osl/file.hxx>
56#include <osl/module.hxx>
71using namespace ::
sfx2;
91 return "com.sun.star.comp.desktop.QuickstartWrapper";
101 return {
"com.sun.star.office.Quickstart" };
113#ifdef ENABLE_QUICKSTART_APPLET
127#ifdef ENABLE_QUICKSTART_APPLET
148 m_bListenForTermination ( false ),
151 m_bInitialized( false )
167 if ( !xDispatchProvider.is() )
170 css::util::URL aDispatchURL;
171 aDispatchURL.Complete =
aURL;
173 css::uno::Reference< util::XURLTransformer > xURLTransformer( util::URLTransformer::create( ::comphelper::getProcessComponentContext() ) );
176 css::uno::Reference< css::frame::XDispatch >
xDispatch;
178 xURLTransformer->parseStrict( aDispatchURL );
181 xDispatch->dispatch( aDispatchURL, aArgs );
183 catch ( css::uno::RuntimeException& )
187 catch ( css::uno::Exception& )
210 css::uno::Reference < css::frame::XFrame >
xFrame( xDesktop->getActiveFrame() );
216 css::uno::Reference< util::XURLTransformer > xTrans( util::URLTransformer::create( ::comphelper::getProcessComponentContext() ) );
219 css::uno::Reference < css::frame::XDispatchProvider > xProv(
xFrame, UNO_QUERY );
220 css::uno::Reference < css::frame::XDispatch > xDisp;
223 xDisp = xProv->queryDispatch(
aTargetURL,
"_self", 0 );
229 css::uno::Reference< css::frame::XNotifyingDispatch > xNotifier(xDisp, UNO_QUERY);
259 ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION,
266 DBG_ASSERT( m_pFileDlg,
"ShutdownIcon, DialogClosedHdl_Impl(): no file dialog" );
271 css::uno::Reference< XFilePicker3 > xPicker = m_pFileDlg->GetFilePicker();
279 css::uno::Reference < XFilePickerControlAccess > xPickerControls ( xPicker, UNO_QUERY );
281 Sequence< OUString > sFiles = xPicker->getSelectedFiles();
282 int nFiles = sFiles.getLength();
284 css::uno::Reference < css::task::XInteractionHandler2 > xInteraction(
285 task::InteractionHandler::createWithParent(::comphelper::getProcessComponentContext(),
nullptr) );
288 Sequence< PropertyValue > aArgs{
296 OUString aFilterName( m_pFileDlg->GetCurrentFilter() );
298 if ( xPickerControls.is() )
306 xPickerControls->getValue( ExtendedFilePickerElementIds::CHECKBOX_READONLY, 0 ) >>=
bReadOnly;
312 aArgs.realloc( ++nArgs );
313 auto pArgs = aArgs.getArray();
314 pArgs[nArgs-1].Name =
"ReadOnly";
320 sal_Int32 iVersion = -1;
322 xPickerControls->getValue( ExtendedFilePickerElementIds::LISTBOX_VERSION, ControlActions::GET_SELECTED_ITEM_INDEX ) >>= iVersion;
326 sal_Int16 uVersion =
static_cast<sal_Int16
>(iVersion);
328 aArgs.realloc( ++nArgs );
329 auto pArgs = aArgs.getArray();
330 pArgs[nArgs-1].Name =
"Version";
331 pArgs[nArgs-1].Value <<= uVersion;
336 if ( aFilterName.isEmpty() )
337 xPickerControls->getValue( CommonFilePickerElementIds::LISTBOX_FILTER, ControlActions::GET_SELECTED_ITEM ) >>= aFilterName;
344 if ( !aFilterName.isEmpty() )
350 aFilterName = pFilter->GetFilterName();
352 if ( !aFilterName.isEmpty() )
354 aArgs.realloc( ++nArgs );
355 auto pArgs = aArgs.getArray();
356 pArgs[nArgs-1].Name =
"FilterName";
357 pArgs[nArgs-1].Value <<= aFilterName;
363 OpenURL( sFiles[0],
"_default", aArgs );
366 OUString aBaseDirURL = sFiles[0];
367 if ( !aBaseDirURL.isEmpty() && !aBaseDirURL.endsWith(
"/") )
371 for ( iFiles = 1; iFiles < nFiles; iFiles++ )
373 OUString
aURL = aBaseDirURL + sFiles[iFiles];
374 OpenURL(
aURL,
"_default", aArgs );
408 css::uno::Reference< XDesktop2 > xDesktop = pInst->
m_xDesktop;
409 if ( ! xDesktop.is())
412 xDesktop->addTerminateListener( pInst );
423 css::uno::Reference< XDesktop2 > xDesktop = pInst->
m_xDesktop;
424 if ( ! xDesktop.is())
429 xDesktop->removeTerminateListener( pInst );
432 css::uno::Reference< XIndexAccess > xTasks = xDesktop->getFrames();
433 if( xTasks.is() && xTasks->getCount() < 1 )
465 css::uno::Reference < XDesktop2 > xDesktop = Desktop::create(
m_xContext );
489 SAL_INFO(
"sfx.appl",
"ShutdownIcon::queryTermination: veto is " <<
m_bVeto);
490 std::unique_lock aGuard(
m_aMutex );
493 throw css::frame::TerminationVetoException();
504 std::unique_lock aGuard(
m_aMutex );
520 bool bQuickstart = ::cppu::any2bool(
aArguments[0] );
533 catch(
const css::lang::IllegalArgumentException&)
540 bool bAutostart = ::cppu::any2bool(
aArguments[1] );
573#ifdef ENABLE_QUICKSTART_APPLET
577 return GetAutostartFolderNameW32() +
"\\" +
SfxResId(STR_QUICKSTART_LNKNAME) +
".lnk";
586#elif defined ENABLE_QUICKSTART_APPLET
589 OUString aShortcutUrl;
590 osl::File::getFileURLFromSystemPath( aShortcut, aShortcutUrl );
591 osl::File f( aShortcutUrl );
592 osl::File::RC error = f.open( osl_File_OpenFlag_Read );
593 if( error == osl::File::E_None )
606#ifdef ENABLE_QUICKSTART_APPLET
614 EnableAutostartW32( aShortcut );
620 OUString aShortcutUrl;
621 ::osl::File::getFileURLFromSystemPath( aShortcut, aShortcutUrl );
622 ::osl::File::remove( aShortcutUrl );
634 const css::uno::Any& aValue )
641 bool bState(
false );
642 if (! (aValue >>= bState))
652 throw css::beans::UnknownPropertyException(OUString::number(
nHandle));
659 css::uno::Any aValue;
670 throw css::beans::UnknownPropertyException(OUString::number(
nHandle));
676extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
678 css::uno::XComponentContext *context,
679 css::uno::Sequence<css::uno::Any>
const &)
Reference< XComponentContext > m_xContext
SfxApplication * SfxGetpApp()
static bool IsHeadlessModeEnabled()
SfxFilterMatcher & GetFilterMatcher()
std::shared_ptr< const SfxFilter > GetFilter4UIName(std::u16string_view rName, SfxFilterFlags nMust=SfxFilterFlags::NONE, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
virtual void SAL_CALL dispatchFinished(const DispatchResultEvent &aEvent) override
virtual void SAL_CALL disposing(const EventObject &aEvent) override
virtual void disposing(std::unique_lock< std::mutex > &) override
static bool IsQuickstarterInstalled()
static ShutdownIcon * createInstance()
virtual ~ShutdownIcon() override
static ShutdownIcon * getInstance()
static OUString getShortcutName()
virtual void SAL_CALL setFastPropertyValue(::sal_Int32 nHandle, const css::uno::Any &aValue) override
bool m_bListenForTermination
static void terminateDesktop()
static rtl::Reference< ShutdownIcon > pShutdownIcon
css::uno::Reference< css::frame::XDesktop2 > m_xDesktop
css::uno::Reference< css::uno::XComponentContext > m_xContext
static void FromTemplate()
virtual void SAL_CALL queryTermination(const css::lang::EventObject &aEvent) override
std::unique_ptr< sfx2::FileDialogHelper > m_pFileDlg
static void addTerminateListener()
virtual void SAL_CALL notifyTermination(const css::lang::EventObject &aEvent) override
ShutdownIcon(css::uno::Reference< css::uno::XComponentContext > xContext)
virtual sal_Bool SAL_CALL supportsService(OUString const &ServiceName) override
virtual css::uno::Any SAL_CALL getFastPropertyValue(::sal_Int32 nHandle) override
static OUString GetUrlDescription(std::u16string_view aUrl)
static void LeaveModalMode()
static bool GetAutostart()
virtual OUString SAL_CALL getImplementationName() override
static void SetAutostart(bool bActivate)
static void OpenURL(const OUString &aURL, const OUString &rTarget, const css::uno::Sequence< css::beans::PropertyValue > &=css::uno::Sequence< css::beans::PropertyValue >(0))
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
static void EnterModalMode()
#define DBG_ASSERT(sCon, aError)
Reference< XDispatch > xDispatch
Sequence< PropertyValue > aArguments
#define LINK(Instance, Class, Member)
#define SAL_INFO(area, stream)
Reference< XComponentContext > getProcessComponentContext()
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
OUString SfxResId(TranslateId aId)
IMPL_LINK(ShutdownIcon, DialogClosedHdl_Impl, FileDialogHelper *,, void)
static bool UseSystemFileDialog()
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_desktop_QuickstartWrapper_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
const ::sal_Int32 PROPHANDLE_TERMINATEVETOSTATE
void SAL_DLLPUBLIC_EXPORT aqua_shutdown_systray()
void win32_init_sys_tray()
void win32_shutdown_sys_tray()
Reference< XFrame > xFrame