[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - vcl/source vcl/unx
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Thu Aug 29 04:17:49 UTC 2019
vcl/source/app/salvtables.cxx | 86 ++++++++++++++++++++++++++----------------
vcl/unx/gtk3/gtk3gtkinst.cxx | 62 +++++++++++++++++++++---------
2 files changed, 97 insertions(+), 51 deletions(-)
New commits:
commit d781aec2ae62e59bb71b05904b240586b6c899dd
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Aug 15 20:29:40 2019 +0100
Commit: Adolfo Jayme Barrientos <fitojb at ubuntu.com>
CommitDate: Thu Aug 29 06:17:12 2019 +0200
tdf#126007 tdf#122355 online help won't look into a dialog notebook
when the focus is on the help button, offline will through the help fallback
route, but online will just fire and forget and let the server side do a
fallback, which can't know what the current notebook page was.
so bodge it to look at the notebook page right from the start if there is one
and its the help button itself which starts the request
Change-Id: Ida1d3101d838d99639dda12c438414c16b1ccda5
Reviewed-on: https://gerrit.libreoffice.org/77549
Tested-by: Jenkins
Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index cbf566008576..c620196e10d9 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -1018,27 +1018,7 @@ public:
return m_xWindow->GetText();
}
- void help()
- {
- //show help for widget with keyboard focus
- vcl::Window* pWidget = ImplGetSVData()->maWinData.mpFocusWin;
- if (!pWidget)
- pWidget = m_xWindow;
- OString sHelpId = pWidget->GetHelpId();
- while (sHelpId.isEmpty())
- {
- pWidget = pWidget->GetParent();
- if (!pWidget)
- break;
- sHelpId = pWidget->GetHelpId();
- }
- std::unique_ptr<weld::Widget> xTemp(pWidget != m_xWindow ? new SalInstanceWidget(pWidget, m_pBuilder, false) : nullptr);
- weld::Widget* pSource = xTemp ? xTemp.get() : this;
- bool bRunNormalHelpRequest = !m_aHelpRequestHdl.IsSet() || m_aHelpRequestHdl.Call(*pSource);
- Help* pHelp = bRunNormalHelpRequest ? Application::GetHelp() : nullptr;
- if (pHelp)
- pHelp->Start(OStringToOUString(sHelpId, RTL_TEXTENCODING_UTF8), pSource);
- }
+ void help();
virtual void set_busy_cursor(bool bBusy) override
{
@@ -5405,6 +5385,17 @@ public:
return std::make_unique<SalInstanceSizeGroup>();
}
+ OString get_current_page_help_id()
+ {
+ TabControl *pCtrl = get_builder().get<TabControl>("tabcontrol");
+ TabPage* pTabPage = pCtrl ? pCtrl->GetTabPage(pCtrl->GetCurPageId()) : nullptr;
+ vcl::Window *pTabChild = pTabPage ? pTabPage->GetWindow(GetWindowType::FirstChild) : nullptr;
+ pTabChild = pTabChild ? pTabChild->GetWindow(GetWindowType::FirstChild) : nullptr;
+ if (pTabChild)
+ return pTabChild->GetHelpId();
+ return OString();
+ }
+
virtual ~SalInstanceBuilder() override
{
if (VclBuilderContainer* pOwnedToplevel = dynamic_cast<VclBuilderContainer*>(m_aOwnedToplevel.get()))
@@ -5434,6 +5425,43 @@ weld::Builder* Application::CreateInterimBuilder(weld::Widget* pParent, const OU
return Application::CreateInterimBuilder(pParentWidget, rUIFile);
}
+void SalInstanceWindow::help()
+{
+ //show help for widget with keyboard focus
+ vcl::Window* pWidget = ImplGetSVData()->maWinData.mpFocusWin;
+ if (!pWidget)
+ pWidget = m_xWindow;
+ OString sHelpId = pWidget->GetHelpId();
+ while (sHelpId.isEmpty())
+ {
+ pWidget = pWidget->GetParent();
+ if (!pWidget)
+ break;
+ sHelpId = pWidget->GetHelpId();
+ }
+ std::unique_ptr<weld::Widget> xTemp(pWidget != m_xWindow ? new SalInstanceWidget(pWidget, m_pBuilder, false) : nullptr);
+ weld::Widget* pSource = xTemp ? xTemp.get() : this;
+ bool bRunNormalHelpRequest = !m_aHelpRequestHdl.IsSet() || m_aHelpRequestHdl.Call(*pSource);
+ Help* pHelp = bRunNormalHelpRequest ? Application::GetHelp() : nullptr;
+ if (pHelp)
+ {
+ // tdf#126007, there's a nice fallback route for offline help where
+ // the current page of a notebook will get checked when the help
+ // button is pressed and there was no help for the dialog found.
+ //
+ // But for online help that route doesn't get taken, so bodge this here
+ // by using the page help id if available and if the help button itself
+ // was the original id
+ if (m_pBuilder && sHelpId.endsWith("/help"))
+ {
+ OString sPageId = m_pBuilder->get_current_page_help_id();
+ if (!sPageId.isEmpty())
+ sHelpId = sPageId;
+ }
+ pHelp->Start(OStringToOUString(sHelpId, RTL_TEXTENCODING_UTF8), pSource);
+ }
+}
+
//iterate upwards through the hierarchy from this widgets through its parents
//calling func with their helpid until func returns true or we run out of parents
void SalInstanceWidget::help_hierarchy_foreach(const std::function<bool(const OString&)>& func)
@@ -5443,17 +5471,11 @@ void SalInstanceWidget::help_hierarchy_foreach(const std::function<bool(const OS
{
if (m_pBuilder && pParent->IsDialog())
{
- // tdf#122355 During help fallback, before we ask a dialog for its help
- // see if it has a TabControl and ask the active tab of that for help
- TabControl *pCtrl = m_pBuilder->get_builder().get<TabControl>("tabcontrol");
- TabPage* pTabPage = pCtrl ? pCtrl->GetTabPage(pCtrl->GetCurPageId()) : nullptr;
- vcl::Window *pTabChild = pTabPage ? pTabPage->GetWindow(GetWindowType::FirstChild) : nullptr;
- pTabChild = pTabChild ? pTabChild->GetWindow(GetWindowType::FirstChild) : nullptr;
- if (pTabChild)
- {
- if (func(pTabChild->GetHelpId()))
- return;
- }
+ // tdf#122355 before trying dialog help, check to see if there is a notebook
+ // called tabcontrol, and try the help for the current page of that first
+ OString sPageHelpId(m_pBuilder->get_current_page_help_id());
+ if (!sPageHelpId.isEmpty() && func(sPageHelpId))
+ return;
}
if (func(pParent->GetHelpId()))
return;
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 928e75835ed0..ded420efe39d 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -10449,6 +10449,31 @@ public:
m_aMnemonicButtons.clear();
}
+ OString get_current_page_help_id()
+ {
+ OString sPageHelpId;
+ // check to see if there is a notebook called tabcontrol and get the
+ // helpid for the current page of that
+ std::unique_ptr<weld::Notebook> xNotebook(weld_notebook("tabcontrol", false));
+ if (xNotebook)
+ {
+ if (GtkInstanceContainer* pPage = dynamic_cast<GtkInstanceContainer*>(xNotebook->get_page(xNotebook->get_current_page_ident())))
+ {
+ GtkWidget* pContainer = pPage->getWidget();
+ GList* pChildren = gtk_container_get_children(GTK_CONTAINER(pContainer));
+ GList* pChild = g_list_first(pChildren);
+ if (pChild)
+ {
+ GtkWidget* pPageWidget = static_cast<GtkWidget*>(pChild->data);
+ sPageHelpId = ::get_help_id(pPageWidget);
+ }
+ g_list_free(pChildren);
+ }
+ }
+ return sPageHelpId;
+ }
+
+
virtual ~GtkInstanceBuilder() override
{
g_slist_free(m_pObjectList);
@@ -10790,7 +10815,22 @@ void GtkInstanceWindow::help()
bool bRunNormalHelpRequest = !m_aHelpRequestHdl.IsSet() || m_aHelpRequestHdl.Call(*pSource);
Help* pHelp = bRunNormalHelpRequest ? Application::GetHelp() : nullptr;
if (pHelp)
+ {
+ // tdf#126007, there's a nice fallback route for offline help where
+ // the current page of a notebook will get checked when the help
+ // button is pressed and there was no help for the dialog found.
+ //
+ // But for online help that route doesn't get taken, so bodge this here
+ // by using the page help id if available and if the help button itself
+ // was the original id
+ if (m_pBuilder && sHelpId.endsWith("/help"))
+ {
+ OString sPageId = m_pBuilder->get_current_page_help_id();
+ if (!sPageId.isEmpty())
+ sHelpId = sPageId;
+ }
pHelp->Start(OStringToOUString(sHelpId, RTL_TEXTENCODING_UTF8), pSource);
+ }
}
//iterate upwards through the hierarchy from this widgets through its parents
@@ -10804,25 +10844,9 @@ void GtkInstanceWidget::help_hierarchy_foreach(const std::function<bool(const OS
// called tabcontrol, and try the help for the current page of that first
if (m_pBuilder && GTK_IS_DIALOG(pParent))
{
- std::unique_ptr<weld::Notebook> xNotebook(m_pBuilder->weld_notebook("tabcontrol", false));
- if (xNotebook)
- {
- if (GtkInstanceContainer* pPage = dynamic_cast<GtkInstanceContainer*>(xNotebook->get_page(xNotebook->get_current_page_ident())))
- {
- bool bFinished = false;
- GtkWidget* pContainer = pPage->getWidget();
- GList* pChildren = gtk_container_get_children(GTK_CONTAINER(pContainer));
- GList* pChild = g_list_first(pChildren);
- if (pChild)
- {
- GtkWidget* pPageWidget = static_cast<GtkWidget*>(pChild->data);
- bFinished = func(::get_help_id(pPageWidget));
- }
- g_list_free(pChildren);
- if (bFinished)
- return;
- }
- }
+ OString sPageHelpId(m_pBuilder->get_current_page_help_id());
+ if (!sPageHelpId.isEmpty() && func(sPageHelpId))
+ return;
}
if (func(::get_help_id(pParent)))
return;
More information about the Libreoffice-commits
mailing list