sfx2/source/appl/sfxhelp.cxx |  137 +++++++++++++++++++++++--------------------
 1 file changed, 76 insertions(+), 61 deletions(-)

New commits:
commit 06a1c2c9fc467604372495023983874fba33ca85
Author: Stephan Bergmann <sberg...@redhat.com>
Date:   Thu Jun 14 17:21:19 2018 +0200

    tdf#33209: Context-sensitive help for extensions in otherwise HTML-help 
cases
    
    When extensions bring along help content (in the form of .xhp files), that 
was
    completely unavailable in --without-help (i.e., defering to online HTML 
help)
    and --with-help=html (i.e., displaying the new offline HTML help in a 
browser)
    builds.  (Merely extended tooltips brought along by extensions would work in
    those builds.)
    
    With this change, at least context-sensitive help (i.e., pressing F1 in an
    extension's dialog) will be shown.  Although not integrated with the rest 
of the
    (browser-based HTML) help, but using LO's own old help viewer.  (Which will 
then
    of course only offer the combined help content of all the installed 
extensions,
    not any help content provided by LO itself.  Thus, links from extensions' 
help
    content to LO help content will not work.)
    
    This is only a cheap stopgap.  If an extension brings along help content 
other
    than context-sensitive help (which is reachable by pressing F1 in the 
respective
    context), there is no easy way for the user to reach it.  (That includes 
help
    pages listed in an extension's help.tree, and index entries.  See the commit
    message of 4a0ca73c31990568bf20a1c3f0906c3a5770a38e "Add some help content 
to
    test-passive.oxt" for an overview of what help conent an extension can 
provide.)
    
    Regarding the details of this code change, I left the
    comphelper::LibreOfficeKit::isActive() case alone, assuming that that case 
never
    wants to display LO's own old help viewer, for one reason or another.  (But
    please correct me/the code if that assumption is wrong.)
    
    Change-Id: I2209b1aa48888c5f25674fbe4ce6643eff1268c6
    Reviewed-on: https://gerrit.libreoffice.org/55816
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx
index 7fd1b642d8ec..cb7e3f0696e9 100644
--- a/sfx2/source/appl/sfxhelp.cxx
+++ b/sfx2/source/appl/sfxhelp.cxx
@@ -812,46 +812,54 @@ bool SfxHelp::Start_Impl(const OUString& rURL, const 
vcl::Window* pWindow, const
         return true;
     }
 
-    if ( impl_hasHTMLHelpInstalled() )
+    // If the HTML or no help is installed, but aHelpURL nevertheless 
references valid help content,
+    // that implies that that help content belongs to an extension (and thus 
would not be available
+    // in neither the offline nor online HTML help); in that case, fall 
through to the "old-help to
+    // display" code below:
+    if (SfxContentHelper::IsHelpErrorDocument(aHelpURL))
     {
-        impl_showOfflineHelp(aHelpURL);
-        return true;
-    }
-
-    if ( !impl_hasHelpInstalled() )
-    {
-        SvtHelpOptions aHelpOptions;
-        bool bShowOfflineHelpPopUp = aHelpOptions.IsOfflineHelpPopUp();
-
-        if(bShowOfflineHelpPopUp)
+        if ( impl_hasHTMLHelpInstalled() )
         {
-            std::unique_ptr<weld::Builder> 
xBuilder(Application::CreateBuilder(pWindow ? pWindow->GetFrameWeld() : 
nullptr, "sfx/ui/helpmanual.ui"));
-            std::unique_ptr<weld::MessageDialog> 
xQueryBox(xBuilder->weld_message_dialog("onlinehelpmanual"));
-            std::unique_ptr<weld::CheckButton> 
m_xHideOfflineHelpCB(xBuilder->weld_check_button("hidedialog"));
-            LanguageTag aLangTag = 
Application::GetSettings().GetUILanguageTag();
-            OUString sLocaleString = SvtLanguageTable::GetLanguageString( 
aLangTag.getLanguageType() );
-            OUString sPrimText = xQueryBox->get_primary_text();
-            xQueryBox->set_primary_text(sPrimText.replaceAll("$UILOCALE", 
sLocaleString));
-            short OnlineHelpBox = xQueryBox->run();
-            bShowOfflineHelpPopUp = OnlineHelpBox != RET_OK;
-            
aHelpOptions.SetOfflineHelpPopUp(!m_xHideOfflineHelpCB->get_state());
+            impl_showOfflineHelp(aHelpURL);
+            return true;
         }
-        if(!bShowOfflineHelpPopUp)
+
+        if ( !impl_hasHelpInstalled() )
         {
-            if ( impl_showOnlineHelp( aHelpURL ) )
-                return true;
+            SvtHelpOptions aHelpOptions;
+            bool bShowOfflineHelpPopUp = aHelpOptions.IsOfflineHelpPopUp();
+
+            if(bShowOfflineHelpPopUp)
+            {
+                std::unique_ptr<weld::Builder> 
xBuilder(Application::CreateBuilder(pWindow ? pWindow->GetFrameWeld() : 
nullptr, "sfx/ui/helpmanual.ui"));
+                std::unique_ptr<weld::MessageDialog> 
xQueryBox(xBuilder->weld_message_dialog("onlinehelpmanual"));
+                std::unique_ptr<weld::CheckButton> 
m_xHideOfflineHelpCB(xBuilder->weld_check_button("hidedialog"));
+                LanguageTag aLangTag = 
Application::GetSettings().GetUILanguageTag();
+                OUString sLocaleString = SvtLanguageTable::GetLanguageString( 
aLangTag.getLanguageType() );
+                OUString sPrimText = xQueryBox->get_primary_text();
+                xQueryBox->set_primary_text(sPrimText.replaceAll("$UILOCALE", 
sLocaleString));
+                short OnlineHelpBox = xQueryBox->run();
+                bShowOfflineHelpPopUp = OnlineHelpBox != RET_OK;
+                
aHelpOptions.SetOfflineHelpPopUp(!m_xHideOfflineHelpCB->get_state());
+            }
+            if(!bShowOfflineHelpPopUp)
+            {
+                if ( impl_showOnlineHelp( aHelpURL ) )
+                    return true;
+                else
+                {
+                    NoHelpErrorBox aErrBox(pWindow ? pWindow->GetFrameWeld() : 
nullptr);
+                    aErrBox.run();
+                    return false;
+                }
+            }
             else
             {
-                NoHelpErrorBox aErrBox(pWindow ? pWindow->GetFrameWeld() : 
nullptr);
-                aErrBox.run();
                 return false;
             }
         }
-        else
-        {
-            return false;
-        }
     }
