1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <config_features.h>
21 #include <com/sun/star/document/XEmbeddedScripts.hpp>
22 #include <com/sun/star/drawing/ModuleDispatcher.hpp>
23 #include <com/sun/star/frame/Desktop.hpp>
24 #include <com/sun/star/frame/DispatchResultEvent.hpp>
25 #include <com/sun/star/frame/DispatchResultState.hpp>
26 #include <com/sun/star/frame/DispatchHelper.hpp>
27 #include <com/sun/star/frame/UnknownModuleException.hpp>
28 #include <com/sun/star/frame/XLayoutManager.hpp>
29 #include <com/sun/star/frame/XSynchronousFrameLoader.hpp>
30 #include <com/sun/star/sdbc/DriverManager.hpp>
31 #include <com/sun/star/system/SystemShellExecute.hpp>
32 #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
33 #include <com/sun/star/text/ModuleDispatcher.hpp>
34 #include <com/sun/star/task/OfficeRestartManager.hpp>
35 #include <com/sun/star/task/XInteractionHandler.hpp>
36 #include <com/sun/star/ui/dialogs/AddressBookSourcePilot.hpp>
37 #include <com/sun/star/ui/UIElementType.hpp>
38 #include <com/sun/star/ui/XUIElement.hpp>
39 #include <com/sun/star/uno/Reference.hxx>
40 #include <com/sun/star/util/XCloseable.hpp>
41 #include <com/sun/star/util/CloseVetoException.hpp>
42 #include <org/freedesktop/PackageKit/SyncDbusSessionHelper.hpp>
44 #include <comphelper/dispatchcommand.hxx>
45 #include <comphelper/lok.hxx>
46 #include <comphelper/namedvaluecollection.hxx>
47 #include <comphelper/processfactory.hxx>
48 #include <comphelper/propertysequence.hxx>
49 #include <comphelper/sequence.hxx>
51 #include <svtools/addresstemplate.hxx>
52 #include <svtools/miscopt.hxx>
53 #include <svtools/restartdialog.hxx>
54 #include <svl/visitem.hxx>
56 #include <unotools/configmgr.hxx>
57 #include <tools/svlibrary.h>
58 #include <tools/diagnose_ex.h>
59 #include <vcl/svapp.hxx>
60 #include <vcl/weld.hxx>
61 #include <svl/intitem.hxx>
62 #include <svl/eitem.hxx>
63 #include <svl/stritem.hxx>
64 #include <basic/sbstar.hxx>
65 #include <basic/basrdll.hxx>
66 #include <basic/sberrors.hxx>
67 #include <vcl/help.hxx>
68 #include <rtl/ustrbuf.hxx>
69 #include <sal/log.hxx>
70 #include <osl/file.hxx>
71 #include <vcl/EnumContext.hxx>
73 #include <unotools/moduleoptions.hxx>
74 #include <svtools/helpopt.hxx>
75 #include <toolkit/helper/vclunohelper.hxx>
76 #include <rtl/bootstrap.hxx>
78 #include <com/sun/star/frame/ModuleManager.hpp>
79 #include <com/sun/star/beans/XPropertySet.hpp>
81 #include <sfx2/app.hxx>
82 #include <sfx2/request.hxx>
83 #include <sfx2/dispatch.hxx>
84 #include <sfx2/bindings.hxx>
85 #include <sfx2/msg.hxx>
86 #include <sfx2/objface.hxx>
87 #include <sfx2/objsh.hxx>
88 #include <sfx2/viewsh.hxx>
89 #include <sfx2/docfac.hxx>
90 #include <sfx2/strings.hrc>
91 #include <sfx2/sfxresid.hxx>
92 #include <appdata.hxx>
93 #include <sfx2/viewfrm.hxx>
94 #include <sfx2/sfxdlg.hxx>
95 #include <sfx2/sfxsids.hrc>
96 #include <sorgitm.hxx>
97 #include <sfx2/sfxhelp.hxx>
98 #include <sfx2/zoomitem.hxx>
99 #include <sfx2/templatedlg.hxx>
100 #include <sfx2/notebookbar/SfxNotebookBar.hxx>
101 #include <sfx2/sidebar/SidebarController.hxx>
102 #include <sfx2/safemode.hxx>
103 #include <sfx2/sfxuno.hxx>
105 #include <comphelper/types.hxx>
106 #include <officecfg/Office/Common.hxx>
107 #include <unotools/confignode.hxx>
108 #include <officecfg/Setup.hxx>
111 #include <openuriexternally.hxx>
113 #include "getbasctlfunction.hxx"
115 using namespace ::com::sun::star
;
116 using namespace ::com::sun::star::beans
;
117 using namespace ::com::sun::star::uno
;
118 using namespace ::com::sun::star::frame
;
119 using namespace ::com::sun::star::container
;
120 using namespace ::com::sun::star::util
;
121 using namespace ::com::sun::star::script
;
122 using namespace ::com::sun::star::system
;
123 using namespace ::com::sun::star::lang
;
124 using namespace ::com::sun::star::document
;
125 using namespace ::com::sun::star::ui
;
129 OUString
lcl_getAppName( vcl::EnumContext::Application eApp
)
133 case vcl::EnumContext::Application::Writer
:
136 case vcl::EnumContext::Application::Calc
:
139 case vcl::EnumContext::Application::Impress
:
142 case vcl::EnumContext::Application::Draw
:
145 case vcl::EnumContext::Application::Formula
:
148 case vcl::EnumContext::Application::Base
:
157 // lp#527938, debian#602953, fdo#33266, i#105408
158 bool lcl_isBaseAvailable()
162 // if we get css::sdbc::DriverManager, libsdbc2 is there
163 // and the bibliography is assumed to work
164 return css::sdbc::DriverManager::create(comphelper::getProcessComponentContext()).is();
166 catch (const Exception
&)
168 TOOLS_INFO_EXCEPTION("sfx.appl", "assuming Base to be missing");
172 void lcl_tryLoadBibliography()
174 // lp#527938, debian#602953, fdo#33266, i#105408
175 // make sure we actually can instantiate services from base first
176 if(!lcl_isBaseAvailable())
178 if (officecfg::Office::Common::PackageKit::EnableBaseInstallation::get())
182 using namespace org::freedesktop::PackageKit
;
183 using namespace svtools
;
184 Reference
< XSyncDbusSessionHelper
> xSyncDbusSessionHelper(SyncDbusSessionHelper::create(comphelper::getProcessComponentContext()));
185 Sequence
< OUString
> vPackages
{ "libreoffice-base" };
186 xSyncDbusSessionHelper
->InstallPackageNames(vPackages
, OUString());
187 // I'll be back (hopefully)!
188 SolarMutexGuard aGuard
;
189 executeRestartDialog(comphelper::getProcessComponentContext(), nullptr, RESTART_REASON_BIBLIOGRAPHY_INSTALL
);
191 catch (const Exception
&)
193 TOOLS_INFO_EXCEPTION("sfx.appl", "trying to install LibreOffice Base");
201 SfxStringItem
aURL(SID_FILE_NAME
, ".component:Bibliography/View1");
202 SfxStringItem
aRef(SID_REFERER
, "private:user");
203 SfxStringItem
aTarget(SID_TARGETNAME
, "_blank");
204 SfxViewFrame::Current()->GetDispatcher()->ExecuteList(SID_OPENDOC
,
205 SfxCallMode::ASYNCHRON
, { &aURL
, &aRef
, &aTarget
});
207 catch (const Exception
&)
209 TOOLS_INFO_EXCEPTION( "sfx.appl", "trying to load bibliography database");
213 /// Find the correct location of the document (CREDITS.fodt, etc.), and return
214 /// it in rURL if found.
215 static bool checkURL( const char *pName
, const char *pExt
, OUString
&rURL
)
218 DirectoryItem aDirItem
;
221 rURL
= "$BRAND_BASE_DIR/Resources/" + OUString::createFromAscii( pName
) +
222 OUString::createFromAscii( pExt
);
224 rURL
= "$BRAND_BASE_DIR/" + OUString::createFromAscii( pName
) +
225 OUString::createFromAscii( pExt
);
227 rtl::Bootstrap::expandMacros( rURL
);
230 return DirectoryItem::get( rURL
, aDirItem
) == DirectoryItem::E_None
;
235 /// Displays CREDITS or LICENSE in any of the available version
236 static void showDocument( const char* pBaseName
)
239 Reference
< XDesktop2
> xDesktop
= Desktop::create( ::comphelper::getProcessComponentContext() );
240 auto args(::comphelper::InitPropertySequence({
241 {"ViewOnly", makeAny(true)},
242 {"ReadOnly", makeAny(true)}
246 if ( checkURL ( pBaseName
, ".fodt", aURL
) ||
247 checkURL ( pBaseName
, ".html", aURL
) ||
248 checkURL ( pBaseName
, "", aURL
) ) {
249 xDesktop
->loadComponentFromURL( aURL
, "_blank", 0, args
);
251 } catch (const css::uno::Exception
&) {
257 Reference
<XFrame
> GetRequestFrame(const SfxRequest
& rReq
)
259 const SfxItemSet
* pArgs
= rReq
.GetInternalArgs_Impl();
260 const SfxPoolItem
* pItem
= nullptr;
261 Reference
<XFrame
> xFrame
;
262 if (pArgs
&& pArgs
->GetItemState(SID_FILLFRAME
, false, &pItem
) == SfxItemState::SET
)
264 OSL_ENSURE( dynamic_cast< const SfxUnoFrameItem
*>( pItem
) != nullptr, "SfxApplication::OfaExec_Impl: XFrames are to be transported via SfxUnoFrameItem by now!" );
265 xFrame
= static_cast< const SfxUnoFrameItem
*>( pItem
)->GetFrame();
270 vcl::Window
* getFrameWindow(const Reference
<XFrame
>& rFrame
)
276 Reference
< awt::XWindow
> xContainerWindow(rFrame
->getContainerWindow(), UNO_SET_THROW
);
277 VclPtr
<vcl::Window
> pWindow
= VCLUnoHelper::GetWindow(xContainerWindow
);
280 catch (const Exception
&)
282 DBG_UNHANDLED_EXCEPTION("sfx.appl");
286 SAL_WARN( "sfx.appl", "no parent for dialogs" );
290 class LicenseDialog
: public weld::GenericDialogController
293 LicenseDialog(weld::Window
* pParent
)
294 : GenericDialogController(pParent
, "sfx/ui/licensedialog.ui", "LicenseDialog")
298 virtual short run() override
300 short nRet
= GenericDialogController::run();
302 showDocument("LICENSE");
307 class SafeModeQueryDialog
: public weld::MessageDialogController
310 SafeModeQueryDialog(weld::Window
* pParent
)
311 : MessageDialogController(pParent
, "sfx/ui/safemodequerydialog.ui", "SafeModeQueryDialog")
315 virtual short run() override
317 short nRet
= MessageDialogController::run();
320 sfx2::SafeMode::putFlag();
321 uno::Reference
< uno::XComponentContext
> xContext
= comphelper::getProcessComponentContext();
322 css::task::OfficeRestartManager::get(xContext
)->requestRestart(
323 css::uno::Reference
< css::task::XInteractionHandler
>());
330 vcl::Window
* SfxRequest::GetFrameWindow() const
332 return getFrameWindow(GetRequestFrame(*this));
335 weld::Window
* SfxRequest::GetFrameWeld() const
337 const SfxItemSet
* pIntArgs
= GetInternalArgs_Impl();
338 const SfxPoolItem
* pItem
= nullptr;
339 if (pIntArgs
&& pIntArgs
->GetItemState(SID_DIALOG_PARENT
, false, &pItem
) == SfxItemState::SET
)
341 assert(dynamic_cast<const SfxUnoAnyItem
*>(pItem
));
342 auto aAny
= static_cast<const SfxUnoAnyItem
*>(pItem
)->GetValue();
343 Reference
<awt::XWindow
> xWindow
;
345 return Application::GetFrameWeld(xWindow
);
348 vcl::Window
* pWin
= GetFrameWindow();
349 return pWin
? pWin
->GetFrameWeld() : nullptr;
352 void SfxApplication::MiscExec_Impl( SfxRequest
& rReq
)
355 switch ( rReq
.GetSlot() )
360 SetOptions_Impl( *rReq
.GetArgs() );
367 // protect against reentrant calls
368 if ( pImpl
->bInQuit
)
371 if ( rReq
.GetSlot() == SID_LOGOUT
)
373 for ( SfxObjectShell
*pObjSh
= SfxObjectShell::GetFirst();
374 pObjSh
; pObjSh
= SfxObjectShell::GetNext( *pObjSh
) )
376 if ( !pObjSh
->IsModified() )
379 SfxViewFrame
* pFrame
= SfxViewFrame::GetFirst( pObjSh
);
380 if ( !pFrame
|| !pFrame
->GetWindow().IsReallyVisible() )
383 if (pObjSh
->PrepareClose())
384 pObjSh
->SetModified( false );
389 SfxStringItem
aNameItem( SID_FILE_NAME
, "vnd.sun.star.cmd:logout" );
390 SfxStringItem
aReferer( SID_REFERER
, "private/user" );
391 pImpl
->pAppDispat
->ExecuteList(SID_OPENDOC
,
392 SfxCallMode::SLOT
, { &aNameItem
, &aReferer
});
396 // try from nested requests again after 100ms
397 if( Application::GetDispatchLevel() > 1 )
399 /* Don't save the request for closing the application and try it later
400 again. This is an UI bound functionality ... and the user will try it again
401 if the dialog is closed. But we should not close the application automatically
402 if this dialog is closed by the user ...
403 So we ignore this request now and wait for a new user decision.
405 SAL_INFO("sfx.appl", "QueryExit => sal_False, DispatchLevel == " << Application::GetDispatchLevel() );
409 // block reentrant calls
410 pImpl
->bInQuit
= true;
411 Reference
< XDesktop2
> xDesktop
= Desktop::create ( ::comphelper::getProcessComponentContext() );
413 rReq
.ForgetAllArgs();
415 // if terminate() failed, pImpl->bInQuit will now be sal_False, allowing further calls of SID_QUITAPP
416 bool bTerminated
= xDesktop
->terminate();
418 // if terminate() was successful, SfxApplication is now dead!
419 pImpl
->bInQuit
= false;
421 // Set return value, terminate if possible
422 rReq
.SetReturnValue( SfxBoolItem( rReq
.GetSlot(), bTerminated
) );
427 case SID_TOOLBOXOPTIONS
:
428 case SID_CONFIGSTATUSBAR
:
430 case SID_CONFIGACCEL
:
431 case SID_CONFIGEVENT
:
433 SfxAbstractDialogFactory
* pFact
=
434 SfxAbstractDialogFactory::Create();
436 const SfxStringItem
* pStringItem
= rReq
.GetArg
<SfxStringItem
>(SID_CONFIG
);
439 GetPool(), svl::Items
<SID_CONFIG
, SID_CONFIG
>{} );
443 aSet
.Put( SfxStringItem(
444 SID_CONFIG
, pStringItem
->GetValue() ) );
447 Reference
<XFrame
> xFrame(GetRequestFrame(rReq
));
448 ScopedVclPtr
<SfxAbstractTabDialog
> pDlg(pFact
->CreateCustomizeTabDialog(rReq
.GetFrameWeld(),
451 const short nRet
= pDlg
->Execute();
461 Reference
< XDesktop2
> xDesktop
= Desktop::create( ::comphelper::getProcessComponentContext() );
462 Reference
< XIndexAccess
> xTasks
= xDesktop
->getFrames();
469 if ( xTasks
->getCount() <= n
)
472 Any aAny
= xTasks
->getByIndex(n
);
473 Reference
< XCloseable
> xTask
;
480 catch( CloseVetoException
& )
486 bool bOk
= ( n
== 0);
487 rReq
.SetReturnValue( SfxBoolItem( 0, bOk
) );
495 for ( SfxObjectShell
*pObjSh
= SfxObjectShell::GetFirst();
497 pObjSh
= SfxObjectShell::GetNext( *pObjSh
) )
499 SfxRequest
aReq( SID_SAVEDOC
, SfxCallMode::SLOT
, pObjSh
->GetPool() );
500 if ( pObjSh
->IsModified() )
502 pObjSh
->ExecuteSlot( aReq
);
503 const SfxBoolItem
*pItem
= dynamic_cast<const SfxBoolItem
*>( aReq
.GetReturnValue() );
504 if ( !pItem
|| !pItem
->GetValue() )
509 rReq
.SetReturnValue( SfxBoolItem( 0, bOK
) );
514 case SID_SEND_FEEDBACK
:
516 OUString module
= SfxHelp::GetCurrentModuleIdentifier();
517 OUString
sURL(officecfg::Office::Common::Menus::SendFeedbackURL::get() + //officecfg/registry/data/org/openoffice/Office/Common.xcu => https://hub.libreoffice.org/send-feedback/
518 "?LOversion=" + utl::ConfigManager::getAboutBoxProductVersion() +
519 "&LOlocale=" + utl::ConfigManager::getUILocale() +
520 "&LOmodule=" + module
.subView(module
.lastIndexOf('.') + 1 ) );
521 sfx2::openUriExternally(sURL
, false);
527 // Askbot has URL's normalized to languages, not locales
528 // Get language from locale: ll or lll or ll-CC or lll-CC
530 OUString
sURL(officecfg::Office::Common::Menus::QA_URL::get() + //https://hub.libreoffice.org/forum/
531 "?LOlocale=" + utl::ConfigManager::getUILocale());
532 sfx2::openUriExternally(sURL
, false);
535 case SID_DOCUMENTATION
:
537 // Open documentation page based on locales
538 OUString
sURL(officecfg::Office::Common::Menus::DocumentationURL::get() + //https://hub.libreoffice.org/documentation/
539 "?LOlocale=" + utl::ConfigManager::getUILocale());
540 sfx2::openUriExternally(sURL
, false);
543 case SID_GETINVOLVED
:
545 // Open get involved/join us page based on locales
546 OUString
sURL(officecfg::Office::Common::Menus::GetInvolvedURL::get() + //https://hub.libreoffice.org/joinus/
547 "?LOlocale=" + utl::ConfigManager::getUILocale());
548 sfx2::openUriExternally(sURL
, false);
553 // Open donation page based on language + script (BCP47) with language as fall back.
554 OUString aLang
= LanguageTag(utl::ConfigManager::getUILocale()).getLanguage();
555 OUString aBcp47
= LanguageTag(utl::ConfigManager::getUILocale()).getBcp47();
556 OUString
sURL(officecfg::Office::Common::Menus::DonationURL::get() + //https://hub.libreoffice.org/donation/
557 "?BCP47=" + aBcp47
+ "&LOlang=" + aLang
);
558 sfx2::openUriExternally(sURL
, false);
563 // Open release notes depending on version and locale
564 OUString
sURL(officecfg::Office::Common::Menus::ReleaseNotesURL::get() + //https://hub.libreoffice.org/ReleaseNotes/
565 "?LOvers=" + utl::ConfigManager::getProductVersion() +
566 "&LOlocale=" + LanguageTag(utl::ConfigManager::getUILocale()).getBcp47() );
567 sfx2::openUriExternally(sURL
, false);
570 case SID_SHOW_LICENSE
:
572 LicenseDialog
aDialog(rReq
.GetFrameWeld());
577 case SID_SHOW_CREDITS
:
579 showDocument( "CREDITS" );
583 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
586 Help
* pHelp
= Application::GetHelp();
589 pHelp
->Start(".uno:HelpIndex", Application::GetDefDialogParent()); // show start page
595 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
598 // Evaluate Parameter
599 const SfxBoolItem
* pOnItem
= rReq
.GetArg
<SfxBoolItem
>(SID_HELPTIPS
);
601 ? pOnItem
->GetValue()
602 : !Help::IsQuickHelpEnabled();
605 Help::EnableQuickHelp();
607 Help::DisableQuickHelp();
608 SvtHelpOptions().SetHelpTips( bOn
);
609 Invalidate(SID_HELPTIPS
);
612 // Record if possible
614 rReq
.AppendItem( SfxBoolItem( SID_HELPTIPS
, bOn
) );
617 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
618 case SID_EXTENDEDHELP
:
620 Help::StartExtHelp();
623 case SID_HELPBALLOONS
:
625 // Evaluate Parameter
626 const SfxBoolItem
* pOnItem
= rReq
.GetArg
<SfxBoolItem
>(SID_HELPBALLOONS
);
628 ? pOnItem
->GetValue()
629 : !Help::IsBalloonHelpEnabled();
632 Help::EnableBalloonHelp();
634 Help::DisableBalloonHelp();
635 SvtHelpOptions().SetExtendedHelp( bOn
);
636 Invalidate(SID_HELPBALLOONS
);
639 // Record if possible
641 rReq
.AppendItem( SfxBoolItem( SID_HELPBALLOONS
, bOn
) );
644 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
645 case SID_TIPOFTHEDAY
:
647 SfxAbstractDialogFactory
* pFact
= SfxAbstractDialogFactory::Create();
648 ScopedVclPtr
<VclAbstractDialog
> pDlg(pFact
->CreateTipOfTheDayDialog(rReq
.GetFrameWeld()));
654 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
657 SfxAbstractDialogFactory
* pFact
= SfxAbstractDialogFactory::Create();
658 ScopedVclPtr
<VclAbstractDialog
> pDlg(pFact
->CreateAboutDialog(rReq
.GetFrameWeld()));
664 case SID_TEMPLATE_MANAGER
:
666 SfxTemplateManagerDlg
aDialog(rReq
.GetFrameWeld());
672 case SID_TEMPLATE_ADDRESSBOKSOURCE
:
674 svt::AddressBookSourceDialog
aDialog(rReq
.GetFrameWeld(), ::comphelper::getProcessComponentContext());
680 #if HAVE_FEATURE_SCRIPTING
685 case SID_BASICBREAK
:
686 BasicDLL::BasicBreak();
690 case SID_ZOOM_50_PERCENT
:
691 case SID_ZOOM_75_PERCENT
:
692 case SID_ZOOM_100_PERCENT
:
693 case SID_ZOOM_150_PERCENT
:
694 case SID_ZOOM_200_PERCENT
:
695 case SID_ZOOM_OPTIMAL
:
696 case SID_ZOOM_ENTIRE_PAGE
:
697 case SID_ZOOM_PAGE_WIDTH
:
699 SfxObjectShell
* pCurrentShell
= SfxObjectShell::Current();
703 // make sure aZoom is initialized with a proper value if SetType
705 SvxZoomItem
aZoom( SvxZoomType::PERCENT
, 100 );
707 switch (rReq
.GetSlot())
709 case SID_ZOOM_50_PERCENT
:
712 case SID_ZOOM_75_PERCENT
:
715 case SID_ZOOM_100_PERCENT
:
718 case SID_ZOOM_150_PERCENT
:
721 case SID_ZOOM_200_PERCENT
:
724 case SID_ZOOM_OPTIMAL
:
725 aZoom
.SetType( SvxZoomType::OPTIMAL
);
727 case SID_ZOOM_ENTIRE_PAGE
:
728 aZoom
.SetType( SvxZoomType::WHOLEPAGE
);
730 case SID_ZOOM_PAGE_WIDTH
:
731 aZoom
.SetType( SvxZoomType::PAGEWIDTH
);
735 pCurrentShell
->GetDispatcher()->ExecuteList(SID_ATTR_ZOOM
, SfxCallMode::ASYNCHRON
, { &aZoom
});
739 case SID_TOOLBAR_MODE
:
741 const SfxStringItem
* pModeName
= rReq
.GetArg
<SfxStringItem
>( SID_TOOLBAR_MODE
);
749 OUString
aNewName(pModeName
->GetValue());
750 uno::Reference
< uno::XComponentContext
> xContext
=
751 ::comphelper::getProcessComponentContext();
753 // Get information about current frame and module
754 Reference
<XFrame
> xCurrentFrame
;
755 vcl::EnumContext::Application eCurrentApp
= vcl::EnumContext::Application::NONE
;
756 OUString aCurrentMode
;
758 SfxViewFrame
* pViewFrame
= SfxViewFrame::Current();
761 xCurrentFrame
= pViewFrame
->GetFrame().GetFrameInterface();
763 const Reference
<frame::XModuleManager
> xModuleManager
= frame::ModuleManager::create( xContext
);
764 eCurrentApp
= vcl::EnumContext::GetApplicationEnum( xModuleManager
->identify( xCurrentFrame
) );
766 OUStringBuffer
aPath("org.openoffice.Office.UI.ToolbarMode/Applications/");
767 aPath
.append( lcl_getAppName( eCurrentApp
) );
769 const utl::OConfigurationTreeRoot
aAppNode(
771 aPath
.makeStringAndClear(),
773 if ( !aAppNode
.isValid() )
779 aCurrentMode
= comphelper::getString( aAppNode
.getNodeValue( "Active" ) );
781 if ( aCurrentMode
== aNewName
)
787 // Save new toolbar mode for a current module
788 aAppNode
.setNodeValue( "Active", makeAny( aNewName
) );
792 // Apply settings for all frames
793 pViewFrame
= SfxViewFrame::GetFirst();
796 Reference
<XFrame
> xFrame
= pViewFrame
->GetFrame().GetFrameInterface();
798 // We want to change mode only for a current app module, ignore other apps
799 const Reference
<frame::XModuleManager
> xModuleManager
= frame::ModuleManager::create( xContext
);
800 vcl::EnumContext::Application eApp
= vcl::EnumContext::GetApplicationEnum( xModuleManager
->identify( xFrame
) );
801 if ( eApp
!= eCurrentApp
)
803 pViewFrame
= SfxViewFrame::GetNext( *pViewFrame
);
807 Reference
<css::beans::XPropertySet
> xPropSet( xFrame
, UNO_QUERY
);
808 Reference
<css::frame::XLayoutManager
> xLayoutManager
;
813 Any aValue
= xPropSet
->getPropertyValue( "LayoutManager" );
814 aValue
>>= xLayoutManager
;
816 catch ( const css::uno::RuntimeException
& )
820 catch ( css::uno::Exception
& )
825 if ( xLayoutManager
.is() )
827 css::uno::Sequence
<OUString
> aMandatoryToolbars
;
828 css::uno::Sequence
<OUString
> aUserToolbars
;
829 std::vector
<OUString
> aBackupList
;
830 OUString aSidebarMode
;
832 OUStringBuffer
aPath( "org.openoffice.Office.UI.ToolbarMode/Applications/" );
833 aPath
.append( lcl_getAppName( eApp
) );
834 aPath
.append( "/Modes" );
836 // Read mode settings
837 const utl::OConfigurationTreeRoot
aModesNode(
839 aPath
.makeStringAndClear(),
841 if ( !aModesNode
.isValid() )
847 const Sequence
<OUString
> aModeNodeNames( aModesNode
.getNodeNames() );
849 for ( const auto& rModeNodeName
: aModeNodeNames
)
851 const utl::OConfigurationNode
aModeNode( aModesNode
.openNode( rModeNodeName
) );
852 if ( !aModeNode
.isValid() )
855 OUString aCommandArg
= comphelper::getString( aModeNode
.getNodeValue( "CommandArg" ) );
857 if ( aCommandArg
== aNewName
)
859 aMandatoryToolbars
= aModeNode
.getNodeValue( "Toolbars" ).get
< uno::Sequence
<OUString
> >();
860 aUserToolbars
= aModeNode
.getNodeValue( "UserToolbars" ).get
< uno::Sequence
<OUString
> >();
861 aSidebarMode
= comphelper::getString( aModeNode
.getNodeValue( "Sidebar" ) );
866 // Backup visible toolbar list and hide all toolbars
867 const Sequence
<Reference
<XUIElement
>> aUIElements
= xLayoutManager
->getElements();
868 for ( const Reference
< XUIElement
>& xUIElement
: aUIElements
)
870 Reference
< XPropertySet
> xPropertySet( xUIElement
, UNO_QUERY
);
871 if ( xPropertySet
.is() && xUIElement
.is() )
876 sal_Int16
nType( -1 );
877 xPropertySet
->getPropertyValue( "Type" ) >>= nType
;
878 xPropertySet
->getPropertyValue( "ResourceURL" ) >>= aResName
;
880 if (( nType
== css::ui::UIElementType::TOOLBAR
) &&
881 !aResName
.isEmpty() )
883 if ( xLayoutManager
->isElementVisible( aResName
) )
885 aBackupList
.push_back( aResName
);
887 xLayoutManager
->hideElement( aResName
);
890 catch ( const Exception
& )
896 // Show/Hide the Notebookbar
897 const SfxStringItem
pItem(SID_NOTEBOOKBAR
, aNewName
);
898 pViewFrame
->GetDispatcher()->ExecuteList(SID_NOTEBOOKBAR
, SfxCallMode::SYNCHRON
, {&pItem
});
901 for ( const OUString
& rName
: std::as_const(aMandatoryToolbars
) )
903 xLayoutManager
->createElement( rName
);
904 xLayoutManager
->showElement( rName
);
907 for ( const OUString
& rName
: std::as_const(aUserToolbars
) )
909 xLayoutManager
->createElement( rName
);
910 xLayoutManager
->showElement( rName
);
914 pViewFrame
->ShowChildWindow( SID_SIDEBAR
);
916 sfx2::sidebar::SidebarController
* pSidebar
=
917 sfx2::sidebar::SidebarController::GetSidebarControllerForFrame( xFrame
);
920 if ( aSidebarMode
== "Arrow" )
924 else if ( aSidebarMode
== "Tabs" )
927 pSidebar
->RequestOpenDeck();
928 pSidebar
->RequestCloseDeck();
930 else if ( aSidebarMode
== "Opened" )
933 pSidebar
->RequestOpenDeck();
938 if ( pViewFrame
== SfxViewFrame::Current() )
940 css::uno::Sequence
<OUString
> aBackup( comphelper::containerToSequence(aBackupList
) );
942 for ( const auto& rModeNodeName
: aModeNodeNames
)
944 const utl::OConfigurationNode
aModeNode( aModesNode
.openNode( rModeNodeName
) );
945 if ( !aModeNode
.isValid() )
948 OUString aCommandArg
= comphelper::getString( aModeNode
.getNodeValue( "CommandArg" ) );
950 if ( aCommandArg
== aCurrentMode
)
952 aModeNode
.setNodeValue( "UserToolbars", makeAny( aBackup
) );
960 pViewFrame
= SfxViewFrame::GetNext(*pViewFrame
);
966 case SID_TOOLBAR_MODE_UI
:
968 SfxAbstractDialogFactory
* pFact
= SfxAbstractDialogFactory::Create();
969 ScopedVclPtr
<VclAbstractDialog
> pDlg(
970 pFact
->CreateToolbarmodeDialog(rReq
.GetFrameWeld()));
975 case SID_AVAILABLE_TOOLBARS
:
977 const SfxStringItem
* pToolbarName
= rReq
.GetArg
<SfxStringItem
>(SID_AVAILABLE_TOOLBARS
);
981 Reference
< XDesktop2
> xDesktop
= Desktop::create ( ::comphelper::getProcessComponentContext() );
982 Reference
< XFrame
> xFrame
= xDesktop
->getActiveFrame();
984 Reference
< css::beans::XPropertySet
> xPropSet( xFrame
, UNO_QUERY
);
985 Reference
< css::frame::XLayoutManager
> xLayoutManager
;
990 Any aValue
= xPropSet
->getPropertyValue("LayoutManager");
991 aValue
>>= xLayoutManager
;
993 catch ( const css::uno::RuntimeException
& )
997 catch ( css::uno::Exception
& )
1002 if ( xLayoutManager
.is() )
1004 OUStringBuffer
aBuf( "private:resource/toolbar/" );
1005 aBuf
.append( pToolbarName
->GetValue() );
1007 // Evaluate Parameter
1008 OUString
aToolbarName( aBuf
.makeStringAndClear() );
1009 bool bShow( !xLayoutManager
->isElementVisible( aToolbarName
));
1013 xLayoutManager
->createElement( aToolbarName
);
1014 xLayoutManager
->showElement( aToolbarName
);
1017 xLayoutManager
->hideElement( aToolbarName
);
1026 sfx2::SfxNotebookBar::ToggleMenubar();
1032 SafeModeQueryDialog
aDialog(rReq
.GetFrameWeld());
1045 void SfxApplication::MiscState_Impl(SfxItemSet
&rSet
)
1047 const sal_uInt16
*pRanges
= rSet
.GetRanges();
1048 DBG_ASSERT(pRanges
&& *pRanges
, "Set without range");
1051 for(sal_uInt16 nWhich
= *pRanges
++; nWhich
<= *pRanges
; ++nWhich
)
1055 case SID_TEMPLATE_ADDRESSBOKSOURCE
:
1056 if ( !SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::EModule::DATABASE
) )
1057 rSet
.Put(SfxVisibilityItem(nWhich
, false));
1061 if ( pImpl
->nDocModalMode
)
1062 rSet
.DisableItem(nWhich
);
1064 rSet
.Put(SfxStringItem(nWhich
, SfxResId(STR_QUITAPP
)));
1069 case SID_TOOLBOXOPTIONS
:
1070 case SID_CONFIGSTATUSBAR
:
1071 case SID_CONFIGMENU
:
1072 case SID_CONFIGACCEL
:
1073 case SID_CONFIGEVENT
:
1075 if( SvtMiscOptions().DisableUICustomization() )
1076 rSet
.DisableItem(nWhich
);
1080 #if HAVE_FEATURE_SCRIPTING
1082 if ( !StarBASIC::IsRunning() )
1083 rSet
.DisableItem(nWhich
);
1089 rSet
.Put( SfxBoolItem( SID_HELPTIPS
, Help::IsQuickHelpEnabled() ) );
1092 case SID_HELPBALLOONS
:
1094 rSet
.Put( SfxBoolItem( SID_HELPBALLOONS
, Help::IsBalloonHelpEnabled() ) );
1098 case SID_EXTENDEDHELP
:
1105 Reference
< XDesktop2
> xDesktop
= Desktop::create( ::comphelper::getProcessComponentContext() );
1106 Reference
< XIndexAccess
> xTasks
= xDesktop
->getFrames();
1107 if ( !xTasks
.is() || !xTasks
->getCount() )
1108 rSet
.DisableItem(nWhich
);
1114 bool bModified
= false;
1115 for ( SfxObjectShell
*pObjSh
= SfxObjectShell::GetFirst();
1117 pObjSh
= SfxObjectShell::GetNext( *pObjSh
) )
1119 if ( pObjSh
->IsModified() )
1127 rSet
.DisableItem( nWhich
);
1131 case SID_TEMPLATE_MANAGER
:
1133 if ( !officecfg::Office::Common::Misc::ExperimentalMode::get() )
1135 rSet
.DisableItem( nWhich
);
1136 rSet
.Put( SfxVisibilityItem( nWhich
, false ) );
1141 case SID_ZOOM_50_PERCENT
:
1142 case SID_ZOOM_75_PERCENT
:
1143 case SID_ZOOM_100_PERCENT
:
1144 case SID_ZOOM_150_PERCENT
:
1145 case SID_ZOOM_200_PERCENT
:
1146 case SID_ZOOM_OPTIMAL
:
1147 case SID_ZOOM_ENTIRE_PAGE
:
1148 case SID_ZOOM_PAGE_WIDTH
:
1150 SfxObjectShell
* pCurrentShell
= SfxObjectShell::Current();
1152 const SfxPoolItem
*pItem
;
1153 SfxItemState aState
= pCurrentShell
?
1154 pCurrentShell
->GetDispatcher()->QueryState(SID_ATTR_ZOOM
, pItem
) : SfxItemState::DISABLED
;
1155 if ( aState
== SfxItemState::DISABLED
)
1156 rSet
.DisableItem( nWhich
);
1162 Reference
< XDesktop2
> xDesktop
= Desktop::create ( ::comphelper::getProcessComponentContext() );
1163 Reference
< XFrame
> xFrame
= xDesktop
->getActiveFrame();
1165 Reference
< css::beans::XPropertySet
> xPropSet( xFrame
, UNO_QUERY
);
1166 Reference
< css::frame::XLayoutManager
> xLayoutManager
;
1167 if ( xPropSet
.is() )
1171 Any aValue
= xPropSet
->getPropertyValue("LayoutManager");
1172 aValue
>>= xLayoutManager
;
1174 catch ( const css::uno::RuntimeException
& )
1178 catch ( css::uno::Exception
& )
1183 if ( xLayoutManager
.is() )
1186 = xLayoutManager
->getElement("private:resource/menubar/menubar").is()
1187 && xLayoutManager
->isElementVisible(
1188 "private:resource/menubar/menubar");
1190 SfxBoolItem
aItem( SID_MENUBAR
, bState
);
1197 // no restart in safe mode when already in safe mode
1198 if ( Application::IsSafeModeEnabled() )
1199 rSet
.DisableItem( SID_SAFE_MODE
);
1212 #if HAVE_FEATURE_SCRIPTING
1214 #ifndef DISABLE_DYNLOADING
1216 typedef rtl_uString
* (*basicide_choose_macro
)(void*, void*, void*, sal_Bool
);
1220 extern "C" rtl_uString
* basicide_choose_macro(void*, void*, void*, sal_Bool
);
1224 static OUString
ChooseMacro(weld::Window
* pParent
, const Reference
<XModel
>& rxLimitToDocument
, const Reference
<XFrame
>& xDocFrame
, bool bChooseOnly
)
1226 #ifndef DISABLE_DYNLOADING
1227 basicide_choose_macro pSymbol
= reinterpret_cast<basicide_choose_macro
>(sfx2::getBasctlFunction("basicide_choose_macro"));
1229 #define pSymbol basicide_choose_macro
1232 // call basicide_choose_macro in basctl
1233 rtl_uString
* pScriptURL
= pSymbol(pParent
, rxLimitToDocument
.get(), xDocFrame
.get(), bChooseOnly
);
1234 OUString
aScriptURL( pScriptURL
);
1235 rtl_uString_release( pScriptURL
);
1238 #ifdef DISABLE_DYNLOADING
1247 #if HAVE_FEATURE_SCRIPTING
1248 weld::Window
* lcl_getDialogParent(const Reference
<XFrame
>& rxFrame
)
1250 Reference
<awt::XWindow
> xContainerWindow
;
1252 xContainerWindow
= rxFrame
->getContainerWindow();
1253 return Application::GetFrameWeld(xContainerWindow
);
1256 SfxViewFrame
* lcl_getBasicIDEViewFrame( SfxObjectShell
const * i_pBasicIDE
)
1258 SfxViewFrame
* pView
= SfxViewFrame::GetFirst( i_pBasicIDE
);
1261 if ( pView
->GetObjectShell()->GetFactory().GetDocumentServiceName() == "com.sun.star.script.BasicIDE" )
1263 pView
= SfxViewFrame::GetNext( *pView
, i_pBasicIDE
);
1267 Reference
< XFrame
> lcl_findStartModuleFrame( const Reference
<XComponentContext
> & rxContext
)
1271 Reference
< XDesktop2
> xDesktop
= Desktop::create( rxContext
);
1272 Reference
< XIndexAccess
> xContainer( xDesktop
->getFrames(), UNO_QUERY_THROW
);
1274 Reference
< XModuleManager2
> xCheck
= ModuleManager::create(rxContext
);
1276 sal_Int32 nCount
= xContainer
->getCount();
1277 for ( sal_Int32 i
=0; i
<nCount
; ++i
)
1281 Reference
< XFrame
> xFrame( xContainer
->getByIndex(i
), UNO_QUERY_THROW
);
1282 OUString sModule
= xCheck
->identify( xFrame
);
1283 if ( sModule
== "com.sun.star.frame.StartModule" )
1286 catch( const UnknownModuleException
& )
1290 catch(const Exception
&)
1292 // re-throw, caught below
1297 catch( const Exception
& )
1299 DBG_UNHANDLED_EXCEPTION("sfx.appl");
1303 #endif // HAVE_FEATURE_SCRIPTING
1306 void SfxApplication::OfaExec_Impl( SfxRequest
& rReq
)
1308 switch ( rReq
.GetSlot() )
1310 case SID_OPTIONS_TREEDIALOG
:
1313 const SfxStringItem
* pURLItem
= rReq
.GetArg
<SfxStringItem
>(SID_OPTIONS_PAGEURL
);
1315 sPageURL
= pURLItem
->GetValue();
1316 Reference
<XFrame
> xFrame(GetRequestFrame(rReq
));
1317 SfxAbstractDialogFactory
* pFact
= SfxAbstractDialogFactory::Create();
1318 VclPtr
<VclAbstractDialog
> pDlg
=
1319 pFact
->CreateFrameDialog(rReq
.GetFrameWeld(), xFrame
, rReq
.GetSlot(), sPageURL
);
1320 short nRet
= pDlg
->Execute();
1321 pDlg
.disposeAndClear();
1322 SfxViewFrame
* pView
= SfxViewFrame::GetFirst();
1327 SfxObjectShell
* pObjSh
= pView
->GetObjectShell();
1329 pObjSh
->SetConfigOptionsChecked(false);
1331 pView
->GetBindings().InvalidateAll(false);
1332 pView
= SfxViewFrame::GetNext( *pView
);
1337 case SID_MORE_DICTIONARIES
:
1339 uno::Sequence
<beans::PropertyValue
> aArgs(1);
1340 aArgs
[0].Name
= "AdditionsTag";
1341 aArgs
[0].Value
<<= OUString("Dictionary");
1342 comphelper::dispatchCommand(".uno:AdditionsDialog", aArgs
);
1345 #if HAVE_FEATURE_SCRIPTING
1346 case SID_BASICIDE_APPEAR
:
1348 SfxViewFrame
* pView
= lcl_getBasicIDEViewFrame( nullptr );
1351 SfxObjectShell
* pBasicIDE
= SfxObjectShell::CreateObject( "com.sun.star.script.BasicIDE" );
1352 pBasicIDE
->DoInitNew();
1353 pBasicIDE
->SetModified( false );
1356 // load the Basic IDE via direct access to the SFX frame loader. A generic loadComponentFromURL
1357 // (which could be done via SfxViewFrame::LoadDocumentIntoFrame) is not feasible here, since the Basic IDE
1358 // does not really play nice with the framework's concept. For instance, it is a "singleton document",
1359 // which conflicts, at the latest, with the framework's concept of loading into _blank frames.
1360 // So, since we know that our frame loader can handle it, we skip the generic framework loader
1361 // mechanism, and the type detection (which doesn't know about the Basic IDE).
1362 Reference
< XComponentContext
> xContext( ::comphelper::getProcessComponentContext() );
1363 Reference
< XSynchronousFrameLoader
> xLoader(
1364 xContext
->getServiceManager()->createInstanceWithContext("com.sun.star.comp.office.FrameLoader", xContext
),
1366 ::comphelper::NamedValueCollection aLoadArgs
;
1367 aLoadArgs
.put( "Model", pBasicIDE
->GetModel() );
1368 aLoadArgs
.put( "URL", OUString( "private:factory/sbasic" ) );
1370 Reference
< XFrame
> xTargetFrame( lcl_findStartModuleFrame( xContext
) );
1371 if ( !xTargetFrame
.is() )
1372 xTargetFrame
= SfxFrame::CreateBlankFrame();
1373 ENSURE_OR_THROW( xTargetFrame
.is(), "could not obtain a frameto load the Basic IDE into!" );
1375 xLoader
->load( aLoadArgs
.getPropertyValues(), xTargetFrame
);
1377 catch( const Exception
& )
1379 DBG_UNHANDLED_EXCEPTION("sfx.appl");
1382 pView
= lcl_getBasicIDEViewFrame( pBasicIDE
);
1384 pView
->SetName( "BASIC:1" );
1388 pView
->GetFrame().Appear();
1390 const SfxItemSet
* pArgs
= rReq
.GetArgs();
1391 if ( pArgs
&& pView
)
1393 SfxViewShell
* pViewShell
= pView
->GetViewShell();
1394 SfxObjectShell
* pObjShell
= pView
->GetObjectShell();
1395 if ( pViewShell
&& pObjShell
)
1397 SfxRequest
aReq( SID_BASICIDE_SHOWWINDOW
, SfxCallMode::SYNCHRON
, pObjShell
->GetPool() );
1398 aReq
.SetArgs( *pArgs
);
1399 pViewShell
->ExecuteSlot( aReq
);
1407 case SID_BASICCHOOSER
:
1409 const SfxItemSet
* pArgs
= rReq
.GetArgs();
1410 const SfxPoolItem
* pItem
;
1411 bool bChooseOnly
= false;
1412 Reference
< XModel
> xLimitToModel
;
1413 if(pArgs
&& SfxItemState::SET
== pArgs
->GetItemState(SID_RECORDMACRO
, false, &pItem
) )
1415 bool bRecord
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
1419 bChooseOnly
= false;
1420 SfxObjectShell
* pCurrentShell
= SfxObjectShell::Current();
1421 OSL_ENSURE( pCurrentShell
, "macro recording outside an SFX document?" );
1422 if ( pCurrentShell
)
1423 xLimitToModel
= pCurrentShell
->GetModel();
1427 Reference
<XFrame
> xFrame(GetRequestFrame(rReq
));
1428 rReq
.SetReturnValue(SfxStringItem(rReq
.GetSlot(), ChooseMacro(rReq
.GetFrameWeld(), xLimitToModel
, xFrame
, bChooseOnly
)));
1433 case SID_MACROORGANIZER
:
1435 SAL_INFO("sfx.appl", "handling SID_MACROORGANIZER");
1436 const SfxItemSet
* pArgs
= rReq
.GetArgs();
1437 const SfxPoolItem
* pItem
;
1438 sal_Int16 nTabId
= 0;
1439 if(pArgs
&& SfxItemState::SET
== pArgs
->GetItemState(SID_MACROORGANIZER
, false, &pItem
) )
1441 nTabId
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
1444 SfxApplication::MacroOrganizer(rReq
.GetFrameWeld(), nTabId
);
1451 SfxAbstractDialogFactory
* pFact
= SfxAbstractDialogFactory::Create();
1452 SAL_INFO("sfx.appl", "SfxApplication::OfaExec_Impl: case ScriptOrg");
1454 Reference
<XFrame
> xFrame(GetRequestFrame(rReq
));
1457 const SfxViewFrame
* pViewFrame
= SfxViewFrame::Current();
1459 xFrame
= pViewFrame
->GetFrame().GetFrameInterface();
1462 do // artificial loop for flow control
1464 ScopedVclPtr
<AbstractScriptSelectorDialog
> pDlg(pFact
->CreateScriptSelectorDialog(lcl_getDialogParent(xFrame
), xFrame
));
1465 OSL_ENSURE( pDlg
, "SfxApplication::OfaExec_Impl( SID_RUNMACRO ): no dialog!" );
1468 pDlg
->SetRunLabel();
1470 short nDialogResult
= pDlg
->Execute();
1471 if ( !nDialogResult
)
1474 Sequence
< Any
> args
;
1475 Sequence
< sal_Int16
> outIndex
;
1476 Sequence
< Any
> outArgs
;
1479 Reference
< XInterface
> xScriptContext
;
1481 Reference
< XController
> xController
;
1483 xController
= xFrame
->getController();
1484 if ( xController
.is() )
1485 xScriptContext
= xController
->getModel();
1486 if ( !xScriptContext
.is() )
1487 xScriptContext
= xController
;
1489 SfxObjectShell::CallXScript( xScriptContext
, pDlg
->GetScriptURL(), args
, ret
, outIndex
, outArgs
);
1496 case SID_SCRIPTORGANIZER
:
1498 SfxAbstractDialogFactory
* pFact
= SfxAbstractDialogFactory::Create();
1499 SAL_INFO("sfx.appl", "SfxApplication::OfaExec_Impl: case ScriptOrg");
1500 const SfxItemSet
* pArgs
= rReq
.GetArgs();
1501 const SfxPoolItem
* pItem
;
1503 if(pArgs
&& SfxItemState::SET
== pArgs
->GetItemState(SID_SCRIPTORGANIZER
, false, &pItem
) )
1505 aLanguage
= static_cast<const SfxScriptOrganizerItem
*>(pItem
)->getLanguage();
1508 OUString
aLang( aLanguage
);
1509 SAL_INFO("sfx.appl", "SfxApplication::OfaExec_Impl: about to create dialog for: " << aLang
);
1510 ScopedVclPtr
<VclAbstractDialog
> pDlg(pFact
->CreateSvxScriptOrgDialog(rReq
.GetFrameWeld(), aLanguage
));
1517 SAL_WARN("sfx.appl", "no dialog!!!");
1522 #endif // HAVE_FEATURE_SCRIPTING
1524 case SID_OFFICE_CHECK_PLZ
:
1527 const SfxStringItem
* pStringItem
= rReq
.GetArg
<SfxStringItem
>(rReq
.GetSlot());
1531 bRet
= true /*!!!SfxIniManager::CheckPLZ( aPLZ )*/;
1533 #if HAVE_FEATURE_SCRIPTING
1535 SbxBase::SetError( ERRCODE_BASIC_WRONG_ARGS
);
1537 rReq
.SetReturnValue( SfxBoolItem( rReq
.GetSlot(), bRet
) );
1541 case SID_AUTO_CORRECT_DLG
:
1543 SfxAbstractDialogFactory
* pFact
= SfxAbstractDialogFactory::Create();
1544 SfxItemSet
aSet(GetPool(), svl::Items
<SID_AUTO_CORRECT_DLG
, SID_AUTO_CORRECT_DLG
>{});
1545 const SfxPoolItem
* pItem
=nullptr;
1546 const SfxItemSet
* pSet
= rReq
.GetArgs();
1547 SfxItemPool
* pSetPool
= pSet
? pSet
->GetPool() : nullptr;
1548 if ( pSet
&& pSet
->GetItemState( pSetPool
->GetWhich( SID_AUTO_CORRECT_DLG
), false, &pItem
) == SfxItemState::SET
)
1551 const SfxViewFrame
* pViewFrame
= SfxViewFrame::Current();
1552 ScopedVclPtr
<SfxAbstractTabDialog
> pDlg(pFact
->CreateAutoCorrTabDialog(pViewFrame
? pViewFrame
->GetWindow().GetFrameWeld() : nullptr, &aSet
));
1560 SvtModuleOptions aModuleOpt
;
1561 if ( !aModuleOpt
.IsImpress() )
1563 std::unique_ptr
<weld::MessageDialog
> xBox(Application::CreateMessageDialog(nullptr,
1564 VclMessageType::Warning
, VclButtonsType::Ok
,
1565 SfxResId(STR_MODULENOTINSTALLED
)));
1570 Reference
< uno::XComponentContext
> xContext
= ::comphelper::getProcessComponentContext();
1571 Reference
< frame::XDispatchProvider
> xProv
= drawing::ModuleDispatcher::create( xContext
);
1573 OUString aCmd
= OUString::createFromAscii( GetInterface()->GetSlot( rReq
.GetSlot() )->GetUnoName() );
1574 Reference
< frame::XDispatchHelper
> xHelper( frame::DispatchHelper::create(xContext
) );
1575 Sequence
< beans::PropertyValue
> aSeq
;
1576 if ( rReq
.GetArgs() )
1577 TransformItems( rReq
.GetSlot(), *rReq
.GetArgs(), aSeq
);
1578 Any aResult
= xHelper
->executeDispatch( xProv
, aCmd
, OUString(), 0, aSeq
);
1579 frame::DispatchResultEvent aEvent
;
1580 bool bSuccess
= (aResult
>>= aEvent
) &&
1581 (aEvent
.State
== frame::DispatchResultState::SUCCESS
);
1582 rReq
.SetReturnValue( SfxBoolItem( rReq
.GetSlot(), bSuccess
) );
1587 case FN_BUSINESS_CARD
:
1588 case FN_XFORMS_INIT
:
1590 Reference
< uno::XComponentContext
> xContext
= ::comphelper::getProcessComponentContext();
1591 Reference
< frame::XDispatchProvider
> xProv
= text::ModuleDispatcher::create( xContext
);
1593 OUString aCmd
= OUString::createFromAscii( GetInterface()->GetSlot( rReq
.GetSlot() )->GetUnoName() );
1594 Reference
< frame::XDispatchHelper
> xHelper( frame::DispatchHelper::create(xContext
) );
1595 Sequence
< beans::PropertyValue
> aSeq
;
1596 if ( rReq
.GetArgs() )
1597 TransformItems( rReq
.GetSlot(), *rReq
.GetArgs(), aSeq
);
1598 Any aResult
= xHelper
->executeDispatch( xProv
, aCmd
, OUString(), 0, aSeq
);
1599 frame::DispatchResultEvent aEvent
;
1600 bool bSuccess
= (aResult
>>= aEvent
) &&
1601 (aEvent
.State
== frame::DispatchResultState::SUCCESS
);
1602 rReq
.SetReturnValue( SfxBoolItem( rReq
.GetSlot(), bSuccess
) );
1606 case SID_ADDRESS_DATA_SOURCE
:
1610 Reference
< uno::XComponentContext
> xORB
= ::comphelper::getProcessComponentContext();
1611 Reference
< ui::dialogs::XExecutableDialog
> xDialog
= ui::dialogs::AddressBookSourcePilot::createWithParent(xORB
, nullptr);
1614 catch(const css::uno::Exception
&)
1616 DBG_UNHANDLED_EXCEPTION("sfx.appl");
1621 case SID_COMP_BIBLIOGRAPHY
:
1622 lcl_tryLoadBibliography();
1627 void SfxApplication::OfaState_Impl(SfxItemSet
&rSet
)
1629 SvtModuleOptions aModuleOpt
;
1631 if( !aModuleOpt
.IsWriter())
1633 rSet
.DisableItem( FN_LABEL
);
1634 rSet
.DisableItem( FN_BUSINESS_CARD
);
1635 rSet
.DisableItem( FN_XFORMS_INIT
);
1637 if ( comphelper::LibreOfficeKit::isActive() )
1638 rSet
.DisableItem( SID_AUTO_CORRECT_DLG
);
1640 bool bMacrosDisabled
1641 = officecfg::Office::Common::Security::Scripting::DisableMacrosExecution::get();
1642 if (bMacrosDisabled
)
1644 rSet
.DisableItem(SID_RUNMACRO
);
1645 rSet
.DisableItem(SID_MACROORGANIZER
);
1646 rSet
.DisableItem(SID_SCRIPTORGANIZER
);
1647 rSet
.DisableItem(SID_BASICIDE_APPEAR
);
1651 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */