[Libreoffice-commits] .: Branch 'libreoffice-3-3' - sfx2/source

Jan Holesovsky kendy at kemper.freedesktop.org
Mon Nov 29 07:06:56 PST 2010


 sfx2/source/appl/sfxhelp.cxx |   50 ++++++++++++++++++++++++++++++++++++-------
 1 file changed, 43 insertions(+), 7 deletions(-)

New commits:
commit db6092bda62b2db7ae1971f01024e5f548336a25
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Sat Nov 27 00:52:09 2010 +0100

    wikihelp: Forward the request for help to help.libreoffice.org.
    
    Based on Muthu's patch.  If the help is not installed, this will forward the
    request to help.libreoffice.org; unfortunately the service is not running
    there yet, but better to have the code in already ;-)

diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx
index 83cc270..b3e52bb 100644
--- a/sfx2/source/appl/sfxhelp.cxx
+++ b/sfx2/source/appl/sfxhelp.cxx
@@ -49,6 +49,8 @@
 #include <com/sun/star/frame/FrameSearchFlag.hpp>
 #include <toolkit/helper/vclunohelper.hxx>
 #include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/system/XSystemShellExecute.hpp>
+#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
 #include <unotools/configmgr.hxx>
 #include <unotools/configitem.hxx>
 #include <svtools/helpopt.hxx>
@@ -84,6 +86,7 @@ using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::util;
 using namespace ::com::sun::star::frame;
 using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::system;
 
 #define ERROR_TAG	String( DEFINE_CONST_UNICODE("Error: ") )
 #define PATH_TAG	String( DEFINE_CONST_UNICODE("\nPath: ") )
@@ -742,25 +745,58 @@ SfxHelpWindow_Impl* impl_createHelp(Reference< XFrame >& rHelpTask   ,
     return pHelpWindow;
 }
 
+static bool impl_showOnlineHelp( const String& rURL )
+{
+    String aInternal( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.help://" ) );
+    if ( rURL.Len() <= aInternal.Len() || rURL.Copy( 0, aInternal.Len() ) != aInternal )
+        return false;
+
+    rtl::OUString aHelpLink( RTL_CONSTASCII_USTRINGPARAM( "http://help.libreoffice.org/" ) );
+    aHelpLink += rURL.Copy( aInternal.Len() );
+    try
+    {
+        Reference< XSystemShellExecute > xSystemShell(
+                ::comphelper::getProcessServiceFactory()->createInstance(
+                    rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.system.SystemShellExecute" ) ) ),
+                UNO_QUERY );
+
+        if ( xSystemShell.is() )
+        {
+            xSystemShell->execute( aHelpLink, rtl::OUString(), SystemShellExecuteFlags::DEFAULTS );
+            return true;
+        }
+    }
+    catch( const Exception& )
+    {
+    }
+    return false;
+}
+
 BOOL SfxHelp::Start( const String& rURL, const Window* pWindow )
 {
+    String aHelpURL( rURL );
+    INetURLObject aParser( aHelpURL );
+    INetProtocol nProtocol = aParser.GetProtocol();
+
     // check if help is available
     String aHelpRootURL( DEFINE_CONST_OUSTRING("vnd.sun.star.help://") );
     AppendConfigToken_Impl( aHelpRootURL, sal_True );
     Sequence< ::rtl::OUString > aFactories = SfxContentHelper::GetResultSet( aHelpRootURL );
     if ( 0 == aFactories.getLength() )
     {
-        // no factories -> no help -> error message and return
-        NoHelpErrorBox aErrBox( const_cast< Window* >( pWindow ) );
-        aErrBox.Execute();
-        return FALSE;
+        // no factories -> no help -> try online
+        if ( nProtocol == INET_PROT_VND_SUN_STAR_HELP && impl_showOnlineHelp( rURL ) )
+            return TRUE;
+        else
+        {
+            NoHelpErrorBox aErrBox( const_cast< Window* >( pWindow ) );
+            aErrBox.Execute();
+            return FALSE;
+        }
     }
 
     // check if it's an URL or a jump mark!
-    String          aHelpURL(rURL    );
-    INetURLObject   aParser (aHelpURL);
     ::rtl::OUString sKeyword;
-    INetProtocol nProtocol = aParser.GetProtocol();
     if ( nProtocol != INET_PROT_VND_SUN_STAR_HELP )
     {
         // #i90162 Accept anything that is not invalid as help id, as both


More information about the Libreoffice-commits mailing list