+
     // old-help to display
     Reference < XDesktop2 > xDesktop = Desktop::create( 
::comphelper::getProcessComponentContext() );
 
@@ -960,46 +968,53 @@ bool SfxHelp::Start_Impl(const OUString& rURL, 
weld::Widget* pWidget, const OUSt
         return true;
     }
 
-    if ( impl_hasHTMLHelpInstalled() )
+    // If the HTML or no help is installed, but aHelpURL nevertheless 
references valid help content,
+    // that implies that that help content belongs to an extension (and thus 
would not be available
+    // in neither the offline nor online HTML help); in that case, fall 
through to the "old-help to
+    // display" code below:
+    if (SfxContentHelper::IsHelpErrorDocument(aHelpURL))
     {
-        impl_showOfflineHelp(aHelpURL);
-        return true;
-    }
-
-    if ( !impl_hasHelpInstalled() )
-    {
-    SvtHelpOptions aHelpOptions;
-    bool bShowOfflineHelpPopUp = aHelpOptions.IsOfflineHelpPopUp();
-
-        if(bShowOfflineHelpPopUp)
+        if ( impl_hasHTMLHelpInstalled() )
         {
-            std::unique_ptr<weld::Builder> 
xBuilder(Application::CreateBuilder(pWidget, "sfx/ui/helpmanual.ui"));
-            std::unique_ptr<weld::MessageDialog> 
xQueryBox(xBuilder->weld_message_dialog("onlinehelpmanual"));
-            std::unique_ptr<weld::CheckButton> 
m_xHideOfflineHelpCB(xBuilder->weld_check_button("hidedialog"));
-            LanguageTag aLangTag = 
Application::GetSettings().GetUILanguageTag();
-            OUString sLocaleString = SvtLanguageTable::GetLanguageString( 
aLangTag.getLanguageType() );
-            OUString sPrimText = xQueryBox->get_primary_text();
-            xQueryBox->set_primary_text(sPrimText.replaceAll("$UILOCALE", 
sLocaleString));
-            short OnlineHelpBox = xQueryBox->run();
-            bShowOfflineHelpPopUp = OnlineHelpBox != RET_OK;
-            
aHelpOptions.SetOfflineHelpPopUp(!m_xHideOfflineHelpCB->get_state());
+            impl_showOfflineHelp(aHelpURL);
+            return true;
         }
-        if(!bShowOfflineHelpPopUp)
+
+        if ( !impl_hasHelpInstalled() )
         {
-            if ( impl_showOnlineHelp( aHelpURL ) )
-                return true;
+            SvtHelpOptions aHelpOptions;
+            bool bShowOfflineHelpPopUp = aHelpOptions.IsOfflineHelpPopUp();
+
+            if(bShowOfflineHelpPopUp)
+            {
+                std::unique_ptr<weld::Builder> 
xBuilder(Application::CreateBuilder(pWidget, "sfx/ui/helpmanual.ui"));
+                std::unique_ptr<weld::MessageDialog> 
xQueryBox(xBuilder->weld_message_dialog("onlinehelpmanual"));
+                std::unique_ptr<weld::CheckButton> 
m_xHideOfflineHelpCB(xBuilder->weld_check_button("hidedialog"));
+                LanguageTag aLangTag = 
Application::GetSettings().GetUILanguageTag();
+                OUString sLocaleString = SvtLanguageTable::GetLanguageString( 
aLangTag.getLanguageType() );
+                OUString sPrimText = xQueryBox->get_primary_text();
+                xQueryBox->set_primary_text(sPrimText.replaceAll("$UILOCALE", 
sLocaleString));
+                short OnlineHelpBox = xQueryBox->run();
+                bShowOfflineHelpPopUp = OnlineHelpBox != RET_OK;
+                
aHelpOptions.SetOfflineHelpPopUp(!m_xHideOfflineHelpCB->get_state());
+            }
+            if(!bShowOfflineHelpPopUp)
+            {
+                if ( impl_showOnlineHelp( aHelpURL ) )
+                    return true;
+                else
+                {
+                    NoHelpErrorBox aErrBox(pWidget);
+                    aErrBox.run();
+                    return false;
+                }
+            }
             else
             {
-                NoHelpErrorBox aErrBox(pWidget);
-                aErrBox.run();
                 return false;
             }
-        }
-        else
-        {
-            return false;
-        }
 
+        }
     }
 
     // old-help to display
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to