tdf#149888 Make F1 work in Math initial state
Currently, when Math is opened and F1 is pressed in its initial state, no help page is opened. This is caused by the GrabFocus call in InitialFocusTimerHdl (see comments in its implementation).
This patch ensures that pressing F1 both in the Edit and Graphics windows will open the main help page of the Math module.
NOTE: This patch will only work after the related patch in helpcontent2 gets accepted, since it is responsible for creating the HID target in the XHP file.
Change-Id: I59980cea1816a863e1aaa2d0757d9b141437ead5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154691
Tested-by: Jenkins
Reviewed-by: Olivier Hallot <olivier.hallot@libreoffice.org>
diff --git a/starmath/inc/helpids.h b/starmath/inc/helpids.h
index 195ccfb..19325eb 100644
--- a/starmath/inc/helpids.h
+++ b/starmath/inc/helpids.h
@@ -21,6 +21,7 @@
#include <rtl/ustring.hxx>
inline constexpr OUStringLiteral HID_SMA_MAIN_HELP = u"STARMATH_HID_SMA_MAIN_HELP";
inline constexpr OUStringLiteral HID_SMA_WIN_DOCUMENT = u"STARMATH_HID_SMA_WIN_DOCUMENT";
inline constexpr OUStringLiteral HID_SMA_COMMAND_WIN_EDIT = u"STARMATH_HID_SMA_COMMAND_WIN_EDIT";
diff --git a/starmath/inc/view.hxx b/starmath/inc/view.hxx
index bef51e8..dc42dde 100644
--- a/starmath/inc/view.hxx
+++ b/starmath/inc/view.hxx
@@ -348,6 +348,9 @@ public:
}
static bool IsInlineEditEnabled();
// Opens the main help page for the Math module
void StartMainHelp();
private:
void ZoomByItemSet(const SfxItemSet *pSet);
};
diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx
index 1eee64a..4cb4f65 100644
--- a/starmath/source/edit.cxx
+++ b/starmath/source/edit.cxx
@@ -288,6 +288,12 @@ bool SmEditTextWindow::Command(const CommandEvent& rCEvt)
bool SmEditTextWindow::KeyInput(const KeyEvent& rKEvt)
{
if (rKEvt.GetKeyCode().GetCode() == KEY_F1)
{
mrEditWindow.GetView()->StartMainHelp();
return true;
}
if (rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE)
{
bool bCallBase = true;
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index a677451..449dc0e 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -66,6 +66,7 @@
#include <sfx2/zoomitem.hxx>
#include <vcl/commandevent.hxx>
#include <vcl/event.hxx>
#include <vcl/help.hxx>
#include <vcl/settings.hxx>
#include <vcl/virdev.hxx>
#include <sal/log.hxx>
@@ -700,6 +701,12 @@ bool CharInput(sal_uInt32 c, SmCursor& rCursor, OutputDevice& rDevice)
bool SmGraphicWidget::KeyInput(const KeyEvent& rKEvt)
{
if (rKEvt.GetKeyCode().GetCode() == KEY_F1)
{
GetView().StartMainHelp();
return true;
}
if (!SmViewShell::IsInlineEditEnabled())
return GetView().KeyInput(rKEvt);
@@ -2329,6 +2336,13 @@ bool SmViewShell::IsInlineEditEnabled()
|| officecfg::Office::Common::Misc::ExperimentalMode::get();
}
void SmViewShell::StartMainHelp()
{
Help* pHelp = Application::GetHelp();
if (pHelp)
pHelp->Start(HID_SMA_MAIN_HELP, GetViewFrame().GetFrameWeld());
}
void SmViewShell::ZoomByItemSet(const SfxItemSet *pSet)
{
assert(pSet);