desktop/source/app/app.cxx | 25 ------- desktop/source/app/appinit.cxx | 4 - desktop/source/app/cmdlineargs.cxx | 5 - desktop/source/app/cmdlineargs.hxx | 4 - framework/source/services/desktop.cxx | 3 include/vcl/svapp.hxx | 14 ---- postprocess/qa/services.cxx | 8 -- sfx2/source/appl/shutdownicon.cxx | 10 ++- svtools/source/uno/fpicker.cxx | 11 ++- vcl/inc/svdata.hxx | 6 - vcl/source/app/svapp.cxx | 108 ---------------------------------- 11 files changed, 22 insertions(+), 176 deletions(-)
New commits: commit 9e786320a7d2609a9f997b32e31347f2eab0489e Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Fri Apr 7 13:24:11 2023 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Fri Apr 7 16:54:45 2023 +0200 move using the vcl file dialog in headless mode to the point of creation instead of setting and unsetting the config option at start and exit because a document that crashes in headless mode leaves my config in an unwanted built-in file dialog state. Change-Id: Ib5fcc5994a08c78bffdf57cb5b252dc469167ba2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150126 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 72674493a0fb..169330dab9f7 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1227,14 +1227,12 @@ struct ExecuteGlobals { Reference < css::document::XDocumentEventListener > xGlobalBroadcaster; bool bRestartRequested; - bool bUseSystemFileDialog; std::unique_ptr<SvtCTLOptions> pCTLLanguageOptions; std::unique_ptr<SvtPathOptions> pPathOptions; rtl::Reference< JVMloadThread > xJVMloadThread; ExecuteGlobals() : bRestartRequested( false ) - , bUseSystemFileDialog( true ) {} }; @@ -1511,18 +1509,6 @@ int Desktop::Main() } } - if ( rCmdLineArgs.IsHeadless() ) - { - // Ensure that we use not the system file dialogs as - // headless mode relies on Application::EnableHeadlessMode() - // which does only work for VCL dialogs!! - pExecGlobals->bUseSystemFileDialog = officecfg::Office::Common::Misc::UseSystemFileDialog::get(); - std::shared_ptr< comphelper::ConfigurationChanges > xChanges( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Misc::UseSystemFileDialog::set( false, xChanges ); - xChanges->commit(); - } - pExecGlobals->bRestartRequested = xRestartManager->isRestartRequested(true); if ( !pExecGlobals->bRestartRequested ) { @@ -1635,16 +1621,7 @@ int Desktop::doShutdown() if ( pExecGlobals->bRestartRequested ) SetRestartState(); - // Restore old value const CommandLineArgs& rCmdLineArgs = GetCommandLineArgs(); - if ( rCmdLineArgs.IsHeadless() ) - { - std::shared_ptr< comphelper::ConfigurationChanges > xChanges( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Misc::UseSystemFileDialog::set( pExecGlobals->bUseSystemFileDialog, xChanges ); - xChanges->commit(); - } - OUString pidfileName = rCmdLineArgs.GetPidfileName(); if ( !pidfileName.isEmpty() ) { diff --git a/postprocess/qa/services.cxx b/postprocess/qa/services.cxx index 94bd76031ff4..c332402e390d 100644 --- a/postprocess/qa/services.cxx +++ b/postprocess/qa/services.cxx @@ -365,14 +365,10 @@ void Test::createInstance( #endif } else if (name == "com.sun.star.ui.dialogs.FolderPicker") { // FolderPicker is a wrapper returning either a platform-specific or the - // generic OfficeFolderPicker: -#if defined(_WIN32) - expImpl = "com.sun.star.ui.dialogs.Win32FolderPicker"; - expServs = {"com.sun.star.ui.dialogs.SystemFolderPicker"}; -#else + // generic OfficeFolderPicker. In headless mode it is always the + // generic one. expImpl = "com.sun.star.svtools.OfficeFolderPicker"; expServs = {"com.sun.star.ui.dialogs.OfficeFolderPicker"}; -#endif } else if (expImpl == "com.sun.star.comp.Calc.SpreadsheetDocument") { expImpl = "ScModelObj"; } else if (expImpl == "com.sun.star.comp.Draw.DrawingDocument" diff --git a/sfx2/source/appl/shutdownicon.cxx b/sfx2/source/appl/shutdownicon.cxx index ae214842f61f..fca7e56b3f3f 100644 --- a/sfx2/source/appl/shutdownicon.cxx +++ b/sfx2/source/appl/shutdownicon.cxx @@ -138,11 +138,15 @@ void ShutdownIcon::deInitSystray() m_bInitialized = false; } +static bool UseSystemFileDialog() +{ + return !Application::IsHeadlessModeEnabled() && officecfg::Office::Common::Misc::UseSystemFileDialog::get(); +} ShutdownIcon::ShutdownIcon( css::uno::Reference< XComponentContext > xContext ) : m_bVeto ( false ), m_bListenForTermination ( false ), - m_bSystemDialogs(officecfg::Office::Common::Misc::UseSystemFileDialog::get()), + m_bSystemDialogs(UseSystemFileDialog()), m_xContext(std::move( xContext )), m_bInitialized( false ) { @@ -241,7 +245,7 @@ void ShutdownIcon::StartFileDialog() { ::SolarMutexGuard aGuard; - bool bDirty = ( m_bSystemDialogs != officecfg::Office::Common::Misc::UseSystemFileDialog::get() ); + bool bDirty = m_bSystemDialogs != UseSystemFileDialog(); if ( m_pFileDlg && bDirty ) { @@ -382,7 +386,7 @@ IMPL_LINK( ShutdownIcon, DialogClosedHdl_Impl, FileDialogHelper*, /*unused*/, vo // This fix is dependent on the dialog settings. Destroying the dialog here will // crash the non-native dialog implementation! Therefore make this dependent on // the settings. - if ( officecfg::Office::Common::Misc::UseSystemFileDialog::get() ) + if (UseSystemFileDialog()) { m_pFileDlg.reset(); } diff --git a/svtools/source/uno/fpicker.cxx b/svtools/source/uno/fpicker.cxx index dbb69d601462..e02d8abebb80 100644 --- a/svtools/source/uno/fpicker.cxx +++ b/svtools/source/uno/fpicker.cxx @@ -48,6 +48,13 @@ static OUString FilePicker_getSystemPickerServiceName() #endif } +// Ensure that we use not the system file dialogs as headless mode relies on +// Application::EnableHeadlessMode() which only works for VCL dialogs +static bool UseSystemFileDialog() +{ + return !Application::IsHeadlessModeEnabled() && officecfg::Office::Common::Misc::UseSystemFileDialog::get(); +} + Reference< css::uno::XInterface > FilePicker_CreateInstance ( Reference< css::uno::XComponentContext > const & context) { @@ -57,7 +64,7 @@ Reference< css::uno::XInterface > FilePicker_CreateInstance ( return xResult; Reference< css::lang::XMultiComponentFactory > xFactory (context->getServiceManager()); - if (xFactory.is() && officecfg::Office::Common::Misc::UseSystemFileDialog::get()) + if (xFactory.is() && UseSystemFileDialog()) { xResult.set( Application::createFilePicker( context ) ); @@ -125,7 +132,7 @@ Reference< css::uno::XInterface > FolderPicker_CreateInstance ( return xResult; Reference< css::lang::XMultiComponentFactory > xFactory (context->getServiceManager()); - if (xFactory.is() && officecfg::Office::Common::Misc::UseSystemFileDialog::get()) + if (xFactory.is() && UseSystemFileDialog()) { xResult.set( Application::createFolderPicker( context ) ); if (!xResult.is()) commit 105a9390e02856887ff5cfb6dbf6fe008738ffe1 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Fri Apr 7 13:04:06 2023 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Fri Apr 7 16:54:36 2023 +0200 drop unused eventtesting stuff eventtesting with input of fuzzed keystroke was a fairly nifty idea, but I never did anything with it beyond an initial experimental run and its cluttering up things so drop it now Change-Id: I44571e3e33124f522374d7c6772b7a7e7721aa1d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150125 Tested-by: Caolán McNamara <caol...@redhat.com> Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 5d76976569b3..72674493a0fb 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -589,7 +589,7 @@ bool Desktop::QueryExit() { xPropertySet->setPropertyValue( SUSPEND_QUICKSTARTVETO, Any(false) ); } - else if (!Application::IsEventTestingModeEnabled()) + else { FlushConfiguration(); try @@ -1511,7 +1511,7 @@ int Desktop::Main() } } - if ( rCmdLineArgs.IsHeadless() || rCmdLineArgs.IsEventTesting() ) + if ( rCmdLineArgs.IsHeadless() ) { // Ensure that we use not the system file dialogs as // headless mode relies on Application::EnableHeadlessMode() @@ -1637,7 +1637,7 @@ int Desktop::doShutdown() // Restore old value const CommandLineArgs& rCmdLineArgs = GetCommandLineArgs(); - if ( rCmdLineArgs.IsHeadless() || rCmdLineArgs.IsEventTesting() ) + if ( rCmdLineArgs.IsHeadless() ) { std::shared_ptr< comphelper::ConfigurationChanges > xChanges( comphelper::ConfigurationChanges::create()); diff --git a/desktop/source/app/appinit.cxx b/desktop/source/app/appinit.cxx index 1c837b833d16..8596f80aaafc 100644 --- a/desktop/source/app/appinit.cxx +++ b/desktop/source/app/appinit.cxx @@ -93,9 +93,7 @@ void Desktop::RegisterServices() CommandLineArgs& rCmdLine = GetCommandLineArgs(); // Headless mode for FAT Office, auto cancels any dialogs that popup - if (rCmdLine.IsEventTesting()) - Application::EnableEventTestingMode(); - else if (rCmdLine.IsHeadless()) + if (rCmdLine.IsHeadless()) Application::EnableHeadlessMode(false); // read accept string from configuration diff --git a/desktop/source/app/cmdlineargs.cxx b/desktop/source/app/cmdlineargs.cxx index f1949cbd0bbf..432bff1f4efc 100644 --- a/desktop/source/app/cmdlineargs.cxx +++ b/desktop/source/app/cmdlineargs.cxx @@ -326,10 +326,6 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier ) { setHeadless(); } - else if ( oArg == "eventtesting" ) - { - m_eventtesting = true; - } else if ( oArg == "safe-mode" ) { m_safemode = true; @@ -707,7 +703,6 @@ void CommandLineArgs::InitParamValues() m_invisible = true; m_headless = true; #endif - m_eventtesting = false; m_quickstart = false; m_noquickstart = false; m_terminateafterinit = false; diff --git a/desktop/source/app/cmdlineargs.hxx b/desktop/source/app/cmdlineargs.hxx index 74236f5b314f..64a1bcfd0ccb 100644 --- a/desktop/source/app/cmdlineargs.hxx +++ b/desktop/source/app/cmdlineargs.hxx @@ -60,12 +60,11 @@ class CommandLineArgs bool IsMinimized() const { return m_minimized;} bool IsInvisible() const { - return m_invisible || (m_headless && !m_eventtesting); + return m_invisible || m_headless; } bool IsNoRestore() const { return m_norestore;} bool IsNoDefault() const { return m_nodefault;} bool IsHeadless() const { return m_headless;} - bool IsEventTesting() const { return m_eventtesting;} bool IsQuickstart() const { return m_quickstart;} bool IsNoQuickstart() const { return m_noquickstart;} bool IsTerminateAfterInit() const { return m_terminateafterinit;} @@ -131,7 +130,6 @@ class CommandLineArgs bool m_invisible; bool m_norestore; bool m_headless; - bool m_eventtesting; bool m_quickstart; bool m_noquickstart; bool m_terminateafterinit; diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx index 048b677c9daa..ea0df283b8a6 100644 --- a/framework/source/services/desktop.cxx +++ b/framework/source/services/desktop.cxx @@ -197,8 +197,7 @@ sal_Bool SAL_CALL Desktop::terminate() css::lang::EventObject aEvent ( static_cast< ::cppu::OWeakObject* >(this) ); bool bAskQuickStart = !m_bSuspendQuickstartVeto; - const bool bRestartableMainLoop = Application::IsEventTestingModeEnabled() || - comphelper::LibreOfficeKit::isActive(); + const bool bRestartableMainLoop = comphelper::LibreOfficeKit::isActive(); aGuard.clear(); // Allow using of any UI ... because Desktop.terminate() was designed as UI functionality in the past. diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx index d153180e8873..c96335f1076f 100644 --- a/include/vcl/svapp.hxx +++ b/include/vcl/svapp.hxx @@ -1243,20 +1243,6 @@ public: ///@} - /** @name Event Testing Mode - */ - - /** Enables event testing mode. - - */ - static void EnableEventTestingMode(); - - /** Determines if event testing mode is enabled - - @return True if event testing mode is enabled, false if not. - */ - static bool IsEventTestingModeEnabled(); - /** Set safe mode to enabled */ static void EnableSafeMode(); diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx index 85579825a23d..0a34fb2f4234 100644 --- a/vcl/inc/svdata.hxx +++ b/vcl/inc/svdata.hxx @@ -167,16 +167,10 @@ struct ImplSVAppData bool mbRenderToBitmaps = false; // set via svp / headless plugin bool m_bUseSystemLoop = false; - SvFileStream* mpEventTestInput = nullptr; - Idle* mpEventTestingIdle = nullptr; - int mnEventTestLimit = 0; - DECL_STATIC_LINK(ImplSVAppData, ImplQuitMsg, void*, void); DECL_STATIC_LINK(ImplSVAppData, ImplPrepareExitMsg, void*, void); DECL_STATIC_LINK(ImplSVAppData, ImplEndAllDialogsMsg, void*, void); DECL_STATIC_LINK(ImplSVAppData, ImplEndAllPopupsMsg, void*, void); - DECL_STATIC_LINK(ImplSVAppData, ImplVclEventTestingHdl, void*, void); - DECL_LINK(VclEventTestingHdl, Timer*, void); }; /// Cache multiple scalings for the same bitmap diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index 6dfc3d7cc4d6..4690c534df70 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -339,92 +339,6 @@ void Application::notifyInvalidation(tools::Rectangle const* /*pRect*/) const { } -namespace -{ - VclPtr<vcl::Window> GetEventWindow() - { - VclPtr<vcl::Window> xWin(Application::GetFirstTopLevelWindow()); - while (xWin) - { - if (xWin->IsVisible()) - break; - xWin.reset(Application::GetNextTopLevelWindow(xWin)); - } - return xWin; - } - - bool InjectKeyEvent(SvStream& rStream) - { - VclPtr<vcl::Window> xWin(GetEventWindow()); - if (!xWin) - return false; - - // skip the first available cycle and insert on the next one when we - // are trying the initial event, flagged by a triggered but undeleted - // mpEventTestingIdle - ImplSVData* pSVData = ImplGetSVData(); - if (pSVData->maAppData.mpEventTestingIdle) - { - delete pSVData->maAppData.mpEventTestingIdle; - pSVData->maAppData.mpEventTestingIdle = nullptr; - return false; - } - - sal_uInt16 nCode, nCharCode; - rStream.ReadUInt16(nCode); - rStream.ReadUInt16(nCharCode); - if (!rStream.good()) - return false; - - KeyEvent aVCLKeyEvt(nCharCode, nCode); - Application::PostKeyEvent(VclEventId::WindowKeyInput, xWin.get(), &aVCLKeyEvt); - Application::PostKeyEvent(VclEventId::WindowKeyUp, xWin.get(), &aVCLKeyEvt); - return true; - } - - void CloseDialogsAndQuit() - { - Application::EndAllPopups(); - Application::EndAllDialogs(); - Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplPrepareExitMsg ) ); - } -} - -IMPL_LINK_NOARG(ImplSVAppData, VclEventTestingHdl, Timer *, void) -{ - if (Application::AnyInput()) - { - mpEventTestingIdle->Start(); - } - else - { - Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplVclEventTestingHdl ) ); - } -} - -IMPL_STATIC_LINK_NOARG( ImplSVAppData, ImplVclEventTestingHdl, void*, void ) -{ - ImplSVData* pSVData = ImplGetSVData(); - SAL_INFO("vcl.eventtesting", "EventTestLimit is " << pSVData->maAppData.mnEventTestLimit); - if (pSVData->maAppData.mnEventTestLimit == 0) - { - delete pSVData->maAppData.mpEventTestInput; - SAL_INFO("vcl.eventtesting", "Event Limit reached, exiting" << pSVData->maAppData.mnEventTestLimit); - CloseDialogsAndQuit(); - } - else - { - if (InjectKeyEvent(*pSVData->maAppData.mpEventTestInput)) - --pSVData->maAppData.mnEventTestLimit; - if (!pSVData->maAppData.mpEventTestInput->good()) - { - SAL_INFO("vcl.eventtesting", "Event Input exhausted, exit next cycle"); - pSVData->maAppData.mnEventTestLimit = 0; - } - Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplVclEventTestingHdl ) ); - } -} - IMPL_STATIC_LINK_NOARG( ImplSVAppData, ImplPrepareExitMsg, void*, void ) { //now close top level frames @@ -437,16 +351,6 @@ void Application::Execute() pSVData->maAppData.mbInAppExecute = true; pSVData->maAppData.mbAppQuit = false; - if (Application::IsEventTestingModeEnabled()) - { - pSVData->maAppData.mnEventTestLimit = 50; - pSVData->maAppData.mpEventTestingIdle = new Idle("eventtesting"); - pSVData->maAppData.mpEventTestingIdle->SetInvokeHandler(LINK(&(pSVData->maAppData), ImplSVAppData, VclEventTestingHdl)); - pSVData->maAppData.mpEventTestingIdle->SetPriority(TaskPriority::HIGH_IDLE); - pSVData->maAppData.mpEventTestInput = new SvFileStream("eventtesting", StreamMode::READ); - pSVData->maAppData.mpEventTestingIdle->Start(); - } - int nExitCode = 0; if (!pSVData->mpDefInst->DoExecute(nExitCode)) { @@ -1695,18 +1599,6 @@ void Application::EnableConsoleOnly() EnableBitmapRendering(); } -static bool bEventTestingMode = false; - -bool Application::IsEventTestingModeEnabled() -{ - return bEventTestingMode; -} - -void Application::EnableEventTestingMode() -{ - bEventTestingMode = true; -} - static bool bSafeMode = false; bool Application::IsSafeModeEnabled()